From a9fa72965b680baffdb907436083b073f7f7f027 Mon Sep 17 00:00:00 2001 From: hackerwins Date: Tue, 10 Dec 2024 11:04:31 +0000 Subject: [PATCH] deploy: ba70776594deaa4df8bf53934575b914327f2645 --- api-reference/assets/search.js | 2 +- api-reference/classes/Change.html | 28 ++-- api-reference/classes/Client.html | 42 +++--- api-reference/classes/Counter.html | 16 +- api-reference/classes/Document.html | 140 +++++++++--------- api-reference/classes/Primitive.html | 48 +++--- api-reference/classes/Text.html | 38 ++--- api-reference/classes/TimeTicket.html | 30 ++-- api-reference/classes/Tree.html | 52 +++---- api-reference/classes/VersionVector.html | 22 +-- api-reference/enums/ClientCondition.html | 6 +- api-reference/enums/ClientStatus.html | 6 +- api-reference/enums/DocEventType.html | 28 ++-- api-reference/enums/DocStatus.html | 8 +- api-reference/enums/DocSyncStatus.html | 6 +- api-reference/enums/LogLevel.html | 4 +- api-reference/enums/OpSource.html | 4 +- .../enums/StreamConnectionStatus.html | 6 +- api-reference/enums/SyncMode.html | 10 +- api-reference/enums/TreeChangeType.html | 4 +- api-reference/interfaces/ChangeInfo.html | 4 +- api-reference/interfaces/ClientOptions.html | 14 +- .../interfaces/ConnectionChangedEvent.html | 4 +- .../interfaces/InitializedEvent.html | 4 +- .../interfaces/LocalChangeEvent.html | 6 +- api-reference/interfaces/Observable.html | 4 +- api-reference/interfaces/Observer.html | 4 +- .../interfaces/PresenceChangedEvent.html | 4 +- .../interfaces/RemoteChangeEvent.html | 6 +- api-reference/interfaces/SnapshotEvent.html | 6 +- .../interfaces/SyncStatusChangedEvent.html | 4 +- api-reference/interfaces/UnwatchedEvent.html | 4 +- api-reference/interfaces/WatchedEvent.html | 4 +- api-reference/modules/Devtools.html | 2 +- api-reference/types/ActorID.html | 2 +- api-reference/types/AddOpInfo.html | 2 +- api-reference/types/ArrayOperationInfo.html | 2 +- api-reference/types/CRDTTreeNodeIDStruct.html | 2 +- api-reference/types/CompleteFn.html | 2 +- api-reference/types/CounterOperationInfo.html | 2 +- api-reference/types/CounterValue.html | 2 +- api-reference/types/Devtools.Client.html | 2 +- .../types/Devtools.ContainerValue.html | 2 +- api-reference/types/Devtools.JSONElement.html | 2 +- .../types/Devtools.TreeNodeInfo.html | 2 +- api-reference/types/DocEvent.html | 2 +- api-reference/types/EditOpInfo.html | 2 +- api-reference/types/ElementNode.html | 2 +- api-reference/types/ErrorFn.html | 2 +- .../types/FullPanelToSDKMessage.html | 2 +- .../types/FullSDKToPanelMessage.html | 2 +- api-reference/types/IncreaseOpInfo.html | 2 +- api-reference/types/Indexable.html | 2 +- api-reference/types/JSONArray.html | 26 ++-- api-reference/types/JSONElement.html | 2 +- api-reference/types/JSONObject.html | 8 +- api-reference/types/MoveOpInfo.html | 2 +- api-reference/types/NextFn.html | 2 +- api-reference/types/ObjectOperationInfo.html | 2 +- api-reference/types/OperationInfo.html | 2 +- api-reference/types/PanelToSDKMessage.html | 2 +- api-reference/types/PrimitiveValue.html | 2 +- api-reference/types/RemoveOpInfo.html | 2 +- api-reference/types/SDKToPanelMessage.html | 2 +- api-reference/types/SetOpInfo.html | 2 +- api-reference/types/StyleOpInfo.html | 2 +- api-reference/types/TextNode.html | 2 +- api-reference/types/TextOperationInfo.html | 2 +- api-reference/types/TextPosStruct.html | 2 +- api-reference/types/TextPosStructRange.html | 2 +- api-reference/types/TimeTicketStruct.html | 2 +- api-reference/types/TransactionEvent.html | 2 +- api-reference/types/TreeChange.html | 2 +- api-reference/types/TreeEditOpInfo.html | 2 +- api-reference/types/TreeNode.html | 2 +- api-reference/types/TreeOperationInfo.html | 2 +- api-reference/types/TreePosStructRange.html | 2 +- api-reference/types/TreeStyleOpInfo.html | 2 +- api-reference/types/Unsubscribe.html | 2 +- api-reference/types/WrappedElement.html | 2 +- .../variables/EventSourceDevPanel.html | 2 +- api-reference/variables/EventSourceSDK.html | 2 +- api-reference/variables/converter.html | 2 +- api-reference/variables/default.html | 2 +- examples/nextjs-scheduler/404.html | 2 +- ...d80820a787.js => page-4229c045ecb9909b.js} | 2 +- .../_buildManifest.js | 0 .../_ssgManifest.js | 0 examples/nextjs-scheduler/index.html | 2 +- examples/nextjs-scheduler/index.txt | 4 +- .../{index-FKMiNpAO.js => index-BZcMnYBH.js} | 14 +- examples/profile-stack/index.html | 2 +- .../{index-CZ-AlliK.js => index-1ncFVCXa.js} | 76 +++++----- examples/react-tldraw/index.html | 2 +- .../{index-CosHSvo1.js => index-4GhU6Gpr.js} | 26 ++-- examples/react-todomvc/index.html | 2 +- .../{index-BJ1xyFxJ.js => index-CUyGqr_M.js} | 24 +-- examples/simultaneous-cursors/index.html | 2 +- .../{index--0f-Tmnq.js => index-DBSPfpB3.js} | 38 ++--- examples/vanilla-codemirror6/index.html | 2 +- .../{index-DK_gU96d.js => index-ZU4bONgA.js} | 16 +- examples/vanilla-quill/index.html | 2 +- .../{index-CvxEjgCh.js => index-C3LyZcN6.js} | 10 +- examples/vuejs-kanban/index.html | 2 +- 104 files changed, 465 insertions(+), 463 deletions(-) rename examples/nextjs-scheduler/_next/static/chunks/app/{page-8756ccd80820a787.js => page-4229c045ecb9909b.js} (51%) rename examples/nextjs-scheduler/_next/static/{Xci5Kvwm4M4WF4ibIjhh4 => wLeZu3DP96EZimuMGR2Il}/_buildManifest.js (100%) rename examples/nextjs-scheduler/_next/static/{Xci5Kvwm4M4WF4ibIjhh4 => wLeZu3DP96EZimuMGR2Il}/_ssgManifest.js (100%) rename examples/profile-stack/assets/{index-FKMiNpAO.js => index-BZcMnYBH.js} (72%) rename examples/react-tldraw/assets/{index-CZ-AlliK.js => index-1ncFVCXa.js} (89%) rename examples/react-todomvc/assets/{index-CosHSvo1.js => index-4GhU6Gpr.js} (76%) rename examples/simultaneous-cursors/assets/{index-BJ1xyFxJ.js => index-CUyGqr_M.js} (76%) rename examples/vanilla-codemirror6/assets/{index--0f-Tmnq.js => index-DBSPfpB3.js} (88%) rename examples/vanilla-quill/assets/{index-DK_gU96d.js => index-ZU4bONgA.js} (86%) rename examples/vuejs-kanban/assets/{index-CvxEjgCh.js => index-C3LyZcN6.js} (74%) diff --git a/api-reference/assets/search.js b/api-reference/assets/search.js index 582d6bd47..b38e95873 100644 --- a/api-reference/assets/search.js +++ b/api-reference/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA8W9bZPcNs4u/F/GX2dnm2/9km9ZO3s2Z5PYJ/bmfqpcqS25W57pdU+rI6kn9p3a//4USVENQgBFqSfJJ7dHIAERIAheAKnfburq1+bmq/e/3XzaH3c3Xyl5e3MsHsubr2525cfifGhvbm/O9eHmq5unot4XHw5l89fuyd1D+3i4ub3ZHoqmKZubr25u/nsbOloao5Z9X//+d/vlVI509aKnAj3e3pyKujy2QKALE7GQuufx8rC3dFk87nriJKu7TiKG46tqe37M5wnIr+H6pt4/7tv9U+Zw3kH6a/i+Kz/nvmlHeg23l9X52JZ1rjp76qvesC5zB7UjvYbbd9X9d+VTecjkCMiv4dqU7UTGcYuJvOe7Aci36/cvIlOASGZmIL49tu/yhblQX6fy4/0EpoB8Kle55vxi19Nf/Z+TPtyIy2qwrY5NW5+3bVWnunoR09FidxIxg7TfJRm4x5d+22b3l33zl1O9fyraMp/Lp/JLko1/fj2fpi3ac5Nk1ZNcz61o22L7YBeZ74tTkimmfAbep/0/Rwa1J3kGbuf24V31qTx+e/xPOWqVFPUsGZL+LIvz3UiU0zUeSswMxLY67vbtvjqmjSwiewaz/nLcfldVp1fnurC9pg18SHy9BHW5rY7Hctu+beuyeHxVHoq08TENnkOStv7yNrxjhhwE+TNIcdqOe/oXkOoZrKBsvw52mraAmPCPmXqQaYgg5Ni8iyRlXrstmk//71ye0+wh1fVDfaqrbdk0++N9kmlE9hyrZHkqDnCvQa+VF6pZPOVCX+KVYtuGFgm3eiHKjDEiHrsyi0tENoePX2UzFuLZ7zHaf08yp//tQ3G8L62z+r7apcdqQDqHn10pRpeSmX3X5WM1Ysg9yZz+78v221fJ7gPFzN7HoqueZE7/++brbTs20QHRzHd4Ox4OQ6qZXF6GYGeMESScw+tDXRW7bdGkF11INctyz8cQL6TNN6K73hPX5+P/FO32IYcxJLye80Nx3B1K12dAzZofy+ZUHZu0hY40vF6yy5LwrUWcjsUhcwUB5M8hhXXqmRIg0uu5WyecxRsRPpddvPRx/Dd1PbLtI8mvl6I8/mLjundF8ynJPqa7nm8X3P0AgdhEEPgDRmEn8MXwEfLb5fH8GHj6R0kgSVzi9lf9hNiN9fYipk15zk48kuPX2fy+nssNj9Zw/YEs+6e5YzZw/nxvL8gFYPgKFwlJjkO3n2BJu/48nuvoJaMg03MMf84dq++L4xl4JaKTFz0JLWwvCNn/j2VxaPePSTFfAKJreLw5Nw+vj4cvWbwA8TU8LdXrjx+zWF5oszlKs0Rz5fUpBq/2dr34WGx7n9YRpA2Ag3aTvQ1A3qHNBunyMM80NwL9nM6QhT1HeCcB0BwxkvDLROZ5GGjoIxsKZUHJtHhJeHKyhhJoYFqMEVxwhiAJgHRMlBGoNEeYi2t/VW2/eSpRvs07Fvgoezl0y+9LhzfgRX3Q3wtMTb9EJCLJtYsi99UxlzPVYi53axcT35toMZv7sTg1D1U7zvRCOJfXd9W2OHiRR9nFtHM5/lg+Vm2ZyRIRz+X57XHf7ovD/n8zNBnTzuXoorQMbhe6uZz+dfw1kxeknMvtTV025XFb5s6LIf1czn8bgD8cz7+NAkCZ8yKf5YB8Ll+bDYl32hxLSDmJGwwKgwdxdNRyFRHkB4VcuDLs7kUyNInl4wKR6lxvc9n1xFcwfCoO51x+gXYau9zwj2M4FvLF7byM3Oji1Sif/V0ztkARcoxWVNVPZf22/GWWPKDxswnUtfiJ3SDkjtJP6a1ClmhwcoP1mp3fmOb6KU72mJ7lA0EnT3Sa6chcz2XLTneaa3rG5zKti19RjDTKGDaZzBwaDoy6WMsZEF1vOnSXadsZyjrZeBi2I9aTzZg1H4Zv2n6y2SYNiGE9bkEp9hHahHdjrB3RlNcbU6LftEUxok/Vbop/WsWjAkQRHN548qEcSfkMMR3f70hwR4s+OehK8B+JvsYEgAPd7dTY4YXPrx/UQW/poYyEm+wAh8xGfF8OO1ZfQ25pLTHMckNkht1YhBw1SwbIW4fIgWKUbOZ3oGmuFCPR6Knbb88QBjSdLwycMT3ewM6ZmOL6WUP0l543SMTJM4diODJ38liys4fimJ4/LMPcGcSyHJtDqOHsWTQmwPg8oiS5YiaNCjQ6l/IEgrMJIWnsnKLorp9ZbK/p+UUKPXmW8cxH5toU9uyM47mn590I89zZN8J+bA6SzWfPxDxhxucjL9UVszJTuNG5OUU4OENB5oCdnZjm+plJ9pielQNBJ89ImunIbMxly85Emmt6FiaYgmoYl3i97LvI+iuaKDeN2rUbpEwSvb6AbZgdDC04XQu2b7YzhEDNZsoRpacv+65hluPybEq9FpWJQj296OnYbAmQi+X092J/yOXW007jGI8VN04T6wBtWSopd1QB2FPxEqdq/9ocLoBqFpcf3bGBESYXonwecrFZCSOBP9+Vn+154Z6V9arWDXV/T44+7i1k41Bn4c+T+npXF8emcDON6hM/TluJjOwtvmIh1LuGB8mecg8wR51lHWHu5cqoQaO55B8wHuPFHDGO2U06ZDzGsTq1Y/w6kufg5k8WEWdrkNouZM/Dtdx+OlX7Mdt7ERE+B+fDJScyNsqI9Dm411U19saWBN3FcMU4H6rj8EwHGuKOZia/rJOjBMexnUzfxMs3f0Aht7uOPodl5tZkzIoi9rDRM8hQPrmCeRuMjUgRUz6HaYEeX3/wmfZ8GUCLZ3GZx8P+WPpayVHfiWifg3+uLfR0zzbBH/ZNW9Vjy+GFKnvBnTGtOy7j98lcmnVycd6rOP7ruKsmsr27NMtjP/FinWlShD/oqeL0r8EPzo/lrMHpmv3Jg2OlGL84IDE47jWYwTnPMJvzn28zZ2Aw68ljck5YSz3DVOo/305qYCTLyQNSJyxk352c/EeWAx1Sz9u57Jt/nXZFS100gRhCwpkLRXS88Wy7Gxv/nij77eKjq+cPzbbefxhjA+nmcTqdPxz2zfBuBrTc9lTzuOybt8Vj+c2htESv65cP+8Pu9cdRzTGNnkOL/g4Fexqt3H2Xv5NJNHsOqYrT6fDFd/mm2A6P7cbCDKnnacfeMJC7jcS0V3DM2i7HlPO4PRTNBBUPqedxLY/NuS5fZuwbY8p53LZ1WYT6sgzTIchneqqy/ToDrAJkcz3IN0cLHb4qn9qqOowpkSCfbanUhSYDI00dmczgwVw4MmAzcuVIzryzZvbj+GYfkc7ml8fqOi5F/aG4L19Wh0O5HWWGia96s9cf/pPBEtHO5vh/vOzfEdeYDThGtM/A8e919ZjjzNhG82Roq//79vUPIzx7ork83lZ1W+6yOEWkV833zOk+f7bbYfl7Vb8riYt/hgN4oZzHzUUjgyOYicgl5xRmbrQ0NpaI9Gp++eyu4+ZKB7NwSYL8Gj3mrEcx5RXcBim+BD9AewVHNhGY4Ey0mT3/f7K1F3/78qZox7ZeA+LZcdrrCdguQT6Pr8VpJ3EmG8zU9G4HOxrT8YB67hvbLeIExmSD2TudN7jQi93lvBmr58qw4++/ZPLDtLM55vN7Tm55yyjZ4GreGXHCm+xsWComKQ8fs98zJv49kyExs7v4v38RPcS5GEc1k11ll3VeKeZ4kWeevFMLPq8Ve7T8c67Y2A5ftw9l3WRbIiafiZ9kZcg6qmuSjhHXj/tDW9Y/lXWzr44/0RfExxLQLZ5Dlrw0WEf1bCOQkV86P+eIZ6Rv6ud8v/uytRbzti22n7JNmmgxH6Uop3InWszjzl87G/Mcv3g2J6KeMIkI8ny+8LCuR6aPHy8mBQ+y9k/zi9Ufy6Yp6KPHqLsXF1JadiAcWx9X+qvE6GvtEL+Iei7Lgr0MDnEr0re/jTLyiyxz3QVmBonnMkzer4EZjt+nQTKEtjcoFQLswrN8uzvCy1q5nl4cUx/M6gXiypyi23lYHmXyap4xJtvq8XQoW3ICxXwAZTar4fhHVc4DXqO1zrEFDZK+fIcZmV8gIMPQbRyqz+R1e5gfoJ3ALvesFsdtrLQRtOsF5Ku/7U3Df79A577m2/8xqaXkWwx6Gfs+YCcFL6a7nGogZ/fXawWF3YxJGgThRX3ZTaKBtJcH1wqMehqTGUjEi/2v43CueW7gybWC467GJIdC0acM3u0fy3f77adyGFBdHo2chwBBUzUswEDdvKj4W3OBMNzmpq4e37oTCqN8ItIJ/HJPTmB+OWcnSIZxBXzxeKrq8be70OXsKMb57sqD/VYmUSaMOUPK5+Ht4jICDMGcL3Sz+aJc1rev3rY1Ve+FWUekc423rTJNFxDO52W3WdlvFxHP5cnWbWB+o5Ub47zuy/Y7PwW+bjLfkmxyPf8JfK/j9yp7iiLiK3h+nTk1I9K5/IqPOS8XqOZyKX85F0StD2bTk83lYzcDRT3ESofrRqCbxAkdQuyJkIvpDiGix9fGIWR/Y8HIQMbMJXCc5R21GqZYj+Dcw8UwQwZ6XbxCCrwsZshArZDTJMCGhR2AF6L7a3ofCqLMNJAWPU32mRubDXvMCs9iMRm1POW+xIunKVA6xxuvsDmMPdm0d8SeP4fP/bV8HovP3CpKsIuor+Oaye46Pm6lel1/88uZ+FgUwRDRX8F5V5anbXUa1pgSXAHtFRx9DimHX095Bbdm/7/DhZWaCJ7uCk7vrUcv2qr+OYffvwP1v2dwjR3v6wCNR6kA736jZyObcxQnlJ/bVM+D55N6f1mdLf6WYkCRTOLxdV0XX1IchgST+vcVtcnRH1JM00Fdlkkd4OfTxme3e32ihiX8/drYL+5oLOi7iMMsp7kc7vLYjFUwwOK4FLdTqjAul9veXk6SxS5QTuY3vCfFHsNoStIG4ofXGgLR25g1IOnyTYLnlbYL1G6ycST4Ji1kEt/4jq1RxmN3bKU5Y4Pxl/OQ5gIfXWssg77GTCWSK99QOD5pM4laTTYSlmfSRCbwhFfqjLBMfddtAkfKc7E8084rzRWb49uyJW2x//u1hhh3NGaFF3HyTZDkkLa/S5PJxkdzS1peLreh2dHMUjaX4IVV/z3nh75/Ni/0/TQf9P0cD0TzSOv/+yu8D8MvaQH5/OryaV+dm28Jf8AxRk2ulIDyRAzntB9KcRyky3d72g1dHlydNI97Gs2bXyTKN0WaR9oUQZvJpsjwS5piNj+bz83j11Feya8d0X0/mvw1HNm8qAiQYZeO/lIcZxtldN9u4uagAfP03cZF29b7D+cWHEaYIMVd1HySQCPK2FbHthzc45gn1KXtlRIN4qL2y4FeHcGTq2Mj1NVodASEmhAf0VxGIiTQaHqMxHBMR0nZHAnPxHFMuqZ8jgPfxI4p75zyuVHeiWM48pGXFM/5BprroIbsZ3qoPDlyXBQn0rhHsDAhG6fED69O9w57G032xtLleweeV9pBoHaTfUSCb9JNTOJLeIoE36SzmMR34C9So8y7jEk8Ka+RYJt2HJM4N6fDvv2ufCoP+eyjNs+k6TeTrAy0eBaNT+Pe08/jTTknPmRBT5/DPU0NXbCA0xzUrBAGN5zlomaFMtM4M05qVkgzjTPppmaENtPfl5ksqXcenS9T3nsi/4zZel14l2I+7qmvDfNGuY+HerQYM8O9fHlyQr6UaGMlYX3v7yqPqz+HpKCv55D4Ujzx+vQ2/mqN/zxE+HO6fAx9OznVx4tAQYvfi0H27r+imuy+J5nTvz14Gx2CpjgAonweoMDuTW1rD/fAHkKVSv/kqkMccS+pMxwXSZjendXYS7z+9qUl7qFAnAbUM7m6o1wdzTvqggjEl6CfyXnfvD2fyBI3xBISzub17bEt74lCrAGvC2E+r9zyS8Qsp/SSYjdcpXI0BwlzCi/zOGdxvYJjzgV1iOXIDXUZXBJX1A14ZdxRl/Ve3JUBxMuN3RUwyo8tg0TMRksgc9xLple51pn8cH4s6/02hxsmnv9uP+VMAUA32z6y1oQL2fw3eukuq919PWqIiHYwv/fHh7Le+++xTZKAOFUzZE2fdpvN0+ZA8975Qvl83LvvgGXxh7TPJ8GbqtnbqspMIRD5M8nRZOuh+R300EzQQ/O76KGONy4M73q4JbmK677B36pjvSb1vbrpvGNArKf5idhtxw8nlfv+T12cTuWuu9Ee9Rs/nNSvXejpTsGTyT2iq40vHfoHk/tztd5Ed+7v2aeTupr0gWF0f3+WE0mwr6yAOAg1ORyOOE0NhnO4ZnB8Hm4umf556KXwWLb4CpkrOI5bwosL0TyOsVvqP4mbZhrR5VpMRsgRMRkGHNP6p8NEzCIdJGZyGTd9RDmL274rph7TTU81i0tqWxQxytkUUbzIUzrUQgQfZbvPd9QctX98FsfZd5R3wYaVZaI7iThM8CUpXiOM5nPJdR4XXhmeI8WDdhuX7tM+I9Vzudunxqh7PL3fXRnd1jXsuSeYIfPjqR3CCUDo7vn0nht7JvvLISU3IJnevyuO/dFeAPeuelM1P5I3zkOrIcmn8z11jd9V3/ZdJvgy5NP5pi9AuczErKtPEnxcvENcJ9Fz6Any+l5KocFdCOXxnrjO/dJ7TzBrZtvEzt++xMXd5BSPCa/hNeJLANUcnWfo+wpdM7gs7D0JkI71zQUBMYOxCCDFxX+jyc2qcWYkcSbP4bHjN1VD300Cn11dCjLobLQQJBKNO4Swy+Vzt+e/cx83mpUYT7DNyIkT/K28XLw0gEgnCHG3JUHTDHFGUuDVx4/wFowpIvVNn1OeujwUFrp5PU2uQbNZJpOcZ/FSSwjkCPLD/LokFu66TPeQHeaHjvLCfCsLe2DIxbvkN8IuXGKqrEA8wZPdWsC3mhL0J3i1ST286B7P4JK9tcCDmNxaJHgwW4u++5GtRaLnD+f9YTdiAZBmluxv04NzoZjV+w/VrhznAKjmjb+N6NIz+wUim86nsZsW5sNEFzYx1UwuY/3P6tmnIpjdWd9/TDWdi93vftt9yTjBBpFdO89td6OqiYjmvdnfzodPeXwg4TxeIxyueocM6Wf131b/3/ffpdx693xOz/SmBXSd3rSM9M3uIyIGoxuIES627jCPU0w5yyvaVcGSWO+adoyIcjo3h7O8q0YmRkw1nYutDu8QlQSXmGoel1GEKeKWDTCNjWA+22nAVupts4Cty+tOAray+L4JI5jFFlJnch2e6YhmxKXk2P55UvK2SyAT3YEn14IBuKvRM/ZAqPzzIAyXkVP2oFFuyXcm35xz0dnctw/7w64uBx8OYHgD8hmcqd0sZXDdn58DK8q2jV6WCQeFiP5HTgiFFjMObFDMRk5qsNyomY++UXuZ+/5BUhlroqcogetL4uOHuacDXqLj+mxfL16OHM5HwpHc4l0Az2t8HzDG6Udi18Hz+zFz90FyHWSIf3z1Lrh1d+/9ELWlSK6dkGyfox/ooOSdiGqOMc8ANMkuZqCZo6KMAJl5clCTPI0dDgjyK6zoD1xnuA4ie5Hq5kVPwgyNF4TpP/F1Ecgj48siAz7ZdWLwXXLKxDAjLm9BMdiTNY5UEVOSC/HNN4ob87G3uVzDt0PHbevFgPR67vijehRb6mt6E/jlVG8BbiPFW2O9f5/xQhHZHD4PRfM6z1gw5cy3yuSGKedwY79+AhmNfvlkdPze5Js9RT1zHCdwpajncC0/l9vziLe/0GRyyPpWNMHhrvu3/3rxCMs71I53nRauShsnJ8LdpfEUUUbzmU9lba+PnSlU1P46ufLreaBkWRU9adNjP9QU85kaA6goBHgqa1hq/FTUe/vRweav/bP58TTX2VggfRGLsQ538QH+CvgItzvUaIT1xMKIKcz7UoBlthix8Nzmv/K6flNsP2ULhhr9saMCmYdRkev8UYmET9jKjHEZNPvj7WU4NkJOs5gpo9PMkI13rr//uDT9oOg5g9LwsyhsWvNHJG7zR8+hnncYETVhRKDoCRuZPia41R9vJ4NxERNcSyw+Fze582Lv0HnhMdlwqz92ZCLuvdOdYDGx+MzIfPjibnRBJ+3GZMOt/tiRibiHkTH5AxNLnx6Yt8fi1DxUk4cGtPtTBifwD8OzmTw8/Rv8zoL1k37R/+JrUseEDX8e2bRU8xWalPuuThWITRN+/Kp1F2Tmu7NJLwK7/wPepmv7D1BwkPk6/0hUH/zOc+wf5ed+JZ88TFZuZjAebPHGtKUqavLHDsaFdb9ILfJHAwjOxnn/KD+jjfx4rAXb/NFxXs+7t44JAwJFZ0fkX/tju45Ps4+LFTX6o8fkwrwflAm76kh4dlR6THaCXLDNHz0mPe9+SCZsG6HoIzgDyATkbvQTqYHfG2P49lXvRyZZSC84MxpvPkwejajJ5NGgFrjJIgzb/SlLHVbN9AhtTD0hKJ88h4mGf852BM/m1fQdydiMfoJfA50WLpFN/9iBGorQO74JG37iRVJxFP0t6aygBjf9E+Kq+KOxwS9OWCaIF6EKrb6r7uMb0H3pUPhzbnHVu3r/tB9cvhr18uJCQ79CLwrJ4VX54Xyf7D9QzOk9unyc6rwjmNP3/xT1Mdl3RzCn72/qGhg31XmgmNP734t2RKeBIrt3LTZaLcAd/GU7MMHHanc+lE2fCQcEpB2CfNk3T+Wx9Tfgviqf3hRH0O1l3hFUSUOnGbx99c90329f/XNSsbMT5F319tU/cZFF66//ws8n9f721T9tcfexPNC9D55P6v3v58NhTH6SZjKXsfcgaZJcNHAyT21VHRpsin8NDyZJ+/KwLwfXovU9+adEh2AC9fJMqo+kWIxldFEbtirSPQVh7CjHO9Aki3Um/DVBgtNYTnlUgvxb7/qu0tffPZ+OMZ9sRcN3yC9WH+ObLlwnW6f1Pfy46KgIqe+MzpCAKqMflSFdUj9DCq4eeVSS8XrkPGmG14Md22J/pC8Iu8yoiOr39XZDVvleL36Z8cNNxNdq+s4gze/6xgNG2e8bvcZ4UXAm39SlJnTjtM3PefdMBzRBiq7xVDn6Zs8nSQPP+efK0aSO/c+RIukPWTEyHeIEOerB9cS5stTkZcXXyjO8OTh72pBXCV8tz9GW9T5Nl6Zv96yy/AAvPpkgyw/4OpRrZWHOKo4LM3pqcY407LnNcXkyTnDOkWhXngYfmRoXJrR6TpsZftE7x2JSx9Ln+f8Zw5H8ztosKarpBnJKFH2nZfj5thv+r34L2PPNVzfyTt3ZepKP+/Kwa26+eu+Fu73ZVo9uH/Fz98wDjpbCk/x1cXP7fnFrNnebpfn559v3oYV74P7gyMTN7XtxK+Wd2GwiMhGRyZvb9/LWiDu9kRGZjMjUze17dWv03dosIzIVkemb2/eaItMRmbm5fW8opiYiW97cvl9SZMuIbHVz+35Fka0isvXN7fs1Jds6Itvc3L7fUGSbeHgX7PgiPThFkAoTsSpswet7IUjKWBtCcVoTsT5sueh7IW+1uDOL+HVErBJhh16oW72+26zWMWWsFVvJ/V7oW23u1ELElLFihFWAMNRgilg3tljxvViSrx6rR1g1iBXZZ6wh6TREalzGKpLsXJFosjgNbSgxZawh6TS0IJnHKrLViO+lICljFUmrBylJylhFNun7XipSzlhF0upBapIyVpFcs4MUa0haNUhDdhlryJZ0vJek1lWsIWX1IFckZawi5RzamqRELs2piFSmilVkS4zfK3IKq1hFyupBkVNYxSqylRvvlSQpYxUpqwdFKlPFKrIZwPeK9L8q1pGyilCGmsMq1pG2ilBL0qfHOtJWEYrUkY51pK0iFDkzdawj7dYdUkcarTxu6VlQPlHHOtJWEZrUkY51pK0iNKkjHetIW0VoUkc61pG2itDkhNOxjrRVhCbnkY51ZKwiNDmPTKwjYxWhSR2ZWEfGKkKT88jEOjJWEZrUkYl1ZKwiDDmPDAoQXIRA6sjEOjJWEYbUkYl1ZKwiDKkjE+vIWEUYUkcm1pGxijCkjkyso6VVhCF1tIx1tLSKMKSOlrGOllYRhtTRMtbR0irCkDpaxjpaWkUsSR0tYx0trSKWpI6WKI7jI4ZlrKPlil3dl7GOlmt2dV/GOlpuuIVrGatotWDX7FWsopVgV+JVrKKVZFf3VayildXDkjTkVayilVMRacirWEUrpyLSkFexilYu1iYNeYWibauHJbkgrGIVrawelqQhr2IVrawilqQhr2Idra0ilqQhr2Mdra0iVqQhr2Mdra0iVqQhr2Mdra0iVqSO1rGO1vxytI51tLaKWJHaXMc6WltFrEhtrmMdrd2WiNTmGm2KrCJWy1sl79ZrHVPGOlpbRaxWt1rdrVcxYayijdXDan2r9J0SMfNNrKING3dvYg1tJGtzm1hDG6chev8Wa2hj1bAm7WMTa2hj1bAm7WMTa2izZEdzE2tos+JGcxMraLPmRxNtXK0a1qRT2uC9q9XDmrQ5/wzSCvad/DNIK7m38o8gqWLfyz+DtJp9M/8M0jplkZPEP4O0vLr8M0i7SsiLNrMLBzWQ088/g7SbhAxIbYKfWWKAOljVrOkdNcYdHLrAyICRBwcw0CrG2INDGDhxkdo8/EDCKRh+cCDDenWrl3ebFUI/MADhYIb1mqZFWnNAw5pcWgQGIURCawiGEA5soEcM4RDCwQ3MiEkMFkl2xBAWIRziwIwYQiOEwxyYEUN4hHCow4aGthAiIWRiriFMQkjWOQoESgjJu0eBcAkh2UBQIGBCOPiBGTEETQgHQDAjhsAJ4SCIDQ3xKYzxKX7EEEAhHAxBjxhCKITDIZgRQxiFcEjEhox3BEIphMMiNvSagnAK4dCIDe2kEVIhHB6xoZ0pwiqEQyQ2tNNDaIVwmMSGjE4FwiuEQyU2ZHwqEGIhHC6xod2Ixuisg2cX9AxCsIVw4IRY0MaDkAvh8AmxoFWHwAvhIAqxoHWH8AvhUAqxoJWHIAzhgAoybyAQhiEcUsFA1QjFEA6rYCBohGMIh1YwIDRCMoTDK8SCNjYEZgjjlUdbm8HoulcebW4I0hDGK4+2N4RqCOOVtyGzAQjYEA6+EEw2AmEbwvD+EoEbwkEYnBAI3xAOxRA20UERI/UtfVKENmSEcgiHZQhBGzICOoSDM4SgDRlhHcIhGqzMOEHi9CdoM0KIh/CQBznKCPIQHvMQ5D5IINRD8LCHQLiHcOiGYJIqCPoQKz6xiLAPsfK6I0EageAP4UAOpl+kuZXXHLnLEwgCESs+skQYiHBIh5D07Fjh3JbTm6TdMUJChMM7hKStGIEhwkEeQtJuE+EhYu3dJm3FCBIRDvgQdG5GIFREOOxD0OkZgYAR4eAPQWdoBMJGxNpnJWn/huAR4UAQQedpBEJIhMNBBJ2qEQgkEQ4KEXS2RiCcRDg0RNAJG4GgEuEQEWFzNoS3QHCJcKCIULQGEWIiHDBCp2MEAk3Ehk+zCASbCAeOCEVbBkJOhMNHhKItA4EnYuMTy7RlIPxEbLz+aMtAEIrYeP3RloFgFOHAEqFpy0BIinB4idCCzIYjMEU6wERoOi+L0BS58JELnZpFcIp0mIn9NCWxtZAIUJEONBF0vkgiREU61ETQKSOJIBXpYBNBZ40kwlTkwmP9pAYlAlWkA04EnTuSCFWRDjkRdPpIIlhFOuhE0BkkiXAV6Ws56CSSRMCK9PUcdB5JImRF+pIOOpUkEbQiHX4i6GySROCK9JUddEJJInRFenSFzilJhK9IX99Bp5UkAlhkV+JBaxAhLLKr8qA1iCAW6Qs96PySxKUevtaDzp5IXO2RKPcY1HtIFgeQuOLDoywkDiBxzYdDUgSdw5G47EMaPuyTuPLDYSmCzvlIXPzh0BQm8JO4/sMXgDAFNbgGxGMtdIgmEdoildcebfgIbpEOUhFL2vAR3iIdpkKnYSTCW6TDVASdr5IIcJHKK5CeJAhykQ5WEUt6MBDmIh2uIlZM6RBSoPL5UnqSINRFOmRF0OkriWAX6aAVOpEiEewiHbQi6ByWRLiLdNiKoNNYEgEv0oErYkXu3iVCXqRDV8SKtgwEvUgPvaxobSPoRXrohY7IJYJepIdeVrRpIOhFanb3JxHwIj3wsqJdLQJepGZ3fxIBL9IDL3QmTCLkRRredyLgRXrghc6bSYS8SMPu/iTCXaTHXda0GSPcRRp29ycR6iI96kJnxSRCXaRHXdZkrZVEqIv0qMuatmKEukiPupA4mESwi/Swy5peGRDsIj3ssqadPYJdpIdd1mvScyLYRXrYhU6dSAS7SA+7bGj/hmAX6WGXDQm7SAS7SA+70LsuiWAX6WEXGtuWCHiRHnihwW2JgBfpgRca3ZYIepEeeqHhbYmgF+mhFxrflgh8kR58oQFuicAX6cEXGuGWCH6RHn6hIW6J4BfJwy8SwS/Swy+MNSP4RXr4hbFmBL9ID78w1ozgF+nhF44Y6W/ta4Zo54ngF9nBL+TURuiLdACLpNF+idAXufbVxrQxI/RFOoBF0mi/ROiLdACLpNF+idAX6QAWScPnEqEv0gEskobPJUJfpANY5ILWNkJfpANYJA2fS4S+yI1XIB3oIPRFOoRF0vC5RPCL3PjSL1qDCH+RDmKRNMwtEf4iN75knNYgwl+kg1gkDXNLhL9IB7FIGrmWCH+RDmKRdNW+RPiLdBCLFLQ7QviL3PDRC0JflANY6CypQuCLWnj1rW/14s4sDCJGdeQLr74NhQEpBL4oh69IGjlWCHxRHnyh3k4h6EU5dIV7O1RQvlim3g7VlCfKWRQCXpTDViSNdCsEvKgFqzqFYBclEqpDqIsSKdUh1EV51IVMDyoEuih/lIZRMwJdlMNVJA3jKwS6KL6kRSHIRQm+OEIhxEWJVWokkOo84sKMBNKcw1QkfWpEIcBFSfb4k0Jwi5J8AZlCeIuSMvFyCHBR/owNnfpQCHFR3TEbWs8IcVHdSRvSDSqEuCiPuNBDgXTnC1uYoUCqk+vUUCDd+TM3ckm/HdKdP3YjVyQxPnij+JIkhY/eKLYkSQ3O3njdkWiZwsdvlJ925Bqt8Akch6dI5rQOPoSjeN3hUzgqoTt8DkeldIeP4qiU7hDUonRKdwhqUTqhO4S0KM3rDuEsSqd0h3AW5aAUyRyJQjiL0rzLRCiL0gmXiUAWpVMuE8EsSq8T6kAwi9KblDqQ7gxfvqkQzqIcmCKZ82EIaVEOTJGKPp+LkBbl4BTJnBJDWIsyXnu0I0RYi+KxFoWwFmUS2kNQizIp7SGoRZmU9hDUokxKewhrUQ5O4QYZYS1qKRKDjLAW5eAUxi4Q1KKWLE6mENCiljoxTRHQopbea9JnMRHQopb+eCl9HBMBLcphKZJO6SoEtCiHpUg6pasQ0KIcliLplK5CQItyWAqtDwSzKA+z0NieQjCL8gd86OOECsEsyiEpkj5RqBDMohySIulUsUIwi3JYiqTPFSoEtKiuzoXCIRTCWdTKHxAmsUuFcBa14qtxFYJZ1CqRY1cIZlHrRI5dIZhFeZiFTpsrhLOoDmchkQWFcBblcRY6ba4QzqI8zkKnzRXCWZTHWTSZXFMIZ1EeZ6HT5grhLMrjLHTaXCGcRTkohTkXjGAW5WEWOsWuEMyiPMxCp9gVglmUh1noFLtCMIvyMAudYlcIZlEeZqFT7ArBLMohKYwPRyiL8iiLIbFLhVAW5VEWOh2vEMqiPMpCp+MVQlmUR1kMHSkjlEU5KEXS6XiFcBa98Gf16WPTCGjRDkshb+7QCGbRvsaF9EUaoSzaoyy0L9IIZdEL/vSJRjCLdlCKXJI3amiEs+gFey2JRiiLdkiKXJIZCY1gFr3g555GKItebHh3oRHOooVXHX3mHAEt2gMtdC5eI6BFi0SBkkZIi/ZIC5241whp0Q5MIa+I0Qhn0R5noS0IAS3agSmcohHSoh2YwsiAdOewFE7RCGjRgr98QSOcRUuvO3J50ghp0dLrjnQVGkEt2kMt9FFajaAW7aEW+jStRlCL9lDLijz0rBHUoj3UsiJXdo2gFu2hFjodqBHYov3VJnRVgkZoi/ZoC12VoBHaoj3aQp+v1Qht0R5toasSNEJbdHfPCX2JBoJbtIdb6AhKI8BF++oWZqoiwEV7wIUuYdAIcNEecKHrEjQCXDQPuGgEuGhf20LeSKQR4KIVezmNRnCL9nDLmr4pBF9+4uGWNW3K+P4TB6lIujBB4ytQtL+nhrZOfAuKA1XIK6704BoU/sYnjS9CcZiKpA/LanwXik65Tnwdimbv5NL4PhSdcp34ShSdcJ0IbtHG646epQhv0R5voc/LaoS3aI+3rOlZivAW7fGWNT2XEN6iPd5CV1JohLdoB6pIupJCI8RFO1RFbmhLRpCL9pALXRyhEeSiPeRCF0doBLloD7nQxREaQS56mVr8EOSiPeRCV1JoBLloB6tIupJCI8xFe8yF8bMIddG+vIXxswh10R51oWs0NEJdtEdd6BoNjVAX7VEXukZDI9RFO2BF0UUMGqEu2gErii5M0Ah10f5KFSYUQLiL9reqMKEAwl20g1YUXfKgEe6iHbSi6JIHjXAXvfK3fdEminAXzZe3aIS66BWPeWqEumiPutDYnUaoi1559dHbIgS76JVXH235CHbRazbLpxHootd8lk8jzEWvecBTI8hFr73q6CmCIBe99qqjpwiCXLSHXOiskkaQi/aQC+NrEeSiPeTC+FoEuWgPuSzomYowF71ms+saIS7aIy5MnIMQF+0RFybOQYiL9ueK6CoYjRAX7UAVRVfBaIS4aI+40FUwGkEu2h8soqsqNYJc9IaHPDVCXPQmEXgiwEX7Y0V0tbZGgIt2mIqi63Y0AlyMP1ZEF40bBLgYh6rQcZFBiItZePXR15shyMUsvProG84Q5GIWXn3MRXTohjd/qoiu1jQIczEOWFF09ZBBqItxwIoS9N11CHUxHnWh7/Q0CHYxfHGLQaCLcbiKoiuCDAJdjMNVFF1hYxDoYjzoQm+CDQJdjD9TRPstg0AX45AVRZe3GAS7GL68xSDUxQh/1yV99R5CXYxgK+INQl2MA1YUXQBiEOpiBK87BLoY6XVHGz0CXQx/msggyMU4VEXRJ2oNglyMZDN9BgEuRnq90bMDAS5G8npDcIuRXm/MJZBIb5LXGwJbjPR6o+ccAlsMf2uLQVCLcWiKoks/DIJajOL1hoAW47AURdcwGAS0GMXrDcEsRrGFgAaBLMYfIaIvWDAIZDEeZKEvKzAIZjHd9bL0pEc4i+FxFoNwFuOvmKXvrTUIZzGaDTQNQlmMv2aWPi5tEMpi+KoWgzAW46+apUsdDEJZjOY1h0AW43AURWfWDQJZjGbhMYMgFqO93uhJj0AWo3m9IYjFeIiFztcbfPGs8TOOnsn47ln+7JDBl886EEXRqX2D75/lzw4ZfAGt8Sk95mJZfAct7ynxJbQOQFF0Yt/ge2gN7ynxRbSGvbTe4JtoHXii6HIBg5AV48ATRZcLGISsGAeeKPpkuUHIill6zdHmjpAV45EV+nifQciKWXrd0QaPkBXjwBM6dka4ill63dEGj3AV46ATxdx2jHAV43EV5sJjhKsYj6swdx4jXMU46EQx1x4jXMWs/OaAufkY6c/jKszlxwhXMSv2OwQGoSpmxXtMhKkYB5zQh64NAlWMA07oQ9cGgSrGgyp0ctwgUMWseI+JIBWz4i8DNAhRMV0hC7lRQ5CKWfPlmwZBKsaXsdC7fYMwFeMxFebaaoSpmDWvOISoGAeaKPpOAoMQFbPmlzqEp5g1vyE3CE4xiQttDUJTzNpPOdqjIDzFpA4KGYSnmE1CdQhOMR5OoQs8DIJTTFfAQtaZGASnGA+n0JczGASnGIeYKLoaxCA4xTjIhIEcDcJTzCYBZhoEqBiHmSi6zsQgQMX4Cha6qN8gQGXpK1joOtIlAlSWHlChL5RYdoiK+7CP+1L47lv/gZ/37/uvDP528+/uqz8ifHfotxtx89Vv/729EQv/r+z+L9f+3+XG/7sJdMJ0P6QMPzoSewOb/7FchR/hL6vQfKXCj64f2XPUq/Cja2WPb3c/VPgRWvXNNx2xPafU/Qh/CaLa4x/dj2X3Q8nwI/xFh7/o0CrwslWs7ocOxDaB638EMSz23P3ouJsghgliWKyg+xEehXe32+fuRyCWgTgMr90Cdj8CsdLhRyeP3Zl0P2T4EWj0MvwIxGF4TRheE17ZBn3+xyo0X4VW6/CXtevwv5fPQ9n/WaMstu3+qWgji5Pri8n5wU803MGWl69z/nZjEiztZ9CBha+AjdtrJxLt9hE/e8z20nIpg8Gtw48N19duVx0P+2O57T4MDfo0BvQpVKKH0959ehSMnFiBtps11/ZjW8YjsFmCdn4Ccu2quvzlbL/0DtguYPM1O4CnvfseLxx54Fw6213yzU+HL9uH4ngf+ycN33lhxlufiu2nqAcJxVizI37poYkFgG/vXQvXfFdty6eBwhewPas02745FqfmoYrba2gwi6T4TVu0ZyT9BrZODn5bF8fGTrzqSLwFnEQL1vBtP78W7fahaeuyeIxFgbNpwc7fui6+VKeyLqwgwymg4RRgzaFti+0DbKiAFhSrRNcsdjr2AtyL+eh0U/unx+IUtV9C6+Nb9x94BC8bucrg6+0hpm410mHtCT56wyq4Z9BW/qOoESMFhLQHKphOzu1DWdexe10BhfDrwLl9aKtP5XF//E85cNCRXXRughupD3VV7LZFE1mnBioKq1xYnCS7xnw42698VvF0syU5l77Mgmv7xQ2l9xfxqmEBp8syNdbDg/2GJWwM1zh2seoaVx/saMbtF7D9CPN+mkVdwNG0cFayC8plWTAaCMH1sC2OdbmLpreIloxViEQlNw7b4ng+4i7ghFuGtVpyRj1ccmw++GICG87jUroXcKm01ywnmyLfZi/sAoFKunHz5bh9rHax4BLOYrZ5uf10qvbIvy/gwBt+sMKHcaFnhTOmDw43rACDmAiIHXYSIQxdsaPvetlWx90eG7BRwPpYy3HtY+2t4RiILkgWISAXqjfHEFGv2HFyvVcnK1rk0pfAtFg/61s35S9xMAWHSXH+sWs7CARgFMLb5aE6xtGXgIufYZlWj/Zzs3HMCY2ZV2P1eDqU8QbBXpJ2aarHmn48xosJDFRY79UbThwtwWAp0fRYbtHWZANsTrBuu2u6r45+EkddLMFCyhsW7mEQqa1BN4KNl7fVsWnr82ApBjYmugVUmGD3YVdvrwPyEcgqbIMX3ZTQYYurwzqseUdQHdtifyzrJ//FeOBS4CbJsCG77QC7EglUqMKu2BZMJbr4HHexBIOgF+F9gj/QOvE+Dm+pY58MF3TBzrzqfEQtwSToR1mEH7wMrp9E/AwM1d7Gk+xmoBh7QOYyNuzudVvv2rYuy2O1K/c7b2jxkgG0ZMvIuG5KhB0oaKCaF981ZLaDcJUUI7x3BQoOYaCpNsHCA9SyZn2G66228nysahs4Rd2u1rBb7q12JQmnRAY/2jQGVGCcxk2RS9u9tYljDA5oDTXJdvHhfB/HmKCZTelx7crTtjpFoIKEkYpcd+GGYod+V34szodovIESec54VZIwOtOSA1F25WH/uMcADIws7G2GHX7ErRO78tTGu1cYNxgW+dmVg20vaKd4DQ+3vZsNXAl4u7ItSbuAQSEHF+y6T9PHvh+axopV676hF2K4/LFREgnULOAarlnddE0xkA5XDTbc2VXbYWgGIyWh2ReutjbmJ5ob+MbsUFfb8yN6Y/C+IcZlVVXu9miVXMHpEDBvdirb9h/Oh0+x64JGsuSmVGj64cupiKeFhNrWJiU71VjBxpyp2MaUgdsDKKA5Zy62OYHkSvDmit2blofS/v+I93kL+Norbr0oH09t7DqXcNllA9zy+Mu5PJdt0UTagvAdG1eXx+Zcl8N9BPRDgoWQHfSMInLoOVlvMEClbNkG2EOEDduSm5iuA7yTgMAti+M4Z9BU53prg/FTcSwP8UoHh23JxW2gl2b3Ke4AwkksfO47GIKuUUS/ZMfv0rr60JT1E1q/YNQo+EH8XG7POGCD0rPo98eiLdCwreBbcyb+cX9AS629WROEB5xL8A2fyrrZ26h9sA+CmzEpOa19rKvHeFpDHDWk61QIFFXItynW29ge6bhVQZdhJGeOlw7iVRVKZtipb1sP/KSC64QJyVHW07s+6rIpj1uETkFcRqTGdLhjEBCWlSYkXdkEgO0l7EDQQERujJXifDi4udxWze7TY9k0BQIJo2Tkih2M8+HQ7D61leuM7CdCq7g18L6oPxT35bY6HBDiaz9eA7Js3IDcl/HyDYMduebm172N74Z5UbhuS/bd78uWxEjhjkWwO3PXmoQqoQZFSnS3DGGA335GCIwX58tscwpchOA+GxbbxuT+EaJwil0G78uW3kbAcEcuOd92X7aduRxipFZA4QWbK4raO38yWM5hikCw25H7EgGscOh7pxi2cHoRfoRcsdZ9BQU7L8rW9W3nerxTh7s1k1AUylnDTFgooRCbBPtD8Xiq6tjEYGQp2VTWpXHRNG29P97HnUC8l13378uW8iowTWoWnLu3jaunoZXCTSO7hNrGXyhHb7/Oc5GcdfT3pQtsm/3/Is3BjQUbaN6XbQ9yxQ4e5n8Mm6+37W02syHwGPvpG7D6J7o4VY3zEMMhhGtmynzoAYQ4tEioPrSmklhwnWMT/6APciBgCMxmr0EncfAOUQspEoZ0qq232z+VeFdtr6O7DCS7r3ZdVJ9R9Qk0Qxa1vS9bm4Vs2mL7iRwCmIxQCU36tPrAEKD8m8RSOVynYCqRhTq7lsNMsP1OHWifev2q6tHaeIcLfSi7dbkv26Y8fCTHDrowNmS1HQycAHTDJjHqFg9BFS9w8qYWjiGUoiKILzj/hAuyw/bhS7zISZi+0mwK/tLaNYs6gLCITEyb4WyB+w82b3JftjZrzps8DO9SLzDMD8DdrlqH3AlbLxT6GKIzAk4cKcaEGIwE3MDpZHN+DwihBxZafyiOu0MZsEiMQ0TbWM4WfReubCrAdE1dNqfq2EQvBS2bxScfiuZQbYsDVcoGi0MEW6zzUDTc0gq3oGwp2kPR0KsaHE/Bxf2gNbWqwfFks2AP5ee2cgUqUWO4kTUsUuoas1ah4IJk2CrUh70ttIrXIzh6gnWnaLMEgZcwndQqbH9D3Re7ldgf7UakQXMD+hfBWWVoSqGXcBvD2sHQsUEwSIWUsQrFHkqGeuINpxvXUfHhEBvWIspaswNrqV0Krq1OVVNj25KwTljLvraO8x1+31ENYWW4Q2TjdjymCiZMDIuF74/7dl8c8HIJA1a9COYhwoaKTcxduotLEcArrPn379sOcikbCPeyBWBdD8MSPOi7Neco9sfmiFL3CsarhsVC9kfrYp7inSnEKdloKyQCqOkNJ4VY8VY4WLWjGhtW8a4yNy7bhMiP5huWRztjqFyb/a4ziBFZTTf2ve8R0ApTuIotWNk3x/NjWe+3w1hlBUMFdsSbLq6Oo2oY52zCUQUWzNk3TfFYdtmUqnZVbNXHWHvQOa/5wWzOJ7zdl3BdVmw6Zt+cT7uixdt8CacKmxG2UFCBliIJDUeym8z/NNXRFVXHHgM6uwWnedu2G7Z4/KEj34SSP1Z6281whyLhbFWsz/9UlqfigEwf1vSzmzJ8HAEae1dSswxVfuEEjP0ET/ejP+bCjQ4F/cCNi1yGyinWHRzK4z1aP2BBtZac53YxXgzTw9CbXXdcO7KIegWsmEVlQWgZLRhAHaukyL7tsGoNmCPrt9m4FuZ8BBuTHar7Q/kUp+dAw/4sFC//8X7gu+Hs5da5x+KIjtTAUJhd6x+LOHqCdbaSjd4fi8+EXUqYMpasegkoUcBgQKrga1mXYZ01FTJCH8lCQXhBF3AySHaNs81Q8nYFpWbjH++UEtVycMhZDMX3Qu04YKrDsHPZp1wHYe0K7pfYgydkvhbOZak5VaElEIZdMhz7U2xKqvr4sUFJJTiLdUDPNbsywTNy8YSOXTX76rzeIPDIAjj0LtfelwYMPtReslkOb+xI7zAOZdGH6uQz/rEbhysbu0usTmjEoHMQbL5jJKUJpWbTFrbSG9URQXdm2ITBYKcEIWoValvVIpzDFf2SHGwxFN6rcCZZheOuKhwZVsFwl6yHsnIk9oH29lCwgUu9TVsN9rgKHhfT/CB+oI8OQdCercU6IWuDMOuSRTzDu3ZCE/tfWNAUTh9rdv5f+usHNB4I2B1buUMhRTB3J4LyRdiRi3D6WfZHpdnwKoUkwS0zG3zGHUTKgsPFQq2o/XCjDPd+bB0YnV2JYo9QVCqWYYVmTwDZve++OjdDfEbCLZ3k36lL1kTYJBjNsHKwEzB0MMSPoSdR7IJ7qqtt2TRoKxUV3/C8XVMcaERFVuyLnz8c9k0MU8MhE+xOoS5+HZrgGhhQuLtAsAnLuiwO7f4x6gEmWtnartDwdG4equMh2hLBfRxb1hU6sOWn1ccoZoA7OHaZrgM67gvMduUB7UXhYt0ZD+svhicGYU1DuKNAslmTujwU1vSo6AU6LDbWtHAEqgyHZRWKdfm+IbF3AkpkbxSAjYebJwgSs8ve8NgvRH/6hZTFvggcRsClUrBIHZkZVdB4DRuj+bb8bQpwu82eruk6IXYlsNKBrU70ze38KXfsHlRG57zTr9O0X+JYX0LAVJsQc7Kwvl0PWj58hiX0kt2W1mVbf7GT+lBVp+GshPm3bk1hY4G6tAmTsjqhMBieWmChzUHmG54OEiGeEwFMMew5hvq0JQ6XRrU4XMvzMQxEtCpEWuHbutTdoDF0JxzjkdpAOH5sJOr3f+i4KNz/bsKdOWzOC7tCGLtJNrhpuurAGFKGzihcgSMDzmbYE4m2s3BLQIyuAlG4+dCULYXuwDHo+LOHbhumFgr6SNZLpWcjtEB2FtguCAcFy0dY/9aw1SdRwV1Cj0OPBHfBmo0FB4UbcO7K/mAcm1qgrg+AFTfhZgt+5LsOBosiLKJg/WhoPczzwuJ/dkkcbt8hZhOMP2RpRch4ipDxFOHcjAh3PAn29F9zOuzbgYXL6Mw/W2FAXAwD8YLAnK228+2pQ8vAttnMh4/7LkeXiTNMMIPLblyIZRMaabiySrPYqOuAOAm0hilb9nS8a03M0ehqGXZxas4fmm29/xBjfHB1EqvgLdm1xi5SMWAAM0+JRuiQHIxVWHjQtvtY7A+oLSw3Z6Nk25Y8FhgVZyYa49U0OhXIBWp9MHMeXmsiI1Svi2dSEuDbNWCoyR5+uBzRoyYLmHMsZDHoYRjuw6nLBq32+JY7xxUvCNA7cy3R3hgWJnQzLNwNoNniVNvJ8NwarIxj9zqtK6tgoV0YmrBLmu3jVDXDgyRyFRXwcxMtaj+EyuCOS7NHNu2mud1vP5UoRQjjATZbdWlMnIaBNSaS9bstiiUgthIuM1G6/xEK8tlzlESGQ0LgRLGOl7spCeLGbEVbaDw8EQV9Alud7O5YGtbXK7j7Nawjayt3gQHO2sMVQ7LISVv9h6wvh6UTsq+DCrdq6JCC1uHKL81iK5aDnSLUrQLQU2s27rU9xJ5SwG2P6G/VDKuTDjdm6sR70zdLwZJmwy5yRE1VhFSEOyoVmzltq8aOx274ZtB5LILls7BdWw1VL2GIp9naA9d0MG3hGhRubzPsNRptZXVKHQ2BiFkAfHW40tSwO/62Ys7EwXnInndoq/P+2K4HtSQKHusx7KGotvr8iE5Qw+WAxS+T1xLCtLZg07z4dBCsVugGL1yqp3k3VJdUHgFeR6HZrfKlMa4gULB4QbN1ULYD5ix5dMcDmyemKvzVIqooTgnvrnLBNYswJDJsUYFtnljPIYLHnkmzffDrsYKVUJrdK9pO2CAe7pTZLUBb75/2+KQyrCrm106kdnhIIJyA24RipJALFYv+LyE/IPo9ZPhLmPaivyCyd2zh8iIV7nRWoe5JhfuGVdh5qlBVrML1wKrHIftrnsISZcJiYNgLdIb38sGs3ipcpssWRdj2GOyX8NyhYgGx85HebK0jSJPTcQfnoWQfmGMsuNu3HIbsENFkIxVXH4j2h3BjzFZWDfJo8OhTAGFCmZ5YBPQhFAqLYB6iv/MrmIcImXYRKn/UojeYYEI6/Ag3halwV7IK1wHqcCe3Xoe7GHpbYutD3GvZA6hE2Al9Hpssch3EDWFljGbxxCfyTAks0VYBmdJs/fsQVJIwXyJZO2IPH0hYXCDZsCVqP7xiVEe3PnHT4NeiRteCQmfPrtbU3AFCs5W17MyBUAULnpIAfHSJHOcrfq2L06nckUWusDyFXpl+vr057U+lRX5vvnr/83//+/8DDvRTK0XUAQA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA8W9bZPcNs4u/F/GX2dnm2/9km9ZO3s2Z5PYJ/bmfqpcqS25W57pdU+rI6kn9p3a//4USVENQgBFqSfJJ7dHIAERIAheAKnfburq1+bmq/e/3XzaH3c3Xyl5e3MsHsubr2525cfifGhvbm/O9eHmq5unot4XHw5l89fuyd1D+3i4ub3ZHoqmKZubr25u/nsbOloao5Z9X//+d/vlVI509aKnAj3e3pyKujy2QKALE7GQuufx8rC3dFk87nriJKu7TiKG46tqe37M5wnIr+H6pt4/7tv9U+Zw3kH6a/i+Kz/nvmlHeg23l9X52JZ1rjp76qvesC5zB7UjvYbbd9X9d+VTecjkCMiv4dqU7UTGcYuJvOe7Aci36/cvIlOASGZmIL49tu/yhblQX6fy4/0EpoB8Kle55vxi19Nf/Z+TPtyIy2qwrY5NW5+3bVWnunoR09FidxIxg7TfJRm4x5d+22b3l33zl1O9fyraMp/Lp/JLko1/fj2fpi3ac5Nk1ZNcz61o22L7YBeZ74tTkimmfAbep/0/Rwa1J3kGbuf24V31qTx+e/xPOWqVFPUsGZL+LIvz3UiU0zUeSswMxLY67vbtvjqmjSwiewaz/nLcfldVp1fnurC9pg18SHy9BHW5rY7Hctu+beuyeHxVHoq08TENnkOStv7yNrxjhhwE+TNIcdqOe/oXkOoZrKBsvw52mraAmPCPmXqQaYgg5Ni8iyRlXrstmk//71ye0+wh1fVDfaqrbdk0++N9kmlE9hyrZHkqDnCvQa+VF6pZPOVCX+KVYtuGFgm3eiHKjDEiHrsyi0tENoePX2UzFuLZ7zHaf08yp//tQ3G8L62z+r7apcdqQDqHn10pRpeSmX3X5WM1Ysg9yZz+78v221fJ7gPFzN7HoqueZE7/++brbTs20QHRzHd4Ox4OQ6qZXF6GYGeMESScw+tDXRW7bdGkF11INctyz8cQL6TNN6K73hPX5+P/FO32IYcxJLye80Nx3B1K12dAzZofy+ZUHZu0hY40vF6yy5LwrUWcjsUhcwUB5M8hhXXqmRIg0uu5WyecxRsRPpddvPRx/Dd1PbLtI8mvl6I8/mLjundF8ynJPqa7nm8X3P0AgdhEEPgDRmEn8MXwEfLb5fH8GHj6R0kgSVzi9lf9hNiN9fYipk15zk48kuPX2fy+nssNj9Zw/YEs+6e5YzZw/nxvL8gFYPgKFwlJjkO3n2BJu/48nuvoJaMg03MMf84dq++L4xl4JaKTFz0JLWwvCNn/j2VxaPePSTFfAKJreLw5Nw+vj4cvWbwA8TU8LdXrjx+zWF5oszlKs0Rz5fUpBq/2dr34WGx7n9YRpA2Ag3aTvQ1A3qHNBunyMM80NwL9nM6QhT1HeCcB0BwxkvDLROZ5GGjoIxsKZUHJtHhJeHKyhhJoYFqMEVxwhiAJgHRMlBGoNEeYi2t/VW2/eSpRvs07Fvgoezl0y+9LhzfgRX3Q3wtMTb9EJCLJtYsi99UxlzPVYi53axcT35toMZv7sTg1D1U7zvRCOJfXd9W2OHiRR9nFtHM5/lg+Vm2ZyRIRz+X57XHf7ovD/n8zNBnTzuXoorQMbhe6uZz+dfw1kxeknMvtTV025XFb5s6LIf1czn8bgD8cz7+NAkCZ8yKf5YB8Ll+bDYl32hxLSDmJGwwKgwdxdNRyFRHkB4VcuDLs7kUyNInl4wKR6lxvc9n1xFcwfCoO51x+gXYau9zwj2M4FvLF7byM3Oji1Sif/V0ztkARcoxWVNVPZf22/GWWPKDxswnUtfiJ3SDkjtJP6a1ClmhwcoP1mp3fmOb6KU72mJ7lA0EnT3Sa6chcz2XLTneaa3rG5zKti19RjDTKGDaZzBwaDoy6WMsZEF1vOnSXadsZyjrZeBi2I9aTzZg1H4Zv2n6y2SYNiGE9bkEp9hHahHdjrB3RlNcbU6LftEUxok/Vbop/WsWjAkQRHN548qEcSfkMMR3f70hwR4s+OehK8B+JvsYEgAPd7dTY4YXPrx/UQW/poYyEm+wAh8xGfF8OO1ZfQ25pLTHMckNkht1YhBw1SwbIW4fIgWKUbOZ3oGmuFCPR6Knbb88QBjSdLwycMT3ewM6ZmOL6WUP0l543SMTJM4diODJ38liys4fimJ4/LMPcGcSyHJtDqOHsWTQmwPg8oiS5YiaNCjQ6l/IEgrMJIWnsnKLorp9ZbK/p+UUKPXmW8cxH5toU9uyM47mn590I89zZN8J+bA6SzWfPxDxhxucjL9UVszJTuNG5OUU4OENB5oCdnZjm+plJ9pielQNBJ89ImunIbMxly85Emmt6FiaYgmoYl3i97LvI+iuaKDeN2rUbpEwSvb6AbZgdDC04XQu2b7YzhEDNZsoRpacv+65hluPybEq9FpWJQj296OnYbAmQi+X092J/yOXW007jGI8VN04T6wBtWSopd1QB2FPxEqdq/9ocLoBqFpcf3bGBESYXonwecrFZCSOBP9+Vn+154Z6V9arWDXV/T44+7i1k41Bn4c+T+npXF8emcDON6hM/TluJjOwtvmIh1LuGB8mecg8wR51lHWHu5cqoQaO55B8wHuPFHDGO2U06ZDzGsTq1Y/w6kufg5k8WEWdrkNouZM/Dtdx+OlX7Mdt7ERE+B+fDJScyNsqI9Dm411U19saWBN3FcMU4H6rj8EwHGuKOZia/rJOjBMexnUzfxMs3f0Aht7uOPodl5tZkzIoi9rDRM8hQPrmCeRuMjUgRUz6HaYEeX3/wmfZ8GUCLZ3GZx8P+WPpayVHfiWifg3+uLfR0zzbBH/ZNW9Vjy+GFKnvBnTGtOy7j98lcmnVycd6rOP7ruKsmsr27NMtjP/FinWlShD/oqeL0r8EPzo/lrMHpmv3Jg2OlGL84IDE47jWYwTnPMJvzn28zZ2Aw68ljck5YSz3DVOo/305qYCTLyQNSJyxk352c/EeWAx1Sz9u57Jt/nXZFS100gRhCwpkLRXS88Wy7Gxv/nij77eKjq+cPzbbefxhjA+nmcTqdPxz2zfBuBrTc9lTzuOybt8Vj+c2htESv65cP+8Pu9cdRzTGNnkOL/g4Fexqt3H2Xv5NJNHsOqYrT6fDFd/mm2A6P7cbCDKnnacfeMJC7jcS0V3DM2i7HlPO4PRTNBBUPqedxLY/NuS5fZuwbY8p53LZ1WYT6sgzTIchneqqy/ToDrAJkcz3IN0cLHb4qn9qqOowpkSCfbanUhSYDI00dmczgwVw4MmAzcuVIzryzZvbj+GYfkc7ml8fqOi5F/aG4L19Wh0O5HWWGia96s9cf/pPBEtHO5vh/vOzfEdeYDThGtM/A8e919ZjjzNhG82Roq//79vUPIzx7ork83lZ1W+6yOEWkV833zOk+f7bbYfl7Vb8riYt/hgN4oZzHzUUjgyOYicgl5xRmbrQ0NpaI9Gp++eyu4+ZKB7NwSYL8Gj3mrEcx5RXcBim+BD9AewVHNhGY4Ey0mT3/f7K1F3/78qZox7ZeA+LZcdrrCdguQT6Pr8VpJ3EmG8zU9G4HOxrT8YB67hvbLeIExmSD2TudN7jQi93lvBmr58qw4++/ZPLDtLM55vN7Tm55yyjZ4GreGXHCm+xsWComKQ8fs98zJv49kyExs7v4v38RPcS5GEc1k11ll3VeKeZ4kWeevFMLPq8Ve7T8c67Y2A5ftw9l3WRbIiafiZ9kZcg6qmuSjhHXj/tDW9Y/lXWzr44/0RfExxLQLZ5Dlrw0WEf1bCOQkV86P+eIZ6Rv6ud8v/uytRbzti22n7JNmmgxH6Uop3InWszjzl87G/Mcv3g2J6KeMIkI8ny+8LCuR6aPHy8mBQ+y9k/zi9Ufy6Yp6KPHqLsXF1JadiAcWx9X+qvE6GvtEL+Iei7Lgr0MDnEr0re/jTLyiyxz3QVmBonnMkzer4EZjt+nQTKEtjcoFQLswrN8uzvCy1q5nl4cUx/M6gXiypyi23lYHmXyap4xJtvq8XQoW3ICxXwAZTar4fhHVc4DXqO1zrEFDZK+fIcZmV8gIMPQbRyqz+R1e5gfoJ3ALvesFsdtrLQRtOsF5Ku/7U3Df79A577m2/8xqaXkWwx6Gfs+YCcFL6a7nGogZ/fXawWF3YxJGgThRX3ZTaKBtJcH1wqMehqTGUjEi/2v43CueW7gybWC467GJIdC0acM3u0fy3f77adyGFBdHo2chwBBUzUswEDdvKj4W3OBMNzmpq4e37oTCqN8ItIJ/HJPTmB+OWcnSIZxBXzxeKrq8be70OXsKMb57sqD/VYmUSaMOUPK5+Ht4jICDMGcL3Sz+aJc1rev3rY1Ve+FWUekc423rTJNFxDO52W3WdlvFxHP5cnWbWB+o5Ub47zuy/Y7PwW+bjLfkmxyPf8JfK/j9yp7iiLiK3h+nTk1I9K5/IqPOS8XqOZyKX85F0StD2bTk83lYzcDRT3ESofrRqCbxAkdQuyJkIvpDiGix9fGIWR/Y8HIQMbMJXCc5R21GqZYj+Dcw8UwQwZ6XbxCCrwsZshArZDTJMCGhR2AF6L7a3ofCqLMNJAWPU32mRubDXvMCs9iMRm1POW+xIunKVA6xxuvsDmMPdm0d0QIeianQHgFr/s8TvfX8nksPnMrNsEuor6Oaya76/i4VfF1/c0vZ+LDVARDRH8F511ZnrbVaVjPSnAFtFdw9PmqHH495RXcmv3/DhdxatJ5uis4vberR9FW9c85/P4dqP89g2vs5F8HGD5KO3hXHz0bAQJQTFJ+blM9D55P6v1ldbZYX4oBRTKJx9d1XXxJcRgSTOrfV+8mR39IMU0HdVkmdYCfTxuf3e71iRqW8Pdr48y4o7EA8yIOs3TncrjLYzNWLQEL8VLcTqkivFxue3sRSha7QDmZ3/BOFnvkoylJG4gfXmsIRG9j1oCkyzcJnlfaLlC7ycaR4Ju0kEl84/u8RhmP3eeV5owNxl8ERJoLfHStsQz6GjOVSK58Q+H4pM0kajXZSFieSROZwBNe3zPCMvUNuQkcKc/F8kw7rzRXbI5vy5a0xf7v1xpi3NGYFV7EyTdBkkPa/i5NJhsfzS1pebnchmZHM0vZXIIXVv33nB/6/tm80PfTfND3czwQzSOt/++v8D4Mv6QF5POry6d9dW6+JfwBxxg1uVICyhMxnNN+KMVxkJrf7Wk3dHlwdYI+7mk0R3+RKN8UaR5pUwRtJpsiwy9pitn8bO44j19HeSW/dkT3/WjyV35k86IiQIZdOvpLcZxtlNHdvolbigbM0/coF21b7z+cW3DwYYIUd1HzSQKNKGNbHdtycGdknlCXtldKNIiL2i8HenUET66OjVBXo9EREGpCfERzGYmQQKPpMRLDMR0lZXMkPBPHMema8jkOfBM7prxzyudGeSeO4cgHZVI85xtoroMasp/pofLkyHFRnEjjHsHChGycEj+8OrU87G00sRxLl+8deF5pB4HaTfYRCb5JNzGJL+EpEnyTzmIS34G/SI0y7zIm8aS8RoJt2nFM4tycDvv2u/KpPOSzj9o8k6bfTLIy0OJZND6Ne08/jzflnPiQBT19Dvc0NXTBAk5zULNCGNxwlouaFcpM48w4qVkhzTTOpJuaEdpMf19msqTeeXS+THnvifwzZut14V2K+binvjbMG+U+HurRYswM9/LlyQn5UqKNlZ/1vb+rPK7+HJKCvp5D4kvxxOvT2/gLOf5TFOHP6VI19J3mVB8vAgUtfi8G2bv/Ymuy+55kTv/2kG904JriAIjyeYBivje1rXPcA3sIVSr9k6sOjMS9pM6LXCRhendWYy8M+9uXlrjzAnEaUM/k6o6NdTTvqMsoEF+CfibnffP2fCJL3BBLSDib17fHtrwnCrEGvC6E+bxySz0Rs5wyT4rdcJXK0RwkzCnyzOOcxfUKjjmX4SGWI7fhZXBJXIc34JVxH17We3HXExAvN3YvwSg/tgwSMRstgcxxL5le5Vpn8sP5saz32xxumHj+u/2UMwUA3Wz7yFoTLmTz3+iluxh39/WoISLawfzeHx/Keu+//TZJAuIEz5A1fbJuNk+bA8175wvl83HvvjmWxR/SPp8Eb6pmb6sqM4VA5M8kR5Oth+Z30EMzQQ/N76KHOt64MLzr4ZbkKq77Bn8Xj/Wa1LfxpvOOAbGe5iditx0/nFTu+z91cTqVu+72fNRv/HBSv3ahpzsFTyb3iK5RvnToH0zuz9V6E925v2efhOpq0geG0f39WU4/wb6yAuIg1ORwOOI0NRjO4ZrB8Xm4uWT656GXwmPZ4utqruA4bgkvLkTzOMZuqf/8bpppRJdrMRkhR8RkGHBM658OEzGLdJCYyWXc9BHlLG77rph6TDc91SwuqW1RxChnU0TxIk/pUAsRfJTtPt9Rc9T+8VkcZ99R3mUeVpaJ7iTiMMGXpHiNMJrPJdd5XHhleI4UD9ptXLpP+4xUz+Vunxqj7vH0fndldDPYsOeeYIbMj6d2CCcAobvn03tu7PnvL4eU3IBkev+uOPZHe9ncu+pN1fxI3m4PrYYkn8731DV+V33bd5ngy5BP55u+bOUyE7OuWUnwcfEOcXVFz6EnyOt7KYUG9y6Ux3vi6vhL7z3BrJltEzt/+xIXd5NTPCa8hteILwFUc3Seoe8rdM3gsrD3JEA61jcXBMQMxiKAFBf/PSg3q8aZkcSZPIfHjt9UDX0PCnx2dSnIoLPRQpBINO4Qwi6Xz91+l8dqXmI8wTYjJ07wt/Jy8dIAIp0gxN2WBE0zxBlJgVcfP8J7MKaI1Dd9Tnnq8lBY6Ob1NLkGzWaZTHKexUstIZAjyA/z65JYuOsy3UN2mB86ygvzrSzsgSEX75LfI7twiamyAvEET3ZrAd9qStCf4NUm9fCiezyDS/bWAg9icmuR4MFsLfruR7YWiZ4/nPeH3YgFQJpZsr9ND86FYlbvP1S7cpwDoJo3/jaiS8/sF4hsOp/GblqYjyBd2MRUM7mM9T+rZ5+KYHZnff8x1XQudr/7bffV5AQbRHbtPLfdjaomIpr3Zn87Hz7l8YGE83iNcLjqHTKkn9V/W/1/33+Xcuvd8zk905sW0HV60zLSN7uPiBiMbiBGuNi6wzxOMeUsr2hXBUtivWvaMSLK6dwczvKuGpkYMdV0LrY6vENUElxiqnlcRhGmiFs2wDQ2gvlspwFbqbfNArYurzsJ2Mri+yaMYBZbSJ3JdXimI5oRl5Jj++dJydsugUx0B55cCwbgrkbP2AOh8s+DMFxGTtmDRrkl35l8c85FZ3PfPuwPu7ocfKSA4Q3IZ3CmdrOUwXV/fg6sKNs2elkmHBQi+h85IRRazDiwQTEbOanBcqNmPvoe7mXu+wdJZayJnqIEri+Jjx/mng54iY7rs329eDlyOB8JR3KLdwE8r/F9wBinH4ldB8/vx8zdB8l1kCH+8dW74NbdHftD1JYiuXZCsn2OfgyEknciqjnGPAPQJLuYgWaOijICZObJQU3yNHY4IMivsKI/pp3hOojsRaqbFz0JMzReEKb/xJdMII+Mr5gM+GTXicF3ySkTw4y4vAXFYE/WOFJFTEkuxPflKG7Mh+Xmcg3fKR23rRcD0uu54w/4UWypL/dN4JdTvQW4jRRvjfX+fcYLRWRz+DwUzes8Y8GUM98qkxumnMON/dIKZDT6lZXR8XuTb/YU9cxxnMCVop7Dtfxcbs8j3v5Ck8kh67vUBIe77t/+S8kjLO9QO951WrgqbZycCHeXxlNEGc1nPpW1vT52plBR++vkyq/ngZJlVfSkTY/9KFTMZ2oMoKIQ4KmsYanxU1Hv7QcOm7/2z+bH01xnY4H0RSzGOtzFB/iL4yPc7lCjEdYTCyOmMO9LAZbZYsTCc5v/yuv6TbH9lC0YavTHjgpkHkZFrvNHJRI+YSszxmXQ7I+3l+HYCDnNYqaMTjNDNt65/v7j0vSDoucMSsPPorBpzR+RuM0fPYd63mFE1IQRgaInbGT6mOBWf7ydDMZFTHAtsfhc3OTOi71D54XHZMOt/tiRibj3TneCxcTiMyPz4Yu70QWdtBuTDbf6Y0cm4h5GxuQPTCx9emDeHotT81BNHhrQ7k8ZnMA/DM9m8vD0b/A7C9ZP+kX/i69JHRM2/Hlk01LNV2hS7rs6VSA2Tfjxq9ZdkJnvzia9COz+D3ibru0/QMFB5uv8I1F98DvPsX+Un/uVfPIwWbmZwXiwxRvTlqqoyR87GBfW/SK1yB8NIDgb5/2j/Iw28uOxFmzzR8d5Pe/eOiYMCBSdHZF/7Y/tOj7NPi5W1OiPHpML835QJuyqI+HZUekx2QlywTZ/9Jj0vPshmbBthKKP4AwgE5C70U+kBn5vjOHbV70fmWQhveDMaLz5MHk0oiaTR4Na4CaLMGz3pyx1WDXTI7Qx9YSgfPIcJhr+OdsRPJtX03ckYzP6CX4NdFq4RDb9YwdqKELv+CZs+IkXScVR9Hers4Ia3PRPiKvij8YGvzhhmSBehCq0+q66j29A96VD4c+5xVXv6v3TfnD5atTLiwsN/Qq9KCSHV+WH832y/0Axp/fo8nGq845gTt//U9THZN8dwZy+v6lrYNxU54FiTu9/L9oRnQaK7N612Gi1AHfwl+3ABB+r3flQNn0mHBCQdgjyZd88lcfW34D7qnx6UxxBt5d5R1AlDZ1m8PbVP9N9v331z0nFzk6Qd9XbV//ERRatv/4LP5/U+9tX/7TF3cfyQPc+eD6p97+fD4cx+UmayVzG3oOkSXLRwMk8tVV1aLAp/jU8mCTty8O+HFyL1vfknxIdggnUyzOpPpJiMZbRRW3Yqkj3FISxoxzvQJMs1pnw1wQJTmM55VEJ8m+967tKX3/3fDrGfLIVDd8hv1h9jG+6cJ1sndb38OOioyKkvjM6QwKqjH5UhnRJ/QwpuHrkUUnG65HzpBleD3Zsi/2RviDsMqMiqt/X2w1Z5Xu9+GXGDzcRX6vpO4M0v+sbDxhlv2/0GuNFwZl8U5ea0I3TNj/n3TMd0AQpusZT5eibPZ8kDTznnytHkzr2P0eKpD9kxch0iBPkqAfXE+fKUpOXFV8rz/Dm4OxpQ14lfLU8R1vW+zRdmr7ds8ryA7z4ZIIsP+DrUK6VhTmrOC7M6KnFOdKw5zbH5ck4wTlHol15GnxkalyY0Oo5bWb4Re8ci0kdS5/n/2cMR/I7a7OkqKYbyClR9J2W4efbbvi/+i1gzzdf3cg7dWfrST7uy8OuufnqvRfu9mZbPbp9xM/dMw84WgpP8tfFze37xa3Z3G3W4uefb9+HFu6B+4MjEze378WtlHdSmIhMRGTy5va9vDXizizWEZmMyNTN7Xt1a/TdeqUiMhWR6Zvb95oi0xGZubl9byimJiJb3ty+X1Jky4hsdXP7fkWRrSKy9c3t+zUl2zoi29zcvt9QZJt4eBfs+CI9OEWQChOxKmzB63shSMpYG0JxWhOxPmy56Hshb7W4MzJ+HRGrRNihF+pWr+82G/RCsVZsJfd7oW+1uVMCcY8VI6wChKEGU8S6scWK78WSfPVYPcKqQazIPmMNSachUuMyVpFk54pEk8VpaEOJKWMNSaehBck8VpGtRnwvBUkZq0haPUhJUsYqsknf91KRcsYqklYPUpOUsYrkmh2kWEPSqkEasstYQ7ak470kta5iDSmrB7kiKWMVKefQ1iQlcmlORaQyVawiW2L8XpFTWMUqUlYPipzCKlaRrdx4ryRJGatIWT0oUpkqVpHNAL5XpP9VsY6UVYQy1BxWsY60VYRakj491pG2ilCkjnSsI20VociZqWMdabfukDrSaOVxS8+C8ok61pG2itCkjnSsI20VoUkd6VhH2ipCkzrSsY60VYQmJ5yOdaStIjQ5j3SsI2MVocl5ZGIdGasITerIxDoyVhGanEcm1pGxitCkjkysI2MVYch5ZFCA4CIEUkcm1pGxijCkjkysI2MVYUgdmVhHxirCkDoysY6MVYQhdWRiHS2tIgypo2Wso6VVhCF1tIx1tLSKMKSOlrGOllYRhtTRMtbR0ipiSepoGetoaRWxJHW0RHEcHzEsYx0tV+zqvox1tFyzq/sy1tFywy1cy1hFqwW7Zq9iFa0EuxKvYhWtJLu6r2IVrawelqQhr2IVrZyKSENexSpaORWRhryKVbRysTZpyCsUbVs9LMkFYRWraGX1sCQNeRWraGUVsSQNeRXraG0VsSQNeR3raG0VsSINeR3raG0VsSINeR3raG0VsSJ1tI51tOaXo3Wso7VVxIrU5jrW0doqYkVqcx3raO22RKQ212hTZBWxWt4qebdZIMpYR2uriNXqVqu79XoVU8Y62lhFrNa3St8pJSPKTayjDRt4b2IVbSRrdJtYRRunInoDF6toY/WwJg1kE6toY/WwJg1kE6tos2SHcxOraLNih3MTq2iz5ocTbV2tHtakW9rg3atVxJq0Ov8M0gr2pfwzSCvZ1/LPIK1iX8w/g7SafTX/DNI6dZHzxD+DtLzC/DNIu0rIi/azC4c2kDPQP4O0m4QMSG+Cn1tiADxY3azpTTWGHhzAwMiAwQeHMTA6xviDQxk4eZHePARBQioYgnBAw3p1q5d3mzXCIDAI4aCG9ZqmRWpzYMOaXF4EBiJEQm0IihAOcGCGDIERwmEOzJBJjBhJdsgQICEc7MAMGYIkhAMemCFDoIRw0MOGxrcQLCFkYrYhYEJI3kEKBE0IybtIgdAJIdlwUCB4QjgQghkyBFAIB0MwQ4YgCuGAiA0N9CmM9Cl+yBBMIRwYwQwZAiqEgyOYIUNQhXCAxIYMewQCK4SDJDb0woLgCuFAiQ3tqBFgIRwssaEdKoIshAMmNrTjQ6CFcNDEhgxSBYIthAMnNmSYKhBwIRw8saE9icYgrUNpF/QcQuiFcBiFWNDWgwAM4WAKsaBVhzAM4ZAKsaB1h2AM4cAKsaCVh5AM4fAKMn0gEJQhHGDBINYIzBAOsmCQaARnCAdaMFg0AjSEgy3EgjY2hGkI45VHW5vBILtXHm1uCNkQxiuPtjcEbgjjlbchkwII3xAOxRBMUgJBHMLwDhNhHMIhGZwQCOYQDswQNt9BESP1LX1uhDZkBHYIB2kIQRsywjuEQzWEoA0ZQR7CARuszDhP4vQnaDNCwIfwyAc5ygj5EB76EORuSCDwQ/Doh0Dwh3Agh2ByKwgBESs+v4ggELHyuiOxGoFQEOGwDqZfpLmV1xy51xMICRErPrhEUIhwgIeQ9OxY4RSX05uk3TECRISDPYSkrRhhIsIhH0LSbhPBImLt3SZtxQgZEQ7/EHSKRiBwRDgIRNBZGoHwEeFQEEEnagSCSMTaJydp/4ZQEuGwEEGnawQCSoSDQwSdsREIKxEOERF00kYguEQ4UETQeRuBEBPhcBFhUzeEt0CgiXDQiFC0BhFuIhw8QmdlBIJOxIbPtggEnggHkQhFWwbCT4RDSYSiLQNBKGLj88u0ZSAURWy8/mjLQECK2Hj90ZaBsBThEBOhactAcIpwoInQgkyKI0RFOtREaDo9iyAVufCRC52hRZiKdLiJ/UIlsbeQCFSRDjgRdNpIIlRFOuRE0JkjiWAV6aATQSePJMJV5MJD/qQGJQJWpANPBJ1CkghZkQ49EXQWSSJoRTr4RNCJJImwFelLOuhckkTgivRlHXQ6SSJ0RfrKDjqjJBG8Ih2EIuikkkT4ivQFHnReSSKARXqAhU4tSQSxSF/mQWeXJMJYZFfpQWsQgSyyK/agNYhQFunrPeg0k8QVH77kg06iSFz0kaj6GJR9SBYIkLjww+MsJBAgcemHw1IEncqRuPpDGj7sk7gAxKEpgk79SFwD4uAUJvCTuAzE14EwdTW4FMSDLXSIJhHcIpXXHm34CG+RDlMRS9rwEeAiHahCZ2MkAlykA1UEnbaSCHGRyiuQniQIcpEOVhFLejAQ5iIdriJWTAURUqDyaVN6kiDURTpkRdBZLIlgF+mgFTqdIhHsIh20IuhUlkS4i3TYiqCzWRIBL9KBK2JF7t4lQl6kQ1fEirYMBL1ID72saG0j6EV66IWOyCWCXqSHXla0aSDoRWp29ycR8CI98LKiXS0CXqRmd38SAS/SAy90Pkwi5EUa3nci4EV64IXOnkmEvEjD7v4kwl2kx13WtBkj3EUadvcnEeoiPepCp8YkQl2kR13WZMmVRKiL9KjLmrZihLpIj7qQOJhEsIv0sMuaXhkQ7CI97LKmnT2CXaSHXdZr0nMi2EV62IXOnkgEu0gPu2xo/4ZgF+lhlw0Ju0gEu0gPu9C7LolgF+lhFxrblgh4kR54ocFtiYAX6YEXGt2WCHqRHnqh4W2JoBfpoRca35YIfJEefKEBbonAF+nBFxrhlgh+kR5+oSFuieAXycMvEsEv0sMvjDUj+EV6+IWxZgS/SA+/MNaM4Bfp4ReOGOlv7UuHaOeJ4BfZwS/k1Eboi3QAi6TRfonQF7n2Rce0MSP0RTqARdJov0Toi3QAi6TRfonQF+kAFknD5xKhL9IBLJKGzyVCX6QDWCQNn0uEvkgHsMgFHagi9EVuvAJpY0boi3QIixS070Lwi9z4CjBagwh/kQ5ikTTMLRH+Ije+cpzWIMJfpINYJA1zS4S/SAexSBq5lgh/kQ5ikXTxvkT4i3QQixS0BhH+Ih3EIgXtjhD+ohbsgQyF0BeVKGhRCHxRC6++za1e3BkpETGqKHf4ipQLCjBSCHxRDl+RNHKsEPiiFqz/VAh6UYmSFoWQF7VYpd4OVZcv+Cy7QsCLctiKpJFuhYAXxZ+lUQh2USKhOoS6KJFSHUJdlEddyFyiQqCLEjqhZgS6KOFPbdD1+wh0UR50oUcCqc6hKtxIIM2JdWokkOo84sKMBNKcw1QknXZQCHBRPOCiEOCiJF+OpBDgovxRG+blEOKi/GkbOvWhEOKiugM3tJ4R4qL8mRvmNAtCXJRk93sK4S1K8hWaCsEtyh+94YYC6c6fvpEr8u3w+Rt/AEeuaWKkPQepMI5icAiH3fEpfApHed1tKGhN4YM4Dk+RilyjFT6Lo/x5KdoV4+M4itcdPo+jErrDJ3JUSncIalE6pTsEtSid0h2CWpRO6A4hLUrzukM4i9Ip3SGcRWmvO3rxQDiL0rzLRCiL0gmXiWAWpVMuE8EsSm9S6kC6M4uEOhDQogxfDKgQ0qIcmCKZk2IIaVEOTpHMYTGEtSgHp0hFIhcKYS3KeO3RjhChLcrw2kNYizIJ7SGoRZmU9hDUokxKewhrUcuU9hDWohycwg0ywlrUUiYGGWEtasnXTisEtSgPtZBjjIAWtTSJaYqAFrX0XpM+lYmAFuWwFEmndBUCWpTDUiSd0lUIaFEOS5F0SlchoEX5Mz706T+FgBblsBRaeQhmUR5moYFAhWAW5ZAUSR8sVAhmUQ5JkXSqWCGYRTksRdLHCxUCWpTDUiSdKlYIaFFdnQsFWiiEsygHpUhNIjgK4SzKQSmMJSOYRfkqFzohrxDMojzMQifkFcJZ1DqRY1cIZ1EdzkIiCwrhLMrjLHTaXCGcRXmchU6bK4SzKI+zaDI5oxDOojzOQqfNFcJZlMdZ6LS5QjiLWifOEiOYRXmYhU6xKwSzKA+z0Cl2hWAW5WEWOsWuEMyiPMxCp9gVglmUh1noFLtCMItySArj8BHKojzKYkjsUiGURXmUhU7HK4SyKI+y0Ol4hVAW5VGWJR0pI5RFL/yRffr0NMJZtMNSJJ2O1who0Q5LIW/70Ahm0b7GhfRFGqEs2qMstC/SCGXRC74oXiOYRTsoRS7JNINGOIt2UArzcuh8uENSpM3cU8ToiPiCn3saoSxaLHh3oRHOooVXHX36HAEt2gMtdC5eI6BFd0AL6Wk1Qlq0R1roZLxGSIsW7LUyGuEs2uMstAUhoEU7MIVTNEJatANTGBmQ7sQmoWgEtGiHpTCKRjiLll53zP0K+CoGrzv6igUEtWgPtdCHajWCWrSHWuiiBI2gFu2hlhW5WGsEtWgPtazIPLxGUIv2UAudO9QIbNEOUJF0VYJGaIv2aAt9zFYjtEV7tIWuStAIbdHddSe02SO0RfsbT+hCA43gFu3hFjqC0ghw0b66hZmqCHDRHnCh6xI0Aly0B1zoYgONABfNAy4aAS7a17aQtxhpBLhoxdZGaHwHiodb1rQN4WtQPNxCn1XV+CYU7a+roW8OwZehOFBF0idb9eA+FM1di6XxhShdXQvpDfGVKNprjjZ6fCuKTrlOfDGKA1UYgZHqdMp1IrxFm4TrRHCLNl539CxFeIv2eMuanqUIb9Eeb1nTsxThLdrjLXQlhUZ4i/Z4C30CUyO8RTtQRW7ICyk0Qly0Q1XkhrZkBLloD7nQxREaQS7aQy50cYRGkIv2kAtdHKER5KKXqcUPQS7aQy50JYVGkIte+vuiaHUjzEV7zIXxswh10b68hfGzCHXRHnWhazQ0Ql20R13oGg2NUBftgBVFFzFohLpoB6woujBBI9RFO2BF0YUJGqEu2l+uwoQCCHfR/n4VJhRAuIt20IqiSx40wl30yl/6RZsowl20g1YUXfKgEe6iVyzmqRHqolc85qkR6qI96kJjdxqhLnrl1UdvixDsotdefbTlI9hFr9ksn0agi17zWT6NMBe95gFPjSAXvfaqo6cIglz02quOniIIctEecqGzShpBLtpDLoyvRZCL9pAL42sR5KI95EKf39QIc9EbNruuEeKiPeLCxDkIcdEecWHiHIS4aAeqKLoKRiPERTtQRdFVMBohLtojLnQVjEaQi/YHi+gSTI0gF73hIU+NEBe9SQSeCHDR/lgRXdqtEeBiHKai6LodgwAX448V0RXmBgEuxqEqdFxkEOJiFl599EVnCHIxC68+5j46dNHbwquPvpIOYS5mkSjtNAhzMQ5YUXT1kEGoi3HAiqKv9jQIdTEedaEPiBoEuxi+uMUg0MU4XEXRFUEGgS7G4SqKrrAxCHQxHnShN8EGgS5GJEpzDQJdjENWFF3eYhDsYvjyFoNQF+OAFUVXlhiEuhjB3k1qEOpihNcdbckIdTGS1x0CXYz0uqONHoEuhr+2xSDIxThURdEnag2CXIxkM30GAS5Ger0xFzwivUlebwhuMdLrjZ5ICG4x/J2yBoEtxuEpij7SaxDYYhSvNwS1GIemKLr0wyCoxShebwhoMQ5LUXQNg0FAi1G83hDMYhRbCGgQyGL8ESL6NgaDQBbjQRb6ZgODYBbjL5qlKw0MwlkMj7MYhLMYf9ksfQbaIJzFaDbQNAhlMf7CWfpYs0Eoi+GrWgzCWIwDUhRd6mAQymI0rzkEshiHoyg6s24QyGL4s0MGQSxGe73Rkx6BLIY/O2Tw/bMeYqHz9QZfQetgFEXn6w2+hdbwMw5fQ+tAFEWn9g2+idbwM25wFa1P6dEzGd9Gy9ezGHwdrQNQFJ3YN/hGWsN7SnwlrYNPSPzDIGTFOPBE0eUCBiErZun1Rk8ihKwYB54o5k5ihKyYpdccbe4IWTEeWaHPAhqErJil1x1t8AhZMQ48oWNnhKuYpdcdbfAIVzEeV2HuPUa4ivG4CnP1McJVjMdVmNuPEa5iHHSiuAuQkf5WfnNAWwbCVYzHVZhrkBGuYnw9C7nMIFTF8IeGDMJUzIq/ENAgUMWs+AsBDQJVjAdV6OS4QaCKWfEeE0EqxqEmNPRhEKJi1vw1VwZBKmbNl28aBKkYX8ZC7/YNwlSMx1ToKgiDMBWz5hWHEBXjQBNF30lgEKJi1vxSh/AUs+Y35AbBKWbN3+RoEJpiNn7K0R4F4SkmdVDIIDzFbBKqQ3CK8XAKXeBhEJxiugIWss7EIDjFeDiFvpzBIDjFOMRE0dUgBsEpxkEmDORoEJ5iNgkw0yBAxTjMRNF1JgYBKktfwUIX9S8RoLL0FSx0HekSASpLD6jQtzksO0TFfQzIfV18963/KND79/2XCX+7+Xf3pSARvlX02424+eq3/97eiIX/V3b/l2v/73Lj/90EOmG6H1KGHx2Jva7N/1iuwo/wl1VovlLhR9eP7DnqVfjRtbJnvbsfKvwIrUJze/iq+xH+El7FHmnxPwILe/jB/1Aq/Ah/0eEvOrQy4cdS+x86ENsErv+x6mgs9ux/bDruRvQ/luFHN6Z2c9/9kOGHDj8CcVCA3VF2PwKxCsTKhB+dPHZn0v1Q4UegCcNrwvDaCLf7EToMr2yDPv8jjLNdYfyPdfjL2nX438snpez/rFEW23b/VLSRxcn1xeT8iyQa7mDLyxc9f7vx8tEt7afTgYWvgI1LlRC1qvcRP3sm99JyKYPBrcOPDdfXblcdD/tjue0+Jg36NAb0KVSih9Pefa4UjJyA8mxY7h/bMh6BzRK08xOQa1fV5S9n+3V4wHaxAs3Xa675ae++4QtHHjiXzmiW7PifTocv24fieB/7Jw2Z+5mdbn0qtp+iHiQUY82O+KWHJhYADt5Cp5rvqm35NFD4ArbnR+90+NIci1PzUMXtNTSYRVL8pi3aM5J+A1snB7+ti2NjJ151JN4CTqIFa3q2n1+LdvvQtHVZPMaiQOtdsPO3rosv1amsCyvIcArA0diwnbRtsX2ADRXQgmKV6JrFTsfelnsxH51uav/0WJyi9ktofXzr/qOQ4GUlUJ4Kvl7p8GNpwtoTfPRmnEFb+Q+pRowUmCL2QAXTybl9KOs6dq8rfWm6TrVsq0/lcX/8Tzlw0JFddG6Ce5EPdVXstkUTWacGKgqjs+7+lewa8+FsvwxaxdPNluRc+jKcr/zwxQ2l9xfxqqGgNGashwf73UvQWCnQWLGj4BtXH+xoxu0FbD/CvJ9msfywC8M5nK4LymVZMBoIwfWwLY51uYumt4iWjFWIRCXnt7bF8XzEXcAJtwxrteRWjuGSY/PBFxPYcDOe0r29nfnC3Iw0Rb7N3u4FApV04+bLcftY7WLBJZzFbPNy++lU7ZF/h2u8MPxghY/pQs8KZ0wfHG5YnQ1iIiB22EmEmHXFjoLrZVsdd3tswAZOobQUsfbWcAxCrG4/WdDJ1JtjiJZX7CC73quTFS1y6Uswt5bsKLvWTflLHEzBYWI9Q9d2EAjAKIS3y0N1jKMvARc/wzKtHu0nauOYExrzivUB1ePpUMYbBHuj2qWpHmv68RgvJjBQMZzv7w0njpZgsJRoeiy3aGuyATYn2D1G13RfHf0kjrpYgoV0xZoG7mEQqa1BN4KNl7fVsWnr82ApBjYmugXUXobfbbnDbjxsce15PB+BLLpJosO00WG3qXlHUB3bYn8s6yf/lXngUgywALNmzbU6ttiVRHFe2BVrNjBxXXyOu1gCXepFeB8RXlUn3sfhLXXsk6E3Erw+zkfUEgxBkGEhww9eBtdPIn4G5mFv40l2M1CMPSBzGRvBKqbetW1dlsdqV+533tDiFRYGbGtuN7GtS4Qd2OorsDSz4ruGzHYQrpKC3c36LnYFCg6Bc7Hl+J2FB6iF3Vz63morz8eqtoFT1O0K+B2tuLfalSScEu0RRpvGgEoU6Y223VubOMbggNZQk2wXH873cYwJtnE2pce1K0/b6hSBCvY0LEAjOpek2KHflR+L8yEab2B8C7YVXpXsyaXLm7Krw6487B/3GICBkYVcBixzxc3iXXlq493rEkbULPKzKwfbXqDhhGENt72bDVwJ+MG1LUm7MHCiss395+xj3w9Ngw0cdvuGXojh8sdGSSRQs4BrOOvlQ1MMpEMN8VJX22FoBiMl+3UfvumXI9XcwDdmh7ranh/RG4P3DTEuq6pyt0er5BpOh4B5s1PZtv9wPnyKXRfcOSy5Nw9NP3w5FfG0kPDd7QGNRAdEY+i6TOrFKQOXMOTTbGhsmxNIrgRvriQXnZSH0v7/iPd5C/jabKxYPp7a2HWu4LIrOSMtj7+cy3PZFk2kLQjfsXF1eWzOdTncR0A/JNh0gYOeUUQOPeeKZYtRKVu2AfYQYcO25CIW1wHeSUDg1rDGZZ1BU53rrQ3GT8WxPMQr3QaudOybX3ppdp9ifwh3biwu5jsYgq5RRM9PsUvr6kNT1k9o/YJhl/2uEdPL53J7RgGbhNKzuPHHoi3QsEFrY3fKH/cHtNTamzVBgMtpzTd8Kutmb6P2wT4IbsYkOz8/1tVjPK0hjhrwAqX7HyFaYb2N7ZGOWxV0GUZyfvbSQbyqQskMO/Vt64GfVGAsVMi/KtbTuz7qsimPW2QKoB8juJlgmw93DPYkBZiM6xB5pzQTdiBoIOB8ZIHFj+fDwc3ltmp2nx7LpikQSBijTOxgnA+HZveprVxnZD9wVFgHd1/UH4r7clsdDgjxFSrKsnEz5b6Ml+8FNPB1ohWVF4XLrlxxc+y+bEmMFGpApFgzUCVMIAsWHLDt7TKEAX77zSEwXtxMsM0pcFFFW7VEY3L/CDdcit173pctvY2AEYtccj7kvmw7cznESK2AwgsWl4naO38yWM5hikOwSaf7EgGscOhVv3MLFRSL8CMkgXRAnsyCnRdl6/q2cz3eqUM9sYDnfdminLWCIWnHXmy46X1ftofi8VTVsYnB0FCyS/alcdE0bb0/3sedQLyXDRzuy5byKjBNatiksW1cPQ2tFOYR2CXUNv5COXr7KZ+L5IJz0felC2yb/f8izcGNBZt+ui/bHuSKHTxMIRkWALXtbTazIfAYARFAKRPGc6oa5yGGQwjXzE3CeukBhDEMu1KC1lQSC65zbNkB6IMcCBgCs9lr0EkcvMNshxQJf3WqrbfbP5V4V22vo7sMJJsNcl1Un1H1CTRDnTBDm4Vs2mL7iRwCmIxgE6quF3IuQflTfmS4TsFUIpuF7FoOM8H2o3agfer1q6pHa+MdLvShKQ/UlIeP5NhBFyYTjmToBCDOzO42bcu2aFHFC5y8i8SID6EUFWEawfknuNth+/AlXuTsbTogREgI0LV2zaIO4BqkEsM2nC1w/5EKjWzWnDd5GN6l+A/zA3C3q9Z97mSsjyE6I+AiJEc7GIwEfAd7jRjfnN8DQuiBhdYfiuPuUAYsEuMQUCFsKYjvwpVNBZiuqcvmVB2b6KWgZbP45EPRHKptcaBK2WByTLA5sYei4ZZWuAVlS+EeioZe1eB4spkw0Jpa1SAswGbBHsrPbeUKVKLGcCNrNGdSrjFrFQoqwbDlBQ97W2gVr0cwJhNskRXaLEHgJWQzVb/9DXVf7FZif7QbkQbNDehfBOfeQlMKvYTbGNYOho4NgkEqpIxVSDQr2b3gcsHpxnVUfDjEhrWIstbswFpql4Jrq1PV1Ni2JCyw0LKvreNmrd93VNhxKVgvqNngH4+pgmWmhgXq9sd9uy8OeLmEcJVeBPMINbeaRfUv3cWlCMCLr3ld9G0HuZQNhHvZAryuh2EJHvTdCX02R5S6VzDgNGzMsz9aF/MUt4Q4JYuihEQANb2hcQu2Mmg/zBxFNTastbnK3LhsU0XJeLZhebQzhsq1CegRBbvT2zf2ve8R0AozfIp/3+Z4fizr/XYYq8BzACwMtG+6uDqOqmGcswlHFdgged80xWPZZVOq2lWxVR9j7UHnvOYHszmf8HZfwhy4YtMx++Z82hUt3uZDXyrYjLCFggq0FNlPPQGom5tl/2mqoyuqjj0GdHZslGzbdsMWt4aOfBNK/lacs7PdDHcoEs5Wzfr8T2V5Kg7I9COgnZMeH0eAxt7ZzDJU+YUDRkr0y1J/zIXrn4J+YPmwXIbKKXZ6HMrjPYLbYeZKS85zuxgvhulh6M2uO64dWUS9AqEGOx1BaBktGEAdrBWAtsOqNWAKrPdl41pYEiLYk0GH6v5QPsXpOdAwxFJsbuZQHe8HvhvOXm4GPhZHdKQG+i82kfJYxNETrLOVbA71sfhM2KWEKWPJhv4ElChgMCD7c2asy7DOmgoZoY9koQC8oAt4ukCya5xthpK3sKRKsoVJ3iklquXgkLOAue+F3HHAqIKdyz7lOghrIY4g2YMnZL4WzmXJ7nTQEggrR6UJpyHZlFT18WODkkpruKiEA4iaXZngGbl4Qseumn11Xm8QPGBzPPQuV8AqCakChsEWXXljR0lGGIeyMV118hn/2I3DsIgF3aoTGjE4vwWLmo+kNKHUbHrJVnqjOiII+Bs2jBwkliFErUJtq1oEyxPhL+G0rAql+CocNFZ9FkkHmpAbXrIeysqR2AcquJ3UbHbT9tJWgz2uvagUbP/YQfxAHh2Ca7hhS05OyNpgumLJpsrCu3ZCE/tfCC+F08eanf+X/voBjQciQqtYiySQIpgBEqHuWoSD0UKF+knZnxLhpkkKSYJgEBt8xh1EyoJwAVt9itoPN8pw78eeUaKzK1HsEYpKRTgUaNhTCHbvu6/ODYHPwC0dm/fqkzURNgmUHVYOdgKGDob4MfQkil1wT3W1LZsGbaWimjpeoa4pDjSiKi1WmecPh30Tw9QwrhEsVlIXvw5NEK6WYQ8lWDStLotDu3+MeoCjxUJGoeHp3DxUx0O0JYKJRrasK3Rgy0+rj1HMAPeB7DJdB3TcF5jtygPai8JtbGc8rNcZnhiENQ2rcOiTjbXq8lBY06OiF+iw2DpcC0egynBYDaFYl+8bEnsnoET2RgHYeLh5giAx68qGx36jwq6wfrK7LwKHEXCxE3qkZYGCBjjl2BjNt+VvU4ABOnsepeuE2JXASge2OtE3t/On3LF7UBmd805Zz1PZtF/iWF/CYg8dYm/Nwvp2PWj58BlWH0h2W1qXbf3FTupDVZ2GsxKG0N2awnr0urQJk7I6oTAYnlrg5cCZb1jCKcJgiACmGPZoa33aEodLo1ocruX5GAYiWhVgLMda9/noUneDxlClHOOR2kA4fmwk6vd/6Lgo3P9uwp057OkA7AphCCzZ4KbpqgNjSBk6o1DbJQPOZth7H2xn4ZaA2LsCUbiAoClbCt2BY9DxZ/NuDVMLFZWsJUYiMRuhBbKbQdsF4aBg+QibM23Y6hMYErHweGNrIbBHgrfmaDYWHBRuwGSG7A/GsYUv1PUBMD0ZDpiyGELoYLAoQhiVBctC62GeFxb/8wM32L5DzCYY/yZ4sLDFFQFjFqHSUYTrqAR77L85HfbtwMIlnG6KLZQhLoaBeEFgPtKeOrQM2LPVWT7uuxxdJs4wwQwu69+JZTNy0P0NXKy6bQfUSSCYsmUPQrrWxByNztjxwp8/NNt6/yHG+OD8FuHuBMmuNXaRigEDmHlKNEKH5GCswsKDtt3HYn9AbWG5OYvI2rbkscCogiTRGK+mUZk8Fxb1wcx5eK2JjFC9Lp5JSYBv14C+lD1qdjmiR00WMOfYjNCgh2G4D6cuW9lpj2+5c1zxggC9M9cS7Y1hKXE3w/pSFLYm1HYyPLcGE9bsZrl1ZRUstAtXU9Yz2z5OVTM8SCKhY9fsbI3aD6EyCJVr9hiA3TS3++2nEqUI4Ruw2apLY+I0DKzMlKzfbVEsAbGVAKKpANOrUGyvWOMmMhwSnk5TrONlbkqCWLdhkzSh8fBEFLRMtrzY3bE0rK9X8DCCYbf7beUuMMBZe3i8QLLISVv9h6wvhwUDsge+1+F2hxAe6HDll2YPwFkOdopQtwrAc8WajXttD7GnFHDbIzb9OY1wKiPcmKlZxIe7WQoWrBh2TzSsqZLRwZFwR6ViIa+2aux47IZvBvc1/X2hbIK/rYaql7CsXLO1Ta7pYNrCNSjcJWpY2KKtrE6poyEQMetvgQsxpGFvlWwr5kxcdLSXt7Xz/tiuB7UkClaqGzZR2VafH9EJargc8JModS0hPMYmeA+CTgfBaoVu8MK1cTrZCZFHgLUHmi25vjTGFQQKoh2aLbywHTBnyaNrv9jQkarwV3D4NL+OhKtccM0iLGMwbFGBbZ5Yz2GWmz1KZvvg12MFUyGa3aXbTtggHu6U2S1AW++f9vikMoxM+bUTqR3W+K877DUUsolFfxVz/5eQHxD9HjL8JWTqRH+TcWiuQnMl+uqmkFwNd5ipcLuw6hHgcD2w6nHI/pqnsESZsBgY9vKe4b18MKu3CpfpSk7jtj0G+yVcmRQbvZ+PAzwLhlzsJD0f6U3aOoJC+dYOBkRJQiAwCwr3LYehPkRC2Vjb1RWifSXcULMVWYP8G1zbwvXVochchIJtETL0IlxsLfq7wsJFICKYlQgVQ2rRG1owvXDERvXFd8tgwqv+UGh/hVdI9vY2yGJC7rXswdVhuAoDAMUmpV0HcUNYiKRZo30iz6LATa8Kd7VqNtM3BKMkzLNI1o7YQwsS1qRLduMVtR9eTQrHzrAu8teiRteJwkWCXeWpuQOEZkM0duZAiIMFXUngPrqAiHNvv9bF6VTuqOJYmNhS9Ir28+3NaX8qLWJ889X7n//73/8f0W+zvh3VAQA="; \ No newline at end of file diff --git a/api-reference/classes/Change.html b/api-reference/classes/Change.html index c6cb3770b..78ed1c5b4 100644 --- a/api-reference/classes/Change.html +++ b/api-reference/classes/Change.html @@ -1,5 +1,5 @@ Change | yorkie-js-sdk

Class Change<P>

Change represents a unit of modification in the document.

-

Type Parameters

Constructors

Type Parameters

Constructors

Properties

Constructors

  • Type Parameters

    Parameters

    • __namedParameters: {
          id: ChangeID;
          message?: string;
          operations?: Operation[];
          presenceChange?: PresenceChange<P>;
      }
      • id: ChangeID
      • Optional message?: string
      • Optional operations?: Operation[]
      • Optional presenceChange?: PresenceChange<P>

    Returns Change<P>

Properties

id: ChangeID
message?: string
operations: Operation[]
presenceChange?: PresenceChange<P>

Methods

  • execute executes the operations of this change to the given root.

    -

    Parameters

    • root: CRDTRoot
    • presences: Map<string, P>
    • source: OpSource

    Returns {
        opInfos: OperationInfo[];
        reverseOps: HistoryOperation<P>[];
    }

  • getMessage returns the message of this change.

    -

    Returns undefined | string

  • getPresenceChange returns the presence change of this change.

    -

    Returns undefined | PresenceChange<P>

  • hasOperations returns whether this change has operations or not.

    -

    Returns boolean

  • hasPresenceChange returns whether this change has presence change or not.

    -

    Returns boolean

  • toTestString returns a string containing the meta data of this change.

    -

    Returns string

  • create creates a new instance of Change.

    -

    Type Parameters

    Parameters

    • __namedParameters: {
          id: ChangeID;
          message?: string;
          operations?: Operation[];
          presenceChange?: PresenceChange<P>;
      }
      • id: ChangeID
      • Optional message?: string
      • Optional operations?: Operation[]
      • Optional presenceChange?: PresenceChange<P>

    Returns Change<P>

\ No newline at end of file +

Constructors

  • Type Parameters

    Parameters

    • __namedParameters: {
          id: ChangeID;
          message?: string;
          operations?: Operation[];
          presenceChange?: PresenceChange<P>;
      }
      • id: ChangeID
      • Optional message?: string
      • Optional operations?: Operation[]
      • Optional presenceChange?: PresenceChange<P>

    Returns Change<P>

Properties

id: ChangeID
message?: string
operations: Operation[]
presenceChange?: PresenceChange<P>

Methods

  • execute executes the operations of this change to the given root.

    +

    Parameters

    • root: CRDTRoot
    • presences: Map<string, P>
    • source: OpSource

    Returns {
        opInfos: OperationInfo[];
        reverseOps: HistoryOperation<P>[];
    }

  • getMessage returns the message of this change.

    +

    Returns undefined | string

  • getPresenceChange returns the presence change of this change.

    +

    Returns undefined | PresenceChange<P>

  • hasOperations returns whether this change has operations or not.

    +

    Returns boolean

  • hasPresenceChange returns whether this change has presence change or not.

    +

    Returns boolean

  • toTestString returns a string containing the meta data of this change.

    +

    Returns string

  • create creates a new instance of Change.

    +

    Type Parameters

    Parameters

    • __namedParameters: {
          id: ChangeID;
          message?: string;
          operations?: Operation[];
          presenceChange?: PresenceChange<P>;
      }
      • id: ChangeID
      • Optional message?: string
      • Optional operations?: Operation[]
      • Optional presenceChange?: PresenceChange<P>

    Returns Change<P>

\ No newline at end of file diff --git a/api-reference/classes/Client.html b/api-reference/classes/Client.html index 36be66fcf..1370b47e6 100644 --- a/api-reference/classes/Client.html +++ b/api-reference/classes/Client.html @@ -1,7 +1,7 @@ Client | yorkie-js-sdk

Client is a normal client that can communicate with the server. It has documents and sends changes of the documents in local to the server to synchronize with other replicas in remote.

-

Constructors

Constructors

Properties

Constructors

Properties

apiKey: string
attachmentMap: Map<string, Attachment<unknown, any>>
authTokenInjector?: ((reason?) => Promise<string>)

Type declaration

    • (reason?): Promise<string>
    • Parameters

      • Optional reason: string

      Returns Promise<string>

conditions: Record<ClientCondition, boolean>
id?: string
keepalive: boolean = false
key: string
processing: boolean = false
reconnectStreamDelay: number
retrySyncLoopDelay: number
rpcClient: PromiseClient<{
    methods: {
        activateClient: {
            I: typeof ActivateClientRequest;
            O: typeof ActivateClientResponse;
            kind: Unary;
            name: "ActivateClient";
        };
        attachDocument: {
            I: typeof AttachDocumentRequest;
            O: typeof AttachDocumentResponse;
            kind: Unary;
            name: "AttachDocument";
        };
        broadcast: {
            I: typeof BroadcastRequest;
            O: typeof BroadcastResponse;
            kind: Unary;
            name: "Broadcast";
        };
        deactivateClient: {
            I: typeof DeactivateClientRequest;
            O: typeof DeactivateClientResponse;
            kind: Unary;
            name: "DeactivateClient";
        };
        detachDocument: {
            I: typeof DetachDocumentRequest;
            O: typeof DetachDocumentResponse;
            kind: Unary;
            name: "DetachDocument";
        };
        pushPullChanges: {
            I: typeof PushPullChangesRequest;
            O: typeof PushPullChangesResponse;
            kind: Unary;
            name: "PushPullChanges";
        };
        removeDocument: {
            I: typeof RemoveDocumentRequest;
            O: typeof RemoveDocumentResponse;
            kind: Unary;
            name: "RemoveDocument";
        };
        watchDocument: {
            I: typeof WatchDocumentRequest;
            O: typeof WatchDocumentResponse;
            kind: ServerStreaming;
            name: "WatchDocument";
        };
    };
    typeName: "yorkie.v1.YorkieService";
}>

Type declaration

  • Readonly methods: {
        activateClient: {
            I: typeof ActivateClientRequest;
            O: typeof ActivateClientResponse;
            kind: Unary;
            name: "ActivateClient";
        };
        attachDocument: {
            I: typeof AttachDocumentRequest;
            O: typeof AttachDocumentResponse;
            kind: Unary;
            name: "AttachDocument";
        };
        broadcast: {
            I: typeof BroadcastRequest;
            O: typeof BroadcastResponse;
            kind: Unary;
            name: "Broadcast";
        };
        deactivateClient: {
            I: typeof DeactivateClientRequest;
            O: typeof DeactivateClientResponse;
            kind: Unary;
            name: "DeactivateClient";
        };
        detachDocument: {
            I: typeof DetachDocumentRequest;
            O: typeof DetachDocumentResponse;
            kind: Unary;
            name: "DetachDocument";
        };
        pushPullChanges: {
            I: typeof PushPullChangesRequest;
            O: typeof PushPullChangesResponse;
            kind: Unary;
            name: "PushPullChanges";
        };
        removeDocument: {
            I: typeof RemoveDocumentRequest;
            O: typeof RemoveDocumentResponse;
            kind: Unary;
            name: "RemoveDocument";
        };
        watchDocument: {
            I: typeof WatchDocumentRequest;
            O: typeof WatchDocumentResponse;
            kind: ServerStreaming;
            name: "WatchDocument";
        };
    }
    • Readonly activateClient: {
          I: typeof ActivateClientRequest;
          O: typeof ActivateClientResponse;
          kind: Unary;
          name: "ActivateClient";
      }

      Generated

      from rpc yorkie.v1.YorkieService.ActivateClient

      +

Returns Client

Properties

apiKey: string
attachmentMap: Map<string, Attachment<unknown, any>>
authTokenInjector?: ((reason?) => Promise<string>)

Type declaration

    • (reason?): Promise<string>
    • Parameters

      • Optional reason: string

      Returns Promise<string>

conditions: Record<ClientCondition, boolean>
id?: string
keepalive: boolean = false
key: string
processing: boolean = false
reconnectStreamDelay: number
retrySyncLoopDelay: number
rpcClient: PromiseClient<{
    methods: {
        activateClient: {
            I: typeof ActivateClientRequest;
            O: typeof ActivateClientResponse;
            kind: Unary;
            name: "ActivateClient";
        };
        attachDocument: {
            I: typeof AttachDocumentRequest;
            O: typeof AttachDocumentResponse;
            kind: Unary;
            name: "AttachDocument";
        };
        broadcast: {
            I: typeof BroadcastRequest;
            O: typeof BroadcastResponse;
            kind: Unary;
            name: "Broadcast";
        };
        deactivateClient: {
            I: typeof DeactivateClientRequest;
            O: typeof DeactivateClientResponse;
            kind: Unary;
            name: "DeactivateClient";
        };
        detachDocument: {
            I: typeof DetachDocumentRequest;
            O: typeof DetachDocumentResponse;
            kind: Unary;
            name: "DetachDocument";
        };
        pushPullChanges: {
            I: typeof PushPullChangesRequest;
            O: typeof PushPullChangesResponse;
            kind: Unary;
            name: "PushPullChanges";
        };
        removeDocument: {
            I: typeof RemoveDocumentRequest;
            O: typeof RemoveDocumentResponse;
            kind: Unary;
            name: "RemoveDocument";
        };
        watchDocument: {
            I: typeof WatchDocumentRequest;
            O: typeof WatchDocumentResponse;
            kind: ServerStreaming;
            name: "WatchDocument";
        };
    };
    typeName: "yorkie.v1.YorkieService";
}>

Type declaration

  • Readonly methods: {
        activateClient: {
            I: typeof ActivateClientRequest;
            O: typeof ActivateClientResponse;
            kind: Unary;
            name: "ActivateClient";
        };
        attachDocument: {
            I: typeof AttachDocumentRequest;
            O: typeof AttachDocumentResponse;
            kind: Unary;
            name: "AttachDocument";
        };
        broadcast: {
            I: typeof BroadcastRequest;
            O: typeof BroadcastResponse;
            kind: Unary;
            name: "Broadcast";
        };
        deactivateClient: {
            I: typeof DeactivateClientRequest;
            O: typeof DeactivateClientResponse;
            kind: Unary;
            name: "DeactivateClient";
        };
        detachDocument: {
            I: typeof DetachDocumentRequest;
            O: typeof DetachDocumentResponse;
            kind: Unary;
            name: "DetachDocument";
        };
        pushPullChanges: {
            I: typeof PushPullChangesRequest;
            O: typeof PushPullChangesResponse;
            kind: Unary;
            name: "PushPullChanges";
        };
        removeDocument: {
            I: typeof RemoveDocumentRequest;
            O: typeof RemoveDocumentResponse;
            kind: Unary;
            name: "RemoveDocument";
        };
        watchDocument: {
            I: typeof WatchDocumentRequest;
            O: typeof WatchDocumentResponse;
            kind: ServerStreaming;
            name: "WatchDocument";
        };
    }
    • Readonly activateClient: {
          I: typeof ActivateClientRequest;
          O: typeof ActivateClientResponse;
          kind: Unary;
          name: "ActivateClient";
      }

      Generated

      from rpc yorkie.v1.YorkieService.ActivateClient

      • Readonly I: typeof ActivateClientRequest
      • Readonly O: typeof ActivateClientResponse
      • Readonly kind: Unary
      • Readonly name: "ActivateClient"
    • Readonly attachDocument: {
          I: typeof AttachDocumentRequest;
          O: typeof AttachDocumentResponse;
          kind: Unary;
          name: "AttachDocument";
      }

      Generated

      from rpc yorkie.v1.YorkieService.AttachDocument

      • Readonly I: typeof AttachDocumentRequest
      • Readonly O: typeof AttachDocumentResponse
      • Readonly kind: Unary
      • Readonly name: "AttachDocument"
    • Readonly broadcast: {
          I: typeof BroadcastRequest;
          O: typeof BroadcastResponse;
          kind: Unary;
          name: "Broadcast";
      }

      Generated

      from rpc yorkie.v1.YorkieService.Broadcast

      • Readonly I: typeof BroadcastRequest
      • Readonly O: typeof BroadcastResponse
      • Readonly kind: Unary
      • Readonly name: "Broadcast"
    • Readonly deactivateClient: {
          I: typeof DeactivateClientRequest;
          O: typeof DeactivateClientResponse;
          kind: Unary;
          name: "DeactivateClient";
      }

      Generated

      from rpc yorkie.v1.YorkieService.DeactivateClient

      @@ -49,39 +49,39 @@
      • Readonly I: typeof DetachDocumentRequest
      • Readonly O: typeof DetachDocumentResponse
      • Readonly kind: Unary
      • Readonly name: "DetachDocument"
    • Readonly pushPullChanges: {
          I: typeof PushPullChangesRequest;
          O: typeof PushPullChangesResponse;
          kind: Unary;
          name: "PushPullChanges";
      }

      Generated

      from rpc yorkie.v1.YorkieService.PushPullChanges

      • Readonly I: typeof PushPullChangesRequest
      • Readonly O: typeof PushPullChangesResponse
      • Readonly kind: Unary
      • Readonly name: "PushPullChanges"
    • Readonly removeDocument: {
          I: typeof RemoveDocumentRequest;
          O: typeof RemoveDocumentResponse;
          kind: Unary;
          name: "RemoveDocument";
      }

      Generated

      from rpc yorkie.v1.YorkieService.RemoveDocument

      • Readonly I: typeof RemoveDocumentRequest
      • Readonly O: typeof RemoveDocumentResponse
      • Readonly kind: Unary
      • Readonly name: "RemoveDocument"
    • Readonly watchDocument: {
          I: typeof WatchDocumentRequest;
          O: typeof WatchDocumentResponse;
          kind: ServerStreaming;
          name: "WatchDocument";
      }

      Generated

      from rpc yorkie.v1.YorkieService.WatchDocument

      -
      • Readonly I: typeof WatchDocumentRequest
      • Readonly O: typeof WatchDocumentResponse
      • Readonly kind: ServerStreaming
      • Readonly name: "WatchDocument"
  • Readonly typeName: "yorkie.v1.YorkieService"
setAuthToken: ((token) => void)

Type declaration

    • (token): void
    • Parameters

      • token: string

      Returns void

status: ClientStatus
syncLoopDuration: number
taskQueue: (() => Promise<any>)[]

Type declaration

    • (): Promise<any>
    • Returns Promise<any>

Methods

  • activate activates this client. That is, it registers itself to the server +

    • Readonly I: typeof WatchDocumentRequest
    • Readonly O: typeof WatchDocumentResponse
    • Readonly kind: ServerStreaming
    • Readonly name: "WatchDocument"
  • Readonly typeName: "yorkie.v1.YorkieService"
  • setAuthToken: ((token) => void)

    Type declaration

      • (token): void
      • Parameters

        • token: string

        Returns void

    status: ClientStatus
    syncLoopDuration: number
    taskQueue: (() => Promise<any>)[]

    Type declaration

      • (): Promise<any>
      • Returns Promise<any>

    Methods

    • activate activates this client. That is, it registers itself to the server and receives a unique ID from the server. The given ID is used to distinguish different clients.

      -

      Returns Promise<void>

    • attach attaches the given document to this client. It tells the server that +

      Returns Promise<void>

    • attach attaches the given document to this client. It tells the server that this client will synchronize the given document.

      -

      Type Parameters

      Parameters

      • doc: Document<T, P>
      • options: {
            initialPresence?: P;
            initialRoot?: T;
            syncMode?: SyncMode;
        } = {}
        • Optional initialPresence?: P
        • Optional initialRoot?: T
        • Optional syncMode?: SyncMode

      Returns Promise<Document<T, P>>

    • broadcast broadcasts the given payload to the given topic.

      -

      Parameters

      • docKey: string
      • topic: string
      • payload: Json
      • Optional options: BroadcastOptions

      Returns Promise<void>

    • deactivate deactivates this client.

      +

      Type Parameters

      Parameters

      • doc: Document<T, P>
      • options: {
            initialPresence?: P;
            initialRoot?: T;
            syncMode?: SyncMode;
        } = {}
        • Optional initialPresence?: P
        • Optional initialRoot?: T
        • Optional syncMode?: SyncMode

      Returns Promise<Document<T, P>>

    • broadcast broadcasts the given payload to the given topic.

      +

      Parameters

      • docKey: string
      • topic: string
      • payload: Json
      • Optional options: BroadcastOptions

      Returns Promise<void>

    • deactivate deactivates this client.

      Parameters

      • options: {
            keepalive: boolean;
        } = ...

        If keepalive is true, the client will request deactivation immediately using fetch with the keepalive option enabled. This is useful for ensuring the deactivation request completes even if the page is being unloaded, such as in beforeunload or unload event listeners.

        -
        • keepalive: boolean

      Returns Promise<void>

    • detach detaches the given document from this client. It tells the +

      • keepalive: boolean

    Returns Promise<void>

    • detach detaches the given document from this client. It tells the server that this client will no longer synchronize the given document.

      To collect garbage things like CRDT tombstones left on the document, all the changes should be applied to other replicas before GC time. For this, if the document is no longer used by this client, it should be detached.

      -

      Type Parameters

      Parameters

      • doc: Document<T, P>
      • options: {
            removeIfNotAttached?: boolean;
        } = {}
        • Optional removeIfNotAttached?: boolean

      Returns Promise<Document<T, P>>

    • enqueueTask enqueues the given task to the task queue.

      -

      Parameters

      • task: (() => Promise<any>)
          • (): Promise<any>
          • Returns Promise<any>

      Returns Promise<any>

    • getID returns a ActorID of client.

      -

      Returns undefined | string

    • handleConnectError handles the given error. If the given error can be +

      Type Parameters

      Parameters

      • doc: Document<T, P>
      • options: {
            removeIfNotAttached?: boolean;
        } = {}
        • Optional removeIfNotAttached?: boolean

      Returns Promise<Document<T, P>>

    • enqueueTask enqueues the given task to the task queue.

      +

      Parameters

      • task: (() => Promise<any>)
          • (): Promise<any>
          • Returns Promise<any>

      Returns Promise<any>

    • getID returns a ActorID of client.

      +

      Returns undefined | string

    • handleConnectError handles the given error. If the given error can be retried after handling, it returns true.

      -

      Parameters

      • err: any

      Returns Promise<boolean>

    • Type Parameters

      Parameters

      • attachment: Attachment<T, P>
      • resp: WatchDocumentResponse

      Returns void

    • isActive checks if the client is active.

      -

      Returns boolean

    • processNext processes the next task in the task queue. This method is +

      Parameters

      • err: any

      Returns Promise<boolean>

    • Type Parameters

      Parameters

      • attachment: Attachment<T, P>
      • resp: WatchDocumentResponse

      Returns void

    • isActive checks if the client is active.

      +

      Returns boolean

    • processNext processes the next task in the task queue. This method is part of enqueueTask.

      -

      Returns Promise<void>

    • runSyncLoop runs the sync loop. The sync loop pushes local changes to +

      Returns Promise<void>

    • runSyncLoop runs the sync loop. The sync loop pushes local changes to the server and pulls remote changes from the server.

      -

      Returns void

    • runWatchLoop runs the watch loop for the given document. The watch loop +

      Returns void

    • runWatchLoop runs the watch loop for the given document. The watch loop listens to the events of the given document from the server.

      -

      Parameters

      • docKey: string

      Returns Promise<void>

    • sync pushes local changes of the attached documents to the server and +

      Parameters

      • docKey: string

      Returns Promise<void>

    • sync pushes local changes of the attached documents to the server and receives changes of the remote replica from the server then apply them to local documents.

      -

      Type Parameters

      Parameters

      Returns Promise<Document<T, P>[]>

    \ No newline at end of file +

    Type Parameters

    Parameters

    Returns Promise<Document<T, P>[]>

    \ No newline at end of file diff --git a/api-reference/classes/Counter.html b/api-reference/classes/Counter.html index cade35c29..ce11f65a4 100644 --- a/api-reference/classes/Counter.html +++ b/api-reference/classes/Counter.html @@ -1,5 +1,5 @@ Counter | yorkie-js-sdk

    Counter is a custom data type that is used to counter.

    -

    Constructors

    Constructors

    Properties

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    counter?: CRDTCounter
    value: number | Long
    valueType: CounterType

    Methods

    • Internal

      getValue returns the value of this counter;

      -

      Returns number | Long

    • getValueType returns the value type of this counter.

      -

      Returns CounterType

    • Internal

      initialize initialize this text with context and internal text.

      -

      Parameters

      • context: ChangeContext<Indexable>
      • counter: CRDTCounter

      Returns void

    \ No newline at end of file +

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    counter?: CRDTCounter
    value: number | Long
    valueType: CounterType

    Methods

    • Internal

      getValue returns the value of this counter;

      +

      Returns number | Long

    • getValueType returns the value type of this counter.

      +

      Returns CounterType

    • Internal

      initialize initialize this text with context and internal text.

      +

      Parameters

      • context: ChangeContext<Indexable>
      • counter: CRDTCounter

      Returns void

    \ No newline at end of file diff --git a/api-reference/classes/Document.html b/api-reference/classes/Document.html index eea66f3ab..253574cda 100644 --- a/api-reference/classes/Document.html +++ b/api-reference/classes/Document.html @@ -1,6 +1,6 @@ Document | yorkie-js-sdk

    Class Document<T, P>

    Document is a CRDT-based data type. We can represent the model of the application and edit it even while offline.

    -

    Type Parameters

    Constructors

    Type Parameters

    Constructors

    Properties

    Constructors

    Properties

    changeID: ChangeID
    checkpoint: Checkpoint
    clone?: {
        presences: Map<string, P>;
        root: CRDTRoot;
    }

    Type declaration

    • presences: Map<string, P>
    • root: CRDTRoot
    eventStreamObserver: Observer<TransactionEvent<P>>
    history: {
        canRedo: (() => boolean);
        canUndo: (() => boolean);
        redo: (() => void);
        undo: (() => void);
    }

    history is exposed to the user to manage undo/redo operations.

    +

    Constructors

    Properties

    changeID: ChangeID
    checkpoint: Checkpoint
    clone?: {
        presences: Map<string, P>;
        root: CRDTRoot;
    }

    Type declaration

    • presences: Map<string, P>
    • root: CRDTRoot
    eventStreamObserver: Observer<TransactionEvent<P>>
    history: {
        canRedo: (() => boolean);
        canUndo: (() => boolean);
        redo: (() => void);
        undo: (() => void);
    }

    history is exposed to the user to manage undo/redo operations.

    Type declaration

    • canRedo: (() => boolean)
        • (): boolean
        • canRedo returns whether there are any operations to redo.

          Returns boolean

    • canUndo: (() => boolean)
        • (): boolean
        • canUndo returns whether there are any operations to undo.

          Returns boolean

    • redo: (() => void)
        • (): void
        • redo redoes the last operation executed by the current client. It does not impact operations made by other clients.

          Returns void

    • undo: (() => void)
        • (): void
        • undo undoes the last operation executed by the current client. It does not impact operations made by other clients.

          -

          Returns void

    internalHistory: History<P>

    internalHistory is used to manage undo/redo operations internally.

    -
    isUpdating: boolean

    isUpdating is whether the document is updating by updater or not. It is +

    Returns void

    internalHistory: History<P>

    internalHistory is used to manage undo/redo operations internally.

    +
    isUpdating: boolean

    isUpdating is whether the document is updating by updater or not. It is used to prevent the updater from calling undo/redo.

    -
    key: string
    localChanges: Change<P>[]
    onlineClients: Set<string>

    onlineClients is a set of client IDs that are currently online.

    -
    opts: DocumentOptions
    presences: Map<string, P>

    presences is a map of client IDs to their presence information.

    -
    root: CRDTRoot
    status: DocStatus

    Methods

    • Internal

      addOnlineClient adds the given clientID into the online client set.

      -

      Parameters

      • clientID: string

      Returns void

    • Internal

      applyChangePack applies the given change pack into this document.

      +
    key: string
    localChanges: Change<P>[]
    onlineClients: Set<string>

    onlineClients is a set of client IDs that are currently online.

    +
    opts: DocumentOptions
    presences: Map<string, P>

    presences is a map of client IDs to their presence information.

    +
    root: CRDTRoot
    status: DocStatus

    Methods

    • Internal

      addOnlineClient adds the given clientID into the online client set.

      +

      Parameters

      • clientID: string

      Returns void

    • Internal

      applyChangePack applies the given change pack into this document.

      1. Remove local changes applied to server.
      2. Update the checkpoint.
      3. Do Garbage collection.

      Parameters

      • pack: ChangePack<P>

        change pack

        -

      Returns void

    • applySnapshot applies the given snapshot into this document.

      -

      Parameters

      • serverSeq: bigint
      • snapshotVector: VersionVector
      • Optional snapshot: Uint8Array
      • clientSeq: number = -1

      Returns void

    • applyWatchStream applies the given watch stream response into this document.

      -

      Parameters

      • resp: WatchDocumentResponse

      Returns void

    • broadcast the payload to the given topic.

      -

      Parameters

      • topic: string
      • payload: Json
      • Optional options: BroadcastOptions

      Returns void

    • canRedo returns whether there are any operations to redo.

      -

      Returns boolean

    • canUndo returns whether there are any operations to undo.

      -

      Returns boolean

    • Internal

      createChangePack create change pack of the local changes to send to the +

    Returns void

    Returns void

    \ No newline at end of file +

    Returns void

    \ No newline at end of file diff --git a/api-reference/classes/Primitive.html b/api-reference/classes/Primitive.html index c50579fb5..63263f1e5 100644 --- a/api-reference/classes/Primitive.html +++ b/api-reference/classes/Primitive.html @@ -1,6 +1,6 @@ Primitive | yorkie-js-sdk

    Class Primitive

    Primitive represents primitive data type including logical clock. It has a type and a value.

    -

    Hierarchy

    • CRDTElement
      • Primitive

    Constructors

    Hierarchy

    • CRDTElement
      • Primitive

    Constructors

    Properties

    Methods

    deepcopy @@ -25,27 +25,27 @@ isSupport of valueFromBytes -

    Constructors

    Properties

    valueType: PrimitiveType

    Methods

    • getPositionedAt returns the time of this element when it was positioned +

    Constructors

    Properties

    valueType: PrimitiveType

    Methods

    • getPositionedAt returns the time of this element when it was positioned in the document by undo/redo or move operation.

      -

      Returns TimeTicket

    • isRemoved check if this element was removed.

      -

      Returns boolean

    • setMovedAt sets the move time of this element.

      -

      Parameters

      Returns boolean

    • setRemovedAt sets the remove time of this element.

      -

      Parameters

      Returns void

    • toSortedJSON returns the sorted JSON encoding of the value.

      -

      Returns string

    • getPrimitiveType returns the primitive type of the value.

      -

      Parameters

      • value: unknown

      Returns undefined | PrimitiveType

    • isInteger checks if the given number is integer.

      -

      Parameters

      • num: number

      Returns boolean

    • isSupport check if the given value is supported type.

      -

      Parameters

      • value: unknown

      Returns boolean

    \ No newline at end of file +

    Returns TimeTicket

    \ No newline at end of file diff --git a/api-reference/classes/Text.html b/api-reference/classes/Text.html index 327ce97b1..3b86cc5d9 100644 --- a/api-reference/classes/Text.html +++ b/api-reference/classes/Text.html @@ -1,5 +1,5 @@ Text | yorkie-js-sdk

    Class Text<A>

    Text is an extended data type for the contents of a text editor.

    -

    Type Parameters

    Constructors

    Type Parameters

    Constructors

    Properties

    Accessors

    length @@ -19,23 +19,23 @@ toString toTestString values -

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    text?: CRDTText<A>

    Accessors

    Methods

    • createRangeForTest returns pair of RGATreeSplitNodePos of the given indexes +

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    text?: CRDTText<A>

    Accessors

    Methods

    • createRangeForTest returns pair of RGATreeSplitNodePos of the given indexes for testing purpose.

      -

      Parameters

      • fromIdx: number
      • toIdx: number

      Returns RGATreeSplitPosRange

    • delete deletes the text in the given range.

      -

      Parameters

      • fromIdx: number
      • toIdx: number

      Returns undefined | [number, number]

    • edit edits this text with the given content.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • content: string
      • Optional attributes: A

      Returns undefined | [number, number]

    • empty makes the text empty.

      -

      Returns undefined | [number, number]

    • getTreeByID returns IDTree of the text for testing purpose.

      -

      Returns LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<CRDTTextValue>>

    • getTreeByIndex returns IndexTree of the text for testing purpose.

      -

      Returns SplayTree<CRDTTextValue>

    • Internal

      initialize initialize this text with context and internal text.

      -

      Parameters

      • context: ChangeContext<Indexable>
      • text: CRDTText<A>

      Returns void

    • setStyle styles this text with the given attributes.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • attributes: A

      Returns boolean

    • toString returns the string representation of this text.

      -

      Returns string

    • toTestString returns a String containing the meta data of the node +

      Parameters

      • fromIdx: number
      • toIdx: number

      Returns RGATreeSplitPosRange

    • delete deletes the text in the given range.

      +

      Parameters

      • fromIdx: number
      • toIdx: number

      Returns undefined | [number, number]

    • edit edits this text with the given content.

      +

      Parameters

      • fromIdx: number
      • toIdx: number
      • content: string
      • Optional attributes: A

      Returns undefined | [number, number]

    • empty makes the text empty.

      +

      Returns undefined | [number, number]

    • getTreeByID returns IDTree of the text for testing purpose.

      +

      Returns LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<CRDTTextValue>>

    • getTreeByIndex returns IndexTree of the text for testing purpose.

      +

      Returns SplayTree<CRDTTextValue>

    • Internal

      initialize initialize this text with context and internal text.

      +

      Parameters

      • context: ChangeContext<Indexable>
      • text: CRDTText<A>

      Returns void

    • setStyle styles this text with the given attributes.

      +

      Parameters

      • fromIdx: number
      • toIdx: number
      • attributes: A

      Returns boolean

    • toString returns the string representation of this text.

      +

      Returns string

    • toTestString returns a String containing the meta data of the node for debugging purpose.

      -

      Returns string

    \ No newline at end of file +

    Returns string

    \ No newline at end of file diff --git a/api-reference/classes/TimeTicket.html b/api-reference/classes/TimeTicket.html index 150baa1a6..f74a9cbb2 100644 --- a/api-reference/classes/TimeTicket.html +++ b/api-reference/classes/TimeTicket.html @@ -1,6 +1,6 @@ TimeTicket | yorkie-js-sdk

    Class TimeTicket

    TimeTicket is a timestamp of the logical clock. Ticket is immutable. It is created by ChangeID.

    -

    Constructors

    Constructors

    Properties

    Constructors

    Properties

    actorID: string
    delimiter: number
    lamport: bigint

    Methods

    • compare returns an integer comparing two Ticket. +

    Constructors

    Properties

    actorID: string
    delimiter: number
    lamport: bigint

    Methods

    • compare returns an integer comparing two Ticket. The result will be 0 if id==other, -1 if id < other, and +1 if id > other. If the receiver or argument is nil, it would panic at runtime.

      -

      Parameters

      Returns number

    • toTestString returns a string containing the meta data of the ticket for debugging purpose.

      -

      Returns string

    \ No newline at end of file +

    Returns string

    \ No newline at end of file diff --git a/api-reference/classes/Tree.html b/api-reference/classes/Tree.html index 37febeaac..82730af31 100644 --- a/api-reference/classes/Tree.html +++ b/api-reference/classes/Tree.html @@ -1,6 +1,6 @@ Tree | yorkie-js-sdk

    Tree is a CRDT-based tree structure that is used to represent the document tree of text-based editor such as ProseMirror.

    -

    Constructors

    Constructors

    Properties

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    initialRoot?: ElementNode
    tree?: CRDTTree

    Methods

    • buildRoot builds the root of this tree with the given initial root +

    Constructors

    Properties

    context?: ChangeContext<Indexable>
    initialRoot?: ElementNode
    tree?: CRDTTree

    Methods

    • buildRoot builds the root of this tree with the given initial root which set by the user.

      -

      Parameters

      Returns CRDTTreeNode

    • edit edits this tree with the given nodes.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • Optional content: TreeNode
      • splitLevel: number = 0

      Returns boolean

    • editBulk edits this tree with the given nodes.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • contents: TreeNode[]
      • splitLevel: number = 0

      Returns boolean

    • editBulkByPath edits this tree with the given node and path.

      -

      Parameters

      • fromPath: number[]
      • toPath: number[]
      • contents: TreeNode[]
      • splitLevel: number = 0

      Returns boolean

    • editByPath edits this tree with the given node and path.

      -

      Parameters

      • fromPath: number[]
      • toPath: number[]
      • Optional content: TreeNode
      • splitLevel: number = 0

      Returns boolean

    • Parameters

      • fromPos: CRDTTreePos
      • toPos: CRDTTreePos
      • contents: TreeNode[]
      • splitLevel: number = 0

      Returns boolean

    • getIndexTree returns the index tree of this tree.

      -

      Returns IndexTree<CRDTTreeNode>

    • indexToPath returns the path of the given index.

      -

      Parameters

      • index: number

      Returns number[]

    • Internal

      initialize initialize this tree with context and internal tree.

      -

      Parameters

      • context: ChangeContext<Indexable>
      • tree: CRDTTree

      Returns void

    • pathToIndex returns the index of given path.

      -

      Parameters

      • path: number[]

      Returns number

    • posRangeToPathRange converts the position range into the path range.

      -

      Parameters

      Returns [number[], number[]]

    • removeStyle removes the attributes to the elements of the given range.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • attributesToRemove: string[]

      Returns void

    • style sets the attributes to the elements of the given range.

      -

      Parameters

      • fromIdx: number
      • toIdx: number
      • attributes: {
            [key: string]: any;
        }
        • [key: string]: any

      Returns void

    • styleByPath sets the attributes to the elements of the given path.

      -

      Parameters

      • path: number[]
      • attributes: {
            [key: string]: any;
        }
        • [key: string]: any

      Returns void

    \ No newline at end of file +

    Parameters

    Returns CRDTTreeNode

    \ No newline at end of file diff --git a/api-reference/classes/VersionVector.html b/api-reference/classes/VersionVector.html index 70c648c1f..0f828f911 100644 --- a/api-reference/classes/VersionVector.html +++ b/api-reference/classes/VersionVector.html @@ -2,7 +2,7 @@ between changes whether they are causally related or concurrent. It is similar to vector clocks, but it is synced with lamport timestamp of the change.

    -

    Constructors

    Constructors

    Properties

    Methods

    [iterator] afterOrEqual @@ -13,12 +13,14 @@ maxLamport set size -

    Constructors

    Properties

    vector: Map<string, bigint>

    Methods

    • get gets the lamport timestamp of the given actor.

      -

      Parameters

      • actorID: string

      Returns undefined | bigint

    • set sets the lamport timestamp of the given actor.

      -

      Parameters

      • actorID: string
      • lamport: bigint

      Returns void

    \ No newline at end of file +unset +

    Constructors

    Properties

    vector: Map<string, bigint>

    Methods

    • get gets the lamport timestamp of the given actor.

      +

      Parameters

      • actorID: string

      Returns undefined | bigint

    • set sets the lamport timestamp of the given actor.

      +

      Parameters

      • actorID: string
      • lamport: bigint

      Returns void

    • unset removes the version for the given actor from the VersionVector.

      +

      Parameters

      • actorID: string

      Returns void

    \ No newline at end of file diff --git a/api-reference/enums/ClientCondition.html b/api-reference/enums/ClientCondition.html index d960d8418..208b7ccaa 100644 --- a/api-reference/enums/ClientCondition.html +++ b/api-reference/enums/ClientCondition.html @@ -1,6 +1,6 @@ ClientCondition | yorkie-js-sdk

    Enumeration ClientCondition

    ClientCondition represents the condition of the client.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    SyncLoop: "SyncLoop"

    SyncLoop is a key of the sync loop condition.

    -
    WatchLoop: "WatchLoop"

    WatchLoop is a key of the watch loop condition.

    -
    \ No newline at end of file +
    WatchLoop: "WatchLoop"

    WatchLoop is a key of the watch loop condition.

    +
    \ No newline at end of file diff --git a/api-reference/enums/ClientStatus.html b/api-reference/enums/ClientStatus.html index 02eb5b447..1c08be1cd 100644 --- a/api-reference/enums/ClientStatus.html +++ b/api-reference/enums/ClientStatus.html @@ -1,9 +1,9 @@ ClientStatus | yorkie-js-sdk

    Enumeration ClientStatus

    ClientStatus represents the status of the client.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Activated: "activated"

    Activated means that the client is activated. If the client is activated, all Documents of the client are also ready to be used.

    -
    Deactivated: "deactivated"

    Deactivated means that the client is not activated. It is the initial +

    Deactivated: "deactivated"

    Deactivated means that the client is not activated. It is the initial status of the client. If the client is deactivated, all Documents of the client are also not used.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/enums/DocEventType.html b/api-reference/enums/DocEventType.html index 65daa1d23..d5e03ac99 100644 --- a/api-reference/enums/DocEventType.html +++ b/api-reference/enums/DocEventType.html @@ -1,5 +1,5 @@ DocEventType | yorkie-js-sdk

    Enumeration DocEventType

    DocEventType represents the type of the event that occurs in Document.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    AuthError: "auth-error"

    AuthError indicates an authorization failure in syncLoop or watchLoop.

    -
    Broadcast: "broadcast"

    Broadcast means that the broadcast event is received from the remote client.

    -
    ConnectionChanged: "connection-changed"

    ConnectionChanged means that the watch stream connection status has changed.

    -
    Initialized: "initialized"

    Initialized means that online clients have been loaded from the server.

    -
    LocalBroadcast: "local-broadcast"

    LocalBroadcast means that the broadcast event is sent from the local client.

    -
    LocalChange: "local-change"

    local document change event type

    -
    PresenceChanged: "presence-changed"

    PresenceChanged means that the presences of the client has updated.

    -
    RemoteChange: "remote-change"

    remote document change event type

    -
    Snapshot: "snapshot"

    snapshot event type

    -
    StatusChanged: "status-changed"

    status changed event type

    -
    SyncStatusChanged: "sync-status-changed"

    SyncStatusChanged means that the document sync status has changed.

    -
    Unwatched: "unwatched"

    Unwatched means that the connection has been disconnected.

    -
    Watched: "watched"

    Watched means that the client has established a connection with the server, +

    Broadcast: "broadcast"

    Broadcast means that the broadcast event is received from the remote client.

    +
    ConnectionChanged: "connection-changed"

    ConnectionChanged means that the watch stream connection status has changed.

    +
    Initialized: "initialized"

    Initialized means that online clients have been loaded from the server.

    +
    LocalBroadcast: "local-broadcast"

    LocalBroadcast means that the broadcast event is sent from the local client.

    +
    LocalChange: "local-change"

    local document change event type

    +
    PresenceChanged: "presence-changed"

    PresenceChanged means that the presences of the client has updated.

    +
    RemoteChange: "remote-change"

    remote document change event type

    +
    Snapshot: "snapshot"

    snapshot event type

    +
    StatusChanged: "status-changed"

    status changed event type

    +
    SyncStatusChanged: "sync-status-changed"

    SyncStatusChanged means that the document sync status has changed.

    +
    Unwatched: "unwatched"

    Unwatched means that the connection has been disconnected.

    +
    Watched: "watched"

    Watched means that the client has established a connection with the server, enabling real-time synchronization.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/enums/DocStatus.html b/api-reference/enums/DocStatus.html index 1f7af8843..44c61094d 100644 --- a/api-reference/enums/DocStatus.html +++ b/api-reference/enums/DocStatus.html @@ -1,11 +1,11 @@ DocStatus | yorkie-js-sdk

    Enumeration DocStatus

    DocStatus represents the status of the document.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Attached: "attached"

    Attached means that this document is attached to the client. The actor of the ticket is created with being assigned by the client.

    -
    Detached: "detached"

    Detached means that the document is not attached to the client. +

    Detached: "detached"

    Detached means that the document is not attached to the client. The actor of the ticket is created without being assigned.

    -
    Removed: "removed"

    Removed means that this document is removed. If the document is removed, +

    Removed: "removed"

    Removed means that this document is removed. If the document is removed, it cannot be edited.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/enums/DocSyncStatus.html b/api-reference/enums/DocSyncStatus.html index e4dd47fd2..86b0f02bc 100644 --- a/api-reference/enums/DocSyncStatus.html +++ b/api-reference/enums/DocSyncStatus.html @@ -1,6 +1,6 @@ DocSyncStatus | yorkie-js-sdk

    Enumeration DocSyncStatus

    DocSyncStatus represents the result of synchronizing the document with the server.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    SyncFailed: "sync-failed"

    SyncFiled means that document synchronization has failed.

    -
    Synced: "synced"

    Synced means that document synced successfully.

    -
    \ No newline at end of file +
    Synced: "synced"

    Synced means that document synced successfully.

    +
    \ No newline at end of file diff --git a/api-reference/enums/LogLevel.html b/api-reference/enums/LogLevel.html index 7ef6a52af..10d4408d2 100644 --- a/api-reference/enums/LogLevel.html +++ b/api-reference/enums/LogLevel.html @@ -1,7 +1,7 @@ -LogLevel | yorkie-js-sdk

    Enumeration LogLevel

    Enumeration Members

    Debug +LogLevel | yorkie-js-sdk

    Enumeration LogLevel

    Enumeration Members

    Enumeration Members

    Debug: 1
    Error: 4
    Fatal: 5
    Info: 2
    Trivial: 0
    Warn: 3
    \ No newline at end of file +

    Enumeration Members

    Debug: 1
    Error: 4
    Fatal: 5
    Info: 2
    Trivial: 0
    Warn: 3
    \ No newline at end of file diff --git a/api-reference/enums/OpSource.html b/api-reference/enums/OpSource.html index f61ee0200..385faf1b1 100644 --- a/api-reference/enums/OpSource.html +++ b/api-reference/enums/OpSource.html @@ -1,7 +1,7 @@ OpSource | yorkie-js-sdk

    Enumeration OpSource

    OpSource represents the source of the operation. It is used to handle corner cases in the operations created by undo/redo allow the removed elements when executing them.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Local: "local"
    Remote: "remote"
    UndoRedo: "undoredo"
    \ No newline at end of file +

    Enumeration Members

    Local: "local"
    Remote: "remote"
    UndoRedo: "undoredo"
    \ No newline at end of file diff --git a/api-reference/enums/StreamConnectionStatus.html b/api-reference/enums/StreamConnectionStatus.html index acd671eaa..a94dd4b51 100644 --- a/api-reference/enums/StreamConnectionStatus.html +++ b/api-reference/enums/StreamConnectionStatus.html @@ -1,6 +1,6 @@ StreamConnectionStatus | yorkie-js-sdk

    Enumeration StreamConnectionStatus

    StreamConnectionStatus represents whether the stream connection is connected or not.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Connected: "connected"

    Connected means that the stream connection is connected.

    -
    Disconnected: "disconnected"

    Disconnected means that the stream connection is disconnected.

    -
    \ No newline at end of file +
    Disconnected: "disconnected"

    Disconnected means that the stream connection is disconnected.

    +
    \ No newline at end of file diff --git a/api-reference/enums/SyncMode.html b/api-reference/enums/SyncMode.html index f6a19fa45..4843f73f9 100644 --- a/api-reference/enums/SyncMode.html +++ b/api-reference/enums/SyncMode.html @@ -1,11 +1,11 @@ SyncMode | yorkie-js-sdk

    Enumeration SyncMode

    SyncMode defines synchronization modes for the PushPullChanges API.

    -

    Enumeration Members

    Enumeration Members

    Manual: "manual"

    Manual mode indicates that changes are not automatically pushed or pulled.

    -
    Realtime: "realtime"

    Realtime mode indicates that changes are automatically pushed and pulled.

    -
    RealtimePushOnly: "realtime-pushonly"

    RealtimePushOnly mode indicates that only local changes are automatically pushed.

    -
    RealtimeSyncOff: "realtime-syncoff"

    RealtimeSyncOff mode indicates that changes are not automatically pushed or pulled, +

    Realtime: "realtime"

    Realtime mode indicates that changes are automatically pushed and pulled.

    +
    RealtimePushOnly: "realtime-pushonly"

    RealtimePushOnly mode indicates that only local changes are automatically pushed.

    +
    RealtimeSyncOff: "realtime-syncoff"

    RealtimeSyncOff mode indicates that changes are not automatically pushed or pulled, but the watch stream is kept active.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/enums/TreeChangeType.html b/api-reference/enums/TreeChangeType.html index 8764d36f8..f2f1670a5 100644 --- a/api-reference/enums/TreeChangeType.html +++ b/api-reference/enums/TreeChangeType.html @@ -1,5 +1,5 @@ TreeChangeType | yorkie-js-sdk

    Enumeration TreeChangeType

    TreeChangeType represents the type of change in the tree.

    -

    Enumeration Members

    Enumeration Members

    Enumeration Members

    Content: "content"
    RemoveStyle: "removeStyle"
    Style: "style"
    \ No newline at end of file +

    Enumeration Members

    Content: "content"
    RemoveStyle: "removeStyle"
    Style: "style"
    \ No newline at end of file diff --git a/api-reference/interfaces/ChangeInfo.html b/api-reference/interfaces/ChangeInfo.html index c124f8d11..5b24aad3e 100644 --- a/api-reference/interfaces/ChangeInfo.html +++ b/api-reference/interfaces/ChangeInfo.html @@ -1,8 +1,8 @@ ChangeInfo | yorkie-js-sdk

    Interface ChangeInfo<T>

    ChangeInfo represents the modifications made during a document update and the message passed.

    -
    interface ChangeInfo<T> {
        actor: string;
        clientSeq: number;
        message: string;
        operations: T[];
        serverSeq: string;
    }

    Type Parameters

    Properties

    interface ChangeInfo<T> {
        actor: string;
        clientSeq: number;
        message: string;
        operations: T[];
        serverSeq: string;
    }

    Type Parameters

    Properties

    actor: string
    clientSeq: number
    message: string
    operations: T[]
    serverSeq: string
    \ No newline at end of file +

    Properties

    actor: string
    clientSeq: number
    message: string
    operations: T[]
    serverSeq: string
    \ No newline at end of file diff --git a/api-reference/interfaces/ClientOptions.html b/api-reference/interfaces/ClientOptions.html index 9ef6aaf97..7ba2bf38c 100644 --- a/api-reference/interfaces/ClientOptions.html +++ b/api-reference/interfaces/ClientOptions.html @@ -1,5 +1,5 @@ ClientOptions | yorkie-js-sdk

    Interface ClientOptions

    ClientOptions are user-settable options used when defining clients.

    -
    interface ClientOptions {
        apiKey?: string;
        authTokenInjector?: ((reason?) => Promise<string>);
        key?: string;
        reconnectStreamDelay?: number;
        retrySyncLoopDelay?: number;
        syncLoopDuration?: number;
    }

    Properties

    interface ClientOptions {
        apiKey?: string;
        authTokenInjector?: ((reason?) => Promise<string>);
        key?: string;
        reconnectStreamDelay?: number;
        retrySyncLoopDelay?: number;
        syncLoopDuration?: number;
    }

    Properties

    apiKey?: string

    apiKey is the API key of the project. It is used to identify the project. If not set, API key of the default project is used.

    -
    authTokenInjector?: ((reason?) => Promise<string>)

    authTokenInjector is a function that provides a token for the auth webhook. +

    authTokenInjector?: ((reason?) => Promise<string>)

    authTokenInjector is a function that provides a token for the auth webhook. When the webhook response status code is 401, this function is called to refresh the token. The reason parameter is the reason from the webhook response.

    -

    Type declaration

      • (reason?): Promise<string>
      • Parameters

        • Optional reason: string

        Returns Promise<string>

    key?: string

    key is the client key. It is used to identify the client. +

    Type declaration

      • (reason?): Promise<string>
      • Parameters

        • Optional reason: string

        Returns Promise<string>

    key?: string

    key is the client key. It is used to identify the client. If not set, a random key is generated.

    -
    reconnectStreamDelay?: number

    reconnectStreamDelay is the delay of the reconnect stream. If the stream +

    reconnectStreamDelay?: number

    reconnectStreamDelay is the delay of the reconnect stream. If the stream is disconnected, the client waits for the delay to reconnect the stream. The default value is 1000(ms).

    -
    retrySyncLoopDelay?: number

    retrySyncLoopDelay is the delay of the retry sync loop. If the sync loop +

    retrySyncLoopDelay?: number

    retrySyncLoopDelay is the delay of the retry sync loop. If the sync loop fails, the client waits for the delay to retry the sync loop. The default value is 1000(ms).

    -
    syncLoopDuration?: number

    syncLoopDuration is the duration of the sync loop. After each sync loop, +

    syncLoopDuration?: number

    syncLoopDuration is the duration of the sync loop. After each sync loop, the client waits for the duration to next sync. The default value is 50(ms).

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/interfaces/ConnectionChangedEvent.html b/api-reference/interfaces/ConnectionChangedEvent.html index bbd329af4..f1f80f96a 100644 --- a/api-reference/interfaces/ConnectionChangedEvent.html +++ b/api-reference/interfaces/ConnectionChangedEvent.html @@ -1,5 +1,5 @@ ConnectionChangedEvent | yorkie-js-sdk

    Interface ConnectionChangedEvent

    ConnectionChangedEvent is an event that occurs when the stream connection state changes.

    -
    interface ConnectionChangedEvent {
        type: ConnectionChanged;
        value: StreamConnectionStatus;
    }

    Hierarchy

    • BaseDocEvent
      • ConnectionChangedEvent

    Properties

    interface ConnectionChangedEvent {
        type: ConnectionChanged;
        value: StreamConnectionStatus;
    }

    Hierarchy

    • BaseDocEvent
      • ConnectionChangedEvent

    Properties

    Properties

    enum DocEventType.ConnectionChanged

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/interfaces/InitializedEvent.html b/api-reference/interfaces/InitializedEvent.html index b451e3635..47831ec64 100644 --- a/api-reference/interfaces/InitializedEvent.html +++ b/api-reference/interfaces/InitializedEvent.html @@ -1,4 +1,4 @@ -InitializedEvent | yorkie-js-sdk

    Interface InitializedEvent<P>

    interface InitializedEvent<P> {
        source: Local;
        type: Initialized;
        value: {
            clientID: string;
            presence: P;
        }[];
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • InitializedEvent

    Properties

    source +InitializedEvent | yorkie-js-sdk

    Interface InitializedEvent<P>

    interface InitializedEvent<P> {
        source: Local;
        type: Initialized;
        value: {
            clientID: string;
            presence: P;
        }[];
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • InitializedEvent

    Properties

    Properties

    source: Local
    value: {
        clientID: string;
        presence: P;
    }[]

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file +

    Properties

    source: Local
    value: {
        clientID: string;
        presence: P;
    }[]

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file diff --git a/api-reference/interfaces/LocalChangeEvent.html b/api-reference/interfaces/LocalChangeEvent.html index cd4c6d742..d6c2d5932 100644 --- a/api-reference/interfaces/LocalChangeEvent.html +++ b/api-reference/interfaces/LocalChangeEvent.html @@ -1,8 +1,8 @@ LocalChangeEvent | yorkie-js-sdk

    Interface LocalChangeEvent<T, P>

    LocalChangeEvent is an event that occurs when the document is changed by local changes.

    -
    interface LocalChangeEvent<T, P> {
        rawChange?: ChangeStruct<P>;
        source: Local | UndoRedo;
        type: LocalChange;
        value: ChangeInfo<T>;
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • LocalChangeEvent

    Properties

    interface LocalChangeEvent<T, P> {
        rawChange?: ChangeStruct<P>;
        source: Local | UndoRedo;
        type: LocalChange;
        value: ChangeInfo<T>;
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • LocalChangeEvent

    Properties

    rawChange?: ChangeStruct<P>
    source: Local | UndoRedo

    enum DocEventType.LocalChange

    -
    value: ChangeInfo<T>
    \ No newline at end of file +

    Properties

    rawChange?: ChangeStruct<P>
    source: Local | UndoRedo

    enum DocEventType.LocalChange

    +
    value: ChangeInfo<T>
    \ No newline at end of file diff --git a/api-reference/interfaces/Observable.html b/api-reference/interfaces/Observable.html index af3f3a3b4..078117c5b 100644 --- a/api-reference/interfaces/Observable.html +++ b/api-reference/interfaces/Observable.html @@ -1,3 +1,3 @@ -Observable | yorkie-js-sdk

    Interface Observable<T>

    interface Observable<T> {
        getProxy?: (() => ObserverProxy<T>);
        subscribe: SubscribeFn<T>;
    }

    Type Parameters

    • T

    Properties

    getProxy? +Observable | yorkie-js-sdk

    Interface Observable<T>

    interface Observable<T> {
        getProxy?: (() => ObserverProxy<T>);
        subscribe: SubscribeFn<T>;
    }

    Type Parameters

    • T

    Properties

    Properties

    getProxy?: (() => ObserverProxy<T>)

    Type declaration

      • (): ObserverProxy<T>
      • Returns ObserverProxy<T>

    subscribe: SubscribeFn<T>
    \ No newline at end of file +

    Properties

    getProxy?: (() => ObserverProxy<T>)

    Type declaration

      • (): ObserverProxy<T>
      • Returns ObserverProxy<T>

    subscribe: SubscribeFn<T>
    \ No newline at end of file diff --git a/api-reference/interfaces/Observer.html b/api-reference/interfaces/Observer.html index 14ab30ef7..e958f889f 100644 --- a/api-reference/interfaces/Observer.html +++ b/api-reference/interfaces/Observer.html @@ -1,4 +1,4 @@ -Observer | yorkie-js-sdk

    Interface Observer<T>

    interface Observer<T> {
        complete?: CompleteFn;
        error?: ErrorFn;
        next: NextFn<T>;
    }

    Type Parameters

    • T

    Properties

    complete? +Observer | yorkie-js-sdk

    Interface Observer<T>

    interface Observer<T> {
        complete?: CompleteFn;
        error?: ErrorFn;
        next: NextFn<T>;
    }

    Type Parameters

    • T

    Properties

    Properties

    complete?: CompleteFn
    error?: ErrorFn
    next: NextFn<T>
    \ No newline at end of file +

    Properties

    complete?: CompleteFn
    error?: ErrorFn
    next: NextFn<T>
    \ No newline at end of file diff --git a/api-reference/interfaces/PresenceChangedEvent.html b/api-reference/interfaces/PresenceChangedEvent.html index c356d8d5b..4e7ce7901 100644 --- a/api-reference/interfaces/PresenceChangedEvent.html +++ b/api-reference/interfaces/PresenceChangedEvent.html @@ -1,4 +1,4 @@ -PresenceChangedEvent | yorkie-js-sdk

    Interface PresenceChangedEvent<P>

    interface PresenceChangedEvent<P> {
        source: OpSource;
        type: PresenceChanged;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • PresenceChangedEvent

    Properties

    source +PresenceChangedEvent | yorkie-js-sdk

    Interface PresenceChangedEvent<P>

    interface PresenceChangedEvent<P> {
        source: OpSource;
        type: PresenceChanged;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • PresenceChangedEvent

    Properties

    Properties

    source: OpSource
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file +

    Properties

    source: OpSource
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file diff --git a/api-reference/interfaces/RemoteChangeEvent.html b/api-reference/interfaces/RemoteChangeEvent.html index 672b7ecb7..9a58b7976 100644 --- a/api-reference/interfaces/RemoteChangeEvent.html +++ b/api-reference/interfaces/RemoteChangeEvent.html @@ -1,8 +1,8 @@ RemoteChangeEvent | yorkie-js-sdk

    Interface RemoteChangeEvent<T, P>

    RemoteChangeEvent is an event that occurs when the document is changed by remote changes.

    -
    interface RemoteChangeEvent<T, P> {
        rawChange?: ChangeStruct<P>;
        source: Remote;
        type: RemoteChange;
        value: ChangeInfo<T>;
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • RemoteChangeEvent

    Properties

    interface RemoteChangeEvent<T, P> {
        rawChange?: ChangeStruct<P>;
        source: Remote;
        type: RemoteChange;
        value: ChangeInfo<T>;
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • RemoteChangeEvent

    Properties

    rawChange?: ChangeStruct<P>
    source: Remote

    enum DocEventType.RemoteChange

    -
    value: ChangeInfo<T>
    \ No newline at end of file +

    Properties

    rawChange?: ChangeStruct<P>
    source: Remote

    enum DocEventType.RemoteChange

    +
    value: ChangeInfo<T>
    \ No newline at end of file diff --git a/api-reference/interfaces/SnapshotEvent.html b/api-reference/interfaces/SnapshotEvent.html index 6f4526788..57a6b5461 100644 --- a/api-reference/interfaces/SnapshotEvent.html +++ b/api-reference/interfaces/SnapshotEvent.html @@ -1,7 +1,7 @@ SnapshotEvent | yorkie-js-sdk

    Interface SnapshotEvent

    SnapshotEvent is an event that occurs when a snapshot is received from the server.

    -
    interface SnapshotEvent {
        source: Remote;
        type: Snapshot;
        value: {
            serverSeq: string;
            snapshot: undefined | string;
            snapshotVector: string;
        };
    }

    Hierarchy

    • BaseDocEvent
      • SnapshotEvent

    Properties

    interface SnapshotEvent {
        source: Remote;
        type: Snapshot;
        value: {
            serverSeq: string;
            snapshot: undefined | string;
            snapshotVector: string;
        };
    }

    Hierarchy

    • BaseDocEvent
      • SnapshotEvent

    Properties

    Properties

    source: Remote
    type: Snapshot

    enum DocEventType.Snapshot

    -
    value: {
        serverSeq: string;
        snapshot: undefined | string;
        snapshotVector: string;
    }

    Type declaration

    • serverSeq: string
    • snapshot: undefined | string
    • snapshotVector: string
    \ No newline at end of file +

    Properties

    source: Remote
    type: Snapshot

    enum DocEventType.Snapshot

    +
    value: {
        serverSeq: string;
        snapshot: undefined | string;
        snapshotVector: string;
    }

    Type declaration

    • serverSeq: string
    • snapshot: undefined | string
    • snapshotVector: string
    \ No newline at end of file diff --git a/api-reference/interfaces/SyncStatusChangedEvent.html b/api-reference/interfaces/SyncStatusChangedEvent.html index ac3bfbbbb..2f029da68 100644 --- a/api-reference/interfaces/SyncStatusChangedEvent.html +++ b/api-reference/interfaces/SyncStatusChangedEvent.html @@ -1,5 +1,5 @@ SyncStatusChangedEvent | yorkie-js-sdk

    Interface SyncStatusChangedEvent

    SyncStatusChangedEvent is an event that occurs when document is synced with the server.

    -
    interface SyncStatusChangedEvent {
        type: SyncStatusChanged;
        value: DocSyncStatus;
    }

    Hierarchy

    • BaseDocEvent
      • SyncStatusChangedEvent

    Properties

    interface SyncStatusChangedEvent {
        type: SyncStatusChanged;
        value: DocSyncStatus;
    }

    Hierarchy

    • BaseDocEvent
      • SyncStatusChangedEvent

    Properties

    Properties

    enum DocEventType.SyncStatusChanged

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/interfaces/UnwatchedEvent.html b/api-reference/interfaces/UnwatchedEvent.html index 38658b004..e6131a671 100644 --- a/api-reference/interfaces/UnwatchedEvent.html +++ b/api-reference/interfaces/UnwatchedEvent.html @@ -1,4 +1,4 @@ -UnwatchedEvent | yorkie-js-sdk

    Interface UnwatchedEvent<P>

    interface UnwatchedEvent<P> {
        source: Remote;
        type: Unwatched;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • UnwatchedEvent

    Properties

    source +UnwatchedEvent | yorkie-js-sdk

    Interface UnwatchedEvent<P>

    interface UnwatchedEvent<P> {
        source: Remote;
        type: Unwatched;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • UnwatchedEvent

    Properties

    Properties

    source: Remote
    type: Unwatched
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file +

    Properties

    source: Remote
    type: Unwatched
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file diff --git a/api-reference/interfaces/WatchedEvent.html b/api-reference/interfaces/WatchedEvent.html index 4d30c28e7..fe9d57df8 100644 --- a/api-reference/interfaces/WatchedEvent.html +++ b/api-reference/interfaces/WatchedEvent.html @@ -1,4 +1,4 @@ -WatchedEvent | yorkie-js-sdk

    Interface WatchedEvent<P>

    interface WatchedEvent<P> {
        source: Remote;
        type: Watched;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • WatchedEvent

    Properties

    source +WatchedEvent | yorkie-js-sdk

    Interface WatchedEvent<P>

    interface WatchedEvent<P> {
        source: Remote;
        type: Watched;
        value: {
            clientID: string;
            presence: P;
        };
    }

    Type Parameters

    Hierarchy

    • BaseDocEvent
      • WatchedEvent

    Properties

    Properties

    source: Remote
    type: Watched
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file +

    Properties

    source: Remote
    type: Watched
    value: {
        clientID: string;
        presence: P;
    }

    Type declaration

    • clientID: string
    • presence: P
    \ No newline at end of file diff --git a/api-reference/modules/Devtools.html b/api-reference/modules/Devtools.html index d936970c4..5ac65982b 100644 --- a/api-reference/modules/Devtools.html +++ b/api-reference/modules/Devtools.html @@ -1,4 +1,4 @@ -Devtools | yorkie-js-sdk

    Namespace Devtools

    Index

    Type Aliases

    Client +Devtools | yorkie-js-sdk

    Namespace Devtools

    Index

    Type Aliases

    Client ContainerValue JSONElement TreeNodeInfo diff --git a/api-reference/types/ActorID.html b/api-reference/types/ActorID.html index e1112213c..633cece4f 100644 --- a/api-reference/types/ActorID.html +++ b/api-reference/types/ActorID.html @@ -1,3 +1,3 @@ ActorID | yorkie-js-sdk

    Type alias ActorID

    ActorID: string

    ActorID is used to identify who is making changes to the document. It is a hexadecimal string and should be generated by a unique value.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/AddOpInfo.html b/api-reference/types/AddOpInfo.html index 7a62c7b11..358b81859 100644 --- a/api-reference/types/AddOpInfo.html +++ b/api-reference/types/AddOpInfo.html @@ -1,2 +1,2 @@ AddOpInfo | yorkie-js-sdk

    Type alias AddOpInfo

    AddOpInfo: {
        index: number;
        path: string;
        type: "add";
    }

    AddOpInfo represents the information of the add operation.

    -

    Type declaration

    • index: number
    • path: string
    • type: "add"
    \ No newline at end of file +

    Type declaration

    • index: number
    • path: string
    • type: "add"
    \ No newline at end of file diff --git a/api-reference/types/ArrayOperationInfo.html b/api-reference/types/ArrayOperationInfo.html index ae9aee46a..070e98ee1 100644 --- a/api-reference/types/ArrayOperationInfo.html +++ b/api-reference/types/ArrayOperationInfo.html @@ -1,2 +1,2 @@ ArrayOperationInfo | yorkie-js-sdk

    Type alias ArrayOperationInfo

    ArrayOperationInfo: AddOpInfo | RemoveOpInfo | MoveOpInfo

    ArrayOperationInfo represents the OperationInfo for the JSONArray.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/CRDTTreeNodeIDStruct.html b/api-reference/types/CRDTTreeNodeIDStruct.html index 905bcd49d..9c4a3350f 100644 --- a/api-reference/types/CRDTTreeNodeIDStruct.html +++ b/api-reference/types/CRDTTreeNodeIDStruct.html @@ -1,3 +1,3 @@ CRDTTreeNodeIDStruct | yorkie-js-sdk

    Type alias CRDTTreeNodeIDStruct

    CRDTTreeNodeIDStruct: {
        createdAt: TimeTicketStruct;
        offset: number;
    }

    CRDTTreeNodeIDStruct represents the structure of CRDTTreeNodeID. It is used to serialize and deserialize the CRDTTreeNodeID.

    -

    Type declaration

    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/CompleteFn.html b/api-reference/types/CompleteFn.html index 5cef46fd1..043e73125 100644 --- a/api-reference/types/CompleteFn.html +++ b/api-reference/types/CompleteFn.html @@ -1 +1 @@ -CompleteFn | yorkie-js-sdk

    Type alias CompleteFn

    CompleteFn: (() => void)

    Type declaration

      • (): void
      • Returns void

    \ No newline at end of file +CompleteFn | yorkie-js-sdk

    Type alias CompleteFn

    CompleteFn: (() => void)

    Type declaration

      • (): void
      • Returns void

    \ No newline at end of file diff --git a/api-reference/types/CounterOperationInfo.html b/api-reference/types/CounterOperationInfo.html index 92776f9a4..40ac2f0b4 100644 --- a/api-reference/types/CounterOperationInfo.html +++ b/api-reference/types/CounterOperationInfo.html @@ -1,2 +1,2 @@ CounterOperationInfo | yorkie-js-sdk

    Type alias CounterOperationInfo

    CounterOperationInfo: IncreaseOpInfo

    CounterOperationInfo represents the OperationInfo for the yorkie.Counter.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/CounterValue.html b/api-reference/types/CounterValue.html index 4b0265284..fca1e65e7 100644 --- a/api-reference/types/CounterValue.html +++ b/api-reference/types/CounterValue.html @@ -1 +1 @@ -CounterValue | yorkie-js-sdk

    Type alias CounterValue

    CounterValue: number | Long
    \ No newline at end of file +CounterValue | yorkie-js-sdk

    Type alias CounterValue

    CounterValue: number | Long
    \ No newline at end of file diff --git a/api-reference/types/Devtools.Client.html b/api-reference/types/Devtools.Client.html index 74d149c58..9bbd85df4 100644 --- a/api-reference/types/Devtools.Client.html +++ b/api-reference/types/Devtools.Client.html @@ -1,2 +1,2 @@ Client | yorkie-js-sdk
    Client: {
        clientID: string;
        presence: Json;
    }

    Client represents a client value in devtools.

    -

    Type declaration

    • clientID: string
    • presence: Json
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/Devtools.ContainerValue.html b/api-reference/types/Devtools.ContainerValue.html index 6ea39db17..1cef3f5f5 100644 --- a/api-reference/types/Devtools.ContainerValue.html +++ b/api-reference/types/Devtools.ContainerValue.html @@ -1,3 +1,3 @@ ContainerValue | yorkie-js-sdk

    Type alias ContainerValue

    ContainerValue: {
        [key: string]: Devtools.JSONElement;
    }

    ContainerValue represents the result of Array.toJSForTest() and Object.toJSForTest().

    -

    Type declaration

    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/Devtools.JSONElement.html b/api-reference/types/Devtools.JSONElement.html index 1d9145700..2e4e9f616 100644 --- a/api-reference/types/Devtools.JSONElement.html +++ b/api-reference/types/Devtools.JSONElement.html @@ -1,2 +1,2 @@ JSONElement | yorkie-js-sdk

    Type alias JSONElement

    JSONElement: {
        createdAt: string;
        key?: string;
        type: JSONElementType;
        value: JSONElementValue;
    }

    JSONElement represents the result of Element.toJSForTest().

    -

    Type declaration

    • createdAt: string
    • Optional key?: string
    • type: JSONElementType
    • value: JSONElementValue
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/Devtools.TreeNodeInfo.html b/api-reference/types/Devtools.TreeNodeInfo.html index 396478a84..0ec6c6d76 100644 --- a/api-reference/types/Devtools.TreeNodeInfo.html +++ b/api-reference/types/Devtools.TreeNodeInfo.html @@ -1,2 +1,2 @@ TreeNodeInfo | yorkie-js-sdk

    Type alias TreeNodeInfo

    TreeNodeInfo: {
        attributes?: object;
        children: TreeNodeInfo[];
        depth: number;
        id: string;
        index?: number;
        insNext?: string;
        insPrev?: string;
        isRemoved: boolean;
        parent?: string;
        path?: number[];
        pos?: CRDTTreePosStruct;
        removedAt?: string;
        size: number;
        type: string;
        value?: string;
    }

    TreeNodeInfo represents the crdt tree node information in devtools.

    -

    Type declaration

    • Optional attributes?: object
    • children: TreeNodeInfo[]
    • depth: number
    • id: string
    • Optional index?: number
    • Optional insNext?: string
    • Optional insPrev?: string
    • isRemoved: boolean
    • Optional parent?: string
    • Optional path?: number[]
    • Optional pos?: CRDTTreePosStruct
    • Optional removedAt?: string
    • size: number
    • type: string
    • Optional value?: string
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/DocEvent.html b/api-reference/types/DocEvent.html index af1a0b15b..d6b9e8df3 100644 --- a/api-reference/types/DocEvent.html +++ b/api-reference/types/DocEvent.html @@ -1,3 +1,3 @@ DocEvent | yorkie-js-sdk

    Type alias DocEvent<P, T>

    DocEvent<P, T>: StatusChangedEvent | ConnectionChangedEvent | SyncStatusChangedEvent | SnapshotEvent | LocalChangeEvent<T, P> | RemoteChangeEvent<T, P> | InitializedEvent<P> | WatchedEvent<P> | UnwatchedEvent<P> | PresenceChangedEvent<P> | BroadcastEvent | LocalBroadcastEvent | AuthErrorEvent

    DocEvent is an event that occurs in Document. It can be delivered using Document.subscribe().

    -

    Type Parameters

    \ No newline at end of file +

    Type Parameters

    \ No newline at end of file diff --git a/api-reference/types/EditOpInfo.html b/api-reference/types/EditOpInfo.html index 36c141835..892378609 100644 --- a/api-reference/types/EditOpInfo.html +++ b/api-reference/types/EditOpInfo.html @@ -1,2 +1,2 @@ EditOpInfo | yorkie-js-sdk

    Type alias EditOpInfo

    EditOpInfo: {
        from: number;
        path: string;
        to: number;
        type: "edit";
        value: {
            attributes: Indexable;
            content: string;
        };
    }

    EditOpInfo represents the information of the edit operation.

    -

    Type declaration

    • from: number
    • path: string
    • to: number
    • type: "edit"
    • value: {
          attributes: Indexable;
          content: string;
      }
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/ElementNode.html b/api-reference/types/ElementNode.html index 88d08f67b..73b042cd4 100644 --- a/api-reference/types/ElementNode.html +++ b/api-reference/types/ElementNode.html @@ -1,2 +1,2 @@ ElementNode | yorkie-js-sdk

    Type alias ElementNode<A>

    ElementNode<A>: {
        attributes?: A;
        children: TreeNode[];
        type: TreeNodeType;
    }

    ElementNode represents an element node. It has an attributes and children.

    -

    Type Parameters

    Type declaration

    • Optional attributes?: A
    • children: TreeNode[]
    • type: TreeNodeType
    \ No newline at end of file +

    Type Parameters

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/ErrorFn.html b/api-reference/types/ErrorFn.html index 3fd6df7fc..f6dd1d791 100644 --- a/api-reference/types/ErrorFn.html +++ b/api-reference/types/ErrorFn.html @@ -1 +1 @@ -ErrorFn | yorkie-js-sdk

    Type alias ErrorFn

    ErrorFn: ((error) => void)

    Type declaration

      • (error): void
      • Parameters

        • error: Error

        Returns void

    \ No newline at end of file +ErrorFn | yorkie-js-sdk

    Type alias ErrorFn

    ErrorFn: ((error) => void)

    Type declaration

      • (error): void
      • Parameters

        • error: Error

        Returns void

    \ No newline at end of file diff --git a/api-reference/types/FullPanelToSDKMessage.html b/api-reference/types/FullPanelToSDKMessage.html index 79f792368..6704ec825 100644 --- a/api-reference/types/FullPanelToSDKMessage.html +++ b/api-reference/types/FullPanelToSDKMessage.html @@ -1 +1 @@ -FullPanelToSDKMessage | yorkie-js-sdk

    Type alias FullPanelToSDKMessage

    FullPanelToSDKMessage: PanelToSDKMessage & {
        source: "yorkie-devtools-panel";
    }

    Type declaration

    • source: "yorkie-devtools-panel"
    \ No newline at end of file +FullPanelToSDKMessage | yorkie-js-sdk

    Type alias FullPanelToSDKMessage

    FullPanelToSDKMessage: PanelToSDKMessage & {
        source: "yorkie-devtools-panel";
    }

    Type declaration

    • source: "yorkie-devtools-panel"
    \ No newline at end of file diff --git a/api-reference/types/FullSDKToPanelMessage.html b/api-reference/types/FullSDKToPanelMessage.html index 547f8e9cc..bb04e785c 100644 --- a/api-reference/types/FullSDKToPanelMessage.html +++ b/api-reference/types/FullSDKToPanelMessage.html @@ -1 +1 @@ -FullSDKToPanelMessage | yorkie-js-sdk

    Type alias FullSDKToPanelMessage

    FullSDKToPanelMessage: SDKToPanelMessage & {
        source: "yorkie-devtools-sdk";
    }

    Type declaration

    • source: "yorkie-devtools-sdk"
    \ No newline at end of file +FullSDKToPanelMessage | yorkie-js-sdk

    Type alias FullSDKToPanelMessage

    FullSDKToPanelMessage: SDKToPanelMessage & {
        source: "yorkie-devtools-sdk";
    }

    Type declaration

    • source: "yorkie-devtools-sdk"
    \ No newline at end of file diff --git a/api-reference/types/IncreaseOpInfo.html b/api-reference/types/IncreaseOpInfo.html index ad214197b..5a7c88b49 100644 --- a/api-reference/types/IncreaseOpInfo.html +++ b/api-reference/types/IncreaseOpInfo.html @@ -1,2 +1,2 @@ IncreaseOpInfo | yorkie-js-sdk

    Type alias IncreaseOpInfo

    IncreaseOpInfo: {
        path: string;
        type: "increase";
        value: number;
    }

    IncreaseOpInfo represents the information of the increase operation.

    -

    Type declaration

    • path: string
    • type: "increase"
    • value: number
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/Indexable.html b/api-reference/types/Indexable.html index 8a588b4bf..d1fdb683d 100644 --- a/api-reference/types/Indexable.html +++ b/api-reference/types/Indexable.html @@ -1,3 +1,3 @@ Indexable | yorkie-js-sdk

    Type alias Indexable

    Indexable: Record<string, Json>

    Indexable represents the type of the indexable object. It is used to represent the presence information of the client.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/JSONArray.html b/api-reference/types/JSONArray.html index 604ddfc8d..a02f78367 100644 --- a/api-reference/types/JSONArray.html +++ b/api-reference/types/JSONArray.html @@ -1,17 +1,17 @@ JSONArray | yorkie-js-sdk

    Type alias JSONArray<T>

    JSONArray<T>: {
        deleteByID?(createdAt): WrappedElement<T>;
        getElementByID?(createdAt): WrappedElement<T>;
        getElementByIndex?(index): WrappedElement<T>;
        getID?(): TimeTicket;
        getLast?(): WrappedElement<T>;
        insertAfter?(prevID, value): WrappedElement<T>;
        insertBefore?(nextID, value): WrappedElement<T>;
        moveAfter?(prevID, id): void;
        moveBefore?(nextID, id): void;
        moveFront?(id): void;
        moveLast?(id): void;
        toJSForTest?(): Devtools.JSONElement;
        toTestString?(): string;
    } & T[]

    JSONArray represents JSON array, but unlike regular JSON, it has time tickets created by a logical clock to resolve conflicts.

    Type Parameters

    • T

    Type declaration

    \ No newline at end of file +

    Returns string

    \ No newline at end of file diff --git a/api-reference/types/JSONElement.html b/api-reference/types/JSONElement.html index ca90f62e8..89e1e522a 100644 --- a/api-reference/types/JSONElement.html +++ b/api-reference/types/JSONElement.html @@ -1,3 +1,3 @@ JSONElement | yorkie-js-sdk

    Type alias JSONElement<T, A>

    JSONElement<T, A>: PrimitiveValue | JSONObject<T> | JSONArray<T> | Text<A> | Counter | Tree

    JSONElement is a wrapper for CRDTElement that provides users with an easy-to-use interface for manipulating Documents.

    -

    Type Parameters

    \ No newline at end of file +

    Type Parameters

    \ No newline at end of file diff --git a/api-reference/types/JSONObject.html b/api-reference/types/JSONObject.html index a9c0da134..69f1cd208 100644 --- a/api-reference/types/JSONObject.html +++ b/api-reference/types/JSONObject.html @@ -1,7 +1,7 @@ JSONObject | yorkie-js-sdk

    Type alias JSONObject<T>

    JSONObject<T>: {
        getID?(): TimeTicket;
        toJS?(): T;
        toJSForTest?(): Devtools.JSONElement;
        toJSON?(): string;
    } & T

    JSONObject represents a JSON object, but unlike regular JSON, it has time tickets created by a logical clock to resolve conflicts.

    Type Parameters

    • T

    Type declaration

    \ No newline at end of file +

    Returns TimeTicket

  • toJS?:function
  • toJSForTest?:function
  • toJSON?:function
  • \ No newline at end of file diff --git a/api-reference/types/MoveOpInfo.html b/api-reference/types/MoveOpInfo.html index d49e7243c..8f4bdf7ab 100644 --- a/api-reference/types/MoveOpInfo.html +++ b/api-reference/types/MoveOpInfo.html @@ -1,2 +1,2 @@ MoveOpInfo | yorkie-js-sdk

    Type alias MoveOpInfo

    MoveOpInfo: {
        index: number;
        path: string;
        previousIndex: number;
        type: "move";
    }

    MoveOpInfo represents the information of the move operation.

    -

    Type declaration

    • index: number
    • path: string
    • previousIndex: number
    • type: "move"
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/NextFn.html b/api-reference/types/NextFn.html index 936e5747f..184a34918 100644 --- a/api-reference/types/NextFn.html +++ b/api-reference/types/NextFn.html @@ -1 +1 @@ -NextFn | yorkie-js-sdk

    Type alias NextFn<T>

    NextFn<T>: ((value) => void)

    Type Parameters

    • T

    Type declaration

      • (value): void
      • Parameters

        • value: T

        Returns void

    \ No newline at end of file +NextFn | yorkie-js-sdk

    Type alias NextFn<T>

    NextFn<T>: ((value) => void)

    Type Parameters

    • T

    Type declaration

      • (value): void
      • Parameters

        • value: T

        Returns void

    \ No newline at end of file diff --git a/api-reference/types/ObjectOperationInfo.html b/api-reference/types/ObjectOperationInfo.html index 20c9bdcdd..bcded46da 100644 --- a/api-reference/types/ObjectOperationInfo.html +++ b/api-reference/types/ObjectOperationInfo.html @@ -1,2 +1,2 @@ ObjectOperationInfo | yorkie-js-sdk

    Type alias ObjectOperationInfo

    ObjectOperationInfo: SetOpInfo | RemoveOpInfo

    ObjectOperationInfo represents the OperationInfo for the JSONObject.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/OperationInfo.html b/api-reference/types/OperationInfo.html index 46db92cbb..037d87168 100644 --- a/api-reference/types/OperationInfo.html +++ b/api-reference/types/OperationInfo.html @@ -1,3 +1,3 @@ OperationInfo | yorkie-js-sdk

    Type alias OperationInfo

    OperationInfo represents the information of an operation. It is used to inform to the user what kind of operation was executed.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/PanelToSDKMessage.html b/api-reference/types/PanelToSDKMessage.html index b21874afa..e37150eb7 100644 --- a/api-reference/types/PanelToSDKMessage.html +++ b/api-reference/types/PanelToSDKMessage.html @@ -1,2 +1,2 @@ PanelToSDKMessage | yorkie-js-sdk

    Type alias PanelToSDKMessage

    PanelToSDKMessage: {
        msg: "devtools::connect";
    } | {
        msg: "devtools::disconnect";
    } | {
        docKey: string;
        msg: "devtools::subscribe";
    }

    PanelToSDKMessage is a message sent from the Devtools panel to the SDK.

    -

    Type declaration

    • msg: "devtools::connect"

    Type declaration

    • msg: "devtools::disconnect"

    Type declaration

    • docKey: string
    • msg: "devtools::subscribe"
    \ No newline at end of file +

    Type declaration

    Type declaration

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/PrimitiveValue.html b/api-reference/types/PrimitiveValue.html index 96bea57bb..efd3fa60a 100644 --- a/api-reference/types/PrimitiveValue.html +++ b/api-reference/types/PrimitiveValue.html @@ -1,3 +1,3 @@ PrimitiveValue | yorkie-js-sdk

    Type alias PrimitiveValue

    PrimitiveValue: null | boolean | number | Long | string | Uint8Array | Date

    PrimitiveValue represents a value of primitive type. Only values of type included in PrimitiveValue can be set to the document.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/RemoveOpInfo.html b/api-reference/types/RemoveOpInfo.html index cc102a85d..134d3d009 100644 --- a/api-reference/types/RemoveOpInfo.html +++ b/api-reference/types/RemoveOpInfo.html @@ -1,2 +1,2 @@ RemoveOpInfo | yorkie-js-sdk

    Type alias RemoveOpInfo

    RemoveOpInfo: {
        index?: number;
        key?: string;
        path: string;
        type: "remove";
    }

    RemoveOpInfo represents the information of the remove operation.

    -

    Type declaration

    • Optional index?: number
    • Optional key?: string
    • path: string
    • type: "remove"
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/SDKToPanelMessage.html b/api-reference/types/SDKToPanelMessage.html index 8ae17977d..01b7dcfb7 100644 --- a/api-reference/types/SDKToPanelMessage.html +++ b/api-reference/types/SDKToPanelMessage.html @@ -1,2 +1,2 @@ SDKToPanelMessage | yorkie-js-sdk

    Type alias SDKToPanelMessage

    SDKToPanelMessage: {
        msg: "refresh-devtools";
    } | {
        docKey: string;
        msg: "doc::available";
    } | {
        docKey: string;
        events: TransactionEvent[];
        msg: "doc::sync::full";
    } | {
        docKey: string;
        event: TransactionEvent;
        msg: "doc::sync::partial";
    }

    Definition of all messages the SDK can send to the Devtools panel.

    -

    Type declaration

    • msg: "refresh-devtools"

    Type declaration

    • docKey: string
    • msg: "doc::available"

    Type declaration

    Type declaration

    \ No newline at end of file +

    Type declaration

    Type declaration

    Type declaration

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/SetOpInfo.html b/api-reference/types/SetOpInfo.html index bb5b80f51..d834627ed 100644 --- a/api-reference/types/SetOpInfo.html +++ b/api-reference/types/SetOpInfo.html @@ -1,2 +1,2 @@ SetOpInfo | yorkie-js-sdk

    Type alias SetOpInfo

    SetOpInfo: {
        key: string;
        path: string;
        type: "set";
    }

    SetOpInfo represents the information of the set operation.

    -

    Type declaration

    • key: string
    • path: string
    • type: "set"
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/StyleOpInfo.html b/api-reference/types/StyleOpInfo.html index 3dc0a4358..37ac2cccf 100644 --- a/api-reference/types/StyleOpInfo.html +++ b/api-reference/types/StyleOpInfo.html @@ -1,2 +1,2 @@ StyleOpInfo | yorkie-js-sdk

    Type alias StyleOpInfo

    StyleOpInfo: {
        from: number;
        path: string;
        to: number;
        type: "style";
        value: {
            attributes: Indexable;
        };
    }

    StyleOpInfo represents the information of the style operation.

    -

    Type declaration

    • from: number
    • path: string
    • to: number
    • type: "style"
    • value: {
          attributes: Indexable;
      }
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TextNode.html b/api-reference/types/TextNode.html index e17d86607..75f85f407 100644 --- a/api-reference/types/TextNode.html +++ b/api-reference/types/TextNode.html @@ -1,2 +1,2 @@ TextNode | yorkie-js-sdk

    Type alias TextNode

    TextNode: {
        type: typeof DefaultTextType;
        value: string;
    }

    TextNode represents a text node. It has a string value.

    -

    Type declaration

    • type: typeof DefaultTextType
    • value: string
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TextOperationInfo.html b/api-reference/types/TextOperationInfo.html index 34e6e47cf..4a3d644c6 100644 --- a/api-reference/types/TextOperationInfo.html +++ b/api-reference/types/TextOperationInfo.html @@ -1,2 +1,2 @@ TextOperationInfo | yorkie-js-sdk

    Type alias TextOperationInfo

    TextOperationInfo: EditOpInfo | StyleOpInfo

    TextOperationInfo represents the OperationInfo for the yorkie.Text.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/TextPosStruct.html b/api-reference/types/TextPosStruct.html index f1c7911da..22f471c25 100644 --- a/api-reference/types/TextPosStruct.html +++ b/api-reference/types/TextPosStruct.html @@ -1,3 +1,3 @@ TextPosStruct | yorkie-js-sdk

    Type alias TextPosStruct

    TextPosStruct: {
        id: {
            createdAt: TimeTicketStruct;
            offset: number;
        };
        relativeOffset: number;
    }

    TextPosStruct represents the structure of RGATreeSplitPos. It is used to serialize and deserialize the RGATreeSplitPos.

    -

    Type declaration

    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TextPosStructRange.html b/api-reference/types/TextPosStructRange.html index 6e29b0e1e..448fa94b4 100644 --- a/api-reference/types/TextPosStructRange.html +++ b/api-reference/types/TextPosStructRange.html @@ -1,3 +1,3 @@ TextPosStructRange | yorkie-js-sdk

    Type alias TextPosStructRange

    TextPosStructRange: [TextPosStruct, TextPosStruct]

    TextPosStructRange represents the structure of RGATreeSplitPosRange. It is used to serialize and deserialize the RGATreeSplitPosRange.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/TimeTicketStruct.html b/api-reference/types/TimeTicketStruct.html index e09d56b57..20356897c 100644 --- a/api-reference/types/TimeTicketStruct.html +++ b/api-reference/types/TimeTicketStruct.html @@ -1,3 +1,3 @@ TimeTicketStruct | yorkie-js-sdk

    Type alias TimeTicketStruct

    TimeTicketStruct: {
        actorID: ActorID;
        delimiter: number;
        lamport: string;
    }

    TimeTicketStruct is a structure represents the meta data of the ticket. It is used to serialize and deserialize the ticket.

    -

    Type declaration

    • actorID: ActorID
    • delimiter: number
    • lamport: string
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TransactionEvent.html b/api-reference/types/TransactionEvent.html index dd1ad3b01..dd9fa33ad 100644 --- a/api-reference/types/TransactionEvent.html +++ b/api-reference/types/TransactionEvent.html @@ -1,3 +1,3 @@ TransactionEvent | yorkie-js-sdk

    Type alias TransactionEvent<P>

    TransactionEvent<P>: DocEvent<P>[]

    TransactionEvent represents document events that occur within a single transaction (e.g., doc.update).

    -

    Type Parameters

    \ No newline at end of file +

    Type Parameters

    \ No newline at end of file diff --git a/api-reference/types/TreeChange.html b/api-reference/types/TreeChange.html index 3e987412b..15d9321c9 100644 --- a/api-reference/types/TreeChange.html +++ b/api-reference/types/TreeChange.html @@ -1,2 +1,2 @@ TreeChange | yorkie-js-sdk

    Type alias TreeChange

    TreeChange: {
        actor: ActorID;
        from: number;
        fromPath: number[];
        splitLevel?: number;
        to: number;
        toPath: number[];
        type: Content;
        value?: TreeNode[];
    } | {
        actor: ActorID;
        from: number;
        fromPath: number[];
        splitLevel?: number;
        to: number;
        toPath: number[];
        type: Style;
        value: {
            [key: string]: string;
        };
    } | {
        actor: ActorID;
        from: number;
        fromPath: number[];
        splitLevel?: number;
        to: number;
        toPath: number[];
        type: RemoveStyle;
        value?: string[];
    }

    TreeChange represents the change in the tree.

    -

    Type declaration

    • actor: ActorID
    • from: number
    • fromPath: number[]
    • Optional splitLevel?: number
    • to: number
    • toPath: number[]
    • type: Content
    • Optional value?: TreeNode[]

    Type declaration

    • actor: ActorID
    • from: number
    • fromPath: number[]
    • Optional splitLevel?: number
    • to: number
    • toPath: number[]
    • type: Style
    • value: {
          [key: string]: string;
      }
      • [key: string]: string

    Type declaration

    • actor: ActorID
    • from: number
    • fromPath: number[]
    • Optional splitLevel?: number
    • to: number
    • toPath: number[]
    • type: RemoveStyle
    • Optional value?: string[]
    \ No newline at end of file +

    Type declaration

    Type declaration

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TreeEditOpInfo.html b/api-reference/types/TreeEditOpInfo.html index 726c17347..258290442 100644 --- a/api-reference/types/TreeEditOpInfo.html +++ b/api-reference/types/TreeEditOpInfo.html @@ -1,2 +1,2 @@ TreeEditOpInfo | yorkie-js-sdk

    Type alias TreeEditOpInfo

    TreeEditOpInfo: {
        from: number;
        fromPath: number[];
        path: string;
        splitLevel?: number;
        to: number;
        toPath: number[];
        type: "tree-edit";
        value?: TreeNode[];
    }

    TreeEditOpInfo represents the information of the tree edit operation.

    -

    Type declaration

    • from: number
    • fromPath: number[]
    • path: string
    • Optional splitLevel?: number
    • to: number
    • toPath: number[]
    • type: "tree-edit"
    • Optional value?: TreeNode[]
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/TreeNode.html b/api-reference/types/TreeNode.html index fe1e9ad72..95fa4dc89 100644 --- a/api-reference/types/TreeNode.html +++ b/api-reference/types/TreeNode.html @@ -1,2 +1,2 @@ TreeNode | yorkie-js-sdk

    Type alias TreeNode

    TreeNode: TextNode | ElementNode

    TreeNode represents a node in the tree.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/TreeOperationInfo.html b/api-reference/types/TreeOperationInfo.html index ca5a26b1c..8f70aad79 100644 --- a/api-reference/types/TreeOperationInfo.html +++ b/api-reference/types/TreeOperationInfo.html @@ -1,2 +1,2 @@ TreeOperationInfo | yorkie-js-sdk

    Type alias TreeOperationInfo

    TreeOperationInfo: TreeEditOpInfo | TreeStyleOpInfo

    TreeOperationInfo represents the OperationInfo for the yorkie.Tree.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/TreePosStructRange.html b/api-reference/types/TreePosStructRange.html index dad27656f..133399195 100644 --- a/api-reference/types/TreePosStructRange.html +++ b/api-reference/types/TreePosStructRange.html @@ -1,3 +1,3 @@ TreePosStructRange | yorkie-js-sdk

    Type alias TreePosStructRange

    TreePosStructRange: [CRDTTreePosStruct, CRDTTreePosStruct]

    TreePosStructRange represents the structure of TreeRange. It is used to serialize and deserialize the TreeRange.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/types/TreeStyleOpInfo.html b/api-reference/types/TreeStyleOpInfo.html index e1a0d536e..5d56611b2 100644 --- a/api-reference/types/TreeStyleOpInfo.html +++ b/api-reference/types/TreeStyleOpInfo.html @@ -1,2 +1,2 @@ TreeStyleOpInfo | yorkie-js-sdk

    Type alias TreeStyleOpInfo

    TreeStyleOpInfo: {
        from: number;
        fromPath: number[];
        path: string;
        to: number;
        toPath: number[];
        type: "tree-style";
        value: {
            attributes?: Indexable;
            attributesToRemove?: string[];
        };
    }

    TreeStyleOpInfo represents the information of the tree style operation.

    -

    Type declaration

    • from: number
    • fromPath: number[]
    • path: string
    • to: number
    • toPath: number[]
    • type: "tree-style"
    • value: {
          attributes?: Indexable;
          attributesToRemove?: string[];
      }
      • Optional attributes?: Indexable
      • Optional attributesToRemove?: string[]
    \ No newline at end of file +

    Type declaration

    \ No newline at end of file diff --git a/api-reference/types/Unsubscribe.html b/api-reference/types/Unsubscribe.html index f70743503..3e3ecd5be 100644 --- a/api-reference/types/Unsubscribe.html +++ b/api-reference/types/Unsubscribe.html @@ -1 +1 @@ -Unsubscribe | yorkie-js-sdk

    Type alias Unsubscribe

    Unsubscribe: (() => void)

    Type declaration

      • (): void
      • Returns void

    \ No newline at end of file +Unsubscribe | yorkie-js-sdk

    Type alias Unsubscribe

    Unsubscribe: (() => void)

    Type declaration

      • (): void
      • Returns void

    \ No newline at end of file diff --git a/api-reference/types/WrappedElement.html b/api-reference/types/WrappedElement.html index a610f6b0a..241e6c685 100644 --- a/api-reference/types/WrappedElement.html +++ b/api-reference/types/WrappedElement.html @@ -1,2 +1,2 @@ WrappedElement | yorkie-js-sdk

    Type alias WrappedElement<T, A>

    WrappedElement<T, A>: Primitive | JSONObject<T> | JSONArray<T> | Text<A> | Counter | Tree

    WrappedElement is a wrapper of JSONElement that provides getID().

    -

    Type Parameters

    \ No newline at end of file +

    Type Parameters

    \ No newline at end of file diff --git a/api-reference/variables/EventSourceDevPanel.html b/api-reference/variables/EventSourceDevPanel.html index 7d06be57f..32baf3d06 100644 --- a/api-reference/variables/EventSourceDevPanel.html +++ b/api-reference/variables/EventSourceDevPanel.html @@ -1,3 +1,3 @@ EventSourceDevPanel | yorkie-js-sdk

    Variable EventSourceDevPanelConst

    EventSourceDevPanel: "yorkie-devtools-panel" = 'yorkie-devtools-panel'

    EventSourceDevPanel is the name of the source representing messages from the Devtools panel.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/variables/EventSourceSDK.html b/api-reference/variables/EventSourceSDK.html index 896c493a2..0790a7459 100644 --- a/api-reference/variables/EventSourceSDK.html +++ b/api-reference/variables/EventSourceSDK.html @@ -1,3 +1,3 @@ EventSourceSDK | yorkie-js-sdk

    Variable EventSourceSDKConst

    EventSourceSDK: "yorkie-devtools-sdk" = 'yorkie-devtools-sdk'

    EventSourceSDK is the name of the source representing messages from the SDK.

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/api-reference/variables/converter.html b/api-reference/variables/converter.html index 1c03c2188..dbe9fb30d 100644 --- a/api-reference/variables/converter.html +++ b/api-reference/variables/converter.html @@ -19,4 +19,4 @@

    Parameters

    Returns PbOperation

  • toTreeNodes: ((node) => PbTreeNode[])
  • toUint8Array: ((hex) => Uint8Array)
  • versionVectorToHex: ((vector) => string)
  • \ No newline at end of file +

    Parameters

    Returns string

    \ No newline at end of file diff --git a/api-reference/variables/default.html b/api-reference/variables/default.html index d8dd6462c..f1815be78 100644 --- a/api-reference/variables/default.html +++ b/api-reference/variables/default.html @@ -3,4 +3,4 @@ assigned to the yorkie global.

    e.g) new yorkie.Client(...);

    Type declaration

    \ No newline at end of file +

    Parameters

    Returns void

    \ No newline at end of file diff --git a/examples/nextjs-scheduler/404.html b/examples/nextjs-scheduler/404.html index ebec9e9e3..0f3d967da 100644 --- a/examples/nextjs-scheduler/404.html +++ b/examples/nextjs-scheduler/404.html @@ -1 +1 @@ -Next.js react-calendar example

    404 not found

    \ No newline at end of file +Next.js react-calendar example

    404 not found

    \ No newline at end of file diff --git a/examples/nextjs-scheduler/_next/static/chunks/app/page-8756ccd80820a787.js b/examples/nextjs-scheduler/_next/static/chunks/app/page-4229c045ecb9909b.js similarity index 51% rename from examples/nextjs-scheduler/_next/static/chunks/app/page-8756ccd80820a787.js rename to examples/nextjs-scheduler/_next/static/chunks/app/page-4229c045ecb9909b.js index bb61dfc97..d3fc6dc29 100644 --- a/examples/nextjs-scheduler/_next/static/chunks/app/page-8756ccd80820a787.js +++ b/examples/nextjs-scheduler/_next/static/chunks/app/page-4229c045ecb9909b.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{4629:function(e,t,r){Promise.resolve().then(r.bind(r,1802))},1802:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return nv}});var n,i,s,o,a,c,l,h,d,u,g,f,m,p,y,v,w,A,T,S,I,C,x,P,E,b,k,D,R,N,B,O,J,L,_,M,q,z,K=r(3165),F=r(7397),V=r.n(F),U=r(6189);let j=["Alice","Bob","Carol","Chuck","Dave","Erin","Frank","Grace","Ivan","Justin","Matilda","Oscar","Steve","Victor","Zoe"];function W(e){let[t,r,n]=e.toLocaleDateString("en").split("/");return t=Number(t)>9?t:"0"+t,r=Number(r)>9?r:"0"+r,n=n.slice(2),"".concat(r,"-").concat(t,"-").concat(n)}var G=r(8358),H=r(6390),Y=r(4715),Z=r(1582),X=r(8728),Q=r(601),$=r(1089),ee=r(6731),et=r(9782);(n=S||(S={}))[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",Q.w.util.setEnumType(S,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]),(i=I||(I={}))[i.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",i[i.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",i[i.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",i[i.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",Q.w.util.setEnumType(I,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);class er extends X.v{static fromBinary(e,t){return new er().fromBinary(e,t)}static fromJson(e,t){return new er().fromJson(e,t)}static fromJsonString(e,t){return new er().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(er,e,t)}constructor(e){super(),this.presences={},Q.w.util.initPartial(e,this)}}er.runtime=Q.w,er.typeName="yorkie.v1.Snapshot",er.fields=Q.w.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:eA},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:eF}}]);class en extends X.v{static fromBinary(e,t){return new en().fromBinary(e,t)}static fromJson(e,t){return new en().fromJson(e,t)}static fromJsonString(e,t){return new en().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(en,e,t)}constructor(e){super(),this.documentKey="",this.snapshot=new Uint8Array(0),this.changes=[],this.isRemoved=!1,Q.w.util.initPartial(e,this)}}en.runtime=Q.w,en.typeName="yorkie.v1.ChangePack",en.fields=Q.w.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:eV},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:ei,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:ej},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:eo}]);class ei extends X.v{static fromBinary(e,t){return new ei().fromBinary(e,t)}static fromJson(e,t){return new ei().fromJson(e,t)}static fromJsonString(e,t){return new ei().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ei,e,t)}constructor(e){super(),this.message="",this.operations=[],Q.w.util.initPartial(e,this)}}ei.runtime=Q.w,ei.typeName="yorkie.v1.Change",ei.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:es},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:ea,repeated:!0},{no:4,name:"presence_change",kind:"message",T:eK}]);class es extends X.v{static fromBinary(e,t){return new es().fromBinary(e,t)}static fromJson(e,t){return new es().fromJson(e,t)}static fromJsonString(e,t){return new es().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(es,e,t)}constructor(e){super(),this.clientSeq=0,this.serverSeq=$.q.zero,this.lamport=$.q.zero,this.actorId=new Uint8Array(0),Q.w.util.initPartial(e,this)}}es.runtime=Q.w,es.typeName="yorkie.v1.ChangeID",es.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:eo}]);class eo extends X.v{static fromBinary(e,t){return new eo().fromBinary(e,t)}static fromJson(e,t){return new eo().fromJson(e,t)}static fromJsonString(e,t){return new eo().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eo,e,t)}constructor(e){super(),this.vector={},Q.w.util.initPartial(e,this)}}eo.runtime=Q.w,eo.typeName="yorkie.v1.VersionVector",eo.fields=Q.w.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}]);class ea extends X.v{static fromBinary(e,t){return new ea().fromBinary(e,t)}static fromJson(e,t){return new ea().fromJson(e,t)}static fromJsonString(e,t){return new ea().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ea,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}ea.runtime=Q.w,ea.typeName="yorkie.v1.Operation",ea.fields=Q.w.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:ec,oneof:"body"},{no:2,name:"add",kind:"message",T:el,oneof:"body"},{no:3,name:"move",kind:"message",T:eh,oneof:"body"},{no:4,name:"remove",kind:"message",T:ed,oneof:"body"},{no:5,name:"edit",kind:"message",T:eu,oneof:"body"},{no:6,name:"select",kind:"message",T:eg,oneof:"body"},{no:7,name:"style",kind:"message",T:ef,oneof:"body"},{no:8,name:"increase",kind:"message",T:em,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:ep,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ey,oneof:"body"},{no:11,name:"array_set",kind:"message",T:ev,oneof:"body"}]);class ec extends X.v{static fromBinary(e,t){return new ec().fromBinary(e,t)}static fromJson(e,t){return new ec().fromJson(e,t)}static fromJsonString(e,t){return new ec().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ec,e,t)}constructor(e){super(),this.key="",Q.w.util.initPartial(e,this)}}ec.runtime=Q.w,ec.typeName="yorkie.v1.Operation.Set",ec.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class el extends X.v{static fromBinary(e,t){return new el().fromBinary(e,t)}static fromJson(e,t){return new el().fromJson(e,t)}static fromJsonString(e,t){return new el().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(el,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}el.runtime=Q.w,el.typeName="yorkie.v1.Operation.Add",el.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"prev_created_at",kind:"message",T:ej},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class eh extends X.v{static fromBinary(e,t){return new eh().fromBinary(e,t)}static fromJson(e,t){return new eh().fromJson(e,t)}static fromJsonString(e,t){return new eh().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eh,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eh.runtime=Q.w,eh.typeName="yorkie.v1.Operation.Move",eh.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"prev_created_at",kind:"message",T:ej},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"executed_at",kind:"message",T:ej}]);class ed extends X.v{static fromBinary(e,t){return new ed().fromBinary(e,t)}static fromJson(e,t){return new ed().fromJson(e,t)}static fromJsonString(e,t){return new ed().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ed,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}ed.runtime=Q.w,ed.typeName="yorkie.v1.Operation.Remove",ed.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"executed_at",kind:"message",T:ej}]);class eu extends X.v{static fromBinary(e,t){return new eu().fromBinary(e,t)}static fromJson(e,t){return new eu().fromJson(e,t)}static fromJsonString(e,t){return new eu().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eu,e,t)}constructor(e){super(),this.createdAtMapByActor={},this.content="",this.attributes={},Q.w.util.initPartial(e,this)}}eu.runtime=Q.w,eu.typeName="yorkie.v1.Operation.Edit",eu.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:ej},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]);class eg extends X.v{static fromBinary(e,t){return new eg().fromBinary(e,t)}static fromJson(e,t){return new eg().fromJson(e,t)}static fromJsonString(e,t){return new eg().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eg,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eg.runtime=Q.w,eg.typeName="yorkie.v1.Operation.Select",eg.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"executed_at",kind:"message",T:ej}]);class ef extends X.v{static fromBinary(e,t){return new ef().fromBinary(e,t)}static fromJson(e,t){return new ef().fromJson(e,t)}static fromJsonString(e,t){return new ef().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ef,e,t)}constructor(e){super(),this.attributes={},this.createdAtMapByActor={},Q.w.util.initPartial(e,this)}}ef.runtime=Q.w,ef.typeName="yorkie.v1.Operation.Style",ef.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:ej},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}}]);class em extends X.v{static fromBinary(e,t){return new em().fromBinary(e,t)}static fromJson(e,t){return new em().fromJson(e,t)}static fromJsonString(e,t){return new em().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(em,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}em.runtime=Q.w,em.typeName="yorkie.v1.Operation.Increase",em.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"value",kind:"message",T:ew},{no:3,name:"executed_at",kind:"message",T:ej}]);class ep extends X.v{static fromBinary(e,t){return new ep().fromBinary(e,t)}static fromJson(e,t){return new ep().fromJson(e,t)}static fromJsonString(e,t){return new ep().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ep,e,t)}constructor(e){super(),this.createdAtMapByActor={},this.contents=[],this.splitLevel=0,Q.w.util.initPartial(e,this)}}ep.runtime=Q.w,ep.typeName="yorkie.v1.Operation.TreeEdit",ep.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eJ},{no:3,name:"to",kind:"message",T:eJ},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}},{no:5,name:"contents",kind:"message",T:eB,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:ej}]);class ey extends X.v{static fromBinary(e,t){return new ey().fromBinary(e,t)}static fromJson(e,t){return new ey().fromJson(e,t)}static fromJsonString(e,t){return new ey().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ey,e,t)}constructor(e){super(),this.attributes={},this.attributesToRemove=[],this.createdAtMapByActor={},Q.w.util.initPartial(e,this)}}ey.runtime=Q.w,ey.typeName="yorkie.v1.Operation.TreeStyle",ey.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eJ},{no:3,name:"to",kind:"message",T:eJ},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:ej},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}}]);class ev extends X.v{static fromBinary(e,t){return new ev().fromBinary(e,t)}static fromJson(e,t){return new ev().fromJson(e,t)}static fromJsonString(e,t){return new ev().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ev,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}ev.runtime=Q.w,ev.typeName="yorkie.v1.Operation.ArraySet",ev.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class ew extends X.v{static fromBinary(e,t){return new ew().fromBinary(e,t)}static fromJson(e,t){return new ew().fromJson(e,t)}static fromJsonString(e,t){return new ew().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ew,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ew.runtime=Q.w,ew.typeName="yorkie.v1.JSONElementSimple",ew.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"moved_at",kind:"message",T:ej},{no:3,name:"removed_at",kind:"message",T:ej},{no:4,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:5,name:"value",kind:"scalar",T:12}]);class eA extends X.v{static fromBinary(e,t){return new eA().fromBinary(e,t)}static fromJson(e,t){return new eA().fromJson(e,t)}static fromJsonString(e,t){return new eA().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eA,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}eA.runtime=Q.w,eA.typeName="yorkie.v1.JSONElement",eA.fields=Q.w.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:eT,oneof:"body"},{no:2,name:"json_array",kind:"message",T:eS,oneof:"body"},{no:3,name:"primitive",kind:"message",T:eI,oneof:"body"},{no:5,name:"text",kind:"message",T:eC,oneof:"body"},{no:6,name:"counter",kind:"message",T:ex,oneof:"body"},{no:7,name:"tree",kind:"message",T:eP,oneof:"body"}]);class eT extends X.v{static fromBinary(e,t){return new eT().fromBinary(e,t)}static fromJson(e,t){return new eT().fromJson(e,t)}static fromJsonString(e,t){return new eT().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eT,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eT.runtime=Q.w,eT.typeName="yorkie.v1.JSONElement.JSONObject",eT.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eE,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eS extends X.v{static fromBinary(e,t){return new eS().fromBinary(e,t)}static fromJson(e,t){return new eS().fromJson(e,t)}static fromJsonString(e,t){return new eS().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eS,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eS.runtime=Q.w,eS.typeName="yorkie.v1.JSONElement.JSONArray",eS.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eb,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eI extends X.v{static fromBinary(e,t){return new eI().fromBinary(e,t)}static fromJson(e,t){return new eI().fromJson(e,t)}static fromJsonString(e,t){return new eI().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eI,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}eI.runtime=Q.w,eI.typeName="yorkie.v1.JSONElement.Primitive",eI.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"moved_at",kind:"message",T:ej},{no:5,name:"removed_at",kind:"message",T:ej}]);class eC extends X.v{static fromBinary(e,t){return new eC().fromBinary(e,t)}static fromJson(e,t){return new eC().fromJson(e,t)}static fromJsonString(e,t){return new eC().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eC,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eC.runtime=Q.w,eC.typeName="yorkie.v1.JSONElement.Text",eC.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eD,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class ex extends X.v{static fromBinary(e,t){return new ex().fromBinary(e,t)}static fromJson(e,t){return new ex().fromJson(e,t)}static fromJsonString(e,t){return new ex().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ex,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ex.runtime=Q.w,ex.typeName="yorkie.v1.JSONElement.Counter",ex.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"moved_at",kind:"message",T:ej},{no:5,name:"removed_at",kind:"message",T:ej}]);class eP extends X.v{static fromBinary(e,t){return new eP().fromBinary(e,t)}static fromJson(e,t){return new eP().fromJson(e,t)}static fromJsonString(e,t){return new eP().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eP,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eP.runtime=Q.w,eP.typeName="yorkie.v1.JSONElement.Tree",eP.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eN,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eE extends X.v{static fromBinary(e,t){return new eE().fromBinary(e,t)}static fromJson(e,t){return new eE().fromJson(e,t)}static fromJsonString(e,t){return new eE().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eE,e,t)}constructor(e){super(),this.key="",Q.w.util.initPartial(e,this)}}eE.runtime=Q.w,eE.typeName="yorkie.v1.RHTNode",eE.fields=Q.w.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:eA}]);class eb extends X.v{static fromBinary(e,t){return new eb().fromBinary(e,t)}static fromJson(e,t){return new eb().fromJson(e,t)}static fromJsonString(e,t){return new eb().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eb,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eb.runtime=Q.w,eb.typeName="yorkie.v1.RGANode",eb.fields=Q.w.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:eb},{no:2,name:"element",kind:"message",T:eA}]);class ek extends X.v{static fromBinary(e,t){return new ek().fromBinary(e,t)}static fromJson(e,t){return new ek().fromJson(e,t)}static fromJsonString(e,t){return new ek().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ek,e,t)}constructor(e){super(),this.value="",this.isRemoved=!1,Q.w.util.initPartial(e,this)}}ek.runtime=Q.w,ek.typeName="yorkie.v1.NodeAttr",ek.fields=Q.w.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:ej},{no:3,name:"is_removed",kind:"scalar",T:8}]);class eD extends X.v{static fromBinary(e,t){return new eD().fromBinary(e,t)}static fromJson(e,t){return new eD().fromJson(e,t)}static fromJsonString(e,t){return new eD().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eD,e,t)}constructor(e){super(),this.value="",this.attributes={},Q.w.util.initPartial(e,this)}}eD.runtime=Q.w,eD.typeName="yorkie.v1.TextNode",eD.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:eR},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:ej},{no:4,name:"ins_prev_id",kind:"message",T:eR},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ek}}]);class eR extends X.v{static fromBinary(e,t){return new eR().fromBinary(e,t)}static fromJson(e,t){return new eR().fromJson(e,t)}static fromJsonString(e,t){return new eR().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eR,e,t)}constructor(e){super(),this.offset=0,Q.w.util.initPartial(e,this)}}eR.runtime=Q.w,eR.typeName="yorkie.v1.TextNodeID",eR.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5}]);class eN extends X.v{static fromBinary(e,t){return new eN().fromBinary(e,t)}static fromJson(e,t){return new eN().fromJson(e,t)}static fromJsonString(e,t){return new eN().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eN,e,t)}constructor(e){super(),this.type="",this.value="",this.depth=0,this.attributes={},Q.w.util.initPartial(e,this)}}eN.runtime=Q.w,eN.typeName="yorkie.v1.TreeNode",eN.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:eO},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:ej},{no:5,name:"ins_prev_id",kind:"message",T:eO},{no:6,name:"ins_next_id",kind:"message",T:eO},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ek}}]);class eB extends X.v{static fromBinary(e,t){return new eB().fromBinary(e,t)}static fromJson(e,t){return new eB().fromJson(e,t)}static fromJsonString(e,t){return new eB().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eB,e,t)}constructor(e){super(),this.content=[],Q.w.util.initPartial(e,this)}}eB.runtime=Q.w,eB.typeName="yorkie.v1.TreeNodes",eB.fields=Q.w.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:eN,repeated:!0}]);class eO extends X.v{static fromBinary(e,t){return new eO().fromBinary(e,t)}static fromJson(e,t){return new eO().fromJson(e,t)}static fromJsonString(e,t){return new eO().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eO,e,t)}constructor(e){super(),this.offset=0,Q.w.util.initPartial(e,this)}}eO.runtime=Q.w,eO.typeName="yorkie.v1.TreeNodeID",eO.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5}]);class eJ extends X.v{static fromBinary(e,t){return new eJ().fromBinary(e,t)}static fromJson(e,t){return new eJ().fromJson(e,t)}static fromJsonString(e,t){return new eJ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eJ,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eJ.runtime=Q.w,eJ.typeName="yorkie.v1.TreePos",eJ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:eO},{no:2,name:"left_sibling_id",kind:"message",T:eO}]);class eL extends X.v{static fromBinary(e,t){return new eL().fromBinary(e,t)}static fromJson(e,t){return new eL().fromJson(e,t)}static fromJsonString(e,t){return new eL().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eL,e,t)}constructor(e){super(),this.id="",this.username="",Q.w.util.initPartial(e,this)}}eL.runtime=Q.w,eL.typeName="yorkie.v1.User",eL.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:ee.E}]);class e_ extends X.v{static fromBinary(e,t){return new e_().fromBinary(e,t)}static fromJson(e,t){return new e_().fromJson(e,t)}static fromJsonString(e,t){return new e_().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e_,e,t)}constructor(e){super(),this.id="",this.name="",this.publicKey="",this.secretKey="",this.authWebhookUrl="",this.authWebhookMethods=[],this.clientDeactivateThreshold="",Q.w.util.initPartial(e,this)}}e_.runtime=Q.w,e_.typeName="yorkie.v1.Project",e_.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:ee.E},{no:9,name:"updated_at",kind:"message",T:ee.E}]);class eM extends X.v{static fromBinary(e,t){return new eM().fromBinary(e,t)}static fromJson(e,t){return new eM().fromJson(e,t)}static fromJsonString(e,t){return new eM().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eM,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eM.runtime=Q.w,eM.typeName="yorkie.v1.UpdatableProjectFields",eM.fields=Q.w.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:et.Gm},{no:2,name:"auth_webhook_url",kind:"message",T:et.Gm},{no:3,name:"auth_webhook_methods",kind:"message",T:eq},{no:4,name:"client_deactivate_threshold",kind:"message",T:et.Gm}]);class eq extends X.v{static fromBinary(e,t){return new eq().fromBinary(e,t)}static fromJson(e,t){return new eq().fromJson(e,t)}static fromJsonString(e,t){return new eq().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eq,e,t)}constructor(e){super(),this.methods=[],Q.w.util.initPartial(e,this)}}eq.runtime=Q.w,eq.typeName="yorkie.v1.UpdatableProjectFields.AuthWebhookMethods",eq.fields=Q.w.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]);class ez extends X.v{static fromBinary(e,t){return new ez().fromBinary(e,t)}static fromJson(e,t){return new ez().fromJson(e,t)}static fromJsonString(e,t){return new ez().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ez,e,t)}constructor(e){super(),this.id="",this.key="",this.snapshot="",Q.w.util.initPartial(e,this)}}ez.runtime=Q.w,ez.typeName="yorkie.v1.DocumentSummary",ez.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:ee.E},{no:5,name:"accessed_at",kind:"message",T:ee.E},{no:6,name:"updated_at",kind:"message",T:ee.E}]);class eK extends X.v{static fromBinary(e,t){return new eK().fromBinary(e,t)}static fromJson(e,t){return new eK().fromJson(e,t)}static fromJsonString(e,t){return new eK().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eK,e,t)}constructor(e){super(),this.type=0,Q.w.util.initPartial(e,this)}}eK.runtime=Q.w,eK.typeName="yorkie.v1.PresenceChange",eK.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(C)},{no:2,name:"presence",kind:"message",T:eF}]),(s=C||(C={}))[s.UNSPECIFIED=0]="UNSPECIFIED",s[s.PUT=1]="PUT",s[s.DELETE=2]="DELETE",s[s.CLEAR=3]="CLEAR",Q.w.util.setEnumType(C,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);class eF extends X.v{static fromBinary(e,t){return new eF().fromBinary(e,t)}static fromJson(e,t){return new eF().fromJson(e,t)}static fromJsonString(e,t){return new eF().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eF,e,t)}constructor(e){super(),this.data={},Q.w.util.initPartial(e,this)}}eF.runtime=Q.w,eF.typeName="yorkie.v1.Presence",eF.fields=Q.w.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}]);class eV extends X.v{static fromBinary(e,t){return new eV().fromBinary(e,t)}static fromJson(e,t){return new eV().fromJson(e,t)}static fromJsonString(e,t){return new eV().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eV,e,t)}constructor(e){super(),this.serverSeq=$.q.zero,this.clientSeq=0,Q.w.util.initPartial(e,this)}}eV.runtime=Q.w,eV.typeName="yorkie.v1.Checkpoint",eV.fields=Q.w.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}]);class eU extends X.v{static fromBinary(e,t){return new eU().fromBinary(e,t)}static fromJson(e,t){return new eU().fromJson(e,t)}static fromJsonString(e,t){return new eU().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eU,e,t)}constructor(e){super(),this.offset=0,this.relativeOffset=0,Q.w.util.initPartial(e,this)}}eU.runtime=Q.w,eU.typeName="yorkie.v1.TextNodePos",eU.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]);class ej extends X.v{static fromBinary(e,t){return new ej().fromBinary(e,t)}static fromJson(e,t){return new ej().fromJson(e,t)}static fromJsonString(e,t){return new ej().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ej,e,t)}constructor(e){super(),this.lamport=$.q.zero,this.delimiter=0,this.actorId=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ej.runtime=Q.w,ej.typeName="yorkie.v1.TimeTicket",ej.fields=Q.w.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}]);class eW extends X.v{static fromBinary(e,t){return new eW().fromBinary(e,t)}static fromJson(e,t){return new eW().fromJson(e,t)}static fromJsonString(e,t){return new eW().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eW,e,t)}constructor(e){super(),this.topic="",this.payload=new Uint8Array(0),Q.w.util.initPartial(e,this)}}eW.runtime=Q.w,eW.typeName="yorkie.v1.DocEventBody",eW.fields=Q.w.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]);class eG extends X.v{static fromBinary(e,t){return new eG().fromBinary(e,t)}static fromJson(e,t){return new eG().fromJson(e,t)}static fromJsonString(e,t){return new eG().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eG,e,t)}constructor(e){super(),this.type=0,this.publisher="",Q.w.util.initPartial(e,this)}}eG.runtime=Q.w,eG.typeName="yorkie.v1.DocEvent",eG.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(I)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:eW}]);class eH extends X.v{static fromBinary(e,t){return new eH().fromBinary(e,t)}static fromJson(e,t){return new eH().fromJson(e,t)}static fromJsonString(e,t){return new eH().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eH,e,t)}constructor(e){super(),this.clientKey="",Q.w.util.initPartial(e,this)}}eH.runtime=Q.w,eH.typeName="yorkie.v1.ActivateClientRequest",eH.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]);class eY extends X.v{static fromBinary(e,t){return new eY().fromBinary(e,t)}static fromJson(e,t){return new eY().fromJson(e,t)}static fromJsonString(e,t){return new eY().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eY,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eY.runtime=Q.w,eY.typeName="yorkie.v1.ActivateClientResponse",eY.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]);class eZ extends X.v{static fromBinary(e,t){return new eZ().fromBinary(e,t)}static fromJson(e,t){return new eZ().fromJson(e,t)}static fromJsonString(e,t){return new eZ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eZ,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eZ.runtime=Q.w,eZ.typeName="yorkie.v1.DeactivateClientRequest",eZ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]);class eX extends X.v{static fromBinary(e,t){return new eX().fromBinary(e,t)}static fromJson(e,t){return new eX().fromJson(e,t)}static fromJsonString(e,t){return new eX().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eX,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eX.runtime=Q.w,eX.typeName="yorkie.v1.DeactivateClientResponse",eX.fields=Q.w.util.newFieldList(()=>[]);class eQ extends X.v{static fromBinary(e,t){return new eQ().fromBinary(e,t)}static fromJson(e,t){return new eQ().fromJson(e,t)}static fromJsonString(e,t){return new eQ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eQ,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eQ.runtime=Q.w,eQ.typeName="yorkie.v1.AttachDocumentRequest",eQ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:en}]);class e$ extends X.v{static fromBinary(e,t){return new e$().fromBinary(e,t)}static fromJson(e,t){return new e$().fromJson(e,t)}static fromJsonString(e,t){return new e$().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e$,e,t)}constructor(e){super(),this.documentId="",Q.w.util.initPartial(e,this)}}e$.runtime=Q.w,e$.typeName="yorkie.v1.AttachDocumentResponse",e$.fields=Q.w.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:en}]);class e0 extends X.v{static fromBinary(e,t){return new e0().fromBinary(e,t)}static fromJson(e,t){return new e0().fromJson(e,t)}static fromJsonString(e,t){return new e0().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e0,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.removeIfNotAttached=!1,Q.w.util.initPartial(e,this)}}e0.runtime=Q.w,e0.typeName="yorkie.v1.DetachDocumentRequest",e0.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]);class e1 extends X.v{static fromBinary(e,t){return new e1().fromBinary(e,t)}static fromJson(e,t){return new e1().fromJson(e,t)}static fromJsonString(e,t){return new e1().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e1,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e1.runtime=Q.w,e1.typeName="yorkie.v1.DetachDocumentResponse",e1.fields=Q.w.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:en}]);class e2 extends X.v{static fromBinary(e,t){return new e2().fromBinary(e,t)}static fromJson(e,t){return new e2().fromJson(e,t)}static fromJsonString(e,t){return new e2().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e2,e,t)}constructor(e){super(),this.clientId="",this.documentId="",Q.w.util.initPartial(e,this)}}e2.runtime=Q.w,e2.typeName="yorkie.v1.WatchDocumentRequest",e2.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]);class e3 extends X.v{static fromBinary(e,t){return new e3().fromBinary(e,t)}static fromJson(e,t){return new e3().fromJson(e,t)}static fromJsonString(e,t){return new e3().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e3,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}e3.runtime=Q.w,e3.typeName="yorkie.v1.WatchDocumentResponse",e3.fields=Q.w.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:e9,oneof:"body"},{no:2,name:"event",kind:"message",T:eG,oneof:"body"}]);class e9 extends X.v{static fromBinary(e,t){return new e9().fromBinary(e,t)}static fromJson(e,t){return new e9().fromJson(e,t)}static fromJsonString(e,t){return new e9().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e9,e,t)}constructor(e){super(),this.clientIds=[],Q.w.util.initPartial(e,this)}}e9.runtime=Q.w,e9.typeName="yorkie.v1.WatchDocumentResponse.Initialization",e9.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]);class e4 extends X.v{static fromBinary(e,t){return new e4().fromBinary(e,t)}static fromJson(e,t){return new e4().fromJson(e,t)}static fromJsonString(e,t){return new e4().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e4,e,t)}constructor(e){super(),this.clientId="",this.documentId="",Q.w.util.initPartial(e,this)}}e4.runtime=Q.w,e4.typeName="yorkie.v1.RemoveDocumentRequest",e4.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en}]);class e8 extends X.v{static fromBinary(e,t){return new e8().fromBinary(e,t)}static fromJson(e,t){return new e8().fromJson(e,t)}static fromJsonString(e,t){return new e8().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e8,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e8.runtime=Q.w,e8.typeName="yorkie.v1.RemoveDocumentResponse",e8.fields=Q.w.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:en}]);class e5 extends X.v{static fromBinary(e,t){return new e5().fromBinary(e,t)}static fromJson(e,t){return new e5().fromJson(e,t)}static fromJsonString(e,t){return new e5().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e5,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.pushOnly=!1,Q.w.util.initPartial(e,this)}}e5.runtime=Q.w,e5.typeName="yorkie.v1.PushPullChangesRequest",e5.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en},{no:4,name:"push_only",kind:"scalar",T:8}]);class e6 extends X.v{static fromBinary(e,t){return new e6().fromBinary(e,t)}static fromJson(e,t){return new e6().fromJson(e,t)}static fromJsonString(e,t){return new e6().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e6,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e6.runtime=Q.w,e6.typeName="yorkie.v1.PushPullChangesResponse",e6.fields=Q.w.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:en}]);class e7 extends X.v{static fromBinary(e,t){return new e7().fromBinary(e,t)}static fromJson(e,t){return new e7().fromJson(e,t)}static fromJsonString(e,t){return new e7().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e7,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.topic="",this.payload=new Uint8Array(0),Q.w.util.initPartial(e,this)}}e7.runtime=Q.w,e7.typeName="yorkie.v1.BroadcastRequest",e7.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]);class te extends X.v{static fromBinary(e,t){return new te().fromBinary(e,t)}static fromJson(e,t){return new te().fromJson(e,t)}static fromJsonString(e,t){return new te().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(te,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}te.runtime=Q.w,te.typeName="yorkie.v1.BroadcastResponse",te.fields=Q.w.util.newFieldList(()=>[]);var tt=r(6438);let tr={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:eH,O:eY,kind:tt.t.Unary},deactivateClient:{name:"DeactivateClient",I:eZ,O:eX,kind:tt.t.Unary},attachDocument:{name:"AttachDocument",I:eQ,O:e$,kind:tt.t.Unary},detachDocument:{name:"DetachDocument",I:e0,O:e1,kind:tt.t.Unary},removeDocument:{name:"RemoveDocument",I:e4,O:e8,kind:tt.t.Unary},pushPullChanges:{name:"PushPullChanges",I:e5,O:e6,kind:tt.t.Unary},watchDocument:{name:"WatchDocument",I:e2,O:e3,kind:tt.t.ServerStreaming},broadcast:{name:"Broadcast",I:e7,O:te,kind:tt.t.Unary}}};var tn=r(624);(o=x||(x={})).Ok="ok",o.ErrClientNotActivated="ErrClientNotActivated",o.ErrClientNotFound="ErrClientNotFound",o.ErrUnimplemented="ErrUnimplemented",o.ErrInvalidType="ErrInvalidType",o.ErrDummy="ErrDummy",o.ErrDocumentNotAttached="ErrDocumentNotAttached",o.ErrDocumentNotDetached="ErrDocumentNotDetached",o.ErrDocumentRemoved="ErrDocumentRemoved",o.ErrInvalidObjectKey="ErrInvalidObjectKey",o.ErrInvalidArgument="ErrInvalidArgument",o.ErrNotInitialized="ErrNotInitialized",o.ErrNotReady="ErrNotReady",o.ErrRefused="ErrRefused",o.ErrContextNotProvided="ErrContextNotProvided",o.ErrPermissionDenied="ErrPermissionDenied",o.ErrUnauthenticated="ErrUnauthenticated";class ti extends Error{constructor(e,t){super(t),this.code=e,this.message=t,this.name="YorkieError",this.toString=()=>"[code=".concat(this.code,"]: ").concat(this.message)}}function ts(e){if(e instanceof Map){let t=Array.from(e);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(e))}let to=e=>!e||0===Object.entries(e).length,ta=e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=JSON.stringify(n);return t},tc=e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=JSON.parse(n);return t};(a=P||(P={})).Put="put",a.Clear="clear";class tl{set(e,t){for(let t of Object.keys(e))this.presence[t]=e[t];this.context.setPresenceChange({type:"put",presence:ts(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}constructor(e,t){this.context=e,this.presence=t}}let th="000000000000000000000000";class td{static of(e,t,r){return new td(e,t,r)}static fromStruct(e){return td.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return"".concat(this.lamport.toString(),":").concat(this.actorID,":").concat(this.delimiter)}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return"".concat(this.lamport.toString(),":").concat(this.actorID.slice(-2),":").concat(this.delimiter)}setActor(e){return new td(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return 0===this.compare(e)}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return -1;let t=this.actorID.localeCompare(e.actorID);return 0!==t?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}constructor(e,t,r){this.lamport=e,this.delimiter=t,this.actorID=r}}let tu=new td(0n,0,th);function tg(e){return e.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case"\n":return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}new td(0x7fffffffffffffffn,4294967295,"FFFFFFFFFFFFFFFFFFFFFFFF");class tf{getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!!(!this.movedAt||e&&e.after(this.movedAt))&&(this.movedAt=e,!0)}setRemovedAt(e){this.removedAt=e}remove(e){return!!(e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt)))&&(this.removedAt=e,!0)}isRemoved(){return!!this.removedAt}constructor(e){this.createdAt=e}}class tm extends tf{constructor(e){super(e)}}class tp{static of(e,t){return new tp(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}constructor(e,t){this.strKey=e,this.value=t}}class ty{static create(){return new ty}set(e,t,r){let n;let i=this.nodeMapByKey.get(e);null!=i&&!i.isRemoved()&&i.remove(r)&&(n=i.getValue());let s=tp.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),s),(null==i||r.after(i.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,s),t.setMovedAt(r)),n}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new ti(x.ErrInvalidArgument,"fail to find ".concat(e.toIDString()));let r=this.nodeMapByCreatedAt.get(e.toIDString());return r.remove(t),r.getValue()}subPathOf(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){let t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(e.getCreatedAt().toIDString()));let r=this.nodeMapByKey.get(t.getStrKey());t===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){let r=this.nodeMapByKey.get(e);if(null!=r&&r.remove(t))return r.getValue()}has(e){let t=this.nodeMapByKey.get(e);return null!=t&&!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){let t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(let[,e]of this.nodeMapByKey)yield e}constructor(){this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}}class tv extends tm{static create(e,t){if(!t)return new tv(e,ty.create());let r=ty.create();for(let[e,n]of Object.entries(t))r.set(e,n.deepcopy(),n.getCreatedAt());return new tv(e,r)}subPathOf(e){return this.memberNodes.subPathOf(e)}purge(e){this.memberNodes.purge(e)}set(e,t,r){return this.memberNodes.set(e,t,r)}delete(e,t){return this.memberNodes.delete(e,t)}deleteByKey(e,t){return this.memberNodes.deleteByKey(e,t)}get(e){let t=this.memberNodes.get(e);return null==t?void 0:t.getValue()}getByID(e){let t=this.memberNodes.getByID(e);return null==t?void 0:t.getValue()}has(e){return this.memberNodes.has(e)}toJSON(){let e=[];for(let[t,r]of this)e.push('"'.concat(tg(t),'":').concat(r.toJSON()));return"{".concat(e.join(","),"}")}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){let e={};for(let[t,r]of this){let{createdAt:n,value:i,type:s}=r.toJSForTest();e[t]={key:t,createdAt:n,value:i,type:s}}return{createdAt:this.getCreatedAt().toTestString(),value:e,type:"YORKIE_OBJECT"}}getKeys(){let e=[];for(let[t]of this)e.push(t);return e}toSortedJSON(){let e=[];for(let[t]of this)e.push(t);let t=[];for(let n of e.sort()){var r;let e=null===(r=this.memberNodes.get(n))||void 0===r?void 0:r.getValue();t.push('"'.concat(tg(n),'":').concat(e.toSortedJSON()))}return"{".concat(t.join(","),"}")}getRHT(){return this.memberNodes}deepcopy(){let e=tv.create(this.getCreatedAt());for(let t of this.memberNodes)e.memberNodes.set(t.getStrKey(),t.getValue().deepcopy(),this.getPositionedAt());return e.remove(this.getRemovedAt()),e}getDescendants(e){for(let t of this.memberNodes){let r=t.getValue();if(e(r,this))return;r instanceof tm&&r.getDescendants(e)}}*[Symbol.iterator](){let e=new Set;for(let t of this.memberNodes)e.has(t.getStrKey())||(e.add(t.getStrKey()),t.isRemoved()||(yield[t.getStrKey(),t.getValue()]))}constructor(e,t){super(e),this.memberNodes=t}}(c=E||(E={})).Local="local",c.Remote="remote",c.UndoRedo="undoredo";class tw{getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new ti(x.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}constructor(e,t){this.parentCreatedAt=e,this.executedAt=t}}class tA{getNodeString(){return"".concat(this.weight).concat(this.value)}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}constructor(e){this.value=e,this.initWeight()}}class tT{get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new ti(x.ErrInvalidArgument,"out of index range: pos: ".concat(e," > node.length: ").concat(t.getLength()));return this.splayNode(t),[t,e]}indexOf(e){return e&&(e===this.root||e.hasLinks())?(this.splayNode(e),this.root.getLeftWeight()):-1}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t)):this.root=t,t}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);let t=new tT(e.getLeft());t.root&&t.root.setParent();let r=new tT(e.getRight());if(r.root&&r.root.setParent(),t.root){let e=t.getRightmost();t.splayNode(e),t.root.setRight(r.root),r.root&&r.root.setParent(t.root),this.root=t.root}else this.root=r.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){let t=[];for(let r of(this.traversePostorder(e.getRight(),t),t))r.initWeight();this.updateTreeWeight(e)}toTestString(){let e=[];return this.traverseInorder(this.root,e),e.map(e=>"[".concat(e.getWeight(),",").concat(e.getLength(),"]").concat(e.getValue()||"")).join("")}checkWeight(){let e=[];for(let t of(this.traverseInorder(this.root,e),e))if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){let t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){let t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return!!(e&&e.hasParent())&&e.getParent().getLeft()===e}isRightChild(e){return!!(e&&e.hasParent())&&e.getParent().getRight()===e}constructor(e){this.root=e}}var tS=r(7319);(l=b||(b={}))[l.Null=0]="Null",l[l.Boolean=1]="Boolean",l[l.Integer=2]="Integer",l[l.Long=3]="Long",l[l.Double=4]="Double",l[l.String=5]="String",l[l.Bytes=6]="Bytes",l[l.Date=7]="Date";class tI extends tf{static of(e,t){return new tI(e,t)}static valueFromBytes(e,t){switch(e){case 0:return null;case 1:return!!t[0];case 2:return t[0]|t[1]<<8|t[2]<<16|t[3]<<24;case 4:{let e=new DataView(t.buffer);return t.forEach(function(t,r){e.setUint8(r,t)}),e.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(t);case 3:return tS.Z.fromBytesLE(Array.from(t));case 6:return t;case 7:return new Date(tS.Z.fromBytesLE(Array.from(t),!0).toNumber());default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}toJSON(){return 5===this.valueType?'"'.concat(tg(this.value),'"'):"".concat(this.value)}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){let e=tI.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":if(this.isInteger(e))return 2;return 4;case"string":return 5;case"object":if(null===e)return 0;if(e instanceof tS.Z)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return void 0!==tI.getPrimitiveType(e)}static isInteger(e){return e%1==0}isNumericType(){let e=this.valueType;return 2===e||3===e||4===e}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:{let e=this.value;return new Uint8Array(e?[1]:[0])}case 2:{let e=this.value;return new Uint8Array([255&e,e>>8&255,e>>16&255,e>>24&255])}case 4:{let e=this.value,t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),t}case 5:return new TextEncoder().encode(this.value);case 3:{let e=this.value.toBytesLE();return Uint8Array.from(e)}case 6:return this.value;case 7:{let e=this.value,t=tS.Z.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(t)}default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(this.valueType))}}constructor(e,t){super(t),this.valueType=tI.getPrimitiveType(e),this.value=void 0===e?null:e}}class tC extends tA{static createAfter(e,t){let r=new tC(t),n=e.next;return e.next=r,r.prev=e,r.next=n,n&&(n.prev=r),r}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}constructor(e){super(e),this.value=e}}class tx{static create(){return new tx}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(e.toIDString()));for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.getCreatedAt(),n=this.findNextBeforeExecutedAt(e,r),i=tC.createAfter(n,t);n===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(n,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(e,t,r){let n=this.nodeMapByCreatedAt.get(e.toIDString());if(!n)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(e.toIDString()));let i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(t.toIDString()));n!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(n.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){let t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find the given createdAt: ".concat(e.getCreatedAt().toIDString()));this.release(t)}getByIndex(e){if(e>=this.length)return;let[t,r]=this.nodeMapByIndex.find(e),n=t;if(0===e&&t===this.dummyHead||r>0)do n&&(n=n.getNext());while(n&&n.isRemoved());return n}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString()),n=r.isRemoved();return r.remove(t)&&!n&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){let r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){let e=[];for(let t of this){let r="".concat(t.getCreatedAt().toIDString(),":").concat(t.getValue().toJSON());t.isRemoved()?e.push("{".concat(r,"}")):e.push("[".concat(r,"]"))}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}constructor(){let e=tI.of(0,tu);e.setRemovedAt(tu),this.dummyHead=new tC(e),this.last=this.dummyHead,this.nodeMapByIndex=new tT,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}}class tP extends tm{static create(e,t){if(!t)return new tP(e,tx.create());let r=tx.create();for(let e of t)r.insertAfter(r.getLastCreatedAt(),e.deepcopy());return new tP(e,r)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,t){this.elements.insertAfter(e,t)}moveAfter(e,t,r){this.elements.moveAfter(e,t,r)}get(e){let t=this.elements.getByIndex(e);return null==t?void 0:t.getValue()}getByID(e){let t=this.elements.getByID(e);return null==t?void 0:t.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,t){return this.elements.delete(e,t)}deleteByIndex(e,t){return this.elements.deleteByIndex(e,t)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(let e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(let t of this.elements){let r=t.getValue();if(e(r,this))return;r instanceof tm&&r.getDescendants(e)}}toJSON(){let e=[];for(let t of this)e.push(t.toJSON());return"[".concat(e.join(","),"]")}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){let e={};for(let t=0;t({...e,value:e.value?{attributes:tc(e.value.getAttributes()),content:e.value.getContent()}:{attributes:void 0,content:""},type:"content"})),l,[a,a]]}setStyle(e,t,r,n,i){let[,s]=this.rgaTreeSplit.findNodeWithSplit(e[1],r),[,o]=this.rgaTreeSplit.findNodeWithSplit(e[0],r),a=[],c=this.rgaTreeSplit.findBetween(o,s),l=new Map,h=[];for(let e of c){let t;let s=e.getCreatedAt().getActorID(),o=0n;if(void 0===i&&void 0===n?o=0x7fffffffffffffffn:i.size()>0?o=i.get(s)?i.get(s):0n:t=n.has(s)?n.get(s):tu,e.canStyle(r,t,o)){let t=l.get(s),r=e.getCreatedAt();(!t||r.after(t))&&l.set(s,r),h.push(e)}}let d=[];for(let e of h){if(e.isRemoved())continue;let[n,i]=this.rgaTreeSplit.findIndexesFromRange(e.createPosRange());for(let[s,o]of(a.push({type:"style",actor:r.getActorID(),from:n,to:i,value:{attributes:tc(t)}}),Object.entries(t))){let[t]=e.getValue().setAttr(s,o,r);void 0!==t&&d.push({parent:e.getValue(),child:t})}}return[l,d,a]}indexRangeToPosRange(e,t){let r=this.rgaTreeSplit.indexToPos(e);return e===t?[r,r]:[r,this.rgaTreeSplit.indexToPos(t)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){let e=[];for(let t of this.rgaTreeSplit)t.isRemoved()||e.push(t.getValue().toJSON());return"[".concat(e.join(","),"]")}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){let e=[];for(let t of this.rgaTreeSplit)if(!t.isRemoved()){let r=t.getValue();e.push({attributes:tc(r.getAttributes()),content:r.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){let e=new tO(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){let e=[];for(let t of this.rgaTreeSplit)for(let r of(t.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:t}),t.getValue().getGCPairs()))e.push(r);return e}constructor(e,t){super(t),this.rgaTreeSplit=e}}class tJ extends tw{static create(e,t,r,n,i,s,o){return new tJ(e,t,r,n,i,s,o)}execute(e,t,r){let n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(n instanceof tO))throw new ti(x.ErrInvalidArgument,"fail to execute, only Text can execute edit");let[,i,s]=n.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(let t of s)e.registerGCPair(t);return{opInfos:i.map(t=>{let{from:r,to:n,value:i}=t;return{type:"edit",from:r,to:n,value:i,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t=this.fromPos.toTestString(),r=this.toPos.toTestString(),n=this.content;return"".concat(e,".EDIT(").concat(t,",").concat(r,",").concat(n,")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.content=i,this.attributes=s}}class tL extends tw{static create(e,t,r,n,i,s){return new tL(e,t,r,n,i,s)}execute(e,t,r){let n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(n instanceof tO))throw new ti(x.ErrInvalidArgument,"fail to execute, only Text can execute edit");let[,i,s]=n.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(let t of i)e.registerGCPair(t);return{opInfos:s.map(t=>{let{from:r,to:n,value:i}=t;return{type:"style",from:r,to:n,value:i,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t=this.fromPos.toTestString(),r=this.toPos.toTestString(),n=this.attributes;return"".concat(e,".STYL(").concat(t,",").concat(r,",").concat(JSON.stringify(n),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s){super(e,s),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.attributes=i}}let t_="text";function tM(e,t){let r=0,n=e.children;for(let e=0;e!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(){for(var e=arguments.length,t=Array(e),r=0;re+t.paddedSize,0),r.size=r._children.reduce((e,t)=>e+t.paddedSize,0),r._children))e.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");let r=this._children.indexOf(t);if(-1===r)throw new ti(x.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");if(e.isRemoved){let t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(e=>!e.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");let t=e;for(;t;){let e=this._children.indexOf(t);if(-1!==e)return e;t=t.parent}return -1}constructor(e,t=[]){if(this.type=e,this.size=0,this._children=t,this.isText&&this._children.length>0)throw new ti(x.ErrRefused,"Text node cannot have children")}}function tz(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;for(let n of e._children)tz(n,t,r+1);t(e,r)}(d=D||(D={})).Start="Start",d.End="End",d.Text="Text";class tK{tokensBetween(e,t,r){!function e(t,r,n,i){if(r>n)throw new ti(x.ErrInvalidArgument,"from is greater than to: ".concat(r," > ").concat(n));if(r>t.size)throw new ti(x.ErrInvalidArgument,"from is out of range: ".concat(r," > ").concat(t.size));if(n>t.size)throw new ti(x.ErrInvalidArgument,"to is out of range: ".concat(n," > ").concat(t.size));if(r===n)return;let s=0;for(let o of t.children){if(r-o.paddedSizeo.size;(o.isText||c)&&i([o,o.isText?"Text":"Start"],l),e(o,Math.max(0,t),Math.min(a,o.size),i),l&&i([o,"End"],l)}s+=o.paddedSize}}(this.root,e,t,r)}traverse(e){!function e(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;for(let i of t.children)e(i,r,n+1);r(t,n)}(this.root,e,0)}traverseAll(e){tz(this.root,e,0)}findTreePos(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return function e(t,r){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r>t.size)throw new ti(x.ErrInvalidArgument,"index is out of range: ".concat(r," > ").concat(t.size));if(t.isText)return{node:t,offset:r};let i=0,s=0;for(let o of t.children){if(n&&o.isText&&o.size>=r-s)return e(o,r-s,n);if(r===s)break;if(!n&&o.paddedSize===r-s)return{node:t,offset:i+1};if(o.paddedSize>r-s)return e(o,r-s-1,n);s+=o.paddedSize,i+=1}return{node:t,offset:i}}(this.root,e,t)}treePosToPath(e){let t=[],r=e.node;if(r.isText){let n=r.parent.findOffset(r);if(-1===n)throw new ti(x.ErrInvalidArgument,"invalid treePos");let i=tM(r.parent,n);t.push(i+e.offset),r=r.parent}else if(r.hasTextChild()){let n=tM(r,e.offset);t.push(n)}else t.push(e.offset);for(;r.parent;){let e=r.parent.findOffset(r);if(-1===e)throw new ti(x.ErrInvalidArgument,"invalid treePos");t.push(e),r=r.parent}return t.reverse()}pathToIndex(e){let t=this.pathToTreePos(e);return this.indexOf(t)}pathToTreePos(e){if(!e.length)throw new ti(x.ErrInvalidArgument,"unacceptable path");let t=this.root;for(let r=0;re===t?0:e0){if(!t.right)return t;t.right.parent=t,t=t.right}else if(!(r<0))return t;else if(t.left)t.left.parent=t,t=t.left;else{let e=t.parent,r=t;for(;e&&r===e.left;)r=e,e=e.parent;return e}}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return 0===this.counter}getInternal(e,t){for(;t;){let r=this.comparator(e,t.key);if(0===r)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new tV(e,t,!0);let n=this.comparator(e,r.key);return n<0?r.left=this.putInternal(e,t,r.left):n>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(0>this.comparator(t,e.key))this.isRed(e.left)||this.isRed(e.left.left)||(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),0===this.comparator(t,e.key)&&!e.right){this.counter-=1;return}if(this.isRed(e.right)||this.isRed(e.right.left)||(e=this.moveRedRight(e)),0===this.comparator(t,e.key)){this.counter-=1;let t=this.min(e.right);e.value=t.value,e.key=t.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return this.isRed(e.left)||this.isRed(e.left.left)||(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){let t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){let t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}constructor(e){this.comparator=void 0!==e?e:tF,this.counter=0}}(u=R||(R={})).Content="content",u.Style="style",u.RemoveStyle="removeStyle";class tW{static of(e,t){return new tW(e,t)}static fromTreePos(e){let t;let{offset:r}=e,{node:n}=e;return n.isText?(t=n.parent.children[0]===n&&0===r?n.parent:n,n=n.parent):t=0===r?n:n.children[r-1],tW.of(n.id,tG.of(t.getCreatedAt(),t.getOffset()+r))}getParentID(){return this.parentID}static fromStruct(e){return tW.of(tG.of(td.fromStruct(e.parentID.createdAt),e.parentID.offset),tG.of(td.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){let t=this.getParentID(),r=this.getLeftSiblingID(),n=e.findFloorNode(t),i=e.findFloorNode(r);if(!n||!i)throw new ti(x.ErrRefused,"cannot find node of CRDTTreePos(".concat(t.toTestString(),", ").concat(r.toTestString(),")"));return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=e.findFloorNode(i.insPrevID)),[n,i]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}constructor(e,t){this.parentID=e,this.leftSiblingID=t}}class tG{static of(e,t){return new tG(e,t)}static fromStruct(e){return tG.of(td.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{let r=e.getCreatedAt().compare(t.getCreatedAt());return 0!==r?r:e.getOffset()>t.getOffset()?1:e.getOffset(){let r=e.deepcopy();return r.parent=t,r}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new ti(x.ErrInvalidType,"cannot get value of element node: ".concat(this.type));return this._value}set value(e){if(!this.isText)throw new ti(x.ErrInvalidType,"cannot set value of element node: ".concat(this.type));this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){let t=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),t&&this.updateAncestorsSize()}cloneText(e){return new tH(tG.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new tH(tG.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,t,r){let n=this.isText?this.splitText(t,this.id.getOffset()):this.splitElement(t,r);return n&&(n.insPrevID=this.id,this.insNextID&&(e.findFloorNode(this.insNextID).insPrevID=n.id,n.insNextID=this.insNextID),this.insNextID=n.id,e.registerNode(n)),n}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,t,r){return(t?!this.getCreatedAt().after(t):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,t,r){return!this.isText&&(t?!this.getCreatedAt().after(t):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,t){this.attrs||(this.attrs=new tN);let r=[];for(let[n,i]of Object.entries(e))r.push(this.attrs.set(n,i,t));return r}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){let e=[];if(!this.attrs)return e;for(let t of this.attrs)t.getRemovedAt()&&e.push({parent:this,child:t});return e}constructor(e,t,r,n,i){super(t),this._value="",this.id=e,this.removedAt=i,n&&(this.attrs=n),"string"==typeof r?this.value=r:Array.isArray(r)&&(this._children=r)}}function tY(e){if(e.isText)return{type:e.type,value:e.value};let t={type:e.type,children:e.children.map(tY)};if(e.attrs){var r;t.attributes=tc(null===(r=e.attrs)||void 0===r?void 0:r.toObject())}return t}function tZ(e){if(e.isText)return e.value;let t="";return e.attrs&&e.attrs.size()&&(t=" "+Array.from(e.attrs).filter(e=>!e.isRemoved()).sort((e,t)=>e.getKey().localeCompare(t.getKey())).map(e=>{let t=JSON.parse(e.getValue());return"string"==typeof t?"".concat(e.getKey(),'="').concat(t,'"'):"".concat(e.getKey(),'="').concat(tg(e.getValue()),'"')}).join(" ")),"<".concat(e.type).concat(t,">").concat(e.children.map(e=>tZ(e)).join(""),"")}class tX extends tf{static create(e,t){return new tX(e,t)}findFloorNode(e){let t=this.nodeMapByID.floorEntry(e);if(t&&t.key.getCreatedAt().equals(e.getCreatedAt()))return t.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,t){let[r,n]=e.toTreeNodePair(this),i=n,s=r===i,o=i.parent&&!s?i.parent:r;if(i.isText&&i.split(this,e.getLeftSiblingID().getOffset()-i.id.getOffset()),t){let e=o.allChildren,r=s?0:e.indexOf(i)+1;for(let n=r;n{let s,[o]=e,a=o.getCreatedAt().getActorID(),c=0n;if(void 0===i&&void 0===n?c=0x7fffffffffffffffn:i.size()>0?c=i.get(a)?i.get(a):0n:s=n.has(a)?n.get(a):tu,o.canStyle(r,s,c)&&t){let e=d.get(a),n=o.getCreatedAt();(!e||n.after(e))&&d.set(a,n);let i=o.setAttrs(t,r),s=i.reduce((e,t)=>{let[,r]=t;return r&&(e[r.getKey()]=h[r.getKey()]),e},{}),c=o.parent,g=o.prevSibling||o.parent;for(let[e]of(Object.keys(s).length>0&&l.push({type:"style",from:this.toIndex(c,g),to:this.toIndex(o,o),fromPath:this.toPath(c,g),toPath:this.toPath(o,o),actor:r.getActorID(),value:s}),i))e&&u.push({parent:o,child:e})}}),[d,u,l]}removeStyle(e,t,r,n,i){let[s,o]=this.findNodesAndSplitText(e[0],r),[a,c]=this.findNodesAndSplitText(e[1],r),l=[],h=new Map,d=[];return this.traverseInPosRange(s,o,a,c,e=>{let s,[o]=e,a=o.getCreatedAt().getActorID(),c=0n;if(void 0===i&&void 0===n?c=0x7fffffffffffffffn:i.size()>0?c=i.get(a)?i.get(a):0n:s=n.has(a)?n.get(a):tu,o.canStyle(r,s,c)&&t){let e=h.get(a),n=o.getCreatedAt();for(let i of((!e||n.after(e))&&h.set(a,n),o.attrs||(o.attrs=new tN),t))for(let e of o.attrs.remove(i,r))d.push({parent:o,child:e});let i=o.parent,s=o.prevSibling||o.parent;l.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(i,s),to:this.toIndex(o,o),fromPath:this.toPath(i,s),toPath:this.toPath(o,o),value:t})}}),[h,d,l]}edit(e,t,r,n,i,s,o){let[a,c]=this.findNodesAndSplitText(e[0],n),[l,h]=this.findNodesAndSplitText(e[1],n),d=this.toIndex(a,c),u=this.toPath(a,c),g=[],f=[],m=[],p=new Map;this.traverseInPosRange(a,c,l,h,(e,t)=>{let r,[i,a]=e;if(a===D.Start&&!t)for(let e of i.children)m.push(e);let c=i.getCreatedAt().getActorID(),l=0n;if(void 0===o&&void 0===s?l=0x7fffffffffffffffn:o.size()>0?l=o.get(c)?o.get(c):0n:r=s.has(c)?s.get(c):tu,i.canDelete(n,r,l)||g.includes(i.parent)){let e=p.get(c),t=i.getCreatedAt();(!e||t.after(e))&&p.set(c,t),(a===D.Text||a===D.Start)&&g.push(i),f.push([i,a])}});let y=this.makeDeletionChanges(f,n),v=[];for(let e of g)e.remove(n),e.isRemoved&&v.push({parent:this,child:e});for(let e of m)e.removedAt||a.append(e);if(r>0){let e=0,t=a,s=c;for(;e{a.isRemoved&&(e.remove(n),v.push({parent:this,child:e})),this.nodeMapByID.put(e.id,e)}),i.isRemoved||e.push(i);if(e.length){let t=e.map(e=>tY(e));y.length&&y[y.length-1].from===d?y[y.length-1].value=t:y.push({type:"content",from:d,to:d,fromPath:u,toPath:u,actor:n.getActorID(),value:t})}}return[y,v,p]}editT(e,t,r,n,i){let s=this.findPos(e[0]),o=this.findPos(e[1]);this.edit([s,o],t,r,n,i)}move(e,t,r){throw new ti(x.ErrUnimplemented,"not implemented: ".concat(e,", ").concat(t,", ").concat(r))}purge(e){var t;null===(t=e.parent)||void 0===t||t.removeChild(e),this.nodeMapByID.remove(e.id);let r=e.insPrevID,n=e.insNextID;r&&(this.findFloorNode(r).insNextID=n),n&&(this.findFloorNode(n).insPrevID=r),e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){let e=[];return this.indexTree.traverse(t=>{for(let r of(t.getRemovedAt()&&e.push({parent:this,child:t}),t.getGCPairs()))e.push(r)}),e}findPos(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=this.indexTree.findTreePos(e,t);return tW.fromTreePos(r)}pathToPosRange(e){let t=this.pathToIndex(e);return[this.findPos(t),this.findPos(t+1)]}pathToPos(e){let t=this.indexTree.pathToIndex(e);return this.findPos(t)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return tZ(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){var e=this;let t=this.indexTree.getRoot(),r=function(t){var n,i,s,o;let a,c,l,h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,g=t.isText?{node:t,offset:0}:h&&d?e.toTreePos(h,d):null;g&&(a=e.indexTree.indexOf(g),c=e.indexTree.treePosToPath(g),l=tW.fromTreePos(g).toStruct());let f={type:t.type,parent:null==h?void 0:h.id.toTestString(),size:t.size,id:t.id.toTestString(),removedAt:null===(n=t.removedAt)||void 0===n?void 0:n.toTestString(),insPrev:null===(i=t.insPrevID)||void 0===i?void 0:i.toTestString(),insNext:null===(s=t.insNextID)||void 0===s?void 0:s.toTestString(),value:t.isText?t.value:void 0,isRemoved:t.isRemoved,children:[],depth:u,attributes:t.attrs?tc(null===(o=t.attrs)||void 0===o?void 0:o.toObject()):void 0,index:a,path:c,pos:l};for(let e=0;e0&&d===r[r.length-1].to?(r[r.length-1].to=u,r[r.length-1].toPath=this.toPath(h,a)):r.push({type:"content",from:d,to:u,fromPath:this.toPath(l,s),toPath:this.toPath(h,a),actor:t.getActorID()}))}return r.reverse()}findRightToken(e){let[t,r]=e;if(r===D.Start){let e=t.allChildren;return e.length>0?[e[0],e[0].isText?D.Text:D.Start]:[t,D.End]}let n=t.parent,i=n.allChildren,s=i.indexOf(t);if(n&&s===i.length-1)return[n,D.End];let o=i[s+1];return[o,o.isText?D.Text:D.Start]}findLeftToken(e){let[t,r]=e;if(r===D.End){let e=t.allChildren;if(e.length>0){let t=e[e.length-1];return[t,t.isText?D.Text:D.End]}return[t,D.Start]}let n=t.parent,i=n.allChildren,s=i.indexOf(t);if(n&&0===s)return[n,D.Start];let o=i[s-1];return[o,o.isText?D.Text:D.End]}constructor(e,t){super(t),this.indexTree=new tK(e),this.nodeMapByID=new tj(tG.createComparator()),this.indexTree.traverseAll(e=>{this.nodeMapByID.put(e.id,e)})}}class tQ extends tw{static create(e,t,r,n,i,s,o){return new tQ(e,t,r,n,i,s,o)}execute(e,t,r){var n;let i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(i instanceof tX))throw new ti(x.ErrInvalidArgument,"fail to execute, only Tree can execute edit");let s=this.getExecutedAt(),[o,a]=i.edit([this.fromPos,this.toPos],null===(n=this.contents)||void 0===n?void 0:n.map(e=>e.deepcopy()),this.splitLevel,s,(()=>{let e=s.getDelimiter();return void 0!==this.contents&&(e+=this.contents.length),()=>td.of(s.getLamport(),++e,s.getActorID())})(),this.maxCreatedAtMapByActor,r);for(let t of a)e.registerGCPair(t);return{opInfos:o.map(t=>{let{from:r,to:n,value:i,splitLevel:s,fromPath:o,toPath:a}=t;return{type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:r,to:n,value:i,splitLevel:s,fromPath:o,toPath:a}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t="".concat(this.fromPos.getLeftSiblingID().getCreatedAt().toTestString(),"/").concat(this.fromPos.getLeftSiblingID().getOffset()),r="".concat(this.toPos.getLeftSiblingID().getCreatedAt().toTestString(),"/").concat(this.toPos.getLeftSiblingID().getOffset()),n=this.contents||[];return"".concat(e,".EDIT(").concat(t,",").concat(r,",").concat(n.map(e=>tZ(e)).join(""),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.contents=n,this.splitLevel=i,this.maxCreatedAtMapByActor=s}}class t${set(e,t){this.vector.set(e,t)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(let[,t]of this)t>e&&(e=t);return e}max(e){let t=new Map;for(let[r,n]of e){let e=this.vector.get(r),i=e&&e>n?e:n;t.set(r,i)}for(let[r,n]of this){let i=e.get(r),s=i&&i>n?i:n;t.set(r,s)}return new t$(t)}afterOrEqual(e){let t=this.vector.get(e.getActorID());return void 0!==t&&t>=e.getLamport()}deepcopy(){let e=new Map;for(let[t,r]of this.vector)e.set(t,r);return new t$(e)}filter(e){let t=new Map;for(let[r]of e){let e=this.vector.get(r);void 0!==e&&t.set(r,e)}return new t$(t)}size(){return this.vector.size}*[Symbol.iterator](){for(let[e,t]of this.vector)yield[e,t]}constructor(e){this.vector=e||new Map}}let t0=new t$(new Map);class t1{static of(e,t,r,n,i){return new t1(e,t,r,n,i)}next(){let e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new t1(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){let t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,r=this.versionVector.max(e.versionVector),n=new t1(this.clientSeq,t,this.actor,r);return n.versionVector.set(this.actor,t),n}setClocks(e,t){let r=e>this.lamport?e:this.lamport+1n,n=this.versionVector.max(t);return n.set(this.actor,r),t1.of(this.clientSeq,r,this.actor,n)}createTimeTicket(e){return td.of(this.lamport,e,this.actor)}setActor(e){return new t1(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new t1(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return"".concat(this.lamport.toString(),":").concat(this.actor.slice(-2),":").concat(this.clientSeq)}constructor(e,t,r,n,i){this.clientSeq=e,this.serverSeq=i,this.lamport=t,this.versionVector=n,this.actor=r}}let t2=new t1(0,0n,th,t0);class t3{static create(e){let{id:t,operations:r,presenceChange:n,message:i}=e;return new t3({id:t,operations:r,presenceChange:n,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(let t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return void 0!==this.presenceChange}getPresenceChange(){return this.presenceChange}execute(e,t,r){let n=[],i=[];for(let t of this.operations){let s=t.execute(e,r,this.id.getVersionVector());if(!s)continue;let{opInfos:o,reverseOp:a}=s;n.push(...o),a&&i.unshift(a)}return this.presenceChange&&(this.presenceChange.type===P.Put?t.set(this.id.getActorID(),ts(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:n,reverseOps:i}}toTestString(){return"".concat(this.operations.map(e=>e.toTestString()).join(","))}toStruct(){return{changeID:rU.bytesToHex(rU.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>rU.bytesToHex(rU.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){let{changeID:t,operations:r,presenceChange:n,message:i}=e;return t3.create({id:rU.bytesToChangeID(rU.hexToBytes(t)),operations:null==r?void 0:r.map(e=>rU.bytesToOperation(rU.hexToBytes(e))),presenceChange:n,message:i})}constructor({id:e,operations:t,presenceChange:r,message:n}){this.id=e,this.operations=t||[],this.presenceChange=r,this.message=n}}class t9{static create(e,t,r,n,i,s,o){return new t9(e,t,r,n,i,s,o)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}constructor(e,t,r,n,i,s,o){this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=n,this.snapshot=s,this.minSyncedTicket=o,this.versionVector=i}}class t4{static of(e,t){return new t4(e,t)}increaseClientSeq(e){return 0===e?this:new t4(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;let t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return t4.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return"serverSeq=".concat(this.serverSeq,", clientSeq=").concat(this.clientSeq)}constructor(e,t){this.serverSeq=e,this.clientSeq=t}}let t8=new t4(0n,0);class t5{static of(e,t){return new t5(e,t)}static fromStruct(e){return t5.of(td.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return 0===this.createdAt.compare(e.createdAt)&&this.offset===e.offset}hasSameCreatedAt(e){return 0===this.createdAt.compare(e.createdAt)}split(e){return new t5(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return"".concat(this.createdAt.toTestString(),":").concat(this.offset)}toIDString(){return"".concat(this.createdAt.toIDString(),":").concat(this.offset)}constructor(e,t){this.createdAt=e,this.offset=t}}let t6=t5.of(tu,0);class t7{static of(e,t){return new t7(e,t)}static fromStruct(e){let t=t5.fromStruct(e.id);return t7.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return t5.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return"".concat(this.id.toTestString(),":").concat(this.relativeOffset)}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return!!this.id.equals(e.id)&&this.relativeOffset===e.relativeOffset}constructor(e,t){this.id=e,this.relativeOffset=t}}class re extends tA{static create(e,t){return new re(e,t)}static createComparator(){return(e,t)=>{let r=e.getCreatedAt().compare(t.getCreatedAt());return 0!==r?r:e.getOffset()>t.getOffset()?1:e.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){let t=this.treeByID.floorEntry(e);if(t&&(t.key.equals(e)||t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){let r=[],n=e;for(;n&&n!==t;)r.push(n),n=n.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new ti(x.ErrInvalidArgument,"offset should be less than or equal to length");if(0===t)return e;if(t===e.getContentLength())return e.getNext();let r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);let n=e.getInsNext();return n&&n.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,n){if(!e.length)return[[],new Map,new Map];let[i,s]=this.filterNodes(e,t,r,n),o=new Map,a=new Map,c=this.makeChanges(s,t);for(let e of i){let r=e.getCreatedAt().getActorID();(!o.has(r)||e.getID().getCreatedAt().after(o.get(r)))&&o.set(r,e.getID().getCreatedAt()),a.set(e.getID().toIDString(),e),e.remove(t)}return this.deleteIndexNodes(s),[c,o,a]}filterNodes(e,t,r,n){let i=[],s=[],[o,a]=this.findEdgesOfCandidates(e);for(let a of(s.push(o),e)){let e;let o=a.getCreatedAt().getActorID(),c=0n;void 0===n&&void 0===r?c=0x7fffffffffffffffn:n.size()>0?c=n.get(o)?n.get(o):0n:e=r.has(o)?r.get(o):tu,a.canDelete(t,e,c)?i.push(a):s.push(a)}return s.push(a),[i,s]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){let r,n;let i=[];for(let s=0;se<0?Math.ceil(e):Math.floor(e);(g=N||(N={}))[g.IntegerCnt=0]="IntegerCnt",g[g.LongCnt=1]="LongCnt";class rn extends tf{static create(e,t,r){return new rn(e,t,r)}static valueFromBytes(e,t){switch(e){case 0:return t[0]|t[1]<<8|t[2]<<16|t[3]<<24;case 1:return tS.Z.fromBytesLE(Array.from(t));default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}toJSON(){return"".concat(this.value)}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){let e=rn.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":if(e instanceof tS.Z)return 1;return;case"number":if(e>2147483647||e<-2147483648)return 1;return 0;default:return}}static isSupport(e){return!!rn.getCounterType(e)}static isInteger(e){return e%1==0}isNumericType(){let e=this.valueType;return 0===e||1===e}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{let e=this.value;return new Uint8Array([255&e,e>>8&255,e>>16&255,e>>24&255])}case 1:{let e=this.value.toBytesLE();return Uint8Array.from(e)}default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(this.valueType))}}increase(e){function t(e){if(!e.isNumericType())throw TypeError("Unsupported type of value: ".concat(typeof e.getValue()))}return t(this),t(e),1===this.valueType?this.value=this.value.add(e.getValue()):e.getType()===b.Long?this.value=this.value+e.getValue().toInt():this.value=tS.Z.fromNumber(this.value+rr(e.getValue())).toInt(),this}constructor(e,t,r){switch(super(r),this.valueType=e,e){case 0:"number"==typeof t?t>2147483647||t<-2147483648?this.value=tS.Z.fromNumber(t).toInt():this.value=rr(t):this.value=t.toInt();break;case 1:"number"==typeof t?this.value=tS.Z.fromNumber(t):this.value=t;break;default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}}class ri extends tw{static create(e,t,r){return new ri(e,t,r)}execute(e){let t=e.findByCreatedAt(this.getParentCreatedAt());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(t instanceof rn))throw new ti(x.ErrInvalidArgument,"fail to execute, only Counter can execute increase");let r=this.value.deepcopy();return t.increase(r),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:r.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){let e=this.value.deepcopy(),t=e.getType()===b.Long?e.getValue().multiply(-1):-1*e.getValue();return ri.create(this.getParentCreatedAt(),tI.of(t,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return"".concat(this.getParentCreatedAt().toTestString(),".INCREASE.").concat(this.value.toJSON())}getValue(){return this.value}constructor(e,t,r){super(e,r),this.value=t}}class rs extends tw{static create(e,t,r,n,i,s){return new rs(e,t,r,n,i,[],s)}static createTreeRemoveStyleOperation(e,t,r,n,i,s){return new rs(e,t,r,n,new Map,i,s)}execute(e,t,r){let n,i;let s=e.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(s instanceof tX))throw new ti(x.ErrInvalidArgument,"fail to execute, only Tree can execute edit");if(this.attributes.size){let e={};[...this.attributes].forEach(t=>{let[r,n]=t;return e[r]=n}),[,i,n]=s.style([this.fromPos,this.toPos],e,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{let e=this.attributesToRemove;[,i,n]=s.removeStyle([this.fromPos,this.toPos],e,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(let t of i)e.registerGCPair(t);return{opInfos:n.map(t=>{let{from:r,to:n,value:i,fromPath:s,toPath:o}=t;return{type:"tree-style",from:r,to:n,value:this.attributes.size?{attributes:i}:{attributesToRemove:i},fromPath:s,toPath:o,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t="".concat(this.fromPos.getLeftSiblingID().getCreatedAt().toTestString(),":").concat(this.fromPos.getLeftSiblingID().getOffset()),r="".concat(this.toPos.getLeftSiblingID().getCreatedAt().toTestString(),":").concat(this.toPos.getLeftSiblingID().getOffset());return"".concat(e,".STYLE(").concat(t,",").concat(r,",").concat(Object.entries(this.attributes||{}).map(e=>{let[t,r]=e;return"".concat(t,':"').concat(r,'"')}).join(" "),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.attributes=i,this.attributesToRemove=s}}function ro(e){return new es({clientSeq:e.getClientSeq(),lamport:e.getLamport(),actorId:rV(e.getActorID()),versionVector:rc(e.getVersionVector())})}function ra(e){if(e)return new ej({lamport:e.getLamport(),delimiter:e.getDelimiter(),actorId:rV(e.getActorID())})}function rc(e){if(!e)return;let t=new eo;for(let[r,n]of e)t.vector[r]=BigInt(n.toString());return t}function rl(e){switch(e){case b.Null:return S.NULL;case b.Boolean:return S.BOOLEAN;case b.Integer:return S.INTEGER;case b.Long:return S.LONG;case b.Double:return S.DOUBLE;case b.String:return S.STRING;case b.Bytes:return S.BYTES;case b.Date:return S.DATE;default:throw new ti(x.ErrInvalidType,"unsupported type: ".concat(e))}}function rh(e){switch(e){case N.IntegerCnt:return S.INTEGER_CNT;case N.LongCnt:return S.LONG_CNT;default:throw new ti(x.ErrInvalidType,"unsupported type: ".concat(e))}}function rd(e){if(e instanceof tv)return new ew({type:S.JSON_OBJECT,createdAt:ra(e.getCreatedAt()),value:rK(e)});if(e instanceof tP)return new ew({type:S.JSON_ARRAY,createdAt:ra(e.getCreatedAt()),value:ry(e).toBinary()});if(e instanceof tO)return new ew({type:S.TEXT,createdAt:ra(e.getCreatedAt())});if(e instanceof tI)return new ew({type:rl(e.getType()),createdAt:ra(e.getCreatedAt()),value:e.toBytes()});if(e instanceof rn)return new ew({type:rh(e.getType()),createdAt:ra(e.getCreatedAt()),value:e.toBytes()});if(e instanceof tX)return new ew({type:S.TREE,createdAt:ra(e.getCreatedAt()),value:rv(e).toBinary()});throw new ti(x.ErrUnimplemented,"unimplemented element")}function ru(e){return new eU({createdAt:ra(e.getID().getCreatedAt()),offset:e.getID().getOffset(),relativeOffset:e.getRelativeOffset()})}function rg(e){return new eJ({parentId:rf(e.getParentID()),leftSiblingId:rf(e.getLeftSiblingID())})}function rf(e){return new eO({createdAt:ra(e.getCreatedAt()),offset:e.getOffset()})}function rm(e){let t=new ea;if(e instanceof tb){let r=new ec;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.key=e.getKey(),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="set",t.body.value=r}else if(e instanceof tk){let r=new el;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.prevCreatedAt=ra(e.getPrevCreatedAt()),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="add",t.body.value=r}else if(e instanceof tD){let r=new eh;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.prevCreatedAt=ra(e.getPrevCreatedAt()),r.createdAt=ra(e.getCreatedAt()),r.executedAt=ra(e.getExecutedAt()),t.body.case="move",t.body.value=r}else if(e instanceof tE){let r=new ed;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.createdAt=ra(e.getCreatedAt()),r.executedAt=ra(e.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(e instanceof tJ){let r=new eu;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=ru(e.getFromPos()),r.to=ru(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);r.content=e.getContent();let i=r.attributes;for(let[t,r]of e.getAttributes())i[t]=r;r.executedAt=ra(e.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(e instanceof tL){let r=new ef;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=ru(e.getFromPos()),r.to=ru(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);let i=r.attributes;for(let[t,r]of e.getAttributes())i[t]=r;r.executedAt=ra(e.getExecutedAt()),t.body.case="style",t.body.value=r}else if(e instanceof ri){let r=new em;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(e instanceof tQ){let r=new ep,n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=rg(e.getFromPos()),r.to=rg(e.getToPos()),r.contents=function(e){let t=[];if(!e||!e.length)return t;for(let r of e)t.push(new eB({content:rp(r)}));return t}(e.getContents()),r.splitLevel=e.getSplitLevel(),r.executedAt=ra(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(e instanceof rs){let r=new ey;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=rg(e.getFromPos()),r.to=rg(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);let i=e.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{let t=r.attributes;for(let[r,n]of e.getAttributes())t[r]=n}r.executedAt=ra(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new ti(x.ErrUnimplemented,"unimplemented operation");return t}function rp(e){if(!e)return[];let t=[];return tz(e,(e,r)=>{let n=new eN({id:rf(e.id),type:e.type,removedAt:ra(e.removedAt),depth:r});e.isText&&(n.value=e.value),e.insPrevID&&(n.insPrevId=rf(e.insPrevID)),e.insNextID&&(n.insNextId=rf(e.insNextID)),e.attrs&&(n.attributes=function(e){let t={};for(let r of e)t[r.getKey()]=new ek({value:r.getValue(),updatedAt:ra(r.getUpdatedAt()),isRemoved:r.isRemoved()});return t}(e.attrs)),t.push(n)}),t}function ry(e){let t=new eA;return t.body.case="jsonArray",t.body.value=new eS({nodes:function(e){let t=[];for(let r of e)t.push(new eb({element:rw(r.getValue())}));return t}(e.getElements()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}function rv(e){let t=new eA;return t.body.case="tree",t.body.value=new eP({nodes:rp(e.getRoot()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}function rw(e){if(e instanceof tv)return function(e){let t=new eA;return t.body.case="jsonObject",t.body.value=new eT({nodes:function(e){let t=[];for(let r of e)t.push(new eE({key:r.getStrKey(),element:rw(r.getValue())}));return t}(e.getRHT()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tP)return ry(e);if(e instanceof tI)return function(e){let t=new eA;return t.body.case="primitive",t.body.value=new eI({type:rl(e.getType()),value:e.toBytes(),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tO)return function(e){let t=new eA;return t.body.case="text",t.body.value=new eC({nodes:function(e){let t=[];for(let n of e){var r;let e=new eD;e.id=new eR({createdAt:ra((r=n.getID()).getCreatedAt()),offset:r.getOffset()}),e.value=n.getValue().getContent(),e.removedAt=ra(n.getRemovedAt());let i=e.attributes;for(let e of n.getValue().getAttrs()){let t=new ek;t.value=e.getValue(),t.updatedAt=ra(e.getUpdatedAt()),i[e.getKey()]=t}t.push(e)}return t}(e.getRGATreeSplit()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof rn)return function(e){let t=new eA;return t.body.case="counter",t.body.value=new ex({type:rh(e.getType()),value:e.toBytes(),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tX)return rv(e);throw new ti(x.ErrUnimplemented,"unimplemented element")}function rA(e){if(!(e instanceof G.K))return{};for(let t of e.findDetails(tn.Qf))return t.metadata;return{}}function rT(e){var t;return null!==(t=rA(e).code)&&void 0!==t?t:""}function rS(e){return t1.of(e.clientSeq,BigInt(e.lamport),rF(e.actorId),rI(e.versionVector),BigInt(e.serverSeq))}function rI(e){if(!e)return;let t=new t$;return Object.entries(e.vector).forEach(e=>{let[r,n]=e;t.set(r,BigInt(n.toString()))}),t}function rC(e){if(e)return td.of(BigInt(e.lamport),e.delimiter,rF(e.actorId))}function rx(e){let t={};return Object.entries(e.data).forEach(e=>{let[r,n]=e;t[r]=JSON.parse(n)}),t}function rP(e){switch(e){case S.NULL:return b.Null;case S.BOOLEAN:return b.Boolean;case S.INTEGER:return b.Integer;case S.LONG:return b.Long;case S.DOUBLE:return b.Double;case S.STRING:return b.String;case S.BYTES:return b.Bytes;case S.DATE:return b.Date}throw new ti(x.ErrUnimplemented,"unimplemented value type: ".concat(e))}function rE(e){switch(e){case S.INTEGER_CNT:return N.IntegerCnt;case S.LONG_CNT:return N.LongCnt}throw new ti(x.ErrUnimplemented,"unimplemented value type: ".concat(e))}function rb(e){switch(e.type){case S.JSON_OBJECT:if(!e.value)return tv.create(rC(e.createdAt));return rz(e.value);case S.JSON_ARRAY:if(!e.value)return tP.create(rC(e.createdAt));return function(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return r_(eA.fromBinary(e).body.value)}(e.value);case S.TEXT:return tO.create(rt.create(),rC(e.createdAt));case S.TREE:return function(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return rM(eA.fromBinary(e).body.value)}(e.value);case S.NULL:case S.BOOLEAN:case S.INTEGER:case S.LONG:case S.DOUBLE:case S.STRING:case S.BYTES:case S.DATE:return tI.of(tI.valueFromBytes(rP(e.type),e.value),rC(e.createdAt));case S.INTEGER_CNT:case S.LONG_CNT:return rn.create(rE(e.type),rn.valueFromBytes(rE(e.type),e.value),rC(e.createdAt))}}function rk(e){return t7.of(t5.of(rC(e.createdAt),e.offset),e.relativeOffset)}function rD(e){return t5.of(rC(e.createdAt),e.offset)}function rR(e){return tW.of(rN(e.parentId),rN(e.leftSiblingId))}function rN(e){return tG.of(rC(e.createdAt),e.offset)}function rB(e){if(0===e.length)return;let t=[];for(let r of e)t.push(function(e){let t=rN(e.id),r=tH.create(t,e.type),n=Object.entries(e.attributes);return r.isText?r.value=e.value:n.length&&(r.attrs=function(e){let t=tN.create();for(let[r,n]of Object.entries(e))t.setInternal(r,n.value,rC(n.updatedAt),n.isRemoved);return t}(e.attributes)),e.insPrevId&&(r.insPrevID=rN(e.insPrevId)),e.insNextId&&(r.insNextID=rN(e.insNextId)),r.removedAt=rC(e.removedAt),r}(r));let r=t[t.length-1],n=new Map;n.set(e[t.length-1].depth,t[t.length-1]);for(let r=t.length-2;r>=0;r--)n.get(e[r].depth-1).prepend(t[r]),n.set(e[r].depth,t[r]);return r.updateDescendantsSize(),tX.create(r,tu).getRoot()}function rO(e){if("set"===e.body.case){let t=e.body.value;return tb.create(t.key,rb(t.value),rC(t.parentCreatedAt),rC(t.executedAt))}if("add"===e.body.case){let t=e.body.value;return tk.create(rC(t.parentCreatedAt),rC(t.prevCreatedAt),rb(t.value),rC(t.executedAt))}if("move"===e.body.case){let t=e.body.value;return tD.create(rC(t.parentCreatedAt),rC(t.prevCreatedAt),rC(t.createdAt),rC(t.executedAt))}if("remove"===e.body.case){let t=e.body.value;return tE.create(rC(t.parentCreatedAt),rC(t.createdAt),rC(t.executedAt))}if("edit"===e.body.case){let t=e.body.value,r=new Map;Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))});let n=new Map;return Object.entries(t.attributes).forEach(e=>{let[t,r]=e;n.set(t,r)}),tJ.create(rC(t.parentCreatedAt),rk(t.from),rk(t.to),r,t.content,n,rC(t.executedAt))}if("style"===e.body.case){let t=e.body.value,r=new Map;Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))});let n=new Map;return Object.entries(t.attributes).forEach(e=>{let[t,r]=e;n.set(t,r)}),tL.create(rC(t.parentCreatedAt),rk(t.from),rk(t.to),r,n,rC(t.executedAt))}if("select"===e.body.case)return;else if("increase"===e.body.case){let t=e.body.value;return ri.create(rC(t.parentCreatedAt),rb(t.value),rC(t.executedAt))}else if("treeEdit"===e.body.case){let t=e.body.value,r=new Map;return Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))}),tQ.create(rC(t.parentCreatedAt),rR(t.from),rR(t.to),function(e){if(!e.length)return;let t=[];return e.forEach(e=>{let r=rB(e.content);t.push(r)}),t}(t.contents),t.splitLevel,r,rC(t.executedAt))}else if("treeStyle"===e.body.case){let t=e.body.value,r=new Map,n=t.attributesToRemove,i=new Map;return((null==t?void 0:t.createdAtMapByActor)&&Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,r]=e;i.set(t,rC(r))}),(null==n?void 0:n.length)>0)?rs.createTreeRemoveStyleOperation(rC(t.parentCreatedAt),rR(t.from),rR(t.to),i,n,rC(t.executedAt)):(Object.entries(t.attributes).forEach(e=>{let[t,n]=e;r.set(t,n)}),rs.create(rC(t.parentCreatedAt),rR(t.from),rR(t.to),i,r,rC(t.executedAt)))}else throw new ti(x.ErrUnimplemented,"unimplemented operation")}function rJ(e){let t=[];for(let r of e)t.push(t3.create({id:rS(r.id),operations:function(e){let t=[];for(let r of e){let e=rO(r);e&&t.push(e)}return t}(r.operations),presenceChange:r.presenceChange?function(e){let t=e.type;if(t===C.PUT){let t=rx(e.presence);return{type:P.Put,presence:t}}if(t===C.CLEAR)return{type:P.Clear};throw new ti(x.ErrInvalidType,"unsupported type: ".concat(t))}(r.presenceChange):void 0,message:r.message}));return t}function rL(e){let t=new ty;for(let r of e.nodes){let e=rq(r.element);t.set(r.key,e,e.getPositionedAt())}let r=new tv(rC(e.createdAt),t);return r.setMovedAt(rC(e.movedAt)),r.setRemovedAt(rC(e.removedAt)),r}function r_(e){let t=new tx;for(let r of e.nodes)t.insert(rq(r.element));let r=new tP(rC(e.createdAt),t);return r.setMovedAt(rC(e.movedAt)),r.setRemovedAt(rC(e.removedAt)),r}function rM(e){let t=rB(e.nodes);return tX.create(t,rC(e.createdAt))}function rq(e){if("jsonObject"===e.body.case)return rL(e.body.value);if("jsonArray"===e.body.case)return r_(e.body.value);if("primitive"===e.body.case)return function(e){let t=tI.of(tI.valueFromBytes(rP(e.type),e.value),rC(e.createdAt));return t.setMovedAt(rC(e.movedAt)),t.setRemovedAt(rC(e.removedAt)),t}(e.body.value);if("text"===e.body.case)return function(e){let t=new rt,r=t.getHead();for(let n of e.nodes){let e=t.insertAfter(r,function(e){let t=tB.create(e.value);Object.entries(e.attributes).forEach(e=>{let[r,n]=e;t.setAttr(r,n.value,rC(n.updatedAt))});let r=re.create(rD(e.id),t);return r.remove(rC(e.removedAt)),r}(n));n.insPrevId&&e.setInsPrev(t.findNode(rD(n.insPrevId))),r=e}let n=new tO(t,rC(e.createdAt));return n.setMovedAt(rC(e.movedAt)),n.setRemovedAt(rC(e.removedAt)),n}(e.body.value);if("counter"===e.body.case)return function(e){let t=rn.create(rE(e.type),rn.valueFromBytes(rE(e.type),e.value),rC(e.createdAt));return t.setMovedAt(rC(e.movedAt)),t.setRemovedAt(rC(e.removedAt)),t}(e.body.value);if("tree"===e.body.case)return rM(e.body.value);throw new ti(x.ErrUnimplemented,"unimplemented element")}function rz(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return rL(eA.fromBinary(e).body.value)}function rK(e){return rw(e).toBinary()}function rF(e){return e?Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function rV(e){return new Uint8Array(e.match(/.{1,2}/g).map(e=>parseInt(e,16)))}let rU={fromPresence:rx,toChangePack:function(e){var t;return new en({documentKey:e.getDocumentKey(),checkpoint:new eV({serverSeq:(t=e.getCheckpoint()).getServerSeq(),clientSeq:t.getClientSeq()}),isRemoved:e.getIsRemoved(),changes:function(e){let t=[];for(let r of e)t.push(function(e){let t=new ei({id:ro(e.getID()),message:e.getMessage()});return e.hasOperations()&&(t.operations=function(e){let t=[];for(let r of e)t.push(rm(r));return t}(e.getOperations())),e.hasPresenceChange()&&(t.presenceChange=function(e){if(e.type===P.Put)return new eK({type:C.PUT,presence:function(e){let t=new eF,r=t.data;for(let[t,n]of Object.entries(e))r[t]=JSON.stringify(n);return t}(e.presence)});if(e.type===P.Clear)return new eK({type:C.CLEAR});throw new ti(x.ErrUnimplemented,"unimplemented type")}(e.getPresenceChange())),t}(r));return t}(e.getChanges()),snapshot:e.getSnapshot(),versionVector:rc(e.getVersionVector()),minSyncedTicket:ra(e.getMinSyncedTicket())})},fromChangePack:function(e){var t;return t9.create(e.documentKey,(t=e.checkpoint,t4.of(BigInt(t.serverSeq),t.clientSeq)),e.isRemoved,rJ(e.changes),rI(e.versionVector),e.snapshot,rC(e.minSyncedTicket))},fromChanges:rJ,toTreeNodes:rp,fromTreeNodes:rB,objectToBytes:rK,bytesToObject:rz,bytesToSnapshot:function(e){if(!e)return{root:tv.create(tu),presences:new Map};let t=er.fromBinary(e);return{root:rq(t.root),presences:function(e){let t=new Map;return Object.entries(e).forEach(e=>{let[r,n]=e;t.set(r,rx(n))}),t}(t.presences)}},bytesToHex:rF,hexToBytes:rV,toHexString:function(e){return rF(e)},toUint8Array:function(e){return rV(e)},toOperation:rm,toChangeID:ro,PbChangeID:es,bytesToChangeID:function(e){return rS(es.fromBinary(e))},bytesToOperation:function(e){return rO(ea.fromBinary(e))},versionVectorToHex:function(e){return rF(rc(e).toBinary())},hexToVersionVector:function(e){let t=rV(e);return rI(eo.fromBinary(t))}};(f=B||(B={}))[f.Trivial=0]="Trivial",f[f.Debug=1]="Debug",f[f.Info=2]="Info",f[f.Warn=3]="Warn",f[f.Error=4]="Error",f[f.Fatal=5]="Fatal";let rj=3;function rW(e){rj=e}let rG={trivial:function(){for(var e=arguments.length,t=Array(e),r=0;r0||"undefined"==typeof console||console.log("YORKIE T:",...t)},debug:function(){for(var e=arguments.length,t=Array(e),r=0;r1||"undefined"==typeof console||console.log("YORKIE D:",...t)},info:function(){for(var e=arguments.length,t=Array(e),r=0;r2||"undefined"==typeof console||console.log("YORKIE I:",...t)},warn:function(){for(var e=arguments.length,t=Array(e),r=0;r3||"undefined"==typeof console||(void 0!==console.warn?console.warn("YORKIE W:",...t):console.log("YORKIE W:",...t))},error:function(){for(var e=arguments.length,t=Array(e),r=0;r4||"undefined"==typeof console||(void 0!==console.error?console.error("YORKIE E:",...t):console.log("YORKIE E:",...t))},fatal:function(){for(var e=arguments.length,t=Array(e),r=0;rrj<=e};function rH(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}class rY{changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode!==M.RealtimeSyncOff&&(this.syncMode===M.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==M.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived))}async runWatchLoop(e){let t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch(e){}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}constructor(e,t,r,n,i){this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=n,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}}let rZ=()=>{};class rX{next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(!e)throw new ti(x.ErrInvalidArgument,"missing observer");if(this.finalized)throw new ti(x.ErrRefused,"observable is finalized due to previous error");void 0===(n="object"==typeof e?e:{next:e,error:t,complete:r}).next&&(n.next=rZ),void 0===n.error&&(n.error=rZ),void 0===n.complete&&(n.complete=rZ);let i=rH(),s=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:n}),this.finalized)try{this.finalError?n.error(this.finalError):n.complete()}catch(e){rG.warn(e)}return s}unsubscribeOne(e){var t;this.observers=null===(t=this.observers)||void 0===t?void 0:t.filter(t=>t.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;t0||void 0!==this.presenceChange}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(let r of Object.keys(e))(null==t?void 0:t.addToHistory)?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(0===this.reversePresenceKeys.size)return;let e={};for(let t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}constructor(e,t,r,n){this.id=e,this.delimiter=0,this.root=t,this.operations=[],this.previousPresence=ts(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=n}}class r${static create(){return new r$(tv.create(tu))}findByCreatedAt(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];let r=[];for(;t.parent;){let e=t.element.getCreatedAt(),n=t.parent.subPathOf(e);if(void 0===n)throw new ti(x.ErrInvalidArgument,"cant find the given element: ".concat(e.toIDString()));r.unshift(n),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof tm&&e.getDescendants((e,t)=>(this.registerElement(e,t),!1))}deregisterElement(e){let t=0,r=e=>{let r=e.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(r),this.gcElementSetByCreatedAt.delete(r),t++};return r(e),e instanceof tm&&e.getDescendants(e=>(r(e),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){let e=new Set;for(let t of this.gcElementSetByCreatedAt){e.add(t);let r=this.elementPairMapByCreatedAt.get(t);r.element instanceof tm&&r.element.getDescendants(t=>(e.add(t.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new r$(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(let r of this.gcElementSetByCreatedAt){let n=this.elementPairMapByCreatedAt.get(r),i=n.element.getRemovedAt();i&&(null==e?void 0:e.afterOrEqual(i))&&(n.parent.purge(n.element),t+=this.deregisterElement(n.element))}for(let[,r]of this.gcPairMap){let n=r.child.getRemovedAt();n&&(null==e?void 0:e.afterOrEqual(n))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}constructor(e){this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof tO||e instanceof tX)for(let t of e.getGCPairs())this.registerGCPair(t);return!1})}}function r0(e,t){let r=new r1(e);return new Proxy(t,r.getHandlers())}class r1{static setInternal(e,t,r,n){if(r.includes("."))throw new ti(x.ErrInvalidObjectKey,"key must not contain the '.'.");let i=e.issueTimeTicket(),s=nt(e,n,i),o=t.set(r,s,i);e.registerElement(s,t),o&&e.registerRemovedElement(o),e.push(tb.create(r,s.deepcopy(),t.getCreatedAt(),i))}static buildObjectMembers(e,t){let r={};for(let[n,i]of Object.entries(t)){if(n.includes("."))throw new ti(x.ErrInvalidObjectKey,"key must not contain the '.'.");let t=e.issueTimeTicket(),s=nt(e,i,t);r[n]=s}return r}static deleteInternal(e,t,r){let n=e.issueTimeTicket(),i=t.deleteByKey(r,n);i&&(e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i))}getHandlers(){return this.handlers}constructor(e){this.context=e,this.handlers={set:(t,r,n)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]=").concat(JSON.stringify(n))),r1.setInternal(e,t,r,n),!0),get:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]")),"getID"===r)?()=>t.getCreatedAt():"toJSON"===r||"toString"===r?()=>t.toJSON():"toJS"===r?()=>t.toJS():"toJSForTest"===r?()=>t.toJSForTest():ne(e,t.get(r)),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]")),r1.deleteInternal(e,t,r),!0)}}}class r2{static*iteratorInternal(e,t){for(let r of t)yield r7(e,r)}static buildArrayElements(e,t){let r=[];for(let n of t){let t=e.issueTimeTicket(),i=nt(e,n,t);r.push(i)}return r}static pushInternal(e,t,r){return r2.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,n){let i=e.issueTimeTicket(),s=t.getPrevCreatedAt(r);t.moveAfter(s,n,i),e.push(tD.create(t.getCreatedAt(),s,n,i))}static moveAfterInternal(e,t,r,n){let i=e.issueTimeTicket();t.moveAfter(r,n,i),e.push(tD.create(t.getCreatedAt(),r,n,i))}static moveFrontInternal(e,t,r){let n=e.issueTimeTicket(),i=t.getHead();t.moveAfter(i.getCreatedAt(),r,n),e.push(tD.create(t.getCreatedAt(),i.getCreatedAt(),r,n))}static moveLastInternal(e,t,r){let n=e.issueTimeTicket(),i=t.getLastCreatedAt();t.moveAfter(i,r,n),e.push(tD.create(t.getCreatedAt(),i,r,n))}static insertAfterInternal(e,t,r,n){let i=e.issueTimeTicket(),s=nt(e,n,i);return t.insertAfter(r,s),e.registerElement(s,t),e.push(tk.create(t.getCreatedAt(),r,s.deepcopy(),i)),s}static insertBeforeInternal(e,t,r,n){return r2.insertAfterInternal(e,t,t.getPrevCreatedAt(r),n)}static deleteInternalByIndex(e,t,r){let n=e.issueTimeTicket(),i=t.deleteByIndex(r,n);if(i)return e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i),i}static deleteInternalByID(e,t,r){let n=e.issueTimeTicket(),i=t.delete(r,n);return e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i),i}static splice(e,t,r,n){for(var i=arguments.length,s=Array(i>4?i-4:0),o=4;o=0?Math.min(r,a):Math.max(a+r,0),l=void 0===n?a:n<0?c:Math.min(c+n,a),h=[];for(let r=c;r=i)return!1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).includes(r,s);for(let e=s;e=i)return -1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).indexOf(r,s);for(let e=s;e=i?i-1:n<0?n+i:n;if(s<0)return -1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).lastIndexOf(r,s);for(let e=s;e>0;e--){var o;if((null===(o=t.get(e))||void 0===o?void 0:o.getID())===r.getID())return e}return -1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}constructor(e,t){this.context=e,this.array=t,this.handlers={get:(t,r,n)=>"getID"===r?()=>t.getCreatedAt():"getElementByID"===r?r=>{let n=t.getByID(r);if(!(!n||n.isRemoved()))return r7(e,n)}:"getElementByIndex"===r?r=>r7(e,t.get(r)):"getLast"===r?()=>r7(e,t.getLast()):"deleteByID"===r?r=>{let n=r2.deleteInternalByID(e,t,r);return r7(e,n)}:"insertAfter"===r?(r,n)=>{let i=r2.insertAfterInternal(e,t,r,n);return r7(e,i)}:"insertBefore"===r?(r,n)=>{let i=r2.insertBeforeInternal(e,t,r,n);return r7(e,i)}:"moveBefore"===r?(r,n)=>{r2.moveBeforeInternal(e,t,r,n)}:"moveAfter"===r?(r,n)=>{r2.moveAfterInternal(e,t,r,n)}:"moveFront"===r?r=>{r2.moveFrontInternal(e,t,r)}:"moveLast"===r?r=>{r2.moveLastInternal(e,t,r)}:("string"==typeof r||r instanceof String)&&!isNaN(r)?ne(e,t.get(Number(r))):"push"===r?r=>r2.pushInternal(e,t,r):"splice"===r?function(r,n){for(var i=arguments.length,s=Array(i>2?i-2:0),o=2;or2.includes(e,t,r,n):"indexOf"===r?(r,n)=>r2.indexOf(e,t,r,n):"lastIndexOf"===r?(r,n)=>r2.lastIndexOf(e,t,r,n):"toJSForTest"===r?()=>t.toJSForTest():"toTestString"===r?()=>r2.toTestString(t):"string"==typeof r&&["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(r)?function(){for(var n=arguments.length,i=Array(n),s=0;sne(e,t));return Array.prototype[r].apply(o,i)}:Reflect.get(t,r,n),deleteProperty:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("array[".concat(r,"]")),r2.deleteInternalByIndex(e,t,Number.parseInt(r)),!0)}}}class r3{initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,n){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.text.indexRangeToPosRange(e,t);rG.isEnabled(B.Debug)&&rG.debug("EDIT: f:".concat(e,"->").concat(i[0].toTestString(),", t:").concat(t,"->").concat(i[1].toTestString()," c:").concat(r));let s=n?ta(n):void 0,o=this.context.issueTimeTicket(),[a,,c,l]=this.text.edit(i,r,o,s);for(let e of c)this.context.registerGCPair(e);return this.context.push(new tJ(this.text.getCreatedAt(),i[0],i[1],a,r,s?new Map(Object.entries(s)):new Map,o)),this.text.findIndexesFromRange(l)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.text.indexRangeToPosRange(e,t);rG.isEnabled(B.Debug)&&rG.debug("STYL: f:".concat(e,"->").concat(n[0].toTestString(),", t:").concat(t,"->").concat(n[1].toTestString()," a:").concat(JSON.stringify(r)));let i=ta(r),s=this.context.issueTimeTicket(),[o,a]=this.text.setStyle(n,i,s);for(let e of a)this.context.registerGCPair(e);return this.context.push(new tL(this.text.getCreatedAt(),n[0],n[1],o,new Map(Object.entries(i)),s)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");let t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");let t=this.text.findIndexesFromRange([t7.fromStruct(e[0]),t7.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}constructor(e,t){this.context=e,this.text=t}}class r9{initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new ti(x.ErrNotInitialized,"Counter is not initialized yet");let t=this.context.issueTimeTicket(),r=tI.of(e,t);if(!r.isNumericType())throw TypeError("Unsupported type of value: ".concat(typeof r.getValue()));return this.counter.increase(r),this.context.push(ri.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new ti(x.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}constructor(e,t){this.valueType=e,this.value=t}}function r4(e,t,r){let{type:n}=e,i=r.issueTimeTicket();if(n===t_){r8(e);let{value:r}=e,s=tH.create(tG.of(i,0),n,r);t.append(s)}else{let s;let{children:o=[]}=e,{attributes:a}=e;if("object"==typeof a&&!to(a)){let e=ta(a);for(let[t,r]of(s=new tN,Object.entries(e)))s.set(t,r,i)}let c=tH.create(tG.of(i,0),n,void 0,s);for(let e of(t.append(c),o))r4(e,c,r)}}function r8(e){if(!e.value.length)throw new ti(x.ErrInvalidArgument,"text node cannot have empty value");return!0}function r5(e){if(!e.length)return!0;if(e[0].type===t_)for(let t of e){let{type:e}=t;if(e!==t_)throw new ti(x.ErrInvalidArgument,"element node and text node cannot be passed together");r8(t)}else for(let t of e){let{type:e}=t;if(e===t_)throw new ti(x.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class r6{initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return tH.create(tG.of(e.issueTimeTicket(),0),"root");let t=tH.create(tG.of(e.issueTimeTicket(),0),this.initialRoot.type);for(let r of this.initialRoot.children)r4(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let[r,n]=this.tree.pathToPosRange(e),i=this.context.issueTimeTicket(),s=t?ta(t):void 0,[o]=this.tree.style([r,n],s,i);this.context.push(rs.create(this.tree.getCreatedAt(),r,n,o,s?new Map(Object.entries(s)):new Map,i))}style(e,t,r){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.tree.findPos(e),i=this.tree.findPos(t),s=this.context.issueTimeTicket(),o=r?ta(r):void 0,[a,c]=this.tree.style([n,i],o,s);for(let e of c)this.context.registerGCPair(e);this.context.push(rs.create(this.tree.getCreatedAt(),n,i,a,o?new Map(Object.entries(o)):new Map,s))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.tree.findPos(e),i=this.tree.findPos(t),s=this.context.issueTimeTicket(),[o,a]=this.tree.removeStyle([n,i],r,s);for(let e of a)this.context.registerGCPair(e);this.context.push(rs.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),n,i,o,r,s))}editInternal(e,t,r){var n;let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(0!==r.length&&r[0]&&(r5(r),r[0].type!==t_))for(let e of r){let{children:t=[]}=e;r5(t)}let s=this.context.getLastTimeTicket(),o=[];if((null===(n=r[0])||void 0===n?void 0:n.type)===t_){let e="";for(let t of r){let{value:r}=t;e+=r}o.push(tH.create(tG.of(this.context.issueTimeTicket(),0),t_,e))}else o=r.map(e=>e&&function(e,t){let r;let{type:n}=t,i=e.issueTimeTicket();if(t.type===t_){let{value:e}=t;r=tH.create(tG.of(i,0),n,e)}else if(t){let s;let{children:o=[]}=t,{attributes:a}=t;if("object"==typeof a&&!to(a)){let e=ta(a);for(let[t,r]of(s=new tN,Object.entries(e)))s.set(t,r,i)}for(let t of(r=tH.create(tG.of(e.issueTimeTicket(),0),n,void 0,s),o))r4(t,r,e)}return r}(this.context,e)).filter(e=>e);let[,a,c]=this.tree.edit([e,t],o.length?o.map(e=>null==e?void 0:e.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(let e of a)this.context.registerGCPair(e);return this.context.push(tQ.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,c,s)),!0}editByPath(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new ti(x.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let i=this.tree.pathToPos(e),s=this.tree.pathToPos(t);return this.editInternal(i,s,r?[r]:[],n)}editBulkByPath(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new ti(x.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let i=this.tree.pathToPos(e),s=this.tree.pathToPos(t);return this.editInternal(i,s,r,n)}edit(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.tree.findPos(e),s=this.tree.findPos(t);return this.editInternal(i,s,r?[r]:[],n)}editBulk(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.tree.findPos(e),s=this.tree.findPos(t);return this.editInternal(i,s,r,n)}toXML(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[tW.fromStruct(e[0]),tW.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[tW.fromStruct(e[0]),tW.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}constructor(e){this.initialRoot=e}}function r7(e,t){if(t){if(t instanceof tI)return t;if(t instanceof tv)return r0(e,t);if(t instanceof tP)return function(e,t){let r=new r2(e,t);return new Proxy(t,r.getHandlers())}(e,t);if(t instanceof tO)return new r3(e,t);else if(t instanceof rn){let r=new r9(N.IntegerCnt,0);return r.initialize(e,t),r}else if(t instanceof tX){let r=new r6;return r.initialize(e,t),r}throw TypeError("Unsupported type of element: ".concat(typeof t))}}function ne(e,t){let r=r7(e,t);return r instanceof tI?r.getValue():r}function nt(e,t,r){let n;if(tI.isSupport(t))n=tI.of(t,r);else if(Array.isArray(t))n=tP.create(r,r2.buildArrayElements(e,t));else if("object"==typeof t)t instanceof r3?(n=tO.create(rt.create(),r),t.initialize(e,n)):t instanceof r9?(n=rn.create(t.getValueType(),t.getValue(),r),t.initialize(e,n)):t instanceof r6?(n=tX.create(t.buildRoot(e),r),t.initialize(e,n)):n=tv.create(r,r1.buildObjectMembers(e,t));else throw TypeError("Unsupported type of value: ".concat(typeof t));return n}class nr{hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=50&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=50&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}constructor(){this.undoStack=[],this.redoStack=[]}}let nn="disconnected",ni=new Map,ns=new Map;function no(e,t){((null==t?void 0:t.force)||"disconnected"!==nn)&&window.postMessage({source:"yorkie-devtools-sdk",...e},"*")}window.transactionEventsByDocKey=ns,(m=O||(O={})).Detached="detached",m.Attached="attached",m.Removed="removed",(p=J||(J={})).StatusChanged="status-changed",p.ConnectionChanged="connection-changed",p.SyncStatusChanged="sync-status-changed",p.Snapshot="snapshot",p.LocalChange="local-change",p.RemoteChange="remote-change",p.Initialized="initialized",p.Watched="watched",p.Unwatched="unwatched",p.PresenceChanged="presence-changed",p.Broadcast="broadcast",p.LocalBroadcast="local-broadcast",p.AuthError="auth-error",(y=L||(L={})).Connected="connected",y.Disconnected="disconnected",(v=_||(_={})).Synced="synced",v.SyncFailed="sync-failed";class na{update(e,t){if("removed"===this.getStatus())throw new ti(x.ErrDocumentRemoved,"".concat(this.key," is removed"));this.ensureClone();let r=this.changeID.getActorID(),n=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{var i;let t=(i=this.clone.root.getObject(),r0(n,i));this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(t,new tl(n,this.clone.presences.get(r)))}catch(e){throw this.clone=void 0,e}finally{this.isUpdating=!1}if(n.hasChange()){rG.isEnabled(B.Trivial)&&rG.trivial("trying to update a local change: ".concat(this.toJSON()));let e=n.getChange(),{opInfos:t,reverseOps:i}=e.execute(this.root,this.presences,E.Local),s=n.getReversePresence();s&&i.push({type:"presence",value:s}),this.localChanges.push(e),i.length>0&&this.internalHistory.pushUndo(i),t.length>0&&this.internalHistory.clearRedo(),this.changeID=e.getID();let o=[];t.length>0&&o.push({type:"local-change",source:E.Local,value:{message:e.getMessage()||"",operations:t,actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq()},rawChange:this.isEnableDevtools()?e.toStruct():void 0}),e.hasPresenceChange()&&o.push({type:"presence-changed",source:E.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(o),rG.isEnabled(B.Trivial)&&rG.trivial("after update a local change: ".concat(this.toJSON()))}}subscribe(e,t,r,n){if("string"==typeof e){if("function"!=typeof t)throw new ti(x.ErrInvalidArgument,"Second argument must be a callback function");return"presence"===e?this.eventStream.subscribe(e=>{for(let r of e)("initialized"===r.type||"watched"===r.type||"unwatched"===r.type||"presence-changed"===r.type)&&t(r)},r,n):"my-presence"===e?this.eventStream.subscribe(e=>{for(let r of e)("initialized"===r.type||"presence-changed"===r.type)&&("presence-changed"!==r.type||r.value.clientID===this.changeID.getActorID())&&t(r)},r,n):"others"===e?this.eventStream.subscribe(e=>{for(let r of e)("watched"===r.type||"unwatched"===r.type||"presence-changed"===r.type)&&r.value.clientID!==this.changeID.getActorID()&&t(r)},r,n):"connection"===e?this.eventStream.subscribe(e=>{for(let r of e)"connection-changed"===r.type&&t(r)},r,n):"status"===e?this.eventStream.subscribe(e=>{for(let r of e)"status-changed"===r.type&&t(r)},r,n):"sync"===e?this.eventStream.subscribe(e=>{for(let r of e)"sync-status-changed"===r.type&&t(r)},r,n):"local-broadcast"===e?this.eventStream.subscribe(e=>{for(let r of e)"local-broadcast"===r.type&&t(r)},r):"broadcast"===e?this.eventStream.subscribe(e=>{for(let r of e)"broadcast"===r.type&&t(r)},r):"auth-error"===e?this.eventStream.subscribe(e=>{for(let r of e)"auth-error"===r.type&&t(r)},r):"all"===e?this.eventStream.subscribe(t,r,n):this.eventStream.subscribe(r=>{for(let n of r){if("local-change"!==n.type&&"remote-change"!==n.type)continue;let r=[];for(let t of n.value.operations)this.isSameElementOrChildOf(t.path,e)&&r.push(t);r.length&&t({...n,value:{...n.value,operations:r}})}},r,n)}if("function"==typeof e)return this.eventStream.subscribe(t=>{for(let r of t)("snapshot"===r.type||"local-change"===r.type||"remote-change"===r.type)&&e(r)},t,r);throw new ti(x.ErrInvalidArgument,'"'.concat(e,'" is not a valid'))}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;let r=e.split(".");return t.split(".").every((e,t)=>e===r[t])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){let t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),E.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),rG.isEnabled(B.Trivial)&&rG.trivial("".concat(this.root.toJSON()))}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:ts(this.presences)})}createChangePack(){let e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return t9.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(let t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){return this.ensureClone(),r0(rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{}),this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,{root:i,presences:s}=rU.bytesToSnapshot(r);this.root=new r$(i),this.presences=s,this.changeID=this.changeID.setClocks(e,t),this.clone=void 0,this.removePushedLocalChanges(n),this.applyChanges(this.localChanges,E.Local),this.publish([{type:"snapshot",source:E.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?rU.bytesToHex(r):void 0,snapshotVector:rU.versionVectorToHex(t)}}])}applyChanges(e,t){for(let r of(rG.isEnabled(B.Debug)&&rG.debug("trying to apply ".concat(e.length," remote changes.")+"elements:".concat(this.root.getElementMapSize(),", ")+"removeds:".concat(this.root.getGarbageElementSetSize())),rG.isEnabled(B.Trivial)&&rG.trivial(e.map(e=>"".concat(e.getID().toTestString()," ").concat(e.toTestString())).join("\n")),e))this.applyChange(r,t);rG.isEnabled(B.Debug)&&rG.debug("after appling ".concat(e.length," remote changes.")+"elements:".concat(this.root.getElementMapSize(),", ")+" removeds:".concat(this.root.getGarbageElementSetSize()))}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);let r=[],n=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(n)){let i=e.getPresenceChange();switch(i.type){case P.Put:r.push(this.presences.has(n)?{type:"presence-changed",source:t,value:{clientID:n,presence:i.presence}}:{type:"watched",source:E.Remote,value:{clientID:n,presence:i.presence}});break;case P.Clear:r.push({type:"unwatched",source:E.Remote,value:{clientID:n,presence:this.getPresence(n)}}),this.removeOnlineClient(n)}}let{opInfos:i}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),i.length>0){let s=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===E.Remote?{type:"remote-change",source:t,value:{actor:n,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:s}:{type:"local-change",source:t,value:{actor:n,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:s})}r.length>0&&this.publish(r)}applyWatchStream(e){if("initialization"===e.body.case){let t=e.body.value.clientIds,r=new Set;for(let e of t)e!==this.changeID.getActorID()&&r.add(e);this.setOnlineClients(r),this.publish([{type:"initialized",source:E.Local,value:this.getPresences()}]);return}if("event"===e.body.case){let{type:t,publisher:r}=e.body.value,n=[];if(t===I.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&n.push({type:"watched",source:E.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===I.DOCUMENT_UNWATCHED){let e=this.getPresence(r);this.removeOnlineClient(r),e&&n.push({type:"unwatched",source:E.Remote,value:{clientID:r,presence:e}})}else if(t===I.DOCUMENT_BROADCAST&&e.body.value.body){let{topic:t,payload:i}=e.body.value.body,s=new TextDecoder;n.push({type:"broadcast",value:{clientID:r,topic:t,payload:JSON.parse(s.decode(i))}})}n.length>0&&this.publish(n)}}applyStatus(e){this.status=e,"detached"===e&&this.setActor(th),this.publish([{source:"removed"===e?E.Remote:E.Local,type:"status-changed",value:"attached"===e?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if("status-changed"===e.type){this.applyStatus(e.value.status),"attached"===e.value.status&&this.setActor(e.value.actorID);return}if("snapshot"===e.type){let{snapshot:t,serverSeq:r,snapshotVector:n}=e.value;if(!t)return;this.applySnapshot(BigInt(r),rU.hexToVersionVector(n),rU.hexToBytes(t));return}if("local-change"===e.type||"remote-change"===e.type){if(!e.rawChange)return;let t=t3.fromStruct(e.rawChange);this.applyChange(t,e.source)}if("initialized"===e.type){let t=new Set;for(let{clientID:r,presence:n}of e.value)t.add(r),this.presences.set(r,n);this.setOnlineClients(t);return}if("watched"===e.type){let{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if("unwatched"===e.type){let{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if("presence-changed"===e.type){let{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(let t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new ti(x.ErrInvalidArgument,'path must start with "$"');let t=e.split(".");t.shift();let r=this.getRoot();for(let e of t)if(void 0===(r=r[e]))return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if("attached"!==this.status)return{};let e=this.presences.get(this.changeID.getActorID());return e?ts(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;let t=this.presences.get(e);return t?ts(t):void 0}getPresenceForTest(e){let t=this.presences.get(e);return t?ts(t):void 0}getPresences(){let e=[];for(let t of(e.push({clientID:this.changeID.getActorID(),presence:ts(this.getMyPresence())}),this.onlineClients))this.presences.has(t)&&e.push({clientID:t,presence:ts(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){let e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((e,t)=>e.clientID>t.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){let t=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(t)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new ti(x.ErrRefused,"Undo is not allowed during an update");let e=this.internalHistory.popUndo();if(void 0===e)throw new ti(x.ErrRefused,"There is no operation to be undone");this.ensureClone();let t=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(let r of e){if(!(r instanceof tw)){new tl(t,ts(this.clone.presences.get(this.changeID.getActorID()))).set(r.value,{addToHistory:!0});continue}let e=t.issueTimeTicket();r.setExecutedAt(e),t.push(r)}let r=t.getChange();r.execute(this.clone.root,this.clone.presences,E.UndoRedo);let{opInfos:n,reverseOps:i}=r.execute(this.root,this.presences,E.UndoRedo),s=t.getReversePresence();if(s&&i.push({type:"presence",value:s}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&0===n.length)return;this.localChanges.push(r),this.changeID=r.getID();let o=this.changeID.getActorID(),a=[];n.length>0&&a.push({type:"local-change",source:E.UndoRedo,value:{message:r.getMessage()||"",operations:n,actor:o,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&a.push({type:"presence-changed",source:E.UndoRedo,value:{clientID:o,presence:this.getPresence(o)}}),this.publish(a)}redo(){if(this.isUpdating)throw new ti(x.ErrRefused,"Redo is not allowed during an update");let e=this.internalHistory.popRedo();if(void 0===e)throw new ti(x.ErrRefused,"There is no operation to be redone");this.ensureClone();let t=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(let r of e){if(!(r instanceof tw)){new tl(t,ts(this.clone.presences.get(this.changeID.getActorID()))).set(r.value,{addToHistory:!0});continue}let e=t.issueTimeTicket();r.setExecutedAt(e),t.push(r)}let r=t.getChange();r.execute(this.clone.root,this.clone.presences,E.UndoRedo);let{opInfos:n,reverseOps:i}=r.execute(this.root,this.presences,E.UndoRedo),s=t.getReversePresence();if(s&&i.push({type:"presence",value:s}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&0===n.length)return;this.localChanges.push(r),this.changeID=r.getID();let o=this.changeID.getActorID(),a=[];n.length>0&&a.push({type:"local-change",source:E.UndoRedo,value:{message:r.getMessage()||"",operations:n,actor:o,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&a.push({type:"presence-changed",source:E.UndoRedo,value:{clientID:o,presence:this.getPresence(o)}}),this.publish(a)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){this.publish([{type:"local-broadcast",value:{topic:e,payload:t},options:r}])}getVersionVector(){return this.changeID.getVersionVector()}constructor(e,t){this.opts=t||{},this.key=e,this.status="detached",this.root=r$.create(),this.changeID=t2,this.checkpoint=t8,this.localChanges=[],this.eventStream=function(e){let t=new rX(e);return{subscribe:t.subscribe.bind(t),getProxy:()=>t}}(e=>{this.eventStreamObserver=e}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new nr,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},function(e){if(!e.isEnableDevtools()||ni.has(e.getKey()))return;ns.set(e.getKey(),[]);let t=e.subscribe("all",t=>{t.some(e=>e.type!==J.StatusChanged&&e.type!==J.Snapshot&&e.type!==J.LocalChange&&e.type!==J.RemoteChange&&e.type!==J.Initialized&&e.type!==J.Watched&&e.type!==J.Unwatched&&e.type!==J.PresenceChanged)||(ns.get(e.getKey()).push(t),"synced"===nn&&no({msg:"doc::sync::partial",docKey:e.getKey(),event:t}))});ni.set(e.getKey(),[t]),no({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var r;if((null===(r=t.data)||void 0===r?void 0:r.source)==="yorkie-devtools-panel")switch(t.data.msg){case"devtools::connect":if("disconnected"!==nn)break;nn="connected",no({msg:"doc::available",docKey:e.getKey()}),rG.info("[YD] Devtools connected. Doc: ".concat(e.getKey()));break;case"devtools::disconnect":nn="disconnected",rG.info("[YD] Devtools disconnected. Doc: ".concat(e.getKey()));break;case"devtools::subscribe":nn="synced",no({msg:"doc::sync::full",docKey:e.getKey(),events:ns.get(e.getKey())}),rG.info("[YD] Devtools subscribed. Doc: ".concat(e.getKey()))}})}(this)}}var nc=JSON.parse('{"u2":"yorkie-js-sdk","i8":"0.5.6"}');let nl=e=>{try{let t=JSON.stringify(e);if(void 0===t)return!1}catch(e){return!1}return!0};(w=M||(M={})).Manual="manual",w.Realtime="realtime",w.RealtimePushOnly="realtime-pushonly",w.RealtimeSyncOff="realtime-syncoff",(A=q||(q={})).Deactivated="deactivated",A.Activated="activated",(T=z||(z={})).SyncLoop="SyncLoop",T.WatchLoop="WatchLoop";let nh={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},nd={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class nu{async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){let e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),rG.info('[AC] c:"'.concat(this.getKey(),'" activated, id:"').concat(this.id,'"'))}).catch(async e=>{throw rG.error('[AC] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}deactivate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{keepalive:!1};if("deactivated"===this.status)return Promise.resolve();let t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),rG.info('[DC] c"'.concat(this.getKey(),'" deactivated'))}catch(e){throw rG.error('[DC] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}};if(e.keepalive){this.keepalive=!0;let e=t();return this.keepalive=!1,e}return this.enqueueTask(t)}attach(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));if(e.getStatus()!==O.Detached)throw new ti(x.ErrDocumentNotDetached,"".concat(e.getKey()," is not detached"));e.setActor(this.id),e.update((e,t)=>t.set(r.initialPresence||{}));let n=e.subscribe("local-broadcast",async t=>{var r;let{topic:n,payload:i}=t.value,s=null===(r=t.options)||void 0===r?void 0:r.error,o=t.options;try{await this.broadcast(e.getKey(),n,i,o)}catch(e){e instanceof Error&&(null==s||s(e))}}),i=null!==(t=r.syncMode)&&void 0!==t?t:"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:rU.toChangePack(e.createChangePack())},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(async t=>{let s=rU.fromChangePack(t.changePack);if(e.applyChangePack(s),e.getStatus()===O.Removed)return e;e.applyStatus(O.Attached),this.attachmentMap.set(e.getKey(),new rY(this.reconnectStreamDelay,e,t.documentId,i,n)),"manual"!==i&&await this.runWatchLoop(e.getKey()),rG.info('[AD] c:"'.concat(this.getKey(),'" attaches d:"').concat(e.getKey(),'"'));let o=e.getRootObject();if(r.initialRoot){let t=r.initialRoot;e.update(e=>{for(let[r,n]of Object.entries(t))o.has(r)||(e[r]=n)})}return e}).catch(async e=>{throw rG.error('[AD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}detach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let r=this.attachmentMap.get(e.getKey());if(!r)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));return e.update((e,t)=>t.clear()),this.enqueueTask(async()=>{var n;return this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:rU.toChangePack(e.createChangePack()),removeIfNotAttached:null!==(n=t.removeIfNotAttached)&&void 0!==n&&n},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(t=>{let r=rU.fromChangePack(t.changePack);return e.applyChangePack(r),e.getStatus()!==O.Removed&&e.applyStatus(O.Detached),this.detachInternal(e.getKey()),rG.info('[DD] c:"'.concat(this.getKey(),'" detaches d:"').concat(e.getKey(),'"')),e}).catch(async e=>{throw rG.error('[DD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e})})}async changeSyncMode(e,t){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let r=this.attachmentMap.get(e.getKey());if(!r)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));let n=r.syncMode;return n===t||((r.changeSyncMode(t),"manual"===t)?r.cancelWatchStream():("realtime"===t&&(r.remoteChangeEventReceived=!0),"manual"===n&&await this.runWatchLoop(e.getKey()))),e}sync(e){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));if(e){let t=this.attachmentMap.get(e.getKey());if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async e=>{throw rG.error('[SY] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}return this.enqueueTask(async()=>{let e=[];for(let[,t]of this.attachmentMap)e.push(this.syncInternal(t,t.syncMode));return Promise.all(e).catch(async e=>{throw rG.error('[SY] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e})})}remove(e){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let t=this.attachmentMap.get(e.getKey());if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));e.setActor(this.id);let r=rU.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(t=>{let r=rU.fromChangePack(t.changePack);e.applyChangePack(r),this.detachInternal(e.getKey()),rG.info('[RD] c:"'.concat(this.getKey(),'" removes d:"').concat(e.getKey(),'"'))}).catch(async e=>{throw rG.error('[RD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}getID(){return this.id}getKey(){return this.key}isActive(){return"activated"===this.status}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,n){var i;if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let s=this.attachmentMap.get(e);if(!s)throw new ti(x.ErrDocumentNotAttached,"".concat(e," is not attached"));if(!nl(r))throw new ti(x.ErrInvalidArgument,"payload is not serializable");let o=null!==(i=null==n?void 0:n.maxRetries)&&void 0!==i?i:nd.maxRetries,a=nd.maxBackoff,c=0,l=e=>Math.min(nd.initialRetryInterval*2**e,a),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e)}}).then(()=>{rG.info('[BC] c:"'.concat(this.getKey(),'" broadcasts d:"').concat(e,'" t:"').concat(t,'"'))}).catch(async e=>{if(rG.error('[BC] c:"'.concat(this.getKey(),'" err:'),e),await this.handleConnectError(e)){if(e instanceof G.K&&rT(e)===x.ErrUnauthenticated&&s.doc.publish([{type:J.AuthError,value:{reason:rA(e).reason,method:"Broadcast"}}]),ch(),l(++c-1)),rG.info('[BC] c:"'.concat(this.getKey(),'" retry attempt ').concat(c,"/").concat(o));else throw rG.error('[BC] c:"'.concat(this.getKey(),'" exceeded maximum retry attempts')),e}else throw e}));return h()}runSyncLoop(){let e=()=>{if(!this.isActive()){rG.debug('[SL] c:"'.concat(this.getKey(),'" exit sync loop')),this.conditions.SyncLoop=!1;return}let t=[];for(let[,e]of this.attachmentMap)e.needRealtimeSync()&&(e.remoteChangeEventReceived=!1,t.push(this.syncInternal(e,e.syncMode).catch(async t=>{throw t instanceof G.K&&rT(t)===x.ErrUnauthenticated&&e.doc.publish([{type:J.AuthError,value:{reason:rA(t).reason,method:"PushPull"}}]),t})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async t=>{rG.error('[SL] c:"'.concat(this.getKey(),'" sync failed:'),t),await this.handleConnectError(t)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};rG.debug('[SL] c:"'.concat(this.getKey(),'" run sync loop')),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){let t=this.attachmentMap.get(e);if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e," is not attached"));return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new ti(x.ErrClientNotActivated,"".concat(this.key," is not active")));let n=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e)},signal:n.signal});return t.doc.publish([{type:J.ConnectionChanged,value:L.Connected}]),rG.info('[WD] c:"'.concat(this.getKey(),'" watches d:"').concat(e,'"')),new Promise((e,s)=>{(async()=>{try{for await(let r of i)this.handleWatchDocumentsResponse(t,r),"initialization"===r.body.case&&e([i,n])}catch(e){t.doc.resetOnlineClients(),t.doc.publish([{type:J.Initialized,source:E.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:J.ConnectionChanged,value:L.Disconnected}]),rG.debug('[WD] c:"'.concat(this.getKey(),'" unwatches')),await this.handleConnectError(e)?(e instanceof G.K&&rT(e)===x.ErrUnauthenticated&&t.doc.publish([{type:J.AuthError,value:{reason:rA(e).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,s(e)}})()})})}handleWatchDocumentsResponse(e,t){if("event"===t.body.case&&t.body.value.type===I.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){for(let[e,t]of(this.status="deactivated",this.attachmentMap))this.detachInternal(e),t.doc.applyStatus(O.Detached)}detachInternal(e){let t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){let{doc:r,docID:n}=e,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:n,changePack:rU.toChangePack(i),pushOnly:"realtime-pushonly"===t},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(r.getKey())}}).then(t=>{let n=rU.fromChangePack(t.changePack);if(n.hasChanges()&&("realtime-pushonly"===e.syncMode||"realtime-syncoff"===e.syncMode))return r;r.applyChangePack(n),e.doc.publish([{type:J.SyncStatusChanged,value:_.Synced}]),r.getStatus()===O.Removed&&this.detachInternal(r.getKey());let s=r.getKey(),o=n.getChangeSize();return rG.info('[PP] c:"'.concat(this.getKey(),'" sync d:"').concat(s,'", push:').concat(i.getChangeSize()," pull:").concat(o," cp:").concat(n.getCheckpoint().toTestString())),r}).catch(async e=>{throw r.publish([{type:J.SyncStatusChanged,value:_.SyncFailed}]),rG.error('[PP] c:"'.concat(this.getKey(),'" err :'),e),e})}async handleConnectError(e){if(!(e instanceof G.K))return!1;if(e.code===H.E.Canceled||e.code===H.E.Unknown||e.code===H.E.ResourceExhausted||e.code===H.E.Unavailable)return!0;if(rT(e)===x.ErrUnauthenticated){if(this.authTokenInjector){let t=await this.authTokenInjector(rA(e).reason);this.setAuthToken(t)}return!0}return(rT(e)===x.ErrClientNotActivated||rT(e)===x.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(0===this.taskQueue.length){this.processing=!1;return}try{this.processing=!0;let e=this.taskQueue.shift();await e()}catch(e){rG.error('[TQ] c:"'.concat(this.getKey(),'" process failed, id:"').concat(this.id,'"'))}this.processNext()}constructor(e,t){var r,n,i,s;let o;this.processing=!1,this.keepalive=!1,t=t||nh,this.key=t.key?t.key:rH(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=null!==(r=t.syncLoopDuration)&&void 0!==r?r:nh.syncLoopDuration,this.reconnectStreamDelay=null!==(n=t.reconnectStreamDelay)&&void 0!==n?n:nh.reconnectStreamDelay,this.retrySyncLoopDelay=null!==(i=t.retrySyncLoopDelay)&&void 0!==i?i:nh.retrySyncLoopDelay;let{authInterceptor:a,setToken:c}=(s=this.apiKey,o=void 0,{authInterceptor:e=>async t=>(s&&t.header.set("x-api-key",s),o&&t.header.set("authorization",o),await e(t)),setToken:e=>{o=e}});this.setAuthToken=c,this.rpcClient=(0,Y.Hb)(tr,(0,Z.u)({baseUrl:e,interceptors:[a,e=>async t=>(t.header.set("x-yorkie-user-agent",nc.u2+"/"+nc.i8),await e(t))],fetch:(e,t)=>{let r={...t,keepalive:this.keepalive};return fetch(e,r)}})),this.taskQueue=[]}}var ng={Client:nu,Document:na,Primitive:tI,Text:r3,Counter:r9,Tree:r6,LogLevel:B,setLogLevel:rW,IntType:N.IntegerCnt,LongType:N.LongCnt};"undefined"!=typeof globalThis&&(globalThis.yorkie={Client:nu,Document:na,Primitive:tI,Text:r3,Counter:r9,Tree:r6,LogLevel:B,setLogLevel:rW,IntType:N.IntegerCnt,LongType:N.LongCnt}),r(109);var nf=r(6182);function nm(e){let{content:t,actions:r}=e,[n,i]=(0,U.useState)(new Date),[s,o]=(0,U.useState)("Enter text here!"),a=n?W(new Date(n.toString())):"",c=e=>{let n=!1;switch(e){case"PUSH":n=!1,t.forEach(e=>{if(e.date===a)return n=!n,0}),n?r.updateContent(a,s):r.addContent(a,s),o("Enter text here!");break;case"DELETE":r.deleteContent(a)}};return(0,K.jsx)("article",{children:(0,K.jsxs)("div",{children:[(0,K.jsx)(nf.ZP,{onChange:i,value:n,locale:"en-EN",showNeighboringMonth:!1,formatDay:(e,t)=>t.toLocaleString("en",{day:"numeric"}),tileClassName:e=>{let{date:r}=e;return t.find(e=>e.date===W(r))?"highlight":""}}),(0,K.jsxs)("p",{children:["selected day : ",a]}),(0,K.jsx)("div",{className:V().memo,children:t.map((e,t)=>{if(e.date===a)return(0,K.jsx)("p",{children:e.text},t)})}),(0,K.jsxs)("div",{className:V().inputForm_editor,children:[(0,K.jsx)("h3",{children:"input form"}),(0,K.jsx)("textarea",{className:V().textArea,value:s,onChange:e=>o(e.target.value)})]}),(0,K.jsx)("button",{className:"button",onClick:()=>c("PUSH"),children:"push"}),(0,K.jsx)("button",{className:"button",onClick:()=>c("DELETE"),children:"pop"})]})})}let np=[{date:W(new Date).replace(/^\d{2}/,"01"),text:"payday"},{date:W(new Date).replace(/^\d{2}/,"17"),text:"Garry's birthday"}],ny="next.js-Scheduler-".concat(W(new Date));function nv(){let[e,t]=(0,U.useState)([]),[r,n]=(0,U.useState)(np),[i]=(0,U.useState)(()=>new ng.Document(ny));return(0,U.useEffect)(()=>{let e=new ng.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});i.subscribe("presence",e=>{e.type!==J.PresenceChanged&&t(function(e){let t=[];for(let{presence:r}of e)t.push(r.userName);return t}(i.getPresences()))}),async function(t,r){await e.activate(),await e.attach(t,{initialPresence:{userName:function(){let e=Math.floor(Math.random()*j.length);return j[e]}()}}),t.update(e=>{e.content||(e.content=np)},"create default content if not exists"),t.subscribe(()=>{r(t.getRoot().content)}),r(t.getRoot().content)}(i,e=>n(e))},[]),(0,K.jsxs)("main",{className:V().main,children:[(0,K.jsxs)("p",{children:["peers : [",e.map((e,t)=>(0,K.jsxs)("span",{children:[" ",e,", "]},t))," ","]"]}),(0,K.jsx)(nm,{content:r,actions:{addContent(e,t){i.update(r=>{r.content.push({date:e,text:t})})},deleteContent(e){i.update(t=>{let r;for(let n of t.content)if(n.date===e){r=n;break}r&&t.content.deleteByID(r.getID())})},updateContent(e,t){i.update(r=>{let n;for(let t of r.content)if(t.date===e){n=t;break}n&&(n.text=t)})}}})]})}},109:function(){},7397:function(e){e.exports={main:"page_main__s_E_L",textArea:"page_textArea__sVKfA",memo:"page_memo__V0Ipn",inputForm_editor:"page_inputForm_editor__Tk7dD"}}},function(e){e.O(0,[662,828,852,744],function(){return e(e.s=4629)}),_N_E=e.O()}]); \ No newline at end of file +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{4629:function(e,t,r){Promise.resolve().then(r.bind(r,1802))},1802:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return nv}});var n,i,s,o,a,c,l,h,d,u,g,f,m,p,y,v,w,A,T,S,I,C,x,P,E,b,k,D,R,N,B,O,J,L,_,M,q,z,K=r(3165),F=r(7397),V=r.n(F),U=r(6189);let j=["Alice","Bob","Carol","Chuck","Dave","Erin","Frank","Grace","Ivan","Justin","Matilda","Oscar","Steve","Victor","Zoe"];function W(e){let[t,r,n]=e.toLocaleDateString("en").split("/");return t=Number(t)>9?t:"0"+t,r=Number(r)>9?r:"0"+r,n=n.slice(2),"".concat(r,"-").concat(t,"-").concat(n)}var G=r(8358),H=r(6390),Y=r(4715),Z=r(1582),X=r(8728),Q=r(601),$=r(1089),ee=r(6731),et=r(9782);(n=S||(S={}))[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",Q.w.util.setEnumType(S,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]),(i=I||(I={}))[i.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",i[i.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",i[i.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",i[i.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",Q.w.util.setEnumType(I,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);class er extends X.v{static fromBinary(e,t){return new er().fromBinary(e,t)}static fromJson(e,t){return new er().fromJson(e,t)}static fromJsonString(e,t){return new er().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(er,e,t)}constructor(e){super(),this.presences={},Q.w.util.initPartial(e,this)}}er.runtime=Q.w,er.typeName="yorkie.v1.Snapshot",er.fields=Q.w.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:eA},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:eF}}]);class en extends X.v{static fromBinary(e,t){return new en().fromBinary(e,t)}static fromJson(e,t){return new en().fromJson(e,t)}static fromJsonString(e,t){return new en().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(en,e,t)}constructor(e){super(),this.documentKey="",this.snapshot=new Uint8Array(0),this.changes=[],this.isRemoved=!1,Q.w.util.initPartial(e,this)}}en.runtime=Q.w,en.typeName="yorkie.v1.ChangePack",en.fields=Q.w.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:eV},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:ei,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:ej},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:eo}]);class ei extends X.v{static fromBinary(e,t){return new ei().fromBinary(e,t)}static fromJson(e,t){return new ei().fromJson(e,t)}static fromJsonString(e,t){return new ei().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ei,e,t)}constructor(e){super(),this.message="",this.operations=[],Q.w.util.initPartial(e,this)}}ei.runtime=Q.w,ei.typeName="yorkie.v1.Change",ei.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:es},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:ea,repeated:!0},{no:4,name:"presence_change",kind:"message",T:eK}]);class es extends X.v{static fromBinary(e,t){return new es().fromBinary(e,t)}static fromJson(e,t){return new es().fromJson(e,t)}static fromJsonString(e,t){return new es().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(es,e,t)}constructor(e){super(),this.clientSeq=0,this.serverSeq=$.q.zero,this.lamport=$.q.zero,this.actorId=new Uint8Array(0),Q.w.util.initPartial(e,this)}}es.runtime=Q.w,es.typeName="yorkie.v1.ChangeID",es.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:eo}]);class eo extends X.v{static fromBinary(e,t){return new eo().fromBinary(e,t)}static fromJson(e,t){return new eo().fromJson(e,t)}static fromJsonString(e,t){return new eo().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eo,e,t)}constructor(e){super(),this.vector={},Q.w.util.initPartial(e,this)}}eo.runtime=Q.w,eo.typeName="yorkie.v1.VersionVector",eo.fields=Q.w.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}]);class ea extends X.v{static fromBinary(e,t){return new ea().fromBinary(e,t)}static fromJson(e,t){return new ea().fromJson(e,t)}static fromJsonString(e,t){return new ea().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ea,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}ea.runtime=Q.w,ea.typeName="yorkie.v1.Operation",ea.fields=Q.w.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:ec,oneof:"body"},{no:2,name:"add",kind:"message",T:el,oneof:"body"},{no:3,name:"move",kind:"message",T:eh,oneof:"body"},{no:4,name:"remove",kind:"message",T:ed,oneof:"body"},{no:5,name:"edit",kind:"message",T:eu,oneof:"body"},{no:6,name:"select",kind:"message",T:eg,oneof:"body"},{no:7,name:"style",kind:"message",T:ef,oneof:"body"},{no:8,name:"increase",kind:"message",T:em,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:ep,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ey,oneof:"body"},{no:11,name:"array_set",kind:"message",T:ev,oneof:"body"}]);class ec extends X.v{static fromBinary(e,t){return new ec().fromBinary(e,t)}static fromJson(e,t){return new ec().fromJson(e,t)}static fromJsonString(e,t){return new ec().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ec,e,t)}constructor(e){super(),this.key="",Q.w.util.initPartial(e,this)}}ec.runtime=Q.w,ec.typeName="yorkie.v1.Operation.Set",ec.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class el extends X.v{static fromBinary(e,t){return new el().fromBinary(e,t)}static fromJson(e,t){return new el().fromJson(e,t)}static fromJsonString(e,t){return new el().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(el,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}el.runtime=Q.w,el.typeName="yorkie.v1.Operation.Add",el.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"prev_created_at",kind:"message",T:ej},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class eh extends X.v{static fromBinary(e,t){return new eh().fromBinary(e,t)}static fromJson(e,t){return new eh().fromJson(e,t)}static fromJsonString(e,t){return new eh().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eh,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eh.runtime=Q.w,eh.typeName="yorkie.v1.Operation.Move",eh.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"prev_created_at",kind:"message",T:ej},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"executed_at",kind:"message",T:ej}]);class ed extends X.v{static fromBinary(e,t){return new ed().fromBinary(e,t)}static fromJson(e,t){return new ed().fromJson(e,t)}static fromJsonString(e,t){return new ed().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ed,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}ed.runtime=Q.w,ed.typeName="yorkie.v1.Operation.Remove",ed.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"executed_at",kind:"message",T:ej}]);class eu extends X.v{static fromBinary(e,t){return new eu().fromBinary(e,t)}static fromJson(e,t){return new eu().fromJson(e,t)}static fromJsonString(e,t){return new eu().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eu,e,t)}constructor(e){super(),this.createdAtMapByActor={},this.content="",this.attributes={},Q.w.util.initPartial(e,this)}}eu.runtime=Q.w,eu.typeName="yorkie.v1.Operation.Edit",eu.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:ej},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]);class eg extends X.v{static fromBinary(e,t){return new eg().fromBinary(e,t)}static fromJson(e,t){return new eg().fromJson(e,t)}static fromJsonString(e,t){return new eg().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eg,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eg.runtime=Q.w,eg.typeName="yorkie.v1.Operation.Select",eg.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"executed_at",kind:"message",T:ej}]);class ef extends X.v{static fromBinary(e,t){return new ef().fromBinary(e,t)}static fromJson(e,t){return new ef().fromJson(e,t)}static fromJsonString(e,t){return new ef().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ef,e,t)}constructor(e){super(),this.attributes={},this.createdAtMapByActor={},Q.w.util.initPartial(e,this)}}ef.runtime=Q.w,ef.typeName="yorkie.v1.Operation.Style",ef.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eU},{no:3,name:"to",kind:"message",T:eU},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:ej},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}}]);class em extends X.v{static fromBinary(e,t){return new em().fromBinary(e,t)}static fromJson(e,t){return new em().fromJson(e,t)}static fromJsonString(e,t){return new em().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(em,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}em.runtime=Q.w,em.typeName="yorkie.v1.Operation.Increase",em.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"value",kind:"message",T:ew},{no:3,name:"executed_at",kind:"message",T:ej}]);class ep extends X.v{static fromBinary(e,t){return new ep().fromBinary(e,t)}static fromJson(e,t){return new ep().fromJson(e,t)}static fromJsonString(e,t){return new ep().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ep,e,t)}constructor(e){super(),this.createdAtMapByActor={},this.contents=[],this.splitLevel=0,Q.w.util.initPartial(e,this)}}ep.runtime=Q.w,ep.typeName="yorkie.v1.Operation.TreeEdit",ep.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eJ},{no:3,name:"to",kind:"message",T:eJ},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}},{no:5,name:"contents",kind:"message",T:eB,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:ej}]);class ey extends X.v{static fromBinary(e,t){return new ey().fromBinary(e,t)}static fromJson(e,t){return new ey().fromJson(e,t)}static fromJsonString(e,t){return new ey().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ey,e,t)}constructor(e){super(),this.attributes={},this.attributesToRemove=[],this.createdAtMapByActor={},Q.w.util.initPartial(e,this)}}ey.runtime=Q.w,ey.typeName="yorkie.v1.Operation.TreeStyle",ey.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"from",kind:"message",T:eJ},{no:3,name:"to",kind:"message",T:eJ},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:ej},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:ej}}]);class ev extends X.v{static fromBinary(e,t){return new ev().fromBinary(e,t)}static fromJson(e,t){return new ev().fromJson(e,t)}static fromJsonString(e,t){return new ev().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ev,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}ev.runtime=Q.w,ev.typeName="yorkie.v1.Operation.ArraySet",ev.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:ej},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"value",kind:"message",T:ew},{no:4,name:"executed_at",kind:"message",T:ej}]);class ew extends X.v{static fromBinary(e,t){return new ew().fromBinary(e,t)}static fromJson(e,t){return new ew().fromJson(e,t)}static fromJsonString(e,t){return new ew().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ew,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ew.runtime=Q.w,ew.typeName="yorkie.v1.JSONElementSimple",ew.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"moved_at",kind:"message",T:ej},{no:3,name:"removed_at",kind:"message",T:ej},{no:4,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:5,name:"value",kind:"scalar",T:12}]);class eA extends X.v{static fromBinary(e,t){return new eA().fromBinary(e,t)}static fromJson(e,t){return new eA().fromJson(e,t)}static fromJsonString(e,t){return new eA().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eA,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}eA.runtime=Q.w,eA.typeName="yorkie.v1.JSONElement",eA.fields=Q.w.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:eT,oneof:"body"},{no:2,name:"json_array",kind:"message",T:eS,oneof:"body"},{no:3,name:"primitive",kind:"message",T:eI,oneof:"body"},{no:5,name:"text",kind:"message",T:eC,oneof:"body"},{no:6,name:"counter",kind:"message",T:ex,oneof:"body"},{no:7,name:"tree",kind:"message",T:eP,oneof:"body"}]);class eT extends X.v{static fromBinary(e,t){return new eT().fromBinary(e,t)}static fromJson(e,t){return new eT().fromJson(e,t)}static fromJsonString(e,t){return new eT().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eT,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eT.runtime=Q.w,eT.typeName="yorkie.v1.JSONElement.JSONObject",eT.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eE,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eS extends X.v{static fromBinary(e,t){return new eS().fromBinary(e,t)}static fromJson(e,t){return new eS().fromJson(e,t)}static fromJsonString(e,t){return new eS().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eS,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eS.runtime=Q.w,eS.typeName="yorkie.v1.JSONElement.JSONArray",eS.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eb,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eI extends X.v{static fromBinary(e,t){return new eI().fromBinary(e,t)}static fromJson(e,t){return new eI().fromJson(e,t)}static fromJsonString(e,t){return new eI().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eI,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}eI.runtime=Q.w,eI.typeName="yorkie.v1.JSONElement.Primitive",eI.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"moved_at",kind:"message",T:ej},{no:5,name:"removed_at",kind:"message",T:ej}]);class eC extends X.v{static fromBinary(e,t){return new eC().fromBinary(e,t)}static fromJson(e,t){return new eC().fromJson(e,t)}static fromJsonString(e,t){return new eC().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eC,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eC.runtime=Q.w,eC.typeName="yorkie.v1.JSONElement.Text",eC.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eD,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class ex extends X.v{static fromBinary(e,t){return new ex().fromBinary(e,t)}static fromJson(e,t){return new ex().fromJson(e,t)}static fromJsonString(e,t){return new ex().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ex,e,t)}constructor(e){super(),this.type=0,this.value=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ex.runtime=Q.w,ex.typeName="yorkie.v1.JSONElement.Counter",ex.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(S)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:ej},{no:4,name:"moved_at",kind:"message",T:ej},{no:5,name:"removed_at",kind:"message",T:ej}]);class eP extends X.v{static fromBinary(e,t){return new eP().fromBinary(e,t)}static fromJson(e,t){return new eP().fromJson(e,t)}static fromJsonString(e,t){return new eP().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eP,e,t)}constructor(e){super(),this.nodes=[],Q.w.util.initPartial(e,this)}}eP.runtime=Q.w,eP.typeName="yorkie.v1.JSONElement.Tree",eP.fields=Q.w.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:eN,repeated:!0},{no:2,name:"created_at",kind:"message",T:ej},{no:3,name:"moved_at",kind:"message",T:ej},{no:4,name:"removed_at",kind:"message",T:ej}]);class eE extends X.v{static fromBinary(e,t){return new eE().fromBinary(e,t)}static fromJson(e,t){return new eE().fromJson(e,t)}static fromJsonString(e,t){return new eE().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eE,e,t)}constructor(e){super(),this.key="",Q.w.util.initPartial(e,this)}}eE.runtime=Q.w,eE.typeName="yorkie.v1.RHTNode",eE.fields=Q.w.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:eA}]);class eb extends X.v{static fromBinary(e,t){return new eb().fromBinary(e,t)}static fromJson(e,t){return new eb().fromJson(e,t)}static fromJsonString(e,t){return new eb().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eb,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eb.runtime=Q.w,eb.typeName="yorkie.v1.RGANode",eb.fields=Q.w.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:eb},{no:2,name:"element",kind:"message",T:eA}]);class ek extends X.v{static fromBinary(e,t){return new ek().fromBinary(e,t)}static fromJson(e,t){return new ek().fromJson(e,t)}static fromJsonString(e,t){return new ek().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ek,e,t)}constructor(e){super(),this.value="",this.isRemoved=!1,Q.w.util.initPartial(e,this)}}ek.runtime=Q.w,ek.typeName="yorkie.v1.NodeAttr",ek.fields=Q.w.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:ej},{no:3,name:"is_removed",kind:"scalar",T:8}]);class eD extends X.v{static fromBinary(e,t){return new eD().fromBinary(e,t)}static fromJson(e,t){return new eD().fromJson(e,t)}static fromJsonString(e,t){return new eD().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eD,e,t)}constructor(e){super(),this.value="",this.attributes={},Q.w.util.initPartial(e,this)}}eD.runtime=Q.w,eD.typeName="yorkie.v1.TextNode",eD.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:eR},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:ej},{no:4,name:"ins_prev_id",kind:"message",T:eR},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ek}}]);class eR extends X.v{static fromBinary(e,t){return new eR().fromBinary(e,t)}static fromJson(e,t){return new eR().fromJson(e,t)}static fromJsonString(e,t){return new eR().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eR,e,t)}constructor(e){super(),this.offset=0,Q.w.util.initPartial(e,this)}}eR.runtime=Q.w,eR.typeName="yorkie.v1.TextNodeID",eR.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5}]);class eN extends X.v{static fromBinary(e,t){return new eN().fromBinary(e,t)}static fromJson(e,t){return new eN().fromJson(e,t)}static fromJsonString(e,t){return new eN().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eN,e,t)}constructor(e){super(),this.type="",this.value="",this.depth=0,this.attributes={},Q.w.util.initPartial(e,this)}}eN.runtime=Q.w,eN.typeName="yorkie.v1.TreeNode",eN.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:eO},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:ej},{no:5,name:"ins_prev_id",kind:"message",T:eO},{no:6,name:"ins_next_id",kind:"message",T:eO},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ek}}]);class eB extends X.v{static fromBinary(e,t){return new eB().fromBinary(e,t)}static fromJson(e,t){return new eB().fromJson(e,t)}static fromJsonString(e,t){return new eB().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eB,e,t)}constructor(e){super(),this.content=[],Q.w.util.initPartial(e,this)}}eB.runtime=Q.w,eB.typeName="yorkie.v1.TreeNodes",eB.fields=Q.w.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:eN,repeated:!0}]);class eO extends X.v{static fromBinary(e,t){return new eO().fromBinary(e,t)}static fromJson(e,t){return new eO().fromJson(e,t)}static fromJsonString(e,t){return new eO().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eO,e,t)}constructor(e){super(),this.offset=0,Q.w.util.initPartial(e,this)}}eO.runtime=Q.w,eO.typeName="yorkie.v1.TreeNodeID",eO.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5}]);class eJ extends X.v{static fromBinary(e,t){return new eJ().fromBinary(e,t)}static fromJson(e,t){return new eJ().fromJson(e,t)}static fromJsonString(e,t){return new eJ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eJ,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eJ.runtime=Q.w,eJ.typeName="yorkie.v1.TreePos",eJ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:eO},{no:2,name:"left_sibling_id",kind:"message",T:eO}]);class eL extends X.v{static fromBinary(e,t){return new eL().fromBinary(e,t)}static fromJson(e,t){return new eL().fromJson(e,t)}static fromJsonString(e,t){return new eL().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eL,e,t)}constructor(e){super(),this.id="",this.username="",Q.w.util.initPartial(e,this)}}eL.runtime=Q.w,eL.typeName="yorkie.v1.User",eL.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:ee.E}]);class e_ extends X.v{static fromBinary(e,t){return new e_().fromBinary(e,t)}static fromJson(e,t){return new e_().fromJson(e,t)}static fromJsonString(e,t){return new e_().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e_,e,t)}constructor(e){super(),this.id="",this.name="",this.publicKey="",this.secretKey="",this.authWebhookUrl="",this.authWebhookMethods=[],this.clientDeactivateThreshold="",Q.w.util.initPartial(e,this)}}e_.runtime=Q.w,e_.typeName="yorkie.v1.Project",e_.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:ee.E},{no:9,name:"updated_at",kind:"message",T:ee.E}]);class eM extends X.v{static fromBinary(e,t){return new eM().fromBinary(e,t)}static fromJson(e,t){return new eM().fromJson(e,t)}static fromJsonString(e,t){return new eM().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eM,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eM.runtime=Q.w,eM.typeName="yorkie.v1.UpdatableProjectFields",eM.fields=Q.w.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:et.Gm},{no:2,name:"auth_webhook_url",kind:"message",T:et.Gm},{no:3,name:"auth_webhook_methods",kind:"message",T:eq},{no:4,name:"client_deactivate_threshold",kind:"message",T:et.Gm}]);class eq extends X.v{static fromBinary(e,t){return new eq().fromBinary(e,t)}static fromJson(e,t){return new eq().fromJson(e,t)}static fromJsonString(e,t){return new eq().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eq,e,t)}constructor(e){super(),this.methods=[],Q.w.util.initPartial(e,this)}}eq.runtime=Q.w,eq.typeName="yorkie.v1.UpdatableProjectFields.AuthWebhookMethods",eq.fields=Q.w.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]);class ez extends X.v{static fromBinary(e,t){return new ez().fromBinary(e,t)}static fromJson(e,t){return new ez().fromJson(e,t)}static fromJsonString(e,t){return new ez().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ez,e,t)}constructor(e){super(),this.id="",this.key="",this.snapshot="",Q.w.util.initPartial(e,this)}}ez.runtime=Q.w,ez.typeName="yorkie.v1.DocumentSummary",ez.fields=Q.w.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:ee.E},{no:5,name:"accessed_at",kind:"message",T:ee.E},{no:6,name:"updated_at",kind:"message",T:ee.E}]);class eK extends X.v{static fromBinary(e,t){return new eK().fromBinary(e,t)}static fromJson(e,t){return new eK().fromJson(e,t)}static fromJsonString(e,t){return new eK().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eK,e,t)}constructor(e){super(),this.type=0,Q.w.util.initPartial(e,this)}}eK.runtime=Q.w,eK.typeName="yorkie.v1.PresenceChange",eK.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(C)},{no:2,name:"presence",kind:"message",T:eF}]),(s=C||(C={}))[s.UNSPECIFIED=0]="UNSPECIFIED",s[s.PUT=1]="PUT",s[s.DELETE=2]="DELETE",s[s.CLEAR=3]="CLEAR",Q.w.util.setEnumType(C,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);class eF extends X.v{static fromBinary(e,t){return new eF().fromBinary(e,t)}static fromJson(e,t){return new eF().fromJson(e,t)}static fromJsonString(e,t){return new eF().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eF,e,t)}constructor(e){super(),this.data={},Q.w.util.initPartial(e,this)}}eF.runtime=Q.w,eF.typeName="yorkie.v1.Presence",eF.fields=Q.w.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}]);class eV extends X.v{static fromBinary(e,t){return new eV().fromBinary(e,t)}static fromJson(e,t){return new eV().fromJson(e,t)}static fromJsonString(e,t){return new eV().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eV,e,t)}constructor(e){super(),this.serverSeq=$.q.zero,this.clientSeq=0,Q.w.util.initPartial(e,this)}}eV.runtime=Q.w,eV.typeName="yorkie.v1.Checkpoint",eV.fields=Q.w.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}]);class eU extends X.v{static fromBinary(e,t){return new eU().fromBinary(e,t)}static fromJson(e,t){return new eU().fromJson(e,t)}static fromJsonString(e,t){return new eU().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eU,e,t)}constructor(e){super(),this.offset=0,this.relativeOffset=0,Q.w.util.initPartial(e,this)}}eU.runtime=Q.w,eU.typeName="yorkie.v1.TextNodePos",eU.fields=Q.w.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:ej},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]);class ej extends X.v{static fromBinary(e,t){return new ej().fromBinary(e,t)}static fromJson(e,t){return new ej().fromJson(e,t)}static fromJsonString(e,t){return new ej().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(ej,e,t)}constructor(e){super(),this.lamport=$.q.zero,this.delimiter=0,this.actorId=new Uint8Array(0),Q.w.util.initPartial(e,this)}}ej.runtime=Q.w,ej.typeName="yorkie.v1.TimeTicket",ej.fields=Q.w.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}]);class eW extends X.v{static fromBinary(e,t){return new eW().fromBinary(e,t)}static fromJson(e,t){return new eW().fromJson(e,t)}static fromJsonString(e,t){return new eW().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eW,e,t)}constructor(e){super(),this.topic="",this.payload=new Uint8Array(0),Q.w.util.initPartial(e,this)}}eW.runtime=Q.w,eW.typeName="yorkie.v1.DocEventBody",eW.fields=Q.w.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]);class eG extends X.v{static fromBinary(e,t){return new eG().fromBinary(e,t)}static fromJson(e,t){return new eG().fromJson(e,t)}static fromJsonString(e,t){return new eG().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eG,e,t)}constructor(e){super(),this.type=0,this.publisher="",Q.w.util.initPartial(e,this)}}eG.runtime=Q.w,eG.typeName="yorkie.v1.DocEvent",eG.fields=Q.w.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:Q.w.getEnumType(I)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:eW}]);class eH extends X.v{static fromBinary(e,t){return new eH().fromBinary(e,t)}static fromJson(e,t){return new eH().fromJson(e,t)}static fromJsonString(e,t){return new eH().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eH,e,t)}constructor(e){super(),this.clientKey="",Q.w.util.initPartial(e,this)}}eH.runtime=Q.w,eH.typeName="yorkie.v1.ActivateClientRequest",eH.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]);class eY extends X.v{static fromBinary(e,t){return new eY().fromBinary(e,t)}static fromJson(e,t){return new eY().fromJson(e,t)}static fromJsonString(e,t){return new eY().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eY,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eY.runtime=Q.w,eY.typeName="yorkie.v1.ActivateClientResponse",eY.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]);class eZ extends X.v{static fromBinary(e,t){return new eZ().fromBinary(e,t)}static fromJson(e,t){return new eZ().fromJson(e,t)}static fromJsonString(e,t){return new eZ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eZ,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eZ.runtime=Q.w,eZ.typeName="yorkie.v1.DeactivateClientRequest",eZ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]);class eX extends X.v{static fromBinary(e,t){return new eX().fromBinary(e,t)}static fromJson(e,t){return new eX().fromJson(e,t)}static fromJsonString(e,t){return new eX().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eX,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}eX.runtime=Q.w,eX.typeName="yorkie.v1.DeactivateClientResponse",eX.fields=Q.w.util.newFieldList(()=>[]);class eQ extends X.v{static fromBinary(e,t){return new eQ().fromBinary(e,t)}static fromJson(e,t){return new eQ().fromJson(e,t)}static fromJsonString(e,t){return new eQ().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(eQ,e,t)}constructor(e){super(),this.clientId="",Q.w.util.initPartial(e,this)}}eQ.runtime=Q.w,eQ.typeName="yorkie.v1.AttachDocumentRequest",eQ.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:en}]);class e$ extends X.v{static fromBinary(e,t){return new e$().fromBinary(e,t)}static fromJson(e,t){return new e$().fromJson(e,t)}static fromJsonString(e,t){return new e$().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e$,e,t)}constructor(e){super(),this.documentId="",Q.w.util.initPartial(e,this)}}e$.runtime=Q.w,e$.typeName="yorkie.v1.AttachDocumentResponse",e$.fields=Q.w.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:en}]);class e0 extends X.v{static fromBinary(e,t){return new e0().fromBinary(e,t)}static fromJson(e,t){return new e0().fromJson(e,t)}static fromJsonString(e,t){return new e0().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e0,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.removeIfNotAttached=!1,Q.w.util.initPartial(e,this)}}e0.runtime=Q.w,e0.typeName="yorkie.v1.DetachDocumentRequest",e0.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]);class e1 extends X.v{static fromBinary(e,t){return new e1().fromBinary(e,t)}static fromJson(e,t){return new e1().fromJson(e,t)}static fromJsonString(e,t){return new e1().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e1,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e1.runtime=Q.w,e1.typeName="yorkie.v1.DetachDocumentResponse",e1.fields=Q.w.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:en}]);class e2 extends X.v{static fromBinary(e,t){return new e2().fromBinary(e,t)}static fromJson(e,t){return new e2().fromJson(e,t)}static fromJsonString(e,t){return new e2().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e2,e,t)}constructor(e){super(),this.clientId="",this.documentId="",Q.w.util.initPartial(e,this)}}e2.runtime=Q.w,e2.typeName="yorkie.v1.WatchDocumentRequest",e2.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]);class e3 extends X.v{static fromBinary(e,t){return new e3().fromBinary(e,t)}static fromJson(e,t){return new e3().fromJson(e,t)}static fromJsonString(e,t){return new e3().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e3,e,t)}constructor(e){super(),this.body={case:void 0},Q.w.util.initPartial(e,this)}}e3.runtime=Q.w,e3.typeName="yorkie.v1.WatchDocumentResponse",e3.fields=Q.w.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:e9,oneof:"body"},{no:2,name:"event",kind:"message",T:eG,oneof:"body"}]);class e9 extends X.v{static fromBinary(e,t){return new e9().fromBinary(e,t)}static fromJson(e,t){return new e9().fromJson(e,t)}static fromJsonString(e,t){return new e9().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e9,e,t)}constructor(e){super(),this.clientIds=[],Q.w.util.initPartial(e,this)}}e9.runtime=Q.w,e9.typeName="yorkie.v1.WatchDocumentResponse.Initialization",e9.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]);class e4 extends X.v{static fromBinary(e,t){return new e4().fromBinary(e,t)}static fromJson(e,t){return new e4().fromJson(e,t)}static fromJsonString(e,t){return new e4().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e4,e,t)}constructor(e){super(),this.clientId="",this.documentId="",Q.w.util.initPartial(e,this)}}e4.runtime=Q.w,e4.typeName="yorkie.v1.RemoveDocumentRequest",e4.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en}]);class e8 extends X.v{static fromBinary(e,t){return new e8().fromBinary(e,t)}static fromJson(e,t){return new e8().fromJson(e,t)}static fromJsonString(e,t){return new e8().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e8,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e8.runtime=Q.w,e8.typeName="yorkie.v1.RemoveDocumentResponse",e8.fields=Q.w.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:en}]);class e5 extends X.v{static fromBinary(e,t){return new e5().fromBinary(e,t)}static fromJson(e,t){return new e5().fromJson(e,t)}static fromJsonString(e,t){return new e5().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e5,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.pushOnly=!1,Q.w.util.initPartial(e,this)}}e5.runtime=Q.w,e5.typeName="yorkie.v1.PushPullChangesRequest",e5.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:en},{no:4,name:"push_only",kind:"scalar",T:8}]);class e6 extends X.v{static fromBinary(e,t){return new e6().fromBinary(e,t)}static fromJson(e,t){return new e6().fromJson(e,t)}static fromJsonString(e,t){return new e6().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e6,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}e6.runtime=Q.w,e6.typeName="yorkie.v1.PushPullChangesResponse",e6.fields=Q.w.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:en}]);class e7 extends X.v{static fromBinary(e,t){return new e7().fromBinary(e,t)}static fromJson(e,t){return new e7().fromJson(e,t)}static fromJsonString(e,t){return new e7().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(e7,e,t)}constructor(e){super(),this.clientId="",this.documentId="",this.topic="",this.payload=new Uint8Array(0),Q.w.util.initPartial(e,this)}}e7.runtime=Q.w,e7.typeName="yorkie.v1.BroadcastRequest",e7.fields=Q.w.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]);class te extends X.v{static fromBinary(e,t){return new te().fromBinary(e,t)}static fromJson(e,t){return new te().fromJson(e,t)}static fromJsonString(e,t){return new te().fromJsonString(e,t)}static equals(e,t){return Q.w.util.equals(te,e,t)}constructor(e){super(),Q.w.util.initPartial(e,this)}}te.runtime=Q.w,te.typeName="yorkie.v1.BroadcastResponse",te.fields=Q.w.util.newFieldList(()=>[]);var tt=r(6438);let tr={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:eH,O:eY,kind:tt.t.Unary},deactivateClient:{name:"DeactivateClient",I:eZ,O:eX,kind:tt.t.Unary},attachDocument:{name:"AttachDocument",I:eQ,O:e$,kind:tt.t.Unary},detachDocument:{name:"DetachDocument",I:e0,O:e1,kind:tt.t.Unary},removeDocument:{name:"RemoveDocument",I:e4,O:e8,kind:tt.t.Unary},pushPullChanges:{name:"PushPullChanges",I:e5,O:e6,kind:tt.t.Unary},watchDocument:{name:"WatchDocument",I:e2,O:e3,kind:tt.t.ServerStreaming},broadcast:{name:"Broadcast",I:e7,O:te,kind:tt.t.Unary}}};var tn=r(624);(o=x||(x={})).Ok="ok",o.ErrClientNotActivated="ErrClientNotActivated",o.ErrClientNotFound="ErrClientNotFound",o.ErrUnimplemented="ErrUnimplemented",o.ErrInvalidType="ErrInvalidType",o.ErrDummy="ErrDummy",o.ErrDocumentNotAttached="ErrDocumentNotAttached",o.ErrDocumentNotDetached="ErrDocumentNotDetached",o.ErrDocumentRemoved="ErrDocumentRemoved",o.ErrInvalidObjectKey="ErrInvalidObjectKey",o.ErrInvalidArgument="ErrInvalidArgument",o.ErrNotInitialized="ErrNotInitialized",o.ErrNotReady="ErrNotReady",o.ErrRefused="ErrRefused",o.ErrContextNotProvided="ErrContextNotProvided",o.ErrPermissionDenied="ErrPermissionDenied",o.ErrUnauthenticated="ErrUnauthenticated";class ti extends Error{constructor(e,t){super(t),this.code=e,this.message=t,this.name="YorkieError",this.toString=()=>"[code=".concat(this.code,"]: ").concat(this.message)}}function ts(e){if(e instanceof Map){let t=Array.from(e);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(e))}let to=e=>!e||0===Object.entries(e).length,ta=e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=JSON.stringify(n);return t},tc=e=>{let t={};for(let[r,n]of Object.entries(e))t[r]=JSON.parse(n);return t};(a=P||(P={})).Put="put",a.Clear="clear";class tl{set(e,t){for(let t of Object.keys(e))this.presence[t]=e[t];this.context.setPresenceChange({type:"put",presence:ts(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}constructor(e,t){this.context=e,this.presence=t}}let th="000000000000000000000000";class td{static of(e,t,r){return new td(e,t,r)}static fromStruct(e){return td.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return"".concat(this.lamport.toString(),":").concat(this.actorID,":").concat(this.delimiter)}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return"".concat(this.lamport.toString(),":").concat(this.actorID.slice(-2),":").concat(this.delimiter)}setActor(e){return new td(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return 0===this.compare(e)}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return -1;let t=this.actorID.localeCompare(e.actorID);return 0!==t?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}constructor(e,t,r){this.lamport=e,this.delimiter=t,this.actorID=r}}let tu=new td(0n,0,th);function tg(e){return e.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case"\n":return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}new td(0x7fffffffffffffffn,4294967295,"FFFFFFFFFFFFFFFFFFFFFFFF");class tf{getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!!(!this.movedAt||e&&e.after(this.movedAt))&&(this.movedAt=e,!0)}setRemovedAt(e){this.removedAt=e}remove(e){return!!(e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt)))&&(this.removedAt=e,!0)}isRemoved(){return!!this.removedAt}constructor(e){this.createdAt=e}}class tm extends tf{constructor(e){super(e)}}class tp{static of(e,t){return new tp(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}constructor(e,t){this.strKey=e,this.value=t}}class ty{static create(){return new ty}set(e,t,r){let n;let i=this.nodeMapByKey.get(e);null!=i&&!i.isRemoved()&&i.remove(r)&&(n=i.getValue());let s=tp.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),s),(null==i||r.after(i.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,s),t.setMovedAt(r)),n}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new ti(x.ErrInvalidArgument,"fail to find ".concat(e.toIDString()));let r=this.nodeMapByCreatedAt.get(e.toIDString());return r.remove(t),r.getValue()}subPathOf(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){let t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(e.getCreatedAt().toIDString()));let r=this.nodeMapByKey.get(t.getStrKey());t===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){let r=this.nodeMapByKey.get(e);if(null!=r&&r.remove(t))return r.getValue()}has(e){let t=this.nodeMapByKey.get(e);return null!=t&&!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){let t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(let[,e]of this.nodeMapByKey)yield e}constructor(){this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}}class tv extends tm{static create(e,t){if(!t)return new tv(e,ty.create());let r=ty.create();for(let[e,n]of Object.entries(t))r.set(e,n.deepcopy(),n.getCreatedAt());return new tv(e,r)}subPathOf(e){return this.memberNodes.subPathOf(e)}purge(e){this.memberNodes.purge(e)}set(e,t,r){return this.memberNodes.set(e,t,r)}delete(e,t){return this.memberNodes.delete(e,t)}deleteByKey(e,t){return this.memberNodes.deleteByKey(e,t)}get(e){let t=this.memberNodes.get(e);return null==t?void 0:t.getValue()}getByID(e){let t=this.memberNodes.getByID(e);return null==t?void 0:t.getValue()}has(e){return this.memberNodes.has(e)}toJSON(){let e=[];for(let[t,r]of this)e.push('"'.concat(tg(t),'":').concat(r.toJSON()));return"{".concat(e.join(","),"}")}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){let e={};for(let[t,r]of this){let{createdAt:n,value:i,type:s}=r.toJSForTest();e[t]={key:t,createdAt:n,value:i,type:s}}return{createdAt:this.getCreatedAt().toTestString(),value:e,type:"YORKIE_OBJECT"}}getKeys(){let e=[];for(let[t]of this)e.push(t);return e}toSortedJSON(){let e=[];for(let[t]of this)e.push(t);let t=[];for(let n of e.sort()){var r;let e=null===(r=this.memberNodes.get(n))||void 0===r?void 0:r.getValue();t.push('"'.concat(tg(n),'":').concat(e.toSortedJSON()))}return"{".concat(t.join(","),"}")}getRHT(){return this.memberNodes}deepcopy(){let e=tv.create(this.getCreatedAt());for(let t of this.memberNodes)e.memberNodes.set(t.getStrKey(),t.getValue().deepcopy(),this.getPositionedAt());return e.remove(this.getRemovedAt()),e}getDescendants(e){for(let t of this.memberNodes){let r=t.getValue();if(e(r,this))return;r instanceof tm&&r.getDescendants(e)}}*[Symbol.iterator](){let e=new Set;for(let t of this.memberNodes)e.has(t.getStrKey())||(e.add(t.getStrKey()),t.isRemoved()||(yield[t.getStrKey(),t.getValue()]))}constructor(e,t){super(e),this.memberNodes=t}}(c=E||(E={})).Local="local",c.Remote="remote",c.UndoRedo="undoredo";class tw{getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new ti(x.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}constructor(e,t){this.parentCreatedAt=e,this.executedAt=t}}class tA{getNodeString(){return"".concat(this.weight).concat(this.value)}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}constructor(e){this.value=e,this.initWeight()}}class tT{get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new ti(x.ErrInvalidArgument,"out of index range: pos: ".concat(e," > node.length: ").concat(t.getLength()));return this.splayNode(t),[t,e]}indexOf(e){return e&&(e===this.root||e.hasLinks())?(this.splayNode(e),this.root.getLeftWeight()):-1}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t)):this.root=t,t}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);let t=new tT(e.getLeft());t.root&&t.root.setParent();let r=new tT(e.getRight());if(r.root&&r.root.setParent(),t.root){let e=t.getRightmost();t.splayNode(e),t.root.setRight(r.root),r.root&&r.root.setParent(t.root),this.root=t.root}else this.root=r.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){let t=[];for(let r of(this.traversePostorder(e.getRight(),t),t))r.initWeight();this.updateTreeWeight(e)}toTestString(){let e=[];return this.traverseInorder(this.root,e),e.map(e=>"[".concat(e.getWeight(),",").concat(e.getLength(),"]").concat(e.getValue()||"")).join("")}checkWeight(){let e=[];for(let t of(this.traverseInorder(this.root,e),e))if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){let t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){let t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return!!(e&&e.hasParent())&&e.getParent().getLeft()===e}isRightChild(e){return!!(e&&e.hasParent())&&e.getParent().getRight()===e}constructor(e){this.root=e}}var tS=r(7319);(l=b||(b={}))[l.Null=0]="Null",l[l.Boolean=1]="Boolean",l[l.Integer=2]="Integer",l[l.Long=3]="Long",l[l.Double=4]="Double",l[l.String=5]="String",l[l.Bytes=6]="Bytes",l[l.Date=7]="Date";class tI extends tf{static of(e,t){return new tI(e,t)}static valueFromBytes(e,t){switch(e){case 0:return null;case 1:return!!t[0];case 2:return t[0]|t[1]<<8|t[2]<<16|t[3]<<24;case 4:{let e=new DataView(t.buffer);return t.forEach(function(t,r){e.setUint8(r,t)}),e.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(t);case 3:return tS.Z.fromBytesLE(Array.from(t));case 6:return t;case 7:return new Date(tS.Z.fromBytesLE(Array.from(t),!0).toNumber());default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}toJSON(){return 5===this.valueType?'"'.concat(tg(this.value),'"'):"".concat(this.value)}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){let e=tI.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":if(this.isInteger(e))return 2;return 4;case"string":return 5;case"object":if(null===e)return 0;if(e instanceof tS.Z)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return void 0!==tI.getPrimitiveType(e)}static isInteger(e){return e%1==0}isNumericType(){let e=this.valueType;return 2===e||3===e||4===e}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:{let e=this.value;return new Uint8Array(e?[1]:[0])}case 2:{let e=this.value;return new Uint8Array([255&e,e>>8&255,e>>16&255,e>>24&255])}case 4:{let e=this.value,t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),t}case 5:return new TextEncoder().encode(this.value);case 3:{let e=this.value.toBytesLE();return Uint8Array.from(e)}case 6:return this.value;case 7:{let e=this.value,t=tS.Z.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(t)}default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(this.valueType))}}constructor(e,t){super(t),this.valueType=tI.getPrimitiveType(e),this.value=void 0===e?null:e}}class tC extends tA{static createAfter(e,t){let r=new tC(t),n=e.next;return e.next=r,r.prev=e,r.next=n,n&&(n.prev=r),r}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}constructor(e){super(e),this.value=e}}class tx{static create(){return new tx}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(e.toIDString()));for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.getCreatedAt(),n=this.findNextBeforeExecutedAt(e,r),i=tC.createAfter(n,t);n===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(n,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(e,t,r){let n=this.nodeMapByCreatedAt.get(e.toIDString());if(!n)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(e.toIDString()));let i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new ti(x.ErrInvalidArgument,"cant find the given node: ".concat(t.toIDString()));n!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(n.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){let t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find the given createdAt: ".concat(e.getCreatedAt().toIDString()));this.release(t)}getByIndex(e){if(e>=this.length)return;let[t,r]=this.nodeMapByIndex.find(e),n=t;if(0===e&&t===this.dummyHead||r>0)do n&&(n=n.getNext());while(n&&n.isRemoved());return n}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString()),n=r.isRemoved();return r.remove(t)&&!n&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){let r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){let e=[];for(let t of this){let r="".concat(t.getCreatedAt().toIDString(),":").concat(t.getValue().toJSON());t.isRemoved()?e.push("{".concat(r,"}")):e.push("[".concat(r,"]"))}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}constructor(){let e=tI.of(0,tu);e.setRemovedAt(tu),this.dummyHead=new tC(e),this.last=this.dummyHead,this.nodeMapByIndex=new tT,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}}class tP extends tm{static create(e,t){if(!t)return new tP(e,tx.create());let r=tx.create();for(let e of t)r.insertAfter(r.getLastCreatedAt(),e.deepcopy());return new tP(e,r)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,t){this.elements.insertAfter(e,t)}moveAfter(e,t,r){this.elements.moveAfter(e,t,r)}get(e){let t=this.elements.getByIndex(e);return null==t?void 0:t.getValue()}getByID(e){let t=this.elements.getByID(e);return null==t?void 0:t.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,t){return this.elements.delete(e,t)}deleteByIndex(e,t){return this.elements.deleteByIndex(e,t)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(let e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(let t of this.elements){let r=t.getValue();if(e(r,this))return;r instanceof tm&&r.getDescendants(e)}}toJSON(){let e=[];for(let t of this)e.push(t.toJSON());return"[".concat(e.join(","),"]")}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){let e={};for(let t=0;t({...e,value:e.value?{attributes:tc(e.value.getAttributes()),content:e.value.getContent()}:{attributes:void 0,content:""},type:"content"})),l,[a,a]]}setStyle(e,t,r,n,i){let[,s]=this.rgaTreeSplit.findNodeWithSplit(e[1],r),[,o]=this.rgaTreeSplit.findNodeWithSplit(e[0],r),a=[],c=this.rgaTreeSplit.findBetween(o,s),l=new Map,h=[];for(let e of c){let t;let s=e.getCreatedAt().getActorID(),o=0n;if(void 0===i&&void 0===n?o=0x7fffffffffffffffn:i.size()>0?o=i.get(s)?i.get(s):0n:t=n.has(s)?n.get(s):tu,e.canStyle(r,t,o)){let t=l.get(s),r=e.getCreatedAt();(!t||r.after(t))&&l.set(s,r),h.push(e)}}let d=[];for(let e of h){if(e.isRemoved())continue;let[n,i]=this.rgaTreeSplit.findIndexesFromRange(e.createPosRange());for(let[s,o]of(a.push({type:"style",actor:r.getActorID(),from:n,to:i,value:{attributes:tc(t)}}),Object.entries(t))){let[t]=e.getValue().setAttr(s,o,r);void 0!==t&&d.push({parent:e.getValue(),child:t})}}return[l,d,a]}indexRangeToPosRange(e,t){let r=this.rgaTreeSplit.indexToPos(e);return e===t?[r,r]:[r,this.rgaTreeSplit.indexToPos(t)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){let e=[];for(let t of this.rgaTreeSplit)t.isRemoved()||e.push(t.getValue().toJSON());return"[".concat(e.join(","),"]")}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){let e=[];for(let t of this.rgaTreeSplit)if(!t.isRemoved()){let r=t.getValue();e.push({attributes:tc(r.getAttributes()),content:r.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){let e=new tO(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){let e=[];for(let t of this.rgaTreeSplit)for(let r of(t.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:t}),t.getValue().getGCPairs()))e.push(r);return e}constructor(e,t){super(t),this.rgaTreeSplit=e}}class tJ extends tw{static create(e,t,r,n,i,s,o){return new tJ(e,t,r,n,i,s,o)}execute(e,t,r){let n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(n instanceof tO))throw new ti(x.ErrInvalidArgument,"fail to execute, only Text can execute edit");let[,i,s]=n.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(let t of s)e.registerGCPair(t);return{opInfos:i.map(t=>{let{from:r,to:n,value:i}=t;return{type:"edit",from:r,to:n,value:i,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t=this.fromPos.toTestString(),r=this.toPos.toTestString(),n=this.content;return"".concat(e,".EDIT(").concat(t,",").concat(r,",").concat(n,")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.content=i,this.attributes=s}}class tL extends tw{static create(e,t,r,n,i,s){return new tL(e,t,r,n,i,s)}execute(e,t,r){let n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(n instanceof tO))throw new ti(x.ErrInvalidArgument,"fail to execute, only Text can execute edit");let[,i,s]=n.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(let t of i)e.registerGCPair(t);return{opInfos:s.map(t=>{let{from:r,to:n,value:i}=t;return{type:"style",from:r,to:n,value:i,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t=this.fromPos.toTestString(),r=this.toPos.toTestString(),n=this.attributes;return"".concat(e,".STYL(").concat(t,",").concat(r,",").concat(JSON.stringify(n),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s){super(e,s),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.attributes=i}}let t_="text";function tM(e,t){let r=0,n=e.children;for(let e=0;e!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(){for(var e=arguments.length,t=Array(e),r=0;re+t.paddedSize,0),r.size=r._children.reduce((e,t)=>e+t.paddedSize,0),r._children))e.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");let r=this._children.indexOf(t);if(-1===r)throw new ti(x.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");if(e.isRemoved){let t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(e=>!e.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new ti(x.ErrRefused,"Text node cannot have children");let t=e;for(;t;){let e=this._children.indexOf(t);if(-1!==e)return e;t=t.parent}return -1}constructor(e,t=[]){if(this.type=e,this.size=0,this._children=t,this.isText&&this._children.length>0)throw new ti(x.ErrRefused,"Text node cannot have children")}}function tz(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;for(let n of e._children)tz(n,t,r+1);t(e,r)}(d=D||(D={})).Start="Start",d.End="End",d.Text="Text";class tK{tokensBetween(e,t,r){!function e(t,r,n,i){if(r>n)throw new ti(x.ErrInvalidArgument,"from is greater than to: ".concat(r," > ").concat(n));if(r>t.size)throw new ti(x.ErrInvalidArgument,"from is out of range: ".concat(r," > ").concat(t.size));if(n>t.size)throw new ti(x.ErrInvalidArgument,"to is out of range: ".concat(n," > ").concat(t.size));if(r===n)return;let s=0;for(let o of t.children){if(r-o.paddedSizeo.size;(o.isText||c)&&i([o,o.isText?"Text":"Start"],l),e(o,Math.max(0,t),Math.min(a,o.size),i),l&&i([o,"End"],l)}s+=o.paddedSize}}(this.root,e,t,r)}traverse(e){!function e(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;for(let i of t.children)e(i,r,n+1);r(t,n)}(this.root,e,0)}traverseAll(e){tz(this.root,e,0)}findTreePos(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return function e(t,r){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r>t.size)throw new ti(x.ErrInvalidArgument,"index is out of range: ".concat(r," > ").concat(t.size));if(t.isText)return{node:t,offset:r};let i=0,s=0;for(let o of t.children){if(n&&o.isText&&o.size>=r-s)return e(o,r-s,n);if(r===s)break;if(!n&&o.paddedSize===r-s)return{node:t,offset:i+1};if(o.paddedSize>r-s)return e(o,r-s-1,n);s+=o.paddedSize,i+=1}return{node:t,offset:i}}(this.root,e,t)}treePosToPath(e){let t=[],r=e.node;if(r.isText){let n=r.parent.findOffset(r);if(-1===n)throw new ti(x.ErrInvalidArgument,"invalid treePos");let i=tM(r.parent,n);t.push(i+e.offset),r=r.parent}else if(r.hasTextChild()){let n=tM(r,e.offset);t.push(n)}else t.push(e.offset);for(;r.parent;){let e=r.parent.findOffset(r);if(-1===e)throw new ti(x.ErrInvalidArgument,"invalid treePos");t.push(e),r=r.parent}return t.reverse()}pathToIndex(e){let t=this.pathToTreePos(e);return this.indexOf(t)}pathToTreePos(e){if(!e.length)throw new ti(x.ErrInvalidArgument,"unacceptable path");let t=this.root;for(let r=0;re===t?0:e0){if(!t.right)return t;t.right.parent=t,t=t.right}else if(!(r<0))return t;else if(t.left)t.left.parent=t,t=t.left;else{let e=t.parent,r=t;for(;e&&r===e.left;)r=e,e=e.parent;return e}}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return 0===this.counter}getInternal(e,t){for(;t;){let r=this.comparator(e,t.key);if(0===r)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new tV(e,t,!0);let n=this.comparator(e,r.key);return n<0?r.left=this.putInternal(e,t,r.left):n>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(0>this.comparator(t,e.key))this.isRed(e.left)||this.isRed(e.left.left)||(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),0===this.comparator(t,e.key)&&!e.right){this.counter-=1;return}if(this.isRed(e.right)||this.isRed(e.right.left)||(e=this.moveRedRight(e)),0===this.comparator(t,e.key)){this.counter-=1;let t=this.min(e.right);e.value=t.value,e.key=t.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return this.isRed(e.left)||this.isRed(e.left.left)||(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){let t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){let t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}constructor(e){this.comparator=void 0!==e?e:tF,this.counter=0}}(u=R||(R={})).Content="content",u.Style="style",u.RemoveStyle="removeStyle";class tW{static of(e,t){return new tW(e,t)}static fromTreePos(e){let t;let{offset:r}=e,{node:n}=e;return n.isText?(t=n.parent.children[0]===n&&0===r?n.parent:n,n=n.parent):t=0===r?n:n.children[r-1],tW.of(n.id,tG.of(t.getCreatedAt(),t.getOffset()+r))}getParentID(){return this.parentID}static fromStruct(e){return tW.of(tG.of(td.fromStruct(e.parentID.createdAt),e.parentID.offset),tG.of(td.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){let t=this.getParentID(),r=this.getLeftSiblingID(),n=e.findFloorNode(t),i=e.findFloorNode(r);if(!n||!i)throw new ti(x.ErrRefused,"cannot find node of CRDTTreePos(".concat(t.toTestString(),", ").concat(r.toTestString(),")"));return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=e.findFloorNode(i.insPrevID)),[n,i]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}constructor(e,t){this.parentID=e,this.leftSiblingID=t}}class tG{static of(e,t){return new tG(e,t)}static fromStruct(e){return tG.of(td.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{let r=e.getCreatedAt().compare(t.getCreatedAt());return 0!==r?r:e.getOffset()>t.getOffset()?1:e.getOffset(){let r=e.deepcopy();return r.parent=t,r}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new ti(x.ErrInvalidType,"cannot get value of element node: ".concat(this.type));return this._value}set value(e){if(!this.isText)throw new ti(x.ErrInvalidType,"cannot set value of element node: ".concat(this.type));this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){let t=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),t&&this.updateAncestorsSize()}cloneText(e){return new tH(tG.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new tH(tG.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,t,r){let n=this.isText?this.splitText(t,this.id.getOffset()):this.splitElement(t,r);return n&&(n.insPrevID=this.id,this.insNextID&&(e.findFloorNode(this.insNextID).insPrevID=n.id,n.insNextID=this.insNextID),this.insNextID=n.id,e.registerNode(n)),n}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,t,r){return(t?!this.getCreatedAt().after(t):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,t,r){return!this.isText&&(t?!this.getCreatedAt().after(t):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,t){this.attrs||(this.attrs=new tN);let r=[];for(let[n,i]of Object.entries(e))r.push(this.attrs.set(n,i,t));return r}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){let e=[];if(!this.attrs)return e;for(let t of this.attrs)t.getRemovedAt()&&e.push({parent:this,child:t});return e}constructor(e,t,r,n,i){super(t),this._value="",this.id=e,this.removedAt=i,n&&(this.attrs=n),"string"==typeof r?this.value=r:Array.isArray(r)&&(this._children=r)}}function tY(e){if(e.isText)return{type:e.type,value:e.value};let t={type:e.type,children:e.children.map(tY)};if(e.attrs){var r;t.attributes=tc(null===(r=e.attrs)||void 0===r?void 0:r.toObject())}return t}function tZ(e){if(e.isText)return e.value;let t="";return e.attrs&&e.attrs.size()&&(t=" "+Array.from(e.attrs).filter(e=>!e.isRemoved()).sort((e,t)=>e.getKey().localeCompare(t.getKey())).map(e=>{let t=JSON.parse(e.getValue());return"string"==typeof t?"".concat(e.getKey(),'="').concat(t,'"'):"".concat(e.getKey(),'="').concat(tg(e.getValue()),'"')}).join(" ")),"<".concat(e.type).concat(t,">").concat(e.children.map(e=>tZ(e)).join(""),"")}class tX extends tf{static create(e,t){return new tX(e,t)}findFloorNode(e){let t=this.nodeMapByID.floorEntry(e);if(t&&t.key.getCreatedAt().equals(e.getCreatedAt()))return t.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,t){let[r,n]=e.toTreeNodePair(this),i=n,s=r===i,o=i.parent&&!s?i.parent:r;if(i.isText&&i.split(this,e.getLeftSiblingID().getOffset()-i.id.getOffset()),t){let e=o.allChildren,r=s?0:e.indexOf(i)+1;for(let n=r;n{let s,[o]=e,a=o.getCreatedAt().getActorID(),c=0n;if(void 0===i&&void 0===n?c=0x7fffffffffffffffn:i.size()>0?c=i.get(a)?i.get(a):0n:s=n.has(a)?n.get(a):tu,o.canStyle(r,s,c)&&t){let e=d.get(a),n=o.getCreatedAt();(!e||n.after(e))&&d.set(a,n);let i=o.setAttrs(t,r),s=i.reduce((e,t)=>{let[,r]=t;return r&&(e[r.getKey()]=h[r.getKey()]),e},{}),c=o.parent,g=o.prevSibling||o.parent;for(let[e]of(Object.keys(s).length>0&&l.push({type:"style",from:this.toIndex(c,g),to:this.toIndex(o,o),fromPath:this.toPath(c,g),toPath:this.toPath(o,o),actor:r.getActorID(),value:s}),i))e&&u.push({parent:o,child:e})}}),[d,u,l]}removeStyle(e,t,r,n,i){let[s,o]=this.findNodesAndSplitText(e[0],r),[a,c]=this.findNodesAndSplitText(e[1],r),l=[],h=new Map,d=[];return this.traverseInPosRange(s,o,a,c,e=>{let s,[o]=e,a=o.getCreatedAt().getActorID(),c=0n;if(void 0===i&&void 0===n?c=0x7fffffffffffffffn:i.size()>0?c=i.get(a)?i.get(a):0n:s=n.has(a)?n.get(a):tu,o.canStyle(r,s,c)&&t){let e=h.get(a),n=o.getCreatedAt();for(let i of((!e||n.after(e))&&h.set(a,n),o.attrs||(o.attrs=new tN),t))for(let e of o.attrs.remove(i,r))d.push({parent:o,child:e});let i=o.parent,s=o.prevSibling||o.parent;l.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(i,s),to:this.toIndex(o,o),fromPath:this.toPath(i,s),toPath:this.toPath(o,o),value:t})}}),[h,d,l]}edit(e,t,r,n,i,s,o){let[a,c]=this.findNodesAndSplitText(e[0],n),[l,h]=this.findNodesAndSplitText(e[1],n),d=this.toIndex(a,c),u=this.toPath(a,c),g=[],f=[],m=[],p=new Map;this.traverseInPosRange(a,c,l,h,(e,t)=>{let r,[i,a]=e;if(a===D.Start&&!t)for(let e of i.children)m.push(e);let c=i.getCreatedAt().getActorID(),l=0n;if(void 0===o&&void 0===s?l=0x7fffffffffffffffn:o.size()>0?l=o.get(c)?o.get(c):0n:r=s.has(c)?s.get(c):tu,i.canDelete(n,r,l)||g.includes(i.parent)){let e=p.get(c),t=i.getCreatedAt();(!e||t.after(e))&&p.set(c,t),(a===D.Text||a===D.Start)&&g.push(i),f.push([i,a])}});let y=this.makeDeletionChanges(f,n),v=[];for(let e of g)e.remove(n),e.isRemoved&&v.push({parent:this,child:e});for(let e of m)e.removedAt||a.append(e);if(r>0){let e=0,t=a,s=c;for(;e{a.isRemoved&&(e.remove(n),v.push({parent:this,child:e})),this.nodeMapByID.put(e.id,e)}),i.isRemoved||e.push(i);if(e.length){let t=e.map(e=>tY(e));y.length&&y[y.length-1].from===d?y[y.length-1].value=t:y.push({type:"content",from:d,to:d,fromPath:u,toPath:u,actor:n.getActorID(),value:t})}}return[y,v,p]}editT(e,t,r,n,i){let s=this.findPos(e[0]),o=this.findPos(e[1]);this.edit([s,o],t,r,n,i)}move(e,t,r){throw new ti(x.ErrUnimplemented,"not implemented: ".concat(e,", ").concat(t,", ").concat(r))}purge(e){var t;null===(t=e.parent)||void 0===t||t.removeChild(e),this.nodeMapByID.remove(e.id);let r=e.insPrevID,n=e.insNextID;r&&(this.findFloorNode(r).insNextID=n),n&&(this.findFloorNode(n).insPrevID=r),e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){let e=[];return this.indexTree.traverse(t=>{for(let r of(t.getRemovedAt()&&e.push({parent:this,child:t}),t.getGCPairs()))e.push(r)}),e}findPos(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=this.indexTree.findTreePos(e,t);return tW.fromTreePos(r)}pathToPosRange(e){let t=this.pathToIndex(e);return[this.findPos(t),this.findPos(t+1)]}pathToPos(e){let t=this.indexTree.pathToIndex(e);return this.findPos(t)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return tZ(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){var e=this;let t=this.indexTree.getRoot(),r=function(t){var n,i,s,o;let a,c,l,h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,g=t.isText?{node:t,offset:0}:h&&d?e.toTreePos(h,d):null;g&&(a=e.indexTree.indexOf(g),c=e.indexTree.treePosToPath(g),l=tW.fromTreePos(g).toStruct());let f={type:t.type,parent:null==h?void 0:h.id.toTestString(),size:t.size,id:t.id.toTestString(),removedAt:null===(n=t.removedAt)||void 0===n?void 0:n.toTestString(),insPrev:null===(i=t.insPrevID)||void 0===i?void 0:i.toTestString(),insNext:null===(s=t.insNextID)||void 0===s?void 0:s.toTestString(),value:t.isText?t.value:void 0,isRemoved:t.isRemoved,children:[],depth:u,attributes:t.attrs?tc(null===(o=t.attrs)||void 0===o?void 0:o.toObject()):void 0,index:a,path:c,pos:l};for(let e=0;e0&&d===r[r.length-1].to?(r[r.length-1].to=u,r[r.length-1].toPath=this.toPath(h,a)):r.push({type:"content",from:d,to:u,fromPath:this.toPath(l,s),toPath:this.toPath(h,a),actor:t.getActorID()}))}return r.reverse()}findRightToken(e){let[t,r]=e;if(r===D.Start){let e=t.allChildren;return e.length>0?[e[0],e[0].isText?D.Text:D.Start]:[t,D.End]}let n=t.parent,i=n.allChildren,s=i.indexOf(t);if(n&&s===i.length-1)return[n,D.End];let o=i[s+1];return[o,o.isText?D.Text:D.Start]}findLeftToken(e){let[t,r]=e;if(r===D.End){let e=t.allChildren;if(e.length>0){let t=e[e.length-1];return[t,t.isText?D.Text:D.End]}return[t,D.Start]}let n=t.parent,i=n.allChildren,s=i.indexOf(t);if(n&&0===s)return[n,D.Start];let o=i[s-1];return[o,o.isText?D.Text:D.End]}constructor(e,t){super(t),this.indexTree=new tK(e),this.nodeMapByID=new tj(tG.createComparator()),this.indexTree.traverseAll(e=>{this.nodeMapByID.put(e.id,e)})}}class tQ extends tw{static create(e,t,r,n,i,s,o){return new tQ(e,t,r,n,i,s,o)}execute(e,t,r){var n;let i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(i instanceof tX))throw new ti(x.ErrInvalidArgument,"fail to execute, only Tree can execute edit");let s=this.getExecutedAt(),[o,a]=i.edit([this.fromPos,this.toPos],null===(n=this.contents)||void 0===n?void 0:n.map(e=>e.deepcopy()),this.splitLevel,s,(()=>{let e=s.getDelimiter();return void 0!==this.contents&&(e+=this.contents.length),()=>td.of(s.getLamport(),++e,s.getActorID())})(),this.maxCreatedAtMapByActor,r);for(let t of a)e.registerGCPair(t);return{opInfos:o.map(t=>{let{from:r,to:n,value:i,splitLevel:s,fromPath:o,toPath:a}=t;return{type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:r,to:n,value:i,splitLevel:s,fromPath:o,toPath:a}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t="".concat(this.fromPos.getLeftSiblingID().getCreatedAt().toTestString(),"/").concat(this.fromPos.getLeftSiblingID().getOffset()),r="".concat(this.toPos.getLeftSiblingID().getCreatedAt().toTestString(),"/").concat(this.toPos.getLeftSiblingID().getOffset()),n=this.contents||[];return"".concat(e,".EDIT(").concat(t,",").concat(r,",").concat(n.map(e=>tZ(e)).join(""),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.contents=n,this.splitLevel=i,this.maxCreatedAtMapByActor=s}}class t${set(e,t){this.vector.set(e,t)}unset(e){this.vector.delete(e)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(let[,t]of this)t>e&&(e=t);return e}max(e){let t=new Map;for(let[r,n]of e){let e=this.vector.get(r),i=e&&e>n?e:n;t.set(r,i)}for(let[r,n]of this){let i=e.get(r),s=i&&i>n?i:n;t.set(r,s)}return new t$(t)}afterOrEqual(e){let t=this.vector.get(e.getActorID());return void 0!==t&&t>=e.getLamport()}deepcopy(){let e=new Map;for(let[t,r]of this.vector)e.set(t,r);return new t$(e)}filter(e){let t=new Map;for(let[r]of e){let e=this.vector.get(r);void 0!==e&&t.set(r,e)}return new t$(t)}size(){return this.vector.size}*[Symbol.iterator](){for(let[e,t]of this.vector)yield[e,t]}constructor(e){this.vector=e||new Map}}let t0=new t$(new Map);class t1{static of(e,t,r,n,i){return new t1(e,t,r,n,i)}next(){let e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new t1(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){let t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,r=e.versionVector;0===r.size()&&(r=r.deepcopy()).set(e.actor,e.lamport);let n=this.versionVector.max(r),i=new t1(this.clientSeq,t,this.actor,n);return i.versionVector.set(this.actor,t),i}setClocks(e,t){let r=e>this.lamport?e+1n:this.lamport+1n;t.unset(th);let n=this.versionVector.max(t);return n.set(this.actor,r),t1.of(this.clientSeq,r,this.actor,n)}createTimeTicket(e){return td.of(this.lamport,e,this.actor)}setActor(e){return new t1(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new t1(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return"".concat(this.lamport.toString(),":").concat(this.actor.slice(-2),":").concat(this.clientSeq)}constructor(e,t,r,n,i){this.clientSeq=e,this.serverSeq=i,this.lamport=t,this.versionVector=n,this.actor=r}}let t2=new t1(0,0n,th,t0);class t3{static create(e){let{id:t,operations:r,presenceChange:n,message:i}=e;return new t3({id:t,operations:r,presenceChange:n,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(let t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return void 0!==this.presenceChange}getPresenceChange(){return this.presenceChange}execute(e,t,r){let n=[],i=[];for(let t of this.operations){let s=t.execute(e,r,this.id.getVersionVector());if(!s)continue;let{opInfos:o,reverseOp:a}=s;n.push(...o),a&&i.unshift(a)}return this.presenceChange&&(this.presenceChange.type===P.Put?t.set(this.id.getActorID(),ts(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:n,reverseOps:i}}toTestString(){return"".concat(this.operations.map(e=>e.toTestString()).join(","))}toStruct(){return{changeID:rU.bytesToHex(rU.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>rU.bytesToHex(rU.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){let{changeID:t,operations:r,presenceChange:n,message:i}=e;return t3.create({id:rU.bytesToChangeID(rU.hexToBytes(t)),operations:null==r?void 0:r.map(e=>rU.bytesToOperation(rU.hexToBytes(e))),presenceChange:n,message:i})}constructor({id:e,operations:t,presenceChange:r,message:n}){this.id=e,this.operations=t||[],this.presenceChange=r,this.message=n}}class t9{static create(e,t,r,n,i,s,o){return new t9(e,t,r,n,i,s,o)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}constructor(e,t,r,n,i,s,o){this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=n,this.snapshot=s,this.minSyncedTicket=o,this.versionVector=i}}class t4{static of(e,t){return new t4(e,t)}increaseClientSeq(e){return 0===e?this:new t4(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;let t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return t4.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return"serverSeq=".concat(this.serverSeq,", clientSeq=").concat(this.clientSeq)}constructor(e,t){this.serverSeq=e,this.clientSeq=t}}let t8=new t4(0n,0);class t5{static of(e,t){return new t5(e,t)}static fromStruct(e){return t5.of(td.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return 0===this.createdAt.compare(e.createdAt)&&this.offset===e.offset}hasSameCreatedAt(e){return 0===this.createdAt.compare(e.createdAt)}split(e){return new t5(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return"".concat(this.createdAt.toTestString(),":").concat(this.offset)}toIDString(){return"".concat(this.createdAt.toIDString(),":").concat(this.offset)}constructor(e,t){this.createdAt=e,this.offset=t}}let t6=t5.of(tu,0);class t7{static of(e,t){return new t7(e,t)}static fromStruct(e){let t=t5.fromStruct(e.id);return t7.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return t5.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return"".concat(this.id.toTestString(),":").concat(this.relativeOffset)}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return!!this.id.equals(e.id)&&this.relativeOffset===e.relativeOffset}constructor(e,t){this.id=e,this.relativeOffset=t}}class re extends tA{static create(e,t){return new re(e,t)}static createComparator(){return(e,t)=>{let r=e.getCreatedAt().compare(t.getCreatedAt());return 0!==r?r:e.getOffset()>t.getOffset()?1:e.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){let t=this.treeByID.floorEntry(e);if(t&&(t.key.equals(e)||t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){let r=[],n=e;for(;n&&n!==t;)r.push(n),n=n.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new ti(x.ErrInvalidArgument,"offset should be less than or equal to length");if(0===t)return e;if(t===e.getContentLength())return e.getNext();let r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);let n=e.getInsNext();return n&&n.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,n){if(!e.length)return[[],new Map,new Map];let[i,s]=this.filterNodes(e,t,r,n),o=new Map,a=new Map,c=this.makeChanges(s,t);for(let e of i){let r=e.getCreatedAt().getActorID();(!o.has(r)||e.getID().getCreatedAt().after(o.get(r)))&&o.set(r,e.getID().getCreatedAt()),a.set(e.getID().toIDString(),e),e.remove(t)}return this.deleteIndexNodes(s),[c,o,a]}filterNodes(e,t,r,n){let i=[],s=[],[o,a]=this.findEdgesOfCandidates(e);for(let a of(s.push(o),e)){let e;let o=a.getCreatedAt().getActorID(),c=0n;void 0===n&&void 0===r?c=0x7fffffffffffffffn:n.size()>0?c=n.get(o)?n.get(o):0n:e=r.has(o)?r.get(o):tu,a.canDelete(t,e,c)?i.push(a):s.push(a)}return s.push(a),[i,s]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){let r,n;let i=[];for(let s=0;se<0?Math.ceil(e):Math.floor(e);(g=N||(N={}))[g.IntegerCnt=0]="IntegerCnt",g[g.LongCnt=1]="LongCnt";class rn extends tf{static create(e,t,r){return new rn(e,t,r)}static valueFromBytes(e,t){switch(e){case 0:return t[0]|t[1]<<8|t[2]<<16|t[3]<<24;case 1:return tS.Z.fromBytesLE(Array.from(t));default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}toJSON(){return"".concat(this.value)}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){let e=rn.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":if(e instanceof tS.Z)return 1;return;case"number":if(e>2147483647||e<-2147483648)return 1;return 0;default:return}}static isSupport(e){return!!rn.getCounterType(e)}static isInteger(e){return e%1==0}isNumericType(){let e=this.valueType;return 0===e||1===e}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{let e=this.value;return new Uint8Array([255&e,e>>8&255,e>>16&255,e>>24&255])}case 1:{let e=this.value.toBytesLE();return Uint8Array.from(e)}default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(this.valueType))}}increase(e){function t(e){if(!e.isNumericType())throw TypeError("Unsupported type of value: ".concat(typeof e.getValue()))}return t(this),t(e),1===this.valueType?this.value=this.value.add(e.getValue()):e.getType()===b.Long?this.value=this.value+e.getValue().toInt():this.value=tS.Z.fromNumber(this.value+rr(e.getValue())).toInt(),this}constructor(e,t,r){switch(super(r),this.valueType=e,e){case 0:"number"==typeof t?t>2147483647||t<-2147483648?this.value=tS.Z.fromNumber(t).toInt():this.value=rr(t):this.value=t.toInt();break;case 1:"number"==typeof t?this.value=tS.Z.fromNumber(t):this.value=t;break;default:throw new ti(x.ErrUnimplemented,"unimplemented type: ".concat(e))}}}class ri extends tw{static create(e,t,r){return new ri(e,t,r)}execute(e){let t=e.findByCreatedAt(this.getParentCreatedAt());if(!t)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(t instanceof rn))throw new ti(x.ErrInvalidArgument,"fail to execute, only Counter can execute increase");let r=this.value.deepcopy();return t.increase(r),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:r.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){let e=this.value.deepcopy(),t=e.getType()===b.Long?e.getValue().multiply(-1):-1*e.getValue();return ri.create(this.getParentCreatedAt(),tI.of(t,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return"".concat(this.getParentCreatedAt().toTestString(),".INCREASE.").concat(this.value.toJSON())}getValue(){return this.value}constructor(e,t,r){super(e,r),this.value=t}}class rs extends tw{static create(e,t,r,n,i,s){return new rs(e,t,r,n,i,[],s)}static createTreeRemoveStyleOperation(e,t,r,n,i,s){return new rs(e,t,r,n,new Map,i,s)}execute(e,t,r){let n,i;let s=e.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new ti(x.ErrInvalidArgument,"fail to find ".concat(this.getParentCreatedAt()));if(!(s instanceof tX))throw new ti(x.ErrInvalidArgument,"fail to execute, only Tree can execute edit");if(this.attributes.size){let e={};[...this.attributes].forEach(t=>{let[r,n]=t;return e[r]=n}),[,i,n]=s.style([this.fromPos,this.toPos],e,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{let e=this.attributesToRemove;[,i,n]=s.removeStyle([this.fromPos,this.toPos],e,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(let t of i)e.registerGCPair(t);return{opInfos:n.map(t=>{let{from:r,to:n,value:i,fromPath:s,toPath:o}=t;return{type:"tree-style",from:r,to:n,value:this.attributes.size?{attributes:i}:{attributesToRemove:i},fromPath:s,toPath:o,path:e.createPath(this.getParentCreatedAt())}})}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){let e=this.getParentCreatedAt().toTestString(),t="".concat(this.fromPos.getLeftSiblingID().getCreatedAt().toTestString(),":").concat(this.fromPos.getLeftSiblingID().getOffset()),r="".concat(this.toPos.getLeftSiblingID().getCreatedAt().toTestString(),":").concat(this.toPos.getLeftSiblingID().getOffset());return"".concat(e,".STYLE(").concat(t,",").concat(r,",").concat(Object.entries(this.attributes||{}).map(e=>{let[t,r]=e;return"".concat(t,':"').concat(r,'"')}).join(" "),")")}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}constructor(e,t,r,n,i,s,o){super(e,o),this.fromPos=t,this.toPos=r,this.maxCreatedAtMapByActor=n,this.attributes=i,this.attributesToRemove=s}}function ro(e){return new es({clientSeq:e.getClientSeq(),lamport:e.getLamport(),actorId:rV(e.getActorID()),versionVector:rc(e.getVersionVector())})}function ra(e){if(e)return new ej({lamport:e.getLamport(),delimiter:e.getDelimiter(),actorId:rV(e.getActorID())})}function rc(e){if(!e)return;let t=new eo;for(let[r,n]of e)t.vector[r]=BigInt(n.toString());return t}function rl(e){switch(e){case b.Null:return S.NULL;case b.Boolean:return S.BOOLEAN;case b.Integer:return S.INTEGER;case b.Long:return S.LONG;case b.Double:return S.DOUBLE;case b.String:return S.STRING;case b.Bytes:return S.BYTES;case b.Date:return S.DATE;default:throw new ti(x.ErrInvalidType,"unsupported type: ".concat(e))}}function rh(e){switch(e){case N.IntegerCnt:return S.INTEGER_CNT;case N.LongCnt:return S.LONG_CNT;default:throw new ti(x.ErrInvalidType,"unsupported type: ".concat(e))}}function rd(e){if(e instanceof tv)return new ew({type:S.JSON_OBJECT,createdAt:ra(e.getCreatedAt()),value:rK(e)});if(e instanceof tP)return new ew({type:S.JSON_ARRAY,createdAt:ra(e.getCreatedAt()),value:ry(e).toBinary()});if(e instanceof tO)return new ew({type:S.TEXT,createdAt:ra(e.getCreatedAt())});if(e instanceof tI)return new ew({type:rl(e.getType()),createdAt:ra(e.getCreatedAt()),value:e.toBytes()});if(e instanceof rn)return new ew({type:rh(e.getType()),createdAt:ra(e.getCreatedAt()),value:e.toBytes()});if(e instanceof tX)return new ew({type:S.TREE,createdAt:ra(e.getCreatedAt()),value:rv(e).toBinary()});throw new ti(x.ErrUnimplemented,"unimplemented element")}function ru(e){return new eU({createdAt:ra(e.getID().getCreatedAt()),offset:e.getID().getOffset(),relativeOffset:e.getRelativeOffset()})}function rg(e){return new eJ({parentId:rf(e.getParentID()),leftSiblingId:rf(e.getLeftSiblingID())})}function rf(e){return new eO({createdAt:ra(e.getCreatedAt()),offset:e.getOffset()})}function rm(e){let t=new ea;if(e instanceof tb){let r=new ec;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.key=e.getKey(),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="set",t.body.value=r}else if(e instanceof tk){let r=new el;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.prevCreatedAt=ra(e.getPrevCreatedAt()),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="add",t.body.value=r}else if(e instanceof tD){let r=new eh;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.prevCreatedAt=ra(e.getPrevCreatedAt()),r.createdAt=ra(e.getCreatedAt()),r.executedAt=ra(e.getExecutedAt()),t.body.case="move",t.body.value=r}else if(e instanceof tE){let r=new ed;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.createdAt=ra(e.getCreatedAt()),r.executedAt=ra(e.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(e instanceof tJ){let r=new eu;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=ru(e.getFromPos()),r.to=ru(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);r.content=e.getContent();let i=r.attributes;for(let[t,r]of e.getAttributes())i[t]=r;r.executedAt=ra(e.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(e instanceof tL){let r=new ef;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=ru(e.getFromPos()),r.to=ru(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);let i=r.attributes;for(let[t,r]of e.getAttributes())i[t]=r;r.executedAt=ra(e.getExecutedAt()),t.body.case="style",t.body.value=r}else if(e instanceof ri){let r=new em;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.value=rd(e.getValue()),r.executedAt=ra(e.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(e instanceof tQ){let r=new ep,n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=rg(e.getFromPos()),r.to=rg(e.getToPos()),r.contents=function(e){let t=[];if(!e||!e.length)return t;for(let r of e)t.push(new eB({content:rp(r)}));return t}(e.getContents()),r.splitLevel=e.getSplitLevel(),r.executedAt=ra(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(e instanceof rs){let r=new ey;r.parentCreatedAt=ra(e.getParentCreatedAt()),r.from=rg(e.getFromPos()),r.to=rg(e.getToPos());let n=r.createdAtMapByActor;for(let[t,r]of e.getMaxCreatedAtMapByActor())n[t]=ra(r);let i=e.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{let t=r.attributes;for(let[r,n]of e.getAttributes())t[r]=n}r.executedAt=ra(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new ti(x.ErrUnimplemented,"unimplemented operation");return t}function rp(e){if(!e)return[];let t=[];return tz(e,(e,r)=>{let n=new eN({id:rf(e.id),type:e.type,removedAt:ra(e.removedAt),depth:r});e.isText&&(n.value=e.value),e.insPrevID&&(n.insPrevId=rf(e.insPrevID)),e.insNextID&&(n.insNextId=rf(e.insNextID)),e.attrs&&(n.attributes=function(e){let t={};for(let r of e)t[r.getKey()]=new ek({value:r.getValue(),updatedAt:ra(r.getUpdatedAt()),isRemoved:r.isRemoved()});return t}(e.attrs)),t.push(n)}),t}function ry(e){let t=new eA;return t.body.case="jsonArray",t.body.value=new eS({nodes:function(e){let t=[];for(let r of e)t.push(new eb({element:rw(r.getValue())}));return t}(e.getElements()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}function rv(e){let t=new eA;return t.body.case="tree",t.body.value=new eP({nodes:rp(e.getRoot()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}function rw(e){if(e instanceof tv)return function(e){let t=new eA;return t.body.case="jsonObject",t.body.value=new eT({nodes:function(e){let t=[];for(let r of e)t.push(new eE({key:r.getStrKey(),element:rw(r.getValue())}));return t}(e.getRHT()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tP)return ry(e);if(e instanceof tI)return function(e){let t=new eA;return t.body.case="primitive",t.body.value=new eI({type:rl(e.getType()),value:e.toBytes(),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tO)return function(e){let t=new eA;return t.body.case="text",t.body.value=new eC({nodes:function(e){let t=[];for(let n of e){var r;let e=new eD;e.id=new eR({createdAt:ra((r=n.getID()).getCreatedAt()),offset:r.getOffset()}),e.value=n.getValue().getContent(),e.removedAt=ra(n.getRemovedAt());let i=e.attributes;for(let e of n.getValue().getAttrs()){let t=new ek;t.value=e.getValue(),t.updatedAt=ra(e.getUpdatedAt()),i[e.getKey()]=t}t.push(e)}return t}(e.getRGATreeSplit()),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof rn)return function(e){let t=new eA;return t.body.case="counter",t.body.value=new ex({type:rh(e.getType()),value:e.toBytes(),createdAt:ra(e.getCreatedAt()),movedAt:ra(e.getMovedAt()),removedAt:ra(e.getRemovedAt())}),t}(e);if(e instanceof tX)return rv(e);throw new ti(x.ErrUnimplemented,"unimplemented element")}function rA(e){if(!(e instanceof G.K))return{};for(let t of e.findDetails(tn.Qf))return t.metadata;return{}}function rT(e){var t;return null!==(t=rA(e).code)&&void 0!==t?t:""}function rS(e){return t1.of(e.clientSeq,BigInt(e.lamport),rF(e.actorId),rI(e.versionVector),BigInt(e.serverSeq))}function rI(e){if(!e)return;let t=new t$;return Object.entries(e.vector).forEach(e=>{let[r,n]=e;t.set(r,BigInt(n.toString()))}),t}function rC(e){if(e)return td.of(BigInt(e.lamport),e.delimiter,rF(e.actorId))}function rx(e){let t={};return Object.entries(e.data).forEach(e=>{let[r,n]=e;t[r]=JSON.parse(n)}),t}function rP(e){switch(e){case S.NULL:return b.Null;case S.BOOLEAN:return b.Boolean;case S.INTEGER:return b.Integer;case S.LONG:return b.Long;case S.DOUBLE:return b.Double;case S.STRING:return b.String;case S.BYTES:return b.Bytes;case S.DATE:return b.Date}throw new ti(x.ErrUnimplemented,"unimplemented value type: ".concat(e))}function rE(e){switch(e){case S.INTEGER_CNT:return N.IntegerCnt;case S.LONG_CNT:return N.LongCnt}throw new ti(x.ErrUnimplemented,"unimplemented value type: ".concat(e))}function rb(e){switch(e.type){case S.JSON_OBJECT:if(!e.value)return tv.create(rC(e.createdAt));return rz(e.value);case S.JSON_ARRAY:if(!e.value)return tP.create(rC(e.createdAt));return function(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return r_(eA.fromBinary(e).body.value)}(e.value);case S.TEXT:return tO.create(rt.create(),rC(e.createdAt));case S.TREE:return function(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return rM(eA.fromBinary(e).body.value)}(e.value);case S.NULL:case S.BOOLEAN:case S.INTEGER:case S.LONG:case S.DOUBLE:case S.STRING:case S.BYTES:case S.DATE:return tI.of(tI.valueFromBytes(rP(e.type),e.value),rC(e.createdAt));case S.INTEGER_CNT:case S.LONG_CNT:return rn.create(rE(e.type),rn.valueFromBytes(rE(e.type),e.value),rC(e.createdAt))}}function rk(e){return t7.of(t5.of(rC(e.createdAt),e.offset),e.relativeOffset)}function rD(e){return t5.of(rC(e.createdAt),e.offset)}function rR(e){return tW.of(rN(e.parentId),rN(e.leftSiblingId))}function rN(e){return tG.of(rC(e.createdAt),e.offset)}function rB(e){if(0===e.length)return;let t=[];for(let r of e)t.push(function(e){let t=rN(e.id),r=tH.create(t,e.type),n=Object.entries(e.attributes);return r.isText?r.value=e.value:n.length&&(r.attrs=function(e){let t=tN.create();for(let[r,n]of Object.entries(e))t.setInternal(r,n.value,rC(n.updatedAt),n.isRemoved);return t}(e.attributes)),e.insPrevId&&(r.insPrevID=rN(e.insPrevId)),e.insNextId&&(r.insNextID=rN(e.insNextId)),r.removedAt=rC(e.removedAt),r}(r));let r=t[t.length-1],n=new Map;n.set(e[t.length-1].depth,t[t.length-1]);for(let r=t.length-2;r>=0;r--)n.get(e[r].depth-1).prepend(t[r]),n.set(e[r].depth,t[r]);return r.updateDescendantsSize(),tX.create(r,tu).getRoot()}function rO(e){if("set"===e.body.case){let t=e.body.value;return tb.create(t.key,rb(t.value),rC(t.parentCreatedAt),rC(t.executedAt))}if("add"===e.body.case){let t=e.body.value;return tk.create(rC(t.parentCreatedAt),rC(t.prevCreatedAt),rb(t.value),rC(t.executedAt))}if("move"===e.body.case){let t=e.body.value;return tD.create(rC(t.parentCreatedAt),rC(t.prevCreatedAt),rC(t.createdAt),rC(t.executedAt))}if("remove"===e.body.case){let t=e.body.value;return tE.create(rC(t.parentCreatedAt),rC(t.createdAt),rC(t.executedAt))}if("edit"===e.body.case){let t=e.body.value,r=new Map;Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))});let n=new Map;return Object.entries(t.attributes).forEach(e=>{let[t,r]=e;n.set(t,r)}),tJ.create(rC(t.parentCreatedAt),rk(t.from),rk(t.to),r,t.content,n,rC(t.executedAt))}if("style"===e.body.case){let t=e.body.value,r=new Map;Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))});let n=new Map;return Object.entries(t.attributes).forEach(e=>{let[t,r]=e;n.set(t,r)}),tL.create(rC(t.parentCreatedAt),rk(t.from),rk(t.to),r,n,rC(t.executedAt))}if("select"===e.body.case)return;else if("increase"===e.body.case){let t=e.body.value;return ri.create(rC(t.parentCreatedAt),rb(t.value),rC(t.executedAt))}else if("treeEdit"===e.body.case){let t=e.body.value,r=new Map;return Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,n]=e;r.set(t,rC(n))}),tQ.create(rC(t.parentCreatedAt),rR(t.from),rR(t.to),function(e){if(!e.length)return;let t=[];return e.forEach(e=>{let r=rB(e.content);t.push(r)}),t}(t.contents),t.splitLevel,r,rC(t.executedAt))}else if("treeStyle"===e.body.case){let t=e.body.value,r=new Map,n=t.attributesToRemove,i=new Map;return((null==t?void 0:t.createdAtMapByActor)&&Object.entries(t.createdAtMapByActor).forEach(e=>{let[t,r]=e;i.set(t,rC(r))}),(null==n?void 0:n.length)>0)?rs.createTreeRemoveStyleOperation(rC(t.parentCreatedAt),rR(t.from),rR(t.to),i,n,rC(t.executedAt)):(Object.entries(t.attributes).forEach(e=>{let[t,n]=e;r.set(t,n)}),rs.create(rC(t.parentCreatedAt),rR(t.from),rR(t.to),i,r,rC(t.executedAt)))}else throw new ti(x.ErrUnimplemented,"unimplemented operation")}function rJ(e){let t=[];for(let r of e)t.push(t3.create({id:rS(r.id),operations:function(e){let t=[];for(let r of e){let e=rO(r);e&&t.push(e)}return t}(r.operations),presenceChange:r.presenceChange?function(e){let t=e.type;if(t===C.PUT){let t=rx(e.presence);return{type:P.Put,presence:t}}if(t===C.CLEAR)return{type:P.Clear};throw new ti(x.ErrInvalidType,"unsupported type: ".concat(t))}(r.presenceChange):void 0,message:r.message}));return t}function rL(e){let t=new ty;for(let r of e.nodes){let e=rq(r.element);t.set(r.key,e,e.getPositionedAt())}let r=new tv(rC(e.createdAt),t);return r.setMovedAt(rC(e.movedAt)),r.setRemovedAt(rC(e.removedAt)),r}function r_(e){let t=new tx;for(let r of e.nodes)t.insert(rq(r.element));let r=new tP(rC(e.createdAt),t);return r.setMovedAt(rC(e.movedAt)),r.setRemovedAt(rC(e.removedAt)),r}function rM(e){let t=rB(e.nodes);return tX.create(t,rC(e.createdAt))}function rq(e){if("jsonObject"===e.body.case)return rL(e.body.value);if("jsonArray"===e.body.case)return r_(e.body.value);if("primitive"===e.body.case)return function(e){let t=tI.of(tI.valueFromBytes(rP(e.type),e.value),rC(e.createdAt));return t.setMovedAt(rC(e.movedAt)),t.setRemovedAt(rC(e.removedAt)),t}(e.body.value);if("text"===e.body.case)return function(e){let t=new rt,r=t.getHead();for(let n of e.nodes){let e=t.insertAfter(r,function(e){let t=tB.create(e.value);Object.entries(e.attributes).forEach(e=>{let[r,n]=e;t.setAttr(r,n.value,rC(n.updatedAt))});let r=re.create(rD(e.id),t);return r.remove(rC(e.removedAt)),r}(n));n.insPrevId&&e.setInsPrev(t.findNode(rD(n.insPrevId))),r=e}let n=new tO(t,rC(e.createdAt));return n.setMovedAt(rC(e.movedAt)),n.setRemovedAt(rC(e.removedAt)),n}(e.body.value);if("counter"===e.body.case)return function(e){let t=rn.create(rE(e.type),rn.valueFromBytes(rE(e.type),e.value),rC(e.createdAt));return t.setMovedAt(rC(e.movedAt)),t.setRemovedAt(rC(e.removedAt)),t}(e.body.value);if("tree"===e.body.case)return rM(e.body.value);throw new ti(x.ErrUnimplemented,"unimplemented element")}function rz(e){if(!e)throw new ti(x.ErrInvalidArgument,"bytes is empty");return rL(eA.fromBinary(e).body.value)}function rK(e){return rw(e).toBinary()}function rF(e){return e?Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function rV(e){return new Uint8Array(e.match(/.{1,2}/g).map(e=>parseInt(e,16)))}let rU={fromPresence:rx,toChangePack:function(e){var t;return new en({documentKey:e.getDocumentKey(),checkpoint:new eV({serverSeq:(t=e.getCheckpoint()).getServerSeq(),clientSeq:t.getClientSeq()}),isRemoved:e.getIsRemoved(),changes:function(e){let t=[];for(let r of e)t.push(function(e){let t=new ei({id:ro(e.getID()),message:e.getMessage()});return e.hasOperations()&&(t.operations=function(e){let t=[];for(let r of e)t.push(rm(r));return t}(e.getOperations())),e.hasPresenceChange()&&(t.presenceChange=function(e){if(e.type===P.Put)return new eK({type:C.PUT,presence:function(e){let t=new eF,r=t.data;for(let[t,n]of Object.entries(e))r[t]=JSON.stringify(n);return t}(e.presence)});if(e.type===P.Clear)return new eK({type:C.CLEAR});throw new ti(x.ErrUnimplemented,"unimplemented type")}(e.getPresenceChange())),t}(r));return t}(e.getChanges()),snapshot:e.getSnapshot(),versionVector:rc(e.getVersionVector()),minSyncedTicket:ra(e.getMinSyncedTicket())})},fromChangePack:function(e){var t;return t9.create(e.documentKey,(t=e.checkpoint,t4.of(BigInt(t.serverSeq),t.clientSeq)),e.isRemoved,rJ(e.changes),rI(e.versionVector),e.snapshot,rC(e.minSyncedTicket))},fromChanges:rJ,toTreeNodes:rp,fromTreeNodes:rB,objectToBytes:rK,bytesToObject:rz,bytesToSnapshot:function(e){if(!e)return{root:tv.create(tu),presences:new Map};let t=er.fromBinary(e);return{root:rq(t.root),presences:function(e){let t=new Map;return Object.entries(e).forEach(e=>{let[r,n]=e;t.set(r,rx(n))}),t}(t.presences)}},bytesToHex:rF,hexToBytes:rV,toHexString:function(e){return rF(e)},toUint8Array:function(e){return rV(e)},toOperation:rm,toChangeID:ro,PbChangeID:es,bytesToChangeID:function(e){return rS(es.fromBinary(e))},bytesToOperation:function(e){return rO(ea.fromBinary(e))},versionVectorToHex:function(e){return rF(rc(e).toBinary())},hexToVersionVector:function(e){let t=rV(e);return rI(eo.fromBinary(t))}};(f=B||(B={}))[f.Trivial=0]="Trivial",f[f.Debug=1]="Debug",f[f.Info=2]="Info",f[f.Warn=3]="Warn",f[f.Error=4]="Error",f[f.Fatal=5]="Fatal";let rj=3;function rW(e){rj=e}let rG={trivial:function(){for(var e=arguments.length,t=Array(e),r=0;r0||"undefined"==typeof console||console.log("YORKIE T:",...t)},debug:function(){for(var e=arguments.length,t=Array(e),r=0;r1||"undefined"==typeof console||console.log("YORKIE D:",...t)},info:function(){for(var e=arguments.length,t=Array(e),r=0;r2||"undefined"==typeof console||console.log("YORKIE I:",...t)},warn:function(){for(var e=arguments.length,t=Array(e),r=0;r3||"undefined"==typeof console||(void 0!==console.warn?console.warn("YORKIE W:",...t):console.log("YORKIE W:",...t))},error:function(){for(var e=arguments.length,t=Array(e),r=0;r4||"undefined"==typeof console||(void 0!==console.error?console.error("YORKIE E:",...t):console.log("YORKIE E:",...t))},fatal:function(){for(var e=arguments.length,t=Array(e),r=0;rrj<=e};function rH(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}class rY{changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode!==M.RealtimeSyncOff&&(this.syncMode===M.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==M.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived))}async runWatchLoop(e){let t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch(e){}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}constructor(e,t,r,n,i){this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=n,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}}let rZ=()=>{};class rX{next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(!e)throw new ti(x.ErrInvalidArgument,"missing observer");if(this.finalized)throw new ti(x.ErrRefused,"observable is finalized due to previous error");void 0===(n="object"==typeof e?e:{next:e,error:t,complete:r}).next&&(n.next=rZ),void 0===n.error&&(n.error=rZ),void 0===n.complete&&(n.complete=rZ);let i=rH(),s=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:n}),this.finalized)try{this.finalError?n.error(this.finalError):n.complete()}catch(e){rG.warn(e)}return s}unsubscribeOne(e){var t;this.observers=null===(t=this.observers)||void 0===t?void 0:t.filter(t=>t.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;t0||void 0!==this.presenceChange}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(let r of Object.keys(e))(null==t?void 0:t.addToHistory)?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(0===this.reversePresenceKeys.size)return;let e={};for(let t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}constructor(e,t,r,n){this.id=e,this.delimiter=0,this.root=t,this.operations=[],this.previousPresence=ts(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=n}}class r${static create(){return new r$(tv.create(tu))}findByCreatedAt(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];let r=[];for(;t.parent;){let e=t.element.getCreatedAt(),n=t.parent.subPathOf(e);if(void 0===n)throw new ti(x.ErrInvalidArgument,"cant find the given element: ".concat(e.toIDString()));r.unshift(n),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof tm&&e.getDescendants((e,t)=>(this.registerElement(e,t),!1))}deregisterElement(e){let t=0,r=e=>{let r=e.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(r),this.gcElementSetByCreatedAt.delete(r),t++};return r(e),e instanceof tm&&e.getDescendants(e=>(r(e),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){let e=new Set;for(let t of this.gcElementSetByCreatedAt){e.add(t);let r=this.elementPairMapByCreatedAt.get(t);r.element instanceof tm&&r.element.getDescendants(t=>(e.add(t.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new r$(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(let r of this.gcElementSetByCreatedAt){let n=this.elementPairMapByCreatedAt.get(r),i=n.element.getRemovedAt();i&&(null==e?void 0:e.afterOrEqual(i))&&(n.parent.purge(n.element),t+=this.deregisterElement(n.element))}for(let[,r]of this.gcPairMap){let n=r.child.getRemovedAt();n&&(null==e?void 0:e.afterOrEqual(n))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}constructor(e){this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof tO||e instanceof tX)for(let t of e.getGCPairs())this.registerGCPair(t);return!1})}}function r0(e,t){let r=new r1(e);return new Proxy(t,r.getHandlers())}class r1{static setInternal(e,t,r,n){if(r.includes("."))throw new ti(x.ErrInvalidObjectKey,"key must not contain the '.'.");let i=e.issueTimeTicket(),s=nt(e,n,i),o=t.set(r,s,i);e.registerElement(s,t),o&&e.registerRemovedElement(o),e.push(tb.create(r,s.deepcopy(),t.getCreatedAt(),i))}static buildObjectMembers(e,t){let r={};for(let[n,i]of Object.entries(t)){if(n.includes("."))throw new ti(x.ErrInvalidObjectKey,"key must not contain the '.'.");let t=e.issueTimeTicket(),s=nt(e,i,t);r[n]=s}return r}static deleteInternal(e,t,r){let n=e.issueTimeTicket(),i=t.deleteByKey(r,n);i&&(e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i))}getHandlers(){return this.handlers}constructor(e){this.context=e,this.handlers={set:(t,r,n)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]=").concat(JSON.stringify(n))),r1.setInternal(e,t,r,n),!0),get:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]")),"getID"===r)?()=>t.getCreatedAt():"toJSON"===r||"toString"===r?()=>t.toJSON():"toJS"===r?()=>t.toJS():"toJSForTest"===r?()=>t.toJSForTest():ne(e,t.get(r)),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("obj[".concat(r,"]")),r1.deleteInternal(e,t,r),!0)}}}class r2{static*iteratorInternal(e,t){for(let r of t)yield r7(e,r)}static buildArrayElements(e,t){let r=[];for(let n of t){let t=e.issueTimeTicket(),i=nt(e,n,t);r.push(i)}return r}static pushInternal(e,t,r){return r2.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,n){let i=e.issueTimeTicket(),s=t.getPrevCreatedAt(r);t.moveAfter(s,n,i),e.push(tD.create(t.getCreatedAt(),s,n,i))}static moveAfterInternal(e,t,r,n){let i=e.issueTimeTicket();t.moveAfter(r,n,i),e.push(tD.create(t.getCreatedAt(),r,n,i))}static moveFrontInternal(e,t,r){let n=e.issueTimeTicket(),i=t.getHead();t.moveAfter(i.getCreatedAt(),r,n),e.push(tD.create(t.getCreatedAt(),i.getCreatedAt(),r,n))}static moveLastInternal(e,t,r){let n=e.issueTimeTicket(),i=t.getLastCreatedAt();t.moveAfter(i,r,n),e.push(tD.create(t.getCreatedAt(),i,r,n))}static insertAfterInternal(e,t,r,n){let i=e.issueTimeTicket(),s=nt(e,n,i);return t.insertAfter(r,s),e.registerElement(s,t),e.push(tk.create(t.getCreatedAt(),r,s.deepcopy(),i)),s}static insertBeforeInternal(e,t,r,n){return r2.insertAfterInternal(e,t,t.getPrevCreatedAt(r),n)}static deleteInternalByIndex(e,t,r){let n=e.issueTimeTicket(),i=t.deleteByIndex(r,n);if(i)return e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i),i}static deleteInternalByID(e,t,r){let n=e.issueTimeTicket(),i=t.delete(r,n);return e.push(tE.create(t.getCreatedAt(),i.getCreatedAt(),n)),e.registerRemovedElement(i),i}static splice(e,t,r,n){for(var i=arguments.length,s=Array(i>4?i-4:0),o=4;o=0?Math.min(r,a):Math.max(a+r,0),l=void 0===n?a:n<0?c:Math.min(c+n,a),h=[];for(let r=c;r=i)return!1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).includes(r,s);for(let e=s;e=i)return -1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).indexOf(r,s);for(let e=s;e=i?i-1:n<0?n+i:n;if(s<0)return -1;if(tI.isSupport(r))return Array.from(t).map(t=>ne(e,t)).lastIndexOf(r,s);for(let e=s;e>0;e--){var o;if((null===(o=t.get(e))||void 0===o?void 0:o.getID())===r.getID())return e}return -1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}constructor(e,t){this.context=e,this.array=t,this.handlers={get:(t,r,n)=>"getID"===r?()=>t.getCreatedAt():"getElementByID"===r?r=>{let n=t.getByID(r);if(!(!n||n.isRemoved()))return r7(e,n)}:"getElementByIndex"===r?r=>r7(e,t.get(r)):"getLast"===r?()=>r7(e,t.getLast()):"deleteByID"===r?r=>{let n=r2.deleteInternalByID(e,t,r);return r7(e,n)}:"insertAfter"===r?(r,n)=>{let i=r2.insertAfterInternal(e,t,r,n);return r7(e,i)}:"insertBefore"===r?(r,n)=>{let i=r2.insertBeforeInternal(e,t,r,n);return r7(e,i)}:"moveBefore"===r?(r,n)=>{r2.moveBeforeInternal(e,t,r,n)}:"moveAfter"===r?(r,n)=>{r2.moveAfterInternal(e,t,r,n)}:"moveFront"===r?r=>{r2.moveFrontInternal(e,t,r)}:"moveLast"===r?r=>{r2.moveLastInternal(e,t,r)}:("string"==typeof r||r instanceof String)&&!isNaN(r)?ne(e,t.get(Number(r))):"push"===r?r=>r2.pushInternal(e,t,r):"splice"===r?function(r,n){for(var i=arguments.length,s=Array(i>2?i-2:0),o=2;or2.includes(e,t,r,n):"indexOf"===r?(r,n)=>r2.indexOf(e,t,r,n):"lastIndexOf"===r?(r,n)=>r2.lastIndexOf(e,t,r,n):"toJSForTest"===r?()=>t.toJSForTest():"toTestString"===r?()=>r2.toTestString(t):"string"==typeof r&&["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(r)?function(){for(var n=arguments.length,i=Array(n),s=0;sne(e,t));return Array.prototype[r].apply(o,i)}:Reflect.get(t,r,n),deleteProperty:(t,r)=>(rG.isEnabled(B.Trivial)&&rG.trivial("array[".concat(r,"]")),r2.deleteInternalByIndex(e,t,Number.parseInt(r)),!0)}}}class r3{initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,n){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.text.indexRangeToPosRange(e,t);rG.isEnabled(B.Debug)&&rG.debug("EDIT: f:".concat(e,"->").concat(i[0].toTestString(),", t:").concat(t,"->").concat(i[1].toTestString()," c:").concat(r));let s=n?ta(n):void 0,o=this.context.issueTimeTicket(),[a,,c,l]=this.text.edit(i,r,o,s);for(let e of c)this.context.registerGCPair(e);return this.context.push(new tJ(this.text.getCreatedAt(),i[0],i[1],a,r,s?new Map(Object.entries(s)):new Map,o)),this.text.findIndexesFromRange(l)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.text.indexRangeToPosRange(e,t);rG.isEnabled(B.Debug)&&rG.debug("STYL: f:".concat(e,"->").concat(n[0].toTestString(),", t:").concat(t,"->").concat(n[1].toTestString()," a:").concat(JSON.stringify(r)));let i=ta(r),s=this.context.issueTimeTicket(),[o,a]=this.text.setStyle(n,i,s);for(let e of a)this.context.registerGCPair(e);return this.context.push(new tL(this.text.getCreatedAt(),n[0],n[1],o,new Map(Object.entries(i)),s)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");let t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");let t=this.text.findIndexesFromRange([t7.fromStruct(e[0]),t7.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new ti(x.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}constructor(e,t){this.context=e,this.text=t}}class r9{initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new ti(x.ErrNotInitialized,"Counter is not initialized yet");let t=this.context.issueTimeTicket(),r=tI.of(e,t);if(!r.isNumericType())throw TypeError("Unsupported type of value: ".concat(typeof r.getValue()));return this.counter.increase(r),this.context.push(ri.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new ti(x.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}constructor(e,t){this.valueType=e,this.value=t}}function r4(e,t,r){let{type:n}=e,i=r.issueTimeTicket();if(n===t_){r8(e);let{value:r}=e,s=tH.create(tG.of(i,0),n,r);t.append(s)}else{let s;let{children:o=[]}=e,{attributes:a}=e;if("object"==typeof a&&!to(a)){let e=ta(a);for(let[t,r]of(s=new tN,Object.entries(e)))s.set(t,r,i)}let c=tH.create(tG.of(i,0),n,void 0,s);for(let e of(t.append(c),o))r4(e,c,r)}}function r8(e){if(!e.value.length)throw new ti(x.ErrInvalidArgument,"text node cannot have empty value");return!0}function r5(e){if(!e.length)return!0;if(e[0].type===t_)for(let t of e){let{type:e}=t;if(e!==t_)throw new ti(x.ErrInvalidArgument,"element node and text node cannot be passed together");r8(t)}else for(let t of e){let{type:e}=t;if(e===t_)throw new ti(x.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class r6{initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return tH.create(tG.of(e.issueTimeTicket(),0),"root");let t=tH.create(tG.of(e.issueTimeTicket(),0),this.initialRoot.type);for(let r of this.initialRoot.children)r4(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let[r,n]=this.tree.pathToPosRange(e),i=this.context.issueTimeTicket(),s=t?ta(t):void 0,[o]=this.tree.style([r,n],s,i);this.context.push(rs.create(this.tree.getCreatedAt(),r,n,o,s?new Map(Object.entries(s)):new Map,i))}style(e,t,r){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.tree.findPos(e),i=this.tree.findPos(t),s=this.context.issueTimeTicket(),o=r?ta(r):void 0,[a,c]=this.tree.style([n,i],o,s);for(let e of c)this.context.registerGCPair(e);this.context.push(rs.create(this.tree.getCreatedAt(),n,i,a,o?new Map(Object.entries(o)):new Map,s))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let n=this.tree.findPos(e),i=this.tree.findPos(t),s=this.context.issueTimeTicket(),[o,a]=this.tree.removeStyle([n,i],r,s);for(let e of a)this.context.registerGCPair(e);this.context.push(rs.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),n,i,o,r,s))}editInternal(e,t,r){var n;let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(0!==r.length&&r[0]&&(r5(r),r[0].type!==t_))for(let e of r){let{children:t=[]}=e;r5(t)}let s=this.context.getLastTimeTicket(),o=[];if((null===(n=r[0])||void 0===n?void 0:n.type)===t_){let e="";for(let t of r){let{value:r}=t;e+=r}o.push(tH.create(tG.of(this.context.issueTimeTicket(),0),t_,e))}else o=r.map(e=>e&&function(e,t){let r;let{type:n}=t,i=e.issueTimeTicket();if(t.type===t_){let{value:e}=t;r=tH.create(tG.of(i,0),n,e)}else if(t){let s;let{children:o=[]}=t,{attributes:a}=t;if("object"==typeof a&&!to(a)){let e=ta(a);for(let[t,r]of(s=new tN,Object.entries(e)))s.set(t,r,i)}for(let t of(r=tH.create(tG.of(e.issueTimeTicket(),0),n,void 0,s),o))r4(t,r,e)}return r}(this.context,e)).filter(e=>e);let[,a,c]=this.tree.edit([e,t],o.length?o.map(e=>null==e?void 0:e.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(let e of a)this.context.registerGCPair(e);return this.context.push(tQ.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,c,s)),!0}editByPath(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new ti(x.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let i=this.tree.pathToPos(e),s=this.tree.pathToPos(t);return this.editInternal(i,s,r?[r]:[],n)}editBulkByPath(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new ti(x.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new ti(x.ErrInvalidArgument,"path should not be empty");let i=this.tree.pathToPos(e),s=this.tree.pathToPos(t);return this.editInternal(i,s,r,n)}edit(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.tree.findPos(e),s=this.tree.findPos(t);return this.editInternal(i,s,r?[r]:[],n)}editBulk(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new ti(x.ErrInvalidArgument,"from should be less than or equal to to");let i=this.tree.findPos(e),s=this.tree.findPos(t);return this.editInternal(i,s,r,n)}toXML(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[tW.fromStruct(e[0]),tW.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new ti(x.ErrNotInitialized,"Tree is not initialized yet");let t=[tW.fromStruct(e[0]),tW.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}constructor(e){this.initialRoot=e}}function r7(e,t){if(t){if(t instanceof tI)return t;if(t instanceof tv)return r0(e,t);if(t instanceof tP)return function(e,t){let r=new r2(e,t);return new Proxy(t,r.getHandlers())}(e,t);if(t instanceof tO)return new r3(e,t);else if(t instanceof rn){let r=new r9(N.IntegerCnt,0);return r.initialize(e,t),r}else if(t instanceof tX){let r=new r6;return r.initialize(e,t),r}throw TypeError("Unsupported type of element: ".concat(typeof t))}}function ne(e,t){let r=r7(e,t);return r instanceof tI?r.getValue():r}function nt(e,t,r){let n;if(tI.isSupport(t))n=tI.of(t,r);else if(Array.isArray(t))n=tP.create(r,r2.buildArrayElements(e,t));else if("object"==typeof t)t instanceof r3?(n=tO.create(rt.create(),r),t.initialize(e,n)):t instanceof r9?(n=rn.create(t.getValueType(),t.getValue(),r),t.initialize(e,n)):t instanceof r6?(n=tX.create(t.buildRoot(e),r),t.initialize(e,n)):n=tv.create(r,r1.buildObjectMembers(e,t));else throw TypeError("Unsupported type of value: ".concat(typeof t));return n}class nr{hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=50&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=50&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}constructor(){this.undoStack=[],this.redoStack=[]}}let nn="disconnected",ni=new Map,ns=new Map;function no(e,t){((null==t?void 0:t.force)||"disconnected"!==nn)&&window.postMessage({source:"yorkie-devtools-sdk",...e},"*")}window.transactionEventsByDocKey=ns,(m=O||(O={})).Detached="detached",m.Attached="attached",m.Removed="removed",(p=J||(J={})).StatusChanged="status-changed",p.ConnectionChanged="connection-changed",p.SyncStatusChanged="sync-status-changed",p.Snapshot="snapshot",p.LocalChange="local-change",p.RemoteChange="remote-change",p.Initialized="initialized",p.Watched="watched",p.Unwatched="unwatched",p.PresenceChanged="presence-changed",p.Broadcast="broadcast",p.LocalBroadcast="local-broadcast",p.AuthError="auth-error",(y=L||(L={})).Connected="connected",y.Disconnected="disconnected",(v=_||(_={})).Synced="synced",v.SyncFailed="sync-failed";class na{update(e,t){if("removed"===this.getStatus())throw new ti(x.ErrDocumentRemoved,"".concat(this.key," is removed"));this.ensureClone();let r=this.changeID.getActorID(),n=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{var i;let t=(i=this.clone.root.getObject(),r0(n,i));this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(t,new tl(n,this.clone.presences.get(r)))}catch(e){throw this.clone=void 0,e}finally{this.isUpdating=!1}if(n.hasChange()){rG.isEnabled(B.Trivial)&&rG.trivial("trying to update a local change: ".concat(this.toJSON()));let e=n.getChange(),{opInfos:t,reverseOps:i}=e.execute(this.root,this.presences,E.Local),s=n.getReversePresence();s&&i.push({type:"presence",value:s}),this.localChanges.push(e),i.length>0&&this.internalHistory.pushUndo(i),t.length>0&&this.internalHistory.clearRedo(),this.changeID=e.getID();let o=[];t.length>0&&o.push({type:"local-change",source:E.Local,value:{message:e.getMessage()||"",operations:t,actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq()},rawChange:this.isEnableDevtools()?e.toStruct():void 0}),e.hasPresenceChange()&&o.push({type:"presence-changed",source:E.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(o),rG.isEnabled(B.Trivial)&&rG.trivial("after update a local change: ".concat(this.toJSON()))}}subscribe(e,t,r,n){if("string"==typeof e){if("function"!=typeof t)throw new ti(x.ErrInvalidArgument,"Second argument must be a callback function");return"presence"===e?this.eventStream.subscribe(e=>{for(let r of e)("initialized"===r.type||"watched"===r.type||"unwatched"===r.type||"presence-changed"===r.type)&&t(r)},r,n):"my-presence"===e?this.eventStream.subscribe(e=>{for(let r of e)("initialized"===r.type||"presence-changed"===r.type)&&("presence-changed"!==r.type||r.value.clientID===this.changeID.getActorID())&&t(r)},r,n):"others"===e?this.eventStream.subscribe(e=>{for(let r of e)("watched"===r.type||"unwatched"===r.type||"presence-changed"===r.type)&&r.value.clientID!==this.changeID.getActorID()&&t(r)},r,n):"connection"===e?this.eventStream.subscribe(e=>{for(let r of e)"connection-changed"===r.type&&t(r)},r,n):"status"===e?this.eventStream.subscribe(e=>{for(let r of e)"status-changed"===r.type&&t(r)},r,n):"sync"===e?this.eventStream.subscribe(e=>{for(let r of e)"sync-status-changed"===r.type&&t(r)},r,n):"local-broadcast"===e?this.eventStream.subscribe(e=>{for(let r of e)"local-broadcast"===r.type&&t(r)},r):"broadcast"===e?this.eventStream.subscribe(e=>{for(let r of e)"broadcast"===r.type&&t(r)},r):"auth-error"===e?this.eventStream.subscribe(e=>{for(let r of e)"auth-error"===r.type&&t(r)},r):"all"===e?this.eventStream.subscribe(t,r,n):this.eventStream.subscribe(r=>{for(let n of r){if("local-change"!==n.type&&"remote-change"!==n.type)continue;let r=[];for(let t of n.value.operations)this.isSameElementOrChildOf(t.path,e)&&r.push(t);r.length&&t({...n,value:{...n.value,operations:r}})}},r,n)}if("function"==typeof e)return this.eventStream.subscribe(t=>{for(let r of t)("snapshot"===r.type||"local-change"===r.type||"remote-change"===r.type)&&e(r)},t,r);throw new ti(x.ErrInvalidArgument,'"'.concat(e,'" is not a valid'))}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;let r=e.split(".");return t.split(".").every((e,t)=>e===r[t])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){let t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),E.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),rG.isEnabled(B.Trivial)&&rG.trivial("".concat(this.root.toJSON()))}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:ts(this.presences)})}createChangePack(){let e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return t9.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(let t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){return this.ensureClone(),r0(rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{}),this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,{root:i,presences:s}=rU.bytesToSnapshot(r);this.root=new r$(i),this.presences=s,this.changeID=this.changeID.setClocks(t.maxLamport(),t),this.clone=void 0,this.removePushedLocalChanges(n),this.applyChanges(this.localChanges,E.Local),this.publish([{type:"snapshot",source:E.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?rU.bytesToHex(r):void 0,snapshotVector:rU.versionVectorToHex(t)}}])}applyChanges(e,t){for(let r of(rG.isEnabled(B.Debug)&&rG.debug("trying to apply ".concat(e.length," remote changes.")+"elements:".concat(this.root.getElementMapSize(),", ")+"removeds:".concat(this.root.getGarbageElementSetSize())),rG.isEnabled(B.Trivial)&&rG.trivial(e.map(e=>"".concat(e.getID().toTestString()," ").concat(e.toTestString())).join("\n")),e))this.applyChange(r,t);rG.isEnabled(B.Debug)&&rG.debug("after appling ".concat(e.length," remote changes.")+"elements:".concat(this.root.getElementMapSize(),", ")+" removeds:".concat(this.root.getGarbageElementSetSize()))}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);let r=[],n=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(n)){let i=e.getPresenceChange();switch(i.type){case P.Put:r.push(this.presences.has(n)?{type:"presence-changed",source:t,value:{clientID:n,presence:i.presence}}:{type:"watched",source:E.Remote,value:{clientID:n,presence:i.presence}});break;case P.Clear:r.push({type:"unwatched",source:E.Remote,value:{clientID:n,presence:this.getPresence(n)}}),this.removeOnlineClient(n)}}let{opInfos:i}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),i.length>0){let s=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===E.Remote?{type:"remote-change",source:t,value:{actor:n,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:s}:{type:"local-change",source:t,value:{actor:n,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:s})}r.length>0&&this.publish(r)}applyWatchStream(e){if("initialization"===e.body.case){let t=e.body.value.clientIds,r=new Set;for(let e of t)e!==this.changeID.getActorID()&&r.add(e);this.setOnlineClients(r),this.publish([{type:"initialized",source:E.Local,value:this.getPresences()}]);return}if("event"===e.body.case){let{type:t,publisher:r}=e.body.value,n=[];if(t===I.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&n.push({type:"watched",source:E.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===I.DOCUMENT_UNWATCHED){let e=this.getPresence(r);this.removeOnlineClient(r),e&&n.push({type:"unwatched",source:E.Remote,value:{clientID:r,presence:e}})}else if(t===I.DOCUMENT_BROADCAST&&e.body.value.body){let{topic:t,payload:i}=e.body.value.body,s=new TextDecoder;n.push({type:"broadcast",value:{clientID:r,topic:t,payload:JSON.parse(s.decode(i))}})}n.length>0&&this.publish(n)}}applyStatus(e){this.status=e,"detached"===e&&this.setActor(th),this.publish([{source:"removed"===e?E.Remote:E.Local,type:"status-changed",value:"attached"===e?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if("status-changed"===e.type){this.applyStatus(e.value.status),"attached"===e.value.status&&this.setActor(e.value.actorID);return}if("snapshot"===e.type){let{snapshot:t,serverSeq:r,snapshotVector:n}=e.value;if(!t)return;this.applySnapshot(BigInt(r),rU.hexToVersionVector(n),rU.hexToBytes(t));return}if("local-change"===e.type||"remote-change"===e.type){if(!e.rawChange)return;let t=t3.fromStruct(e.rawChange);this.applyChange(t,e.source)}if("initialized"===e.type){let t=new Set;for(let{clientID:r,presence:n}of e.value)t.add(r),this.presences.set(r,n);this.setOnlineClients(t);return}if("watched"===e.type){let{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if("unwatched"===e.type){let{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if("presence-changed"===e.type){let{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(let t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new ti(x.ErrInvalidArgument,'path must start with "$"');let t=e.split(".");t.shift();let r=this.getRoot();for(let e of t)if(void 0===(r=r[e]))return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if("attached"!==this.status)return{};let e=this.presences.get(this.changeID.getActorID());return e?ts(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;let t=this.presences.get(e);return t?ts(t):void 0}getPresenceForTest(e){let t=this.presences.get(e);return t?ts(t):void 0}getPresences(){let e=[];for(let t of(e.push({clientID:this.changeID.getActorID(),presence:ts(this.getMyPresence())}),this.onlineClients))this.presences.has(t)&&e.push({clientID:t,presence:ts(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){let e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((e,t)=>e.clientID>t.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){let t=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(t)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new ti(x.ErrRefused,"Undo is not allowed during an update");let e=this.internalHistory.popUndo();if(void 0===e)throw new ti(x.ErrRefused,"There is no operation to be undone");this.ensureClone();let t=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(let r of e){if(!(r instanceof tw)){new tl(t,ts(this.clone.presences.get(this.changeID.getActorID()))).set(r.value,{addToHistory:!0});continue}let e=t.issueTimeTicket();r.setExecutedAt(e),t.push(r)}let r=t.getChange();r.execute(this.clone.root,this.clone.presences,E.UndoRedo);let{opInfos:n,reverseOps:i}=r.execute(this.root,this.presences,E.UndoRedo),s=t.getReversePresence();if(s&&i.push({type:"presence",value:s}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&0===n.length)return;this.localChanges.push(r),this.changeID=r.getID();let o=this.changeID.getActorID(),a=[];n.length>0&&a.push({type:"local-change",source:E.UndoRedo,value:{message:r.getMessage()||"",operations:n,actor:o,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&a.push({type:"presence-changed",source:E.UndoRedo,value:{clientID:o,presence:this.getPresence(o)}}),this.publish(a)}redo(){if(this.isUpdating)throw new ti(x.ErrRefused,"Redo is not allowed during an update");let e=this.internalHistory.popRedo();if(void 0===e)throw new ti(x.ErrRefused,"There is no operation to be redone");this.ensureClone();let t=rQ.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(let r of e){if(!(r instanceof tw)){new tl(t,ts(this.clone.presences.get(this.changeID.getActorID()))).set(r.value,{addToHistory:!0});continue}let e=t.issueTimeTicket();r.setExecutedAt(e),t.push(r)}let r=t.getChange();r.execute(this.clone.root,this.clone.presences,E.UndoRedo);let{opInfos:n,reverseOps:i}=r.execute(this.root,this.presences,E.UndoRedo),s=t.getReversePresence();if(s&&i.push({type:"presence",value:s}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&0===n.length)return;this.localChanges.push(r),this.changeID=r.getID();let o=this.changeID.getActorID(),a=[];n.length>0&&a.push({type:"local-change",source:E.UndoRedo,value:{message:r.getMessage()||"",operations:n,actor:o,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&a.push({type:"presence-changed",source:E.UndoRedo,value:{clientID:o,presence:this.getPresence(o)}}),this.publish(a)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){this.publish([{type:"local-broadcast",value:{topic:e,payload:t},options:r}])}getVersionVector(){return this.changeID.getVersionVector()}constructor(e,t){this.opts=t||{},this.key=e,this.status="detached",this.root=r$.create(),this.changeID=t2,this.checkpoint=t8,this.localChanges=[],this.eventStream=function(e){let t=new rX(e);return{subscribe:t.subscribe.bind(t),getProxy:()=>t}}(e=>{this.eventStreamObserver=e}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new nr,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},function(e){if(!e.isEnableDevtools()||ni.has(e.getKey()))return;ns.set(e.getKey(),[]);let t=e.subscribe("all",t=>{t.some(e=>e.type!==J.StatusChanged&&e.type!==J.Snapshot&&e.type!==J.LocalChange&&e.type!==J.RemoteChange&&e.type!==J.Initialized&&e.type!==J.Watched&&e.type!==J.Unwatched&&e.type!==J.PresenceChanged)||(ns.get(e.getKey()).push(t),"synced"===nn&&no({msg:"doc::sync::partial",docKey:e.getKey(),event:t}))});ni.set(e.getKey(),[t]),no({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var r;if((null===(r=t.data)||void 0===r?void 0:r.source)==="yorkie-devtools-panel")switch(t.data.msg){case"devtools::connect":if("disconnected"!==nn)break;nn="connected",no({msg:"doc::available",docKey:e.getKey()}),rG.info("[YD] Devtools connected. Doc: ".concat(e.getKey()));break;case"devtools::disconnect":nn="disconnected",rG.info("[YD] Devtools disconnected. Doc: ".concat(e.getKey()));break;case"devtools::subscribe":nn="synced",no({msg:"doc::sync::full",docKey:e.getKey(),events:ns.get(e.getKey())}),rG.info("[YD] Devtools subscribed. Doc: ".concat(e.getKey()))}})}(this)}}var nc=JSON.parse('{"u2":"yorkie-js-sdk","i8":"0.5.6"}');let nl=e=>{try{let t=JSON.stringify(e);if(void 0===t)return!1}catch(e){return!1}return!0};(w=M||(M={})).Manual="manual",w.Realtime="realtime",w.RealtimePushOnly="realtime-pushonly",w.RealtimeSyncOff="realtime-syncoff",(A=q||(q={})).Deactivated="deactivated",A.Activated="activated",(T=z||(z={})).SyncLoop="SyncLoop",T.WatchLoop="WatchLoop";let nh={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},nd={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class nu{async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){let e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),rG.info('[AC] c:"'.concat(this.getKey(),'" activated, id:"').concat(this.id,'"'))}).catch(async e=>{throw rG.error('[AC] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}deactivate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{keepalive:!1};if("deactivated"===this.status)return Promise.resolve();let t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),rG.info('[DC] c"'.concat(this.getKey(),'" deactivated'))}catch(e){throw rG.error('[DC] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}};if(e.keepalive){this.keepalive=!0;let e=t();return this.keepalive=!1,e}return this.enqueueTask(t)}attach(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));if(e.getStatus()!==O.Detached)throw new ti(x.ErrDocumentNotDetached,"".concat(e.getKey()," is not detached"));e.setActor(this.id),e.update((e,t)=>t.set(r.initialPresence||{}));let n=e.subscribe("local-broadcast",async t=>{var r;let{topic:n,payload:i}=t.value,s=null===(r=t.options)||void 0===r?void 0:r.error,o=t.options;try{await this.broadcast(e.getKey(),n,i,o)}catch(e){e instanceof Error&&(null==s||s(e))}}),i=null!==(t=r.syncMode)&&void 0!==t?t:"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:rU.toChangePack(e.createChangePack())},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(async t=>{let s=rU.fromChangePack(t.changePack);if(e.applyChangePack(s),e.getStatus()===O.Removed)return e;e.applyStatus(O.Attached),this.attachmentMap.set(e.getKey(),new rY(this.reconnectStreamDelay,e,t.documentId,i,n)),"manual"!==i&&await this.runWatchLoop(e.getKey()),rG.info('[AD] c:"'.concat(this.getKey(),'" attaches d:"').concat(e.getKey(),'"'));let o=e.getRootObject();if(r.initialRoot){let t=r.initialRoot;e.update(e=>{for(let[r,n]of Object.entries(t))o.has(r)||(e[r]=n)})}return e}).catch(async e=>{throw rG.error('[AD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}detach(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let r=this.attachmentMap.get(e.getKey());if(!r)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));return e.update((e,t)=>t.clear()),this.enqueueTask(async()=>{var n;return this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:rU.toChangePack(e.createChangePack()),removeIfNotAttached:null!==(n=t.removeIfNotAttached)&&void 0!==n&&n},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(t=>{let r=rU.fromChangePack(t.changePack);return e.applyChangePack(r),e.getStatus()!==O.Removed&&e.applyStatus(O.Detached),this.detachInternal(e.getKey()),rG.info('[DD] c:"'.concat(this.getKey(),'" detaches d:"').concat(e.getKey(),'"')),e}).catch(async e=>{throw rG.error('[DD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e})})}async changeSyncMode(e,t){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let r=this.attachmentMap.get(e.getKey());if(!r)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));let n=r.syncMode;return n===t||((r.changeSyncMode(t),"manual"===t)?r.cancelWatchStream():("realtime"===t&&(r.remoteChangeEventReceived=!0),"manual"===n&&await this.runWatchLoop(e.getKey()))),e}sync(e){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));if(e){let t=this.attachmentMap.get(e.getKey());if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async e=>{throw rG.error('[SY] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}return this.enqueueTask(async()=>{let e=[];for(let[,t]of this.attachmentMap)e.push(this.syncInternal(t,t.syncMode));return Promise.all(e).catch(async e=>{throw rG.error('[SY] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e})})}remove(e){if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let t=this.attachmentMap.get(e.getKey());if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e.getKey()," is not attached"));e.setActor(this.id);let r=rU.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e.getKey())}}).then(t=>{let r=rU.fromChangePack(t.changePack);e.applyChangePack(r),this.detachInternal(e.getKey()),rG.info('[RD] c:"'.concat(this.getKey(),'" removes d:"').concat(e.getKey(),'"'))}).catch(async e=>{throw rG.error('[RD] c:"'.concat(this.getKey(),'" err :'),e),await this.handleConnectError(e),e}))}getID(){return this.id}getKey(){return this.key}isActive(){return"activated"===this.status}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,n){var i;if(!this.isActive())throw new ti(x.ErrClientNotActivated,"".concat(this.key," is not active"));let s=this.attachmentMap.get(e);if(!s)throw new ti(x.ErrDocumentNotAttached,"".concat(e," is not attached"));if(!nl(r))throw new ti(x.ErrInvalidArgument,"payload is not serializable");let o=null!==(i=null==n?void 0:n.maxRetries)&&void 0!==i?i:nd.maxRetries,a=nd.maxBackoff,c=0,l=e=>Math.min(nd.initialRetryInterval*2**e,a),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e)}}).then(()=>{rG.info('[BC] c:"'.concat(this.getKey(),'" broadcasts d:"').concat(e,'" t:"').concat(t,'"'))}).catch(async e=>{if(rG.error('[BC] c:"'.concat(this.getKey(),'" err:'),e),await this.handleConnectError(e)){if(e instanceof G.K&&rT(e)===x.ErrUnauthenticated&&s.doc.publish([{type:J.AuthError,value:{reason:rA(e).reason,method:"Broadcast"}}]),ch(),l(++c-1)),rG.info('[BC] c:"'.concat(this.getKey(),'" retry attempt ').concat(c,"/").concat(o));else throw rG.error('[BC] c:"'.concat(this.getKey(),'" exceeded maximum retry attempts')),e}else throw e}));return h()}runSyncLoop(){let e=()=>{if(!this.isActive()){rG.debug('[SL] c:"'.concat(this.getKey(),'" exit sync loop')),this.conditions.SyncLoop=!1;return}let t=[];for(let[,e]of this.attachmentMap)e.needRealtimeSync()&&(e.remoteChangeEventReceived=!1,t.push(this.syncInternal(e,e.syncMode).catch(async t=>{throw t instanceof G.K&&rT(t)===x.ErrUnauthenticated&&e.doc.publish([{type:J.AuthError,value:{reason:rA(t).reason,method:"PushPull"}}]),t})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async t=>{rG.error('[SL] c:"'.concat(this.getKey(),'" sync failed:'),t),await this.handleConnectError(t)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};rG.debug('[SL] c:"'.concat(this.getKey(),'" run sync loop')),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){let t=this.attachmentMap.get(e);if(!t)throw new ti(x.ErrDocumentNotAttached,"".concat(e," is not attached"));return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new ti(x.ErrClientNotActivated,"".concat(this.key," is not active")));let n=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(e)},signal:n.signal});return t.doc.publish([{type:J.ConnectionChanged,value:L.Connected}]),rG.info('[WD] c:"'.concat(this.getKey(),'" watches d:"').concat(e,'"')),new Promise((e,s)=>{(async()=>{try{for await(let r of i)this.handleWatchDocumentsResponse(t,r),"initialization"===r.body.case&&e([i,n])}catch(e){t.doc.resetOnlineClients(),t.doc.publish([{type:J.Initialized,source:E.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:J.ConnectionChanged,value:L.Disconnected}]),rG.debug('[WD] c:"'.concat(this.getKey(),'" unwatches')),await this.handleConnectError(e)?(e instanceof G.K&&rT(e)===x.ErrUnauthenticated&&t.doc.publish([{type:J.AuthError,value:{reason:rA(e).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,s(e)}})()})})}handleWatchDocumentsResponse(e,t){if("event"===t.body.case&&t.body.value.type===I.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){for(let[e,t]of(this.status="deactivated",this.attachmentMap))this.detachInternal(e),t.doc.applyStatus(O.Detached)}detachInternal(e){let t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){let{doc:r,docID:n}=e,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:n,changePack:rU.toChangePack(i),pushOnly:"realtime-pushonly"===t},{headers:{"x-shard-key":"".concat(this.apiKey,"/").concat(r.getKey())}}).then(t=>{let n=rU.fromChangePack(t.changePack);if(n.hasChanges()&&("realtime-pushonly"===e.syncMode||"realtime-syncoff"===e.syncMode))return r;r.applyChangePack(n),e.doc.publish([{type:J.SyncStatusChanged,value:_.Synced}]),r.getStatus()===O.Removed&&this.detachInternal(r.getKey());let s=r.getKey(),o=n.getChangeSize();return rG.info('[PP] c:"'.concat(this.getKey(),'" sync d:"').concat(s,'", push:').concat(i.getChangeSize()," pull:").concat(o," cp:").concat(n.getCheckpoint().toTestString())),r}).catch(async e=>{throw r.publish([{type:J.SyncStatusChanged,value:_.SyncFailed}]),rG.error('[PP] c:"'.concat(this.getKey(),'" err :'),e),e})}async handleConnectError(e){if(!(e instanceof G.K))return!1;if(e.code===H.E.Canceled||e.code===H.E.Unknown||e.code===H.E.ResourceExhausted||e.code===H.E.Unavailable)return!0;if(rT(e)===x.ErrUnauthenticated){if(this.authTokenInjector){let t=await this.authTokenInjector(rA(e).reason);this.setAuthToken(t)}return!0}return(rT(e)===x.ErrClientNotActivated||rT(e)===x.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(0===this.taskQueue.length){this.processing=!1;return}try{this.processing=!0;let e=this.taskQueue.shift();await e()}catch(e){rG.error('[TQ] c:"'.concat(this.getKey(),'" process failed, id:"').concat(this.id,'"'))}this.processNext()}constructor(e,t){var r,n,i,s;let o;this.processing=!1,this.keepalive=!1,t=t||nh,this.key=t.key?t.key:rH(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=null!==(r=t.syncLoopDuration)&&void 0!==r?r:nh.syncLoopDuration,this.reconnectStreamDelay=null!==(n=t.reconnectStreamDelay)&&void 0!==n?n:nh.reconnectStreamDelay,this.retrySyncLoopDelay=null!==(i=t.retrySyncLoopDelay)&&void 0!==i?i:nh.retrySyncLoopDelay;let{authInterceptor:a,setToken:c}=(s=this.apiKey,o=void 0,{authInterceptor:e=>async t=>(s&&t.header.set("x-api-key",s),o&&t.header.set("authorization",o),await e(t)),setToken:e=>{o=e}});this.setAuthToken=c,this.rpcClient=(0,Y.Hb)(tr,(0,Z.u)({baseUrl:e,interceptors:[a,e=>async t=>(t.header.set("x-yorkie-user-agent",nc.u2+"/"+nc.i8),await e(t))],fetch:(e,t)=>{let r={...t,keepalive:this.keepalive};return fetch(e,r)}})),this.taskQueue=[]}}var ng={Client:nu,Document:na,Primitive:tI,Text:r3,Counter:r9,Tree:r6,LogLevel:B,setLogLevel:rW,IntType:N.IntegerCnt,LongType:N.LongCnt};"undefined"!=typeof globalThis&&(globalThis.yorkie={Client:nu,Document:na,Primitive:tI,Text:r3,Counter:r9,Tree:r6,LogLevel:B,setLogLevel:rW,IntType:N.IntegerCnt,LongType:N.LongCnt}),r(109);var nf=r(6182);function nm(e){let{content:t,actions:r}=e,[n,i]=(0,U.useState)(new Date),[s,o]=(0,U.useState)("Enter text here!"),a=n?W(new Date(n.toString())):"",c=e=>{let n=!1;switch(e){case"PUSH":n=!1,t.forEach(e=>{if(e.date===a)return n=!n,0}),n?r.updateContent(a,s):r.addContent(a,s),o("Enter text here!");break;case"DELETE":r.deleteContent(a)}};return(0,K.jsx)("article",{children:(0,K.jsxs)("div",{children:[(0,K.jsx)(nf.ZP,{onChange:i,value:n,locale:"en-EN",showNeighboringMonth:!1,formatDay:(e,t)=>t.toLocaleString("en",{day:"numeric"}),tileClassName:e=>{let{date:r}=e;return t.find(e=>e.date===W(r))?"highlight":""}}),(0,K.jsxs)("p",{children:["selected day : ",a]}),(0,K.jsx)("div",{className:V().memo,children:t.map((e,t)=>{if(e.date===a)return(0,K.jsx)("p",{children:e.text},t)})}),(0,K.jsxs)("div",{className:V().inputForm_editor,children:[(0,K.jsx)("h3",{children:"input form"}),(0,K.jsx)("textarea",{className:V().textArea,value:s,onChange:e=>o(e.target.value)})]}),(0,K.jsx)("button",{className:"button",onClick:()=>c("PUSH"),children:"push"}),(0,K.jsx)("button",{className:"button",onClick:()=>c("DELETE"),children:"pop"})]})})}let np=[{date:W(new Date).replace(/^\d{2}/,"01"),text:"payday"},{date:W(new Date).replace(/^\d{2}/,"17"),text:"Garry's birthday"}],ny="next.js-Scheduler-".concat(W(new Date));function nv(){let[e,t]=(0,U.useState)([]),[r,n]=(0,U.useState)(np),[i]=(0,U.useState)(()=>new ng.Document(ny));return(0,U.useEffect)(()=>{let e=new ng.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});i.subscribe("presence",e=>{e.type!==J.PresenceChanged&&t(function(e){let t=[];for(let{presence:r}of e)t.push(r.userName);return t}(i.getPresences()))}),async function(t,r){await e.activate(),await e.attach(t,{initialPresence:{userName:function(){let e=Math.floor(Math.random()*j.length);return j[e]}()}}),t.update(e=>{e.content||(e.content=np)},"create default content if not exists"),t.subscribe(()=>{r(t.getRoot().content)}),r(t.getRoot().content)}(i,e=>n(e))},[]),(0,K.jsxs)("main",{className:V().main,children:[(0,K.jsxs)("p",{children:["peers : [",e.map((e,t)=>(0,K.jsxs)("span",{children:[" ",e,", "]},t))," ","]"]}),(0,K.jsx)(nm,{content:r,actions:{addContent(e,t){i.update(r=>{r.content.push({date:e,text:t})})},deleteContent(e){i.update(t=>{let r;for(let n of t.content)if(n.date===e){r=n;break}r&&t.content.deleteByID(r.getID())})},updateContent(e,t){i.update(r=>{let n;for(let t of r.content)if(t.date===e){n=t;break}n&&(n.text=t)})}}})]})}},109:function(){},7397:function(e){e.exports={main:"page_main__s_E_L",textArea:"page_textArea__sVKfA",memo:"page_memo__V0Ipn",inputForm_editor:"page_inputForm_editor__Tk7dD"}}},function(e){e.O(0,[662,828,852,744],function(){return e(e.s=4629)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/examples/nextjs-scheduler/_next/static/Xci5Kvwm4M4WF4ibIjhh4/_buildManifest.js b/examples/nextjs-scheduler/_next/static/wLeZu3DP96EZimuMGR2Il/_buildManifest.js similarity index 100% rename from examples/nextjs-scheduler/_next/static/Xci5Kvwm4M4WF4ibIjhh4/_buildManifest.js rename to examples/nextjs-scheduler/_next/static/wLeZu3DP96EZimuMGR2Il/_buildManifest.js diff --git a/examples/nextjs-scheduler/_next/static/Xci5Kvwm4M4WF4ibIjhh4/_ssgManifest.js b/examples/nextjs-scheduler/_next/static/wLeZu3DP96EZimuMGR2Il/_ssgManifest.js similarity index 100% rename from examples/nextjs-scheduler/_next/static/Xci5Kvwm4M4WF4ibIjhh4/_ssgManifest.js rename to examples/nextjs-scheduler/_next/static/wLeZu3DP96EZimuMGR2Il/_ssgManifest.js diff --git a/examples/nextjs-scheduler/index.html b/examples/nextjs-scheduler/index.html index 85d9dad10..7935e36ee 100644 --- a/examples/nextjs-scheduler/index.html +++ b/examples/nextjs-scheduler/index.html @@ -1 +1 @@ -Next.js react-calendar example

    peers : [ ]

    Mon
    Tue
    Wed
    Thu
    Fri
    Sat
    Sun

    selected day : 09-12-24

    input form

    \ No newline at end of file +Next.js react-calendar example

    peers : [ ]

    Mon
    Tue
    Wed
    Thu
    Fri
    Sat
    Sun

    selected day : 10-12-24

    input form

    \ No newline at end of file diff --git a/examples/nextjs-scheduler/index.txt b/examples/nextjs-scheduler/index.txt index 91826230d..90be09bf8 100644 --- a/examples/nextjs-scheduler/index.txt +++ b/examples/nextjs-scheduler/index.txt @@ -1,7 +1,7 @@ 2:I[9974,[],""] -3:I[1802,["662","static/chunks/662-2ca4b8930a4bf5cf.js","931","static/chunks/app/page-8756ccd80820a787.js"],""] +3:I[1802,["662","static/chunks/662-2ca4b8930a4bf5cf.js","931","static/chunks/app/page-4229c045ecb9909b.js"],""] 4:I[4926,[],""] 5:I[4582,[],""] -0:["Xci5Kvwm4M4WF4ibIjhh4",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":["$","h1",null,{"children":"404 not found"}],"notFoundStyles":[],"styles":[["$","link","0",{"rel":"stylesheet","href":"/yorkie-js-sdk/examples/nextjs-scheduler/_next/static/css/0b8518b4fc95b726.css","precedence":"next","crossOrigin":""}]]}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/yorkie-js-sdk/examples/nextjs-scheduler/_next/static/css/55c28824c4a39011.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] +0:["wLeZu3DP96EZimuMGR2Il",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},["$L1",["$","$L2",null,{"propsForComponent":{"params":{}},"Component":"$3","isStaticGeneration":true}],null]]},[null,["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":["$","h1",null,{"children":"404 not found"}],"notFoundStyles":[],"styles":[["$","link","0",{"rel":"stylesheet","href":"/yorkie-js-sdk/examples/nextjs-scheduler/_next/static/css/0b8518b4fc95b726.css","precedence":"next","crossOrigin":""}]]}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/yorkie-js-sdk/examples/nextjs-scheduler/_next/static/css/55c28824c4a39011.css","precedence":"next","crossOrigin":""}]],"$L6"]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"Next.js react-calendar example"}],["$","meta","3",{"name":"description","content":"example of yorkie-js-sdk with next.js & react-calendar"}],["$","link","4",{"rel":"icon","href":"/yorkie-js-sdk/examples/nextjs-scheduler/favicon.ico","type":"image/x-icon","sizes":"64x64"}]] 1:null diff --git a/examples/profile-stack/assets/index-FKMiNpAO.js b/examples/profile-stack/assets/index-BZcMnYBH.js similarity index 72% rename from examples/profile-stack/assets/index-FKMiNpAO.js rename to examples/profile-stack/assets/index-BZcMnYBH.js index 48b1cdcfc..e02cd710b 100644 --- a/examples/profile-stack/assets/index-FKMiNpAO.js +++ b/examples/profile-stack/assets/index-BZcMnYBH.js @@ -1,6 +1,6 @@ -var la=Object.defineProperty;var ha=(n,t,e)=>t in n?la(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var a=(n,t,e)=>ha(n,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function e(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=e(s);fetch(s.href,i)}})();var R;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(R||(R={}));function ci(n){const t=R[n];return typeof t!="string"?n.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>"_"+e.toLowerCase())}class M extends Error{constructor(t,e=R.Unknown,r,s,i){super(fa(t,e)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=e,this.metadata=new Headers(r??{}),this.details=s??[],this.cause=i}static from(t,e=R.Unknown){return t instanceof M?t:t instanceof Error?t.name=="AbortError"?new M(t.message,R.Canceled):new M(t.message,e,void 0,void 0,t):new M(String(t),e,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===M.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const e="typeName"in t?{findMessage:s=>s===t.typeName?t:void 0}:t,r=[];for(const s of this.details){if("getType"in s){e.findMessage(s.getType().typeName)&&r.push(s);continue}const i=e.findMessage(s.type);if(i)try{r.push(i.fromBinary(s.value))}catch{}}return r}}function fa(n,t){return n.length?`[${ci(t)}] ${n}`:`[${ci(t)}]`}function z(n,t){if(!n)throw new Error(t)}const da=34028234663852886e22,ga=-34028234663852886e22,ma=4294967295,pa=2147483647,ya=-2147483648;function pn(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>pa||nma||n<0)throw new Error("invalid uint 32: "+n)}function eo(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>da||n({no:s.no,name:s.name,localName:n[s.no]})))}function no(n,t,e){const r=Object.create(null),s=Object.create(null),i=[];for(const o of t){const c=so(o);i.push(c),r[o.name]=c,s[o.no]=c}return{typeName:n,values:i,findName(o){return r[o]},findNumber(o){return s[o]}}}function wa(n,t,e){const r={};for(const s of t){const i=so(s);r[i.localName]=i.no,r[i.no]=i.localName}return ro(r,n,t),r}function so(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class A{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,e){const r=this.getType(),s=r.runtime.bin,i=s.makeReadOptions(e);return s.readMessage(this,i.readerFactory(t),t.byteLength,i),this}fromJson(t,e){const r=this.getType(),s=r.runtime.json,i=s.makeReadOptions(e);return s.readMessage(r,t,i,this),this}fromJsonString(t,e){let r;try{r=JSON.parse(t)}catch(s){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${s instanceof Error?s.message:String(s)}`)}return this.fromJson(r,e)}toBinary(t){const e=this.getType(),r=e.runtime.bin,s=r.makeWriteOptions(t),i=s.writerFactory();return r.writeMessage(this,i,s),i.finish()}toJson(t){const e=this.getType(),r=e.runtime.json,s=r.makeWriteOptions(t);return r.writeMessage(this,s)}toJsonString(t){var e;const r=this.toJson(t);return JSON.stringify(r,null,(e=t==null?void 0:t.prettySpaces)!==null&&e!==void 0?e:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Ta(n,t,e,r){var s;const i=(s=r==null?void 0:r.localName)!==null&&s!==void 0?s:t.substring(t.lastIndexOf(".")+1),o={[i]:function(c){n.util.initFields(this),n.util.initPartial(c,this)}}[i];return Object.setPrototypeOf(o.prototype,new A),Object.assign(o,{runtime:n,typeName:t,fields:n.util.newFieldList(e),fromBinary(c,l){return new o().fromBinary(c,l)},fromJson(c,l){return new o().fromJson(c,l)},fromJsonString(c,l){return new o().fromJsonString(c,l)},equals(c,l){return n.util.equals(o,c,l)}}),o}function Aa(){let n=0,t=0;for(let r=0;r<28;r+=7){let s=this.buf[this.pos++];if(n|=(s&127)<>4,!(e&128))return this.assertBounds(),[n,t];for(let r=3;r<=31;r+=7){let s=this.buf[this.pos++];if(t|=(s&127)<>>i,c=!(!(o>>>7)&&t==0),l=(c?o|128:o)&255;if(e.push(l),!c)return}const r=n>>>28&15|(t&7)<<4,s=!!(t>>3);if(e.push((s?r|128:r)&255),!!s){for(let i=3;i<31;i=i+7){const o=t>>>i,c=!!(o>>>7),l=(c?o|128:o)&255;if(e.push(l),!c)return}e.push(t>>>31&1)}}const yn=4294967296;function ui(n){const t=n[0]==="-";t&&(n=n.slice(1));const e=1e6;let r=0,s=0;function i(o,c){const l=Number(n.slice(o,c));s*=e,r=r*e+l,r>=yn&&(s=s+(r/yn|0),r=r%yn)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),t?oo(r,s):qs(r,s)}function ba(n,t){let e=qs(n,t);const r=e.hi&2147483648;r&&(e=oo(e.lo,e.hi));const s=io(e.lo,e.hi);return r?"-"+s:s}function io(n,t){if({lo:n,hi:t}=Ia(n,t),t<=2097151)return String(yn*t+n);const e=n&16777215,r=(n>>>24|t<<8)&16777215,s=t>>16&65535;let i=e+r*6777216+s*6710656,o=r+s*8147497,c=s*2;const l=1e7;return i>=l&&(o+=Math.floor(i/l),i%=l),o>=l&&(c+=Math.floor(o/l),o%=l),c.toString()+li(o)+li(i)}function Ia(n,t){return{lo:n>>>0,hi:t>>>0}}function qs(n,t){return{lo:n|0,hi:t|0}}function oo(n,t){return t=~t,n?n=~n+1:t+=1,qs(n,t)}const li=n=>{const t=String(n);return"0000000".slice(t.length)+t};function hi(n,t){if(n>=0){for(;n>127;)t.push(n&127|128),n=n>>>7;t.push(n)}else{for(let e=0;e<9;e++)t.push(n&127|128),n=n>>7;t.push(1)}}function Sa(){let n=this.buf[this.pos++],t=n&127;if(!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<7,!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<14,!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<21,!(n&128))return this.assertBounds(),t;n=this.buf[this.pos++],t|=(n&15)<<28;for(let e=5;n&128&&e<10;e++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var fi={};function ka(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof fi!="object"||fi.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),c=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const h=typeof l=="bigint"?l:BigInt(l);if(h>i||hc||hz(/^-?[0-9]+$/.test(s),`int64 invalid: ${s}`),r=s=>z(/^[0-9]+$/.test(s),`uint64 invalid: ${s}`);return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),e(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),r(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),e(s),ui(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),r(s),ui(s)},dec(s,i){return ba(s,i)},uDec(s,i){return io(s,i)}}}const $=ka();var y;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(y||(y={}));var ur;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(ur||(ur={}));function rr(n,t,e){if(t===e)return!0;if(n==y.BYTES){if(!(t instanceof Uint8Array)||!(e instanceof Uint8Array)||t.length!==e.length)return!1;for(let r=0;r>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(fs(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return pn(t),hi(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){eo(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){fs(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){pn(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return pn(t),t=(t<<1^t>>31)>>>0,hi(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),r=new DataView(e.buffer),s=$.enc(t);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),r=new DataView(e.buffer),s=$.uEnc(t);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(e)}int64(t){let e=$.enc(t);return ts(e.lo,e.hi,this.buf),this}sint64(t){let e=$.enc(t),r=e.hi>>31,s=e.lo<<1^r,i=(e.hi<<1|e.lo>>>31)^r;return ts(s,i,this.buf),this}uint64(t){let e=$.uEnc(t);return ts(e.lo,e.hi,this.buf),this}}class Ea{constructor(t,e){this.varint64=Aa,this.uint32=Sa,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e??new TextDecoder}tag(){let t=this.uint32(),e=t>>>3,r=t&7;if(e<=0||r<0||r>5)throw new Error("illegal tag: field no "+e+" wire type "+r);return[e,r]}skip(t,e){let r=this.pos;switch(t){case G.Varint:for(;this.buf[this.pos++]&128;);break;case G.Bit64:this.pos+=4;case G.Bit32:this.pos+=4;break;case G.LengthDelimited:let s=this.uint32();this.pos+=s;break;case G.StartGroup:for(;;){const[i,o]=this.tag();if(o===G.EndGroup){if(e!==void 0&&i!==e)throw new Error("invalid end group tag");break}this.skip(o,i)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return $.dec(...this.varint64())}uint64(){return $.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),r=-(t&1);return t=(t>>>1|(e&1)<<31)^r,e=e>>>1^r,$.dec(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}}function Na(n,t,e,r){let s;return{typeName:t,extendee:e,get field(){if(!s){const i=typeof r=="function"?r():r;i.name=t.split(".").pop(),i.jsonName=`[${t}]`,s=n.util.newFieldList([i]).list()[0]}return s},runtime:n}}function co(n){const t=n.field.localName,e=Object.create(null);return e[t]=Ca(n),[e,()=>e[t]]}function Ca(n){const t=n.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Or(t.T,t.L);case"message":const e=t.T,r=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Pa(n,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let e=n.length-1;e>=0;--e)if(n[e].no==t.no)return[n[e]];return[]}return n.filter(e=>e.no===t.no)}let Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Wn=[];for(let n=0;n>4,o=i,s=2;break;case 2:e[r++]=(o&15)<<4|(i&60)>>2,o=i,s=3;break;case 3:e[r++]=(o&3)<<6|i,s=0;break}}if(s==1)throw Error("invalid base64 string.");return e.subarray(0,r)},enc(n){let t="",e=0,r,s=0;for(let i=0;i>2],s=(r&3)<<4,e=1;break;case 1:t+=Wt[s|r>>4],s=(r&15)<<2,e=2;break;case 2:t+=Wt[s|r>>6],t+=Wt[r&63],e=0;break}return e&&(t+=Wt[s],t+="=",e==1&&(t+="=")),t}};function Da(n,t,e){lo(t,n);const r=t.runtime.bin.makeReadOptions(e),s=Pa(n.getType().runtime.bin.listUnknownFields(n),t.field),[i,o]=co(t);for(const c of s)t.runtime.bin.readField(i,r.readerFactory(c.data),t.field,c.wireType,r);return o()}function Oa(n,t,e,r){lo(t,n);const s=t.runtime.bin.makeReadOptions(r),i=t.runtime.bin.makeWriteOptions(r);if(uo(n,t)){const h=n.getType().runtime.bin.listUnknownFields(n).filter(f=>f.no!=t.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const f of h)n.getType().runtime.bin.onUnknownField(n,f.no,f.wireType,f.data)}const o=i.writerFactory();let c=t.field;!c.opt&&!c.repeated&&(c.kind=="enum"||c.kind=="scalar")&&(c=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(c,e,o,i);const l=s.readerFactory(o.finish());for(;l.posr.no==t.field.no)}function lo(n,t){z(n.extendee.typeName==t.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function ho(n,t){const e=n.localName;if(n.repeated)return t[e].length>0;if(n.oneof)return t[n.oneof.localName].case===e;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?t[e]!==void 0:n.kind=="enum"?t[e]!==n.T.values[0].no:!ao(n.T,t[e]);case"message":return t[e]!==void 0;case"map":return Object.keys(t[e]).length>0}}function di(n,t){const e=n.localName,r=!n.opt&&!n.req;if(n.repeated)t[e]=[];else if(n.oneof)t[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":t[e]={};break;case"enum":t[e]=r?n.T.values[0].no:void 0;break;case"scalar":t[e]=r?Or(n.T,n.L):void 0;break;case"message":t[e]=void 0;break}}function pr(n,t){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(A.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const e=n.getType();return e===null||typeof e!="function"||!("typeName"in e)||typeof e.typeName!="string"?!1:t===void 0?!0:e.typeName==t.typeName}function fo(n,t){return pr(t)||!n.fieldWrapper?t:n.fieldWrapper.wrapField(t)}y.DOUBLE,y.FLOAT,y.INT64,y.UINT64,y.INT32,y.UINT32,y.BOOL,y.STRING,y.BYTES;const gi={ignoreUnknownFields:!1},mi={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ba(n){return n?Object.assign(Object.assign({},gi),n):gi}function Ra(n){return n?Object.assign(Object.assign({},mi),n):mi}const In=Symbol(),vn=Symbol();function La(){return{makeReadOptions:Ba,makeWriteOptions:Ra,readMessage(n,t,e,r){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Be(t)}`);r=r??new n;const s=new Map,i=e.typeRegistry;for(const[o,c]of Object.entries(t)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(c===null&&l.kind=="scalar")continue;const h=s.get(l.oneof);if(h!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${h}", "${o}"`);s.set(l.oneof,o)}pi(r,c,l,e,n)}else{let h=!1;if(i!=null&&i.findExtension&&o.startsWith("[")&&o.endsWith("]")){const f=i.findExtension(o.substring(1,o.length-1));if(f&&f.extendee.typeName==n.typeName){h=!0;const[g,v]=co(f);pi(g,c,f.field,e,f),Oa(r,f,v(),e)}}if(!h&&!e.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,t){const e=n.getType(),r={};let s;try{for(s of e.fields.byNumber()){if(!ho(s,n)){if(s.req)throw"required field not set";if(!t.emitDefaultValues||!Fa(s))continue}const o=s.oneof?n[s.oneof.localName].value:n[s.localName],c=yi(s,o,t);c!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=c)}const i=t.typeRegistry;if(i!=null&&i.findExtensionFor)for(const o of e.runtime.bin.listUnknownFields(n)){const c=i.findExtensionFor(e.typeName,o.no);if(c&&uo(n,c)){const l=Da(n,c,t),h=yi(c.field,l,t);h!==void 0&&(r[c.field.jsonName]=h)}}}catch(i){const o=s?`cannot encode field ${e.typeName}.${s.name} to JSON`:`cannot encode message ${e.typeName} to JSON`,c=i instanceof Error?i.message:String(i);throw new Error(o+(c.length>0?`: ${c}`:""))}return r},readScalar(n,t,e){return Vr(n,t,e??ur.BIGINT,!0)},writeScalar(n,t,e){if(t!==void 0&&(e||ao(n,t)))return wn(n,t)},debug:Be}}function Be(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function pi(n,t,e,r,s){let i=e.localName;if(e.repeated){if(z(e.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`);const o=n[i];for(const c of t){if(c===null)throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(c)}`);switch(e.kind){case"message":o.push(e.T.fromJson(c,r));break;case"enum":const l=rs(e.T,c,r.ignoreUnknownFields,!0);l!==vn&&o.push(l);break;case"scalar":try{o.push(Vr(e.T,c,e.L,!0))}catch(h){let f=`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(c)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}break}}}else if(e.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`);const o=n[i];for(const[c,l]of Object.entries(t)){if(l===null)throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: map value null`);let h;try{h=Ja(e.K,c)}catch(f){let g=`cannot decode map key for field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw f instanceof Error&&f.message.length>0&&(g+=`: ${f.message}`),new Error(g)}switch(e.V.kind){case"message":o[h]=e.V.T.fromJson(l,r);break;case"enum":const f=rs(e.V.T,l,r.ignoreUnknownFields,!0);f!==vn&&(o[h]=f);break;case"scalar":try{o[h]=Vr(e.V.T,l,ur.BIGINT,!0)}catch(g){let v=`cannot decode map value for field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw g instanceof Error&&g.message.length>0&&(v+=`: ${g.message}`),new Error(v)}break}}}else switch(e.oneof&&(n=n[e.oneof.localName]={case:i},i="value"),e.kind){case"message":const o=e.T;if(t===null&&o.typeName!="google.protobuf.Value")return;let c=n[i];pr(c)?c.fromJson(t,r):(n[i]=c=o.fromJson(t,r),o.fieldWrapper&&!e.oneof&&(n[i]=o.fieldWrapper.unwrapField(c)));break;case"enum":const l=rs(e.T,t,r.ignoreUnknownFields,!1);switch(l){case In:di(e,n);break;case vn:break;default:n[i]=l;break}break;case"scalar":try{const h=Vr(e.T,t,e.L,!1);switch(h){case In:di(e,n);break;default:n[i]=h;break}}catch(h){let f=`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}break}}function Ja(n,t){if(n===y.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return Vr(n,t,ur.BIGINT,!0).toString()}function Vr(n,t,e,r){if(t===null)return r?Or(n,e):In;switch(n){case y.DOUBLE:case y.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s))break;return n==y.FLOAT&&eo(s),s;case y.INT32:case y.FIXED32:case y.SFIXED32:case y.SINT32:case y.UINT32:let i;if(typeof t=="number"?i=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(i=Number(t)),i===void 0)break;return n==y.UINT32||n==y.FIXED32?fs(i):pn(i),i;case y.INT64:case y.SFIXED64:case y.SINT64:if(typeof t!="number"&&typeof t!="string")break;const o=$.parse(t);return e?o.toString():o;case y.FIXED64:case y.UINT64:if(typeof t!="number"&&typeof t!="string")break;const c=$.uParse(t);return e?c.toString():c;case y.BOOL:if(typeof t!="boolean")break;return t;case y.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case y.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return zs.dec(t)}throw new Error}function rs(n,t,e,r){if(t===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:In;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const s=n.findName(t);if(s!==void 0)return s.no;if(e)return vn;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Be(t)}`)}function Fa(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function yi(n,t,e){if(n.kind=="map"){z(typeof t=="object"&&t!=null);const r={},s=Object.entries(t);switch(n.V.kind){case"scalar":for(const[o,c]of s)r[o.toString()]=wn(n.V.T,c);break;case"message":for(const[o,c]of s)r[o.toString()]=c.toJson(e);break;case"enum":const i=n.V.T;for(const[o,c]of s)r[o.toString()]=ns(i,c,e.enumAsInteger);break}return e.emitDefaultValues||s.length>0?r:void 0}if(n.repeated){z(Array.isArray(t));const r=[];switch(n.kind){case"scalar":for(let s=0;s0?r:void 0}switch(n.kind){case"scalar":return wn(n.T,t);case"enum":return ns(n.T,t,e.enumAsInteger);case"message":return fo(n.T,t).toJson(e)}}function ns(n,t,e){var r;if(z(typeof t=="number"),n.typeName=="google.protobuf.NullValue")return null;if(e)return t;const s=n.findNumber(t);return(r=s==null?void 0:s.name)!==null&&r!==void 0?r:t}function wn(n,t){switch(n){case y.INT32:case y.SFIXED32:case y.SINT32:case y.FIXED32:case y.UINT32:return z(typeof t=="number"),t;case y.FLOAT:case y.DOUBLE:return z(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case y.STRING:return z(typeof t=="string"),t;case y.BOOL:return z(typeof t=="boolean"),t;case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return z(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case y.BYTES:return z(t instanceof Uint8Array),zs.enc(t)}}const Ir=Symbol("@bufbuild/protobuf/unknown-fields"),vi={readUnknownFields:!0,readerFactory:n=>new Ea(n)},wi={writeUnknownFields:!0,writerFactory:()=>new xa};function Ma(n){return n?Object.assign(Object.assign({},vi),n):vi}function $a(n){return n?Object.assign(Object.assign({},wi),n):wi}function Ua(){return{makeReadOptions:Ma,makeWriteOptions:$a,listUnknownFields(n){var t;return(t=n[Ir])!==null&&t!==void 0?t:[]},discardUnknownFields(n){delete n[Ir]},writeUnknownFields(n,t){const r=n[Ir];if(r)for(const s of r)t.tag(s.no,s.wireType).raw(s.data)},onUnknownField(n,t,e,r){const s=n;Array.isArray(s[Ir])||(s[Ir]=[]),s[Ir].push({no:t,wireType:e,data:r})},readMessage(n,t,e,r,s){const i=n.getType(),o=s?t.len:t.pos+e;let c,l;for(;t.pos0&&(l=za),i){let v=n[o];if(r==G.LengthDelimited&&c!=y.STRING&&c!=y.BYTES){let w=t.uint32()+t.pos;for(;t.pospr(v,g)?v:new g(v));else{const v=o[s];g.fieldWrapper?g.typeName==="google.protobuf.BytesValue"?i[s]=Ur(v):i[s]=v:i[s]=pr(v,g)?v:new g(v)}break}}},equals(n,t,e){return t===e?!0:!t||!e?!1:n.fields.byMember().every(r=>{const s=t[r.localName],i=e[r.localName];if(r.repeated){if(s.length!==i.length)return!1;switch(r.kind){case"message":return s.every((o,c)=>r.T.equals(o,i[c]));case"scalar":return s.every((o,c)=>rr(r.T,o,i[c]));case"enum":return s.every((o,c)=>rr(y.INT32,o,i[c]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(s,i);case"enum":return rr(y.INT32,s,i);case"scalar":return rr(r.T,s,i);case"oneof":if(s.case!==i.case)return!1;const o=r.findField(s.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(s.value,i.value);case"enum":return rr(y.INT32,s.value,i.value);case"scalar":return rr(o.T,s.value,i.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const c=Object.keys(s).concat(Object.keys(i));switch(r.V.kind){case"message":const l=r.V.T;return c.every(f=>l.equals(s[f],i[f]));case"enum":return c.every(f=>rr(y.INT32,s[f],i[f]));case"scalar":const h=r.V.T;return c.every(f=>rr(h,s[f],i[f]))}break}})},clone(n){const t=n.getType(),e=new t,r=e;for(const s of t.fields.byMember()){const i=n[s.localName];let o;if(s.repeated)o=i.map(ln);else if(s.kind=="map"){o=r[s.localName];for(const[c,l]of Object.entries(i))o[c]=ln(l)}else s.kind=="oneof"?o=s.findField(i.case)?{case:i.case,value:ln(i.value)}:{case:void 0}:o=ln(i);r[s.localName]=o}for(const s of t.runtime.bin.listUnknownFields(n))t.runtime.bin.onUnknownField(r,s.no,s.wireType,s.data);return e}}}function ln(n){if(n===void 0)return n;if(pr(n))return n.clone();if(n instanceof Uint8Array){const t=new Uint8Array(n.byteLength);return t.set(n),t}return n}function Ur(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function Ga(n,t,e){return{syntax:n,json:La(),bin:Ua(),util:Object.assign(Object.assign({},ja()),{newFieldList:t,initFields:e}),makeMessageType(r,s,i){return Ta(this,r,s,i)},makeEnum:wa,makeEnumType:no,getEnumType:va,makeExtension(r,s,i){return Na(this,r,s,i)}}}class Wa{constructor(t,e){this._fields=t,this._normalizer=e}findJsonName(t){if(!this.jsonNames){const e={};for(const r of this.list())e[r.jsonName]=e[r.name]=r;this.jsonNames=e}return this.jsonNames[t]}find(t){if(!this.numbers){const e={};for(const r of this.list())e[r.no]=r;this.numbers=e}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,e)=>t.no-e.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let e;for(const r of this.list())r.oneof?r.oneof!==e&&(e=r.oneof,t.push(e)):t.push(r)}return this.members}}function mo(n,t){const e=po(n);return t?e:_a(Qa(e))}function Ha(n){return mo(n,!1)}const Ya=po;function po(n){let t=!1;const e=[];for(let r=0;r`${n}$`,Qa=n=>Za.has(n)?yo(n):n,_a=n=>Xa.has(n)?yo(n):n;class ec{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=Ha(t)}addField(t){z(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;enew Wa(n,t=>tc(t)),n=>{for(const t of n.getType().fields.byMember()){if(t.opt)continue;const e=t.localName,r=n;if(t.repeated){r[e]=[];continue}switch(t.kind){case"oneof":r[e]={case:void 0};break;case"enum":r[e]=0;break;case"map":r[e]={};break;case"scalar":r[e]=Or(t.T,t.L);break}}});var ee;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(ee||(ee={}));var Ii;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Ii||(Ii={}));class Q extends A{constructor(t){super(),this.seconds=$.zero,this.nanos=0,u.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${u.json.debug(t)}`);const r=t.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(sDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=$.parse(s/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(t){const e=Number(this.seconds)*1e3;if(eDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const s=(this.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(e).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Q.fromDate(new Date)}static fromDate(t){const e=t.getTime();return new Q({seconds:$.parse(Math.floor(e/1e3)),nanos:e%1e3*1e6})}static fromBinary(t,e){return new Q().fromBinary(t,e)}static fromJson(t,e){return new Q().fromJson(t,e)}static fromJsonString(t,e){return new Q().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Q,t,e)}}Q.runtime=u;Q.typeName="google.protobuf.Timestamp";Q.fields=u.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Ht extends A{constructor(t){super(),this.seconds=$.zero,this.nanos=0,u.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);const r=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);const s=Number(r[1]);if(s>315576e6||s<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);if(this.seconds=$.parse(s),typeof r[2]=="string"){const i=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(i),(s<0||Object.is(s,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let e=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),e+="."+r,this.nanos<0&&Number(this.seconds)==0&&(e="-"+e)}return e+"s"}static fromBinary(t,e){return new Ht().fromBinary(t,e)}static fromJson(t,e){return new Ht().fromJson(t,e)}static fromJsonString(t,e){return new Ht().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ht,t,e)}}Ht.runtime=u;Ht.typeName="google.protobuf.Duration";Ht.fields=u.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Re extends A{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),u.util.initPartial(t,this)}toJson(t){var e;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),s=(e=t==null?void 0:t.typeRegistry)===null||e===void 0?void 0:e.findMessage(r);if(!s)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=s.fromBinary(this.value).toJson(t);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(t,e){var r;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const s=t["@type"];if(typeof s!="string"||s=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const i=this.typeUrlToName(s),o=(r=e==null?void 0:e.typeRegistry)===null||r===void 0?void 0:r.findMessage(i);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${s} is not in the type registry`);let c;if(i.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))c=o.fromJson(t.value,e);else{const l=Object.assign({},t);delete l["@type"],c=o.fromJson(l,e)}return this.packFrom(c),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const e=t.findMessage(this.typeUrlToName(this.typeUrl));if(e)return e.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const e=this.typeUrlToName(this.typeUrl);let r="";return typeof t=="string"?r=t:r=t.typeName,e===r}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const e=t.lastIndexOf("/"),r=e>=0?t.substring(e+1):t;if(!r.length)throw new Error(`invalid type url: ${t}`);return r}static pack(t){const e=new Re;return e.packFrom(t),e}static fromBinary(t,e){return new Re().fromBinary(t,e)}static fromJson(t,e){return new Re().fromJson(t,e)}static fromJsonString(t,e){return new Re().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Re,t,e)}}Re.runtime=u;Re.typeName="google.protobuf.Any";Re.fields=u.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Le extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.DOUBLE,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.DOUBLE,t)}catch(r){let s='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Le().fromBinary(t,e)}static fromJson(t,e){return new Le().fromJson(t,e)}static fromJsonString(t,e){return new Le().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Le,t,e)}}Le.runtime=u;Le.typeName="google.protobuf.DoubleValue";Le.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Le.fieldWrapper={wrapField(n){return new Le({value:n})},unwrapField(n){return n.value}};class Je extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.FLOAT,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.FLOAT,t)}catch(r){let s='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Je().fromBinary(t,e)}static fromJson(t,e){return new Je().fromJson(t,e)}static fromJsonString(t,e){return new Je().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Je,t,e)}}Je.runtime=u;Je.typeName="google.protobuf.FloatValue";Je.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Je.fieldWrapper={wrapField(n){return new Je({value:n})},unwrapField(n){return n.value}};class Fe extends A{constructor(t){super(),this.value=$.zero,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.INT64,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.INT64,t)}catch(r){let s='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Fe().fromBinary(t,e)}static fromJson(t,e){return new Fe().fromJson(t,e)}static fromJsonString(t,e){return new Fe().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Fe,t,e)}}Fe.runtime=u;Fe.typeName="google.protobuf.Int64Value";Fe.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Fe.fieldWrapper={wrapField(n){return new Fe({value:n})},unwrapField(n){return n.value}};class Me extends A{constructor(t){super(),this.value=$.zero,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.UINT64,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.UINT64,t)}catch(r){let s='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Me().fromBinary(t,e)}static fromJson(t,e){return new Me().fromJson(t,e)}static fromJsonString(t,e){return new Me().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Me,t,e)}}Me.runtime=u;Me.typeName="google.protobuf.UInt64Value";Me.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Me.fieldWrapper={wrapField(n){return new Me({value:n})},unwrapField(n){return n.value}};class $e extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.INT32,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.INT32,t)}catch(r){let s='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new $e().fromBinary(t,e)}static fromJson(t,e){return new $e().fromJson(t,e)}static fromJsonString(t,e){return new $e().fromJsonString(t,e)}static equals(t,e){return u.util.equals($e,t,e)}}$e.runtime=u;$e.typeName="google.protobuf.Int32Value";$e.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);$e.fieldWrapper={wrapField(n){return new $e({value:n})},unwrapField(n){return n.value}};class Ue extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.UINT32,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.UINT32,t)}catch(r){let s='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Ue().fromBinary(t,e)}static fromJson(t,e){return new Ue().fromJson(t,e)}static fromJsonString(t,e){return new Ue().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ue,t,e)}}Ue.runtime=u;Ue.typeName="google.protobuf.UInt32Value";Ue.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Ue.fieldWrapper={wrapField(n){return new Ue({value:n})},unwrapField(n){return n.value}};class qe extends A{constructor(t){super(),this.value=!1,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.BOOL,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.BOOL,t)}catch(r){let s='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new qe().fromBinary(t,e)}static fromJson(t,e){return new qe().fromJson(t,e)}static fromJsonString(t,e){return new qe().fromJsonString(t,e)}static equals(t,e){return u.util.equals(qe,t,e)}}qe.runtime=u;qe.typeName="google.protobuf.BoolValue";qe.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);qe.fieldWrapper={wrapField(n){return new qe({value:n})},unwrapField(n){return n.value}};class ie extends A{constructor(t){super(),this.value="",u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.STRING,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.STRING,t)}catch(r){let s='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new ie().fromBinary(t,e)}static fromJson(t,e){return new ie().fromJson(t,e)}static fromJsonString(t,e){return new ie().fromJsonString(t,e)}static equals(t,e){return u.util.equals(ie,t,e)}}ie.runtime=u;ie.typeName="google.protobuf.StringValue";ie.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);ie.fieldWrapper={wrapField(n){return new ie({value:n})},unwrapField(n){return n.value}};class ze extends A{constructor(t){super(),this.value=new Uint8Array(0),u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.BYTES,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.BYTES,t)}catch(r){let s='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new ze().fromBinary(t,e)}static fromJson(t,e){return new ze().fromJson(t,e)}static fromJsonString(t,e){return new ze().fromJsonString(t,e)}static equals(t,e){return u.util.equals(ze,t,e)}}ze.runtime=u;ze.typeName="google.protobuf.BytesValue";ze.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);ze.fieldWrapper={wrapField(n){return new ze({value:n})},unwrapField(n){return n.value}};function rc(n,t,e){try{const r=zs.dec(n);return t?t.fromBinary(r,e):r}catch(r){throw M.from(r,R.DataLoss)}}function nc(n,t){const e={};for(const[r,s]of Object.entries(n.methods)){const i=t(Object.assign(Object.assign({},s),{localName:r,service:n}));i!=null&&(e[r]=i)}return e}function Si(n){let t,e=new Uint8Array(0);function r(s){const i=new Uint8Array(e.length+s.length);i.set(e),i.set(s,e.length),e=i}return new ReadableStream({start(){t=n.getReader()},async pull(s){let i;for(;;){if(i===void 0&&e.byteLength>=5){let l=0;for(let h=1;h<5;h++)l=(l<<8)+e[h];i={flags:e[0],length:l}}if(i!==void 0&&e.byteLength>=i.length+5)break;const c=await t.read();if(c.done)break;r(c.value)}if(i===void 0){if(e.byteLength==0){s.close();return}s.error(new M("premature end of stream",R.DataLoss));return}const o=e.subarray(5,5+i.length);e=e.subarray(5+i.length),s.enqueue({flags:i.flags,data:o})}})}function ki(n,t){const e=new Uint8Array(t.length+5);e.set(t,5);const r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setUint8(0,n),r.setUint32(1,t.length),e}var sc=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(c,l){o=n[i](o),s(c,l,o.done,o.value)})}}function s(i,o,c,l){Promise.resolve(l).then(function(h){i({value:h,done:c})},o)}},Hr=function(n){return this instanceof Hr?(this.v=n,this):new Hr(n)},ic=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof Hr?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}},oc=function(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:Hr(n[s](o)),done:!1}:i?i(o):o}:i}};function ac(n){return ic(this,arguments,function*(){yield Hr(yield*oc(sc(n)))})}var vo=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(c,l){o=n[i](o),s(c,l,o.done,o.value)})}}function s(i,o,c,l){Promise.resolve(l).then(function(h){i({value:h,done:c})},o)}},Br=function(n){return this instanceof Br?(this.v=n,this):new Br(n)},cc=function(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:Br(n[s](o)),done:!1}:i?i(o):o}:i}},uc=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof Br?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}};function lc(n,t){return nc(n,e=>{switch(e.kind){case ee.Unary:return hc(t,n,e);case ee.ServerStreaming:return fc(t,n,e);case ee.ClientStreaming:return dc(t,n,e);case ee.BiDiStreaming:return gc(t,n,e);default:return null}})}function hc(n,t,e){return async function(r,s){var i,o;const c=await n.unary(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);return(i=s==null?void 0:s.onHeader)===null||i===void 0||i.call(s,c.header),(o=s==null?void 0:s.onTrailer)===null||o===void 0||o.call(s,c.trailer),c.message}}function fc(n,t,e){return function(r,s){return wo(n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,ac([r]),s==null?void 0:s.contextValues),s)}}function dc(n,t,e){return async function(r,s){var i,o,c,l,h,f;const g=await n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);(h=s==null?void 0:s.onHeader)===null||h===void 0||h.call(s,g.header);let v;try{for(var p=!0,w=vo(g.message),b;b=await w.next(),i=b.done,!i;p=!0)l=b.value,p=!1,v=l}catch(x){o={error:x}}finally{try{!p&&!i&&(c=w.return)&&await c.call(w)}finally{if(o)throw o.error}}if(!v)throw new M("protocol error: missing response message",R.Internal);return(f=s==null?void 0:s.onTrailer)===null||f===void 0||f.call(s,g.trailer),v}}function gc(n,t,e){return function(r,s){return wo(n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues),s)}}function wo(n,t){const e=function(){var r,s;return uc(this,arguments,function*(){const i=yield Br(n);(r=t==null?void 0:t.onHeader)===null||r===void 0||r.call(t,i.header),yield Br(yield*cc(vo(i.message))),(s=t==null?void 0:t.onTrailer)===null||s===void 0||s.call(t,i.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>e.next()})}}function mc(...n){const t=new AbortController,e=n.filter(s=>s!==void 0).concat(t.signal);for(const s of e){if(s.aborted){r.apply(s);break}s.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(To(this));for(const s of e)s.removeEventListener("abort",r)}return t}function pc(n){const t=new AbortController,e=()=>{t.abort(new M("the operation timed out",R.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?e():r=setTimeout(e,n)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function To(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function xi(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,t){return this[n.id]=t,this},delete(n){return delete this[n.id],this}}}const ss=128;function Ei(n){const t=new Headers,e=new TextDecoder().decode(n).split(`\r -`);for(const r of e){if(r==="")continue;const s=r.indexOf(":");if(s>0){const i=r.substring(0,s).trim(),o=r.substring(s+1).trim();t.append(i,o)}}return t}const yc="Content-Type",vc="Grpc-Timeout",Ao="Grpc-Status",bo="Grpc-Message",wc="Grpc-Status-Details-Bin",Tc="X-User-Agent",Ac="X-Grpc-Web",bc="application/grpc-web+proto",Ic="application/grpc-web+json";class Yt extends A{constructor(t){super(),this.code=0,this.message="",this.details=[],u.util.initPartial(t,this)}static fromBinary(t,e){return new Yt().fromBinary(t,e)}static fromJson(t,e){return new Yt().fromJson(t,e)}static fromJsonString(t,e){return new Yt().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Yt,t,e)}}Yt.runtime=u;Yt.typeName="google.rpc.Status";Yt.fields=u.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Re,repeated:!0}]);const Sc="0";function Io(n){var t;const e=n.get(wc);if(e!=null){const s=rc(e,Yt);if(s.code==0)return;const i=new M(s.message,s.code,n);return i.details=s.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),i}const r=n.get(Ao);if(r!=null){if(r===Sc)return;const s=parseInt(r,10);return s in R?new M(decodeURIComponent((t=n.get(bo))!==null&&t!==void 0?t:""),s,n):new M(`invalid grpc-status: ${r}`,R.Internal,n)}}function Ni(n,t,e){const r=typeof t=="string"?t:t.typeName,s=typeof e=="string"?e:e.name;return n.toString().replace(/\/?$/,`/${r}/${s}`)}function So(n,t){return t instanceof n?t:new n(t)}function kc(n,t){function e(r){return r.done===!0?r:{done:r.done,value:So(n,r.value)}}return{[Symbol.asyncIterator](){const r=t[Symbol.asyncIterator](),s={next:()=>r.next().then(e)};return r.throw!==void 0&&(s.throw=i=>r.throw(i).then(e)),r.return!==void 0&&(s.return=i=>r.return(i).then(e)),s}}}function ko(n,t){var e;return(e=t==null?void 0:t.concat().reverse().reduce((r,s)=>s(r),n))!==null&&e!==void 0?e:n}function xc(n){var t;const e=Object.assign({},n);return(t=e.ignoreUnknownFields)!==null&&t!==void 0||(e.ignoreUnknownFields=!0),e}function Ci(n,t,e,r){const s=t?Pi(n.I,r):Di(n.I,e);return{parse:(t?Pi(n.O,r):Di(n.O,e)).parse,serialize:s.serialize}}function Pi(n,t){return{parse(e){try{return n.fromBinary(e,t)}catch(r){const s=r instanceof Error?r.message:String(r);throw new M(`parse binary: ${s}`,R.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(r){const s=r instanceof Error?r.message:String(r);throw new M(`serialize binary: ${s}`,R.Internal)}}}}function Di(n,t){var e,r;const s=(e=t==null?void 0:t.textEncoder)!==null&&e!==void 0?e:new TextEncoder,i=(r=t==null?void 0:t.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=xc(t);return{parse(c){try{const l=i.decode(c);return n.fromJsonString(l,o)}catch(l){throw M.from(l,R.InvalidArgument)}},serialize(c){try{const l=c.toJsonString(o);return s.encode(l)}catch(l){throw M.from(l,R.Internal)}}}}function Ec(n){const t=ko(n.next,n.interceptors),[e,r,s]=xo(n),i=Object.assign(Object.assign({},n.req),{message:So(n.req.method.I,n.req.message),signal:e});return t(i).then(o=>(s(),o),r)}function Nc(n){const t=ko(n.next,n.interceptors),[e,r,s]=xo(n),i=Object.assign(Object.assign({},n.req),{message:kc(n.req.method.I,n.req.message),signal:e});let o=!1;return e.addEventListener("abort",function(){var c,l;const h=n.req.message[Symbol.asyncIterator]();o||(c=h.throw)===null||c===void 0||c.call(h,this.reason).catch(()=>{}),(l=h.return)===null||l===void 0||l.call(h).catch(()=>{})}),t(i).then(c=>Object.assign(Object.assign({},c),{message:{[Symbol.asyncIterator](){const l=c.message[Symbol.asyncIterator]();return{next(){return l.next().then(h=>(h.done==!0&&(o=!0,s()),h),r)}}}}}),r)}function xo(n){const{signal:t,cleanup:e}=pc(n.timeoutMs),r=mc(n.signal,t);return[r.signal,function(i){const o=M.from(t.aborted?To(t):i);return r.abort(o),e(),Promise.reject(o)},function(){e(),r.abort()}]}function Cc(){try{new Headers}catch{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.")}}function Oi(n,t){const e=Io(n);if(e)throw t.forEach((r,s)=>{e.metadata.append(s,r)}),e}function Bi(n,t,e,r){const s=new Headers(e??{});return s.set(yc,n?bc:Ic),s.set(Ac,"1"),s.set(Tc,"connect-es/1.4.0"),t!==void 0&&s.set(vc,`${t}m`),s}function Pc(n){switch(n){case 400:return R.Internal;case 401:return R.Unauthenticated;case 403:return R.PermissionDenied;case 404:return R.Unimplemented;case 429:return R.Unavailable;case 502:return R.Unavailable;case 503:return R.Unavailable;case 504:return R.Unavailable;default:return R.Unknown}}function Ri(n,t){var e;if(n>=200&&n<300){const r=Io(t);if(r)throw r;return{foundStatus:t.has(Ao)}}throw new M(decodeURIComponent((e=t.get(bo))!==null&&e!==void 0?e:`HTTP ${n}`),Pc(n),t)}var gr=function(n){return this instanceof gr?(this.v=n,this):new gr(n)},Dc=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof gr?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}};function Oc(n){var t;Cc();const e=(t=n.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(r,s,i,o,c,l,h){var f;const{serialize:g,parse:v}=Ci(s,e,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await Ec({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!1,service:r,method:s,url:Ni(n.baseUrl,r,s),init:{method:"POST",credentials:(f=n.credentials)!==null&&f!==void 0?f:"same-origin",redirect:"error",mode:"cors"},header:Bi(e,o,c),contextValues:h??xi(),message:l},next:async p=>{var w;const x=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:ki(0,g(p.message))}));if(Ri(x.status,x.headers),!x.body)throw"missing response body";const C=Si(x.body).getReader();let P,L;for(;;){const Y=await C.read();if(Y.done)break;const{flags:D,data:F}=Y.value;if(D===ss){if(P!==void 0)throw"extra trailer";P=Ei(F);continue}if(L!==void 0)throw"extra message";L=v(F)}if(P===void 0)throw"missing trailer";if(Oi(P,x.headers),L===void 0)throw"missing message";return{stream:!1,service:r,method:s,header:x.headers,message:L,trailer:P}}})},async stream(r,s,i,o,c,l,h){var f;const{serialize:g,parse:v}=Ci(s,e,n.jsonOptions,n.binaryOptions);function p(b,x,C,P){return Dc(this,arguments,function*(){const Y=Si(b).getReader();if(x){if(!(yield gr(Y.read())).done)throw"extra data for trailers-only";return yield gr(void 0)}let D=!1;for(;;){const F=yield gr(Y.read());if(F.done)break;const{flags:V,data:K}=F.value;if((V&ss)===ss){if(D)throw"extra trailer";D=!0;const ue=Ei(K);Oi(ue,P),ue.forEach((Ge,br)=>C.set(br,Ge));continue}if(D)throw"extra message";yield yield gr(v(K))}if(!D)throw"missing trailer"})}async function w(b){if(s.kind!=ee.ServerStreaming)throw"The fetch API does not support streaming request bodies";const x=await b[Symbol.asyncIterator]().next();if(x.done==!0)throw"missing request message";return ki(0,g(x.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,Nc({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!0,service:r,method:s,url:Ni(n.baseUrl,r,s),init:{method:"POST",credentials:(f=n.credentials)!==null&&f!==void 0?f:"same-origin",redirect:"error",mode:"cors"},header:Bi(e,o,c),contextValues:h??xi(),message:l},next:async b=>{var x;const P=await((x=n.fetch)!==null&&x!==void 0?x:globalThis.fetch)(b.url,Object.assign(Object.assign({},b.init),{headers:b.header,signal:b.signal,body:await w(b.message)})),{foundStatus:L}=Ri(P.status,P.headers);if(!P.body)throw"missing response body";const Y=new Headers;return Object.assign(Object.assign({},b),{header:P.headers,trailer:Y,message:p(P.body,L,Y,P.headers)})}})}}}var N=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(N||{});u.util.setEnumType(N,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var yr=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(yr||{});u.util.setEnumType(yr,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const We=class We extends A{constructor(e){super();a(this,"root");a(this,"presences",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new We().fromBinary(e,r)}static fromJson(e,r){return new We().fromJson(e,r)}static fromJsonString(e,r){return new We().fromJsonString(e,r)}static equals(e,r){return u.util.equals(We,e,r)}};a(We,"runtime",u),a(We,"typeName","yorkie.v1.Snapshot"),a(We,"fields",u.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:se},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Ks}}]));let ds=We;var he;let tr=(he=class extends A{constructor(e){super();a(this,"documentKey","");a(this,"checkpoint");a(this,"snapshot",new Uint8Array(0));a(this,"changes",[]);a(this,"minSyncedTicket");a(this,"isRemoved",!1);a(this,"versionVector");u.util.initPartial(e,this)}static fromBinary(e,r){return new he().fromBinary(e,r)}static fromJson(e,r){return new he().fromJson(e,r)}static fromJsonString(e,r){return new he().fromJsonString(e,r)}static equals(e,r){return u.util.equals(he,e,r)}},a(he,"runtime",u),a(he,"typeName","yorkie.v1.ChangePack"),a(he,"fields",u.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Co},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Eo,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:I},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Yn}])),he);var fe;let Eo=(fe=class extends A{constructor(e){super();a(this,"id");a(this,"message","");a(this,"operations",[]);a(this,"presenceChange");u.util.initPartial(e,this)}static fromBinary(e,r){return new fe().fromBinary(e,r)}static fromJson(e,r){return new fe().fromJson(e,r)}static fromJsonString(e,r){return new fe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(fe,e,r)}},a(fe,"runtime",u),a(fe,"typeName","yorkie.v1.Change"),a(fe,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Hn},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Vs,repeated:!0},{no:4,name:"presence_change",kind:"message",T:Zr}])),fe);var de;let Hn=(de=class extends A{constructor(e){super();a(this,"clientSeq",0);a(this,"serverSeq",$.zero);a(this,"lamport",$.zero);a(this,"actorId",new Uint8Array(0));a(this,"versionVector");u.util.initPartial(e,this)}static fromBinary(e,r){return new de().fromBinary(e,r)}static fromJson(e,r){return new de().fromJson(e,r)}static fromJsonString(e,r){return new de().fromJsonString(e,r)}static equals(e,r){return u.util.equals(de,e,r)}},a(de,"runtime",u),a(de,"typeName","yorkie.v1.ChangeID"),a(de,"fields",u.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Yn}])),de);var ge;let Yn=(ge=class extends A{constructor(e){super();a(this,"vector",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new ge().fromBinary(e,r)}static fromJson(e,r){return new ge().fromJson(e,r)}static fromJsonString(e,r){return new ge().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ge,e,r)}},a(ge,"runtime",u),a(ge,"typeName","yorkie.v1.VersionVector"),a(ge,"fields",u.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),ge);var me;let Vs=(me=class extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new me().fromBinary(e,r)}static fromJson(e,r){return new me().fromJson(e,r)}static fromJsonString(e,r){return new me().fromJsonString(e,r)}static equals(e,r){return u.util.equals(me,e,r)}},a(me,"runtime",u),a(me,"typeName","yorkie.v1.Operation"),a(me,"fields",u.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:kn,oneof:"body"},{no:2,name:"add",kind:"message",T:xn,oneof:"body"},{no:3,name:"move",kind:"message",T:En,oneof:"body"},{no:4,name:"remove",kind:"message",T:Nn,oneof:"body"},{no:5,name:"edit",kind:"message",T:Cn,oneof:"body"},{no:6,name:"select",kind:"message",T:gs,oneof:"body"},{no:7,name:"style",kind:"message",T:Pn,oneof:"body"},{no:8,name:"increase",kind:"message",T:Dn,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:On,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:Bn,oneof:"body"},{no:11,name:"array_set",kind:"message",T:ms,oneof:"body"}])),me);const He=class He extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"key","");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new He().fromBinary(e,r)}static fromJson(e,r){return new He().fromJson(e,r)}static fromJsonString(e,r){return new He().fromJsonString(e,r)}static equals(e,r){return u.util.equals(He,e,r)}};a(He,"runtime",u),a(He,"typeName","yorkie.v1.Operation.Set"),a(He,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let kn=He;const Ye=class Ye extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"prevCreatedAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ye().fromBinary(e,r)}static fromJson(e,r){return new Ye().fromJson(e,r)}static fromJsonString(e,r){return new Ye().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ye,e,r)}};a(Ye,"runtime",u),a(Ye,"typeName","yorkie.v1.Operation.Add"),a(Ye,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"prev_created_at",kind:"message",T:I},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let xn=Ye;const Xe=class Xe extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"prevCreatedAt");a(this,"createdAt");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Xe().fromBinary(e,r)}static fromJson(e,r){return new Xe().fromJson(e,r)}static fromJsonString(e,r){return new Xe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Xe,e,r)}};a(Xe,"runtime",u),a(Xe,"typeName","yorkie.v1.Operation.Move"),a(Xe,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"prev_created_at",kind:"message",T:I},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"executed_at",kind:"message",T:I}]));let En=Xe;const Ze=class Ze extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"createdAt");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ze().fromBinary(e,r)}static fromJson(e,r){return new Ze().fromJson(e,r)}static fromJsonString(e,r){return new Ze().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ze,e,r)}};a(Ze,"runtime",u),a(Ze,"typeName","yorkie.v1.Operation.Remove"),a(Ze,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"executed_at",kind:"message",T:I}]));let Nn=Ze;const Qe=class Qe extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"createdAtMapByActor",{});a(this,"content","");a(this,"executedAt");a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new Qe().fromBinary(e,r)}static fromJson(e,r){return new Qe().fromJson(e,r)}static fromJsonString(e,r){return new Qe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Qe,e,r)}};a(Qe,"runtime",u),a(Qe,"typeName","yorkie.v1.Operation.Edit"),a(Qe,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:I},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let Cn=Qe;const _e=class _e extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new _e().fromBinary(e,r)}static fromJson(e,r){return new _e().fromJson(e,r)}static fromJsonString(e,r){return new _e().fromJsonString(e,r)}static equals(e,r){return u.util.equals(_e,e,r)}};a(_e,"runtime",u),a(_e,"typeName","yorkie.v1.Operation.Select"),a(_e,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"executed_at",kind:"message",T:I}]));let gs=_e;const et=class et extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"attributes",{});a(this,"executedAt");a(this,"createdAtMapByActor",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new et().fromBinary(e,r)}static fromJson(e,r){return new et().fromJson(e,r)}static fromJsonString(e,r){return new et().fromJsonString(e,r)}static equals(e,r){return u.util.equals(et,e,r)}};a(et,"runtime",u),a(et,"typeName","yorkie.v1.Operation.Style"),a(et,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:I},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}}]));let Pn=et;const tt=class tt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new tt().fromBinary(e,r)}static fromJson(e,r){return new tt().fromJson(e,r)}static fromJsonString(e,r){return new tt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(tt,e,r)}};a(tt,"runtime",u),a(tt,"typeName","yorkie.v1.Operation.Increase"),a(tt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"value",kind:"message",T:le},{no:3,name:"executed_at",kind:"message",T:I}]));let Dn=tt;const rt=class rt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"createdAtMapByActor",{});a(this,"contents",[]);a(this,"splitLevel",0);a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new rt().fromBinary(e,r)}static fromJson(e,r){return new rt().fromJson(e,r)}static fromJsonString(e,r){return new rt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(rt,e,r)}};a(rt,"runtime",u),a(rt,"typeName","yorkie.v1.Operation.TreeEdit"),a(rt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:vr},{no:3,name:"to",kind:"message",T:vr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}},{no:5,name:"contents",kind:"message",T:zn,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:I}]));let On=rt;const nt=class nt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"attributes",{});a(this,"executedAt");a(this,"attributesToRemove",[]);a(this,"createdAtMapByActor",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new nt().fromBinary(e,r)}static fromJson(e,r){return new nt().fromJson(e,r)}static fromJsonString(e,r){return new nt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(nt,e,r)}};a(nt,"runtime",u),a(nt,"typeName","yorkie.v1.Operation.TreeStyle"),a(nt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:vr},{no:3,name:"to",kind:"message",T:vr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:I},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}}]));let Bn=nt;const st=class st extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"createdAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new st().fromBinary(e,r)}static fromJson(e,r){return new st().fromJson(e,r)}static fromJsonString(e,r){return new st().fromJsonString(e,r)}static equals(e,r){return u.util.equals(st,e,r)}};a(st,"runtime",u),a(st,"typeName","yorkie.v1.Operation.ArraySet"),a(st,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let ms=st;const it=class it extends A{constructor(e){super();a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");a(this,"type",0);a(this,"value",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new it().fromBinary(e,r)}static fromJson(e,r){return new it().fromJson(e,r)}static fromJsonString(e,r){return new it().fromJsonString(e,r)}static equals(e,r){return u.util.equals(it,e,r)}};a(it,"runtime",u),a(it,"typeName","yorkie.v1.JSONElementSimple"),a(it,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"moved_at",kind:"message",T:I},{no:3,name:"removed_at",kind:"message",T:I},{no:4,name:"type",kind:"enum",T:u.getEnumType(N)},{no:5,name:"value",kind:"scalar",T:12}]));let le=it;const ot=class ot extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new ot().fromBinary(e,r)}static fromJson(e,r){return new ot().fromJson(e,r)}static fromJsonString(e,r){return new ot().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ot,e,r)}};a(ot,"runtime",u),a(ot,"typeName","yorkie.v1.JSONElement"),a(ot,"fields",u.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Rn,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Ln,oneof:"body"},{no:3,name:"primitive",kind:"message",T:Jn,oneof:"body"},{no:5,name:"text",kind:"message",T:Fn,oneof:"body"},{no:6,name:"counter",kind:"message",T:Mn,oneof:"body"},{no:7,name:"tree",kind:"message",T:$n,oneof:"body"}]));let se=ot;const at=class at extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new at().fromBinary(e,r)}static fromJson(e,r){return new at().fromJson(e,r)}static fromJsonString(e,r){return new at().fromJsonString(e,r)}static equals(e,r){return u.util.equals(at,e,r)}};a(at,"runtime",u),a(at,"typeName","yorkie.v1.JSONElement.JSONObject"),a(at,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:No,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Rn=at;const ct=class ct extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ct().fromBinary(e,r)}static fromJson(e,r){return new ct().fromJson(e,r)}static fromJsonString(e,r){return new ct().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ct,e,r)}};a(ct,"runtime",u),a(ct,"typeName","yorkie.v1.JSONElement.JSONArray"),a(ct,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Un,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Ln=ct;const ut=class ut extends A{constructor(e){super();a(this,"type",0);a(this,"value",new Uint8Array(0));a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ut().fromBinary(e,r)}static fromJson(e,r){return new ut().fromJson(e,r)}static fromJsonString(e,r){return new ut().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ut,e,r)}};a(ut,"runtime",u),a(ut,"typeName","yorkie.v1.JSONElement.Primitive"),a(ut,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(N)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"moved_at",kind:"message",T:I},{no:5,name:"removed_at",kind:"message",T:I}]));let Jn=ut;const lt=class lt extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new lt().fromBinary(e,r)}static fromJson(e,r){return new lt().fromJson(e,r)}static fromJsonString(e,r){return new lt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(lt,e,r)}};a(lt,"runtime",u),a(lt,"typeName","yorkie.v1.JSONElement.Text"),a(lt,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:qn,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Fn=lt;const ht=class ht extends A{constructor(e){super();a(this,"type",0);a(this,"value",new Uint8Array(0));a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ht().fromBinary(e,r)}static fromJson(e,r){return new ht().fromJson(e,r)}static fromJsonString(e,r){return new ht().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ht,e,r)}};a(ht,"runtime",u),a(ht,"typeName","yorkie.v1.JSONElement.Counter"),a(ht,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(N)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"moved_at",kind:"message",T:I},{no:5,name:"removed_at",kind:"message",T:I}]));let Mn=ht;const ft=class ft extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ft().fromBinary(e,r)}static fromJson(e,r){return new ft().fromJson(e,r)}static fromJsonString(e,r){return new ft().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ft,e,r)}};a(ft,"runtime",u),a(ft,"typeName","yorkie.v1.JSONElement.Tree"),a(ft,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Xr,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let $n=ft;var pe;let No=(pe=class extends A{constructor(e){super();a(this,"key","");a(this,"element");u.util.initPartial(e,this)}static fromBinary(e,r){return new pe().fromBinary(e,r)}static fromJson(e,r){return new pe().fromJson(e,r)}static fromJsonString(e,r){return new pe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(pe,e,r)}},a(pe,"runtime",u),a(pe,"typeName","yorkie.v1.RHTNode"),a(pe,"fields",u.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:se}])),pe);const Oe=class Oe extends A{constructor(e){super();a(this,"next");a(this,"element");u.util.initPartial(e,this)}static fromBinary(e,r){return new Oe().fromBinary(e,r)}static fromJson(e,r){return new Oe().fromJson(e,r)}static fromJsonString(e,r){return new Oe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Oe,e,r)}};a(Oe,"runtime",u),a(Oe,"typeName","yorkie.v1.RGANode"),a(Oe,"fields",u.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Oe},{no:2,name:"element",kind:"message",T:se}]));let Un=Oe;const dt=class dt extends A{constructor(e){super();a(this,"value","");a(this,"updatedAt");a(this,"isRemoved",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new dt().fromBinary(e,r)}static fromJson(e,r){return new dt().fromJson(e,r)}static fromJsonString(e,r){return new dt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(dt,e,r)}};a(dt,"runtime",u),a(dt,"typeName","yorkie.v1.NodeAttr"),a(dt,"fields",u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:I},{no:3,name:"is_removed",kind:"scalar",T:8}]));let Rr=dt;const gt=class gt extends A{constructor(e){super();a(this,"id");a(this,"value","");a(this,"removedAt");a(this,"insPrevId");a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new gt().fromBinary(e,r)}static fromJson(e,r){return new gt().fromJson(e,r)}static fromJsonString(e,r){return new gt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(gt,e,r)}};a(gt,"runtime",u),a(gt,"typeName","yorkie.v1.TextNode"),a(gt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Yr},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:I},{no:4,name:"ins_prev_id",kind:"message",T:Yr},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Rr}}]));let qn=gt;const mt=class mt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new mt().fromBinary(e,r)}static fromJson(e,r){return new mt().fromJson(e,r)}static fromJsonString(e,r){return new mt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(mt,e,r)}};a(mt,"runtime",u),a(mt,"typeName","yorkie.v1.TextNodeID"),a(mt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5}]));let Yr=mt;const pt=class pt extends A{constructor(e){super();a(this,"id");a(this,"type","");a(this,"value","");a(this,"removedAt");a(this,"insPrevId");a(this,"insNextId");a(this,"depth",0);a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new pt().fromBinary(e,r)}static fromJson(e,r){return new pt().fromJson(e,r)}static fromJsonString(e,r){return new pt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(pt,e,r)}};a(pt,"runtime",u),a(pt,"typeName","yorkie.v1.TreeNode"),a(pt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:or},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:I},{no:5,name:"ins_prev_id",kind:"message",T:or},{no:6,name:"ins_next_id",kind:"message",T:or},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Rr}}]));let Xr=pt;const yt=class yt extends A{constructor(e){super();a(this,"content",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new yt().fromBinary(e,r)}static fromJson(e,r){return new yt().fromJson(e,r)}static fromJsonString(e,r){return new yt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(yt,e,r)}};a(yt,"runtime",u),a(yt,"typeName","yorkie.v1.TreeNodes"),a(yt,"fields",u.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:Xr,repeated:!0}]));let zn=yt;const vt=class vt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new vt().fromBinary(e,r)}static fromJson(e,r){return new vt().fromJson(e,r)}static fromJsonString(e,r){return new vt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(vt,e,r)}};a(vt,"runtime",u),a(vt,"typeName","yorkie.v1.TreeNodeID"),a(vt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5}]));let or=vt;const wt=class wt extends A{constructor(e){super();a(this,"parentId");a(this,"leftSiblingId");u.util.initPartial(e,this)}static fromBinary(e,r){return new wt().fromBinary(e,r)}static fromJson(e,r){return new wt().fromJson(e,r)}static fromJsonString(e,r){return new wt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(wt,e,r)}};a(wt,"runtime",u),a(wt,"typeName","yorkie.v1.TreePos"),a(wt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:or},{no:2,name:"left_sibling_id",kind:"message",T:or}]));let vr=wt;const Tt=class Tt extends A{constructor(e){super();a(this,"id","");a(this,"username","");a(this,"createdAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Tt().fromBinary(e,r)}static fromJson(e,r){return new Tt().fromJson(e,r)}static fromJsonString(e,r){return new Tt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Tt,e,r)}};a(Tt,"runtime",u),a(Tt,"typeName","yorkie.v1.User"),a(Tt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Q}]));let Li=Tt;const At=class At extends A{constructor(e){super();a(this,"id","");a(this,"name","");a(this,"publicKey","");a(this,"secretKey","");a(this,"authWebhookUrl","");a(this,"authWebhookMethods",[]);a(this,"clientDeactivateThreshold","");a(this,"createdAt");a(this,"updatedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new At().fromBinary(e,r)}static fromJson(e,r){return new At().fromJson(e,r)}static fromJsonString(e,r){return new At().fromJsonString(e,r)}static equals(e,r){return u.util.equals(At,e,r)}};a(At,"runtime",u),a(At,"typeName","yorkie.v1.Project"),a(At,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Q},{no:9,name:"updated_at",kind:"message",T:Q}]));let Ji=At;const bt=class bt extends A{constructor(e){super();a(this,"name");a(this,"authWebhookUrl");a(this,"authWebhookMethods");a(this,"clientDeactivateThreshold");u.util.initPartial(e,this)}static fromBinary(e,r){return new bt().fromBinary(e,r)}static fromJson(e,r){return new bt().fromJson(e,r)}static fromJsonString(e,r){return new bt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(bt,e,r)}};a(bt,"runtime",u),a(bt,"typeName","yorkie.v1.UpdatableProjectFields"),a(bt,"fields",u.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:ie},{no:2,name:"auth_webhook_url",kind:"message",T:ie},{no:3,name:"auth_webhook_methods",kind:"message",T:ps},{no:4,name:"client_deactivate_threshold",kind:"message",T:ie}]));let Fi=bt;const It=class It extends A{constructor(e){super();a(this,"methods",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new It().fromBinary(e,r)}static fromJson(e,r){return new It().fromJson(e,r)}static fromJsonString(e,r){return new It().fromJsonString(e,r)}static equals(e,r){return u.util.equals(It,e,r)}};a(It,"runtime",u),a(It,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),a(It,"fields",u.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let ps=It;const St=class St extends A{constructor(e){super();a(this,"id","");a(this,"key","");a(this,"snapshot","");a(this,"createdAt");a(this,"accessedAt");a(this,"updatedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new St().fromBinary(e,r)}static fromJson(e,r){return new St().fromJson(e,r)}static fromJsonString(e,r){return new St().fromJsonString(e,r)}static equals(e,r){return u.util.equals(St,e,r)}};a(St,"runtime",u),a(St,"typeName","yorkie.v1.DocumentSummary"),a(St,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Q},{no:5,name:"accessed_at",kind:"message",T:Q},{no:6,name:"updated_at",kind:"message",T:Q}]));let Mi=St;const kt=class kt extends A{constructor(e){super();a(this,"type",0);a(this,"presence");u.util.initPartial(e,this)}static fromBinary(e,r){return new kt().fromBinary(e,r)}static fromJson(e,r){return new kt().fromJson(e,r)}static fromJsonString(e,r){return new kt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(kt,e,r)}};a(kt,"runtime",u),a(kt,"typeName","yorkie.v1.PresenceChange"),a(kt,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(wr)},{no:2,name:"presence",kind:"message",T:Ks}]));let Zr=kt;var wr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(wr||{});u.util.setEnumType(wr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var ye;let Ks=(ye=class extends A{constructor(e){super();a(this,"data",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new ye().fromBinary(e,r)}static fromJson(e,r){return new ye().fromJson(e,r)}static fromJsonString(e,r){return new ye().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ye,e,r)}},a(ye,"runtime",u),a(ye,"typeName","yorkie.v1.Presence"),a(ye,"fields",u.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),ye);var ve;let Co=(ve=class extends A{constructor(e){super();a(this,"serverSeq",$.zero);a(this,"clientSeq",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new ve().fromBinary(e,r)}static fromJson(e,r){return new ve().fromJson(e,r)}static fromJsonString(e,r){return new ve().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ve,e,r)}},a(ve,"runtime",u),a(ve,"typeName","yorkie.v1.Checkpoint"),a(ve,"fields",u.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),ve);const xt=class xt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);a(this,"relativeOffset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new xt().fromBinary(e,r)}static fromJson(e,r){return new xt().fromJson(e,r)}static fromJsonString(e,r){return new xt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(xt,e,r)}};a(xt,"runtime",u),a(xt,"typeName","yorkie.v1.TextNodePos"),a(xt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let _t=xt;var we;let I=(we=class extends A{constructor(e){super();a(this,"lamport",$.zero);a(this,"delimiter",0);a(this,"actorId",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new we().fromBinary(e,r)}static fromJson(e,r){return new we().fromJson(e,r)}static fromJsonString(e,r){return new we().fromJsonString(e,r)}static equals(e,r){return u.util.equals(we,e,r)}},a(we,"runtime",u),a(we,"typeName","yorkie.v1.TimeTicket"),a(we,"fields",u.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),we);const Et=class Et extends A{constructor(e){super();a(this,"topic","");a(this,"payload",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new Et().fromBinary(e,r)}static fromJson(e,r){return new Et().fromJson(e,r)}static fromJsonString(e,r){return new Et().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Et,e,r)}};a(Et,"runtime",u),a(Et,"typeName","yorkie.v1.DocEventBody"),a(Et,"fields",u.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let ys=Et;const Nt=class Nt extends A{constructor(e){super();a(this,"type",0);a(this,"publisher","");a(this,"body");u.util.initPartial(e,this)}static fromBinary(e,r){return new Nt().fromBinary(e,r)}static fromJson(e,r){return new Nt().fromJson(e,r)}static fromJsonString(e,r){return new Nt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Nt,e,r)}};a(Nt,"runtime",u),a(Nt,"typeName","yorkie.v1.DocEvent"),a(Nt,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(yr)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:ys}]));let vs=Nt;const Ct=class Ct extends A{constructor(e){super();a(this,"clientKey","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ct().fromBinary(e,r)}static fromJson(e,r){return new Ct().fromJson(e,r)}static fromJsonString(e,r){return new Ct().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ct,e,r)}};a(Ct,"runtime",u),a(Ct,"typeName","yorkie.v1.ActivateClientRequest"),a(Ct,"fields",u.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let ws=Ct;const Pt=class Pt extends A{constructor(e){super();a(this,"clientId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Pt().fromBinary(e,r)}static fromJson(e,r){return new Pt().fromJson(e,r)}static fromJsonString(e,r){return new Pt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Pt,e,r)}};a(Pt,"runtime",u),a(Pt,"typeName","yorkie.v1.ActivateClientResponse"),a(Pt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Ts=Pt;const Dt=class Dt extends A{constructor(e){super();a(this,"clientId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Dt().fromBinary(e,r)}static fromJson(e,r){return new Dt().fromJson(e,r)}static fromJsonString(e,r){return new Dt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Dt,e,r)}};a(Dt,"runtime",u),a(Dt,"typeName","yorkie.v1.DeactivateClientRequest"),a(Dt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let As=Dt;const Ot=class Ot extends A{constructor(t){super(),u.util.initPartial(t,this)}static fromBinary(t,e){return new Ot().fromBinary(t,e)}static fromJson(t,e){return new Ot().fromJson(t,e)}static fromJsonString(t,e){return new Ot().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ot,t,e)}};a(Ot,"runtime",u),a(Ot,"typeName","yorkie.v1.DeactivateClientResponse"),a(Ot,"fields",u.util.newFieldList(()=>[]));let bs=Ot;const Bt=class Bt extends A{constructor(e){super();a(this,"clientId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Bt().fromBinary(e,r)}static fromJson(e,r){return new Bt().fromJson(e,r)}static fromJsonString(e,r){return new Bt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Bt,e,r)}};a(Bt,"runtime",u),a(Bt,"typeName","yorkie.v1.AttachDocumentRequest"),a(Bt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:tr}]));let Is=Bt;const Rt=class Rt extends A{constructor(e){super();a(this,"documentId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Rt().fromBinary(e,r)}static fromJson(e,r){return new Rt().fromJson(e,r)}static fromJsonString(e,r){return new Rt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Rt,e,r)}};a(Rt,"runtime",u),a(Rt,"typeName","yorkie.v1.AttachDocumentResponse"),a(Rt,"fields",u.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:tr}]));let Ss=Rt;const Lt=class Lt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");a(this,"removeIfNotAttached",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new Lt().fromBinary(e,r)}static fromJson(e,r){return new Lt().fromJson(e,r)}static fromJsonString(e,r){return new Lt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Lt,e,r)}};a(Lt,"runtime",u),a(Lt,"typeName","yorkie.v1.DetachDocumentRequest"),a(Lt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let ks=Lt;const Jt=class Jt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Jt().fromBinary(e,r)}static fromJson(e,r){return new Jt().fromJson(e,r)}static fromJsonString(e,r){return new Jt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Jt,e,r)}};a(Jt,"runtime",u),a(Jt,"typeName","yorkie.v1.DetachDocumentResponse"),a(Jt,"fields",u.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:tr}]));let xs=Jt;const Ft=class Ft extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ft().fromBinary(e,r)}static fromJson(e,r){return new Ft().fromJson(e,r)}static fromJsonString(e,r){return new Ft().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ft,e,r)}};a(Ft,"runtime",u),a(Ft,"typeName","yorkie.v1.WatchDocumentRequest"),a(Ft,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Es=Ft;const Mt=class Mt extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new Mt().fromBinary(e,r)}static fromJson(e,r){return new Mt().fromJson(e,r)}static fromJsonString(e,r){return new Mt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Mt,e,r)}};a(Mt,"runtime",u),a(Mt,"typeName","yorkie.v1.WatchDocumentResponse"),a(Mt,"fields",u.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Cs,oneof:"body"},{no:2,name:"event",kind:"message",T:vs,oneof:"body"}]));let Ns=Mt;const $t=class $t extends A{constructor(e){super();a(this,"clientIds",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new $t().fromBinary(e,r)}static fromJson(e,r){return new $t().fromJson(e,r)}static fromJsonString(e,r){return new $t().fromJsonString(e,r)}static equals(e,r){return u.util.equals($t,e,r)}};a($t,"runtime",u),a($t,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),a($t,"fields",u.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Cs=$t;const Ut=class Ut extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ut().fromBinary(e,r)}static fromJson(e,r){return new Ut().fromJson(e,r)}static fromJsonString(e,r){return new Ut().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ut,e,r)}};a(Ut,"runtime",u),a(Ut,"typeName","yorkie.v1.RemoveDocumentRequest"),a(Ut,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr}]));let Ps=Ut;const qt=class qt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new qt().fromBinary(e,r)}static fromJson(e,r){return new qt().fromJson(e,r)}static fromJsonString(e,r){return new qt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(qt,e,r)}};a(qt,"runtime",u),a(qt,"typeName","yorkie.v1.RemoveDocumentResponse"),a(qt,"fields",u.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:tr}]));let Ds=qt;const zt=class zt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");a(this,"pushOnly",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new zt().fromBinary(e,r)}static fromJson(e,r){return new zt().fromJson(e,r)}static fromJsonString(e,r){return new zt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(zt,e,r)}};a(zt,"runtime",u),a(zt,"typeName","yorkie.v1.PushPullChangesRequest"),a(zt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr},{no:4,name:"push_only",kind:"scalar",T:8}]));let Os=zt;const Vt=class Vt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Vt().fromBinary(e,r)}static fromJson(e,r){return new Vt().fromJson(e,r)}static fromJsonString(e,r){return new Vt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Vt,e,r)}};a(Vt,"runtime",u),a(Vt,"typeName","yorkie.v1.PushPullChangesResponse"),a(Vt,"fields",u.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:tr}]));let Bs=Vt;const Kt=class Kt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"topic","");a(this,"payload",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new Kt().fromBinary(e,r)}static fromJson(e,r){return new Kt().fromJson(e,r)}static fromJsonString(e,r){return new Kt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Kt,e,r)}};a(Kt,"runtime",u),a(Kt,"typeName","yorkie.v1.BroadcastRequest"),a(Kt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Rs=Kt;const jt=class jt extends A{constructor(t){super(),u.util.initPartial(t,this)}static fromBinary(t,e){return new jt().fromBinary(t,e)}static fromJson(t,e){return new jt().fromJson(t,e)}static fromJsonString(t,e){return new jt().fromJsonString(t,e)}static equals(t,e){return u.util.equals(jt,t,e)}};a(jt,"runtime",u),a(jt,"typeName","yorkie.v1.BroadcastResponse"),a(jt,"fields",u.util.newFieldList(()=>[]));let Ls=jt;const Bc={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:ws,O:Ts,kind:ee.Unary},deactivateClient:{name:"DeactivateClient",I:As,O:bs,kind:ee.Unary},attachDocument:{name:"AttachDocument",I:Is,O:Ss,kind:ee.Unary},detachDocument:{name:"DetachDocument",I:ks,O:xs,kind:ee.Unary},removeDocument:{name:"RemoveDocument",I:Ps,O:Ds,kind:ee.Unary},pushPullChanges:{name:"PushPullChanges",I:Os,O:Bs,kind:ee.Unary},watchDocument:{name:"WatchDocument",I:Es,O:Ns,kind:ee.ServerStreaming},broadcast:{name:"Broadcast",I:Rs,O:Ls,kind:ee.Unary}}},Rc=u.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);u.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Ht}]);u.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:Lc,repeated:!0}]);const Lc=u.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});u.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:Jc,repeated:!0}]);const Jc=u.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});u.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:Fc,repeated:!0}]);const Fc=u.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});u.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Mc,repeated:!0}]);const Mc=u.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});u.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var d=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(d||{});class m extends Error{constructor(e,r){super(r);a(this,"name","YorkieError");a(this,"stack");this.code=e,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function ke(n){if(n instanceof Map){const t=Array.from(n);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(n))}const Po=n=>n?Object.entries(n).length===0:!0,Lr=n=>{const t={};for(const[e,r]of Object.entries(n))t[e]=JSON.stringify(r);return t},Cr=n=>{const t={};for(const[e,r]of Object.entries(n))t[e]=JSON.parse(r);return t};var lr=(n=>(n.Put="put",n.Clear="clear",n))(lr||{});class is{constructor(t,e){a(this,"context");a(this,"presence");this.context=t,this.presence=e}set(t,e){for(const r of Object.keys(t))this.presence[r]=t[r];this.context.setPresenceChange({type:"put",presence:ke(this.presence)}),this.context.setReversePresence(t,e)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const js="000000000000000000000000";class be{constructor(t,e,r){a(this,"lamport");a(this,"delimiter");a(this,"actorID");this.lamport=t,this.delimiter=e,this.actorID=r}static of(t,e,r){return new be(t,e,r)}static fromStruct(t){return be.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new be(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const e=this.actorID.localeCompare(t.actorID);return e!==0?e:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const Do=0,jr=9223372036854775807n,Ne=new be(0n,Do,js);function Ve(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` +var la=Object.defineProperty;var ha=(n,t,e)=>t in n?la(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var a=(n,t,e)=>ha(n,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function e(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=e(s);fetch(s.href,i)}})();var R;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(R||(R={}));function ci(n){const t=R[n];return typeof t!="string"?n.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>"_"+e.toLowerCase())}class M extends Error{constructor(t,e=R.Unknown,r,s,i){super(fa(t,e)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=e,this.metadata=new Headers(r??{}),this.details=s??[],this.cause=i}static from(t,e=R.Unknown){return t instanceof M?t:t instanceof Error?t.name=="AbortError"?new M(t.message,R.Canceled):new M(t.message,e,void 0,void 0,t):new M(String(t),e,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===M.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const e="typeName"in t?{findMessage:s=>s===t.typeName?t:void 0}:t,r=[];for(const s of this.details){if("getType"in s){e.findMessage(s.getType().typeName)&&r.push(s);continue}const i=e.findMessage(s.type);if(i)try{r.push(i.fromBinary(s.value))}catch{}}return r}}function fa(n,t){return n.length?`[${ci(t)}] ${n}`:`[${ci(t)}]`}function z(n,t){if(!n)throw new Error(t)}const da=34028234663852886e22,ga=-34028234663852886e22,ma=4294967295,pa=2147483647,ya=-2147483648;function pn(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>pa||nma||n<0)throw new Error("invalid uint 32: "+n)}function eo(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>da||n({no:s.no,name:s.name,localName:n[s.no]})))}function no(n,t,e){const r=Object.create(null),s=Object.create(null),i=[];for(const o of t){const c=so(o);i.push(c),r[o.name]=c,s[o.no]=c}return{typeName:n,values:i,findName(o){return r[o]},findNumber(o){return s[o]}}}function wa(n,t,e){const r={};for(const s of t){const i=so(s);r[i.localName]=i.no,r[i.no]=i.localName}return ro(r,n,t),r}function so(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class A{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,e){const r=this.getType(),s=r.runtime.bin,i=s.makeReadOptions(e);return s.readMessage(this,i.readerFactory(t),t.byteLength,i),this}fromJson(t,e){const r=this.getType(),s=r.runtime.json,i=s.makeReadOptions(e);return s.readMessage(r,t,i,this),this}fromJsonString(t,e){let r;try{r=JSON.parse(t)}catch(s){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${s instanceof Error?s.message:String(s)}`)}return this.fromJson(r,e)}toBinary(t){const e=this.getType(),r=e.runtime.bin,s=r.makeWriteOptions(t),i=s.writerFactory();return r.writeMessage(this,i,s),i.finish()}toJson(t){const e=this.getType(),r=e.runtime.json,s=r.makeWriteOptions(t);return r.writeMessage(this,s)}toJsonString(t){var e;const r=this.toJson(t);return JSON.stringify(r,null,(e=t==null?void 0:t.prettySpaces)!==null&&e!==void 0?e:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Ta(n,t,e,r){var s;const i=(s=r==null?void 0:r.localName)!==null&&s!==void 0?s:t.substring(t.lastIndexOf(".")+1),o={[i]:function(c){n.util.initFields(this),n.util.initPartial(c,this)}}[i];return Object.setPrototypeOf(o.prototype,new A),Object.assign(o,{runtime:n,typeName:t,fields:n.util.newFieldList(e),fromBinary(c,l){return new o().fromBinary(c,l)},fromJson(c,l){return new o().fromJson(c,l)},fromJsonString(c,l){return new o().fromJsonString(c,l)},equals(c,l){return n.util.equals(o,c,l)}}),o}function Aa(){let n=0,t=0;for(let r=0;r<28;r+=7){let s=this.buf[this.pos++];if(n|=(s&127)<>4,!(e&128))return this.assertBounds(),[n,t];for(let r=3;r<=31;r+=7){let s=this.buf[this.pos++];if(t|=(s&127)<>>i,c=!(!(o>>>7)&&t==0),l=(c?o|128:o)&255;if(e.push(l),!c)return}const r=n>>>28&15|(t&7)<<4,s=!!(t>>3);if(e.push((s?r|128:r)&255),!!s){for(let i=3;i<31;i=i+7){const o=t>>>i,c=!!(o>>>7),l=(c?o|128:o)&255;if(e.push(l),!c)return}e.push(t>>>31&1)}}const yn=4294967296;function ui(n){const t=n[0]==="-";t&&(n=n.slice(1));const e=1e6;let r=0,s=0;function i(o,c){const l=Number(n.slice(o,c));s*=e,r=r*e+l,r>=yn&&(s=s+(r/yn|0),r=r%yn)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),t?oo(r,s):zs(r,s)}function ba(n,t){let e=zs(n,t);const r=e.hi&2147483648;r&&(e=oo(e.lo,e.hi));const s=io(e.lo,e.hi);return r?"-"+s:s}function io(n,t){if({lo:n,hi:t}=Ia(n,t),t<=2097151)return String(yn*t+n);const e=n&16777215,r=(n>>>24|t<<8)&16777215,s=t>>16&65535;let i=e+r*6777216+s*6710656,o=r+s*8147497,c=s*2;const l=1e7;return i>=l&&(o+=Math.floor(i/l),i%=l),o>=l&&(c+=Math.floor(o/l),o%=l),c.toString()+li(o)+li(i)}function Ia(n,t){return{lo:n>>>0,hi:t>>>0}}function zs(n,t){return{lo:n|0,hi:t|0}}function oo(n,t){return t=~t,n?n=~n+1:t+=1,zs(n,t)}const li=n=>{const t=String(n);return"0000000".slice(t.length)+t};function hi(n,t){if(n>=0){for(;n>127;)t.push(n&127|128),n=n>>>7;t.push(n)}else{for(let e=0;e<9;e++)t.push(n&127|128),n=n>>7;t.push(1)}}function Sa(){let n=this.buf[this.pos++],t=n&127;if(!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<7,!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<14,!(n&128))return this.assertBounds(),t;if(n=this.buf[this.pos++],t|=(n&127)<<21,!(n&128))return this.assertBounds(),t;n=this.buf[this.pos++],t|=(n&15)<<28;for(let e=5;n&128&&e<10;e++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var fi={};function ka(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof fi!="object"||fi.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),c=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const h=typeof l=="bigint"?l:BigInt(l);if(h>i||hc||hz(/^-?[0-9]+$/.test(s),`int64 invalid: ${s}`),r=s=>z(/^[0-9]+$/.test(s),`uint64 invalid: ${s}`);return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),e(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),r(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),e(s),ui(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),r(s),ui(s)},dec(s,i){return ba(s,i)},uDec(s,i){return io(s,i)}}}const $=ka();var y;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(y||(y={}));var ur;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(ur||(ur={}));function rr(n,t,e){if(t===e)return!0;if(n==y.BYTES){if(!(t instanceof Uint8Array)||!(e instanceof Uint8Array)||t.length!==e.length)return!1;for(let r=0;r>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(ds(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return pn(t),hi(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){eo(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){ds(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){pn(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return pn(t),t=(t<<1^t>>31)>>>0,hi(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),r=new DataView(e.buffer),s=$.enc(t);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),r=new DataView(e.buffer),s=$.uEnc(t);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(e)}int64(t){let e=$.enc(t);return rs(e.lo,e.hi,this.buf),this}sint64(t){let e=$.enc(t),r=e.hi>>31,s=e.lo<<1^r,i=(e.hi<<1|e.lo>>>31)^r;return rs(s,i,this.buf),this}uint64(t){let e=$.uEnc(t);return rs(e.lo,e.hi,this.buf),this}}class Ea{constructor(t,e){this.varint64=Aa,this.uint32=Sa,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e??new TextDecoder}tag(){let t=this.uint32(),e=t>>>3,r=t&7;if(e<=0||r<0||r>5)throw new Error("illegal tag: field no "+e+" wire type "+r);return[e,r]}skip(t,e){let r=this.pos;switch(t){case G.Varint:for(;this.buf[this.pos++]&128;);break;case G.Bit64:this.pos+=4;case G.Bit32:this.pos+=4;break;case G.LengthDelimited:let s=this.uint32();this.pos+=s;break;case G.StartGroup:for(;;){const[i,o]=this.tag();if(o===G.EndGroup){if(e!==void 0&&i!==e)throw new Error("invalid end group tag");break}this.skip(o,i)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return $.dec(...this.varint64())}uint64(){return $.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),r=-(t&1);return t=(t>>>1|(e&1)<<31)^r,e=e>>>1^r,$.dec(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}}function Na(n,t,e,r){let s;return{typeName:t,extendee:e,get field(){if(!s){const i=typeof r=="function"?r():r;i.name=t.split(".").pop(),i.jsonName=`[${t}]`,s=n.util.newFieldList([i]).list()[0]}return s},runtime:n}}function co(n){const t=n.field.localName,e=Object.create(null);return e[t]=Ca(n),[e,()=>e[t]]}function Ca(n){const t=n.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Or(t.T,t.L);case"message":const e=t.T,r=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Pa(n,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let e=n.length-1;e>=0;--e)if(n[e].no==t.no)return[n[e]];return[]}return n.filter(e=>e.no===t.no)}let Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Wn=[];for(let n=0;n>4,o=i,s=2;break;case 2:e[r++]=(o&15)<<4|(i&60)>>2,o=i,s=3;break;case 3:e[r++]=(o&3)<<6|i,s=0;break}}if(s==1)throw Error("invalid base64 string.");return e.subarray(0,r)},enc(n){let t="",e=0,r,s=0;for(let i=0;i>2],s=(r&3)<<4,e=1;break;case 1:t+=Wt[s|r>>4],s=(r&15)<<2,e=2;break;case 2:t+=Wt[s|r>>6],t+=Wt[r&63],e=0;break}return e&&(t+=Wt[s],t+="=",e==1&&(t+="=")),t}};function Da(n,t,e){lo(t,n);const r=t.runtime.bin.makeReadOptions(e),s=Pa(n.getType().runtime.bin.listUnknownFields(n),t.field),[i,o]=co(t);for(const c of s)t.runtime.bin.readField(i,r.readerFactory(c.data),t.field,c.wireType,r);return o()}function Oa(n,t,e,r){lo(t,n);const s=t.runtime.bin.makeReadOptions(r),i=t.runtime.bin.makeWriteOptions(r);if(uo(n,t)){const h=n.getType().runtime.bin.listUnknownFields(n).filter(f=>f.no!=t.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const f of h)n.getType().runtime.bin.onUnknownField(n,f.no,f.wireType,f.data)}const o=i.writerFactory();let c=t.field;!c.opt&&!c.repeated&&(c.kind=="enum"||c.kind=="scalar")&&(c=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(c,e,o,i);const l=s.readerFactory(o.finish());for(;l.posr.no==t.field.no)}function lo(n,t){z(n.extendee.typeName==t.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function ho(n,t){const e=n.localName;if(n.repeated)return t[e].length>0;if(n.oneof)return t[n.oneof.localName].case===e;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?t[e]!==void 0:n.kind=="enum"?t[e]!==n.T.values[0].no:!ao(n.T,t[e]);case"message":return t[e]!==void 0;case"map":return Object.keys(t[e]).length>0}}function di(n,t){const e=n.localName,r=!n.opt&&!n.req;if(n.repeated)t[e]=[];else if(n.oneof)t[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":t[e]={};break;case"enum":t[e]=r?n.T.values[0].no:void 0;break;case"scalar":t[e]=r?Or(n.T,n.L):void 0;break;case"message":t[e]=void 0;break}}function pr(n,t){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(A.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const e=n.getType();return e===null||typeof e!="function"||!("typeName"in e)||typeof e.typeName!="string"?!1:t===void 0?!0:e.typeName==t.typeName}function fo(n,t){return pr(t)||!n.fieldWrapper?t:n.fieldWrapper.wrapField(t)}y.DOUBLE,y.FLOAT,y.INT64,y.UINT64,y.INT32,y.UINT32,y.BOOL,y.STRING,y.BYTES;const gi={ignoreUnknownFields:!1},mi={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ba(n){return n?Object.assign(Object.assign({},gi),n):gi}function Ra(n){return n?Object.assign(Object.assign({},mi),n):mi}const In=Symbol(),vn=Symbol();function La(){return{makeReadOptions:Ba,makeWriteOptions:Ra,readMessage(n,t,e,r){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Be(t)}`);r=r??new n;const s=new Map,i=e.typeRegistry;for(const[o,c]of Object.entries(t)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(c===null&&l.kind=="scalar")continue;const h=s.get(l.oneof);if(h!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${h}", "${o}"`);s.set(l.oneof,o)}pi(r,c,l,e,n)}else{let h=!1;if(i!=null&&i.findExtension&&o.startsWith("[")&&o.endsWith("]")){const f=i.findExtension(o.substring(1,o.length-1));if(f&&f.extendee.typeName==n.typeName){h=!0;const[g,v]=co(f);pi(g,c,f.field,e,f),Oa(r,f,v(),e)}}if(!h&&!e.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,t){const e=n.getType(),r={};let s;try{for(s of e.fields.byNumber()){if(!ho(s,n)){if(s.req)throw"required field not set";if(!t.emitDefaultValues||!Fa(s))continue}const o=s.oneof?n[s.oneof.localName].value:n[s.localName],c=yi(s,o,t);c!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=c)}const i=t.typeRegistry;if(i!=null&&i.findExtensionFor)for(const o of e.runtime.bin.listUnknownFields(n)){const c=i.findExtensionFor(e.typeName,o.no);if(c&&uo(n,c)){const l=Da(n,c,t),h=yi(c.field,l,t);h!==void 0&&(r[c.field.jsonName]=h)}}}catch(i){const o=s?`cannot encode field ${e.typeName}.${s.name} to JSON`:`cannot encode message ${e.typeName} to JSON`,c=i instanceof Error?i.message:String(i);throw new Error(o+(c.length>0?`: ${c}`:""))}return r},readScalar(n,t,e){return Vr(n,t,e??ur.BIGINT,!0)},writeScalar(n,t,e){if(t!==void 0&&(e||ao(n,t)))return wn(n,t)},debug:Be}}function Be(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function pi(n,t,e,r,s){let i=e.localName;if(e.repeated){if(z(e.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`);const o=n[i];for(const c of t){if(c===null)throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(c)}`);switch(e.kind){case"message":o.push(e.T.fromJson(c,r));break;case"enum":const l=ns(e.T,c,r.ignoreUnknownFields,!0);l!==vn&&o.push(l);break;case"scalar":try{o.push(Vr(e.T,c,e.L,!0))}catch(h){let f=`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(c)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}break}}}else if(e.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`);const o=n[i];for(const[c,l]of Object.entries(t)){if(l===null)throw new Error(`cannot decode field ${s.typeName}.${e.name} from JSON: map value null`);let h;try{h=Ja(e.K,c)}catch(f){let g=`cannot decode map key for field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw f instanceof Error&&f.message.length>0&&(g+=`: ${f.message}`),new Error(g)}switch(e.V.kind){case"message":o[h]=e.V.T.fromJson(l,r);break;case"enum":const f=ns(e.V.T,l,r.ignoreUnknownFields,!0);f!==vn&&(o[h]=f);break;case"scalar":try{o[h]=Vr(e.V.T,l,ur.BIGINT,!0)}catch(g){let v=`cannot decode map value for field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw g instanceof Error&&g.message.length>0&&(v+=`: ${g.message}`),new Error(v)}break}}}else switch(e.oneof&&(n=n[e.oneof.localName]={case:i},i="value"),e.kind){case"message":const o=e.T;if(t===null&&o.typeName!="google.protobuf.Value")return;let c=n[i];pr(c)?c.fromJson(t,r):(n[i]=c=o.fromJson(t,r),o.fieldWrapper&&!e.oneof&&(n[i]=o.fieldWrapper.unwrapField(c)));break;case"enum":const l=ns(e.T,t,r.ignoreUnknownFields,!1);switch(l){case In:di(e,n);break;case vn:break;default:n[i]=l;break}break;case"scalar":try{const h=Vr(e.T,t,e.L,!1);switch(h){case In:di(e,n);break;default:n[i]=h;break}}catch(h){let f=`cannot decode field ${s.typeName}.${e.name} from JSON: ${Be(t)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}break}}function Ja(n,t){if(n===y.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return Vr(n,t,ur.BIGINT,!0).toString()}function Vr(n,t,e,r){if(t===null)return r?Or(n,e):In;switch(n){case y.DOUBLE:case y.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s))break;return n==y.FLOAT&&eo(s),s;case y.INT32:case y.FIXED32:case y.SFIXED32:case y.SINT32:case y.UINT32:let i;if(typeof t=="number"?i=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(i=Number(t)),i===void 0)break;return n==y.UINT32||n==y.FIXED32?ds(i):pn(i),i;case y.INT64:case y.SFIXED64:case y.SINT64:if(typeof t!="number"&&typeof t!="string")break;const o=$.parse(t);return e?o.toString():o;case y.FIXED64:case y.UINT64:if(typeof t!="number"&&typeof t!="string")break;const c=$.uParse(t);return e?c.toString():c;case y.BOOL:if(typeof t!="boolean")break;return t;case y.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case y.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return Vs.dec(t)}throw new Error}function ns(n,t,e,r){if(t===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:In;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const s=n.findName(t);if(s!==void 0)return s.no;if(e)return vn;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Be(t)}`)}function Fa(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function yi(n,t,e){if(n.kind=="map"){z(typeof t=="object"&&t!=null);const r={},s=Object.entries(t);switch(n.V.kind){case"scalar":for(const[o,c]of s)r[o.toString()]=wn(n.V.T,c);break;case"message":for(const[o,c]of s)r[o.toString()]=c.toJson(e);break;case"enum":const i=n.V.T;for(const[o,c]of s)r[o.toString()]=ss(i,c,e.enumAsInteger);break}return e.emitDefaultValues||s.length>0?r:void 0}if(n.repeated){z(Array.isArray(t));const r=[];switch(n.kind){case"scalar":for(let s=0;s0?r:void 0}switch(n.kind){case"scalar":return wn(n.T,t);case"enum":return ss(n.T,t,e.enumAsInteger);case"message":return fo(n.T,t).toJson(e)}}function ss(n,t,e){var r;if(z(typeof t=="number"),n.typeName=="google.protobuf.NullValue")return null;if(e)return t;const s=n.findNumber(t);return(r=s==null?void 0:s.name)!==null&&r!==void 0?r:t}function wn(n,t){switch(n){case y.INT32:case y.SFIXED32:case y.SINT32:case y.FIXED32:case y.UINT32:return z(typeof t=="number"),t;case y.FLOAT:case y.DOUBLE:return z(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case y.STRING:return z(typeof t=="string"),t;case y.BOOL:return z(typeof t=="boolean"),t;case y.UINT64:case y.FIXED64:case y.INT64:case y.SFIXED64:case y.SINT64:return z(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case y.BYTES:return z(t instanceof Uint8Array),Vs.enc(t)}}const Ir=Symbol("@bufbuild/protobuf/unknown-fields"),vi={readUnknownFields:!0,readerFactory:n=>new Ea(n)},wi={writeUnknownFields:!0,writerFactory:()=>new xa};function Ma(n){return n?Object.assign(Object.assign({},vi),n):vi}function $a(n){return n?Object.assign(Object.assign({},wi),n):wi}function Ua(){return{makeReadOptions:Ma,makeWriteOptions:$a,listUnknownFields(n){var t;return(t=n[Ir])!==null&&t!==void 0?t:[]},discardUnknownFields(n){delete n[Ir]},writeUnknownFields(n,t){const r=n[Ir];if(r)for(const s of r)t.tag(s.no,s.wireType).raw(s.data)},onUnknownField(n,t,e,r){const s=n;Array.isArray(s[Ir])||(s[Ir]=[]),s[Ir].push({no:t,wireType:e,data:r})},readMessage(n,t,e,r,s){const i=n.getType(),o=s?t.len:t.pos+e;let c,l;for(;t.pos0&&(l=za),i){let v=n[o];if(r==G.LengthDelimited&&c!=y.STRING&&c!=y.BYTES){let w=t.uint32()+t.pos;for(;t.pospr(v,g)?v:new g(v));else{const v=o[s];g.fieldWrapper?g.typeName==="google.protobuf.BytesValue"?i[s]=Ur(v):i[s]=v:i[s]=pr(v,g)?v:new g(v)}break}}},equals(n,t,e){return t===e?!0:!t||!e?!1:n.fields.byMember().every(r=>{const s=t[r.localName],i=e[r.localName];if(r.repeated){if(s.length!==i.length)return!1;switch(r.kind){case"message":return s.every((o,c)=>r.T.equals(o,i[c]));case"scalar":return s.every((o,c)=>rr(r.T,o,i[c]));case"enum":return s.every((o,c)=>rr(y.INT32,o,i[c]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(s,i);case"enum":return rr(y.INT32,s,i);case"scalar":return rr(r.T,s,i);case"oneof":if(s.case!==i.case)return!1;const o=r.findField(s.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(s.value,i.value);case"enum":return rr(y.INT32,s.value,i.value);case"scalar":return rr(o.T,s.value,i.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const c=Object.keys(s).concat(Object.keys(i));switch(r.V.kind){case"message":const l=r.V.T;return c.every(f=>l.equals(s[f],i[f]));case"enum":return c.every(f=>rr(y.INT32,s[f],i[f]));case"scalar":const h=r.V.T;return c.every(f=>rr(h,s[f],i[f]))}break}})},clone(n){const t=n.getType(),e=new t,r=e;for(const s of t.fields.byMember()){const i=n[s.localName];let o;if(s.repeated)o=i.map(ln);else if(s.kind=="map"){o=r[s.localName];for(const[c,l]of Object.entries(i))o[c]=ln(l)}else s.kind=="oneof"?o=s.findField(i.case)?{case:i.case,value:ln(i.value)}:{case:void 0}:o=ln(i);r[s.localName]=o}for(const s of t.runtime.bin.listUnknownFields(n))t.runtime.bin.onUnknownField(r,s.no,s.wireType,s.data);return e}}}function ln(n){if(n===void 0)return n;if(pr(n))return n.clone();if(n instanceof Uint8Array){const t=new Uint8Array(n.byteLength);return t.set(n),t}return n}function Ur(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function Ga(n,t,e){return{syntax:n,json:La(),bin:Ua(),util:Object.assign(Object.assign({},ja()),{newFieldList:t,initFields:e}),makeMessageType(r,s,i){return Ta(this,r,s,i)},makeEnum:wa,makeEnumType:no,getEnumType:va,makeExtension(r,s,i){return Na(this,r,s,i)}}}class Wa{constructor(t,e){this._fields=t,this._normalizer=e}findJsonName(t){if(!this.jsonNames){const e={};for(const r of this.list())e[r.jsonName]=e[r.name]=r;this.jsonNames=e}return this.jsonNames[t]}find(t){if(!this.numbers){const e={};for(const r of this.list())e[r.no]=r;this.numbers=e}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,e)=>t.no-e.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let e;for(const r of this.list())r.oneof?r.oneof!==e&&(e=r.oneof,t.push(e)):t.push(r)}return this.members}}function mo(n,t){const e=po(n);return t?e:_a(Qa(e))}function Ha(n){return mo(n,!1)}const Ya=po;function po(n){let t=!1;const e=[];for(let r=0;r`${n}$`,Qa=n=>Za.has(n)?yo(n):n,_a=n=>Xa.has(n)?yo(n):n;class ec{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=Ha(t)}addField(t){z(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;enew Wa(n,t=>tc(t)),n=>{for(const t of n.getType().fields.byMember()){if(t.opt)continue;const e=t.localName,r=n;if(t.repeated){r[e]=[];continue}switch(t.kind){case"oneof":r[e]={case:void 0};break;case"enum":r[e]=0;break;case"map":r[e]={};break;case"scalar":r[e]=Or(t.T,t.L);break}}});var ee;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(ee||(ee={}));var Ii;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Ii||(Ii={}));class Q extends A{constructor(t){super(),this.seconds=$.zero,this.nanos=0,u.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${u.json.debug(t)}`);const r=t.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(sDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=$.parse(s/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(t){const e=Number(this.seconds)*1e3;if(eDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const s=(this.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(e).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Q.fromDate(new Date)}static fromDate(t){const e=t.getTime();return new Q({seconds:$.parse(Math.floor(e/1e3)),nanos:e%1e3*1e6})}static fromBinary(t,e){return new Q().fromBinary(t,e)}static fromJson(t,e){return new Q().fromJson(t,e)}static fromJsonString(t,e){return new Q().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Q,t,e)}}Q.runtime=u;Q.typeName="google.protobuf.Timestamp";Q.fields=u.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Ht extends A{constructor(t){super(),this.seconds=$.zero,this.nanos=0,u.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);const r=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);const s=Number(r[1]);if(s>315576e6||s<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${u.json.debug(t)}`);if(this.seconds=$.parse(s),typeof r[2]=="string"){const i=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(i),(s<0||Object.is(s,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let e=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),e+="."+r,this.nanos<0&&Number(this.seconds)==0&&(e="-"+e)}return e+"s"}static fromBinary(t,e){return new Ht().fromBinary(t,e)}static fromJson(t,e){return new Ht().fromJson(t,e)}static fromJsonString(t,e){return new Ht().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ht,t,e)}}Ht.runtime=u;Ht.typeName="google.protobuf.Duration";Ht.fields=u.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Re extends A{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),u.util.initPartial(t,this)}toJson(t){var e;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),s=(e=t==null?void 0:t.typeRegistry)===null||e===void 0?void 0:e.findMessage(r);if(!s)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=s.fromBinary(this.value).toJson(t);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(t,e){var r;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const s=t["@type"];if(typeof s!="string"||s=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const i=this.typeUrlToName(s),o=(r=e==null?void 0:e.typeRegistry)===null||r===void 0?void 0:r.findMessage(i);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${s} is not in the type registry`);let c;if(i.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))c=o.fromJson(t.value,e);else{const l=Object.assign({},t);delete l["@type"],c=o.fromJson(l,e)}return this.packFrom(c),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const e=t.findMessage(this.typeUrlToName(this.typeUrl));if(e)return e.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const e=this.typeUrlToName(this.typeUrl);let r="";return typeof t=="string"?r=t:r=t.typeName,e===r}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const e=t.lastIndexOf("/"),r=e>=0?t.substring(e+1):t;if(!r.length)throw new Error(`invalid type url: ${t}`);return r}static pack(t){const e=new Re;return e.packFrom(t),e}static fromBinary(t,e){return new Re().fromBinary(t,e)}static fromJson(t,e){return new Re().fromJson(t,e)}static fromJsonString(t,e){return new Re().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Re,t,e)}}Re.runtime=u;Re.typeName="google.protobuf.Any";Re.fields=u.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Le extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.DOUBLE,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.DOUBLE,t)}catch(r){let s='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Le().fromBinary(t,e)}static fromJson(t,e){return new Le().fromJson(t,e)}static fromJsonString(t,e){return new Le().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Le,t,e)}}Le.runtime=u;Le.typeName="google.protobuf.DoubleValue";Le.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Le.fieldWrapper={wrapField(n){return new Le({value:n})},unwrapField(n){return n.value}};class Je extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.FLOAT,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.FLOAT,t)}catch(r){let s='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Je().fromBinary(t,e)}static fromJson(t,e){return new Je().fromJson(t,e)}static fromJsonString(t,e){return new Je().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Je,t,e)}}Je.runtime=u;Je.typeName="google.protobuf.FloatValue";Je.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Je.fieldWrapper={wrapField(n){return new Je({value:n})},unwrapField(n){return n.value}};class Fe extends A{constructor(t){super(),this.value=$.zero,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.INT64,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.INT64,t)}catch(r){let s='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Fe().fromBinary(t,e)}static fromJson(t,e){return new Fe().fromJson(t,e)}static fromJsonString(t,e){return new Fe().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Fe,t,e)}}Fe.runtime=u;Fe.typeName="google.protobuf.Int64Value";Fe.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Fe.fieldWrapper={wrapField(n){return new Fe({value:n})},unwrapField(n){return n.value}};class Me extends A{constructor(t){super(),this.value=$.zero,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.UINT64,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.UINT64,t)}catch(r){let s='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Me().fromBinary(t,e)}static fromJson(t,e){return new Me().fromJson(t,e)}static fromJsonString(t,e){return new Me().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Me,t,e)}}Me.runtime=u;Me.typeName="google.protobuf.UInt64Value";Me.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Me.fieldWrapper={wrapField(n){return new Me({value:n})},unwrapField(n){return n.value}};class $e extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.INT32,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.INT32,t)}catch(r){let s='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new $e().fromBinary(t,e)}static fromJson(t,e){return new $e().fromJson(t,e)}static fromJsonString(t,e){return new $e().fromJsonString(t,e)}static equals(t,e){return u.util.equals($e,t,e)}}$e.runtime=u;$e.typeName="google.protobuf.Int32Value";$e.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);$e.fieldWrapper={wrapField(n){return new $e({value:n})},unwrapField(n){return n.value}};class Ue extends A{constructor(t){super(),this.value=0,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.UINT32,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.UINT32,t)}catch(r){let s='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new Ue().fromBinary(t,e)}static fromJson(t,e){return new Ue().fromJson(t,e)}static fromJsonString(t,e){return new Ue().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ue,t,e)}}Ue.runtime=u;Ue.typeName="google.protobuf.UInt32Value";Ue.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Ue.fieldWrapper={wrapField(n){return new Ue({value:n})},unwrapField(n){return n.value}};class qe extends A{constructor(t){super(),this.value=!1,u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.BOOL,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.BOOL,t)}catch(r){let s='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new qe().fromBinary(t,e)}static fromJson(t,e){return new qe().fromJson(t,e)}static fromJsonString(t,e){return new qe().fromJsonString(t,e)}static equals(t,e){return u.util.equals(qe,t,e)}}qe.runtime=u;qe.typeName="google.protobuf.BoolValue";qe.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);qe.fieldWrapper={wrapField(n){return new qe({value:n})},unwrapField(n){return n.value}};class ie extends A{constructor(t){super(),this.value="",u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.STRING,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.STRING,t)}catch(r){let s='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new ie().fromBinary(t,e)}static fromJson(t,e){return new ie().fromJson(t,e)}static fromJsonString(t,e){return new ie().fromJsonString(t,e)}static equals(t,e){return u.util.equals(ie,t,e)}}ie.runtime=u;ie.typeName="google.protobuf.StringValue";ie.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);ie.fieldWrapper={wrapField(n){return new ie({value:n})},unwrapField(n){return n.value}};class ze extends A{constructor(t){super(),this.value=new Uint8Array(0),u.util.initPartial(t,this)}toJson(t){return u.json.writeScalar(y.BYTES,this.value,!0)}fromJson(t,e){try{this.value=u.json.readScalar(y.BYTES,t)}catch(r){let s='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(t,e){return new ze().fromBinary(t,e)}static fromJson(t,e){return new ze().fromJson(t,e)}static fromJsonString(t,e){return new ze().fromJsonString(t,e)}static equals(t,e){return u.util.equals(ze,t,e)}}ze.runtime=u;ze.typeName="google.protobuf.BytesValue";ze.fields=u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);ze.fieldWrapper={wrapField(n){return new ze({value:n})},unwrapField(n){return n.value}};function rc(n,t,e){try{const r=Vs.dec(n);return t?t.fromBinary(r,e):r}catch(r){throw M.from(r,R.DataLoss)}}function nc(n,t){const e={};for(const[r,s]of Object.entries(n.methods)){const i=t(Object.assign(Object.assign({},s),{localName:r,service:n}));i!=null&&(e[r]=i)}return e}function Si(n){let t,e=new Uint8Array(0);function r(s){const i=new Uint8Array(e.length+s.length);i.set(e),i.set(s,e.length),e=i}return new ReadableStream({start(){t=n.getReader()},async pull(s){let i;for(;;){if(i===void 0&&e.byteLength>=5){let l=0;for(let h=1;h<5;h++)l=(l<<8)+e[h];i={flags:e[0],length:l}}if(i!==void 0&&e.byteLength>=i.length+5)break;const c=await t.read();if(c.done)break;r(c.value)}if(i===void 0){if(e.byteLength==0){s.close();return}s.error(new M("premature end of stream",R.DataLoss));return}const o=e.subarray(5,5+i.length);e=e.subarray(5+i.length),s.enqueue({flags:i.flags,data:o})}})}function ki(n,t){const e=new Uint8Array(t.length+5);e.set(t,5);const r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.setUint8(0,n),r.setUint32(1,t.length),e}var sc=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(c,l){o=n[i](o),s(c,l,o.done,o.value)})}}function s(i,o,c,l){Promise.resolve(l).then(function(h){i({value:h,done:c})},o)}},Hr=function(n){return this instanceof Hr?(this.v=n,this):new Hr(n)},ic=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof Hr?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}},oc=function(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:Hr(n[s](o)),done:!1}:i?i(o):o}:i}};function ac(n){return ic(this,arguments,function*(){yield Hr(yield*oc(sc(n)))})}var vo=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(i){e[i]=n[i]&&function(o){return new Promise(function(c,l){o=n[i](o),s(c,l,o.done,o.value)})}}function s(i,o,c,l){Promise.resolve(l).then(function(h){i({value:h,done:c})},o)}},Br=function(n){return this instanceof Br?(this.v=n,this):new Br(n)},cc=function(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,i){t[s]=n[s]?function(o){return(e=!e)?{value:Br(n[s](o)),done:!1}:i?i(o):o}:i}},uc=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof Br?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}};function lc(n,t){return nc(n,e=>{switch(e.kind){case ee.Unary:return hc(t,n,e);case ee.ServerStreaming:return fc(t,n,e);case ee.ClientStreaming:return dc(t,n,e);case ee.BiDiStreaming:return gc(t,n,e);default:return null}})}function hc(n,t,e){return async function(r,s){var i,o;const c=await n.unary(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);return(i=s==null?void 0:s.onHeader)===null||i===void 0||i.call(s,c.header),(o=s==null?void 0:s.onTrailer)===null||o===void 0||o.call(s,c.trailer),c.message}}function fc(n,t,e){return function(r,s){return wo(n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,ac([r]),s==null?void 0:s.contextValues),s)}}function dc(n,t,e){return async function(r,s){var i,o,c,l,h,f;const g=await n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);(h=s==null?void 0:s.onHeader)===null||h===void 0||h.call(s,g.header);let v;try{for(var p=!0,w=vo(g.message),b;b=await w.next(),i=b.done,!i;p=!0)l=b.value,p=!1,v=l}catch(x){o={error:x}}finally{try{!p&&!i&&(c=w.return)&&await c.call(w)}finally{if(o)throw o.error}}if(!v)throw new M("protocol error: missing response message",R.Internal);return(f=s==null?void 0:s.onTrailer)===null||f===void 0||f.call(s,g.trailer),v}}function gc(n,t,e){return function(r,s){return wo(n.stream(t,e,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues),s)}}function wo(n,t){const e=function(){var r,s;return uc(this,arguments,function*(){const i=yield Br(n);(r=t==null?void 0:t.onHeader)===null||r===void 0||r.call(t,i.header),yield Br(yield*cc(vo(i.message))),(s=t==null?void 0:t.onTrailer)===null||s===void 0||s.call(t,i.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>e.next()})}}function mc(...n){const t=new AbortController,e=n.filter(s=>s!==void 0).concat(t.signal);for(const s of e){if(s.aborted){r.apply(s);break}s.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(To(this));for(const s of e)s.removeEventListener("abort",r)}return t}function pc(n){const t=new AbortController,e=()=>{t.abort(new M("the operation timed out",R.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?e():r=setTimeout(e,n)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function To(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function xi(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,t){return this[n.id]=t,this},delete(n){return delete this[n.id],this}}}const is=128;function Ei(n){const t=new Headers,e=new TextDecoder().decode(n).split(`\r +`);for(const r of e){if(r==="")continue;const s=r.indexOf(":");if(s>0){const i=r.substring(0,s).trim(),o=r.substring(s+1).trim();t.append(i,o)}}return t}const yc="Content-Type",vc="Grpc-Timeout",Ao="Grpc-Status",bo="Grpc-Message",wc="Grpc-Status-Details-Bin",Tc="X-User-Agent",Ac="X-Grpc-Web",bc="application/grpc-web+proto",Ic="application/grpc-web+json";class Yt extends A{constructor(t){super(),this.code=0,this.message="",this.details=[],u.util.initPartial(t,this)}static fromBinary(t,e){return new Yt().fromBinary(t,e)}static fromJson(t,e){return new Yt().fromJson(t,e)}static fromJsonString(t,e){return new Yt().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Yt,t,e)}}Yt.runtime=u;Yt.typeName="google.rpc.Status";Yt.fields=u.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Re,repeated:!0}]);const Sc="0";function Io(n){var t;const e=n.get(wc);if(e!=null){const s=rc(e,Yt);if(s.code==0)return;const i=new M(s.message,s.code,n);return i.details=s.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),i}const r=n.get(Ao);if(r!=null){if(r===Sc)return;const s=parseInt(r,10);return s in R?new M(decodeURIComponent((t=n.get(bo))!==null&&t!==void 0?t:""),s,n):new M(`invalid grpc-status: ${r}`,R.Internal,n)}}function Ni(n,t,e){const r=typeof t=="string"?t:t.typeName,s=typeof e=="string"?e:e.name;return n.toString().replace(/\/?$/,`/${r}/${s}`)}function So(n,t){return t instanceof n?t:new n(t)}function kc(n,t){function e(r){return r.done===!0?r:{done:r.done,value:So(n,r.value)}}return{[Symbol.asyncIterator](){const r=t[Symbol.asyncIterator](),s={next:()=>r.next().then(e)};return r.throw!==void 0&&(s.throw=i=>r.throw(i).then(e)),r.return!==void 0&&(s.return=i=>r.return(i).then(e)),s}}}function ko(n,t){var e;return(e=t==null?void 0:t.concat().reverse().reduce((r,s)=>s(r),n))!==null&&e!==void 0?e:n}function xc(n){var t;const e=Object.assign({},n);return(t=e.ignoreUnknownFields)!==null&&t!==void 0||(e.ignoreUnknownFields=!0),e}function Ci(n,t,e,r){const s=t?Pi(n.I,r):Di(n.I,e);return{parse:(t?Pi(n.O,r):Di(n.O,e)).parse,serialize:s.serialize}}function Pi(n,t){return{parse(e){try{return n.fromBinary(e,t)}catch(r){const s=r instanceof Error?r.message:String(r);throw new M(`parse binary: ${s}`,R.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(r){const s=r instanceof Error?r.message:String(r);throw new M(`serialize binary: ${s}`,R.Internal)}}}}function Di(n,t){var e,r;const s=(e=t==null?void 0:t.textEncoder)!==null&&e!==void 0?e:new TextEncoder,i=(r=t==null?void 0:t.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=xc(t);return{parse(c){try{const l=i.decode(c);return n.fromJsonString(l,o)}catch(l){throw M.from(l,R.InvalidArgument)}},serialize(c){try{const l=c.toJsonString(o);return s.encode(l)}catch(l){throw M.from(l,R.Internal)}}}}function Ec(n){const t=ko(n.next,n.interceptors),[e,r,s]=xo(n),i=Object.assign(Object.assign({},n.req),{message:So(n.req.method.I,n.req.message),signal:e});return t(i).then(o=>(s(),o),r)}function Nc(n){const t=ko(n.next,n.interceptors),[e,r,s]=xo(n),i=Object.assign(Object.assign({},n.req),{message:kc(n.req.method.I,n.req.message),signal:e});let o=!1;return e.addEventListener("abort",function(){var c,l;const h=n.req.message[Symbol.asyncIterator]();o||(c=h.throw)===null||c===void 0||c.call(h,this.reason).catch(()=>{}),(l=h.return)===null||l===void 0||l.call(h).catch(()=>{})}),t(i).then(c=>Object.assign(Object.assign({},c),{message:{[Symbol.asyncIterator](){const l=c.message[Symbol.asyncIterator]();return{next(){return l.next().then(h=>(h.done==!0&&(o=!0,s()),h),r)}}}}}),r)}function xo(n){const{signal:t,cleanup:e}=pc(n.timeoutMs),r=mc(n.signal,t);return[r.signal,function(i){const o=M.from(t.aborted?To(t):i);return r.abort(o),e(),Promise.reject(o)},function(){e(),r.abort()}]}function Cc(){try{new Headers}catch{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.")}}function Oi(n,t){const e=Io(n);if(e)throw t.forEach((r,s)=>{e.metadata.append(s,r)}),e}function Bi(n,t,e,r){const s=new Headers(e??{});return s.set(yc,n?bc:Ic),s.set(Ac,"1"),s.set(Tc,"connect-es/1.4.0"),t!==void 0&&s.set(vc,`${t}m`),s}function Pc(n){switch(n){case 400:return R.Internal;case 401:return R.Unauthenticated;case 403:return R.PermissionDenied;case 404:return R.Unimplemented;case 429:return R.Unavailable;case 502:return R.Unavailable;case 503:return R.Unavailable;case 504:return R.Unavailable;default:return R.Unknown}}function Ri(n,t){var e;if(n>=200&&n<300){const r=Io(t);if(r)throw r;return{foundStatus:t.has(Ao)}}throw new M(decodeURIComponent((e=t.get(bo))!==null&&e!==void 0?e:`HTTP ${n}`),Pc(n),t)}var gr=function(n){return this instanceof gr?(this.v=n,this):new gr(n)},Dc=function(n,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e.apply(n,t||[]),s,i=[];return s={},c("next"),c("throw"),c("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(w){return Promise.resolve(w).then(p,g)}}function c(p,w){r[p]&&(s[p]=function(b){return new Promise(function(x,C){i.push([p,b,x,C])>1||l(p,b)})},w&&(s[p]=w(s[p])))}function l(p,w){try{h(r[p](w))}catch(b){v(i[0][3],b)}}function h(p){p.value instanceof gr?Promise.resolve(p.value.v).then(f,g):v(i[0][2],p)}function f(p){l("next",p)}function g(p){l("throw",p)}function v(p,w){p(w),i.shift(),i.length&&l(i[0][0],i[0][1])}};function Oc(n){var t;Cc();const e=(t=n.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(r,s,i,o,c,l,h){var f;const{serialize:g,parse:v}=Ci(s,e,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await Ec({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!1,service:r,method:s,url:Ni(n.baseUrl,r,s),init:{method:"POST",credentials:(f=n.credentials)!==null&&f!==void 0?f:"same-origin",redirect:"error",mode:"cors"},header:Bi(e,o,c),contextValues:h??xi(),message:l},next:async p=>{var w;const x=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:ki(0,g(p.message))}));if(Ri(x.status,x.headers),!x.body)throw"missing response body";const C=Si(x.body).getReader();let P,L;for(;;){const Y=await C.read();if(Y.done)break;const{flags:D,data:F}=Y.value;if(D===is){if(P!==void 0)throw"extra trailer";P=Ei(F);continue}if(L!==void 0)throw"extra message";L=v(F)}if(P===void 0)throw"missing trailer";if(Oi(P,x.headers),L===void 0)throw"missing message";return{stream:!1,service:r,method:s,header:x.headers,message:L,trailer:P}}})},async stream(r,s,i,o,c,l,h){var f;const{serialize:g,parse:v}=Ci(s,e,n.jsonOptions,n.binaryOptions);function p(b,x,C,P){return Dc(this,arguments,function*(){const Y=Si(b).getReader();if(x){if(!(yield gr(Y.read())).done)throw"extra data for trailers-only";return yield gr(void 0)}let D=!1;for(;;){const F=yield gr(Y.read());if(F.done)break;const{flags:V,data:K}=F.value;if((V&is)===is){if(D)throw"extra trailer";D=!0;const ue=Ei(K);Oi(ue,P),ue.forEach((Ge,br)=>C.set(br,Ge));continue}if(D)throw"extra message";yield yield gr(v(K))}if(!D)throw"missing trailer"})}async function w(b){if(s.kind!=ee.ServerStreaming)throw"The fetch API does not support streaming request bodies";const x=await b[Symbol.asyncIterator]().next();if(x.done==!0)throw"missing request message";return ki(0,g(x.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,Nc({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!0,service:r,method:s,url:Ni(n.baseUrl,r,s),init:{method:"POST",credentials:(f=n.credentials)!==null&&f!==void 0?f:"same-origin",redirect:"error",mode:"cors"},header:Bi(e,o,c),contextValues:h??xi(),message:l},next:async b=>{var x;const P=await((x=n.fetch)!==null&&x!==void 0?x:globalThis.fetch)(b.url,Object.assign(Object.assign({},b.init),{headers:b.header,signal:b.signal,body:await w(b.message)})),{foundStatus:L}=Ri(P.status,P.headers);if(!P.body)throw"missing response body";const Y=new Headers;return Object.assign(Object.assign({},b),{header:P.headers,trailer:Y,message:p(P.body,L,Y,P.headers)})}})}}}var N=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(N||{});u.util.setEnumType(N,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var yr=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(yr||{});u.util.setEnumType(yr,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const We=class We extends A{constructor(e){super();a(this,"root");a(this,"presences",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new We().fromBinary(e,r)}static fromJson(e,r){return new We().fromJson(e,r)}static fromJsonString(e,r){return new We().fromJsonString(e,r)}static equals(e,r){return u.util.equals(We,e,r)}};a(We,"runtime",u),a(We,"typeName","yorkie.v1.Snapshot"),a(We,"fields",u.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:se},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:js}}]));let gs=We;var he;let tr=(he=class extends A{constructor(e){super();a(this,"documentKey","");a(this,"checkpoint");a(this,"snapshot",new Uint8Array(0));a(this,"changes",[]);a(this,"minSyncedTicket");a(this,"isRemoved",!1);a(this,"versionVector");u.util.initPartial(e,this)}static fromBinary(e,r){return new he().fromBinary(e,r)}static fromJson(e,r){return new he().fromJson(e,r)}static fromJsonString(e,r){return new he().fromJsonString(e,r)}static equals(e,r){return u.util.equals(he,e,r)}},a(he,"runtime",u),a(he,"typeName","yorkie.v1.ChangePack"),a(he,"fields",u.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Co},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Eo,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:I},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Yn}])),he);var fe;let Eo=(fe=class extends A{constructor(e){super();a(this,"id");a(this,"message","");a(this,"operations",[]);a(this,"presenceChange");u.util.initPartial(e,this)}static fromBinary(e,r){return new fe().fromBinary(e,r)}static fromJson(e,r){return new fe().fromJson(e,r)}static fromJsonString(e,r){return new fe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(fe,e,r)}},a(fe,"runtime",u),a(fe,"typeName","yorkie.v1.Change"),a(fe,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Hn},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Ks,repeated:!0},{no:4,name:"presence_change",kind:"message",T:Zr}])),fe);var de;let Hn=(de=class extends A{constructor(e){super();a(this,"clientSeq",0);a(this,"serverSeq",$.zero);a(this,"lamport",$.zero);a(this,"actorId",new Uint8Array(0));a(this,"versionVector");u.util.initPartial(e,this)}static fromBinary(e,r){return new de().fromBinary(e,r)}static fromJson(e,r){return new de().fromJson(e,r)}static fromJsonString(e,r){return new de().fromJsonString(e,r)}static equals(e,r){return u.util.equals(de,e,r)}},a(de,"runtime",u),a(de,"typeName","yorkie.v1.ChangeID"),a(de,"fields",u.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Yn}])),de);var ge;let Yn=(ge=class extends A{constructor(e){super();a(this,"vector",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new ge().fromBinary(e,r)}static fromJson(e,r){return new ge().fromJson(e,r)}static fromJsonString(e,r){return new ge().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ge,e,r)}},a(ge,"runtime",u),a(ge,"typeName","yorkie.v1.VersionVector"),a(ge,"fields",u.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),ge);var me;let Ks=(me=class extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new me().fromBinary(e,r)}static fromJson(e,r){return new me().fromJson(e,r)}static fromJsonString(e,r){return new me().fromJsonString(e,r)}static equals(e,r){return u.util.equals(me,e,r)}},a(me,"runtime",u),a(me,"typeName","yorkie.v1.Operation"),a(me,"fields",u.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:kn,oneof:"body"},{no:2,name:"add",kind:"message",T:xn,oneof:"body"},{no:3,name:"move",kind:"message",T:En,oneof:"body"},{no:4,name:"remove",kind:"message",T:Nn,oneof:"body"},{no:5,name:"edit",kind:"message",T:Cn,oneof:"body"},{no:6,name:"select",kind:"message",T:ms,oneof:"body"},{no:7,name:"style",kind:"message",T:Pn,oneof:"body"},{no:8,name:"increase",kind:"message",T:Dn,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:On,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:Bn,oneof:"body"},{no:11,name:"array_set",kind:"message",T:ps,oneof:"body"}])),me);const He=class He extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"key","");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new He().fromBinary(e,r)}static fromJson(e,r){return new He().fromJson(e,r)}static fromJsonString(e,r){return new He().fromJsonString(e,r)}static equals(e,r){return u.util.equals(He,e,r)}};a(He,"runtime",u),a(He,"typeName","yorkie.v1.Operation.Set"),a(He,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let kn=He;const Ye=class Ye extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"prevCreatedAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ye().fromBinary(e,r)}static fromJson(e,r){return new Ye().fromJson(e,r)}static fromJsonString(e,r){return new Ye().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ye,e,r)}};a(Ye,"runtime",u),a(Ye,"typeName","yorkie.v1.Operation.Add"),a(Ye,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"prev_created_at",kind:"message",T:I},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let xn=Ye;const Xe=class Xe extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"prevCreatedAt");a(this,"createdAt");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Xe().fromBinary(e,r)}static fromJson(e,r){return new Xe().fromJson(e,r)}static fromJsonString(e,r){return new Xe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Xe,e,r)}};a(Xe,"runtime",u),a(Xe,"typeName","yorkie.v1.Operation.Move"),a(Xe,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"prev_created_at",kind:"message",T:I},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"executed_at",kind:"message",T:I}]));let En=Xe;const Ze=class Ze extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"createdAt");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ze().fromBinary(e,r)}static fromJson(e,r){return new Ze().fromJson(e,r)}static fromJsonString(e,r){return new Ze().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ze,e,r)}};a(Ze,"runtime",u),a(Ze,"typeName","yorkie.v1.Operation.Remove"),a(Ze,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"executed_at",kind:"message",T:I}]));let Nn=Ze;const Qe=class Qe extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"createdAtMapByActor",{});a(this,"content","");a(this,"executedAt");a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new Qe().fromBinary(e,r)}static fromJson(e,r){return new Qe().fromJson(e,r)}static fromJsonString(e,r){return new Qe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Qe,e,r)}};a(Qe,"runtime",u),a(Qe,"typeName","yorkie.v1.Operation.Edit"),a(Qe,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:I},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let Cn=Qe;const _e=class _e extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new _e().fromBinary(e,r)}static fromJson(e,r){return new _e().fromJson(e,r)}static fromJsonString(e,r){return new _e().fromJsonString(e,r)}static equals(e,r){return u.util.equals(_e,e,r)}};a(_e,"runtime",u),a(_e,"typeName","yorkie.v1.Operation.Select"),a(_e,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"executed_at",kind:"message",T:I}]));let ms=_e;const et=class et extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"attributes",{});a(this,"executedAt");a(this,"createdAtMapByActor",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new et().fromBinary(e,r)}static fromJson(e,r){return new et().fromJson(e,r)}static fromJsonString(e,r){return new et().fromJsonString(e,r)}static equals(e,r){return u.util.equals(et,e,r)}};a(et,"runtime",u),a(et,"typeName","yorkie.v1.Operation.Style"),a(et,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:_t},{no:3,name:"to",kind:"message",T:_t},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:I},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}}]));let Pn=et;const tt=class tt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new tt().fromBinary(e,r)}static fromJson(e,r){return new tt().fromJson(e,r)}static fromJsonString(e,r){return new tt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(tt,e,r)}};a(tt,"runtime",u),a(tt,"typeName","yorkie.v1.Operation.Increase"),a(tt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"value",kind:"message",T:le},{no:3,name:"executed_at",kind:"message",T:I}]));let Dn=tt;const rt=class rt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"createdAtMapByActor",{});a(this,"contents",[]);a(this,"splitLevel",0);a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new rt().fromBinary(e,r)}static fromJson(e,r){return new rt().fromJson(e,r)}static fromJsonString(e,r){return new rt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(rt,e,r)}};a(rt,"runtime",u),a(rt,"typeName","yorkie.v1.Operation.TreeEdit"),a(rt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:vr},{no:3,name:"to",kind:"message",T:vr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}},{no:5,name:"contents",kind:"message",T:zn,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:I}]));let On=rt;const nt=class nt extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"from");a(this,"to");a(this,"attributes",{});a(this,"executedAt");a(this,"attributesToRemove",[]);a(this,"createdAtMapByActor",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new nt().fromBinary(e,r)}static fromJson(e,r){return new nt().fromJson(e,r)}static fromJsonString(e,r){return new nt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(nt,e,r)}};a(nt,"runtime",u),a(nt,"typeName","yorkie.v1.Operation.TreeStyle"),a(nt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"from",kind:"message",T:vr},{no:3,name:"to",kind:"message",T:vr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:I},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:I}}]));let Bn=nt;const st=class st extends A{constructor(e){super();a(this,"parentCreatedAt");a(this,"createdAt");a(this,"value");a(this,"executedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new st().fromBinary(e,r)}static fromJson(e,r){return new st().fromJson(e,r)}static fromJsonString(e,r){return new st().fromJsonString(e,r)}static equals(e,r){return u.util.equals(st,e,r)}};a(st,"runtime",u),a(st,"typeName","yorkie.v1.Operation.ArraySet"),a(st,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:I},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"value",kind:"message",T:le},{no:4,name:"executed_at",kind:"message",T:I}]));let ps=st;const it=class it extends A{constructor(e){super();a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");a(this,"type",0);a(this,"value",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new it().fromBinary(e,r)}static fromJson(e,r){return new it().fromJson(e,r)}static fromJsonString(e,r){return new it().fromJsonString(e,r)}static equals(e,r){return u.util.equals(it,e,r)}};a(it,"runtime",u),a(it,"typeName","yorkie.v1.JSONElementSimple"),a(it,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"moved_at",kind:"message",T:I},{no:3,name:"removed_at",kind:"message",T:I},{no:4,name:"type",kind:"enum",T:u.getEnumType(N)},{no:5,name:"value",kind:"scalar",T:12}]));let le=it;const ot=class ot extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new ot().fromBinary(e,r)}static fromJson(e,r){return new ot().fromJson(e,r)}static fromJsonString(e,r){return new ot().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ot,e,r)}};a(ot,"runtime",u),a(ot,"typeName","yorkie.v1.JSONElement"),a(ot,"fields",u.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Rn,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Ln,oneof:"body"},{no:3,name:"primitive",kind:"message",T:Jn,oneof:"body"},{no:5,name:"text",kind:"message",T:Fn,oneof:"body"},{no:6,name:"counter",kind:"message",T:Mn,oneof:"body"},{no:7,name:"tree",kind:"message",T:$n,oneof:"body"}]));let se=ot;const at=class at extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new at().fromBinary(e,r)}static fromJson(e,r){return new at().fromJson(e,r)}static fromJsonString(e,r){return new at().fromJsonString(e,r)}static equals(e,r){return u.util.equals(at,e,r)}};a(at,"runtime",u),a(at,"typeName","yorkie.v1.JSONElement.JSONObject"),a(at,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:No,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Rn=at;const ct=class ct extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ct().fromBinary(e,r)}static fromJson(e,r){return new ct().fromJson(e,r)}static fromJsonString(e,r){return new ct().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ct,e,r)}};a(ct,"runtime",u),a(ct,"typeName","yorkie.v1.JSONElement.JSONArray"),a(ct,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Un,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Ln=ct;const ut=class ut extends A{constructor(e){super();a(this,"type",0);a(this,"value",new Uint8Array(0));a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ut().fromBinary(e,r)}static fromJson(e,r){return new ut().fromJson(e,r)}static fromJsonString(e,r){return new ut().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ut,e,r)}};a(ut,"runtime",u),a(ut,"typeName","yorkie.v1.JSONElement.Primitive"),a(ut,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(N)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"moved_at",kind:"message",T:I},{no:5,name:"removed_at",kind:"message",T:I}]));let Jn=ut;const lt=class lt extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new lt().fromBinary(e,r)}static fromJson(e,r){return new lt().fromJson(e,r)}static fromJsonString(e,r){return new lt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(lt,e,r)}};a(lt,"runtime",u),a(lt,"typeName","yorkie.v1.JSONElement.Text"),a(lt,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:qn,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let Fn=lt;const ht=class ht extends A{constructor(e){super();a(this,"type",0);a(this,"value",new Uint8Array(0));a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ht().fromBinary(e,r)}static fromJson(e,r){return new ht().fromJson(e,r)}static fromJsonString(e,r){return new ht().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ht,e,r)}};a(ht,"runtime",u),a(ht,"typeName","yorkie.v1.JSONElement.Counter"),a(ht,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(N)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:I},{no:4,name:"moved_at",kind:"message",T:I},{no:5,name:"removed_at",kind:"message",T:I}]));let Mn=ht;const ft=class ft extends A{constructor(e){super();a(this,"nodes",[]);a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new ft().fromBinary(e,r)}static fromJson(e,r){return new ft().fromJson(e,r)}static fromJsonString(e,r){return new ft().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ft,e,r)}};a(ft,"runtime",u),a(ft,"typeName","yorkie.v1.JSONElement.Tree"),a(ft,"fields",u.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Xr,repeated:!0},{no:2,name:"created_at",kind:"message",T:I},{no:3,name:"moved_at",kind:"message",T:I},{no:4,name:"removed_at",kind:"message",T:I}]));let $n=ft;var pe;let No=(pe=class extends A{constructor(e){super();a(this,"key","");a(this,"element");u.util.initPartial(e,this)}static fromBinary(e,r){return new pe().fromBinary(e,r)}static fromJson(e,r){return new pe().fromJson(e,r)}static fromJsonString(e,r){return new pe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(pe,e,r)}},a(pe,"runtime",u),a(pe,"typeName","yorkie.v1.RHTNode"),a(pe,"fields",u.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:se}])),pe);const Oe=class Oe extends A{constructor(e){super();a(this,"next");a(this,"element");u.util.initPartial(e,this)}static fromBinary(e,r){return new Oe().fromBinary(e,r)}static fromJson(e,r){return new Oe().fromJson(e,r)}static fromJsonString(e,r){return new Oe().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Oe,e,r)}};a(Oe,"runtime",u),a(Oe,"typeName","yorkie.v1.RGANode"),a(Oe,"fields",u.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Oe},{no:2,name:"element",kind:"message",T:se}]));let Un=Oe;const dt=class dt extends A{constructor(e){super();a(this,"value","");a(this,"updatedAt");a(this,"isRemoved",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new dt().fromBinary(e,r)}static fromJson(e,r){return new dt().fromJson(e,r)}static fromJsonString(e,r){return new dt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(dt,e,r)}};a(dt,"runtime",u),a(dt,"typeName","yorkie.v1.NodeAttr"),a(dt,"fields",u.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:I},{no:3,name:"is_removed",kind:"scalar",T:8}]));let Rr=dt;const gt=class gt extends A{constructor(e){super();a(this,"id");a(this,"value","");a(this,"removedAt");a(this,"insPrevId");a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new gt().fromBinary(e,r)}static fromJson(e,r){return new gt().fromJson(e,r)}static fromJsonString(e,r){return new gt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(gt,e,r)}};a(gt,"runtime",u),a(gt,"typeName","yorkie.v1.TextNode"),a(gt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Yr},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:I},{no:4,name:"ins_prev_id",kind:"message",T:Yr},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Rr}}]));let qn=gt;const mt=class mt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new mt().fromBinary(e,r)}static fromJson(e,r){return new mt().fromJson(e,r)}static fromJsonString(e,r){return new mt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(mt,e,r)}};a(mt,"runtime",u),a(mt,"typeName","yorkie.v1.TextNodeID"),a(mt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5}]));let Yr=mt;const pt=class pt extends A{constructor(e){super();a(this,"id");a(this,"type","");a(this,"value","");a(this,"removedAt");a(this,"insPrevId");a(this,"insNextId");a(this,"depth",0);a(this,"attributes",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new pt().fromBinary(e,r)}static fromJson(e,r){return new pt().fromJson(e,r)}static fromJsonString(e,r){return new pt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(pt,e,r)}};a(pt,"runtime",u),a(pt,"typeName","yorkie.v1.TreeNode"),a(pt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:or},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:I},{no:5,name:"ins_prev_id",kind:"message",T:or},{no:6,name:"ins_next_id",kind:"message",T:or},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Rr}}]));let Xr=pt;const yt=class yt extends A{constructor(e){super();a(this,"content",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new yt().fromBinary(e,r)}static fromJson(e,r){return new yt().fromJson(e,r)}static fromJsonString(e,r){return new yt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(yt,e,r)}};a(yt,"runtime",u),a(yt,"typeName","yorkie.v1.TreeNodes"),a(yt,"fields",u.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:Xr,repeated:!0}]));let zn=yt;const vt=class vt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new vt().fromBinary(e,r)}static fromJson(e,r){return new vt().fromJson(e,r)}static fromJsonString(e,r){return new vt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(vt,e,r)}};a(vt,"runtime",u),a(vt,"typeName","yorkie.v1.TreeNodeID"),a(vt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5}]));let or=vt;const wt=class wt extends A{constructor(e){super();a(this,"parentId");a(this,"leftSiblingId");u.util.initPartial(e,this)}static fromBinary(e,r){return new wt().fromBinary(e,r)}static fromJson(e,r){return new wt().fromJson(e,r)}static fromJsonString(e,r){return new wt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(wt,e,r)}};a(wt,"runtime",u),a(wt,"typeName","yorkie.v1.TreePos"),a(wt,"fields",u.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:or},{no:2,name:"left_sibling_id",kind:"message",T:or}]));let vr=wt;const Tt=class Tt extends A{constructor(e){super();a(this,"id","");a(this,"username","");a(this,"createdAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new Tt().fromBinary(e,r)}static fromJson(e,r){return new Tt().fromJson(e,r)}static fromJsonString(e,r){return new Tt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Tt,e,r)}};a(Tt,"runtime",u),a(Tt,"typeName","yorkie.v1.User"),a(Tt,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Q}]));let Li=Tt;const At=class At extends A{constructor(e){super();a(this,"id","");a(this,"name","");a(this,"publicKey","");a(this,"secretKey","");a(this,"authWebhookUrl","");a(this,"authWebhookMethods",[]);a(this,"clientDeactivateThreshold","");a(this,"createdAt");a(this,"updatedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new At().fromBinary(e,r)}static fromJson(e,r){return new At().fromJson(e,r)}static fromJsonString(e,r){return new At().fromJsonString(e,r)}static equals(e,r){return u.util.equals(At,e,r)}};a(At,"runtime",u),a(At,"typeName","yorkie.v1.Project"),a(At,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Q},{no:9,name:"updated_at",kind:"message",T:Q}]));let Ji=At;const bt=class bt extends A{constructor(e){super();a(this,"name");a(this,"authWebhookUrl");a(this,"authWebhookMethods");a(this,"clientDeactivateThreshold");u.util.initPartial(e,this)}static fromBinary(e,r){return new bt().fromBinary(e,r)}static fromJson(e,r){return new bt().fromJson(e,r)}static fromJsonString(e,r){return new bt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(bt,e,r)}};a(bt,"runtime",u),a(bt,"typeName","yorkie.v1.UpdatableProjectFields"),a(bt,"fields",u.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:ie},{no:2,name:"auth_webhook_url",kind:"message",T:ie},{no:3,name:"auth_webhook_methods",kind:"message",T:ys},{no:4,name:"client_deactivate_threshold",kind:"message",T:ie}]));let Fi=bt;const It=class It extends A{constructor(e){super();a(this,"methods",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new It().fromBinary(e,r)}static fromJson(e,r){return new It().fromJson(e,r)}static fromJsonString(e,r){return new It().fromJsonString(e,r)}static equals(e,r){return u.util.equals(It,e,r)}};a(It,"runtime",u),a(It,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),a(It,"fields",u.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let ys=It;const St=class St extends A{constructor(e){super();a(this,"id","");a(this,"key","");a(this,"snapshot","");a(this,"createdAt");a(this,"accessedAt");a(this,"updatedAt");u.util.initPartial(e,this)}static fromBinary(e,r){return new St().fromBinary(e,r)}static fromJson(e,r){return new St().fromJson(e,r)}static fromJsonString(e,r){return new St().fromJsonString(e,r)}static equals(e,r){return u.util.equals(St,e,r)}};a(St,"runtime",u),a(St,"typeName","yorkie.v1.DocumentSummary"),a(St,"fields",u.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Q},{no:5,name:"accessed_at",kind:"message",T:Q},{no:6,name:"updated_at",kind:"message",T:Q}]));let Mi=St;const kt=class kt extends A{constructor(e){super();a(this,"type",0);a(this,"presence");u.util.initPartial(e,this)}static fromBinary(e,r){return new kt().fromBinary(e,r)}static fromJson(e,r){return new kt().fromJson(e,r)}static fromJsonString(e,r){return new kt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(kt,e,r)}};a(kt,"runtime",u),a(kt,"typeName","yorkie.v1.PresenceChange"),a(kt,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(wr)},{no:2,name:"presence",kind:"message",T:js}]));let Zr=kt;var wr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(wr||{});u.util.setEnumType(wr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var ye;let js=(ye=class extends A{constructor(e){super();a(this,"data",{});u.util.initPartial(e,this)}static fromBinary(e,r){return new ye().fromBinary(e,r)}static fromJson(e,r){return new ye().fromJson(e,r)}static fromJsonString(e,r){return new ye().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ye,e,r)}},a(ye,"runtime",u),a(ye,"typeName","yorkie.v1.Presence"),a(ye,"fields",u.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),ye);var ve;let Co=(ve=class extends A{constructor(e){super();a(this,"serverSeq",$.zero);a(this,"clientSeq",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new ve().fromBinary(e,r)}static fromJson(e,r){return new ve().fromJson(e,r)}static fromJsonString(e,r){return new ve().fromJsonString(e,r)}static equals(e,r){return u.util.equals(ve,e,r)}},a(ve,"runtime",u),a(ve,"typeName","yorkie.v1.Checkpoint"),a(ve,"fields",u.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),ve);const xt=class xt extends A{constructor(e){super();a(this,"createdAt");a(this,"offset",0);a(this,"relativeOffset",0);u.util.initPartial(e,this)}static fromBinary(e,r){return new xt().fromBinary(e,r)}static fromJson(e,r){return new xt().fromJson(e,r)}static fromJsonString(e,r){return new xt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(xt,e,r)}};a(xt,"runtime",u),a(xt,"typeName","yorkie.v1.TextNodePos"),a(xt,"fields",u.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:I},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let _t=xt;var we;let I=(we=class extends A{constructor(e){super();a(this,"lamport",$.zero);a(this,"delimiter",0);a(this,"actorId",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new we().fromBinary(e,r)}static fromJson(e,r){return new we().fromJson(e,r)}static fromJsonString(e,r){return new we().fromJsonString(e,r)}static equals(e,r){return u.util.equals(we,e,r)}},a(we,"runtime",u),a(we,"typeName","yorkie.v1.TimeTicket"),a(we,"fields",u.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),we);const Et=class Et extends A{constructor(e){super();a(this,"topic","");a(this,"payload",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new Et().fromBinary(e,r)}static fromJson(e,r){return new Et().fromJson(e,r)}static fromJsonString(e,r){return new Et().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Et,e,r)}};a(Et,"runtime",u),a(Et,"typeName","yorkie.v1.DocEventBody"),a(Et,"fields",u.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let vs=Et;const Nt=class Nt extends A{constructor(e){super();a(this,"type",0);a(this,"publisher","");a(this,"body");u.util.initPartial(e,this)}static fromBinary(e,r){return new Nt().fromBinary(e,r)}static fromJson(e,r){return new Nt().fromJson(e,r)}static fromJsonString(e,r){return new Nt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Nt,e,r)}};a(Nt,"runtime",u),a(Nt,"typeName","yorkie.v1.DocEvent"),a(Nt,"fields",u.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:u.getEnumType(yr)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:vs}]));let ws=Nt;const Ct=class Ct extends A{constructor(e){super();a(this,"clientKey","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ct().fromBinary(e,r)}static fromJson(e,r){return new Ct().fromJson(e,r)}static fromJsonString(e,r){return new Ct().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ct,e,r)}};a(Ct,"runtime",u),a(Ct,"typeName","yorkie.v1.ActivateClientRequest"),a(Ct,"fields",u.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Ts=Ct;const Pt=class Pt extends A{constructor(e){super();a(this,"clientId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Pt().fromBinary(e,r)}static fromJson(e,r){return new Pt().fromJson(e,r)}static fromJsonString(e,r){return new Pt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Pt,e,r)}};a(Pt,"runtime",u),a(Pt,"typeName","yorkie.v1.ActivateClientResponse"),a(Pt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let As=Pt;const Dt=class Dt extends A{constructor(e){super();a(this,"clientId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Dt().fromBinary(e,r)}static fromJson(e,r){return new Dt().fromJson(e,r)}static fromJsonString(e,r){return new Dt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Dt,e,r)}};a(Dt,"runtime",u),a(Dt,"typeName","yorkie.v1.DeactivateClientRequest"),a(Dt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let bs=Dt;const Ot=class Ot extends A{constructor(t){super(),u.util.initPartial(t,this)}static fromBinary(t,e){return new Ot().fromBinary(t,e)}static fromJson(t,e){return new Ot().fromJson(t,e)}static fromJsonString(t,e){return new Ot().fromJsonString(t,e)}static equals(t,e){return u.util.equals(Ot,t,e)}};a(Ot,"runtime",u),a(Ot,"typeName","yorkie.v1.DeactivateClientResponse"),a(Ot,"fields",u.util.newFieldList(()=>[]));let Is=Ot;const Bt=class Bt extends A{constructor(e){super();a(this,"clientId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Bt().fromBinary(e,r)}static fromJson(e,r){return new Bt().fromJson(e,r)}static fromJsonString(e,r){return new Bt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Bt,e,r)}};a(Bt,"runtime",u),a(Bt,"typeName","yorkie.v1.AttachDocumentRequest"),a(Bt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:tr}]));let Ss=Bt;const Rt=class Rt extends A{constructor(e){super();a(this,"documentId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Rt().fromBinary(e,r)}static fromJson(e,r){return new Rt().fromJson(e,r)}static fromJsonString(e,r){return new Rt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Rt,e,r)}};a(Rt,"runtime",u),a(Rt,"typeName","yorkie.v1.AttachDocumentResponse"),a(Rt,"fields",u.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:tr}]));let ks=Rt;const Lt=class Lt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");a(this,"removeIfNotAttached",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new Lt().fromBinary(e,r)}static fromJson(e,r){return new Lt().fromJson(e,r)}static fromJsonString(e,r){return new Lt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Lt,e,r)}};a(Lt,"runtime",u),a(Lt,"typeName","yorkie.v1.DetachDocumentRequest"),a(Lt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let xs=Lt;const Jt=class Jt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Jt().fromBinary(e,r)}static fromJson(e,r){return new Jt().fromJson(e,r)}static fromJsonString(e,r){return new Jt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Jt,e,r)}};a(Jt,"runtime",u),a(Jt,"typeName","yorkie.v1.DetachDocumentResponse"),a(Jt,"fields",u.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:tr}]));let Es=Jt;const Ft=class Ft extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ft().fromBinary(e,r)}static fromJson(e,r){return new Ft().fromJson(e,r)}static fromJsonString(e,r){return new Ft().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ft,e,r)}};a(Ft,"runtime",u),a(Ft,"typeName","yorkie.v1.WatchDocumentRequest"),a(Ft,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Ns=Ft;const Mt=class Mt extends A{constructor(e){super();a(this,"body",{case:void 0});u.util.initPartial(e,this)}static fromBinary(e,r){return new Mt().fromBinary(e,r)}static fromJson(e,r){return new Mt().fromJson(e,r)}static fromJsonString(e,r){return new Mt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Mt,e,r)}};a(Mt,"runtime",u),a(Mt,"typeName","yorkie.v1.WatchDocumentResponse"),a(Mt,"fields",u.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Ps,oneof:"body"},{no:2,name:"event",kind:"message",T:ws,oneof:"body"}]));let Cs=Mt;const $t=class $t extends A{constructor(e){super();a(this,"clientIds",[]);u.util.initPartial(e,this)}static fromBinary(e,r){return new $t().fromBinary(e,r)}static fromJson(e,r){return new $t().fromJson(e,r)}static fromJsonString(e,r){return new $t().fromJsonString(e,r)}static equals(e,r){return u.util.equals($t,e,r)}};a($t,"runtime",u),a($t,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),a($t,"fields",u.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Ps=$t;const Ut=class Ut extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Ut().fromBinary(e,r)}static fromJson(e,r){return new Ut().fromJson(e,r)}static fromJsonString(e,r){return new Ut().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Ut,e,r)}};a(Ut,"runtime",u),a(Ut,"typeName","yorkie.v1.RemoveDocumentRequest"),a(Ut,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr}]));let Ds=Ut;const qt=class qt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new qt().fromBinary(e,r)}static fromJson(e,r){return new qt().fromJson(e,r)}static fromJsonString(e,r){return new qt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(qt,e,r)}};a(qt,"runtime",u),a(qt,"typeName","yorkie.v1.RemoveDocumentResponse"),a(qt,"fields",u.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:tr}]));let Os=qt;const zt=class zt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"changePack");a(this,"pushOnly",!1);u.util.initPartial(e,this)}static fromBinary(e,r){return new zt().fromBinary(e,r)}static fromJson(e,r){return new zt().fromJson(e,r)}static fromJsonString(e,r){return new zt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(zt,e,r)}};a(zt,"runtime",u),a(zt,"typeName","yorkie.v1.PushPullChangesRequest"),a(zt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:tr},{no:4,name:"push_only",kind:"scalar",T:8}]));let Bs=zt;const Vt=class Vt extends A{constructor(e){super();a(this,"changePack");u.util.initPartial(e,this)}static fromBinary(e,r){return new Vt().fromBinary(e,r)}static fromJson(e,r){return new Vt().fromJson(e,r)}static fromJsonString(e,r){return new Vt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Vt,e,r)}};a(Vt,"runtime",u),a(Vt,"typeName","yorkie.v1.PushPullChangesResponse"),a(Vt,"fields",u.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:tr}]));let Rs=Vt;const Kt=class Kt extends A{constructor(e){super();a(this,"clientId","");a(this,"documentId","");a(this,"topic","");a(this,"payload",new Uint8Array(0));u.util.initPartial(e,this)}static fromBinary(e,r){return new Kt().fromBinary(e,r)}static fromJson(e,r){return new Kt().fromJson(e,r)}static fromJsonString(e,r){return new Kt().fromJsonString(e,r)}static equals(e,r){return u.util.equals(Kt,e,r)}};a(Kt,"runtime",u),a(Kt,"typeName","yorkie.v1.BroadcastRequest"),a(Kt,"fields",u.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Ls=Kt;const jt=class jt extends A{constructor(t){super(),u.util.initPartial(t,this)}static fromBinary(t,e){return new jt().fromBinary(t,e)}static fromJson(t,e){return new jt().fromJson(t,e)}static fromJsonString(t,e){return new jt().fromJsonString(t,e)}static equals(t,e){return u.util.equals(jt,t,e)}};a(jt,"runtime",u),a(jt,"typeName","yorkie.v1.BroadcastResponse"),a(jt,"fields",u.util.newFieldList(()=>[]));let Js=jt;const Bc={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Ts,O:As,kind:ee.Unary},deactivateClient:{name:"DeactivateClient",I:bs,O:Is,kind:ee.Unary},attachDocument:{name:"AttachDocument",I:Ss,O:ks,kind:ee.Unary},detachDocument:{name:"DetachDocument",I:xs,O:Es,kind:ee.Unary},removeDocument:{name:"RemoveDocument",I:Ds,O:Os,kind:ee.Unary},pushPullChanges:{name:"PushPullChanges",I:Bs,O:Rs,kind:ee.Unary},watchDocument:{name:"WatchDocument",I:Ns,O:Cs,kind:ee.ServerStreaming},broadcast:{name:"Broadcast",I:Ls,O:Js,kind:ee.Unary}}},Rc=u.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);u.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Ht}]);u.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:Lc,repeated:!0}]);const Lc=u.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});u.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:Jc,repeated:!0}]);const Jc=u.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});u.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:Fc,repeated:!0}]);const Fc=u.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});u.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);u.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Mc,repeated:!0}]);const Mc=u.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});u.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var d=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(d||{});class m extends Error{constructor(e,r){super(r);a(this,"name","YorkieError");a(this,"stack");this.code=e,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function ke(n){if(n instanceof Map){const t=Array.from(n);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(n))}const Po=n=>n?Object.entries(n).length===0:!0,Lr=n=>{const t={};for(const[e,r]of Object.entries(n))t[e]=JSON.stringify(r);return t},Cr=n=>{const t={};for(const[e,r]of Object.entries(n))t[e]=JSON.parse(r);return t};var lr=(n=>(n.Put="put",n.Clear="clear",n))(lr||{});class os{constructor(t,e){a(this,"context");a(this,"presence");this.context=t,this.presence=e}set(t,e){for(const r of Object.keys(t))this.presence[r]=t[r];this.context.setPresenceChange({type:"put",presence:ke(this.presence)}),this.context.setReversePresence(t,e)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Xn="000000000000000000000000";class be{constructor(t,e,r){a(this,"lamport");a(this,"delimiter");a(this,"actorID");this.lamport=t,this.delimiter=e,this.actorID=r}static of(t,e,r){return new be(t,e,r)}static fromStruct(t){return be.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new be(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const e=this.actorID.localeCompare(t.actorID);return e!==0?e:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const Do=0,jr=9223372036854775807n,Ne=new be(0n,Do,Xn);function Ve(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return t}})}class sn{constructor(t){a(this,"createdAt");a(this,"movedAt");a(this,"removedAt");this.createdAt=t}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(t){return!this.movedAt||t&&t.after(this.movedAt)?(this.movedAt=t,!0):!1}setRemovedAt(t){this.removedAt=t}remove(t){return t&&t.after(this.getPositionedAt())&&(!this.removedAt||t.after(this.removedAt))?(this.removedAt=t,!0):!1}isRemoved(){return!!this.removedAt}}class ar extends sn{constructor(t){super(t)}}class Gs{constructor(t,e){a(this,"strKey");a(this,"value");this.strKey=t,this.value=e}static of(t,e){return new Gs(t,e)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(t){return this.value.remove(t)}}class Qr{constructor(){a(this,"nodeMapByKey");a(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new Qr}set(t,e,r){let s;const i=this.nodeMapByKey.get(t);i!=null&&!i.isRemoved()&&i.remove(r)&&(s=i.getValue());const o=Gs.of(t,e);return this.nodeMapByCreatedAt.set(e.getCreatedAt().toIDString(),o),(i==null||r.after(i.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(t,o),e.setMovedAt(r)),s}delete(t,e){if(!this.nodeMapByCreatedAt.has(t.toIDString()))throw new m(d.ErrInvalidArgument,`fail to find ${t.toIDString()}`);const r=this.nodeMapByCreatedAt.get(t.toIDString());return r.remove(e),r.getValue()}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return e.getStrKey()}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new m(d.ErrInvalidArgument,`fail to find ${t.getCreatedAt().toIDString()}`);const r=this.nodeMapByKey.get(e.getStrKey());e===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}deleteByKey(t,e){const r=this.nodeMapByKey.get(t);if(r!=null&&r.remove(e))return r.getValue()}has(t){const e=this.nodeMapByKey.get(t);return e==null?!1:!e.isRemoved()}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}get(t){const e=this.nodeMapByKey.get(t);if(!(!e||e.isRemoved()))return e}*[Symbol.iterator](){for(const[,t]of this.nodeMapByKey)yield t}}class ne extends ar{constructor(e,r){super(e);a(this,"memberNodes");this.memberNodes=r}static create(e,r){if(!r)return new ne(e,Qr.create());const s=Qr.create();for(const[i,o]of Object.entries(r))s.set(i,o.deepcopy(),o.getCreatedAt());return new ne(e,s)}subPathOf(e){return this.memberNodes.subPathOf(e)}purge(e){this.memberNodes.purge(e)}set(e,r,s){return this.memberNodes.set(e,r,s)}delete(e,r){return this.memberNodes.delete(e,r)}deleteByKey(e,r){return this.memberNodes.deleteByKey(e,r)}get(e){const r=this.memberNodes.get(e);return r==null?void 0:r.getValue()}getByID(e){const r=this.memberNodes.getByID(e);return r==null?void 0:r.getValue()}has(e){return this.memberNodes.has(e)}toJSON(){const e=[];for(const[r,s]of this)e.push(`"${Ve(r)}":${s.toJSON()}`);return`{${e.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(const[r,s]of this){const{createdAt:i,value:o,type:c}=s.toJSForTest();e[r]={key:r,createdAt:i,value:o,type:c}}return{createdAt:this.getCreatedAt().toTestString(),value:e,type:"YORKIE_OBJECT"}}getKeys(){const e=Array();for(const[r]of this)e.push(r);return e}toSortedJSON(){var s;const e=Array();for(const[i]of this)e.push(i);const r=[];for(const i of e.sort()){const o=(s=this.memberNodes.get(i))==null?void 0:s.getValue();r.push(`"${Ve(i)}":${o.toSortedJSON()}`)}return`{${r.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const e=ne.create(this.getCreatedAt());for(const r of this.memberNodes)e.memberNodes.set(r.getStrKey(),r.getValue().deepcopy(),this.getPositionedAt());return e.remove(this.getRemovedAt()),e}getDescendants(e){for(const r of this.memberNodes){const s=r.getValue();if(e(s,this))return;s instanceof ar&&s.getDescendants(e)}}*[Symbol.iterator](){const e=new Set;for(const r of this.memberNodes)e.has(r.getStrKey())||(e.add(r.getStrKey()),r.isRemoved()||(yield[r.getStrKey(),r.getValue()]))}}var J=(n=>(n.Local="local",n.Remote="remote",n.UndoRedo="undoredo",n))(J||{});class Pe{constructor(t,e){a(this,"parentCreatedAt");a(this,"executedAt");this.parentCreatedAt=t,this.executedAt=e}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new m(d.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(t){this.executedAt&&(this.executedAt=this.executedAt.setActor(t))}setExecutedAt(t){this.executedAt=t}}class Oo{constructor(t){a(this,"value");a(this,"left");a(this,"right");a(this,"parent");a(this,"weight");this.value=t,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(t){this.left=t}setRight(t){this.right=t}setParent(t){this.parent=t}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(t){this.weight+=t}initWeight(){this.weight=this.getLength()}}class _r{constructor(t){a(this,"root");this.root=t}get length(){return this.root?this.root.getWeight():0}find(t){if(!this.root||t<0)return[void 0,0];let e=this.root;for(;;)if(e.hasLeft()&&t<=e.getLeftWeight())e=e.getLeft();else if(e.hasRight()&&e.getLeftWeight()+e.getLength()e.getLength())throw new m(d.ErrInvalidArgument,`out of index range: pos: ${t} > node.length: ${e.getLength()}`);return this.splayNode(e),[e,t]}indexOf(t){return!t||t!==this.root&&!t.hasLinks()?-1:(this.splayNode(t),this.root.getLeftWeight())}getRoot(){return this.root}insert(t){return this.insertAfter(this.root,t)}insertAfter(t,e){return t?(this.splayNode(t),this.root=e,e.setRight(t.getRight()),t.hasRight()&&t.getRight().setParent(e),e.setLeft(t),t.setParent(e),t.setRight(),this.updateWeight(t),this.updateWeight(e),e):(this.root=e,e)}updateWeight(t){t.initWeight(),t.hasLeft()&&t.increaseWeight(t.getLeftWeight()),t.hasRight()&&t.increaseWeight(t.getRightWeight())}updateTreeWeight(t){for(;t;)this.updateWeight(t),t=t.getParent()}splayNode(t){if(t)for(;;)if(this.isLeftChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t),this.rotateLeft(t);else if(this.isLeftChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t.getParent()),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t.getParent()),this.rotateLeft(t);else{this.isLeftChild(t)?this.rotateRight(t):this.isRightChild(t)&&this.rotateLeft(t),this.updateWeight(t);return}}delete(t){this.splayNode(t);const e=new _r(t.getLeft());e.root&&e.root.setParent();const r=new _r(t.getRight());if(r.root&&r.root.setParent(),e.root){const s=e.getRightmost();e.splayNode(s),e.root.setRight(r.root),r.root&&r.root.setParent(e.root),this.root=e.root}else this.root=r.root;t.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(t,e){if(!e){this.splayNode(t),this.cutOffRight(t);return}this.splayNode(t),this.splayNode(e),e.getLeft()!=t&&this.rotateRight(t),this.cutOffRight(t)}cutOffRight(t){const e=[];this.traversePostorder(t.getRight(),e);for(const r of e)r.initWeight();this.updateTreeWeight(t)}toTestString(){const t=[];return this.traverseInorder(this.root,t),t.map(e=>`[${e.getWeight()},${e.getLength()}]${e.getValue()||""}`).join("")}checkWeight(){const t=[];this.traverseInorder(this.root,t);for(const e of t)if(e.getWeight()!=e.getLength()+e.getLeftWeight()+e.getRightWeight())return!1;return!0}getRightmost(){let t=this.root;for(;t.hasRight();)t=t.getRight();return t}traverseInorder(t,e){t&&(this.traverseInorder(t.getLeft(),e),e.push(t),this.traverseInorder(t.getRight(),e))}traversePostorder(t,e){t&&(this.traversePostorder(t.getLeft(),e),this.traversePostorder(t.getRight(),e),e.push(t))}rotateLeft(t){const e=t.getParent();e.hasParent()?e===e.getParent().getLeft()?e.getParent().setLeft(t):e.getParent().setRight(t):this.root=t,t.setParent(e.getParent()),e.setRight(t.getLeft()),e.hasRight()&&e.getRight().setParent(e),t.setLeft(e),t.getLeft().setParent(t),this.updateWeight(e),this.updateWeight(t)}rotateRight(t){const e=t.getParent();e.hasParent()?e===e.getParent().getLeft()?e.getParent().setLeft(t):e.getParent().setRight(t):this.root=t,t.setParent(e.getParent()),e.setLeft(t.getRight()),e.hasLeft()&&e.getLeft().setParent(e),t.setRight(e),t.getRight().setParent(t),this.updateWeight(e),this.updateWeight(t)}isLeftChild(t){return t&&t.hasParent()?t.getParent().getLeft()===t:!1}isRightChild(t){return t&&t.hasParent()?t.getParent().getRight()===t:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -19,8 +19,8 @@ var la=Object.defineProperty;var ha=(n,t,e)=>t in n?la(n,t,{enumerable:!0,config * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var Te=null;try{Te=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function O(n,t,e){this.low=n|0,this.high=t|0,this.unsigned=!!e}O.prototype.__isLong__;Object.defineProperty(O.prototype,"__isLong__",{value:!0});function _(n){return(n&&n.__isLong__)===!0}function $i(n){var t=Math.clz32(n&-n);return n?31-t:t}O.isLong=_;var Ui={},qi={};function Ar(n,t){var e,r,s;return t?(n>>>=0,(s=0<=n&&n<256)&&(r=qi[n],r)?r:(e=B(n,0,!0),s&&(qi[n]=e),e)):(n|=0,(s=-128<=n&&n<128)&&(r=Ui[n],r)?r:(e=B(n,n<0?-1:0,!1),s&&(Ui[n]=e),e))}O.fromInt=Ar;function Ae(n,t){if(isNaN(n))return t?Xt:xe;if(t){if(n<0)return Xt;if(n>=Bo)return Jo}else{if(n<=-Vi)return re;if(n+1>=Vi)return Lo}return n<0?Ae(-n,t).neg():B(n%Jr|0,n/Jr|0,t)}O.fromNumber=Ae;function B(n,t,e){return new O(n,t,e)}O.fromBits=B;var Vn=Math.pow;function Ws(n,t,e){if(n.length===0)throw Error("empty string");if(typeof t=="number"?(e=t,t=!1):t=!!t,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return t?Xt:xe;if(e=e||10,e<2||360)throw Error("interior hyphen");if(r===0)return Ws(n.substring(1),t,e).neg();for(var s=Ae(Vn(e,8)),i=xe,o=0;o>>0:this.low};T.toNumber=function(){return this.unsigned?(this.high>>>0)*Jr+(this.low>>>0):this.high*Jr+(this.low>>>0)};T.toString=function(t){if(t=t||10,t<2||36>>0,f=h.toString(t);if(o=l,o.isZero())return f+c;for(;f.length<6;)f="0"+f;c=""+f+c}};T.getHighBits=function(){return this.high};T.getHighBitsUnsigned=function(){return this.high>>>0};T.getLowBits=function(){return this.low};T.getLowBitsUnsigned=function(){return this.low>>>0};T.getNumBitsAbs=function(){if(this.isNegative())return this.eq(re)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&!(t&1<=0};T.isOdd=function(){return(this.low&1)===1};T.isEven=function(){return(this.low&1)===0};T.equals=function(t){return _(t)||(t=De(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};T.eq=T.equals;T.notEquals=function(t){return!this.eq(t)};T.neq=T.notEquals;T.ne=T.notEquals;T.lessThan=function(t){return this.comp(t)<0};T.lt=T.lessThan;T.lessThanOrEqual=function(t){return this.comp(t)<=0};T.lte=T.lessThanOrEqual;T.le=T.lessThanOrEqual;T.greaterThan=function(t){return this.comp(t)>0};T.gt=T.greaterThan;T.greaterThanOrEqual=function(t){return this.comp(t)>=0};T.gte=T.greaterThanOrEqual;T.ge=T.greaterThanOrEqual;T.compare=function(t){if(_(t)||(t=De(t)),this.eq(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};T.comp=T.compare;T.negate=function(){return!this.unsigned&&this.eq(re)?re:this.not().add(Er)};T.neg=T.negate;T.add=function(t){_(t)||(t=De(t));var e=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=t.high>>>16,c=t.high&65535,l=t.low>>>16,h=t.low&65535,f=0,g=0,v=0,p=0;return p+=i+h,v+=p>>>16,p&=65535,v+=s+l,g+=v>>>16,v&=65535,g+=r+c,f+=g>>>16,g&=65535,f+=e+o,f&=65535,B(v<<16|p,f<<16|g,this.unsigned)};T.subtract=function(t){return _(t)||(t=De(t)),this.add(t.neg())};T.sub=T.subtract;T.multiply=function(t){if(this.isZero())return this;if(_(t)||(t=De(t)),Te){var e=Te.mul(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Xt:xe;if(this.eq(re))return t.isOdd()?re:xe;if(t.eq(re))return this.isOdd()?re:xe;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Ki)&&t.lt(Ki))return Ae(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,o=this.low&65535,c=t.high>>>16,l=t.high&65535,h=t.low>>>16,f=t.low&65535,g=0,v=0,p=0,w=0;return w+=o*f,p+=w>>>16,w&=65535,p+=i*f,v+=p>>>16,p&=65535,p+=o*h,v+=p>>>16,p&=65535,v+=s*f,g+=v>>>16,v&=65535,v+=i*h,g+=v>>>16,v&=65535,v+=o*l,g+=v>>>16,v&=65535,g+=r*f+s*h+i*l+o*c,g&=65535,B(p<<16|w,g<<16|v,this.unsigned)};T.mul=T.multiply;T.divide=function(t){if(_(t)||(t=De(t)),t.isZero())throw Error("division by zero");if(Te){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?Te.div_u:Te.div_s)(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Xt:xe;var r,s,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Xt;if(t.gt(this.shru(1)))return Ro;i=Xt}else{if(this.eq(re)){if(t.eq(Er)||t.eq(Js))return re;if(t.eq(re))return Er;var o=this.shr(1);return r=o.div(t).shl(1),r.eq(xe)?t.isNegative()?Er:Js:(s=this.sub(t.mul(r)),i=r.add(s.div(t)),i)}else if(t.eq(re))return this.unsigned?Xt:xe;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=xe}for(s=this;s.gte(t);){r=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(r)/Math.LN2),l=c<=48?1:Vn(2,c-48),h=Ae(r),f=h.mul(t);f.isNegative()||f.gt(s);)r-=l,h=Ae(r,this.unsigned),f=h.mul(t);h.isZero()&&(h=Er),i=i.add(h),s=s.sub(f)}return i};T.div=T.divide;T.modulo=function(t){if(_(t)||(t=De(t)),Te){var e=(this.unsigned?Te.rem_u:Te.rem_s)(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};T.mod=T.modulo;T.rem=T.modulo;T.not=function(){return B(~this.low,~this.high,this.unsigned)};T.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};T.clz=T.countLeadingZeros;T.countTrailingZeros=function(){return this.low?$i(this.low):$i(this.high)+32};T.ctz=T.countTrailingZeros;T.and=function(t){return _(t)||(t=De(t)),B(this.low&t.low,this.high&t.high,this.unsigned)};T.or=function(t){return _(t)||(t=De(t)),B(this.low|t.low,this.high|t.high,this.unsigned)};T.xor=function(t){return _(t)||(t=De(t)),B(this.low^t.low,this.high^t.high,this.unsigned)};T.shiftLeft=function(t){return _(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low<>>32-t,this.unsigned):B(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):B(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};T.shr=T.shiftRight;T.shiftRightUnsigned=function(t){return _(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?B(this.high,0,this.unsigned):B(this.high>>>t-32,0,this.unsigned)};T.shru=T.shiftRightUnsigned;T.shr_u=T.shiftRightUnsigned;T.rotateLeft=function(t){var e;return _(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(e=32-t,B(this.low<>>e,this.high<>>e,this.unsigned)):(t-=32,e=32-t,B(this.high<>>e,this.low<>>e,this.unsigned))};T.rotl=T.rotateLeft;T.rotateRight=function(t){var e;return _(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(e=32-t,B(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,e=32-t,B(this.low<>>t,this.high<>>t,this.unsigned))};T.rotr=T.rotateRight;T.toSigned=function(){return this.unsigned?B(this.low,this.high,!1):this};T.toUnsigned=function(){return this.unsigned?this:B(this.low,this.high,!0)};T.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};T.toBytesLE=function(){var t=this.high,e=this.low;return[e&255,e>>>8&255,e>>>16&255,e>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};T.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,e>>>24,e>>>16&255,e>>>8&255,e&255]};O.fromBytes=function(t,e,r){return r?O.fromBytesLE(t,e):O.fromBytesBE(t,e)};O.fromBytesLE=function(t,e){return new O(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};O.fromBytesBE=function(t,e){return new O(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)};var H=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(H||{});class U extends sn{constructor(e,r){super(r);a(this,"valueType");a(this,"value");this.valueType=U.getPrimitiveType(e),this.value=e===void 0?null:e}static of(e,r){return new U(e,r)}static valueFromBytes(e,r){switch(e){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const s=new DataView(r.buffer);return r.forEach(function(i,o){s.setUint8(o,i)}),s.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return O.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(O.fromBytesLE(Array.from(r),!0).toNumber());default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return this.valueType===5?`"${Ve(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const e=U.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(e)?2:4;case"string":return 5;case"object":if(e===null)return 0;if(e instanceof O)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return U.getPrimitiveType(e)!==void 0}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===2||e===3||e===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 4:{const e=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,e,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const e=this.value,r=O.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new m(d.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class Kn extends Oo{constructor(e){super(e);a(this,"prev");a(this,"next");this.value=e}static createAfter(e,r){const s=new Kn(r),i=e.next;return e.next=s,s.prev=e,s.next=i,i&&(i.prev=s),s}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class en{constructor(){a(this,"dummyHead");a(this,"last");a(this,"nodeMapByIndex");a(this,"nodeMapByCreatedAt");const t=U.of(0,Ne);t.setRemovedAt(Ne),this.dummyHead=new Kn(t),this.last=this.dummyHead,this.nodeMapByIndex=new _r,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new en}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,e){let r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new m(d.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(e);)r=r.getNext();return r}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,e,r=e.getCreatedAt()){const s=this.findNextBeforeExecutedAt(t,r),i=Kn.createAfter(s,e);s===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(s,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(t,e,r){const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new m(d.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new m(d.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);s!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(s.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return String(this.nodeMapByIndex.indexOf(e))}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new m(d.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(e)}getByIndex(t){if(t>=this.length)return;const[e,r]=this.nodeMapByIndex.find(t);let s=e;if(t===0&&e===this.dummyHead||r>0)do s&&(s=s.getNext());while(s&&s.isRemoved());return s}getPrevCreatedAt(t){let e=this.nodeMapByCreatedAt.get(t.toIDString());do e=e.getPrev();while(this.dummyHead!==e&&e.isRemoved());return e.getValue().getCreatedAt()}delete(t,e){const r=this.nodeMapByCreatedAt.get(t.toIDString()),s=r.isRemoved();return r.remove(e)&&!s&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(t,e){const r=this.getByIndex(t);if(r)return r.remove(e)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const e of this){const r=`${e.getCreatedAt().toIDString()}:${e.getValue().toJSON()}`;e.isRemoved()?t.push(`{${r}}`):t.push(`[${r}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class ae extends ar{constructor(e,r){super(e);a(this,"elements");this.elements=r}static create(e,r){if(!r)return new ae(e,en.create());const s=en.create();for(const i of r)s.insertAfter(s.getLastCreatedAt(),i.deepcopy());return new ae(e,s)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,r){this.elements.insertAfter(e,r)}moveAfter(e,r,s){this.elements.moveAfter(e,r,s)}get(e){const r=this.elements.getByIndex(e);return r==null?void 0:r.getValue()}getByID(e){const r=this.elements.getByID(e);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,r){return this.elements.delete(e,r)}deleteByIndex(e,r){return this.elements.deleteByIndex(e,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(const r of this.elements){const s=r.getValue();if(e(s,this))return;s instanceof ar&&s.getDescendants(e)}}toJSON(){const e=[];for(const r of this)e.push(r.toJSON());return`[${e.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(let r=0;r({...w,value:w.value?{attributes:Cr(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[f,p,g,[h,h]]}setStyle(e,r,s,i,o){const[,c]=this.rgaTreeSplit.findNodeWithSplit(e[1],s),[,l]=this.rgaTreeSplit.findNodeWithSplit(e[0],s),h=[],f=this.rgaTreeSplit.findBetween(l,c),g=new Map,v=[];for(const w of f){const b=w.getCreatedAt().getActorID();let x,C=0n;if(o===void 0&&i===void 0?C=jr:o.size()>0?C=o.get(b)?o.get(b):0n:x=i.has(b)?i.get(b):Ne,w.canStyle(s,x,C)){const P=g.get(b),L=w.getCreatedAt();(!P||L.after(P))&&g.set(b,L),v.push(w)}}const p=[];for(const w of v){if(w.isRemoved())continue;const[b,x]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());h.push({type:"style",actor:s.getActorID(),from:b,to:x,value:{attributes:Cr(r)}});for(const[C,P]of Object.entries(r)){const[L]=w.getValue().setAttr(C,P,s);L!==void 0&&p.push({parent:w.getValue(),child:L})}}return[g,p,h]}indexRangeToPosRange(e,r){const s=this.rgaTreeSplit.indexToPos(e);return e===r?[s,s]:[s,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const e=[];for(const r of this.rgaTreeSplit)r.isRemoved()||e.push(r.getValue().toJSON());return`[${e.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const e=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const s=r.getValue();e.push({attributes:Cr(s.getAttributes()),content:s.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const e=new Ie(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){const e=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:r});for(const s of r.getValue().getGCPairs())e.push(s)}return e}}class an extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"content");a(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.content=o,this.attributes=c}static create(e,r,s,i,o,c,l){return new an(e,r,s,i,o,c,l)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Ie))throw new m(d.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,c,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,s);for(const h of l)e.registerGCPair(h);return{opInfos:c.map(({from:h,to:f,value:g})=>({type:"edit",from:h,to:f,value:g,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.content;return`${e}.EDIT(${r},${s},${i})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class cn extends Pe{constructor(e,r,s,i,o,c){super(e,c);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o}static create(e,r,s,i,o,c){return new cn(e,r,s,i,o,c)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Ie))throw new m(d.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,c,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,s);for(const h of c)e.registerGCPair(h);return{opInfos:l.map(({from:h,to:f,value:g})=>({type:"style",from:h,to:f,value:g,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.attributes;return`${e}.STYL(${r},${s},${JSON.stringify(i)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const Uc=2,qc="root",Zt="text";function qr(n,t){let e=0;const r=n.children;for(let s=0;s0)throw new m(d.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const e=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*e,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const e of this._children){const r=e.updateDescendantsSize();e.isRemoved||(t+=r)}return this.size+=t,this.paddedSize}get isText(){return this.type===Zt}get paddedSize(){return this.size+(this.isText?0:Uc)}isAncestorOf(t){return Vc(this,t)}get nextSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t+1];if(e)return e}get prevSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t-1];if(e)return e}splitText(t,e){if(t===0||t===this.size)return;const r=this.value.slice(0,t),s=this.value.slice(t);if(!s.length)return;this.value=r;const i=this.cloneText(t+e);return i.value=s,this.parent.insertAfterInternal(i,this),i}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const e of t)e.parent=this,e.updateAncestorsSize()}prepend(...t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const e of t)e.parent=this}insertBefore(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r),t.updateAncestorsSize()}insertAfter(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1),t.updateAncestorsSize()}insertAt(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,e),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const e=this._children.indexOf(t);if(e===-1)throw new m(d.ErrInvalidArgument,"child not found");this._children.splice(e,1),t.parent=void 0}splitElement(t,e){const r=this.cloneElement(e);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const s=this.children.slice(0,t),i=this.children.slice(t);this._children=s,r._children=i,this.size=this._children.reduce((o,c)=>o+c.paddedSize,0),r.size=r._children.reduce((o,c)=>o+c.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1)}insertAtInternal(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.splice(e,0,t),t.parent=this}findOffset(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");if(t.isRemoved){const e=this._children.indexOf(t);return this.allChildren.splice(0,e).filter(s=>!s.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");let e=t;for(;e;){const r=this._children.indexOf(e);if(r!==-1)return r;e=e.parent}return-1}}function Vc(n,t){if(n===t)return!1;for(;t.parent;){if(t.parent===n)return!0;t=t.parent}return!1}var W=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(W||{});function Fo(n,t,e,r){if(t>e)throw new m(d.ErrInvalidArgument,`from is greater than to: ${t} > ${e}`);if(t>n.size)throw new m(d.ErrInvalidArgument,`from is out of range: ${t} > ${n.size}`);if(e>n.size)throw new m(d.ErrInvalidArgument,`to is out of range: ${e} > ${n.size}`);if(t===e)return;let s=0;for(const i of n.children){if(t-i.paddedSizei.size;(i.isText||l)&&r([i,i.isText?"Text":"Start"],h),Fo(i,Math.max(0,o),Math.min(c,i.size),r),h&&r([i,"End"],h)}s+=i.paddedSize}}function Mo(n,t,e=0){for(const r of n.children)Mo(r,t,e+1);t(n,e)}function Xn(n,t,e=0){for(const r of n._children)Xn(r,t,e+1);t(n,e)}function Fs(n,t,e=!0){if(t>n.size)throw new m(d.ErrInvalidArgument,`index is out of range: ${t} > ${n.size}`);if(n.isText)return{node:n,offset:t};let r=0,s=0;for(const i of n.children){if(e&&i.isText&&i.size>=t-s)return Fs(i,t-s,e);if(t===s)return{node:n,offset:r};if(!e&&i.paddedSize===t-s)return{node:n,offset:r+1};if(i.paddedSize>t-s)return Fs(i,t-s-1,e);s+=i.paddedSize,r+=1}return{node:n,offset:r}}function $o(n){return n.isText||n.children.length===0?n:$o(n.children[0])}function Kc(n,t){if(n.sizen===t?0:n0)if(e.right)e.right.parent=e,e=e.right;else return e;else if(r<0)if(e.left)e.left.parent=e,e=e.left;else{let s=e.parent,i=e;for(;s&&i===s.left;)i=s,s=s.parent;return s}else return e}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,e){for(;e;){const r=this.comparator(t,e.key);if(r===0)return e;r<0?e=e.left:r>0&&(e=e.right)}}putInternal(t,e,r){if(!r)return this.counter+=1,new Wc(t,e,!0);const s=this.comparator(t,r.key);return s<0?r.left=this.putInternal(t,e,r.left):s>0?r.right=this.putInternal(t,e,r.right):r.value=e,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(t,e){if(this.comparator(e,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,e);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(e,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(e,t.key)===0){this.counter-=1;const r=this.min(t.right);t.value=r.value,t.key=r.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,e)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const e=t.right;return t.right=e.left,e.left=t,e.isRed=e.left.isRed,e.left.isRed=!0,e}rotateRight(t){const e=t.left;return t.left=e.right,e.right=t,e.isRed=e.right.isRed,e.right.isRed=!0,e}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class Ee{constructor(t,e){a(this,"parentID");a(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=e}static of(t,e){return new Ee(t,e)}static fromTreePos(t){const{offset:e}=t;let{node:r}=t,s;return r.isText?(r.parent.children[0]===r&&e===0?s=r.parent:s=r,r=r.parent):e===0?s=r:s=r.children[e-1],Ee.of(r.id,Z.of(s.getCreatedAt(),s.getOffset()+e))}getParentID(){return this.parentID}static fromStruct(t){return Ee.of(Z.of(be.fromStruct(t.parentID.createdAt),t.parentID.offset),Z.of(be.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const e=this.getParentID(),r=this.getLeftSiblingID(),s=t.findFloorNode(e);let i=t.findFloorNode(r);if(!s||!i)throw new m(d.ErrRefused,`cannot find node of CRDTTreePos(${e.toTestString()}, ${r.toTestString()})`);return!r.equals(e)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=t.findFloorNode(i.insPrevID)),[s,i]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class Z{constructor(t,e){a(this,"createdAt");a(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new Z(t,e)}static fromStruct(t){return Z.of(be.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,e)=>{const r=t.getCreatedAt().compare(e.getCreatedAt());return r!==0?r:t.getOffset()>e.getOffset()?1:t.getOffset(){const i=s.deepcopy();return i.parent=e,i}),e.insPrevID=this.insPrevID,e.insNextID=this.insNextID,e}get value(){if(!this.isText)throw new m(d.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(e){if(!this.isText)throw new m(d.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),r&&this.updateAncestorsSize()}cloneText(e){return new oe(Z.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new oe(Z.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,r,s){const i=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,s);if(i){if(i.insPrevID=this.id,this.insNextID){const o=e.findFloorNode(this.insNextID);o.insPrevID=i.id,i.insNextID=this.insNextID}this.insNextID=i.id,e.registerNode(i)}return i}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,r,s){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,r,s){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,r){this.attrs||(this.attrs=new er);const s=[];for(const[i,o]of Object.entries(e))s.push(this.attrs.set(i,o,r));return s}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){const e=[];if(!this.attrs)return e;for(const r of this.attrs)r.getRemovedAt()&&e.push({parent:this,child:r});return e}}function Ms(n){var e;if(n.isText){const r=n;return{type:r.type,value:r.value}}const t={type:n.type,children:n.children.map(Ms)};return n.attrs&&(t.attributes=Cr((e=n.attrs)==null?void 0:e.toObject())),t}function Hs(n){if(n.isText)return n.value;let t="";return n.attrs&&n.attrs.size()&&(t=" "+Array.from(n.attrs).filter(e=>!e.isRemoved()).sort((e,r)=>e.getKey().localeCompare(r.getKey())).map(e=>{const r=JSON.parse(e.getValue());return typeof r=="string"?`${e.getKey()}="${r}"`:`${e.getKey()}="${Ve(e.getValue())}"`}).join(" ")),`<${n.type}${t}>${n.children.map(e=>Hs(e)).join("")}`}function qo(n){if(n.isText){const t=n;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:n.type,children:n.children.map(qo),size:n.size,isRemoved:n.isRemoved}}class Se extends sn{constructor(e,r){super(r);a(this,"indexTree");a(this,"nodeMapByID");this.indexTree=new jc(e),this.nodeMapByID=new Uo(Z.createComparator()),this.indexTree.traverseAll(s=>{this.nodeMapByID.put(s.id,s)})}static create(e,r){return new Se(e,r)}findFloorNode(e){const r=this.nodeMapByID.floorEntry(e);if(!(!r||!r.key.getCreatedAt().equals(e.getCreatedAt())))return r.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,r){const[s,i]=e.toTreeNodePair(this);let o=i;const c=s===o,l=o.parent&&!c?o.parent:s;if(o.isText&&o.split(this,e.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const h=l.allChildren,f=c?0:h.indexOf(o)+1;for(let g=f;g{const x=b.getCreatedAt().getActorID();let C,P=0n;if(o===void 0&&i===void 0?P=jr:o.size()>0?P=o.get(x)?o.get(x):0n:C=i.has(x)?i.get(x):Ne,b.canStyle(s,C,P)&&r){const L=p.get(x),Y=b.getCreatedAt();(!L||Y.after(L))&&p.set(x,Y);const D=b.setAttrs(r,s),F=D.reduce((ue,[,Ge])=>(Ge&&(ue[Ge.getKey()]=v[Ge.getKey()]),ue),{}),V=b.parent,K=b.prevSibling||b.parent;Object.keys(F).length>0&&g.push({type:"style",from:this.toIndex(V,K),to:this.toIndex(b,b),fromPath:this.toPath(V,K),toPath:this.toPath(b,b),actor:s.getActorID(),value:F});for(const[ue]of D)ue&&w.push({parent:b,child:ue})}}),[p,w,g]}removeStyle(e,r,s,i,o){const[c,l]=this.findNodesAndSplitText(e[0],s),[h,f]=this.findNodesAndSplitText(e[1],s),g=[],v=new Map,p=[];return this.traverseInPosRange(c,l,h,f,([w])=>{const b=w.getCreatedAt().getActorID();let x,C=0n;if(o===void 0&&i===void 0?C=jr:o.size()>0?C=o.get(b)?o.get(b):0n:x=i.has(b)?i.get(b):Ne,w.canStyle(s,x,C)&&r){const P=v.get(b),L=w.getCreatedAt();(!P||L.after(P))&&v.set(b,L),w.attrs||(w.attrs=new er);for(const F of r){const V=w.attrs.remove(F,s);for(const K of V)p.push({parent:w,child:K})}const Y=w.parent,D=w.prevSibling||w.parent;g.push({actor:s.getActorID(),type:"removeStyle",from:this.toIndex(Y,D),to:this.toIndex(w,w),fromPath:this.toPath(Y,D),toPath:this.toPath(w,w),value:r})}}),[v,p,g]}edit(e,r,s,i,o,c,l){const[h,f]=this.findNodesAndSplitText(e[0],i),[g,v]=this.findNodesAndSplitText(e[1],i),p=this.toIndex(h,f),w=this.toPath(h,f),b=[],x=[],C=[],P=new Map;this.traverseInPosRange(h,f,g,v,([D,F],V)=>{if(F===W.Start&&!V)for(const br of D.children)C.push(br);const K=D.getCreatedAt().getActorID();let ue,Ge=0n;if(l===void 0&&c===void 0?Ge=jr:l.size()>0?Ge=l.get(K)?l.get(K):0n:ue=c.has(K)?c.get(K):Ne,D.canDelete(i,ue,Ge)||b.includes(D.parent)){const br=P.get(K),ai=D.getCreatedAt();(!br||ai.after(br))&&P.set(K,ai),(F===W.Text||F===W.Start)&&b.push(D),x.push([D,F])}});const L=this.makeDeletionChanges(x,i),Y=[];for(const D of b)D.remove(i),D.isRemoved&&Y.push({parent:this,child:D});for(const D of C)D.removedAt||h.append(D);if(s>0){let D=0,F=h,V=f;for(;D{h.isRemoved&&(K.remove(i),Y.push({parent:this,child:K})),this.nodeMapByID.put(K.id,K)}),V.isRemoved||D.push(V);if(D.length){const V=D.map(K=>Ms(K));L.length&&L[L.length-1].from===p?L[L.length-1].value=V:L.push({type:"content",from:p,to:p,fromPath:w,toPath:w,actor:i.getActorID(),value:V})}}return[L,Y,P]}editT(e,r,s,i,o){const c=this.findPos(e[0]),l=this.findPos(e[1]);this.edit([c,l],r,s,i,o)}move(e,r,s){throw new m(d.ErrUnimplemented,`not implemented: ${e}, ${r}, ${s}`)}purge(e){var i;(i=e.parent)==null||i.removeChild(e),this.nodeMapByID.remove(e.id);const r=e.insPrevID,s=e.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=s}if(s){const o=this.findFloorNode(s);o.insPrevID=r}e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){const e=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&e.push({parent:this,child:r});for(const s of r.getGCPairs())e.push(s)}),e}findPos(e,r=!0){const s=this.indexTree.findTreePos(e,r);return Ee.fromTreePos(s)}pathToPosRange(e){const r=this.pathToIndex(e);return[this.findPos(r),this.findPos(r+1)]}pathToPos(e){const r=this.indexTree.pathToIndex(e);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Hs(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const e=this.indexTree.getRoot(),r=(s,i=void 0,o=void 0,c=0)=>{var p,w,b,x;let l,h,f;const g=s.isText?{node:s,offset:0}:i&&o?this.toTreePos(i,o):null;g&&(l=this.indexTree.indexOf(g),h=this.indexTree.treePosToPath(g),f=Ee.fromTreePos(g).toStruct());const v={type:s.type,parent:i==null?void 0:i.id.toTestString(),size:s.size,id:s.id.toTestString(),removedAt:(p=s.removedAt)==null?void 0:p.toTestString(),insPrev:(w=s.insPrevID)==null?void 0:w.toTestString(),insNext:(b=s.insNextID)==null?void 0:b.toTestString(),value:s.isText?s.value:void 0,isRemoved:s.isRemoved,children:[],depth:c,attributes:s.attrs?Cr((x=s.attrs)==null?void 0:x.toObject()):void 0,index:l,path:h,pos:f};for(let C=0;C0&&C===s[s.length-1].to?(s[s.length-1].to=P,s[s.length-1].toPath=this.toPath(x,p)):s.push({type:"content",from:C,to:P,fromPath:this.toPath(b,g),toPath:this.toPath(x,p),actor:r.getActorID()}))}return s.reverse()}findRightToken([e,r]){if(r===W.Start){const l=e.allChildren;return l.length>0?[l[0],l[0].isText?W.Text:W.Start]:[e,W.End]}const s=e.parent,i=s.allChildren,o=i.indexOf(e);if(s&&o===i.length-1)return[s,W.End];const c=i[o+1];return[c,c.isText?W.Text:W.Start]}findLeftToken([e,r]){if(r===W.End){const l=e.allChildren;if(l.length>0){const h=l[l.length-1];return[h,h.isText?W.Text:W.End]}return[e,W.Start]}const s=e.parent,i=s.allChildren,o=i.indexOf(e);if(s&&o===0)return[s,W.Start];const c=i[o-1];return[c,c.isText?W.Text:W.End]}}class un extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"contents");a(this,"splitLevel");a(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=s,this.contents=i,this.splitLevel=o,this.maxCreatedAtMapByActor=c}static create(e,r,s,i,o,c,l){return new un(e,r,s,i,o,c,l)}execute(e,r,s){var f;const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Se))throw new m(d.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),c=i,[l,h]=c.edit([this.fromPos,this.toPos],(f=this.contents)==null?void 0:f.map(g=>g.deepcopy()),this.splitLevel,o,(()=>{let g=o.getDelimiter();return this.contents!==void 0&&(g+=this.contents.length),()=>be.of(o.getLamport(),++g,o.getActorID())})(),this.maxCreatedAtMapByActor,s);for(const g of h)e.registerGCPair(g);return{opInfos:l.map(({from:g,to:v,value:p,splitLevel:w,fromPath:b,toPath:x})=>({type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:g,to:v,value:p,splitLevel:w,fromPath:b,toPath:x}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,i=this.contents||[];return`${e}.EDIT(${r},${s},${i.map(o=>Hs(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Pr{constructor(t){a(this,"vector");this.vector=t||new Map}set(t,e){this.vector.set(t,e)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,e]of this)e>t&&(t=e);return t}max(t){const e=new Map;for(const[r,s]of t){const i=this.vector.get(r),o=i&&i>s?i:s;e.set(r,o)}for(const[r,s]of this){const i=t.get(r),o=i&&i>s?i:s;e.set(r,o)}return new Pr(e)}afterOrEqual(t){const e=this.vector.get(t.getActorID());return e===void 0?!1:e>=t.getLamport()}deepcopy(){const t=new Map;for(const[e,r]of this.vector)t.set(e,r);return new Pr(t)}filter(t){const e=new Map;for(const[r]of t){const s=this.vector.get(r);s!==void 0&&e.set(r,s)}return new Pr(e)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,e]of this.vector)yield[t,e]}}const Yc=new Pr(new Map);class Gt{constructor(t,e,r,s,i){a(this,"clientSeq");a(this,"serverSeq");a(this,"lamport");a(this,"actor");a(this,"versionVector");this.clientSeq=t,this.serverSeq=i,this.lamport=e,this.versionVector=s,this.actor=r}static of(t,e,r,s,i){return new Gt(t,e,r,s,i)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new Gt(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const e=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n,r=this.versionVector.max(t.versionVector),s=new Gt(this.clientSeq,e,this.actor,r);return s.versionVector.set(this.actor,e),s}setClocks(t,e){const r=t>this.lamport?t:this.lamport+1n,s=this.versionVector.max(e);return s.set(this.actor,r),Gt.of(this.clientSeq,r,this.actor,s)}createTimeTicket(t){return be.of(this.lamport,t,this.actor)}setActor(t){return new Gt(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new Gt(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const Xc=new Gt(0,0n,js,Yc);class Fr{constructor({id:t,operations:e,presenceChange:r,message:s}){a(this,"id");a(this,"operations");a(this,"presenceChange");a(this,"message");this.id=t,this.operations=e||[],this.presenceChange=r,this.message=s}static create({id:t,operations:e,presenceChange:r,message:s}){return new Fr({id:t,operations:e,presenceChange:r,message:s})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const e of this.operations)e.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,e,r){const s=[],i=[];for(const o of this.operations){const c=o.execute(t,r,this.id.getVersionVector());if(!c)continue;const{opInfos:l,reverseOp:h}=c;s.push(...l),h&&i.unshift(h)}return this.presenceChange&&(this.presenceChange.type===lr.Put?e.set(this.id.getActorID(),ke(this.presenceChange.presence)):e.delete(this.id.getActorID())),{opInfos:s,reverseOps:i}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:j.bytesToHex(j.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>j.bytesToHex(j.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:e,operations:r,presenceChange:s,message:i}=t;return Fr.create({id:j.bytesToChangeID(j.hexToBytes(e)),operations:r==null?void 0:r.map(o=>j.bytesToOperation(j.hexToBytes(o))),presenceChange:s,message:i})}}class Zn{constructor(t,e,r,s,i,o,c){a(this,"documentKey");a(this,"checkpoint");a(this,"isRemoved");a(this,"changes");a(this,"snapshot");a(this,"minSyncedTicket");a(this,"versionVector");this.documentKey=t,this.checkpoint=e,this.isRemoved=r,this.changes=s,this.snapshot=o,this.minSyncedTicket=c,this.versionVector=i}static create(t,e,r,s,i,o,c){return new Zn(t,e,r,s,i,o,c)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Dr{constructor(t,e){a(this,"serverSeq");a(this,"clientSeq");this.serverSeq=t,this.clientSeq=e}static of(t,e){return new Dr(t,e)}increaseClientSeq(t){return t===0?this:new Dr(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const e=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,r=Math.max(this.clientSeq,t.clientSeq);return Dr.of(e,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const Zc=new Dr(0n,0);class Ke{constructor(t,e){a(this,"createdAt");a(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new Ke(t,e)}static fromStruct(t){return Ke.of(be.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new Ke(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Qc=Ke.of(Ne,0);class Ce{constructor(t,e){a(this,"id");a(this,"relativeOffset");this.id=t,this.relativeOffset=e}static of(t,e){return new Ce(t,e)}static fromStruct(t){const e=Ke.fromStruct(t.id);return Ce.of(e,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return Ke.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class cr extends Oo{constructor(e,r,s){super(r);a(this,"id");a(this,"removedAt");a(this,"prev");a(this,"next");a(this,"insPrev");a(this,"insNext");this.id=e,this.removedAt=s}static create(e,r){return new cr(e,r)}static createComparator(){return(e,r)=>{const s=e.getCreatedAt().compare(r.getCreatedAt());return s!==0?s:e.getOffset()>r.getOffset()?1:e.getOffset()0&&e.getID().getOffset()==t.getOffset()){if(!e.hasInsPrev())return e;e=e.getInsPrev()}return e}findFloorNode(t){const e=this.treeByID.floorEntry(t);if(e&&!(!e.key.equals(t)&&!e.key.hasSameCreatedAt(t)))return e.value}findBetween(t,e){const r=[];let s=t;for(;s&&s!==e;)r.push(s),s=s.getNext();return r}splitNode(t,e){if(e>t.getContentLength())throw new m(d.ErrInvalidArgument,"offset should be less than or equal to length");if(e===0)return t;if(e===t.getContentLength())return t.getNext();const r=t.split(e);this.treeByIndex.updateWeight(r),this.insertAfter(t,r);const s=t.getInsNext();return s&&s.setInsPrev(r),r.setInsPrev(t),r}deleteNodes(t,e,r,s){if(!t.length)return[[],new Map,new Map];const[i,o]=this.filterNodes(t,e,r,s),c=new Map,l=new Map,h=this.makeChanges(o,e);for(const f of i){const g=f.getCreatedAt().getActorID();(!c.has(g)||f.getID().getCreatedAt().after(c.get(g)))&&c.set(g,f.getID().getCreatedAt()),l.set(f.getID().toIDString(),f),f.remove(e)}return this.deleteIndexNodes(o),[h,c,l]}filterNodes(t,e,r,s){const i=[],o=[],[c,l]=this.findEdgesOfCandidates(t);o.push(c);for(const h of t){const f=h.getCreatedAt().getActorID();let g,v=0n;s===void 0&&r===void 0?v=jr:s.size()>0?v=s.get(f)?s.get(f):0n:g=r.has(f)?r.get(f):Ne,h.canDelete(e,g,v)?i.push(h):o.push(h)}return o.push(l),[i,o]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,e){const r=[];let s,i;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var je=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(je||{});class ce extends sn{constructor(e,r,s){super(s);a(this,"valueType");a(this,"value");switch(this.valueType=e,e){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=O.fromNumber(r).toInt():this.value=ji(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=O.fromNumber(r):this.value=r;break;default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}static create(e,r,s){return new ce(e,r,s)}static valueFromBytes(e,r){switch(e){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return O.fromBytesLE(Array.from(r));default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const e=ce.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":return e instanceof O?1:void 0;case"number":return e>Math.pow(2,31)-1||e<-Math.pow(2,31)?1:0;default:return}}static isSupport(e){return!!ce.getCounterType(e)}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===0||e===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new m(d.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(e){function r(s){if(!s.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof s.getValue()}`)}return r(this),r(e),this.valueType===1?this.value=this.value.add(e.getValue()):e.getType()===H.Long?this.value=this.value+e.getValue().toInt():this.value=O.fromNumber(this.value+ji(e.getValue())).toInt(),this}}class $r extends Pe{constructor(e,r,s){super(e,s);a(this,"value");this.value=r}static create(e,r,s){return new $r(e,r,s)}execute(e){const r=e.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof ce))throw new m(d.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const s=r,i=this.value.deepcopy();return s.increase(i),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:i.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const e=this.value.deepcopy(),s=e.getType()===H.Long?e.getValue().multiply(-1):e.getValue()*-1;return $r.create(this.getParentCreatedAt(),U.of(s,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Qt extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"attributes");a(this,"attributesToRemove");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o,this.attributesToRemove=c}static create(e,r,s,i,o,c){return new Qt(e,r,s,i,o,[],c)}static createTreeRemoveStyleOperation(e,r,s,i,o,c){return new Qt(e,r,s,i,new Map,o,c)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Se))throw new m(d.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=i;let c,l;if(this.attributes.size){const h={};[...this.attributes].forEach(([f,g])=>h[f]=g),[,l,c]=o.style([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}else{const h=this.attributesToRemove;[,l,c]=o.removeStyle([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}for(const h of l)e.registerGCPair(h);return{opInfos:c.map(({from:h,to:f,value:g,fromPath:v,toPath:p})=>({type:"tree-style",from:h,to:f,value:this.attributes.size?{attributes:g}:{attributesToRemove:g},fromPath:v,toPath:p,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${e}.STYLE(${r},${s},${Object.entries(this.attributes||{}).map(([i,o])=>`${i}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function _c(n){const t=new Ks,e=t.data;for(const[r,s]of Object.entries(n))e[r]=JSON.stringify(s);return t}function eu(n){if(n.type===lr.Put)return new Zr({type:wr.PUT,presence:_c(n.presence)});if(n.type===lr.Clear)return new Zr({type:wr.CLEAR});throw new m(d.ErrUnimplemented,"unimplemented type")}function tu(n){return new Co({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function zo(n){return new Hn({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:ii(n.getActorID()),versionVector:Ys(n.getVersionVector())})}function S(n){if(n)return new I({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:ii(n.getActorID())})}function Ys(n){if(!n)return;const t=new Yn;for(const[e,r]of n)t.vector[e]=BigInt(r.toString());return t}function Vo(n){switch(n){case H.Null:return N.NULL;case H.Boolean:return N.BOOLEAN;case H.Integer:return N.INTEGER;case H.Long:return N.LONG;case H.Double:return N.DOUBLE;case H.String:return N.STRING;case H.Bytes:return N.BYTES;case H.Date:return N.DATE;default:throw new m(d.ErrInvalidType,`unsupported type: ${n}`)}}function Ko(n){switch(n){case je.IntegerCnt:return N.INTEGER_CNT;case je.LongCnt:return N.LONG_CNT;default:throw new m(d.ErrInvalidType,`unsupported type: ${n}`)}}function os(n){if(n instanceof ne)return new le({type:N.JSON_OBJECT,createdAt:S(n.getCreatedAt()),value:na(n)});if(n instanceof ae)return new le({type:N.JSON_ARRAY,createdAt:S(n.getCreatedAt()),value:Ou(n)});if(n instanceof Ie)return new le({type:N.TEXT,createdAt:S(n.getCreatedAt())});if(n instanceof U)return new le({type:Vo(n.getType()),createdAt:S(n.getCreatedAt()),value:n.toBytes()});if(n instanceof ce)return new le({type:Ko(n.getType()),createdAt:S(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Se)return new le({type:N.TREE,createdAt:S(n.getCreatedAt()),value:Ru(n)});throw new m(d.ErrUnimplemented,"unimplemented element")}function ru(n){return new Yr({createdAt:S(n.getCreatedAt()),offset:n.getOffset()})}function hn(n){return new _t({createdAt:S(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function fn(n){return new vr({parentId:Gr(n.getParentID()),leftSiblingId:Gr(n.getLeftSiblingID())})}function Gr(n){return new or({createdAt:S(n.getCreatedAt()),offset:n.getOffset()})}function jo(n){const t=new Vs;if(n instanceof Tr){const e=n,r=new kn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.key=e.getKey(),r.value=os(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="set",t.body.value=r}else if(n instanceof on){const e=n,r=new xn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.prevCreatedAt=S(e.getPrevCreatedAt()),r.value=os(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="add",t.body.value=r}else if(n instanceof ir){const e=n,r=new En;r.parentCreatedAt=S(e.getParentCreatedAt()),r.prevCreatedAt=S(e.getPrevCreatedAt()),r.createdAt=S(e.getCreatedAt()),r.executedAt=S(e.getExecutedAt()),t.body.case="move",t.body.value=r}else if(n instanceof hr){const e=n,r=new Nn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.createdAt=S(e.getCreatedAt()),r.executedAt=S(e.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(n instanceof an){const e=n,r=new Cn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=hn(e.getFromPos()),r.to=hn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);r.content=e.getContent();const i=r.attributes;for(const[o,c]of e.getAttributes())i[o]=c;r.executedAt=S(e.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(n instanceof cn){const e=n,r=new Pn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=hn(e.getFromPos()),r.to=hn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);const i=r.attributes;for(const[o,c]of e.getAttributes())i[o]=c;r.executedAt=S(e.getExecutedAt()),t.body.case="style",t.body.value=r}else if(n instanceof $r){const e=n,r=new Dn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.value=os(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(n instanceof un){const e=n,r=new On,s=r.createdAtMapByActor;for(const[i,o]of e.getMaxCreatedAtMapByActor())s[i]=S(o);r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=fn(e.getFromPos()),r.to=fn(e.getToPos()),r.contents=uu(e.getContents()),r.splitLevel=e.getSplitLevel(),r.executedAt=S(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(n instanceof Qt){const e=n,r=new Bn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=fn(e.getFromPos()),r.to=fn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);const i=e.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{const o=r.attributes;for(const[c,l]of e.getAttributes())o[c]=l}r.executedAt=S(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new m(d.ErrUnimplemented,"unimplemented operation");return t}function nu(n){const t=[];for(const e of n)t.push(jo(e));return t}function su(n){const t=new Eo({id:zo(n.getID()),message:n.getMessage()});return n.hasOperations()&&(t.operations=nu(n.getOperations())),n.hasPresenceChange()&&(t.presenceChange=eu(n.getPresenceChange())),t}function iu(n){const t=[];for(const e of n)t.push(su(e));return t}function ou(n){const t=[];for(const e of n)t.push(new No({key:e.getStrKey(),element:Zs(e.getValue())}));return t}function au(n){const t=[];for(const e of n)t.push(new Un({element:Zs(e.getValue())}));return t}function cu(n){const t=[];for(const e of n){const r=new qn;r.id=ru(e.getID()),r.value=e.getValue().getContent(),r.removedAt=S(e.getRemovedAt());const s=r.attributes,i=e.getValue().getAttrs();for(const o of i){const c=new Rr;c.value=o.getValue(),c.updatedAt=S(o.getUpdatedAt()),s[o.getKey()]=c}t.push(r)}return t}function uu(n){const t=[];if(!n||!n.length)return t;for(const e of n)t.push(new zn({content:Xs(e)}));return t}function lu(n){const t={};for(const e of n)t[e.getKey()]=new Rr({value:e.getValue(),updatedAt:S(e.getUpdatedAt()),isRemoved:e.isRemoved()});return t}function Xs(n){if(!n)return[];const t=[];return Xn(n,(e,r)=>{const s=new Xr({id:Gr(e.id),type:e.type,removedAt:S(e.removedAt),depth:r});e.isText&&(s.value=e.value),e.insPrevID&&(s.insPrevId=Gr(e.insPrevID)),e.insNextID&&(s.insNextId=Gr(e.insNextID)),e.attrs&&(s.attributes=lu(e.attrs)),t.push(s)}),t}function hu(n){const t=new se;return t.body.case="jsonObject",t.body.value=new Rn({nodes:ou(n.getRHT()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Go(n){const t=new se;return t.body.case="jsonArray",t.body.value=new Ln({nodes:au(n.getElements()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function fu(n){const t=new se;return t.body.case="primitive",t.body.value=new Jn({type:Vo(n.getType()),value:n.toBytes(),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function du(n){const t=new se;return t.body.case="text",t.body.value=new Fn({nodes:cu(n.getRGATreeSplit()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function gu(n){const t=new se;return t.body.case="counter",t.body.value=new Mn({type:Ko(n.getType()),value:n.toBytes(),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Wo(n){const t=new se;return t.body.case="tree",t.body.value=new $n({nodes:Xs(n.getRoot()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Zs(n){if(n instanceof ne)return hu(n);if(n instanceof ae)return Go(n);if(n instanceof U)return fu(n);if(n instanceof Ie)return du(n);if(n instanceof ce)return gu(n);if(n instanceof Se)return Wo(n);throw new m(d.ErrUnimplemented,"unimplemented element")}function mu(n){return new tr({documentKey:n.getDocumentKey(),checkpoint:tu(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:iu(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Ys(n.getVersionVector()),minSyncedTicket:S(n.getMinSyncedTicket())})}function zr(n){if(!(n instanceof M))return{};const t=n.findDetails(Rc);for(const e of t)return e.metadata;return{}}function Sr(n){return zr(n).code??""}function Ho(n){return Gt.of(n.clientSeq,BigInt(n.lamport),ni(n.actorId),Qs(n.versionVector),BigInt(n.serverSeq))}function Qs(n){if(!n)return;const t=new Pr;return Object.entries(n.vector).forEach(([e,r])=>{t.set(e,BigInt(r.toString()))}),t}function k(n){if(n)return be.of(BigInt(n.lamport),n.delimiter,ni(n.actorId))}function _s(n){const t={};return Object.entries(n.data).forEach(([e,r])=>{t[e]=JSON.parse(r)}),t}function pu(n){const t=n.type;if(t===wr.PUT){const e=_s(n.presence);return{type:lr.Put,presence:e}}if(t===wr.CLEAR)return{type:lr.Clear};throw new m(d.ErrInvalidType,`unsupported type: ${t}`)}function yu(n){const t=new Map;return Object.entries(n).forEach(([e,r])=>{t.set(e,_s(r))}),t}function Yo(n){switch(n){case N.NULL:return H.Null;case N.BOOLEAN:return H.Boolean;case N.INTEGER:return H.Integer;case N.LONG:return H.Long;case N.DOUBLE:return H.Double;case N.STRING:return H.String;case N.BYTES:return H.Bytes;case N.DATE:return H.Date}throw new m(d.ErrUnimplemented,`unimplemented value type: ${n}`)}function jn(n){switch(n){case N.INTEGER_CNT:return je.IntegerCnt;case N.LONG_CNT:return je.LongCnt}throw new m(d.ErrUnimplemented,`unimplemented value type: ${n}`)}function as(n){switch(n.type){case N.JSON_OBJECT:return n.value?ra(n.value):ne.create(k(n.createdAt));case N.JSON_ARRAY:return n.value?Du(n.value):ae.create(k(n.createdAt));case N.TEXT:return Ie.create(Mr.create(),k(n.createdAt));case N.TREE:return Bu(n.value);case N.NULL:case N.BOOLEAN:case N.INTEGER:case N.LONG:case N.DOUBLE:case N.STRING:case N.BYTES:case N.DATE:return U.of(U.valueFromBytes(Yo(n.type),n.value),k(n.createdAt));case N.INTEGER_CNT:case N.LONG_CNT:return ce.create(jn(n.type),ce.valueFromBytes(jn(n.type),n.value),k(n.createdAt))}}function dn(n){return Ce.of(Ke.of(k(n.createdAt),n.offset),n.relativeOffset)}function Xo(n){return Ke.of(k(n.createdAt),n.offset)}function vu(n){const t=tn.create(n.value);Object.entries(n.attributes).forEach(([r,s])=>{t.setAttr(r,s.value,k(s.updatedAt))});const e=cr.create(Xo(n.id),t);return e.remove(k(n.removedAt)),e}function kr(n){return Ee.of(Wr(n.parentId),Wr(n.leftSiblingId))}function Wr(n){return Z.of(k(n.createdAt),n.offset)}function wu(n){if(!n.length)return;const t=[];return n.forEach(e=>{const r=ei(e.content);t.push(r)}),t}function ei(n){if(n.length===0)return;const t=[];for(const s of n)t.push(Au(s));const e=t[t.length-1],r=new Map;r.set(n[t.length-1].depth,t[t.length-1]);for(let s=t.length-2;s>=0;s--)r.get(n[s].depth-1).prepend(t[s]),r.set(n[s].depth,t[s]);return e.updateDescendantsSize(),Se.create(e,Ne).getRoot()}function Tu(n){const t=er.create();for(const[e,r]of Object.entries(n))t.setInternal(e,r.value,k(r.updatedAt),r.isRemoved);return t}function Au(n){const t=Wr(n.id),e=oe.create(t,n.type),r=Object.entries(n.attributes);return e.isText?e.value=n.value:r.length&&(e.attrs=Tu(n.attributes)),n.insPrevId&&(e.insPrevID=Wr(n.insPrevId)),n.insNextId&&(e.insNextID=Wr(n.insNextId)),e.removedAt=k(n.removedAt),e}function Zo(n){if(n.body.case==="set"){const t=n.body.value;return Tr.create(t.key,as(t.value),k(t.parentCreatedAt),k(t.executedAt))}else if(n.body.case==="add"){const t=n.body.value;return on.create(k(t.parentCreatedAt),k(t.prevCreatedAt),as(t.value),k(t.executedAt))}else if(n.body.case==="move"){const t=n.body.value;return ir.create(k(t.parentCreatedAt),k(t.prevCreatedAt),k(t.createdAt),k(t.executedAt))}else if(n.body.case==="remove"){const t=n.body.value;return hr.create(k(t.parentCreatedAt),k(t.createdAt),k(t.executedAt))}else if(n.body.case==="edit"){const t=n.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([s,i])=>{e.set(s,k(i))});const r=new Map;return Object.entries(t.attributes).forEach(([s,i])=>{r.set(s,i)}),an.create(k(t.parentCreatedAt),dn(t.from),dn(t.to),e,t.content,r,k(t.executedAt))}else if(n.body.case==="style"){const t=n.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([s,i])=>{e.set(s,k(i))});const r=new Map;return Object.entries(t.attributes).forEach(([s,i])=>{r.set(s,i)}),cn.create(k(t.parentCreatedAt),dn(t.from),dn(t.to),e,r,k(t.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const t=n.body.value;return $r.create(k(t.parentCreatedAt),as(t.value),k(t.executedAt))}else if(n.body.case==="treeEdit"){const t=n.body.value,e=new Map;return Object.entries(t.createdAtMapByActor).forEach(([r,s])=>{e.set(r,k(s))}),un.create(k(t.parentCreatedAt),kr(t.from),kr(t.to),wu(t.contents),t.splitLevel,e,k(t.executedAt))}else if(n.body.case==="treeStyle"){const t=n.body.value,e=new Map,r=t.attributesToRemove,s=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{s.set(i,k(o))}),(r==null?void 0:r.length)>0?Qt.createTreeRemoveStyleOperation(k(t.parentCreatedAt),kr(t.from),kr(t.to),s,r,k(t.executedAt)):(Object.entries(t.attributes).forEach(([i,o])=>{e.set(i,o)}),Qt.create(k(t.parentCreatedAt),kr(t.from),kr(t.to),s,e,k(t.executedAt)))}else throw new m(d.ErrUnimplemented,"unimplemented operation")}}function bu(n){const t=[];for(const e of n){const r=Zo(e);r&&t.push(r)}return t}function Qo(n){const t=[];for(const e of n)t.push(Fr.create({id:Ho(e.id),operations:bu(e.operations),presenceChange:e.presenceChange?pu(e.presenceChange):void 0,message:e.message}));return t}function Iu(n){return Dr.of(BigInt(n.serverSeq),n.clientSeq)}function Su(n){return Zn.create(n.documentKey,Iu(n.checkpoint),n.isRemoved,Qo(n.changes),Qs(n.versionVector),n.snapshot,k(n.minSyncedTicket))}function _o(n){const t=new Qr;for(const r of n.nodes){const s=ti(r.element);t.set(r.key,s,s.getPositionedAt())}const e=new ne(k(n.createdAt),t);return e.setMovedAt(k(n.movedAt)),e.setRemovedAt(k(n.removedAt)),e}function ea(n){const t=new en;for(const r of n.nodes)t.insert(ti(r.element));const e=new ae(k(n.createdAt),t);return e.setMovedAt(k(n.movedAt)),e.setRemovedAt(k(n.removedAt)),e}function ku(n){const t=U.of(U.valueFromBytes(Yo(n.type),n.value),k(n.createdAt));return t.setMovedAt(k(n.movedAt)),t.setRemovedAt(k(n.removedAt)),t}function xu(n){const t=new Mr;let e=t.getHead();for(const s of n.nodes){const i=t.insertAfter(e,vu(s));s.insPrevId&&i.setInsPrev(t.findNode(Xo(s.insPrevId))),e=i}const r=new Ie(t,k(n.createdAt));return r.setMovedAt(k(n.movedAt)),r.setRemovedAt(k(n.removedAt)),r}function Eu(n){const t=ce.create(jn(n.type),ce.valueFromBytes(jn(n.type),n.value),k(n.createdAt));return t.setMovedAt(k(n.movedAt)),t.setRemovedAt(k(n.removedAt)),t}function ta(n){const t=ei(n.nodes);return Se.create(t,k(n.createdAt))}function ti(n){if(n.body.case==="jsonObject")return _o(n.body.value);if(n.body.case==="jsonArray")return ea(n.body.value);if(n.body.case==="primitive")return ku(n.body.value);if(n.body.case==="text")return xu(n.body.value);if(n.body.case==="counter")return Eu(n.body.value);if(n.body.case==="tree")return ta(n.body.value);throw new m(d.ErrUnimplemented,"unimplemented element")}function Nu(n){if(!n)return{root:ne.create(Ne),presences:new Map};const t=ds.fromBinary(n);return{root:ti(t.root),presences:yu(t.presences)}}function Cu(n){const t=Ys(n);return ri(t.toBinary())}function Pu(n){const t=si(n),e=Yn.fromBinary(t);return Qs(e)}function ra(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return _o(t.body.value)}function na(n){return Zs(n).toBinary()}function Du(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return ea(t.body.value)}function Ou(n){return Go(n).toBinary()}function Bu(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return ta(t.body.value)}function Ru(n){return Wo(n).toBinary()}function ri(n){return n?Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function ni(n){return ri(n)}function si(n){return new Uint8Array(n.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function ii(n){return si(n)}function Lu(n){const t=Hn.fromBinary(n);return Ho(t)}function Ju(n){const t=Vs.fromBinary(n);return Zo(t)}const j={fromPresence:_s,toChangePack:mu,fromChangePack:Su,fromChanges:Qo,toTreeNodes:Xs,fromTreeNodes:ei,objectToBytes:na,bytesToObject:ra,bytesToSnapshot:Nu,bytesToHex:ri,hexToBytes:si,toHexString:ni,toUint8Array:ii,toOperation:jo,toChangeID:zo,PbChangeID:Hn,bytesToChangeID:Lu,bytesToOperation:Ju,versionVectorToHex:Cu,hexToVersionVector:Pu};var te=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(te||{});let fr=3;function sa(n){fr=n}const E={trivial:(...n)=>{fr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{fr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{fr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{fr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{fr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>fr<=n};function ia(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}class Fu{constructor(t,e,r,s,i){a(this,"reconnectStreamDelay");a(this,"doc");a(this,"docID");a(this,"syncMode");a(this,"remoteChangeEventReceived");a(this,"watchStream");a(this,"watchLoopTimerID");a(this,"watchAbortController");a(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=e,this.docID=r,this.syncMode=s,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===bn.RealtimeSyncOff?!1:this.syncMode===bn.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==bn.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const e=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(e,this.reconnectStreamDelay)})}catch{}};await e()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const cs=()=>{};class Mu{constructor(t){a(this,"finalized",!1);a(this,"observers",[]);a(this,"finalError");try{t(this)}catch(e){this.error(e)}}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,r){let s;if(!t)throw new m(d.ErrInvalidArgument,"missing observer");if(this.finalized)throw new m(d.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?s=t:s={next:t,error:e,complete:r},s.next===void 0&&(s.next=cs),s.error===void 0&&(s.error=cs),s.complete===void 0&&(s.complete=cs);const i=ia(),o=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:s}),this.finalized)try{this.finalError?s.error(this.finalError):s.complete()}catch(c){E.warn(c)}return o}unsubscribeOne(t){var e;this.observers=(e=this.observers)==null?void 0:e.filter(r=>r.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let e=0;et}}class Nr{constructor(t,e,r,s){a(this,"id");a(this,"delimiter");a(this,"message");a(this,"root");a(this,"operations");a(this,"presenceChange");a(this,"previousPresence");a(this,"reversePresenceKeys");this.id=t,this.delimiter=Do,this.root=e,this.operations=[],this.previousPresence=ke(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=s}static create(t,e,r,s){return new Nr(t,e,r,s)}push(t){this.operations.push(t)}registerElement(t,e){this.root.registerElement(t,e)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return Fr.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,e){for(const r of Object.keys(t))e!=null&&e.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const e of this.reversePresenceKeys)t[e]=this.previousPresence[e];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class rn{constructor(t){a(this,"rootObject");a(this,"elementPairMapByCreatedAt");a(this,"gcElementSetByCreatedAt");a(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof Ie||e instanceof Se)for(const r of e.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new rn(ne.create(Ne))}findByCreatedAt(t){const e=this.elementPairMapByCreatedAt.get(t.toIDString());if(e)return e.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let e=this.elementPairMapByCreatedAt.get(t.toIDString());if(!e)return[];const r=[];for(;e.parent;){const s=e.element.getCreatedAt(),i=e.parent.subPathOf(s);if(i===void 0)throw new m(d.ErrInvalidArgument,`cant find the given element: ${s.toIDString()}`);r.unshift(i),e=this.elementPairMapByCreatedAt.get(e.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,e){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:e,element:t}),t instanceof ar&&t.getDescendants((r,s)=>(this.registerElement(r,s),!1))}deregisterElement(t){let e=0;const r=s=>{const i=s.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(i),this.gcElementSetByCreatedAt.delete(i),e++};return r(t),t instanceof ar&&t.getDescendants(s=>(r(s),!1)),e}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const e of this.gcElementSetByCreatedAt){t.add(e);const r=this.elementPairMapByCreatedAt.get(e);r.element instanceof ar&&r.element.getDescendants(s=>(t.add(s.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new rn(this.rootObject.deepcopy())}garbageCollect(t){let e=0;for(const r of this.gcElementSetByCreatedAt){const s=this.elementPairMapByCreatedAt.get(r),i=s.element.getRemovedAt();i&&(t!=null&&t.afterOrEqual(i))&&(s.parent.purge(s.element),e+=this.deregisterElement(s.element))}for(const[,r]of this.gcPairMap){const s=r.child.getRemovedAt();s&&(t!=null&&t.afterOrEqual(s))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),e+=1)}return e}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function oa(n,t){const e=new nn(n);return new Proxy(t,e.getHandlers())}class nn{constructor(t){a(this,"context");a(this,"handlers");this.context=t,this.handlers={set:(e,r,s)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]=${JSON.stringify(s)}`),nn.setInternal(t,e,r,s),!0),get:(e,r)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]`),r==="getID"?()=>e.getCreatedAt():r==="toJSON"||r==="toString"?()=>e.toJSON():r==="toJS"?()=>e.toJS():r==="toJSForTest"?()=>e.toJSForTest():dr(t,e.get(r))),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(e,r)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]`),nn.deleteInternal(t,e,r),!0)}}static setInternal(t,e,r,s){if(r.includes("."))throw new m(d.ErrInvalidObjectKey,"key must not contain the '.'.");const i=t.issueTimeTicket(),o=Gn(t,s,i),c=e.set(r,o,i);t.registerElement(o,e),c&&t.registerRemovedElement(c),t.push(Tr.create(r,o.deepcopy(),e.getCreatedAt(),i))}static buildObjectMembers(t,e){const r={};for(const[s,i]of Object.entries(e)){if(s.includes("."))throw new m(d.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),c=Gn(t,i,o);r[s]=c}return r}static deleteInternal(t,e,r){const s=t.issueTimeTicket(),i=e.deleteByKey(r,s);i&&(t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i))}getHandlers(){return this.handlers}}function Uu(n,t){const e=new q(n,t);return new Proxy(t,e.getHandlers())}function qu(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zu(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class q{constructor(t,e){a(this,"context");a(this,"handlers");a(this,"array");this.context=t,this.array=e,this.handlers={get:(r,s,i)=>s==="getID"?()=>r.getCreatedAt():s==="getElementByID"?o=>{const c=r.getByID(o);if(!(!c||c.isRemoved()))return nr(t,c)}:s==="getElementByIndex"?o=>{const c=r.get(o);return nr(t,c)}:s==="getLast"?()=>nr(t,r.getLast()):s==="deleteByID"?o=>{const c=q.deleteInternalByID(t,r,o);return nr(t,c)}:s==="insertAfter"?(o,c)=>{const l=q.insertAfterInternal(t,r,o,c);return nr(t,l)}:s==="insertBefore"?(o,c)=>{const l=q.insertBeforeInternal(t,r,o,c);return nr(t,l)}:s==="moveBefore"?(o,c)=>{q.moveBeforeInternal(t,r,o,c)}:s==="moveAfter"?(o,c)=>{q.moveAfterInternal(t,r,o,c)}:s==="moveFront"?o=>{q.moveFrontInternal(t,r,o)}:s==="moveLast"?o=>{q.moveLastInternal(t,r,o)}:qu(s)?dr(t,r.get(Number(s))):s==="push"?o=>q.pushInternal(t,r,o):s==="splice"?(o,c,...l)=>q.splice(t,r,o,c,...l):s==="length"?r.length:typeof s=="symbol"&&s===Symbol.iterator?q.iteratorInternal.bind(this,t,r):s==="includes"?(o,c)=>q.includes(t,r,o,c):s==="indexOf"?(o,c)=>q.indexOf(t,r,o,c):s==="lastIndexOf"?(o,c)=>q.lastIndexOf(t,r,o,c):s==="toJSForTest"?()=>r.toJSForTest():s==="toTestString"?()=>q.toTestString(r):typeof s=="string"&&zu(s)?(...o)=>{const c=Array.from(r).map(l=>dr(t,l));return Array.prototype[s].apply(c,o)}:Reflect.get(r,s,i),deleteProperty:(r,s)=>(E.isEnabled(te.Trivial)&&E.trivial(`array[${s}]`),q.deleteInternalByIndex(t,r,Number.parseInt(s)),!0)}}static*iteratorInternal(t,e){for(const r of e)yield nr(t,r)}static buildArrayElements(t,e){const r=[];for(const s of e){const i=t.issueTimeTicket(),o=Gn(t,s,i);r.push(o)}return r}static pushInternal(t,e,r){return q.insertAfterInternal(t,e,e.getLastCreatedAt(),r),e.length}static moveBeforeInternal(t,e,r,s){const i=t.issueTimeTicket(),o=e.getPrevCreatedAt(r);e.moveAfter(o,s,i),t.push(ir.create(e.getCreatedAt(),o,s,i))}static moveAfterInternal(t,e,r,s){const i=t.issueTimeTicket();e.moveAfter(r,s,i),t.push(ir.create(e.getCreatedAt(),r,s,i))}static moveFrontInternal(t,e,r){const s=t.issueTimeTicket(),i=e.getHead();e.moveAfter(i.getCreatedAt(),r,s),t.push(ir.create(e.getCreatedAt(),i.getCreatedAt(),r,s))}static moveLastInternal(t,e,r){const s=t.issueTimeTicket(),i=e.getLastCreatedAt();e.moveAfter(i,r,s),t.push(ir.create(e.getCreatedAt(),i,r,s))}static insertAfterInternal(t,e,r,s){const i=t.issueTimeTicket(),o=Gn(t,s,i);return e.insertAfter(r,o),t.registerElement(o,e),t.push(on.create(e.getCreatedAt(),r,o.deepcopy(),i)),o}static insertBeforeInternal(t,e,r,s){return q.insertAfterInternal(t,e,e.getPrevCreatedAt(r),s)}static deleteInternalByIndex(t,e,r){const s=t.issueTimeTicket(),i=e.deleteByIndex(r,s);if(i)return t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i),i}static deleteInternalByID(t,e,r){const s=t.issueTimeTicket(),i=e.delete(r,s);return t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i),i}static splice(t,e,r,s,...i){const o=e.length,c=r>=0?Math.min(r,o):Math.max(o+r,0),l=s===void 0?o:s<0?c:Math.min(c+s,o),h=[];for(let f=c;f=i)return!1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).includes(r,o);for(let l=o;l=i)return-1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).indexOf(r,o);for(let l=o;l=i?i-1:s<0?s+i:s;if(o<0)return-1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).lastIndexOf(r,o);for(let l=o;l>0;l--)if(((c=e.get(l))==null?void 0:c.getID())===r.getID())return l;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}class Qn{constructor(t,e){a(this,"context");a(this,"text");this.context=t,this.text=e}initialize(t,e){this.context=t,this.text=e}getID(){return this.text.getID()}edit(t,e,r,s){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(t,e);E.isEnabled(te.Debug)&&E.debug(`EDIT: f:${t}->${i[0].toTestString()}, t:${e}->${i[1].toTestString()} c:${r}`);const o=s?Lr(s):void 0,c=this.context.issueTimeTicket(),[l,,h,f]=this.text.edit(i,r,c,o);for(const g of h)this.context.registerGCPair(g);return this.context.push(new an(this.text.getCreatedAt(),i[0],i[1],l,r,o?new Map(Object.entries(o)):new Map,c)),this.text.findIndexesFromRange(f)}delete(t,e){return this.edit(t,e,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,e,r){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(t,e);E.isEnabled(te.Debug)&&E.debug(`STYL: f:${t}->${s[0].toTestString()}, t:${e}->${s[1].toTestString()} a:${JSON.stringify(r)}`);const i=Lr(r),o=this.context.issueTimeTicket(),[c,l]=this.text.setStyle(s,i,o);for(const h of l)this.context.registerGCPair(h);return this.context.push(new cn(this.text.getCreatedAt(),s[0],s[1],c,new Map(Object.entries(i)),o)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");const e=this.text.indexRangeToPosRange(t[0],t[1]);return[e[0].toStruct(),e[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");const e=this.text.findIndexesFromRange([Ce.fromStruct(t[0]),Ce.fromStruct(t[1])]);return[e[0],e[1]]}toTestString(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,e){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,e)}}class _n{constructor(t,e){a(this,"valueType");a(this,"value");a(this,"context");a(this,"counter");this.valueType=t,this.value=e}initialize(t,e){this.valueType=e.getValueType(),this.context=t,this.counter=e,this.value=e.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new m(d.ErrNotInitialized,"Counter is not initialized yet");const e=this.context.issueTimeTicket(),r=U.of(t,e);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push($r.create(this.counter.getCreatedAt(),r,e)),this}toJSForTest(){if(!this.context||!this.counter)throw new m(d.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function oi(n,t,e){const{type:r}=n,s=e.issueTimeTicket();if(r===Zt){aa(n);const{value:i}=n,o=oe.create(Z.of(s,0),r,i);t.append(o)}else{const{children:i=[]}=n,{attributes:o}=n;let c;if(typeof o=="object"&&!Po(o)){const h=Lr(o);c=new er;for(const[f,g]of Object.entries(h))c.set(f,g,s)}const l=oe.create(Z.of(s,0),r,void 0,c);t.append(l);for(const h of i)oi(h,l,e)}}function Vu(n,t){const{type:e}=t,r=n.issueTimeTicket();let s;if(t.type===Zt){const{value:i}=t;s=oe.create(Z.of(r,0),e,i)}else if(t){const{children:i=[]}=t,{attributes:o}=t;let c;if(typeof o=="object"&&!Po(o)){const l=Lr(o);c=new er;for(const[h,f]of Object.entries(l))c.set(h,f,r)}s=oe.create(Z.of(n.issueTimeTicket(),0),e,void 0,c);for(const l of i)oi(l,s,n)}return s}function aa(n){if(!n.value.length)throw new m(d.ErrInvalidArgument,"text node cannot have empty value");return!0}function Gi(n){if(!n.length)return!0;if(n[0].type===Zt)for(const e of n){const{type:r}=e;if(r!==Zt)throw new m(d.ErrInvalidArgument,"element node and text node cannot be passed together");aa(e)}else for(const e of n){const{type:r}=e;if(r===Zt)throw new m(d.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class es{constructor(t){a(this,"initialRoot");a(this,"context");a(this,"tree");this.initialRoot=t}initialize(t,e){this.context=t,this.tree=e}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return oe.create(Z.of(t.issueTimeTicket(),0),qc);const e=oe.create(Z.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)oi(r,e,t);return e}getSize(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,e){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const[r,s]=this.tree.pathToPosRange(t),i=this.context.issueTimeTicket(),o=e?Lr(e):void 0,[c]=this.tree.style([r,s],o,i);this.context.push(Qt.create(this.tree.getCreatedAt(),r,s,c,o?new Map(Object.entries(o)):new Map,i))}style(t,e,r){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(t),i=this.tree.findPos(e),o=this.context.issueTimeTicket(),c=r?Lr(r):void 0,[l,h]=this.tree.style([s,i],c,o);for(const f of h)this.context.registerGCPair(f);this.context.push(Qt.create(this.tree.getCreatedAt(),s,i,l,c?new Map(Object.entries(c)):new Map,o))}removeStyle(t,e,r){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(t),i=this.tree.findPos(e),o=this.context.issueTimeTicket(),[c,l]=this.tree.removeStyle([s,i],r,o);for(const h of l)this.context.registerGCPair(h);this.context.push(Qt.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),s,i,c,r,o))}editInternal(t,e,r,s=0){var h;if(r.length!==0&&r[0]&&(Gi(r),r[0].type!==Zt))for(const f of r){const{children:g=[]}=f;Gi(g)}const i=this.context.getLastTimeTicket();let o=new Array;if(((h=r[0])==null?void 0:h.type)===Zt){let f="";for(const g of r){const{value:v}=g;f+=v}o.push(oe.create(Z.of(this.context.issueTimeTicket(),0),Zt,f))}else o=r.map(f=>f&&Vu(this.context,f)).filter(f=>f);const[,c,l]=this.tree.edit([t,e],o.length?o.map(f=>f==null?void 0:f.deepcopy()):void 0,s,i,()=>this.context.issueTimeTicket());for(const f of c)this.context.registerGCPair(f);return this.context.push(un.create(this.tree.getCreatedAt(),t,e,o.length?o:void 0,s,l,i)),!0}editByPath(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new m(d.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(t),o=this.tree.pathToPos(e);return this.editInternal(i,o,r?[r]:[],s)}editBulkByPath(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new m(d.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(t),o=this.tree.pathToPos(e);return this.editInternal(i,o,r,s)}edit(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(e);return this.editInternal(i,o,r?[r]:[],s)}editBulk(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(e);return this.editInternal(i,o,r,s)}toXML(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],r=this.tree.indexRangeToPosRange(e);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[Ee.fromStruct(t[0]),Ee.fromStruct(t[1])];return this.tree.posRangeToIndexRange(e)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[Ee.fromStruct(t[0]),Ee.fromStruct(t[1])];return this.tree.posRangeToPathRange(e)}}function Wi(n,t){return oa(n,t)}function nr(n,t){if(t){if(t instanceof U)return t;if(t instanceof ne)return oa(n,t);if(t instanceof ae)return Uu(n,t);if(t instanceof Ie)return new Qn(n,t);if(t instanceof ce){const e=new _n(je.IntegerCnt,0);return e.initialize(n,t),e}else if(t instanceof Se){const e=new es;return e.initialize(n,t),e}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function dr(n,t){const e=nr(n,t);return e instanceof U?e.getValue():e}function Gn(n,t,e){let r;if(U.isSupport(t))r=U.of(t,e);else if(Array.isArray(t))r=ae.create(e,q.buildArrayElements(n,t));else if(typeof t=="object")t instanceof Qn?(r=Ie.create(Mr.create(),e),t.initialize(n,r)):t instanceof _n?(r=ce.create(t.getValueType(),t.getValue(),e),t.initialize(n,r)):t instanceof es?(r=Se.create(t.buildRoot(n),e),t.initialize(n,r)):r=ne.create(e,nn.buildObjectMembers(n,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return r}const Hi=50;class Ku{constructor(){a(this,"undoStack",[]);a(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Hi&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Hi&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const ju="yorkie-devtools-panel",Gu="yorkie-devtools-sdk";let xr="disconnected";const Yi=new Map,An=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=An);function gn(n,t){(t!=null&&t.force||xr!=="disconnected")&&window.postMessage({source:Gu,...n},"*")}function Wu(n){if(!n.isEnableDevtools()||typeof window>"u"||Yi.has(n.getKey()))return;An.set(n.getKey(),[]);const t=n.subscribe("all",e=>{e.some(r=>r.type!==X.StatusChanged&&r.type!==X.Snapshot&&r.type!==X.LocalChange&&r.type!==X.RemoteChange&&r.type!==X.Initialized&&r.type!==X.Watched&&r.type!==X.Unwatched&&r.type!==X.PresenceChanged)||(An.get(n.getKey()).push(e),xr==="synced"&&gn({msg:"doc::sync::partial",docKey:n.getKey(),event:e}))});Yi.set(n.getKey(),[t]),gn({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",e=>{var s;if(((s=e.data)==null?void 0:s.source)!==ju)return;switch(e.data.msg){case"devtools::connect":if(xr!=="disconnected")break;xr="connected",gn({msg:"doc::available",docKey:n.getKey()}),E.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":xr="disconnected",E.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":xr="synced",gn({msg:"doc::sync::full",docKey:n.getKey(),events:An.get(n.getKey())}),E.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var sr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(sr||{}),X=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(X||{}),$s=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))($s||{}),Us=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Us||{});class ca{constructor(t,e){a(this,"key");a(this,"status");a(this,"opts");a(this,"changeID");a(this,"checkpoint");a(this,"localChanges");a(this,"root");a(this,"clone");a(this,"eventStream");a(this,"eventStreamObserver");a(this,"onlineClients");a(this,"presences");a(this,"history");a(this,"internalHistory");a(this,"isUpdating");this.opts=e||{},this.key=t,this.status="detached",this.root=rn.create(),this.changeID=Xc,this.checkpoint=Zc,this.localChanges=[],this.eventStream=$u(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Ku,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},Wu(this)}update(t,e){if(this.getStatus()==="removed")throw new m(d.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),s=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},e);try{const i=Wi(s,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,t(i,new is(s,this.clone.presences.get(r)))}catch(i){throw this.clone=void 0,i}finally{this.isUpdating=!1}if(s.hasChange()){E.isEnabled(te.Trivial)&&E.trivial(`trying to update a local change: ${this.toJSON()}`);const i=s.getChange(),{opInfos:o,reverseOps:c}=i.execute(this.root,this.presences,J.Local),l=s.getReversePresence();l&&c.push({type:"presence",value:l}),this.localChanges.push(i),c.length>0&&this.internalHistory.pushUndo(c),o.length>0&&this.internalHistory.clearRedo(),this.changeID=i.getID();const h=[];o.length>0&&h.push({type:"local-change",source:J.Local,value:{message:i.getMessage()||"",operations:o,actor:r,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&h.push({type:"presence-changed",source:J.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(h),E.isEnabled(te.Trivial)&&E.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,e,r,s){if(typeof t=="string"){if(typeof e!="function")throw new m(d.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||c(h)},r,s)}if(t==="my-presence"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="presence-changed"||h.type==="presence-changed"&&h.value.clientID!==this.changeID.getActorID()||c(h)},r,s)}if(t==="others"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||h.value.clientID!==this.changeID.getActorID()&&c(h)},r,s)}if(t==="connection"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="connection-changed"&&c(h)},r,s)}if(t==="status"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="status-changed"&&c(h)},r,s)}if(t==="sync"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="sync-status-changed"&&c(h)},r,s)}if(t==="local-broadcast"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="local-broadcast"&&c(h)},r)}if(t==="broadcast"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="broadcast"&&c(h)},r)}if(t==="auth-error"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="auth-error"&&c(h)},r)}if(t==="all"){const c=e;return this.eventStream.subscribe(c,r,s)}const i=t,o=e;return this.eventStream.subscribe(c=>{for(const l of c){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const h=[];for(const f of l.value.operations)this.isSameElementOrChildOf(f.path,i)&&h.push(f);h.length&&o({...l,value:{...l.value,operations:h}})}},r,s)}if(typeof t=="function"){const i=t,o=e,c=r;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="snapshot"&&h.type!=="local-change"&&h.type!=="remote-change"||i(h)},o,c)}throw new m(d.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,e){if(e===t)return!0;const r=t.split(".");return e.split(".").every((i,o)=>i===r[o])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const e=t.hasSnapshot();e?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),J.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),e||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),E.isEnabled(te.Trivial)&&E.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:ke(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),e=this.checkpoint.increaseClientSeq(t.length);return Zn.create(this.key,e,!1,t,this.getVersionVector())}setActor(t){for(const e of this.localChanges)e.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Wi(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,e,r,s=-1){const{root:i,presences:o}=j.bytesToSnapshot(r);this.root=new rn(i),this.presences=o,this.changeID=this.changeID.setClocks(t,e),this.clone=void 0,this.removePushedLocalChanges(s),this.applyChanges(this.localChanges,J.Local),this.publish([{type:"snapshot",source:J.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?j.bytesToHex(r):void 0,snapshotVector:j.versionVectorToHex(e)}}])}applyChanges(t,e){E.isEnabled(te.Debug)&&E.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),E.isEnabled(te.Trivial)&&E.trivial(t.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` -`));for(const r of t)this.applyChange(r,e);E.isEnabled(te.Debug)&&E.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,e){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,e);const r=[],s=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(s)){const o=t.getPresenceChange();switch(o.type){case lr.Put:r.push(this.presences.has(s)?{type:"presence-changed",source:e,value:{clientID:s,presence:o.presence}}:{type:"watched",source:J.Remote,value:{clientID:s,presence:o.presence}});break;case lr.Clear:r.push({type:"unwatched",source:J.Remote,value:{clientID:s,presence:this.getPresence(s)}}),this.removeOnlineClient(s);break}}const{opInfos:i}=t.execute(this.root,this.presences,e);if(this.changeID=this.changeID.syncClocks(t.getID()),i.length>0){const o=this.isEnableDevtools()?t.toStruct():void 0;r.push(e===J.Remote?{type:"remote-change",source:e,value:{actor:s,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:i},rawChange:o}:{type:"local-change",source:e,value:{actor:s,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:i},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(t){if(t.body.case==="initialization"){const e=t.body.value.clientIds,r=new Set;for(const s of e)s!==this.changeID.getActorID()&&r.add(s);this.setOnlineClients(r),this.publish([{type:"initialized",source:J.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:e,publisher:r}=t.body.value,s=[];if(e===yr.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&s.push({type:"watched",source:J.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(e===yr.DOCUMENT_UNWATCHED){const i=this.getPresence(r);this.removeOnlineClient(r),i&&s.push({type:"unwatched",source:J.Remote,value:{clientID:r,presence:i}})}else if(e===yr.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:i,payload:o}=t.body.value.body,c=new TextDecoder;s.push({type:"broadcast",value:{clientID:r,topic:i,payload:JSON.parse(c.decode(o))}})}s.length>0&&this.publish(s)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(js),this.publish([{source:t==="removed"?J.Remote:J.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:e,serverSeq:r,snapshotVector:s}=t.value;if(!e)return;this.applySnapshot(BigInt(r),j.hexToVersionVector(s),j.hexToBytes(e));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const e=Fr.fromStruct(t.rawChange);this.applyChange(e,t.source)}if(t.type==="initialized"){const e=new Set;for(const{clientID:r,presence:s}of t.value)e.add(r),this.presences.set(r,s);this.setOnlineClients(e);return}if(t.type==="watched"){const{clientID:e,presence:r}=t.value;this.addOnlineClient(e),this.presences.set(e,r);return}if(t.type==="unwatched"){const{clientID:e}=t.value;this.removeOnlineClient(e),this.presences.delete(e)}if(t.type==="presence-changed"){const{clientID:e,presence:r}=t.value;this.presences.set(e,r)}}applyTransactionEvent(t){for(const e of t)this.applyDocEvent(e)}getValueByPath(t){if(!t.startsWith("$"))throw new m(d.ErrInvalidArgument,'path must start with "$"');const e=t.split(".");e.shift();let r=this.getRoot();for(const s of e)if(r=r[s],r===void 0)return;return r}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?ke(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const e=this.presences.get(t);return e?ke(e):void 0}getPresenceForTest(t){const e=this.presences.get(t);return e?ke(e):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:ke(this.getMyPresence())});for(const e of this.onlineClients)this.presences.has(e)&&t.push({clientID:e,presence:ke(this.presences.get(e))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(e=>e.clientID!==t).sort((e,r)=>e.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const r=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new m(d.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new m(d.ErrRefused,"There is no operation to be undone");this.ensureClone();const e=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of t){if(!(h instanceof Pe)){new is(e,ke(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const f=e.issueTimeTicket();h.setExecutedAt(f),e.push(h)}const r=e.getChange();r.execute(this.clone.root,this.clone.presences,J.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,J.UndoRedo),o=e.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const c=this.changeID.getActorID(),l=[];s.length>0&&l.push({type:"local-change",source:J.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:c,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:J.UndoRedo,value:{clientID:c,presence:this.getPresence(c)}}),this.publish(l)}redo(){if(this.isUpdating)throw new m(d.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new m(d.ErrRefused,"There is no operation to be redone");this.ensureClone();const e=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of t){if(!(h instanceof Pe)){new is(e,ke(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const f=e.issueTimeTicket();h.setExecutedAt(f),e.push(h)}const r=e.getChange();r.execute(this.clone.root,this.clone.presences,J.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,J.UndoRedo),o=e.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const c=this.changeID.getActorID(),l=[];s.length>0&&l.push({type:"local-change",source:J.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:c,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:J.UndoRedo,value:{clientID:c,presence:this.getPresence(c)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,e,r){const s={type:"local-broadcast",value:{topic:t,payload:e},options:r};this.publish([s])}getVersionVector(){return this.changeID.getVersionVector()}}function Hu(n,t){let e=t;return{authInterceptor:i=>async o=>(n&&o.header.set("x-api-key",n),e&&o.header.set("authorization",e),await i(o)),setToken:i=>{e=i}}}const Yu="yorkie-js-sdk",Xu="0.5.6",Zu="Yorkie JS SDK",Qu="./src/yorkie.ts",_u={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},el=["dist"],tl={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},rl={node:">=18.0.0",npm:">=7.1.0"},nl={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},sl={name:"hackerwins",email:"susukang98@gmail.com"},il="Apache-2.0",ol={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},al="https://github.com/yorkie-team/yorkie-js-sdk#readme",cl={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ul={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Xi={name:Yu,version:Xu,description:Zu,main:Qu,publishConfig:_u,files:el,scripts:tl,engines:rl,repository:nl,author:sl,license:il,bugs:ol,homepage:al,devDependencies:cl,dependencies:ul};function ll(){return n=>async t=>(t.header.set("x-yorkie-user-agent",Xi.name+"/"+Xi.version),await n(t))}const hl=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var bn=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(bn||{});const mn={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},us={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class ua{constructor(t,e){a(this,"id");a(this,"key");a(this,"status");a(this,"attachmentMap");a(this,"apiKey");a(this,"authTokenInjector");a(this,"conditions");a(this,"syncLoopDuration");a(this,"reconnectStreamDelay");a(this,"retrySyncLoopDelay");a(this,"rpcClient");a(this,"setAuthToken");a(this,"taskQueue");a(this,"processing",!1);a(this,"keepalive",!1);e=e||mn,this.key=e.key?e.key:ia(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=e.apiKey||"",this.authTokenInjector=e.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=e.syncLoopDuration??mn.syncLoopDuration,this.reconnectStreamDelay=e.reconnectStreamDelay??mn.reconnectStreamDelay,this.retrySyncLoopDelay=e.retrySyncLoopDelay??mn.retrySyncLoopDelay;const{authInterceptor:r,setToken:s}=Hu(this.apiKey);this.setAuthToken=s,this.rpcClient=lc(Bc,Oc({baseUrl:t,interceptors:[r,ll()],fetch:(i,o)=>{const c={...o,keepalive:this.keepalive};return fetch(i,c)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),E.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw E.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const e=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),E.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw E.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(t.keepalive){this.keepalive=!0;const r=e();return this.keepalive=!1,r}return this.enqueueTask(e)}attach(t,e={}){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==sr.Detached)throw new m(d.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((i,o)=>o.set(e.initialPresence||{}));const r=t.subscribe("local-broadcast",async i=>{var f;const{topic:o,payload:c}=i.value,l=(f=i.options)==null?void 0:f.error,h=i.options;try{await this.broadcast(t.getKey(),o,c,h)}catch(g){g instanceof Error&&(l==null||l(g))}}),s=e.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:j.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async i=>{const o=j.fromChangePack(i.changePack);if(t.applyChangePack(o),t.getStatus()===sr.Removed)return t;t.applyStatus(sr.Attached),this.attachmentMap.set(t.getKey(),new Fu(this.reconnectStreamDelay,t,i.documentId,s,r)),s!=="manual"&&await this.runWatchLoop(t.getKey()),E.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const c=t.getRootObject();if(e.initialRoot){const l=e.initialRoot;t.update(h=>{for(const[f,g]of Object.entries(l))if(!c.has(f)){const v=f;h[v]=g}})}return t}).catch(async i=>{throw E.error(`[AD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}detach(t,e={}){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((s,i)=>i.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:j.toChangePack(t.createChangePack()),removeIfNotAttached:e.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(s=>{const i=j.fromChangePack(s.changePack);return t.applyChangePack(i),t.getStatus()!==sr.Removed&&t.applyStatus(sr.Detached),this.detachInternal(t.getKey()),E.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async s=>{throw E.error(`[DD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}async changeSyncMode(t,e){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const s=r.syncMode;return s===e?t:(r.changeSyncMode(e),e==="manual"?(r.cancelWatchStream(),t):(e==="realtime"&&(r.remoteChangeEventReceived=!0),s==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);if(t){const e=this.attachmentMap.get(t.getKey());if(!e)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(e,"realtime").catch(async r=>{throw E.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const e=[];for(const[,r]of this.attachmentMap)e.push(this.syncInternal(r,r.syncMode));return Promise.all(e).catch(async r=>{throw E.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(t){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const e=this.attachmentMap.get(t.getKey());if(!e)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const r=j.toChangePack(t.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:e.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(s=>{const i=j.fromChangePack(s.changePack);t.applyChangePack(i),this.detachInternal(t.getKey()),E.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async s=>{throw E.error(`[RD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,e,r,s){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(t);if(!i)throw new m(d.ErrDocumentNotAttached,`${t} is not attached`);if(!hl(r))throw new m(d.ErrInvalidArgument,"payload is not serializable");const o=(s==null?void 0:s.maxRetries)??us.maxRetries,c=us.maxBackoff;let l=0;const h=g=>Math.min(us.initialRetryInterval*2**g,c),f=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:i.docID,topic:e,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{E.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${e}"`)}).catch(async g=>{if(E.error(`[BC] c:"${this.getKey()}" err:`,g),await this.handleConnectError(g))if(g instanceof M&&Sr(g)===d.ErrUnauthenticated&&i.doc.publish([{type:X.AuthError,value:{reason:zr(g).reason,method:"Broadcast"}}]),lf(),h(l-1)),E.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw E.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),g;else throw g}));return f()}runSyncLoop(){const t=()=>{if(!this.isActive()){E.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const e=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,e.push(this.syncInternal(r,r.syncMode).catch(async s=>{throw s instanceof M&&Sr(s)===d.ErrUnauthenticated&&r.doc.publish([{type:X.AuthError,value:{reason:zr(s).reason,method:"PushPull"}}]),s})));Promise.all(e).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async r=>{E.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};E.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const e=this.attachmentMap.get(t);if(!e)throw new m(d.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,e.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new m(d.ErrClientNotActivated,`${this.key} is not active`));const s=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:e.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:s.signal});return e.doc.publish([{type:X.ConnectionChanged,value:$s.Connected}]),E.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((o,c)=>{(async()=>{try{for await(const h of i)this.handleWatchDocumentsResponse(e,h),h.body.case==="initialization"&&o([i,s])}catch(h){e.doc.resetOnlineClients(),e.doc.publish([{type:X.Initialized,source:J.Local,value:e.doc.getPresences()}]),e.doc.publish([{type:X.ConnectionChanged,value:$s.Disconnected}]),E.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(h)?(h instanceof M&&Sr(h)===d.ErrUnauthenticated&&e.doc.publish([{type:X.AuthError,value:{reason:zr(h).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,c(h)}})()})})}handleWatchDocumentsResponse(t,e){if(e.body.case==="event"&&e.body.value.type===yr.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(e)}deactivateInternal(){this.status="deactivated";for(const[t,e]of this.attachmentMap)this.detachInternal(t),e.doc.applyStatus(sr.Detached)}detachInternal(t){const e=this.attachmentMap.get(t);e&&(e.cancelWatchStream(),e.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,e){const{doc:r,docID:s}=t,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:s,changePack:j.toChangePack(i),pushOnly:e==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const c=j.fromChangePack(o.changePack);if(c.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return r;r.applyChangePack(c),t.doc.publish([{type:X.SyncStatusChanged,value:Us.Synced}]),r.getStatus()===sr.Removed&&this.detachInternal(r.getKey());const l=r.getKey(),h=c.getChangeSize();return E.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${i.getChangeSize()} pull:${h} cp:${c.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:X.SyncStatusChanged,value:Us.SyncFailed}]),E.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(t){if(!(t instanceof M))return!1;if(t.code===R.Canceled||t.code===R.Unknown||t.code===R.ResourceExhausted||t.code===R.Unavailable)return!0;if(Sr(t)===d.ErrUnauthenticated){if(this.authTokenInjector){const e=await this.authTokenInjector(zr(t).reason);this.setAuthToken(e)}return!0}return(Sr(t)===d.ErrClientNotActivated||Sr(t)===d.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((e,r)=>{this.taskQueue.push(()=>t().then(e).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{E.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Zi={Client:ua,Document:ca,Primitive:U,Text:Qn,Counter:_n,Tree:es,LogLevel:te,setLogLevel:sa,IntType:je.IntegerCnt,LongType:je.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:ua,Document:ca,Primitive:U,Text:Qn,Counter:_n,Tree:es,LogLevel:te,setLogLevel:sa,IntType:je.IntegerCnt,LongType:je.LongCnt});const Qi=["Ali","Beatriz","Charles","Diya","Eric","Fatima","Gabriel","Hanna","Johnson","Perry","Parker","Kelly"],fl=()=>{const n=Math.floor(Math.random()*Qi.length);return Qi[n]},_i=["red","yellow","orange","green","blue","purple"],dl=()=>{const n=Math.floor(Math.random()*_i.length);return _i[n]};async function gl(){const n=new Zi.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await n.activate();const t=new Zi.Document("profile-stack",{enableDevtools:!0});t.subscribe("presence",e=>{e.type!==X.PresenceChanged&&ml(t.getPresences(),n.getID())}),await n.attach(t,{initialPresence:{name:fl(),color:dl()}}),window.addEventListener("beforeunload",()=>{n.deactivate()})}const ls=4,hs=(n,t,e)=>{const r=document.createElement("div");return r.className="peer",e==="main"?r.innerHTML=` + */var Te=null;try{Te=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function O(n,t,e){this.low=n|0,this.high=t|0,this.unsigned=!!e}O.prototype.__isLong__;Object.defineProperty(O.prototype,"__isLong__",{value:!0});function _(n){return(n&&n.__isLong__)===!0}function $i(n){var t=Math.clz32(n&-n);return n?31-t:t}O.isLong=_;var Ui={},qi={};function Ar(n,t){var e,r,s;return t?(n>>>=0,(s=0<=n&&n<256)&&(r=qi[n],r)?r:(e=B(n,0,!0),s&&(qi[n]=e),e)):(n|=0,(s=-128<=n&&n<128)&&(r=Ui[n],r)?r:(e=B(n,n<0?-1:0,!1),s&&(Ui[n]=e),e))}O.fromInt=Ar;function Ae(n,t){if(isNaN(n))return t?Xt:xe;if(t){if(n<0)return Xt;if(n>=Bo)return Jo}else{if(n<=-Vi)return re;if(n+1>=Vi)return Lo}return n<0?Ae(-n,t).neg():B(n%Jr|0,n/Jr|0,t)}O.fromNumber=Ae;function B(n,t,e){return new O(n,t,e)}O.fromBits=B;var Vn=Math.pow;function Ws(n,t,e){if(n.length===0)throw Error("empty string");if(typeof t=="number"?(e=t,t=!1):t=!!t,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return t?Xt:xe;if(e=e||10,e<2||360)throw Error("interior hyphen");if(r===0)return Ws(n.substring(1),t,e).neg();for(var s=Ae(Vn(e,8)),i=xe,o=0;o>>0:this.low};T.toNumber=function(){return this.unsigned?(this.high>>>0)*Jr+(this.low>>>0):this.high*Jr+(this.low>>>0)};T.toString=function(t){if(t=t||10,t<2||36>>0,f=h.toString(t);if(o=l,o.isZero())return f+c;for(;f.length<6;)f="0"+f;c=""+f+c}};T.getHighBits=function(){return this.high};T.getHighBitsUnsigned=function(){return this.high>>>0};T.getLowBits=function(){return this.low};T.getLowBitsUnsigned=function(){return this.low>>>0};T.getNumBitsAbs=function(){if(this.isNegative())return this.eq(re)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&!(t&1<=0};T.isOdd=function(){return(this.low&1)===1};T.isEven=function(){return(this.low&1)===0};T.equals=function(t){return _(t)||(t=De(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};T.eq=T.equals;T.notEquals=function(t){return!this.eq(t)};T.neq=T.notEquals;T.ne=T.notEquals;T.lessThan=function(t){return this.comp(t)<0};T.lt=T.lessThan;T.lessThanOrEqual=function(t){return this.comp(t)<=0};T.lte=T.lessThanOrEqual;T.le=T.lessThanOrEqual;T.greaterThan=function(t){return this.comp(t)>0};T.gt=T.greaterThan;T.greaterThanOrEqual=function(t){return this.comp(t)>=0};T.gte=T.greaterThanOrEqual;T.ge=T.greaterThanOrEqual;T.compare=function(t){if(_(t)||(t=De(t)),this.eq(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};T.comp=T.compare;T.negate=function(){return!this.unsigned&&this.eq(re)?re:this.not().add(Er)};T.neg=T.negate;T.add=function(t){_(t)||(t=De(t));var e=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=t.high>>>16,c=t.high&65535,l=t.low>>>16,h=t.low&65535,f=0,g=0,v=0,p=0;return p+=i+h,v+=p>>>16,p&=65535,v+=s+l,g+=v>>>16,v&=65535,g+=r+c,f+=g>>>16,g&=65535,f+=e+o,f&=65535,B(v<<16|p,f<<16|g,this.unsigned)};T.subtract=function(t){return _(t)||(t=De(t)),this.add(t.neg())};T.sub=T.subtract;T.multiply=function(t){if(this.isZero())return this;if(_(t)||(t=De(t)),Te){var e=Te.mul(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Xt:xe;if(this.eq(re))return t.isOdd()?re:xe;if(t.eq(re))return this.isOdd()?re:xe;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Ki)&&t.lt(Ki))return Ae(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,o=this.low&65535,c=t.high>>>16,l=t.high&65535,h=t.low>>>16,f=t.low&65535,g=0,v=0,p=0,w=0;return w+=o*f,p+=w>>>16,w&=65535,p+=i*f,v+=p>>>16,p&=65535,p+=o*h,v+=p>>>16,p&=65535,v+=s*f,g+=v>>>16,v&=65535,v+=i*h,g+=v>>>16,v&=65535,v+=o*l,g+=v>>>16,v&=65535,g+=r*f+s*h+i*l+o*c,g&=65535,B(p<<16|w,g<<16|v,this.unsigned)};T.mul=T.multiply;T.divide=function(t){if(_(t)||(t=De(t)),t.isZero())throw Error("division by zero");if(Te){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?Te.div_u:Te.div_s)(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Xt:xe;var r,s,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Xt;if(t.gt(this.shru(1)))return Ro;i=Xt}else{if(this.eq(re)){if(t.eq(Er)||t.eq(Fs))return re;if(t.eq(re))return Er;var o=this.shr(1);return r=o.div(t).shl(1),r.eq(xe)?t.isNegative()?Er:Fs:(s=this.sub(t.mul(r)),i=r.add(s.div(t)),i)}else if(t.eq(re))return this.unsigned?Xt:xe;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=xe}for(s=this;s.gte(t);){r=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(r)/Math.LN2),l=c<=48?1:Vn(2,c-48),h=Ae(r),f=h.mul(t);f.isNegative()||f.gt(s);)r-=l,h=Ae(r,this.unsigned),f=h.mul(t);h.isZero()&&(h=Er),i=i.add(h),s=s.sub(f)}return i};T.div=T.divide;T.modulo=function(t){if(_(t)||(t=De(t)),Te){var e=(this.unsigned?Te.rem_u:Te.rem_s)(this.low,this.high,t.low,t.high);return B(e,Te.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};T.mod=T.modulo;T.rem=T.modulo;T.not=function(){return B(~this.low,~this.high,this.unsigned)};T.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};T.clz=T.countLeadingZeros;T.countTrailingZeros=function(){return this.low?$i(this.low):$i(this.high)+32};T.ctz=T.countTrailingZeros;T.and=function(t){return _(t)||(t=De(t)),B(this.low&t.low,this.high&t.high,this.unsigned)};T.or=function(t){return _(t)||(t=De(t)),B(this.low|t.low,this.high|t.high,this.unsigned)};T.xor=function(t){return _(t)||(t=De(t)),B(this.low^t.low,this.high^t.high,this.unsigned)};T.shiftLeft=function(t){return _(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low<>>32-t,this.unsigned):B(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):B(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};T.shr=T.shiftRight;T.shiftRightUnsigned=function(t){return _(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?B(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?B(this.high,0,this.unsigned):B(this.high>>>t-32,0,this.unsigned)};T.shru=T.shiftRightUnsigned;T.shr_u=T.shiftRightUnsigned;T.rotateLeft=function(t){var e;return _(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(e=32-t,B(this.low<>>e,this.high<>>e,this.unsigned)):(t-=32,e=32-t,B(this.high<>>e,this.low<>>e,this.unsigned))};T.rotl=T.rotateLeft;T.rotateRight=function(t){var e;return _(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?B(this.high,this.low,this.unsigned):t<32?(e=32-t,B(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,e=32-t,B(this.low<>>t,this.high<>>t,this.unsigned))};T.rotr=T.rotateRight;T.toSigned=function(){return this.unsigned?B(this.low,this.high,!1):this};T.toUnsigned=function(){return this.unsigned?this:B(this.low,this.high,!0)};T.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};T.toBytesLE=function(){var t=this.high,e=this.low;return[e&255,e>>>8&255,e>>>16&255,e>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};T.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,e>>>24,e>>>16&255,e>>>8&255,e&255]};O.fromBytes=function(t,e,r){return r?O.fromBytesLE(t,e):O.fromBytesBE(t,e)};O.fromBytesLE=function(t,e){return new O(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};O.fromBytesBE=function(t,e){return new O(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)};var H=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(H||{});class U extends sn{constructor(e,r){super(r);a(this,"valueType");a(this,"value");this.valueType=U.getPrimitiveType(e),this.value=e===void 0?null:e}static of(e,r){return new U(e,r)}static valueFromBytes(e,r){switch(e){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const s=new DataView(r.buffer);return r.forEach(function(i,o){s.setUint8(o,i)}),s.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return O.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(O.fromBytesLE(Array.from(r),!0).toNumber());default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return this.valueType===5?`"${Ve(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const e=U.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(e)?2:4;case"string":return 5;case"object":if(e===null)return 0;if(e instanceof O)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return U.getPrimitiveType(e)!==void 0}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===2||e===3||e===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 4:{const e=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,e,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const e=this.value,r=O.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new m(d.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class Kn extends Oo{constructor(e){super(e);a(this,"prev");a(this,"next");this.value=e}static createAfter(e,r){const s=new Kn(r),i=e.next;return e.next=s,s.prev=e,s.next=i,i&&(i.prev=s),s}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class en{constructor(){a(this,"dummyHead");a(this,"last");a(this,"nodeMapByIndex");a(this,"nodeMapByCreatedAt");const t=U.of(0,Ne);t.setRemovedAt(Ne),this.dummyHead=new Kn(t),this.last=this.dummyHead,this.nodeMapByIndex=new _r,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new en}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,e){let r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new m(d.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(e);)r=r.getNext();return r}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,e,r=e.getCreatedAt()){const s=this.findNextBeforeExecutedAt(t,r),i=Kn.createAfter(s,e);s===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(s,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(t,e,r){const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new m(d.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new m(d.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);s!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(s.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return String(this.nodeMapByIndex.indexOf(e))}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new m(d.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(e)}getByIndex(t){if(t>=this.length)return;const[e,r]=this.nodeMapByIndex.find(t);let s=e;if(t===0&&e===this.dummyHead||r>0)do s&&(s=s.getNext());while(s&&s.isRemoved());return s}getPrevCreatedAt(t){let e=this.nodeMapByCreatedAt.get(t.toIDString());do e=e.getPrev();while(this.dummyHead!==e&&e.isRemoved());return e.getValue().getCreatedAt()}delete(t,e){const r=this.nodeMapByCreatedAt.get(t.toIDString()),s=r.isRemoved();return r.remove(e)&&!s&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(t,e){const r=this.getByIndex(t);if(r)return r.remove(e)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const e of this){const r=`${e.getCreatedAt().toIDString()}:${e.getValue().toJSON()}`;e.isRemoved()?t.push(`{${r}}`):t.push(`[${r}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class ae extends ar{constructor(e,r){super(e);a(this,"elements");this.elements=r}static create(e,r){if(!r)return new ae(e,en.create());const s=en.create();for(const i of r)s.insertAfter(s.getLastCreatedAt(),i.deepcopy());return new ae(e,s)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,r){this.elements.insertAfter(e,r)}moveAfter(e,r,s){this.elements.moveAfter(e,r,s)}get(e){const r=this.elements.getByIndex(e);return r==null?void 0:r.getValue()}getByID(e){const r=this.elements.getByID(e);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,r){return this.elements.delete(e,r)}deleteByIndex(e,r){return this.elements.deleteByIndex(e,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(const r of this.elements){const s=r.getValue();if(e(s,this))return;s instanceof ar&&s.getDescendants(e)}}toJSON(){const e=[];for(const r of this)e.push(r.toJSON());return`[${e.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(let r=0;r({...w,value:w.value?{attributes:Cr(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[f,p,g,[h,h]]}setStyle(e,r,s,i,o){const[,c]=this.rgaTreeSplit.findNodeWithSplit(e[1],s),[,l]=this.rgaTreeSplit.findNodeWithSplit(e[0],s),h=[],f=this.rgaTreeSplit.findBetween(l,c),g=new Map,v=[];for(const w of f){const b=w.getCreatedAt().getActorID();let x,C=0n;if(o===void 0&&i===void 0?C=jr:o.size()>0?C=o.get(b)?o.get(b):0n:x=i.has(b)?i.get(b):Ne,w.canStyle(s,x,C)){const P=g.get(b),L=w.getCreatedAt();(!P||L.after(P))&&g.set(b,L),v.push(w)}}const p=[];for(const w of v){if(w.isRemoved())continue;const[b,x]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());h.push({type:"style",actor:s.getActorID(),from:b,to:x,value:{attributes:Cr(r)}});for(const[C,P]of Object.entries(r)){const[L]=w.getValue().setAttr(C,P,s);L!==void 0&&p.push({parent:w.getValue(),child:L})}}return[g,p,h]}indexRangeToPosRange(e,r){const s=this.rgaTreeSplit.indexToPos(e);return e===r?[s,s]:[s,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const e=[];for(const r of this.rgaTreeSplit)r.isRemoved()||e.push(r.getValue().toJSON());return`[${e.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const e=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const s=r.getValue();e.push({attributes:Cr(s.getAttributes()),content:s.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const e=new Ie(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){const e=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:r});for(const s of r.getValue().getGCPairs())e.push(s)}return e}}class an extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"content");a(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.content=o,this.attributes=c}static create(e,r,s,i,o,c,l){return new an(e,r,s,i,o,c,l)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Ie))throw new m(d.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,c,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,s);for(const h of l)e.registerGCPair(h);return{opInfos:c.map(({from:h,to:f,value:g})=>({type:"edit",from:h,to:f,value:g,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.content;return`${e}.EDIT(${r},${s},${i})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class cn extends Pe{constructor(e,r,s,i,o,c){super(e,c);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o}static create(e,r,s,i,o,c){return new cn(e,r,s,i,o,c)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Ie))throw new m(d.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,c,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,s);for(const h of c)e.registerGCPair(h);return{opInfos:l.map(({from:h,to:f,value:g})=>({type:"style",from:h,to:f,value:g,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.attributes;return`${e}.STYL(${r},${s},${JSON.stringify(i)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const Uc=2,qc="root",Zt="text";function qr(n,t){let e=0;const r=n.children;for(let s=0;s0)throw new m(d.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const e=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*e,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const e of this._children){const r=e.updateDescendantsSize();e.isRemoved||(t+=r)}return this.size+=t,this.paddedSize}get isText(){return this.type===Zt}get paddedSize(){return this.size+(this.isText?0:Uc)}isAncestorOf(t){return Vc(this,t)}get nextSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t+1];if(e)return e}get prevSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t-1];if(e)return e}splitText(t,e){if(t===0||t===this.size)return;const r=this.value.slice(0,t),s=this.value.slice(t);if(!s.length)return;this.value=r;const i=this.cloneText(t+e);return i.value=s,this.parent.insertAfterInternal(i,this),i}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const e of t)e.parent=this,e.updateAncestorsSize()}prepend(...t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const e of t)e.parent=this}insertBefore(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r),t.updateAncestorsSize()}insertAfter(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1),t.updateAncestorsSize()}insertAt(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,e),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const e=this._children.indexOf(t);if(e===-1)throw new m(d.ErrInvalidArgument,"child not found");this._children.splice(e,1),t.parent=void 0}splitElement(t,e){const r=this.cloneElement(e);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const s=this.children.slice(0,t),i=this.children.slice(t);this._children=s,r._children=i,this.size=this._children.reduce((o,c)=>o+c.paddedSize,0),r.size=r._children.reduce((o,c)=>o+c.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(e);if(r===-1)throw new m(d.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1)}insertAtInternal(t,e){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");this._children.splice(e,0,t),t.parent=this}findOffset(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");if(t.isRemoved){const e=this._children.indexOf(t);return this.allChildren.splice(0,e).filter(s=>!s.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new m(d.ErrRefused,"Text node cannot have children");let e=t;for(;e;){const r=this._children.indexOf(e);if(r!==-1)return r;e=e.parent}return-1}}function Vc(n,t){if(n===t)return!1;for(;t.parent;){if(t.parent===n)return!0;t=t.parent}return!1}var W=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(W||{});function Fo(n,t,e,r){if(t>e)throw new m(d.ErrInvalidArgument,`from is greater than to: ${t} > ${e}`);if(t>n.size)throw new m(d.ErrInvalidArgument,`from is out of range: ${t} > ${n.size}`);if(e>n.size)throw new m(d.ErrInvalidArgument,`to is out of range: ${e} > ${n.size}`);if(t===e)return;let s=0;for(const i of n.children){if(t-i.paddedSizei.size;(i.isText||l)&&r([i,i.isText?"Text":"Start"],h),Fo(i,Math.max(0,o),Math.min(c,i.size),r),h&&r([i,"End"],h)}s+=i.paddedSize}}function Mo(n,t,e=0){for(const r of n.children)Mo(r,t,e+1);t(n,e)}function Zn(n,t,e=0){for(const r of n._children)Zn(r,t,e+1);t(n,e)}function Ms(n,t,e=!0){if(t>n.size)throw new m(d.ErrInvalidArgument,`index is out of range: ${t} > ${n.size}`);if(n.isText)return{node:n,offset:t};let r=0,s=0;for(const i of n.children){if(e&&i.isText&&i.size>=t-s)return Ms(i,t-s,e);if(t===s)return{node:n,offset:r};if(!e&&i.paddedSize===t-s)return{node:n,offset:r+1};if(i.paddedSize>t-s)return Ms(i,t-s-1,e);s+=i.paddedSize,r+=1}return{node:n,offset:r}}function $o(n){return n.isText||n.children.length===0?n:$o(n.children[0])}function Kc(n,t){if(n.sizen===t?0:n0)if(e.right)e.right.parent=e,e=e.right;else return e;else if(r<0)if(e.left)e.left.parent=e,e=e.left;else{let s=e.parent,i=e;for(;s&&i===s.left;)i=s,s=s.parent;return s}else return e}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,e){for(;e;){const r=this.comparator(t,e.key);if(r===0)return e;r<0?e=e.left:r>0&&(e=e.right)}}putInternal(t,e,r){if(!r)return this.counter+=1,new Wc(t,e,!0);const s=this.comparator(t,r.key);return s<0?r.left=this.putInternal(t,e,r.left):s>0?r.right=this.putInternal(t,e,r.right):r.value=e,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(t,e){if(this.comparator(e,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,e);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(e,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(e,t.key)===0){this.counter-=1;const r=this.min(t.right);t.value=r.value,t.key=r.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,e)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const e=t.right;return t.right=e.left,e.left=t,e.isRed=e.left.isRed,e.left.isRed=!0,e}rotateRight(t){const e=t.left;return t.left=e.right,e.right=t,e.isRed=e.right.isRed,e.right.isRed=!0,e}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class Ee{constructor(t,e){a(this,"parentID");a(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=e}static of(t,e){return new Ee(t,e)}static fromTreePos(t){const{offset:e}=t;let{node:r}=t,s;return r.isText?(r.parent.children[0]===r&&e===0?s=r.parent:s=r,r=r.parent):e===0?s=r:s=r.children[e-1],Ee.of(r.id,Z.of(s.getCreatedAt(),s.getOffset()+e))}getParentID(){return this.parentID}static fromStruct(t){return Ee.of(Z.of(be.fromStruct(t.parentID.createdAt),t.parentID.offset),Z.of(be.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const e=this.getParentID(),r=this.getLeftSiblingID(),s=t.findFloorNode(e);let i=t.findFloorNode(r);if(!s||!i)throw new m(d.ErrRefused,`cannot find node of CRDTTreePos(${e.toTestString()}, ${r.toTestString()})`);return!r.equals(e)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=t.findFloorNode(i.insPrevID)),[s,i]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class Z{constructor(t,e){a(this,"createdAt");a(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new Z(t,e)}static fromStruct(t){return Z.of(be.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,e)=>{const r=t.getCreatedAt().compare(e.getCreatedAt());return r!==0?r:t.getOffset()>e.getOffset()?1:t.getOffset(){const i=s.deepcopy();return i.parent=e,i}),e.insPrevID=this.insPrevID,e.insNextID=this.insNextID,e}get value(){if(!this.isText)throw new m(d.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(e){if(!this.isText)throw new m(d.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),r&&this.updateAncestorsSize()}cloneText(e){return new oe(Z.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new oe(Z.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,r,s){const i=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,s);if(i){if(i.insPrevID=this.id,this.insNextID){const o=e.findFloorNode(this.insNextID);o.insPrevID=i.id,i.insNextID=this.insNextID}this.insNextID=i.id,e.registerNode(i)}return i}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,r,s){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,r,s){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,r){this.attrs||(this.attrs=new er);const s=[];for(const[i,o]of Object.entries(e))s.push(this.attrs.set(i,o,r));return s}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){const e=[];if(!this.attrs)return e;for(const r of this.attrs)r.getRemovedAt()&&e.push({parent:this,child:r});return e}}function $s(n){var e;if(n.isText){const r=n;return{type:r.type,value:r.value}}const t={type:n.type,children:n.children.map($s)};return n.attrs&&(t.attributes=Cr((e=n.attrs)==null?void 0:e.toObject())),t}function Hs(n){if(n.isText)return n.value;let t="";return n.attrs&&n.attrs.size()&&(t=" "+Array.from(n.attrs).filter(e=>!e.isRemoved()).sort((e,r)=>e.getKey().localeCompare(r.getKey())).map(e=>{const r=JSON.parse(e.getValue());return typeof r=="string"?`${e.getKey()}="${r}"`:`${e.getKey()}="${Ve(e.getValue())}"`}).join(" ")),`<${n.type}${t}>${n.children.map(e=>Hs(e)).join("")}`}function qo(n){if(n.isText){const t=n;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:n.type,children:n.children.map(qo),size:n.size,isRemoved:n.isRemoved}}class Se extends sn{constructor(e,r){super(r);a(this,"indexTree");a(this,"nodeMapByID");this.indexTree=new jc(e),this.nodeMapByID=new Uo(Z.createComparator()),this.indexTree.traverseAll(s=>{this.nodeMapByID.put(s.id,s)})}static create(e,r){return new Se(e,r)}findFloorNode(e){const r=this.nodeMapByID.floorEntry(e);if(!(!r||!r.key.getCreatedAt().equals(e.getCreatedAt())))return r.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,r){const[s,i]=e.toTreeNodePair(this);let o=i;const c=s===o,l=o.parent&&!c?o.parent:s;if(o.isText&&o.split(this,e.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const h=l.allChildren,f=c?0:h.indexOf(o)+1;for(let g=f;g{const x=b.getCreatedAt().getActorID();let C,P=0n;if(o===void 0&&i===void 0?P=jr:o.size()>0?P=o.get(x)?o.get(x):0n:C=i.has(x)?i.get(x):Ne,b.canStyle(s,C,P)&&r){const L=p.get(x),Y=b.getCreatedAt();(!L||Y.after(L))&&p.set(x,Y);const D=b.setAttrs(r,s),F=D.reduce((ue,[,Ge])=>(Ge&&(ue[Ge.getKey()]=v[Ge.getKey()]),ue),{}),V=b.parent,K=b.prevSibling||b.parent;Object.keys(F).length>0&&g.push({type:"style",from:this.toIndex(V,K),to:this.toIndex(b,b),fromPath:this.toPath(V,K),toPath:this.toPath(b,b),actor:s.getActorID(),value:F});for(const[ue]of D)ue&&w.push({parent:b,child:ue})}}),[p,w,g]}removeStyle(e,r,s,i,o){const[c,l]=this.findNodesAndSplitText(e[0],s),[h,f]=this.findNodesAndSplitText(e[1],s),g=[],v=new Map,p=[];return this.traverseInPosRange(c,l,h,f,([w])=>{const b=w.getCreatedAt().getActorID();let x,C=0n;if(o===void 0&&i===void 0?C=jr:o.size()>0?C=o.get(b)?o.get(b):0n:x=i.has(b)?i.get(b):Ne,w.canStyle(s,x,C)&&r){const P=v.get(b),L=w.getCreatedAt();(!P||L.after(P))&&v.set(b,L),w.attrs||(w.attrs=new er);for(const F of r){const V=w.attrs.remove(F,s);for(const K of V)p.push({parent:w,child:K})}const Y=w.parent,D=w.prevSibling||w.parent;g.push({actor:s.getActorID(),type:"removeStyle",from:this.toIndex(Y,D),to:this.toIndex(w,w),fromPath:this.toPath(Y,D),toPath:this.toPath(w,w),value:r})}}),[v,p,g]}edit(e,r,s,i,o,c,l){const[h,f]=this.findNodesAndSplitText(e[0],i),[g,v]=this.findNodesAndSplitText(e[1],i),p=this.toIndex(h,f),w=this.toPath(h,f),b=[],x=[],C=[],P=new Map;this.traverseInPosRange(h,f,g,v,([D,F],V)=>{if(F===W.Start&&!V)for(const br of D.children)C.push(br);const K=D.getCreatedAt().getActorID();let ue,Ge=0n;if(l===void 0&&c===void 0?Ge=jr:l.size()>0?Ge=l.get(K)?l.get(K):0n:ue=c.has(K)?c.get(K):Ne,D.canDelete(i,ue,Ge)||b.includes(D.parent)){const br=P.get(K),ai=D.getCreatedAt();(!br||ai.after(br))&&P.set(K,ai),(F===W.Text||F===W.Start)&&b.push(D),x.push([D,F])}});const L=this.makeDeletionChanges(x,i),Y=[];for(const D of b)D.remove(i),D.isRemoved&&Y.push({parent:this,child:D});for(const D of C)D.removedAt||h.append(D);if(s>0){let D=0,F=h,V=f;for(;D{h.isRemoved&&(K.remove(i),Y.push({parent:this,child:K})),this.nodeMapByID.put(K.id,K)}),V.isRemoved||D.push(V);if(D.length){const V=D.map(K=>$s(K));L.length&&L[L.length-1].from===p?L[L.length-1].value=V:L.push({type:"content",from:p,to:p,fromPath:w,toPath:w,actor:i.getActorID(),value:V})}}return[L,Y,P]}editT(e,r,s,i,o){const c=this.findPos(e[0]),l=this.findPos(e[1]);this.edit([c,l],r,s,i,o)}move(e,r,s){throw new m(d.ErrUnimplemented,`not implemented: ${e}, ${r}, ${s}`)}purge(e){var i;(i=e.parent)==null||i.removeChild(e),this.nodeMapByID.remove(e.id);const r=e.insPrevID,s=e.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=s}if(s){const o=this.findFloorNode(s);o.insPrevID=r}e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){const e=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&e.push({parent:this,child:r});for(const s of r.getGCPairs())e.push(s)}),e}findPos(e,r=!0){const s=this.indexTree.findTreePos(e,r);return Ee.fromTreePos(s)}pathToPosRange(e){const r=this.pathToIndex(e);return[this.findPos(r),this.findPos(r+1)]}pathToPos(e){const r=this.indexTree.pathToIndex(e);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Hs(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const e=this.indexTree.getRoot(),r=(s,i=void 0,o=void 0,c=0)=>{var p,w,b,x;let l,h,f;const g=s.isText?{node:s,offset:0}:i&&o?this.toTreePos(i,o):null;g&&(l=this.indexTree.indexOf(g),h=this.indexTree.treePosToPath(g),f=Ee.fromTreePos(g).toStruct());const v={type:s.type,parent:i==null?void 0:i.id.toTestString(),size:s.size,id:s.id.toTestString(),removedAt:(p=s.removedAt)==null?void 0:p.toTestString(),insPrev:(w=s.insPrevID)==null?void 0:w.toTestString(),insNext:(b=s.insNextID)==null?void 0:b.toTestString(),value:s.isText?s.value:void 0,isRemoved:s.isRemoved,children:[],depth:c,attributes:s.attrs?Cr((x=s.attrs)==null?void 0:x.toObject()):void 0,index:l,path:h,pos:f};for(let C=0;C0&&C===s[s.length-1].to?(s[s.length-1].to=P,s[s.length-1].toPath=this.toPath(x,p)):s.push({type:"content",from:C,to:P,fromPath:this.toPath(b,g),toPath:this.toPath(x,p),actor:r.getActorID()}))}return s.reverse()}findRightToken([e,r]){if(r===W.Start){const l=e.allChildren;return l.length>0?[l[0],l[0].isText?W.Text:W.Start]:[e,W.End]}const s=e.parent,i=s.allChildren,o=i.indexOf(e);if(s&&o===i.length-1)return[s,W.End];const c=i[o+1];return[c,c.isText?W.Text:W.Start]}findLeftToken([e,r]){if(r===W.End){const l=e.allChildren;if(l.length>0){const h=l[l.length-1];return[h,h.isText?W.Text:W.End]}return[e,W.Start]}const s=e.parent,i=s.allChildren,o=i.indexOf(e);if(s&&o===0)return[s,W.Start];const c=i[o-1];return[c,c.isText?W.Text:W.End]}}class un extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"contents");a(this,"splitLevel");a(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=s,this.contents=i,this.splitLevel=o,this.maxCreatedAtMapByActor=c}static create(e,r,s,i,o,c,l){return new un(e,r,s,i,o,c,l)}execute(e,r,s){var f;const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Se))throw new m(d.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),c=i,[l,h]=c.edit([this.fromPos,this.toPos],(f=this.contents)==null?void 0:f.map(g=>g.deepcopy()),this.splitLevel,o,(()=>{let g=o.getDelimiter();return this.contents!==void 0&&(g+=this.contents.length),()=>be.of(o.getLamport(),++g,o.getActorID())})(),this.maxCreatedAtMapByActor,s);for(const g of h)e.registerGCPair(g);return{opInfos:l.map(({from:g,to:v,value:p,splitLevel:w,fromPath:b,toPath:x})=>({type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:g,to:v,value:p,splitLevel:w,fromPath:b,toPath:x}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,i=this.contents||[];return`${e}.EDIT(${r},${s},${i.map(o=>Hs(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Pr{constructor(t){a(this,"vector");this.vector=t||new Map}set(t,e){this.vector.set(t,e)}unset(t){this.vector.delete(t)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,e]of this)e>t&&(t=e);return t}max(t){const e=new Map;for(const[r,s]of t){const i=this.vector.get(r),o=i&&i>s?i:s;e.set(r,o)}for(const[r,s]of this){const i=t.get(r),o=i&&i>s?i:s;e.set(r,o)}return new Pr(e)}afterOrEqual(t){const e=this.vector.get(t.getActorID());return e===void 0?!1:e>=t.getLamport()}deepcopy(){const t=new Map;for(const[e,r]of this.vector)t.set(e,r);return new Pr(t)}filter(t){const e=new Map;for(const[r]of t){const s=this.vector.get(r);s!==void 0&&e.set(r,s)}return new Pr(e)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,e]of this.vector)yield[t,e]}}const Yc=new Pr(new Map);class Gt{constructor(t,e,r,s,i){a(this,"clientSeq");a(this,"serverSeq");a(this,"lamport");a(this,"actor");a(this,"versionVector");this.clientSeq=t,this.serverSeq=i,this.lamport=e,this.versionVector=s,this.actor=r}static of(t,e,r,s,i){return new Gt(t,e,r,s,i)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new Gt(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const e=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n;let r=t.versionVector;r.size()===0&&(r=r.deepcopy(),r.set(t.actor,t.lamport));const s=this.versionVector.max(r),i=new Gt(this.clientSeq,e,this.actor,s);return i.versionVector.set(this.actor,e),i}setClocks(t,e){const r=t>this.lamport?t+1n:this.lamport+1n;e.unset(Xn);const s=this.versionVector.max(e);return s.set(this.actor,r),Gt.of(this.clientSeq,r,this.actor,s)}createTimeTicket(t){return be.of(this.lamport,t,this.actor)}setActor(t){return new Gt(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new Gt(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const Xc=new Gt(0,0n,Xn,Yc);class Fr{constructor({id:t,operations:e,presenceChange:r,message:s}){a(this,"id");a(this,"operations");a(this,"presenceChange");a(this,"message");this.id=t,this.operations=e||[],this.presenceChange=r,this.message=s}static create({id:t,operations:e,presenceChange:r,message:s}){return new Fr({id:t,operations:e,presenceChange:r,message:s})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const e of this.operations)e.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,e,r){const s=[],i=[];for(const o of this.operations){const c=o.execute(t,r,this.id.getVersionVector());if(!c)continue;const{opInfos:l,reverseOp:h}=c;s.push(...l),h&&i.unshift(h)}return this.presenceChange&&(this.presenceChange.type===lr.Put?e.set(this.id.getActorID(),ke(this.presenceChange.presence)):e.delete(this.id.getActorID())),{opInfos:s,reverseOps:i}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:j.bytesToHex(j.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>j.bytesToHex(j.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:e,operations:r,presenceChange:s,message:i}=t;return Fr.create({id:j.bytesToChangeID(j.hexToBytes(e)),operations:r==null?void 0:r.map(o=>j.bytesToOperation(j.hexToBytes(o))),presenceChange:s,message:i})}}class Qn{constructor(t,e,r,s,i,o,c){a(this,"documentKey");a(this,"checkpoint");a(this,"isRemoved");a(this,"changes");a(this,"snapshot");a(this,"minSyncedTicket");a(this,"versionVector");this.documentKey=t,this.checkpoint=e,this.isRemoved=r,this.changes=s,this.snapshot=o,this.minSyncedTicket=c,this.versionVector=i}static create(t,e,r,s,i,o,c){return new Qn(t,e,r,s,i,o,c)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Dr{constructor(t,e){a(this,"serverSeq");a(this,"clientSeq");this.serverSeq=t,this.clientSeq=e}static of(t,e){return new Dr(t,e)}increaseClientSeq(t){return t===0?this:new Dr(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const e=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,r=Math.max(this.clientSeq,t.clientSeq);return Dr.of(e,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const Zc=new Dr(0n,0);class Ke{constructor(t,e){a(this,"createdAt");a(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new Ke(t,e)}static fromStruct(t){return Ke.of(be.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new Ke(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Qc=Ke.of(Ne,0);class Ce{constructor(t,e){a(this,"id");a(this,"relativeOffset");this.id=t,this.relativeOffset=e}static of(t,e){return new Ce(t,e)}static fromStruct(t){const e=Ke.fromStruct(t.id);return Ce.of(e,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return Ke.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class cr extends Oo{constructor(e,r,s){super(r);a(this,"id");a(this,"removedAt");a(this,"prev");a(this,"next");a(this,"insPrev");a(this,"insNext");this.id=e,this.removedAt=s}static create(e,r){return new cr(e,r)}static createComparator(){return(e,r)=>{const s=e.getCreatedAt().compare(r.getCreatedAt());return s!==0?s:e.getOffset()>r.getOffset()?1:e.getOffset()0&&e.getID().getOffset()==t.getOffset()){if(!e.hasInsPrev())return e;e=e.getInsPrev()}return e}findFloorNode(t){const e=this.treeByID.floorEntry(t);if(e&&!(!e.key.equals(t)&&!e.key.hasSameCreatedAt(t)))return e.value}findBetween(t,e){const r=[];let s=t;for(;s&&s!==e;)r.push(s),s=s.getNext();return r}splitNode(t,e){if(e>t.getContentLength())throw new m(d.ErrInvalidArgument,"offset should be less than or equal to length");if(e===0)return t;if(e===t.getContentLength())return t.getNext();const r=t.split(e);this.treeByIndex.updateWeight(r),this.insertAfter(t,r);const s=t.getInsNext();return s&&s.setInsPrev(r),r.setInsPrev(t),r}deleteNodes(t,e,r,s){if(!t.length)return[[],new Map,new Map];const[i,o]=this.filterNodes(t,e,r,s),c=new Map,l=new Map,h=this.makeChanges(o,e);for(const f of i){const g=f.getCreatedAt().getActorID();(!c.has(g)||f.getID().getCreatedAt().after(c.get(g)))&&c.set(g,f.getID().getCreatedAt()),l.set(f.getID().toIDString(),f),f.remove(e)}return this.deleteIndexNodes(o),[h,c,l]}filterNodes(t,e,r,s){const i=[],o=[],[c,l]=this.findEdgesOfCandidates(t);o.push(c);for(const h of t){const f=h.getCreatedAt().getActorID();let g,v=0n;s===void 0&&r===void 0?v=jr:s.size()>0?v=s.get(f)?s.get(f):0n:g=r.has(f)?r.get(f):Ne,h.canDelete(e,g,v)?i.push(h):o.push(h)}return o.push(l),[i,o]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,e){const r=[];let s,i;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var je=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(je||{});class ce extends sn{constructor(e,r,s){super(s);a(this,"valueType");a(this,"value");switch(this.valueType=e,e){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=O.fromNumber(r).toInt():this.value=ji(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=O.fromNumber(r):this.value=r;break;default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}static create(e,r,s){return new ce(e,r,s)}static valueFromBytes(e,r){switch(e){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return O.fromBytesLE(Array.from(r));default:throw new m(d.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const e=ce.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":return e instanceof O?1:void 0;case"number":return e>Math.pow(2,31)-1||e<-Math.pow(2,31)?1:0;default:return}}static isSupport(e){return!!ce.getCounterType(e)}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===0||e===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new m(d.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(e){function r(s){if(!s.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof s.getValue()}`)}return r(this),r(e),this.valueType===1?this.value=this.value.add(e.getValue()):e.getType()===H.Long?this.value=this.value+e.getValue().toInt():this.value=O.fromNumber(this.value+ji(e.getValue())).toInt(),this}}class $r extends Pe{constructor(e,r,s){super(e,s);a(this,"value");this.value=r}static create(e,r,s){return new $r(e,r,s)}execute(e){const r=e.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof ce))throw new m(d.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const s=r,i=this.value.deepcopy();return s.increase(i),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:i.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const e=this.value.deepcopy(),s=e.getType()===H.Long?e.getValue().multiply(-1):e.getValue()*-1;return $r.create(this.getParentCreatedAt(),U.of(s,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Qt extends Pe{constructor(e,r,s,i,o,c,l){super(e,l);a(this,"fromPos");a(this,"toPos");a(this,"maxCreatedAtMapByActor");a(this,"attributes");a(this,"attributesToRemove");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o,this.attributesToRemove=c}static create(e,r,s,i,o,c){return new Qt(e,r,s,i,o,[],c)}static createTreeRemoveStyleOperation(e,r,s,i,o,c){return new Qt(e,r,s,i,new Map,o,c)}execute(e,r,s){const i=e.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new m(d.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof Se))throw new m(d.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=i;let c,l;if(this.attributes.size){const h={};[...this.attributes].forEach(([f,g])=>h[f]=g),[,l,c]=o.style([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}else{const h=this.attributesToRemove;[,l,c]=o.removeStyle([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}for(const h of l)e.registerGCPair(h);return{opInfos:c.map(({from:h,to:f,value:g,fromPath:v,toPath:p})=>({type:"tree-style",from:h,to:f,value:this.attributes.size?{attributes:g}:{attributesToRemove:g},fromPath:v,toPath:p,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${e}.STYLE(${r},${s},${Object.entries(this.attributes||{}).map(([i,o])=>`${i}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function _c(n){const t=new js,e=t.data;for(const[r,s]of Object.entries(n))e[r]=JSON.stringify(s);return t}function eu(n){if(n.type===lr.Put)return new Zr({type:wr.PUT,presence:_c(n.presence)});if(n.type===lr.Clear)return new Zr({type:wr.CLEAR});throw new m(d.ErrUnimplemented,"unimplemented type")}function tu(n){return new Co({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function zo(n){return new Hn({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:ii(n.getActorID()),versionVector:Ys(n.getVersionVector())})}function S(n){if(n)return new I({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:ii(n.getActorID())})}function Ys(n){if(!n)return;const t=new Yn;for(const[e,r]of n)t.vector[e]=BigInt(r.toString());return t}function Vo(n){switch(n){case H.Null:return N.NULL;case H.Boolean:return N.BOOLEAN;case H.Integer:return N.INTEGER;case H.Long:return N.LONG;case H.Double:return N.DOUBLE;case H.String:return N.STRING;case H.Bytes:return N.BYTES;case H.Date:return N.DATE;default:throw new m(d.ErrInvalidType,`unsupported type: ${n}`)}}function Ko(n){switch(n){case je.IntegerCnt:return N.INTEGER_CNT;case je.LongCnt:return N.LONG_CNT;default:throw new m(d.ErrInvalidType,`unsupported type: ${n}`)}}function as(n){if(n instanceof ne)return new le({type:N.JSON_OBJECT,createdAt:S(n.getCreatedAt()),value:na(n)});if(n instanceof ae)return new le({type:N.JSON_ARRAY,createdAt:S(n.getCreatedAt()),value:Ou(n)});if(n instanceof Ie)return new le({type:N.TEXT,createdAt:S(n.getCreatedAt())});if(n instanceof U)return new le({type:Vo(n.getType()),createdAt:S(n.getCreatedAt()),value:n.toBytes()});if(n instanceof ce)return new le({type:Ko(n.getType()),createdAt:S(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Se)return new le({type:N.TREE,createdAt:S(n.getCreatedAt()),value:Ru(n)});throw new m(d.ErrUnimplemented,"unimplemented element")}function ru(n){return new Yr({createdAt:S(n.getCreatedAt()),offset:n.getOffset()})}function hn(n){return new _t({createdAt:S(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function fn(n){return new vr({parentId:Gr(n.getParentID()),leftSiblingId:Gr(n.getLeftSiblingID())})}function Gr(n){return new or({createdAt:S(n.getCreatedAt()),offset:n.getOffset()})}function jo(n){const t=new Ks;if(n instanceof Tr){const e=n,r=new kn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.key=e.getKey(),r.value=as(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="set",t.body.value=r}else if(n instanceof on){const e=n,r=new xn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.prevCreatedAt=S(e.getPrevCreatedAt()),r.value=as(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="add",t.body.value=r}else if(n instanceof ir){const e=n,r=new En;r.parentCreatedAt=S(e.getParentCreatedAt()),r.prevCreatedAt=S(e.getPrevCreatedAt()),r.createdAt=S(e.getCreatedAt()),r.executedAt=S(e.getExecutedAt()),t.body.case="move",t.body.value=r}else if(n instanceof hr){const e=n,r=new Nn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.createdAt=S(e.getCreatedAt()),r.executedAt=S(e.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(n instanceof an){const e=n,r=new Cn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=hn(e.getFromPos()),r.to=hn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);r.content=e.getContent();const i=r.attributes;for(const[o,c]of e.getAttributes())i[o]=c;r.executedAt=S(e.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(n instanceof cn){const e=n,r=new Pn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=hn(e.getFromPos()),r.to=hn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);const i=r.attributes;for(const[o,c]of e.getAttributes())i[o]=c;r.executedAt=S(e.getExecutedAt()),t.body.case="style",t.body.value=r}else if(n instanceof $r){const e=n,r=new Dn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.value=as(e.getValue()),r.executedAt=S(e.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(n instanceof un){const e=n,r=new On,s=r.createdAtMapByActor;for(const[i,o]of e.getMaxCreatedAtMapByActor())s[i]=S(o);r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=fn(e.getFromPos()),r.to=fn(e.getToPos()),r.contents=uu(e.getContents()),r.splitLevel=e.getSplitLevel(),r.executedAt=S(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(n instanceof Qt){const e=n,r=new Bn;r.parentCreatedAt=S(e.getParentCreatedAt()),r.from=fn(e.getFromPos()),r.to=fn(e.getToPos());const s=r.createdAtMapByActor;for(const[o,c]of e.getMaxCreatedAtMapByActor())s[o]=S(c);const i=e.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{const o=r.attributes;for(const[c,l]of e.getAttributes())o[c]=l}r.executedAt=S(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new m(d.ErrUnimplemented,"unimplemented operation");return t}function nu(n){const t=[];for(const e of n)t.push(jo(e));return t}function su(n){const t=new Eo({id:zo(n.getID()),message:n.getMessage()});return n.hasOperations()&&(t.operations=nu(n.getOperations())),n.hasPresenceChange()&&(t.presenceChange=eu(n.getPresenceChange())),t}function iu(n){const t=[];for(const e of n)t.push(su(e));return t}function ou(n){const t=[];for(const e of n)t.push(new No({key:e.getStrKey(),element:Zs(e.getValue())}));return t}function au(n){const t=[];for(const e of n)t.push(new Un({element:Zs(e.getValue())}));return t}function cu(n){const t=[];for(const e of n){const r=new qn;r.id=ru(e.getID()),r.value=e.getValue().getContent(),r.removedAt=S(e.getRemovedAt());const s=r.attributes,i=e.getValue().getAttrs();for(const o of i){const c=new Rr;c.value=o.getValue(),c.updatedAt=S(o.getUpdatedAt()),s[o.getKey()]=c}t.push(r)}return t}function uu(n){const t=[];if(!n||!n.length)return t;for(const e of n)t.push(new zn({content:Xs(e)}));return t}function lu(n){const t={};for(const e of n)t[e.getKey()]=new Rr({value:e.getValue(),updatedAt:S(e.getUpdatedAt()),isRemoved:e.isRemoved()});return t}function Xs(n){if(!n)return[];const t=[];return Zn(n,(e,r)=>{const s=new Xr({id:Gr(e.id),type:e.type,removedAt:S(e.removedAt),depth:r});e.isText&&(s.value=e.value),e.insPrevID&&(s.insPrevId=Gr(e.insPrevID)),e.insNextID&&(s.insNextId=Gr(e.insNextID)),e.attrs&&(s.attributes=lu(e.attrs)),t.push(s)}),t}function hu(n){const t=new se;return t.body.case="jsonObject",t.body.value=new Rn({nodes:ou(n.getRHT()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Go(n){const t=new se;return t.body.case="jsonArray",t.body.value=new Ln({nodes:au(n.getElements()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function fu(n){const t=new se;return t.body.case="primitive",t.body.value=new Jn({type:Vo(n.getType()),value:n.toBytes(),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function du(n){const t=new se;return t.body.case="text",t.body.value=new Fn({nodes:cu(n.getRGATreeSplit()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function gu(n){const t=new se;return t.body.case="counter",t.body.value=new Mn({type:Ko(n.getType()),value:n.toBytes(),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Wo(n){const t=new se;return t.body.case="tree",t.body.value=new $n({nodes:Xs(n.getRoot()),createdAt:S(n.getCreatedAt()),movedAt:S(n.getMovedAt()),removedAt:S(n.getRemovedAt())}),t}function Zs(n){if(n instanceof ne)return hu(n);if(n instanceof ae)return Go(n);if(n instanceof U)return fu(n);if(n instanceof Ie)return du(n);if(n instanceof ce)return gu(n);if(n instanceof Se)return Wo(n);throw new m(d.ErrUnimplemented,"unimplemented element")}function mu(n){return new tr({documentKey:n.getDocumentKey(),checkpoint:tu(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:iu(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Ys(n.getVersionVector()),minSyncedTicket:S(n.getMinSyncedTicket())})}function zr(n){if(!(n instanceof M))return{};const t=n.findDetails(Rc);for(const e of t)return e.metadata;return{}}function Sr(n){return zr(n).code??""}function Ho(n){return Gt.of(n.clientSeq,BigInt(n.lamport),ni(n.actorId),Qs(n.versionVector),BigInt(n.serverSeq))}function Qs(n){if(!n)return;const t=new Pr;return Object.entries(n.vector).forEach(([e,r])=>{t.set(e,BigInt(r.toString()))}),t}function k(n){if(n)return be.of(BigInt(n.lamport),n.delimiter,ni(n.actorId))}function _s(n){const t={};return Object.entries(n.data).forEach(([e,r])=>{t[e]=JSON.parse(r)}),t}function pu(n){const t=n.type;if(t===wr.PUT){const e=_s(n.presence);return{type:lr.Put,presence:e}}if(t===wr.CLEAR)return{type:lr.Clear};throw new m(d.ErrInvalidType,`unsupported type: ${t}`)}function yu(n){const t=new Map;return Object.entries(n).forEach(([e,r])=>{t.set(e,_s(r))}),t}function Yo(n){switch(n){case N.NULL:return H.Null;case N.BOOLEAN:return H.Boolean;case N.INTEGER:return H.Integer;case N.LONG:return H.Long;case N.DOUBLE:return H.Double;case N.STRING:return H.String;case N.BYTES:return H.Bytes;case N.DATE:return H.Date}throw new m(d.ErrUnimplemented,`unimplemented value type: ${n}`)}function jn(n){switch(n){case N.INTEGER_CNT:return je.IntegerCnt;case N.LONG_CNT:return je.LongCnt}throw new m(d.ErrUnimplemented,`unimplemented value type: ${n}`)}function cs(n){switch(n.type){case N.JSON_OBJECT:return n.value?ra(n.value):ne.create(k(n.createdAt));case N.JSON_ARRAY:return n.value?Du(n.value):ae.create(k(n.createdAt));case N.TEXT:return Ie.create(Mr.create(),k(n.createdAt));case N.TREE:return Bu(n.value);case N.NULL:case N.BOOLEAN:case N.INTEGER:case N.LONG:case N.DOUBLE:case N.STRING:case N.BYTES:case N.DATE:return U.of(U.valueFromBytes(Yo(n.type),n.value),k(n.createdAt));case N.INTEGER_CNT:case N.LONG_CNT:return ce.create(jn(n.type),ce.valueFromBytes(jn(n.type),n.value),k(n.createdAt))}}function dn(n){return Ce.of(Ke.of(k(n.createdAt),n.offset),n.relativeOffset)}function Xo(n){return Ke.of(k(n.createdAt),n.offset)}function vu(n){const t=tn.create(n.value);Object.entries(n.attributes).forEach(([r,s])=>{t.setAttr(r,s.value,k(s.updatedAt))});const e=cr.create(Xo(n.id),t);return e.remove(k(n.removedAt)),e}function kr(n){return Ee.of(Wr(n.parentId),Wr(n.leftSiblingId))}function Wr(n){return Z.of(k(n.createdAt),n.offset)}function wu(n){if(!n.length)return;const t=[];return n.forEach(e=>{const r=ei(e.content);t.push(r)}),t}function ei(n){if(n.length===0)return;const t=[];for(const s of n)t.push(Au(s));const e=t[t.length-1],r=new Map;r.set(n[t.length-1].depth,t[t.length-1]);for(let s=t.length-2;s>=0;s--)r.get(n[s].depth-1).prepend(t[s]),r.set(n[s].depth,t[s]);return e.updateDescendantsSize(),Se.create(e,Ne).getRoot()}function Tu(n){const t=er.create();for(const[e,r]of Object.entries(n))t.setInternal(e,r.value,k(r.updatedAt),r.isRemoved);return t}function Au(n){const t=Wr(n.id),e=oe.create(t,n.type),r=Object.entries(n.attributes);return e.isText?e.value=n.value:r.length&&(e.attrs=Tu(n.attributes)),n.insPrevId&&(e.insPrevID=Wr(n.insPrevId)),n.insNextId&&(e.insNextID=Wr(n.insNextId)),e.removedAt=k(n.removedAt),e}function Zo(n){if(n.body.case==="set"){const t=n.body.value;return Tr.create(t.key,cs(t.value),k(t.parentCreatedAt),k(t.executedAt))}else if(n.body.case==="add"){const t=n.body.value;return on.create(k(t.parentCreatedAt),k(t.prevCreatedAt),cs(t.value),k(t.executedAt))}else if(n.body.case==="move"){const t=n.body.value;return ir.create(k(t.parentCreatedAt),k(t.prevCreatedAt),k(t.createdAt),k(t.executedAt))}else if(n.body.case==="remove"){const t=n.body.value;return hr.create(k(t.parentCreatedAt),k(t.createdAt),k(t.executedAt))}else if(n.body.case==="edit"){const t=n.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([s,i])=>{e.set(s,k(i))});const r=new Map;return Object.entries(t.attributes).forEach(([s,i])=>{r.set(s,i)}),an.create(k(t.parentCreatedAt),dn(t.from),dn(t.to),e,t.content,r,k(t.executedAt))}else if(n.body.case==="style"){const t=n.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([s,i])=>{e.set(s,k(i))});const r=new Map;return Object.entries(t.attributes).forEach(([s,i])=>{r.set(s,i)}),cn.create(k(t.parentCreatedAt),dn(t.from),dn(t.to),e,r,k(t.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const t=n.body.value;return $r.create(k(t.parentCreatedAt),cs(t.value),k(t.executedAt))}else if(n.body.case==="treeEdit"){const t=n.body.value,e=new Map;return Object.entries(t.createdAtMapByActor).forEach(([r,s])=>{e.set(r,k(s))}),un.create(k(t.parentCreatedAt),kr(t.from),kr(t.to),wu(t.contents),t.splitLevel,e,k(t.executedAt))}else if(n.body.case==="treeStyle"){const t=n.body.value,e=new Map,r=t.attributesToRemove,s=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{s.set(i,k(o))}),(r==null?void 0:r.length)>0?Qt.createTreeRemoveStyleOperation(k(t.parentCreatedAt),kr(t.from),kr(t.to),s,r,k(t.executedAt)):(Object.entries(t.attributes).forEach(([i,o])=>{e.set(i,o)}),Qt.create(k(t.parentCreatedAt),kr(t.from),kr(t.to),s,e,k(t.executedAt)))}else throw new m(d.ErrUnimplemented,"unimplemented operation")}}function bu(n){const t=[];for(const e of n){const r=Zo(e);r&&t.push(r)}return t}function Qo(n){const t=[];for(const e of n)t.push(Fr.create({id:Ho(e.id),operations:bu(e.operations),presenceChange:e.presenceChange?pu(e.presenceChange):void 0,message:e.message}));return t}function Iu(n){return Dr.of(BigInt(n.serverSeq),n.clientSeq)}function Su(n){return Qn.create(n.documentKey,Iu(n.checkpoint),n.isRemoved,Qo(n.changes),Qs(n.versionVector),n.snapshot,k(n.minSyncedTicket))}function _o(n){const t=new Qr;for(const r of n.nodes){const s=ti(r.element);t.set(r.key,s,s.getPositionedAt())}const e=new ne(k(n.createdAt),t);return e.setMovedAt(k(n.movedAt)),e.setRemovedAt(k(n.removedAt)),e}function ea(n){const t=new en;for(const r of n.nodes)t.insert(ti(r.element));const e=new ae(k(n.createdAt),t);return e.setMovedAt(k(n.movedAt)),e.setRemovedAt(k(n.removedAt)),e}function ku(n){const t=U.of(U.valueFromBytes(Yo(n.type),n.value),k(n.createdAt));return t.setMovedAt(k(n.movedAt)),t.setRemovedAt(k(n.removedAt)),t}function xu(n){const t=new Mr;let e=t.getHead();for(const s of n.nodes){const i=t.insertAfter(e,vu(s));s.insPrevId&&i.setInsPrev(t.findNode(Xo(s.insPrevId))),e=i}const r=new Ie(t,k(n.createdAt));return r.setMovedAt(k(n.movedAt)),r.setRemovedAt(k(n.removedAt)),r}function Eu(n){const t=ce.create(jn(n.type),ce.valueFromBytes(jn(n.type),n.value),k(n.createdAt));return t.setMovedAt(k(n.movedAt)),t.setRemovedAt(k(n.removedAt)),t}function ta(n){const t=ei(n.nodes);return Se.create(t,k(n.createdAt))}function ti(n){if(n.body.case==="jsonObject")return _o(n.body.value);if(n.body.case==="jsonArray")return ea(n.body.value);if(n.body.case==="primitive")return ku(n.body.value);if(n.body.case==="text")return xu(n.body.value);if(n.body.case==="counter")return Eu(n.body.value);if(n.body.case==="tree")return ta(n.body.value);throw new m(d.ErrUnimplemented,"unimplemented element")}function Nu(n){if(!n)return{root:ne.create(Ne),presences:new Map};const t=gs.fromBinary(n);return{root:ti(t.root),presences:yu(t.presences)}}function Cu(n){const t=Ys(n);return ri(t.toBinary())}function Pu(n){const t=si(n),e=Yn.fromBinary(t);return Qs(e)}function ra(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return _o(t.body.value)}function na(n){return Zs(n).toBinary()}function Du(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return ea(t.body.value)}function Ou(n){return Go(n).toBinary()}function Bu(n){if(!n)throw new m(d.ErrInvalidArgument,"bytes is empty");const t=se.fromBinary(n);return ta(t.body.value)}function Ru(n){return Wo(n).toBinary()}function ri(n){return n?Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function ni(n){return ri(n)}function si(n){return new Uint8Array(n.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function ii(n){return si(n)}function Lu(n){const t=Hn.fromBinary(n);return Ho(t)}function Ju(n){const t=Ks.fromBinary(n);return Zo(t)}const j={fromPresence:_s,toChangePack:mu,fromChangePack:Su,fromChanges:Qo,toTreeNodes:Xs,fromTreeNodes:ei,objectToBytes:na,bytesToObject:ra,bytesToSnapshot:Nu,bytesToHex:ri,hexToBytes:si,toHexString:ni,toUint8Array:ii,toOperation:jo,toChangeID:zo,PbChangeID:Hn,bytesToChangeID:Lu,bytesToOperation:Ju,versionVectorToHex:Cu,hexToVersionVector:Pu};var te=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(te||{});let fr=3;function sa(n){fr=n}const E={trivial:(...n)=>{fr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{fr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{fr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{fr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{fr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>fr<=n};function ia(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}class Fu{constructor(t,e,r,s,i){a(this,"reconnectStreamDelay");a(this,"doc");a(this,"docID");a(this,"syncMode");a(this,"remoteChangeEventReceived");a(this,"watchStream");a(this,"watchLoopTimerID");a(this,"watchAbortController");a(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=e,this.docID=r,this.syncMode=s,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===bn.RealtimeSyncOff?!1:this.syncMode===bn.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==bn.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const e=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(e,this.reconnectStreamDelay)})}catch{}};await e()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const us=()=>{};class Mu{constructor(t){a(this,"finalized",!1);a(this,"observers",[]);a(this,"finalError");try{t(this)}catch(e){this.error(e)}}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,r){let s;if(!t)throw new m(d.ErrInvalidArgument,"missing observer");if(this.finalized)throw new m(d.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?s=t:s={next:t,error:e,complete:r},s.next===void 0&&(s.next=us),s.error===void 0&&(s.error=us),s.complete===void 0&&(s.complete=us);const i=ia(),o=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:s}),this.finalized)try{this.finalError?s.error(this.finalError):s.complete()}catch(c){E.warn(c)}return o}unsubscribeOne(t){var e;this.observers=(e=this.observers)==null?void 0:e.filter(r=>r.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let e=0;et}}class Nr{constructor(t,e,r,s){a(this,"id");a(this,"delimiter");a(this,"message");a(this,"root");a(this,"operations");a(this,"presenceChange");a(this,"previousPresence");a(this,"reversePresenceKeys");this.id=t,this.delimiter=Do,this.root=e,this.operations=[],this.previousPresence=ke(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=s}static create(t,e,r,s){return new Nr(t,e,r,s)}push(t){this.operations.push(t)}registerElement(t,e){this.root.registerElement(t,e)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return Fr.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,e){for(const r of Object.keys(t))e!=null&&e.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const e of this.reversePresenceKeys)t[e]=this.previousPresence[e];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class rn{constructor(t){a(this,"rootObject");a(this,"elementPairMapByCreatedAt");a(this,"gcElementSetByCreatedAt");a(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof Ie||e instanceof Se)for(const r of e.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new rn(ne.create(Ne))}findByCreatedAt(t){const e=this.elementPairMapByCreatedAt.get(t.toIDString());if(e)return e.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let e=this.elementPairMapByCreatedAt.get(t.toIDString());if(!e)return[];const r=[];for(;e.parent;){const s=e.element.getCreatedAt(),i=e.parent.subPathOf(s);if(i===void 0)throw new m(d.ErrInvalidArgument,`cant find the given element: ${s.toIDString()}`);r.unshift(i),e=this.elementPairMapByCreatedAt.get(e.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,e){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:e,element:t}),t instanceof ar&&t.getDescendants((r,s)=>(this.registerElement(r,s),!1))}deregisterElement(t){let e=0;const r=s=>{const i=s.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(i),this.gcElementSetByCreatedAt.delete(i),e++};return r(t),t instanceof ar&&t.getDescendants(s=>(r(s),!1)),e}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const e of this.gcElementSetByCreatedAt){t.add(e);const r=this.elementPairMapByCreatedAt.get(e);r.element instanceof ar&&r.element.getDescendants(s=>(t.add(s.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new rn(this.rootObject.deepcopy())}garbageCollect(t){let e=0;for(const r of this.gcElementSetByCreatedAt){const s=this.elementPairMapByCreatedAt.get(r),i=s.element.getRemovedAt();i&&(t!=null&&t.afterOrEqual(i))&&(s.parent.purge(s.element),e+=this.deregisterElement(s.element))}for(const[,r]of this.gcPairMap){const s=r.child.getRemovedAt();s&&(t!=null&&t.afterOrEqual(s))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),e+=1)}return e}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function oa(n,t){const e=new nn(n);return new Proxy(t,e.getHandlers())}class nn{constructor(t){a(this,"context");a(this,"handlers");this.context=t,this.handlers={set:(e,r,s)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]=${JSON.stringify(s)}`),nn.setInternal(t,e,r,s),!0),get:(e,r)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]`),r==="getID"?()=>e.getCreatedAt():r==="toJSON"||r==="toString"?()=>e.toJSON():r==="toJS"?()=>e.toJS():r==="toJSForTest"?()=>e.toJSForTest():dr(t,e.get(r))),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(e,r)=>(E.isEnabled(te.Trivial)&&E.trivial(`obj[${r}]`),nn.deleteInternal(t,e,r),!0)}}static setInternal(t,e,r,s){if(r.includes("."))throw new m(d.ErrInvalidObjectKey,"key must not contain the '.'.");const i=t.issueTimeTicket(),o=Gn(t,s,i),c=e.set(r,o,i);t.registerElement(o,e),c&&t.registerRemovedElement(c),t.push(Tr.create(r,o.deepcopy(),e.getCreatedAt(),i))}static buildObjectMembers(t,e){const r={};for(const[s,i]of Object.entries(e)){if(s.includes("."))throw new m(d.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),c=Gn(t,i,o);r[s]=c}return r}static deleteInternal(t,e,r){const s=t.issueTimeTicket(),i=e.deleteByKey(r,s);i&&(t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i))}getHandlers(){return this.handlers}}function Uu(n,t){const e=new q(n,t);return new Proxy(t,e.getHandlers())}function qu(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zu(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class q{constructor(t,e){a(this,"context");a(this,"handlers");a(this,"array");this.context=t,this.array=e,this.handlers={get:(r,s,i)=>s==="getID"?()=>r.getCreatedAt():s==="getElementByID"?o=>{const c=r.getByID(o);if(!(!c||c.isRemoved()))return nr(t,c)}:s==="getElementByIndex"?o=>{const c=r.get(o);return nr(t,c)}:s==="getLast"?()=>nr(t,r.getLast()):s==="deleteByID"?o=>{const c=q.deleteInternalByID(t,r,o);return nr(t,c)}:s==="insertAfter"?(o,c)=>{const l=q.insertAfterInternal(t,r,o,c);return nr(t,l)}:s==="insertBefore"?(o,c)=>{const l=q.insertBeforeInternal(t,r,o,c);return nr(t,l)}:s==="moveBefore"?(o,c)=>{q.moveBeforeInternal(t,r,o,c)}:s==="moveAfter"?(o,c)=>{q.moveAfterInternal(t,r,o,c)}:s==="moveFront"?o=>{q.moveFrontInternal(t,r,o)}:s==="moveLast"?o=>{q.moveLastInternal(t,r,o)}:qu(s)?dr(t,r.get(Number(s))):s==="push"?o=>q.pushInternal(t,r,o):s==="splice"?(o,c,...l)=>q.splice(t,r,o,c,...l):s==="length"?r.length:typeof s=="symbol"&&s===Symbol.iterator?q.iteratorInternal.bind(this,t,r):s==="includes"?(o,c)=>q.includes(t,r,o,c):s==="indexOf"?(o,c)=>q.indexOf(t,r,o,c):s==="lastIndexOf"?(o,c)=>q.lastIndexOf(t,r,o,c):s==="toJSForTest"?()=>r.toJSForTest():s==="toTestString"?()=>q.toTestString(r):typeof s=="string"&&zu(s)?(...o)=>{const c=Array.from(r).map(l=>dr(t,l));return Array.prototype[s].apply(c,o)}:Reflect.get(r,s,i),deleteProperty:(r,s)=>(E.isEnabled(te.Trivial)&&E.trivial(`array[${s}]`),q.deleteInternalByIndex(t,r,Number.parseInt(s)),!0)}}static*iteratorInternal(t,e){for(const r of e)yield nr(t,r)}static buildArrayElements(t,e){const r=[];for(const s of e){const i=t.issueTimeTicket(),o=Gn(t,s,i);r.push(o)}return r}static pushInternal(t,e,r){return q.insertAfterInternal(t,e,e.getLastCreatedAt(),r),e.length}static moveBeforeInternal(t,e,r,s){const i=t.issueTimeTicket(),o=e.getPrevCreatedAt(r);e.moveAfter(o,s,i),t.push(ir.create(e.getCreatedAt(),o,s,i))}static moveAfterInternal(t,e,r,s){const i=t.issueTimeTicket();e.moveAfter(r,s,i),t.push(ir.create(e.getCreatedAt(),r,s,i))}static moveFrontInternal(t,e,r){const s=t.issueTimeTicket(),i=e.getHead();e.moveAfter(i.getCreatedAt(),r,s),t.push(ir.create(e.getCreatedAt(),i.getCreatedAt(),r,s))}static moveLastInternal(t,e,r){const s=t.issueTimeTicket(),i=e.getLastCreatedAt();e.moveAfter(i,r,s),t.push(ir.create(e.getCreatedAt(),i,r,s))}static insertAfterInternal(t,e,r,s){const i=t.issueTimeTicket(),o=Gn(t,s,i);return e.insertAfter(r,o),t.registerElement(o,e),t.push(on.create(e.getCreatedAt(),r,o.deepcopy(),i)),o}static insertBeforeInternal(t,e,r,s){return q.insertAfterInternal(t,e,e.getPrevCreatedAt(r),s)}static deleteInternalByIndex(t,e,r){const s=t.issueTimeTicket(),i=e.deleteByIndex(r,s);if(i)return t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i),i}static deleteInternalByID(t,e,r){const s=t.issueTimeTicket(),i=e.delete(r,s);return t.push(hr.create(e.getCreatedAt(),i.getCreatedAt(),s)),t.registerRemovedElement(i),i}static splice(t,e,r,s,...i){const o=e.length,c=r>=0?Math.min(r,o):Math.max(o+r,0),l=s===void 0?o:s<0?c:Math.min(c+s,o),h=[];for(let f=c;f=i)return!1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).includes(r,o);for(let l=o;l=i)return-1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).indexOf(r,o);for(let l=o;l=i?i-1:s<0?s+i:s;if(o<0)return-1;if(U.isSupport(r))return Array.from(e).map(h=>dr(t,h)).lastIndexOf(r,o);for(let l=o;l>0;l--)if(((c=e.get(l))==null?void 0:c.getID())===r.getID())return l;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}class _n{constructor(t,e){a(this,"context");a(this,"text");this.context=t,this.text=e}initialize(t,e){this.context=t,this.text=e}getID(){return this.text.getID()}edit(t,e,r,s){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(t,e);E.isEnabled(te.Debug)&&E.debug(`EDIT: f:${t}->${i[0].toTestString()}, t:${e}->${i[1].toTestString()} c:${r}`);const o=s?Lr(s):void 0,c=this.context.issueTimeTicket(),[l,,h,f]=this.text.edit(i,r,c,o);for(const g of h)this.context.registerGCPair(g);return this.context.push(new an(this.text.getCreatedAt(),i[0],i[1],l,r,o?new Map(Object.entries(o)):new Map,c)),this.text.findIndexesFromRange(f)}delete(t,e){return this.edit(t,e,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,e,r){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(t,e);E.isEnabled(te.Debug)&&E.debug(`STYL: f:${t}->${s[0].toTestString()}, t:${e}->${s[1].toTestString()} a:${JSON.stringify(r)}`);const i=Lr(r),o=this.context.issueTimeTicket(),[c,l]=this.text.setStyle(s,i,o);for(const h of l)this.context.registerGCPair(h);return this.context.push(new cn(this.text.getCreatedAt(),s[0],s[1],c,new Map(Object.entries(i)),o)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");const e=this.text.indexRangeToPosRange(t[0],t[1]);return[e[0].toStruct(),e[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");const e=this.text.findIndexesFromRange([Ce.fromStruct(t[0]),Ce.fromStruct(t[1])]);return[e[0],e[1]]}toTestString(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,e){if(!this.context||!this.text)throw new m(d.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,e)}}class es{constructor(t,e){a(this,"valueType");a(this,"value");a(this,"context");a(this,"counter");this.valueType=t,this.value=e}initialize(t,e){this.valueType=e.getValueType(),this.context=t,this.counter=e,this.value=e.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new m(d.ErrNotInitialized,"Counter is not initialized yet");const e=this.context.issueTimeTicket(),r=U.of(t,e);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push($r.create(this.counter.getCreatedAt(),r,e)),this}toJSForTest(){if(!this.context||!this.counter)throw new m(d.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function oi(n,t,e){const{type:r}=n,s=e.issueTimeTicket();if(r===Zt){aa(n);const{value:i}=n,o=oe.create(Z.of(s,0),r,i);t.append(o)}else{const{children:i=[]}=n,{attributes:o}=n;let c;if(typeof o=="object"&&!Po(o)){const h=Lr(o);c=new er;for(const[f,g]of Object.entries(h))c.set(f,g,s)}const l=oe.create(Z.of(s,0),r,void 0,c);t.append(l);for(const h of i)oi(h,l,e)}}function Vu(n,t){const{type:e}=t,r=n.issueTimeTicket();let s;if(t.type===Zt){const{value:i}=t;s=oe.create(Z.of(r,0),e,i)}else if(t){const{children:i=[]}=t,{attributes:o}=t;let c;if(typeof o=="object"&&!Po(o)){const l=Lr(o);c=new er;for(const[h,f]of Object.entries(l))c.set(h,f,r)}s=oe.create(Z.of(n.issueTimeTicket(),0),e,void 0,c);for(const l of i)oi(l,s,n)}return s}function aa(n){if(!n.value.length)throw new m(d.ErrInvalidArgument,"text node cannot have empty value");return!0}function Gi(n){if(!n.length)return!0;if(n[0].type===Zt)for(const e of n){const{type:r}=e;if(r!==Zt)throw new m(d.ErrInvalidArgument,"element node and text node cannot be passed together");aa(e)}else for(const e of n){const{type:r}=e;if(r===Zt)throw new m(d.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class ts{constructor(t){a(this,"initialRoot");a(this,"context");a(this,"tree");this.initialRoot=t}initialize(t,e){this.context=t,this.tree=e}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return oe.create(Z.of(t.issueTimeTicket(),0),qc);const e=oe.create(Z.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)oi(r,e,t);return e}getSize(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,e){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const[r,s]=this.tree.pathToPosRange(t),i=this.context.issueTimeTicket(),o=e?Lr(e):void 0,[c]=this.tree.style([r,s],o,i);this.context.push(Qt.create(this.tree.getCreatedAt(),r,s,c,o?new Map(Object.entries(o)):new Map,i))}style(t,e,r){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(t),i=this.tree.findPos(e),o=this.context.issueTimeTicket(),c=r?Lr(r):void 0,[l,h]=this.tree.style([s,i],c,o);for(const f of h)this.context.registerGCPair(f);this.context.push(Qt.create(this.tree.getCreatedAt(),s,i,l,c?new Map(Object.entries(c)):new Map,o))}removeStyle(t,e,r){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(t),i=this.tree.findPos(e),o=this.context.issueTimeTicket(),[c,l]=this.tree.removeStyle([s,i],r,o);for(const h of l)this.context.registerGCPair(h);this.context.push(Qt.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),s,i,c,r,o))}editInternal(t,e,r,s=0){var h;if(r.length!==0&&r[0]&&(Gi(r),r[0].type!==Zt))for(const f of r){const{children:g=[]}=f;Gi(g)}const i=this.context.getLastTimeTicket();let o=new Array;if(((h=r[0])==null?void 0:h.type)===Zt){let f="";for(const g of r){const{value:v}=g;f+=v}o.push(oe.create(Z.of(this.context.issueTimeTicket(),0),Zt,f))}else o=r.map(f=>f&&Vu(this.context,f)).filter(f=>f);const[,c,l]=this.tree.edit([t,e],o.length?o.map(f=>f==null?void 0:f.deepcopy()):void 0,s,i,()=>this.context.issueTimeTicket());for(const f of c)this.context.registerGCPair(f);return this.context.push(un.create(this.tree.getCreatedAt(),t,e,o.length?o:void 0,s,l,i)),!0}editByPath(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new m(d.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(t),o=this.tree.pathToPos(e);return this.editInternal(i,o,r?[r]:[],s)}editBulkByPath(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new m(d.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new m(d.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(t),o=this.tree.pathToPos(e);return this.editInternal(i,o,r,s)}edit(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(e);return this.editInternal(i,o,r?[r]:[],s)}editBulk(t,e,r,s=0){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new m(d.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(e);return this.editInternal(i,o,r,s)}toXML(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],r=this.tree.indexRangeToPosRange(e);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[Ee.fromStruct(t[0]),Ee.fromStruct(t[1])];return this.tree.posRangeToIndexRange(e)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new m(d.ErrNotInitialized,"Tree is not initialized yet");const e=[Ee.fromStruct(t[0]),Ee.fromStruct(t[1])];return this.tree.posRangeToPathRange(e)}}function Wi(n,t){return oa(n,t)}function nr(n,t){if(t){if(t instanceof U)return t;if(t instanceof ne)return oa(n,t);if(t instanceof ae)return Uu(n,t);if(t instanceof Ie)return new _n(n,t);if(t instanceof ce){const e=new es(je.IntegerCnt,0);return e.initialize(n,t),e}else if(t instanceof Se){const e=new ts;return e.initialize(n,t),e}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function dr(n,t){const e=nr(n,t);return e instanceof U?e.getValue():e}function Gn(n,t,e){let r;if(U.isSupport(t))r=U.of(t,e);else if(Array.isArray(t))r=ae.create(e,q.buildArrayElements(n,t));else if(typeof t=="object")t instanceof _n?(r=Ie.create(Mr.create(),e),t.initialize(n,r)):t instanceof es?(r=ce.create(t.getValueType(),t.getValue(),e),t.initialize(n,r)):t instanceof ts?(r=Se.create(t.buildRoot(n),e),t.initialize(n,r)):r=ne.create(e,nn.buildObjectMembers(n,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return r}const Hi=50;class Ku{constructor(){a(this,"undoStack",[]);a(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Hi&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Hi&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const ju="yorkie-devtools-panel",Gu="yorkie-devtools-sdk";let xr="disconnected";const Yi=new Map,An=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=An);function gn(n,t){(t!=null&&t.force||xr!=="disconnected")&&window.postMessage({source:Gu,...n},"*")}function Wu(n){if(!n.isEnableDevtools()||typeof window>"u"||Yi.has(n.getKey()))return;An.set(n.getKey(),[]);const t=n.subscribe("all",e=>{e.some(r=>r.type!==X.StatusChanged&&r.type!==X.Snapshot&&r.type!==X.LocalChange&&r.type!==X.RemoteChange&&r.type!==X.Initialized&&r.type!==X.Watched&&r.type!==X.Unwatched&&r.type!==X.PresenceChanged)||(An.get(n.getKey()).push(e),xr==="synced"&&gn({msg:"doc::sync::partial",docKey:n.getKey(),event:e}))});Yi.set(n.getKey(),[t]),gn({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",e=>{var s;if(((s=e.data)==null?void 0:s.source)!==ju)return;switch(e.data.msg){case"devtools::connect":if(xr!=="disconnected")break;xr="connected",gn({msg:"doc::available",docKey:n.getKey()}),E.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":xr="disconnected",E.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":xr="synced",gn({msg:"doc::sync::full",docKey:n.getKey(),events:An.get(n.getKey())}),E.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var sr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(sr||{}),X=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(X||{}),Us=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Us||{}),qs=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(qs||{});class ca{constructor(t,e){a(this,"key");a(this,"status");a(this,"opts");a(this,"changeID");a(this,"checkpoint");a(this,"localChanges");a(this,"root");a(this,"clone");a(this,"eventStream");a(this,"eventStreamObserver");a(this,"onlineClients");a(this,"presences");a(this,"history");a(this,"internalHistory");a(this,"isUpdating");this.opts=e||{},this.key=t,this.status="detached",this.root=rn.create(),this.changeID=Xc,this.checkpoint=Zc,this.localChanges=[],this.eventStream=$u(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Ku,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},Wu(this)}update(t,e){if(this.getStatus()==="removed")throw new m(d.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),s=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},e);try{const i=Wi(s,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,t(i,new os(s,this.clone.presences.get(r)))}catch(i){throw this.clone=void 0,i}finally{this.isUpdating=!1}if(s.hasChange()){E.isEnabled(te.Trivial)&&E.trivial(`trying to update a local change: ${this.toJSON()}`);const i=s.getChange(),{opInfos:o,reverseOps:c}=i.execute(this.root,this.presences,J.Local),l=s.getReversePresence();l&&c.push({type:"presence",value:l}),this.localChanges.push(i),c.length>0&&this.internalHistory.pushUndo(c),o.length>0&&this.internalHistory.clearRedo(),this.changeID=i.getID();const h=[];o.length>0&&h.push({type:"local-change",source:J.Local,value:{message:i.getMessage()||"",operations:o,actor:r,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&h.push({type:"presence-changed",source:J.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(h),E.isEnabled(te.Trivial)&&E.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,e,r,s){if(typeof t=="string"){if(typeof e!="function")throw new m(d.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||c(h)},r,s)}if(t==="my-presence"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="presence-changed"||h.type==="presence-changed"&&h.value.clientID!==this.changeID.getActorID()||c(h)},r,s)}if(t==="others"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||h.value.clientID!==this.changeID.getActorID()&&c(h)},r,s)}if(t==="connection"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="connection-changed"&&c(h)},r,s)}if(t==="status"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="status-changed"&&c(h)},r,s)}if(t==="sync"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="sync-status-changed"&&c(h)},r,s)}if(t==="local-broadcast"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="local-broadcast"&&c(h)},r)}if(t==="broadcast"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="broadcast"&&c(h)},r)}if(t==="auth-error"){const c=e;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="auth-error"&&c(h)},r)}if(t==="all"){const c=e;return this.eventStream.subscribe(c,r,s)}const i=t,o=e;return this.eventStream.subscribe(c=>{for(const l of c){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const h=[];for(const f of l.value.operations)this.isSameElementOrChildOf(f.path,i)&&h.push(f);h.length&&o({...l,value:{...l.value,operations:h}})}},r,s)}if(typeof t=="function"){const i=t,o=e,c=r;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="snapshot"&&h.type!=="local-change"&&h.type!=="remote-change"||i(h)},o,c)}throw new m(d.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,e){if(e===t)return!0;const r=t.split(".");return e.split(".").every((i,o)=>i===r[o])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const e=t.hasSnapshot();e?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),J.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),e||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),E.isEnabled(te.Trivial)&&E.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:ke(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),e=this.checkpoint.increaseClientSeq(t.length);return Qn.create(this.key,e,!1,t,this.getVersionVector())}setActor(t){for(const e of this.localChanges)e.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Wi(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,e,r,s=-1){const{root:i,presences:o}=j.bytesToSnapshot(r);this.root=new rn(i),this.presences=o,this.changeID=this.changeID.setClocks(e.maxLamport(),e),this.clone=void 0,this.removePushedLocalChanges(s),this.applyChanges(this.localChanges,J.Local),this.publish([{type:"snapshot",source:J.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?j.bytesToHex(r):void 0,snapshotVector:j.versionVectorToHex(e)}}])}applyChanges(t,e){E.isEnabled(te.Debug)&&E.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),E.isEnabled(te.Trivial)&&E.trivial(t.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` +`));for(const r of t)this.applyChange(r,e);E.isEnabled(te.Debug)&&E.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,e){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,e);const r=[],s=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(s)){const o=t.getPresenceChange();switch(o.type){case lr.Put:r.push(this.presences.has(s)?{type:"presence-changed",source:e,value:{clientID:s,presence:o.presence}}:{type:"watched",source:J.Remote,value:{clientID:s,presence:o.presence}});break;case lr.Clear:r.push({type:"unwatched",source:J.Remote,value:{clientID:s,presence:this.getPresence(s)}}),this.removeOnlineClient(s);break}}const{opInfos:i}=t.execute(this.root,this.presences,e);if(this.changeID=this.changeID.syncClocks(t.getID()),i.length>0){const o=this.isEnableDevtools()?t.toStruct():void 0;r.push(e===J.Remote?{type:"remote-change",source:e,value:{actor:s,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:i},rawChange:o}:{type:"local-change",source:e,value:{actor:s,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:i},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(t){if(t.body.case==="initialization"){const e=t.body.value.clientIds,r=new Set;for(const s of e)s!==this.changeID.getActorID()&&r.add(s);this.setOnlineClients(r),this.publish([{type:"initialized",source:J.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:e,publisher:r}=t.body.value,s=[];if(e===yr.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&s.push({type:"watched",source:J.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(e===yr.DOCUMENT_UNWATCHED){const i=this.getPresence(r);this.removeOnlineClient(r),i&&s.push({type:"unwatched",source:J.Remote,value:{clientID:r,presence:i}})}else if(e===yr.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:i,payload:o}=t.body.value.body,c=new TextDecoder;s.push({type:"broadcast",value:{clientID:r,topic:i,payload:JSON.parse(c.decode(o))}})}s.length>0&&this.publish(s)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(Xn),this.publish([{source:t==="removed"?J.Remote:J.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:e,serverSeq:r,snapshotVector:s}=t.value;if(!e)return;this.applySnapshot(BigInt(r),j.hexToVersionVector(s),j.hexToBytes(e));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const e=Fr.fromStruct(t.rawChange);this.applyChange(e,t.source)}if(t.type==="initialized"){const e=new Set;for(const{clientID:r,presence:s}of t.value)e.add(r),this.presences.set(r,s);this.setOnlineClients(e);return}if(t.type==="watched"){const{clientID:e,presence:r}=t.value;this.addOnlineClient(e),this.presences.set(e,r);return}if(t.type==="unwatched"){const{clientID:e}=t.value;this.removeOnlineClient(e),this.presences.delete(e)}if(t.type==="presence-changed"){const{clientID:e,presence:r}=t.value;this.presences.set(e,r)}}applyTransactionEvent(t){for(const e of t)this.applyDocEvent(e)}getValueByPath(t){if(!t.startsWith("$"))throw new m(d.ErrInvalidArgument,'path must start with "$"');const e=t.split(".");e.shift();let r=this.getRoot();for(const s of e)if(r=r[s],r===void 0)return;return r}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?ke(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const e=this.presences.get(t);return e?ke(e):void 0}getPresenceForTest(t){const e=this.presences.get(t);return e?ke(e):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:ke(this.getMyPresence())});for(const e of this.onlineClients)this.presences.has(e)&&t.push({clientID:e,presence:ke(this.presences.get(e))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(e=>e.clientID!==t).sort((e,r)=>e.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const r=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new m(d.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new m(d.ErrRefused,"There is no operation to be undone");this.ensureClone();const e=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of t){if(!(h instanceof Pe)){new os(e,ke(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const f=e.issueTimeTicket();h.setExecutedAt(f),e.push(h)}const r=e.getChange();r.execute(this.clone.root,this.clone.presences,J.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,J.UndoRedo),o=e.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const c=this.changeID.getActorID(),l=[];s.length>0&&l.push({type:"local-change",source:J.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:c,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:J.UndoRedo,value:{clientID:c,presence:this.getPresence(c)}}),this.publish(l)}redo(){if(this.isUpdating)throw new m(d.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new m(d.ErrRefused,"There is no operation to be redone");this.ensureClone();const e=Nr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of t){if(!(h instanceof Pe)){new os(e,ke(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const f=e.issueTimeTicket();h.setExecutedAt(f),e.push(h)}const r=e.getChange();r.execute(this.clone.root,this.clone.presences,J.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,J.UndoRedo),o=e.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const c=this.changeID.getActorID(),l=[];s.length>0&&l.push({type:"local-change",source:J.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:c,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:J.UndoRedo,value:{clientID:c,presence:this.getPresence(c)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,e,r){const s={type:"local-broadcast",value:{topic:t,payload:e},options:r};this.publish([s])}getVersionVector(){return this.changeID.getVersionVector()}}function Hu(n,t){let e=t;return{authInterceptor:i=>async o=>(n&&o.header.set("x-api-key",n),e&&o.header.set("authorization",e),await i(o)),setToken:i=>{e=i}}}const Yu="yorkie-js-sdk",Xu="0.5.6",Zu="Yorkie JS SDK",Qu="./src/yorkie.ts",_u={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},el=["dist"],tl={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},rl={node:">=18.0.0",npm:">=7.1.0"},nl={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},sl={name:"hackerwins",email:"susukang98@gmail.com"},il="Apache-2.0",ol={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},al="https://github.com/yorkie-team/yorkie-js-sdk#readme",cl={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ul={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Xi={name:Yu,version:Xu,description:Zu,main:Qu,publishConfig:_u,files:el,scripts:tl,engines:rl,repository:nl,author:sl,license:il,bugs:ol,homepage:al,devDependencies:cl,dependencies:ul};function ll(){return n=>async t=>(t.header.set("x-yorkie-user-agent",Xi.name+"/"+Xi.version),await n(t))}const hl=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var bn=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(bn||{});const mn={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},ls={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class ua{constructor(t,e){a(this,"id");a(this,"key");a(this,"status");a(this,"attachmentMap");a(this,"apiKey");a(this,"authTokenInjector");a(this,"conditions");a(this,"syncLoopDuration");a(this,"reconnectStreamDelay");a(this,"retrySyncLoopDelay");a(this,"rpcClient");a(this,"setAuthToken");a(this,"taskQueue");a(this,"processing",!1);a(this,"keepalive",!1);e=e||mn,this.key=e.key?e.key:ia(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=e.apiKey||"",this.authTokenInjector=e.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=e.syncLoopDuration??mn.syncLoopDuration,this.reconnectStreamDelay=e.reconnectStreamDelay??mn.reconnectStreamDelay,this.retrySyncLoopDelay=e.retrySyncLoopDelay??mn.retrySyncLoopDelay;const{authInterceptor:r,setToken:s}=Hu(this.apiKey);this.setAuthToken=s,this.rpcClient=lc(Bc,Oc({baseUrl:t,interceptors:[r,ll()],fetch:(i,o)=>{const c={...o,keepalive:this.keepalive};return fetch(i,c)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),E.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw E.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const e=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),E.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw E.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(t.keepalive){this.keepalive=!0;const r=e();return this.keepalive=!1,r}return this.enqueueTask(e)}attach(t,e={}){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==sr.Detached)throw new m(d.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((i,o)=>o.set(e.initialPresence||{}));const r=t.subscribe("local-broadcast",async i=>{var f;const{topic:o,payload:c}=i.value,l=(f=i.options)==null?void 0:f.error,h=i.options;try{await this.broadcast(t.getKey(),o,c,h)}catch(g){g instanceof Error&&(l==null||l(g))}}),s=e.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:j.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async i=>{const o=j.fromChangePack(i.changePack);if(t.applyChangePack(o),t.getStatus()===sr.Removed)return t;t.applyStatus(sr.Attached),this.attachmentMap.set(t.getKey(),new Fu(this.reconnectStreamDelay,t,i.documentId,s,r)),s!=="manual"&&await this.runWatchLoop(t.getKey()),E.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const c=t.getRootObject();if(e.initialRoot){const l=e.initialRoot;t.update(h=>{for(const[f,g]of Object.entries(l))if(!c.has(f)){const v=f;h[v]=g}})}return t}).catch(async i=>{throw E.error(`[AD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}detach(t,e={}){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((s,i)=>i.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:j.toChangePack(t.createChangePack()),removeIfNotAttached:e.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(s=>{const i=j.fromChangePack(s.changePack);return t.applyChangePack(i),t.getStatus()!==sr.Removed&&t.applyStatus(sr.Detached),this.detachInternal(t.getKey()),E.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async s=>{throw E.error(`[DD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}async changeSyncMode(t,e){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const s=r.syncMode;return s===e?t:(r.changeSyncMode(e),e==="manual"?(r.cancelWatchStream(),t):(e==="realtime"&&(r.remoteChangeEventReceived=!0),s==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);if(t){const e=this.attachmentMap.get(t.getKey());if(!e)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(e,"realtime").catch(async r=>{throw E.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const e=[];for(const[,r]of this.attachmentMap)e.push(this.syncInternal(r,r.syncMode));return Promise.all(e).catch(async r=>{throw E.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(t){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const e=this.attachmentMap.get(t.getKey());if(!e)throw new m(d.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const r=j.toChangePack(t.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:e.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(s=>{const i=j.fromChangePack(s.changePack);t.applyChangePack(i),this.detachInternal(t.getKey()),E.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async s=>{throw E.error(`[RD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,e,r,s){if(!this.isActive())throw new m(d.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(t);if(!i)throw new m(d.ErrDocumentNotAttached,`${t} is not attached`);if(!hl(r))throw new m(d.ErrInvalidArgument,"payload is not serializable");const o=(s==null?void 0:s.maxRetries)??ls.maxRetries,c=ls.maxBackoff;let l=0;const h=g=>Math.min(ls.initialRetryInterval*2**g,c),f=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:i.docID,topic:e,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{E.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${e}"`)}).catch(async g=>{if(E.error(`[BC] c:"${this.getKey()}" err:`,g),await this.handleConnectError(g))if(g instanceof M&&Sr(g)===d.ErrUnauthenticated&&i.doc.publish([{type:X.AuthError,value:{reason:zr(g).reason,method:"Broadcast"}}]),lf(),h(l-1)),E.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw E.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),g;else throw g}));return f()}runSyncLoop(){const t=()=>{if(!this.isActive()){E.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const e=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,e.push(this.syncInternal(r,r.syncMode).catch(async s=>{throw s instanceof M&&Sr(s)===d.ErrUnauthenticated&&r.doc.publish([{type:X.AuthError,value:{reason:zr(s).reason,method:"PushPull"}}]),s})));Promise.all(e).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async r=>{E.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};E.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const e=this.attachmentMap.get(t);if(!e)throw new m(d.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,e.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new m(d.ErrClientNotActivated,`${this.key} is not active`));const s=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:e.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:s.signal});return e.doc.publish([{type:X.ConnectionChanged,value:Us.Connected}]),E.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((o,c)=>{(async()=>{try{for await(const h of i)this.handleWatchDocumentsResponse(e,h),h.body.case==="initialization"&&o([i,s])}catch(h){e.doc.resetOnlineClients(),e.doc.publish([{type:X.Initialized,source:J.Local,value:e.doc.getPresences()}]),e.doc.publish([{type:X.ConnectionChanged,value:Us.Disconnected}]),E.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(h)?(h instanceof M&&Sr(h)===d.ErrUnauthenticated&&e.doc.publish([{type:X.AuthError,value:{reason:zr(h).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,c(h)}})()})})}handleWatchDocumentsResponse(t,e){if(e.body.case==="event"&&e.body.value.type===yr.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(e)}deactivateInternal(){this.status="deactivated";for(const[t,e]of this.attachmentMap)this.detachInternal(t),e.doc.applyStatus(sr.Detached)}detachInternal(t){const e=this.attachmentMap.get(t);e&&(e.cancelWatchStream(),e.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,e){const{doc:r,docID:s}=t,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:s,changePack:j.toChangePack(i),pushOnly:e==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const c=j.fromChangePack(o.changePack);if(c.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return r;r.applyChangePack(c),t.doc.publish([{type:X.SyncStatusChanged,value:qs.Synced}]),r.getStatus()===sr.Removed&&this.detachInternal(r.getKey());const l=r.getKey(),h=c.getChangeSize();return E.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${i.getChangeSize()} pull:${h} cp:${c.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:X.SyncStatusChanged,value:qs.SyncFailed}]),E.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(t){if(!(t instanceof M))return!1;if(t.code===R.Canceled||t.code===R.Unknown||t.code===R.ResourceExhausted||t.code===R.Unavailable)return!0;if(Sr(t)===d.ErrUnauthenticated){if(this.authTokenInjector){const e=await this.authTokenInjector(zr(t).reason);this.setAuthToken(e)}return!0}return(Sr(t)===d.ErrClientNotActivated||Sr(t)===d.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((e,r)=>{this.taskQueue.push(()=>t().then(e).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{E.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Zi={Client:ua,Document:ca,Primitive:U,Text:_n,Counter:es,Tree:ts,LogLevel:te,setLogLevel:sa,IntType:je.IntegerCnt,LongType:je.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:ua,Document:ca,Primitive:U,Text:_n,Counter:es,Tree:ts,LogLevel:te,setLogLevel:sa,IntType:je.IntegerCnt,LongType:je.LongCnt});const Qi=["Ali","Beatriz","Charles","Diya","Eric","Fatima","Gabriel","Hanna","Johnson","Perry","Parker","Kelly"],fl=()=>{const n=Math.floor(Math.random()*Qi.length);return Qi[n]},_i=["red","yellow","orange","green","blue","purple"],dl=()=>{const n=Math.floor(Math.random()*_i.length);return _i[n]};async function gl(){const n=new Zi.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await n.activate();const t=new Zi.Document("profile-stack",{enableDevtools:!0});t.subscribe("presence",e=>{e.type!==X.PresenceChanged&&ml(t.getPresences(),n.getID())}),await n.attach(t,{initialPresence:{name:fl(),color:dl()}}),window.addEventListener("beforeunload",()=>{n.deactivate()})}const hs=4,fs=(n,t,e)=>{const r=document.createElement("div");return r.className="peer",e==="main"?r.innerHTML=`
    profile
    @@ -28,8 +28,8 @@ var la=Object.defineProperty;var ha=(n,t,e)=>t in n?la(n,t,{enumerable:!0,config `:e==="more"&&(r.innerHTML=` profile ${n} - `),r},ml=(n,t)=>{const e=n.filter(({clientID:h,presence:f})=>h!==t&&f.name&&f.color),r=e.length+1,s=r>ls,i=document.getElementById("peerList");i.innerHTML="";const o=document.createElement("div");o.className="peer-more-list speech-bubbles";const c=n.find(({clientID:h})=>h===t).presence,l=hs(`${c.name} (me)`,c.color,"main");if(l.classList.add("me"),i.appendChild(l),e.forEach((h,f)=>{const{name:g,color:v}=h.presence;if(f{const e=n.filter(({clientID:h,presence:f})=>h!==t&&f.name&&f.color),r=e.length+1,s=r>hs,i=document.getElementById("peerList");i.innerHTML="";const o=document.createElement("div");o.className="peer-more-list speech-bubbles";const c=n.find(({clientID:h})=>h===t).presence,l=fs(`${c.name} (me)`,c.color,"main");if(l.classList.add("me"),i.appendChild(l),e.forEach((h,f)=>{const{name:g,color:v}=h.presence;if(f - +${r-ls} + +${r-hs} `,h.appendChild(o),i.appendChild(h)}};gl(); diff --git a/examples/profile-stack/index.html b/examples/profile-stack/index.html index cfc2f4ca7..f9570bc32 100644 --- a/examples/profile-stack/index.html +++ b/examples/profile-stack/index.html @@ -5,7 +5,7 @@ Profile Stack - Yorkie Example - + diff --git a/examples/react-tldraw/assets/index-CZ-AlliK.js b/examples/react-tldraw/assets/index-1ncFVCXa.js similarity index 89% rename from examples/react-tldraw/assets/index-CZ-AlliK.js rename to examples/react-tldraw/assets/index-1ncFVCXa.js index 0f37cfb89..2067519b6 100644 --- a/examples/react-tldraw/assets/index-CZ-AlliK.js +++ b/examples/react-tldraw/assets/index-1ncFVCXa.js @@ -6,7 +6,7 @@ var G_=Object.defineProperty;var J_=(e,t,n)=>t in e?G_(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var yh=Symbol.for("react.element"),Y_=Symbol.for("react.portal"),q_=Symbol.for("react.fragment"),X_=Symbol.for("react.strict_mode"),Z_=Symbol.for("react.profiler"),Q_=Symbol.for("react.provider"),eN=Symbol.for("react.context"),tN=Symbol.for("react.forward_ref"),nN=Symbol.for("react.suspense"),rN=Symbol.for("react.memo"),iN=Symbol.for("react.lazy"),Pb=Symbol.iterator;function oN(e){return e===null||typeof e!="object"?null:(e=Pb&&e[Pb]||e["@@iterator"],typeof e=="function"?e:null)}var Hx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},jx=Object.assign,Ux={};function pd(e,t,n){this.props=e,this.context=t,this.refs=Ux,this.updater=n||Hx}pd.prototype.isReactComponent={};pd.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};pd.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Kx(){}Kx.prototype=pd.prototype;function S3(e,t,n){this.props=e,this.context=t,this.refs=Ux,this.updater=n||Hx}var x3=S3.prototype=new Kx;x3.constructor=S3;jx(x3,pd.prototype);x3.isPureReactComponent=!0;var Bb=Array.isArray,Vx=Object.prototype.hasOwnProperty,A3={current:null},Gx={key:!0,ref:!0,__self:!0,__source:!0};function Jx(e,t,n){var r,i={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)Vx.call(t,r)&&!Gx.hasOwnProperty(r)&&(i[r]=t[r]);var s=arguments.length-2;if(s===1)i.children=n;else if(1t in e?G_(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var cN=l,dN=Symbol.for("react.element"),hN=Symbol.for("react.fragment"),fN=Object.prototype.hasOwnProperty,pN=cN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,gN={key:!0,ref:!0,__self:!0,__source:!0};function Yx(e,t,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)fN.call(t,r)&&!gN.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:dN,type:e,key:o,ref:a,props:i,_owner:pN.current}}hm.Fragment=hN;hm.jsx=Yx;hm.jsxs=Yx;Nx.exports=hm;var ce=Nx.exports,s2={},qx={exports:{}},Gr={},Xx={exports:{}},Zx={};/** + */var cN=l,dN=Symbol.for("react.element"),hN=Symbol.for("react.fragment"),fN=Object.prototype.hasOwnProperty,pN=cN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,gN={key:!0,ref:!0,__self:!0,__source:!0};function Yx(e,t,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)fN.call(t,r)&&!gN.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:dN,type:e,key:o,ref:a,props:i,_owner:pN.current}}hm.Fragment=hN;hm.jsx=Yx;hm.jsxs=Yx;Nx.exports=hm;var ce=Nx.exports,u2={},qx={exports:{}},Gr={},Xx={exports:{}},Zx={};/** * @license React * scheduler.production.min.js * @@ -30,19 +30,19 @@ var G_=Object.defineProperty;var J_=(e,t,n)=>t in e?G_(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Qx=l,Kr=mN;function de(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u2=Object.prototype.hasOwnProperty,vN=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,$b={},Rb={};function yN(e){return u2.call(Rb,e)?!0:u2.call($b,e)?!1:vN.test(e)?Rb[e]=!0:($b[e]=!0,!1)}function EN(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function CN(e,t,n,r){if(t===null||typeof t>"u"||EN(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function cr(e,t,n,r,i,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var Ln={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ln[e]=new cr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ln[t]=new cr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ln[e]=new cr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ln[e]=new cr(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ln[e]=new cr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ln[e]=new cr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ln[e]=new cr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ln[e]=new cr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ln[e]=new cr(e,5,!1,e.toLowerCase(),null,!1,!1)});var I3=/[\-:]([a-z])/g;function D3(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(I3,D3);Ln[t]=new cr(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(I3,D3);Ln[t]=new cr(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(I3,D3);Ln[t]=new cr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ln[e]=new cr(e,1,!1,e.toLowerCase(),null,!1,!1)});Ln.xlinkHref=new cr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ln[e]=new cr(e,1,!1,e.toLowerCase(),null,!0,!0)});function T3(e,t,n,r){var i=Ln.hasOwnProperty(t)?Ln[t]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),l2=Object.prototype.hasOwnProperty,vN=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,$b={},Rb={};function yN(e){return l2.call(Rb,e)?!0:l2.call($b,e)?!1:vN.test(e)?Rb[e]=!0:($b[e]=!0,!1)}function EN(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function CN(e,t,n,r){if(t===null||typeof t>"u"||EN(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function cr(e,t,n,r,i,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var Ln={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ln[e]=new cr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ln[t]=new cr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ln[e]=new cr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ln[e]=new cr(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ln[e]=new cr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ln[e]=new cr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ln[e]=new cr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ln[e]=new cr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ln[e]=new cr(e,5,!1,e.toLowerCase(),null,!1,!1)});var D3=/[\-:]([a-z])/g;function T3(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(D3,T3);Ln[t]=new cr(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(D3,T3);Ln[t]=new cr(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(D3,T3);Ln[t]=new cr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ln[e]=new cr(e,1,!1,e.toLowerCase(),null,!1,!1)});Ln.xlinkHref=new cr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ln[e]=new cr(e,1,!1,e.toLowerCase(),null,!0,!0)});function P3(e,t,n,r){var i=Ln.hasOwnProperty(t)?Ln[t]:null;(i!==null?i.type!==0:r||!(2s||i[a]!==o[s]){var u=` -`+i[a].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=a&&0<=s);break}}}finally{W4=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?u0(e):""}function bN(e){switch(e.tag){case 5:return u0(e.type);case 16:return u0("Lazy");case 13:return u0("Suspense");case 19:return u0("SuspenseList");case 0:case 2:case 15:return e=Y4(e.type,!1),e;case 11:return e=Y4(e.type.render,!1),e;case 1:return e=Y4(e.type,!0),e;default:return""}}function h2(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mc:return"Fragment";case gc:return"Portal";case l2:return"Profiler";case P3:return"StrictMode";case c2:return"Suspense";case d2:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case n8:return(e.displayName||"Context")+".Consumer";case t8:return(e._context.displayName||"Context")+".Provider";case B3:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case M3:return t=e.displayName||null,t!==null?t:h2(e.type)||"Memo";case Qs:t=e._payload,e=e._init;try{return h2(e(t))}catch{}}return null}function wN(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return h2(t);case 8:return t===P3?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Eu(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function i8(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function SN(e){var t=i8(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Rf(e){e._valueTracker||(e._valueTracker=SN(e))}function o8(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=i8(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Zp(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function f2(e,t){var n=t.checked;return Yt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Lb(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Eu(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function a8(e,t){t=t.checked,t!=null&&T3(e,"checked",t,!1)}function p2(e,t){a8(e,t);var n=Eu(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?g2(e,t.type,n):t.hasOwnProperty("defaultValue")&&g2(e,t.type,Eu(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ob(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function g2(e,t,n){(t!=="number"||Zp(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var l0=Array.isArray;function Bc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Ff.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function _0(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var p0={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},xN=["Webkit","ms","Moz","O"];Object.keys(p0).forEach(function(e){xN.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),p0[t]=p0[e]})});function c8(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||p0.hasOwnProperty(e)&&p0[e]?(""+t).trim():t+"px"}function d8(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=c8(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var AN=Yt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function y2(e,t){if(t){if(AN[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(de(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(de(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(de(61))}if(t.style!=null&&typeof t.style!="object")throw Error(de(62))}}function E2(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var C2=null;function $3(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var b2=null,Mc=null,$c=null;function zb(e){if(e=bh(e)){if(typeof b2!="function")throw Error(de(280));var t=e.stateNode;t&&(t=vm(t),b2(e.stateNode,e.type,t))}}function h8(e){Mc?$c?$c.push(e):$c=[e]:Mc=e}function f8(){if(Mc){var e=Mc,t=$c;if($c=Mc=null,zb(e),t)for(e=0;e>>=0,e===0?32:31-(LN(e)/ON|0)|0}var Lf=64,Of=4194304;function c0(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ng(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var s=a&~i;s!==0?r=c0(s):(o&=a,o!==0&&(r=c0(o)))}else a=n&~i,a!==0?r=c0(a):o!==0&&(r=c0(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Eh(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Zi(t),e[t]=n}function HN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=m0),Yb=" ",qb=!1;function $8(e,t){switch(e){case"keyup":return gz.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function R8(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vc=!1;function vz(e,t){switch(e){case"compositionend":return R8(t);case"keypress":return t.which!==32?null:(qb=!0,Yb);case"textInput":return e=t.data,e===Yb&&qb?null:e;default:return null}}function yz(e,t){if(vc)return e==="compositionend"||!H3&&$8(e,t)?(e=B8(),Bp=_3=iu=null,vc=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ew(n)}}function _8(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_8(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function N8(){for(var e=window,t=Zp();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zp(e.document)}return t}function j3(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Iz(e){var t=N8(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&_8(n.ownerDocument.documentElement,n)){if(r!==null&&j3(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=tw(n,o);var a=tw(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,yc=null,I2=null,y0=null,D2=!1;function nw(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;D2||yc==null||yc!==Zp(r)||(r=yc,"selectionStart"in r&&j3(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),y0&&K0(y0,r)||(y0=r,r=og(I2,"onSelect"),0bc||(e.current=R2[bc],R2[bc]=null,bc--)}function Dt(e,t){bc++,R2[bc]=e.current,e.current=t}var Cu={},Gn=Bu(Cu),Er=Bu(!1),vl=Cu;function Vc(e,t){var n=e.type.contextTypes;if(!n)return Cu;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Cr(e){return e=e.childContextTypes,e!=null}function sg(){$t(Er),$t(Gn)}function lw(e,t,n){if(Gn.current!==Cu)throw Error(de(168));Dt(Gn,t),Dt(Er,n)}function W8(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(de(108,wN(e)||"Unknown",i));return Yt({},n,r)}function ug(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Cu,vl=Gn.current,Dt(Gn,e),Dt(Er,Er.current),!0}function cw(e,t,n){var r=e.stateNode;if(!r)throw Error(de(169));n?(e=W8(e,t,vl),r.__reactInternalMemoizedMergedChildContext=e,$t(Er),$t(Gn),Dt(Gn,e)):$t(Er),Dt(Er,n)}var os=null,ym=!1,lv=!1;function Y8(e){os===null?os=[e]:os.push(e)}function Nz(e){ym=!0,Y8(e)}function Mu(){if(!lv&&os!==null){lv=!0;var e=0,t=yt;try{var n=os;for(yt=1;e>=a,i-=a,us=1<<32-Zi(t)+i|n<M?(O=I,I=null):O=I.sibling;var z=g(C,I,A[M],T);if(z===null){I===null&&(I=O);break}e&&I&&z.alternate===null&&t(C,I),b=o(z,b,M),D===null?B=z:D.sibling=z,D=z,I=O}if(M===A.length)return n(C,I),_t&&Zu(C,M),B;if(I===null){for(;MM?(O=I,I=null):O=I.sibling;var K=g(C,I,z.value,T);if(K===null){I===null&&(I=O);break}e&&I&&K.alternate===null&&t(C,I),b=o(K,b,M),D===null?B=K:D.sibling=K,D=K,I=O}if(z.done)return n(C,I),_t&&Zu(C,M),B;if(I===null){for(;!z.done;M++,z=A.next())z=p(C,z.value,T),z!==null&&(b=o(z,b,M),D===null?B=z:D.sibling=z,D=z);return _t&&Zu(C,M),B}for(I=r(C,I);!z.done;M++,z=A.next())z=m(I,C,M,z.value,T),z!==null&&(e&&z.alternate!==null&&I.delete(z.key===null?M:z.key),b=o(z,b,M),D===null?B=z:D.sibling=z,D=z);return e&&I.forEach(function(X){return t(C,X)}),_t&&Zu(C,M),B}function w(C,b,A,T){if(typeof A=="object"&&A!==null&&A.type===mc&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case $f:e:{for(var B=A.key,D=b;D!==null;){if(D.key===B){if(B=A.type,B===mc){if(D.tag===7){n(C,D.sibling),b=i(D,A.props.children),b.return=C,C=b;break e}}else if(D.elementType===B||typeof B=="object"&&B!==null&&B.$$typeof===Qs&&vw(B)===D.type){n(C,D.sibling),b=i(D,A.props),b.ref=Zd(C,D,A),b.return=C,C=b;break e}n(C,D);break}else t(C,D);D=D.sibling}A.type===mc?(b=hl(A.props.children,C.mode,T,A.key),b.return=C,C=b):(T=Np(A.type,A.key,A.props,null,C.mode,T),T.ref=Zd(C,b,A),T.return=C,C=T)}return a(C);case gc:e:{for(D=A.key;b!==null;){if(b.key===D)if(b.tag===4&&b.stateNode.containerInfo===A.containerInfo&&b.stateNode.implementation===A.implementation){n(C,b.sibling),b=i(b,A.children||[]),b.return=C,C=b;break e}else{n(C,b);break}else t(C,b);b=b.sibling}b=vv(A,C.mode,T),b.return=C,C=b}return a(C);case Qs:return D=A._init,w(C,b,D(A._payload),T)}if(l0(A))return v(C,b,A,T);if(Jd(A))return E(C,b,A,T);Kf(C,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,b!==null&&b.tag===6?(n(C,b.sibling),b=i(b,A),b.return=C,C=b):(n(C,b),b=mv(A,C.mode,T),b.return=C,C=b),a(C)):n(C,b)}return w}var Jc=r7(!0),i7=r7(!1),wh={},No=Bu(wh),W0=Bu(wh),Y0=Bu(wh);function ol(e){if(e===wh)throw Error(de(174));return e}function X3(e,t){switch(Dt(Y0,t),Dt(W0,e),Dt(No,wh),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:v2(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=v2(t,e)}$t(No),Dt(No,t)}function Wc(){$t(No),$t(W0),$t(Y0)}function o7(e){ol(Y0.current);var t=ol(No.current),n=v2(t,e.type);t!==n&&(Dt(W0,e),Dt(No,n))}function Z3(e){W0.current===e&&($t(No),$t(W0))}var Vt=Bu(0);function pg(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var cv=[];function Q3(){for(var e=0;en?n:4,e(!0);var r=dv.transition;dv.transition={};try{e(!1),t()}finally{yt=n,dv.transition=r}}function b7(){return Ii().memoizedState}function Uz(e,t,n){var r=fu(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},w7(e))S7(t,n);else if(n=Q8(e,t,n,r),n!==null){var i=ar();Qi(n,e,r,i),x7(n,t,r)}}function Kz(e,t,n){var r=fu(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(w7(e))S7(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,s=o(a,n);if(i.hasEagerState=!0,i.eagerState=s,ro(s,a)){var u=t.interleaved;u===null?(i.next=i,Y3(t)):(i.next=u.next,u.next=i),t.interleaved=i;return}}catch{}finally{}n=Q8(e,t,i,r),n!==null&&(i=ar(),Qi(n,e,r,i),x7(n,t,r))}}function w7(e){var t=e.alternate;return e===Wt||t!==null&&t===Wt}function S7(e,t){E0=gg=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function x7(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,F3(e,n)}}var mg={readContext:ki,useCallback:Hn,useContext:Hn,useEffect:Hn,useImperativeHandle:Hn,useInsertionEffect:Hn,useLayoutEffect:Hn,useMemo:Hn,useReducer:Hn,useRef:Hn,useState:Hn,useDebugValue:Hn,useDeferredValue:Hn,useTransition:Hn,useMutableSource:Hn,useSyncExternalStore:Hn,useId:Hn,unstable_isNewReconciler:!1},Vz={readContext:ki,useCallback:function(e,t){return Eo().memoizedState=[e,t===void 0?null:t],e},useContext:ki,useEffect:Ew,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fp(4194308,4,m7.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fp(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fp(4,2,e,t)},useMemo:function(e,t){var n=Eo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Eo();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Uz.bind(null,Wt,e),[r.memoizedState,e]},useRef:function(e){var t=Eo();return e={current:e},t.memoizedState=e},useState:yw,useDebugValue:iE,useDeferredValue:function(e){return Eo().memoizedState=e},useTransition:function(){var e=yw(!1),t=e[0];return e=jz.bind(null,e[1]),Eo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Wt,i=Eo();if(_t){if(n===void 0)throw Error(de(407));n=n()}else{if(n=t(),kn===null)throw Error(de(349));El&30||u7(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Ew(c7.bind(null,r,o,e),[e]),r.flags|=2048,Z0(9,l7.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Eo(),t=kn.identifierPrefix;if(_t){var n=ls,r=us;n=(r&~(1<<32-Zi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=q0++,0")&&(u=u.replace("",e.displayName)),u}while(1<=a&&0<=s);break}}}finally{Y4=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?u0(e):""}function bN(e){switch(e.tag){case 5:return u0(e.type);case 16:return u0("Lazy");case 13:return u0("Suspense");case 19:return u0("SuspenseList");case 0:case 2:case 15:return e=q4(e.type,!1),e;case 11:return e=q4(e.type.render,!1),e;case 1:return e=q4(e.type,!0),e;default:return""}}function f2(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mc:return"Fragment";case gc:return"Portal";case c2:return"Profiler";case B3:return"StrictMode";case d2:return"Suspense";case h2:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case n8:return(e.displayName||"Context")+".Consumer";case t8:return(e._context.displayName||"Context")+".Provider";case M3:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $3:return t=e.displayName||null,t!==null?t:f2(e.type)||"Memo";case Qs:t=e._payload,e=e._init;try{return f2(e(t))}catch{}}return null}function wN(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return f2(t);case 8:return t===B3?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Eu(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function i8(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function SN(e){var t=i8(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Rf(e){e._valueTracker||(e._valueTracker=SN(e))}function o8(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=i8(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Zp(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function p2(e,t){var n=t.checked;return Yt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Lb(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Eu(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function a8(e,t){t=t.checked,t!=null&&P3(e,"checked",t,!1)}function g2(e,t){a8(e,t);var n=Eu(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?m2(e,t.type,n):t.hasOwnProperty("defaultValue")&&m2(e,t.type,Eu(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ob(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function m2(e,t,n){(t!=="number"||Zp(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var l0=Array.isArray;function Bc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Ff.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function _0(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var p0={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},xN=["Webkit","ms","Moz","O"];Object.keys(p0).forEach(function(e){xN.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),p0[t]=p0[e]})});function c8(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||p0.hasOwnProperty(e)&&p0[e]?(""+t).trim():t+"px"}function d8(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=c8(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var AN=Yt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function E2(e,t){if(t){if(AN[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(de(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(de(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(de(61))}if(t.style!=null&&typeof t.style!="object")throw Error(de(62))}}function C2(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var b2=null;function R3(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var w2=null,Mc=null,$c=null;function zb(e){if(e=bh(e)){if(typeof w2!="function")throw Error(de(280));var t=e.stateNode;t&&(t=vm(t),w2(e.stateNode,e.type,t))}}function h8(e){Mc?$c?$c.push(e):$c=[e]:Mc=e}function f8(){if(Mc){var e=Mc,t=$c;if($c=Mc=null,zb(e),t)for(e=0;e>>=0,e===0?32:31-(LN(e)/ON|0)|0}var Lf=64,Of=4194304;function c0(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ng(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var s=a&~i;s!==0?r=c0(s):(o&=a,o!==0&&(r=c0(o)))}else a=n&~i,a!==0?r=c0(a):o!==0&&(r=c0(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Eh(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Zi(t),e[t]=n}function HN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=m0),Yb=" ",qb=!1;function $8(e,t){switch(e){case"keyup":return gz.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function R8(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vc=!1;function vz(e,t){switch(e){case"compositionend":return R8(t);case"keypress":return t.which!==32?null:(qb=!0,Yb);case"textInput":return e=t.data,e===Yb&&qb?null:e;default:return null}}function yz(e,t){if(vc)return e==="compositionend"||!j3&&$8(e,t)?(e=B8(),Bp=N3=iu=null,vc=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ew(n)}}function _8(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?_8(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function N8(){for(var e=window,t=Zp();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zp(e.document)}return t}function U3(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Iz(e){var t=N8(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&_8(n.ownerDocument.documentElement,n)){if(r!==null&&U3(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=tw(n,o);var a=tw(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,yc=null,D2=null,y0=null,T2=!1;function nw(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;T2||yc==null||yc!==Zp(r)||(r=yc,"selectionStart"in r&&U3(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),y0&&K0(y0,r)||(y0=r,r=og(D2,"onSelect"),0bc||(e.current=F2[bc],F2[bc]=null,bc--)}function Dt(e,t){bc++,F2[bc]=e.current,e.current=t}var Cu={},Gn=Bu(Cu),Er=Bu(!1),vl=Cu;function Vc(e,t){var n=e.type.contextTypes;if(!n)return Cu;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Cr(e){return e=e.childContextTypes,e!=null}function sg(){$t(Er),$t(Gn)}function lw(e,t,n){if(Gn.current!==Cu)throw Error(de(168));Dt(Gn,t),Dt(Er,n)}function W8(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(de(108,wN(e)||"Unknown",i));return Yt({},n,r)}function ug(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Cu,vl=Gn.current,Dt(Gn,e),Dt(Er,Er.current),!0}function cw(e,t,n){var r=e.stateNode;if(!r)throw Error(de(169));n?(e=W8(e,t,vl),r.__reactInternalMemoizedMergedChildContext=e,$t(Er),$t(Gn),Dt(Gn,e)):$t(Er),Dt(Er,n)}var os=null,ym=!1,cv=!1;function Y8(e){os===null?os=[e]:os.push(e)}function Nz(e){ym=!0,Y8(e)}function Mu(){if(!cv&&os!==null){cv=!0;var e=0,t=yt;try{var n=os;for(yt=1;e>=a,i-=a,us=1<<32-Zi(t)+i|n<M?(O=I,I=null):O=I.sibling;var z=g(C,I,A[M],T);if(z===null){I===null&&(I=O);break}e&&I&&z.alternate===null&&t(C,I),b=o(z,b,M),D===null?B=z:D.sibling=z,D=z,I=O}if(M===A.length)return n(C,I),_t&&Zu(C,M),B;if(I===null){for(;MM?(O=I,I=null):O=I.sibling;var K=g(C,I,z.value,T);if(K===null){I===null&&(I=O);break}e&&I&&K.alternate===null&&t(C,I),b=o(K,b,M),D===null?B=K:D.sibling=K,D=K,I=O}if(z.done)return n(C,I),_t&&Zu(C,M),B;if(I===null){for(;!z.done;M++,z=A.next())z=p(C,z.value,T),z!==null&&(b=o(z,b,M),D===null?B=z:D.sibling=z,D=z);return _t&&Zu(C,M),B}for(I=r(C,I);!z.done;M++,z=A.next())z=m(I,C,M,z.value,T),z!==null&&(e&&z.alternate!==null&&I.delete(z.key===null?M:z.key),b=o(z,b,M),D===null?B=z:D.sibling=z,D=z);return e&&I.forEach(function(X){return t(C,X)}),_t&&Zu(C,M),B}function w(C,b,A,T){if(typeof A=="object"&&A!==null&&A.type===mc&&A.key===null&&(A=A.props.children),typeof A=="object"&&A!==null){switch(A.$$typeof){case $f:e:{for(var B=A.key,D=b;D!==null;){if(D.key===B){if(B=A.type,B===mc){if(D.tag===7){n(C,D.sibling),b=i(D,A.props.children),b.return=C,C=b;break e}}else if(D.elementType===B||typeof B=="object"&&B!==null&&B.$$typeof===Qs&&vw(B)===D.type){n(C,D.sibling),b=i(D,A.props),b.ref=Zd(C,D,A),b.return=C,C=b;break e}n(C,D);break}else t(C,D);D=D.sibling}A.type===mc?(b=hl(A.props.children,C.mode,T,A.key),b.return=C,C=b):(T=Np(A.type,A.key,A.props,null,C.mode,T),T.ref=Zd(C,b,A),T.return=C,C=T)}return a(C);case gc:e:{for(D=A.key;b!==null;){if(b.key===D)if(b.tag===4&&b.stateNode.containerInfo===A.containerInfo&&b.stateNode.implementation===A.implementation){n(C,b.sibling),b=i(b,A.children||[]),b.return=C,C=b;break e}else{n(C,b);break}else t(C,b);b=b.sibling}b=yv(A,C.mode,T),b.return=C,C=b}return a(C);case Qs:return D=A._init,w(C,b,D(A._payload),T)}if(l0(A))return v(C,b,A,T);if(Jd(A))return E(C,b,A,T);Kf(C,A)}return typeof A=="string"&&A!==""||typeof A=="number"?(A=""+A,b!==null&&b.tag===6?(n(C,b.sibling),b=i(b,A),b.return=C,C=b):(n(C,b),b=vv(A,C.mode,T),b.return=C,C=b),a(C)):n(C,b)}return w}var Jc=r7(!0),i7=r7(!1),wh={},No=Bu(wh),W0=Bu(wh),Y0=Bu(wh);function ol(e){if(e===wh)throw Error(de(174));return e}function Z3(e,t){switch(Dt(Y0,t),Dt(W0,e),Dt(No,wh),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:y2(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=y2(t,e)}$t(No),Dt(No,t)}function Wc(){$t(No),$t(W0),$t(Y0)}function o7(e){ol(Y0.current);var t=ol(No.current),n=y2(t,e.type);t!==n&&(Dt(W0,e),Dt(No,n))}function Q3(e){W0.current===e&&($t(No),$t(W0))}var Vt=Bu(0);function pg(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var dv=[];function eE(){for(var e=0;en?n:4,e(!0);var r=hv.transition;hv.transition={};try{e(!1),t()}finally{yt=n,hv.transition=r}}function b7(){return Ii().memoizedState}function Uz(e,t,n){var r=fu(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},w7(e))S7(t,n);else if(n=Q8(e,t,n,r),n!==null){var i=ar();Qi(n,e,r,i),x7(n,t,r)}}function Kz(e,t,n){var r=fu(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(w7(e))S7(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,s=o(a,n);if(i.hasEagerState=!0,i.eagerState=s,ro(s,a)){var u=t.interleaved;u===null?(i.next=i,q3(t)):(i.next=u.next,u.next=i),t.interleaved=i;return}}catch{}finally{}n=Q8(e,t,i,r),n!==null&&(i=ar(),Qi(n,e,r,i),x7(n,t,r))}}function w7(e){var t=e.alternate;return e===Wt||t!==null&&t===Wt}function S7(e,t){E0=gg=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function x7(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,L3(e,n)}}var mg={readContext:ki,useCallback:Hn,useContext:Hn,useEffect:Hn,useImperativeHandle:Hn,useInsertionEffect:Hn,useLayoutEffect:Hn,useMemo:Hn,useReducer:Hn,useRef:Hn,useState:Hn,useDebugValue:Hn,useDeferredValue:Hn,useTransition:Hn,useMutableSource:Hn,useSyncExternalStore:Hn,useId:Hn,unstable_isNewReconciler:!1},Vz={readContext:ki,useCallback:function(e,t){return Eo().memoizedState=[e,t===void 0?null:t],e},useContext:ki,useEffect:Ew,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fp(4194308,4,m7.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fp(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fp(4,2,e,t)},useMemo:function(e,t){var n=Eo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Eo();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Uz.bind(null,Wt,e),[r.memoizedState,e]},useRef:function(e){var t=Eo();return e={current:e},t.memoizedState=e},useState:yw,useDebugValue:oE,useDeferredValue:function(e){return Eo().memoizedState=e},useTransition:function(){var e=yw(!1),t=e[0];return e=jz.bind(null,e[1]),Eo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Wt,i=Eo();if(_t){if(n===void 0)throw Error(de(407));n=n()}else{if(n=t(),kn===null)throw Error(de(349));El&30||u7(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Ew(c7.bind(null,r,o,e),[e]),r.flags|=2048,Z0(9,l7.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Eo(),t=kn.identifierPrefix;if(_t){var n=ls,r=us;n=(r&~(1<<32-Zi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=q0++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Ao]=t,e[J0]=r,$7(e,t,!1,!1),t.stateNode=e;e:{switch(a=E2(n,r),n){case"dialog":Bt("cancel",e),Bt("close",e),i=r;break;case"iframe":case"object":case"embed":Bt("load",e),i=r;break;case"video":case"audio":for(i=0;iqc&&(t.flags|=128,r=!0,Qd(o,!1),t.lanes=4194304)}else{if(!r)if(e=pg(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Qd(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!_t)return jn(t),null}else 2*an()-o.renderingStartTime>qc&&n!==1073741824&&(t.flags|=128,r=!0,Qd(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=an(),t.sibling=null,n=Vt.current,Dt(Vt,r?n&1|2:n&1),t):(jn(t),null);case 22:case 23:return cE(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Br&1073741824&&(jn(t),t.subtreeFlags&6&&(t.flags|=8192)):jn(t),null;case 24:return null;case 25:return null}throw Error(de(156,t.tag))}function Qz(e,t){switch(K3(t),t.tag){case 1:return Cr(t.type)&&sg(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wc(),$t(Er),$t(Gn),Q3(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Z3(t),null;case 13:if($t(Vt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(de(340));Gc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $t(Vt),null;case 4:return Wc(),null;case 10:return W3(t.type._context),null;case 22:case 23:return cE(),null;case 24:return null;default:return null}}var Gf=!1,Kn=!1,eH=typeof WeakSet=="function"?WeakSet:Set,Se=null;function Ac(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Zt(e,t,r)}else n.current=null}function G2(e,t,n){try{n()}catch(r){Zt(e,t,r)}}var Dw=!1;function tH(e,t){if(T2=rg,e=N8(),j3(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,s=-1,u=-1,d=0,h=0,p=e,g=null;t:for(;;){for(var m;p!==n||i!==0&&p.nodeType!==3||(s=a+i),p!==o||r!==0&&p.nodeType!==3||(u=a+r),p.nodeType===3&&(a+=p.nodeValue.length),(m=p.firstChild)!==null;)g=p,p=m;for(;;){if(p===e)break t;if(g===n&&++d===i&&(s=a),g===o&&++h===r&&(u=a),(m=p.nextSibling)!==null)break;p=g,g=p.parentNode}p=m}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(P2={focusedElem:e,selectionRange:n},rg=!1,Se=t;Se!==null;)if(t=Se,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Se=e;else for(;Se!==null;){t=Se;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var E=v.memoizedProps,w=v.memoizedState,C=t.stateNode,b=C.getSnapshotBeforeUpdate(t.elementType===t.type?E:Ui(t.type,E),w);C.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var A=t.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(de(163))}}catch(T){Zt(t,t.return,T)}if(e=t.sibling,e!==null){e.return=t.return,Se=e;break}Se=t.return}return v=Dw,Dw=!1,v}function C0(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&G2(t,n,o)}i=i.next}while(i!==r)}}function bm(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function J2(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function L7(e){var t=e.alternate;t!==null&&(e.alternate=null,L7(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ao],delete t[J0],delete t[$2],delete t[Oz],delete t[_z])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function O7(e){return e.tag===5||e.tag===3||e.tag===4}function Tw(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||O7(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function W2(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ag));else if(r!==4&&(e=e.child,e!==null))for(W2(e,t,n),e=e.sibling;e!==null;)W2(e,t,n),e=e.sibling}function Y2(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Y2(e,t,n),e=e.sibling;e!==null;)Y2(e,t,n),e=e.sibling}var Mn=null,Ji=!1;function Ks(e,t,n){for(n=n.child;n!==null;)_7(e,t,n),n=n.sibling}function _7(e,t,n){if(_o&&typeof _o.onCommitFiberUnmount=="function")try{_o.onCommitFiberUnmount(fm,n)}catch{}switch(n.tag){case 5:Kn||Ac(n,t);case 6:var r=Mn,i=Ji;Mn=null,Ks(e,t,n),Mn=r,Ji=i,Mn!==null&&(Ji?(e=Mn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Mn.removeChild(n.stateNode));break;case 18:Mn!==null&&(Ji?(e=Mn,n=n.stateNode,e.nodeType===8?uv(e.parentNode,n):e.nodeType===1&&uv(e,n),j0(e)):uv(Mn,n.stateNode));break;case 4:r=Mn,i=Ji,Mn=n.stateNode.containerInfo,Ji=!0,Ks(e,t,n),Mn=r,Ji=i;break;case 0:case 11:case 14:case 15:if(!Kn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&G2(n,t,a),i=i.next}while(i!==r)}Ks(e,t,n);break;case 1:if(!Kn&&(Ac(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Zt(n,t,s)}Ks(e,t,n);break;case 21:Ks(e,t,n);break;case 22:n.mode&1?(Kn=(r=Kn)||n.memoizedState!==null,Ks(e,t,n),Kn=r):Ks(e,t,n);break;default:Ks(e,t,n)}}function Pw(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new eH),t.forEach(function(r){var i=cH.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function zi(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=a),r&=~o}if(r=i,r=an()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*rH(r/1960))-r,10e?16:e,ou===null)var r=!1;else{if(e=ou,ou=null,Eg=0,ut&6)throw Error(de(331));var i=ut;for(ut|=4,Se=e.current;Se!==null;){var o=Se,a=o.child;if(Se.flags&16){var s=o.deletions;if(s!==null){for(var u=0;uan()-uE?dl(e,0):sE|=n),br(e,t)}function G7(e,t){t===0&&(e.mode&1?(t=Of,Of<<=1,!(Of&130023424)&&(Of=4194304)):t=1);var n=ar();e=bs(e,t),e!==null&&(Eh(e,t,n),br(e,n))}function lH(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),G7(e,n)}function cH(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(de(314))}r!==null&&r.delete(t),G7(e,n)}var J7;J7=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Er.current)vr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return vr=!1,Xz(e,t,n);vr=!!(e.flags&131072)}else vr=!1,_t&&t.flags&1048576&&q8(t,cg,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Lp(e,t),e=t.pendingProps;var i=Vc(t,Gn.current);Fc(t,n),i=tE(null,t,r,e,i,n);var o=nE();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Cr(r)?(o=!0,ug(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,q3(t),i.updater=Em,t.stateNode=i,i._reactInternals=t,N2(t,r,e,n),t=j2(null,t,r,!0,o,n)):(t.tag=0,_t&&o&&U3(t),nr(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Lp(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=hH(r),e=Ui(r,e),i){case 0:t=H2(null,t,r,e,n);break e;case 1:t=Aw(null,t,r,e,n);break e;case 11:t=Sw(null,t,r,e,n);break e;case 14:t=xw(null,t,r,Ui(r.type,e),n);break e}throw Error(de(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),H2(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Aw(e,t,r,i,n);case 3:e:{if(P7(t),e===null)throw Error(de(387));r=t.pendingProps,o=t.memoizedState,i=o.element,e7(e,t),fg(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Yc(Error(de(423)),t),t=kw(e,t,r,n,i);break e}else if(r!==i){i=Yc(Error(de(424)),t),t=kw(e,t,r,n,i);break e}else for(Rr=cu(t.stateNode.containerInfo.firstChild),zr=t,_t=!0,Wi=null,n=i7(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Gc(),r===i){t=ws(e,t,n);break e}nr(e,t,r,n)}t=t.child}return t;case 5:return o7(t),e===null&&L2(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,a=i.children,B2(r,i)?a=null:o!==null&&B2(r,o)&&(t.flags|=32),T7(e,t),nr(e,t,a,n),t.child;case 6:return e===null&&L2(t),null;case 13:return B7(e,t,n);case 4:return X3(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Jc(t,null,r,n):nr(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Sw(e,t,r,i,n);case 7:return nr(e,t,t.pendingProps,n),t.child;case 8:return nr(e,t,t.pendingProps.children,n),t.child;case 12:return nr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value,Dt(dg,r._currentValue),r._currentValue=a,o!==null)if(ro(o.value,a)){if(o.children===i.children&&!Er.current){t=ws(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){a=o.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=fs(-1,n&-n),u.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?u.next=u:(u.next=h.next,h.next=u),d.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),O2(o.return,n,t),s.lanes|=n;break}u=u.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(de(341));a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),O2(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}nr(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Fc(t,n),i=ki(i),r=r(i),t.flags|=1,nr(e,t,r,n),t.child;case 14:return r=t.type,i=Ui(r,t.pendingProps),i=Ui(r.type,i),xw(e,t,r,i,n);case 15:return I7(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Lp(e,t),t.tag=1,Cr(r)?(e=!0,ug(t)):e=!1,Fc(t,n),n7(t,r,i),N2(t,r,i,n),j2(null,t,r,!0,e,n);case 19:return M7(e,t,n);case 22:return D7(e,t,n)}throw Error(de(156,t.tag))};function W7(e,t){return C8(e,t)}function dH(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(e,t,n,r){return new dH(e,t,n,r)}function hE(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hH(e){if(typeof e=="function")return hE(e)?1:0;if(e!=null){if(e=e.$$typeof,e===B3)return 11;if(e===M3)return 14}return 2}function pu(e,t){var n=e.alternate;return n===null?(n=Ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Np(e,t,n,r,i,o){var a=2;if(r=e,typeof e=="function")hE(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case mc:return hl(n.children,i,o,t);case P3:a=8,i|=8;break;case l2:return e=Ei(12,n,t,i|2),e.elementType=l2,e.lanes=o,e;case c2:return e=Ei(13,n,t,i),e.elementType=c2,e.lanes=o,e;case d2:return e=Ei(19,n,t,i),e.elementType=d2,e.lanes=o,e;case r8:return Sm(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case t8:a=10;break e;case n8:a=9;break e;case B3:a=11;break e;case M3:a=14;break e;case Qs:a=16,r=null;break e}throw Error(de(130,e==null?e:typeof e,""))}return t=Ei(a,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function hl(e,t,n,r){return e=Ei(7,e,r,t),e.lanes=n,e}function Sm(e,t,n,r){return e=Ei(22,e,r,t),e.elementType=r8,e.lanes=n,e.stateNode={isHidden:!1},e}function mv(e,t,n){return e=Ei(6,e,null,t),e.lanes=n,e}function vv(e,t,n){return t=Ei(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fH(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=X4(0),this.expirationTimes=X4(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=X4(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function fE(e,t,n,r,i,o,a,s,u){return e=new fH(e,t,n,s,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ei(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},q3(o),e}function pH(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Z7)}catch(e){console.error(e)}}Z7(),qx.exports=Gr;var $u=qx.exports;const Q7=vh($u);var _w=$u;s2.createRoot=_w.createRoot,s2.hydrateRoot=_w.hydrateRoot;var EH=Object.defineProperty,CH=(e,t,n)=>t in e?EH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ze=(e,t,n)=>(CH(e,typeof t!="symbol"?t+"":t,n),n),Re=class{static clamp(t,n,r){return Math.max(n,typeof r<"u"?Math.min(t,r):t)}static clampV(t,n,r){return t.map(i=>r?Re.clamp(i,n,r):Re.clamp(i,n))}static cross(t,n,r){return(n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1])}static snap(t,n=1){return[Math.round(t[0]/n)*n,Math.round(t[1]/n)*n]}},te=Re;ze(te,"neg",e=>[-e[0],-e[1]]),ze(te,"add",(e,t)=>[e[0]+t[0],e[1]+t[1]]),ze(te,"addScalar",(e,t)=>[e[0]+t,e[1]+t]),ze(te,"sub",(e,t)=>[e[0]-t[0],e[1]-t[1]]),ze(te,"subScalar",(e,t)=>[e[0]-t,e[1]-t]),ze(te,"vec",(e,t)=>[t[0]-e[0],t[1]-e[1]]),ze(te,"mul",(e,t)=>[e[0]*t,e[1]*t]),ze(te,"mulV",(e,t)=>[e[0]*t[0],e[1]*t[1]]),ze(te,"div",(e,t)=>[e[0]/t,e[1]/t]),ze(te,"divV",(e,t)=>[e[0]/t[0],e[1]/t[1]]),ze(te,"per",e=>[e[1],-e[0]]),ze(te,"dpr",(e,t)=>e[0]*t[0]+e[1]*t[1]),ze(te,"cpr",(e,t)=>e[0]*t[1]-t[0]*e[1]),ze(te,"len2",e=>e[0]*e[0]+e[1]*e[1]),ze(te,"len",e=>Math.hypot(e[0],e[1])),ze(te,"pry",(e,t)=>Re.dpr(e,t)/Re.len(t)),ze(te,"uni",e=>Re.div(e,Re.len(e))),ze(te,"normalize",e=>Re.uni(e)),ze(te,"tangent",(e,t)=>Re.uni(Re.sub(e,t))),ze(te,"dist2",(e,t)=>Re.len2(Re.sub(e,t))),ze(te,"dist",(e,t)=>Math.hypot(e[1]-t[1],e[0]-t[0])),ze(te,"fastDist",(e,t)=>{let n=[t[0]-e[0],t[1]-e[1]],r=[Math.abs(n[0]),Math.abs(n[1])],i=1/Math.max(r[0],r[1]);return i=i*(1.29289-(r[0]+r[1])*i*.29289),[n[0]*i,n[1]*i]}),ze(te,"ang",(e,t)=>Math.atan2(Re.cpr(e,t),Re.dpr(e,t))),ze(te,"angle",(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0])),ze(te,"med",(e,t)=>Re.mul(Re.add(e,t),.5)),ze(te,"rot",(e,t=0)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)]),ze(te,"rotWith",(e,t,n=0)=>{if(n===0)return e;let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}),ze(te,"isEqual",(e,t)=>e[0]===t[0]&&e[1]===t[1]),ze(te,"lrp",(e,t,n)=>Re.add(e,Re.mul(Re.sub(t,e),n))),ze(te,"int",(e,t,n,r,i=1)=>{let o=(Re.clamp(n,r)-n)/(r-n);return Re.add(Re.mul(e,1-o),Re.mul(t,i))}),ze(te,"ang3",(e,t,n)=>{let r=Re.vec(t,e),i=Re.vec(t,n);return Re.ang(r,i)}),ze(te,"abs",e=>[Math.abs(e[0]),Math.abs(e[1])]),ze(te,"rescale",(e,t)=>{let n=Re.len(e);return[t*e[0]/n,t*e[1]/n]}),ze(te,"isLeft",(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])),ze(te,"clockwise",(e,t,n)=>Re.isLeft(e,t,n)>0),ze(te,"toFixed",e=>e.map(t=>Math.round(t*100)/100)),ze(te,"nearestPointOnLineThroughPoint",(e,t,n)=>Re.add(e,Re.mul(t,Re.pry(Re.sub(n,e),t)))),ze(te,"distanceToLineThroughPoint",(e,t,n)=>Re.dist(n,Re.nearestPointOnLineThroughPoint(e,t,n))),ze(te,"nearestPointOnLineSegment",(e,t,n,r=!0)=>{let i=Re.uni(Re.sub(t,e)),o=Re.add(e,Re.mul(i,Re.pry(Re.sub(n,e),i)));if(r){if(o[0]Math.max(e[0],t[0]))return e[0]>t[0]?e:t;if(o[1]Math.max(e[1],t[1]))return e[1]>t[1]?e:t}return o}),ze(te,"distanceToLineSegment",(e,t,n,r=!0)=>Re.dist(n,Re.nearestPointOnLineSegment(e,t,n,r))),ze(te,"nearestPointOnBounds",(e,t)=>[Re.clamp(t[0],e.minX,e.maxX),Re.clamp(t[1],e.minY,e.maxY)]),ze(te,"distanceToBounds",(e,t)=>Re.dist(t,Re.nearestPointOnBounds(e,t))),ze(te,"nudge",(e,t,n)=>Re.isEqual(e,t)?e:Re.add(e,Re.mul(Re.uni(Re.sub(t,e)),n))),ze(te,"nudgeAtAngle",(e,t,n)=>[Math.cos(t)*n+e[0],Math.sin(t)*n+e[1]]),ze(te,"toPrecision",(e,t=4)=>[+e[0].toPrecision(t),+e[1].toPrecision(t)]),ze(te,"pointsBetween",(e,t,n=6)=>Array.from(Array(n)).map((r,i)=>{let o=i/(n-1),a=Math.min(1,.5+Math.abs(.5-o));return[...Re.lrp(e,t,o),a]})),ze(te,"slope",(e,t)=>e[0]===t[0]?NaN:(e[1]-t[1])/(e[0]-t[0])),ze(te,"max",(...e)=>[Math.max(...e.map(t=>t[0])),Math.max(...e.map(t=>t[1]))]),ze(te,"min",(...e)=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1]))]);function bH(e,t,n){return Math.max(t,Math.min(e,n))}const Rt={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function Nw(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function zw(e,t,n,r=.15){return r===0?bH(e,t,n):en?+Nw(e-n,n-t,r)+n:e}function wH(e,[t,n],[r,i]){const[[o,a],[s,u]]=e;return[zw(t,o,a,r),zw(n,s,u,i)]}function cn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Gt(e){for(var t=1;t{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function PH(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function nA(e){return Dm(e)?PH(e)[0]:e}function ey(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY,i=(t.clientX+e.clientX)/2,o=(t.clientY+e.clientY)/2,a=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:a,origin:[i,o]}}function BH(e){return TH(e).map(t=>t.identifier)}function Uw(e,t){const[n,r]=Array.from(e.touches).filter(i=>t.includes(i.identifier));return ey(n,r)}function yv(e){const t=nA(e);return Dm(e)?t.identifier:t.pointerId}function Xc(e){const t=nA(e);return[t.clientX,t.clientY]}const Kw=40,Vw=800;function rA(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=Kw,n*=Kw):r===2&&(t*=Vw,n*=Vw),[t,n]}function MH(e){var t,n;const{scrollX:r,scrollY:i,scrollLeft:o,scrollTop:a}=e.currentTarget;return[(t=r??o)!==null&&t!==void 0?t:0,(n=i??a)!==null&&n!==void 0?n:0]}function $H(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:i,ctrlKey:o}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:i,ctrlKey:o})}return t}function wg(e,...t){return typeof e=="function"?e(...t):e}function RH(){}function FH(...e){return e.length===0?RH:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function Gw(e,t){return Object.assign({},t,e||{})}const LH=32;class iA{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:i}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=i,t.axis=void 0,t.memo=void 0,t.elapsedTime=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?wg(r.from,n):n.offset,n.offset=n.lastOffset),n.startTime=n.timeStamp=t.timeStamp}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:i}=this;n.args=this.args;let o=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,$H(t)),i.down=i.pressed=i.buttons%2===1||i.touches>0,o=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const D=n._delta.map(Math.abs);Rt.addTo(n._distance,D)}this.axisIntent&&this.axisIntent(t);const[a,s]=n._movement,[u,d]=r.threshold,{_step:h,values:p}=n;if(r.hasCustomTransform?(h[0]===!1&&(h[0]=Math.abs(a)>=u&&p[0]),h[1]===!1&&(h[1]=Math.abs(s)>=d&&p[1])):(h[0]===!1&&(h[0]=Math.abs(a)>=u&&Math.sign(a)*u),h[1]===!1&&(h[1]=Math.abs(s)>=d&&Math.sign(s)*d)),n.intentional=h[0]!==!1||h[1]!==!1,!n.intentional)return;const g=[0,0];if(r.hasCustomTransform){const[D,I]=p;g[0]=h[0]!==!1?D-h[0]:0,g[1]=h[1]!==!1?I-h[1]:0}else g[0]=h[0]!==!1?a-h[0]:0,g[1]=h[1]!==!1?s-h[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(g);const m=n.offset,v=n._active&&!n._blocked||n.active;v&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=i[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=wg(r.bounds,n)),this.setup&&this.setup()),n.movement=g,this.computeOffset()));const[E,w]=n.offset,[[C,b],[A,T]]=n._bounds;n.overflow=[Eb?1:0,wT?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const B=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=wH(n._bounds,n.offset,B),n.delta=Rt.sub(n.offset,m),this.computeMovement(),v&&(!n.last||o>LH)){n.delta=Rt.sub(n.offset,m);const D=n.delta.map(Math.abs);Rt.addTo(n.distance,D),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[D[0]/o,D[1]/o])}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const i=this.handler(Gt(Gt(Gt({},n),t),{},{[this.aliasKey]:t.values}));i!==void 0&&(t.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function OH([e,t],n){const r=Math.abs(e),i=Math.abs(t);if(r>i&&r>n)return"x";if(i>r&&i>n)return"y"}class Sh extends iA{constructor(...t){super(...t),cn(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Rt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Rt.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const i=typeof r.axisThreshold=="object"?r.axisThreshold[tA(t)]:r.axisThreshold;n.axis=OH(n._movement,i)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const _H=e=>e,Jw=.15,oA={enabled(e=!0){return e},eventOptions(e,t,n){return Gt(Gt({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[Jw,Jw];case!1:return[0,0];default:return Rt.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Rt.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||_H},threshold(e){return Rt.toVector(e,0)}},NH=0,Ml=Gt(Gt({},oA),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=NH){return e},bounds(e={}){if(typeof e=="function")return o=>Ml.bounds(e(o));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:i=1/0}=e;return[[t,n],[r,i]]}}),Yf=10,Ww={ArrowRight:(e=1)=>[Yf*e,0],ArrowLeft:(e=1)=>[-Yf*e,0],ArrowUp:(e=1)=>[0,-Yf*e],ArrowDown:(e=1)=>[0,Yf*e]};class zH extends Sh{constructor(...t){super(...t),cn(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),i={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=Ml.bounds(i)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const i=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(i&&i.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=yv(t),r._pointerActive=!0,this.computeValues(Xc(t)),this.computeInitial(),n.preventScrollAxis&&tA(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive||n.type===t.type&&t.timeStamp===n.timeStamp)return;const i=yv(t);if(n._pointerId!==void 0&&i!==n._pointerId)return;const o=Xc(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Rt.sub(o,n._values),this.computeValues(o)),Rt.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const i=yv(t);if(n._pointerId!==void 0&&i!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[o,a]=n._distance;if(n.tap=o<=r.tapsThreshold&&a<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[s,u]=n.direction,[d,h]=n.velocity,[p,g]=n.movement,[m,v]=r.swipe.velocity,[E,w]=r.swipe.distance,C=r.swipe.duration;n.elapsedTimem&&Math.abs(p)>E&&(n.swipe[0]=s),Math.abs(h)>v&&Math.abs(g)>w&&(n.swipe[1]=u))}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,HH(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=Ww[t.key];if(n){const r=this.state,i=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(i),r._keyboardActive=!0,Rt.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Ww&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function HH(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const xh=typeof window<"u"&&window.document&&window.document.createElement;function jH(){return xh&&"ontouchstart"in window}function Yw(){return jH()||xh&&window.navigator.maxTouchPoints>1}function UH(){return xh&&"onpointerdown"in window}function KH(){return xh&&"exitPointerLock"in window.document}function VH(){try{return"constructor"in GestureEvent}catch{return!1}}const si={isBrowser:xh,gesture:VH(),touch:Yw(),touchscreen:Yw(),pointer:UH(),pointerLock:KH()},GH=250,JH=180,WH=.5,YH=50,qH=250,qw={mouse:0,touch:0,pen:8},XH=Gt(Gt({},Ml),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:i=!1}={}}){return this.pointerLock=r&&si.pointerLock,si.touch&&n?"touch":this.pointerLock?"mouse":si.pointer&&!i?"pointer":si.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?GH:void 0,!(!si.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:i=!0}={}}){return this.pointerButtons=r,this.keys=i,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:i=void 0}){const o=Rt.toVector(e,n?r:i?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:e=WH,distance:t=YH,duration:n=qH}={}){return{velocity:this.transform(Rt.toVector(e)),distance:this.transform(Rt.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return JH;case!1:return 0;default:return e}},axisThreshold(e){return e?Gt(Gt({},qw),e):qw}});function aA(e){const[t,n]=e.overflow,[r,i]=e._delta,[o,a]=e._direction;(t<0&&r>0&&o<0||t>0&&r<0&&o>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&i>0&&a<0||n>0&&i<0&&a>0)&&(e._movement[1]=e._movementBound[1])}const ZH=30,QH=100;class ej extends iA{constructor(...t){super(...t),cn(this,"ingKey","pinching"),cn(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=Rt.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const i=Math.abs(n)*ZH-Math.abs(r);i<0?t.axis="angle":i>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(o=>r.has(o))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const i=Uw(t,n._touchIds);this.pinchStart(t,i)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,i=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(a=>i.has(a))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const o=ey(...Array.from(r.values()));this.pinchStart(t,o)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=Uw(t,this.state._touchIds);this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=ey(...Array.from(n.values()));this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,i=r._values[1],o=n.angle-i;let a=0;Math.abs(o)>270&&(a+=Math.sign(o)),this.computeValues([n.distance,n.angle-360*a]),r.origin=n.origin,r.turns=a,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=Rt.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&!t[n]||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-rA(t)[1]/QH*r.offset[0],0],Rt.addTo(r._movement,r._delta),aA(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const tj=Gt(Gt({},oA),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!si.touch&&si.gesture)return"gesture";if(si.touch&&r)return"touch";if(si.touchscreen){if(si.pointer)return"pointer";if(si.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const i=a=>{const s=Gw(wg(n,a),{min:-1/0,max:1/0});return[s.min,s.max]},o=a=>{const s=Gw(wg(r,a),{min:-1/0,max:1/0});return[s.min,s.max]};return typeof n!="function"&&typeof r!="function"?[i(),o()]:a=>[i(a),o(a)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Rt.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class nj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(Xc(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const n=Xc(t),r=this.state;r._delta=Rt.sub(n,r._values),Rt.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const rj=Gt(Gt({},Ml),{},{mouseOnly:(e=!0)=>e});class ij extends Sh{constructor(...t){super(...t),cn(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const n=this.state,r=MH(t);n._delta=Rt.sub(r,n._values),Rt.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const oj=Ml;class aj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=rA(t),Rt.addTo(n._movement,n._delta),aA(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const sj=Ml;class uj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Xc(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=Xc(t);n._movement=n._delta=Rt.sub(r,n._values),this.computeValues(r),this.compute(t),n.delta=n.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const lj=Gt(Gt({},Ml),{},{mouseOnly:(e=!0)=>e}),vE=new Map,ty=new Map;function cj(e){vE.set(e.key,e.engine),ty.set(e.key,e.resolver)}const dj={key:"drag",engine:zH,resolver:XH},hj={key:"hover",engine:uj,resolver:lj},fj={key:"move",engine:nj,resolver:rj},pj={key:"pinch",engine:ej,resolver:tj},gj={key:"scroll",engine:ij,resolver:oj},mj={key:"wheel",engine:aj,resolver:sj};function vj(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o=0)&&(n[i]=e[i]);return n}function yj(e,t){if(e==null)return{};var n=vj(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const Ej={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=si.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},Cj=["target","eventOptions","window","enabled","transform"];function zp(e={},t){const n={};for(const[r,i]of Object.entries(t))switch(typeof i){case"function":n[r]=i.call(n,e[r],r,e);break;case"object":n[r]=zp(e[r],i);break;case"boolean":i&&(n[r]=e[r]);break}return n}function bj(e,t,n={}){const r=e,{target:i,eventOptions:o,window:a,enabled:s,transform:u}=r,d=yj(r,Cj);if(n.shared=zp({target:i,eventOptions:o,window:a,enabled:s,transform:u},Ej),t){const h=ty.get(t);n[t]=zp(Gt({shared:n.shared},d),h)}else for(const h in d){const p=ty.get(h);p&&(n[h]=zp(Gt({shared:n.shared},d[h]),p))}return n}class sA{constructor(t,n){cn(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,i,o){const a=this._listeners,s=DH(n,r),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=Gt(Gt({},u),o);t.addEventListener(s,i,d);const h=()=>{t.removeEventListener(s,i,d),a.delete(h)};return a.add(h),h}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class wj{constructor(){cn(this,"_timeouts",new Map)}add(t,n,r=140,...i){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...i))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class Sj{constructor(t){cn(this,"gestures",new Set),cn(this,"_targetEventStore",new sA(this)),cn(this,"gestureEventStores",{}),cn(this,"gestureTimeoutStores",{}),cn(this,"handlers",{}),cn(this,"config",{}),cn(this,"pointerIds",new Set),cn(this,"touchIds",new Set),cn(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),xj(this,t)}setEventIds(t){if(Dm(t))return this.touchIds=new Set(BH(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=bj(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let i;if(!(n.target&&(i=n.target(),!i))){if(n.enabled){for(const a of this.gestures){const s=this.config[a],u=Xw(r,s.eventOptions,!!i);if(s.enabled){const d=vE.get(a);new d(this,t,a).bind(u)}}const o=Xw(r,n.eventOptions,!!i);for(const a in this.nativeHandlers)o(a,"",s=>this.nativeHandlers[a](Gt(Gt({},this.state.shared),{},{event:s,args:t})),void 0,!0)}for(const o in r)r[o]=FH(...r[o]);if(!i)return r;for(const o in r){const{device:a,capture:s,passive:u}=IH(o);this._targetEventStore.add(i,a,"",r[o],{capture:s,passive:u})}}}}function tc(e,t){e.gestures.add(t),e.gestureEventStores[t]=new sA(e,t),e.gestureTimeoutStores[t]=new wj}function xj(e,t){t.drag&&tc(e,"drag"),t.wheel&&tc(e,"wheel"),t.scroll&&tc(e,"scroll"),t.move&&tc(e,"move"),t.pinch&&tc(e,"pinch"),t.hover&&tc(e,"hover")}const Xw=(e,t,n)=>(r,i,o,a={},s=!1)=>{var u,d;const h=(u=a.capture)!==null&&u!==void 0?u:t.capture,p=(d=a.passive)!==null&&d!==void 0?d:t.passive;let g=s?r:AH(r,i,h);n&&p&&(g+="Passive"),e[g]=e[g]||[],e[g].push(o)},Aj=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function kj(e){const t={},n={},r=new Set;for(let i in e)Aj.test(i)?(r.add(RegExp.lastMatch),n[i]=e[i]):t[i]=e[i];return[n,t,r]}function nc(e,t,n,r,i,o){if(!e.has(n)||!vE.has(r))return;const a=n+"Start",s=n+"End",u=d=>{let h;return d.first&&a in t&&t[a](d),n in t&&(h=t[n](d)),d.last&&s in t&&t[s](d),h};i[r]=u,o[r]=o[r]||{}}function Ij(e,t){const[n,r,i]=kj(e),o={};return nc(i,n,"onDrag","drag",o,t),nc(i,n,"onWheel","wheel",o,t),nc(i,n,"onScroll","scroll",o,t),nc(i,n,"onPinch","pinch",o,t),nc(i,n,"onMove","move",o,t),nc(i,n,"onHover","hover",o,t),{handlers:o,config:t,nativeHandlers:r}}function Dj(e,t={},n,r){const i=Kt.useMemo(()=>new Sj(e),[]);if(i.applyHandlers(e,r),i.applyConfig(t,n),Kt.useEffect(i.effect.bind(i)),Kt.useEffect(()=>i.clean.bind(i),[]),t.target===void 0)return i.bind.bind(i)}function Tj(e){return e.forEach(cj),function(n,r){const{handlers:i,nativeHandlers:o,config:a}=Ij(n,r||{});return Dj(i,a,void 0,o)}}function Pj(e,t){return Tj([dj,pj,gj,mj,fj,hj])(e,t||{})}function Zw(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}function Bj(e){return[-e[0],-e[1]]}function Ki(e,t){return[e[0]+t[0],e[1]+t[1]]}function ii(e,t){return[e[0]-t[0],e[1]-t[1]]}function ji(e,t){return[e[0]*t,e[1]*t]}function Mj(e,t){return[e[0]/t,e[1]/t]}function t0(e){return[e[1],-e[0]]}function Qw(e,t){return e[0]*t[0]+e[1]*t[1]}function $j(e,t){return e[0]===t[0]&&e[1]===t[1]}function Rj(e){return Math.hypot(e[0],e[1])}function Fj(e){return e[0]*e[0]+e[1]*e[1]}function e6(e,t){return Fj(ii(e,t))}function uA(e){return Mj(e,Rj(e))}function Lj(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function n0(e,t,n){let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}function ny(e,t,n){return Ki(e,ji(ii(t,e),n))}function t6(e,t,n){return Ki(e,ji(t,n))}var{min:rc,PI:Oj}=Math,n6=.275,r0=Oj+1e-4;function yE(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:o=!0,easing:a=W=>W,start:s={},end:u={},last:d=!1}=t,{cap:h=!0,easing:p=W=>W*(2-W)}=s,{cap:g=!0,easing:m=W=>--W*W*W+1}=u;if(e.length===0||n<=0)return[];let v=e[e.length-1].runningLength,E=s.taper===!1?0:s.taper===!0?Math.max(n,v):s.taper,w=u.taper===!1?0:u.taper===!0?Math.max(n,v):u.taper,C=Math.pow(n*r,2),b=[],A=[],T=e.slice(0,10).reduce((W,U)=>{let ne=U.pressure;if(o){let le=rc(1,U.distance/n),Ae=rc(1,1-le);ne=rc(1,W+(Ae-W)*(le*n6))}return(W+ne)/2},e[0].pressure),B=Zw(n,i,e[e.length-1].pressure,a),D,I=e[0].vector,M=e[0].point,O=M,z=M,K=O,X=!1;for(let W=0;WC)&&(b.push(z),M=z),K=Ki(ne,pn),(W<=1||e6(O,K)>C)&&(A.push(K),O=K),T=U,I=le}let Z=e[0].point.slice(0,2),pe=e.length>1?e[e.length-1].point.slice(0,2):Ki(e[0].point,[1,1]),me=[],Ce=[];if(e.length===1){if(!(E||w)||d){let W=t6(Z,uA(t0(ii(Z,pe))),-(D||B)),U=[];for(let ne=1/13,le=ne;le<=1;le+=ne)U.push(n0(W,Z,r0*2*le));return U}}else{if(!(E||w&&e.length===1))if(h)for(let U=1/13,ne=U;ne<=1;ne+=U){let le=n0(A[0],Z,r0*ne);me.push(le)}else{let U=ii(b[0],A[0]),ne=ji(U,.5),le=ji(U,.51);me.push(ii(Z,ne),ii(Z,le),Ki(Z,le),Ki(Z,ne))}let W=t0(Bj(e[e.length-1].vector));if(w||E&&e.length===1)Ce.push(pe);else if(g){let U=t6(pe,W,B);for(let ne=1/29,le=ne;le<1;le+=ne)Ce.push(n0(U,pe,r0*3*le))}else Ce.push(Ki(pe,ji(W,B)),Ki(pe,ji(W,B*.99)),ii(pe,ji(W,B*.99)),ii(pe,ji(W,B)))}return b.concat(Ce,A.reverse(),me)}function vd(e,t={}){var n;let{streamline:r=.5,size:i=16,last:o=!1}=t;if(e.length===0)return[];let a=.15+(1-r)*.85,s=Array.isArray(e[0])?e:e.map(({x:m,y:v,pressure:E=.5})=>[m,v,E]);if(s.length===2){let m=s[1];s=s.slice(0,-1);for(let v=1;v<5;v++)s.push(ny(s[0],m,v/4))}s.length===1&&(s=[...s,[...Ki(s[0],[1,1]),...s[0].slice(2)]]);let u=[{point:[s[0][0],s[0][1]],pressure:s[0][2]>=0?s[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=!1,h=0,p=u[0],g=s.length-1;for(let m=1;m=0?s[m][2]:.5,vector:uA(ii(p.point,v)),distance:E,runningLength:h},u.push(p)}return u[0].vector=((n=u[1])==null?void 0:n.vector)||[0,0],u}function _j(e,t={}){return yE(vd(e,t),t)}var Ah=_j;function al(e,...t){return{didIntersect:t.length>0,message:e,points:t}}function Nj(e,t,n=0){let r=[e[0]+t[0]/2,e[1]+t[1]/2],i=te.rotWith(e,r,n),o=te.rotWith(te.add(e,[t[0],0]),r,n),a=te.rotWith(te.add(e,t),r,n),s=te.rotWith(te.add(e,[0,t[1]]),r,n);return[["top",[i,o]],["right",[o,a]],["bottom",[a,s]],["left",[s,i]]]}function zj(e,t,n,r){let i=te.sub(e,n),o=te.sub(r,n),a=te.sub(t,e),s=o[0]*i[1]-o[1]*i[0],u=a[0]*i[1]-a[1]*i[0],d=o[1]*a[0]-o[0]*a[1];if(s===0||u===0)return al("coincident");if(d===0)return al("parallel");if(d!==0){let h=s/d,p=u/d;if(0<=h&&h<=1&&0<=p&&p<=1)return al("intersection",te.add(e,te.mul(a,h)))}return al("no intersection")}function Hj(e,t,n){let r=[];for(let i=1;i{let s=Hj(o,a,n);return s.didIntersect&&r.push(al(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function Uj(e,t){return jj([t.minX,t.minY],[t.width,t.height],e)}var Kj=Object.defineProperty,Vj=Object.defineProperties,Gj=Object.getOwnPropertyDescriptors,Sg=Object.getOwnPropertySymbols,lA=Object.prototype.hasOwnProperty,cA=Object.prototype.propertyIsEnumerable,ry=(e,t,n)=>t in e?Kj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t)=>{for(var n in t||(t={}))lA.call(t,n)&&ry(e,n,t[n]);if(Sg)for(var n of Sg(t))cA.call(t,n)&&ry(e,n,t[n]);return e},Io=(e,t)=>Vj(e,Gj(t)),yd=(e,t)=>{var n={};for(var r in e)lA.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Sg)for(var r of Sg(e))t.indexOf(r)<0&&cA.call(e,r)&&(n[r]=e[r]);return n},Ot=(e,t,n)=>(ry(e,typeof t!="symbol"?t+"":t,n),n),EE=l.createContext({});function Jn(){return l.useContext(EE)}var Jj=(e=>(e.TransformSelected="transform_selected",e.TranslateSelected="translate_selected",e.TransformAll="transform_all",e.TranslateAll="translate_all",e))(Jj||{}),Wj=(e=>(e.Top="top_edge",e.Right="right_edge",e.Bottom="bottom_edge",e.Left="left_edge",e))(Wj||{}),Yi=(e=>(e.TopLeft="top_left_corner",e.TopRight="top_right_corner",e.BottomRight="bottom_right_corner",e.BottomLeft="bottom_left_corner",e))(Yi||{}),Yj=(e=>(e.minX="minX",e.midX="midX",e.maxX="maxX",e.minY="minY",e.midY="midY",e.maxY="maxY",e))(Yj||{});String.prototype.replaceAll||(String.prototype.replaceAll=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object regexp]"?this.replace(e,t):this.replace(new RegExp(e,"g"),t)});var qf=Math.PI*2,vn=class{static lerp(t,n,r){return r=vn.clamp(r,0,1),t*(1-r)+n*r}static lerpColor(t,n,r=.5){function i(d){let h=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(d);return[parseInt(h[1],16),parseInt(h[2],16),parseInt(h[3],16)]}function o(d){return"#"+((1<<24)+(d[0]<<16)+(d[1]<<8)+d[2]).toString(16).slice(1)}let a=i(t)||[0,0,0],s=i(n)||[0,0,0],u=a.slice();for(let d=0;d<3;d++)u[d]=Math.round(u[d]+r*(s[d]-a[d]));return o(u)}static modulate(t,n,r,i=!1){let[o,a]=n,[s,u]=r,d=s+(t-o)/(a-o)*(u-s);return i?sn[r]=typeof t[r]=="object"?vn.deepClone(t[r]):t[r]),n}return t}static rng(t=""){let n=0,r=0,i=0,o=0;function a(){let s=n^n<<11;return n=r,r=i,i=o,o^=(o>>>19^s^s>>>8)>>>0,o/4294967296}for(let s=0;si}static degreesToRadians(t){return t*Math.PI/180}static radiansToDegrees(t){return t*180/Math.PI}static getArcLength(t,n,r,i){let o=vn.getSweep(t,r,i);return n*(2*Math.PI)*(o/(2*Math.PI))}static getSweepFlag(t,n,r){let i=te.angle(t,r);return(te.angle(t,n)-i+3*Math.PI)%(2*Math.PI)-Math.PI>0?0:1}static getLargeArcFlag(t,n,r){let i=te.angle(r,t),o=(te.angle(r,n)-i+3*Math.PI)%(2*Math.PI)-Math.PI;return Math.abs(o)>Math.PI/2?0:1}static getArcDashOffset(t,n,r,i,o){let a=vn.getSweepFlag(t,r,i),s=vn.getArcLength(t,n,r,i);return-(a<0?s:2*Math.PI*t[2]-s)/2+o}static getEllipseDashOffset(t,n){return-(2*Math.PI*t[2])/2+-n}static pointInCircle(t,n,r){return te.dist(t,n)<=r}static pointInEllipse(t,n,r,i,o=0){o=o||0;let a=Math.cos(o),s=Math.sin(o),u=te.sub(t,n),d=a*u[0]+s*u[1],h=s*u[0]-a*u[1];return d*d/(r*r)+h*h/(i*i)<=1}static pointInRect(t,n){return!(t[0]t[0]+n[0]||t[1]t[1]+n[1])}static pointInPolygon(t,n){let r=0;return n.forEach((i,o)=>{let a=n[(o+1)%n.length];i[1]<=t[1]?a[1]>t[1]&&te.cross(i,a,t)>0&&(r+=1):a[1]<=t[1]&&te.cross(i,a,t)<0&&(r-=1)}),r!==0}static pointInBounds(t,n){return!(t[0]n.maxX||t[1]n.maxY)}static pointInPolyline(t,n,r=3){for(let i=1;in.maxX||t.maxYn.maxY)}static boundsContain(t,n){return t.minXn.maxY&&t.maxX>n.maxX}static boundsContained(t,n){return vn.boundsContain(n,t)}static boundsAreEqual(t,n){return!(n.maxX!==t.maxX||n.minX!==t.minX||n.maxY!==t.maxY||n.minY!==t.minY)}static getBoundsFromPoints(t,n=0){let r=1/0,i=1/0,o=-1/0,a=-1/0;if(t.length<2)r=0,i=0,o=1,a=1;else for(let[s,u]of t)r=Math.min(s,r),i=Math.min(u,i),o=Math.max(s,o),a=Math.max(u,a);return n!==0?vn.getBoundsFromPoints(t.map(s=>te.rotWith(s,[(r+o)/2,(i+a)/2],n))):{minX:r,minY:i,maxX:o,maxY:a,width:Math.max(1,o-r),height:Math.max(1,a-i)}}static centerBounds(t,n){let r=this.getBoundsCenter(t),i=n[0]-r[0],o=n[1]-r[1];return this.translateBounds(t,[i,o])}static snapBoundsToGrid(t,n){let r=Math.round(t.minX/n)*n,i=Math.round(t.minY/n)*n,o=Math.round(t.maxX/n)*n,a=Math.round(t.maxY/n)*n;return{minX:r,minY:i,maxX:o,maxY:a,width:Math.max(1,o-r),height:Math.max(1,a-i)}}static translateBounds(t,n){return{minX:t.minX+n[0],minY:t.minY+n[1],maxX:t.maxX+n[0],maxY:t.maxY+n[1],width:t.width,height:t.height}}static rotateBounds(t,n,r){let[i,o]=te.rotWith([t.minX,t.minY],n,r),[a,s]=te.rotWith([t.maxX,t.maxY],n,r);return{minX:i,minY:o,maxX:a,maxY:s,width:t.width,height:t.height}}static getRotatedEllipseBounds(t,n,r,i,o=0){let a=Math.cos(o),s=Math.sin(o),u=Math.hypot(r*a,i*s),d=Math.hypot(r*s,i*a);return{minX:t+r-u,minY:n+i-d,maxX:t+r+u,maxY:n+i+d,width:u*2,height:d*2}}static getExpandedBounds(t,n){let r=Math.min(t.minX,n.minX),i=Math.min(t.minY,n.minY),o=Math.max(t.maxX,n.maxX),a=Math.max(t.maxY,n.maxY),s=Math.abs(o-r),u=Math.abs(a-i);return{minX:r,minY:i,maxX:o,maxY:a,width:s,height:u}}static getCommonBounds(t){if(t.length<2)return t[0];let n=t[0];for(let r=1;rte.rotWith(i,r,n))}static getTransformedBoundingBox(t,n,r,i=0,o=!1){let[a,s]=[t.minX,t.minY],[u,d]=[t.maxX,t.maxY],[h,p]=[t.minX,t.minY],[g,m]=[t.maxX,t.maxY];if(n==="center")return{minX:h+r[0],minY:p+r[1],maxX:g+r[0],maxY:m+r[1],width:g-h,height:m-p,scaleX:1,scaleY:1};let[v,E]=te.rot(r,-i);switch(n){case"top_edge":case"top_left_corner":case"top_right_corner":{p+=E;break}case"bottom_edge":case"bottom_left_corner":case"bottom_right_corner":{m+=E;break}}switch(n){case"left_edge":case"top_left_corner":case"bottom_left_corner":{h+=v;break}case"right_edge":case"top_right_corner":case"bottom_right_corner":{g+=v;break}}let w=u-a,C=d-s,b=(g-h)/w,A=(m-p)/C,T=b<0,B=A<0,D=Math.abs(g-h),I=Math.abs(m-p);if(o){let M=w/C,O=Mte.rotWith(a,r,n)),o=vn.getBoundsFromPoints(i);return[o.width,o.height]}static getBoundsCenter(t){return[t.minX+t.width/2,t.minY+t.height/2]}static getBoundsWithCenter(t){let n=vn.getBoundsCenter(t);return Io(lt({},t),{midX:n[0],midY:n[1]})}static getCommonTopLeft(t){let n=[1/0,1/0];return t.forEach(r=>{n[0]=Math.min(n[0],r[0]),n[1]=Math.min(n[1],r[1])}),n}static getFromCache(t,n,r){let i=t.get(n);if(i===void 0&&(t.set(n,r()),i=t.get(n),i===void 0))throw Error("Cache did not include item!");return i}static uniqueId(t=""){return t?((Number(t)^Math.random()*16)>>Number(t)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,vn.uniqueId)}static rotateArray(t,n){return t.map((r,i)=>t[(i+n)%t.length])}static debounce(t,n=0){let r;return function(...i){clearTimeout(r),r=setTimeout(()=>t.apply(i),n)}}static getSvgPathFromStroke(t,n=!0){let r=t.length;if(r<4)return"";let i=t[0],o=t[1],a=t[2],s=`M${i[0].toFixed(2)},${i[1].toFixed(2)} Q${o[0].toFixed(2)},${o[1].toFixed(2)} ${Vs(o[0],a[0]).toFixed(2)},${Vs(o[1],a[1]).toFixed(2)} T`;for(let u=2,d=r-1;u"u")return!1;let t=window.navigator.userAgent,n=!!t.match(/iPad/i)||!!t.match(/iPhone/i),r=!!t.match(/WebKit/i);return n&&r&&!t.match(/CriOS/i)}static throttle(t,n){let r,i;return function(...o){return r||(r=!0,setTimeout(()=>r=!1,n),i=t(...o)),i}}static isDarwin(){return/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)}static metaKey(t){return vn.isDarwin()?t.metaKey:t.ctrlKey}static lns(t){let n=t.split("");return n.push(...n.splice(0,Math.round(n.length/5))),n.push(...n.splice(0,Math.round(n.length/4))),n.push(...n.splice(0,Math.round(n.length/3))),n.push(...n.splice(0,Math.round(n.length/2))),n.reverse().map(r=>+r?+r<5?5+ +r:+r>5?+r-5:r:r).join("")}},N=vn;Ot(N,"getSnapPoints",(e,t,n)=>{let r=lt({},e),i=[0,0],o=[],a={minX:{id:"minX",isSnapped:!1},midX:{id:"midX",isSnapped:!1},maxX:{id:"maxX",isSnapped:!1},minY:{id:"minY",isSnapped:!1},midY:{id:"midY",isSnapped:!1},maxY:{id:"maxY",isSnapped:!1}},s=["midX","minX","maxX"],u=["midY","minY","maxY"],d=t.map(v=>{let E=s.flatMap((C,b)=>s.map((A,T)=>{let B=r[C]-v[A],D=Math.abs(B);return{f:C,t:A,gap:B,distance:D,isCareful:b===0||b+T===3}})),w=u.flatMap((C,b)=>u.map((A,T)=>{let B=r[C]-v[A],D=Math.abs(B);return{f:C,t:A,gap:B,distance:D,isCareful:b===0||b+T===3}}));return[v,E,w]}),h=1/0,p=1/0,g=1/0,m=1/0;return d.forEach(([v,E,w])=>{E.forEach(C=>{C.distance{C.distance{h!==1/0&&E.forEach(C=>{Math.abs(C.gap-h)<2&&(a[C.f]=Io(lt({},a[C.f]),{isSnapped:!0,to:v[C.t],B:v,distance:C.distance}))}),p!==1/0&&w.forEach(C=>{Math.abs(C.gap-p)<2&&(a[C.f]=Io(lt({},a[C.f]),{isSnapped:!0,to:v[C.t],B:v,distance:C.distance}))})}),i[0]=h===1/0?0:h,i[1]=p===1/0?0:p,r.minX-=i[0],r.midX-=i[0],r.maxX-=i[0],r.minY-=i[1],r.midY-=i[1],r.maxY-=i[1],s.forEach(v=>{let E=a[v];if(!E.isSnapped)return;let{id:w,B:C}=E,b=r[w];o.push(w==="minX"?[[b,r.midY],[b,C.minY],[b,C.maxY]]:[[b,r.minY],[b,r.maxY],[b,C.minY],[b,C.maxY]])}),u.forEach(v=>{let E=a[v];if(!E.isSnapped)return;let{id:w,B:C}=E,b=r[w];o.push(w==="midY"?[[r.midX,b],[C.minX,b],[C.maxX,b]]:[[r.minX,b],[r.maxX,b],[C.minX,b],[C.maxX,b]])}),{offset:i,snapLines:o}}),Ot(N,"deepMerge",(e,t)=>{let n=lt({},e),r=Object.entries(t);for(let[i,o]of r)n[i]=o===Object(o)&&!Array.isArray(o)?vn.deepMerge(n[i],o):o;return n});function Vs(e,t){return(e+t)/2}var Fr=N;function qj(e,t){let n=l.useRef(void 0),r=l.useRef(void 0),i=l.useRef([0,0]),o=l.useRef(0),{inputs:a,bounds:s,callbacks:u}=Jn();l.useEffect(()=>{let m=v=>v.preventDefault();return document.addEventListener("gesturestart",m),document.addEventListener("gesturechange",m),()=>{document.removeEventListener("gesturestart",m),document.removeEventListener("gesturechange",m)}},[]);let d=l.useCallback(({event:m})=>{var v,E,w,C;if(m.preventDefault(),a.isPinching||m.timeStamp<=o.current)return;o.current=m.timeStamp;let[b,A,T]=Xj(m);if((m.altKey||m.ctrlKey||m.metaKey)&&m.buttons===0){let I=[...(E=(v=a.pointer)==null?void 0:v.point)!=null?E:[s.width/2,s.height/2],T*.618],M=a.pan(I,m);(w=u.onZoom)==null||w.call(u,Io(lt({},M),{delta:I}),m);return}let B=te.mul(m.shiftKey&&!Fr.isDarwin()?[A,0]:[b,A],.5);if(te.isEqual(B,[0,0]))return;let D=a.pan(B,m);(C=u.onPan)==null||C.call(u,D,m)},[u,a,s]),h=l.useCallback(({origin:m,event:v})=>{var E;if(v instanceof WheelEvent)return;let w=t.current;if(!w||!(v.target===w||w.contains(v.target)))return;let C=a.pinch(m,m);a.isPinching=!0,(E=u.onPinchStart)==null||E.call(u,C,v),r.current=C.point,n.current=C.origin,i.current=[0,0]},[u,a,s]),p=l.useCallback(({origin:m,offset:v,event:E})=>{var w;if(E instanceof WheelEvent)return;let C=t.current;if(!(E.target===C||C!=null&&C.contains(E.target))||!n.current)return;let b=a.pinch(m,n.current),A=te.sub(b.delta,i.current);i.current=b.delta,(w=u.onPinch)==null||w.call(u,Io(lt({},b),{point:b.point,origin:n.current,delta:[...A,v[0]]}),E),r.current=m},[u,a,s]),g=l.useCallback(({origin:m,event:v})=>{var E;let w=t.current;if(!(v.target===w||w!=null&&w.contains(v.target)))return;let C=a.pinch(m,m);a.isPinching=!1,(E=u.onPinchEnd)==null||E.call(u,C,v),r.current=void 0,n.current=void 0,i.current=[0,0]},[]);Pj({onWheel:d,onPinchStart:h,onPinch:p,onPinchEnd:g},{target:t,eventOptions:{passive:!1},pinch:{from:[e.current,0],scaleBounds:()=>({from:e.current,max:5,min:.1})}})}var r6=10;function Xj(e){let{deltaY:t,deltaX:n}=e,r=0;if(e.ctrlKey||e.metaKey){let i=Math.sign(e.deltaY),o=Math.abs(e.deltaY),a=t;o>r6&&(a=r6*i),r=a}return[n,t,r]}function Zj(){let{callbacks:e}=Jn();l.useEffect(()=>{function t(){var n;(n=e.onShapeBlur)==null||n.call(e)}return Fr.isMobileSafari()?(document.addEventListener("focusout",t),()=>document.removeEventListener("focusout",t)):()=>null},[e])}function Qj(){let{callbacks:e,inputs:t}=Jn();return l.useMemo(()=>({onPointerDown:n=>{var r,i,o;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;if(n.currentTarget.setPointerCapture(n.pointerId),n.button===2){(r=e.onRightPointCanvas)==null||r.call(e,t.pointerDown(n,"canvas"),n);return}let a=t.pointerDown(n,"canvas");n.button===0&&((i=e.onPointCanvas)==null||i.call(e,a,n)),(o=e.onPointerDown)==null||o.call(e,a,n)},onPointerMove:n=>{var r,i;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;let o=t.pointerMove(n,"canvas");n.buttons===1&&n.currentTarget.hasPointerCapture(n.pointerId)&&((r=e.onDragCanvas)==null||r.call(e,o,n)),(i=e.onPointerMove)==null||i.call(e,o,n)},onPointerUp:n=>{var r,i,o,a,s;if(n.dead||(n.dead=!0,t.activePointer=void 0,!t.pointerIsValid(n)))return;let u=t.isDoubleClick(),d=t.pointerUp(n,"canvas");if(n.button===2){(r=e.onPointerUp)==null||r.call(e,d,n);return}n.currentTarget.hasPointerCapture(n.pointerId)&&((i=n.currentTarget)==null||i.releasePointerCapture(n.pointerId)),n.button===0&&(u&&!(d.altKey||d.metaKey)&&((o=e.onDoubleClickCanvas)==null||o.call(e,d,n)),(a=e.onReleaseCanvas)==null||a.call(e,d,n)),(s=e.onPointerUp)==null||s.call(e,d,n)},onDrop:e.onDrop,onDragOver:e.onDragOver}),[e,t])}function eU(e){let{rPageState:t,rSelectionBounds:n,callbacks:r,inputs:i}=l.useContext(EE);return l.useMemo(()=>({onPointerDown:o=>{var a,s,u,d,h,p,g;if(o.dead||(o.dead=!0,!i.pointerIsValid(o)))return;if(o.button===2){(a=r.onRightPointShape)==null||a.call(r,i.pointerDown(o,e),o);return}let m=i.pointerDown(o,e);if((s=o.currentTarget)==null||s.setPointerCapture(o.pointerId),n.current&&N.pointInBounds(m.point,n.current)&&!t.current.selectedIds.includes(e)){o.button===0&&((u=r.onPointBounds)==null||u.call(r,i.pointerDown(o,"bounds"),o),(d=r.onPointShape)==null||d.call(r,m,o)),(h=r.onPointerDown)==null||h.call(r,m,o);return}o.button===0&&((p=r.onPointShape)==null||p.call(r,m,o)),(g=r.onPointerDown)==null||g.call(r,m,o)},onPointerUp:o=>{var a,s,u,d;if(o.dead||(o.dead=!0,!i.pointerIsValid(o))||o.button===2)return;i.activePointer=void 0;let h=i.isDoubleClick(),p=i.pointerUp(o,e);o.pointerId&&o.currentTarget.hasPointerCapture(o.pointerId)&&((a=o.currentTarget)==null||a.releasePointerCapture(o.pointerId)),o.button===0&&(h&&!(p.altKey||p.metaKey)&&((s=r.onDoubleClickShape)==null||s.call(r,p,o)),(u=r.onReleaseShape)==null||u.call(r,p,o)),(d=r.onPointerUp)==null||d.call(r,p,o)},onPointerMove:o=>{var a,s;if(o.dead||(o.dead=!0,o.buttons===2||!i.pointerIsValid(o)||i.pointer&&o.pointerId!==i.pointer.pointerId))return;let u=i.pointerMove(o,e);o.buttons===1&&o.currentTarget.hasPointerCapture(o.pointerId)&&((a=r.onDragShape)==null||a.call(r,u,o)),(s=r.onPointerMove)==null||s.call(r,u,o)},onPointerEnter:o=>{var a;if(!i.pointerIsValid(o))return;let s=i.pointerEnter(o,e);(a=r.onHoverShape)==null||a.call(r,s,o)},onPointerLeave:o=>{var a;if(!i.pointerIsValid(o))return;let s=i.pointerEnter(o,e);(a=r.onUnhoverShape)==null||a.call(r,s,o)}}),[i,r,e])}function dA(e,t,n,r,i,o=!1,a=!1,s,u){let d={shape:e,asset:e.assetId?i[e.assetId]:void 0,meta:s,isChildOfSelected:a,isGhost:e.isGhost||o,isEditing:r.editingId===e.id,isBinding:u===e.id,isSelected:r.selectedIds.includes(e.id),isHovered:r.hoveredId===e.id||e.children!==void 0&&(r.hoveredId&&e.children.includes(r.hoveredId)||e.children.some(h=>r.selectedIds.includes(h)))};t.push(d),e.children&&(d.children=[],e.children.map(h=>n[h]).filter(h=>n[h.id]).sort((h,p)=>h.childIndex-p.childIndex).forEach(h=>dA(h,d.children,n,r,i,d.isGhost,d.isSelected||d.isChildOfSelected,s)))}function tU(e,t){return N.boundsContain(t,e)||N.boundsCollide(t,e)}function nU(e,t,n,r){let{callbacks:i,shapeUtils:o,bounds:a}=Jn(),s=l.useRef(),u=l.useRef(-1),d=l.useRef(new Set),h=l.useRef(new Set),{selectedIds:p,camera:g}=t,[m,v]=te.sub(te.div([0,0],g.zoom),g.point),[E,w]=te.sub(te.div([a.width,a.height],g.zoom),g.point),C={minX:m,minY:v,maxX:E,maxY:w,height:E-m,width:w-v},b=h.current,A=d.current;b.clear(),A.clear(),Object.values(e.shapes).filter(D=>o[D.type].isStateful||p.includes(D.id)||tU(o[D.type].getBounds(D),C)).forEach(D=>{if(D.parentId===e.id){A.add(D.id),b.add(D);return}let I=e.shapes[D.parentId];if(I===void 0)throw Error(`A shape (${D.id}) has a parent (${D.parentId}) that does not exist!`);A.add(I.id),b.add(I)}),b.size!==u.current&&(s.current&&clearTimeout(s.current),s.current=requestAnimationFrame(()=>{var D;(D=i.onRenderCountChange)==null||D.call(i,Array.from(A.values()))}),u.current=b.size);let T=t.bindingId?e.bindings[t.bindingId].toId:void 0,B=[];return b.forEach(D=>{if(D===void 0)throw Error("Rendered shapes included a missing shape");dA(D,B,e.shapes,t,n,D.isGhost,!1,r,T)}),B.sort((D,I)=>D.shape.childIndex-I.shape.childIndex),B}var Ev=new Map;function rU(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r];return i?n+`${`--${e}-${r}`}: ${i}; +`+o.stack}return{value:e,source:t,stack:i,digest:null}}function gv(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function H2(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Wz=typeof WeakMap=="function"?WeakMap:Map;function A7(e,t,n){n=fs(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){yg||(yg=!0,X2=r),H2(e,t)},n}function k7(e,t,n){n=fs(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){H2(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){H2(e,t),typeof r!="function"&&(hu===null?hu=new Set([this]):hu.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Cw(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Wz;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=uH.bind(null,e,t,n),t.then(e,e))}function bw(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function ww(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=fs(-1,1),t.tag=2,du(n,t,1))),n.lanes|=1),e)}var Yz=Ts.ReactCurrentOwner,vr=!1;function nr(e,t,n,r){t.child=e===null?i7(t,null,n,r):Jc(t,e.child,n,r)}function Sw(e,t,n,r,i){n=n.render;var o=t.ref;return Fc(t,i),r=nE(e,t,n,r,o,i),n=rE(),e!==null&&!vr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ws(e,t,i)):(_t&&n&&K3(t),t.flags|=1,nr(e,t,r,i),t.child)}function xw(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!fE(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,I7(e,t,o,r,i)):(e=Np(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:K0,n(a,r)&&e.ref===t.ref)return ws(e,t,i)}return t.flags|=1,e=pu(o,r),e.ref=t.ref,e.return=t,t.child=e}function I7(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(K0(o,r)&&e.ref===t.ref)if(vr=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(vr=!0);else return t.lanes=e.lanes,ws(e,t,i)}return j2(e,t,n,r,i)}function D7(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt(kc,Br),Br|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Dt(kc,Br),Br|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,Dt(kc,Br),Br|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,Dt(kc,Br),Br|=r;return nr(e,t,i,n),t.child}function T7(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function j2(e,t,n,r,i){var o=Cr(n)?vl:Gn.current;return o=Vc(t,o),Fc(t,i),n=nE(e,t,n,r,o,i),r=rE(),e!==null&&!vr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,ws(e,t,i)):(_t&&r&&K3(t),t.flags|=1,nr(e,t,n,i),t.child)}function Aw(e,t,n,r,i){if(Cr(n)){var o=!0;ug(t)}else o=!1;if(Fc(t,i),t.stateNode===null)Lp(e,t),n7(t,n,r),z2(t,n,r,i),r=!0;else if(e===null){var a=t.stateNode,s=t.memoizedProps;a.props=s;var u=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=ki(d):(d=Cr(n)?vl:Gn.current,d=Vc(t,d));var h=n.getDerivedStateFromProps,p=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(s!==r||u!==d)&&mw(t,a,r,d),eu=!1;var g=t.memoizedState;a.state=g,fg(t,r,a,i),u=t.memoizedState,s!==r||g!==u||Er.current||eu?(typeof h=="function"&&(N2(t,n,h,r),u=t.memoizedState),(s=eu||gw(t,n,s,r,g,u,d))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=d,r=s):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,e7(e,t),s=t.memoizedProps,d=t.type===t.elementType?s:Ui(t.type,s),a.props=d,p=t.pendingProps,g=a.context,u=n.contextType,typeof u=="object"&&u!==null?u=ki(u):(u=Cr(n)?vl:Gn.current,u=Vc(t,u));var m=n.getDerivedStateFromProps;(h=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(s!==p||g!==u)&&mw(t,a,r,u),eu=!1,g=t.memoizedState,a.state=g,fg(t,r,a,i);var v=t.memoizedState;s!==p||g!==v||Er.current||eu?(typeof m=="function"&&(N2(t,n,m,r),v=t.memoizedState),(d=eu||gw(t,n,d,r,g,v,u)||!1)?(h||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,v,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,v,u)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||s===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),a.props=r,a.state=v,a.context=u,r=d):(typeof a.componentDidUpdate!="function"||s===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),r=!1)}return U2(e,t,n,r,o,i)}function U2(e,t,n,r,i,o){T7(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&cw(t,n,!1),ws(e,t,o);r=t.stateNode,Yz.current=t;var s=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Jc(t,e.child,null,o),t.child=Jc(t,null,s,o)):nr(e,t,s,o),t.memoizedState=r.state,i&&cw(t,n,!0),t.child}function P7(e){var t=e.stateNode;t.pendingContext?lw(e,t.pendingContext,t.pendingContext!==t.context):t.context&&lw(e,t.context,!1),Z3(e,t.containerInfo)}function kw(e,t,n,r,i){return Gc(),G3(i),t.flags|=256,nr(e,t,n,r),t.child}var K2={dehydrated:null,treeContext:null,retryLane:0};function V2(e){return{baseLanes:e,cachePool:null,transitions:null}}function B7(e,t,n){var r=t.pendingProps,i=Vt.current,o=!1,a=(t.flags&128)!==0,s;if((s=a)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!==0),s?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Dt(Vt,i&1),e===null)return O2(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=Sm(a,r,0,null),e=hl(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=V2(n),t.memoizedState=K2,e):aE(t,a));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return qz(e,t,a,r,s,i,n);if(o){o=r.fallback,a=t.mode,i=e.child,s=i.sibling;var u={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=pu(i,u),r.subtreeFlags=i.subtreeFlags&14680064),s!==null?o=pu(s,o):(o=hl(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?V2(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=K2,r}return o=e.child,e=o.sibling,r=pu(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function aE(e,t){return t=Sm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Vf(e,t,n,r){return r!==null&&G3(r),Jc(t,e.child,null,n),e=aE(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function qz(e,t,n,r,i,o,a){if(n)return t.flags&256?(t.flags&=-257,r=gv(Error(de(422))),Vf(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=Sm({mode:"visible",children:r.children},i,0,null),o=hl(o,i,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Jc(t,e.child,null,a),t.child.memoizedState=V2(a),t.memoizedState=K2,o);if(!(t.mode&1))return Vf(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var s=r.dgst;return r=s,o=Error(de(419)),r=gv(o,r,void 0),Vf(e,t,a,r)}if(s=(a&e.childLanes)!==0,vr||s){if(r=kn,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,bs(e,i),Qi(r,e,i,-1))}return hE(),r=gv(Error(de(421))),Vf(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=lH.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,Rr=cu(i.nextSibling),zr=t,_t=!0,Wi=null,e!==null&&(oi[ai++]=us,oi[ai++]=ls,oi[ai++]=yl,us=e.id,ls=e.overflow,yl=t),t=aE(t,r.children),t.flags|=4096,t)}function Iw(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),_2(e.return,t,n)}function mv(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function M7(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(nr(e,t,r.children,n),r=Vt.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Iw(e,n,t);else if(e.tag===19)Iw(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Dt(Vt,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&pg(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),mv(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&pg(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}mv(t,!0,n,null,o);break;case"together":mv(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Lp(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ws(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Cl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(de(153));if(t.child!==null){for(e=t.child,n=pu(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=pu(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Xz(e,t,n){switch(t.tag){case 3:P7(t),Gc();break;case 5:o7(t);break;case 1:Cr(t.type)&&ug(t);break;case 4:Z3(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Dt(dg,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Dt(Vt,Vt.current&1),t.flags|=128,null):n&t.child.childLanes?B7(e,t,n):(Dt(Vt,Vt.current&1),e=ws(e,t,n),e!==null?e.sibling:null);Dt(Vt,Vt.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return M7(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Dt(Vt,Vt.current),r)break;return null;case 22:case 23:return t.lanes=0,D7(e,t,n)}return ws(e,t,n)}var $7,G2,R7,F7;$7=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};G2=function(){};R7=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,ol(No.current);var o=null;switch(n){case"input":i=p2(e,i),r=p2(e,r),o=[];break;case"select":i=Yt({},i,{value:void 0}),r=Yt({},r,{value:void 0}),o=[];break;case"textarea":i=v2(e,i),r=v2(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ag)}E2(n,r);var a;n=null;for(d in i)if(!r.hasOwnProperty(d)&&i.hasOwnProperty(d)&&i[d]!=null)if(d==="style"){var s=i[d];for(a in s)s.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(O0.hasOwnProperty(d)?o||(o=[]):(o=o||[]).push(d,null));for(d in r){var u=r[d];if(s=i!=null?i[d]:void 0,r.hasOwnProperty(d)&&u!==s&&(u!=null||s!=null))if(d==="style")if(s){for(a in s)!s.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in u)u.hasOwnProperty(a)&&s[a]!==u[a]&&(n||(n={}),n[a]=u[a])}else n||(o||(o=[]),o.push(d,n)),n=u;else d==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,s=s?s.__html:void 0,u!=null&&s!==u&&(o=o||[]).push(d,u)):d==="children"?typeof u!="string"&&typeof u!="number"||(o=o||[]).push(d,""+u):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(O0.hasOwnProperty(d)?(u!=null&&d==="onScroll"&&Bt("scroll",e),o||s===u||(o=[])):(o=o||[]).push(d,u))}n&&(o=o||[]).push("style",n);var d=o;(t.updateQueue=d)&&(t.flags|=4)}};F7=function(e,t,n,r){n!==r&&(t.flags|=4)};function Qd(e,t){if(!_t)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function jn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Zz(e,t,n){var r=t.pendingProps;switch(V3(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jn(t),null;case 1:return Cr(t.type)&&sg(),jn(t),null;case 3:return r=t.stateNode,Wc(),$t(Er),$t(Gn),eE(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Uf(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Wi!==null&&(ey(Wi),Wi=null))),G2(e,t),jn(t),null;case 5:Q3(t);var i=ol(Y0.current);if(n=t.type,e!==null&&t.stateNode!=null)R7(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(de(166));return jn(t),null}if(e=ol(No.current),Uf(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ao]=t,r[J0]=o,e=(t.mode&1)!==0,n){case"dialog":Bt("cancel",r),Bt("close",r);break;case"iframe":case"object":case"embed":Bt("load",r);break;case"video":case"audio":for(i=0;i<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Ao]=t,e[J0]=r,$7(e,t,!1,!1),t.stateNode=e;e:{switch(a=C2(n,r),n){case"dialog":Bt("cancel",e),Bt("close",e),i=r;break;case"iframe":case"object":case"embed":Bt("load",e),i=r;break;case"video":case"audio":for(i=0;iqc&&(t.flags|=128,r=!0,Qd(o,!1),t.lanes=4194304)}else{if(!r)if(e=pg(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Qd(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!_t)return jn(t),null}else 2*an()-o.renderingStartTime>qc&&n!==1073741824&&(t.flags|=128,r=!0,Qd(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=an(),t.sibling=null,n=Vt.current,Dt(Vt,r?n&1|2:n&1),t):(jn(t),null);case 22:case 23:return dE(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Br&1073741824&&(jn(t),t.subtreeFlags&6&&(t.flags|=8192)):jn(t),null;case 24:return null;case 25:return null}throw Error(de(156,t.tag))}function Qz(e,t){switch(V3(t),t.tag){case 1:return Cr(t.type)&&sg(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wc(),$t(Er),$t(Gn),eE(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Q3(t),null;case 13:if($t(Vt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(de(340));Gc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $t(Vt),null;case 4:return Wc(),null;case 10:return Y3(t.type._context),null;case 22:case 23:return dE(),null;case 24:return null;default:return null}}var Gf=!1,Kn=!1,eH=typeof WeakSet=="function"?WeakSet:Set,Se=null;function Ac(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Zt(e,t,r)}else n.current=null}function J2(e,t,n){try{n()}catch(r){Zt(e,t,r)}}var Dw=!1;function tH(e,t){if(P2=rg,e=N8(),U3(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,s=-1,u=-1,d=0,h=0,p=e,g=null;t:for(;;){for(var m;p!==n||i!==0&&p.nodeType!==3||(s=a+i),p!==o||r!==0&&p.nodeType!==3||(u=a+r),p.nodeType===3&&(a+=p.nodeValue.length),(m=p.firstChild)!==null;)g=p,p=m;for(;;){if(p===e)break t;if(g===n&&++d===i&&(s=a),g===o&&++h===r&&(u=a),(m=p.nextSibling)!==null)break;p=g,g=p.parentNode}p=m}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(B2={focusedElem:e,selectionRange:n},rg=!1,Se=t;Se!==null;)if(t=Se,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Se=e;else for(;Se!==null;){t=Se;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var E=v.memoizedProps,w=v.memoizedState,C=t.stateNode,b=C.getSnapshotBeforeUpdate(t.elementType===t.type?E:Ui(t.type,E),w);C.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var A=t.stateNode.containerInfo;A.nodeType===1?A.textContent="":A.nodeType===9&&A.documentElement&&A.removeChild(A.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(de(163))}}catch(T){Zt(t,t.return,T)}if(e=t.sibling,e!==null){e.return=t.return,Se=e;break}Se=t.return}return v=Dw,Dw=!1,v}function C0(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&J2(t,n,o)}i=i.next}while(i!==r)}}function bm(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function W2(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function L7(e){var t=e.alternate;t!==null&&(e.alternate=null,L7(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ao],delete t[J0],delete t[R2],delete t[Oz],delete t[_z])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function O7(e){return e.tag===5||e.tag===3||e.tag===4}function Tw(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||O7(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Y2(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ag));else if(r!==4&&(e=e.child,e!==null))for(Y2(e,t,n),e=e.sibling;e!==null;)Y2(e,t,n),e=e.sibling}function q2(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(q2(e,t,n),e=e.sibling;e!==null;)q2(e,t,n),e=e.sibling}var Mn=null,Ji=!1;function Ks(e,t,n){for(n=n.child;n!==null;)_7(e,t,n),n=n.sibling}function _7(e,t,n){if(_o&&typeof _o.onCommitFiberUnmount=="function")try{_o.onCommitFiberUnmount(fm,n)}catch{}switch(n.tag){case 5:Kn||Ac(n,t);case 6:var r=Mn,i=Ji;Mn=null,Ks(e,t,n),Mn=r,Ji=i,Mn!==null&&(Ji?(e=Mn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Mn.removeChild(n.stateNode));break;case 18:Mn!==null&&(Ji?(e=Mn,n=n.stateNode,e.nodeType===8?lv(e.parentNode,n):e.nodeType===1&&lv(e,n),j0(e)):lv(Mn,n.stateNode));break;case 4:r=Mn,i=Ji,Mn=n.stateNode.containerInfo,Ji=!0,Ks(e,t,n),Mn=r,Ji=i;break;case 0:case 11:case 14:case 15:if(!Kn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&J2(n,t,a),i=i.next}while(i!==r)}Ks(e,t,n);break;case 1:if(!Kn&&(Ac(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Zt(n,t,s)}Ks(e,t,n);break;case 21:Ks(e,t,n);break;case 22:n.mode&1?(Kn=(r=Kn)||n.memoizedState!==null,Ks(e,t,n),Kn=r):Ks(e,t,n);break;default:Ks(e,t,n)}}function Pw(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new eH),t.forEach(function(r){var i=cH.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function zi(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=a),r&=~o}if(r=i,r=an()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*rH(r/1960))-r,10e?16:e,ou===null)var r=!1;else{if(e=ou,ou=null,Eg=0,ut&6)throw Error(de(331));var i=ut;for(ut|=4,Se=e.current;Se!==null;){var o=Se,a=o.child;if(Se.flags&16){var s=o.deletions;if(s!==null){for(var u=0;uan()-lE?dl(e,0):uE|=n),br(e,t)}function G7(e,t){t===0&&(e.mode&1?(t=Of,Of<<=1,!(Of&130023424)&&(Of=4194304)):t=1);var n=ar();e=bs(e,t),e!==null&&(Eh(e,t,n),br(e,n))}function lH(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),G7(e,n)}function cH(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(de(314))}r!==null&&r.delete(t),G7(e,n)}var J7;J7=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Er.current)vr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return vr=!1,Xz(e,t,n);vr=!!(e.flags&131072)}else vr=!1,_t&&t.flags&1048576&&q8(t,cg,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Lp(e,t),e=t.pendingProps;var i=Vc(t,Gn.current);Fc(t,n),i=nE(null,t,r,e,i,n);var o=rE();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Cr(r)?(o=!0,ug(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,X3(t),i.updater=Em,t.stateNode=i,i._reactInternals=t,z2(t,r,e,n),t=U2(null,t,r,!0,o,n)):(t.tag=0,_t&&o&&K3(t),nr(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Lp(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=hH(r),e=Ui(r,e),i){case 0:t=j2(null,t,r,e,n);break e;case 1:t=Aw(null,t,r,e,n);break e;case 11:t=Sw(null,t,r,e,n);break e;case 14:t=xw(null,t,r,Ui(r.type,e),n);break e}throw Error(de(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),j2(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Aw(e,t,r,i,n);case 3:e:{if(P7(t),e===null)throw Error(de(387));r=t.pendingProps,o=t.memoizedState,i=o.element,e7(e,t),fg(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Yc(Error(de(423)),t),t=kw(e,t,r,n,i);break e}else if(r!==i){i=Yc(Error(de(424)),t),t=kw(e,t,r,n,i);break e}else for(Rr=cu(t.stateNode.containerInfo.firstChild),zr=t,_t=!0,Wi=null,n=i7(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Gc(),r===i){t=ws(e,t,n);break e}nr(e,t,r,n)}t=t.child}return t;case 5:return o7(t),e===null&&O2(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,a=i.children,M2(r,i)?a=null:o!==null&&M2(r,o)&&(t.flags|=32),T7(e,t),nr(e,t,a,n),t.child;case 6:return e===null&&O2(t),null;case 13:return B7(e,t,n);case 4:return Z3(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Jc(t,null,r,n):nr(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Sw(e,t,r,i,n);case 7:return nr(e,t,t.pendingProps,n),t.child;case 8:return nr(e,t,t.pendingProps.children,n),t.child;case 12:return nr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value,Dt(dg,r._currentValue),r._currentValue=a,o!==null)if(ro(o.value,a)){if(o.children===i.children&&!Er.current){t=ws(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){a=o.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=fs(-1,n&-n),u.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?u.next=u:(u.next=h.next,h.next=u),d.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),_2(o.return,n,t),s.lanes|=n;break}u=u.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(de(341));a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),_2(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}nr(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Fc(t,n),i=ki(i),r=r(i),t.flags|=1,nr(e,t,r,n),t.child;case 14:return r=t.type,i=Ui(r,t.pendingProps),i=Ui(r.type,i),xw(e,t,r,i,n);case 15:return I7(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ui(r,i),Lp(e,t),t.tag=1,Cr(r)?(e=!0,ug(t)):e=!1,Fc(t,n),n7(t,r,i),z2(t,r,i,n),U2(null,t,r,!0,e,n);case 19:return M7(e,t,n);case 22:return D7(e,t,n)}throw Error(de(156,t.tag))};function W7(e,t){return C8(e,t)}function dH(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(e,t,n,r){return new dH(e,t,n,r)}function fE(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hH(e){if(typeof e=="function")return fE(e)?1:0;if(e!=null){if(e=e.$$typeof,e===M3)return 11;if(e===$3)return 14}return 2}function pu(e,t){var n=e.alternate;return n===null?(n=Ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Np(e,t,n,r,i,o){var a=2;if(r=e,typeof e=="function")fE(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case mc:return hl(n.children,i,o,t);case B3:a=8,i|=8;break;case c2:return e=Ei(12,n,t,i|2),e.elementType=c2,e.lanes=o,e;case d2:return e=Ei(13,n,t,i),e.elementType=d2,e.lanes=o,e;case h2:return e=Ei(19,n,t,i),e.elementType=h2,e.lanes=o,e;case r8:return Sm(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case t8:a=10;break e;case n8:a=9;break e;case M3:a=11;break e;case $3:a=14;break e;case Qs:a=16,r=null;break e}throw Error(de(130,e==null?e:typeof e,""))}return t=Ei(a,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function hl(e,t,n,r){return e=Ei(7,e,r,t),e.lanes=n,e}function Sm(e,t,n,r){return e=Ei(22,e,r,t),e.elementType=r8,e.lanes=n,e.stateNode={isHidden:!1},e}function vv(e,t,n){return e=Ei(6,e,null,t),e.lanes=n,e}function yv(e,t,n){return t=Ei(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fH(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Z4(0),this.expirationTimes=Z4(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Z4(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function pE(e,t,n,r,i,o,a,s,u){return e=new fH(e,t,n,s,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ei(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},X3(o),e}function pH(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Z7)}catch(e){console.error(e)}}Z7(),qx.exports=Gr;var $u=qx.exports;const Q7=vh($u);var _w=$u;u2.createRoot=_w.createRoot,u2.hydrateRoot=_w.hydrateRoot;var EH=Object.defineProperty,CH=(e,t,n)=>t in e?EH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ze=(e,t,n)=>(CH(e,typeof t!="symbol"?t+"":t,n),n),Re=class{static clamp(t,n,r){return Math.max(n,typeof r<"u"?Math.min(t,r):t)}static clampV(t,n,r){return t.map(i=>r?Re.clamp(i,n,r):Re.clamp(i,n))}static cross(t,n,r){return(n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1])}static snap(t,n=1){return[Math.round(t[0]/n)*n,Math.round(t[1]/n)*n]}},te=Re;ze(te,"neg",e=>[-e[0],-e[1]]),ze(te,"add",(e,t)=>[e[0]+t[0],e[1]+t[1]]),ze(te,"addScalar",(e,t)=>[e[0]+t,e[1]+t]),ze(te,"sub",(e,t)=>[e[0]-t[0],e[1]-t[1]]),ze(te,"subScalar",(e,t)=>[e[0]-t,e[1]-t]),ze(te,"vec",(e,t)=>[t[0]-e[0],t[1]-e[1]]),ze(te,"mul",(e,t)=>[e[0]*t,e[1]*t]),ze(te,"mulV",(e,t)=>[e[0]*t[0],e[1]*t[1]]),ze(te,"div",(e,t)=>[e[0]/t,e[1]/t]),ze(te,"divV",(e,t)=>[e[0]/t[0],e[1]/t[1]]),ze(te,"per",e=>[e[1],-e[0]]),ze(te,"dpr",(e,t)=>e[0]*t[0]+e[1]*t[1]),ze(te,"cpr",(e,t)=>e[0]*t[1]-t[0]*e[1]),ze(te,"len2",e=>e[0]*e[0]+e[1]*e[1]),ze(te,"len",e=>Math.hypot(e[0],e[1])),ze(te,"pry",(e,t)=>Re.dpr(e,t)/Re.len(t)),ze(te,"uni",e=>Re.div(e,Re.len(e))),ze(te,"normalize",e=>Re.uni(e)),ze(te,"tangent",(e,t)=>Re.uni(Re.sub(e,t))),ze(te,"dist2",(e,t)=>Re.len2(Re.sub(e,t))),ze(te,"dist",(e,t)=>Math.hypot(e[1]-t[1],e[0]-t[0])),ze(te,"fastDist",(e,t)=>{let n=[t[0]-e[0],t[1]-e[1]],r=[Math.abs(n[0]),Math.abs(n[1])],i=1/Math.max(r[0],r[1]);return i=i*(1.29289-(r[0]+r[1])*i*.29289),[n[0]*i,n[1]*i]}),ze(te,"ang",(e,t)=>Math.atan2(Re.cpr(e,t),Re.dpr(e,t))),ze(te,"angle",(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0])),ze(te,"med",(e,t)=>Re.mul(Re.add(e,t),.5)),ze(te,"rot",(e,t=0)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)]),ze(te,"rotWith",(e,t,n=0)=>{if(n===0)return e;let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}),ze(te,"isEqual",(e,t)=>e[0]===t[0]&&e[1]===t[1]),ze(te,"lrp",(e,t,n)=>Re.add(e,Re.mul(Re.sub(t,e),n))),ze(te,"int",(e,t,n,r,i=1)=>{let o=(Re.clamp(n,r)-n)/(r-n);return Re.add(Re.mul(e,1-o),Re.mul(t,i))}),ze(te,"ang3",(e,t,n)=>{let r=Re.vec(t,e),i=Re.vec(t,n);return Re.ang(r,i)}),ze(te,"abs",e=>[Math.abs(e[0]),Math.abs(e[1])]),ze(te,"rescale",(e,t)=>{let n=Re.len(e);return[t*e[0]/n,t*e[1]/n]}),ze(te,"isLeft",(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])),ze(te,"clockwise",(e,t,n)=>Re.isLeft(e,t,n)>0),ze(te,"toFixed",e=>e.map(t=>Math.round(t*100)/100)),ze(te,"nearestPointOnLineThroughPoint",(e,t,n)=>Re.add(e,Re.mul(t,Re.pry(Re.sub(n,e),t)))),ze(te,"distanceToLineThroughPoint",(e,t,n)=>Re.dist(n,Re.nearestPointOnLineThroughPoint(e,t,n))),ze(te,"nearestPointOnLineSegment",(e,t,n,r=!0)=>{let i=Re.uni(Re.sub(t,e)),o=Re.add(e,Re.mul(i,Re.pry(Re.sub(n,e),i)));if(r){if(o[0]Math.max(e[0],t[0]))return e[0]>t[0]?e:t;if(o[1]Math.max(e[1],t[1]))return e[1]>t[1]?e:t}return o}),ze(te,"distanceToLineSegment",(e,t,n,r=!0)=>Re.dist(n,Re.nearestPointOnLineSegment(e,t,n,r))),ze(te,"nearestPointOnBounds",(e,t)=>[Re.clamp(t[0],e.minX,e.maxX),Re.clamp(t[1],e.minY,e.maxY)]),ze(te,"distanceToBounds",(e,t)=>Re.dist(t,Re.nearestPointOnBounds(e,t))),ze(te,"nudge",(e,t,n)=>Re.isEqual(e,t)?e:Re.add(e,Re.mul(Re.uni(Re.sub(t,e)),n))),ze(te,"nudgeAtAngle",(e,t,n)=>[Math.cos(t)*n+e[0],Math.sin(t)*n+e[1]]),ze(te,"toPrecision",(e,t=4)=>[+e[0].toPrecision(t),+e[1].toPrecision(t)]),ze(te,"pointsBetween",(e,t,n=6)=>Array.from(Array(n)).map((r,i)=>{let o=i/(n-1),a=Math.min(1,.5+Math.abs(.5-o));return[...Re.lrp(e,t,o),a]})),ze(te,"slope",(e,t)=>e[0]===t[0]?NaN:(e[1]-t[1])/(e[0]-t[0])),ze(te,"max",(...e)=>[Math.max(...e.map(t=>t[0])),Math.max(...e.map(t=>t[1]))]),ze(te,"min",(...e)=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1]))]);function bH(e,t,n){return Math.max(t,Math.min(e,n))}const Rt={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function Nw(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function zw(e,t,n,r=.15){return r===0?bH(e,t,n):en?+Nw(e-n,n-t,r)+n:e}function wH(e,[t,n],[r,i]){const[[o,a],[s,u]]=e;return[zw(t,o,a,r),zw(n,s,u,i)]}function cn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Gt(e){for(var t=1;t{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function PH(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function nA(e){return Dm(e)?PH(e)[0]:e}function ty(e,t){const n=t.clientX-e.clientX,r=t.clientY-e.clientY,i=(t.clientX+e.clientX)/2,o=(t.clientY+e.clientY)/2,a=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:a,origin:[i,o]}}function BH(e){return TH(e).map(t=>t.identifier)}function Uw(e,t){const[n,r]=Array.from(e.touches).filter(i=>t.includes(i.identifier));return ty(n,r)}function Ev(e){const t=nA(e);return Dm(e)?t.identifier:t.pointerId}function Xc(e){const t=nA(e);return[t.clientX,t.clientY]}const Kw=40,Vw=800;function rA(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=Kw,n*=Kw):r===2&&(t*=Vw,n*=Vw),[t,n]}function MH(e){var t,n;const{scrollX:r,scrollY:i,scrollLeft:o,scrollTop:a}=e.currentTarget;return[(t=r??o)!==null&&t!==void 0?t:0,(n=i??a)!==null&&n!==void 0?n:0]}function $H(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:i,ctrlKey:o}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:i,ctrlKey:o})}return t}function wg(e,...t){return typeof e=="function"?e(...t):e}function RH(){}function FH(...e){return e.length===0?RH:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function Gw(e,t){return Object.assign({},t,e||{})}const LH=32;class iA{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:i}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=i,t.axis=void 0,t.memo=void 0,t.elapsedTime=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?wg(r.from,n):n.offset,n.offset=n.lastOffset),n.startTime=n.timeStamp=t.timeStamp}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:i}=this;n.args=this.args;let o=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,$H(t)),i.down=i.pressed=i.buttons%2===1||i.touches>0,o=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const D=n._delta.map(Math.abs);Rt.addTo(n._distance,D)}this.axisIntent&&this.axisIntent(t);const[a,s]=n._movement,[u,d]=r.threshold,{_step:h,values:p}=n;if(r.hasCustomTransform?(h[0]===!1&&(h[0]=Math.abs(a)>=u&&p[0]),h[1]===!1&&(h[1]=Math.abs(s)>=d&&p[1])):(h[0]===!1&&(h[0]=Math.abs(a)>=u&&Math.sign(a)*u),h[1]===!1&&(h[1]=Math.abs(s)>=d&&Math.sign(s)*d)),n.intentional=h[0]!==!1||h[1]!==!1,!n.intentional)return;const g=[0,0];if(r.hasCustomTransform){const[D,I]=p;g[0]=h[0]!==!1?D-h[0]:0,g[1]=h[1]!==!1?I-h[1]:0}else g[0]=h[0]!==!1?a-h[0]:0,g[1]=h[1]!==!1?s-h[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(g);const m=n.offset,v=n._active&&!n._blocked||n.active;v&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=i[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=wg(r.bounds,n)),this.setup&&this.setup()),n.movement=g,this.computeOffset()));const[E,w]=n.offset,[[C,b],[A,T]]=n._bounds;n.overflow=[Eb?1:0,wT?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const B=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=wH(n._bounds,n.offset,B),n.delta=Rt.sub(n.offset,m),this.computeMovement(),v&&(!n.last||o>LH)){n.delta=Rt.sub(n.offset,m);const D=n.delta.map(Math.abs);Rt.addTo(n.distance,D),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[D[0]/o,D[1]/o])}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const i=this.handler(Gt(Gt(Gt({},n),t),{},{[this.aliasKey]:t.values}));i!==void 0&&(t.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function OH([e,t],n){const r=Math.abs(e),i=Math.abs(t);if(r>i&&r>n)return"x";if(i>r&&i>n)return"y"}class Sh extends iA{constructor(...t){super(...t),cn(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Rt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Rt.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const i=typeof r.axisThreshold=="object"?r.axisThreshold[tA(t)]:r.axisThreshold;n.axis=OH(n._movement,i)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const _H=e=>e,Jw=.15,oA={enabled(e=!0){return e},eventOptions(e,t,n){return Gt(Gt({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[Jw,Jw];case!1:return[0,0];default:return Rt.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Rt.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||_H},threshold(e){return Rt.toVector(e,0)}},NH=0,Ml=Gt(Gt({},oA),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=NH){return e},bounds(e={}){if(typeof e=="function")return o=>Ml.bounds(e(o));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:i=1/0}=e;return[[t,n],[r,i]]}}),Yf=10,Ww={ArrowRight:(e=1)=>[Yf*e,0],ArrowLeft:(e=1)=>[-Yf*e,0],ArrowUp:(e=1)=>[0,-Yf*e],ArrowDown:(e=1)=>[0,Yf*e]};class zH extends Sh{constructor(...t){super(...t),cn(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),i={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=Ml.bounds(i)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const i=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(i&&i.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=Ev(t),r._pointerActive=!0,this.computeValues(Xc(t)),this.computeInitial(),n.preventScrollAxis&&tA(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive||n.type===t.type&&t.timeStamp===n.timeStamp)return;const i=Ev(t);if(n._pointerId!==void 0&&i!==n._pointerId)return;const o=Xc(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Rt.sub(o,n._values),this.computeValues(o)),Rt.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const i=Ev(t);if(n._pointerId!==void 0&&i!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[o,a]=n._distance;if(n.tap=o<=r.tapsThreshold&&a<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[s,u]=n.direction,[d,h]=n.velocity,[p,g]=n.movement,[m,v]=r.swipe.velocity,[E,w]=r.swipe.distance,C=r.swipe.duration;n.elapsedTimem&&Math.abs(p)>E&&(n.swipe[0]=s),Math.abs(h)>v&&Math.abs(g)>w&&(n.swipe[1]=u))}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,HH(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=Ww[t.key];if(n){const r=this.state,i=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(i),r._keyboardActive=!0,Rt.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Ww&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function HH(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const xh=typeof window<"u"&&window.document&&window.document.createElement;function jH(){return xh&&"ontouchstart"in window}function Yw(){return jH()||xh&&window.navigator.maxTouchPoints>1}function UH(){return xh&&"onpointerdown"in window}function KH(){return xh&&"exitPointerLock"in window.document}function VH(){try{return"constructor"in GestureEvent}catch{return!1}}const si={isBrowser:xh,gesture:VH(),touch:Yw(),touchscreen:Yw(),pointer:UH(),pointerLock:KH()},GH=250,JH=180,WH=.5,YH=50,qH=250,qw={mouse:0,touch:0,pen:8},XH=Gt(Gt({},Ml),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:i=!1}={}}){return this.pointerLock=r&&si.pointerLock,si.touch&&n?"touch":this.pointerLock?"mouse":si.pointer&&!i?"pointer":si.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?GH:void 0,!(!si.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:i=!0}={}}){return this.pointerButtons=r,this.keys=i,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:i=void 0}){const o=Rt.toVector(e,n?r:i?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:e=WH,distance:t=YH,duration:n=qH}={}){return{velocity:this.transform(Rt.toVector(e)),distance:this.transform(Rt.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return JH;case!1:return 0;default:return e}},axisThreshold(e){return e?Gt(Gt({},qw),e):qw}});function aA(e){const[t,n]=e.overflow,[r,i]=e._delta,[o,a]=e._direction;(t<0&&r>0&&o<0||t>0&&r<0&&o>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&i>0&&a<0||n>0&&i<0&&a>0)&&(e._movement[1]=e._movementBound[1])}const ZH=30,QH=100;class ej extends iA{constructor(...t){super(...t),cn(this,"ingKey","pinching"),cn(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=Rt.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const i=Math.abs(n)*ZH-Math.abs(r);i<0?t.axis="angle":i>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(o=>r.has(o))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const i=Uw(t,n._touchIds);this.pinchStart(t,i)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,i=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(a=>i.has(a))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const o=ty(...Array.from(r.values()));this.pinchStart(t,o)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=Uw(t,this.state._touchIds);this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=ty(...Array.from(n.values()));this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,i=r._values[1],o=n.angle-i;let a=0;Math.abs(o)>270&&(a+=Math.sign(o)),this.computeValues([n.distance,n.angle-360*a]),r.origin=n.origin,r.turns=a,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=Rt.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&!t[n]||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-rA(t)[1]/QH*r.offset[0],0],Rt.addTo(r._movement,r._delta),aA(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const tj=Gt(Gt({},oA),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!si.touch&&si.gesture)return"gesture";if(si.touch&&r)return"touch";if(si.touchscreen){if(si.pointer)return"pointer";if(si.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const i=a=>{const s=Gw(wg(n,a),{min:-1/0,max:1/0});return[s.min,s.max]},o=a=>{const s=Gw(wg(r,a),{min:-1/0,max:1/0});return[s.min,s.max]};return typeof n!="function"&&typeof r!="function"?[i(),o()]:a=>[i(a),o(a)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Rt.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class nj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(Xc(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const n=Xc(t),r=this.state;r._delta=Rt.sub(n,r._values),Rt.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const rj=Gt(Gt({},Ml),{},{mouseOnly:(e=!0)=>e});class ij extends Sh{constructor(...t){super(...t),cn(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const n=this.state,r=MH(t);n._delta=Rt.sub(r,n._values),Rt.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const oj=Ml;class aj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=rA(t),Rt.addTo(n._movement,n._delta),aA(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const sj=Ml;class uj extends Sh{constructor(...t){super(...t),cn(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Xc(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=Xc(t);n._movement=n._delta=Rt.sub(r,n._values),this.computeValues(r),this.compute(t),n.delta=n.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const lj=Gt(Gt({},Ml),{},{mouseOnly:(e=!0)=>e}),yE=new Map,ny=new Map;function cj(e){yE.set(e.key,e.engine),ny.set(e.key,e.resolver)}const dj={key:"drag",engine:zH,resolver:XH},hj={key:"hover",engine:uj,resolver:lj},fj={key:"move",engine:nj,resolver:rj},pj={key:"pinch",engine:ej,resolver:tj},gj={key:"scroll",engine:ij,resolver:oj},mj={key:"wheel",engine:aj,resolver:sj};function vj(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o=0)&&(n[i]=e[i]);return n}function yj(e,t){if(e==null)return{};var n=vj(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const Ej={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=si.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},Cj=["target","eventOptions","window","enabled","transform"];function zp(e={},t){const n={};for(const[r,i]of Object.entries(t))switch(typeof i){case"function":n[r]=i.call(n,e[r],r,e);break;case"object":n[r]=zp(e[r],i);break;case"boolean":i&&(n[r]=e[r]);break}return n}function bj(e,t,n={}){const r=e,{target:i,eventOptions:o,window:a,enabled:s,transform:u}=r,d=yj(r,Cj);if(n.shared=zp({target:i,eventOptions:o,window:a,enabled:s,transform:u},Ej),t){const h=ny.get(t);n[t]=zp(Gt({shared:n.shared},d),h)}else for(const h in d){const p=ny.get(h);p&&(n[h]=zp(Gt({shared:n.shared},d[h]),p))}return n}class sA{constructor(t,n){cn(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,i,o){const a=this._listeners,s=DH(n,r),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=Gt(Gt({},u),o);t.addEventListener(s,i,d);const h=()=>{t.removeEventListener(s,i,d),a.delete(h)};return a.add(h),h}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class wj{constructor(){cn(this,"_timeouts",new Map)}add(t,n,r=140,...i){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...i))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class Sj{constructor(t){cn(this,"gestures",new Set),cn(this,"_targetEventStore",new sA(this)),cn(this,"gestureEventStores",{}),cn(this,"gestureTimeoutStores",{}),cn(this,"handlers",{}),cn(this,"config",{}),cn(this,"pointerIds",new Set),cn(this,"touchIds",new Set),cn(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),xj(this,t)}setEventIds(t){if(Dm(t))return this.touchIds=new Set(BH(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=bj(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let i;if(!(n.target&&(i=n.target(),!i))){if(n.enabled){for(const a of this.gestures){const s=this.config[a],u=Xw(r,s.eventOptions,!!i);if(s.enabled){const d=yE.get(a);new d(this,t,a).bind(u)}}const o=Xw(r,n.eventOptions,!!i);for(const a in this.nativeHandlers)o(a,"",s=>this.nativeHandlers[a](Gt(Gt({},this.state.shared),{},{event:s,args:t})),void 0,!0)}for(const o in r)r[o]=FH(...r[o]);if(!i)return r;for(const o in r){const{device:a,capture:s,passive:u}=IH(o);this._targetEventStore.add(i,a,"",r[o],{capture:s,passive:u})}}}}function tc(e,t){e.gestures.add(t),e.gestureEventStores[t]=new sA(e,t),e.gestureTimeoutStores[t]=new wj}function xj(e,t){t.drag&&tc(e,"drag"),t.wheel&&tc(e,"wheel"),t.scroll&&tc(e,"scroll"),t.move&&tc(e,"move"),t.pinch&&tc(e,"pinch"),t.hover&&tc(e,"hover")}const Xw=(e,t,n)=>(r,i,o,a={},s=!1)=>{var u,d;const h=(u=a.capture)!==null&&u!==void 0?u:t.capture,p=(d=a.passive)!==null&&d!==void 0?d:t.passive;let g=s?r:AH(r,i,h);n&&p&&(g+="Passive"),e[g]=e[g]||[],e[g].push(o)},Aj=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function kj(e){const t={},n={},r=new Set;for(let i in e)Aj.test(i)?(r.add(RegExp.lastMatch),n[i]=e[i]):t[i]=e[i];return[n,t,r]}function nc(e,t,n,r,i,o){if(!e.has(n)||!yE.has(r))return;const a=n+"Start",s=n+"End",u=d=>{let h;return d.first&&a in t&&t[a](d),n in t&&(h=t[n](d)),d.last&&s in t&&t[s](d),h};i[r]=u,o[r]=o[r]||{}}function Ij(e,t){const[n,r,i]=kj(e),o={};return nc(i,n,"onDrag","drag",o,t),nc(i,n,"onWheel","wheel",o,t),nc(i,n,"onScroll","scroll",o,t),nc(i,n,"onPinch","pinch",o,t),nc(i,n,"onMove","move",o,t),nc(i,n,"onHover","hover",o,t),{handlers:o,config:t,nativeHandlers:r}}function Dj(e,t={},n,r){const i=Kt.useMemo(()=>new Sj(e),[]);if(i.applyHandlers(e,r),i.applyConfig(t,n),Kt.useEffect(i.effect.bind(i)),Kt.useEffect(()=>i.clean.bind(i),[]),t.target===void 0)return i.bind.bind(i)}function Tj(e){return e.forEach(cj),function(n,r){const{handlers:i,nativeHandlers:o,config:a}=Ij(n,r||{});return Dj(i,a,void 0,o)}}function Pj(e,t){return Tj([dj,pj,gj,mj,fj,hj])(e,t||{})}function Zw(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}function Bj(e){return[-e[0],-e[1]]}function Ki(e,t){return[e[0]+t[0],e[1]+t[1]]}function ii(e,t){return[e[0]-t[0],e[1]-t[1]]}function ji(e,t){return[e[0]*t,e[1]*t]}function Mj(e,t){return[e[0]/t,e[1]/t]}function t0(e){return[e[1],-e[0]]}function Qw(e,t){return e[0]*t[0]+e[1]*t[1]}function $j(e,t){return e[0]===t[0]&&e[1]===t[1]}function Rj(e){return Math.hypot(e[0],e[1])}function Fj(e){return e[0]*e[0]+e[1]*e[1]}function e6(e,t){return Fj(ii(e,t))}function uA(e){return Mj(e,Rj(e))}function Lj(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function n0(e,t,n){let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}function ry(e,t,n){return Ki(e,ji(ii(t,e),n))}function t6(e,t,n){return Ki(e,ji(t,n))}var{min:rc,PI:Oj}=Math,n6=.275,r0=Oj+1e-4;function EE(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:o=!0,easing:a=W=>W,start:s={},end:u={},last:d=!1}=t,{cap:h=!0,easing:p=W=>W*(2-W)}=s,{cap:g=!0,easing:m=W=>--W*W*W+1}=u;if(e.length===0||n<=0)return[];let v=e[e.length-1].runningLength,E=s.taper===!1?0:s.taper===!0?Math.max(n,v):s.taper,w=u.taper===!1?0:u.taper===!0?Math.max(n,v):u.taper,C=Math.pow(n*r,2),b=[],A=[],T=e.slice(0,10).reduce((W,U)=>{let ne=U.pressure;if(o){let le=rc(1,U.distance/n),Ae=rc(1,1-le);ne=rc(1,W+(Ae-W)*(le*n6))}return(W+ne)/2},e[0].pressure),B=Zw(n,i,e[e.length-1].pressure,a),D,I=e[0].vector,M=e[0].point,O=M,z=M,K=O,X=!1;for(let W=0;WC)&&(b.push(z),M=z),K=Ki(ne,pn),(W<=1||e6(O,K)>C)&&(A.push(K),O=K),T=U,I=le}let Z=e[0].point.slice(0,2),pe=e.length>1?e[e.length-1].point.slice(0,2):Ki(e[0].point,[1,1]),me=[],Ce=[];if(e.length===1){if(!(E||w)||d){let W=t6(Z,uA(t0(ii(Z,pe))),-(D||B)),U=[];for(let ne=1/13,le=ne;le<=1;le+=ne)U.push(n0(W,Z,r0*2*le));return U}}else{if(!(E||w&&e.length===1))if(h)for(let U=1/13,ne=U;ne<=1;ne+=U){let le=n0(A[0],Z,r0*ne);me.push(le)}else{let U=ii(b[0],A[0]),ne=ji(U,.5),le=ji(U,.51);me.push(ii(Z,ne),ii(Z,le),Ki(Z,le),Ki(Z,ne))}let W=t0(Bj(e[e.length-1].vector));if(w||E&&e.length===1)Ce.push(pe);else if(g){let U=t6(pe,W,B);for(let ne=1/29,le=ne;le<1;le+=ne)Ce.push(n0(U,pe,r0*3*le))}else Ce.push(Ki(pe,ji(W,B)),Ki(pe,ji(W,B*.99)),ii(pe,ji(W,B*.99)),ii(pe,ji(W,B)))}return b.concat(Ce,A.reverse(),me)}function vd(e,t={}){var n;let{streamline:r=.5,size:i=16,last:o=!1}=t;if(e.length===0)return[];let a=.15+(1-r)*.85,s=Array.isArray(e[0])?e:e.map(({x:m,y:v,pressure:E=.5})=>[m,v,E]);if(s.length===2){let m=s[1];s=s.slice(0,-1);for(let v=1;v<5;v++)s.push(ry(s[0],m,v/4))}s.length===1&&(s=[...s,[...Ki(s[0],[1,1]),...s[0].slice(2)]]);let u=[{point:[s[0][0],s[0][1]],pressure:s[0][2]>=0?s[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=!1,h=0,p=u[0],g=s.length-1;for(let m=1;m=0?s[m][2]:.5,vector:uA(ii(p.point,v)),distance:E,runningLength:h},u.push(p)}return u[0].vector=((n=u[1])==null?void 0:n.vector)||[0,0],u}function _j(e,t={}){return EE(vd(e,t),t)}var Ah=_j;function al(e,...t){return{didIntersect:t.length>0,message:e,points:t}}function Nj(e,t,n=0){let r=[e[0]+t[0]/2,e[1]+t[1]/2],i=te.rotWith(e,r,n),o=te.rotWith(te.add(e,[t[0],0]),r,n),a=te.rotWith(te.add(e,t),r,n),s=te.rotWith(te.add(e,[0,t[1]]),r,n);return[["top",[i,o]],["right",[o,a]],["bottom",[a,s]],["left",[s,i]]]}function zj(e,t,n,r){let i=te.sub(e,n),o=te.sub(r,n),a=te.sub(t,e),s=o[0]*i[1]-o[1]*i[0],u=a[0]*i[1]-a[1]*i[0],d=o[1]*a[0]-o[0]*a[1];if(s===0||u===0)return al("coincident");if(d===0)return al("parallel");if(d!==0){let h=s/d,p=u/d;if(0<=h&&h<=1&&0<=p&&p<=1)return al("intersection",te.add(e,te.mul(a,h)))}return al("no intersection")}function Hj(e,t,n){let r=[];for(let i=1;i{let s=Hj(o,a,n);return s.didIntersect&&r.push(al(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function Uj(e,t){return jj([t.minX,t.minY],[t.width,t.height],e)}var Kj=Object.defineProperty,Vj=Object.defineProperties,Gj=Object.getOwnPropertyDescriptors,Sg=Object.getOwnPropertySymbols,lA=Object.prototype.hasOwnProperty,cA=Object.prototype.propertyIsEnumerable,iy=(e,t,n)=>t in e?Kj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t)=>{for(var n in t||(t={}))lA.call(t,n)&&iy(e,n,t[n]);if(Sg)for(var n of Sg(t))cA.call(t,n)&&iy(e,n,t[n]);return e},Io=(e,t)=>Vj(e,Gj(t)),yd=(e,t)=>{var n={};for(var r in e)lA.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Sg)for(var r of Sg(e))t.indexOf(r)<0&&cA.call(e,r)&&(n[r]=e[r]);return n},Ot=(e,t,n)=>(iy(e,typeof t!="symbol"?t+"":t,n),n),CE=l.createContext({});function Jn(){return l.useContext(CE)}var Jj=(e=>(e.TransformSelected="transform_selected",e.TranslateSelected="translate_selected",e.TransformAll="transform_all",e.TranslateAll="translate_all",e))(Jj||{}),Wj=(e=>(e.Top="top_edge",e.Right="right_edge",e.Bottom="bottom_edge",e.Left="left_edge",e))(Wj||{}),Yi=(e=>(e.TopLeft="top_left_corner",e.TopRight="top_right_corner",e.BottomRight="bottom_right_corner",e.BottomLeft="bottom_left_corner",e))(Yi||{}),Yj=(e=>(e.minX="minX",e.midX="midX",e.maxX="maxX",e.minY="minY",e.midY="midY",e.maxY="maxY",e))(Yj||{});String.prototype.replaceAll||(String.prototype.replaceAll=function(e,t){return Object.prototype.toString.call(e).toLowerCase()==="[object regexp]"?this.replace(e,t):this.replace(new RegExp(e,"g"),t)});var qf=Math.PI*2,vn=class{static lerp(t,n,r){return r=vn.clamp(r,0,1),t*(1-r)+n*r}static lerpColor(t,n,r=.5){function i(d){let h=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(d);return[parseInt(h[1],16),parseInt(h[2],16),parseInt(h[3],16)]}function o(d){return"#"+((1<<24)+(d[0]<<16)+(d[1]<<8)+d[2]).toString(16).slice(1)}let a=i(t)||[0,0,0],s=i(n)||[0,0,0],u=a.slice();for(let d=0;d<3;d++)u[d]=Math.round(u[d]+r*(s[d]-a[d]));return o(u)}static modulate(t,n,r,i=!1){let[o,a]=n,[s,u]=r,d=s+(t-o)/(a-o)*(u-s);return i?sn[r]=typeof t[r]=="object"?vn.deepClone(t[r]):t[r]),n}return t}static rng(t=""){let n=0,r=0,i=0,o=0;function a(){let s=n^n<<11;return n=r,r=i,i=o,o^=(o>>>19^s^s>>>8)>>>0,o/4294967296}for(let s=0;si}static degreesToRadians(t){return t*Math.PI/180}static radiansToDegrees(t){return t*180/Math.PI}static getArcLength(t,n,r,i){let o=vn.getSweep(t,r,i);return n*(2*Math.PI)*(o/(2*Math.PI))}static getSweepFlag(t,n,r){let i=te.angle(t,r);return(te.angle(t,n)-i+3*Math.PI)%(2*Math.PI)-Math.PI>0?0:1}static getLargeArcFlag(t,n,r){let i=te.angle(r,t),o=(te.angle(r,n)-i+3*Math.PI)%(2*Math.PI)-Math.PI;return Math.abs(o)>Math.PI/2?0:1}static getArcDashOffset(t,n,r,i,o){let a=vn.getSweepFlag(t,r,i),s=vn.getArcLength(t,n,r,i);return-(a<0?s:2*Math.PI*t[2]-s)/2+o}static getEllipseDashOffset(t,n){return-(2*Math.PI*t[2])/2+-n}static pointInCircle(t,n,r){return te.dist(t,n)<=r}static pointInEllipse(t,n,r,i,o=0){o=o||0;let a=Math.cos(o),s=Math.sin(o),u=te.sub(t,n),d=a*u[0]+s*u[1],h=s*u[0]-a*u[1];return d*d/(r*r)+h*h/(i*i)<=1}static pointInRect(t,n){return!(t[0]t[0]+n[0]||t[1]t[1]+n[1])}static pointInPolygon(t,n){let r=0;return n.forEach((i,o)=>{let a=n[(o+1)%n.length];i[1]<=t[1]?a[1]>t[1]&&te.cross(i,a,t)>0&&(r+=1):a[1]<=t[1]&&te.cross(i,a,t)<0&&(r-=1)}),r!==0}static pointInBounds(t,n){return!(t[0]n.maxX||t[1]n.maxY)}static pointInPolyline(t,n,r=3){for(let i=1;in.maxX||t.maxYn.maxY)}static boundsContain(t,n){return t.minXn.maxY&&t.maxX>n.maxX}static boundsContained(t,n){return vn.boundsContain(n,t)}static boundsAreEqual(t,n){return!(n.maxX!==t.maxX||n.minX!==t.minX||n.maxY!==t.maxY||n.minY!==t.minY)}static getBoundsFromPoints(t,n=0){let r=1/0,i=1/0,o=-1/0,a=-1/0;if(t.length<2)r=0,i=0,o=1,a=1;else for(let[s,u]of t)r=Math.min(s,r),i=Math.min(u,i),o=Math.max(s,o),a=Math.max(u,a);return n!==0?vn.getBoundsFromPoints(t.map(s=>te.rotWith(s,[(r+o)/2,(i+a)/2],n))):{minX:r,minY:i,maxX:o,maxY:a,width:Math.max(1,o-r),height:Math.max(1,a-i)}}static centerBounds(t,n){let r=this.getBoundsCenter(t),i=n[0]-r[0],o=n[1]-r[1];return this.translateBounds(t,[i,o])}static snapBoundsToGrid(t,n){let r=Math.round(t.minX/n)*n,i=Math.round(t.minY/n)*n,o=Math.round(t.maxX/n)*n,a=Math.round(t.maxY/n)*n;return{minX:r,minY:i,maxX:o,maxY:a,width:Math.max(1,o-r),height:Math.max(1,a-i)}}static translateBounds(t,n){return{minX:t.minX+n[0],minY:t.minY+n[1],maxX:t.maxX+n[0],maxY:t.maxY+n[1],width:t.width,height:t.height}}static rotateBounds(t,n,r){let[i,o]=te.rotWith([t.minX,t.minY],n,r),[a,s]=te.rotWith([t.maxX,t.maxY],n,r);return{minX:i,minY:o,maxX:a,maxY:s,width:t.width,height:t.height}}static getRotatedEllipseBounds(t,n,r,i,o=0){let a=Math.cos(o),s=Math.sin(o),u=Math.hypot(r*a,i*s),d=Math.hypot(r*s,i*a);return{minX:t+r-u,minY:n+i-d,maxX:t+r+u,maxY:n+i+d,width:u*2,height:d*2}}static getExpandedBounds(t,n){let r=Math.min(t.minX,n.minX),i=Math.min(t.minY,n.minY),o=Math.max(t.maxX,n.maxX),a=Math.max(t.maxY,n.maxY),s=Math.abs(o-r),u=Math.abs(a-i);return{minX:r,minY:i,maxX:o,maxY:a,width:s,height:u}}static getCommonBounds(t){if(t.length<2)return t[0];let n=t[0];for(let r=1;rte.rotWith(i,r,n))}static getTransformedBoundingBox(t,n,r,i=0,o=!1){let[a,s]=[t.minX,t.minY],[u,d]=[t.maxX,t.maxY],[h,p]=[t.minX,t.minY],[g,m]=[t.maxX,t.maxY];if(n==="center")return{minX:h+r[0],minY:p+r[1],maxX:g+r[0],maxY:m+r[1],width:g-h,height:m-p,scaleX:1,scaleY:1};let[v,E]=te.rot(r,-i);switch(n){case"top_edge":case"top_left_corner":case"top_right_corner":{p+=E;break}case"bottom_edge":case"bottom_left_corner":case"bottom_right_corner":{m+=E;break}}switch(n){case"left_edge":case"top_left_corner":case"bottom_left_corner":{h+=v;break}case"right_edge":case"top_right_corner":case"bottom_right_corner":{g+=v;break}}let w=u-a,C=d-s,b=(g-h)/w,A=(m-p)/C,T=b<0,B=A<0,D=Math.abs(g-h),I=Math.abs(m-p);if(o){let M=w/C,O=Mte.rotWith(a,r,n)),o=vn.getBoundsFromPoints(i);return[o.width,o.height]}static getBoundsCenter(t){return[t.minX+t.width/2,t.minY+t.height/2]}static getBoundsWithCenter(t){let n=vn.getBoundsCenter(t);return Io(lt({},t),{midX:n[0],midY:n[1]})}static getCommonTopLeft(t){let n=[1/0,1/0];return t.forEach(r=>{n[0]=Math.min(n[0],r[0]),n[1]=Math.min(n[1],r[1])}),n}static getFromCache(t,n,r){let i=t.get(n);if(i===void 0&&(t.set(n,r()),i=t.get(n),i===void 0))throw Error("Cache did not include item!");return i}static uniqueId(t=""){return t?((Number(t)^Math.random()*16)>>Number(t)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,vn.uniqueId)}static rotateArray(t,n){return t.map((r,i)=>t[(i+n)%t.length])}static debounce(t,n=0){let r;return function(...i){clearTimeout(r),r=setTimeout(()=>t.apply(i),n)}}static getSvgPathFromStroke(t,n=!0){let r=t.length;if(r<4)return"";let i=t[0],o=t[1],a=t[2],s=`M${i[0].toFixed(2)},${i[1].toFixed(2)} Q${o[0].toFixed(2)},${o[1].toFixed(2)} ${Vs(o[0],a[0]).toFixed(2)},${Vs(o[1],a[1]).toFixed(2)} T`;for(let u=2,d=r-1;u"u")return!1;let t=window.navigator.userAgent,n=!!t.match(/iPad/i)||!!t.match(/iPhone/i),r=!!t.match(/WebKit/i);return n&&r&&!t.match(/CriOS/i)}static throttle(t,n){let r,i;return function(...o){return r||(r=!0,setTimeout(()=>r=!1,n),i=t(...o)),i}}static isDarwin(){return/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)}static metaKey(t){return vn.isDarwin()?t.metaKey:t.ctrlKey}static lns(t){let n=t.split("");return n.push(...n.splice(0,Math.round(n.length/5))),n.push(...n.splice(0,Math.round(n.length/4))),n.push(...n.splice(0,Math.round(n.length/3))),n.push(...n.splice(0,Math.round(n.length/2))),n.reverse().map(r=>+r?+r<5?5+ +r:+r>5?+r-5:r:r).join("")}},N=vn;Ot(N,"getSnapPoints",(e,t,n)=>{let r=lt({},e),i=[0,0],o=[],a={minX:{id:"minX",isSnapped:!1},midX:{id:"midX",isSnapped:!1},maxX:{id:"maxX",isSnapped:!1},minY:{id:"minY",isSnapped:!1},midY:{id:"midY",isSnapped:!1},maxY:{id:"maxY",isSnapped:!1}},s=["midX","minX","maxX"],u=["midY","minY","maxY"],d=t.map(v=>{let E=s.flatMap((C,b)=>s.map((A,T)=>{let B=r[C]-v[A],D=Math.abs(B);return{f:C,t:A,gap:B,distance:D,isCareful:b===0||b+T===3}})),w=u.flatMap((C,b)=>u.map((A,T)=>{let B=r[C]-v[A],D=Math.abs(B);return{f:C,t:A,gap:B,distance:D,isCareful:b===0||b+T===3}}));return[v,E,w]}),h=1/0,p=1/0,g=1/0,m=1/0;return d.forEach(([v,E,w])=>{E.forEach(C=>{C.distance{C.distance{h!==1/0&&E.forEach(C=>{Math.abs(C.gap-h)<2&&(a[C.f]=Io(lt({},a[C.f]),{isSnapped:!0,to:v[C.t],B:v,distance:C.distance}))}),p!==1/0&&w.forEach(C=>{Math.abs(C.gap-p)<2&&(a[C.f]=Io(lt({},a[C.f]),{isSnapped:!0,to:v[C.t],B:v,distance:C.distance}))})}),i[0]=h===1/0?0:h,i[1]=p===1/0?0:p,r.minX-=i[0],r.midX-=i[0],r.maxX-=i[0],r.minY-=i[1],r.midY-=i[1],r.maxY-=i[1],s.forEach(v=>{let E=a[v];if(!E.isSnapped)return;let{id:w,B:C}=E,b=r[w];o.push(w==="minX"?[[b,r.midY],[b,C.minY],[b,C.maxY]]:[[b,r.minY],[b,r.maxY],[b,C.minY],[b,C.maxY]])}),u.forEach(v=>{let E=a[v];if(!E.isSnapped)return;let{id:w,B:C}=E,b=r[w];o.push(w==="midY"?[[r.midX,b],[C.minX,b],[C.maxX,b]]:[[r.minX,b],[r.maxX,b],[C.minX,b],[C.maxX,b]])}),{offset:i,snapLines:o}}),Ot(N,"deepMerge",(e,t)=>{let n=lt({},e),r=Object.entries(t);for(let[i,o]of r)n[i]=o===Object(o)&&!Array.isArray(o)?vn.deepMerge(n[i],o):o;return n});function Vs(e,t){return(e+t)/2}var Fr=N;function qj(e,t){let n=l.useRef(void 0),r=l.useRef(void 0),i=l.useRef([0,0]),o=l.useRef(0),{inputs:a,bounds:s,callbacks:u}=Jn();l.useEffect(()=>{let m=v=>v.preventDefault();return document.addEventListener("gesturestart",m),document.addEventListener("gesturechange",m),()=>{document.removeEventListener("gesturestart",m),document.removeEventListener("gesturechange",m)}},[]);let d=l.useCallback(({event:m})=>{var v,E,w,C;if(m.preventDefault(),a.isPinching||m.timeStamp<=o.current)return;o.current=m.timeStamp;let[b,A,T]=Xj(m);if((m.altKey||m.ctrlKey||m.metaKey)&&m.buttons===0){let I=[...(E=(v=a.pointer)==null?void 0:v.point)!=null?E:[s.width/2,s.height/2],T*.618],M=a.pan(I,m);(w=u.onZoom)==null||w.call(u,Io(lt({},M),{delta:I}),m);return}let B=te.mul(m.shiftKey&&!Fr.isDarwin()?[A,0]:[b,A],.5);if(te.isEqual(B,[0,0]))return;let D=a.pan(B,m);(C=u.onPan)==null||C.call(u,D,m)},[u,a,s]),h=l.useCallback(({origin:m,event:v})=>{var E;if(v instanceof WheelEvent)return;let w=t.current;if(!w||!(v.target===w||w.contains(v.target)))return;let C=a.pinch(m,m);a.isPinching=!0,(E=u.onPinchStart)==null||E.call(u,C,v),r.current=C.point,n.current=C.origin,i.current=[0,0]},[u,a,s]),p=l.useCallback(({origin:m,offset:v,event:E})=>{var w;if(E instanceof WheelEvent)return;let C=t.current;if(!(E.target===C||C!=null&&C.contains(E.target))||!n.current)return;let b=a.pinch(m,n.current),A=te.sub(b.delta,i.current);i.current=b.delta,(w=u.onPinch)==null||w.call(u,Io(lt({},b),{point:b.point,origin:n.current,delta:[...A,v[0]]}),E),r.current=m},[u,a,s]),g=l.useCallback(({origin:m,event:v})=>{var E;let w=t.current;if(!(v.target===w||w!=null&&w.contains(v.target)))return;let C=a.pinch(m,m);a.isPinching=!1,(E=u.onPinchEnd)==null||E.call(u,C,v),r.current=void 0,n.current=void 0,i.current=[0,0]},[]);Pj({onWheel:d,onPinchStart:h,onPinch:p,onPinchEnd:g},{target:t,eventOptions:{passive:!1},pinch:{from:[e.current,0],scaleBounds:()=>({from:e.current,max:5,min:.1})}})}var r6=10;function Xj(e){let{deltaY:t,deltaX:n}=e,r=0;if(e.ctrlKey||e.metaKey){let i=Math.sign(e.deltaY),o=Math.abs(e.deltaY),a=t;o>r6&&(a=r6*i),r=a}return[n,t,r]}function Zj(){let{callbacks:e}=Jn();l.useEffect(()=>{function t(){var n;(n=e.onShapeBlur)==null||n.call(e)}return Fr.isMobileSafari()?(document.addEventListener("focusout",t),()=>document.removeEventListener("focusout",t)):()=>null},[e])}function Qj(){let{callbacks:e,inputs:t}=Jn();return l.useMemo(()=>({onPointerDown:n=>{var r,i,o;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;if(n.currentTarget.setPointerCapture(n.pointerId),n.button===2){(r=e.onRightPointCanvas)==null||r.call(e,t.pointerDown(n,"canvas"),n);return}let a=t.pointerDown(n,"canvas");n.button===0&&((i=e.onPointCanvas)==null||i.call(e,a,n)),(o=e.onPointerDown)==null||o.call(e,a,n)},onPointerMove:n=>{var r,i;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;let o=t.pointerMove(n,"canvas");n.buttons===1&&n.currentTarget.hasPointerCapture(n.pointerId)&&((r=e.onDragCanvas)==null||r.call(e,o,n)),(i=e.onPointerMove)==null||i.call(e,o,n)},onPointerUp:n=>{var r,i,o,a,s;if(n.dead||(n.dead=!0,t.activePointer=void 0,!t.pointerIsValid(n)))return;let u=t.isDoubleClick(),d=t.pointerUp(n,"canvas");if(n.button===2){(r=e.onPointerUp)==null||r.call(e,d,n);return}n.currentTarget.hasPointerCapture(n.pointerId)&&((i=n.currentTarget)==null||i.releasePointerCapture(n.pointerId)),n.button===0&&(u&&!(d.altKey||d.metaKey)&&((o=e.onDoubleClickCanvas)==null||o.call(e,d,n)),(a=e.onReleaseCanvas)==null||a.call(e,d,n)),(s=e.onPointerUp)==null||s.call(e,d,n)},onDrop:e.onDrop,onDragOver:e.onDragOver}),[e,t])}function eU(e){let{rPageState:t,rSelectionBounds:n,callbacks:r,inputs:i}=l.useContext(CE);return l.useMemo(()=>({onPointerDown:o=>{var a,s,u,d,h,p,g;if(o.dead||(o.dead=!0,!i.pointerIsValid(o)))return;if(o.button===2){(a=r.onRightPointShape)==null||a.call(r,i.pointerDown(o,e),o);return}let m=i.pointerDown(o,e);if((s=o.currentTarget)==null||s.setPointerCapture(o.pointerId),n.current&&N.pointInBounds(m.point,n.current)&&!t.current.selectedIds.includes(e)){o.button===0&&((u=r.onPointBounds)==null||u.call(r,i.pointerDown(o,"bounds"),o),(d=r.onPointShape)==null||d.call(r,m,o)),(h=r.onPointerDown)==null||h.call(r,m,o);return}o.button===0&&((p=r.onPointShape)==null||p.call(r,m,o)),(g=r.onPointerDown)==null||g.call(r,m,o)},onPointerUp:o=>{var a,s,u,d;if(o.dead||(o.dead=!0,!i.pointerIsValid(o))||o.button===2)return;i.activePointer=void 0;let h=i.isDoubleClick(),p=i.pointerUp(o,e);o.pointerId&&o.currentTarget.hasPointerCapture(o.pointerId)&&((a=o.currentTarget)==null||a.releasePointerCapture(o.pointerId)),o.button===0&&(h&&!(p.altKey||p.metaKey)&&((s=r.onDoubleClickShape)==null||s.call(r,p,o)),(u=r.onReleaseShape)==null||u.call(r,p,o)),(d=r.onPointerUp)==null||d.call(r,p,o)},onPointerMove:o=>{var a,s;if(o.dead||(o.dead=!0,o.buttons===2||!i.pointerIsValid(o)||i.pointer&&o.pointerId!==i.pointer.pointerId))return;let u=i.pointerMove(o,e);o.buttons===1&&o.currentTarget.hasPointerCapture(o.pointerId)&&((a=r.onDragShape)==null||a.call(r,u,o)),(s=r.onPointerMove)==null||s.call(r,u,o)},onPointerEnter:o=>{var a;if(!i.pointerIsValid(o))return;let s=i.pointerEnter(o,e);(a=r.onHoverShape)==null||a.call(r,s,o)},onPointerLeave:o=>{var a;if(!i.pointerIsValid(o))return;let s=i.pointerEnter(o,e);(a=r.onUnhoverShape)==null||a.call(r,s,o)}}),[i,r,e])}function dA(e,t,n,r,i,o=!1,a=!1,s,u){let d={shape:e,asset:e.assetId?i[e.assetId]:void 0,meta:s,isChildOfSelected:a,isGhost:e.isGhost||o,isEditing:r.editingId===e.id,isBinding:u===e.id,isSelected:r.selectedIds.includes(e.id),isHovered:r.hoveredId===e.id||e.children!==void 0&&(r.hoveredId&&e.children.includes(r.hoveredId)||e.children.some(h=>r.selectedIds.includes(h)))};t.push(d),e.children&&(d.children=[],e.children.map(h=>n[h]).filter(h=>n[h.id]).sort((h,p)=>h.childIndex-p.childIndex).forEach(h=>dA(h,d.children,n,r,i,d.isGhost,d.isSelected||d.isChildOfSelected,s)))}function tU(e,t){return N.boundsContain(t,e)||N.boundsCollide(t,e)}function nU(e,t,n,r){let{callbacks:i,shapeUtils:o,bounds:a}=Jn(),s=l.useRef(),u=l.useRef(-1),d=l.useRef(new Set),h=l.useRef(new Set),{selectedIds:p,camera:g}=t,[m,v]=te.sub(te.div([0,0],g.zoom),g.point),[E,w]=te.sub(te.div([a.width,a.height],g.zoom),g.point),C={minX:m,minY:v,maxX:E,maxY:w,height:E-m,width:w-v},b=h.current,A=d.current;b.clear(),A.clear(),Object.values(e.shapes).filter(D=>o[D.type].isStateful||p.includes(D.id)||tU(o[D.type].getBounds(D),C)).forEach(D=>{if(D.parentId===e.id){A.add(D.id),b.add(D);return}let I=e.shapes[D.parentId];if(I===void 0)throw Error(`A shape (${D.id}) has a parent (${D.parentId}) that does not exist!`);A.add(I.id),b.add(I)}),b.size!==u.current&&(s.current&&clearTimeout(s.current),s.current=requestAnimationFrame(()=>{var D;(D=i.onRenderCountChange)==null||D.call(i,Array.from(A.values()))}),u.current=b.size);let T=t.bindingId?e.bindings[t.bindingId].toId:void 0,B=[];return b.forEach(D=>{if(D===void 0)throw Error("Rendered shapes included a missing shape");dA(D,B,e.shapes,t,n,D.isGhost,!1,r,T)}),B.sort((D,I)=>D.shape.childIndex-I.shape.childIndex),B}var Cv=new Map;function rU(e,t){return Object.keys(t).reduce((n,r)=>{let i=t[r];return i?n+`${`--${e}-${r}`}: ${i}; `:n},"")}function iU(e,t,n=":root"){l.useLayoutEffect(()=>{let r=document.createElement("style"),i=rU(e,t);return r.setAttribute("id",`${e}-theme`),r.setAttribute("data-selector",n),r.innerHTML=` ${n} { ${i} } - `,document.head.appendChild(r),()=>{r&&document.head.contains(r)&&document.head.removeChild(r)}},[e,t,n])}function oU(e,t){l.useLayoutEffect(()=>{if(Ev.get(e))return()=>{};let n=document.createElement("style");return n.innerHTML=t,n.setAttribute("id",e),document.head.appendChild(n),Ev.set(e,n),()=>{n&&document.head.contains(n)&&(document.head.removeChild(n),Ev.delete(e))}},[e,t])}var aU=(e,...t)=>e.reduce((n,r,i)=>n+r+(i{r&&document.head.contains(r)&&document.head.removeChild(r)}},[e,t,n])}function oU(e,t){l.useLayoutEffect(()=>{if(Cv.get(e))return()=>{};let n=document.createElement("style");return n.innerHTML=t,n.setAttribute("id",e),document.head.appendChild(n),Cv.set(e,n),()=>{n&&document.head.contains(n)&&(document.head.removeChild(n),Cv.delete(e))}},[e,t])}var aU=(e,...t)=>e.reduce((n,r,i)=>n+r+(ilt(lt({},sU),e),[e]);iU("tl",n,t),oU("tl-canvas",uU)}function Oc(e){let{callbacks:t,inputs:n}=Jn(),r=l.useCallback(u=>{var d,h,p,g;if(u.dead||(u.dead=!0,!n.pointerIsValid(u)))return;(d=u.currentTarget)==null||d.setPointerCapture(u.pointerId);let m=n.pointerDown(u,e);if(u.button===2){(h=t.onRightPointBoundsHandle)==null||h.call(t,m,u);return}u.button===0&&((p=t.onPointBoundsHandle)==null||p.call(t,m,u)),(g=t.onPointerDown)==null||g.call(t,m,u)},[n,t,e]),i=l.useCallback(u=>{var d,h,p;if(u.dead||(u.dead=!0,u.button===2||!n.pointerIsValid(u)))return;let g=n.pointerUp(u,e),m=n.isDoubleClick();u.button===0&&(m&&!(g.altKey||g.metaKey)&&((d=t.onDoubleClickBoundsHandle)==null||d.call(t,g,u)),(h=t.onReleaseBoundsHandle)==null||h.call(t,g,u)),(p=t.onPointerUp)==null||p.call(t,g,u)},[n,t,e]),o=l.useCallback(u=>{var d,h;if(u.dead||(u.dead=!0,!n.pointerIsValid(u))||u.buttons===2)return;let p=n.pointerMove(u,e);u.buttons===1&&u.currentTarget.hasPointerCapture(u.pointerId)&&((d=t.onDragBoundsHandle)==null||d.call(t,p,u)),(h=t.onPointerMove)==null||h.call(t,p,u)},[n,t,e]),a=l.useCallback(u=>{var d;!n.pointerIsValid(u)||(d=t.onHoverBoundsHandle)==null||d.call(t,n.pointerEnter(u,e),u)},[n,t,e]),s=l.useCallback(u=>{var d;!n.pointerIsValid(u)||(d=t.onUnhoverBoundsHandle)==null||d.call(t,n.pointerEnter(u,e),u)},[n,t,e]);return{onPointerDown:r,onPointerUp:i,onPointerEnter:a,onPointerMove:o,onPointerLeave:s}}function cU(e,t,n){let r=l.useRef(),i=l.useRef();l.useLayoutEffect(()=>{let{zoom:o,point:a}=n.camera,s=o!==r.current,u=a!==i.current;if(r.current=o,i.current=a,s||u){let d=e.current;if(t&&"current"in t){let h=t.current;s&&h&&h.style.setProperty("--tl-zoom",o.toString()),d&&d.style.setProperty("transform",`scale(${o}) translateX(${a[0]}px) translateY(${a[1]}px)`)}}},[n.camera.zoom,n.camera.point])}function i6(e,t){return[(e[0]+t.point[0])*t.zoom,(e[1]+t.point[1])*t.zoom]}function Cv(e,t){return e[t.type]}function dU(e,t,n){let{rSelectionBounds:r}=Jn(),{selectedIds:i}=t,o=l.useRef(),a,s=0,u=!1,d=!1;if(i.length===1){let p=i[0],g=e.shapes[p];if(!g)throw Error(`selectedIds is set to the id of a shape that doesn't exist: ${p}`);s=g.rotation||0,u=g.isLocked||!1;let m=Cv(n,g);a=m.hideBounds?void 0:m.getBounds(g)}else if(i.length>1){let p=i.map(g=>e.shapes[g]);s=0,u=p.every(g=>g.isLocked),a=p.reduce((g,m,v)=>v===0?Cv(n,m).getRotatedBounds(m):Fr.getExpandedBounds(g,Cv(n,m).getRotatedBounds(m)),{})}if(a){let[p,g]=i6([a.minX,a.minY],t.camera),[m,v]=i6([a.maxX,a.maxY],t.camera);d=!!Object.values(e.bindings).find(E=>i.includes(E.toId)||i.includes(E.fromId)),r.current={minX:p,minY:g,maxX:m,maxY:v,width:m-p,height:v-g}}else r.current=null;let h=o.current;return!h||!a?o.current=a:a&&h.minX===a.minX&&h.minY===a.minY&&h.maxX===a.maxX&&h.maxY===a.maxY&&(a=o.current),{bounds:a,rotation:s,isLocked:u,isLinked:d}}function hU(e){let{inputs:t,callbacks:n}=Jn();return l.useMemo(()=>({onPointerDown:r=>{var i,o,a;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.button===2)return;(i=r.currentTarget)==null||i.setPointerCapture(r.pointerId);let s=t.pointerDown(r,e);r.button===0&&((o=n.onPointHandle)==null||o.call(n,s,r)),(a=n.onPointerDown)==null||a.call(n,s,r)},onPointerUp:r=>{var i,o,a,s;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.button===2)return;let u=t.isDoubleClick(),d=t.pointerUp(r,e);r.currentTarget.hasPointerCapture(r.pointerId)&&((i=r.currentTarget)==null||i.releasePointerCapture(r.pointerId),r.button===0&&(u&&!(d.altKey||d.metaKey)&&((o=n.onDoubleClickHandle)==null||o.call(n,d,r)),(a=n.onReleaseHandle)==null||a.call(n,d,r))),(s=n.onPointerUp)==null||s.call(n,d,r)},onPointerMove:r=>{var i,o;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.buttons===2)return;let a=t.pointerMove(r,e);r.buttons===1&&r.currentTarget.hasPointerCapture(r.pointerId)&&((i=n.onDragHandle)==null||i.call(n,a,r)),(o=n.onPointerMove)==null||o.call(n,a,r)},onPointerEnter:r=>{var i;if(!t.pointerIsValid(r))return;let o=t.pointerEnter(r,e);(i=n.onHoverHandle)==null||i.call(n,o,r)},onPointerLeave:r=>{var i;if(!t.pointerIsValid(r))return;let o=t.pointerEnter(r,e);(i=n.onUnhoverHandle)==null||i.call(n,o,r)}}),[t,n,e])}function fU(e){let{bounds:t}=Jn();l.useEffect(()=>{let n=o=>{o.preventDefault()},r=o=>{let a=o.touches[0].pageX,s=o.touches[0].radiusX||0;(a-s<10||a+s>t.width-10)&&o.preventDefault()},i=e.current;return i?(i.addEventListener("gestureend",n),i.addEventListener("gesturechange",n),i.addEventListener("gesturestart",n),i.addEventListener("touchstart",r),()=>{i&&(i.removeEventListener("gestureend",n),i.removeEventListener("gesturechange",n),i.removeEventListener("gesturestart",n),i.removeEventListener("touchstart",r))}):()=>{}},[e,t.width])}function pU(){let{callbacks:e,inputs:t}=Jn();return l.useMemo(()=>({onPointerDown:n=>{var r,i,o,a;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;if(n.button===2){(r=e.onRightPointBounds)==null||r.call(e,t.pointerDown(n,"bounds"),n);return}let s=t.pointerDown(n,"bounds");(i=n.currentTarget)==null||i.setPointerCapture(n.pointerId),n.button===0&&((o=e.onPointBounds)==null||o.call(e,s,n)),(a=e.onPointerDown)==null||a.call(e,s,n)},onPointerUp:n=>{var r,i,o,a;if(n.dead||(n.dead=!0,n.button===2)||(t.activePointer=void 0,!t.pointerIsValid(n)))return;let s=t.isDoubleClick(),u=t.pointerUp(n,"bounds");n.currentTarget.hasPointerCapture(n.pointerId)&&((r=n.currentTarget)==null||r.releasePointerCapture(n.pointerId)),n.button===0&&(s&&!(u.altKey||u.metaKey)&&((i=e.onDoubleClickBounds)==null||i.call(e,u,n)),(o=e.onReleaseBounds)==null||o.call(e,u,n)),(a=e.onPointerUp)==null||a.call(e,u,n)},onPointerMove:n=>{var r,i;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;n.buttons===1&&n.currentTarget.hasPointerCapture(n.pointerId)&&((r=e.onDragBounds)==null||r.call(e,t.pointerMove(n,"bounds"),n));let o=t.pointerMove(n,"bounds");(i=e.onPointerMove)==null||i.call(e,o,n)},onPointerEnter:n=>{var r;!t.pointerIsValid(n)||(r=e.onHoverBounds)==null||r.call(e,t.pointerEnter(n,"bounds"),n)},onPointerLeave:n=>{var r;!t.pointerIsValid(n)||(r=e.onUnhoverBounds)==null||r.call(e,t.pointerEnter(n,"bounds"),n)}}),[t,e])}function hA(e,t=0){let n=l.useRef(null);return l.useLayoutEffect(()=>{let r=n.current,i=` +`;function lU(e,t){let n=l.useMemo(()=>lt(lt({},sU),e),[e]);iU("tl",n,t),oU("tl-canvas",uU)}function Oc(e){let{callbacks:t,inputs:n}=Jn(),r=l.useCallback(u=>{var d,h,p,g;if(u.dead||(u.dead=!0,!n.pointerIsValid(u)))return;(d=u.currentTarget)==null||d.setPointerCapture(u.pointerId);let m=n.pointerDown(u,e);if(u.button===2){(h=t.onRightPointBoundsHandle)==null||h.call(t,m,u);return}u.button===0&&((p=t.onPointBoundsHandle)==null||p.call(t,m,u)),(g=t.onPointerDown)==null||g.call(t,m,u)},[n,t,e]),i=l.useCallback(u=>{var d,h,p;if(u.dead||(u.dead=!0,u.button===2||!n.pointerIsValid(u)))return;let g=n.pointerUp(u,e),m=n.isDoubleClick();u.button===0&&(m&&!(g.altKey||g.metaKey)&&((d=t.onDoubleClickBoundsHandle)==null||d.call(t,g,u)),(h=t.onReleaseBoundsHandle)==null||h.call(t,g,u)),(p=t.onPointerUp)==null||p.call(t,g,u)},[n,t,e]),o=l.useCallback(u=>{var d,h;if(u.dead||(u.dead=!0,!n.pointerIsValid(u))||u.buttons===2)return;let p=n.pointerMove(u,e);u.buttons===1&&u.currentTarget.hasPointerCapture(u.pointerId)&&((d=t.onDragBoundsHandle)==null||d.call(t,p,u)),(h=t.onPointerMove)==null||h.call(t,p,u)},[n,t,e]),a=l.useCallback(u=>{var d;!n.pointerIsValid(u)||(d=t.onHoverBoundsHandle)==null||d.call(t,n.pointerEnter(u,e),u)},[n,t,e]),s=l.useCallback(u=>{var d;!n.pointerIsValid(u)||(d=t.onUnhoverBoundsHandle)==null||d.call(t,n.pointerEnter(u,e),u)},[n,t,e]);return{onPointerDown:r,onPointerUp:i,onPointerEnter:a,onPointerMove:o,onPointerLeave:s}}function cU(e,t,n){let r=l.useRef(),i=l.useRef();l.useLayoutEffect(()=>{let{zoom:o,point:a}=n.camera,s=o!==r.current,u=a!==i.current;if(r.current=o,i.current=a,s||u){let d=e.current;if(t&&"current"in t){let h=t.current;s&&h&&h.style.setProperty("--tl-zoom",o.toString()),d&&d.style.setProperty("transform",`scale(${o}) translateX(${a[0]}px) translateY(${a[1]}px)`)}}},[n.camera.zoom,n.camera.point])}function i6(e,t){return[(e[0]+t.point[0])*t.zoom,(e[1]+t.point[1])*t.zoom]}function bv(e,t){return e[t.type]}function dU(e,t,n){let{rSelectionBounds:r}=Jn(),{selectedIds:i}=t,o=l.useRef(),a,s=0,u=!1,d=!1;if(i.length===1){let p=i[0],g=e.shapes[p];if(!g)throw Error(`selectedIds is set to the id of a shape that doesn't exist: ${p}`);s=g.rotation||0,u=g.isLocked||!1;let m=bv(n,g);a=m.hideBounds?void 0:m.getBounds(g)}else if(i.length>1){let p=i.map(g=>e.shapes[g]);s=0,u=p.every(g=>g.isLocked),a=p.reduce((g,m,v)=>v===0?bv(n,m).getRotatedBounds(m):Fr.getExpandedBounds(g,bv(n,m).getRotatedBounds(m)),{})}if(a){let[p,g]=i6([a.minX,a.minY],t.camera),[m,v]=i6([a.maxX,a.maxY],t.camera);d=!!Object.values(e.bindings).find(E=>i.includes(E.toId)||i.includes(E.fromId)),r.current={minX:p,minY:g,maxX:m,maxY:v,width:m-p,height:v-g}}else r.current=null;let h=o.current;return!h||!a?o.current=a:a&&h.minX===a.minX&&h.minY===a.minY&&h.maxX===a.maxX&&h.maxY===a.maxY&&(a=o.current),{bounds:a,rotation:s,isLocked:u,isLinked:d}}function hU(e){let{inputs:t,callbacks:n}=Jn();return l.useMemo(()=>({onPointerDown:r=>{var i,o,a;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.button===2)return;(i=r.currentTarget)==null||i.setPointerCapture(r.pointerId);let s=t.pointerDown(r,e);r.button===0&&((o=n.onPointHandle)==null||o.call(n,s,r)),(a=n.onPointerDown)==null||a.call(n,s,r)},onPointerUp:r=>{var i,o,a,s;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.button===2)return;let u=t.isDoubleClick(),d=t.pointerUp(r,e);r.currentTarget.hasPointerCapture(r.pointerId)&&((i=r.currentTarget)==null||i.releasePointerCapture(r.pointerId),r.button===0&&(u&&!(d.altKey||d.metaKey)&&((o=n.onDoubleClickHandle)==null||o.call(n,d,r)),(a=n.onReleaseHandle)==null||a.call(n,d,r))),(s=n.onPointerUp)==null||s.call(n,d,r)},onPointerMove:r=>{var i,o;if(r.dead||(r.dead=!0,!t.pointerIsValid(r))||r.buttons===2)return;let a=t.pointerMove(r,e);r.buttons===1&&r.currentTarget.hasPointerCapture(r.pointerId)&&((i=n.onDragHandle)==null||i.call(n,a,r)),(o=n.onPointerMove)==null||o.call(n,a,r)},onPointerEnter:r=>{var i;if(!t.pointerIsValid(r))return;let o=t.pointerEnter(r,e);(i=n.onHoverHandle)==null||i.call(n,o,r)},onPointerLeave:r=>{var i;if(!t.pointerIsValid(r))return;let o=t.pointerEnter(r,e);(i=n.onUnhoverHandle)==null||i.call(n,o,r)}}),[t,n,e])}function fU(e){let{bounds:t}=Jn();l.useEffect(()=>{let n=o=>{o.preventDefault()},r=o=>{let a=o.touches[0].pageX,s=o.touches[0].radiusX||0;(a-s<10||a+s>t.width-10)&&o.preventDefault()},i=e.current;return i?(i.addEventListener("gestureend",n),i.addEventListener("gesturechange",n),i.addEventListener("gesturestart",n),i.addEventListener("touchstart",r),()=>{i&&(i.removeEventListener("gestureend",n),i.removeEventListener("gesturechange",n),i.removeEventListener("gesturestart",n),i.removeEventListener("touchstart",r))}):()=>{}},[e,t.width])}function pU(){let{callbacks:e,inputs:t}=Jn();return l.useMemo(()=>({onPointerDown:n=>{var r,i,o,a;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;if(n.button===2){(r=e.onRightPointBounds)==null||r.call(e,t.pointerDown(n,"bounds"),n);return}let s=t.pointerDown(n,"bounds");(i=n.currentTarget)==null||i.setPointerCapture(n.pointerId),n.button===0&&((o=e.onPointBounds)==null||o.call(e,s,n)),(a=e.onPointerDown)==null||a.call(e,s,n)},onPointerUp:n=>{var r,i,o,a;if(n.dead||(n.dead=!0,n.button===2)||(t.activePointer=void 0,!t.pointerIsValid(n)))return;let s=t.isDoubleClick(),u=t.pointerUp(n,"bounds");n.currentTarget.hasPointerCapture(n.pointerId)&&((r=n.currentTarget)==null||r.releasePointerCapture(n.pointerId)),n.button===0&&(s&&!(u.altKey||u.metaKey)&&((i=e.onDoubleClickBounds)==null||i.call(e,u,n)),(o=e.onReleaseBounds)==null||o.call(e,u,n)),(a=e.onPointerUp)==null||a.call(e,u,n)},onPointerMove:n=>{var r,i;if(n.dead||(n.dead=!0,!t.pointerIsValid(n)))return;n.buttons===1&&n.currentTarget.hasPointerCapture(n.pointerId)&&((r=e.onDragBounds)==null||r.call(e,t.pointerMove(n,"bounds"),n));let o=t.pointerMove(n,"bounds");(i=e.onPointerMove)==null||i.call(e,o,n)},onPointerEnter:n=>{var r;!t.pointerIsValid(n)||(r=e.onHoverBounds)==null||r.call(e,t.pointerEnter(n,"bounds"),n)},onPointerLeave:n=>{var r;!t.pointerIsValid(n)||(r=e.onUnhoverBounds)==null||r.call(e,t.pointerEnter(n,"bounds"),n)}}),[t,e])}function hA(e,t=0){let n=l.useRef(null);return l.useLayoutEffect(()=>{let r=n.current,i=` translate( calc(${e.minX}px - var(--tl-padding)), calc(${e.minY}px - var(--tl-padding)) ) - rotate(${t+(e.rotation||0)}rad)`;r.style.setProperty("transform",i),r.style.setProperty("width",`calc(${Math.floor(e.width)}px + (var(--tl-padding) * 2))`),r.style.setProperty("height",`calc(${Math.floor(e.height)}px + (var(--tl-padding) * 2))`)},[e,t]),n}function gU(){let{inputs:e,callbacks:t}=Jn();l.useEffect(()=>{let n=i=>{var o;(o=t.onKeyDown)==null||o.call(t,i.key,e.keydown(i),i)},r=i=>{var o;e.keyup(i),(o=t.onKeyUp)==null||o.call(t,i.key,e.keyup(i),i)};return window.addEventListener("keydown",n),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",r)}},[e,t])}function mU(e,t){l.useLayoutEffect(()=>{if(t&&"current"in t){let n=t==null?void 0:t.current;if(!n)return;switch(e){case"transform_selected":{n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","transform, contents");break}case"transform_all":{n.style.setProperty("--tl-performance-all","transform, contents"),n.style.setProperty("--tl-performance-selected","transform, contents");break}case"translate_selected":{n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","transform");break}case"translate_all":{n.style.setProperty("--tl-performance-all","transform"),n.style.setProperty("--tl-performance-selected","transform");break}default:n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","auto")}}},[e])}function vU(e){var t=e,{id:n,bounds:r,rotation:i=0,isGhost:o=!1,isSelected:a=!1,children:s}=t,u=yd(t,["id","bounds","rotation","isGhost","isSelected","children"]);let d=hA(r,i);return l.createElement("div",lt({id:n,ref:d,className:`tl-positioned${o?" tl-ghost":""}${a?" tl-positioned-selected":""}`,"aria-label":"container","data-testid":"container"},u),s)}var kh=l.memo(vU);function yU({brush:e,zoom:t,dashed:n}){return l.createElement(kh,{bounds:e,rotation:0},l.createElement(xi,null,l.createElement("rect",{className:"tl-brush"+(n?" dashed":""),opacity:1,x:0,y:0,width:e.width,height:e.height,"aria-label":"brush"}),n&&l.createElement("g",{className:"tl-dashed-brush-line"},l.createElement(Xf,{x1:0,y1:0,x2:e.width,y2:0,zoom:t}),l.createElement(Xf,{x1:e.width,y1:0,x2:e.width,y2:e.height,zoom:t}),l.createElement(Xf,{x1:0,y1:e.height,x2:e.width,y2:e.height,zoom:t}),l.createElement(Xf,{x1:0,y1:0,x2:0,y2:e.height,zoom:t}))))}var EU=l.memo(yU);function Xf({x1:e,y1:t,x2:n,y2:r,zoom:i}){let o=Fr.getPerfectDashProps(Math.hypot(n-e,r-t),1/i,"dashed",1,!0,3);return l.createElement("line",{x1:e,y1:t,x2:n,y2:r,strokeWidth:1/i,strokeDasharray:o.strokeDasharray,strokeDashoffset:o.strokeDashoffset})}var CU=l.memo(({color:e})=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 35 35",fill:"none",fillRule:"evenodd"},l.createElement("g",{fill:"rgba(0,0,0,.2)",transform:"translate(1,1)"},l.createElement("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),l.createElement("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})),l.createElement("g",{fill:"white"},l.createElement("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),l.createElement("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})),l.createElement("g",{fill:e},l.createElement("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),l.createElement("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"}))));function bU({points:e,zoom:t}){if(e.length===0)return null;let n=Fr.getSvgPathFromStroke(Ah(e,{size:16/t,start:{taper:!0}}));return l.createElement("path",{d:n,className:"tl-erase-line"})}var wU=l.memo(bU),o6=[[-1,.15,64],[.05,.375,16],[.15,1,4],[.7,2.5,1]];function SU({grid:e,camera:t}){return l.createElement("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},l.createElement("defs",null,o6.map(([n,r,i],o)=>{let a=i*e*t.zoom,s=t.point[0]*t.zoom,u=t.point[1]*t.zoom,d=s>0?s%a:a+s%a,h=u>0?u%a:a+u%a,p=t.zooml.createElement("rect",{key:`grid-rect-${r}`,width:"100%",height:"100%",fill:`url(#grid-${r})`})))}function xU({camera:{zoom:e,point:t},children:n}){let r=2.5/e;return l.createElement("svg",{className:"tl-overlay"},l.createElement("defs",null,l.createElement("g",{id:"tl-snap-point"},l.createElement("path",{className:"tl-snap-point",d:`M ${-r},${-r} L ${r},${r} M ${-r},${r} L ${r},${-r}`}))),l.createElement("g",{transform:`scale(${e}) translate(${t})`},n))}var AU=l.memo(xU),xi=l.memo(l.forwardRef(function(e,t){var n=e,{id:r,className:i="",children:o}=n,a=yd(n,["id","className","children"]);return l.createElement("svg",lt({ref:t,className:`tl-positioned-svg ${i}`},a),l.createElement("g",{id:r,className:"tl-centered-g"},o))}));function kU({bounds:e,isLocked:t,isHidden:n}){return l.createElement("rect",{className:["tl-bounds-center",t?"tl-dashed":""].join(" "),x:-1,y:-1,width:e.width+2,height:e.height+2,opacity:n?0:1,pointerEvents:"none","aria-label":"center handle"})}var IU=l.memo(kU),DU={right:0,bottomRight:45,bottom:90,bottomLeft:135,left:180,topLeft:225,top:270,topRight:315};function TU({bounds:e,side:t,targetSize:n,size:r}){let i=n*2,o={left:-i,topLeft:-i,bottomLeft:-i,right:e.width,topRight:e.width,bottomRight:e.width,top:e.width/2-i/2,bottom:e.width/2-i/2}[t],a={left:e.height/2-i/2,right:e.height/2-i/2,top:-i*2,topLeft:-i,topRight:-i,bottom:e.height,bottomLeft:e.height,bottomRight:e.height}[t],{callbacks:s,inputs:u}=Jn(),d=l.useCallback(h=>{var p;h.stopPropagation();let g=u.pointerDown(h,t);(p=s.onShapeClone)==null||p.call(s,g,h)},[s.onShapeClone]);return l.createElement("g",{className:"tl-clone-target",transform:`translate(${o}, ${a})`,"aria-label":"clone button"},l.createElement("rect",{className:"tl-transparent",width:n*2,height:n*2}),l.createElement("g",{className:"tl-clone-button-target",onPointerDown:d,transform:`translate(${n}, ${n}) rotate(${DU[t]})`},l.createElement("circle",{className:"tl-transparent ",r:n}),l.createElement("path",{className:"tl-clone-button",d:`M -${r/2},-${r/2} L ${r/2},0 -${r/2},${r/2} Z`,strokeLinejoin:"round"})))}var Gs=l.memo(TU);function PU({targetSize:e,size:t,bounds:n}){return l.createElement(l.Fragment,null,l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"top"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"right"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottom"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"left"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"topLeft"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"topRight"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottomLeft"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottomRight"}))}var BU=l.memo(PU),MU={top_left_corner:"tl-cursor-nwse",top_right_corner:"tl-cursor-nesw",bottom_right_corner:"tl-cursor-nwse",bottom_left_corner:"tl-cursor-nesw"};function $U({size:e,targetSize:t,isHidden:n,corner:r,bounds:i}){let o=Oc(r),a=r==="top_left_corner"||r==="top_right_corner",s=r==="top_left_corner"||r==="bottom_left_corner";return l.createElement("g",{opacity:n?0:1},l.createElement("rect",lt({className:"tl-transparent "+(n?"":MU[r]),"aria-label":"corner transparent",x:(s?-1:i.width+1)-t,y:(a?-1:i.height+1)-t,width:t*2,height:t*2,pointerEvents:n?"none":"all"},o)),l.createElement("rect",{className:"tl-corner-handle","aria-label":"corner handle",x:(s?-1:i.width+1)-e/2,y:(a?-1:i.height+1)-e/2,width:e,height:e,pointerEvents:"none"}))}var Zf=l.memo($U),RU={top_edge:"tl-cursor-ns",right_edge:"tl-cursor-ew",bottom_edge:"tl-cursor-ns",left_edge:"tl-cursor-ew"};function FU({size:e,isHidden:t,bounds:n,edge:r}){let i=Oc(r),o=r==="top_edge"||r==="bottom_edge",a=r==="right_edge"||r==="bottom_edge",{height:s,width:u}=n;return l.createElement("rect",lt({pointerEvents:t?"none":"all",className:"tl-transparent tl-edge-handle "+(t?"":RU[r]),"aria-label":`${r} handle`,opacity:t?0:1,x:o?e/2:(a?u+1:-1)-e/2,y:o?(a?s+1:-1)-e/2:e/2,width:o?Math.max(0,u+1-e):e,height:o?e:Math.max(0,s+1-e)},i))}var Qf=l.memo(FU);function LU({size:e,bounds:t,isHidden:n}){let r=Oc("left"),i=Oc("center"),o=Oc("right");return l.createElement("g",{cursor:"grab",transform:`translate(${t.width/2-e*4}, ${t.height+e*2})`,"aria-label":"link handle"},l.createElement("g",{className:"tl-transparent",pointerEvents:n?"none":"all"},l.createElement("rect",lt({x:0,y:0,width:e*2,height:e*2},r)),l.createElement("rect",lt({x:e*3,y:0,width:e*2,height:e*2},i)),l.createElement("rect",lt({x:e*6,y:0,width:e*2,height:e*2},o))),l.createElement("g",{className:"tl-rotate-handle",transform:`translate(${e/2}, ${e/2})`,"aria-label":"link rotate handle"},l.createElement("path",{d:`M 0,${e/2} L ${e},${e} ${e},0 Z`,pointerEvents:"none",opacity:n?0:1}),l.createElement("path",{transform:`translate(${e*3}, 0)`,d:`M 0,0 L ${e},0 ${e/2},${e} Z`,pointerEvents:"none",opacity:n?0:1}),l.createElement("path",{transform:`translate(${e*6}, 0)`,d:`M ${e},${e/2} L 0,0 0,${e} Z`,pointerEvents:"none",opacity:n?0:1})))}var OU=l.memo(LU);function _U({bounds:e,targetSize:t,size:n,isHidden:r}){let i=Oc("rotate");return l.createElement("g",{cursor:"grab",opacity:r?0:1},l.createElement("circle",lt({className:"tl-transparent","aria-label":"rotate handle transparent",cx:e.width/2,cy:n*-2,r:t,pointerEvents:r?"none":"all"},i)),l.createElement("circle",{className:"tl-rotate-handle","aria-label":"rotate handle",cx:e.width/2,cy:n*-2,r:n/2,pointerEvents:"none"}))}var NU=l.memo(_U),zU=function({zoom:e,bounds:t,viewportWidth:n,rotation:r,isHidden:i,isLocked:o,hideCloneHandles:a,hideResizeHandles:s,hideRotateHandle:u,hideBindingHandles:d}){let h=(n<768?16:8)/e,p=8/e,g=Math.min(t.width,t.height)*e,m=!u&&!i&&!o&&g>32,v=!i&&!o&&g>24,E=!i&&!o&&g>20,w=!a&&g>24;return l.createElement(kh,{bounds:t,rotation:r},l.createElement(xi,null,l.createElement(IU,{bounds:t,isLocked:o,isHidden:i}),!s&&!o?l.createElement(l.Fragment,null,l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"top_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"right_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"bottom_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"left_edge",isHidden:!v}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"top_left_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"top_right_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"bottom_right_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"bottom_left_corner"})):null,m&&l.createElement(NU,{targetSize:h,size:p,bounds:t,isHidden:!v}),w&&l.createElement(BU,{bounds:t,targetSize:h,size:p}),!d&&l.createElement(OU,{targetSize:h,size:p,bounds:t,isHidden:!v})))},HU=l.memo(zU);function jU({bounds:e,rotation:t,isHidden:n}){let r=pU();return l.createElement(kh,{bounds:e,rotation:t},l.createElement(xi,null,l.createElement("rect",lt({className:"tl-bounds-bg","aria-label":"bounds bg",width:e.width,height:e.height,opacity:n?0:1},r))))}var UU=l.memo(jU);function KU({id:e,point:t}){let n=hU(e);return l.createElement(kh,{bounds:Fr.translateBounds({minX:0,minY:0,maxX:0,maxY:0,width:0,height:0},t)},l.createElement(xi,null,l.createElement("g",lt({className:"tl-handle","aria-label":"handle"},n),l.createElement("circle",{className:"tl-handle-bg",pointerEvents:"all"}),l.createElement("circle",{className:"tl-counter-scaled tl-handle",pointerEvents:"none",r:4}))))}var VU=l.memo(KU);function GU({shape:e,zoom:t}){if(e.handles===void 0)return null;let n=null,r=Object.values(e.handles).reduce((i,o)=>{let a=te.add(o.point,e.point);return(!n||te.dist(a,n)*t>=32)&&(i.push(o),n=a),i},[]);return r.length===1?null:l.createElement(l.Fragment,null,r.map(i=>l.createElement(VU,{key:e.id+"_"+i.id,id:i.id,point:te.add(i.point,e.point)})))}var JU=l.memo(GU);function WU(e){let t=e.utils.getRef(e.shape);return l.createElement(e.utils.Component,lt({ref:t},e))}var YU=l.memo(WU,(e,t)=>e.isHovered!==t.isHovered||e.isSelected!==t.isSelected||e.isEditing!==t.isEditing||e.isBinding!==t.isBinding||e.isGhost!==t.isGhost||e.meta!==t.meta?!1:t.shape!==e.shape?!t.utils.shouldRender(t.shape,e.shape):!0);function qU(e){var t=e,{shape:n,utils:r,meta:i}=t,o=yd(t,["shape","utils","meta"]);let{callbacks:a}=Jn(),s=r.getBounds(n),u=eU(n.id);return l.createElement(kh,{id:n.id,bounds:s,rotation:n.rotation,"data-shape":n.type,isGhost:o.isGhost,isSelected:o.isSelected},l.createElement(YU,lt({shape:n,utils:r,meta:i,events:u,bounds:s,onShapeChange:a.onShapeChange,onShapeBlur:a.onShapeBlur},o)))}var XU=l.memo(qU);function ZU(e){var t=e,{shape:n,utils:r,meta:i,children:o}=t,a=yd(t,["shape","utils","meta","children"]);return l.createElement(l.Fragment,null,l.createElement(XU,lt({shape:n,utils:r[n.type],meta:i},a)),o&&o.map(s=>l.createElement(fA,lt({key:s.shape.id,utils:r},s))))}var fA=l.memo(ZU);function QU({isHovered:e=!1,isSelected:t=!1,isEditing:n=!1,shape:r,user:i,meta:o}){let{shapeUtils:a}=Jn(),s=a[r.type],u=s.getBounds(r),d=hA(u,r.rotation);return l.createElement("div",{ref:d,draggable:!1,className:["tl-indicator","tl-absolute",t&&!i?"tl-selected":"tl-hovered",n?"tl-editing":"",r.isLocked?"tl-locked":""].join(" ")},l.createElement("svg",{width:"100%",height:"100%"},l.createElement("g",{className:"tl-centered-g",stroke:i==null?void 0:i.color},l.createElement(s.Indicator,{shape:r,meta:o,user:i,bounds:u,isSelected:t,isHovered:e}))))}var iy=l.memo(QU);function eK({page:e,pageState:t,assets:n,hideBounds:r,hideHandles:i,hideIndicators:o,hideBindingHandles:a,hideCloneHandles:s,hideRotateHandle:u,hideResizeHandles:d,meta:h}){let{bounds:p,shapeUtils:g}=Jn(),m=nU(e,t,n,h),{bounds:v,isLinked:E,isLocked:w,rotation:C}=dU(e,t,g),{selectedIds:b,hoveredId:A,editingId:T,camera:{zoom:B}}=t,D=o,I=!0,M=!1,O,z=b.map(K=>e.shapes[K]);if(z.length===1){let K=z[0];M=T===K.id,M&&(D=!0);let X=g[K.type];I=s||!X.showCloneHandles,K.handles!==void 0&&!M&&(O=K)}return l.createElement(l.Fragment,null,v&&l.createElement(UU,{bounds:v,rotation:C,isHidden:r}),m.map(K=>l.createElement(fA,lt({key:K.shape.id,utils:g},K))),!D&&z.map(K=>l.createElement(iy,{key:"selected_"+K.id,shape:K,meta:h,isSelected:!0,isEditing:M})),!D&&A&&A!==T&&l.createElement(iy,{key:"hovered_"+A,shape:e.shapes[A],meta:h,isHovered:!0}),v&&l.createElement(HU,{zoom:B,bounds:v,viewportWidth:p.width,isLocked:w,rotation:C,isHidden:r,hideRotateHandle:u,hideResizeHandles:d,hideBindingHandles:a||!E,hideCloneHandles:I}),!i&&O&&l.createElement(JU,{shape:O,zoom:B}))}var tK=l.memo(eK);function nK({snapLines:e}){return l.createElement(l.Fragment,null,e.map((t,n)=>l.createElement(iK,{key:n,snapLine:t})))}function rK({snapLine:e}){let t=Fr.getBoundsFromPoints(e);return l.createElement(l.Fragment,null,l.createElement("line",{className:"tl-snap-line",x1:t.minX,y1:t.minY,x2:t.maxX,y2:t.maxY}),e.map(([n,r],i)=>l.createElement("use",{key:i,href:"#tl-snap-point",x:n,y:r})))}var iK=l.memo(rK),oK=l.memo(nK);function aK({user:e,Cursor:t}){let n=l.useRef(null);return l.useLayoutEffect(()=>{n.current&&(n.current.style.transform=`translate(${e.point[0]}px, ${e.point[1]}px)`)},[e.point]),l.createElement("div",{ref:n,className:`tl-absolute tl-user tl-counter-scaled ${e.session?"":"tl-animated"}`},l.createElement(t,{id:e.id,color:e.color,metadata:e.metadata}))}function sK({userId:e,users:t,Cursor:n}){return l.createElement(l.Fragment,null,Object.values(t).filter(r=>r&&r.id!==e).map(r=>l.createElement(aK,{key:r.id,user:r,Cursor:n})))}function uK({userId:e,users:t,meta:n,page:r}){let{shapeUtils:i}=Jn();return l.createElement(l.Fragment,null,Object.values(t).filter(Boolean).filter(o=>o.id!==e&&o.selectedIds.length>0).map(o=>{let a=o.selectedIds.map(u=>r.shapes[u]).filter(Boolean);if(a.length===0)return null;let s=Fr.getCommonBounds(a.map(u=>i[u.type].getBounds(u)));return l.createElement(l.Fragment,{key:o.id+"_shapes"},l.createElement("div",{className:"tl-absolute tl-user-indicator-bounds",style:{backgroundColor:o.color+"0d",borderColor:o.color+"78",transform:`translate(${s.minX}px, ${s.minY}px)`,width:s.width,height:s.height,pointerEvents:"none"}}),a.map(u=>l.createElement(iy,{key:`${o.id}_${u.id}_indicator`,shape:u,user:o,meta:n,isHovered:!0})))}))}var lK=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:n}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return t;t=t.parentElement}return document};function cK(e,t){let{inputs:n,callbacks:r}=Jn(),i=l.useRef(!1),o=l.useCallback(()=>{var a,s;if(i.current){let u=(a=e.current)==null?void 0:a.getBoundingClientRect();if(u){let d={minX:u.left,maxX:u.left+u.width,minY:u.top,maxY:u.top+u.height,width:u.width,height:u.height};n.bounds=d,t(d),(s=r.onBoundsChange)==null||s.call(r,d)}}else i.current=!0},[e,n,r.onBoundsChange]);l.useEffect(()=>{let a=e.current?lK(e.current):document,s=N.debounce(o,100);return a.addEventListener("scroll",s),window.addEventListener("resize",s),()=>{a.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[]),l.useEffect(()=>{let a=new ResizeObserver(s=>{n.isPinching||s[0].contentRect&&o()});return e.current&&a.observe(e.current),()=>{a.disconnect()}},[e,n]),l.useEffect(()=>{o()},[e])}function dK({id:e,page:t,pageState:n,assets:r,snapLines:i,eraseLine:o,grid:a,users:s,userId:u,components:d={},meta:h,performanceMode:p,showDashedBrush:g,hideHandles:m,hideBounds:v,hideIndicators:E,hideBindingHandles:w,hideCloneHandles:C,hideResizeHandles:b,hideRotateHandle:A,hideGrid:T,onBoundsChange:B,hideCursors:D}){var I;let M=l.useRef(null),O=l.useRef(n.camera.zoom);O.current=n.camera.zoom,qj(O,M),cK(M,B),Zj(),fU(M);let z=l.useRef(null),K=l.useRef(null);cU(K,z,n),mU(p,z),gU();let X=Qj();return l.createElement("div",{id:e,className:"tl-container",ref:z},l.createElement("div",lt({id:"canvas",className:"tl-absolute tl-canvas",ref:M},X),!T&&a&&l.createElement(SU,{grid:a,camera:n.camera}),l.createElement("div",{ref:K,className:"tl-absolute tl-layer","data-testid":"layer"},l.createElement(tK,{page:t,pageState:n,assets:r,hideBounds:v,hideIndicators:E,hideHandles:m,hideBindingHandles:w,hideCloneHandles:C,hideResizeHandles:b,hideRotateHandle:A,meta:h}),s&&u&&l.createElement(uK,{userId:u,users:s,page:t,meta:h}),n.brush&&l.createElement(EU,{brush:n.brush,dashed:g,zoom:n.camera.zoom}),s&&!D&&l.createElement(sK,{userId:u,users:s,Cursor:(I=d==null?void 0:d.Cursor)!=null?I:CU})),l.createElement(AU,{camera:n.camera},o&&l.createElement(wU,{points:o,zoom:n.camera.zoom}),i&&l.createElement(oK,{snapLines:i}))))}var hK=l.memo(dK),fK=250,ln=class{constructor(){Ot(this,"pointer"),Ot(this,"keyboard"),Ot(this,"keys",{}),Ot(this,"isPinching",!1),Ot(this,"bounds",{minX:0,maxX:640,minY:0,maxY:480,width:640,height:480}),Ot(this,"pointerUpTime",0),Ot(this,"activePointer"),Ot(this,"panStart",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t,u={target:"wheel",pointerId:((n=this.pointer)==null?void 0:n.pointerId)||0,origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],delta:[0,0],pressure:.5,point:ln.getPoint(t,this.bounds),shiftKey:i,ctrlKey:o,metaKey:a,altKey:s,spaceKey:this.keys[" "]};return this.pointer=u,u}),Ot(this,"pan",(t,n)=>{if(!this.pointer||this.pointer.target!=="wheel")return this.panStart(n);let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=n,s=this.pointer,u=ln.getPoint(n,this.bounds),d=Io(lt({},s),{target:"wheel",delta:t,point:u,shiftKey:r,ctrlKey:i,metaKey:o,altKey:a,spaceKey:this.keys[" "]});return this.pointer=d,d}),Ot(this,"keydown",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t;return this.keys[t.key]=!0,{point:((n=this.pointer)==null?void 0:n.point)||[0,0],origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],key:t.key,keys:Object.keys(this.keys),shiftKey:i,ctrlKey:o,metaKey:N.isDarwin()?a:o,altKey:s}}),Ot(this,"keyup",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t;return delete this.keys[t.key],{point:((n=this.pointer)==null?void 0:n.point)||[0,0],origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],key:t.key,keys:Object.keys(this.keys),shiftKey:i,ctrlKey:o,metaKey:N.isDarwin()?a:o,altKey:s}})}pointerIsValid(t){if("pointerId"in t&&this.activePointer&&this.activePointer!==t.pointerId)return!1;if("touches"in t){let n=t.changedTouches[0];if(this.activePointer&&this.activePointer!==n.identifier)return!1}return!0}touchStart(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0];this.activePointer=s.identifier;let u={target:n,pointerId:s.identifier,origin:ln.getPoint(s,this.bounds),delta:[0,0],point:ln.getPoint(s,this.bounds),pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}touchEnd(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0],u={target:n,pointerId:s.identifier,origin:ln.getPoint(s,this.bounds),delta:[0,0],point:ln.getPoint(s,this.bounds),pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,this.activePointer=void 0,u}touchMove(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0],u=this.pointer,d=ln.getPoint(s,this.bounds),h=u!=null&&u.point?te.sub(d,u.point):[0,0],p=Io(lt({origin:d},u),{target:n,pointerId:s.identifier,point:d,delta:h,pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=p,p}pointerDown(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=ln.getPoint(t,this.bounds);this.activePointer=t.pointerId;let u={target:n,pointerId:t.pointerId,origin:s,point:s,delta:[0,0],pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}pointerEnter(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=ln.getPoint(t,this.bounds),u={target:n,pointerId:t.pointerId,origin:s,delta:[0,0],point:s,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}pointerMove(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=this.pointer,u=ln.getPoint(t,this.bounds),d=s!=null&&s.point?te.sub(u,s.point):[0,0],h=Io(lt({origin:u},s),{target:n,pointerId:t.pointerId,point:u,delta:d,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=h,h}pointerUp(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=this.pointer,u=ln.getPoint(t,this.bounds),d=s!=null&&s.point?te.sub(u,s.point):[0,0];this.activePointer=void 0;let h=Io(lt({origin:u},s),{target:n,pointerId:t.pointerId,point:u,delta:d,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=h,this.pointerUpTime=performance.now(),h}isDoubleClick(){if(!this.pointer)return!1;let{origin:t,point:n}=this.pointer,r=performance.now()-this.pointerUpTime{Z.current=o},[o]);let[pe,me]=l.useState(()=>({callbacks:K,shapeUtils:r,rSelectionBounds:X,rPageState:Z,bounds:{minX:0,minY:0,maxX:1/0,maxY:1/0,width:1/0,height:1/0},inputs:new ln})),Ce=l.useCallback(W=>{me(U=>Io(lt({},U),{bounds:W}))},[]);return l.createElement(EE.Provider,{value:pe},l.createElement(hK,{id:n,page:i,pageState:o,assets:a,snapLines:p,eraseLine:g,grid:m,users:s,userId:u,externalContainerRef:v,hideBounds:I,hideIndicators:b,hideHandles:C,hideCloneHandles:A,hideBindingHandles:T,hideRotateHandle:D,hideResizeHandles:B,hideGrid:M,showDashedBrush:O,onBoundsChange:Ce,performanceMode:E,components:w,meta:h,hideCursors:z}))}var mK=l.memo(gK),Tm=l.memo(l.forwardRef(function(e,t){var n=e,{children:r,className:i=""}=n,o=yd(n,["children","className"]);return l.createElement("div",lt({ref:t,className:`tl-positioned-div ${i}`,draggable:!1},o),l.createElement("div",{className:"tl-inner-div"},r))})),oy=class{constructor(){Ot(this,"refMap",new Map),Ot(this,"boundsCache",new WeakMap),Ot(this,"showCloneHandles",!1),Ot(this,"hideBounds",!1),Ot(this,"isStateful",!1),Ot(this,"shouldRender",(e,t)=>!0),Ot(this,"getRef",e=>(this.refMap.has(e.id)||this.refMap.set(e.id,l.createRef()),this.refMap.get(e.id))),Ot(this,"hitTestBounds",(e,t)=>{let n=this.getBounds(e),r=Fr.getRotatedCorners(n,e.rotation);return r.every(i=>Fr.pointInBounds(i,t))||Uj(r,t).length>0}),Ot(this,"getRotatedBounds",e=>Fr.getBoundsFromPoints(Fr.getRotatedCorners(this.getBounds(e),e.rotation)))}};Ot(oy,"Component",e=>l.forwardRef(e)),Ot(oy,"Indicator",e=>e);/** + rotate(${t+(e.rotation||0)}rad)`;r.style.setProperty("transform",i),r.style.setProperty("width",`calc(${Math.floor(e.width)}px + (var(--tl-padding) * 2))`),r.style.setProperty("height",`calc(${Math.floor(e.height)}px + (var(--tl-padding) * 2))`)},[e,t]),n}function gU(){let{inputs:e,callbacks:t}=Jn();l.useEffect(()=>{let n=i=>{var o;(o=t.onKeyDown)==null||o.call(t,i.key,e.keydown(i),i)},r=i=>{var o;e.keyup(i),(o=t.onKeyUp)==null||o.call(t,i.key,e.keyup(i),i)};return window.addEventListener("keydown",n),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",r)}},[e,t])}function mU(e,t){l.useLayoutEffect(()=>{if(t&&"current"in t){let n=t==null?void 0:t.current;if(!n)return;switch(e){case"transform_selected":{n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","transform, contents");break}case"transform_all":{n.style.setProperty("--tl-performance-all","transform, contents"),n.style.setProperty("--tl-performance-selected","transform, contents");break}case"translate_selected":{n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","transform");break}case"translate_all":{n.style.setProperty("--tl-performance-all","transform"),n.style.setProperty("--tl-performance-selected","transform");break}default:n.style.setProperty("--tl-performance-all","auto"),n.style.setProperty("--tl-performance-selected","auto")}}},[e])}function vU(e){var t=e,{id:n,bounds:r,rotation:i=0,isGhost:o=!1,isSelected:a=!1,children:s}=t,u=yd(t,["id","bounds","rotation","isGhost","isSelected","children"]);let d=hA(r,i);return l.createElement("div",lt({id:n,ref:d,className:`tl-positioned${o?" tl-ghost":""}${a?" tl-positioned-selected":""}`,"aria-label":"container","data-testid":"container"},u),s)}var kh=l.memo(vU);function yU({brush:e,zoom:t,dashed:n}){return l.createElement(kh,{bounds:e,rotation:0},l.createElement(xi,null,l.createElement("rect",{className:"tl-brush"+(n?" dashed":""),opacity:1,x:0,y:0,width:e.width,height:e.height,"aria-label":"brush"}),n&&l.createElement("g",{className:"tl-dashed-brush-line"},l.createElement(Xf,{x1:0,y1:0,x2:e.width,y2:0,zoom:t}),l.createElement(Xf,{x1:e.width,y1:0,x2:e.width,y2:e.height,zoom:t}),l.createElement(Xf,{x1:0,y1:e.height,x2:e.width,y2:e.height,zoom:t}),l.createElement(Xf,{x1:0,y1:0,x2:0,y2:e.height,zoom:t}))))}var EU=l.memo(yU);function Xf({x1:e,y1:t,x2:n,y2:r,zoom:i}){let o=Fr.getPerfectDashProps(Math.hypot(n-e,r-t),1/i,"dashed",1,!0,3);return l.createElement("line",{x1:e,y1:t,x2:n,y2:r,strokeWidth:1/i,strokeDasharray:o.strokeDasharray,strokeDashoffset:o.strokeDashoffset})}var CU=l.memo(({color:e})=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 35 35",fill:"none",fillRule:"evenodd"},l.createElement("g",{fill:"rgba(0,0,0,.2)",transform:"translate(1,1)"},l.createElement("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),l.createElement("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})),l.createElement("g",{fill:"white"},l.createElement("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),l.createElement("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})),l.createElement("g",{fill:e},l.createElement("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),l.createElement("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"}))));function bU({points:e,zoom:t}){if(e.length===0)return null;let n=Fr.getSvgPathFromStroke(Ah(e,{size:16/t,start:{taper:!0}}));return l.createElement("path",{d:n,className:"tl-erase-line"})}var wU=l.memo(bU),o6=[[-1,.15,64],[.05,.375,16],[.15,1,4],[.7,2.5,1]];function SU({grid:e,camera:t}){return l.createElement("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},l.createElement("defs",null,o6.map(([n,r,i],o)=>{let a=i*e*t.zoom,s=t.point[0]*t.zoom,u=t.point[1]*t.zoom,d=s>0?s%a:a+s%a,h=u>0?u%a:a+u%a,p=t.zooml.createElement("rect",{key:`grid-rect-${r}`,width:"100%",height:"100%",fill:`url(#grid-${r})`})))}function xU({camera:{zoom:e,point:t},children:n}){let r=2.5/e;return l.createElement("svg",{className:"tl-overlay"},l.createElement("defs",null,l.createElement("g",{id:"tl-snap-point"},l.createElement("path",{className:"tl-snap-point",d:`M ${-r},${-r} L ${r},${r} M ${-r},${r} L ${r},${-r}`}))),l.createElement("g",{transform:`scale(${e}) translate(${t})`},n))}var AU=l.memo(xU),xi=l.memo(l.forwardRef(function(e,t){var n=e,{id:r,className:i="",children:o}=n,a=yd(n,["id","className","children"]);return l.createElement("svg",lt({ref:t,className:`tl-positioned-svg ${i}`},a),l.createElement("g",{id:r,className:"tl-centered-g"},o))}));function kU({bounds:e,isLocked:t,isHidden:n}){return l.createElement("rect",{className:["tl-bounds-center",t?"tl-dashed":""].join(" "),x:-1,y:-1,width:e.width+2,height:e.height+2,opacity:n?0:1,pointerEvents:"none","aria-label":"center handle"})}var IU=l.memo(kU),DU={right:0,bottomRight:45,bottom:90,bottomLeft:135,left:180,topLeft:225,top:270,topRight:315};function TU({bounds:e,side:t,targetSize:n,size:r}){let i=n*2,o={left:-i,topLeft:-i,bottomLeft:-i,right:e.width,topRight:e.width,bottomRight:e.width,top:e.width/2-i/2,bottom:e.width/2-i/2}[t],a={left:e.height/2-i/2,right:e.height/2-i/2,top:-i*2,topLeft:-i,topRight:-i,bottom:e.height,bottomLeft:e.height,bottomRight:e.height}[t],{callbacks:s,inputs:u}=Jn(),d=l.useCallback(h=>{var p;h.stopPropagation();let g=u.pointerDown(h,t);(p=s.onShapeClone)==null||p.call(s,g,h)},[s.onShapeClone]);return l.createElement("g",{className:"tl-clone-target",transform:`translate(${o}, ${a})`,"aria-label":"clone button"},l.createElement("rect",{className:"tl-transparent",width:n*2,height:n*2}),l.createElement("g",{className:"tl-clone-button-target",onPointerDown:d,transform:`translate(${n}, ${n}) rotate(${DU[t]})`},l.createElement("circle",{className:"tl-transparent ",r:n}),l.createElement("path",{className:"tl-clone-button",d:`M -${r/2},-${r/2} L ${r/2},0 -${r/2},${r/2} Z`,strokeLinejoin:"round"})))}var Gs=l.memo(TU);function PU({targetSize:e,size:t,bounds:n}){return l.createElement(l.Fragment,null,l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"top"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"right"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottom"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"left"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"topLeft"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"topRight"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottomLeft"}),l.createElement(Gs,{targetSize:e,size:t,bounds:n,side:"bottomRight"}))}var BU=l.memo(PU),MU={top_left_corner:"tl-cursor-nwse",top_right_corner:"tl-cursor-nesw",bottom_right_corner:"tl-cursor-nwse",bottom_left_corner:"tl-cursor-nesw"};function $U({size:e,targetSize:t,isHidden:n,corner:r,bounds:i}){let o=Oc(r),a=r==="top_left_corner"||r==="top_right_corner",s=r==="top_left_corner"||r==="bottom_left_corner";return l.createElement("g",{opacity:n?0:1},l.createElement("rect",lt({className:"tl-transparent "+(n?"":MU[r]),"aria-label":"corner transparent",x:(s?-1:i.width+1)-t,y:(a?-1:i.height+1)-t,width:t*2,height:t*2,pointerEvents:n?"none":"all"},o)),l.createElement("rect",{className:"tl-corner-handle","aria-label":"corner handle",x:(s?-1:i.width+1)-e/2,y:(a?-1:i.height+1)-e/2,width:e,height:e,pointerEvents:"none"}))}var Zf=l.memo($U),RU={top_edge:"tl-cursor-ns",right_edge:"tl-cursor-ew",bottom_edge:"tl-cursor-ns",left_edge:"tl-cursor-ew"};function FU({size:e,isHidden:t,bounds:n,edge:r}){let i=Oc(r),o=r==="top_edge"||r==="bottom_edge",a=r==="right_edge"||r==="bottom_edge",{height:s,width:u}=n;return l.createElement("rect",lt({pointerEvents:t?"none":"all",className:"tl-transparent tl-edge-handle "+(t?"":RU[r]),"aria-label":`${r} handle`,opacity:t?0:1,x:o?e/2:(a?u+1:-1)-e/2,y:o?(a?s+1:-1)-e/2:e/2,width:o?Math.max(0,u+1-e):e,height:o?e:Math.max(0,s+1-e)},i))}var Qf=l.memo(FU);function LU({size:e,bounds:t,isHidden:n}){let r=Oc("left"),i=Oc("center"),o=Oc("right");return l.createElement("g",{cursor:"grab",transform:`translate(${t.width/2-e*4}, ${t.height+e*2})`,"aria-label":"link handle"},l.createElement("g",{className:"tl-transparent",pointerEvents:n?"none":"all"},l.createElement("rect",lt({x:0,y:0,width:e*2,height:e*2},r)),l.createElement("rect",lt({x:e*3,y:0,width:e*2,height:e*2},i)),l.createElement("rect",lt({x:e*6,y:0,width:e*2,height:e*2},o))),l.createElement("g",{className:"tl-rotate-handle",transform:`translate(${e/2}, ${e/2})`,"aria-label":"link rotate handle"},l.createElement("path",{d:`M 0,${e/2} L ${e},${e} ${e},0 Z`,pointerEvents:"none",opacity:n?0:1}),l.createElement("path",{transform:`translate(${e*3}, 0)`,d:`M 0,0 L ${e},0 ${e/2},${e} Z`,pointerEvents:"none",opacity:n?0:1}),l.createElement("path",{transform:`translate(${e*6}, 0)`,d:`M ${e},${e/2} L 0,0 0,${e} Z`,pointerEvents:"none",opacity:n?0:1})))}var OU=l.memo(LU);function _U({bounds:e,targetSize:t,size:n,isHidden:r}){let i=Oc("rotate");return l.createElement("g",{cursor:"grab",opacity:r?0:1},l.createElement("circle",lt({className:"tl-transparent","aria-label":"rotate handle transparent",cx:e.width/2,cy:n*-2,r:t,pointerEvents:r?"none":"all"},i)),l.createElement("circle",{className:"tl-rotate-handle","aria-label":"rotate handle",cx:e.width/2,cy:n*-2,r:n/2,pointerEvents:"none"}))}var NU=l.memo(_U),zU=function({zoom:e,bounds:t,viewportWidth:n,rotation:r,isHidden:i,isLocked:o,hideCloneHandles:a,hideResizeHandles:s,hideRotateHandle:u,hideBindingHandles:d}){let h=(n<768?16:8)/e,p=8/e,g=Math.min(t.width,t.height)*e,m=!u&&!i&&!o&&g>32,v=!i&&!o&&g>24,E=!i&&!o&&g>20,w=!a&&g>24;return l.createElement(kh,{bounds:t,rotation:r},l.createElement(xi,null,l.createElement(IU,{bounds:t,isLocked:o,isHidden:i}),!s&&!o?l.createElement(l.Fragment,null,l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"top_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"right_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"bottom_edge",isHidden:!v}),l.createElement(Qf,{targetSize:h,size:p,bounds:t,edge:"left_edge",isHidden:!v}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"top_left_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"top_right_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"bottom_right_corner"}),l.createElement(Zf,{targetSize:h,size:p,bounds:t,isHidden:i||!E,corner:"bottom_left_corner"})):null,m&&l.createElement(NU,{targetSize:h,size:p,bounds:t,isHidden:!v}),w&&l.createElement(BU,{bounds:t,targetSize:h,size:p}),!d&&l.createElement(OU,{targetSize:h,size:p,bounds:t,isHidden:!v})))},HU=l.memo(zU);function jU({bounds:e,rotation:t,isHidden:n}){let r=pU();return l.createElement(kh,{bounds:e,rotation:t},l.createElement(xi,null,l.createElement("rect",lt({className:"tl-bounds-bg","aria-label":"bounds bg",width:e.width,height:e.height,opacity:n?0:1},r))))}var UU=l.memo(jU);function KU({id:e,point:t}){let n=hU(e);return l.createElement(kh,{bounds:Fr.translateBounds({minX:0,minY:0,maxX:0,maxY:0,width:0,height:0},t)},l.createElement(xi,null,l.createElement("g",lt({className:"tl-handle","aria-label":"handle"},n),l.createElement("circle",{className:"tl-handle-bg",pointerEvents:"all"}),l.createElement("circle",{className:"tl-counter-scaled tl-handle",pointerEvents:"none",r:4}))))}var VU=l.memo(KU);function GU({shape:e,zoom:t}){if(e.handles===void 0)return null;let n=null,r=Object.values(e.handles).reduce((i,o)=>{let a=te.add(o.point,e.point);return(!n||te.dist(a,n)*t>=32)&&(i.push(o),n=a),i},[]);return r.length===1?null:l.createElement(l.Fragment,null,r.map(i=>l.createElement(VU,{key:e.id+"_"+i.id,id:i.id,point:te.add(i.point,e.point)})))}var JU=l.memo(GU);function WU(e){let t=e.utils.getRef(e.shape);return l.createElement(e.utils.Component,lt({ref:t},e))}var YU=l.memo(WU,(e,t)=>e.isHovered!==t.isHovered||e.isSelected!==t.isSelected||e.isEditing!==t.isEditing||e.isBinding!==t.isBinding||e.isGhost!==t.isGhost||e.meta!==t.meta?!1:t.shape!==e.shape?!t.utils.shouldRender(t.shape,e.shape):!0);function qU(e){var t=e,{shape:n,utils:r,meta:i}=t,o=yd(t,["shape","utils","meta"]);let{callbacks:a}=Jn(),s=r.getBounds(n),u=eU(n.id);return l.createElement(kh,{id:n.id,bounds:s,rotation:n.rotation,"data-shape":n.type,isGhost:o.isGhost,isSelected:o.isSelected},l.createElement(YU,lt({shape:n,utils:r,meta:i,events:u,bounds:s,onShapeChange:a.onShapeChange,onShapeBlur:a.onShapeBlur},o)))}var XU=l.memo(qU);function ZU(e){var t=e,{shape:n,utils:r,meta:i,children:o}=t,a=yd(t,["shape","utils","meta","children"]);return l.createElement(l.Fragment,null,l.createElement(XU,lt({shape:n,utils:r[n.type],meta:i},a)),o&&o.map(s=>l.createElement(fA,lt({key:s.shape.id,utils:r},s))))}var fA=l.memo(ZU);function QU({isHovered:e=!1,isSelected:t=!1,isEditing:n=!1,shape:r,user:i,meta:o}){let{shapeUtils:a}=Jn(),s=a[r.type],u=s.getBounds(r),d=hA(u,r.rotation);return l.createElement("div",{ref:d,draggable:!1,className:["tl-indicator","tl-absolute",t&&!i?"tl-selected":"tl-hovered",n?"tl-editing":"",r.isLocked?"tl-locked":""].join(" ")},l.createElement("svg",{width:"100%",height:"100%"},l.createElement("g",{className:"tl-centered-g",stroke:i==null?void 0:i.color},l.createElement(s.Indicator,{shape:r,meta:o,user:i,bounds:u,isSelected:t,isHovered:e}))))}var oy=l.memo(QU);function eK({page:e,pageState:t,assets:n,hideBounds:r,hideHandles:i,hideIndicators:o,hideBindingHandles:a,hideCloneHandles:s,hideRotateHandle:u,hideResizeHandles:d,meta:h}){let{bounds:p,shapeUtils:g}=Jn(),m=nU(e,t,n,h),{bounds:v,isLinked:E,isLocked:w,rotation:C}=dU(e,t,g),{selectedIds:b,hoveredId:A,editingId:T,camera:{zoom:B}}=t,D=o,I=!0,M=!1,O,z=b.map(K=>e.shapes[K]);if(z.length===1){let K=z[0];M=T===K.id,M&&(D=!0);let X=g[K.type];I=s||!X.showCloneHandles,K.handles!==void 0&&!M&&(O=K)}return l.createElement(l.Fragment,null,v&&l.createElement(UU,{bounds:v,rotation:C,isHidden:r}),m.map(K=>l.createElement(fA,lt({key:K.shape.id,utils:g},K))),!D&&z.map(K=>l.createElement(oy,{key:"selected_"+K.id,shape:K,meta:h,isSelected:!0,isEditing:M})),!D&&A&&A!==T&&l.createElement(oy,{key:"hovered_"+A,shape:e.shapes[A],meta:h,isHovered:!0}),v&&l.createElement(HU,{zoom:B,bounds:v,viewportWidth:p.width,isLocked:w,rotation:C,isHidden:r,hideRotateHandle:u,hideResizeHandles:d,hideBindingHandles:a||!E,hideCloneHandles:I}),!i&&O&&l.createElement(JU,{shape:O,zoom:B}))}var tK=l.memo(eK);function nK({snapLines:e}){return l.createElement(l.Fragment,null,e.map((t,n)=>l.createElement(iK,{key:n,snapLine:t})))}function rK({snapLine:e}){let t=Fr.getBoundsFromPoints(e);return l.createElement(l.Fragment,null,l.createElement("line",{className:"tl-snap-line",x1:t.minX,y1:t.minY,x2:t.maxX,y2:t.maxY}),e.map(([n,r],i)=>l.createElement("use",{key:i,href:"#tl-snap-point",x:n,y:r})))}var iK=l.memo(rK),oK=l.memo(nK);function aK({user:e,Cursor:t}){let n=l.useRef(null);return l.useLayoutEffect(()=>{n.current&&(n.current.style.transform=`translate(${e.point[0]}px, ${e.point[1]}px)`)},[e.point]),l.createElement("div",{ref:n,className:`tl-absolute tl-user tl-counter-scaled ${e.session?"":"tl-animated"}`},l.createElement(t,{id:e.id,color:e.color,metadata:e.metadata}))}function sK({userId:e,users:t,Cursor:n}){return l.createElement(l.Fragment,null,Object.values(t).filter(r=>r&&r.id!==e).map(r=>l.createElement(aK,{key:r.id,user:r,Cursor:n})))}function uK({userId:e,users:t,meta:n,page:r}){let{shapeUtils:i}=Jn();return l.createElement(l.Fragment,null,Object.values(t).filter(Boolean).filter(o=>o.id!==e&&o.selectedIds.length>0).map(o=>{let a=o.selectedIds.map(u=>r.shapes[u]).filter(Boolean);if(a.length===0)return null;let s=Fr.getCommonBounds(a.map(u=>i[u.type].getBounds(u)));return l.createElement(l.Fragment,{key:o.id+"_shapes"},l.createElement("div",{className:"tl-absolute tl-user-indicator-bounds",style:{backgroundColor:o.color+"0d",borderColor:o.color+"78",transform:`translate(${s.minX}px, ${s.minY}px)`,width:s.width,height:s.height,pointerEvents:"none"}}),a.map(u=>l.createElement(oy,{key:`${o.id}_${u.id}_indicator`,shape:u,user:o,meta:n,isHovered:!0})))}))}var lK=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:n}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return t;t=t.parentElement}return document};function cK(e,t){let{inputs:n,callbacks:r}=Jn(),i=l.useRef(!1),o=l.useCallback(()=>{var a,s;if(i.current){let u=(a=e.current)==null?void 0:a.getBoundingClientRect();if(u){let d={minX:u.left,maxX:u.left+u.width,minY:u.top,maxY:u.top+u.height,width:u.width,height:u.height};n.bounds=d,t(d),(s=r.onBoundsChange)==null||s.call(r,d)}}else i.current=!0},[e,n,r.onBoundsChange]);l.useEffect(()=>{let a=e.current?lK(e.current):document,s=N.debounce(o,100);return a.addEventListener("scroll",s),window.addEventListener("resize",s),()=>{a.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[]),l.useEffect(()=>{let a=new ResizeObserver(s=>{n.isPinching||s[0].contentRect&&o()});return e.current&&a.observe(e.current),()=>{a.disconnect()}},[e,n]),l.useEffect(()=>{o()},[e])}function dK({id:e,page:t,pageState:n,assets:r,snapLines:i,eraseLine:o,grid:a,users:s,userId:u,components:d={},meta:h,performanceMode:p,showDashedBrush:g,hideHandles:m,hideBounds:v,hideIndicators:E,hideBindingHandles:w,hideCloneHandles:C,hideResizeHandles:b,hideRotateHandle:A,hideGrid:T,onBoundsChange:B,hideCursors:D}){var I;let M=l.useRef(null),O=l.useRef(n.camera.zoom);O.current=n.camera.zoom,qj(O,M),cK(M,B),Zj(),fU(M);let z=l.useRef(null),K=l.useRef(null);cU(K,z,n),mU(p,z),gU();let X=Qj();return l.createElement("div",{id:e,className:"tl-container",ref:z},l.createElement("div",lt({id:"canvas",className:"tl-absolute tl-canvas",ref:M},X),!T&&a&&l.createElement(SU,{grid:a,camera:n.camera}),l.createElement("div",{ref:K,className:"tl-absolute tl-layer","data-testid":"layer"},l.createElement(tK,{page:t,pageState:n,assets:r,hideBounds:v,hideIndicators:E,hideHandles:m,hideBindingHandles:w,hideCloneHandles:C,hideResizeHandles:b,hideRotateHandle:A,meta:h}),s&&u&&l.createElement(uK,{userId:u,users:s,page:t,meta:h}),n.brush&&l.createElement(EU,{brush:n.brush,dashed:g,zoom:n.camera.zoom}),s&&!D&&l.createElement(sK,{userId:u,users:s,Cursor:(I=d==null?void 0:d.Cursor)!=null?I:CU})),l.createElement(AU,{camera:n.camera},o&&l.createElement(wU,{points:o,zoom:n.camera.zoom}),i&&l.createElement(oK,{snapLines:i}))))}var hK=l.memo(dK),fK=250,ln=class{constructor(){Ot(this,"pointer"),Ot(this,"keyboard"),Ot(this,"keys",{}),Ot(this,"isPinching",!1),Ot(this,"bounds",{minX:0,maxX:640,minY:0,maxY:480,width:640,height:480}),Ot(this,"pointerUpTime",0),Ot(this,"activePointer"),Ot(this,"panStart",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t,u={target:"wheel",pointerId:((n=this.pointer)==null?void 0:n.pointerId)||0,origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],delta:[0,0],pressure:.5,point:ln.getPoint(t,this.bounds),shiftKey:i,ctrlKey:o,metaKey:a,altKey:s,spaceKey:this.keys[" "]};return this.pointer=u,u}),Ot(this,"pan",(t,n)=>{if(!this.pointer||this.pointer.target!=="wheel")return this.panStart(n);let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=n,s=this.pointer,u=ln.getPoint(n,this.bounds),d=Io(lt({},s),{target:"wheel",delta:t,point:u,shiftKey:r,ctrlKey:i,metaKey:o,altKey:a,spaceKey:this.keys[" "]});return this.pointer=d,d}),Ot(this,"keydown",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t;return this.keys[t.key]=!0,{point:((n=this.pointer)==null?void 0:n.point)||[0,0],origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],key:t.key,keys:Object.keys(this.keys),shiftKey:i,ctrlKey:o,metaKey:N.isDarwin()?a:o,altKey:s}}),Ot(this,"keyup",t=>{var n,r;let{shiftKey:i,ctrlKey:o,metaKey:a,altKey:s}=t;return delete this.keys[t.key],{point:((n=this.pointer)==null?void 0:n.point)||[0,0],origin:((r=this.pointer)==null?void 0:r.origin)||[0,0],key:t.key,keys:Object.keys(this.keys),shiftKey:i,ctrlKey:o,metaKey:N.isDarwin()?a:o,altKey:s}})}pointerIsValid(t){if("pointerId"in t&&this.activePointer&&this.activePointer!==t.pointerId)return!1;if("touches"in t){let n=t.changedTouches[0];if(this.activePointer&&this.activePointer!==n.identifier)return!1}return!0}touchStart(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0];this.activePointer=s.identifier;let u={target:n,pointerId:s.identifier,origin:ln.getPoint(s,this.bounds),delta:[0,0],point:ln.getPoint(s,this.bounds),pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}touchEnd(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0],u={target:n,pointerId:s.identifier,origin:ln.getPoint(s,this.bounds),delta:[0,0],point:ln.getPoint(s,this.bounds),pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,this.activePointer=void 0,u}touchMove(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=t.changedTouches[0],u=this.pointer,d=ln.getPoint(s,this.bounds),h=u!=null&&u.point?te.sub(d,u.point):[0,0],p=Io(lt({origin:d},u),{target:n,pointerId:s.identifier,point:d,delta:h,pressure:ln.getPressure(s),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=p,p}pointerDown(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=ln.getPoint(t,this.bounds);this.activePointer=t.pointerId;let u={target:n,pointerId:t.pointerId,origin:s,point:s,delta:[0,0],pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}pointerEnter(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=ln.getPoint(t,this.bounds),u={target:n,pointerId:t.pointerId,origin:s,delta:[0,0],point:s,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]};return this.pointer=u,u}pointerMove(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=this.pointer,u=ln.getPoint(t,this.bounds),d=s!=null&&s.point?te.sub(u,s.point):[0,0],h=Io(lt({origin:u},s),{target:n,pointerId:t.pointerId,point:u,delta:d,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=h,h}pointerUp(t,n){let{shiftKey:r,ctrlKey:i,metaKey:o,altKey:a}=t,s=this.pointer,u=ln.getPoint(t,this.bounds),d=s!=null&&s.point?te.sub(u,s.point):[0,0];this.activePointer=void 0;let h=Io(lt({origin:u},s),{target:n,pointerId:t.pointerId,point:u,delta:d,pressure:ln.getPressure(t),shiftKey:r,ctrlKey:i,metaKey:N.isDarwin()?o:i,altKey:a,spaceKey:this.keys[" "]});return this.pointer=h,this.pointerUpTime=performance.now(),h}isDoubleClick(){if(!this.pointer)return!1;let{origin:t,point:n}=this.pointer,r=performance.now()-this.pointerUpTime{Z.current=o},[o]);let[pe,me]=l.useState(()=>({callbacks:K,shapeUtils:r,rSelectionBounds:X,rPageState:Z,bounds:{minX:0,minY:0,maxX:1/0,maxY:1/0,width:1/0,height:1/0},inputs:new ln})),Ce=l.useCallback(W=>{me(U=>Io(lt({},U),{bounds:W}))},[]);return l.createElement(CE.Provider,{value:pe},l.createElement(hK,{id:n,page:i,pageState:o,assets:a,snapLines:p,eraseLine:g,grid:m,users:s,userId:u,externalContainerRef:v,hideBounds:I,hideIndicators:b,hideHandles:C,hideCloneHandles:A,hideBindingHandles:T,hideRotateHandle:D,hideResizeHandles:B,hideGrid:M,showDashedBrush:O,onBoundsChange:Ce,performanceMode:E,components:w,meta:h,hideCursors:z}))}var mK=l.memo(gK),Tm=l.memo(l.forwardRef(function(e,t){var n=e,{children:r,className:i=""}=n,o=yd(n,["children","className"]);return l.createElement("div",lt({ref:t,className:`tl-positioned-div ${i}`,draggable:!1},o),l.createElement("div",{className:"tl-inner-div"},r))})),ay=class{constructor(){Ot(this,"refMap",new Map),Ot(this,"boundsCache",new WeakMap),Ot(this,"showCloneHandles",!1),Ot(this,"hideBounds",!1),Ot(this,"isStateful",!1),Ot(this,"shouldRender",(e,t)=>!0),Ot(this,"getRef",e=>(this.refMap.has(e.id)||this.refMap.set(e.id,l.createRef()),this.refMap.get(e.id))),Ot(this,"hitTestBounds",(e,t)=>{let n=this.getBounds(e),r=Fr.getRotatedCorners(n,e.rotation);return r.every(i=>Fr.pointInBounds(i,t))||Uj(r,t).length>0}),Ot(this,"getRotatedBounds",e=>Fr.getBoundsFromPoints(Fr.getRotatedCorners(this.getBounds(e),e.rotation)))}};Ot(ay,"Component",e=>l.forwardRef(e)),Ot(ay,"Indicator",e=>e);/** * String.prototype.replaceAll() polyfill * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/ * @author Chris Ferdinandi * @license MIT -*/function ay(e,t){return ay=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},ay(e,t)}function vK(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ay(e,t)}var yK=function(t,n){return t===void 0&&(t=[]),n===void 0&&(n=[]),t.length!==n.length||t.some(function(r,i){return!Object.is(r,n[i])})},a6={error:null},EK=function(e){vK(t,e);function t(){for(var r,i=arguments.length,o=new Array(i),a=0;a0}),n=[],r=0,i=t;r1)throw new RangeError("integer-width stems only accept a single optional option");i.options[0].replace(FK,function(u,d,h,p,g,m){if(d)t.minimumIntegerDigits=h.length;else{if(p&&g)throw new Error("We currently do not support maximum integer digits");if(m)throw new Error("We currently do not support exact integer digits")}return""});continue}if(DA.test(i.stem)){t.minimumIntegerDigits=i.stem.length;continue}if(u6.test(i.stem)){if(i.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");i.stem.replace(u6,function(u,d,h,p,g,m){return h==="*"?t.minimumFractionDigits=d.length:p&&p[0]==="#"?t.maximumFractionDigits=p.length:g&&m?(t.minimumFractionDigits=g.length,t.maximumFractionDigits=g.length+m.length):(t.minimumFractionDigits=d.length,t.maximumFractionDigits=d.length),""});var o=i.options[0];o==="w"?t=Ee(Ee({},t),{trailingZeroDisplay:"stripIfInteger"}):o&&(t=Ee(Ee({},t),l6(o)));continue}if(IA.test(i.stem)){t=Ee(Ee({},t),l6(i.stem));continue}var a=TA(i.stem);a&&(t=Ee(Ee({},t),a));var s=LK(i.stem);s&&(t=Ee(Ee({},t),s))}return t}var ep={"001":["H","h"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["H","h","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["H","hB","h","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["H","h","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["H","h","hB","hb"],CU:["H","h","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["H","hB","h","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GT:["H","h","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["H","h","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["H","h","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["H","h","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["H","hB","h","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["H","h","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["H","h","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["H","h","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"es-BO":["H","h","hB","hb"],"es-BR":["H","h","hB","hb"],"es-EC":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"es-PE":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function _K(e,t){for(var n="",r=0;r>1),u="a",d=NK(t);for((d=="H"||d=="k")&&(s=0);s-- >0;)n+=u;for(;a-- >0;)n=d+n}else i==="J"?n+="H":n+=i}return n}function NK(e){var t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}var n=e.language,r;n!=="root"&&(r=e.maximize().region);var i=ep[r||""]||ep[n||""]||ep["".concat(n,"-001")]||ep["001"];return i[0]}var bv,zK=new RegExp("^".concat(kA.source,"*")),HK=new RegExp("".concat(kA.source,"*$"));function ot(e,t){return{start:e,end:t}}var jK=!!String.prototype.startsWith&&"_a".startsWith("a",1),UK=!!String.fromCodePoint,KK=!!Object.fromEntries,VK=!!String.prototype.codePointAt,GK=!!String.prototype.trimStart,JK=!!String.prototype.trimEnd,WK=!!Number.isSafeInteger,YK=WK?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},ly=!0;try{var qK=BA("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");ly=((bv=qK.exec("a"))===null||bv===void 0?void 0:bv[0])==="a"}catch{ly=!1}var d6=jK?function(t,n,r){return t.startsWith(n,r)}:function(t,n,r){return t.slice(r,r+n.length)===n},cy=UK?String.fromCodePoint:function(){for(var t=[],n=0;no;){if(a=t[o++],a>1114111)throw RangeError(a+" is not a valid code point");r+=a<65536?String.fromCharCode(a):String.fromCharCode(((a-=65536)>>10)+55296,a%1024+56320)}return r},h6=KK?Object.fromEntries:function(t){for(var n={},r=0,i=t;r=r)){var i=t.charCodeAt(n),o;return i<55296||i>56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?i:(i-55296<<10)+(o-56320)+65536}},XK=GK?function(t){return t.trimStart()}:function(t){return t.replace(zK,"")},ZK=JK?function(t){return t.trimEnd()}:function(t){return t.replace(HK,"")};function BA(e,t){return new RegExp(e,t)}var dy;if(ly){var f6=BA("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");dy=function(t,n){var r;f6.lastIndex=n;var i=f6.exec(t);return(r=i[1])!==null&&r!==void 0?r:""}}else dy=function(t,n){for(var r=[];;){var i=PA(t,n);if(i===void 0||MA(i)||nV(i))break;r.push(i),n+=i>=65536?2:1}return cy.apply(void 0,r)};var QK=function(){function e(t,n){n===void 0&&(n={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!n.ignoreTag,this.locale=n.locale,this.requiresOtherClause=!!n.requiresOtherClause,this.shouldParseSkeletons=!!n.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,n,r){for(var i=[];!this.isEOF();){var o=this.char();if(o===123){var a=this.parseArgument(t,r);if(a.err)return a;i.push(a.val)}else{if(o===125&&t>0)break;if(o===35&&(n==="plural"||n==="selectordinal")){var s=this.clonePosition();this.bump(),i.push({type:Mt.pound,location:ot(s,this.clonePosition())})}else if(o===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(it.UNMATCHED_CLOSING_TAG,ot(this.clonePosition(),this.clonePosition()))}else if(o===60&&!this.ignoreTag&&hy(this.peek()||0)){var a=this.parseTag(t,n);if(a.err)return a;i.push(a.val)}else{var a=this.parseLiteral(t,n);if(a.err)return a;i.push(a.val)}}}return{val:i,err:null}},e.prototype.parseTag=function(t,n){var r=this.clonePosition();this.bump();var i=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:Mt.literal,value:"<".concat(i,"/>"),location:ot(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var o=this.parseMessage(t+1,n,!0);if(o.err)return o;var a=o.val,s=this.clonePosition();if(this.bumpIf("")?{val:{type:Mt.tag,value:i,children:a,location:ot(r,this.clonePosition())},err:null}:this.error(it.INVALID_TAG,ot(s,this.clonePosition())))}else return this.error(it.UNCLOSED_TAG,ot(r,this.clonePosition()))}else return this.error(it.INVALID_TAG,ot(r,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&tV(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,n){for(var r=this.clonePosition(),i="";;){var o=this.tryParseQuote(n);if(o){i+=o;continue}var a=this.tryParseUnquoted(t,n);if(a){i+=a;continue}var s=this.tryParseLeftAngleBracket();if(s){i+=s;continue}break}var u=ot(r,this.clonePosition());return{val:{type:Mt.literal,value:i,location:u},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!eV(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var n=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(r===39)if(this.peek()===39)n.push(39),this.bump();else{this.bump();break}else n.push(r);this.bump()}return cy.apply(void 0,n)},e.prototype.tryParseUnquoted=function(t,n){if(this.isEOF())return null;var r=this.char();return r===60||r===123||r===35&&(n==="plural"||n==="selectordinal")||r===125&&t>0?null:(this.bump(),cy(r))},e.prototype.parseArgument=function(t,n){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(it.EMPTY_ARGUMENT,ot(r,this.clonePosition()));var i=this.parseIdentifierIfPossible().value;if(!i)return this.error(it.MALFORMED_ARGUMENT,ot(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:Mt.argument,value:i,location:ot(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition())):this.parseArgumentOptions(t,n,i,r);default:return this.error(it.MALFORMED_ARGUMENT,ot(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),n=this.offset(),r=dy(this.message,n),i=n+r.length;this.bumpTo(i);var o=this.clonePosition(),a=ot(t,o);return{value:r,location:a}},e.prototype.parseArgumentOptions=function(t,n,r,i){var o,a=this.clonePosition(),s=this.parseIdentifierIfPossible().value,u=this.clonePosition();switch(s){case"":return this.error(it.EXPECT_ARGUMENT_TYPE,ot(a,u));case"number":case"date":case"time":{this.bumpSpace();var d=null;if(this.bumpIf(",")){this.bumpSpace();var h=this.clonePosition(),p=this.parseSimpleArgStyleIfPossible();if(p.err)return p;var g=ZK(p.val);if(g.length===0)return this.error(it.EXPECT_ARGUMENT_STYLE,ot(this.clonePosition(),this.clonePosition()));var m=ot(h,this.clonePosition());d={style:g,styleLocation:m}}var v=this.tryParseArgumentClose(i);if(v.err)return v;var E=ot(i,this.clonePosition());if(d&&d6(d==null?void 0:d.style,"::",0)){var w=XK(d.style.slice(2));if(s==="number"){var p=this.parseNumberSkeletonFromString(w,d.styleLocation);return p.err?p:{val:{type:Mt.number,value:r,location:E,style:p.val},err:null}}else{if(w.length===0)return this.error(it.EXPECT_DATE_TIME_SKELETON,E);var C=w;this.locale&&(C=_K(w,this.locale));var g={type:Zc.dateTime,pattern:C,location:d.styleLocation,parsedOptions:this.shouldParseSkeletons?BK(C):{}},b=s==="date"?Mt.date:Mt.time;return{val:{type:b,value:r,location:E,style:g},err:null}}}return{val:{type:s==="number"?Mt.number:s==="date"?Mt.date:Mt.time,value:r,location:E,style:(o=d==null?void 0:d.style)!==null&&o!==void 0?o:null},err:null}}case"plural":case"selectordinal":case"select":{var A=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(it.EXPECT_SELECT_ARGUMENT_OPTIONS,ot(A,Ee({},A)));this.bumpSpace();var T=this.parseIdentifierIfPossible(),B=0;if(s!=="select"&&T.value==="offset"){if(!this.bumpIf(":"))return this.error(it.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,ot(this.clonePosition(),this.clonePosition()));this.bumpSpace();var p=this.tryParseDecimalInteger(it.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,it.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(p.err)return p;this.bumpSpace(),T=this.parseIdentifierIfPossible(),B=p.val}var D=this.tryParsePluralOrSelectOptions(t,s,n,T);if(D.err)return D;var v=this.tryParseArgumentClose(i);if(v.err)return v;var I=ot(i,this.clonePosition());return s==="select"?{val:{type:Mt.select,value:r,options:h6(D.val),location:I},err:null}:{val:{type:Mt.plural,value:r,options:h6(D.val),offset:B,pluralType:s==="plural"?"cardinal":"ordinal",location:I},err:null}}default:return this.error(it.INVALID_ARGUMENT_TYPE,ot(a,u))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,n=this.clonePosition();!this.isEOF();){var r=this.char();switch(r){case 39:{this.bump();var i=this.clonePosition();if(!this.bumpUntil("'"))return this.error(it.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,ot(i,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(n.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(n.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,n){var r=[];try{r=$K(t)}catch{return this.error(it.INVALID_NUMBER_SKELETON,n)}return{val:{type:Zc.number,tokens:r,location:n,parsedOptions:this.shouldParseSkeletons?OK(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,n,r,i){for(var o,a=!1,s=[],u=new Set,d=i.value,h=i.location;;){if(d.length===0){var p=this.clonePosition();if(n!=="select"&&this.bumpIf("=")){var g=this.tryParseDecimalInteger(it.EXPECT_PLURAL_ARGUMENT_SELECTOR,it.INVALID_PLURAL_ARGUMENT_SELECTOR);if(g.err)return g;h=ot(p,this.clonePosition()),d=this.message.slice(p.offset,this.offset())}else break}if(u.has(d))return this.error(n==="select"?it.DUPLICATE_SELECT_ARGUMENT_SELECTOR:it.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,h);d==="other"&&(a=!0),this.bumpSpace();var m=this.clonePosition();if(!this.bumpIf("{"))return this.error(n==="select"?it.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:it.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,ot(this.clonePosition(),this.clonePosition()));var v=this.parseMessage(t+1,n,r);if(v.err)return v;var E=this.tryParseArgumentClose(m);if(E.err)return E;s.push([d,{value:v.val,location:ot(m,this.clonePosition())}]),u.add(d),this.bumpSpace(),o=this.parseIdentifierIfPossible(),d=o.value,h=o.location}return s.length===0?this.error(n==="select"?it.EXPECT_SELECT_ARGUMENT_SELECTOR:it.EXPECT_PLURAL_ARGUMENT_SELECTOR,ot(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!a?this.error(it.MISSING_OTHER_CLAUSE,ot(this.clonePosition(),this.clonePosition())):{val:s,err:null}},e.prototype.tryParseDecimalInteger=function(t,n){var r=1,i=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var o=!1,a=0;!this.isEOF();){var s=this.char();if(s>=48&&s<=57)o=!0,a=a*10+(s-48),this.bump();else break}var u=ot(i,this.clonePosition());return o?(a*=r,YK(a)?{val:a,err:null}:this.error(n,u)):this.error(t,u)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var n=PA(this.message,t);if(n===void 0)throw Error("Offset ".concat(t," is at invalid UTF-16 code unit boundary"));return n},e.prototype.error=function(t,n){return{val:null,err:{kind:t,message:this.message,location:n}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(d6(this.message,t,this.offset())){for(var n=0;n=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset ".concat(t," must be greater than or equal to the current offset ").concat(this.offset()));for(t=Math.min(t,this.message.length);;){var n=this.offset();if(n===t)break;if(n>t)throw Error("targetOffset ".concat(t," is at invalid UTF-16 code unit boundary"));if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&MA(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),n=this.offset(),r=this.message.charCodeAt(n+(t>=65536?2:1));return r??null},e}();function hy(e){return e>=97&&e<=122||e>=65&&e<=90}function eV(e){return hy(e)||e===47}function tV(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function MA(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function nV(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function fy(e){e.forEach(function(t){if(delete t.location,wA(t)||SA(t))for(var n in t.options)delete t.options[n].location,fy(t.options[n].value);else EA(t)&&AA(t.style)||(CA(t)||bA(t))&&uy(t.style)?delete t.style.location:xA(t)&&fy(t.children)})}function rV(e,t){t===void 0&&(t={}),t=Ee({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new QK(e,t).parse();if(n.err){var r=SyntaxError(it[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||fy(n.val),n.val}function bo(e,t){var n=t&&t.cache?t.cache:lV,r=t&&t.serializer?t.serializer:uV,i=t&&t.strategy?t.strategy:oV;return i(e,{cache:n,serializer:r})}function iV(e){return e==null||typeof e=="number"||typeof e=="boolean"}function $A(e,t,n,r){var i=iV(r)?r:n(r),o=t.get(i);return typeof o>"u"&&(o=e.call(this,r),t.set(i,o)),o}function RA(e,t,n){var r=Array.prototype.slice.call(arguments,3),i=n(r),o=t.get(i);return typeof o>"u"&&(o=e.apply(this,r),t.set(i,o)),o}function SE(e,t,n,r,i){return n.bind(t,e,r,i)}function oV(e,t){var n=e.length===1?$A:RA;return SE(e,this,n,t.cache.create(),t.serializer)}function aV(e,t){return SE(e,this,RA,t.cache.create(),t.serializer)}function sV(e,t){return SE(e,this,$A,t.cache.create(),t.serializer)}var uV=function(){return JSON.stringify(arguments)};function xE(){this.cache=Object.create(null)}xE.prototype.get=function(e){return this.cache[e]};xE.prototype.set=function(e,t){this.cache[e]=t};var lV={create:function(){return new xE}},wo={variadic:aV,monadic:sV},Ho;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Ho||(Ho={}));var Ru=function(e){Bi(t,e);function t(n,r,i){var o=e.call(this,n)||this;return o.code=r,o.originalMessage=i,o}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error),p6=function(e){Bi(t,e);function t(n,r,i,o){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(i).join('", "'),'"'),Ho.INVALID_VALUE,o)||this}return t}(Ru),cV=function(e){Bi(t,e);function t(n,r,i){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Ho.INVALID_VALUE,i)||this}return t}(Ru),dV=function(e){Bi(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Ho.MISSING_VALUE,r)||this}return t}(Ru),tr;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(tr||(tr={}));function hV(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==tr.literal||n.type!==tr.literal?t.push(n):r.value+=n.value,t},[])}function FA(e){return typeof e=="function"}function Hp(e,t,n,r,i,o,a){if(e.length===1&&s6(e[0]))return[{type:tr.literal,value:e[0].value}];for(var s=[],u=0,d=e;u0}),n=[],r=0,i=t;r1)throw new RangeError("integer-width stems only accept a single optional option");i.options[0].replace(FK,function(u,d,h,p,g,m){if(d)t.minimumIntegerDigits=h.length;else{if(p&&g)throw new Error("We currently do not support maximum integer digits");if(m)throw new Error("We currently do not support exact integer digits")}return""});continue}if(DA.test(i.stem)){t.minimumIntegerDigits=i.stem.length;continue}if(u6.test(i.stem)){if(i.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");i.stem.replace(u6,function(u,d,h,p,g,m){return h==="*"?t.minimumFractionDigits=d.length:p&&p[0]==="#"?t.maximumFractionDigits=p.length:g&&m?(t.minimumFractionDigits=g.length,t.maximumFractionDigits=g.length+m.length):(t.minimumFractionDigits=d.length,t.maximumFractionDigits=d.length),""});var o=i.options[0];o==="w"?t=Ee(Ee({},t),{trailingZeroDisplay:"stripIfInteger"}):o&&(t=Ee(Ee({},t),l6(o)));continue}if(IA.test(i.stem)){t=Ee(Ee({},t),l6(i.stem));continue}var a=TA(i.stem);a&&(t=Ee(Ee({},t),a));var s=LK(i.stem);s&&(t=Ee(Ee({},t),s))}return t}var ep={"001":["H","h"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["H","h","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BI:["H","h"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["H","hB","h","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BY:["H","h"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["H","h","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["H","h","hB","hb"],CU:["H","h","hB","hb"],CV:["H","hB"],CW:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["H","hB","h","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FO:["H","h"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GL:["H","h"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GT:["H","h","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["H","h","hB","hb"],HR:["H","hB"],HU:["H","h"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","K","h"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MG:["H","h"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MT:["H","h"],MU:["H","h"],MV:["H","h"],MW:["h","hb","H","hB"],MX:["H","h","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["H","h","hB","hb"],NL:["H","hB"],NO:["H","h"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["H","hB","h","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PL:["H","h"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["H","h","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],RW:["H","h"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["H","h","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TH:["H","h"],TJ:["H","h"],TL:["H","hB","hb","h"],TM:["H","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["H","h","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VN:["H","h"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],ZW:["H","h"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"es-BO":["H","h","hB","hb"],"es-BR":["H","h","hB","hb"],"es-EC":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"es-PE":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function _K(e,t){for(var n="",r=0;r>1),u="a",d=NK(t);for((d=="H"||d=="k")&&(s=0);s-- >0;)n+=u;for(;a-- >0;)n=d+n}else i==="J"?n+="H":n+=i}return n}function NK(e){var t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}var n=e.language,r;n!=="root"&&(r=e.maximize().region);var i=ep[r||""]||ep[n||""]||ep["".concat(n,"-001")]||ep["001"];return i[0]}var wv,zK=new RegExp("^".concat(kA.source,"*")),HK=new RegExp("".concat(kA.source,"*$"));function ot(e,t){return{start:e,end:t}}var jK=!!String.prototype.startsWith&&"_a".startsWith("a",1),UK=!!String.fromCodePoint,KK=!!Object.fromEntries,VK=!!String.prototype.codePointAt,GK=!!String.prototype.trimStart,JK=!!String.prototype.trimEnd,WK=!!Number.isSafeInteger,YK=WK?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},cy=!0;try{var qK=BA("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");cy=((wv=qK.exec("a"))===null||wv===void 0?void 0:wv[0])==="a"}catch{cy=!1}var d6=jK?function(t,n,r){return t.startsWith(n,r)}:function(t,n,r){return t.slice(r,r+n.length)===n},dy=UK?String.fromCodePoint:function(){for(var t=[],n=0;no;){if(a=t[o++],a>1114111)throw RangeError(a+" is not a valid code point");r+=a<65536?String.fromCharCode(a):String.fromCharCode(((a-=65536)>>10)+55296,a%1024+56320)}return r},h6=KK?Object.fromEntries:function(t){for(var n={},r=0,i=t;r=r)){var i=t.charCodeAt(n),o;return i<55296||i>56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?i:(i-55296<<10)+(o-56320)+65536}},XK=GK?function(t){return t.trimStart()}:function(t){return t.replace(zK,"")},ZK=JK?function(t){return t.trimEnd()}:function(t){return t.replace(HK,"")};function BA(e,t){return new RegExp(e,t)}var hy;if(cy){var f6=BA("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");hy=function(t,n){var r;f6.lastIndex=n;var i=f6.exec(t);return(r=i[1])!==null&&r!==void 0?r:""}}else hy=function(t,n){for(var r=[];;){var i=PA(t,n);if(i===void 0||MA(i)||nV(i))break;r.push(i),n+=i>=65536?2:1}return dy.apply(void 0,r)};var QK=function(){function e(t,n){n===void 0&&(n={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!n.ignoreTag,this.locale=n.locale,this.requiresOtherClause=!!n.requiresOtherClause,this.shouldParseSkeletons=!!n.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,n,r){for(var i=[];!this.isEOF();){var o=this.char();if(o===123){var a=this.parseArgument(t,r);if(a.err)return a;i.push(a.val)}else{if(o===125&&t>0)break;if(o===35&&(n==="plural"||n==="selectordinal")){var s=this.clonePosition();this.bump(),i.push({type:Mt.pound,location:ot(s,this.clonePosition())})}else if(o===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(it.UNMATCHED_CLOSING_TAG,ot(this.clonePosition(),this.clonePosition()))}else if(o===60&&!this.ignoreTag&&fy(this.peek()||0)){var a=this.parseTag(t,n);if(a.err)return a;i.push(a.val)}else{var a=this.parseLiteral(t,n);if(a.err)return a;i.push(a.val)}}}return{val:i,err:null}},e.prototype.parseTag=function(t,n){var r=this.clonePosition();this.bump();var i=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:Mt.literal,value:"<".concat(i,"/>"),location:ot(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var o=this.parseMessage(t+1,n,!0);if(o.err)return o;var a=o.val,s=this.clonePosition();if(this.bumpIf("")?{val:{type:Mt.tag,value:i,children:a,location:ot(r,this.clonePosition())},err:null}:this.error(it.INVALID_TAG,ot(s,this.clonePosition())))}else return this.error(it.UNCLOSED_TAG,ot(r,this.clonePosition()))}else return this.error(it.INVALID_TAG,ot(r,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&tV(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,n){for(var r=this.clonePosition(),i="";;){var o=this.tryParseQuote(n);if(o){i+=o;continue}var a=this.tryParseUnquoted(t,n);if(a){i+=a;continue}var s=this.tryParseLeftAngleBracket();if(s){i+=s;continue}break}var u=ot(r,this.clonePosition());return{val:{type:Mt.literal,value:i,location:u},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!eV(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var n=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(r===39)if(this.peek()===39)n.push(39),this.bump();else{this.bump();break}else n.push(r);this.bump()}return dy.apply(void 0,n)},e.prototype.tryParseUnquoted=function(t,n){if(this.isEOF())return null;var r=this.char();return r===60||r===123||r===35&&(n==="plural"||n==="selectordinal")||r===125&&t>0?null:(this.bump(),dy(r))},e.prototype.parseArgument=function(t,n){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(it.EMPTY_ARGUMENT,ot(r,this.clonePosition()));var i=this.parseIdentifierIfPossible().value;if(!i)return this.error(it.MALFORMED_ARGUMENT,ot(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:Mt.argument,value:i,location:ot(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(r,this.clonePosition())):this.parseArgumentOptions(t,n,i,r);default:return this.error(it.MALFORMED_ARGUMENT,ot(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),n=this.offset(),r=hy(this.message,n),i=n+r.length;this.bumpTo(i);var o=this.clonePosition(),a=ot(t,o);return{value:r,location:a}},e.prototype.parseArgumentOptions=function(t,n,r,i){var o,a=this.clonePosition(),s=this.parseIdentifierIfPossible().value,u=this.clonePosition();switch(s){case"":return this.error(it.EXPECT_ARGUMENT_TYPE,ot(a,u));case"number":case"date":case"time":{this.bumpSpace();var d=null;if(this.bumpIf(",")){this.bumpSpace();var h=this.clonePosition(),p=this.parseSimpleArgStyleIfPossible();if(p.err)return p;var g=ZK(p.val);if(g.length===0)return this.error(it.EXPECT_ARGUMENT_STYLE,ot(this.clonePosition(),this.clonePosition()));var m=ot(h,this.clonePosition());d={style:g,styleLocation:m}}var v=this.tryParseArgumentClose(i);if(v.err)return v;var E=ot(i,this.clonePosition());if(d&&d6(d==null?void 0:d.style,"::",0)){var w=XK(d.style.slice(2));if(s==="number"){var p=this.parseNumberSkeletonFromString(w,d.styleLocation);return p.err?p:{val:{type:Mt.number,value:r,location:E,style:p.val},err:null}}else{if(w.length===0)return this.error(it.EXPECT_DATE_TIME_SKELETON,E);var C=w;this.locale&&(C=_K(w,this.locale));var g={type:Zc.dateTime,pattern:C,location:d.styleLocation,parsedOptions:this.shouldParseSkeletons?BK(C):{}},b=s==="date"?Mt.date:Mt.time;return{val:{type:b,value:r,location:E,style:g},err:null}}}return{val:{type:s==="number"?Mt.number:s==="date"?Mt.date:Mt.time,value:r,location:E,style:(o=d==null?void 0:d.style)!==null&&o!==void 0?o:null},err:null}}case"plural":case"selectordinal":case"select":{var A=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(it.EXPECT_SELECT_ARGUMENT_OPTIONS,ot(A,Ee({},A)));this.bumpSpace();var T=this.parseIdentifierIfPossible(),B=0;if(s!=="select"&&T.value==="offset"){if(!this.bumpIf(":"))return this.error(it.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,ot(this.clonePosition(),this.clonePosition()));this.bumpSpace();var p=this.tryParseDecimalInteger(it.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,it.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(p.err)return p;this.bumpSpace(),T=this.parseIdentifierIfPossible(),B=p.val}var D=this.tryParsePluralOrSelectOptions(t,s,n,T);if(D.err)return D;var v=this.tryParseArgumentClose(i);if(v.err)return v;var I=ot(i,this.clonePosition());return s==="select"?{val:{type:Mt.select,value:r,options:h6(D.val),location:I},err:null}:{val:{type:Mt.plural,value:r,options:h6(D.val),offset:B,pluralType:s==="plural"?"cardinal":"ordinal",location:I},err:null}}default:return this.error(it.INVALID_ARGUMENT_TYPE,ot(a,u))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(it.EXPECT_ARGUMENT_CLOSING_BRACE,ot(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,n=this.clonePosition();!this.isEOF();){var r=this.char();switch(r){case 39:{this.bump();var i=this.clonePosition();if(!this.bumpUntil("'"))return this.error(it.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,ot(i,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(n.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(n.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,n){var r=[];try{r=$K(t)}catch{return this.error(it.INVALID_NUMBER_SKELETON,n)}return{val:{type:Zc.number,tokens:r,location:n,parsedOptions:this.shouldParseSkeletons?OK(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,n,r,i){for(var o,a=!1,s=[],u=new Set,d=i.value,h=i.location;;){if(d.length===0){var p=this.clonePosition();if(n!=="select"&&this.bumpIf("=")){var g=this.tryParseDecimalInteger(it.EXPECT_PLURAL_ARGUMENT_SELECTOR,it.INVALID_PLURAL_ARGUMENT_SELECTOR);if(g.err)return g;h=ot(p,this.clonePosition()),d=this.message.slice(p.offset,this.offset())}else break}if(u.has(d))return this.error(n==="select"?it.DUPLICATE_SELECT_ARGUMENT_SELECTOR:it.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,h);d==="other"&&(a=!0),this.bumpSpace();var m=this.clonePosition();if(!this.bumpIf("{"))return this.error(n==="select"?it.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:it.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,ot(this.clonePosition(),this.clonePosition()));var v=this.parseMessage(t+1,n,r);if(v.err)return v;var E=this.tryParseArgumentClose(m);if(E.err)return E;s.push([d,{value:v.val,location:ot(m,this.clonePosition())}]),u.add(d),this.bumpSpace(),o=this.parseIdentifierIfPossible(),d=o.value,h=o.location}return s.length===0?this.error(n==="select"?it.EXPECT_SELECT_ARGUMENT_SELECTOR:it.EXPECT_PLURAL_ARGUMENT_SELECTOR,ot(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!a?this.error(it.MISSING_OTHER_CLAUSE,ot(this.clonePosition(),this.clonePosition())):{val:s,err:null}},e.prototype.tryParseDecimalInteger=function(t,n){var r=1,i=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var o=!1,a=0;!this.isEOF();){var s=this.char();if(s>=48&&s<=57)o=!0,a=a*10+(s-48),this.bump();else break}var u=ot(i,this.clonePosition());return o?(a*=r,YK(a)?{val:a,err:null}:this.error(n,u)):this.error(t,u)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var n=PA(this.message,t);if(n===void 0)throw Error("Offset ".concat(t," is at invalid UTF-16 code unit boundary"));return n},e.prototype.error=function(t,n){return{val:null,err:{kind:t,message:this.message,location:n}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(d6(this.message,t,this.offset())){for(var n=0;n=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset ".concat(t," must be greater than or equal to the current offset ").concat(this.offset()));for(t=Math.min(t,this.message.length);;){var n=this.offset();if(n===t)break;if(n>t)throw Error("targetOffset ".concat(t," is at invalid UTF-16 code unit boundary"));if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&MA(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),n=this.offset(),r=this.message.charCodeAt(n+(t>=65536?2:1));return r??null},e}();function fy(e){return e>=97&&e<=122||e>=65&&e<=90}function eV(e){return fy(e)||e===47}function tV(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function MA(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function nV(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function py(e){e.forEach(function(t){if(delete t.location,wA(t)||SA(t))for(var n in t.options)delete t.options[n].location,py(t.options[n].value);else EA(t)&&AA(t.style)||(CA(t)||bA(t))&&ly(t.style)?delete t.style.location:xA(t)&&py(t.children)})}function rV(e,t){t===void 0&&(t={}),t=Ee({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new QK(e,t).parse();if(n.err){var r=SyntaxError(it[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||py(n.val),n.val}function bo(e,t){var n=t&&t.cache?t.cache:lV,r=t&&t.serializer?t.serializer:uV,i=t&&t.strategy?t.strategy:oV;return i(e,{cache:n,serializer:r})}function iV(e){return e==null||typeof e=="number"||typeof e=="boolean"}function $A(e,t,n,r){var i=iV(r)?r:n(r),o=t.get(i);return typeof o>"u"&&(o=e.call(this,r),t.set(i,o)),o}function RA(e,t,n){var r=Array.prototype.slice.call(arguments,3),i=n(r),o=t.get(i);return typeof o>"u"&&(o=e.apply(this,r),t.set(i,o)),o}function xE(e,t,n,r,i){return n.bind(t,e,r,i)}function oV(e,t){var n=e.length===1?$A:RA;return xE(e,this,n,t.cache.create(),t.serializer)}function aV(e,t){return xE(e,this,RA,t.cache.create(),t.serializer)}function sV(e,t){return xE(e,this,$A,t.cache.create(),t.serializer)}var uV=function(){return JSON.stringify(arguments)};function AE(){this.cache=Object.create(null)}AE.prototype.get=function(e){return this.cache[e]};AE.prototype.set=function(e,t){this.cache[e]=t};var lV={create:function(){return new AE}},wo={variadic:aV,monadic:sV},Ho;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Ho||(Ho={}));var Ru=function(e){Bi(t,e);function t(n,r,i){var o=e.call(this,n)||this;return o.code=r,o.originalMessage=i,o}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error),p6=function(e){Bi(t,e);function t(n,r,i,o){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(i).join('", "'),'"'),Ho.INVALID_VALUE,o)||this}return t}(Ru),cV=function(e){Bi(t,e);function t(n,r,i){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Ho.INVALID_VALUE,i)||this}return t}(Ru),dV=function(e){Bi(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Ho.MISSING_VALUE,r)||this}return t}(Ru),tr;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(tr||(tr={}));function hV(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==tr.literal||n.type!==tr.literal?t.push(n):r.value+=n.value,t},[])}function FA(e){return typeof e=="function"}function Hp(e,t,n,r,i,o,a){if(e.length===1&&s6(e[0]))return[{type:tr.literal,value:e[0].value}];for(var s=[],u=0,d=e;u"u")){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=rV,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}(),wl;(function(e){e.FORMAT_ERROR="FORMAT_ERROR",e.UNSUPPORTED_FORMATTER="UNSUPPORTED_FORMATTER",e.INVALID_CONFIG="INVALID_CONFIG",e.MISSING_DATA="MISSING_DATA",e.MISSING_TRANSLATION="MISSING_TRANSLATION"})(wl||(wl={}));var Ih=function(e){Bi(t,e);function t(n,r,i){var o=this,a=i?i instanceof Error?i:new Error(String(i)):void 0;return o=e.call(this,"[@formatjs/intl Error ".concat(n,"] ").concat(r,` +`,Ho.MISSING_INTL_API,a);var T=n.getPluralRules(t,{type:h.pluralType}).select(g-(h.offset||0));A=h.options[T]||h.options.other}if(!A)throw new p6(h.value,g,Object.keys(h.options),a);s.push.apply(s,Hp(A.value,t,n,r,i,g-(h.offset||0)));continue}}return hV(s)}function fV(e,t){return t?Ee(Ee(Ee({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=Ee(Ee({},e[r]),t[r]||{}),n},{})):e}function pV(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=fV(e[r],t[r]),n},Ee({},e)):e}function Sv(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function gV(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:bo(function(){for(var t,n=[],r=0;r"u")){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=rV,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}(),wl;(function(e){e.FORMAT_ERROR="FORMAT_ERROR",e.UNSUPPORTED_FORMATTER="UNSUPPORTED_FORMATTER",e.INVALID_CONFIG="INVALID_CONFIG",e.MISSING_DATA="MISSING_DATA",e.MISSING_TRANSLATION="MISSING_TRANSLATION"})(wl||(wl={}));var Ih=function(e){Bi(t,e);function t(n,r,i){var o=this,a=i?i instanceof Error?i:new Error(String(i)):void 0;return o=e.call(this,"[@formatjs/intl Error ".concat(n,"] ").concat(r,` `).concat(a?` `.concat(a.message,` `).concat(a.stack):""))||this,o.code=n,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(o,t),o}return t}(Error),mV=function(e){Bi(t,e);function t(n,r){return e.call(this,wl.UNSUPPORTED_FORMATTER,n,r)||this}return t}(Ih),vV=function(e){Bi(t,e);function t(n,r){return e.call(this,wl.INVALID_CONFIG,n,r)||this}return t}(Ih),g6=function(e){Bi(t,e);function t(n,r){return e.call(this,wl.MISSING_DATA,n,r)||this}return t}(Ih),Mi=function(e){Bi(t,e);function t(n,r,i){var o=e.call(this,wl.FORMAT_ERROR,"".concat(n,` Locale: `).concat(r,` -`),i)||this;return o.locale=r,o}return t}(Ih),Sv=function(e){Bi(t,e);function t(n,r,i,o){var a=e.call(this,"".concat(n,` +`),i)||this;return o.locale=r,o}return t}(Ih),xv=function(e){Bi(t,e);function t(n,r,i,o){var a=e.call(this,"".concat(n,` MessageID: `).concat(i==null?void 0:i.id,` Default Message: `).concat(i==null?void 0:i.defaultMessage,` Description: `).concat(i==null?void 0:i.description,` -`),r,o)||this;return a.descriptor=i,a.locale=r,a}return t}(Mi),yV=function(e){Bi(t,e);function t(n,r){var i=e.call(this,wl.MISSING_TRANSLATION,'Missing message: "'.concat(n.id,'" for locale "').concat(r,'", using ').concat(n.defaultMessage?"default message (".concat(typeof n.defaultMessage=="string"?n.defaultMessage:n.defaultMessage.map(function(o){var a;return(a=o.value)!==null&&a!==void 0?a:JSON.stringify(o)}).join(),")"):"id"," as fallback."))||this;return i.descriptor=n,i}return t}(Ih);function $l(e,t,n){return n===void 0&&(n={}),t.reduce(function(r,i){return i in e?r[i]=e[i]:i in n&&(r[i]=n[i]),r},{})}var EV=function(e){},CV=function(e){},OA={formats:{},messages:{},timeZone:void 0,defaultLocale:"en",defaultFormats:{},fallbackOnEmptyString:!0,onError:EV,onWarn:CV};function _A(){return{dateTime:{},number:{},message:{},relativeTime:{},pluralRules:{},list:{},displayNames:{}}}function qu(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function bV(e){e===void 0&&(e=_A());var t=Intl.RelativeTimeFormat,n=Intl.ListFormat,r=Intl.DisplayNames,i=bo(function(){for(var s,u=[],d=0;d needs to exist in the component ancestry.")}var UA=Ee(Ee({},OA),{textComponent:l.Fragment});function UV(e){return function(t){return e(l.Children.toArray(t))}}function gy(e,t){if(e===t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t),i=n.length;if(r.length!==i)return!1;for(var o=0;ov,Object.values(v));return l.createElement(E.Provider,{value:w},m)}function h(p,g){const m=(g==null?void 0:g[e][u])||s,v=l.useContext(m);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return d.displayName=o+"Provider",[d,h]}const i=()=>{const o=n.map(a=>l.createContext(a));return function(s){const u=(s==null?void 0:s[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,YV(i,...t)]}function YV(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const a=r.reduce((s,{useScope:u,scopeName:d})=>{const p=u(o)[`__scope${d}`];return{...s,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function qV(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Hm(...e){return t=>e.forEach(n=>qV(n,t))}function Vr(...e){return l.useCallback(Hm(...e),e)}const eh=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(ZV);if(o){const a=o.props.children,s=i.map(u=>u===o?l.Children.count(a)>1?l.Children.only(null):l.isValidElement(a)?a.props.children:null:u);return l.createElement(yy,De({},r,{ref:t}),l.isValidElement(a)?l.cloneElement(a,void 0,s):null)}return l.createElement(yy,De({},r,{ref:t}),n)});eh.displayName="Slot";const yy=l.forwardRef((e,t)=>{const{children:n,...r}=e;return l.isValidElement(n)?l.cloneElement(n,{...QV(r,n.props),ref:Hm(t,n.ref)}):l.Children.count(n)>1?l.Children.only(null):null});yy.displayName="SlotClone";const XV=({children:e})=>l.createElement(l.Fragment,null,e);function ZV(e){return l.isValidElement(e)&&e.type===XV}function QV(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?n[r]=(...s)=>{o==null||o(...s),i==null||i(...s)}:r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}const eG=["a","button","div","h2","h3","img","li","nav","ol","p","span","svg","ul"],sr=eG.reduce((e,t)=>{const n=l.forwardRef((r,i)=>{const{asChild:o,...a}=r,s=o?eh:t;return l.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),l.createElement(s,De({},a,{ref:i}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function JA(e,t){e&&$u.flushSync(()=>e.dispatchEvent(t))}function WA(e){const t=e+"CollectionProvider",[n,r]=Ed(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:v,children:E}=m,w=Kt.useRef(null),C=Kt.useRef(new Map).current;return Kt.createElement(i,{scope:v,itemMap:C,collectionRef:w},E)},s=e+"CollectionSlot",u=Kt.forwardRef((m,v)=>{const{scope:E,children:w}=m,C=o(s,E),b=Vr(v,C.collectionRef);return Kt.createElement(eh,{ref:b},w)}),d=e+"CollectionItemSlot",h="data-radix-collection-item",p=Kt.forwardRef((m,v)=>{const{scope:E,children:w,...C}=m,b=Kt.useRef(null),A=Vr(v,b),T=o(d,E);return Kt.useEffect(()=>(T.itemMap.set(b,{ref:b,...C}),()=>void T.itemMap.delete(b))),Kt.createElement(eh,{[h]:"",ref:A},w)});function g(m){const v=o(e+"CollectionConsumer",m);return Kt.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((T,B)=>C.indexOf(T.ref.current)-C.indexOf(B.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:u,ItemSlot:p},g,r]}const tG=l.createContext(void 0);function YA(e){const t=l.useContext(tG);return e||t||"ltr"}function Di(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function nG(e){const t=Di(e);l.useEffect(()=>{const n=r=>{r.key==="Escape"&&t(r)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t])}const Ey="dismissableLayer.update",rG="dismissableLayer.pointerDownOutside",iG="dismissableLayer.focusOutside";let b6;const oG=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),aG=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:a,onDismiss:s,...u}=e,d=l.useContext(oG),[h,p]=l.useState(null),[,g]=l.useState({}),m=Vr(t,D=>p(D)),v=Array.from(d.layers),[E]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=v.indexOf(E),C=h?v.indexOf(h):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,A=C>=w,T=sG(D=>{const I=D.target,M=[...d.branches].some(O=>O.contains(I));!A||M||(i==null||i(D),a==null||a(D),D.defaultPrevented||s==null||s())}),B=uG(D=>{const I=D.target;[...d.branches].some(O=>O.contains(I))||(o==null||o(D),a==null||a(D),D.defaultPrevented||s==null||s())});return nG(D=>{C===d.layers.size-1&&(r==null||r(D),!D.defaultPrevented&&s&&(D.preventDefault(),s()))}),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(b6=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),w6(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(document.body.style.pointerEvents=b6)}},[h,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),w6())},[h,d]),l.useEffect(()=>{const D=()=>g({});return document.addEventListener(Ey,D),()=>document.removeEventListener(Ey,D)},[]),l.createElement(sr.div,De({},u,{ref:m,style:{pointerEvents:b?A?"auto":"none":void 0,...e.style},onFocusCapture:Xe(e.onFocusCapture,B.onFocusCapture),onBlurCapture:Xe(e.onBlurCapture,B.onBlurCapture),onPointerDownCapture:Xe(e.onPointerDownCapture,T.onPointerDownCapture)}))});function sG(e){const t=Di(e),n=l.useRef(!1),r=l.useRef(()=>{});return l.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let d=function(){qA(rG,t,u,{discrete:!0})};var s=d;const u={originalEvent:a};a.pointerType==="touch"?(document.removeEventListener("click",r.current),r.current=d,document.addEventListener("click",r.current,{once:!0})):d()}n.current=!1},o=window.setTimeout(()=>{document.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),document.removeEventListener("pointerdown",i),document.removeEventListener("click",r.current)}},[t]),{onPointerDownCapture:()=>n.current=!0}}function uG(e){const t=Di(e),n=l.useRef(!1);return l.useEffect(()=>{const r=i=>{i.target&&!n.current&&qA(iG,t,{originalEvent:i},{discrete:!1})};return document.addEventListener("focusin",r),()=>document.removeEventListener("focusin",r)},[t]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function w6(){const e=new CustomEvent(Ey);document.dispatchEvent(e)}function qA(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?JA(i,o):i.dispatchEvent(o)}let Av=0;function lG(){l.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:S6()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:S6()),Av++,()=>{Av===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Av--}},[])}function S6(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}const kv="focusScope.autoFocusOnMount",Iv="focusScope.autoFocusOnUnmount",x6={bubbles:!1,cancelable:!0},cG=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=l.useState(null),d=Di(i),h=Di(o),p=l.useRef(null),g=Vr(t,E=>u(E)),m=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let C=function(A){if(m.paused||!s)return;const T=A.target;s.contains(T)?p.current=T:el(p.current,{select:!0})},b=function(A){m.paused||!s||s.contains(A.relatedTarget)||el(p.current,{select:!0})};var E=C,w=b;return document.addEventListener("focusin",C),document.addEventListener("focusout",b),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",b)}}},[r,s,m.paused]),l.useEffect(()=>{if(s){k6.add(m);const E=document.activeElement;if(!s.contains(E)){const C=new CustomEvent(kv,x6);s.addEventListener(kv,d),s.dispatchEvent(C),C.defaultPrevented||(dG(mG(XA(s)),{select:!0}),document.activeElement===E&&el(s))}return()=>{s.removeEventListener(kv,d),setTimeout(()=>{const C=new CustomEvent(Iv,x6);s.addEventListener(Iv,h),s.dispatchEvent(C),C.defaultPrevented||el(E??document.body,{select:!0}),s.removeEventListener(Iv,h),k6.remove(m)},0)}}},[s,d,h,m]);const v=l.useCallback(E=>{if(!n&&!r||m.paused)return;const w=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,C=document.activeElement;if(w&&C){const b=E.currentTarget,[A,T]=hG(b);A&&T?!E.shiftKey&&C===T?(E.preventDefault(),n&&el(A,{select:!0})):E.shiftKey&&C===A&&(E.preventDefault(),n&&el(T,{select:!0})):C===b&&E.preventDefault()}},[n,r,m.paused]);return l.createElement(sr.div,De({tabIndex:-1},a,{ref:g,onKeyDown:v}))});function dG(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(el(r,{select:t}),document.activeElement!==n)return}function hG(e){const t=XA(e),n=A6(t,e),r=A6(t.reverse(),e);return[n,r]}function XA(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function A6(e,t){for(const n of e)if(!fG(n,{upTo:t}))return n}function fG(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function pG(e){return e instanceof HTMLInputElement&&"select"in e}function el(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pG(e)&&t&&e.select()}}const k6=gG();function gG(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=I6(e,t),e.unshift(t)},remove(t){var n;e=I6(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function I6(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function mG(e){return e.filter(t=>t.tagName!=="A")}const Qc=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},vG=Wx.useId||(()=>{});let yG=0;function th(e){const[t,n]=l.useState(vG());return Qc(()=>{e||n(r=>r??String(yG++))},[e]),e||(t?`radix-${t}`:"")}function Cd(e){return e.split("-")[0]}function jm(e){return e.split("-")[1]}function bd(e){return["top","bottom"].includes(Cd(e))?"x":"y"}function IE(e){return e==="y"?"height":"width"}function D6(e,t,n){let{reference:r,floating:i}=e;const o=r.x+r.width/2-i.width/2,a=r.y+r.height/2-i.height/2,s=bd(t),u=IE(s),d=r[u]/2-i[u]/2,h=s==="x";let p;switch(Cd(t)){case"top":p={x:o,y:r.y-i.height};break;case"bottom":p={x:o,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:a};break;case"left":p={x:r.x-i.width,y:a};break;default:p={x:r.x,y:r.y}}switch(jm(t)){case"start":p[s]-=d*(n&&h?-1:1);break;case"end":p[s]+=d*(n&&h?-1:1)}return p}const EG=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,s=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:h}=D6(u,r,s),p=r,g={},m=0;for(let v=0;v({name:"arrow",options:e,async fn(t){const{element:n,padding:r=0}=e??{},{x:i,y:o,placement:a,rects:s,platform:u}=t;if(n==null)return{};const d=ZA(r),h={x:i,y:o},p=bd(a),g=jm(a),m=IE(p),v=await u.getDimensions(n),E=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=s.reference[m]+s.reference[p]-h[p]-s.floating[m],b=h[p]-s.reference[p],A=await(u.getOffsetParent==null?void 0:u.getOffsetParent(n));let T=A?p==="y"?A.clientHeight||0:A.clientWidth||0:0;T===0&&(T=s.floating[m]);const B=C/2-b/2,D=d[E],I=T-v[m]-d[w],M=T/2-v[m]/2+B,O=Cy(D,M,I),z=(g==="start"?d[E]:d[w])>0&&M!==O&&s.reference[m]<=s.floating[m];return{[p]:h[p]-(z?MwG[t])}function SG(e,t,n){n===void 0&&(n=!1);const r=jm(e),i=bd(e),o=IE(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=kg(a)),{main:a,cross:kg(a)}}const xG={start:"end",end:"start"};function P6(e){return e.replace(/start|end/g,t=>xG[t])}const QA=["top","right","bottom","left"];QA.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);const AG=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n;const{placement:r,middlewareData:i,rects:o,initialPlacement:a,platform:s,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",flipAlignment:m=!0,...v}=e,E=Cd(r),w=p||(E===a||!m?[kg(a)]:function(M){const O=kg(M);return[P6(M),O,P6(O)]}(a)),C=[a,...w],b=await Ag(t,v),A=[];let T=((n=i.flip)==null?void 0:n.overflows)||[];if(d&&A.push(b[E]),h){const{main:M,cross:O}=SG(r,o,await(s.isRTL==null?void 0:s.isRTL(u.floating)));A.push(b[M],b[O])}if(T=[...T,{placement:r,overflows:A}],!A.every(M=>M<=0)){var B,D;const M=((B=(D=i.flip)==null?void 0:D.index)!=null?B:0)+1,O=C[M];if(O)return{data:{index:M,overflows:T},reset:{placement:O}};let z="bottom";switch(g){case"bestFit":{var I;const K=(I=T.map(X=>[X,X.overflows.filter(Z=>Z>0).reduce((Z,pe)=>Z+pe,0)]).sort((X,Z)=>X[1]-Z[1])[0])==null?void 0:I[0].placement;K&&(z=K);break}case"initialPlacement":z=a}if(r!==z)return{reset:{placement:z}}}return{}}}};function B6(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function M6(e){return QA.some(t=>e[t]>=0)}const kG=function(e){let{strategy:t="referenceHidden",...n}=e===void 0?{}:e;return{name:"hide",async fn(r){const{rects:i}=r;switch(t){case"referenceHidden":{const o=B6(await Ag(r,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:M6(o)}}}case"escaped":{const o=B6(await Ag(r,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:o,escaped:M6(o)}}}default:return{}}}}},IG=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){const{x:n,y:r}=t,i=await async function(o,a){const{placement:s,platform:u,elements:d}=o,h=await(u.isRTL==null?void 0:u.isRTL(d.floating)),p=Cd(s),g=jm(s),m=bd(s)==="x",v=["left","top"].includes(p)?-1:1,E=h&&m?-1:1,w=typeof a=="function"?a(o):a;let{mainAxis:C,crossAxis:b,alignmentAxis:A}=typeof w=="number"?{mainAxis:w,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...w};return g&&typeof A=="number"&&(b=g==="end"?-1*A:A),m?{x:b*E,y:C*v}:{x:C*v,y:b*E}}(t,e);return{x:n+i.x,y:r+i.y,data:i}}}};function ek(e){return e==="x"?"y":"x"}const DG=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:w=>{let{x:C,y:b}=w;return{x:C,y:b}}},...u}=e,d={x:n,y:r},h=await Ag(t,u),p=bd(Cd(i)),g=ek(p);let m=d[p],v=d[g];if(o){const w=p==="y"?"bottom":"right";m=Cy(m+h[p==="y"?"top":"left"],m,m-h[w])}if(a){const w=g==="y"?"bottom":"right";v=Cy(v+h[g==="y"?"top":"left"],v,v-h[w])}const E=s.fn({...t,[p]:m,[g]:v});return{...E,data:{x:E.x-n,y:E.y-r}}}}},TG=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:s=0,mainAxis:u=!0,crossAxis:d=!0}=e,h={x:n,y:r},p=bd(i),g=ek(p);let m=h[p],v=h[g];const E=typeof s=="function"?s({...o,placement:i}):s,w=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(u){const B=p==="y"?"height":"width",D=o.reference[p]-o.floating[B]+w.mainAxis,I=o.reference[p]+o.reference[B]-w.mainAxis;mI&&(m=I)}if(d){var C,b,A,T;const B=p==="y"?"width":"height",D=["top","left"].includes(Cd(i)),I=o.reference[g]-o.floating[B]+(D&&(C=(b=a.offset)==null?void 0:b[g])!=null?C:0)+(D?0:w.crossAxis),M=o.reference[g]+o.reference[B]+(D?0:(A=(T=a.offset)==null?void 0:T[g])!=null?A:0)-(D?w.crossAxis:0);vM&&(v=M)}return{[p]:m,[g]:v}}}};function tk(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}function Ps(e){if(e==null)return window;if(!tk(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}function Th(e){return Ps(e).getComputedStyle(e)}function ps(e){return tk(e)?"":e?(e.nodeName||"").toLowerCase():""}function nk(){const e=navigator.userAgentData;return e!=null&&e.brands?e.brands.map(t=>t.brand+"/"+t.version).join(" "):navigator.userAgent}function jo(e){return e instanceof Ps(e).HTMLElement}function bu(e){return e instanceof Ps(e).Element}function DE(e){return typeof ShadowRoot>"u"?!1:e instanceof Ps(e).ShadowRoot||e instanceof ShadowRoot}function Um(e){const{overflow:t,overflowX:n,overflowY:r}=Th(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function PG(e){return["table","td","th"].includes(ps(e))}function $6(e){const t=/firefox/i.test(nk()),n=Th(e);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||t&&n.willChange==="filter"||t&&!!n.filter&&n.filter!=="none"}function rk(){return!/^((?!chrome|android).)*safari/i.test(nk())}const R6=Math.min,S0=Math.max,Ig=Math.round;function gs(e,t,n){var r,i,o,a;t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect();let u=1,d=1;t&&jo(e)&&(u=e.offsetWidth>0&&Ig(s.width)/e.offsetWidth||1,d=e.offsetHeight>0&&Ig(s.height)/e.offsetHeight||1);const h=bu(e)?Ps(e):window,p=!rk()&&n,g=(s.left+(p&&(r=(i=h.visualViewport)==null?void 0:i.offsetLeft)!=null?r:0))/u,m=(s.top+(p&&(o=(a=h.visualViewport)==null?void 0:a.offsetTop)!=null?o:0))/d,v=s.width/u,E=s.height/d;return{width:v,height:E,top:m,right:g+v,bottom:m+E,left:g,x:g,y:m}}function gu(e){return(t=e,(t instanceof Ps(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function Km(e){return bu(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function ik(e){return gs(gu(e)).left+Km(e).scrollLeft}function BG(e,t,n){const r=jo(t),i=gu(t),o=gs(e,r&&function(u){const d=gs(u);return Ig(d.width)!==u.offsetWidth||Ig(d.height)!==u.offsetHeight}(t),n==="fixed");let a={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(r||!r&&n!=="fixed")if((ps(t)!=="body"||Um(i))&&(a=Km(t)),jo(t)){const u=gs(t,!0);s.x=u.x+t.clientLeft,s.y=u.y+t.clientTop}else i&&(s.x=ik(i));return{x:o.left+a.scrollLeft-s.x,y:o.top+a.scrollTop-s.y,width:o.width,height:o.height}}function ok(e){return ps(e)==="html"?e:e.assignedSlot||e.parentNode||(DE(e)?e.host:null)||gu(e)}function F6(e){return jo(e)&&getComputedStyle(e).position!=="fixed"?e.offsetParent:null}function by(e){const t=Ps(e);let n=F6(e);for(;n&&PG(n)&&getComputedStyle(n).position==="static";)n=F6(n);return n&&(ps(n)==="html"||ps(n)==="body"&&getComputedStyle(n).position==="static"&&!$6(n))?t:n||function(r){let i=ok(r);for(DE(i)&&(i=i.host);jo(i)&&!["html","body"].includes(ps(i));){if($6(i))return i;i=i.parentNode}return null}(e)||t}function L6(e){if(jo(e))return{width:e.offsetWidth,height:e.offsetHeight};const t=gs(e);return{width:t.width,height:t.height}}function ak(e){const t=ok(e);return["html","body","#document"].includes(ps(t))?e.ownerDocument.body:jo(t)&&Um(t)?t:ak(t)}function Dg(e,t){var n;t===void 0&&(t=[]);const r=ak(e),i=r===((n=e.ownerDocument)==null?void 0:n.body),o=Ps(r),a=i?[o].concat(o.visualViewport||[],Um(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(Dg(a))}function O6(e,t,n){return t==="viewport"?xg(function(r,i){const o=Ps(r),a=gu(r),s=o.visualViewport;let u=a.clientWidth,d=a.clientHeight,h=0,p=0;if(s){u=s.width,d=s.height;const g=rk();(g||!g&&i==="fixed")&&(h=s.offsetLeft,p=s.offsetTop)}return{width:u,height:d,x:h,y:p}}(e,n)):bu(t)?function(r,i){const o=gs(r,!1,i==="fixed"),a=o.top+r.clientTop,s=o.left+r.clientLeft;return{top:a,left:s,x:s,y:a,right:s+r.clientWidth,bottom:a+r.clientHeight,width:r.clientWidth,height:r.clientHeight}}(t,n):xg(function(r){var i;const o=gu(r),a=Km(r),s=(i=r.ownerDocument)==null?void 0:i.body,u=S0(o.scrollWidth,o.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),d=S0(o.scrollHeight,o.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0);let h=-a.scrollLeft+ik(r);const p=-a.scrollTop;return Th(s||o).direction==="rtl"&&(h+=S0(o.clientWidth,s?s.clientWidth:0)-u),{width:u,height:d,x:h,y:p}}(gu(e)))}function MG(e){const t=Dg(e),n=["absolute","fixed"].includes(Th(e).position)&&jo(e)?by(e):e;return bu(n)?t.filter(r=>bu(r)&&function(i,o){const a=o.getRootNode==null?void 0:o.getRootNode();if(i.contains(o))return!0;if(a&&DE(a)){let s=o;do{if(s&&i===s)return!0;s=s.parentNode||s.host}while(s)}return!1}(r,n)&&ps(r)!=="body"):[]}const $G={getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?MG(t):[].concat(n),r],a=o[0],s=o.reduce((u,d)=>{const h=O6(t,d,i);return u.top=S0(h.top,u.top),u.right=R6(h.right,u.right),u.bottom=R6(h.bottom,u.bottom),u.left=S0(h.left,u.left),u},O6(t,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{rect:t,offsetParent:n,strategy:r}=e;const i=jo(n),o=gu(n);if(n===o)return t;let a={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if((i||!i&&r!=="fixed")&&((ps(n)!=="body"||Um(o))&&(a=Km(n)),jo(n))){const u=gs(n,!0);s.x=u.x+n.clientLeft,s.y=u.y+n.clientTop}return{...t,x:t.x-a.scrollLeft+s.x,y:t.y-a.scrollTop+s.y}},isElement:bu,getDimensions:L6,getOffsetParent:by,getDocumentElement:gu,getElementRects:e=>{let{reference:t,floating:n,strategy:r}=e;return{reference:BG(t,by(n),r),floating:{...L6(n),x:0,y:0}}},getClientRects:e=>Array.from(e.getClientRects()),isRTL:e=>Th(e).direction==="rtl"};function RG(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,u=i&&!s,d=o&&!s,h=u||d?[...bu(e)?Dg(e):[],...Dg(t)]:[];h.forEach(v=>{u&&v.addEventListener("scroll",n,{passive:!0}),d&&v.addEventListener("resize",n)});let p,g=null;if(a){let v=!0;g=new ResizeObserver(()=>{v||n(),v=!1}),bu(e)&&!s&&g.observe(e),g.observe(t)}let m=s?gs(e):null;return s&&function v(){const E=gs(e);!m||E.x===m.x&&E.y===m.y&&E.width===m.width&&E.height===m.height||n(),m=E,p=requestAnimationFrame(v)}(),n(),()=>{var v;h.forEach(E=>{u&&E.removeEventListener("scroll",n),d&&E.removeEventListener("resize",n)}),(v=g)==null||v.disconnect(),g=null,s&&cancelAnimationFrame(p)}}const FG=(e,t,n)=>EG(e,t,{platform:$G,...n});var wy=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Sy(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Sy(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Sy(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function LG(e){const t=l.useRef(e);return wy(()=>{t.current=e}),t}function OG(e){let{middleware:t,placement:n="bottom",strategy:r="absolute",whileElementsMounted:i}=e===void 0?{}:e;const o=l.useRef(null),a=l.useRef(null),s=LG(i),u=l.useRef(null),[d,h]=l.useState({x:null,y:null,strategy:r,placement:n,middlewareData:{}}),[p,g]=l.useState(t);Sy(p==null?void 0:p.map(A=>{let{options:T}=A;return T}),t==null?void 0:t.map(A=>{let{options:T}=A;return T}))||g(t);const m=l.useCallback(()=>{!o.current||!a.current||FG(o.current,a.current,{middleware:p,placement:n,strategy:r}).then(A=>{v.current&&$u.flushSync(()=>{h(A)})})},[p,n,r]);wy(()=>{v.current&&m()},[m]);const v=l.useRef(!1);wy(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=l.useCallback(()=>{if(typeof u.current=="function"&&(u.current(),u.current=null),o.current&&a.current)if(s.current){const A=s.current(o.current,a.current,m);u.current=A}else m()},[m,s]),w=l.useCallback(A=>{o.current=A,E()},[E]),C=l.useCallback(A=>{a.current=A,E()},[E]),b=l.useMemo(()=>({reference:o,floating:a}),[]);return l.useMemo(()=>({...d,update:m,refs:b,reference:w,floating:C}),[d,m,b,w,C])}const _G=e=>{const{element:t,padding:n}=e;function r(i){return Object.prototype.hasOwnProperty.call(i,"current")}return{name:"arrow",options:e,fn(i){return r(t)?t.current!=null?T6({element:t.current,padding:n}).fn(i):{}:t?T6({element:t,padding:n}).fn(i):{}}}},NG=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return l.createElement(sr.svg,De({},o,{ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),e.asChild?n:l.createElement("polygon",{points:"0,0 30,0 15,10"}))}),zG=NG;function HG(e){const[t,n]=l.useState(void 0);return Qc(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,s;if("borderBoxSize"in o){const u=o.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,s=d.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const sk="Popper",[TE,uk]=Ed(sk),[jG,lk]=TE(sk),UG=e=>{const{__scopePopper:t,children:n}=e,[r,i]=l.useState(null);return l.createElement(jG,{scope:t,anchor:r,onAnchorChange:i},n)},KG="PopperAnchor",VG=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=lk(KG,n),a=l.useRef(null),s=Vr(t,a);return l.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:l.createElement(sr.div,De({},i,{ref:s}))}),Tg="PopperContent",[GG,JG]=TE(Tg),[WG,YG]=TE(Tg,{hasParent:!1,positionUpdateFns:new Set}),qG=l.forwardRef((e,t)=>{var n,r,i,o,a,s,u,d;const{__scopePopper:h,side:p="bottom",sideOffset:g=0,align:m="center",alignOffset:v=0,arrowPadding:E=0,collisionBoundary:w=[],collisionPadding:C=0,sticky:b="partial",hideWhenDetached:A=!1,avoidCollisions:T=!0,...B}=e,D=lk(Tg,h),[I,M]=l.useState(null),O=Vr(t,Wo=>M(Wo)),[z,K]=l.useState(null),X=HG(z),Z=(n=X==null?void 0:X.width)!==null&&n!==void 0?n:0,pe=(r=X==null?void 0:X.height)!==null&&r!==void 0?r:0,me=p+(m!=="center"?"-"+m:""),Ce=typeof C=="number"?C:{top:0,right:0,bottom:0,left:0,...C},W=Array.isArray(w)?w:[w],U=W.length>0,ne={padding:Ce,boundary:W.filter(tJ),altBoundary:U},{reference:le,floating:Ae,strategy:we,x:ft,y:Ze,placement:qe,middlewareData:Ge,update:At}=OG({strategy:"fixed",placement:me,whileElementsMounted:RG,middleware:[IG({mainAxis:g+pe,alignmentAxis:v}),T?DG({mainAxis:!0,crossAxis:!1,limiter:b==="partial"?TG():void 0,...ne}):void 0,z?_G({element:z,padding:E}):void 0,T?AG({...ne}):void 0,nJ({arrowWidth:Z,arrowHeight:pe}),A?kG({strategy:"referenceHidden"}):void 0].filter(eJ)});Qc(()=>{le(D.anchor)},[le,D.anchor]);const dt=ft!==null&&Ze!==null,[pn,Dn]=ck(qe),On=(i=Ge.arrow)===null||i===void 0?void 0:i.x,_n=(o=Ge.arrow)===null||o===void 0?void 0:o.y,Tn=((a=Ge.arrow)===null||a===void 0?void 0:a.centerOffset)!==0,[tn,Ri]=l.useState();Qc(()=>{I&&Ri(window.getComputedStyle(I).zIndex)},[I]);const{hasParent:zu,positionUpdateFns:Sn}=YG(Tg,h),ho=!zu;l.useLayoutEffect(()=>{if(!ho)return Sn.add(At),()=>{Sn.delete(At)}},[ho,Sn,At]),l.useLayoutEffect(()=>{ho&&dt&&Array.from(Sn).reverse().forEach(Wo=>requestAnimationFrame(Wo))},[ho,dt,Sn]);const Jo={"data-side":pn,"data-align":Dn,...B,ref:O,style:{...B.style,animation:dt?void 0:"none",opacity:(s=Ge.hide)!==null&&s!==void 0&&s.referenceHidden?0:void 0}};return l.createElement("div",{ref:Ae,"data-radix-popper-content-wrapper":"",style:{position:we,left:0,top:0,transform:dt?`translate3d(${Math.round(ft)}px, ${Math.round(Ze)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:tn,"--radix-popper-transform-origin":[(u=Ge.transformOrigin)===null||u===void 0?void 0:u.x,(d=Ge.transformOrigin)===null||d===void 0?void 0:d.y].join(" ")}},l.createElement(GG,{scope:h,placedSide:pn,onArrowChange:K,arrowX:On,arrowY:_n,shouldHideArrow:Tn},ho?l.createElement(WG,{scope:h,hasParent:!0,positionUpdateFns:Sn},l.createElement(sr.div,Jo)):l.createElement(sr.div,Jo)))}),XG="PopperArrow",ZG={top:"bottom",right:"left",bottom:"top",left:"right"},QG=l.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=JG(XG,r),a=ZG[o.placedSide];return l.createElement("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0}},l.createElement(zG,De({},i,{ref:n,style:{...i.style,display:"block"}})))});function eJ(e){return e!==void 0}function tJ(e){return e!==null}const nJ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,i,o,a;const{placement:s,rects:u,middlewareData:d}=t,p=((n=d.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,g=p?0:e.arrowWidth,m=p?0:e.arrowHeight,[v,E]=ck(s),w={start:"0%",center:"50%",end:"100%"}[E],C=((r=(i=d.arrow)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)+g/2,b=((o=(a=d.arrow)===null||a===void 0?void 0:a.y)!==null&&o!==void 0?o:0)+m/2;let A="",T="";return v==="bottom"?(A=p?w:`${C}px`,T=`${-m}px`):v==="top"?(A=p?w:`${C}px`,T=`${u.floating.height+m}px`):v==="right"?(A=`${-m}px`,T=p?w:`${b}px`):v==="left"&&(A=`${u.floating.width+m}px`,T=p?w:`${b}px`),{data:{x:A,y:T}}}});function ck(e){const[t,n="center"]=e.split("-");return[t,n]}const dk=UG,rJ=VG,iJ=qG,oJ=QG,aJ=l.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...i}=e;return r?Q7.createPortal(l.createElement(sr.div,De({},i,{ref:t})),r):null});function sJ(e,t){return l.useReducer((n,r)=>{const i=t[n][r];return i??n},e)}const Ph=e=>{const{present:t,children:n}=e,r=uJ(t),i=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),o=Vr(r.ref,i.ref);return typeof n=="function"||r.isPresent?l.cloneElement(i,{ref:o}):null};Ph.displayName="Presence";function uJ(e){const[t,n]=l.useState(),r=l.useRef({}),i=l.useRef(e),o=l.useRef("none"),a=e?"mounted":"unmounted",[s,u]=sJ(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=np(r.current);o.current=s==="mounted"?d:"none"},[s]),Qc(()=>{const d=r.current,h=i.current;if(h!==e){const g=o.current,m=np(d);e?u("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&g!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Qc(()=>{if(t){const d=p=>{const m=np(r.current).includes(p.animationName);p.target===t&&m&&$u.flushSync(()=>u("ANIMATION_END"))},h=p=>{p.target===t&&(o.current=np(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:l.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function np(e){return(e==null?void 0:e.animationName)||"none"}function Vm({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=lJ({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=Di(n),u=l.useCallback(d=>{if(o){const p=typeof d=="function"?d(e):d;p!==e&&s(p)}else i(d)},[o,e,i,s]);return[a,u]}function lJ({defaultProp:e,onChange:t}){const n=l.useState(e),[r]=n,i=l.useRef(r),o=Di(t);return l.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}const Dv="rovingFocusGroup.onEntryFocus",cJ={bubbles:!1,cancelable:!0},PE="RovingFocusGroup",[xy,hk,dJ]=WA(PE),[hJ,fk]=Ed(PE,[dJ]),[fJ,pJ]=hJ(PE),gJ=l.forwardRef((e,t)=>l.createElement(xy.Provider,{scope:e.__scopeRovingFocusGroup},l.createElement(xy.Slot,{scope:e.__scopeRovingFocusGroup},l.createElement(mJ,De({},e,{ref:t}))))),mJ=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:u,onEntryFocus:d,...h}=e,p=l.useRef(null),g=Vr(t,p),m=YA(o),[v=null,E]=Vm({prop:a,defaultProp:s,onChange:u}),[w,C]=l.useState(!1),b=Di(d),A=hk(n),T=l.useRef(!1);return l.useEffect(()=>{const B=p.current;if(B)return B.addEventListener(Dv,b),()=>B.removeEventListener(Dv,b)},[b]),l.createElement(fJ,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:l.useCallback(B=>E(B),[E]),onItemShiftTab:l.useCallback(()=>C(!0),[])},l.createElement(sr.div,De({tabIndex:w?-1:0,"data-orientation":r},h,{ref:g,style:{outline:"none",...e.style},onMouseDown:Xe(e.onMouseDown,()=>{T.current=!0}),onFocus:Xe(e.onFocus,B=>{const D=!T.current;if(B.target===B.currentTarget&&D&&!w){const I=new CustomEvent(Dv,cJ);if(B.currentTarget.dispatchEvent(I),!I.defaultPrevented){const M=A().filter(Z=>Z.focusable),O=M.find(Z=>Z.active),z=M.find(Z=>Z.id===v),X=[O,z,...M].filter(Boolean).map(Z=>Z.ref.current);pk(X)}}T.current=!1}),onBlur:Xe(e.onBlur,()=>C(!1))})))}),vJ="RovingFocusGroupItem",yJ=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,...o}=e,a=th(),s=pJ(vJ,n),u=s.currentTabStopId===a,d=hk(n);return l.createElement(xy.ItemSlot,{scope:n,id:a,focusable:r,active:i},l.createElement(sr.span,De({tabIndex:u?0:-1,"data-orientation":s.orientation},o,{ref:t,onMouseDown:Xe(e.onMouseDown,h=>{r?s.onItemFocus(a):h.preventDefault()}),onFocus:Xe(e.onFocus,()=>s.onItemFocus(a)),onKeyDown:Xe(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){s.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const p=bJ(h,s.orientation,s.dir);if(p!==void 0){h.preventDefault();let m=d().filter(v=>v.focusable).map(v=>v.ref.current);if(p==="last")m.reverse();else if(p==="prev"||p==="next"){p==="prev"&&m.reverse();const v=m.indexOf(h.currentTarget);m=s.loop?wJ(m,v+1):m.slice(v+1)}setTimeout(()=>pk(m))}})})))}),EJ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CJ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function bJ(e,t,n){const r=CJ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return EJ[r]}function pk(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const SJ=gJ,xJ=yJ;var AJ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ic=new WeakMap,rp=new WeakMap,ip={},Tv=0,gk=function(e){return e&&(e.host||gk(e.parentNode))},kJ=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=gk(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},IJ=function(e,t,n,r){var i=kJ(t,Array.isArray(e)?e:[e]);ip[n]||(ip[n]=new WeakMap);var o=ip[n],a=[],s=new Set,u=new Set(i),d=function(p){!p||s.has(p)||(s.add(p),d(p.parentNode))};i.forEach(d);var h=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(g){if(s.has(g))h(g);else{var m=g.getAttribute(r),v=m!==null&&m!=="false",E=(ic.get(g)||0)+1,w=(o.get(g)||0)+1;ic.set(g,E),o.set(g,w),a.push(g),E===1&&v&&rp.set(g,!0),w===1&&g.setAttribute(n,"true"),v||g.setAttribute(r,"true")}})};return h(t),s.clear(),Tv++,function(){a.forEach(function(p){var g=ic.get(p)-1,m=o.get(p)-1;ic.set(p,g),o.set(p,m),g||(rp.has(p)||p.removeAttribute(r),rp.delete(p)),m||p.removeAttribute(n)}),Tv--,Tv||(ic=new WeakMap,ic=new WeakMap,rp=new WeakMap,ip={})}},BE=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=AJ(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),IJ(r,i,n,"aria-hidden")):function(){return null}},x0="right-scroll-bar-position",A0="width-before-scroll-bar",DJ="with-scroll-bars-hidden",TJ="--removed-body-scroll-bar-size";function PJ(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function BJ(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}function mk(e,t){return BJ(null,function(n){return e.forEach(function(r){return PJ(r,n)})})}function MJ(e){return e}function $J(e,t){t===void 0&&(t=MJ);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var a=t(o,r);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(o){for(r=!0;n.length;){var a=n;n=[],a.forEach(o)}n={push:function(s){return o(s)},filter:function(){return n}}},assignMedium:function(o){r=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(o),a=n}var u=function(){var h=a;a=[],h.forEach(o)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(h){a.push(h),d()},filter:function(h){return a=a.filter(h),n}}}};return i}function vk(e){e===void 0&&(e={});var t=$J(null);return t.options=Ee({async:!0,ssr:!1},e),t}var yk=function(e){var t=e.sideCar,n=Ss(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,Ee({},n))};yk.isSideCarExport=!0;function Ek(e,t){return e.useMedium(t),yk}var Ck=vk(),Pv=function(){},Gm=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Pv,onWheelCapture:Pv,onTouchMoveCapture:Pv}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,g=e.sideCar,m=e.noIsolation,v=e.inert,E=e.allowPinchZoom,w=e.as,C=w===void 0?"div":w,b=Ss(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),A=g,T=mk([n,t]),B=Ee(Ee({},b),i);return l.createElement(l.Fragment,null,h&&l.createElement(A,{sideCar:Ck,removeScrollBar:d,shards:p,noIsolation:m,inert:v,setCallbacks:o,allowPinchZoom:!!E,lockRef:n}),a?l.cloneElement(l.Children.only(s),Ee(Ee({},B),{ref:T})):l.createElement(C,Ee({},B,{className:u,ref:T}),s))});Gm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Gm.classNames={fullWidth:A0,zeroRight:x0};var RJ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function FJ(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=RJ();return t&&e.setAttribute("nonce",t),e}function LJ(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OJ(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var _J=function(){var e=0,t=null;return{add:function(n){e==0&&(t=FJ())&&(LJ(t,n),OJ(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},NJ=function(){var e=_J();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ME=function(){var e=NJ(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},zJ={left:0,top:0,right:0,gap:0},Bv=function(e){return parseInt(e||"",10)||0},HJ=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Bv(n),Bv(r),Bv(i)]},jJ=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zJ;var t=HJ(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},UJ=ME(),KJ=function(e,t,n,r){var i=e.left,o=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),` +For more details see https://formatjs.io/docs/getting-started/message-distribution`)}function jV(e,t){var n=bV(t),r=Ee(Ee({},OA),e),i=r.locale,o=r.defaultLocale,a=r.onError;return i?!Intl.NumberFormat.supportedLocalesOf(i).length&&a?a(new g6('Missing locale data for locale: "'.concat(i,'" in Intl.NumberFormat. Using default locale: "').concat(o,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):!Intl.DateTimeFormat.supportedLocalesOf(i).length&&a&&a(new g6('Missing locale data for locale: "'.concat(i,'" in Intl.DateTimeFormat. Using default locale: "').concat(o,'" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'))):(a&&a(new vV('"locale" was not configured, using "'.concat(o,'" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'))),r.locale=r.defaultLocale||"en"),HV(r),Ee(Ee({},r),{formatters:n,formatNumber:_V.bind(null,r,n.getNumberFormat),formatNumberToParts:NV.bind(null,r,n.getNumberFormat),formatRelativeTime:LV.bind(null,r,n.getRelativeTimeFormat),formatDate:wV.bind(null,r,n.getDateTimeFormat),formatDateToParts:AV.bind(null,r,n.getDateTimeFormat),formatTime:SV.bind(null,r,n.getDateTimeFormat),formatDateTimeRange:xV.bind(null,r,n.getDateTimeFormat),formatTimeToParts:kV.bind(null,r,n.getDateTimeFormat),formatPlural:$V.bind(null,r,n.getPluralRules),formatMessage:gy.bind(null,r,n),$t:gy.bind(null,r,n),formatList:BV.bind(null,r,n.getListFormat),formatListToParts:zA.bind(null,r,n.getListFormat),formatDisplayName:DV.bind(null,r,n.getDisplayNames)})}function jA(e){yA(e,"[React Intl] Could not find required `intl` object. needs to exist in the component ancestry.")}var UA=Ee(Ee({},OA),{textComponent:l.Fragment});function UV(e){return function(t){return e(l.Children.toArray(t))}}function my(e,t){if(e===t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t),i=n.length;if(r.length!==i)return!1;for(var o=0;ov,Object.values(v));return l.createElement(E.Provider,{value:w},m)}function h(p,g){const m=(g==null?void 0:g[e][u])||s,v=l.useContext(m);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return d.displayName=o+"Provider",[d,h]}const i=()=>{const o=n.map(a=>l.createContext(a));return function(s){const u=(s==null?void 0:s[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,YV(i,...t)]}function YV(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const a=r.reduce((s,{useScope:u,scopeName:d})=>{const p=u(o)[`__scope${d}`];return{...s,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function qV(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Hm(...e){return t=>e.forEach(n=>qV(n,t))}function Vr(...e){return l.useCallback(Hm(...e),e)}const eh=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(ZV);if(o){const a=o.props.children,s=i.map(u=>u===o?l.Children.count(a)>1?l.Children.only(null):l.isValidElement(a)?a.props.children:null:u);return l.createElement(Ey,De({},r,{ref:t}),l.isValidElement(a)?l.cloneElement(a,void 0,s):null)}return l.createElement(Ey,De({},r,{ref:t}),n)});eh.displayName="Slot";const Ey=l.forwardRef((e,t)=>{const{children:n,...r}=e;return l.isValidElement(n)?l.cloneElement(n,{...QV(r,n.props),ref:Hm(t,n.ref)}):l.Children.count(n)>1?l.Children.only(null):null});Ey.displayName="SlotClone";const XV=({children:e})=>l.createElement(l.Fragment,null,e);function ZV(e){return l.isValidElement(e)&&e.type===XV}function QV(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?n[r]=(...s)=>{o==null||o(...s),i==null||i(...s)}:r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}const eG=["a","button","div","h2","h3","img","li","nav","ol","p","span","svg","ul"],sr=eG.reduce((e,t)=>{const n=l.forwardRef((r,i)=>{const{asChild:o,...a}=r,s=o?eh:t;return l.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),l.createElement(s,De({},a,{ref:i}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function JA(e,t){e&&$u.flushSync(()=>e.dispatchEvent(t))}function WA(e){const t=e+"CollectionProvider",[n,r]=Ed(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:v,children:E}=m,w=Kt.useRef(null),C=Kt.useRef(new Map).current;return Kt.createElement(i,{scope:v,itemMap:C,collectionRef:w},E)},s=e+"CollectionSlot",u=Kt.forwardRef((m,v)=>{const{scope:E,children:w}=m,C=o(s,E),b=Vr(v,C.collectionRef);return Kt.createElement(eh,{ref:b},w)}),d=e+"CollectionItemSlot",h="data-radix-collection-item",p=Kt.forwardRef((m,v)=>{const{scope:E,children:w,...C}=m,b=Kt.useRef(null),A=Vr(v,b),T=o(d,E);return Kt.useEffect(()=>(T.itemMap.set(b,{ref:b,...C}),()=>void T.itemMap.delete(b))),Kt.createElement(eh,{[h]:"",ref:A},w)});function g(m){const v=o(e+"CollectionConsumer",m);return Kt.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((T,B)=>C.indexOf(T.ref.current)-C.indexOf(B.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:u,ItemSlot:p},g,r]}const tG=l.createContext(void 0);function YA(e){const t=l.useContext(tG);return e||t||"ltr"}function Di(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function nG(e){const t=Di(e);l.useEffect(()=>{const n=r=>{r.key==="Escape"&&t(r)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t])}const Cy="dismissableLayer.update",rG="dismissableLayer.pointerDownOutside",iG="dismissableLayer.focusOutside";let b6;const oG=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),aG=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:a,onDismiss:s,...u}=e,d=l.useContext(oG),[h,p]=l.useState(null),[,g]=l.useState({}),m=Vr(t,D=>p(D)),v=Array.from(d.layers),[E]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=v.indexOf(E),C=h?v.indexOf(h):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,A=C>=w,T=sG(D=>{const I=D.target,M=[...d.branches].some(O=>O.contains(I));!A||M||(i==null||i(D),a==null||a(D),D.defaultPrevented||s==null||s())}),B=uG(D=>{const I=D.target;[...d.branches].some(O=>O.contains(I))||(o==null||o(D),a==null||a(D),D.defaultPrevented||s==null||s())});return nG(D=>{C===d.layers.size-1&&(r==null||r(D),!D.defaultPrevented&&s&&(D.preventDefault(),s()))}),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(b6=document.body.style.pointerEvents,document.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),w6(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(document.body.style.pointerEvents=b6)}},[h,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),w6())},[h,d]),l.useEffect(()=>{const D=()=>g({});return document.addEventListener(Cy,D),()=>document.removeEventListener(Cy,D)},[]),l.createElement(sr.div,De({},u,{ref:m,style:{pointerEvents:b?A?"auto":"none":void 0,...e.style},onFocusCapture:Xe(e.onFocusCapture,B.onFocusCapture),onBlurCapture:Xe(e.onBlurCapture,B.onBlurCapture),onPointerDownCapture:Xe(e.onPointerDownCapture,T.onPointerDownCapture)}))});function sG(e){const t=Di(e),n=l.useRef(!1),r=l.useRef(()=>{});return l.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let d=function(){qA(rG,t,u,{discrete:!0})};var s=d;const u={originalEvent:a};a.pointerType==="touch"?(document.removeEventListener("click",r.current),r.current=d,document.addEventListener("click",r.current,{once:!0})):d()}n.current=!1},o=window.setTimeout(()=>{document.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),document.removeEventListener("pointerdown",i),document.removeEventListener("click",r.current)}},[t]),{onPointerDownCapture:()=>n.current=!0}}function uG(e){const t=Di(e),n=l.useRef(!1);return l.useEffect(()=>{const r=i=>{i.target&&!n.current&&qA(iG,t,{originalEvent:i},{discrete:!1})};return document.addEventListener("focusin",r),()=>document.removeEventListener("focusin",r)},[t]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function w6(){const e=new CustomEvent(Cy);document.dispatchEvent(e)}function qA(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?JA(i,o):i.dispatchEvent(o)}let kv=0;function lG(){l.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:S6()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:S6()),kv++,()=>{kv===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),kv--}},[])}function S6(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}const Iv="focusScope.autoFocusOnMount",Dv="focusScope.autoFocusOnUnmount",x6={bubbles:!1,cancelable:!0},cG=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=l.useState(null),d=Di(i),h=Di(o),p=l.useRef(null),g=Vr(t,E=>u(E)),m=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let C=function(A){if(m.paused||!s)return;const T=A.target;s.contains(T)?p.current=T:el(p.current,{select:!0})},b=function(A){m.paused||!s||s.contains(A.relatedTarget)||el(p.current,{select:!0})};var E=C,w=b;return document.addEventListener("focusin",C),document.addEventListener("focusout",b),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",b)}}},[r,s,m.paused]),l.useEffect(()=>{if(s){k6.add(m);const E=document.activeElement;if(!s.contains(E)){const C=new CustomEvent(Iv,x6);s.addEventListener(Iv,d),s.dispatchEvent(C),C.defaultPrevented||(dG(mG(XA(s)),{select:!0}),document.activeElement===E&&el(s))}return()=>{s.removeEventListener(Iv,d),setTimeout(()=>{const C=new CustomEvent(Dv,x6);s.addEventListener(Dv,h),s.dispatchEvent(C),C.defaultPrevented||el(E??document.body,{select:!0}),s.removeEventListener(Dv,h),k6.remove(m)},0)}}},[s,d,h,m]);const v=l.useCallback(E=>{if(!n&&!r||m.paused)return;const w=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,C=document.activeElement;if(w&&C){const b=E.currentTarget,[A,T]=hG(b);A&&T?!E.shiftKey&&C===T?(E.preventDefault(),n&&el(A,{select:!0})):E.shiftKey&&C===A&&(E.preventDefault(),n&&el(T,{select:!0})):C===b&&E.preventDefault()}},[n,r,m.paused]);return l.createElement(sr.div,De({tabIndex:-1},a,{ref:g,onKeyDown:v}))});function dG(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(el(r,{select:t}),document.activeElement!==n)return}function hG(e){const t=XA(e),n=A6(t,e),r=A6(t.reverse(),e);return[n,r]}function XA(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function A6(e,t){for(const n of e)if(!fG(n,{upTo:t}))return n}function fG(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function pG(e){return e instanceof HTMLInputElement&&"select"in e}function el(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pG(e)&&t&&e.select()}}const k6=gG();function gG(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=I6(e,t),e.unshift(t)},remove(t){var n;e=I6(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function I6(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function mG(e){return e.filter(t=>t.tagName!=="A")}const Qc=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},vG=Wx.useId||(()=>{});let yG=0;function th(e){const[t,n]=l.useState(vG());return Qc(()=>{e||n(r=>r??String(yG++))},[e]),e||(t?`radix-${t}`:"")}function Cd(e){return e.split("-")[0]}function jm(e){return e.split("-")[1]}function bd(e){return["top","bottom"].includes(Cd(e))?"x":"y"}function DE(e){return e==="y"?"height":"width"}function D6(e,t,n){let{reference:r,floating:i}=e;const o=r.x+r.width/2-i.width/2,a=r.y+r.height/2-i.height/2,s=bd(t),u=DE(s),d=r[u]/2-i[u]/2,h=s==="x";let p;switch(Cd(t)){case"top":p={x:o,y:r.y-i.height};break;case"bottom":p={x:o,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:a};break;case"left":p={x:r.x-i.width,y:a};break;default:p={x:r.x,y:r.y}}switch(jm(t)){case"start":p[s]-=d*(n&&h?-1:1);break;case"end":p[s]+=d*(n&&h?-1:1)}return p}const EG=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,s=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:h}=D6(u,r,s),p=r,g={},m=0;for(let v=0;v({name:"arrow",options:e,async fn(t){const{element:n,padding:r=0}=e??{},{x:i,y:o,placement:a,rects:s,platform:u}=t;if(n==null)return{};const d=ZA(r),h={x:i,y:o},p=bd(a),g=jm(a),m=DE(p),v=await u.getDimensions(n),E=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=s.reference[m]+s.reference[p]-h[p]-s.floating[m],b=h[p]-s.reference[p],A=await(u.getOffsetParent==null?void 0:u.getOffsetParent(n));let T=A?p==="y"?A.clientHeight||0:A.clientWidth||0:0;T===0&&(T=s.floating[m]);const B=C/2-b/2,D=d[E],I=T-v[m]-d[w],M=T/2-v[m]/2+B,O=by(D,M,I),z=(g==="start"?d[E]:d[w])>0&&M!==O&&s.reference[m]<=s.floating[m];return{[p]:h[p]-(z?MwG[t])}function SG(e,t,n){n===void 0&&(n=!1);const r=jm(e),i=bd(e),o=DE(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=kg(a)),{main:a,cross:kg(a)}}const xG={start:"end",end:"start"};function P6(e){return e.replace(/start|end/g,t=>xG[t])}const QA=["top","right","bottom","left"];QA.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);const AG=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n;const{placement:r,middlewareData:i,rects:o,initialPlacement:a,platform:s,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",flipAlignment:m=!0,...v}=e,E=Cd(r),w=p||(E===a||!m?[kg(a)]:function(M){const O=kg(M);return[P6(M),O,P6(O)]}(a)),C=[a,...w],b=await Ag(t,v),A=[];let T=((n=i.flip)==null?void 0:n.overflows)||[];if(d&&A.push(b[E]),h){const{main:M,cross:O}=SG(r,o,await(s.isRTL==null?void 0:s.isRTL(u.floating)));A.push(b[M],b[O])}if(T=[...T,{placement:r,overflows:A}],!A.every(M=>M<=0)){var B,D;const M=((B=(D=i.flip)==null?void 0:D.index)!=null?B:0)+1,O=C[M];if(O)return{data:{index:M,overflows:T},reset:{placement:O}};let z="bottom";switch(g){case"bestFit":{var I;const K=(I=T.map(X=>[X,X.overflows.filter(Z=>Z>0).reduce((Z,pe)=>Z+pe,0)]).sort((X,Z)=>X[1]-Z[1])[0])==null?void 0:I[0].placement;K&&(z=K);break}case"initialPlacement":z=a}if(r!==z)return{reset:{placement:z}}}return{}}}};function B6(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function M6(e){return QA.some(t=>e[t]>=0)}const kG=function(e){let{strategy:t="referenceHidden",...n}=e===void 0?{}:e;return{name:"hide",async fn(r){const{rects:i}=r;switch(t){case"referenceHidden":{const o=B6(await Ag(r,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:M6(o)}}}case"escaped":{const o=B6(await Ag(r,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:o,escaped:M6(o)}}}default:return{}}}}},IG=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){const{x:n,y:r}=t,i=await async function(o,a){const{placement:s,platform:u,elements:d}=o,h=await(u.isRTL==null?void 0:u.isRTL(d.floating)),p=Cd(s),g=jm(s),m=bd(s)==="x",v=["left","top"].includes(p)?-1:1,E=h&&m?-1:1,w=typeof a=="function"?a(o):a;let{mainAxis:C,crossAxis:b,alignmentAxis:A}=typeof w=="number"?{mainAxis:w,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...w};return g&&typeof A=="number"&&(b=g==="end"?-1*A:A),m?{x:b*E,y:C*v}:{x:C*v,y:b*E}}(t,e);return{x:n+i.x,y:r+i.y,data:i}}}};function ek(e){return e==="x"?"y":"x"}const DG=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:w=>{let{x:C,y:b}=w;return{x:C,y:b}}},...u}=e,d={x:n,y:r},h=await Ag(t,u),p=bd(Cd(i)),g=ek(p);let m=d[p],v=d[g];if(o){const w=p==="y"?"bottom":"right";m=by(m+h[p==="y"?"top":"left"],m,m-h[w])}if(a){const w=g==="y"?"bottom":"right";v=by(v+h[g==="y"?"top":"left"],v,v-h[w])}const E=s.fn({...t,[p]:m,[g]:v});return{...E,data:{x:E.x-n,y:E.y-r}}}}},TG=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:s=0,mainAxis:u=!0,crossAxis:d=!0}=e,h={x:n,y:r},p=bd(i),g=ek(p);let m=h[p],v=h[g];const E=typeof s=="function"?s({...o,placement:i}):s,w=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(u){const B=p==="y"?"height":"width",D=o.reference[p]-o.floating[B]+w.mainAxis,I=o.reference[p]+o.reference[B]-w.mainAxis;mI&&(m=I)}if(d){var C,b,A,T;const B=p==="y"?"width":"height",D=["top","left"].includes(Cd(i)),I=o.reference[g]-o.floating[B]+(D&&(C=(b=a.offset)==null?void 0:b[g])!=null?C:0)+(D?0:w.crossAxis),M=o.reference[g]+o.reference[B]+(D?0:(A=(T=a.offset)==null?void 0:T[g])!=null?A:0)-(D?w.crossAxis:0);vM&&(v=M)}return{[p]:m,[g]:v}}}};function tk(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}function Ps(e){if(e==null)return window;if(!tk(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}function Th(e){return Ps(e).getComputedStyle(e)}function ps(e){return tk(e)?"":e?(e.nodeName||"").toLowerCase():""}function nk(){const e=navigator.userAgentData;return e!=null&&e.brands?e.brands.map(t=>t.brand+"/"+t.version).join(" "):navigator.userAgent}function jo(e){return e instanceof Ps(e).HTMLElement}function bu(e){return e instanceof Ps(e).Element}function TE(e){return typeof ShadowRoot>"u"?!1:e instanceof Ps(e).ShadowRoot||e instanceof ShadowRoot}function Um(e){const{overflow:t,overflowX:n,overflowY:r}=Th(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function PG(e){return["table","td","th"].includes(ps(e))}function $6(e){const t=/firefox/i.test(nk()),n=Th(e);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||t&&n.willChange==="filter"||t&&!!n.filter&&n.filter!=="none"}function rk(){return!/^((?!chrome|android).)*safari/i.test(nk())}const R6=Math.min,S0=Math.max,Ig=Math.round;function gs(e,t,n){var r,i,o,a;t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect();let u=1,d=1;t&&jo(e)&&(u=e.offsetWidth>0&&Ig(s.width)/e.offsetWidth||1,d=e.offsetHeight>0&&Ig(s.height)/e.offsetHeight||1);const h=bu(e)?Ps(e):window,p=!rk()&&n,g=(s.left+(p&&(r=(i=h.visualViewport)==null?void 0:i.offsetLeft)!=null?r:0))/u,m=(s.top+(p&&(o=(a=h.visualViewport)==null?void 0:a.offsetTop)!=null?o:0))/d,v=s.width/u,E=s.height/d;return{width:v,height:E,top:m,right:g+v,bottom:m+E,left:g,x:g,y:m}}function gu(e){return(t=e,(t instanceof Ps(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function Km(e){return bu(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function ik(e){return gs(gu(e)).left+Km(e).scrollLeft}function BG(e,t,n){const r=jo(t),i=gu(t),o=gs(e,r&&function(u){const d=gs(u);return Ig(d.width)!==u.offsetWidth||Ig(d.height)!==u.offsetHeight}(t),n==="fixed");let a={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if(r||!r&&n!=="fixed")if((ps(t)!=="body"||Um(i))&&(a=Km(t)),jo(t)){const u=gs(t,!0);s.x=u.x+t.clientLeft,s.y=u.y+t.clientTop}else i&&(s.x=ik(i));return{x:o.left+a.scrollLeft-s.x,y:o.top+a.scrollTop-s.y,width:o.width,height:o.height}}function ok(e){return ps(e)==="html"?e:e.assignedSlot||e.parentNode||(TE(e)?e.host:null)||gu(e)}function F6(e){return jo(e)&&getComputedStyle(e).position!=="fixed"?e.offsetParent:null}function wy(e){const t=Ps(e);let n=F6(e);for(;n&&PG(n)&&getComputedStyle(n).position==="static";)n=F6(n);return n&&(ps(n)==="html"||ps(n)==="body"&&getComputedStyle(n).position==="static"&&!$6(n))?t:n||function(r){let i=ok(r);for(TE(i)&&(i=i.host);jo(i)&&!["html","body"].includes(ps(i));){if($6(i))return i;i=i.parentNode}return null}(e)||t}function L6(e){if(jo(e))return{width:e.offsetWidth,height:e.offsetHeight};const t=gs(e);return{width:t.width,height:t.height}}function ak(e){const t=ok(e);return["html","body","#document"].includes(ps(t))?e.ownerDocument.body:jo(t)&&Um(t)?t:ak(t)}function Dg(e,t){var n;t===void 0&&(t=[]);const r=ak(e),i=r===((n=e.ownerDocument)==null?void 0:n.body),o=Ps(r),a=i?[o].concat(o.visualViewport||[],Um(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(Dg(a))}function O6(e,t,n){return t==="viewport"?xg(function(r,i){const o=Ps(r),a=gu(r),s=o.visualViewport;let u=a.clientWidth,d=a.clientHeight,h=0,p=0;if(s){u=s.width,d=s.height;const g=rk();(g||!g&&i==="fixed")&&(h=s.offsetLeft,p=s.offsetTop)}return{width:u,height:d,x:h,y:p}}(e,n)):bu(t)?function(r,i){const o=gs(r,!1,i==="fixed"),a=o.top+r.clientTop,s=o.left+r.clientLeft;return{top:a,left:s,x:s,y:a,right:s+r.clientWidth,bottom:a+r.clientHeight,width:r.clientWidth,height:r.clientHeight}}(t,n):xg(function(r){var i;const o=gu(r),a=Km(r),s=(i=r.ownerDocument)==null?void 0:i.body,u=S0(o.scrollWidth,o.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),d=S0(o.scrollHeight,o.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0);let h=-a.scrollLeft+ik(r);const p=-a.scrollTop;return Th(s||o).direction==="rtl"&&(h+=S0(o.clientWidth,s?s.clientWidth:0)-u),{width:u,height:d,x:h,y:p}}(gu(e)))}function MG(e){const t=Dg(e),n=["absolute","fixed"].includes(Th(e).position)&&jo(e)?wy(e):e;return bu(n)?t.filter(r=>bu(r)&&function(i,o){const a=o.getRootNode==null?void 0:o.getRootNode();if(i.contains(o))return!0;if(a&&TE(a)){let s=o;do{if(s&&i===s)return!0;s=s.parentNode||s.host}while(s)}return!1}(r,n)&&ps(r)!=="body"):[]}const $G={getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?MG(t):[].concat(n),r],a=o[0],s=o.reduce((u,d)=>{const h=O6(t,d,i);return u.top=S0(h.top,u.top),u.right=R6(h.right,u.right),u.bottom=R6(h.bottom,u.bottom),u.left=S0(h.left,u.left),u},O6(t,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{rect:t,offsetParent:n,strategy:r}=e;const i=jo(n),o=gu(n);if(n===o)return t;let a={scrollLeft:0,scrollTop:0};const s={x:0,y:0};if((i||!i&&r!=="fixed")&&((ps(n)!=="body"||Um(o))&&(a=Km(n)),jo(n))){const u=gs(n,!0);s.x=u.x+n.clientLeft,s.y=u.y+n.clientTop}return{...t,x:t.x-a.scrollLeft+s.x,y:t.y-a.scrollTop+s.y}},isElement:bu,getDimensions:L6,getOffsetParent:wy,getDocumentElement:gu,getElementRects:e=>{let{reference:t,floating:n,strategy:r}=e;return{reference:BG(t,wy(n),r),floating:{...L6(n),x:0,y:0}}},getClientRects:e=>Array.from(e.getClientRects()),isRTL:e=>Th(e).direction==="rtl"};function RG(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,u=i&&!s,d=o&&!s,h=u||d?[...bu(e)?Dg(e):[],...Dg(t)]:[];h.forEach(v=>{u&&v.addEventListener("scroll",n,{passive:!0}),d&&v.addEventListener("resize",n)});let p,g=null;if(a){let v=!0;g=new ResizeObserver(()=>{v||n(),v=!1}),bu(e)&&!s&&g.observe(e),g.observe(t)}let m=s?gs(e):null;return s&&function v(){const E=gs(e);!m||E.x===m.x&&E.y===m.y&&E.width===m.width&&E.height===m.height||n(),m=E,p=requestAnimationFrame(v)}(),n(),()=>{var v;h.forEach(E=>{u&&E.removeEventListener("scroll",n),d&&E.removeEventListener("resize",n)}),(v=g)==null||v.disconnect(),g=null,s&&cancelAnimationFrame(p)}}const FG=(e,t,n)=>EG(e,t,{platform:$G,...n});var Sy=typeof document<"u"?l.useLayoutEffect:l.useEffect;function xy(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!xy(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!xy(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function LG(e){const t=l.useRef(e);return Sy(()=>{t.current=e}),t}function OG(e){let{middleware:t,placement:n="bottom",strategy:r="absolute",whileElementsMounted:i}=e===void 0?{}:e;const o=l.useRef(null),a=l.useRef(null),s=LG(i),u=l.useRef(null),[d,h]=l.useState({x:null,y:null,strategy:r,placement:n,middlewareData:{}}),[p,g]=l.useState(t);xy(p==null?void 0:p.map(A=>{let{options:T}=A;return T}),t==null?void 0:t.map(A=>{let{options:T}=A;return T}))||g(t);const m=l.useCallback(()=>{!o.current||!a.current||FG(o.current,a.current,{middleware:p,placement:n,strategy:r}).then(A=>{v.current&&$u.flushSync(()=>{h(A)})})},[p,n,r]);Sy(()=>{v.current&&m()},[m]);const v=l.useRef(!1);Sy(()=>(v.current=!0,()=>{v.current=!1}),[]);const E=l.useCallback(()=>{if(typeof u.current=="function"&&(u.current(),u.current=null),o.current&&a.current)if(s.current){const A=s.current(o.current,a.current,m);u.current=A}else m()},[m,s]),w=l.useCallback(A=>{o.current=A,E()},[E]),C=l.useCallback(A=>{a.current=A,E()},[E]),b=l.useMemo(()=>({reference:o,floating:a}),[]);return l.useMemo(()=>({...d,update:m,refs:b,reference:w,floating:C}),[d,m,b,w,C])}const _G=e=>{const{element:t,padding:n}=e;function r(i){return Object.prototype.hasOwnProperty.call(i,"current")}return{name:"arrow",options:e,fn(i){return r(t)?t.current!=null?T6({element:t.current,padding:n}).fn(i):{}:t?T6({element:t,padding:n}).fn(i):{}}}},NG=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return l.createElement(sr.svg,De({},o,{ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),e.asChild?n:l.createElement("polygon",{points:"0,0 30,0 15,10"}))}),zG=NG;function HG(e){const[t,n]=l.useState(void 0);return Qc(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,s;if("borderBoxSize"in o){const u=o.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,s=d.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const sk="Popper",[PE,uk]=Ed(sk),[jG,lk]=PE(sk),UG=e=>{const{__scopePopper:t,children:n}=e,[r,i]=l.useState(null);return l.createElement(jG,{scope:t,anchor:r,onAnchorChange:i},n)},KG="PopperAnchor",VG=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=lk(KG,n),a=l.useRef(null),s=Vr(t,a);return l.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:l.createElement(sr.div,De({},i,{ref:s}))}),Tg="PopperContent",[GG,JG]=PE(Tg),[WG,YG]=PE(Tg,{hasParent:!1,positionUpdateFns:new Set}),qG=l.forwardRef((e,t)=>{var n,r,i,o,a,s,u,d;const{__scopePopper:h,side:p="bottom",sideOffset:g=0,align:m="center",alignOffset:v=0,arrowPadding:E=0,collisionBoundary:w=[],collisionPadding:C=0,sticky:b="partial",hideWhenDetached:A=!1,avoidCollisions:T=!0,...B}=e,D=lk(Tg,h),[I,M]=l.useState(null),O=Vr(t,Wo=>M(Wo)),[z,K]=l.useState(null),X=HG(z),Z=(n=X==null?void 0:X.width)!==null&&n!==void 0?n:0,pe=(r=X==null?void 0:X.height)!==null&&r!==void 0?r:0,me=p+(m!=="center"?"-"+m:""),Ce=typeof C=="number"?C:{top:0,right:0,bottom:0,left:0,...C},W=Array.isArray(w)?w:[w],U=W.length>0,ne={padding:Ce,boundary:W.filter(tJ),altBoundary:U},{reference:le,floating:Ae,strategy:we,x:ft,y:Ze,placement:qe,middlewareData:Ge,update:At}=OG({strategy:"fixed",placement:me,whileElementsMounted:RG,middleware:[IG({mainAxis:g+pe,alignmentAxis:v}),T?DG({mainAxis:!0,crossAxis:!1,limiter:b==="partial"?TG():void 0,...ne}):void 0,z?_G({element:z,padding:E}):void 0,T?AG({...ne}):void 0,nJ({arrowWidth:Z,arrowHeight:pe}),A?kG({strategy:"referenceHidden"}):void 0].filter(eJ)});Qc(()=>{le(D.anchor)},[le,D.anchor]);const dt=ft!==null&&Ze!==null,[pn,Dn]=ck(qe),On=(i=Ge.arrow)===null||i===void 0?void 0:i.x,_n=(o=Ge.arrow)===null||o===void 0?void 0:o.y,Tn=((a=Ge.arrow)===null||a===void 0?void 0:a.centerOffset)!==0,[tn,Ri]=l.useState();Qc(()=>{I&&Ri(window.getComputedStyle(I).zIndex)},[I]);const{hasParent:zu,positionUpdateFns:Sn}=YG(Tg,h),ho=!zu;l.useLayoutEffect(()=>{if(!ho)return Sn.add(At),()=>{Sn.delete(At)}},[ho,Sn,At]),l.useLayoutEffect(()=>{ho&&dt&&Array.from(Sn).reverse().forEach(Wo=>requestAnimationFrame(Wo))},[ho,dt,Sn]);const Jo={"data-side":pn,"data-align":Dn,...B,ref:O,style:{...B.style,animation:dt?void 0:"none",opacity:(s=Ge.hide)!==null&&s!==void 0&&s.referenceHidden?0:void 0}};return l.createElement("div",{ref:Ae,"data-radix-popper-content-wrapper":"",style:{position:we,left:0,top:0,transform:dt?`translate3d(${Math.round(ft)}px, ${Math.round(Ze)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:tn,"--radix-popper-transform-origin":[(u=Ge.transformOrigin)===null||u===void 0?void 0:u.x,(d=Ge.transformOrigin)===null||d===void 0?void 0:d.y].join(" ")}},l.createElement(GG,{scope:h,placedSide:pn,onArrowChange:K,arrowX:On,arrowY:_n,shouldHideArrow:Tn},ho?l.createElement(WG,{scope:h,hasParent:!0,positionUpdateFns:Sn},l.createElement(sr.div,Jo)):l.createElement(sr.div,Jo)))}),XG="PopperArrow",ZG={top:"bottom",right:"left",bottom:"top",left:"right"},QG=l.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=JG(XG,r),a=ZG[o.placedSide];return l.createElement("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0}},l.createElement(zG,De({},i,{ref:n,style:{...i.style,display:"block"}})))});function eJ(e){return e!==void 0}function tJ(e){return e!==null}const nJ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,i,o,a;const{placement:s,rects:u,middlewareData:d}=t,p=((n=d.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,g=p?0:e.arrowWidth,m=p?0:e.arrowHeight,[v,E]=ck(s),w={start:"0%",center:"50%",end:"100%"}[E],C=((r=(i=d.arrow)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)+g/2,b=((o=(a=d.arrow)===null||a===void 0?void 0:a.y)!==null&&o!==void 0?o:0)+m/2;let A="",T="";return v==="bottom"?(A=p?w:`${C}px`,T=`${-m}px`):v==="top"?(A=p?w:`${C}px`,T=`${u.floating.height+m}px`):v==="right"?(A=`${-m}px`,T=p?w:`${b}px`):v==="left"&&(A=`${u.floating.width+m}px`,T=p?w:`${b}px`),{data:{x:A,y:T}}}});function ck(e){const[t,n="center"]=e.split("-");return[t,n]}const dk=UG,rJ=VG,iJ=qG,oJ=QG,aJ=l.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...i}=e;return r?Q7.createPortal(l.createElement(sr.div,De({},i,{ref:t})),r):null});function sJ(e,t){return l.useReducer((n,r)=>{const i=t[n][r];return i??n},e)}const Ph=e=>{const{present:t,children:n}=e,r=uJ(t),i=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),o=Vr(r.ref,i.ref);return typeof n=="function"||r.isPresent?l.cloneElement(i,{ref:o}):null};Ph.displayName="Presence";function uJ(e){const[t,n]=l.useState(),r=l.useRef({}),i=l.useRef(e),o=l.useRef("none"),a=e?"mounted":"unmounted",[s,u]=sJ(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=np(r.current);o.current=s==="mounted"?d:"none"},[s]),Qc(()=>{const d=r.current,h=i.current;if(h!==e){const g=o.current,m=np(d);e?u("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&g!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Qc(()=>{if(t){const d=p=>{const m=np(r.current).includes(p.animationName);p.target===t&&m&&$u.flushSync(()=>u("ANIMATION_END"))},h=p=>{p.target===t&&(o.current=np(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:l.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function np(e){return(e==null?void 0:e.animationName)||"none"}function Vm({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=lJ({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=Di(n),u=l.useCallback(d=>{if(o){const p=typeof d=="function"?d(e):d;p!==e&&s(p)}else i(d)},[o,e,i,s]);return[a,u]}function lJ({defaultProp:e,onChange:t}){const n=l.useState(e),[r]=n,i=l.useRef(r),o=Di(t);return l.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}const Tv="rovingFocusGroup.onEntryFocus",cJ={bubbles:!1,cancelable:!0},BE="RovingFocusGroup",[Ay,hk,dJ]=WA(BE),[hJ,fk]=Ed(BE,[dJ]),[fJ,pJ]=hJ(BE),gJ=l.forwardRef((e,t)=>l.createElement(Ay.Provider,{scope:e.__scopeRovingFocusGroup},l.createElement(Ay.Slot,{scope:e.__scopeRovingFocusGroup},l.createElement(mJ,De({},e,{ref:t}))))),mJ=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:u,onEntryFocus:d,...h}=e,p=l.useRef(null),g=Vr(t,p),m=YA(o),[v=null,E]=Vm({prop:a,defaultProp:s,onChange:u}),[w,C]=l.useState(!1),b=Di(d),A=hk(n),T=l.useRef(!1);return l.useEffect(()=>{const B=p.current;if(B)return B.addEventListener(Tv,b),()=>B.removeEventListener(Tv,b)},[b]),l.createElement(fJ,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:l.useCallback(B=>E(B),[E]),onItemShiftTab:l.useCallback(()=>C(!0),[])},l.createElement(sr.div,De({tabIndex:w?-1:0,"data-orientation":r},h,{ref:g,style:{outline:"none",...e.style},onMouseDown:Xe(e.onMouseDown,()=>{T.current=!0}),onFocus:Xe(e.onFocus,B=>{const D=!T.current;if(B.target===B.currentTarget&&D&&!w){const I=new CustomEvent(Tv,cJ);if(B.currentTarget.dispatchEvent(I),!I.defaultPrevented){const M=A().filter(Z=>Z.focusable),O=M.find(Z=>Z.active),z=M.find(Z=>Z.id===v),X=[O,z,...M].filter(Boolean).map(Z=>Z.ref.current);pk(X)}}T.current=!1}),onBlur:Xe(e.onBlur,()=>C(!1))})))}),vJ="RovingFocusGroupItem",yJ=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,...o}=e,a=th(),s=pJ(vJ,n),u=s.currentTabStopId===a,d=hk(n);return l.createElement(Ay.ItemSlot,{scope:n,id:a,focusable:r,active:i},l.createElement(sr.span,De({tabIndex:u?0:-1,"data-orientation":s.orientation},o,{ref:t,onMouseDown:Xe(e.onMouseDown,h=>{r?s.onItemFocus(a):h.preventDefault()}),onFocus:Xe(e.onFocus,()=>s.onItemFocus(a)),onKeyDown:Xe(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){s.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const p=bJ(h,s.orientation,s.dir);if(p!==void 0){h.preventDefault();let m=d().filter(v=>v.focusable).map(v=>v.ref.current);if(p==="last")m.reverse();else if(p==="prev"||p==="next"){p==="prev"&&m.reverse();const v=m.indexOf(h.currentTarget);m=s.loop?wJ(m,v+1):m.slice(v+1)}setTimeout(()=>pk(m))}})})))}),EJ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CJ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function bJ(e,t,n){const r=CJ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return EJ[r]}function pk(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const SJ=gJ,xJ=yJ;var AJ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ic=new WeakMap,rp=new WeakMap,ip={},Pv=0,gk=function(e){return e&&(e.host||gk(e.parentNode))},kJ=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=gk(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},IJ=function(e,t,n,r){var i=kJ(t,Array.isArray(e)?e:[e]);ip[n]||(ip[n]=new WeakMap);var o=ip[n],a=[],s=new Set,u=new Set(i),d=function(p){!p||s.has(p)||(s.add(p),d(p.parentNode))};i.forEach(d);var h=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(g){if(s.has(g))h(g);else{var m=g.getAttribute(r),v=m!==null&&m!=="false",E=(ic.get(g)||0)+1,w=(o.get(g)||0)+1;ic.set(g,E),o.set(g,w),a.push(g),E===1&&v&&rp.set(g,!0),w===1&&g.setAttribute(n,"true"),v||g.setAttribute(r,"true")}})};return h(t),s.clear(),Pv++,function(){a.forEach(function(p){var g=ic.get(p)-1,m=o.get(p)-1;ic.set(p,g),o.set(p,m),g||(rp.has(p)||p.removeAttribute(r),rp.delete(p)),m||p.removeAttribute(n)}),Pv--,Pv||(ic=new WeakMap,ic=new WeakMap,rp=new WeakMap,ip={})}},ME=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=AJ(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),IJ(r,i,n,"aria-hidden")):function(){return null}},x0="right-scroll-bar-position",A0="width-before-scroll-bar",DJ="with-scroll-bars-hidden",TJ="--removed-body-scroll-bar-size";function PJ(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function BJ(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}function mk(e,t){return BJ(null,function(n){return e.forEach(function(r){return PJ(r,n)})})}function MJ(e){return e}function $J(e,t){t===void 0&&(t=MJ);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var a=t(o,r);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(o){for(r=!0;n.length;){var a=n;n=[],a.forEach(o)}n={push:function(s){return o(s)},filter:function(){return n}}},assignMedium:function(o){r=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(o),a=n}var u=function(){var h=a;a=[],h.forEach(o)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(h){a.push(h),d()},filter:function(h){return a=a.filter(h),n}}}};return i}function vk(e){e===void 0&&(e={});var t=$J(null);return t.options=Ee({async:!0,ssr:!1},e),t}var yk=function(e){var t=e.sideCar,n=Ss(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,Ee({},n))};yk.isSideCarExport=!0;function Ek(e,t){return e.useMedium(t),yk}var Ck=vk(),Bv=function(){},Gm=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Bv,onWheelCapture:Bv,onTouchMoveCapture:Bv}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,g=e.sideCar,m=e.noIsolation,v=e.inert,E=e.allowPinchZoom,w=e.as,C=w===void 0?"div":w,b=Ss(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),A=g,T=mk([n,t]),B=Ee(Ee({},b),i);return l.createElement(l.Fragment,null,h&&l.createElement(A,{sideCar:Ck,removeScrollBar:d,shards:p,noIsolation:m,inert:v,setCallbacks:o,allowPinchZoom:!!E,lockRef:n}),a?l.cloneElement(l.Children.only(s),Ee(Ee({},B),{ref:T})):l.createElement(C,Ee({},B,{className:u,ref:T}),s))});Gm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Gm.classNames={fullWidth:A0,zeroRight:x0};var RJ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function FJ(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=RJ();return t&&e.setAttribute("nonce",t),e}function LJ(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OJ(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var _J=function(){var e=0,t=null;return{add:function(n){e==0&&(t=FJ())&&(LJ(t,n),OJ(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},NJ=function(){var e=_J();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},$E=function(){var e=NJ(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},zJ={left:0,top:0,right:0,gap:0},Mv=function(e){return parseInt(e||"",10)||0},HJ=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Mv(n),Mv(r),Mv(i)]},jJ=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zJ;var t=HJ(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},UJ=$E(),KJ=function(e,t,n,r){var i=e.left,o=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),` .`.concat(DJ,` { overflow: hidden `).concat(r,`; padding-right: `).concat(s,"px ").concat(r,`; @@ -419,23 +419,23 @@ For more details see https://formatjs.io/docs/getting-started/message-distributi body { `).concat(TJ,": ").concat(s,`px; } -`)},bk=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r,o=l.useMemo(function(){return jJ(i)},[i]);return l.createElement(UJ,{styles:KJ(o,!t,i,n?"":"!important")})},Ay=!1;if(typeof window<"u")try{var op=Object.defineProperty({},"passive",{get:function(){return Ay=!0,!0}});window.addEventListener("test",op,op),window.removeEventListener("test",op,op)}catch{Ay=!1}var oc=Ay?{passive:!1}:!1,VJ=function(e){var t=window.getComputedStyle(e);return t.overflowY!=="hidden"&&!(t.overflowY===t.overflowX&&t.overflowY==="visible")},GJ=function(e){var t=window.getComputedStyle(e);return t.overflowX!=="hidden"&&!(t.overflowY===t.overflowX&&t.overflowX==="visible")},_6=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=wk(e,n);if(r){var i=Sk(e,n),o=i[1],a=i[2];if(o>a)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},JJ=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},WJ=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},wk=function(e,t){return e==="v"?VJ(t):GJ(t)},Sk=function(e,t){return e==="v"?JJ(t):WJ(t)},YJ=function(e,t){return e==="h"&&t==="rtl"?-1:1},qJ=function(e,t,n,r,i){var o=YJ(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,u=t.contains(s),d=!1,h=a>0,p=0,g=0;do{var m=Sk(e,s),v=m[0],E=m[1],w=m[2],C=E-w-o*v;(v||C)&&wk(e,s)&&(p+=C,g+=v),s=s.parentNode}while(!u&&s!==document.body||u&&(t.contains(s)||t===s));return(h&&(p===0||!i)||!h&&(g===0||!i))&&(d=!0),d},ap=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},N6=function(e){return[e.deltaX,e.deltaY]},z6=function(e){return e&&"current"in e?e.current:e},XJ=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ZJ=function(e){return` +`)},bk=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r,o=l.useMemo(function(){return jJ(i)},[i]);return l.createElement(UJ,{styles:KJ(o,!t,i,n?"":"!important")})},ky=!1;if(typeof window<"u")try{var op=Object.defineProperty({},"passive",{get:function(){return ky=!0,!0}});window.addEventListener("test",op,op),window.removeEventListener("test",op,op)}catch{ky=!1}var oc=ky?{passive:!1}:!1,VJ=function(e){var t=window.getComputedStyle(e);return t.overflowY!=="hidden"&&!(t.overflowY===t.overflowX&&t.overflowY==="visible")},GJ=function(e){var t=window.getComputedStyle(e);return t.overflowX!=="hidden"&&!(t.overflowY===t.overflowX&&t.overflowX==="visible")},_6=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=wk(e,n);if(r){var i=Sk(e,n),o=i[1],a=i[2];if(o>a)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},JJ=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},WJ=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},wk=function(e,t){return e==="v"?VJ(t):GJ(t)},Sk=function(e,t){return e==="v"?JJ(t):WJ(t)},YJ=function(e,t){return e==="h"&&t==="rtl"?-1:1},qJ=function(e,t,n,r,i){var o=YJ(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,u=t.contains(s),d=!1,h=a>0,p=0,g=0;do{var m=Sk(e,s),v=m[0],E=m[1],w=m[2],C=E-w-o*v;(v||C)&&wk(e,s)&&(p+=C,g+=v),s=s.parentNode}while(!u&&s!==document.body||u&&(t.contains(s)||t===s));return(h&&(p===0||!i)||!h&&(g===0||!i))&&(d=!0),d},ap=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},N6=function(e){return[e.deltaX,e.deltaY]},z6=function(e){return e&&"current"in e?e.current:e},XJ=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ZJ=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},QJ=0,ac=[];function eW(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),i=l.useState(QJ++)[0],o=l.useState(function(){return ME()})[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var E=ui([e.lockRef.current],(e.shards||[]).map(z6),!0).filter(Boolean);return E.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),E.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=l.useCallback(function(E,w){if("touches"in E&&E.touches.length===2)return!a.current.allowPinchZoom;var C=ap(E),b=n.current,A="deltaX"in E?E.deltaX:b[0]-C[0],T="deltaY"in E?E.deltaY:b[1]-C[1],B,D=E.target,I=Math.abs(A)>Math.abs(T)?"h":"v";if("touches"in E&&I==="h"&&D.type==="range")return!1;var M=_6(I,D);if(!M)return!0;if(M?B=I:(B=I==="v"?"h":"v",M=_6(I,D)),!M)return!1;if(!r.current&&"changedTouches"in E&&(A||T)&&(r.current=B),!B)return!0;var O=r.current||B;return qJ(O,w,E,O==="h"?A:T,!0)},[]),u=l.useCallback(function(E){var w=E;if(!(!ac.length||ac[ac.length-1]!==o)){var C="deltaY"in w?N6(w):ap(w),b=t.current.filter(function(B){return B.name===w.type&&B.target===w.target&&XJ(B.delta,C)})[0];if(b&&b.should){w.preventDefault();return}if(!b){var A=(a.current.shards||[]).map(z6).filter(Boolean).filter(function(B){return B.contains(w.target)}),T=A.length>0?s(w,A[0]):!a.current.noIsolation;T&&w.preventDefault()}}},[]),d=l.useCallback(function(E,w,C,b){var A={name:E,delta:w,target:C,should:b};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(T){return T!==A})},1)},[]),h=l.useCallback(function(E){n.current=ap(E),r.current=void 0},[]),p=l.useCallback(function(E){d(E.type,N6(E),E.target,s(E,e.lockRef.current))},[]),g=l.useCallback(function(E){d(E.type,ap(E),E.target,s(E,e.lockRef.current))},[]);l.useEffect(function(){return ac.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",u,oc),document.addEventListener("touchmove",u,oc),document.addEventListener("touchstart",h,oc),function(){ac=ac.filter(function(E){return E!==o}),document.removeEventListener("wheel",u,oc),document.removeEventListener("touchmove",u,oc),document.removeEventListener("touchstart",h,oc)}},[]);var m=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(o,{styles:ZJ(i)}):null,m?l.createElement(bk,{gapMode:"margin"}):null)}const tW=Ek(Ck,eW);var xk=l.forwardRef(function(e,t){return l.createElement(Gm,Ee({},e,{ref:t,sideCar:tW}))});xk.classNames=Gm.classNames;const ky=["Enter"," "],nW=["ArrowDown","PageUp","Home"],Ak=["ArrowUp","PageDown","End"],rW=[...nW,...Ak],iW={ltr:[...ky,"ArrowRight"],rtl:[...ky,"ArrowLeft"]},oW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Jm="Menu",[nh,aW,sW]=WA(Jm),[Rl,Wm]=Ed(Jm,[sW,uk,fk]),Bh=uk(),kk=fk(),[Ik,Fu]=Rl(Jm),[uW,Mh]=Rl(Jm),lW=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:a=!0}=e,s=Bh(t),[u,d]=l.useState(null),h=l.useRef(!1),p=Di(o),g=YA(i);return l.useEffect(()=>{const m=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),l.createElement(dk,s,l.createElement(Ik,{scope:t,open:n,onOpenChange:p,content:u,onContentChange:d},l.createElement(uW,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:g,modal:a},r)))},Dk=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Bh(n);return l.createElement(rJ,De({},i,r,{ref:t}))}),Tk="MenuPortal",[cW,Pk]=Rl(Tk,{forceMount:void 0}),dW=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Fu(Tk,t);return l.createElement(cW,{scope:t,forceMount:n},l.createElement(Ph,{present:n||o.open},l.createElement(aJ,{asChild:!0,container:i},r)))},eo="MenuContent",[hW,$E]=Rl(eo),fW=l.forwardRef((e,t)=>{const n=Pk(eo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Fu(eo,e.__scopeMenu),a=Mh(eo,e.__scopeMenu);return l.createElement(nh.Provider,{scope:e.__scopeMenu},l.createElement(Ph,{present:r||o.open},l.createElement(nh.Slot,{scope:e.__scopeMenu},a.modal?l.createElement(pW,De({},i,{ref:t})):l.createElement(gW,De({},i,{ref:t})))))}),pW=l.forwardRef((e,t)=>{const n=Fu(eo,e.__scopeMenu),r=l.useRef(null),i=Vr(t,r);return l.useEffect(()=>{const o=r.current;if(o)return BE(o)},[]),l.createElement(RE,De({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),gW=l.forwardRef((e,t)=>{const n=Fu(eo,e.__scopeMenu);return l.createElement(RE,De({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),RE=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:g,disableOutsideScroll:m,...v}=e,E=Fu(eo,n),w=Mh(eo,n),C=Bh(n),b=kk(n),A=aW(n),[T,B]=l.useState(null),D=l.useRef(null),I=Vr(t,D,E.onContentChange),M=l.useRef(0),O=l.useRef(""),z=l.useRef(0),K=l.useRef(null),X=l.useRef("right"),Z=l.useRef(0),pe=m?xk:l.Fragment,me=m?{as:eh,allowPinchZoom:!0}:void 0,Ce=U=>{var ne,le;const Ae=O.current+U,we=A().filter(dt=>!dt.disabled),ft=document.activeElement,Ze=(ne=we.find(dt=>dt.ref.current===ft))===null||ne===void 0?void 0:ne.textValue,qe=we.map(dt=>dt.textValue),Ge=FW(qe,Ae,Ze),At=(le=we.find(dt=>dt.textValue===Ge))===null||le===void 0?void 0:le.ref.current;(function dt(pn){O.current=pn,window.clearTimeout(M.current),pn!==""&&(M.current=window.setTimeout(()=>dt(""),1e3))})(Ae),At&&setTimeout(()=>At.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),lG();const W=l.useCallback(U=>{var ne,le;return X.current===((ne=K.current)===null||ne===void 0?void 0:ne.side)&&OW(U,(le=K.current)===null||le===void 0?void 0:le.area)},[]);return l.createElement(hW,{scope:n,searchRef:O,onItemEnter:l.useCallback(U=>{W(U)&&U.preventDefault()},[W]),onItemLeave:l.useCallback(U=>{var ne;W(U)||((ne=D.current)===null||ne===void 0||ne.focus(),B(null))},[W]),onTriggerLeave:l.useCallback(U=>{W(U)&&U.preventDefault()},[W]),pointerGraceTimerRef:z,onPointerGraceIntentChange:l.useCallback(U=>{K.current=U},[])},l.createElement(pe,me,l.createElement(cG,{asChild:!0,trapped:i,onMountAutoFocus:Xe(o,U=>{var ne;U.preventDefault(),(ne=D.current)===null||ne===void 0||ne.focus()}),onUnmountAutoFocus:a},l.createElement(aG,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:g},l.createElement(SJ,De({asChild:!0},b,{dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:B,onEntryFocus:U=>{w.isUsingKeyboardRef.current||U.preventDefault()}}),l.createElement(iJ,De({role:"menu","aria-orientation":"vertical","data-state":Lk(E.open),dir:w.dir},C,v,{ref:I,style:{outline:"none",...v.style},onKeyDown:Xe(v.onKeyDown,U=>{const le=U.target.closest('[role="menu"]')===U.currentTarget,Ae=U.ctrlKey||U.altKey||U.metaKey,we=U.key.length===1;le&&(U.key==="Tab"&&U.preventDefault(),!Ae&&we&&Ce(U.key));const ft=D.current;if(U.target!==ft||!rW.includes(U.key))return;U.preventDefault();const qe=A().filter(Ge=>!Ge.disabled).map(Ge=>Ge.ref.current);Ak.includes(U.key)&&qe.reverse(),$W(qe)}),onBlur:Xe(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(M.current),O.current="")}),onPointerMove:Xe(e.onPointerMove,rh(U=>{const ne=U.target,le=Z.current!==U.clientX;if(U.currentTarget.contains(ne)&&le){const Ae=U.clientX>Z.current?"right":"left";X.current=Ae,Z.current=U.clientX}}))})))))))}),mW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.createElement(sr.div,De({role:"group"},r,{ref:t}))}),Iy="MenuItem",H6="menu.itemSelect",FE=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,o=l.useRef(null),a=Mh(Iy,e.__scopeMenu),s=$E(Iy,e.__scopeMenu),u=Vr(t,o),d=l.useRef(!1),h=()=>{const p=o.current;if(!n&&p){const g=new CustomEvent(H6,{bubbles:!0,cancelable:!0});p.addEventListener(H6,m=>r==null?void 0:r(m),{once:!0}),JA(p,g),g.defaultPrevented?d.current=!1:a.onClose()}};return l.createElement(Bk,De({},i,{ref:u,disabled:n,onClick:Xe(e.onClick,h),onPointerDown:p=>{var g;(g=e.onPointerDown)===null||g===void 0||g.call(e,p),d.current=!0},onPointerUp:Xe(e.onPointerUp,p=>{var g;d.current||(g=p.currentTarget)===null||g===void 0||g.click()}),onKeyDown:Xe(e.onKeyDown,p=>{const g=s.searchRef.current!=="";n||g&&p.key===" "||ky.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})}))}),Bk=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,a=$E(Iy,n),s=kk(n),u=l.useRef(null),d=Vr(t,u),[h,p]=l.useState(!1),[g,m]=l.useState("");return l.useEffect(()=>{const v=u.current;if(v){var E;m(((E=v.textContent)!==null&&E!==void 0?E:"").trim())}},[o.children]),l.createElement(nh.ItemSlot,{scope:n,disabled:r,textValue:i??g},l.createElement(xJ,De({asChild:!0},s,{focusable:!r}),l.createElement(sr.div,De({role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},o,{ref:d,onPointerMove:Xe(e.onPointerMove,rh(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:Xe(e.onPointerLeave,rh(v=>a.onItemLeave(v))),onFocus:Xe(e.onFocus,()=>p(!0)),onBlur:Xe(e.onBlur,()=>p(!1))}))))}),vW=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return l.createElement($k,{scope:e.__scopeMenu,checked:n},l.createElement(FE,De({role:"menuitemcheckbox","aria-checked":n},i,{ref:t,"data-state":LE(n),onSelect:Xe(i.onSelect,()=>r==null?void 0:r(!n),{checkForDefaultPrevented:!1})})))}),yW="MenuRadioGroup",[EW,CW]=Rl(yW,{value:void 0,onValueChange:()=>{}}),bW=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=Di(r);return l.createElement(EW,{scope:e.__scopeMenu,value:n,onValueChange:o},l.createElement(mW,De({},i,{ref:t})))}),wW="MenuRadioItem",SW=l.forwardRef((e,t)=>{const{value:n,...r}=e,i=CW(wW,e.__scopeMenu),o=n===i.value;return l.createElement($k,{scope:e.__scopeMenu,checked:o},l.createElement(FE,De({role:"menuitemradio","aria-checked":o},r,{ref:t,"data-state":LE(o),onSelect:Xe(r.onSelect,()=>{var a;return(a=i.onValueChange)===null||a===void 0?void 0:a.call(i,n)},{checkForDefaultPrevented:!1})})))}),Mk="MenuItemIndicator",[$k,xW]=Rl(Mk,{checked:!1}),AW=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=xW(Mk,n);return l.createElement(Ph,{present:r||o.checked},l.createElement(sr.span,De({},i,{ref:t,"data-state":LE(o.checked)})))}),kW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.createElement(sr.div,De({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),IW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Bh(n);return l.createElement(oJ,De({},i,r,{ref:t}))}),Rk="MenuSub",[DW,Fk]=Rl(Rk),TW=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,o=Fu(Rk,t),a=Bh(t),[s,u]=l.useState(null),[d,h]=l.useState(null),p=Di(i);return l.useEffect(()=>(o.open===!1&&p(!1),()=>p(!1)),[o.open,p]),l.createElement(dk,a,l.createElement(Ik,{scope:t,open:r,onOpenChange:p,content:d,onContentChange:h},l.createElement(DW,{scope:t,contentId:th(),triggerId:th(),trigger:s,onTriggerChange:u},n)))},sp="MenuSubTrigger",PW=l.forwardRef((e,t)=>{const n=Fu(sp,e.__scopeMenu),r=Mh(sp,e.__scopeMenu),i=Fk(sp,e.__scopeMenu),o=$E(sp,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:u}=o,d={__scopeMenu:e.__scopeMenu},h=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>h,[h]),l.useEffect(()=>{const p=s.current;return()=>{window.clearTimeout(p),u(null)}},[s,u]),l.createElement(Dk,De({asChild:!0},d),l.createElement(Bk,De({id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Lk(n.open)},e,{ref:Hm(t,i.onTriggerChange),onClick:p=>{var g;(g=e.onClick)===null||g===void 0||g.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Xe(e.onPointerMove,rh(p=>{o.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Xe(e.onPointerLeave,rh(p=>{var g;h();const m=(g=n.content)===null||g===void 0?void 0:g.getBoundingClientRect();if(m){var v;const E=(v=n.content)===null||v===void 0?void 0:v.dataset.side,w=E==="right",C=w?-5:5,b=m[w?"left":"right"],A=m[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:p.clientX+C,y:p.clientY},{x:b,y:m.top},{x:A,y:m.top},{x:A,y:m.bottom},{x:b,y:m.bottom}],side:E}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(p),p.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Xe(e.onKeyDown,p=>{const g=o.searchRef.current!=="";if(!(e.disabled||g&&p.key===" ")&&iW[r.dir].includes(p.key)){var m;n.onOpenChange(!0),(m=n.content)===null||m===void 0||m.focus(),p.preventDefault()}})})))}),BW="MenuSubContent",MW=l.forwardRef((e,t)=>{const n=Pk(eo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Fu(eo,e.__scopeMenu),a=Mh(eo,e.__scopeMenu),s=Fk(BW,e.__scopeMenu),u=l.useRef(null),d=Vr(t,u);return l.createElement(nh.Provider,{scope:e.__scopeMenu},l.createElement(Ph,{present:r||o.open},l.createElement(nh.Slot,{scope:e.__scopeMenu},l.createElement(RE,De({id:s.contentId,"aria-labelledby":s.triggerId},i,{ref:d,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var p;a.isUsingKeyboardRef.current&&((p=u.current)===null||p===void 0||p.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Xe(e.onFocusOutside,h=>{h.target!==s.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Xe(e.onEscapeKeyDown,a.onClose),onKeyDown:Xe(e.onKeyDown,h=>{const p=h.currentTarget.contains(h.target),g=oW[a.dir].includes(h.key);if(p&&g){var m;o.onOpenChange(!1),(m=s.trigger)===null||m===void 0||m.focus(),h.preventDefault()}})})))))});function Lk(e){return e?"open":"closed"}function LE(e){return e?"checked":"unchecked"}function $W(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function RW(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function FW(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let a=RW(e,Math.max(o,0));i.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function LW(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;or!=h>r&&n<(d-s)*(r-u)/(h-u)+s&&(i=!i)}return i}function OW(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return LW(n,t)}function rh(e){return t=>t.pointerType==="mouse"?e(t):void 0}const Ok=lW,_k=Dk,Nk=dW,zk=fW,Hk=FE,_W=vW,NW=bW,zW=SW,HW=AW,jW=kW,jk=IW,Uk=TW,Kk=PW,Vk=MW,Gk="ContextMenu",[UW,eGe]=Ed(Gk,[Wm]),Bs=Wm(),[KW,Jk]=UW(Gk),VW=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:o=!0}=e,[a,s]=l.useState(!1),u=Bs(t),d=Di(r),h=l.useCallback(p=>{s(p),d(p)},[d]);return l.createElement(KW,{scope:t,open:a,onOpenChange:h,modal:o},l.createElement(Ok,De({},u,{dir:i,open:a,onOpenChange:h,modal:o}),n))},GW="ContextMenuTrigger",JW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Jk(GW,n),o=Bs(n),a=l.useRef({x:0,y:0}),s=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(u.current),[]),h=p=>{a.current={x:p.clientX,y:p.clientY},i.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.createElement(l.Fragment,null,l.createElement(_k,De({},o,{virtualRef:s})),l.createElement(sr.span,De({"data-state":i.open?"open":"closed"},r,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:Xe(e.onContextMenu,p=>{d(),h(p),p.preventDefault()}),onPointerDown:Xe(e.onPointerDown,up(p=>{d(),u.current=window.setTimeout(()=>h(p),700)})),onPointerMove:Xe(e.onPointerMove,up(d)),onPointerCancel:Xe(e.onPointerCancel,up(d)),onPointerUp:Xe(e.onPointerUp,up(d))})))}),WW=e=>{const{__scopeContextMenu:t,...n}=e,r=Bs(t);return l.createElement(Nk,De({},r,n))},YW="ContextMenuContent",qW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Jk(YW,n),o=Bs(n),a=l.useRef(!1);return l.createElement(zk,De({},o,r,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:s=>{var u;(u=e.onCloseAutoFocus)===null||u===void 0||u.call(e,s),!s.defaultPrevented&&a.current&&s.preventDefault(),a.current=!1},onInteractOutside:s=>{var u;(u=e.onInteractOutside)===null||u===void 0||u.call(e,s),!s.defaultPrevented&&!i.modal&&(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),Wk=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Hk,De({},i,r,{ref:t}))}),XW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(jk,De({},i,r,{ref:t}))}),ZW=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:o}=e,a=Bs(t),[s,u]=Vm({prop:i,defaultProp:o,onChange:r});return l.createElement(Uk,De({},a,{open:s,onOpenChange:u}),n)},QW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Kk,De({},i,r,{ref:t}))}),eY=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Vk,De({},i,r,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))});function up(e){return t=>t.pointerType!=="mouse"?e(t):void 0}const tY=VW,nY=JW,Ym=WW,rY=qW,OE=ZW,iY=QW,_E=eY;function je(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o=0)&&(n[i]=e[i]);return n}var oY=["color"],Yk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,oY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M9 3C9 2.44772 8.55229 2 8 2H7C6.44772 2 6 2.44772 6 3L6 14H1.5C1.22386 14 1 14.2239 1 14.5C1 14.7761 1.22386 15 1.5 15L6 15H9H13.5C13.7761 15 14 14.7761 14 14.5C14 14.2239 13.7761 14 13.5 14H9V3Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),aY=["color"],qk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,aY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.99988 6C1.44759 6 0.999877 6.44772 0.999877 7L0.999877 8C0.999877 8.55228 1.44759 9 1.99988 9L6.99988 9L6.99988 13.5C6.99988 13.7761 7.22374 14 7.49988 14C7.77602 14 7.99988 13.7761 7.99988 13.5L7.99988 9L12.9999 9C13.5522 9 13.9999 8.55228 13.9999 8L13.9999 7C13.9999 6.44772 13.5522 6 12.9999 6L7.99988 6L7.99988 1.5C7.99988 1.22386 7.77602 1 7.49988 1C7.22373 1 6.99988 1.22386 6.99988 1.5L6.99988 6L1.99988 6Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),sY=["color"],Xk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,sY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M6.99988 1C6.44759 1 5.99988 1.44772 5.99988 2V7H1.49988C1.22374 7 0.999878 7.22386 0.999878 7.5C0.999878 7.77614 1.22374 8 1.49988 8H5.99988V13C5.99988 13.5523 6.44759 14 6.99988 14H7.99988C8.55216 14 8.99988 13.5523 8.99988 13V8H13.4999C13.776 8 13.9999 7.77614 13.9999 7.5C13.9999 7.22386 13.776 7 13.4999 7H8.99988V2C8.99988 1.44772 8.55216 1 7.99988 1L6.99988 1Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),uY=["color"],Zk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,uY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.499995 0.999995C0.223855 0.999995 -5.58458e-07 1.22385 -5.46388e-07 1.49999L-2.18554e-08 13.4999C-9.78492e-09 13.776 0.223855 13.9999 0.499995 13.9999C0.776136 13.9999 0.999991 13.776 0.999991 13.4999L0.999991 8.99993L12 8.99993C12.5523 8.99993 13 8.55222 13 7.99993L13 6.99994C13 6.44766 12.5523 5.99995 12 5.99995L0.999991 5.99995L0.999991 1.49999C0.999991 1.22385 0.776135 0.999995 0.499995 0.999995Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lY=["color"],Qk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,lY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 1C14.2237 1 13.9999 1.22386 13.9999 1.5L13.9999 6L2.99988 6C2.44759 6 1.99988 6.44772 1.99988 7L1.99988 8C1.99988 8.55228 2.44759 9 2.99988 9L13.9999 9L13.9999 13.5C13.9999 13.7761 14.2237 14 14.4999 14C14.776 14 14.9999 13.7761 14.9999 13.5L14.9999 9L14.9999 6L14.9999 1.5C14.9999 1.22386 14.776 1 14.4999 1Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),cY=["color"],eI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,cY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.5 0C1.22386 0 1 0.223858 1 0.5C1 0.776142 1.22386 1 1.5 1H6V12C6 12.5523 6.44772 13 7 13H8C8.55228 13 9 12.5523 9 12V1H13.5C13.7761 1 14 0.776142 14 0.5C14 0.223858 13.7761 0 13.5 0H9H6H1.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),dY=["color"],hY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,dY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M8.8914 2.1937C9.1158 2.35464 9.16725 2.66701 9.00631 2.89141L2.47388 12H13.5C13.7761 12 14 12.2239 14 12.5C14 12.7762 13.7761 13 13.5 13H1.5C1.31254 13 1.14082 12.8952 1.0552 12.7284C0.969578 12.5616 0.984438 12.361 1.09369 12.2086L8.19369 2.30862C8.35462 2.08422 8.667 2.03277 8.8914 2.1937ZM11.1 6.50001C11.1 6.22387 11.3238 6.00001 11.6 6.00001C11.8761 6.00001 12.1 6.22387 12.1 6.50001C12.1 6.77615 11.8761 7.00001 11.6 7.00001C11.3238 7.00001 11.1 6.77615 11.1 6.50001ZM10.4 4.00001C10.1239 4.00001 9.90003 4.22387 9.90003 4.50001C9.90003 4.77615 10.1239 5.00001 10.4 5.00001C10.6762 5.00001 10.9 4.77615 10.9 4.50001C10.9 4.22387 10.6762 4.00001 10.4 4.00001ZM12.1 8.50001C12.1 8.22387 12.3238 8.00001 12.6 8.00001C12.8761 8.00001 13.1 8.22387 13.1 8.50001C13.1 8.77615 12.8761 9.00001 12.6 9.00001C12.3238 9.00001 12.1 8.77615 12.1 8.50001ZM13.4 10C13.1239 10 12.9 10.2239 12.9 10.5C12.9 10.7761 13.1239 11 13.4 11C13.6762 11 13.9 10.7761 13.9 10.5C13.9 10.2239 13.6762 10 13.4 10Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fY=["color"],pY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,fY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gY=["color"],mY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,gY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),vY=["color"],yY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,vY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),EY=["color"],CY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,EY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 2H12.5C12.7761 2 13 2.22386 13 2.5V12.5C13 12.7761 12.7761 13 12.5 13H2.5C2.22386 13 2 12.7761 2 12.5V2.5C2 2.22386 2.22386 2 2.5 2ZM1 2.5C1 1.67157 1.67157 1 2.5 1H12.5C13.3284 1 14 1.67157 14 2.5V12.5C14 13.3284 13.3284 14 12.5 14H2.5C1.67157 14 1 13.3284 1 12.5V2.5ZM7.5 4C7.77614 4 8 3.77614 8 3.5C8 3.22386 7.77614 3 7.5 3C7.22386 3 7 3.22386 7 3.5C7 3.77614 7.22386 4 7.5 4ZM8 5.5C8 5.77614 7.77614 6 7.5 6C7.22386 6 7 5.77614 7 5.5C7 5.22386 7.22386 5 7.5 5C7.77614 5 8 5.22386 8 5.5ZM7.5 8C7.77614 8 8 7.77614 8 7.5C8 7.22386 7.77614 7 7.5 7C7.22386 7 7 7.22386 7 7.5C7 7.77614 7.22386 8 7.5 8ZM10 7.5C10 7.77614 9.77614 8 9.5 8C9.22386 8 9 7.77614 9 7.5C9 7.22386 9.22386 7 9.5 7C9.77614 7 10 7.22386 10 7.5ZM11.5 8C11.7761 8 12 7.77614 12 7.5C12 7.22386 11.7761 7 11.5 7C11.2239 7 11 7.22386 11 7.5C11 7.77614 11.2239 8 11.5 8Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),bY=["color"],wY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,bY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M12.5 2H2.5C2.22386 2 2 2.22386 2 2.5V12.5C2 12.7761 2.22386 13 2.5 13H12.5C12.7761 13 13 12.7761 13 12.5V2.5C13 2.22386 12.7761 2 12.5 2ZM2.5 1C1.67157 1 1 1.67157 1 2.5V12.5C1 13.3284 1.67157 14 2.5 14H12.5C13.3284 14 14 13.3284 14 12.5V2.5C14 1.67157 13.3284 1 12.5 1H2.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),SY=["color"],Pg=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,SY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),xY=["color"],AY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,xY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),kY=["color"],IY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,kY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.877075 7.49991C0.877075 3.84222 3.84222 0.877075 7.49991 0.877075C11.1576 0.877075 14.1227 3.84222 14.1227 7.49991C14.1227 11.1576 11.1576 14.1227 7.49991 14.1227C3.84222 14.1227 0.877075 11.1576 0.877075 7.49991ZM7.49991 1.82708C4.36689 1.82708 1.82708 4.36689 1.82708 7.49991C1.82708 10.6329 4.36689 13.1727 7.49991 13.1727C10.6329 13.1727 13.1727 10.6329 13.1727 7.49991C13.1727 4.36689 10.6329 1.82708 7.49991 1.82708Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),DY=["color"],j6=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,DY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 2V1H10V2H5ZM4.75 0C4.33579 0 4 0.335786 4 0.75V1H3.5C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H11.5C12.3284 14 13 13.3284 13 12.5V2.5C13 1.67157 12.3284 1 11.5 1H11V0.75C11 0.335786 10.6642 0 10.25 0H4.75ZM11 2V2.25C11 2.66421 10.6642 3 10.25 3H4.75C4.33579 3 4 2.66421 4 2.25V2H3.5C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V2.5C12 2.22386 11.7761 2 11.5 2H11Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),TY=["color"],PY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,TY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1 9.50006C1 10.3285 1.67157 11.0001 2.5 11.0001H4L4 10.0001H2.5C2.22386 10.0001 2 9.7762 2 9.50006L2 2.50006C2 2.22392 2.22386 2.00006 2.5 2.00006L9.5 2.00006C9.77614 2.00006 10 2.22392 10 2.50006V4.00002H5.5C4.67158 4.00002 4 4.67159 4 5.50002V12.5C4 13.3284 4.67158 14 5.5 14H12.5C13.3284 14 14 13.3284 14 12.5V5.50002C14 4.67159 13.3284 4.00002 12.5 4.00002H11V2.50006C11 1.67163 10.3284 1.00006 9.5 1.00006H2.5C1.67157 1.00006 1 1.67163 1 2.50006V9.50006ZM5 5.50002C5 5.22388 5.22386 5.00002 5.5 5.00002H12.5C12.7761 5.00002 13 5.22388 13 5.50002V12.5C13 12.7762 12.7761 13 12.5 13H5.5C5.22386 13 5 12.7762 5 12.5V5.50002Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),BY=["color"],MY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,BY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),$Y=["color"],RY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,$Y);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.29227 0.048984C3.47033 -0.032338 3.67946 -0.00228214 3.8274 0.125891L12.8587 7.95026C13.0134 8.08432 13.0708 8.29916 13.0035 8.49251C12.9362 8.68586 12.7578 8.81866 12.5533 8.82768L9.21887 8.97474L11.1504 13.2187C11.2648 13.47 11.1538 13.7664 10.9026 13.8808L8.75024 14.8613C8.499 14.9758 8.20255 14.8649 8.08802 14.6137L6.15339 10.3703L3.86279 12.7855C3.72196 12.934 3.50487 12.9817 3.31479 12.9059C3.1247 12.8301 3 12.6461 3 12.4414V0.503792C3 0.308048 3.11422 0.130306 3.29227 0.048984ZM4 1.59852V11.1877L5.93799 9.14425C6.05238 9.02363 6.21924 8.96776 6.38319 8.99516C6.54715 9.02256 6.68677 9.12965 6.75573 9.2809L8.79056 13.7441L10.0332 13.178L8.00195 8.71497C7.93313 8.56376 7.94391 8.38824 8.03072 8.24659C8.11753 8.10494 8.26903 8.01566 8.435 8.00834L11.2549 7.88397L4 1.59852Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),FY=["color"],LY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,FY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M9.875 7.5C9.875 8.81168 8.81168 9.875 7.5 9.875C6.18832 9.875 5.125 8.81168 5.125 7.5C5.125 6.18832 6.18832 5.125 7.5 5.125C8.81168 5.125 9.875 6.18832 9.875 7.5Z",fill:r}))}),OY=["color"],_Y=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,OY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.625 7.5C3.625 8.12132 3.12132 8.625 2.5 8.625C1.87868 8.625 1.375 8.12132 1.375 7.5C1.375 6.87868 1.87868 6.375 2.5 6.375C3.12132 6.375 3.625 6.87868 3.625 7.5ZM8.625 7.5C8.625 8.12132 8.12132 8.625 7.5 8.625C6.87868 8.625 6.375 8.12132 6.375 7.5C6.375 6.87868 6.87868 6.375 7.5 6.375C8.12132 6.375 8.625 6.87868 8.625 7.5ZM12.5 8.625C13.1213 8.625 13.625 8.12132 13.625 7.5C13.625 6.87868 13.1213 6.375 12.5 6.375C11.8787 6.375 11.375 6.87868 11.375 7.5C11.375 8.12132 11.8787 8.625 12.5 8.625Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),NY=["color"],tI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,NY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),zY=["color"],HY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,zY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),jY=["color"],UY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,jY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.44995 0.949951C1.31734 0.949951 1.19016 1.00263 1.0964 1.0964C1.00263 1.19017 0.949951 1.31735 0.949951 1.44995L0.949966 3.44995C0.949969 3.7261 1.17383 3.94995 1.44997 3.94995C1.72611 3.94995 1.94997 3.72609 1.94997 3.44995L1.94995 1.94995H3.44997C3.72611 1.94995 3.94997 1.72609 3.94997 1.44995C3.94997 1.17381 3.72611 0.949951 3.44997 0.949951H1.44995ZM5.94995 0.949951C5.67381 0.949951 5.44995 1.17381 5.44995 1.44995C5.44995 1.72609 5.67381 1.94995 5.94995 1.94995H8.94995C9.22609 1.94995 9.44995 1.72609 9.44995 1.44995C9.44995 1.17381 9.22609 0.949951 8.94995 0.949951H5.94995ZM5.44995 13.45C5.44995 13.1738 5.67381 12.95 5.94995 12.95H8.94995C9.22609 12.95 9.44995 13.1738 9.44995 13.45C9.44995 13.7261 9.22609 13.95 8.94995 13.95H5.94995C5.67381 13.95 5.44995 13.7261 5.44995 13.45ZM1.94995 5.94995C1.94995 5.67381 1.72609 5.44995 1.44995 5.44995C1.17381 5.44995 0.949951 5.67381 0.949951 5.94995V8.94995C0.949951 9.22609 1.17381 9.44995 1.44995 9.44995C1.72609 9.44995 1.94995 9.22609 1.94995 8.94995V5.94995ZM13.45 5.44995C13.7261 5.44995 13.95 5.67381 13.95 5.94995V8.94995C13.95 9.22609 13.7261 9.44995 13.45 9.44995C13.1738 9.44995 12.95 9.22609 12.95 8.94995V5.94995C12.95 5.67381 13.1738 5.44995 13.45 5.44995ZM11.45 0.949951C11.1738 0.949951 10.95 1.17381 10.95 1.44995C10.95 1.72609 11.1738 1.94995 11.45 1.94995H12.9499V3.44995C12.9499 3.72609 13.1738 3.94995 13.4499 3.94995C13.7261 3.94995 13.9499 3.72609 13.9499 3.44995V1.44995C13.9499 1.17381 13.7252 0.949951 13.449 0.949951H11.45ZM1.44995 10.95C1.72609 10.95 1.94995 11.1738 1.94995 11.45V12.95H3.44997C3.72611 12.95 3.94997 13.1738 3.94997 13.45C3.94997 13.7261 3.72611 13.95 3.44997 13.95H1.44995C1.17381 13.95 0.949951 13.7261 0.949951 13.45V11.45C0.949951 11.1738 1.17381 10.95 1.44995 10.95ZM13.95 11.45C13.95 11.1738 13.7261 10.95 13.45 10.95C13.1738 10.9499 12.95 11.1738 12.95 11.4499L12.9491 12.95H11.45C11.1738 12.95 10.95 13.1738 10.95 13.45C10.95 13.7261 11.1738 13.95 11.45 13.95H13.4499C13.7261 13.95 13.9499 13.7261 13.9499 13.45L13.95 11.45Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KY=["color"],VY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,KY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.5 3C1.22386 3 1 3.22386 1 3.5C1 3.77614 1.22386 4 1.5 4H13.5C13.7761 4 14 3.77614 14 3.5C14 3.22386 13.7761 3 13.5 3H1.5ZM1 7.5C1 7.22386 1.22386 7 1.5 7H13.5C13.7761 7 14 7.22386 14 7.5C14 7.77614 13.7761 8 13.5 8H1.5C1.22386 8 1 7.77614 1 7.5ZM1 11.5C1 11.2239 1.22386 11 1.5 11H13.5C13.7761 11 14 11.2239 14 11.5C14 11.7761 13.7761 12 13.5 12H1.5C1.22386 12 1 11.7761 1 11.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),GY=["color"],JY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,GY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.35248 4.90532C1.35248 2.94498 2.936 1.35248 4.89346 1.35248C6.25769 1.35248 6.86058 1.92336 7.50002 2.93545C8.13946 1.92336 8.74235 1.35248 10.1066 1.35248C12.064 1.35248 13.6476 2.94498 13.6476 4.90532C13.6476 6.74041 12.6013 8.50508 11.4008 9.96927C10.2636 11.3562 8.92194 12.5508 8.00601 13.3664C7.94645 13.4194 7.88869 13.4709 7.83291 13.5206C7.64324 13.6899 7.3568 13.6899 7.16713 13.5206C7.11135 13.4709 7.05359 13.4194 6.99403 13.3664C6.0781 12.5508 4.73641 11.3562 3.59926 9.96927C2.39872 8.50508 1.35248 6.74041 1.35248 4.90532Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),WY=["color"],YY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,WY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 1H12.5C13.3284 1 14 1.67157 14 2.5V12.5C14 13.3284 13.3284 14 12.5 14H2.5C1.67157 14 1 13.3284 1 12.5V2.5C1 1.67157 1.67157 1 2.5 1ZM2.5 2C2.22386 2 2 2.22386 2 2.5V8.3636L3.6818 6.6818C3.76809 6.59551 3.88572 6.54797 4.00774 6.55007C4.12975 6.55216 4.24568 6.60372 4.32895 6.69293L7.87355 10.4901L10.6818 7.6818C10.8575 7.50607 11.1425 7.50607 11.3182 7.6818L13 9.3636V2.5C13 2.22386 12.7761 2 12.5 2H2.5ZM2 12.5V9.6364L3.98887 7.64753L7.5311 11.4421L8.94113 13H2.5C2.22386 13 2 12.7761 2 12.5ZM12.5 13H10.155L8.48336 11.153L11 8.6364L13 10.6364V12.5C13 12.7761 12.7761 13 12.5 13ZM6.64922 5.5C6.64922 5.03013 7.03013 4.64922 7.5 4.64922C7.96987 4.64922 8.35078 5.03013 8.35078 5.5C8.35078 5.96987 7.96987 6.35078 7.5 6.35078C7.03013 6.35078 6.64922 5.96987 6.64922 5.5ZM7.5 3.74922C6.53307 3.74922 5.74922 4.53307 5.74922 5.5C5.74922 6.46693 6.53307 7.25078 7.5 7.25078C8.46693 7.25078 9.25078 6.46693 9.25078 5.5C9.25078 4.53307 8.46693 3.74922 7.5 3.74922Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),qY=["color"],XY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,qY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 4.63601C5 3.76031 5.24219 3.1054 5.64323 2.67357C6.03934 2.24705 6.64582 1.9783 7.5014 1.9783C8.35745 1.9783 8.96306 2.24652 9.35823 2.67208C9.75838 3.10299 10 3.75708 10 4.63325V5.99999H5V4.63601ZM4 5.99999V4.63601C4 3.58148 4.29339 2.65754 4.91049 1.99307C5.53252 1.32329 6.42675 0.978302 7.5014 0.978302C8.57583 0.978302 9.46952 1.32233 10.091 1.99162C10.7076 2.65557 11 3.57896 11 4.63325V5.99999H12C12.5523 5.99999 13 6.44771 13 6.99999V13C13 13.5523 12.5523 14 12 14H3C2.44772 14 2 13.5523 2 13V6.99999C2 6.44771 2.44772 5.99999 3 5.99999H4ZM3 6.99999H12V13H3V6.99999Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),ZY=["color"],QY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,ZY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.4986 0C6.3257 0 5.36107 0.38943 4.73753 1.19361C4.23745 1.83856 4 2.68242 4 3.63325H5C5 2.84313 5.19691 2.23312 5.5278 1.80636C5.91615 1.30552 6.55152 1 7.4986 1C8.35683 1 8.96336 1.26502 9.35846 1.68623C9.75793 2.11211 10 2.76044 10 3.63601V6H3C2.44772 6 2 6.44772 2 7V13C2 13.5523 2.44772 14 3 14H12C12.5523 14 13 13.5523 13 13V7C13 6.44771 12.5523 6 12 6H11V3.63601C11 2.58135 10.7065 1.66167 10.0878 1.0021C9.46477 0.337871 8.57061 0 7.4986 0ZM3 7H12V13H3V7Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),eq=["color"],tq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,eq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 1.5C5 1.22386 4.77614 1 4.5 1C4.22386 1 4 1.22386 4 1.5L4 7C4 7.01671 4.00082 7.03323 4.00242 7.04952C2.86009 7.28022 2 8.28967 2 9.5C2 10.7103 2.86009 11.7198 4.00242 11.9505C4.00082 11.9668 4 11.9833 4 12V13.5C4 13.7761 4.22386 14 4.5 14C4.77614 14 5 13.7761 5 13.5V12C5 11.9833 4.99918 11.9668 4.99758 11.9505C6.1399 11.7198 7 10.7103 7 9.5C7 8.28967 6.1399 7.28022 4.99758 7.04952C4.99918 7.03323 5 7.01671 5 7L5 1.5ZM11 1.5C11 1.22386 10.7761 1 10.5 1C10.2239 1 10 1.22386 10 1.5V3C10 3.01671 10.0008 3.03323 10.0024 3.04952C8.8601 3.28022 8 4.28967 8 5.5C8 6.71033 8.8601 7.71978 10.0024 7.95048C10.0008 7.96677 10 7.98329 10 8V13.5C10 13.7761 10.2239 14 10.5 14C10.7761 14 11 13.7761 11 13.5V8C11 7.98329 10.9992 7.96677 10.9976 7.95048C12.1399 7.71978 13 6.71033 13 5.5C13 4.28967 12.1399 3.28022 10.9976 3.04952C10.9992 3.03323 11 3.01671 11 3V1.5ZM4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8ZM9 5.5C9 4.67157 9.67157 4 10.5 4C11.3284 4 12 4.67157 12 5.5C12 6.32843 11.3284 7 10.5 7C9.67157 7 9 6.32843 9 5.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),nq=["color"],NE=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,nq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.8536 1.14645C11.6583 0.951184 11.3417 0.951184 11.1465 1.14645L3.71455 8.57836C3.62459 8.66832 3.55263 8.77461 3.50251 8.89155L2.04044 12.303C1.9599 12.491 2.00189 12.709 2.14646 12.8536C2.29103 12.9981 2.50905 13.0401 2.69697 12.9596L6.10847 11.4975C6.2254 11.4474 6.3317 11.3754 6.42166 11.2855L13.8536 3.85355C14.0488 3.65829 14.0488 3.34171 13.8536 3.14645L11.8536 1.14645ZM4.42166 9.28547L11.5 2.20711L12.7929 3.5L5.71455 10.5784L4.21924 11.2192L3.78081 10.7808L4.42166 9.28547Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),rq=["color"],iq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,rq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M12.1464 1.14645C12.3417 0.951184 12.6583 0.951184 12.8535 1.14645L14.8535 3.14645C15.0488 3.34171 15.0488 3.65829 14.8535 3.85355L10.9109 7.79618C10.8349 7.87218 10.7471 7.93543 10.651 7.9835L6.72359 9.94721C6.53109 10.0435 6.29861 10.0057 6.14643 9.85355C5.99425 9.70137 5.95652 9.46889 6.05277 9.27639L8.01648 5.34897C8.06455 5.25283 8.1278 5.16507 8.2038 5.08907L12.1464 1.14645ZM12.5 2.20711L8.91091 5.79618L7.87266 7.87267L8.12731 8.12732L10.2038 7.08907L13.7929 3.5L12.5 2.20711ZM9.99998 2L8.99998 3H4.9C4.47171 3 4.18056 3.00039 3.95552 3.01877C3.73631 3.03668 3.62421 3.06915 3.54601 3.10899C3.35785 3.20487 3.20487 3.35785 3.10899 3.54601C3.06915 3.62421 3.03669 3.73631 3.01878 3.95552C3.00039 4.18056 3 4.47171 3 4.9V11.1C3 11.5283 3.00039 11.8194 3.01878 12.0445C3.03669 12.2637 3.06915 12.3758 3.10899 12.454C3.20487 12.6422 3.35785 12.7951 3.54601 12.891C3.62421 12.9309 3.73631 12.9633 3.95552 12.9812C4.18056 12.9996 4.47171 13 4.9 13H11.1C11.5283 13 11.8194 12.9996 12.0445 12.9812C12.2637 12.9633 12.3758 12.9309 12.454 12.891C12.6422 12.7951 12.7951 12.6422 12.891 12.454C12.9309 12.3758 12.9633 12.2637 12.9812 12.0445C12.9996 11.8194 13 11.5283 13 11.1V6.99998L14 5.99998V11.1V11.1207C14 11.5231 14 11.8553 13.9779 12.1259C13.9549 12.407 13.9057 12.6653 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.6653 13.9057 12.407 13.9549 12.1259 13.9779C11.8553 14 11.5231 14 11.1207 14H11.1H4.9H4.87934C4.47686 14 4.14468 14 3.87409 13.9779C3.59304 13.9549 3.33469 13.9057 3.09202 13.782C2.7157 13.5903 2.40973 13.2843 2.21799 12.908C2.09434 12.6653 2.04506 12.407 2.0221 12.1259C1.99999 11.8553 1.99999 11.5231 2 11.1207V11.1206V11.1V4.9V4.87935V4.87932V4.87931C1.99999 4.47685 1.99999 4.14468 2.0221 3.87409C2.04506 3.59304 2.09434 3.33469 2.21799 3.09202C2.40973 2.71569 2.7157 2.40973 3.09202 2.21799C3.33469 2.09434 3.59304 2.04506 3.87409 2.0221C4.14468 1.99999 4.47685 1.99999 4.87932 2H4.87935H4.9H9.99998Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),oq=["color"],aq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,oq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M13.5 13.95C13.7485 13.95 13.95 13.7485 13.95 13.5C13.95 13.2514 13.7485 13.05 13.5 13.05L1.49995 13.05C1.25142 13.05 1.04995 13.2514 1.04995 13.5C1.04995 13.7485 1.25142 13.95 1.49995 13.95L13.5 13.95ZM11.0681 7.5683C11.2439 7.39257 11.2439 7.10764 11.0681 6.93191C10.8924 6.75617 10.6075 6.75617 10.4317 6.93191L7.94993 9.41371L7.94993 1.49998C7.94993 1.25146 7.74846 1.04998 7.49993 1.04998C7.2514 1.04998 7.04993 1.25146 7.04993 1.49998L7.04993 9.41371L4.56813 6.93191C4.39239 6.75617 4.10746 6.75617 3.93173 6.93191C3.75599 7.10764 3.75599 7.39257 3.93173 7.5683L7.18173 10.8183C7.35746 10.994 7.64239 10.994 7.81812 10.8183L11.0681 7.5683Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),sq=["color"],uq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,sq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.50005 1.05005C1.25152 1.05005 1.05005 1.25152 1.05005 1.50005C1.05005 1.74858 1.25152 1.95005 1.50005 1.95005L13.5 1.95005C13.7486 1.95005 13.95 1.74858 13.95 1.50005C13.95 1.25152 13.7486 1.05005 13.5 1.05005H1.50005ZM3.93188 7.43169C3.75614 7.60743 3.75614 7.89236 3.93188 8.06809C4.10761 8.24383 4.39254 8.24383 4.56827 8.06809L7.05007 5.58629V13.5C7.05007 13.7485 7.25155 13.95 7.50007 13.95C7.7486 13.95 7.95007 13.7485 7.95007 13.5L7.95007 5.58629L10.4319 8.06809C10.6076 8.24383 10.8925 8.24383 11.0683 8.06809C11.244 7.89235 11.244 7.60743 11.0683 7.43169L7.81827 4.18169C7.64254 4.00596 7.35761 4.00596 7.18188 4.18169L3.93188 7.43169Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lq=["color"],cq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,lq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M8 2.75C8 2.47386 7.77614 2.25 7.5 2.25C7.22386 2.25 7 2.47386 7 2.75V7H2.75C2.47386 7 2.25 7.22386 2.25 7.5C2.25 7.77614 2.47386 8 2.75 8H7V12.25C7 12.5261 7.22386 12.75 7.5 12.75C7.77614 12.75 8 12.5261 8 12.25V8H12.25C12.5261 8 12.75 7.77614 12.75 7.5C12.75 7.22386 12.5261 7 12.25 7H8V2.75Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),dq=["color"],hq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,dq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5.07505 4.10001C5.07505 2.91103 6.25727 1.92502 7.50005 1.92502C8.74283 1.92502 9.92505 2.91103 9.92505 4.10001C9.92505 5.19861 9.36782 5.71436 8.61854 6.37884L8.58757 6.4063C7.84481 7.06467 6.92505 7.87995 6.92505 9.5C6.92505 9.81757 7.18248 10.075 7.50005 10.075C7.81761 10.075 8.07505 9.81757 8.07505 9.5C8.07505 8.41517 8.62945 7.90623 9.38156 7.23925L9.40238 7.22079C10.1496 6.55829 11.075 5.73775 11.075 4.10001C11.075 2.12757 9.21869 0.775024 7.50005 0.775024C5.7814 0.775024 3.92505 2.12757 3.92505 4.10001C3.92505 4.41758 4.18249 4.67501 4.50005 4.67501C4.81761 4.67501 5.07505 4.41758 5.07505 4.10001ZM7.50005 13.3575C7.9833 13.3575 8.37505 12.9657 8.37505 12.4825C8.37505 11.9992 7.9833 11.6075 7.50005 11.6075C7.0168 11.6075 6.62505 11.9992 6.62505 12.4825C6.62505 12.9657 7.0168 13.3575 7.50005 13.3575Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fq=["color"],pq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,fq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.59664 2.93628C7.76085 3.06401 8.00012 2.94698 8.00012 2.73895V1.99998C9.98143 2 11.1848 2.3637 11.9105 3.08945C12.6363 3.81522 13 5.0186 13 6.99998C13 7.27613 13.2239 7.49998 13.5 7.49998C13.7761 7.49998 14 7.27613 14 6.99998C14 4.9438 13.6325 3.39719 12.6176 2.38234C11.6028 1.36752 10.0562 0.999999 8.00012 0.999984V0.261266C8.00012 0.0532293 7.76085 -0.0637944 7.59664 0.063928L6.00384 1.30277C5.87516 1.40286 5.87516 1.59735 6.00384 1.69744L7.59664 2.93628ZM9.5 5H2.5C2.22386 5 2 5.22386 2 5.5V12.5C2 12.7761 2.22386 13 2.5 13H9.5C9.77614 13 10 12.7761 10 12.5V5.5C10 5.22386 9.77614 5 9.5 5ZM2.5 4C1.67157 4 1 4.67157 1 5.5V12.5C1 13.3284 1.67157 14 2.5 14H9.5C10.3284 14 11 13.3284 11 12.5V5.5C11 4.67157 10.3284 4 9.5 4H2.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gq=["color"],nI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,gq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 0.999992C14.2237 0.999992 13.9999 1.22385 13.9999 1.49999L13.9999 13.4999C13.9999 13.776 14.2237 13.9999 14.4999 13.9999C14.776 13.9999 14.9999 13.776 14.9999 13.4999L14.9999 1.49999C14.9999 1.22385 14.776 0.999992 14.4999 0.999992ZM0.499996 0.999992C0.223856 0.999992 -9.78509e-09 1.22385 -2.18556e-08 1.49999L4.07279e-07 13.4999C3.95208e-07 13.776 0.223855 13.9999 0.499996 13.9999C0.776136 13.9999 0.999992 13.776 0.999992 13.4999L0.999992 1.49999C0.999992 1.22385 0.776136 0.999992 0.499996 0.999992ZM1.99998 6.99994C1.99998 6.44766 2.44769 5.99995 2.99998 5.99995L5.99995 5.99995C6.55223 5.99995 6.99994 6.44766 6.99994 6.99994L6.99994 7.99993C6.99994 8.55221 6.55223 8.99992 5.99995 8.99992L2.99998 8.99992C2.4477 8.99992 1.99998 8.55221 1.99998 7.99993L1.99998 6.99994ZM8.99993 5.99995C8.44765 5.99995 7.99993 6.44766 7.99993 6.99994L7.99993 7.99993C7.99993 8.55221 8.44765 8.99992 8.99993 8.99992L11.9999 8.99992C12.5522 8.99992 12.9999 8.55221 12.9999 7.99993L12.9999 6.99994C12.9999 6.44766 12.5522 5.99995 11.9999 5.99995L8.99993 5.99995Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),mq=["color"],rI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,mq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.999878 0.5C0.999878 0.223858 1.22374 0 1.49988 0H13.4999C13.776 0 13.9999 0.223858 13.9999 0.5C13.9999 0.776142 13.776 1 13.4999 1H1.49988C1.22374 1 0.999878 0.776142 0.999878 0.5ZM7 2C6.44772 2 6 2.44772 6 3V6C6 6.55228 6.44772 7 7 7H8C8.55228 7 9 6.55228 9 6V3C9 2.44772 8.55228 2 8 2H7ZM7 8C6.44772 8 6 8.44771 6 9V12C6 12.5523 6.44772 13 7 13H8C8.55228 13 9 12.5523 9 12V9C9 8.44772 8.55228 8 8 8H7ZM1.49988 14C1.22374 14 0.999878 14.2239 0.999878 14.5C0.999878 14.7761 1.22374 15 1.49988 15H13.4999C13.776 15 13.9999 14.7761 13.9999 14.5C13.9999 14.2239 13.776 14 13.4999 14H1.49988Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),vq=["color"],yq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,vq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1 1H1.5H13.5H14V1.5V13.5V14H13.5H1.5H1V13.5V1.5V1ZM2 2V13H13V2H2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Eq=["color"],iI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Eq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 0.999992C14.2237 0.999992 13.9999 1.22385 13.9999 1.49999L13.9999 5.99995L0.999992 5.99995L0.999992 1.49999C0.999992 1.22385 0.776136 0.999992 0.499996 0.999992C0.223856 0.999992 -9.78509e-09 1.22385 -2.18556e-08 1.49999L4.07279e-07 13.4999C3.95208e-07 13.776 0.223855 13.9999 0.499996 13.9999C0.776136 13.9999 0.999992 13.776 0.999992 13.4999L0.999992 8.99992L13.9999 8.99992L13.9999 13.4999C13.9999 13.776 14.2237 13.9999 14.4999 13.9999C14.776 13.9999 14.9999 13.776 14.9999 13.4999L14.9999 1.49999C14.9999 1.22385 14.776 0.999992 14.4999 0.999992Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Cq=["color"],oI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Cq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.999878 0.5C0.999878 0.223858 1.22374 0 1.49988 0H13.4999C13.776 0 13.9999 0.223858 13.9999 0.5C13.9999 0.776142 13.776 1 13.4999 1H6H1.49988C1.22374 1 0.999878 0.776142 0.999878 0.5ZM9 14V1L6 1V14H1.49988C1.22374 14 0.999878 14.2239 0.999878 14.5C0.999878 14.7761 1.22374 15 1.49988 15H13.4999C13.776 15 13.9999 14.7761 13.9999 14.5C13.9999 14.2239 13.776 14 13.4999 14H9Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),bq=["color"],wq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,bq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.94993 2.95002L3.94993 4.49998C3.94993 4.74851 3.74845 4.94998 3.49993 4.94998C3.2514 4.94998 3.04993 4.74851 3.04993 4.49998V2.50004C3.04993 2.45246 3.05731 2.40661 3.07099 2.36357C3.12878 2.18175 3.29897 2.05002 3.49993 2.05002H11.4999C11.6553 2.05002 11.7922 2.12872 11.8731 2.24842C11.9216 2.32024 11.9499 2.40682 11.9499 2.50002L11.9499 2.50004V4.49998C11.9499 4.74851 11.7485 4.94998 11.4999 4.94998C11.2514 4.94998 11.0499 4.74851 11.0499 4.49998V2.95002H8.04993V12.05H9.25428C9.50281 12.05 9.70428 12.2515 9.70428 12.5C9.70428 12.7486 9.50281 12.95 9.25428 12.95H5.75428C5.50575 12.95 5.30428 12.7486 5.30428 12.5C5.30428 12.2515 5.50575 12.05 5.75428 12.05H6.94993V2.95002H3.94993Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Sq=["color"],xq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Sq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM4 7.5C4 7.22386 4.22386 7 4.5 7H10.5C10.7761 7 11 7.22386 11 7.5C11 7.77614 10.7761 8 10.5 8H4.5C4.22386 8 4 7.77614 4 7.5ZM3 10.5C3 10.2239 3.22386 10 3.5 10H11.5C11.7761 10 12 10.2239 12 10.5C12 10.7761 11.7761 11 11.5 11H3.5C3.22386 11 3 10.7761 3 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Aq=["color"],kq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Aq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 4C2.22386 4 2 4.22386 2 4.5C2 4.77614 2.22386 5 2.5 5H12.5C12.7761 5 13 4.77614 13 4.5C13 4.22386 12.7761 4 12.5 4H2.5ZM2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5ZM2 10.5C2 10.2239 2.22386 10 2.5 10H12.5C12.7761 10 13 10.2239 13 10.5C13 10.7761 12.7761 11 12.5 11H2.5C2.22386 11 2 10.7761 2 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Iq=["color"],Dq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Iq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM2 7.5C2 7.22386 2.22386 7 2.5 7H7.5C7.77614 7 8 7.22386 8 7.5C8 7.77614 7.77614 8 7.5 8H2.5C2.22386 8 2 7.77614 2 7.5ZM2 10.5C2 10.2239 2.22386 10 2.5 10H10.5C10.7761 10 11 10.2239 11 10.5C11 10.7761 10.7761 11 10.5 11H2.5C2.22386 11 2 10.7761 2 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Tq=["color"],Pq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Tq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM7 7.5C7 7.22386 7.22386 7 7.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H7.5C7.22386 8 7 7.77614 7 7.5ZM4 10.5C4 10.2239 4.22386 10 4.5 10H12.5C12.7761 10 13 10.2239 13 10.5C13 10.7761 12.7761 11 12.5 11H4.5C4.22386 11 4 10.7761 4 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Bq=["color"],Mq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Bq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.23336 4.69629C7.23336 2.96884 8.63335 1.56857 10.36 1.56857C11.3736 1.56857 12.183 2.04804 12.7254 2.74385C13.3079 2.62467 13.8557 2.40913 14.3513 2.11508C14.1559 2.72598 13.7424 3.2396 13.2033 3.56463C13.2038 3.56568 13.2042 3.56674 13.2047 3.56779C13.7334 3.50361 14.2364 3.36302 14.7048 3.15546L14.7037 3.15715C14.3667 3.66183 13.9431 4.10736 13.4561 4.47034C13.4823 4.64672 13.4956 4.82427 13.4956 5.00079C13.4956 8.6871 10.6873 12.9746 5.52122 12.9746C3.93906 12.9746 2.46544 12.511 1.22505 11.7152C0.992632 11.5661 0.925108 11.2568 1.07423 11.0244C1.0874 11.0038 1.10183 10.9846 1.11734 10.9666C1.20582 10.8202 1.37438 10.7309 1.5554 10.7522C2.47066 10.8601 3.38568 10.7485 4.19219 10.3962C3.39226 10.0434 2.77129 9.35975 2.50204 8.51974C2.45359 8.3686 2.48835 8.20311 2.59351 8.08422C2.59716 8.0801 2.60087 8.07606 2.60464 8.0721C1.96391 7.50819 1.55973 6.68208 1.55973 5.76143V5.72759C1.55973 5.56814 1.64411 5.42059 1.78155 5.33974C1.82671 5.31317 1.87537 5.29511 1.92532 5.28558C1.70549 4.86154 1.58116 4.37984 1.58116 3.86958C1.58116 3.40165 1.58384 2.81192 1.91332 2.28081C1.98718 2.16175 2.10758 2.08915 2.2364 2.07195C2.42588 2.01237 2.64087 2.06969 2.77406 2.23302C3.86536 3.57126 5.44066 4.49583 7.23366 4.73961L7.23336 4.69629ZM5.52122 11.9746C4.73387 11.9746 3.97781 11.8435 3.27248 11.6023C4.13012 11.4538 4.95307 11.1159 5.66218 10.5602C5.81211 10.4427 5.87182 10.2435 5.81126 10.0629C5.7507 9.88234 5.583 9.75943 5.39255 9.75607C4.68968 9.74366 4.06712 9.39716 3.67793 8.86845C3.86828 8.85306 4.05428 8.82039 4.23445 8.77167C4.43603 8.71716 4.57363 8.53114 4.56674 8.32243C4.55985 8.11372 4.41029 7.93718 4.20555 7.89607C3.42694 7.73977 2.79883 7.16764 2.56169 6.42174C2.76255 6.47025 2.97102 6.4991 3.18482 6.5061C3.38563 6.51267 3.56646 6.38533 3.62795 6.19405C3.68943 6.00277 3.61666 5.79391 3.44963 5.68224C2.86523 5.29155 2.48116 4.62464 2.48116 3.86958C2.48116 3.70213 2.48352 3.55268 2.49355 3.41719C3.85115 4.79913 5.70873 5.68931 7.77588 5.79338C7.93225 5.80126 8.08328 5.73543 8.18395 5.61553C8.28463 5.49562 8.32332 5.33548 8.28851 5.18284C8.25255 5.02517 8.23336 4.86284 8.23336 4.69629C8.23336 3.52085 9.18591 2.56857 10.36 2.56857C11.5943 2.56857 12.4956 3.71208 12.4956 5.00079C12.4956 8.25709 10.0202 11.9746 5.52122 11.9746Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),$q=["color"],Rq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,$q);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.49998 1L6.92321 2.00307L1.17498 12L0.599976 13H1.7535H13.2464H14.4L13.825 12L8.07674 2.00307L7.49998 1ZM7.49998 3.00613L2.3285 12H12.6714L7.49998 3.00613Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Ct="colors",er="sizes",xe="space",aI={gap:xe,gridGap:xe,columnGap:xe,gridColumnGap:xe,rowGap:xe,gridRowGap:xe,inset:xe,insetBlock:xe,insetBlockEnd:xe,insetBlockStart:xe,insetInline:xe,insetInlineEnd:xe,insetInlineStart:xe,margin:xe,marginTop:xe,marginRight:xe,marginBottom:xe,marginLeft:xe,marginBlock:xe,marginBlockEnd:xe,marginBlockStart:xe,marginInline:xe,marginInlineEnd:xe,marginInlineStart:xe,padding:xe,paddingTop:xe,paddingRight:xe,paddingBottom:xe,paddingLeft:xe,paddingBlock:xe,paddingBlockEnd:xe,paddingBlockStart:xe,paddingInline:xe,paddingInlineEnd:xe,paddingInlineStart:xe,top:xe,right:xe,bottom:xe,left:xe,scrollMargin:xe,scrollMarginTop:xe,scrollMarginRight:xe,scrollMarginBottom:xe,scrollMarginLeft:xe,scrollMarginX:xe,scrollMarginY:xe,scrollMarginBlock:xe,scrollMarginBlockEnd:xe,scrollMarginBlockStart:xe,scrollMarginInline:xe,scrollMarginInlineEnd:xe,scrollMarginInlineStart:xe,scrollPadding:xe,scrollPaddingTop:xe,scrollPaddingRight:xe,scrollPaddingBottom:xe,scrollPaddingLeft:xe,scrollPaddingX:xe,scrollPaddingY:xe,scrollPaddingBlock:xe,scrollPaddingBlockEnd:xe,scrollPaddingBlockStart:xe,scrollPaddingInline:xe,scrollPaddingInlineEnd:xe,scrollPaddingInlineStart:xe,fontSize:"fontSizes",background:Ct,backgroundColor:Ct,backgroundImage:Ct,borderImage:Ct,border:Ct,borderBlock:Ct,borderBlockEnd:Ct,borderBlockStart:Ct,borderBottom:Ct,borderBottomColor:Ct,borderColor:Ct,borderInline:Ct,borderInlineEnd:Ct,borderInlineStart:Ct,borderLeft:Ct,borderLeftColor:Ct,borderRight:Ct,borderRightColor:Ct,borderTop:Ct,borderTopColor:Ct,caretColor:Ct,color:Ct,columnRuleColor:Ct,fill:Ct,outline:Ct,outlineColor:Ct,stroke:Ct,textDecorationColor:Ct,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:er,minBlockSize:er,maxBlockSize:er,inlineSize:er,minInlineSize:er,maxInlineSize:er,width:er,minWidth:er,maxWidth:er,height:er,minHeight:er,maxHeight:er,flexBasis:er,gridTemplateColumns:er,gridTemplateRows:er,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},Fq=(e,t)=>typeof t=="function"?{"()":Function.prototype.toString.call(t)}:t,wd=()=>{const e=Object.create(null);return(t,n,...r)=>{const i=(o=>JSON.stringify(o,Fq))(t);return i in e?e[i]:e[i]=n(t,...r)}},fl=Symbol.for("sxs.internal"),zE=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),U6=e=>{for(const t in e)return!0;return!1},{hasOwnProperty:Lq}=Object.prototype,Dy=e=>e.includes("-")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),Oq=/\s+(?![^()]*\))/,sc=e=>t=>e(...typeof t=="string"?String(t).split(Oq):[t]),K6={appearance:e=>({WebkitAppearance:e,appearance:e}),backfaceVisibility:e=>({WebkitBackfaceVisibility:e,backfaceVisibility:e}),backdropFilter:e=>({WebkitBackdropFilter:e,backdropFilter:e}),backgroundClip:e=>({WebkitBackgroundClip:e,backgroundClip:e}),boxDecorationBreak:e=>({WebkitBoxDecorationBreak:e,boxDecorationBreak:e}),clipPath:e=>({WebkitClipPath:e,clipPath:e}),content:e=>({content:e.includes('"')||e.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(e)?e:`"${e}"`}),hyphens:e=>({WebkitHyphens:e,hyphens:e}),maskImage:e=>({WebkitMaskImage:e,maskImage:e}),maskSize:e=>({WebkitMaskSize:e,maskSize:e}),tabSize:e=>({MozTabSize:e,tabSize:e}),textSizeAdjust:e=>({WebkitTextSizeAdjust:e,textSizeAdjust:e}),userSelect:e=>({WebkitUserSelect:e,userSelect:e}),marginBlock:sc((e,t)=>({marginBlockStart:e,marginBlockEnd:t||e})),marginInline:sc((e,t)=>({marginInlineStart:e,marginInlineEnd:t||e})),maxSize:sc((e,t)=>({maxBlockSize:e,maxInlineSize:t||e})),minSize:sc((e,t)=>({minBlockSize:e,minInlineSize:t||e})),paddingBlock:sc((e,t)=>({paddingBlockStart:e,paddingBlockEnd:t||e})),paddingInline:sc((e,t)=>({paddingInlineStart:e,paddingInlineEnd:t||e}))},Mv=/([\d.]+)([^]*)/,_q=(e,t)=>e.length?e.reduce((n,r)=>(n.push(...t.map(i=>i.includes("&")?i.replace(/&/g,/[ +>|~]/.test(r)&&/&.*&/.test(i)?`:is(${r})`:r):r+" "+i)),n),[]):t,Nq=(e,t)=>e in zq&&typeof t=="string"?t.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,(n,r,i,o)=>r+(i==="stretch"?`-moz-available${o};${Dy(e)}:${r}-webkit-fill-available`:`-moz-fit-content${o};${Dy(e)}:${r}fit-content`)+o):String(t),zq={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},xs=e=>e?e+"-":"",sI=(e,t,n)=>e.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,(r,i,o,a,s)=>a=="$"==!!o?r:(i||a=="--"?"calc(":"")+"var(--"+(a==="$"?xs(t)+(s.includes("$")?"":xs(n))+s.replace(/\$/g,"-"):s)+")"+(i||a=="--"?"*"+(i||"")+(o||"1")+")":"")),Hq=/\s*,\s*(?![^()]*\))/,jq=Object.prototype.toString,Ic=(e,t,n,r,i)=>{let o,a,s;const u=(d,h,p)=>{let g,m;const v=E=>{for(g in E){const b=g.charCodeAt(0)===64,A=b&&Array.isArray(E[g])?E[g]:[E[g]];for(m of A){const T=/[A-Z]/.test(C=g)?C:C.replace(/-[^]/g,D=>D[1].toUpperCase()),B=typeof m=="object"&&m&&m.toString===jq&&(!r.utils[T]||!h.length);if(T in r.utils&&!B){const D=r.utils[T];if(D!==a){a=D,v(D(m)),a=null;continue}}else if(T in K6){const D=K6[T];if(D!==s){s=D,v(D(m)),s=null;continue}}if(b&&(w=g.slice(1)in r.media?"@media "+r.media[g.slice(1)]:g,g=w.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,(D,I,M,O,z,K)=>{const X=Mv.test(I),Z=.0625*(X?-1:1),[pe,me]=X?[O,I]:[I,O];return"("+(M[0]==="="?"":M[0]===">"===X?"max-":"min-")+pe+":"+(M[0]!=="="&&M.length===1?me.replace(Mv,(Ce,W,U)=>Number(W)+Z*(M===">"?1:-1)+U):me)+(z?") and ("+(z[0]===">"?"min-":"max-")+pe+":"+(z.length===1?K.replace(Mv,(Ce,W,U)=>Number(W)+Z*(z===">"?-1:1)+U):K):"")+")"})),B){const D=b?p.concat(g):[...p],I=b?[...h]:_q(h,g.split(Hq));o!==void 0&&i(V6(...o)),o=void 0,u(m,I,D)}else o===void 0&&(o=[[],h,p]),g=b||g.charCodeAt(0)!==36?g:`--${xs(r.prefix)}${g.slice(1).replace(/\$/g,"-")}`,m=B?m:typeof m=="number"?m&&T in Uq?String(m)+"px":String(m):sI(Nq(T,m??""),r.prefix,r.themeMap[T]),o[0].push(`${b?`${g} `:`${Dy(g)}:`}${m}`)}}var w,C};v(d),o!==void 0&&i(V6(...o)),o=void 0};u(e,t,n)},V6=(e,t,n)=>`${n.map(r=>`${r}{`).join("")}${t.length?`${t.join(",")}{`:""}${e.join(";")}${t.length?"}":""}${Array(n.length?n.length+1:0).join("}")}`,Uq={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},G6=e=>String.fromCharCode(e+(e>25?39:97)),pl=e=>(t=>{let n,r="";for(n=Math.abs(t);n>52;n=n/52|0)r=G6(n%52)+r;return G6(n%52)+r})(((t,n)=>{let r=n.length;for(;r;)t=33*t^n.charCodeAt(--r);return t})(5381,JSON.stringify(e))>>>0),h0=["themed","global","styled","onevar","resonevar","allvar","inline"],Kq=e=>{if(e.href&&!e.href.startsWith(location.origin))return!1;try{return!!e.cssRules}catch{return!1}},Vq=e=>{let t;const n=()=>{const{cssRules:i}=t.sheet;return[].map.call(i,(o,a)=>{const{cssText:s}=o;let u="";if(s.startsWith("--sxs"))return"";if(i[a-1]&&(u=i[a-1].cssText).startsWith("--sxs")){if(!o.cssRules.length)return"";for(const d in t.rules)if(t.rules[d].group===o)return`--sxs{--sxs:${[...t.rules[d].cache].join(" ")}}${s}`;return o.cssRules.length?`${u}${s}`:""}return s}).join("")},r=()=>{if(t){const{rules:s,sheet:u}=t;if(!u.deleteRule){for(;Object(Object(u.cssRules)[0]).type===3;)u.cssRules.splice(0,1);u.cssRules=[]}for(const d in s)delete s[d]}const i=Object(e).styleSheets||[];for(const s of i)if(Kq(s)){for(let u=0,d=s.cssRules;d[u];++u){const h=Object(d[u]);if(h.type!==1)continue;const p=Object(d[u+1]);if(p.type!==4)continue;++u;const{cssText:g}=h;if(!g.startsWith("--sxs"))continue;const m=g.slice(14,-3).trim().split(/\s+/),v=h0[m[0]];v&&(t||(t={sheet:s,reset:r,rules:{},toString:n}),t.rules[v]={group:p,index:u,cache:new Set(m)})}if(t)break}if(!t){const s=(u,d)=>({type:d,cssRules:[],insertRule(h,p){this.cssRules.splice(p,0,s(h,{import:3,undefined:1}[(h.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return u==="@media{}"?`@media{${[].map.call(this.cssRules,h=>h.cssText).join("")}}`:u}});t={sheet:e?(e.head||e).appendChild(document.createElement("style")).sheet:s("","text/css"),rules:{},reset:r,toString:n}}const{sheet:o,rules:a}=t;for(let s=h0.length-1;s>=0;--s){const u=h0[s];if(!a[u]){const d=h0[s+1],h=a[d]?a[d].index:o.cssRules.length;o.insertRule("@media{}",h),o.insertRule(`--sxs{--sxs:${s}}`,h),a[u]={group:o.cssRules[h+1],index:h,cache:new Set([s])}}Gq(a[u])}};return r(),t},Gq=e=>{const t=e.group;let n=t.cssRules.length;e.apply=r=>{try{t.insertRule(r,n),++n}catch{}}},i0=Symbol(),Jq=wd(),J6=(e,t)=>Jq(e,()=>(...n)=>{let r={type:null,composers:new Set};for(const i of n)if(i!=null)if(i[fl]){r.type==null&&(r.type=i[fl].type);for(const o of i[fl].composers)r.composers.add(o)}else i.constructor!==Object||i.$$typeof?r.type==null&&(r.type=i):r.composers.add(Wq(i,e));return r.type==null&&(r.type="span"),r.composers.size||r.composers.add(["PJLV",{},[],[],{},[]]),Yq(e,r,t)}),Wq=({variants:e,compoundVariants:t,defaultVariants:n,...r},i)=>{const o=`${xs(i.prefix)}c-${pl(r)}`,a=[],s=[],u=Object.create(null),d=[];for(const g in n)u[g]=String(n[g]);if(typeof e=="object"&&e)for(const g in e){h=u,p=g,Lq.call(h,p)||(u[g]="undefined");const m=e[g];for(const v in m){const E={[g]:String(v)};String(v)==="undefined"&&d.push(g);const w=m[v],C=[E,w,!U6(w)];a.push(C)}}var h,p;if(typeof t=="object"&&t)for(const g of t){let{css:m,...v}=g;m=typeof m=="object"&&m||{};for(const w in v)v[w]=String(v[w]);const E=[v,m,!U6(m)];s.push(E)}return[o,r,a,s,u,d]},Yq=(e,t,n)=>{const[r,i,o,a]=qq(t.composers),s=typeof t.type=="function"||t.type.$$typeof?(p=>{function g(){for(let m=0;mg.rules[m]={apply:v=>g[i0].push([m,v])}),g})(n):null,u=(s||n).rules,d=`.${r}${i.length>1?`:where(.${i.slice(1).join(".")})`:""}`,h=p=>{p=typeof p=="object"&&p||Xq;const{css:g,...m}=p,v={};for(const C in o)if(delete m[C],C in p){let b=p[C];typeof b=="object"&&b?v[C]={"@initial":o[C],...b}:(b=String(b),v[C]=b!=="undefined"||a.has(C)?b:o[C])}else v[C]=o[C];const E=new Set([...i]);for(const[C,b,A,T]of t.composers){n.rules.styled.cache.has(C)||(n.rules.styled.cache.add(C),Ic(b,[`.${C}`],[],e,I=>{u.styled.apply(I)}));const B=W6(A,v,e.media),D=W6(T,v,e.media,!0);for(const I of B)if(I!==void 0)for(const[M,O,z]of I){const K=`${C}-${pl(O)}-${M}`;E.add(K);const X=(z?n.rules.resonevar:n.rules.onevar).cache,Z=z?u.resonevar:u.onevar;X.has(K)||(X.add(K),Ic(O,[`.${K}`],[],e,pe=>{Z.apply(pe)}))}for(const I of D)if(I!==void 0)for(const[M,O]of I){const z=`${C}-${pl(O)}-${M}`;E.add(z),n.rules.allvar.cache.has(z)||(n.rules.allvar.cache.add(z),Ic(O,[`.${z}`],[],e,K=>{u.allvar.apply(K)}))}}if(typeof g=="object"&&g){const C=`${r}-i${pl(g)}-css`;E.add(C),n.rules.inline.cache.has(C)||(n.rules.inline.cache.add(C),Ic(g,[`.${C}`],[],e,b=>{u.inline.apply(b)}))}for(const C of String(p.className||"").trim().split(/\s+/))C&&E.add(C);const w=m.className=[...E].join(" ");return{type:t.type,className:w,selector:d,props:m,toString:()=>w,deferredInjector:s}};return zE(h,{className:r,selector:d,[fl]:t,toString:()=>(n.rules.styled.cache.has(r)||h(),r)})},qq=e=>{let t="";const n=[],r={},i=[];for(const[o,,,,a,s]of e){t===""&&(t=o),n.push(o),i.push(...s);for(const u in a){const d=a[u];(r[u]===void 0||d!=="undefined"||s.includes(d))&&(r[u]=d)}}return[t,n,r,new Set(i)]},W6=(e,t,n,r)=>{const i=[];e:for(let[o,a,s]of e){if(s)continue;let u,d=0,h=!1;for(u in o){const p=o[u];let g=t[u];if(g!==p){if(typeof g!="object"||!g)continue e;{let m,v,E=0;for(const w in g){if(p===String(g[w])){if(w!=="@initial"){const C=w.slice(1);(v=v||[]).push(C in n?n[C]:w.replace(/^@media ?/,"")),h=!0}d+=E,m=!0}++E}if(v&&v.length&&(a={["@media "+v.join(", ")]:a}),!m)continue e}}}(i[d]=i[d]||[]).push([r?"cv":`${u}-${o[u]}`,a,h])}return i},Xq={},Zq=wd(),Qq=(e,t)=>Zq(e,()=>(...n)=>{const r=()=>{for(let i of n){i=typeof i=="object"&&i||{};let o=pl(i);if(!t.rules.global.cache.has(o)){if(t.rules.global.cache.add(o),"@import"in i){let a=[].indexOf.call(t.sheet.cssRules,t.rules.themed.group)-1;for(let s of[].concat(i["@import"]))s=s.includes('"')||s.includes("'")?s:`"${s}"`,t.sheet.insertRule(`@import ${s};`,a++);delete i["@import"]}Ic(i,[],[],e,a=>{t.rules.global.apply(a)})}}return""};return zE(r,{toString:r})}),eX=wd(),tX=(e,t)=>eX(e,()=>n=>{const r=`${xs(e.prefix)}k-${pl(n)}`,i=()=>{if(!t.rules.global.cache.has(r)){t.rules.global.cache.add(r);const o=[];Ic(n,[],[],e,s=>o.push(s));const a=`@keyframes ${r}{${o.join("")}}`;t.rules.global.apply(a)}return r};return zE(i,{get name(){return i()},toString:i})}),nX=class{constructor(t,n,r,i){this.token=t==null?"":String(t),this.value=n==null?"":String(n),this.scale=r==null?"":String(r),this.prefix=i==null?"":String(i)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+xs(this.prefix)+xs(this.scale)+this.token}toString(){return this.computedValue}},rX=wd(),iX=(e,t)=>rX(e,()=>(n,r)=>{r=typeof n=="object"&&n||Object(r);const i=`.${n=(n=typeof n=="string"?n:"")||`${xs(e.prefix)}t-${pl(r)}`}`,o={},a=[];for(const u in r){o[u]={};for(const d in r[u]){const h=`--${xs(e.prefix)}${u}-${d}`,p=sI(String(r[u][d]),e.prefix,u);o[u][d]=new nX(d,p,u,e.prefix),a.push(`${h}:${p}`)}}const s=()=>{if(a.length&&!t.rules.themed.cache.has(n)){t.rules.themed.cache.add(n);const u=`${r===e.theme?":root,":""}.${n}{${a.join(";")}}`;t.rules.themed.apply(u)}return n};return{...o,get className(){return s()},selector:i,toString:s}}),oX=wd(),Y6,aX=wd(),uI=e=>{const t=(n=>{let r=!1;const i=oX(n,o=>{r=!0;const a="prefix"in(o=typeof o=="object"&&o||{})?String(o.prefix):"",s=typeof o.media=="object"&&o.media||{},u=typeof o.root=="object"?o.root||null:globalThis.document||null,d=typeof o.theme=="object"&&o.theme||{},h={prefix:a,media:s,theme:d,themeMap:typeof o.themeMap=="object"&&o.themeMap||{...aI},utils:typeof o.utils=="object"&&o.utils||{}},p=Vq(u),g={css:J6(h,p),globalCss:Qq(h,p),keyframes:tX(h,p),createTheme:iX(h,p),reset(){p.reset(),g.theme.toString()},theme:{},sheet:p,config:h,prefix:a,getCssText:p.toString,toString:p.toString};return String(g.theme=g.createTheme(d)),g});return r||i.reset(),i})(e);return t.styled=(({config:n,sheet:r})=>aX(n,()=>{const i=J6(n,r);return(...o)=>{const a=i(...o),s=a[fl].type,u=Kt.forwardRef((d,h)=>{const p=d&&d.as||s,{props:g,deferredInjector:m}=a(d);return delete g.as,g.ref=h,m?Kt.createElement(Kt.Fragment,null,Kt.createElement(p,g),Kt.createElement(m,null)):Kt.createElement(p,g)});return u.className=a.className,u.displayName=`Styled.${s.displayName||s.name||s}`,u.selector=a.selector,u.toString=()=>a.selector,u[fl]=a[fl],u}}))(t),t},sX=()=>Y6||(Y6=uI()),qm=(...e)=>sX().styled(...e);const lI="DropdownMenu",[uX,nGe]=Ed(lI,[Wm]),xr=Wm(),[lX,cI]=uX(lI),cX=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:a,modal:s=!0}=e,u=xr(t),d=l.useRef(null),[h=!1,p]=Vm({prop:i,defaultProp:o,onChange:a});return l.createElement(lX,{scope:t,triggerId:th(),triggerRef:d,contentId:th(),open:h,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(g=>!g),[p]),modal:s},l.createElement(Ok,De({},u,{open:h,onOpenChange:p,dir:r,modal:s}),n))},dX="DropdownMenuTrigger",hX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=cI(dX,n),a=xr(n);return l.createElement(_k,De({asChild:!0},a),l.createElement(sr.button,De({type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open?!0:void 0,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},i,{ref:Hm(t,o.triggerRef),onPointerDown:Xe(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(o.onOpenToggle(),o.open||s.preventDefault())}),onKeyDown:Xe(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&o.onOpenToggle(),s.key==="ArrowDown"&&o.onOpenChange(!0),[" ","ArrowDown"].includes(s.key)&&s.preventDefault())})})))}),fX=e=>{const{__scopeDropdownMenu:t,...n}=e,r=xr(t);return l.createElement(Nk,De({},r,n))},pX="DropdownMenuContent",gX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=cI(pX,n),o=xr(n),a=l.useRef(!1);return l.createElement(zk,De({id:i.contentId,"aria-labelledby":i.triggerId},o,r,{ref:t,onCloseAutoFocus:Xe(e.onCloseAutoFocus,s=>{var u;a.current||(u=i.triggerRef.current)===null||u===void 0||u.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Xe(e.onInteractOutside,s=>{const u=s.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!i.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),mX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Hk,De({},i,r,{ref:t}))}),vX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(_W,De({},i,r,{ref:t}))}),dI=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(NW,De({},i,r,{ref:t}))}),yX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(zW,De({},i,r,{ref:t}))}),EX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(HW,De({},i,r,{ref:t}))}),CX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(jW,De({},i,r,{ref:t}))}),bX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(jk,De({},i,r,{ref:t}))}),wX=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,a=xr(t),[s=!1,u]=Vm({prop:r,defaultProp:o,onChange:i});return l.createElement(Uk,De({},a,{open:s,onOpenChange:u}),n)},SX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Kk,De({},i,r,{ref:t}))}),xX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Vk,De({},i,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),Lu=cX,Fl=hX,AX=fX,hI=gX,Xm=mX,kX=vX,IX=dI,fI=yX,pI=EX,DX=CX,TX=bX,PX=wX,BX=SX,MX=xX;function hn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function $X(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function gI(...e){return t=>e.forEach(n=>$X(n,t))}function dr(...e){return l.useCallback(gI(...e),e)}function RX(e,t){const n=l.createContext(t);function r(o){const{children:a,...s}=o,u=l.useMemo(()=>s,Object.values(s));return ce.jsx(n.Provider,{value:u,children:a})}function i(o){const a=l.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",[r,i]}function $h(e,t=[]){let n=[];function r(o,a){const s=l.createContext(a),u=n.length;n=[...n,a];function d(p){const{scope:g,children:m,...v}=p,E=(g==null?void 0:g[e][u])||s,w=l.useMemo(()=>v,Object.values(v));return ce.jsx(E.Provider,{value:w,children:m})}function h(p,g){const m=(g==null?void 0:g[e][u])||s,v=l.useContext(m);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return d.displayName=o+"Provider",[d,h]}const i=()=>{const o=n.map(a=>l.createContext(a));return function(s){const u=(s==null?void 0:s[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,FX(i,...t)]}function FX(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const a=r.reduce((s,{useScope:u,scopeName:d})=>{const p=u(o)[`__scope${d}`];return{...s,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Zm=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(LX);if(o){const a=o.props.children,s=i.map(u=>u===o?l.Children.count(a)>1?l.Children.only(null):l.isValidElement(a)?a.props.children:null:u);return ce.jsx(Ty,{...r,ref:t,children:l.isValidElement(a)?l.cloneElement(a,void 0,s):null})}return ce.jsx(Ty,{...r,ref:t,children:n})});Zm.displayName="Slot";var Ty=l.forwardRef((e,t)=>{const{children:n,...r}=e;if(l.isValidElement(n)){const i=_X(n);return l.cloneElement(n,{...OX(r,n.props),ref:t?gI(t,i):i})}return l.Children.count(n)>1?l.Children.only(null):null});Ty.displayName="SlotClone";var HE=({children:e})=>ce.jsx(ce.Fragment,{children:e});function LX(e){return l.isValidElement(e)&&e.type===HE}function OX(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...s)=>{o(...s),i(...s)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function _X(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var NX=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Yn=NX.reduce((e,t)=>{const n=l.forwardRef((r,i)=>{const{asChild:o,...a}=r,s=o?Zm:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ce.jsx(s,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function zX(e,t){e&&$u.flushSync(()=>e.dispatchEvent(t))}function wu(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function HX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e);l.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var jX="DismissableLayer",Py="dismissableLayer.update",UX="dismissableLayer.pointerDownOutside",KX="dismissableLayer.focusOutside",q6,mI=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Qm=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:a,onDismiss:s,...u}=e,d=l.useContext(mI),[h,p]=l.useState(null),g=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=l.useState({}),v=dr(t,I=>p(I)),E=Array.from(d.layers),[w]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=E.indexOf(w),b=h?E.indexOf(h):-1,A=d.layersWithOutsidePointerEventsDisabled.size>0,T=b>=C,B=JX(I=>{const M=I.target,O=[...d.branches].some(z=>z.contains(M));!T||O||(i==null||i(I),a==null||a(I),I.defaultPrevented||s==null||s())},g),D=WX(I=>{const M=I.target;[...d.branches].some(z=>z.contains(M))||(o==null||o(I),a==null||a(I),I.defaultPrevented||s==null||s())},g);return HX(I=>{b===d.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},g),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(q6=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),X6(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=q6)}},[h,g,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),X6())},[h,d]),l.useEffect(()=>{const I=()=>m({});return document.addEventListener(Py,I),()=>document.removeEventListener(Py,I)},[]),ce.jsx(Yn.div,{...u,ref:v,style:{pointerEvents:A?T?"auto":"none":void 0,...e.style},onFocusCapture:hn(e.onFocusCapture,D.onFocusCapture),onBlurCapture:hn(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:hn(e.onPointerDownCapture,B.onPointerDownCapture)})});Qm.displayName=jX;var VX="DismissableLayerBranch",GX=l.forwardRef((e,t)=>{const n=l.useContext(mI),r=l.useRef(null),i=dr(t,r);return l.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),ce.jsx(Yn.div,{...e,ref:i})});GX.displayName=VX;function JX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e),r=l.useRef(!1),i=l.useRef(()=>{});return l.useEffect(()=>{const o=s=>{if(s.target&&!r.current){let u=function(){vI(UX,n,d,{discrete:!0})};const d={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=u,t.addEventListener("click",i.current,{once:!0})):u()}else t.removeEventListener("click",i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function WX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e),r=l.useRef(!1);return l.useEffect(()=>{const i=o=>{o.target&&!r.current&&vI(KX,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function X6(){const e=new CustomEvent(Py);document.dispatchEvent(e)}function vI(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?zX(i,o):i.dispatchEvent(o)}var Sl=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},YX=Wx.useId||(()=>{}),qX=0;function k0(e){const[t,n]=l.useState(YX());return Sl(()=>{n(r=>r??String(qX++))},[e]),t?`radix-${t}`:""}const XX=["top","right","bottom","left"],Do=Math.min,Mr=Math.max,Bg=Math.round,lp=Math.floor,Su=e=>({x:e,y:e}),ZX={left:"right",right:"left",bottom:"top",top:"bottom"},QX={start:"end",end:"start"};function By(e,t,n){return Mr(e,Do(t,n))}function As(e,t){return typeof e=="function"?e(t):e}function ks(e){return e.split("-")[0]}function Sd(e){return e.split("-")[1]}function jE(e){return e==="x"?"y":"x"}function UE(e){return e==="y"?"height":"width"}function xu(e){return["top","bottom"].includes(ks(e))?"y":"x"}function KE(e){return jE(xu(e))}function eZ(e,t,n){n===void 0&&(n=!1);const r=Sd(e),i=KE(e),o=UE(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Mg(a)),[a,Mg(a)]}function tZ(e){const t=Mg(e);return[My(e),t,My(t)]}function My(e){return e.replace(/start|end/g,t=>QX[t])}function nZ(e,t,n){const r=["left","right"],i=["right","left"],o=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?o:a;default:return[]}}function rZ(e,t,n,r){const i=Sd(e);let o=nZ(ks(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(My)))),o}function Mg(e){return e.replace(/left|right|bottom|top/g,t=>ZX[t])}function iZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function yI(e){return typeof e!="number"?iZ(e):{top:e,right:e,bottom:e,left:e}}function $g(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Z6(e,t,n){let{reference:r,floating:i}=e;const o=xu(t),a=KE(t),s=UE(a),u=ks(t),d=o==="y",h=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,g=r[s]/2-i[s]/2;let m;switch(u){case"top":m={x:h,y:r.y-i.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:p};break;case"left":m={x:r.x-i.width,y:p};break;default:m={x:r.x,y:r.y}}switch(Sd(t)){case"start":m[a]-=g*(n&&d?-1:1);break;case"end":m[a]+=g*(n&&d?-1:1);break}return m}const oZ=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,s=o.filter(Boolean),u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:p}=Z6(d,r,u),g=r,m={},v=0;for(let E=0;E({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:s,middlewareData:u}=t,{element:d,padding:h=0}=As(e,t)||{};if(d==null)return{};const p=yI(h),g={x:n,y:r},m=KE(i),v=UE(m),E=await a.getDimensions(d),w=m==="y",C=w?"top":"left",b=w?"bottom":"right",A=w?"clientHeight":"clientWidth",T=o.reference[v]+o.reference[m]-g[m]-o.floating[v],B=g[m]-o.reference[m],D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let I=D?D[A]:0;(!I||!await(a.isElement==null?void 0:a.isElement(D)))&&(I=s.floating[A]||o.floating[v]);const M=T/2-B/2,O=I/2-E[v]/2-1,z=Do(p[C],O),K=Do(p[b],O),X=z,Z=I-E[v]-K,pe=I/2-E[v]/2+M,me=By(X,pe,Z),Ce=!u.arrow&&Sd(i)!=null&&pe!==me&&o.reference[v]/2-(pepe<=0)){var K,X;const pe=(((K=o.flip)==null?void 0:K.index)||0)+1,me=I[pe];if(me)return{data:{index:pe,overflows:z},reset:{placement:me}};let Ce=(X=z.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:X.placement;if(!Ce)switch(m){case"bestFit":{var Z;const W=(Z=z.filter(U=>{if(D){const ne=xu(U.placement);return ne===b||ne==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(ne=>ne>0).reduce((ne,le)=>ne+le,0)]).sort((U,ne)=>U[1]-ne[1])[0])==null?void 0:Z[0];W&&(Ce=W);break}case"initialPlacement":Ce=s;break}if(i!==Ce)return{reset:{placement:Ce}}}return{}}}};function Q6(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function eS(e){return XX.some(t=>e[t]>=0)}const uZ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=As(e,t);switch(r){case"referenceHidden":{const o=await ih(t,{...i,elementContext:"reference"}),a=Q6(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:eS(a)}}}case"escaped":{const o=await ih(t,{...i,altBoundary:!0}),a=Q6(o,n.floating);return{data:{escapedOffsets:a,escaped:eS(a)}}}default:return{}}}}};async function lZ(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=ks(n),s=Sd(n),u=xu(n)==="y",d=["left","top"].includes(a)?-1:1,h=o&&u?-1:1,p=As(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return s&&typeof v=="number"&&(m=s==="end"?v*-1:v),u?{x:m*h,y:g*d}:{x:g*d,y:m*h}}const cZ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:s}=t,u=await lZ(t,e);return a===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:a}}}}},dZ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:w=>{let{x:C,y:b}=w;return{x:C,y:b}}},...u}=As(e,t),d={x:n,y:r},h=await ih(t,u),p=xu(ks(i)),g=jE(p);let m=d[g],v=d[p];if(o){const w=g==="y"?"top":"left",C=g==="y"?"bottom":"right",b=m+h[w],A=m-h[C];m=By(b,m,A)}if(a){const w=p==="y"?"top":"left",C=p==="y"?"bottom":"right",b=v+h[w],A=v-h[C];v=By(b,v,A)}const E=s.fn({...t,[g]:m,[p]:v});return{...E,data:{x:E.x-n,y:E.y-r}}}}},hZ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:s=0,mainAxis:u=!0,crossAxis:d=!0}=As(e,t),h={x:n,y:r},p=xu(i),g=jE(p);let m=h[g],v=h[p];const E=As(s,t),w=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(u){const A=g==="y"?"height":"width",T=o.reference[g]-o.floating[A]+w.mainAxis,B=o.reference[g]+o.reference[A]-w.mainAxis;mB&&(m=B)}if(d){var C,b;const A=g==="y"?"width":"height",T=["top","left"].includes(ks(i)),B=o.reference[p]-o.floating[A]+(T&&((C=a.offset)==null?void 0:C[p])||0)+(T?0:w.crossAxis),D=o.reference[p]+o.reference[A]+(T?0:((b=a.offset)==null?void 0:b[p])||0)-(T?w.crossAxis:0);vD&&(v=D)}return{[g]:m,[p]:v}}}},fZ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:a=()=>{},...s}=As(e,t),u=await ih(t,s),d=ks(n),h=Sd(n),p=xu(n)==="y",{width:g,height:m}=r.floating;let v,E;d==="top"||d==="bottom"?(v=d,E=h===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(E=d,v=h==="end"?"top":"bottom");const w=m-u.top-u.bottom,C=g-u.left-u.right,b=Do(m-u[v],w),A=Do(g-u[E],C),T=!t.middlewareData.shift;let B=b,D=A;if(p?D=h||T?Do(A,C):C:B=h||T?Do(b,w):w,T&&!h){const M=Mr(u.left,0),O=Mr(u.right,0),z=Mr(u.top,0),K=Mr(u.bottom,0);p?D=g-2*(M!==0||O!==0?M+O:Mr(u.left,u.right)):B=m-2*(z!==0||K!==0?z+K:Mr(u.top,u.bottom))}await a({...t,availableWidth:D,availableHeight:B});const I=await i.getDimensions(o.floating);return g!==I.width||m!==I.height?{reset:{rects:!0}}:{}}}};function xd(e){return EI(e)?(e.nodeName||"").toLowerCase():"#document"}function Hr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ms(e){var t;return(t=(EI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function EI(e){return e instanceof Node||e instanceof Hr(e).Node}function io(e){return e instanceof Element||e instanceof Hr(e).Element}function Uo(e){return e instanceof HTMLElement||e instanceof Hr(e).HTMLElement}function tS(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Hr(e).ShadowRoot}function Rh(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=oo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function pZ(e){return["table","td","th"].includes(xd(e))}function e1(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function VE(e){const t=GE(),n=io(e)?oo(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function gZ(e){let t=Au(e);for(;Uo(t)&&!ed(t);){if(VE(t))return t;if(e1(t))return null;t=Au(t)}return null}function GE(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ed(e){return["html","body","#document"].includes(xd(e))}function oo(e){return Hr(e).getComputedStyle(e)}function t1(e){return io(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Au(e){if(xd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||tS(e)&&e.host||Ms(e);return tS(t)?t.host:t}function CI(e){const t=Au(e);return ed(t)?e.ownerDocument?e.ownerDocument.body:e.body:Uo(t)&&Rh(t)?t:CI(t)}function oh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=CI(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=Hr(i);if(o){const s=$y(a);return t.concat(a,a.visualViewport||[],Rh(i)?i:[],s&&n?oh(s):[])}return t.concat(i,oh(i,[],n))}function $y(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bI(e){const t=oo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Uo(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,s=Bg(n)!==o||Bg(r)!==a;return s&&(n=o,r=a),{width:n,height:r,$:s}}function JE(e){return io(e)?e:e.contextElement}function _c(e){const t=JE(e);if(!Uo(t))return Su(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=bI(t);let a=(o?Bg(n.width):n.width)/r,s=(o?Bg(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const mZ=Su(0);function wI(e){const t=Hr(e);return!GE()||!t.visualViewport?mZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Hr(e)?!1:t}function xl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=JE(e);let a=Su(1);t&&(r?io(r)&&(a=_c(r)):a=_c(e));const s=vZ(o,n,r)?wI(o):Su(0);let u=(i.left+s.x)/a.x,d=(i.top+s.y)/a.y,h=i.width/a.x,p=i.height/a.y;if(o){const g=Hr(o),m=r&&io(r)?Hr(r):r;let v=g,E=$y(v);for(;E&&r&&m!==v;){const w=_c(E),C=E.getBoundingClientRect(),b=oo(E),A=C.left+(E.clientLeft+parseFloat(b.paddingLeft))*w.x,T=C.top+(E.clientTop+parseFloat(b.paddingTop))*w.y;u*=w.x,d*=w.y,h*=w.x,p*=w.y,u+=A,d+=T,v=Hr(E),E=$y(v)}}return $g({width:h,height:p,x:u,y:d})}function yZ(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Ms(r),s=t?e1(t.floating):!1;if(r===a||s&&o)return n;let u={scrollLeft:0,scrollTop:0},d=Su(1);const h=Su(0),p=Uo(r);if((p||!p&&!o)&&((xd(r)!=="body"||Rh(a))&&(u=t1(r)),Uo(r))){const g=xl(r);d=_c(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x,y:n.y*d.y-u.scrollTop*d.y+h.y}}function EZ(e){return Array.from(e.getClientRects())}function SI(e){return xl(Ms(e)).left+t1(e).scrollLeft}function CZ(e){const t=Ms(e),n=t1(e),r=e.ownerDocument.body,i=Mr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Mr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+SI(e);const s=-n.scrollTop;return oo(r).direction==="rtl"&&(a+=Mr(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:s}}function bZ(e,t){const n=Hr(e),r=Ms(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,s=0,u=0;if(i){o=i.width,a=i.height;const d=GE();(!d||d&&t==="fixed")&&(s=i.offsetLeft,u=i.offsetTop)}return{width:o,height:a,x:s,y:u}}function wZ(e,t){const n=xl(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Uo(e)?_c(e):Su(1),a=e.clientWidth*o.x,s=e.clientHeight*o.y,u=i*o.x,d=r*o.y;return{width:a,height:s,x:u,y:d}}function nS(e,t,n){let r;if(t==="viewport")r=bZ(e,n);else if(t==="document")r=CZ(Ms(e));else if(io(t))r=wZ(t,n);else{const i=wI(e);r={...t,x:t.x-i.x,y:t.y-i.y}}return $g(r)}function xI(e,t){const n=Au(e);return n===t||!io(n)||ed(n)?!1:oo(n).position==="fixed"||xI(n,t)}function SZ(e,t){const n=t.get(e);if(n)return n;let r=oh(e,[],!1).filter(s=>io(s)&&xd(s)!=="body"),i=null;const o=oo(e).position==="fixed";let a=o?Au(e):e;for(;io(a)&&!ed(a);){const s=oo(a),u=VE(a);!u&&s.position==="fixed"&&(i=null),(o?!u&&!i:!u&&s.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Rh(a)&&!u&&xI(e,a))?r=r.filter(h=>h!==a):i=s,a=Au(a)}return t.set(e,r),r}function xZ(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?e1(t)?[]:SZ(t,this._c):[].concat(n),r],s=a[0],u=a.reduce((d,h)=>{const p=nS(t,h,i);return d.top=Mr(p.top,d.top),d.right=Do(p.right,d.right),d.bottom=Do(p.bottom,d.bottom),d.left=Mr(p.left,d.left),d},nS(t,s,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function AZ(e){const{width:t,height:n}=bI(e);return{width:t,height:n}}function kZ(e,t,n){const r=Uo(t),i=Ms(t),o=n==="fixed",a=xl(e,!0,o,t);let s={scrollLeft:0,scrollTop:0};const u=Su(0);if(r||!r&&!o)if((xd(t)!=="body"||Rh(i))&&(s=t1(t)),r){const p=xl(t,!0,o,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}else i&&(u.x=SI(i));const d=a.left+s.scrollLeft-u.x,h=a.top+s.scrollTop-u.y;return{x:d,y:h,width:a.width,height:a.height}}function $v(e){return oo(e).position==="static"}function rS(e,t){return!Uo(e)||oo(e).position==="fixed"?null:t?t(e):e.offsetParent}function AI(e,t){const n=Hr(e);if(e1(e))return n;if(!Uo(e)){let i=Au(e);for(;i&&!ed(i);){if(io(i)&&!$v(i))return i;i=Au(i)}return n}let r=rS(e,t);for(;r&&pZ(r)&&$v(r);)r=rS(r,t);return r&&ed(r)&&$v(r)&&!VE(r)?n:r||gZ(e)||n}const IZ=async function(e){const t=this.getOffsetParent||AI,n=this.getDimensions,r=await n(e.floating);return{reference:kZ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DZ(e){return oo(e).direction==="rtl"}const TZ={convertOffsetParentRelativeRectToViewportRelativeRect:yZ,getDocumentElement:Ms,getClippingRect:xZ,getOffsetParent:AI,getElementRects:IZ,getClientRects:EZ,getDimensions:AZ,getScale:_c,isElement:io,isRTL:DZ};function PZ(e,t){let n=null,r;const i=Ms(e);function o(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function a(s,u){s===void 0&&(s=!1),u===void 0&&(u=1),o();const{left:d,top:h,width:p,height:g}=e.getBoundingClientRect();if(s||t(),!p||!g)return;const m=lp(h),v=lp(i.clientWidth-(d+p)),E=lp(i.clientHeight-(h+g)),w=lp(d),b={rootMargin:-m+"px "+-v+"px "+-E+"px "+-w+"px",threshold:Mr(0,Do(1,u))||1};let A=!0;function T(B){const D=B[0].intersectionRatio;if(D!==u){if(!A)return a();D?a(!1,D):r=setTimeout(()=>{a(!1,1e-7)},1e3)}A=!1}try{n=new IntersectionObserver(T,{...b,root:i.ownerDocument})}catch{n=new IntersectionObserver(T,b)}n.observe(e)}return a(!0),o}function BZ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=JE(e),h=i||o?[...d?oh(d):[],...oh(t)]:[];h.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),o&&C.addEventListener("resize",n)});const p=d&&s?PZ(d,n):null;let g=-1,m=null;a&&(m=new ResizeObserver(C=>{let[b]=C;b&&b.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var A;(A=m)==null||A.observe(t)})),n()}),d&&!u&&m.observe(d),m.observe(t));let v,E=u?xl(e):null;u&&w();function w(){const C=xl(e);E&&(C.x!==E.x||C.y!==E.y||C.width!==E.width||C.height!==E.height)&&n(),E=C,v=requestAnimationFrame(w)}return n(),()=>{var C;h.forEach(b=>{i&&b.removeEventListener("scroll",n),o&&b.removeEventListener("resize",n)}),p==null||p(),(C=m)==null||C.disconnect(),m=null,u&&cancelAnimationFrame(v)}}const MZ=cZ,$Z=dZ,RZ=sZ,FZ=fZ,LZ=uZ,iS=aZ,OZ=hZ,_Z=(e,t,n)=>{const r=new Map,i={platform:TZ,...n},o={...i.platform,_c:r};return oZ(e,t,{...i,platform:o})};var jp=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Rg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Rg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Rg(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function kI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oS(e,t){const n=kI(e);return Math.round(t*n)/n}function aS(e){const t=l.useRef(e);return jp(()=>{t.current=e}),t}function NZ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:s=!0,whileElementsMounted:u,open:d}=e,[h,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,m]=l.useState(r);Rg(g,r)||m(r);const[v,E]=l.useState(null),[w,C]=l.useState(null),b=l.useCallback(W=>{W!==D.current&&(D.current=W,E(W))},[]),A=l.useCallback(W=>{W!==I.current&&(I.current=W,C(W))},[]),T=o||v,B=a||w,D=l.useRef(null),I=l.useRef(null),M=l.useRef(h),O=u!=null,z=aS(u),K=aS(i),X=l.useCallback(()=>{if(!D.current||!I.current)return;const W={placement:t,strategy:n,middleware:g};K.current&&(W.platform=K.current),_Z(D.current,I.current,W).then(U=>{const ne={...U,isPositioned:!0};Z.current&&!Rg(M.current,ne)&&(M.current=ne,$u.flushSync(()=>{p(ne)}))})},[g,t,n,K]);jp(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,p(W=>({...W,isPositioned:!1})))},[d]);const Z=l.useRef(!1);jp(()=>(Z.current=!0,()=>{Z.current=!1}),[]),jp(()=>{if(T&&(D.current=T),B&&(I.current=B),T&&B){if(z.current)return z.current(T,B,X);X()}},[T,B,X,z,O]);const pe=l.useMemo(()=>({reference:D,floating:I,setReference:b,setFloating:A}),[b,A]),me=l.useMemo(()=>({reference:T,floating:B}),[T,B]),Ce=l.useMemo(()=>{const W={position:n,left:0,top:0};if(!me.floating)return W;const U=oS(me.floating,h.x),ne=oS(me.floating,h.y);return s?{...W,transform:"translate("+U+"px, "+ne+"px)",...kI(me.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:ne}},[n,s,me.floating,h.x,h.y]);return l.useMemo(()=>({...h,update:X,refs:pe,elements:me,floatingStyles:Ce}),[h,X,pe,me,Ce])}const zZ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?iS({element:r.current,padding:i}).fn(n):{}:r?iS({element:r,padding:i}).fn(n):{}}}},HZ=(e,t)=>({...MZ(e),options:[e,t]}),jZ=(e,t)=>({...$Z(e),options:[e,t]}),UZ=(e,t)=>({...OZ(e),options:[e,t]}),KZ=(e,t)=>({...RZ(e),options:[e,t]}),VZ=(e,t)=>({...FZ(e),options:[e,t]}),GZ=(e,t)=>({...LZ(e),options:[e,t]}),JZ=(e,t)=>({...zZ(e),options:[e,t]});var WZ="Arrow",II=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return ce.jsx(Yn.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:ce.jsx("polygon",{points:"0,0 30,0 15,10"})})});II.displayName=WZ;var YZ=II;function qZ(e){const[t,n]=l.useState(void 0);return Sl(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,s;if("borderBoxSize"in o){const u=o.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,s=d.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var WE="Popper",[DI,n1]=$h(WE),[XZ,TI]=DI(WE),PI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=l.useState(null);return ce.jsx(XZ,{scope:t,anchor:r,onAnchorChange:i,children:n})};PI.displayName=WE;var BI="PopperAnchor",MI=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=TI(BI,n),a=l.useRef(null),s=dr(t,a);return l.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:ce.jsx(Yn.div,{...i,ref:s})});MI.displayName=BI;var YE="PopperContent",[ZZ,QZ]=DI(YE),$I=l.forwardRef((e,t)=>{var At,dt,pn,Dn,On,_n;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:m="optimized",onPlaced:v,...E}=e,w=TI(YE,n),[C,b]=l.useState(null),A=dr(t,Tn=>b(Tn)),[T,B]=l.useState(null),D=qZ(T),I=(D==null?void 0:D.width)??0,M=(D==null?void 0:D.height)??0,O=r+(o!=="center"?"-"+o:""),z=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},K=Array.isArray(d)?d:[d],X=K.length>0,Z={padding:z,boundary:K.filter(tQ),altBoundary:X},{refs:pe,floatingStyles:me,placement:Ce,isPositioned:W,middlewareData:U}=NZ({strategy:"fixed",placement:O,whileElementsMounted:(...Tn)=>BZ(...Tn,{animationFrame:m==="always"}),elements:{reference:w.anchor},middleware:[HZ({mainAxis:i+M,alignmentAxis:a}),u&&jZ({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?UZ():void 0,...Z}),u&&KZ({...Z}),VZ({...Z,apply:({elements:Tn,rects:tn,availableWidth:Ri,availableHeight:zu})=>{const{width:Sn,height:ho}=tn.reference,Jo=Tn.floating.style;Jo.setProperty("--radix-popper-available-width",`${Ri}px`),Jo.setProperty("--radix-popper-available-height",`${zu}px`),Jo.setProperty("--radix-popper-anchor-width",`${Sn}px`),Jo.setProperty("--radix-popper-anchor-height",`${ho}px`)}}),T&&JZ({element:T,padding:s}),nQ({arrowWidth:I,arrowHeight:M}),g&&GZ({strategy:"referenceHidden",...Z})]}),[ne,le]=LI(Ce),Ae=wu(v);Sl(()=>{W&&(Ae==null||Ae())},[W,Ae]);const we=(At=U.arrow)==null?void 0:At.x,ft=(dt=U.arrow)==null?void 0:dt.y,Ze=((pn=U.arrow)==null?void 0:pn.centerOffset)!==0,[qe,Ge]=l.useState();return Sl(()=>{C&&Ge(window.getComputedStyle(C).zIndex)},[C]),ce.jsx("div",{ref:pe.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:W?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:qe,"--radix-popper-transform-origin":[(Dn=U.transformOrigin)==null?void 0:Dn.x,(On=U.transformOrigin)==null?void 0:On.y].join(" "),...((_n=U.hide)==null?void 0:_n.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:ce.jsx(ZZ,{scope:n,placedSide:ne,onArrowChange:B,arrowX:we,arrowY:ft,shouldHideArrow:Ze,children:ce.jsx(Yn.div,{"data-side":ne,"data-align":le,...E,ref:A,style:{...E.style,animation:W?void 0:"none"}})})})});$I.displayName=YE;var RI="PopperArrow",eQ={top:"bottom",right:"left",bottom:"top",left:"right"},FI=l.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=QZ(RI,r),a=eQ[o.placedSide];return ce.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:ce.jsx(YZ,{...i,ref:n,style:{...i.style,display:"block"}})})});FI.displayName=RI;function tQ(e){return e!==null}var nQ=e=>({name:"transformOrigin",options:e,fn(t){var w,C,b;const{placement:n,rects:r,middlewareData:i}=t,a=((w=i.arrow)==null?void 0:w.centerOffset)!==0,s=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,h]=LI(n),p={start:"0%",center:"50%",end:"100%"}[h],g=(((C=i.arrow)==null?void 0:C.x)??0)+s/2,m=(((b=i.arrow)==null?void 0:b.y)??0)+u/2;let v="",E="";return d==="bottom"?(v=a?p:`${g}px`,E=`${-u}px`):d==="top"?(v=a?p:`${g}px`,E=`${r.floating.height+u}px`):d==="right"?(v=`${-u}px`,E=a?p:`${m}px`):d==="left"&&(v=`${r.floating.width+u}px`,E=a?p:`${m}px`),{data:{x:v,y:E}}}});function LI(e){const[t,n="center"]=e.split("-");return[t,n]}var OI=PI,qE=MI,_I=$I,NI=FI,rQ="Portal",zI=l.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[i,o]=l.useState(!1);Sl(()=>o(!0),[]);const a=n||i&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return a?Q7.createPortal(ce.jsx(Yn.div,{...r,ref:t}),a):null});zI.displayName=rQ;function iQ(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Ad=e=>{const{present:t,children:n}=e,r=oQ(t),i=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),o=dr(r.ref,aQ(i));return typeof n=="function"||r.isPresent?l.cloneElement(i,{ref:o}):null};Ad.displayName="Presence";function oQ(e){const[t,n]=l.useState(),r=l.useRef({}),i=l.useRef(e),o=l.useRef("none"),a=e?"mounted":"unmounted",[s,u]=iQ(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=cp(r.current);o.current=s==="mounted"?d:"none"},[s]),Sl(()=>{const d=r.current,h=i.current;if(h!==e){const g=o.current,m=cp(d);e?u("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&g!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Sl(()=>{if(t){const d=p=>{const m=cp(r.current).includes(p.animationName);p.target===t&&m&&$u.flushSync(()=>u("ANIMATION_END"))},h=p=>{p.target===t&&(o.current=cp(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:l.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function cp(e){return(e==null?void 0:e.animationName)||"none"}function aQ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function XE({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=sQ({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=wu(n),u=l.useCallback(d=>{if(o){const p=typeof d=="function"?d(e):d;p!==e&&s(p)}else i(d)},[o,e,i,s]);return[a,u]}function sQ({defaultProp:e,onChange:t}){const n=l.useState(e),[r]=n,i=l.useRef(r),o=wu(t);return l.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}var uQ="VisuallyHidden",HI=l.forwardRef((e,t)=>ce.jsx(Yn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));HI.displayName=uQ;var lQ=HI,[r1,rGe]=$h("Tooltip",[n1]),i1=n1(),jI="TooltipProvider",cQ=700,Ry="tooltip.open",[dQ,ZE]=r1(jI),UI=e=>{const{__scopeTooltip:t,delayDuration:n=cQ,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,[a,s]=l.useState(!0),u=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),ce.jsx(dQ,{scope:t,isOpenDelayed:a,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),s(!1)},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>s(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:l.useCallback(h=>{u.current=h},[]),disableHoverableContent:i,children:o})};UI.displayName=jI;var o1="Tooltip",[hQ,a1]=r1(o1),KI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i=!1,onOpenChange:o,disableHoverableContent:a,delayDuration:s}=e,u=ZE(o1,e.__scopeTooltip),d=i1(t),[h,p]=l.useState(null),g=k0(),m=l.useRef(0),v=a??u.disableHoverableContent,E=s??u.delayDuration,w=l.useRef(!1),[C=!1,b]=XE({prop:r,defaultProp:i,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(Ry))):u.onClose(),o==null||o(I)}}),A=l.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=l.useCallback(()=>{window.clearTimeout(m.current),w.current=!1,b(!0)},[b]),B=l.useCallback(()=>{window.clearTimeout(m.current),b(!1)},[b]),D=l.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,b(!0)},E)},[E,b]);return l.useEffect(()=>()=>window.clearTimeout(m.current),[]),ce.jsx(OI,{...d,children:ce.jsx(hQ,{scope:t,contentId:g,open:C,stateAttribute:A,trigger:h,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{u.isOpenDelayed?D():T()},[u.isOpenDelayed,D,T]),onTriggerLeave:l.useCallback(()=>{v?B():window.clearTimeout(m.current)},[B,v]),onOpen:T,onClose:B,disableHoverableContent:v,children:n})})};KI.displayName=o1;var Fy="TooltipTrigger",VI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=a1(Fy,n),o=ZE(Fy,n),a=i1(n),s=l.useRef(null),u=dr(t,s,i.onTriggerChange),d=l.useRef(!1),h=l.useRef(!1),p=l.useCallback(()=>d.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),ce.jsx(qE,{asChild:!0,...a,children:ce.jsx(Yn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:hn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!h.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:hn(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:hn(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:hn(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:hn(e.onBlur,i.onClose),onClick:hn(e.onClick,i.onClose)})})});VI.displayName=Fy;var fQ="TooltipPortal",[iGe,pQ]=r1(fQ,{forceMount:void 0}),td="TooltipContent",GI=l.forwardRef((e,t)=>{const n=pQ(td,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,a=a1(td,e.__scopeTooltip);return ce.jsx(Ad,{present:r||a.open,children:a.disableHoverableContent?ce.jsx(JI,{side:i,...o,ref:t}):ce.jsx(gQ,{side:i,...o,ref:t})})}),gQ=l.forwardRef((e,t)=>{const n=a1(td,e.__scopeTooltip),r=ZE(td,e.__scopeTooltip),i=l.useRef(null),o=dr(t,i),[a,s]=l.useState(null),{trigger:u,onClose:d}=n,h=i.current,{onPointerInTransitChange:p}=r,g=l.useCallback(()=>{s(null),p(!1)},[p]),m=l.useCallback((v,E)=>{const w=v.currentTarget,C={x:v.clientX,y:v.clientY},b=yQ(C,w.getBoundingClientRect()),A=EQ(C,b),T=CQ(E.getBoundingClientRect()),B=wQ([...A,...T]);s(B),p(!0)},[p]);return l.useEffect(()=>()=>g(),[g]),l.useEffect(()=>{if(u&&h){const v=w=>m(w,h),E=w=>m(w,u);return u.addEventListener("pointerleave",v),h.addEventListener("pointerleave",E),()=>{u.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",E)}}},[u,h,m,g]),l.useEffect(()=>{if(a){const v=E=>{const w=E.target,C={x:E.clientX,y:E.clientY},b=(u==null?void 0:u.contains(w))||(h==null?void 0:h.contains(w)),A=!bQ(C,a);b?g():A&&(g(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,h,a,d,g]),ce.jsx(JI,{...e,ref:o})}),[mQ,vQ]=r1(o1,{isInside:!1}),JI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:a,...s}=e,u=a1(td,n),d=i1(n),{onClose:h}=u;return l.useEffect(()=>(document.addEventListener(Ry,h),()=>document.removeEventListener(Ry,h)),[h]),l.useEffect(()=>{if(u.trigger){const p=g=>{const m=g.target;m!=null&&m.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),ce.jsx(Qm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:ce.jsxs(_I,{"data-state":u.stateAttribute,...d,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[ce.jsx(HE,{children:r}),ce.jsx(mQ,{scope:n,isInside:!0,children:ce.jsx(lQ,{id:u.contentId,role:"tooltip",children:i||r})})]})})});GI.displayName=td;var WI="TooltipArrow",YI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=i1(n);return vQ(WI,n).isInside?null:ce.jsx(NI,{...i,...r,ref:t})});YI.displayName=WI;function yQ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function EQ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function CQ(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function bQ(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;or!=h>r&&n<(d-s)*(r-u)/(h-u)+s&&(i=!i)}return i}function wQ(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),SQ(t)}function SQ(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const o=t[t.length-1],a=t[t.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xQ=UI,AQ=KI,kQ=VI,IQ=GI,DQ=YI,Rv=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Fv(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function qI(e,t){for(var n=t.slice(0,t.length-1),r=0;r=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function TQ(e,t){for(var n=e.length>=t.length?e:t,r=e.length>=t.length?t:e,i=!0,o=0;o=0&&Lt.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&Lt.splice(0,Lt.length),(t===93||t===224)&&(t=91),t in $n){$n[t]=!1;for(var r in ku)ku[r]===t&&(Lr[r]=!1)}}function FQ(e){if(typeof e>"u")Object.keys(dn).forEach(function(a){return delete dn[a]});else if(Array.isArray(e))e.forEach(function(a){a.key&&Lv(a)});else if(typeof e=="object")e.key&&Lv(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?qI(ku,d):[];dn[g]=dn[g].filter(function(v){var E=i?v.method===i:!0;return!(E&&v.scope===r&&TQ(v.mods,m))})}})};function uS(e,t,n,r){if(t.element===r){var i;if(t.scope===n||t.scope==="all"){i=t.mods.length>0;for(var o in $n)Object.prototype.hasOwnProperty.call($n,o)&&(!$n[o]&&t.mods.indexOf(+o)>-1||$n[o]&&t.mods.indexOf(+o)===-1)&&(i=!1);(t.mods.length===0&&!$n[16]&&!$n[18]&&!$n[17]&&!$n[91]||i||t.shortcut==="*")&&t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}}function lS(e,t){var n=dn["*"],r=e.keyCode||e.which||e.charCode;if(Lr.filter.call(this,e)){if((r===93||r===224)&&(r=91),Lt.indexOf(r)===-1&&r!==229&&Lt.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(v){var E=Ly[v];e[v]&&Lt.indexOf(E)===-1?Lt.push(E):!e[v]&&Lt.indexOf(E)>-1?Lt.splice(Lt.indexOf(E),1):v==="metaKey"&&e[v]&&Lt.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(Lt=Lt.slice(Lt.indexOf(E))))}),r in $n){$n[r]=!0;for(var i in ku)ku[i]===r&&(Lr[i]=!0);if(!n)return}for(var o in $n)Object.prototype.hasOwnProperty.call($n,o)&&($n[o]=e[Ly[o]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(Lt.indexOf(17)===-1&&Lt.push(17),Lt.indexOf(18)===-1&&Lt.push(18),$n[17]=!0,$n[18]=!0);var a=ah();if(n)for(var s=0;s-1}function Lr(e,t,n){Lt=[];var r=XI(e),i=[],o="all",a=document,s=0,u=!1,d=!0,h="+",p=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(o=t.scope),t.element&&(a=t.element),t.keyup&&(u=t.keyup),t.keydown!==void 0&&(d=t.keydown),t.capture!==void 0&&(p=t.capture),typeof t.splitKey=="string"&&(h=t.splitKey)),typeof t=="string"&&(o=t);s1&&(i=qI(ku,e)),e=e[e.length-1],e=e==="*"?"*":s1(e),e in dn||(dn[e]=[]),dn[e].push({keyup:u,keydown:d,scope:o,mods:i,shortcut:r[s],method:n,key:r[s],splitKey:h,element:a});typeof a<"u"&&!LQ(a)&&window&&(QI.push(a),Fv(a,"keydown",function(g){lS(g,a)},p),sS||(sS=!0,Fv(window,"focus",function(){Lt=[]},p)),Fv(a,"keyup",function(g){lS(g,a),RQ(g)},p))}function OQ(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(dn).forEach(function(n){var r=dn[n].find(function(i){return i.scope===t&&i.shortcut===e});r&&r.method&&r.method()})}var Ov={setScope:eD,getScope:ah,deleteScope:$Q,getPressedKeyCodes:PQ,isPressed:MQ,filter:BQ,trigger:OQ,unbind:FQ,keyMap:QE,modifier:ku,modifierMap:Ly};for(var _v in Ov)Object.prototype.hasOwnProperty.call(Ov,_v)&&(Lr[_v]=Ov[_v]);if(typeof window<"u"){var _Q=window.hotkeys;Lr.noConflict=function(e){return e&&window.hotkeys===Lr&&(window.hotkeys=_Q),Lr},window.hotkeys=Lr}Lr.filter=function(){return!0};var tD=function(t,n){var r=t.target,i=r&&r.tagName;return!!(i&&n&&n.includes(i))},NQ=function(t){return tD(t,["INPUT","TEXTAREA","SELECT"])};function Me(e,t,n,r){n instanceof Array&&(r=n,n=void 0);var i=n||{},o=i.enableOnTags,a=i.filter,s=i.keyup,u=i.keydown,d=i.filterPreventDefault,h=d===void 0?!0:d,p=i.enabled,g=p===void 0?!0:p,m=i.enableOnContentEditable,v=m===void 0?!1:m,E=l.useRef(null),w=l.useCallback(function(C,b){var A,T;return a&&!a(C)?!h:NQ(C)&&!tD(C,o)||(A=C.target)!=null&&A.isContentEditable&&!v?!0:E.current===null||document.activeElement===E.current||(T=E.current)!=null&&T.contains(document.activeElement)?(t(C,b),!0):!1},r?[E,o,a].concat(r):[E,o,a]);return l.useEffect(function(){if(!g){Lr.unbind(e,w);return}return s&&u!==!0&&(n.keydown=!1),Lr(e,n||{},w),function(){return Lr.unbind(e,w)}},[w,e,g]),E}Lr.isPressed;var Nv="focusScope.autoFocusOnMount",zv="focusScope.autoFocusOnUnmount",cS={bubbles:!1,cancelable:!0},zQ="FocusScope",eC=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=l.useState(null),d=wu(i),h=wu(o),p=l.useRef(null),g=dr(t,E=>u(E)),m=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let E=function(A){if(m.paused||!s)return;const T=A.target;s.contains(T)?p.current=T:Ws(p.current,{select:!0})},w=function(A){if(m.paused||!s)return;const T=A.relatedTarget;T!==null&&(s.contains(T)||Ws(p.current,{select:!0}))},C=function(A){if(document.activeElement===document.body)for(const B of A)B.removedNodes.length>0&&Ws(s)};document.addEventListener("focusin",E),document.addEventListener("focusout",w);const b=new MutationObserver(C);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",w),b.disconnect()}}},[r,s,m.paused]),l.useEffect(()=>{if(s){hS.add(m);const E=document.activeElement;if(!s.contains(E)){const C=new CustomEvent(Nv,cS);s.addEventListener(Nv,d),s.dispatchEvent(C),C.defaultPrevented||(HQ(GQ(nD(s)),{select:!0}),document.activeElement===E&&Ws(s))}return()=>{s.removeEventListener(Nv,d),setTimeout(()=>{const C=new CustomEvent(zv,cS);s.addEventListener(zv,h),s.dispatchEvent(C),C.defaultPrevented||Ws(E??document.body,{select:!0}),s.removeEventListener(zv,h),hS.remove(m)},0)}}},[s,d,h,m]);const v=l.useCallback(E=>{if(!n&&!r||m.paused)return;const w=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,C=document.activeElement;if(w&&C){const b=E.currentTarget,[A,T]=jQ(b);A&&T?!E.shiftKey&&C===T?(E.preventDefault(),n&&Ws(A,{select:!0})):E.shiftKey&&C===A&&(E.preventDefault(),n&&Ws(T,{select:!0})):C===b&&E.preventDefault()}},[n,r,m.paused]);return ce.jsx(Yn.div,{tabIndex:-1,...a,ref:g,onKeyDown:v})});eC.displayName=zQ;function HQ(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ws(r,{select:t}),document.activeElement!==n)return}function jQ(e){const t=nD(e),n=dS(t,e),r=dS(t.reverse(),e);return[n,r]}function nD(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function dS(e,t){for(const n of e)if(!UQ(n,{upTo:t}))return n}function UQ(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function KQ(e){return e instanceof HTMLInputElement&&"select"in e}function Ws(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&KQ(e)&&t&&e.select()}}var hS=VQ();function VQ(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=fS(e,t),e.unshift(t)},remove(t){var n;e=fS(e,t),(n=e[0])==null||n.resume()}}}function fS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function GQ(e){return e.filter(t=>t.tagName!=="A")}var Hv=0;function rD(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pS()),document.body.insertAdjacentElement("beforeend",e[1]??pS()),Hv++,()=>{Hv===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hv--}},[])}function pS(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var iD=vk(),jv=function(){},u1=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:jv,onWheelCapture:jv,onTouchMoveCapture:jv}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,g=e.sideCar,m=e.noIsolation,v=e.inert,E=e.allowPinchZoom,w=e.as,C=w===void 0?"div":w,b=e.gapMode,A=Ss(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=g,B=mk([n,t]),D=Ee(Ee({},A),i);return l.createElement(l.Fragment,null,h&&l.createElement(T,{sideCar:iD,removeScrollBar:d,shards:p,noIsolation:m,inert:v,setCallbacks:o,allowPinchZoom:!!E,lockRef:n,gapMode:b}),a?l.cloneElement(l.Children.only(s),Ee(Ee({},D),{ref:B})):l.createElement(C,Ee({},D,{className:u,ref:B}),s))});u1.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};u1.classNames={fullWidth:A0,zeroRight:x0};var Oy=!1;if(typeof window<"u")try{var hp=Object.defineProperty({},"passive",{get:function(){return Oy=!0,!0}});window.addEventListener("test",hp,hp),window.removeEventListener("test",hp,hp)}catch{Oy=!1}var uc=Oy?{passive:!1}:!1,JQ=function(e){return e.tagName==="TEXTAREA"},oD=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!JQ(e)&&n[t]==="visible")},WQ=function(e){return oD(e,"overflowY")},YQ=function(e){return oD(e,"overflowX")},gS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=aD(e,r);if(i){var o=sD(e,r),a=o[1],s=o[2];if(a>s)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qQ=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},XQ=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},aD=function(e,t){return e==="v"?WQ(t):YQ(t)},sD=function(e,t){return e==="v"?qQ(t):XQ(t)},ZQ=function(e,t){return e==="h"&&t==="rtl"?-1:1},QQ=function(e,t,n,r,i){var o=ZQ(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,u=t.contains(s),d=!1,h=a>0,p=0,g=0;do{var m=sD(e,s),v=m[0],E=m[1],w=m[2],C=E-w-o*v;(v||C)&&aD(e,s)&&(p+=C,g+=v),s instanceof ShadowRoot?s=s.host:s=s.parentNode}while(!u&&s!==document.body||u&&(t.contains(s)||t===s));return(h&&(Math.abs(p)<1||!i)||!h&&(Math.abs(g)<1||!i))&&(d=!0),d},fp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},mS=function(e){return[e.deltaX,e.deltaY]},vS=function(e){return e&&"current"in e?e.current:e},eee=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tee=function(e){return` +`)},QJ=0,ac=[];function eW(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),i=l.useState(QJ++)[0],o=l.useState(function(){return $E()})[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var E=ui([e.lockRef.current],(e.shards||[]).map(z6),!0).filter(Boolean);return E.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),E.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=l.useCallback(function(E,w){if("touches"in E&&E.touches.length===2)return!a.current.allowPinchZoom;var C=ap(E),b=n.current,A="deltaX"in E?E.deltaX:b[0]-C[0],T="deltaY"in E?E.deltaY:b[1]-C[1],B,D=E.target,I=Math.abs(A)>Math.abs(T)?"h":"v";if("touches"in E&&I==="h"&&D.type==="range")return!1;var M=_6(I,D);if(!M)return!0;if(M?B=I:(B=I==="v"?"h":"v",M=_6(I,D)),!M)return!1;if(!r.current&&"changedTouches"in E&&(A||T)&&(r.current=B),!B)return!0;var O=r.current||B;return qJ(O,w,E,O==="h"?A:T,!0)},[]),u=l.useCallback(function(E){var w=E;if(!(!ac.length||ac[ac.length-1]!==o)){var C="deltaY"in w?N6(w):ap(w),b=t.current.filter(function(B){return B.name===w.type&&B.target===w.target&&XJ(B.delta,C)})[0];if(b&&b.should){w.preventDefault();return}if(!b){var A=(a.current.shards||[]).map(z6).filter(Boolean).filter(function(B){return B.contains(w.target)}),T=A.length>0?s(w,A[0]):!a.current.noIsolation;T&&w.preventDefault()}}},[]),d=l.useCallback(function(E,w,C,b){var A={name:E,delta:w,target:C,should:b};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(T){return T!==A})},1)},[]),h=l.useCallback(function(E){n.current=ap(E),r.current=void 0},[]),p=l.useCallback(function(E){d(E.type,N6(E),E.target,s(E,e.lockRef.current))},[]),g=l.useCallback(function(E){d(E.type,ap(E),E.target,s(E,e.lockRef.current))},[]);l.useEffect(function(){return ac.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",u,oc),document.addEventListener("touchmove",u,oc),document.addEventListener("touchstart",h,oc),function(){ac=ac.filter(function(E){return E!==o}),document.removeEventListener("wheel",u,oc),document.removeEventListener("touchmove",u,oc),document.removeEventListener("touchstart",h,oc)}},[]);var m=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(o,{styles:ZJ(i)}):null,m?l.createElement(bk,{gapMode:"margin"}):null)}const tW=Ek(Ck,eW);var xk=l.forwardRef(function(e,t){return l.createElement(Gm,Ee({},e,{ref:t,sideCar:tW}))});xk.classNames=Gm.classNames;const Iy=["Enter"," "],nW=["ArrowDown","PageUp","Home"],Ak=["ArrowUp","PageDown","End"],rW=[...nW,...Ak],iW={ltr:[...Iy,"ArrowRight"],rtl:[...Iy,"ArrowLeft"]},oW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Jm="Menu",[nh,aW,sW]=WA(Jm),[Rl,Wm]=Ed(Jm,[sW,uk,fk]),Bh=uk(),kk=fk(),[Ik,Fu]=Rl(Jm),[uW,Mh]=Rl(Jm),lW=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:a=!0}=e,s=Bh(t),[u,d]=l.useState(null),h=l.useRef(!1),p=Di(o),g=YA(i);return l.useEffect(()=>{const m=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),l.createElement(dk,s,l.createElement(Ik,{scope:t,open:n,onOpenChange:p,content:u,onContentChange:d},l.createElement(uW,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:g,modal:a},r)))},Dk=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Bh(n);return l.createElement(rJ,De({},i,r,{ref:t}))}),Tk="MenuPortal",[cW,Pk]=Rl(Tk,{forceMount:void 0}),dW=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=Fu(Tk,t);return l.createElement(cW,{scope:t,forceMount:n},l.createElement(Ph,{present:n||o.open},l.createElement(aJ,{asChild:!0,container:i},r)))},eo="MenuContent",[hW,RE]=Rl(eo),fW=l.forwardRef((e,t)=>{const n=Pk(eo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Fu(eo,e.__scopeMenu),a=Mh(eo,e.__scopeMenu);return l.createElement(nh.Provider,{scope:e.__scopeMenu},l.createElement(Ph,{present:r||o.open},l.createElement(nh.Slot,{scope:e.__scopeMenu},a.modal?l.createElement(pW,De({},i,{ref:t})):l.createElement(gW,De({},i,{ref:t})))))}),pW=l.forwardRef((e,t)=>{const n=Fu(eo,e.__scopeMenu),r=l.useRef(null),i=Vr(t,r);return l.useEffect(()=>{const o=r.current;if(o)return ME(o)},[]),l.createElement(FE,De({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),gW=l.forwardRef((e,t)=>{const n=Fu(eo,e.__scopeMenu);return l.createElement(FE,De({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),FE=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:g,disableOutsideScroll:m,...v}=e,E=Fu(eo,n),w=Mh(eo,n),C=Bh(n),b=kk(n),A=aW(n),[T,B]=l.useState(null),D=l.useRef(null),I=Vr(t,D,E.onContentChange),M=l.useRef(0),O=l.useRef(""),z=l.useRef(0),K=l.useRef(null),X=l.useRef("right"),Z=l.useRef(0),pe=m?xk:l.Fragment,me=m?{as:eh,allowPinchZoom:!0}:void 0,Ce=U=>{var ne,le;const Ae=O.current+U,we=A().filter(dt=>!dt.disabled),ft=document.activeElement,Ze=(ne=we.find(dt=>dt.ref.current===ft))===null||ne===void 0?void 0:ne.textValue,qe=we.map(dt=>dt.textValue),Ge=FW(qe,Ae,Ze),At=(le=we.find(dt=>dt.textValue===Ge))===null||le===void 0?void 0:le.ref.current;(function dt(pn){O.current=pn,window.clearTimeout(M.current),pn!==""&&(M.current=window.setTimeout(()=>dt(""),1e3))})(Ae),At&&setTimeout(()=>At.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),lG();const W=l.useCallback(U=>{var ne,le;return X.current===((ne=K.current)===null||ne===void 0?void 0:ne.side)&&OW(U,(le=K.current)===null||le===void 0?void 0:le.area)},[]);return l.createElement(hW,{scope:n,searchRef:O,onItemEnter:l.useCallback(U=>{W(U)&&U.preventDefault()},[W]),onItemLeave:l.useCallback(U=>{var ne;W(U)||((ne=D.current)===null||ne===void 0||ne.focus(),B(null))},[W]),onTriggerLeave:l.useCallback(U=>{W(U)&&U.preventDefault()},[W]),pointerGraceTimerRef:z,onPointerGraceIntentChange:l.useCallback(U=>{K.current=U},[])},l.createElement(pe,me,l.createElement(cG,{asChild:!0,trapped:i,onMountAutoFocus:Xe(o,U=>{var ne;U.preventDefault(),(ne=D.current)===null||ne===void 0||ne.focus()}),onUnmountAutoFocus:a},l.createElement(aG,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:p,onDismiss:g},l.createElement(SJ,De({asChild:!0},b,{dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:B,onEntryFocus:U=>{w.isUsingKeyboardRef.current||U.preventDefault()}}),l.createElement(iJ,De({role:"menu","aria-orientation":"vertical","data-state":Lk(E.open),dir:w.dir},C,v,{ref:I,style:{outline:"none",...v.style},onKeyDown:Xe(v.onKeyDown,U=>{const le=U.target.closest('[role="menu"]')===U.currentTarget,Ae=U.ctrlKey||U.altKey||U.metaKey,we=U.key.length===1;le&&(U.key==="Tab"&&U.preventDefault(),!Ae&&we&&Ce(U.key));const ft=D.current;if(U.target!==ft||!rW.includes(U.key))return;U.preventDefault();const qe=A().filter(Ge=>!Ge.disabled).map(Ge=>Ge.ref.current);Ak.includes(U.key)&&qe.reverse(),$W(qe)}),onBlur:Xe(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(M.current),O.current="")}),onPointerMove:Xe(e.onPointerMove,rh(U=>{const ne=U.target,le=Z.current!==U.clientX;if(U.currentTarget.contains(ne)&&le){const Ae=U.clientX>Z.current?"right":"left";X.current=Ae,Z.current=U.clientX}}))})))))))}),mW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.createElement(sr.div,De({role:"group"},r,{ref:t}))}),Dy="MenuItem",H6="menu.itemSelect",LE=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,o=l.useRef(null),a=Mh(Dy,e.__scopeMenu),s=RE(Dy,e.__scopeMenu),u=Vr(t,o),d=l.useRef(!1),h=()=>{const p=o.current;if(!n&&p){const g=new CustomEvent(H6,{bubbles:!0,cancelable:!0});p.addEventListener(H6,m=>r==null?void 0:r(m),{once:!0}),JA(p,g),g.defaultPrevented?d.current=!1:a.onClose()}};return l.createElement(Bk,De({},i,{ref:u,disabled:n,onClick:Xe(e.onClick,h),onPointerDown:p=>{var g;(g=e.onPointerDown)===null||g===void 0||g.call(e,p),d.current=!0},onPointerUp:Xe(e.onPointerUp,p=>{var g;d.current||(g=p.currentTarget)===null||g===void 0||g.click()}),onKeyDown:Xe(e.onKeyDown,p=>{const g=s.searchRef.current!=="";n||g&&p.key===" "||Iy.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})}))}),Bk=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,a=RE(Dy,n),s=kk(n),u=l.useRef(null),d=Vr(t,u),[h,p]=l.useState(!1),[g,m]=l.useState("");return l.useEffect(()=>{const v=u.current;if(v){var E;m(((E=v.textContent)!==null&&E!==void 0?E:"").trim())}},[o.children]),l.createElement(nh.ItemSlot,{scope:n,disabled:r,textValue:i??g},l.createElement(xJ,De({asChild:!0},s,{focusable:!r}),l.createElement(sr.div,De({role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},o,{ref:d,onPointerMove:Xe(e.onPointerMove,rh(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:Xe(e.onPointerLeave,rh(v=>a.onItemLeave(v))),onFocus:Xe(e.onFocus,()=>p(!0)),onBlur:Xe(e.onBlur,()=>p(!1))}))))}),vW=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return l.createElement($k,{scope:e.__scopeMenu,checked:n},l.createElement(LE,De({role:"menuitemcheckbox","aria-checked":n},i,{ref:t,"data-state":OE(n),onSelect:Xe(i.onSelect,()=>r==null?void 0:r(!n),{checkForDefaultPrevented:!1})})))}),yW="MenuRadioGroup",[EW,CW]=Rl(yW,{value:void 0,onValueChange:()=>{}}),bW=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=Di(r);return l.createElement(EW,{scope:e.__scopeMenu,value:n,onValueChange:o},l.createElement(mW,De({},i,{ref:t})))}),wW="MenuRadioItem",SW=l.forwardRef((e,t)=>{const{value:n,...r}=e,i=CW(wW,e.__scopeMenu),o=n===i.value;return l.createElement($k,{scope:e.__scopeMenu,checked:o},l.createElement(LE,De({role:"menuitemradio","aria-checked":o},r,{ref:t,"data-state":OE(o),onSelect:Xe(r.onSelect,()=>{var a;return(a=i.onValueChange)===null||a===void 0?void 0:a.call(i,n)},{checkForDefaultPrevented:!1})})))}),Mk="MenuItemIndicator",[$k,xW]=Rl(Mk,{checked:!1}),AW=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=xW(Mk,n);return l.createElement(Ph,{present:r||o.checked},l.createElement(sr.span,De({},i,{ref:t,"data-state":OE(o.checked)})))}),kW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.createElement(sr.div,De({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),IW=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Bh(n);return l.createElement(oJ,De({},i,r,{ref:t}))}),Rk="MenuSub",[DW,Fk]=Rl(Rk),TW=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,o=Fu(Rk,t),a=Bh(t),[s,u]=l.useState(null),[d,h]=l.useState(null),p=Di(i);return l.useEffect(()=>(o.open===!1&&p(!1),()=>p(!1)),[o.open,p]),l.createElement(dk,a,l.createElement(Ik,{scope:t,open:r,onOpenChange:p,content:d,onContentChange:h},l.createElement(DW,{scope:t,contentId:th(),triggerId:th(),trigger:s,onTriggerChange:u},n)))},sp="MenuSubTrigger",PW=l.forwardRef((e,t)=>{const n=Fu(sp,e.__scopeMenu),r=Mh(sp,e.__scopeMenu),i=Fk(sp,e.__scopeMenu),o=RE(sp,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:u}=o,d={__scopeMenu:e.__scopeMenu},h=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>h,[h]),l.useEffect(()=>{const p=s.current;return()=>{window.clearTimeout(p),u(null)}},[s,u]),l.createElement(Dk,De({asChild:!0},d),l.createElement(Bk,De({id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Lk(n.open)},e,{ref:Hm(t,i.onTriggerChange),onClick:p=>{var g;(g=e.onClick)===null||g===void 0||g.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Xe(e.onPointerMove,rh(p=>{o.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Xe(e.onPointerLeave,rh(p=>{var g;h();const m=(g=n.content)===null||g===void 0?void 0:g.getBoundingClientRect();if(m){var v;const E=(v=n.content)===null||v===void 0?void 0:v.dataset.side,w=E==="right",C=w?-5:5,b=m[w?"left":"right"],A=m[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:p.clientX+C,y:p.clientY},{x:b,y:m.top},{x:A,y:m.top},{x:A,y:m.bottom},{x:b,y:m.bottom}],side:E}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(p),p.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Xe(e.onKeyDown,p=>{const g=o.searchRef.current!=="";if(!(e.disabled||g&&p.key===" ")&&iW[r.dir].includes(p.key)){var m;n.onOpenChange(!0),(m=n.content)===null||m===void 0||m.focus(),p.preventDefault()}})})))}),BW="MenuSubContent",MW=l.forwardRef((e,t)=>{const n=Pk(eo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=Fu(eo,e.__scopeMenu),a=Mh(eo,e.__scopeMenu),s=Fk(BW,e.__scopeMenu),u=l.useRef(null),d=Vr(t,u);return l.createElement(nh.Provider,{scope:e.__scopeMenu},l.createElement(Ph,{present:r||o.open},l.createElement(nh.Slot,{scope:e.__scopeMenu},l.createElement(FE,De({id:s.contentId,"aria-labelledby":s.triggerId},i,{ref:d,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var p;a.isUsingKeyboardRef.current&&((p=u.current)===null||p===void 0||p.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Xe(e.onFocusOutside,h=>{h.target!==s.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Xe(e.onEscapeKeyDown,a.onClose),onKeyDown:Xe(e.onKeyDown,h=>{const p=h.currentTarget.contains(h.target),g=oW[a.dir].includes(h.key);if(p&&g){var m;o.onOpenChange(!1),(m=s.trigger)===null||m===void 0||m.focus(),h.preventDefault()}})})))))});function Lk(e){return e?"open":"closed"}function OE(e){return e?"checked":"unchecked"}function $W(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function RW(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function FW(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let a=RW(e,Math.max(o,0));i.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function LW(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;or!=h>r&&n<(d-s)*(r-u)/(h-u)+s&&(i=!i)}return i}function OW(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return LW(n,t)}function rh(e){return t=>t.pointerType==="mouse"?e(t):void 0}const Ok=lW,_k=Dk,Nk=dW,zk=fW,Hk=LE,_W=vW,NW=bW,zW=SW,HW=AW,jW=kW,jk=IW,Uk=TW,Kk=PW,Vk=MW,Gk="ContextMenu",[UW,eGe]=Ed(Gk,[Wm]),Bs=Wm(),[KW,Jk]=UW(Gk),VW=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:o=!0}=e,[a,s]=l.useState(!1),u=Bs(t),d=Di(r),h=l.useCallback(p=>{s(p),d(p)},[d]);return l.createElement(KW,{scope:t,open:a,onOpenChange:h,modal:o},l.createElement(Ok,De({},u,{dir:i,open:a,onOpenChange:h,modal:o}),n))},GW="ContextMenuTrigger",JW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Jk(GW,n),o=Bs(n),a=l.useRef({x:0,y:0}),s=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(u.current),[]),h=p=>{a.current={x:p.clientX,y:p.clientY},i.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.createElement(l.Fragment,null,l.createElement(_k,De({},o,{virtualRef:s})),l.createElement(sr.span,De({"data-state":i.open?"open":"closed"},r,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:Xe(e.onContextMenu,p=>{d(),h(p),p.preventDefault()}),onPointerDown:Xe(e.onPointerDown,up(p=>{d(),u.current=window.setTimeout(()=>h(p),700)})),onPointerMove:Xe(e.onPointerMove,up(d)),onPointerCancel:Xe(e.onPointerCancel,up(d)),onPointerUp:Xe(e.onPointerUp,up(d))})))}),WW=e=>{const{__scopeContextMenu:t,...n}=e,r=Bs(t);return l.createElement(Nk,De({},r,n))},YW="ContextMenuContent",qW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Jk(YW,n),o=Bs(n),a=l.useRef(!1);return l.createElement(zk,De({},o,r,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:s=>{var u;(u=e.onCloseAutoFocus)===null||u===void 0||u.call(e,s),!s.defaultPrevented&&a.current&&s.preventDefault(),a.current=!1},onInteractOutside:s=>{var u;(u=e.onInteractOutside)===null||u===void 0||u.call(e,s),!s.defaultPrevented&&!i.modal&&(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),Wk=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Hk,De({},i,r,{ref:t}))}),XW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(jk,De({},i,r,{ref:t}))}),ZW=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:o}=e,a=Bs(t),[s,u]=Vm({prop:i,defaultProp:o,onChange:r});return l.createElement(Uk,De({},a,{open:s,onOpenChange:u}),n)},QW=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Kk,De({},i,r,{ref:t}))}),eY=l.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Bs(n);return l.createElement(Vk,De({},i,r,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))});function up(e){return t=>t.pointerType!=="mouse"?e(t):void 0}const tY=VW,nY=JW,Ym=WW,rY=qW,_E=ZW,iY=QW,NE=eY;function je(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o=0)&&(n[i]=e[i]);return n}var oY=["color"],Yk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,oY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M9 3C9 2.44772 8.55229 2 8 2H7C6.44772 2 6 2.44772 6 3L6 14H1.5C1.22386 14 1 14.2239 1 14.5C1 14.7761 1.22386 15 1.5 15L6 15H9H13.5C13.7761 15 14 14.7761 14 14.5C14 14.2239 13.7761 14 13.5 14H9V3Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),aY=["color"],qk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,aY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.99988 6C1.44759 6 0.999877 6.44772 0.999877 7L0.999877 8C0.999877 8.55228 1.44759 9 1.99988 9L6.99988 9L6.99988 13.5C6.99988 13.7761 7.22374 14 7.49988 14C7.77602 14 7.99988 13.7761 7.99988 13.5L7.99988 9L12.9999 9C13.5522 9 13.9999 8.55228 13.9999 8L13.9999 7C13.9999 6.44772 13.5522 6 12.9999 6L7.99988 6L7.99988 1.5C7.99988 1.22386 7.77602 1 7.49988 1C7.22373 1 6.99988 1.22386 6.99988 1.5L6.99988 6L1.99988 6Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),sY=["color"],Xk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,sY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M6.99988 1C6.44759 1 5.99988 1.44772 5.99988 2V7H1.49988C1.22374 7 0.999878 7.22386 0.999878 7.5C0.999878 7.77614 1.22374 8 1.49988 8H5.99988V13C5.99988 13.5523 6.44759 14 6.99988 14H7.99988C8.55216 14 8.99988 13.5523 8.99988 13V8H13.4999C13.776 8 13.9999 7.77614 13.9999 7.5C13.9999 7.22386 13.776 7 13.4999 7H8.99988V2C8.99988 1.44772 8.55216 1 7.99988 1L6.99988 1Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),uY=["color"],Zk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,uY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.499995 0.999995C0.223855 0.999995 -5.58458e-07 1.22385 -5.46388e-07 1.49999L-2.18554e-08 13.4999C-9.78492e-09 13.776 0.223855 13.9999 0.499995 13.9999C0.776136 13.9999 0.999991 13.776 0.999991 13.4999L0.999991 8.99993L12 8.99993C12.5523 8.99993 13 8.55222 13 7.99993L13 6.99994C13 6.44766 12.5523 5.99995 12 5.99995L0.999991 5.99995L0.999991 1.49999C0.999991 1.22385 0.776135 0.999995 0.499995 0.999995Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lY=["color"],Qk=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,lY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 1C14.2237 1 13.9999 1.22386 13.9999 1.5L13.9999 6L2.99988 6C2.44759 6 1.99988 6.44772 1.99988 7L1.99988 8C1.99988 8.55228 2.44759 9 2.99988 9L13.9999 9L13.9999 13.5C13.9999 13.7761 14.2237 14 14.4999 14C14.776 14 14.9999 13.7761 14.9999 13.5L14.9999 9L14.9999 6L14.9999 1.5C14.9999 1.22386 14.776 1 14.4999 1Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),cY=["color"],eI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,cY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.5 0C1.22386 0 1 0.223858 1 0.5C1 0.776142 1.22386 1 1.5 1H6V12C6 12.5523 6.44772 13 7 13H8C8.55228 13 9 12.5523 9 12V1H13.5C13.7761 1 14 0.776142 14 0.5C14 0.223858 13.7761 0 13.5 0H9H6H1.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),dY=["color"],hY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,dY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M8.8914 2.1937C9.1158 2.35464 9.16725 2.66701 9.00631 2.89141L2.47388 12H13.5C13.7761 12 14 12.2239 14 12.5C14 12.7762 13.7761 13 13.5 13H1.5C1.31254 13 1.14082 12.8952 1.0552 12.7284C0.969578 12.5616 0.984438 12.361 1.09369 12.2086L8.19369 2.30862C8.35462 2.08422 8.667 2.03277 8.8914 2.1937ZM11.1 6.50001C11.1 6.22387 11.3238 6.00001 11.6 6.00001C11.8761 6.00001 12.1 6.22387 12.1 6.50001C12.1 6.77615 11.8761 7.00001 11.6 7.00001C11.3238 7.00001 11.1 6.77615 11.1 6.50001ZM10.4 4.00001C10.1239 4.00001 9.90003 4.22387 9.90003 4.50001C9.90003 4.77615 10.1239 5.00001 10.4 5.00001C10.6762 5.00001 10.9 4.77615 10.9 4.50001C10.9 4.22387 10.6762 4.00001 10.4 4.00001ZM12.1 8.50001C12.1 8.22387 12.3238 8.00001 12.6 8.00001C12.8761 8.00001 13.1 8.22387 13.1 8.50001C13.1 8.77615 12.8761 9.00001 12.6 9.00001C12.3238 9.00001 12.1 8.77615 12.1 8.50001ZM13.4 10C13.1239 10 12.9 10.2239 12.9 10.5C12.9 10.7761 13.1239 11 13.4 11C13.6762 11 13.9 10.7761 13.9 10.5C13.9 10.2239 13.6762 10 13.4 10Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fY=["color"],pY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,fY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gY=["color"],mY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,gY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),vY=["color"],yY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,vY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),EY=["color"],CY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,EY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 2H12.5C12.7761 2 13 2.22386 13 2.5V12.5C13 12.7761 12.7761 13 12.5 13H2.5C2.22386 13 2 12.7761 2 12.5V2.5C2 2.22386 2.22386 2 2.5 2ZM1 2.5C1 1.67157 1.67157 1 2.5 1H12.5C13.3284 1 14 1.67157 14 2.5V12.5C14 13.3284 13.3284 14 12.5 14H2.5C1.67157 14 1 13.3284 1 12.5V2.5ZM7.5 4C7.77614 4 8 3.77614 8 3.5C8 3.22386 7.77614 3 7.5 3C7.22386 3 7 3.22386 7 3.5C7 3.77614 7.22386 4 7.5 4ZM8 5.5C8 5.77614 7.77614 6 7.5 6C7.22386 6 7 5.77614 7 5.5C7 5.22386 7.22386 5 7.5 5C7.77614 5 8 5.22386 8 5.5ZM7.5 8C7.77614 8 8 7.77614 8 7.5C8 7.22386 7.77614 7 7.5 7C7.22386 7 7 7.22386 7 7.5C7 7.77614 7.22386 8 7.5 8ZM10 7.5C10 7.77614 9.77614 8 9.5 8C9.22386 8 9 7.77614 9 7.5C9 7.22386 9.22386 7 9.5 7C9.77614 7 10 7.22386 10 7.5ZM11.5 8C11.7761 8 12 7.77614 12 7.5C12 7.22386 11.7761 7 11.5 7C11.2239 7 11 7.22386 11 7.5C11 7.77614 11.2239 8 11.5 8Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),bY=["color"],wY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,bY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M12.5 2H2.5C2.22386 2 2 2.22386 2 2.5V12.5C2 12.7761 2.22386 13 2.5 13H12.5C12.7761 13 13 12.7761 13 12.5V2.5C13 2.22386 12.7761 2 12.5 2ZM2.5 1C1.67157 1 1 1.67157 1 2.5V12.5C1 13.3284 1.67157 14 2.5 14H12.5C13.3284 14 14 13.3284 14 12.5V2.5C14 1.67157 13.3284 1 12.5 1H2.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),SY=["color"],Pg=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,SY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),xY=["color"],AY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,xY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),kY=["color"],IY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,kY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.877075 7.49991C0.877075 3.84222 3.84222 0.877075 7.49991 0.877075C11.1576 0.877075 14.1227 3.84222 14.1227 7.49991C14.1227 11.1576 11.1576 14.1227 7.49991 14.1227C3.84222 14.1227 0.877075 11.1576 0.877075 7.49991ZM7.49991 1.82708C4.36689 1.82708 1.82708 4.36689 1.82708 7.49991C1.82708 10.6329 4.36689 13.1727 7.49991 13.1727C10.6329 13.1727 13.1727 10.6329 13.1727 7.49991C13.1727 4.36689 10.6329 1.82708 7.49991 1.82708Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),DY=["color"],j6=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,DY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 2V1H10V2H5ZM4.75 0C4.33579 0 4 0.335786 4 0.75V1H3.5C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H11.5C12.3284 14 13 13.3284 13 12.5V2.5C13 1.67157 12.3284 1 11.5 1H11V0.75C11 0.335786 10.6642 0 10.25 0H4.75ZM11 2V2.25C11 2.66421 10.6642 3 10.25 3H4.75C4.33579 3 4 2.66421 4 2.25V2H3.5C3.22386 2 3 2.22386 3 2.5V12.5C3 12.7761 3.22386 13 3.5 13H11.5C11.7761 13 12 12.7761 12 12.5V2.5C12 2.22386 11.7761 2 11.5 2H11Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),TY=["color"],PY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,TY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1 9.50006C1 10.3285 1.67157 11.0001 2.5 11.0001H4L4 10.0001H2.5C2.22386 10.0001 2 9.7762 2 9.50006L2 2.50006C2 2.22392 2.22386 2.00006 2.5 2.00006L9.5 2.00006C9.77614 2.00006 10 2.22392 10 2.50006V4.00002H5.5C4.67158 4.00002 4 4.67159 4 5.50002V12.5C4 13.3284 4.67158 14 5.5 14H12.5C13.3284 14 14 13.3284 14 12.5V5.50002C14 4.67159 13.3284 4.00002 12.5 4.00002H11V2.50006C11 1.67163 10.3284 1.00006 9.5 1.00006H2.5C1.67157 1.00006 1 1.67163 1 2.50006V9.50006ZM5 5.50002C5 5.22388 5.22386 5.00002 5.5 5.00002H12.5C12.7761 5.00002 13 5.22388 13 5.50002V12.5C13 12.7762 12.7761 13 12.5 13H5.5C5.22386 13 5 12.7762 5 12.5V5.50002Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),BY=["color"],MY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,BY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),$Y=["color"],RY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,$Y);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.29227 0.048984C3.47033 -0.032338 3.67946 -0.00228214 3.8274 0.125891L12.8587 7.95026C13.0134 8.08432 13.0708 8.29916 13.0035 8.49251C12.9362 8.68586 12.7578 8.81866 12.5533 8.82768L9.21887 8.97474L11.1504 13.2187C11.2648 13.47 11.1538 13.7664 10.9026 13.8808L8.75024 14.8613C8.499 14.9758 8.20255 14.8649 8.08802 14.6137L6.15339 10.3703L3.86279 12.7855C3.72196 12.934 3.50487 12.9817 3.31479 12.9059C3.1247 12.8301 3 12.6461 3 12.4414V0.503792C3 0.308048 3.11422 0.130306 3.29227 0.048984ZM4 1.59852V11.1877L5.93799 9.14425C6.05238 9.02363 6.21924 8.96776 6.38319 8.99516C6.54715 9.02256 6.68677 9.12965 6.75573 9.2809L8.79056 13.7441L10.0332 13.178L8.00195 8.71497C7.93313 8.56376 7.94391 8.38824 8.03072 8.24659C8.11753 8.10494 8.26903 8.01566 8.435 8.00834L11.2549 7.88397L4 1.59852Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),FY=["color"],LY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,FY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M9.875 7.5C9.875 8.81168 8.81168 9.875 7.5 9.875C6.18832 9.875 5.125 8.81168 5.125 7.5C5.125 6.18832 6.18832 5.125 7.5 5.125C8.81168 5.125 9.875 6.18832 9.875 7.5Z",fill:r}))}),OY=["color"],_Y=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,OY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.625 7.5C3.625 8.12132 3.12132 8.625 2.5 8.625C1.87868 8.625 1.375 8.12132 1.375 7.5C1.375 6.87868 1.87868 6.375 2.5 6.375C3.12132 6.375 3.625 6.87868 3.625 7.5ZM8.625 7.5C8.625 8.12132 8.12132 8.625 7.5 8.625C6.87868 8.625 6.375 8.12132 6.375 7.5C6.375 6.87868 6.87868 6.375 7.5 6.375C8.12132 6.375 8.625 6.87868 8.625 7.5ZM12.5 8.625C13.1213 8.625 13.625 8.12132 13.625 7.5C13.625 6.87868 13.1213 6.375 12.5 6.375C11.8787 6.375 11.375 6.87868 11.375 7.5C11.375 8.12132 11.8787 8.625 12.5 8.625Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),NY=["color"],tI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,NY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),zY=["color"],HY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,zY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),jY=["color"],UY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,jY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.44995 0.949951C1.31734 0.949951 1.19016 1.00263 1.0964 1.0964C1.00263 1.19017 0.949951 1.31735 0.949951 1.44995L0.949966 3.44995C0.949969 3.7261 1.17383 3.94995 1.44997 3.94995C1.72611 3.94995 1.94997 3.72609 1.94997 3.44995L1.94995 1.94995H3.44997C3.72611 1.94995 3.94997 1.72609 3.94997 1.44995C3.94997 1.17381 3.72611 0.949951 3.44997 0.949951H1.44995ZM5.94995 0.949951C5.67381 0.949951 5.44995 1.17381 5.44995 1.44995C5.44995 1.72609 5.67381 1.94995 5.94995 1.94995H8.94995C9.22609 1.94995 9.44995 1.72609 9.44995 1.44995C9.44995 1.17381 9.22609 0.949951 8.94995 0.949951H5.94995ZM5.44995 13.45C5.44995 13.1738 5.67381 12.95 5.94995 12.95H8.94995C9.22609 12.95 9.44995 13.1738 9.44995 13.45C9.44995 13.7261 9.22609 13.95 8.94995 13.95H5.94995C5.67381 13.95 5.44995 13.7261 5.44995 13.45ZM1.94995 5.94995C1.94995 5.67381 1.72609 5.44995 1.44995 5.44995C1.17381 5.44995 0.949951 5.67381 0.949951 5.94995V8.94995C0.949951 9.22609 1.17381 9.44995 1.44995 9.44995C1.72609 9.44995 1.94995 9.22609 1.94995 8.94995V5.94995ZM13.45 5.44995C13.7261 5.44995 13.95 5.67381 13.95 5.94995V8.94995C13.95 9.22609 13.7261 9.44995 13.45 9.44995C13.1738 9.44995 12.95 9.22609 12.95 8.94995V5.94995C12.95 5.67381 13.1738 5.44995 13.45 5.44995ZM11.45 0.949951C11.1738 0.949951 10.95 1.17381 10.95 1.44995C10.95 1.72609 11.1738 1.94995 11.45 1.94995H12.9499V3.44995C12.9499 3.72609 13.1738 3.94995 13.4499 3.94995C13.7261 3.94995 13.9499 3.72609 13.9499 3.44995V1.44995C13.9499 1.17381 13.7252 0.949951 13.449 0.949951H11.45ZM1.44995 10.95C1.72609 10.95 1.94995 11.1738 1.94995 11.45V12.95H3.44997C3.72611 12.95 3.94997 13.1738 3.94997 13.45C3.94997 13.7261 3.72611 13.95 3.44997 13.95H1.44995C1.17381 13.95 0.949951 13.7261 0.949951 13.45V11.45C0.949951 11.1738 1.17381 10.95 1.44995 10.95ZM13.95 11.45C13.95 11.1738 13.7261 10.95 13.45 10.95C13.1738 10.9499 12.95 11.1738 12.95 11.4499L12.9491 12.95H11.45C11.1738 12.95 10.95 13.1738 10.95 13.45C10.95 13.7261 11.1738 13.95 11.45 13.95H13.4499C13.7261 13.95 13.9499 13.7261 13.9499 13.45L13.95 11.45Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),KY=["color"],VY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,KY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.5 3C1.22386 3 1 3.22386 1 3.5C1 3.77614 1.22386 4 1.5 4H13.5C13.7761 4 14 3.77614 14 3.5C14 3.22386 13.7761 3 13.5 3H1.5ZM1 7.5C1 7.22386 1.22386 7 1.5 7H13.5C13.7761 7 14 7.22386 14 7.5C14 7.77614 13.7761 8 13.5 8H1.5C1.22386 8 1 7.77614 1 7.5ZM1 11.5C1 11.2239 1.22386 11 1.5 11H13.5C13.7761 11 14 11.2239 14 11.5C14 11.7761 13.7761 12 13.5 12H1.5C1.22386 12 1 11.7761 1 11.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),GY=["color"],JY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,GY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.35248 4.90532C1.35248 2.94498 2.936 1.35248 4.89346 1.35248C6.25769 1.35248 6.86058 1.92336 7.50002 2.93545C8.13946 1.92336 8.74235 1.35248 10.1066 1.35248C12.064 1.35248 13.6476 2.94498 13.6476 4.90532C13.6476 6.74041 12.6013 8.50508 11.4008 9.96927C10.2636 11.3562 8.92194 12.5508 8.00601 13.3664C7.94645 13.4194 7.88869 13.4709 7.83291 13.5206C7.64324 13.6899 7.3568 13.6899 7.16713 13.5206C7.11135 13.4709 7.05359 13.4194 6.99403 13.3664C6.0781 12.5508 4.73641 11.3562 3.59926 9.96927C2.39872 8.50508 1.35248 6.74041 1.35248 4.90532Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),WY=["color"],YY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,WY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 1H12.5C13.3284 1 14 1.67157 14 2.5V12.5C14 13.3284 13.3284 14 12.5 14H2.5C1.67157 14 1 13.3284 1 12.5V2.5C1 1.67157 1.67157 1 2.5 1ZM2.5 2C2.22386 2 2 2.22386 2 2.5V8.3636L3.6818 6.6818C3.76809 6.59551 3.88572 6.54797 4.00774 6.55007C4.12975 6.55216 4.24568 6.60372 4.32895 6.69293L7.87355 10.4901L10.6818 7.6818C10.8575 7.50607 11.1425 7.50607 11.3182 7.6818L13 9.3636V2.5C13 2.22386 12.7761 2 12.5 2H2.5ZM2 12.5V9.6364L3.98887 7.64753L7.5311 11.4421L8.94113 13H2.5C2.22386 13 2 12.7761 2 12.5ZM12.5 13H10.155L8.48336 11.153L11 8.6364L13 10.6364V12.5C13 12.7761 12.7761 13 12.5 13ZM6.64922 5.5C6.64922 5.03013 7.03013 4.64922 7.5 4.64922C7.96987 4.64922 8.35078 5.03013 8.35078 5.5C8.35078 5.96987 7.96987 6.35078 7.5 6.35078C7.03013 6.35078 6.64922 5.96987 6.64922 5.5ZM7.5 3.74922C6.53307 3.74922 5.74922 4.53307 5.74922 5.5C5.74922 6.46693 6.53307 7.25078 7.5 7.25078C8.46693 7.25078 9.25078 6.46693 9.25078 5.5C9.25078 4.53307 8.46693 3.74922 7.5 3.74922Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),qY=["color"],XY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,qY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 4.63601C5 3.76031 5.24219 3.1054 5.64323 2.67357C6.03934 2.24705 6.64582 1.9783 7.5014 1.9783C8.35745 1.9783 8.96306 2.24652 9.35823 2.67208C9.75838 3.10299 10 3.75708 10 4.63325V5.99999H5V4.63601ZM4 5.99999V4.63601C4 3.58148 4.29339 2.65754 4.91049 1.99307C5.53252 1.32329 6.42675 0.978302 7.5014 0.978302C8.57583 0.978302 9.46952 1.32233 10.091 1.99162C10.7076 2.65557 11 3.57896 11 4.63325V5.99999H12C12.5523 5.99999 13 6.44771 13 6.99999V13C13 13.5523 12.5523 14 12 14H3C2.44772 14 2 13.5523 2 13V6.99999C2 6.44771 2.44772 5.99999 3 5.99999H4ZM3 6.99999H12V13H3V6.99999Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),ZY=["color"],QY=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,ZY);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.4986 0C6.3257 0 5.36107 0.38943 4.73753 1.19361C4.23745 1.83856 4 2.68242 4 3.63325H5C5 2.84313 5.19691 2.23312 5.5278 1.80636C5.91615 1.30552 6.55152 1 7.4986 1C8.35683 1 8.96336 1.26502 9.35846 1.68623C9.75793 2.11211 10 2.76044 10 3.63601V6H3C2.44772 6 2 6.44772 2 7V13C2 13.5523 2.44772 14 3 14H12C12.5523 14 13 13.5523 13 13V7C13 6.44771 12.5523 6 12 6H11V3.63601C11 2.58135 10.7065 1.66167 10.0878 1.0021C9.46477 0.337871 8.57061 0 7.4986 0ZM3 7H12V13H3V7Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),eq=["color"],tq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,eq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5 1.5C5 1.22386 4.77614 1 4.5 1C4.22386 1 4 1.22386 4 1.5L4 7C4 7.01671 4.00082 7.03323 4.00242 7.04952C2.86009 7.28022 2 8.28967 2 9.5C2 10.7103 2.86009 11.7198 4.00242 11.9505C4.00082 11.9668 4 11.9833 4 12V13.5C4 13.7761 4.22386 14 4.5 14C4.77614 14 5 13.7761 5 13.5V12C5 11.9833 4.99918 11.9668 4.99758 11.9505C6.1399 11.7198 7 10.7103 7 9.5C7 8.28967 6.1399 7.28022 4.99758 7.04952C4.99918 7.03323 5 7.01671 5 7L5 1.5ZM11 1.5C11 1.22386 10.7761 1 10.5 1C10.2239 1 10 1.22386 10 1.5V3C10 3.01671 10.0008 3.03323 10.0024 3.04952C8.8601 3.28022 8 4.28967 8 5.5C8 6.71033 8.8601 7.71978 10.0024 7.95048C10.0008 7.96677 10 7.98329 10 8V13.5C10 13.7761 10.2239 14 10.5 14C10.7761 14 11 13.7761 11 13.5V8C11 7.98329 10.9992 7.96677 10.9976 7.95048C12.1399 7.71978 13 6.71033 13 5.5C13 4.28967 12.1399 3.28022 10.9976 3.04952C10.9992 3.03323 11 3.01671 11 3V1.5ZM4.5 8C3.67157 8 3 8.67157 3 9.5C3 10.3284 3.67157 11 4.5 11C5.32843 11 6 10.3284 6 9.5C6 8.67157 5.32843 8 4.5 8ZM9 5.5C9 4.67157 9.67157 4 10.5 4C11.3284 4 12 4.67157 12 5.5C12 6.32843 11.3284 7 10.5 7C9.67157 7 9 6.32843 9 5.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),nq=["color"],zE=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,nq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M11.8536 1.14645C11.6583 0.951184 11.3417 0.951184 11.1465 1.14645L3.71455 8.57836C3.62459 8.66832 3.55263 8.77461 3.50251 8.89155L2.04044 12.303C1.9599 12.491 2.00189 12.709 2.14646 12.8536C2.29103 12.9981 2.50905 13.0401 2.69697 12.9596L6.10847 11.4975C6.2254 11.4474 6.3317 11.3754 6.42166 11.2855L13.8536 3.85355C14.0488 3.65829 14.0488 3.34171 13.8536 3.14645L11.8536 1.14645ZM4.42166 9.28547L11.5 2.20711L12.7929 3.5L5.71455 10.5784L4.21924 11.2192L3.78081 10.7808L4.42166 9.28547Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),rq=["color"],iq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,rq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M12.1464 1.14645C12.3417 0.951184 12.6583 0.951184 12.8535 1.14645L14.8535 3.14645C15.0488 3.34171 15.0488 3.65829 14.8535 3.85355L10.9109 7.79618C10.8349 7.87218 10.7471 7.93543 10.651 7.9835L6.72359 9.94721C6.53109 10.0435 6.29861 10.0057 6.14643 9.85355C5.99425 9.70137 5.95652 9.46889 6.05277 9.27639L8.01648 5.34897C8.06455 5.25283 8.1278 5.16507 8.2038 5.08907L12.1464 1.14645ZM12.5 2.20711L8.91091 5.79618L7.87266 7.87267L8.12731 8.12732L10.2038 7.08907L13.7929 3.5L12.5 2.20711ZM9.99998 2L8.99998 3H4.9C4.47171 3 4.18056 3.00039 3.95552 3.01877C3.73631 3.03668 3.62421 3.06915 3.54601 3.10899C3.35785 3.20487 3.20487 3.35785 3.10899 3.54601C3.06915 3.62421 3.03669 3.73631 3.01878 3.95552C3.00039 4.18056 3 4.47171 3 4.9V11.1C3 11.5283 3.00039 11.8194 3.01878 12.0445C3.03669 12.2637 3.06915 12.3758 3.10899 12.454C3.20487 12.6422 3.35785 12.7951 3.54601 12.891C3.62421 12.9309 3.73631 12.9633 3.95552 12.9812C4.18056 12.9996 4.47171 13 4.9 13H11.1C11.5283 13 11.8194 12.9996 12.0445 12.9812C12.2637 12.9633 12.3758 12.9309 12.454 12.891C12.6422 12.7951 12.7951 12.6422 12.891 12.454C12.9309 12.3758 12.9633 12.2637 12.9812 12.0445C12.9996 11.8194 13 11.5283 13 11.1V6.99998L14 5.99998V11.1V11.1207C14 11.5231 14 11.8553 13.9779 12.1259C13.9549 12.407 13.9057 12.6653 13.782 12.908C13.5903 13.2843 13.2843 13.5903 12.908 13.782C12.6653 13.9057 12.407 13.9549 12.1259 13.9779C11.8553 14 11.5231 14 11.1207 14H11.1H4.9H4.87934C4.47686 14 4.14468 14 3.87409 13.9779C3.59304 13.9549 3.33469 13.9057 3.09202 13.782C2.7157 13.5903 2.40973 13.2843 2.21799 12.908C2.09434 12.6653 2.04506 12.407 2.0221 12.1259C1.99999 11.8553 1.99999 11.5231 2 11.1207V11.1206V11.1V4.9V4.87935V4.87932V4.87931C1.99999 4.47685 1.99999 4.14468 2.0221 3.87409C2.04506 3.59304 2.09434 3.33469 2.21799 3.09202C2.40973 2.71569 2.7157 2.40973 3.09202 2.21799C3.33469 2.09434 3.59304 2.04506 3.87409 2.0221C4.14468 1.99999 4.47685 1.99999 4.87932 2H4.87935H4.9H9.99998Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),oq=["color"],aq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,oq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M13.5 13.95C13.7485 13.95 13.95 13.7485 13.95 13.5C13.95 13.2514 13.7485 13.05 13.5 13.05L1.49995 13.05C1.25142 13.05 1.04995 13.2514 1.04995 13.5C1.04995 13.7485 1.25142 13.95 1.49995 13.95L13.5 13.95ZM11.0681 7.5683C11.2439 7.39257 11.2439 7.10764 11.0681 6.93191C10.8924 6.75617 10.6075 6.75617 10.4317 6.93191L7.94993 9.41371L7.94993 1.49998C7.94993 1.25146 7.74846 1.04998 7.49993 1.04998C7.2514 1.04998 7.04993 1.25146 7.04993 1.49998L7.04993 9.41371L4.56813 6.93191C4.39239 6.75617 4.10746 6.75617 3.93173 6.93191C3.75599 7.10764 3.75599 7.39257 3.93173 7.5683L7.18173 10.8183C7.35746 10.994 7.64239 10.994 7.81812 10.8183L11.0681 7.5683Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),sq=["color"],uq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,sq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1.50005 1.05005C1.25152 1.05005 1.05005 1.25152 1.05005 1.50005C1.05005 1.74858 1.25152 1.95005 1.50005 1.95005L13.5 1.95005C13.7486 1.95005 13.95 1.74858 13.95 1.50005C13.95 1.25152 13.7486 1.05005 13.5 1.05005H1.50005ZM3.93188 7.43169C3.75614 7.60743 3.75614 7.89236 3.93188 8.06809C4.10761 8.24383 4.39254 8.24383 4.56827 8.06809L7.05007 5.58629V13.5C7.05007 13.7485 7.25155 13.95 7.50007 13.95C7.7486 13.95 7.95007 13.7485 7.95007 13.5L7.95007 5.58629L10.4319 8.06809C10.6076 8.24383 10.8925 8.24383 11.0683 8.06809C11.244 7.89235 11.244 7.60743 11.0683 7.43169L7.81827 4.18169C7.64254 4.00596 7.35761 4.00596 7.18188 4.18169L3.93188 7.43169Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lq=["color"],cq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,lq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M8 2.75C8 2.47386 7.77614 2.25 7.5 2.25C7.22386 2.25 7 2.47386 7 2.75V7H2.75C2.47386 7 2.25 7.22386 2.25 7.5C2.25 7.77614 2.47386 8 2.75 8H7V12.25C7 12.5261 7.22386 12.75 7.5 12.75C7.77614 12.75 8 12.5261 8 12.25V8H12.25C12.5261 8 12.75 7.77614 12.75 7.5C12.75 7.22386 12.5261 7 12.25 7H8V2.75Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),dq=["color"],hq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,dq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M5.07505 4.10001C5.07505 2.91103 6.25727 1.92502 7.50005 1.92502C8.74283 1.92502 9.92505 2.91103 9.92505 4.10001C9.92505 5.19861 9.36782 5.71436 8.61854 6.37884L8.58757 6.4063C7.84481 7.06467 6.92505 7.87995 6.92505 9.5C6.92505 9.81757 7.18248 10.075 7.50005 10.075C7.81761 10.075 8.07505 9.81757 8.07505 9.5C8.07505 8.41517 8.62945 7.90623 9.38156 7.23925L9.40238 7.22079C10.1496 6.55829 11.075 5.73775 11.075 4.10001C11.075 2.12757 9.21869 0.775024 7.50005 0.775024C5.7814 0.775024 3.92505 2.12757 3.92505 4.10001C3.92505 4.41758 4.18249 4.67501 4.50005 4.67501C4.81761 4.67501 5.07505 4.41758 5.07505 4.10001ZM7.50005 13.3575C7.9833 13.3575 8.37505 12.9657 8.37505 12.4825C8.37505 11.9992 7.9833 11.6075 7.50005 11.6075C7.0168 11.6075 6.62505 11.9992 6.62505 12.4825C6.62505 12.9657 7.0168 13.3575 7.50005 13.3575Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),fq=["color"],pq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,fq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.59664 2.93628C7.76085 3.06401 8.00012 2.94698 8.00012 2.73895V1.99998C9.98143 2 11.1848 2.3637 11.9105 3.08945C12.6363 3.81522 13 5.0186 13 6.99998C13 7.27613 13.2239 7.49998 13.5 7.49998C13.7761 7.49998 14 7.27613 14 6.99998C14 4.9438 13.6325 3.39719 12.6176 2.38234C11.6028 1.36752 10.0562 0.999999 8.00012 0.999984V0.261266C8.00012 0.0532293 7.76085 -0.0637944 7.59664 0.063928L6.00384 1.30277C5.87516 1.40286 5.87516 1.59735 6.00384 1.69744L7.59664 2.93628ZM9.5 5H2.5C2.22386 5 2 5.22386 2 5.5V12.5C2 12.7761 2.22386 13 2.5 13H9.5C9.77614 13 10 12.7761 10 12.5V5.5C10 5.22386 9.77614 5 9.5 5ZM2.5 4C1.67157 4 1 4.67157 1 5.5V12.5C1 13.3284 1.67157 14 2.5 14H9.5C10.3284 14 11 13.3284 11 12.5V5.5C11 4.67157 10.3284 4 9.5 4H2.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),gq=["color"],nI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,gq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 0.999992C14.2237 0.999992 13.9999 1.22385 13.9999 1.49999L13.9999 13.4999C13.9999 13.776 14.2237 13.9999 14.4999 13.9999C14.776 13.9999 14.9999 13.776 14.9999 13.4999L14.9999 1.49999C14.9999 1.22385 14.776 0.999992 14.4999 0.999992ZM0.499996 0.999992C0.223856 0.999992 -9.78509e-09 1.22385 -2.18556e-08 1.49999L4.07279e-07 13.4999C3.95208e-07 13.776 0.223855 13.9999 0.499996 13.9999C0.776136 13.9999 0.999992 13.776 0.999992 13.4999L0.999992 1.49999C0.999992 1.22385 0.776136 0.999992 0.499996 0.999992ZM1.99998 6.99994C1.99998 6.44766 2.44769 5.99995 2.99998 5.99995L5.99995 5.99995C6.55223 5.99995 6.99994 6.44766 6.99994 6.99994L6.99994 7.99993C6.99994 8.55221 6.55223 8.99992 5.99995 8.99992L2.99998 8.99992C2.4477 8.99992 1.99998 8.55221 1.99998 7.99993L1.99998 6.99994ZM8.99993 5.99995C8.44765 5.99995 7.99993 6.44766 7.99993 6.99994L7.99993 7.99993C7.99993 8.55221 8.44765 8.99992 8.99993 8.99992L11.9999 8.99992C12.5522 8.99992 12.9999 8.55221 12.9999 7.99993L12.9999 6.99994C12.9999 6.44766 12.5522 5.99995 11.9999 5.99995L8.99993 5.99995Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),mq=["color"],rI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,mq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.999878 0.5C0.999878 0.223858 1.22374 0 1.49988 0H13.4999C13.776 0 13.9999 0.223858 13.9999 0.5C13.9999 0.776142 13.776 1 13.4999 1H1.49988C1.22374 1 0.999878 0.776142 0.999878 0.5ZM7 2C6.44772 2 6 2.44772 6 3V6C6 6.55228 6.44772 7 7 7H8C8.55228 7 9 6.55228 9 6V3C9 2.44772 8.55228 2 8 2H7ZM7 8C6.44772 8 6 8.44771 6 9V12C6 12.5523 6.44772 13 7 13H8C8.55228 13 9 12.5523 9 12V9C9 8.44772 8.55228 8 8 8H7ZM1.49988 14C1.22374 14 0.999878 14.2239 0.999878 14.5C0.999878 14.7761 1.22374 15 1.49988 15H13.4999C13.776 15 13.9999 14.7761 13.9999 14.5C13.9999 14.2239 13.776 14 13.4999 14H1.49988Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),vq=["color"],yq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,vq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M1 1H1.5H13.5H14V1.5V13.5V14H13.5H1.5H1V13.5V1.5V1ZM2 2V13H13V2H2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Eq=["color"],iI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Eq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M14.4999 0.999992C14.2237 0.999992 13.9999 1.22385 13.9999 1.49999L13.9999 5.99995L0.999992 5.99995L0.999992 1.49999C0.999992 1.22385 0.776136 0.999992 0.499996 0.999992C0.223856 0.999992 -9.78509e-09 1.22385 -2.18556e-08 1.49999L4.07279e-07 13.4999C3.95208e-07 13.776 0.223855 13.9999 0.499996 13.9999C0.776136 13.9999 0.999992 13.776 0.999992 13.4999L0.999992 8.99992L13.9999 8.99992L13.9999 13.4999C13.9999 13.776 14.2237 13.9999 14.4999 13.9999C14.776 13.9999 14.9999 13.776 14.9999 13.4999L14.9999 1.49999C14.9999 1.22385 14.776 0.999992 14.4999 0.999992Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Cq=["color"],oI=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Cq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M0.999878 0.5C0.999878 0.223858 1.22374 0 1.49988 0H13.4999C13.776 0 13.9999 0.223858 13.9999 0.5C13.9999 0.776142 13.776 1 13.4999 1H6H1.49988C1.22374 1 0.999878 0.776142 0.999878 0.5ZM9 14V1L6 1V14H1.49988C1.22374 14 0.999878 14.2239 0.999878 14.5C0.999878 14.7761 1.22374 15 1.49988 15H13.4999C13.776 15 13.9999 14.7761 13.9999 14.5C13.9999 14.2239 13.776 14 13.4999 14H9Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),bq=["color"],wq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,bq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M3.94993 2.95002L3.94993 4.49998C3.94993 4.74851 3.74845 4.94998 3.49993 4.94998C3.2514 4.94998 3.04993 4.74851 3.04993 4.49998V2.50004C3.04993 2.45246 3.05731 2.40661 3.07099 2.36357C3.12878 2.18175 3.29897 2.05002 3.49993 2.05002H11.4999C11.6553 2.05002 11.7922 2.12872 11.8731 2.24842C11.9216 2.32024 11.9499 2.40682 11.9499 2.50002L11.9499 2.50004V4.49998C11.9499 4.74851 11.7485 4.94998 11.4999 4.94998C11.2514 4.94998 11.0499 4.74851 11.0499 4.49998V2.95002H8.04993V12.05H9.25428C9.50281 12.05 9.70428 12.2515 9.70428 12.5C9.70428 12.7486 9.50281 12.95 9.25428 12.95H5.75428C5.50575 12.95 5.30428 12.7486 5.30428 12.5C5.30428 12.2515 5.50575 12.05 5.75428 12.05H6.94993V2.95002H3.94993Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Sq=["color"],xq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Sq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM4 7.5C4 7.22386 4.22386 7 4.5 7H10.5C10.7761 7 11 7.22386 11 7.5C11 7.77614 10.7761 8 10.5 8H4.5C4.22386 8 4 7.77614 4 7.5ZM3 10.5C3 10.2239 3.22386 10 3.5 10H11.5C11.7761 10 12 10.2239 12 10.5C12 10.7761 11.7761 11 11.5 11H3.5C3.22386 11 3 10.7761 3 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Aq=["color"],kq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Aq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2.5 4C2.22386 4 2 4.22386 2 4.5C2 4.77614 2.22386 5 2.5 5H12.5C12.7761 5 13 4.77614 13 4.5C13 4.22386 12.7761 4 12.5 4H2.5ZM2 7.5C2 7.22386 2.22386 7 2.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H2.5C2.22386 8 2 7.77614 2 7.5ZM2 10.5C2 10.2239 2.22386 10 2.5 10H12.5C12.7761 10 13 10.2239 13 10.5C13 10.7761 12.7761 11 12.5 11H2.5C2.22386 11 2 10.7761 2 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Iq=["color"],Dq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Iq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM2 7.5C2 7.22386 2.22386 7 2.5 7H7.5C7.77614 7 8 7.22386 8 7.5C8 7.77614 7.77614 8 7.5 8H2.5C2.22386 8 2 7.77614 2 7.5ZM2 10.5C2 10.2239 2.22386 10 2.5 10H10.5C10.7761 10 11 10.2239 11 10.5C11 10.7761 10.7761 11 10.5 11H2.5C2.22386 11 2 10.7761 2 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Tq=["color"],Pq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Tq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M2 4.5C2 4.22386 2.22386 4 2.5 4H12.5C12.7761 4 13 4.22386 13 4.5C13 4.77614 12.7761 5 12.5 5H2.5C2.22386 5 2 4.77614 2 4.5ZM7 7.5C7 7.22386 7.22386 7 7.5 7H12.5C12.7761 7 13 7.22386 13 7.5C13 7.77614 12.7761 8 12.5 8H7.5C7.22386 8 7 7.77614 7 7.5ZM4 10.5C4 10.2239 4.22386 10 4.5 10H12.5C12.7761 10 13 10.2239 13 10.5C13 10.7761 12.7761 11 12.5 11H4.5C4.22386 11 4 10.7761 4 10.5Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Bq=["color"],Mq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,Bq);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.23336 4.69629C7.23336 2.96884 8.63335 1.56857 10.36 1.56857C11.3736 1.56857 12.183 2.04804 12.7254 2.74385C13.3079 2.62467 13.8557 2.40913 14.3513 2.11508C14.1559 2.72598 13.7424 3.2396 13.2033 3.56463C13.2038 3.56568 13.2042 3.56674 13.2047 3.56779C13.7334 3.50361 14.2364 3.36302 14.7048 3.15546L14.7037 3.15715C14.3667 3.66183 13.9431 4.10736 13.4561 4.47034C13.4823 4.64672 13.4956 4.82427 13.4956 5.00079C13.4956 8.6871 10.6873 12.9746 5.52122 12.9746C3.93906 12.9746 2.46544 12.511 1.22505 11.7152C0.992632 11.5661 0.925108 11.2568 1.07423 11.0244C1.0874 11.0038 1.10183 10.9846 1.11734 10.9666C1.20582 10.8202 1.37438 10.7309 1.5554 10.7522C2.47066 10.8601 3.38568 10.7485 4.19219 10.3962C3.39226 10.0434 2.77129 9.35975 2.50204 8.51974C2.45359 8.3686 2.48835 8.20311 2.59351 8.08422C2.59716 8.0801 2.60087 8.07606 2.60464 8.0721C1.96391 7.50819 1.55973 6.68208 1.55973 5.76143V5.72759C1.55973 5.56814 1.64411 5.42059 1.78155 5.33974C1.82671 5.31317 1.87537 5.29511 1.92532 5.28558C1.70549 4.86154 1.58116 4.37984 1.58116 3.86958C1.58116 3.40165 1.58384 2.81192 1.91332 2.28081C1.98718 2.16175 2.10758 2.08915 2.2364 2.07195C2.42588 2.01237 2.64087 2.06969 2.77406 2.23302C3.86536 3.57126 5.44066 4.49583 7.23366 4.73961L7.23336 4.69629ZM5.52122 11.9746C4.73387 11.9746 3.97781 11.8435 3.27248 11.6023C4.13012 11.4538 4.95307 11.1159 5.66218 10.5602C5.81211 10.4427 5.87182 10.2435 5.81126 10.0629C5.7507 9.88234 5.583 9.75943 5.39255 9.75607C4.68968 9.74366 4.06712 9.39716 3.67793 8.86845C3.86828 8.85306 4.05428 8.82039 4.23445 8.77167C4.43603 8.71716 4.57363 8.53114 4.56674 8.32243C4.55985 8.11372 4.41029 7.93718 4.20555 7.89607C3.42694 7.73977 2.79883 7.16764 2.56169 6.42174C2.76255 6.47025 2.97102 6.4991 3.18482 6.5061C3.38563 6.51267 3.56646 6.38533 3.62795 6.19405C3.68943 6.00277 3.61666 5.79391 3.44963 5.68224C2.86523 5.29155 2.48116 4.62464 2.48116 3.86958C2.48116 3.70213 2.48352 3.55268 2.49355 3.41719C3.85115 4.79913 5.70873 5.68931 7.77588 5.79338C7.93225 5.80126 8.08328 5.73543 8.18395 5.61553C8.28463 5.49562 8.32332 5.33548 8.28851 5.18284C8.25255 5.02517 8.23336 4.86284 8.23336 4.69629C8.23336 3.52085 9.18591 2.56857 10.36 2.56857C11.5943 2.56857 12.4956 3.71208 12.4956 5.00079C12.4956 8.25709 10.0202 11.9746 5.52122 11.9746Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),$q=["color"],Rq=l.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,i=je(e,$q);return l.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},i,{ref:t}),l.createElement("path",{d:"M7.49998 1L6.92321 2.00307L1.17498 12L0.599976 13H1.7535H13.2464H14.4L13.825 12L8.07674 2.00307L7.49998 1ZM7.49998 3.00613L2.3285 12H12.6714L7.49998 3.00613Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),Ct="colors",er="sizes",xe="space",aI={gap:xe,gridGap:xe,columnGap:xe,gridColumnGap:xe,rowGap:xe,gridRowGap:xe,inset:xe,insetBlock:xe,insetBlockEnd:xe,insetBlockStart:xe,insetInline:xe,insetInlineEnd:xe,insetInlineStart:xe,margin:xe,marginTop:xe,marginRight:xe,marginBottom:xe,marginLeft:xe,marginBlock:xe,marginBlockEnd:xe,marginBlockStart:xe,marginInline:xe,marginInlineEnd:xe,marginInlineStart:xe,padding:xe,paddingTop:xe,paddingRight:xe,paddingBottom:xe,paddingLeft:xe,paddingBlock:xe,paddingBlockEnd:xe,paddingBlockStart:xe,paddingInline:xe,paddingInlineEnd:xe,paddingInlineStart:xe,top:xe,right:xe,bottom:xe,left:xe,scrollMargin:xe,scrollMarginTop:xe,scrollMarginRight:xe,scrollMarginBottom:xe,scrollMarginLeft:xe,scrollMarginX:xe,scrollMarginY:xe,scrollMarginBlock:xe,scrollMarginBlockEnd:xe,scrollMarginBlockStart:xe,scrollMarginInline:xe,scrollMarginInlineEnd:xe,scrollMarginInlineStart:xe,scrollPadding:xe,scrollPaddingTop:xe,scrollPaddingRight:xe,scrollPaddingBottom:xe,scrollPaddingLeft:xe,scrollPaddingX:xe,scrollPaddingY:xe,scrollPaddingBlock:xe,scrollPaddingBlockEnd:xe,scrollPaddingBlockStart:xe,scrollPaddingInline:xe,scrollPaddingInlineEnd:xe,scrollPaddingInlineStart:xe,fontSize:"fontSizes",background:Ct,backgroundColor:Ct,backgroundImage:Ct,borderImage:Ct,border:Ct,borderBlock:Ct,borderBlockEnd:Ct,borderBlockStart:Ct,borderBottom:Ct,borderBottomColor:Ct,borderColor:Ct,borderInline:Ct,borderInlineEnd:Ct,borderInlineStart:Ct,borderLeft:Ct,borderLeftColor:Ct,borderRight:Ct,borderRightColor:Ct,borderTop:Ct,borderTopColor:Ct,caretColor:Ct,color:Ct,columnRuleColor:Ct,fill:Ct,outline:Ct,outlineColor:Ct,stroke:Ct,textDecorationColor:Ct,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:er,minBlockSize:er,maxBlockSize:er,inlineSize:er,minInlineSize:er,maxInlineSize:er,width:er,minWidth:er,maxWidth:er,height:er,minHeight:er,maxHeight:er,flexBasis:er,gridTemplateColumns:er,gridTemplateRows:er,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},Fq=(e,t)=>typeof t=="function"?{"()":Function.prototype.toString.call(t)}:t,wd=()=>{const e=Object.create(null);return(t,n,...r)=>{const i=(o=>JSON.stringify(o,Fq))(t);return i in e?e[i]:e[i]=n(t,...r)}},fl=Symbol.for("sxs.internal"),HE=(e,t)=>Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)),U6=e=>{for(const t in e)return!0;return!1},{hasOwnProperty:Lq}=Object.prototype,Ty=e=>e.includes("-")?e:e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),Oq=/\s+(?![^()]*\))/,sc=e=>t=>e(...typeof t=="string"?String(t).split(Oq):[t]),K6={appearance:e=>({WebkitAppearance:e,appearance:e}),backfaceVisibility:e=>({WebkitBackfaceVisibility:e,backfaceVisibility:e}),backdropFilter:e=>({WebkitBackdropFilter:e,backdropFilter:e}),backgroundClip:e=>({WebkitBackgroundClip:e,backgroundClip:e}),boxDecorationBreak:e=>({WebkitBoxDecorationBreak:e,boxDecorationBreak:e}),clipPath:e=>({WebkitClipPath:e,clipPath:e}),content:e=>({content:e.includes('"')||e.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(e)?e:`"${e}"`}),hyphens:e=>({WebkitHyphens:e,hyphens:e}),maskImage:e=>({WebkitMaskImage:e,maskImage:e}),maskSize:e=>({WebkitMaskSize:e,maskSize:e}),tabSize:e=>({MozTabSize:e,tabSize:e}),textSizeAdjust:e=>({WebkitTextSizeAdjust:e,textSizeAdjust:e}),userSelect:e=>({WebkitUserSelect:e,userSelect:e}),marginBlock:sc((e,t)=>({marginBlockStart:e,marginBlockEnd:t||e})),marginInline:sc((e,t)=>({marginInlineStart:e,marginInlineEnd:t||e})),maxSize:sc((e,t)=>({maxBlockSize:e,maxInlineSize:t||e})),minSize:sc((e,t)=>({minBlockSize:e,minInlineSize:t||e})),paddingBlock:sc((e,t)=>({paddingBlockStart:e,paddingBlockEnd:t||e})),paddingInline:sc((e,t)=>({paddingInlineStart:e,paddingInlineEnd:t||e}))},$v=/([\d.]+)([^]*)/,_q=(e,t)=>e.length?e.reduce((n,r)=>(n.push(...t.map(i=>i.includes("&")?i.replace(/&/g,/[ +>|~]/.test(r)&&/&.*&/.test(i)?`:is(${r})`:r):r+" "+i)),n),[]):t,Nq=(e,t)=>e in zq&&typeof t=="string"?t.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,(n,r,i,o)=>r+(i==="stretch"?`-moz-available${o};${Ty(e)}:${r}-webkit-fill-available`:`-moz-fit-content${o};${Ty(e)}:${r}fit-content`)+o):String(t),zq={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},xs=e=>e?e+"-":"",sI=(e,t,n)=>e.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,(r,i,o,a,s)=>a=="$"==!!o?r:(i||a=="--"?"calc(":"")+"var(--"+(a==="$"?xs(t)+(s.includes("$")?"":xs(n))+s.replace(/\$/g,"-"):s)+")"+(i||a=="--"?"*"+(i||"")+(o||"1")+")":"")),Hq=/\s*,\s*(?![^()]*\))/,jq=Object.prototype.toString,Ic=(e,t,n,r,i)=>{let o,a,s;const u=(d,h,p)=>{let g,m;const v=E=>{for(g in E){const b=g.charCodeAt(0)===64,A=b&&Array.isArray(E[g])?E[g]:[E[g]];for(m of A){const T=/[A-Z]/.test(C=g)?C:C.replace(/-[^]/g,D=>D[1].toUpperCase()),B=typeof m=="object"&&m&&m.toString===jq&&(!r.utils[T]||!h.length);if(T in r.utils&&!B){const D=r.utils[T];if(D!==a){a=D,v(D(m)),a=null;continue}}else if(T in K6){const D=K6[T];if(D!==s){s=D,v(D(m)),s=null;continue}}if(b&&(w=g.slice(1)in r.media?"@media "+r.media[g.slice(1)]:g,g=w.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,(D,I,M,O,z,K)=>{const X=$v.test(I),Z=.0625*(X?-1:1),[pe,me]=X?[O,I]:[I,O];return"("+(M[0]==="="?"":M[0]===">"===X?"max-":"min-")+pe+":"+(M[0]!=="="&&M.length===1?me.replace($v,(Ce,W,U)=>Number(W)+Z*(M===">"?1:-1)+U):me)+(z?") and ("+(z[0]===">"?"min-":"max-")+pe+":"+(z.length===1?K.replace($v,(Ce,W,U)=>Number(W)+Z*(z===">"?-1:1)+U):K):"")+")"})),B){const D=b?p.concat(g):[...p],I=b?[...h]:_q(h,g.split(Hq));o!==void 0&&i(V6(...o)),o=void 0,u(m,I,D)}else o===void 0&&(o=[[],h,p]),g=b||g.charCodeAt(0)!==36?g:`--${xs(r.prefix)}${g.slice(1).replace(/\$/g,"-")}`,m=B?m:typeof m=="number"?m&&T in Uq?String(m)+"px":String(m):sI(Nq(T,m??""),r.prefix,r.themeMap[T]),o[0].push(`${b?`${g} `:`${Ty(g)}:`}${m}`)}}var w,C};v(d),o!==void 0&&i(V6(...o)),o=void 0};u(e,t,n)},V6=(e,t,n)=>`${n.map(r=>`${r}{`).join("")}${t.length?`${t.join(",")}{`:""}${e.join(";")}${t.length?"}":""}${Array(n.length?n.length+1:0).join("}")}`,Uq={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},G6=e=>String.fromCharCode(e+(e>25?39:97)),pl=e=>(t=>{let n,r="";for(n=Math.abs(t);n>52;n=n/52|0)r=G6(n%52)+r;return G6(n%52)+r})(((t,n)=>{let r=n.length;for(;r;)t=33*t^n.charCodeAt(--r);return t})(5381,JSON.stringify(e))>>>0),h0=["themed","global","styled","onevar","resonevar","allvar","inline"],Kq=e=>{if(e.href&&!e.href.startsWith(location.origin))return!1;try{return!!e.cssRules}catch{return!1}},Vq=e=>{let t;const n=()=>{const{cssRules:i}=t.sheet;return[].map.call(i,(o,a)=>{const{cssText:s}=o;let u="";if(s.startsWith("--sxs"))return"";if(i[a-1]&&(u=i[a-1].cssText).startsWith("--sxs")){if(!o.cssRules.length)return"";for(const d in t.rules)if(t.rules[d].group===o)return`--sxs{--sxs:${[...t.rules[d].cache].join(" ")}}${s}`;return o.cssRules.length?`${u}${s}`:""}return s}).join("")},r=()=>{if(t){const{rules:s,sheet:u}=t;if(!u.deleteRule){for(;Object(Object(u.cssRules)[0]).type===3;)u.cssRules.splice(0,1);u.cssRules=[]}for(const d in s)delete s[d]}const i=Object(e).styleSheets||[];for(const s of i)if(Kq(s)){for(let u=0,d=s.cssRules;d[u];++u){const h=Object(d[u]);if(h.type!==1)continue;const p=Object(d[u+1]);if(p.type!==4)continue;++u;const{cssText:g}=h;if(!g.startsWith("--sxs"))continue;const m=g.slice(14,-3).trim().split(/\s+/),v=h0[m[0]];v&&(t||(t={sheet:s,reset:r,rules:{},toString:n}),t.rules[v]={group:p,index:u,cache:new Set(m)})}if(t)break}if(!t){const s=(u,d)=>({type:d,cssRules:[],insertRule(h,p){this.cssRules.splice(p,0,s(h,{import:3,undefined:1}[(h.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return u==="@media{}"?`@media{${[].map.call(this.cssRules,h=>h.cssText).join("")}}`:u}});t={sheet:e?(e.head||e).appendChild(document.createElement("style")).sheet:s("","text/css"),rules:{},reset:r,toString:n}}const{sheet:o,rules:a}=t;for(let s=h0.length-1;s>=0;--s){const u=h0[s];if(!a[u]){const d=h0[s+1],h=a[d]?a[d].index:o.cssRules.length;o.insertRule("@media{}",h),o.insertRule(`--sxs{--sxs:${s}}`,h),a[u]={group:o.cssRules[h+1],index:h,cache:new Set([s])}}Gq(a[u])}};return r(),t},Gq=e=>{const t=e.group;let n=t.cssRules.length;e.apply=r=>{try{t.insertRule(r,n),++n}catch{}}},i0=Symbol(),Jq=wd(),J6=(e,t)=>Jq(e,()=>(...n)=>{let r={type:null,composers:new Set};for(const i of n)if(i!=null)if(i[fl]){r.type==null&&(r.type=i[fl].type);for(const o of i[fl].composers)r.composers.add(o)}else i.constructor!==Object||i.$$typeof?r.type==null&&(r.type=i):r.composers.add(Wq(i,e));return r.type==null&&(r.type="span"),r.composers.size||r.composers.add(["PJLV",{},[],[],{},[]]),Yq(e,r,t)}),Wq=({variants:e,compoundVariants:t,defaultVariants:n,...r},i)=>{const o=`${xs(i.prefix)}c-${pl(r)}`,a=[],s=[],u=Object.create(null),d=[];for(const g in n)u[g]=String(n[g]);if(typeof e=="object"&&e)for(const g in e){h=u,p=g,Lq.call(h,p)||(u[g]="undefined");const m=e[g];for(const v in m){const E={[g]:String(v)};String(v)==="undefined"&&d.push(g);const w=m[v],C=[E,w,!U6(w)];a.push(C)}}var h,p;if(typeof t=="object"&&t)for(const g of t){let{css:m,...v}=g;m=typeof m=="object"&&m||{};for(const w in v)v[w]=String(v[w]);const E=[v,m,!U6(m)];s.push(E)}return[o,r,a,s,u,d]},Yq=(e,t,n)=>{const[r,i,o,a]=qq(t.composers),s=typeof t.type=="function"||t.type.$$typeof?(p=>{function g(){for(let m=0;mg.rules[m]={apply:v=>g[i0].push([m,v])}),g})(n):null,u=(s||n).rules,d=`.${r}${i.length>1?`:where(.${i.slice(1).join(".")})`:""}`,h=p=>{p=typeof p=="object"&&p||Xq;const{css:g,...m}=p,v={};for(const C in o)if(delete m[C],C in p){let b=p[C];typeof b=="object"&&b?v[C]={"@initial":o[C],...b}:(b=String(b),v[C]=b!=="undefined"||a.has(C)?b:o[C])}else v[C]=o[C];const E=new Set([...i]);for(const[C,b,A,T]of t.composers){n.rules.styled.cache.has(C)||(n.rules.styled.cache.add(C),Ic(b,[`.${C}`],[],e,I=>{u.styled.apply(I)}));const B=W6(A,v,e.media),D=W6(T,v,e.media,!0);for(const I of B)if(I!==void 0)for(const[M,O,z]of I){const K=`${C}-${pl(O)}-${M}`;E.add(K);const X=(z?n.rules.resonevar:n.rules.onevar).cache,Z=z?u.resonevar:u.onevar;X.has(K)||(X.add(K),Ic(O,[`.${K}`],[],e,pe=>{Z.apply(pe)}))}for(const I of D)if(I!==void 0)for(const[M,O]of I){const z=`${C}-${pl(O)}-${M}`;E.add(z),n.rules.allvar.cache.has(z)||(n.rules.allvar.cache.add(z),Ic(O,[`.${z}`],[],e,K=>{u.allvar.apply(K)}))}}if(typeof g=="object"&&g){const C=`${r}-i${pl(g)}-css`;E.add(C),n.rules.inline.cache.has(C)||(n.rules.inline.cache.add(C),Ic(g,[`.${C}`],[],e,b=>{u.inline.apply(b)}))}for(const C of String(p.className||"").trim().split(/\s+/))C&&E.add(C);const w=m.className=[...E].join(" ");return{type:t.type,className:w,selector:d,props:m,toString:()=>w,deferredInjector:s}};return HE(h,{className:r,selector:d,[fl]:t,toString:()=>(n.rules.styled.cache.has(r)||h(),r)})},qq=e=>{let t="";const n=[],r={},i=[];for(const[o,,,,a,s]of e){t===""&&(t=o),n.push(o),i.push(...s);for(const u in a){const d=a[u];(r[u]===void 0||d!=="undefined"||s.includes(d))&&(r[u]=d)}}return[t,n,r,new Set(i)]},W6=(e,t,n,r)=>{const i=[];e:for(let[o,a,s]of e){if(s)continue;let u,d=0,h=!1;for(u in o){const p=o[u];let g=t[u];if(g!==p){if(typeof g!="object"||!g)continue e;{let m,v,E=0;for(const w in g){if(p===String(g[w])){if(w!=="@initial"){const C=w.slice(1);(v=v||[]).push(C in n?n[C]:w.replace(/^@media ?/,"")),h=!0}d+=E,m=!0}++E}if(v&&v.length&&(a={["@media "+v.join(", ")]:a}),!m)continue e}}}(i[d]=i[d]||[]).push([r?"cv":`${u}-${o[u]}`,a,h])}return i},Xq={},Zq=wd(),Qq=(e,t)=>Zq(e,()=>(...n)=>{const r=()=>{for(let i of n){i=typeof i=="object"&&i||{};let o=pl(i);if(!t.rules.global.cache.has(o)){if(t.rules.global.cache.add(o),"@import"in i){let a=[].indexOf.call(t.sheet.cssRules,t.rules.themed.group)-1;for(let s of[].concat(i["@import"]))s=s.includes('"')||s.includes("'")?s:`"${s}"`,t.sheet.insertRule(`@import ${s};`,a++);delete i["@import"]}Ic(i,[],[],e,a=>{t.rules.global.apply(a)})}}return""};return HE(r,{toString:r})}),eX=wd(),tX=(e,t)=>eX(e,()=>n=>{const r=`${xs(e.prefix)}k-${pl(n)}`,i=()=>{if(!t.rules.global.cache.has(r)){t.rules.global.cache.add(r);const o=[];Ic(n,[],[],e,s=>o.push(s));const a=`@keyframes ${r}{${o.join("")}}`;t.rules.global.apply(a)}return r};return HE(i,{get name(){return i()},toString:i})}),nX=class{constructor(t,n,r,i){this.token=t==null?"":String(t),this.value=n==null?"":String(n),this.scale=r==null?"":String(r),this.prefix=i==null?"":String(i)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+xs(this.prefix)+xs(this.scale)+this.token}toString(){return this.computedValue}},rX=wd(),iX=(e,t)=>rX(e,()=>(n,r)=>{r=typeof n=="object"&&n||Object(r);const i=`.${n=(n=typeof n=="string"?n:"")||`${xs(e.prefix)}t-${pl(r)}`}`,o={},a=[];for(const u in r){o[u]={};for(const d in r[u]){const h=`--${xs(e.prefix)}${u}-${d}`,p=sI(String(r[u][d]),e.prefix,u);o[u][d]=new nX(d,p,u,e.prefix),a.push(`${h}:${p}`)}}const s=()=>{if(a.length&&!t.rules.themed.cache.has(n)){t.rules.themed.cache.add(n);const u=`${r===e.theme?":root,":""}.${n}{${a.join(";")}}`;t.rules.themed.apply(u)}return n};return{...o,get className(){return s()},selector:i,toString:s}}),oX=wd(),Y6,aX=wd(),uI=e=>{const t=(n=>{let r=!1;const i=oX(n,o=>{r=!0;const a="prefix"in(o=typeof o=="object"&&o||{})?String(o.prefix):"",s=typeof o.media=="object"&&o.media||{},u=typeof o.root=="object"?o.root||null:globalThis.document||null,d=typeof o.theme=="object"&&o.theme||{},h={prefix:a,media:s,theme:d,themeMap:typeof o.themeMap=="object"&&o.themeMap||{...aI},utils:typeof o.utils=="object"&&o.utils||{}},p=Vq(u),g={css:J6(h,p),globalCss:Qq(h,p),keyframes:tX(h,p),createTheme:iX(h,p),reset(){p.reset(),g.theme.toString()},theme:{},sheet:p,config:h,prefix:a,getCssText:p.toString,toString:p.toString};return String(g.theme=g.createTheme(d)),g});return r||i.reset(),i})(e);return t.styled=(({config:n,sheet:r})=>aX(n,()=>{const i=J6(n,r);return(...o)=>{const a=i(...o),s=a[fl].type,u=Kt.forwardRef((d,h)=>{const p=d&&d.as||s,{props:g,deferredInjector:m}=a(d);return delete g.as,g.ref=h,m?Kt.createElement(Kt.Fragment,null,Kt.createElement(p,g),Kt.createElement(m,null)):Kt.createElement(p,g)});return u.className=a.className,u.displayName=`Styled.${s.displayName||s.name||s}`,u.selector=a.selector,u.toString=()=>a.selector,u[fl]=a[fl],u}}))(t),t},sX=()=>Y6||(Y6=uI()),qm=(...e)=>sX().styled(...e);const lI="DropdownMenu",[uX,nGe]=Ed(lI,[Wm]),xr=Wm(),[lX,cI]=uX(lI),cX=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:a,modal:s=!0}=e,u=xr(t),d=l.useRef(null),[h=!1,p]=Vm({prop:i,defaultProp:o,onChange:a});return l.createElement(lX,{scope:t,triggerId:th(),triggerRef:d,contentId:th(),open:h,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(g=>!g),[p]),modal:s},l.createElement(Ok,De({},u,{open:h,onOpenChange:p,dir:r,modal:s}),n))},dX="DropdownMenuTrigger",hX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=cI(dX,n),a=xr(n);return l.createElement(_k,De({asChild:!0},a),l.createElement(sr.button,De({type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open?!0:void 0,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},i,{ref:Hm(t,o.triggerRef),onPointerDown:Xe(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(o.onOpenToggle(),o.open||s.preventDefault())}),onKeyDown:Xe(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&o.onOpenToggle(),s.key==="ArrowDown"&&o.onOpenChange(!0),[" ","ArrowDown"].includes(s.key)&&s.preventDefault())})})))}),fX=e=>{const{__scopeDropdownMenu:t,...n}=e,r=xr(t);return l.createElement(Nk,De({},r,n))},pX="DropdownMenuContent",gX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=cI(pX,n),o=xr(n),a=l.useRef(!1);return l.createElement(zk,De({id:i.contentId,"aria-labelledby":i.triggerId},o,r,{ref:t,onCloseAutoFocus:Xe(e.onCloseAutoFocus,s=>{var u;a.current||(u=i.triggerRef.current)===null||u===void 0||u.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Xe(e.onInteractOutside,s=>{const u=s.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!i.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),mX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Hk,De({},i,r,{ref:t}))}),vX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(_W,De({},i,r,{ref:t}))}),dI=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(NW,De({},i,r,{ref:t}))}),yX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(zW,De({},i,r,{ref:t}))}),EX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(HW,De({},i,r,{ref:t}))}),CX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(jW,De({},i,r,{ref:t}))}),bX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(jk,De({},i,r,{ref:t}))}),wX=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,a=xr(t),[s=!1,u]=Vm({prop:r,defaultProp:o,onChange:i});return l.createElement(Uk,De({},a,{open:s,onOpenChange:u}),n)},SX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Kk,De({},i,r,{ref:t}))}),xX=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=xr(n);return l.createElement(Vk,De({},i,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)"}}))}),Lu=cX,Fl=hX,AX=fX,hI=gX,Xm=mX,kX=vX,IX=dI,fI=yX,pI=EX,DX=CX,TX=bX,PX=wX,BX=SX,MX=xX;function hn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function $X(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function gI(...e){return t=>e.forEach(n=>$X(n,t))}function dr(...e){return l.useCallback(gI(...e),e)}function RX(e,t){const n=l.createContext(t);function r(o){const{children:a,...s}=o,u=l.useMemo(()=>s,Object.values(s));return ce.jsx(n.Provider,{value:u,children:a})}function i(o){const a=l.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",[r,i]}function $h(e,t=[]){let n=[];function r(o,a){const s=l.createContext(a),u=n.length;n=[...n,a];function d(p){const{scope:g,children:m,...v}=p,E=(g==null?void 0:g[e][u])||s,w=l.useMemo(()=>v,Object.values(v));return ce.jsx(E.Provider,{value:w,children:m})}function h(p,g){const m=(g==null?void 0:g[e][u])||s,v=l.useContext(m);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return d.displayName=o+"Provider",[d,h]}const i=()=>{const o=n.map(a=>l.createContext(a));return function(s){const u=(s==null?void 0:s[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...s,[e]:u}}),[s,u])}};return i.scopeName=e,[r,FX(i,...t)]}function FX(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const a=r.reduce((s,{useScope:u,scopeName:d})=>{const p=u(o)[`__scope${d}`];return{...s,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Zm=l.forwardRef((e,t)=>{const{children:n,...r}=e,i=l.Children.toArray(n),o=i.find(LX);if(o){const a=o.props.children,s=i.map(u=>u===o?l.Children.count(a)>1?l.Children.only(null):l.isValidElement(a)?a.props.children:null:u);return ce.jsx(Py,{...r,ref:t,children:l.isValidElement(a)?l.cloneElement(a,void 0,s):null})}return ce.jsx(Py,{...r,ref:t,children:n})});Zm.displayName="Slot";var Py=l.forwardRef((e,t)=>{const{children:n,...r}=e;if(l.isValidElement(n)){const i=_X(n);return l.cloneElement(n,{...OX(r,n.props),ref:t?gI(t,i):i})}return l.Children.count(n)>1?l.Children.only(null):null});Py.displayName="SlotClone";var jE=({children:e})=>ce.jsx(ce.Fragment,{children:e});function LX(e){return l.isValidElement(e)&&e.type===jE}function OX(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...s)=>{o(...s),i(...s)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function _X(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var NX=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Yn=NX.reduce((e,t)=>{const n=l.forwardRef((r,i)=>{const{asChild:o,...a}=r,s=o?Zm:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ce.jsx(s,{...a,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function zX(e,t){e&&$u.flushSync(()=>e.dispatchEvent(t))}function wu(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function HX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e);l.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var jX="DismissableLayer",By="dismissableLayer.update",UX="dismissableLayer.pointerDownOutside",KX="dismissableLayer.focusOutside",q6,mI=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Qm=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:a,onDismiss:s,...u}=e,d=l.useContext(mI),[h,p]=l.useState(null),g=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=l.useState({}),v=dr(t,I=>p(I)),E=Array.from(d.layers),[w]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=E.indexOf(w),b=h?E.indexOf(h):-1,A=d.layersWithOutsidePointerEventsDisabled.size>0,T=b>=C,B=JX(I=>{const M=I.target,O=[...d.branches].some(z=>z.contains(M));!T||O||(i==null||i(I),a==null||a(I),I.defaultPrevented||s==null||s())},g),D=WX(I=>{const M=I.target;[...d.branches].some(z=>z.contains(M))||(o==null||o(I),a==null||a(I),I.defaultPrevented||s==null||s())},g);return HX(I=>{b===d.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},g),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(q6=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),X6(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=q6)}},[h,g,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),X6())},[h,d]),l.useEffect(()=>{const I=()=>m({});return document.addEventListener(By,I),()=>document.removeEventListener(By,I)},[]),ce.jsx(Yn.div,{...u,ref:v,style:{pointerEvents:A?T?"auto":"none":void 0,...e.style},onFocusCapture:hn(e.onFocusCapture,D.onFocusCapture),onBlurCapture:hn(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:hn(e.onPointerDownCapture,B.onPointerDownCapture)})});Qm.displayName=jX;var VX="DismissableLayerBranch",GX=l.forwardRef((e,t)=>{const n=l.useContext(mI),r=l.useRef(null),i=dr(t,r);return l.useEffect(()=>{const o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),ce.jsx(Yn.div,{...e,ref:i})});GX.displayName=VX;function JX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e),r=l.useRef(!1),i=l.useRef(()=>{});return l.useEffect(()=>{const o=s=>{if(s.target&&!r.current){let u=function(){vI(UX,n,d,{discrete:!0})};const d={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=u,t.addEventListener("click",i.current,{once:!0})):u()}else t.removeEventListener("click",i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function WX(e,t=globalThis==null?void 0:globalThis.document){const n=wu(e),r=l.useRef(!1);return l.useEffect(()=>{const i=o=>{o.target&&!r.current&&vI(KX,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function X6(){const e=new CustomEvent(By);document.dispatchEvent(e)}function vI(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?zX(i,o):i.dispatchEvent(o)}var Sl=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},YX=Wx.useId||(()=>{}),qX=0;function k0(e){const[t,n]=l.useState(YX());return Sl(()=>{n(r=>r??String(qX++))},[e]),t?`radix-${t}`:""}const XX=["top","right","bottom","left"],Do=Math.min,Mr=Math.max,Bg=Math.round,lp=Math.floor,Su=e=>({x:e,y:e}),ZX={left:"right",right:"left",bottom:"top",top:"bottom"},QX={start:"end",end:"start"};function My(e,t,n){return Mr(e,Do(t,n))}function As(e,t){return typeof e=="function"?e(t):e}function ks(e){return e.split("-")[0]}function Sd(e){return e.split("-")[1]}function UE(e){return e==="x"?"y":"x"}function KE(e){return e==="y"?"height":"width"}function xu(e){return["top","bottom"].includes(ks(e))?"y":"x"}function VE(e){return UE(xu(e))}function eZ(e,t,n){n===void 0&&(n=!1);const r=Sd(e),i=VE(e),o=KE(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Mg(a)),[a,Mg(a)]}function tZ(e){const t=Mg(e);return[$y(e),t,$y(t)]}function $y(e){return e.replace(/start|end/g,t=>QX[t])}function nZ(e,t,n){const r=["left","right"],i=["right","left"],o=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?o:a;default:return[]}}function rZ(e,t,n,r){const i=Sd(e);let o=nZ(ks(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map($y)))),o}function Mg(e){return e.replace(/left|right|bottom|top/g,t=>ZX[t])}function iZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function yI(e){return typeof e!="number"?iZ(e):{top:e,right:e,bottom:e,left:e}}function $g(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Z6(e,t,n){let{reference:r,floating:i}=e;const o=xu(t),a=VE(t),s=KE(a),u=ks(t),d=o==="y",h=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,g=r[s]/2-i[s]/2;let m;switch(u){case"top":m={x:h,y:r.y-i.height};break;case"bottom":m={x:h,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:p};break;case"left":m={x:r.x-i.width,y:p};break;default:m={x:r.x,y:r.y}}switch(Sd(t)){case"start":m[a]-=g*(n&&d?-1:1);break;case"end":m[a]+=g*(n&&d?-1:1);break}return m}const oZ=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,s=o.filter(Boolean),u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:p}=Z6(d,r,u),g=r,m={},v=0;for(let E=0;E({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:s,middlewareData:u}=t,{element:d,padding:h=0}=As(e,t)||{};if(d==null)return{};const p=yI(h),g={x:n,y:r},m=VE(i),v=KE(m),E=await a.getDimensions(d),w=m==="y",C=w?"top":"left",b=w?"bottom":"right",A=w?"clientHeight":"clientWidth",T=o.reference[v]+o.reference[m]-g[m]-o.floating[v],B=g[m]-o.reference[m],D=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let I=D?D[A]:0;(!I||!await(a.isElement==null?void 0:a.isElement(D)))&&(I=s.floating[A]||o.floating[v]);const M=T/2-B/2,O=I/2-E[v]/2-1,z=Do(p[C],O),K=Do(p[b],O),X=z,Z=I-E[v]-K,pe=I/2-E[v]/2+M,me=My(X,pe,Z),Ce=!u.arrow&&Sd(i)!=null&&pe!==me&&o.reference[v]/2-(pepe<=0)){var K,X;const pe=(((K=o.flip)==null?void 0:K.index)||0)+1,me=I[pe];if(me)return{data:{index:pe,overflows:z},reset:{placement:me}};let Ce=(X=z.filter(W=>W.overflows[0]<=0).sort((W,U)=>W.overflows[1]-U.overflows[1])[0])==null?void 0:X.placement;if(!Ce)switch(m){case"bestFit":{var Z;const W=(Z=z.filter(U=>{if(D){const ne=xu(U.placement);return ne===b||ne==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(ne=>ne>0).reduce((ne,le)=>ne+le,0)]).sort((U,ne)=>U[1]-ne[1])[0])==null?void 0:Z[0];W&&(Ce=W);break}case"initialPlacement":Ce=s;break}if(i!==Ce)return{reset:{placement:Ce}}}return{}}}};function Q6(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function eS(e){return XX.some(t=>e[t]>=0)}const uZ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=As(e,t);switch(r){case"referenceHidden":{const o=await ih(t,{...i,elementContext:"reference"}),a=Q6(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:eS(a)}}}case"escaped":{const o=await ih(t,{...i,altBoundary:!0}),a=Q6(o,n.floating);return{data:{escapedOffsets:a,escaped:eS(a)}}}default:return{}}}}};async function lZ(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=ks(n),s=Sd(n),u=xu(n)==="y",d=["left","top"].includes(a)?-1:1,h=o&&u?-1:1,p=As(t,e);let{mainAxis:g,crossAxis:m,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return s&&typeof v=="number"&&(m=s==="end"?v*-1:v),u?{x:m*h,y:g*d}:{x:g*d,y:m*h}}const cZ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:s}=t,u=await lZ(t,e);return a===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:a}}}}},dZ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:w=>{let{x:C,y:b}=w;return{x:C,y:b}}},...u}=As(e,t),d={x:n,y:r},h=await ih(t,u),p=xu(ks(i)),g=UE(p);let m=d[g],v=d[p];if(o){const w=g==="y"?"top":"left",C=g==="y"?"bottom":"right",b=m+h[w],A=m-h[C];m=My(b,m,A)}if(a){const w=p==="y"?"top":"left",C=p==="y"?"bottom":"right",b=v+h[w],A=v-h[C];v=My(b,v,A)}const E=s.fn({...t,[g]:m,[p]:v});return{...E,data:{x:E.x-n,y:E.y-r}}}}},hZ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:a}=t,{offset:s=0,mainAxis:u=!0,crossAxis:d=!0}=As(e,t),h={x:n,y:r},p=xu(i),g=UE(p);let m=h[g],v=h[p];const E=As(s,t),w=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:0,crossAxis:0,...E};if(u){const A=g==="y"?"height":"width",T=o.reference[g]-o.floating[A]+w.mainAxis,B=o.reference[g]+o.reference[A]-w.mainAxis;mB&&(m=B)}if(d){var C,b;const A=g==="y"?"width":"height",T=["top","left"].includes(ks(i)),B=o.reference[p]-o.floating[A]+(T&&((C=a.offset)==null?void 0:C[p])||0)+(T?0:w.crossAxis),D=o.reference[p]+o.reference[A]+(T?0:((b=a.offset)==null?void 0:b[p])||0)-(T?w.crossAxis:0);vD&&(v=D)}return{[g]:m,[p]:v}}}},fZ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:a=()=>{},...s}=As(e,t),u=await ih(t,s),d=ks(n),h=Sd(n),p=xu(n)==="y",{width:g,height:m}=r.floating;let v,E;d==="top"||d==="bottom"?(v=d,E=h===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(E=d,v=h==="end"?"top":"bottom");const w=m-u.top-u.bottom,C=g-u.left-u.right,b=Do(m-u[v],w),A=Do(g-u[E],C),T=!t.middlewareData.shift;let B=b,D=A;if(p?D=h||T?Do(A,C):C:B=h||T?Do(b,w):w,T&&!h){const M=Mr(u.left,0),O=Mr(u.right,0),z=Mr(u.top,0),K=Mr(u.bottom,0);p?D=g-2*(M!==0||O!==0?M+O:Mr(u.left,u.right)):B=m-2*(z!==0||K!==0?z+K:Mr(u.top,u.bottom))}await a({...t,availableWidth:D,availableHeight:B});const I=await i.getDimensions(o.floating);return g!==I.width||m!==I.height?{reset:{rects:!0}}:{}}}};function xd(e){return EI(e)?(e.nodeName||"").toLowerCase():"#document"}function Hr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ms(e){var t;return(t=(EI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function EI(e){return e instanceof Node||e instanceof Hr(e).Node}function io(e){return e instanceof Element||e instanceof Hr(e).Element}function Uo(e){return e instanceof HTMLElement||e instanceof Hr(e).HTMLElement}function tS(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Hr(e).ShadowRoot}function Rh(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=oo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function pZ(e){return["table","td","th"].includes(xd(e))}function e1(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function GE(e){const t=JE(),n=io(e)?oo(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function gZ(e){let t=Au(e);for(;Uo(t)&&!ed(t);){if(GE(t))return t;if(e1(t))return null;t=Au(t)}return null}function JE(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ed(e){return["html","body","#document"].includes(xd(e))}function oo(e){return Hr(e).getComputedStyle(e)}function t1(e){return io(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Au(e){if(xd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||tS(e)&&e.host||Ms(e);return tS(t)?t.host:t}function CI(e){const t=Au(e);return ed(t)?e.ownerDocument?e.ownerDocument.body:e.body:Uo(t)&&Rh(t)?t:CI(t)}function oh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=CI(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=Hr(i);if(o){const s=Ry(a);return t.concat(a,a.visualViewport||[],Rh(i)?i:[],s&&n?oh(s):[])}return t.concat(i,oh(i,[],n))}function Ry(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bI(e){const t=oo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Uo(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,s=Bg(n)!==o||Bg(r)!==a;return s&&(n=o,r=a),{width:n,height:r,$:s}}function WE(e){return io(e)?e:e.contextElement}function _c(e){const t=WE(e);if(!Uo(t))return Su(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=bI(t);let a=(o?Bg(n.width):n.width)/r,s=(o?Bg(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const mZ=Su(0);function wI(e){const t=Hr(e);return!JE()||!t.visualViewport?mZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Hr(e)?!1:t}function xl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=WE(e);let a=Su(1);t&&(r?io(r)&&(a=_c(r)):a=_c(e));const s=vZ(o,n,r)?wI(o):Su(0);let u=(i.left+s.x)/a.x,d=(i.top+s.y)/a.y,h=i.width/a.x,p=i.height/a.y;if(o){const g=Hr(o),m=r&&io(r)?Hr(r):r;let v=g,E=Ry(v);for(;E&&r&&m!==v;){const w=_c(E),C=E.getBoundingClientRect(),b=oo(E),A=C.left+(E.clientLeft+parseFloat(b.paddingLeft))*w.x,T=C.top+(E.clientTop+parseFloat(b.paddingTop))*w.y;u*=w.x,d*=w.y,h*=w.x,p*=w.y,u+=A,d+=T,v=Hr(E),E=Ry(v)}}return $g({width:h,height:p,x:u,y:d})}function yZ(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Ms(r),s=t?e1(t.floating):!1;if(r===a||s&&o)return n;let u={scrollLeft:0,scrollTop:0},d=Su(1);const h=Su(0),p=Uo(r);if((p||!p&&!o)&&((xd(r)!=="body"||Rh(a))&&(u=t1(r)),Uo(r))){const g=xl(r);d=_c(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x,y:n.y*d.y-u.scrollTop*d.y+h.y}}function EZ(e){return Array.from(e.getClientRects())}function SI(e){return xl(Ms(e)).left+t1(e).scrollLeft}function CZ(e){const t=Ms(e),n=t1(e),r=e.ownerDocument.body,i=Mr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Mr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+SI(e);const s=-n.scrollTop;return oo(r).direction==="rtl"&&(a+=Mr(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:s}}function bZ(e,t){const n=Hr(e),r=Ms(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,s=0,u=0;if(i){o=i.width,a=i.height;const d=JE();(!d||d&&t==="fixed")&&(s=i.offsetLeft,u=i.offsetTop)}return{width:o,height:a,x:s,y:u}}function wZ(e,t){const n=xl(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Uo(e)?_c(e):Su(1),a=e.clientWidth*o.x,s=e.clientHeight*o.y,u=i*o.x,d=r*o.y;return{width:a,height:s,x:u,y:d}}function nS(e,t,n){let r;if(t==="viewport")r=bZ(e,n);else if(t==="document")r=CZ(Ms(e));else if(io(t))r=wZ(t,n);else{const i=wI(e);r={...t,x:t.x-i.x,y:t.y-i.y}}return $g(r)}function xI(e,t){const n=Au(e);return n===t||!io(n)||ed(n)?!1:oo(n).position==="fixed"||xI(n,t)}function SZ(e,t){const n=t.get(e);if(n)return n;let r=oh(e,[],!1).filter(s=>io(s)&&xd(s)!=="body"),i=null;const o=oo(e).position==="fixed";let a=o?Au(e):e;for(;io(a)&&!ed(a);){const s=oo(a),u=GE(a);!u&&s.position==="fixed"&&(i=null),(o?!u&&!i:!u&&s.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Rh(a)&&!u&&xI(e,a))?r=r.filter(h=>h!==a):i=s,a=Au(a)}return t.set(e,r),r}function xZ(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?e1(t)?[]:SZ(t,this._c):[].concat(n),r],s=a[0],u=a.reduce((d,h)=>{const p=nS(t,h,i);return d.top=Mr(p.top,d.top),d.right=Do(p.right,d.right),d.bottom=Do(p.bottom,d.bottom),d.left=Mr(p.left,d.left),d},nS(t,s,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function AZ(e){const{width:t,height:n}=bI(e);return{width:t,height:n}}function kZ(e,t,n){const r=Uo(t),i=Ms(t),o=n==="fixed",a=xl(e,!0,o,t);let s={scrollLeft:0,scrollTop:0};const u=Su(0);if(r||!r&&!o)if((xd(t)!=="body"||Rh(i))&&(s=t1(t)),r){const p=xl(t,!0,o,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}else i&&(u.x=SI(i));const d=a.left+s.scrollLeft-u.x,h=a.top+s.scrollTop-u.y;return{x:d,y:h,width:a.width,height:a.height}}function Rv(e){return oo(e).position==="static"}function rS(e,t){return!Uo(e)||oo(e).position==="fixed"?null:t?t(e):e.offsetParent}function AI(e,t){const n=Hr(e);if(e1(e))return n;if(!Uo(e)){let i=Au(e);for(;i&&!ed(i);){if(io(i)&&!Rv(i))return i;i=Au(i)}return n}let r=rS(e,t);for(;r&&pZ(r)&&Rv(r);)r=rS(r,t);return r&&ed(r)&&Rv(r)&&!GE(r)?n:r||gZ(e)||n}const IZ=async function(e){const t=this.getOffsetParent||AI,n=this.getDimensions,r=await n(e.floating);return{reference:kZ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DZ(e){return oo(e).direction==="rtl"}const TZ={convertOffsetParentRelativeRectToViewportRelativeRect:yZ,getDocumentElement:Ms,getClippingRect:xZ,getOffsetParent:AI,getElementRects:IZ,getClientRects:EZ,getDimensions:AZ,getScale:_c,isElement:io,isRTL:DZ};function PZ(e,t){let n=null,r;const i=Ms(e);function o(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function a(s,u){s===void 0&&(s=!1),u===void 0&&(u=1),o();const{left:d,top:h,width:p,height:g}=e.getBoundingClientRect();if(s||t(),!p||!g)return;const m=lp(h),v=lp(i.clientWidth-(d+p)),E=lp(i.clientHeight-(h+g)),w=lp(d),b={rootMargin:-m+"px "+-v+"px "+-E+"px "+-w+"px",threshold:Mr(0,Do(1,u))||1};let A=!0;function T(B){const D=B[0].intersectionRatio;if(D!==u){if(!A)return a();D?a(!1,D):r=setTimeout(()=>{a(!1,1e-7)},1e3)}A=!1}try{n=new IntersectionObserver(T,{...b,root:i.ownerDocument})}catch{n=new IntersectionObserver(T,b)}n.observe(e)}return a(!0),o}function BZ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=WE(e),h=i||o?[...d?oh(d):[],...oh(t)]:[];h.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),o&&C.addEventListener("resize",n)});const p=d&&s?PZ(d,n):null;let g=-1,m=null;a&&(m=new ResizeObserver(C=>{let[b]=C;b&&b.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var A;(A=m)==null||A.observe(t)})),n()}),d&&!u&&m.observe(d),m.observe(t));let v,E=u?xl(e):null;u&&w();function w(){const C=xl(e);E&&(C.x!==E.x||C.y!==E.y||C.width!==E.width||C.height!==E.height)&&n(),E=C,v=requestAnimationFrame(w)}return n(),()=>{var C;h.forEach(b=>{i&&b.removeEventListener("scroll",n),o&&b.removeEventListener("resize",n)}),p==null||p(),(C=m)==null||C.disconnect(),m=null,u&&cancelAnimationFrame(v)}}const MZ=cZ,$Z=dZ,RZ=sZ,FZ=fZ,LZ=uZ,iS=aZ,OZ=hZ,_Z=(e,t,n)=>{const r=new Map,i={platform:TZ,...n},o={...i.platform,_c:r};return oZ(e,t,{...i,platform:o})};var jp=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Rg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Rg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Rg(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function kI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oS(e,t){const n=kI(e);return Math.round(t*n)/n}function aS(e){const t=l.useRef(e);return jp(()=>{t.current=e}),t}function NZ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:s=!0,whileElementsMounted:u,open:d}=e,[h,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,m]=l.useState(r);Rg(g,r)||m(r);const[v,E]=l.useState(null),[w,C]=l.useState(null),b=l.useCallback(W=>{W!==D.current&&(D.current=W,E(W))},[]),A=l.useCallback(W=>{W!==I.current&&(I.current=W,C(W))},[]),T=o||v,B=a||w,D=l.useRef(null),I=l.useRef(null),M=l.useRef(h),O=u!=null,z=aS(u),K=aS(i),X=l.useCallback(()=>{if(!D.current||!I.current)return;const W={placement:t,strategy:n,middleware:g};K.current&&(W.platform=K.current),_Z(D.current,I.current,W).then(U=>{const ne={...U,isPositioned:!0};Z.current&&!Rg(M.current,ne)&&(M.current=ne,$u.flushSync(()=>{p(ne)}))})},[g,t,n,K]);jp(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,p(W=>({...W,isPositioned:!1})))},[d]);const Z=l.useRef(!1);jp(()=>(Z.current=!0,()=>{Z.current=!1}),[]),jp(()=>{if(T&&(D.current=T),B&&(I.current=B),T&&B){if(z.current)return z.current(T,B,X);X()}},[T,B,X,z,O]);const pe=l.useMemo(()=>({reference:D,floating:I,setReference:b,setFloating:A}),[b,A]),me=l.useMemo(()=>({reference:T,floating:B}),[T,B]),Ce=l.useMemo(()=>{const W={position:n,left:0,top:0};if(!me.floating)return W;const U=oS(me.floating,h.x),ne=oS(me.floating,h.y);return s?{...W,transform:"translate("+U+"px, "+ne+"px)",...kI(me.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:ne}},[n,s,me.floating,h.x,h.y]);return l.useMemo(()=>({...h,update:X,refs:pe,elements:me,floatingStyles:Ce}),[h,X,pe,me,Ce])}const zZ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?iS({element:r.current,padding:i}).fn(n):{}:r?iS({element:r,padding:i}).fn(n):{}}}},HZ=(e,t)=>({...MZ(e),options:[e,t]}),jZ=(e,t)=>({...$Z(e),options:[e,t]}),UZ=(e,t)=>({...OZ(e),options:[e,t]}),KZ=(e,t)=>({...RZ(e),options:[e,t]}),VZ=(e,t)=>({...FZ(e),options:[e,t]}),GZ=(e,t)=>({...LZ(e),options:[e,t]}),JZ=(e,t)=>({...zZ(e),options:[e,t]});var WZ="Arrow",II=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return ce.jsx(Yn.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:ce.jsx("polygon",{points:"0,0 30,0 15,10"})})});II.displayName=WZ;var YZ=II;function qZ(e){const[t,n]=l.useState(void 0);return Sl(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let a,s;if("borderBoxSize"in o){const u=o.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,s=d.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var YE="Popper",[DI,n1]=$h(YE),[XZ,TI]=DI(YE),PI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=l.useState(null);return ce.jsx(XZ,{scope:t,anchor:r,onAnchorChange:i,children:n})};PI.displayName=YE;var BI="PopperAnchor",MI=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=TI(BI,n),a=l.useRef(null),s=dr(t,a);return l.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||a.current)}),r?null:ce.jsx(Yn.div,{...i,ref:s})});MI.displayName=BI;var qE="PopperContent",[ZZ,QZ]=DI(qE),$I=l.forwardRef((e,t)=>{var At,dt,pn,Dn,On,_n;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:m="optimized",onPlaced:v,...E}=e,w=TI(qE,n),[C,b]=l.useState(null),A=dr(t,Tn=>b(Tn)),[T,B]=l.useState(null),D=qZ(T),I=(D==null?void 0:D.width)??0,M=(D==null?void 0:D.height)??0,O=r+(o!=="center"?"-"+o:""),z=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},K=Array.isArray(d)?d:[d],X=K.length>0,Z={padding:z,boundary:K.filter(tQ),altBoundary:X},{refs:pe,floatingStyles:me,placement:Ce,isPositioned:W,middlewareData:U}=NZ({strategy:"fixed",placement:O,whileElementsMounted:(...Tn)=>BZ(...Tn,{animationFrame:m==="always"}),elements:{reference:w.anchor},middleware:[HZ({mainAxis:i+M,alignmentAxis:a}),u&&jZ({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?UZ():void 0,...Z}),u&&KZ({...Z}),VZ({...Z,apply:({elements:Tn,rects:tn,availableWidth:Ri,availableHeight:zu})=>{const{width:Sn,height:ho}=tn.reference,Jo=Tn.floating.style;Jo.setProperty("--radix-popper-available-width",`${Ri}px`),Jo.setProperty("--radix-popper-available-height",`${zu}px`),Jo.setProperty("--radix-popper-anchor-width",`${Sn}px`),Jo.setProperty("--radix-popper-anchor-height",`${ho}px`)}}),T&&JZ({element:T,padding:s}),nQ({arrowWidth:I,arrowHeight:M}),g&&GZ({strategy:"referenceHidden",...Z})]}),[ne,le]=LI(Ce),Ae=wu(v);Sl(()=>{W&&(Ae==null||Ae())},[W,Ae]);const we=(At=U.arrow)==null?void 0:At.x,ft=(dt=U.arrow)==null?void 0:dt.y,Ze=((pn=U.arrow)==null?void 0:pn.centerOffset)!==0,[qe,Ge]=l.useState();return Sl(()=>{C&&Ge(window.getComputedStyle(C).zIndex)},[C]),ce.jsx("div",{ref:pe.setFloating,"data-radix-popper-content-wrapper":"",style:{...me,transform:W?me.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:qe,"--radix-popper-transform-origin":[(Dn=U.transformOrigin)==null?void 0:Dn.x,(On=U.transformOrigin)==null?void 0:On.y].join(" "),...((_n=U.hide)==null?void 0:_n.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:ce.jsx(ZZ,{scope:n,placedSide:ne,onArrowChange:B,arrowX:we,arrowY:ft,shouldHideArrow:Ze,children:ce.jsx(Yn.div,{"data-side":ne,"data-align":le,...E,ref:A,style:{...E.style,animation:W?void 0:"none"}})})})});$I.displayName=qE;var RI="PopperArrow",eQ={top:"bottom",right:"left",bottom:"top",left:"right"},FI=l.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=QZ(RI,r),a=eQ[o.placedSide];return ce.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:ce.jsx(YZ,{...i,ref:n,style:{...i.style,display:"block"}})})});FI.displayName=RI;function tQ(e){return e!==null}var nQ=e=>({name:"transformOrigin",options:e,fn(t){var w,C,b;const{placement:n,rects:r,middlewareData:i}=t,a=((w=i.arrow)==null?void 0:w.centerOffset)!==0,s=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,h]=LI(n),p={start:"0%",center:"50%",end:"100%"}[h],g=(((C=i.arrow)==null?void 0:C.x)??0)+s/2,m=(((b=i.arrow)==null?void 0:b.y)??0)+u/2;let v="",E="";return d==="bottom"?(v=a?p:`${g}px`,E=`${-u}px`):d==="top"?(v=a?p:`${g}px`,E=`${r.floating.height+u}px`):d==="right"?(v=`${-u}px`,E=a?p:`${m}px`):d==="left"&&(v=`${r.floating.width+u}px`,E=a?p:`${m}px`),{data:{x:v,y:E}}}});function LI(e){const[t,n="center"]=e.split("-");return[t,n]}var OI=PI,XE=MI,_I=$I,NI=FI,rQ="Portal",zI=l.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[i,o]=l.useState(!1);Sl(()=>o(!0),[]);const a=n||i&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return a?Q7.createPortal(ce.jsx(Yn.div,{...r,ref:t}),a):null});zI.displayName=rQ;function iQ(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Ad=e=>{const{present:t,children:n}=e,r=oQ(t),i=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),o=dr(r.ref,aQ(i));return typeof n=="function"||r.isPresent?l.cloneElement(i,{ref:o}):null};Ad.displayName="Presence";function oQ(e){const[t,n]=l.useState(),r=l.useRef({}),i=l.useRef(e),o=l.useRef("none"),a=e?"mounted":"unmounted",[s,u]=iQ(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=cp(r.current);o.current=s==="mounted"?d:"none"},[s]),Sl(()=>{const d=r.current,h=i.current;if(h!==e){const g=o.current,m=cp(d);e?u("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&g!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Sl(()=>{if(t){const d=p=>{const m=cp(r.current).includes(p.animationName);p.target===t&&m&&$u.flushSync(()=>u("ANIMATION_END"))},h=p=>{p.target===t&&(o.current=cp(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:l.useCallback(d=>{d&&(r.current=getComputedStyle(d)),n(d)},[])}}function cp(e){return(e==null?void 0:e.animationName)||"none"}function aQ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ZE({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=sQ({defaultProp:t,onChange:n}),o=e!==void 0,a=o?e:r,s=wu(n),u=l.useCallback(d=>{if(o){const p=typeof d=="function"?d(e):d;p!==e&&s(p)}else i(d)},[o,e,i,s]);return[a,u]}function sQ({defaultProp:e,onChange:t}){const n=l.useState(e),[r]=n,i=l.useRef(r),o=wu(t);return l.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}var uQ="VisuallyHidden",HI=l.forwardRef((e,t)=>ce.jsx(Yn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));HI.displayName=uQ;var lQ=HI,[r1,rGe]=$h("Tooltip",[n1]),i1=n1(),jI="TooltipProvider",cQ=700,Fy="tooltip.open",[dQ,QE]=r1(jI),UI=e=>{const{__scopeTooltip:t,delayDuration:n=cQ,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,[a,s]=l.useState(!0),u=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),ce.jsx(dQ,{scope:t,isOpenDelayed:a,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),s(!1)},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>s(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:l.useCallback(h=>{u.current=h},[]),disableHoverableContent:i,children:o})};UI.displayName=jI;var o1="Tooltip",[hQ,a1]=r1(o1),KI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i=!1,onOpenChange:o,disableHoverableContent:a,delayDuration:s}=e,u=QE(o1,e.__scopeTooltip),d=i1(t),[h,p]=l.useState(null),g=k0(),m=l.useRef(0),v=a??u.disableHoverableContent,E=s??u.delayDuration,w=l.useRef(!1),[C=!1,b]=ZE({prop:r,defaultProp:i,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(Fy))):u.onClose(),o==null||o(I)}}),A=l.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=l.useCallback(()=>{window.clearTimeout(m.current),w.current=!1,b(!0)},[b]),B=l.useCallback(()=>{window.clearTimeout(m.current),b(!1)},[b]),D=l.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,b(!0)},E)},[E,b]);return l.useEffect(()=>()=>window.clearTimeout(m.current),[]),ce.jsx(OI,{...d,children:ce.jsx(hQ,{scope:t,contentId:g,open:C,stateAttribute:A,trigger:h,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{u.isOpenDelayed?D():T()},[u.isOpenDelayed,D,T]),onTriggerLeave:l.useCallback(()=>{v?B():window.clearTimeout(m.current)},[B,v]),onOpen:T,onClose:B,disableHoverableContent:v,children:n})})};KI.displayName=o1;var Ly="TooltipTrigger",VI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=a1(Ly,n),o=QE(Ly,n),a=i1(n),s=l.useRef(null),u=dr(t,s,i.onTriggerChange),d=l.useRef(!1),h=l.useRef(!1),p=l.useCallback(()=>d.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),ce.jsx(XE,{asChild:!0,...a,children:ce.jsx(Yn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:hn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!h.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:hn(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:hn(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:hn(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:hn(e.onBlur,i.onClose),onClick:hn(e.onClick,i.onClose)})})});VI.displayName=Ly;var fQ="TooltipPortal",[iGe,pQ]=r1(fQ,{forceMount:void 0}),td="TooltipContent",GI=l.forwardRef((e,t)=>{const n=pQ(td,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,a=a1(td,e.__scopeTooltip);return ce.jsx(Ad,{present:r||a.open,children:a.disableHoverableContent?ce.jsx(JI,{side:i,...o,ref:t}):ce.jsx(gQ,{side:i,...o,ref:t})})}),gQ=l.forwardRef((e,t)=>{const n=a1(td,e.__scopeTooltip),r=QE(td,e.__scopeTooltip),i=l.useRef(null),o=dr(t,i),[a,s]=l.useState(null),{trigger:u,onClose:d}=n,h=i.current,{onPointerInTransitChange:p}=r,g=l.useCallback(()=>{s(null),p(!1)},[p]),m=l.useCallback((v,E)=>{const w=v.currentTarget,C={x:v.clientX,y:v.clientY},b=yQ(C,w.getBoundingClientRect()),A=EQ(C,b),T=CQ(E.getBoundingClientRect()),B=wQ([...A,...T]);s(B),p(!0)},[p]);return l.useEffect(()=>()=>g(),[g]),l.useEffect(()=>{if(u&&h){const v=w=>m(w,h),E=w=>m(w,u);return u.addEventListener("pointerleave",v),h.addEventListener("pointerleave",E),()=>{u.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",E)}}},[u,h,m,g]),l.useEffect(()=>{if(a){const v=E=>{const w=E.target,C={x:E.clientX,y:E.clientY},b=(u==null?void 0:u.contains(w))||(h==null?void 0:h.contains(w)),A=!bQ(C,a);b?g():A&&(g(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,h,a,d,g]),ce.jsx(JI,{...e,ref:o})}),[mQ,vQ]=r1(o1,{isInside:!1}),JI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:a,...s}=e,u=a1(td,n),d=i1(n),{onClose:h}=u;return l.useEffect(()=>(document.addEventListener(Fy,h),()=>document.removeEventListener(Fy,h)),[h]),l.useEffect(()=>{if(u.trigger){const p=g=>{const m=g.target;m!=null&&m.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),ce.jsx(Qm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:ce.jsxs(_I,{"data-state":u.stateAttribute,...d,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[ce.jsx(jE,{children:r}),ce.jsx(mQ,{scope:n,isInside:!0,children:ce.jsx(lQ,{id:u.contentId,role:"tooltip",children:i||r})})]})})});GI.displayName=td;var WI="TooltipArrow",YI=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=i1(n);return vQ(WI,n).isInside?null:ce.jsx(NI,{...i,...r,ref:t})});YI.displayName=WI;function yQ(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function EQ(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function CQ(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function bQ(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,a=t.length-1;or!=h>r&&n<(d-s)*(r-u)/(h-u)+s&&(i=!i)}return i}function wQ(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),SQ(t)}function SQ(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const o=t[t.length-1],a=t[t.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(i.y-a.y)>=(o.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xQ=UI,AQ=KI,kQ=VI,IQ=GI,DQ=YI,Fv=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Lv(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),function(){n(window.event)})}function qI(e,t){for(var n=t.slice(0,t.length-1),r=0;r=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function TQ(e,t){for(var n=e.length>=t.length?e:t,r=e.length>=t.length?t:e,i=!0,o=0;o=0&&Lt.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&Lt.splice(0,Lt.length),(t===93||t===224)&&(t=91),t in $n){$n[t]=!1;for(var r in ku)ku[r]===t&&(Lr[r]=!1)}}function FQ(e){if(typeof e>"u")Object.keys(dn).forEach(function(a){return delete dn[a]});else if(Array.isArray(e))e.forEach(function(a){a.key&&Ov(a)});else if(typeof e=="object")e.key&&Ov(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?qI(ku,d):[];dn[g]=dn[g].filter(function(v){var E=i?v.method===i:!0;return!(E&&v.scope===r&&TQ(v.mods,m))})}})};function uS(e,t,n,r){if(t.element===r){var i;if(t.scope===n||t.scope==="all"){i=t.mods.length>0;for(var o in $n)Object.prototype.hasOwnProperty.call($n,o)&&(!$n[o]&&t.mods.indexOf(+o)>-1||$n[o]&&t.mods.indexOf(+o)===-1)&&(i=!1);(t.mods.length===0&&!$n[16]&&!$n[18]&&!$n[17]&&!$n[91]||i||t.shortcut==="*")&&t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}}function lS(e,t){var n=dn["*"],r=e.keyCode||e.which||e.charCode;if(Lr.filter.call(this,e)){if((r===93||r===224)&&(r=91),Lt.indexOf(r)===-1&&r!==229&&Lt.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(v){var E=Oy[v];e[v]&&Lt.indexOf(E)===-1?Lt.push(E):!e[v]&&Lt.indexOf(E)>-1?Lt.splice(Lt.indexOf(E),1):v==="metaKey"&&e[v]&&Lt.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(Lt=Lt.slice(Lt.indexOf(E))))}),r in $n){$n[r]=!0;for(var i in ku)ku[i]===r&&(Lr[i]=!0);if(!n)return}for(var o in $n)Object.prototype.hasOwnProperty.call($n,o)&&($n[o]=e[Oy[o]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(Lt.indexOf(17)===-1&&Lt.push(17),Lt.indexOf(18)===-1&&Lt.push(18),$n[17]=!0,$n[18]=!0);var a=ah();if(n)for(var s=0;s-1}function Lr(e,t,n){Lt=[];var r=XI(e),i=[],o="all",a=document,s=0,u=!1,d=!0,h="+",p=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(o=t.scope),t.element&&(a=t.element),t.keyup&&(u=t.keyup),t.keydown!==void 0&&(d=t.keydown),t.capture!==void 0&&(p=t.capture),typeof t.splitKey=="string"&&(h=t.splitKey)),typeof t=="string"&&(o=t);s1&&(i=qI(ku,e)),e=e[e.length-1],e=e==="*"?"*":s1(e),e in dn||(dn[e]=[]),dn[e].push({keyup:u,keydown:d,scope:o,mods:i,shortcut:r[s],method:n,key:r[s],splitKey:h,element:a});typeof a<"u"&&!LQ(a)&&window&&(QI.push(a),Lv(a,"keydown",function(g){lS(g,a)},p),sS||(sS=!0,Lv(window,"focus",function(){Lt=[]},p)),Lv(a,"keyup",function(g){lS(g,a),RQ(g)},p))}function OQ(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(dn).forEach(function(n){var r=dn[n].find(function(i){return i.scope===t&&i.shortcut===e});r&&r.method&&r.method()})}var _v={setScope:eD,getScope:ah,deleteScope:$Q,getPressedKeyCodes:PQ,isPressed:MQ,filter:BQ,trigger:OQ,unbind:FQ,keyMap:eC,modifier:ku,modifierMap:Oy};for(var Nv in _v)Object.prototype.hasOwnProperty.call(_v,Nv)&&(Lr[Nv]=_v[Nv]);if(typeof window<"u"){var _Q=window.hotkeys;Lr.noConflict=function(e){return e&&window.hotkeys===Lr&&(window.hotkeys=_Q),Lr},window.hotkeys=Lr}Lr.filter=function(){return!0};var tD=function(t,n){var r=t.target,i=r&&r.tagName;return!!(i&&n&&n.includes(i))},NQ=function(t){return tD(t,["INPUT","TEXTAREA","SELECT"])};function Me(e,t,n,r){n instanceof Array&&(r=n,n=void 0);var i=n||{},o=i.enableOnTags,a=i.filter,s=i.keyup,u=i.keydown,d=i.filterPreventDefault,h=d===void 0?!0:d,p=i.enabled,g=p===void 0?!0:p,m=i.enableOnContentEditable,v=m===void 0?!1:m,E=l.useRef(null),w=l.useCallback(function(C,b){var A,T;return a&&!a(C)?!h:NQ(C)&&!tD(C,o)||(A=C.target)!=null&&A.isContentEditable&&!v?!0:E.current===null||document.activeElement===E.current||(T=E.current)!=null&&T.contains(document.activeElement)?(t(C,b),!0):!1},r?[E,o,a].concat(r):[E,o,a]);return l.useEffect(function(){if(!g){Lr.unbind(e,w);return}return s&&u!==!0&&(n.keydown=!1),Lr(e,n||{},w),function(){return Lr.unbind(e,w)}},[w,e,g]),E}Lr.isPressed;var zv="focusScope.autoFocusOnMount",Hv="focusScope.autoFocusOnUnmount",cS={bubbles:!1,cancelable:!0},zQ="FocusScope",tC=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...a}=e,[s,u]=l.useState(null),d=wu(i),h=wu(o),p=l.useRef(null),g=dr(t,E=>u(E)),m=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let E=function(A){if(m.paused||!s)return;const T=A.target;s.contains(T)?p.current=T:Ws(p.current,{select:!0})},w=function(A){if(m.paused||!s)return;const T=A.relatedTarget;T!==null&&(s.contains(T)||Ws(p.current,{select:!0}))},C=function(A){if(document.activeElement===document.body)for(const B of A)B.removedNodes.length>0&&Ws(s)};document.addEventListener("focusin",E),document.addEventListener("focusout",w);const b=new MutationObserver(C);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",w),b.disconnect()}}},[r,s,m.paused]),l.useEffect(()=>{if(s){hS.add(m);const E=document.activeElement;if(!s.contains(E)){const C=new CustomEvent(zv,cS);s.addEventListener(zv,d),s.dispatchEvent(C),C.defaultPrevented||(HQ(GQ(nD(s)),{select:!0}),document.activeElement===E&&Ws(s))}return()=>{s.removeEventListener(zv,d),setTimeout(()=>{const C=new CustomEvent(Hv,cS);s.addEventListener(Hv,h),s.dispatchEvent(C),C.defaultPrevented||Ws(E??document.body,{select:!0}),s.removeEventListener(Hv,h),hS.remove(m)},0)}}},[s,d,h,m]);const v=l.useCallback(E=>{if(!n&&!r||m.paused)return;const w=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,C=document.activeElement;if(w&&C){const b=E.currentTarget,[A,T]=jQ(b);A&&T?!E.shiftKey&&C===T?(E.preventDefault(),n&&Ws(A,{select:!0})):E.shiftKey&&C===A&&(E.preventDefault(),n&&Ws(T,{select:!0})):C===b&&E.preventDefault()}},[n,r,m.paused]);return ce.jsx(Yn.div,{tabIndex:-1,...a,ref:g,onKeyDown:v})});tC.displayName=zQ;function HQ(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ws(r,{select:t}),document.activeElement!==n)return}function jQ(e){const t=nD(e),n=dS(t,e),r=dS(t.reverse(),e);return[n,r]}function nD(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function dS(e,t){for(const n of e)if(!UQ(n,{upTo:t}))return n}function UQ(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function KQ(e){return e instanceof HTMLInputElement&&"select"in e}function Ws(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&KQ(e)&&t&&e.select()}}var hS=VQ();function VQ(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=fS(e,t),e.unshift(t)},remove(t){var n;e=fS(e,t),(n=e[0])==null||n.resume()}}}function fS(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function GQ(e){return e.filter(t=>t.tagName!=="A")}var jv=0;function rD(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pS()),document.body.insertAdjacentElement("beforeend",e[1]??pS()),jv++,()=>{jv===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),jv--}},[])}function pS(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var iD=vk(),Uv=function(){},u1=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Uv,onWheelCapture:Uv,onTouchMoveCapture:Uv}),i=r[0],o=r[1],a=e.forwardProps,s=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,g=e.sideCar,m=e.noIsolation,v=e.inert,E=e.allowPinchZoom,w=e.as,C=w===void 0?"div":w,b=e.gapMode,A=Ss(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=g,B=mk([n,t]),D=Ee(Ee({},A),i);return l.createElement(l.Fragment,null,h&&l.createElement(T,{sideCar:iD,removeScrollBar:d,shards:p,noIsolation:m,inert:v,setCallbacks:o,allowPinchZoom:!!E,lockRef:n,gapMode:b}),a?l.cloneElement(l.Children.only(s),Ee(Ee({},D),{ref:B})):l.createElement(C,Ee({},D,{className:u,ref:B}),s))});u1.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};u1.classNames={fullWidth:A0,zeroRight:x0};var _y=!1;if(typeof window<"u")try{var hp=Object.defineProperty({},"passive",{get:function(){return _y=!0,!0}});window.addEventListener("test",hp,hp),window.removeEventListener("test",hp,hp)}catch{_y=!1}var uc=_y?{passive:!1}:!1,JQ=function(e){return e.tagName==="TEXTAREA"},oD=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!JQ(e)&&n[t]==="visible")},WQ=function(e){return oD(e,"overflowY")},YQ=function(e){return oD(e,"overflowX")},gS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=aD(e,r);if(i){var o=sD(e,r),a=o[1],s=o[2];if(a>s)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qQ=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},XQ=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},aD=function(e,t){return e==="v"?WQ(t):YQ(t)},sD=function(e,t){return e==="v"?qQ(t):XQ(t)},ZQ=function(e,t){return e==="h"&&t==="rtl"?-1:1},QQ=function(e,t,n,r,i){var o=ZQ(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,u=t.contains(s),d=!1,h=a>0,p=0,g=0;do{var m=sD(e,s),v=m[0],E=m[1],w=m[2],C=E-w-o*v;(v||C)&&aD(e,s)&&(p+=C,g+=v),s instanceof ShadowRoot?s=s.host:s=s.parentNode}while(!u&&s!==document.body||u&&(t.contains(s)||t===s));return(h&&(Math.abs(p)<1||!i)||!h&&(Math.abs(g)<1||!i))&&(d=!0),d},fp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},mS=function(e){return[e.deltaX,e.deltaY]},vS=function(e){return e&&"current"in e?e.current:e},eee=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tee=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},nee=0,lc=[];function ree(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),i=l.useState(nee++)[0],o=l.useState(ME)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var E=ui([e.lockRef.current],(e.shards||[]).map(vS),!0).filter(Boolean);return E.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),E.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=l.useCallback(function(E,w){if("touches"in E&&E.touches.length===2)return!a.current.allowPinchZoom;var C=fp(E),b=n.current,A="deltaX"in E?E.deltaX:b[0]-C[0],T="deltaY"in E?E.deltaY:b[1]-C[1],B,D=E.target,I=Math.abs(A)>Math.abs(T)?"h":"v";if("touches"in E&&I==="h"&&D.type==="range")return!1;var M=gS(I,D);if(!M)return!0;if(M?B=I:(B=I==="v"?"h":"v",M=gS(I,D)),!M)return!1;if(!r.current&&"changedTouches"in E&&(A||T)&&(r.current=B),!B)return!0;var O=r.current||B;return QQ(O,w,E,O==="h"?A:T,!0)},[]),u=l.useCallback(function(E){var w=E;if(!(!lc.length||lc[lc.length-1]!==o)){var C="deltaY"in w?mS(w):fp(w),b=t.current.filter(function(B){return B.name===w.type&&(B.target===w.target||w.target===B.shadowParent)&&eee(B.delta,C)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var A=(a.current.shards||[]).map(vS).filter(Boolean).filter(function(B){return B.contains(w.target)}),T=A.length>0?s(w,A[0]):!a.current.noIsolation;T&&w.cancelable&&w.preventDefault()}}},[]),d=l.useCallback(function(E,w,C,b){var A={name:E,delta:w,target:C,should:b,shadowParent:iee(C)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(T){return T!==A})},1)},[]),h=l.useCallback(function(E){n.current=fp(E),r.current=void 0},[]),p=l.useCallback(function(E){d(E.type,mS(E),E.target,s(E,e.lockRef.current))},[]),g=l.useCallback(function(E){d(E.type,fp(E),E.target,s(E,e.lockRef.current))},[]);l.useEffect(function(){return lc.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",u,uc),document.addEventListener("touchmove",u,uc),document.addEventListener("touchstart",h,uc),function(){lc=lc.filter(function(E){return E!==o}),document.removeEventListener("wheel",u,uc),document.removeEventListener("touchmove",u,uc),document.removeEventListener("touchstart",h,uc)}},[]);var m=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(o,{styles:tee(i)}):null,m?l.createElement(bk,{gapMode:e.gapMode}):null)}function iee(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const oee=Ek(iD,ree);var tC=l.forwardRef(function(e,t){return l.createElement(u1,Ee({},e,{ref:t,sideCar:oee}))});tC.classNames=u1.classNames;var nC="Dialog",[uD,lD]=$h(nC),[aee,uo]=uD(nC),cD=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,s=l.useRef(null),u=l.useRef(null),[d=!1,h]=XE({prop:r,defaultProp:i,onChange:o});return ce.jsx(aee,{scope:t,triggerRef:s,contentRef:u,contentId:k0(),titleId:k0(),descriptionId:k0(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(p=>!p),[h]),modal:a,children:n})};cD.displayName=nC;var dD="DialogTrigger",hD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(dD,n),o=dr(t,i.triggerRef);return ce.jsx(Yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":oC(i.open),...r,ref:o,onClick:hn(e.onClick,i.onOpenToggle)})});hD.displayName=dD;var rC="DialogPortal",[see,fD]=uD(rC,{forceMount:void 0}),pD=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=uo(rC,t);return ce.jsx(see,{scope:t,forceMount:n,children:l.Children.map(r,a=>ce.jsx(Ad,{present:n||o.open,children:ce.jsx(zI,{asChild:!0,container:i,children:a})}))})};pD.displayName=rC;var Fg="DialogOverlay",gD=l.forwardRef((e,t)=>{const n=fD(Fg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=uo(Fg,e.__scopeDialog);return o.modal?ce.jsx(Ad,{present:r||o.open,children:ce.jsx(uee,{...i,ref:t})}):null});gD.displayName=Fg;var uee=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(Fg,n);return ce.jsx(tC,{as:Zm,allowPinchZoom:!0,shards:[i.contentRef],children:ce.jsx(Yn.div,{"data-state":oC(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Al="DialogContent",mD=l.forwardRef((e,t)=>{const n=fD(Al,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=uo(Al,e.__scopeDialog);return ce.jsx(Ad,{present:r||o.open,children:o.modal?ce.jsx(lee,{...i,ref:t}):ce.jsx(cee,{...i,ref:t})})});mD.displayName=Al;var lee=l.forwardRef((e,t)=>{const n=uo(Al,e.__scopeDialog),r=l.useRef(null),i=dr(t,n.contentRef,r);return l.useEffect(()=>{const o=r.current;if(o)return BE(o)},[]),ce.jsx(vD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hn(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:hn(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&o.preventDefault()}),onFocusOutside:hn(e.onFocusOutside,o=>o.preventDefault())})}),cee=l.forwardRef((e,t)=>{const n=uo(Al,e.__scopeDialog),r=l.useRef(!1),i=l.useRef(!1);return ce.jsx(vD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),vD=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...a}=e,s=uo(Al,n),u=l.useRef(null),d=dr(t,u);return rD(),ce.jsxs(ce.Fragment,{children:[ce.jsx(eC,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:ce.jsx(Qm,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":oC(s.open),...a,ref:d,onDismiss:()=>s.onOpenChange(!1)})}),ce.jsxs(ce.Fragment,{children:[ce.jsx(hee,{titleId:s.titleId}),ce.jsx(pee,{contentRef:u,descriptionId:s.descriptionId})]})]})}),iC="DialogTitle",yD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(iC,n);return ce.jsx(Yn.h2,{id:i.titleId,...r,ref:t})});yD.displayName=iC;var ED="DialogDescription",CD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(ED,n);return ce.jsx(Yn.p,{id:i.descriptionId,...r,ref:t})});CD.displayName=ED;var bD="DialogClose",wD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(bD,n);return ce.jsx(Yn.button,{type:"button",...r,ref:t,onClick:hn(e.onClick,()=>i.onOpenChange(!1))})});wD.displayName=bD;function oC(e){return e?"open":"closed"}var SD="DialogTitleWarning",[dee,xD]=RX(SD,{contentName:Al,titleName:iC,docsSlug:"dialog"}),hee=({titleId:e})=>{const t=xD(SD),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. +`)},nee=0,lc=[];function ree(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),i=l.useState(nee++)[0],o=l.useState($E)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var E=ui([e.lockRef.current],(e.shards||[]).map(vS),!0).filter(Boolean);return E.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),E.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var s=l.useCallback(function(E,w){if("touches"in E&&E.touches.length===2)return!a.current.allowPinchZoom;var C=fp(E),b=n.current,A="deltaX"in E?E.deltaX:b[0]-C[0],T="deltaY"in E?E.deltaY:b[1]-C[1],B,D=E.target,I=Math.abs(A)>Math.abs(T)?"h":"v";if("touches"in E&&I==="h"&&D.type==="range")return!1;var M=gS(I,D);if(!M)return!0;if(M?B=I:(B=I==="v"?"h":"v",M=gS(I,D)),!M)return!1;if(!r.current&&"changedTouches"in E&&(A||T)&&(r.current=B),!B)return!0;var O=r.current||B;return QQ(O,w,E,O==="h"?A:T,!0)},[]),u=l.useCallback(function(E){var w=E;if(!(!lc.length||lc[lc.length-1]!==o)){var C="deltaY"in w?mS(w):fp(w),b=t.current.filter(function(B){return B.name===w.type&&(B.target===w.target||w.target===B.shadowParent)&&eee(B.delta,C)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var A=(a.current.shards||[]).map(vS).filter(Boolean).filter(function(B){return B.contains(w.target)}),T=A.length>0?s(w,A[0]):!a.current.noIsolation;T&&w.cancelable&&w.preventDefault()}}},[]),d=l.useCallback(function(E,w,C,b){var A={name:E,delta:w,target:C,should:b,shadowParent:iee(C)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(T){return T!==A})},1)},[]),h=l.useCallback(function(E){n.current=fp(E),r.current=void 0},[]),p=l.useCallback(function(E){d(E.type,mS(E),E.target,s(E,e.lockRef.current))},[]),g=l.useCallback(function(E){d(E.type,fp(E),E.target,s(E,e.lockRef.current))},[]);l.useEffect(function(){return lc.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",u,uc),document.addEventListener("touchmove",u,uc),document.addEventListener("touchstart",h,uc),function(){lc=lc.filter(function(E){return E!==o}),document.removeEventListener("wheel",u,uc),document.removeEventListener("touchmove",u,uc),document.removeEventListener("touchstart",h,uc)}},[]);var m=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(o,{styles:tee(i)}):null,m?l.createElement(bk,{gapMode:e.gapMode}):null)}function iee(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const oee=Ek(iD,ree);var nC=l.forwardRef(function(e,t){return l.createElement(u1,Ee({},e,{ref:t,sideCar:oee}))});nC.classNames=u1.classNames;var rC="Dialog",[uD,lD]=$h(rC),[aee,uo]=uD(rC),cD=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!0}=e,s=l.useRef(null),u=l.useRef(null),[d=!1,h]=ZE({prop:r,defaultProp:i,onChange:o});return ce.jsx(aee,{scope:t,triggerRef:s,contentRef:u,contentId:k0(),titleId:k0(),descriptionId:k0(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(p=>!p),[h]),modal:a,children:n})};cD.displayName=rC;var dD="DialogTrigger",hD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(dD,n),o=dr(t,i.triggerRef);return ce.jsx(Yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":aC(i.open),...r,ref:o,onClick:hn(e.onClick,i.onOpenToggle)})});hD.displayName=dD;var iC="DialogPortal",[see,fD]=uD(iC,{forceMount:void 0}),pD=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=uo(iC,t);return ce.jsx(see,{scope:t,forceMount:n,children:l.Children.map(r,a=>ce.jsx(Ad,{present:n||o.open,children:ce.jsx(zI,{asChild:!0,container:i,children:a})}))})};pD.displayName=iC;var Fg="DialogOverlay",gD=l.forwardRef((e,t)=>{const n=fD(Fg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=uo(Fg,e.__scopeDialog);return o.modal?ce.jsx(Ad,{present:r||o.open,children:ce.jsx(uee,{...i,ref:t})}):null});gD.displayName=Fg;var uee=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(Fg,n);return ce.jsx(nC,{as:Zm,allowPinchZoom:!0,shards:[i.contentRef],children:ce.jsx(Yn.div,{"data-state":aC(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Al="DialogContent",mD=l.forwardRef((e,t)=>{const n=fD(Al,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=uo(Al,e.__scopeDialog);return ce.jsx(Ad,{present:r||o.open,children:o.modal?ce.jsx(lee,{...i,ref:t}):ce.jsx(cee,{...i,ref:t})})});mD.displayName=Al;var lee=l.forwardRef((e,t)=>{const n=uo(Al,e.__scopeDialog),r=l.useRef(null),i=dr(t,n.contentRef,r);return l.useEffect(()=>{const o=r.current;if(o)return ME(o)},[]),ce.jsx(vD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hn(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:hn(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&o.preventDefault()}),onFocusOutside:hn(e.onFocusOutside,o=>o.preventDefault())})}),cee=l.forwardRef((e,t)=>{const n=uo(Al,e.__scopeDialog),r=l.useRef(!1),i=l.useRef(!1);return ce.jsx(vD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),vD=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...a}=e,s=uo(Al,n),u=l.useRef(null),d=dr(t,u);return rD(),ce.jsxs(ce.Fragment,{children:[ce.jsx(tC,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:ce.jsx(Qm,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":aC(s.open),...a,ref:d,onDismiss:()=>s.onOpenChange(!1)})}),ce.jsxs(ce.Fragment,{children:[ce.jsx(hee,{titleId:s.titleId}),ce.jsx(pee,{contentRef:u,descriptionId:s.descriptionId})]})]})}),oC="DialogTitle",yD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(oC,n);return ce.jsx(Yn.h2,{id:i.titleId,...r,ref:t})});yD.displayName=oC;var ED="DialogDescription",CD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(ED,n);return ce.jsx(Yn.p,{id:i.descriptionId,...r,ref:t})});CD.displayName=ED;var bD="DialogClose",wD=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=uo(bD,n);return ce.jsx(Yn.button,{type:"button",...r,ref:t,onClick:hn(e.onClick,()=>i.onOpenChange(!1))})});wD.displayName=bD;function aC(e){return e?"open":"closed"}var SD="DialogTitleWarning",[dee,xD]=RX(SD,{contentName:Al,titleName:oC,docsSlug:"dialog"}),hee=({titleId:e})=>{const t=xD(SD),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. -For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},fee="DialogDescriptionWarning",pee=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xD(fee).contentName}}.`;return l.useEffect(()=>{var o;const i=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},AD=cD,kD=hD,ID=pD,DD=gD,TD=mD,PD=yD,gee=CD,aC=wD,BD="AlertDialog",[mee,oGe]=$h(BD,[lD]),$s=lD(),MD=e=>{const{__scopeAlertDialog:t,...n}=e,r=$s(t);return ce.jsx(AD,{...r,...n,modal:!0})};MD.displayName=BD;var vee="AlertDialogTrigger",$D=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(kD,{...i,...r,ref:t})});$D.displayName=vee;var yee="AlertDialogPortal",RD=e=>{const{__scopeAlertDialog:t,...n}=e,r=$s(t);return ce.jsx(ID,{...r,...n})};RD.displayName=yee;var Eee="AlertDialogOverlay",FD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(DD,{...i,...r,ref:t})});FD.displayName=Eee;var Nc="AlertDialogContent",[Cee,bee]=mee(Nc),LD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...i}=e,o=$s(n),a=l.useRef(null),s=dr(t,a),u=l.useRef(null);return ce.jsx(dee,{contentName:Nc,titleName:OD,docsSlug:"alert-dialog",children:ce.jsx(Cee,{scope:n,cancelRef:u,children:ce.jsxs(TD,{role:"alertdialog",...o,...i,ref:s,onOpenAutoFocus:hn(i.onOpenAutoFocus,d=>{var h;d.preventDefault(),(h=u.current)==null||h.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[ce.jsx(HE,{children:r}),ce.jsx(xee,{contentRef:a})]})})})});LD.displayName=Nc;var OD="AlertDialogTitle",wee=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(PD,{...i,...r,ref:t})});wee.displayName=OD;var _D="AlertDialogDescription",ND=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(gee,{...i,...r,ref:t})});ND.displayName=_D;var See="AlertDialogAction",zD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(aC,{...i,...r,ref:t})});zD.displayName=See;var HD="AlertDialogCancel",jD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=bee(HD,n),o=$s(n),a=dr(t,i);return ce.jsx(aC,{...o,...r,ref:a})});jD.displayName=HD;var xee=({contentRef:e})=>{const t=`\`${Nc}\` requires a description for the component to be accessible for screen reader users. +For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},fee="DialogDescriptionWarning",pee=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xD(fee).contentName}}.`;return l.useEffect(()=>{var o;const i=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},AD=cD,kD=hD,ID=pD,DD=gD,TD=mD,PD=yD,gee=CD,sC=wD,BD="AlertDialog",[mee,oGe]=$h(BD,[lD]),$s=lD(),MD=e=>{const{__scopeAlertDialog:t,...n}=e,r=$s(t);return ce.jsx(AD,{...r,...n,modal:!0})};MD.displayName=BD;var vee="AlertDialogTrigger",$D=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(kD,{...i,...r,ref:t})});$D.displayName=vee;var yee="AlertDialogPortal",RD=e=>{const{__scopeAlertDialog:t,...n}=e,r=$s(t);return ce.jsx(ID,{...r,...n})};RD.displayName=yee;var Eee="AlertDialogOverlay",FD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(DD,{...i,...r,ref:t})});FD.displayName=Eee;var Nc="AlertDialogContent",[Cee,bee]=mee(Nc),LD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...i}=e,o=$s(n),a=l.useRef(null),s=dr(t,a),u=l.useRef(null);return ce.jsx(dee,{contentName:Nc,titleName:OD,docsSlug:"alert-dialog",children:ce.jsx(Cee,{scope:n,cancelRef:u,children:ce.jsxs(TD,{role:"alertdialog",...o,...i,ref:s,onOpenAutoFocus:hn(i.onOpenAutoFocus,d=>{var h;d.preventDefault(),(h=u.current)==null||h.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[ce.jsx(jE,{children:r}),ce.jsx(xee,{contentRef:a})]})})})});LD.displayName=Nc;var OD="AlertDialogTitle",wee=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(PD,{...i,...r,ref:t})});wee.displayName=OD;var _D="AlertDialogDescription",ND=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(gee,{...i,...r,ref:t})});ND.displayName=_D;var See="AlertDialogAction",zD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,i=$s(n);return ce.jsx(sC,{...i,...r,ref:t})});zD.displayName=See;var HD="AlertDialogCancel",jD=l.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=bee(HD,n),o=$s(n),a=dr(t,i);return ce.jsx(sC,{...o,...r,ref:a})});jD.displayName=HD;var xee=({contentRef:e})=>{const t=`\`${Nc}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Nc}\` by passing a \`${_D}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Nc}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. -For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return l.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},sC=MD,Aee=$D,uC=RD,l1=FD,lC=LD,Lg=zD,UD=jD,kee=ND,cC="Popover",[KD,aGe]=$h(cC,[n1]),Fh=n1(),[Iee,Ll]=KD(cC),VD=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!1}=e,s=Fh(t),u=l.useRef(null),[d,h]=l.useState(!1),[p=!1,g]=XE({prop:r,defaultProp:i,onChange:o});return ce.jsx(OI,{...s,children:ce.jsx(Iee,{scope:t,contentId:k0(),triggerRef:u,open:p,onOpenChange:g,onOpenToggle:l.useCallback(()=>g(m=>!m),[g]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>h(!0),[]),onCustomAnchorRemove:l.useCallback(()=>h(!1),[]),modal:a,children:n})})};VD.displayName=cC;var GD="PopoverAnchor",JD=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(GD,n),o=Fh(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=i;return l.useEffect(()=>(a(),()=>s()),[a,s]),ce.jsx(qE,{...o,...r,ref:t})});JD.displayName=GD;var WD="PopoverTrigger",YD=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(WD,n),o=Fh(n),a=dr(t,i.triggerRef),s=ce.jsx(Yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":QD(i.open),...r,ref:a,onClick:hn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:ce.jsx(qE,{asChild:!0,...o,children:s})});YD.displayName=WD;var Dee="PopoverPortal",[sGe,Tee]=KD(Dee,{forceMount:void 0}),nd="PopoverContent",qD=l.forwardRef((e,t)=>{const n=Tee(nd,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=Ll(nd,e.__scopePopover);return ce.jsx(Ad,{present:r||o.open,children:o.modal?ce.jsx(Pee,{...i,ref:t}):ce.jsx(Bee,{...i,ref:t})})});qD.displayName=nd;var Pee=l.forwardRef((e,t)=>{const n=Ll(nd,e.__scopePopover),r=l.useRef(null),i=dr(t,r),o=l.useRef(!1);return l.useEffect(()=>{const a=r.current;if(a)return BE(a)},[]),ce.jsx(tC,{as:Zm,allowPinchZoom:!0,children:ce.jsx(XD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hn(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),o.current||(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:hn(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,u=s.button===0&&s.ctrlKey===!0,d=s.button===2||u;o.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:hn(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Bee=l.forwardRef((e,t)=>{const n=Ll(nd,e.__scopePopover),r=l.useRef(!1),i=l.useRef(!1);return ce.jsx(XD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),XD=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...p}=e,g=Ll(nd,n),m=Fh(n);return rD(),ce.jsx(eC,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:ce.jsx(Qm,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:s,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>g.onOpenChange(!1),children:ce.jsx(_I,{"data-state":QD(g.open),role:"dialog",id:g.contentId,...m,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ZD="PopoverClose",Mee=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(ZD,n);return ce.jsx(Yn.button,{type:"button",...r,ref:t,onClick:hn(e.onClick,()=>i.onOpenChange(!1))})});Mee.displayName=ZD;var $ee="PopoverArrow",Ree=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Fh(n);return ce.jsx(NI,{...i,...r,ref:t})});Ree.displayName=$ee;function QD(e){return e?"open":"closed"}var Fee=VD,Lee=JD,Oee=YD,_ee=qD;const kd=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{}catch{return!1}else if("showOpenFilePicker"in self)return"showOpenFilePicker";return!1})(),Nee=kd?Promise.resolve().then(function(){return Kee}):Promise.resolve().then(function(){return Jee});async function dC(...e){return(await Nee).default(...e)}const zee=kd?Promise.resolve().then(function(){return Vee}):Promise.resolve().then(function(){return Wee});async function Hee(...e){return(await zee).default(...e)}const jee=kd?Promise.resolve().then(function(){return Gee}):Promise.resolve().then(function(){return Yee});async function eT(...e){return(await jee).default(...e)}const Uee=async e=>{const t=await e.getFile();return t.handle=e,t};var tT=async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((i,o)=>{t[o]={description:i.description||"Files",accept:{}},i.mimeTypes?i.mimeTypes.map(a=>{t[o].accept[a]=i.extensions||[]}):t[o].accept["*/*"]=i.extensions||[]});const n=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=await Promise.all(n.map(Uee));return e[0].multiple?r:r[0]},Kee={__proto__:null,default:tT};function Up(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Up=function(n){this.s=n,this.n=n.next},Up.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(n){var r=this.s.return;return r===void 0?Promise.resolve({value:n,done:!0}):t(r.apply(this.s,arguments))},throw:function(n){var r=this.s.return;return r===void 0?Promise.reject(n):t(r.apply(this.s,arguments))}},new Up(e)}const nT=async(e,t,n=e.name,r)=>{const i=[],o=[];var a,s=!1,u=!1;try{for(var d,h=function(p){var g,m,v,E=2;for(typeof Symbol<"u"&&(m=Symbol.asyncIterator,v=Symbol.iterator);E--;){if(m&&(g=p[m])!=null)return g.call(p);if(v&&(g=p[v])!=null)return new Up(g.call(p));m="@@asyncIterator",v="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(d=await h.next()).done;s=!1){const p=d.value,g=`${n}/${p.name}`;p.kind==="file"?o.push(p.getFile().then(m=>(m.directoryHandle=e,m.handle=p,Object.defineProperty(m,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>g})))):p.kind!=="directory"||!t||r&&r(p)||i.push(nT(p,t,g,r))}}catch(p){u=!0,a=p}finally{try{s&&h.return!=null&&await h.return()}finally{if(u)throw a}}return[...(await Promise.all(i)).flat(),...await Promise.all(o)]};var rT=async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return nT(t,e.recursive,void 0,e.skipDirectory)},Vee={__proto__:null,default:rT},iT=async(e,t=[{}],n=null,r=!1,i=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const o=[];let a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach((d,h)=>{o[h]={description:d.description||"Files",accept:{}},d.mimeTypes?(h===0&&a&&d.mimeTypes.push(a),d.mimeTypes.map(p=>{o[h].accept[p]=d.extensions||[]})):a?o[h].accept[a]=d.extensions||[]:o[h].accept["*/*"]=d.extensions||[]}),n)try{await n.getFile()}catch(d){if(n=null,r)throw d}const s=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:o,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&i&&i(s);const u=await s.createWritable();return"stream"in e?(await e.stream().pipeTo(u),s):"body"in e?(await e.body.pipeTo(u),s):(await u.write(await e),await u.close(),s)},Gee={__proto__:null,default:iT},oT=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,n)=>{const r=document.createElement("input");r.type="file";const i=[...e.map(u=>u.mimeTypes||[]),...e.map(u=>u.extensions||[])].join();r.multiple=e[0].multiple||!1,r.accept=i||"",r.style.display="none",document.body.append(r);const o=u=>{typeof a=="function"&&a(),t(u)},a=e[0].legacySetup&&e[0].legacySetup(o,()=>a(n),r),s=()=>{window.removeEventListener("focus",s),r.remove()};r.addEventListener("click",()=>{window.addEventListener("focus",s)}),r.addEventListener("change",()=>{window.removeEventListener("focus",s),r.remove(),o(r.multiple?Array.from(r.files):r.files[0])}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Jee={__proto__:null,default:oT},aT=async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,n)=>{const r=document.createElement("input");r.type="file",r.webkitdirectory=!0;const i=a=>{typeof o=="function"&&o(),t(a)},o=e[0].legacySetup&&e[0].legacySetup(i,()=>o(n),r);r.addEventListener("change",()=>{let a=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(a=a.filter(s=>s.webkitRelativePath.split("/").every(u=>!e[0].skipDirectory({name:u,kind:"directory"})))):a=a.filter(s=>s.webkitRelativePath.split("/").length===2),i(a)}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Wee={__proto__:null,default:aT},sT=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const n=document.createElement("a");let r=e;"body"in e&&(r=await async function(a,s){const u=a.getReader(),d=new ReadableStream({start:g=>async function m(){return u.read().then(({done:v,value:E})=>{if(!v)return g.enqueue(E),m();g.close()})}()}),h=new Response(d),p=await h.blob();return u.releaseLock(),new Blob([p],{type:s})}(e.body,e.headers.get("content-type"))),n.download=t.fileName||"Untitled",n.href=URL.createObjectURL(await r);const i=()=>{typeof o=="function"&&o()},o=t.legacySetup&&t.legacySetup(i,()=>o(),n);return n.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null},Yee={__proto__:null,default:sT};const qee=Object.freeze(Object.defineProperty({__proto__:null,directoryOpen:Hee,directoryOpenLegacy:aT,directoryOpenModern:rT,fileOpen:dC,fileOpenLegacy:oT,fileOpenModern:tT,fileSave:eT,fileSaveLegacy:sT,fileSaveModern:iT,supported:kd},Symbol.toStringTag,{value:"Module"}));var Xee=Object.defineProperty,Zee=(e,t,n)=>t in e?Xee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(Zee(e,typeof t!="symbol"?t+"":t,n),n),Fe=class{static clamp(t,n,r){return Math.max(n,typeof r<"u"?Math.min(t,r):t)}static clampV(t,n,r){return t.map(i=>r?Fe.clamp(i,n,r):Fe.clamp(i,n))}static cross(t,n,r){return(n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1])}static snap(t,n=1){return[Math.round(t[0]/n)*n,Math.round(t[1]/n)*n]}},$=Fe;He($,"neg",e=>[-e[0],-e[1]]),He($,"add",(e,t)=>[e[0]+t[0],e[1]+t[1]]),He($,"addScalar",(e,t)=>[e[0]+t,e[1]+t]),He($,"sub",(e,t)=>[e[0]-t[0],e[1]-t[1]]),He($,"subScalar",(e,t)=>[e[0]-t,e[1]-t]),He($,"vec",(e,t)=>[t[0]-e[0],t[1]-e[1]]),He($,"mul",(e,t)=>[e[0]*t,e[1]*t]),He($,"mulV",(e,t)=>[e[0]*t[0],e[1]*t[1]]),He($,"div",(e,t)=>[e[0]/t,e[1]/t]),He($,"divV",(e,t)=>[e[0]/t[0],e[1]/t[1]]),He($,"per",e=>[e[1],-e[0]]),He($,"dpr",(e,t)=>e[0]*t[0]+e[1]*t[1]),He($,"cpr",(e,t)=>e[0]*t[1]-t[0]*e[1]),He($,"len2",e=>e[0]*e[0]+e[1]*e[1]),He($,"len",e=>Math.hypot(e[0],e[1])),He($,"pry",(e,t)=>Fe.dpr(e,t)/Fe.len(t)),He($,"uni",e=>Fe.div(e,Fe.len(e))),He($,"normalize",e=>Fe.uni(e)),He($,"tangent",(e,t)=>Fe.uni(Fe.sub(e,t))),He($,"dist2",(e,t)=>Fe.len2(Fe.sub(e,t))),He($,"dist",(e,t)=>Math.hypot(e[1]-t[1],e[0]-t[0])),He($,"fastDist",(e,t)=>{let n=[t[0]-e[0],t[1]-e[1]],r=[Math.abs(n[0]),Math.abs(n[1])],i=1/Math.max(r[0],r[1]);return i=i*(1.29289-(r[0]+r[1])*i*.29289),[n[0]*i,n[1]*i]}),He($,"ang",(e,t)=>Math.atan2(Fe.cpr(e,t),Fe.dpr(e,t))),He($,"angle",(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0])),He($,"med",(e,t)=>Fe.mul(Fe.add(e,t),.5)),He($,"rot",(e,t=0)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)]),He($,"rotWith",(e,t,n=0)=>{if(n===0)return e;let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}),He($,"isEqual",(e,t)=>e[0]===t[0]&&e[1]===t[1]),He($,"lrp",(e,t,n)=>Fe.add(e,Fe.mul(Fe.sub(t,e),n))),He($,"int",(e,t,n,r,i=1)=>{let o=(Fe.clamp(n,r)-n)/(r-n);return Fe.add(Fe.mul(e,1-o),Fe.mul(t,i))}),He($,"ang3",(e,t,n)=>{let r=Fe.vec(t,e),i=Fe.vec(t,n);return Fe.ang(r,i)}),He($,"abs",e=>[Math.abs(e[0]),Math.abs(e[1])]),He($,"rescale",(e,t)=>{let n=Fe.len(e);return[t*e[0]/n,t*e[1]/n]}),He($,"isLeft",(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])),He($,"clockwise",(e,t,n)=>Fe.isLeft(e,t,n)>0),He($,"toFixed",e=>e.map(t=>Math.round(t*100)/100)),He($,"nearestPointOnLineThroughPoint",(e,t,n)=>Fe.add(e,Fe.mul(t,Fe.pry(Fe.sub(n,e),t)))),He($,"distanceToLineThroughPoint",(e,t,n)=>Fe.dist(n,Fe.nearestPointOnLineThroughPoint(e,t,n))),He($,"nearestPointOnLineSegment",(e,t,n,r=!0)=>{let i=Fe.uni(Fe.sub(t,e)),o=Fe.add(e,Fe.mul(i,Fe.pry(Fe.sub(n,e),i)));if(r){if(o[0]Math.max(e[0],t[0]))return e[0]>t[0]?e:t;if(o[1]Math.max(e[1],t[1]))return e[1]>t[1]?e:t}return o}),He($,"distanceToLineSegment",(e,t,n,r=!0)=>Fe.dist(n,Fe.nearestPointOnLineSegment(e,t,n,r))),He($,"nearestPointOnBounds",(e,t)=>[Fe.clamp(t[0],e.minX,e.maxX),Fe.clamp(t[1],e.minY,e.maxY)]),He($,"distanceToBounds",(e,t)=>Fe.dist(t,Fe.nearestPointOnBounds(e,t))),He($,"nudge",(e,t,n)=>Fe.isEqual(e,t)?e:Fe.add(e,Fe.mul(Fe.uni(Fe.sub(t,e)),n))),He($,"nudgeAtAngle",(e,t,n)=>[Math.cos(t)*n+e[0],Math.sin(t)*n+e[1]]),He($,"toPrecision",(e,t=4)=>[+e[0].toPrecision(t),+e[1].toPrecision(t)]),He($,"pointsBetween",(e,t,n=6)=>Array.from(Array(n)).map((r,i)=>{let o=i/(n-1),a=Math.min(1,.5+Math.abs(.5-o));return[...Fe.lrp(e,t,o),a]})),He($,"slope",(e,t)=>e[0]===t[0]?NaN:(e[1]-t[1])/(e[0]-t[0])),He($,"max",(...e)=>[Math.max(...e.map(t=>t[0])),Math.max(...e.map(t=>t[1]))]),He($,"min",(...e)=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1]))]);var se=$,Qee=Object.defineProperty,ete=Object.defineProperties,tte=Object.getOwnPropertyDescriptors,yS=Object.getOwnPropertySymbols,nte=Object.prototype.hasOwnProperty,rte=Object.prototype.propertyIsEnumerable,ES=(e,t,n)=>t in e?Qee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hC=(e,t)=>{for(var n in t||(t={}))nte.call(t,n)&&ES(e,n,t[n]);if(yS)for(var n of yS(t))rte.call(t,n)&&ES(e,n,t[n]);return e},fC=(e,t)=>ete(e,tte(t));function Tt(e,...t){return{didIntersect:t.length>0,message:e,points:t}}function Ou(e,t,n=0){let r=[e[0]+t[0]/2,e[1]+t[1]/2],i=$.rotWith(e,r,n),o=$.rotWith($.add(e,[t[0],0]),r,n),a=$.rotWith($.add(e,t),r,n),s=$.rotWith($.add(e,[0,t[1]]),r,n);return[["top",[i,o]],["right",[o,a]],["bottom",[a,s]],["left",[s,i]]]}function ite(e,t,n){if(n===e||n===t)return!0;let r=Math.PI*2,i=(t-e+r)%r,o=(n-e+r)%r;return i<=Math.PI!=o>i}function ote(e,t){let n=$.slope(e[0],e[1]),r=$.slope(t[0],t[1]);if(n===r)return;if(Number.isNaN(n)&&!Number.isNaN(r))return[e[0][0],(e[0][0]-t[0][0])*r+t[0][1]];if(Number.isNaN(r)&&!Number.isNaN(n))return[t[0][0],(t[0][0]-e[0][0])*n+e[0][1]];let i=(n*e[0][0]-r*t[0][0]+t[0][1]-e[0][1])/(n-r),o=r*(i-t[0][0])+t[0][1];return[i,o]}function pC(e,t,n,r){let[i,o]=e,[a,s]=t,[u,d]=n,[h,p]=r;if(s/a!==(p-d)/(h-u)){let g=a*(p-d)-s*(h-u);if(g!==0){let m=((o-d)*(h-u)-(i-u)*(p-d))/g,v=((o-d)*a-(i-u)*s)/g;if(m>=0&&v>=0&&v<=1)return Tt("intersection",[i+m*a,o+m*s])}}return Tt("no intersection")}function ate(e,t,n,r,i=0){return cte(n,r,i,e,t)}function uT(e,t,n,r,i,o){let a=e,s=$.mul(t,999999999);return zc(a,s,n,r,i,o)}function Kp(e,t,n,r=0){let{minX:i,minY:o,width:a,height:s}=n;return ate(e,t,[i,o],[a,s],r)}function Lh(e,t,n,r){let i=$.sub(e,n),o=$.sub(r,n),a=$.sub(t,e),s=o[0]*i[1]-o[1]*i[0],u=a[0]*i[1]-a[1]*i[0],d=o[1]*a[0]-o[0]*a[1];if(s===0||u===0)return Tt("coincident");if(d===0)return Tt("parallel");if(d!==0){let h=s/d,p=u/d;if(0<=h&&h<=1&&0<=p&&p<=1)return Tt("intersection",$.add(e,$.mul(a,h)))}return Tt("no intersection")}function ste(e,t,n,r){return lT(n,r,e,t)}function ute(e,t,n,r,i,o){let a=$.angle(n,i),s=$.angle(n,o),u=wte(n,r,r,0,e,t);if(!u.didIntersect)return Tt("no intersection");let d=u.points.filter(h=>ite(a,s,$.angle(n,h)));return d.length===0?Tt("no intersection"):Tt("intersection",...d)}function gC(e,t,n,r){let i=(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]),o=2*((t[0]-e[0])*(e[0]-n[0])+(t[1]-e[1])*(e[1]-n[1])),a=n[0]*n[0]+n[1]*n[1]+e[0]*e[0]+e[1]*e[1]-2*(n[0]*e[0]+n[1]*e[1])-r*r,s=o*o-4*i*a;if(s<0)return Tt("outside");if(s===0)return Tt("tangent");let u=Math.sqrt(s),d=(-o+u)/(2*i),h=(-o-u)/(2*i);if((d<0||d>1)&&(h<0||h>1))return d<0&&h<0||d>1&&h>1?Tt("outside"):Tt("inside");let p=[];return 0<=d&&d<=1&&p.push($.lrp(e,t,d)),0<=h&&h<=1&&p.push($.lrp(e,t,h)),Tt("intersection",...p)}function zc(e,t,n,r,i,o=0){if(r===0||i===0||$.isEqual(e,t))return Tt("no intersection");r=r<0?r:-r,i=i<0?i:-i,e=$.sub($.rotWith(e,n,-o),n),t=$.sub($.rotWith(t,n,-o),n);let a=$.sub(t,e),s=a[0]*a[0]/r/r+a[1]*a[1]/i/i,u=2*e[0]*a[0]/r/r+2*e[1]*a[1]/i/i,d=e[0]*e[0]/r/r+e[1]*e[1]/i/i-1,h=[],p=u*u-4*s*d;if(p===0)h.push(-u/2/s);else if(p>0){let m=Math.sqrt(p);h.push((-u+m)/2/s),h.push((-u-m)/2/s)}let g=h.filter(m=>m>=0&&m<=1).map(m=>$.add(n,$.add(e,$.mul($.sub(t,e),m)))).map(m=>$.rotWith(m,n,o));return Tt("intersection",...g)}function mC(e,t,n){return Ate(n,e,t)}function vC(e,t,n){let r=[];for(let i=1;i{let d=pC(r,i,s,u);return d&&o.push(Tt(a,...d.points)),o},[]).filter(o=>o.didIntersect)}function lT(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=Lh(n,r,a,s);return u&&i.push(Tt(o,...u.points)),i},[]).filter(i=>i.didIntersect)}function dte(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=lT(n,r,a,s);return i.push(...u.map(d=>Tt(`${o} ${d.message}`,...d.points))),i},[]).filter(i=>i.didIntersect)}function hte(e,t,n,r,i,o){return Ou(e,t).reduce((a,[s,[u,d]])=>{let h=vte(n,r,i,o,u,d);return h&&a.push(fC(hC({},h),{message:s})),a},[]).filter(a=>a.didIntersect)}function fte(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=gC(a,s,n,r);return u&&i.push(fC(hC({},u),{message:o})),i},[]).filter(i=>i.didIntersect)}function pte(e,t,n,r,i,o=0){return Ou(e,t).reduce((a,[s,[u,d]])=>{let h=zc(u,d,n,r,i,o);return h&&a.push(fC(hC({},h),{message:s})),a},[]).filter(a=>a.didIntersect)}function gte(e,t,n){return Ou(e,t).reduce((r,[i,[o,a]])=>{let s=vC(o,a,n);return s.didIntersect&&r.push(Tt(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function mte(e,t,n){return Ou(e,t).reduce((r,[i,[o,a]])=>{let s=lte(o,a,n);return s.didIntersect&&r.push(Tt(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function vte(e,t,n,r,i,o){return ute(i,o,e,t,n,r)}function yte(e,t,n,r,i,o){return hte(i,o,e,t,n,r)}function Ete(e,t,n,r,i){let{minX:o,minY:a,width:s,height:u}=i;return yte(e,t,n,r,[o,a],[s,u])}function Cte(e,t,n,r){return gC(n,r,e,t)}function bte(e,t,n,r){let i=n[0]-e[0],o=n[1]-e[1],a=Math.sqrt(i*i+o*o),s=(a*a-r*r+t*t)/(2*a),u=Math.sqrt(t*t-s*s);return i/=a,o/=a,Tt("intersection",[e[0]+i*s-o*u,e[1]+o*s+i*u],[e[0]+i*s+o*u,e[1]+o*s-i*u])}function wte(e,t,n,r=0,i,o){return t===n?gC(i,o,e,t):zc(i,o,e,t,n,r)}function Ste(e,t,n,r=0,i,o){return t===n?fte(i,o,e,t):pte(i,o,e,t,n,r)}function xte(e,t,n,r,i){let{minX:o,minY:a,width:s,height:u}=i;return Ste(e,t,n,r,[o,a],[s,u])}function Ate(e,t,n){let{minX:r,minY:i,width:o,height:a}=e;return ste(t,n,[r,i],[o,a])}function kte(e,t){return dte([e.minX,e.minY],[e.width,e.height],[t.minX,t.minY],[t.width,t.height])}function CS(e,t){return Dte(t,e)}function Ite(e,t){return Tte(t,e)}function Dte(e,t){return gte([t.minX,t.minY],[t.width,t.height],e)}function Tte(e,t){return mte([t.minX,t.minY],[t.width,t.height],e)}function yC(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Pte(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=yC(n);return(i,o)=>r.then(a=>o(a.transaction(t,i).objectStore(t)))}let Uv;function cT(){return Uv||(Uv=Pte("keyval-store","keyval")),Uv}function Og(e,t=cT()){return t("readonly",n=>yC(n.get(e)))}function I0(e,t,n=cT()){return n("readwrite",r=>(r.put(t,e),yC(r.transaction)))}var dT={BASE_URL:"./",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_YORKIE_API_ADDR:"https://api.yorkie.dev",VITE_YORKIE_API_KEY:"cedaovjuioqlk4pjqn6g"};const bS=e=>{let t;const n=new Set,r=(h,p)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const m=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(v=>v(t,m))}},i=()=>t,u={setState:r,getState:i,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(dT?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,i,u);return u},hT=e=>e?bS(e):bS;var Bte=e=>((dT?"production":void 0)!=="production"&&console.warn("[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'."),hT(e)),fT={exports:{}},pT={},gT={exports:{}},mT={};/** +For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return l.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},uC=MD,Aee=$D,lC=RD,l1=FD,cC=LD,Lg=zD,UD=jD,kee=ND,dC="Popover",[KD,aGe]=$h(dC,[n1]),Fh=n1(),[Iee,Ll]=KD(dC),VD=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:a=!1}=e,s=Fh(t),u=l.useRef(null),[d,h]=l.useState(!1),[p=!1,g]=ZE({prop:r,defaultProp:i,onChange:o});return ce.jsx(OI,{...s,children:ce.jsx(Iee,{scope:t,contentId:k0(),triggerRef:u,open:p,onOpenChange:g,onOpenToggle:l.useCallback(()=>g(m=>!m),[g]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>h(!0),[]),onCustomAnchorRemove:l.useCallback(()=>h(!1),[]),modal:a,children:n})})};VD.displayName=dC;var GD="PopoverAnchor",JD=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(GD,n),o=Fh(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=i;return l.useEffect(()=>(a(),()=>s()),[a,s]),ce.jsx(XE,{...o,...r,ref:t})});JD.displayName=GD;var WD="PopoverTrigger",YD=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(WD,n),o=Fh(n),a=dr(t,i.triggerRef),s=ce.jsx(Yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":QD(i.open),...r,ref:a,onClick:hn(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:ce.jsx(XE,{asChild:!0,...o,children:s})});YD.displayName=WD;var Dee="PopoverPortal",[sGe,Tee]=KD(Dee,{forceMount:void 0}),nd="PopoverContent",qD=l.forwardRef((e,t)=>{const n=Tee(nd,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=Ll(nd,e.__scopePopover);return ce.jsx(Ad,{present:r||o.open,children:o.modal?ce.jsx(Pee,{...i,ref:t}):ce.jsx(Bee,{...i,ref:t})})});qD.displayName=nd;var Pee=l.forwardRef((e,t)=>{const n=Ll(nd,e.__scopePopover),r=l.useRef(null),i=dr(t,r),o=l.useRef(!1);return l.useEffect(()=>{const a=r.current;if(a)return ME(a)},[]),ce.jsx(nC,{as:Zm,allowPinchZoom:!0,children:ce.jsx(XD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hn(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),o.current||(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:hn(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,u=s.button===0&&s.ctrlKey===!0,d=s.button===2||u;o.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:hn(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Bee=l.forwardRef((e,t)=>{const n=Ll(nd,e.__scopePopover),r=l.useRef(!1),i=l.useRef(!1);return ce.jsx(XD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=o.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),XD=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...p}=e,g=Ll(nd,n),m=Fh(n);return rD(),ce.jsx(tC,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:ce.jsx(Qm,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:s,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>g.onOpenChange(!1),children:ce.jsx(_I,{"data-state":QD(g.open),role:"dialog",id:g.contentId,...m,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ZD="PopoverClose",Mee=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(ZD,n);return ce.jsx(Yn.button,{type:"button",...r,ref:t,onClick:hn(e.onClick,()=>i.onOpenChange(!1))})});Mee.displayName=ZD;var $ee="PopoverArrow",Ree=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Fh(n);return ce.jsx(NI,{...i,...r,ref:t})});Ree.displayName=$ee;function QD(e){return e?"open":"closed"}var Fee=VD,Lee=JD,Oee=YD,_ee=qD;const kd=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{}catch{return!1}else if("showOpenFilePicker"in self)return"showOpenFilePicker";return!1})(),Nee=kd?Promise.resolve().then(function(){return Kee}):Promise.resolve().then(function(){return Jee});async function hC(...e){return(await Nee).default(...e)}const zee=kd?Promise.resolve().then(function(){return Vee}):Promise.resolve().then(function(){return Wee});async function Hee(...e){return(await zee).default(...e)}const jee=kd?Promise.resolve().then(function(){return Gee}):Promise.resolve().then(function(){return Yee});async function eT(...e){return(await jee).default(...e)}const Uee=async e=>{const t=await e.getFile();return t.handle=e,t};var tT=async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((i,o)=>{t[o]={description:i.description||"Files",accept:{}},i.mimeTypes?i.mimeTypes.map(a=>{t[o].accept[a]=i.extensions||[]}):t[o].accept["*/*"]=i.extensions||[]});const n=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=await Promise.all(n.map(Uee));return e[0].multiple?r:r[0]},Kee={__proto__:null,default:tT};function Up(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Up=function(n){this.s=n,this.n=n.next},Up.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(n){var r=this.s.return;return r===void 0?Promise.resolve({value:n,done:!0}):t(r.apply(this.s,arguments))},throw:function(n){var r=this.s.return;return r===void 0?Promise.reject(n):t(r.apply(this.s,arguments))}},new Up(e)}const nT=async(e,t,n=e.name,r)=>{const i=[],o=[];var a,s=!1,u=!1;try{for(var d,h=function(p){var g,m,v,E=2;for(typeof Symbol<"u"&&(m=Symbol.asyncIterator,v=Symbol.iterator);E--;){if(m&&(g=p[m])!=null)return g.call(p);if(v&&(g=p[v])!=null)return new Up(g.call(p));m="@@asyncIterator",v="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(d=await h.next()).done;s=!1){const p=d.value,g=`${n}/${p.name}`;p.kind==="file"?o.push(p.getFile().then(m=>(m.directoryHandle=e,m.handle=p,Object.defineProperty(m,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>g})))):p.kind!=="directory"||!t||r&&r(p)||i.push(nT(p,t,g,r))}}catch(p){u=!0,a=p}finally{try{s&&h.return!=null&&await h.return()}finally{if(u)throw a}}return[...(await Promise.all(i)).flat(),...await Promise.all(o)]};var rT=async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return nT(t,e.recursive,void 0,e.skipDirectory)},Vee={__proto__:null,default:rT},iT=async(e,t=[{}],n=null,r=!1,i=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const o=[];let a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach((d,h)=>{o[h]={description:d.description||"Files",accept:{}},d.mimeTypes?(h===0&&a&&d.mimeTypes.push(a),d.mimeTypes.map(p=>{o[h].accept[p]=d.extensions||[]})):a?o[h].accept[a]=d.extensions||[]:o[h].accept["*/*"]=d.extensions||[]}),n)try{await n.getFile()}catch(d){if(n=null,r)throw d}const s=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:o,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&i&&i(s);const u=await s.createWritable();return"stream"in e?(await e.stream().pipeTo(u),s):"body"in e?(await e.body.pipeTo(u),s):(await u.write(await e),await u.close(),s)},Gee={__proto__:null,default:iT},oT=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,n)=>{const r=document.createElement("input");r.type="file";const i=[...e.map(u=>u.mimeTypes||[]),...e.map(u=>u.extensions||[])].join();r.multiple=e[0].multiple||!1,r.accept=i||"",r.style.display="none",document.body.append(r);const o=u=>{typeof a=="function"&&a(),t(u)},a=e[0].legacySetup&&e[0].legacySetup(o,()=>a(n),r),s=()=>{window.removeEventListener("focus",s),r.remove()};r.addEventListener("click",()=>{window.addEventListener("focus",s)}),r.addEventListener("change",()=>{window.removeEventListener("focus",s),r.remove(),o(r.multiple?Array.from(r.files):r.files[0])}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Jee={__proto__:null,default:oT},aT=async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,n)=>{const r=document.createElement("input");r.type="file",r.webkitdirectory=!0;const i=a=>{typeof o=="function"&&o(),t(a)},o=e[0].legacySetup&&e[0].legacySetup(i,()=>o(n),r);r.addEventListener("change",()=>{let a=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(a=a.filter(s=>s.webkitRelativePath.split("/").every(u=>!e[0].skipDirectory({name:u,kind:"directory"})))):a=a.filter(s=>s.webkitRelativePath.split("/").length===2),i(a)}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Wee={__proto__:null,default:aT},sT=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const n=document.createElement("a");let r=e;"body"in e&&(r=await async function(a,s){const u=a.getReader(),d=new ReadableStream({start:g=>async function m(){return u.read().then(({done:v,value:E})=>{if(!v)return g.enqueue(E),m();g.close()})}()}),h=new Response(d),p=await h.blob();return u.releaseLock(),new Blob([p],{type:s})}(e.body,e.headers.get("content-type"))),n.download=t.fileName||"Untitled",n.href=URL.createObjectURL(await r);const i=()=>{typeof o=="function"&&o()},o=t.legacySetup&&t.legacySetup(i,()=>o(),n);return n.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null},Yee={__proto__:null,default:sT};const qee=Object.freeze(Object.defineProperty({__proto__:null,directoryOpen:Hee,directoryOpenLegacy:aT,directoryOpenModern:rT,fileOpen:hC,fileOpenLegacy:oT,fileOpenModern:tT,fileSave:eT,fileSaveLegacy:sT,fileSaveModern:iT,supported:kd},Symbol.toStringTag,{value:"Module"}));var Xee=Object.defineProperty,Zee=(e,t,n)=>t in e?Xee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t,n)=>(Zee(e,typeof t!="symbol"?t+"":t,n),n),Fe=class{static clamp(t,n,r){return Math.max(n,typeof r<"u"?Math.min(t,r):t)}static clampV(t,n,r){return t.map(i=>r?Fe.clamp(i,n,r):Fe.clamp(i,n))}static cross(t,n,r){return(n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1])}static snap(t,n=1){return[Math.round(t[0]/n)*n,Math.round(t[1]/n)*n]}},$=Fe;He($,"neg",e=>[-e[0],-e[1]]),He($,"add",(e,t)=>[e[0]+t[0],e[1]+t[1]]),He($,"addScalar",(e,t)=>[e[0]+t,e[1]+t]),He($,"sub",(e,t)=>[e[0]-t[0],e[1]-t[1]]),He($,"subScalar",(e,t)=>[e[0]-t,e[1]-t]),He($,"vec",(e,t)=>[t[0]-e[0],t[1]-e[1]]),He($,"mul",(e,t)=>[e[0]*t,e[1]*t]),He($,"mulV",(e,t)=>[e[0]*t[0],e[1]*t[1]]),He($,"div",(e,t)=>[e[0]/t,e[1]/t]),He($,"divV",(e,t)=>[e[0]/t[0],e[1]/t[1]]),He($,"per",e=>[e[1],-e[0]]),He($,"dpr",(e,t)=>e[0]*t[0]+e[1]*t[1]),He($,"cpr",(e,t)=>e[0]*t[1]-t[0]*e[1]),He($,"len2",e=>e[0]*e[0]+e[1]*e[1]),He($,"len",e=>Math.hypot(e[0],e[1])),He($,"pry",(e,t)=>Fe.dpr(e,t)/Fe.len(t)),He($,"uni",e=>Fe.div(e,Fe.len(e))),He($,"normalize",e=>Fe.uni(e)),He($,"tangent",(e,t)=>Fe.uni(Fe.sub(e,t))),He($,"dist2",(e,t)=>Fe.len2(Fe.sub(e,t))),He($,"dist",(e,t)=>Math.hypot(e[1]-t[1],e[0]-t[0])),He($,"fastDist",(e,t)=>{let n=[t[0]-e[0],t[1]-e[1]],r=[Math.abs(n[0]),Math.abs(n[1])],i=1/Math.max(r[0],r[1]);return i=i*(1.29289-(r[0]+r[1])*i*.29289),[n[0]*i,n[1]*i]}),He($,"ang",(e,t)=>Math.atan2(Fe.cpr(e,t),Fe.dpr(e,t))),He($,"angle",(e,t)=>Math.atan2(t[1]-e[1],t[0]-e[0])),He($,"med",(e,t)=>Fe.mul(Fe.add(e,t),.5)),He($,"rot",(e,t=0)=>[e[0]*Math.cos(t)-e[1]*Math.sin(t),e[0]*Math.sin(t)+e[1]*Math.cos(t)]),He($,"rotWith",(e,t,n=0)=>{if(n===0)return e;let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,u=o*r+a*i;return[s+t[0],u+t[1]]}),He($,"isEqual",(e,t)=>e[0]===t[0]&&e[1]===t[1]),He($,"lrp",(e,t,n)=>Fe.add(e,Fe.mul(Fe.sub(t,e),n))),He($,"int",(e,t,n,r,i=1)=>{let o=(Fe.clamp(n,r)-n)/(r-n);return Fe.add(Fe.mul(e,1-o),Fe.mul(t,i))}),He($,"ang3",(e,t,n)=>{let r=Fe.vec(t,e),i=Fe.vec(t,n);return Fe.ang(r,i)}),He($,"abs",e=>[Math.abs(e[0]),Math.abs(e[1])]),He($,"rescale",(e,t)=>{let n=Fe.len(e);return[t*e[0]/n,t*e[1]/n]}),He($,"isLeft",(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])),He($,"clockwise",(e,t,n)=>Fe.isLeft(e,t,n)>0),He($,"toFixed",e=>e.map(t=>Math.round(t*100)/100)),He($,"nearestPointOnLineThroughPoint",(e,t,n)=>Fe.add(e,Fe.mul(t,Fe.pry(Fe.sub(n,e),t)))),He($,"distanceToLineThroughPoint",(e,t,n)=>Fe.dist(n,Fe.nearestPointOnLineThroughPoint(e,t,n))),He($,"nearestPointOnLineSegment",(e,t,n,r=!0)=>{let i=Fe.uni(Fe.sub(t,e)),o=Fe.add(e,Fe.mul(i,Fe.pry(Fe.sub(n,e),i)));if(r){if(o[0]Math.max(e[0],t[0]))return e[0]>t[0]?e:t;if(o[1]Math.max(e[1],t[1]))return e[1]>t[1]?e:t}return o}),He($,"distanceToLineSegment",(e,t,n,r=!0)=>Fe.dist(n,Fe.nearestPointOnLineSegment(e,t,n,r))),He($,"nearestPointOnBounds",(e,t)=>[Fe.clamp(t[0],e.minX,e.maxX),Fe.clamp(t[1],e.minY,e.maxY)]),He($,"distanceToBounds",(e,t)=>Fe.dist(t,Fe.nearestPointOnBounds(e,t))),He($,"nudge",(e,t,n)=>Fe.isEqual(e,t)?e:Fe.add(e,Fe.mul(Fe.uni(Fe.sub(t,e)),n))),He($,"nudgeAtAngle",(e,t,n)=>[Math.cos(t)*n+e[0],Math.sin(t)*n+e[1]]),He($,"toPrecision",(e,t=4)=>[+e[0].toPrecision(t),+e[1].toPrecision(t)]),He($,"pointsBetween",(e,t,n=6)=>Array.from(Array(n)).map((r,i)=>{let o=i/(n-1),a=Math.min(1,.5+Math.abs(.5-o));return[...Fe.lrp(e,t,o),a]})),He($,"slope",(e,t)=>e[0]===t[0]?NaN:(e[1]-t[1])/(e[0]-t[0])),He($,"max",(...e)=>[Math.max(...e.map(t=>t[0])),Math.max(...e.map(t=>t[1]))]),He($,"min",(...e)=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1]))]);var se=$,Qee=Object.defineProperty,ete=Object.defineProperties,tte=Object.getOwnPropertyDescriptors,yS=Object.getOwnPropertySymbols,nte=Object.prototype.hasOwnProperty,rte=Object.prototype.propertyIsEnumerable,ES=(e,t,n)=>t in e?Qee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fC=(e,t)=>{for(var n in t||(t={}))nte.call(t,n)&&ES(e,n,t[n]);if(yS)for(var n of yS(t))rte.call(t,n)&&ES(e,n,t[n]);return e},pC=(e,t)=>ete(e,tte(t));function Tt(e,...t){return{didIntersect:t.length>0,message:e,points:t}}function Ou(e,t,n=0){let r=[e[0]+t[0]/2,e[1]+t[1]/2],i=$.rotWith(e,r,n),o=$.rotWith($.add(e,[t[0],0]),r,n),a=$.rotWith($.add(e,t),r,n),s=$.rotWith($.add(e,[0,t[1]]),r,n);return[["top",[i,o]],["right",[o,a]],["bottom",[a,s]],["left",[s,i]]]}function ite(e,t,n){if(n===e||n===t)return!0;let r=Math.PI*2,i=(t-e+r)%r,o=(n-e+r)%r;return i<=Math.PI!=o>i}function ote(e,t){let n=$.slope(e[0],e[1]),r=$.slope(t[0],t[1]);if(n===r)return;if(Number.isNaN(n)&&!Number.isNaN(r))return[e[0][0],(e[0][0]-t[0][0])*r+t[0][1]];if(Number.isNaN(r)&&!Number.isNaN(n))return[t[0][0],(t[0][0]-e[0][0])*n+e[0][1]];let i=(n*e[0][0]-r*t[0][0]+t[0][1]-e[0][1])/(n-r),o=r*(i-t[0][0])+t[0][1];return[i,o]}function gC(e,t,n,r){let[i,o]=e,[a,s]=t,[u,d]=n,[h,p]=r;if(s/a!==(p-d)/(h-u)){let g=a*(p-d)-s*(h-u);if(g!==0){let m=((o-d)*(h-u)-(i-u)*(p-d))/g,v=((o-d)*a-(i-u)*s)/g;if(m>=0&&v>=0&&v<=1)return Tt("intersection",[i+m*a,o+m*s])}}return Tt("no intersection")}function ate(e,t,n,r,i=0){return cte(n,r,i,e,t)}function uT(e,t,n,r,i,o){let a=e,s=$.mul(t,999999999);return zc(a,s,n,r,i,o)}function Kp(e,t,n,r=0){let{minX:i,minY:o,width:a,height:s}=n;return ate(e,t,[i,o],[a,s],r)}function Lh(e,t,n,r){let i=$.sub(e,n),o=$.sub(r,n),a=$.sub(t,e),s=o[0]*i[1]-o[1]*i[0],u=a[0]*i[1]-a[1]*i[0],d=o[1]*a[0]-o[0]*a[1];if(s===0||u===0)return Tt("coincident");if(d===0)return Tt("parallel");if(d!==0){let h=s/d,p=u/d;if(0<=h&&h<=1&&0<=p&&p<=1)return Tt("intersection",$.add(e,$.mul(a,h)))}return Tt("no intersection")}function ste(e,t,n,r){return lT(n,r,e,t)}function ute(e,t,n,r,i,o){let a=$.angle(n,i),s=$.angle(n,o),u=wte(n,r,r,0,e,t);if(!u.didIntersect)return Tt("no intersection");let d=u.points.filter(h=>ite(a,s,$.angle(n,h)));return d.length===0?Tt("no intersection"):Tt("intersection",...d)}function mC(e,t,n,r){let i=(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]),o=2*((t[0]-e[0])*(e[0]-n[0])+(t[1]-e[1])*(e[1]-n[1])),a=n[0]*n[0]+n[1]*n[1]+e[0]*e[0]+e[1]*e[1]-2*(n[0]*e[0]+n[1]*e[1])-r*r,s=o*o-4*i*a;if(s<0)return Tt("outside");if(s===0)return Tt("tangent");let u=Math.sqrt(s),d=(-o+u)/(2*i),h=(-o-u)/(2*i);if((d<0||d>1)&&(h<0||h>1))return d<0&&h<0||d>1&&h>1?Tt("outside"):Tt("inside");let p=[];return 0<=d&&d<=1&&p.push($.lrp(e,t,d)),0<=h&&h<=1&&p.push($.lrp(e,t,h)),Tt("intersection",...p)}function zc(e,t,n,r,i,o=0){if(r===0||i===0||$.isEqual(e,t))return Tt("no intersection");r=r<0?r:-r,i=i<0?i:-i,e=$.sub($.rotWith(e,n,-o),n),t=$.sub($.rotWith(t,n,-o),n);let a=$.sub(t,e),s=a[0]*a[0]/r/r+a[1]*a[1]/i/i,u=2*e[0]*a[0]/r/r+2*e[1]*a[1]/i/i,d=e[0]*e[0]/r/r+e[1]*e[1]/i/i-1,h=[],p=u*u-4*s*d;if(p===0)h.push(-u/2/s);else if(p>0){let m=Math.sqrt(p);h.push((-u+m)/2/s),h.push((-u-m)/2/s)}let g=h.filter(m=>m>=0&&m<=1).map(m=>$.add(n,$.add(e,$.mul($.sub(t,e),m)))).map(m=>$.rotWith(m,n,o));return Tt("intersection",...g)}function vC(e,t,n){return Ate(n,e,t)}function yC(e,t,n){let r=[];for(let i=1;i{let d=gC(r,i,s,u);return d&&o.push(Tt(a,...d.points)),o},[]).filter(o=>o.didIntersect)}function lT(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=Lh(n,r,a,s);return u&&i.push(Tt(o,...u.points)),i},[]).filter(i=>i.didIntersect)}function dte(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=lT(n,r,a,s);return i.push(...u.map(d=>Tt(`${o} ${d.message}`,...d.points))),i},[]).filter(i=>i.didIntersect)}function hte(e,t,n,r,i,o){return Ou(e,t).reduce((a,[s,[u,d]])=>{let h=vte(n,r,i,o,u,d);return h&&a.push(pC(fC({},h),{message:s})),a},[]).filter(a=>a.didIntersect)}function fte(e,t,n,r){return Ou(e,t).reduce((i,[o,[a,s]])=>{let u=mC(a,s,n,r);return u&&i.push(pC(fC({},u),{message:o})),i},[]).filter(i=>i.didIntersect)}function pte(e,t,n,r,i,o=0){return Ou(e,t).reduce((a,[s,[u,d]])=>{let h=zc(u,d,n,r,i,o);return h&&a.push(pC(fC({},h),{message:s})),a},[]).filter(a=>a.didIntersect)}function gte(e,t,n){return Ou(e,t).reduce((r,[i,[o,a]])=>{let s=yC(o,a,n);return s.didIntersect&&r.push(Tt(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function mte(e,t,n){return Ou(e,t).reduce((r,[i,[o,a]])=>{let s=lte(o,a,n);return s.didIntersect&&r.push(Tt(i,...s.points)),r},[]).filter(r=>r.didIntersect)}function vte(e,t,n,r,i,o){return ute(i,o,e,t,n,r)}function yte(e,t,n,r,i,o){return hte(i,o,e,t,n,r)}function Ete(e,t,n,r,i){let{minX:o,minY:a,width:s,height:u}=i;return yte(e,t,n,r,[o,a],[s,u])}function Cte(e,t,n,r){return mC(n,r,e,t)}function bte(e,t,n,r){let i=n[0]-e[0],o=n[1]-e[1],a=Math.sqrt(i*i+o*o),s=(a*a-r*r+t*t)/(2*a),u=Math.sqrt(t*t-s*s);return i/=a,o/=a,Tt("intersection",[e[0]+i*s-o*u,e[1]+o*s+i*u],[e[0]+i*s+o*u,e[1]+o*s-i*u])}function wte(e,t,n,r=0,i,o){return t===n?mC(i,o,e,t):zc(i,o,e,t,n,r)}function Ste(e,t,n,r=0,i,o){return t===n?fte(i,o,e,t):pte(i,o,e,t,n,r)}function xte(e,t,n,r,i){let{minX:o,minY:a,width:s,height:u}=i;return Ste(e,t,n,r,[o,a],[s,u])}function Ate(e,t,n){let{minX:r,minY:i,width:o,height:a}=e;return ste(t,n,[r,i],[o,a])}function kte(e,t){return dte([e.minX,e.minY],[e.width,e.height],[t.minX,t.minY],[t.width,t.height])}function CS(e,t){return Dte(t,e)}function Ite(e,t){return Tte(t,e)}function Dte(e,t){return gte([t.minX,t.minY],[t.width,t.height],e)}function Tte(e,t){return mte([t.minX,t.minY],[t.width,t.height],e)}function EC(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function Pte(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=EC(n);return(i,o)=>r.then(a=>o(a.transaction(t,i).objectStore(t)))}let Kv;function cT(){return Kv||(Kv=Pte("keyval-store","keyval")),Kv}function Og(e,t=cT()){return t("readonly",n=>EC(n.get(e)))}function I0(e,t,n=cT()){return n("readwrite",r=>(r.put(t,e),EC(r.transaction)))}var dT={BASE_URL:"./",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_YORKIE_API_ADDR:"https://api.yorkie.dev",VITE_YORKIE_API_KEY:"cedaovjuioqlk4pjqn6g"};const bS=e=>{let t;const n=new Set,r=(h,p)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const m=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(v=>v(t,m))}},i=()=>t,u={setState:r,getState:i,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(dT?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,i,u);return u},hT=e=>e?bS(e):bS;var Bte=e=>((dT?"production":void 0)!=="production"&&console.warn("[DEPRECATED] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'."),hT(e)),fT={exports:{}},pT={},gT={exports:{}},mT={};/** * @license React * use-sync-external-store-shim.production.min.js * @@ -443,7 +443,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert- * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var rd=l;function Mte(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $te=typeof Object.is=="function"?Object.is:Mte,Rte=rd.useState,Fte=rd.useEffect,Lte=rd.useLayoutEffect,Ote=rd.useDebugValue;function _te(e,t){var n=t(),r=Rte({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return Lte(function(){i.value=n,i.getSnapshot=t,Kv(i)&&o({inst:i})},[e,n,t]),Fte(function(){return Kv(i)&&o({inst:i}),e(function(){Kv(i)&&o({inst:i})})},[e]),Ote(n),n}function Kv(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$te(e,n)}catch{return!0}}function Nte(e,t){return t()}var zte=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Nte:_te;mT.useSyncExternalStore=rd.useSyncExternalStore!==void 0?rd.useSyncExternalStore:zte;gT.exports=mT;var Hte=gT.exports;/** + */var rd=l;function Mte(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $te=typeof Object.is=="function"?Object.is:Mte,Rte=rd.useState,Fte=rd.useEffect,Lte=rd.useLayoutEffect,Ote=rd.useDebugValue;function _te(e,t){var n=t(),r=Rte({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return Lte(function(){i.value=n,i.getSnapshot=t,Vv(i)&&o({inst:i})},[e,n,t]),Fte(function(){return Vv(i)&&o({inst:i}),e(function(){Vv(i)&&o({inst:i})})},[e]),Ote(n),n}function Vv(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$te(e,n)}catch{return!0}}function Nte(e,t){return t()}var zte=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Nte:_te;mT.useSyncExternalStore=rd.useSyncExternalStore!==void 0?rd.useSyncExternalStore:zte;gT.exports=mT;var Hte=gT.exports;/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * @@ -451,12 +451,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert- * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var c1=l,jte=Hte;function Ute(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Kte=typeof Object.is=="function"?Object.is:Ute,Vte=jte.useSyncExternalStore,Gte=c1.useRef,Jte=c1.useEffect,Wte=c1.useMemo,Yte=c1.useDebugValue;pT.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=Gte(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=Wte(function(){function u(m){if(!d){if(d=!0,h=m,m=r(m),i!==void 0&&a.hasValue){var v=a.value;if(i(v,m))return p=v}return p=m}if(v=p,Kte(h,m))return v;var E=r(m);return i!==void 0&&i(v,E)?v:(h=m,p=E)}var d=!1,h,p,g=n===void 0?null:n;return[function(){return u(t())},g===null?void 0:function(){return u(g())}]},[t,n,r,i]);var s=Vte(e,o[0],o[1]);return Jte(function(){a.hasValue=!0,a.value=s},[s]),Yte(s),s};fT.exports=pT;var qte=fT.exports;const Xte=vh(qte);var EC={BASE_URL:"./",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_YORKIE_API_ADDR:"https://api.yorkie.dev",VITE_YORKIE_API_KEY:"cedaovjuioqlk4pjqn6g"};const{useDebugValue:Zte}=Kt,{useSyncExternalStoreWithSelector:Qte}=Xte;let wS=!1;const ene=e=>e;function tne(e,t=ene,n){(EC?"production":void 0)!=="production"&&n&&!wS&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),wS=!0);const r=Qte(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Zte(r),r}const SS=e=>{(EC?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?hT(e):e,n=(r,i)=>tne(t,r,i);return Object.assign(n,t),n},nne=e=>e?SS(e):SS;var rne=e=>((EC?"production":void 0)!=="production"&&console.warn("[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'`."),nne(e)),CC=Object.defineProperty,ine=Object.defineProperties,one=Object.getOwnPropertyDescriptor,ane=Object.getOwnPropertyDescriptors,sne=Object.getOwnPropertyNames,_g=Object.getOwnPropertySymbols,bC=Object.prototype.hasOwnProperty,vT=Object.prototype.propertyIsEnumerable,_y=(e,t,n)=>t in e?CC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))bC.call(t,n)&&_y(e,n,t[n]);if(_g)for(var n of _g(t))vT.call(t,n)&&_y(e,n,t[n]);return e},q=(e,t)=>ine(e,ane(t)),$i=(e,t)=>{var n={};for(var r in e)bC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_g)for(var r of _g(e))t.indexOf(r)<0&&vT.call(e,r)&&(n[r]=e[r]);return n},une=(e,t)=>{for(var n in t)CC(e,n,{get:t[n],enumerable:!0})},lne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sne(t))!bC.call(e,i)&&i!=="default"&&CC(e,i,{get:()=>t[i],enumerable:!(r=one(t,i))||r.enumerable});return e},S=(e,t,n)=>(_y(e,typeof t!="symbol"?t+"":t,n),n),Oe=(e,t,n)=>new Promise((r,i)=>{var o=u=>{try{s(n.next(u))}catch(d){i(d)}},a=u=>{try{s(n.throw(u))}catch(d){i(d)}},s=u=>u.done?r(u.value):Promise.resolve(u.value).then(o,a);s((n=n.apply(e,t)).next())}),{styled:fe,createTheme:cne}=uI({themeMap:_({},aI),theme:{colors:{bounds:"rgba(65, 132, 244, 1.000)",boundsBg:"rgba(65, 132, 244, 0.05)",hover:"#ececec",overlay:"rgba(0, 0, 0, 0.15)",overlayContrast:"rgba(255, 255, 255, 0.15)",panel:"#fefefe",panelContrast:"#ffffff",selected:"rgba(66, 133, 244, 1.000)",selectedContrast:"#fefefe",text:"#333333",tooltip:"#1d1d1d",tooltipContrast:"#ffffff",warn:"rgba(255, 100, 100, 1)",canvas:"rgb(248, 249, 250)"},shadows:{2:"0px 1px 1px rgba(0, 0, 0, 0.14)",3:"0px 2px 3px rgba(0, 0, 0, 0.14)",4:"0px 4px 5px -1px rgba(0, 0, 0, 0.14)",8:"0px 12px 17px rgba(0, 0, 0, 0.14)",12:"0px 12px 17px rgba(0, 0, 0, 0.14)",24:"0px 24px 38px rgba(0, 0, 0, 0.14)",key:"1px 1px rgba(0,0,0,1)",panel:`0px 0px 16px -1px rgba(0, 0, 0, 0.05), + */var c1=l,jte=Hte;function Ute(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Kte=typeof Object.is=="function"?Object.is:Ute,Vte=jte.useSyncExternalStore,Gte=c1.useRef,Jte=c1.useEffect,Wte=c1.useMemo,Yte=c1.useDebugValue;pT.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=Gte(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=Wte(function(){function u(m){if(!d){if(d=!0,h=m,m=r(m),i!==void 0&&a.hasValue){var v=a.value;if(i(v,m))return p=v}return p=m}if(v=p,Kte(h,m))return v;var E=r(m);return i!==void 0&&i(v,E)?v:(h=m,p=E)}var d=!1,h,p,g=n===void 0?null:n;return[function(){return u(t())},g===null?void 0:function(){return u(g())}]},[t,n,r,i]);var s=Vte(e,o[0],o[1]);return Jte(function(){a.hasValue=!0,a.value=s},[s]),Yte(s),s};fT.exports=pT;var qte=fT.exports;const Xte=vh(qte);var CC={BASE_URL:"./",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_YORKIE_API_ADDR:"https://api.yorkie.dev",VITE_YORKIE_API_KEY:"cedaovjuioqlk4pjqn6g"};const{useDebugValue:Zte}=Kt,{useSyncExternalStoreWithSelector:Qte}=Xte;let wS=!1;const ene=e=>e;function tne(e,t=ene,n){(CC?"production":void 0)!=="production"&&n&&!wS&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),wS=!0);const r=Qte(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Zte(r),r}const SS=e=>{(CC?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?hT(e):e,n=(r,i)=>tne(t,r,i);return Object.assign(n,t),n},nne=e=>e?SS(e):SS;var rne=e=>((CC?"production":void 0)!=="production"&&console.warn("[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'`."),nne(e)),bC=Object.defineProperty,ine=Object.defineProperties,one=Object.getOwnPropertyDescriptor,ane=Object.getOwnPropertyDescriptors,sne=Object.getOwnPropertyNames,_g=Object.getOwnPropertySymbols,wC=Object.prototype.hasOwnProperty,vT=Object.prototype.propertyIsEnumerable,Ny=(e,t,n)=>t in e?bC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))wC.call(t,n)&&Ny(e,n,t[n]);if(_g)for(var n of _g(t))vT.call(t,n)&&Ny(e,n,t[n]);return e},q=(e,t)=>ine(e,ane(t)),$i=(e,t)=>{var n={};for(var r in e)wC.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_g)for(var r of _g(e))t.indexOf(r)<0&&vT.call(e,r)&&(n[r]=e[r]);return n},une=(e,t)=>{for(var n in t)bC(e,n,{get:t[n],enumerable:!0})},lne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sne(t))!wC.call(e,i)&&i!=="default"&&bC(e,i,{get:()=>t[i],enumerable:!(r=one(t,i))||r.enumerable});return e},S=(e,t,n)=>(Ny(e,typeof t!="symbol"?t+"":t,n),n),Oe=(e,t,n)=>new Promise((r,i)=>{var o=u=>{try{s(n.next(u))}catch(d){i(d)}},a=u=>{try{s(n.throw(u))}catch(d){i(d)}},s=u=>u.done?r(u.value):Promise.resolve(u.value).then(o,a);s((n=n.apply(e,t)).next())}),{styled:fe,createTheme:cne}=uI({themeMap:_({},aI),theme:{colors:{bounds:"rgba(65, 132, 244, 1.000)",boundsBg:"rgba(65, 132, 244, 0.05)",hover:"#ececec",overlay:"rgba(0, 0, 0, 0.15)",overlayContrast:"rgba(255, 255, 255, 0.15)",panel:"#fefefe",panelContrast:"#ffffff",selected:"rgba(66, 133, 244, 1.000)",selectedContrast:"#fefefe",text:"#333333",tooltip:"#1d1d1d",tooltipContrast:"#ffffff",warn:"rgba(255, 100, 100, 1)",canvas:"rgb(248, 249, 250)"},shadows:{2:"0px 1px 1px rgba(0, 0, 0, 0.14)",3:"0px 2px 3px rgba(0, 0, 0, 0.14)",4:"0px 4px 5px -1px rgba(0, 0, 0, 0.14)",8:"0px 12px 17px rgba(0, 0, 0, 0.14)",12:"0px 12px 17px rgba(0, 0, 0, 0.14)",24:"0px 24px 38px rgba(0, 0, 0, 0.14)",key:"1px 1px rgba(0,0,0,1)",panel:`0px 0px 16px -1px rgba(0, 0, 0, 0.05), 0px 0px 16px -8px rgba(0, 0, 0, 0.05), 0px 0px 16px -12px rgba(0, 0, 0, 0.12), 0px 0px 2px 0px rgba(0, 0, 0, 0.08)`},space:{0:"2px",1:"3px",2:"4px",3:"8px",4:"12px",5:"16px",6:"32px",7:"48px"},fontSizes:{0:"10px",1:"12px",2:"13px",3:"16px",4:"18px"},fonts:{ui:'"Recursive", system-ui, sans-serif',body:'"Recursive", system-ui, sans-serif',mono:'"Recursive Mono", monospace'},fontWeights:{},lineHeights:{},letterSpacings:{},sizes:{},borderWidths:{0:"$1"},borderStyles:{},radii:{0:"2px",1:"4px",2:"8px",3:"12px",4:"16px"},zIndices:{},transitions:{}},media:{micro:"(max-width: 370px)",sm:"(min-width: 640px)",md:"(min-width: 768px)",lg:"(min-width: 1024px)"},utils:{zStrokeWidth:()=>e=>Array.isArray(e)?{strokeWidth:`calc(${e[0]}px / var(--camera-zoom))`}:{strokeWidth:`calc(${e}px / var(--camera-zoom))`}}}),xS=cne({colors:{bounds:"rgba(38, 150, 255, 1.000)",boundsBg:"rgba(38, 150, 255, 0.05)",hover:"#444A50",overlay:"rgba(0, 0, 0, 0.15)",overlayContrast:"rgba(255, 255, 255, 0.15)",panel:"#363D44",panelContrast:"#49555f",selected:"rgba(38, 150, 255, 1.000)",selectedContrast:"#fefefe",text:"#f8f9fa",tooltip:"#1d1d1d",tooltipContrast:"#ffffff",canvas:"#212529"},shadows:{2:"0px 1px 1px rgba(0, 0, 0, 0.24)",3:"0px 2px 3px rgba(0, 0, 0, 0.24)",4:"0px 4px 5px -1px rgba(0, 0, 0, 0.24)",8:"0px 12px 17px rgba(0, 0, 0, 0.24)",12:"0px 12px 17px rgba(0, 0, 0, 0.24)",24:"0px 24px 38px rgba(0, 0, 0, 0.24)",panel:`0px 0px 16px -1px rgba(0, 0, 0, 0.05), 0px 0px 16px -8px rgba(0, 0, 0, 0.09), - 0px 0px 16px -12px rgba(0, 0, 0, 0.2)`}}),Qt=fe("hr",{height:0,paddingTop:1,width:"calc(100%+8px)",backgroundColor:"$hover",border:"none",margin:"$2 -4px"}),_u=fe("div",{position:"relative",overflow:"hidden",userSelect:"none",display:"flex",flexDirection:"column",zIndex:99997,minWidth:180,pointerEvents:"all",backgroundColor:"$panel",border:"1px solid $panelContrast",boxShadow:"$panel",padding:"$2 $2",borderRadius:"$3",font:"$ui",maxHeight:"100vh",overflowY:"auto",overflowX:"hidden","&::webkit-scrollbar":{display:"none"},"-ms-overflow-style":"none",scrollbarWidth:"none",variants:{size:{small:{minWidth:72}},overflow:{true:{maxHeight:"60vh"}}}}),dne=()=>N.isDarwin()?"⌘":"Ctrl";function wC({variant:e,children:t}){return l.createElement(hne,{variant:e},t.split("").map((n,r)=>l.createElement("span",{key:r},n.replace("#",dne()))))}var hne=fe("kbd",{marginLeft:"$3",textShadow:"$2",textAlign:"center",fontSize:"$0",fontFamily:"$ui",color:"$text",background:"none",fontWeight:400,gap:"$1",display:"flex",alignItems:"center","& > span":{padding:"$0",borderRadius:"$0",display:"flex",alignItems:"center",justifyContent:"center"},variants:{variant:{tooltip:{"& > span":{color:"$tooltipContrast",background:"$overlayContrast",boxShadow:"$key",width:"20px",height:"20px"}},menu:{}}}}),ao=fe("div",{height:"100%",borderRadius:"4px",marginRight:"1px",width:"fit-content",display:"grid",alignItems:"center",justifyContent:"center",outline:"none",border:"none",pointerEvents:"all",cursor:"pointer",color:"currentColor","& svg":{height:16,width:16,strokeWidth:1},"& > *":{gridRow:1,gridColumn:1}}),Ci={"@initial":"mobile","@micro":"micro","@sm":"small","@md":"medium","@lg":"large"},ur=l.forwardRef((e,t)=>{var n=e,{onClick:r,isActive:i=!1,isWarning:o=!1,hasIndicator:a=!1,hasArrow:s=!1,disabled:u=!1,variant:d,kbd:h,children:p}=n,g=$i(n,["onClick","isActive","isWarning","hasIndicator","hasArrow","disabled","variant","kbd","children"]);return l.createElement(fne,_({ref:t,bp:Ci,isWarning:o,isActive:i,disabled:u,onClick:r,variant:d},g),l.createElement(yT,null,p,h?l.createElement(wC,{variant:"menu"},h):void 0,a&&l.createElement(pI,{dir:"ltr"},l.createElement(ao,null,l.createElement(Pg,null))),s&&l.createElement(ao,null,l.createElement(AY,null))))}),yT=fe("div",{height:"100%",width:"100%",backgroundColor:"$panel",borderRadius:"$2",display:"flex",gap:"$1",flexDirection:"row",alignItems:"center",padding:"0 $3",justifyContent:"space-between",border:"1px solid transparent","& svg":{position:"relative",stroke:"$overlay",strokeWidth:1,zIndex:1},[`& > ${ao}`]:{paddingLeft:"$3"}}),fne=fe("button",{position:"relative",width:"100%",background:"none",border:"none",cursor:"pointer",height:32,minHeight:32,outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",borderRadius:4,userSelect:"none",margin:0,padding:"0 0","&[data-disabled]":{opacity:.3},"&:disabled":{opacity:.3},[`&:focus:not(:disabled) ${yT}`]:{backgroundColor:"$hover"},"& a":{textDecoration:"none",color:"$text"},variants:{bp:{mobile:{},small:{}},variant:{styleMenu:{margin:"$1 0 $1 0"},wide:{gridColumn:"1 / span 4"}},size:{icon:{padding:"4px ",width:"auto"}},isWarning:{true:{color:"$warn"}},isActive:{true:{backgroundColor:"$hover"},false:{}}}});function jt({children:e,label:t,kbd:n,id:r,side:i="top"}){return l.createElement("span",{id:r},l.createElement(xQ,null,l.createElement(AQ,null,l.createElement(kQ,{dir:"ltr",asChild:!0},l.createElement("span",null,e)),l.createElement(pne,{dir:"ltr",side:i,sideOffset:8},t,n?l.createElement(wC,{variant:"tooltip"},n):null,l.createElement(gne,null)))))}var pne=fe(IQ,{borderRadius:3,padding:"$3 $3 $3 $3",fontSize:"$1",backgroundColor:"$tooltip",color:"$tooltipContrast",boxShadow:"$3",display:"flex",alignItems:"center",fontFamily:"$ui",userSelect:"none"}),gne=fe(DQ,{fill:"$tooltip",margin:"0 8px"});function mne(){let e=l.useCallback((o,a)=>Oe(this,null,function*(){a(o.fileSystemHandle?"saveFirstTime":"saveAgain",()=>Oe(this,null,function*(){try{yield o.saveProject(),o.newProject()}catch{}}),()=>Oe(this,null,function*(){o.newProject()}),()=>Oe(this,null,function*(){}))}),[]),t=l.useCallback((o,a)=>Oe(this,null,function*(){a(o.fileSystemHandle?"saveFirstTime":"saveAgain",()=>Oe(this,null,function*(){try{yield o.saveProject(),yield o.openProject()}catch{}}),()=>Oe(this,null,function*(){o.openProject()}),()=>Oe(this,null,function*(){}))}),[]),n=l.useCallback(o=>{o.saveProject()},[]),r=l.useCallback(o=>{o.saveProjectAs()},[]),i=l.useCallback(o=>Oe(this,null,function*(){var a;(a=o.openAsset)==null||a.call(o)}),[]);return{onNewProject:e,onSaveProject:n,onSaveProjectAs:r,onOpenProject:t,onOpenMedia:i}}function ET(){let e=wt(),{openDialog:t}=TT(),n=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onNewProject)==null||d.call(u,e,t)}),[e,t]),r=l.useCallback(s=>{var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onSaveProject)==null||d.call(u,e)},[e]),i=l.useCallback(s=>{var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onSaveProjectAs)==null||d.call(u,e)},[e]),o=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onOpenProject)==null||d.call(u,e,t)}),[e,t]),a=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenMedia&&s.preventDefault(),(d=(u=e.callbacks).onOpenMedia)==null||d.call(u,e)}),[e]);return{onNewProject:n,onSaveProject:r,onSaveProjectAs:i,onOpenProject:o,onOpenMedia:a}}var vne=class{constructor(){S(this,"onPinchStart"),S(this,"onPinchEnd"),S(this,"onPinch"),S(this,"onKeyDown"),S(this,"onKeyUp"),S(this,"onPointerMove"),S(this,"onPointerUp"),S(this,"onPan"),S(this,"onZoom"),S(this,"onPointerDown"),S(this,"onPointCanvas"),S(this,"onDoubleClickCanvas"),S(this,"onRightPointCanvas"),S(this,"onDragCanvas"),S(this,"onReleaseCanvas"),S(this,"onPointShape"),S(this,"onDoubleClickShape"),S(this,"onRightPointShape"),S(this,"onDragShape"),S(this,"onHoverShape"),S(this,"onUnhoverShape"),S(this,"onReleaseShape"),S(this,"onPointBounds"),S(this,"onDoubleClickBounds"),S(this,"onRightPointBounds"),S(this,"onDragBounds"),S(this,"onHoverBounds"),S(this,"onUnhoverBounds"),S(this,"onReleaseBounds"),S(this,"onPointBoundsHandle"),S(this,"onDoubleClickBoundsHandle"),S(this,"onRightPointBoundsHandle"),S(this,"onDragBoundsHandle"),S(this,"onHoverBoundsHandle"),S(this,"onUnhoverBoundsHandle"),S(this,"onReleaseBoundsHandle"),S(this,"onPointHandle"),S(this,"onDoubleClickHandle"),S(this,"onRightPointHandle"),S(this,"onDragHandle"),S(this,"onHoverHandle"),S(this,"onUnhoverHandle"),S(this,"onReleaseHandle"),S(this,"onShapeBlur"),S(this,"onShapeClone")}},CT=(e=>(e.Idle="idle",e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e))(CT||{}),yne=(e=>(e.Transform="transform",e.Translate="translate",e.TransformSingle="transformSingle",e.Brush="brush",e.Arrow="arrow",e.Draw="draw",e.Erase="erase",e.Rotate="rotate",e.Handle="handle",e.Grid="grid",e.Edit="edit",e))(yne||{}),Ene=(e=>(e.Idle="idle",e.PointingHandle="pointingHandle",e.PointingBounds="pointingBounds",e.PointingBoundsHandle="pointingBoundsHandle",e.TranslatingLabel="translatingLabel",e.TranslatingHandle="translatingHandle",e.Translating="translating",e.Transforming="transforming",e.Rotating="rotating",e.Pinching="pinching",e.Brushing="brushing",e.Creating="creating",e.EditingText="editing-text",e))(Ene||{}),Cne=(e=>(e.Backward="backward",e.Forward="forward",e.ToFront="toFront",e.ToBack="toBack",e))(Cne||{}),bne=(e=>(e.Top="top",e.CenterVertical="centerVertical",e.Bottom="bottom",e.Left="left",e.CenterHorizontal="centerHorizontal",e.Right="right",e))(bne||{}),wne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(wne||{}),Sne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(Sne||{}),xne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(xne||{}),Ane=(e=>(e.Sticky="sticky",e.Ellipse="ellipse",e.Rectangle="rectangle",e.Triangle="triangle",e.Draw="draw",e.Arrow="arrow",e.Line="line",e.Text="text",e.Group="group",e.Image="image",e.Video="video",e))(Ane||{}),kne=(e=>(e.Arrow="arrow",e))(kne||{}),Ine=(e=>(e.White="white",e.LightGray="lightGray",e.Gray="gray",e.Black="black",e.Green="green",e.Cyan="cyan",e.Blue="blue",e.Indigo="indigo",e.Violet="violet",e.Red="red",e.Orange="orange",e.Yellow="yellow",e))(Ine||{}),bT=(e=>(e.Small="small",e.Medium="medium",e.Large="large",e))(bT||{}),wT=(e=>(e.Draw="draw",e.Solid="solid",e.Dashed="dashed",e.Dotted="dotted",e))(wT||{}),Dne=(e=>(e.Small="small",e.Medium="medium",e.Large="large",e.ExtraLarge="extraLarge",e))(Dne||{}),ST=(e=>(e.Start="start",e.Middle="middle",e.End="end",e.Justify="justify",e))(ST||{}),xT=(e=>(e.Script="script",e.Sans="sans",e.Serif="serif",e.Mono="mono",e))(xT||{}),Tne=(e=>(e.Image="image",e.Video="video",e))(Tne||{}),Pne=(e=>(e.PNG="png",e.JPG="jpeg",e.WEBP="webp",e.SVG="svg",e.JSON="json",e))(Pne||{}),AT=(e=>(e.Transparent="transparent",e.Auto="auto",e.Light="light",e.Dark="dark",e))(AT||{});function Bne(e){let t=wt(),n=l.useCallback((u=!1)=>{let d=e.current;return u&&(t.isMenuOpen||t.settings.keepStyleMenuOpen)?!0:(d==null||d.focus(),d&&(document.activeElement===d||d.contains(document.activeElement)))},[e]);l.useEffect(()=>{if(!t)return;let u=p=>{if(n(!0)){if(t.readOnly){t.copy(void 0,p);return}t.cut(void 0,p)}},d=p=>{!n(!0)||t.copy(void 0,p)},h=p=>{!n(!0)||t.readOnly||t.paste(void 0,p)};return document.addEventListener("cut",u),document.addEventListener("copy",d),document.addEventListener("paste",h),()=>{document.removeEventListener("cut",u),document.removeEventListener("copy",d),document.removeEventListener("paste",h)}},[t]),Me("v,1",()=>{!n(!0)||t.selectTool("select")},[t,e.current]),Me("d,p,2",()=>{!n(!0)||t.selectTool("draw")},void 0,[t]),Me("e,3",()=>{!n(!0)||t.selectTool("erase")},void 0,[t]),Me("r,4",()=>{!n(!0)||t.selectTool("rectangle")},void 0,[t]),Me("o,5",()=>{!n(!0)||t.selectTool("ellipse")},void 0,[t]),Me("g,6",()=>{!n()||t.selectTool("triangle")},void 0,[t]),Me("l,7",()=>{!n(!0)||t.selectTool("line")},void 0,[t]),Me("a,8",()=>{!n(!0)||t.selectTool("arrow")},void 0,[t]),Me("t,9",()=>{!n(!0)||t.selectTool("text")},void 0,[t]),Me("s,0",()=>{!n(!0)||t.selectTool("sticky")},void 0,[t]),Me("ctrl+shift+d,⌘+shift+d",u=>{!n(!0)||(t.toggleDarkMode(),u.preventDefault())},void 0,[t]),Me("ctrl+.,⌘+.",()=>{!n(!0)||t.toggleFocusMode()},void 0,[t]),Me("ctrl+shift+g,⌘+shift+g",()=>{!n(!0)||t.toggleGrid()},void 0,[t]);let{onNewProject:r,onOpenProject:i,onSaveProject:o,onSaveProjectAs:a,onOpenMedia:s}=ET();Me("ctrl+n,⌘+n",u=>{u.preventDefault(),n()&&r(u)},void 0,[t]),Me("ctrl+s,⌘+s",u=>{!n()||o(u)},void 0,[t]),Me("ctrl+shift+s,⌘+shift+s",u=>{!n()||a(u)},void 0,[t]),Me("ctrl+o,⌘+o",u=>{!n()||i(u)},void 0,[t]),Me("ctrl+u,⌘+u",u=>{!n()||s(u)},void 0,[t]),Me("⌘+z,ctrl+z",u=>{u.preventDefault(),n(!0)&&(t.session?t.cancelSession():t.undo())},void 0,[t]),Me("ctrl+shift+z,⌘+shift+z",()=>{!n(!0)||(t.session?t.cancelSession():t.redo())},void 0,[t]),Me("⌘+u,ctrl+u",()=>{!n()||t.undoSelect()},void 0,[t]),Me("ctrl+shift-u,⌘+shift+u",()=>{!n()||t.redoSelect()},void 0,[t]),Me("ctrl+=,⌘+=,ctrl+num_add,⌘+num_add",u=>{!n(!0)||(t.zoomIn(),u.preventDefault())},void 0,[t]),Me("ctrl+-,⌘+-,ctrl+num_subtract,⌘+num_subtract",u=>{!n(!0)||(t.zoomOut(),u.preventDefault())},void 0,[t]),Me("shift+0,ctrl+numpad_0,⌘+numpad_0",()=>{!n(!0)||t.resetZoom()},void 0,[t]),Me("shift+1",()=>{!n(!0)||t.zoomToFit()},void 0,[t]),Me("shift+2",()=>{!n(!0)||t.zoomToSelection()},void 0,[t]),Me("ctrl+d,⌘+d",u=>{!n()||(t.duplicate(),u.preventDefault())},void 0,[t]),Me("shift+h",()=>{!n(!0)||t.flipHorizontal()},void 0,[t]),Me("shift+v",()=>{!n(!0)||t.flipVertical()},void 0,[t]),Me("escape",()=>{!n(!0)||t.cancel()},void 0,[t]),Me("backspace,del",()=>{!n()||t.delete()},void 0,[t]),Me("⌘+a,ctrl+a",()=>{!n(!0)||t.selectAll()},void 0,[t]),Me("up",()=>{!n()||t.nudge([0,-1],!1)},void 0,[t]),Me("right",()=>{!n()||t.nudge([1,0],!1)},void 0,[t]),Me("down",()=>{!n()||t.nudge([0,1],!1)},void 0,[t]),Me("left",()=>{!n()||t.nudge([-1,0],!1)},void 0,[t]),Me("shift+up",()=>{!n()||t.nudge([0,-1],!0)},void 0,[t]),Me("shift+right",()=>{!n()||t.nudge([1,0],!0)},void 0,[t]),Me("shift+down",()=>{!n()||t.nudge([0,1],!0)},void 0,[t]),Me("shift+left",()=>{!n()||t.nudge([-1,0],!0)},void 0,[t]),Me("⌘+shift+l,ctrl+shift+l",()=>{!n()||t.toggleLocked()},void 0,[t]),Me("⌘+shift+c,ctrl+shift+c",u=>{!n()||(t.copySvg(),u.preventDefault())},void 0,[t]),Me("⌘+g,ctrl+g",u=>{!n()||(t.group(),u.preventDefault())},void 0,[t]),Me("⌘+shift+g,ctrl+shift+g",u=>{!n()||(t.ungroup(),u.preventDefault())},void 0,[t]),Me("[",()=>{!n(!0)||t.moveBackward()},void 0,[t]),Me("]",()=>{!n(!0)||t.moveForward()},void 0,[t]),Me("shift+[",()=>{!n(!0)||t.moveToBack()},void 0,[t]),Me("shift+]",()=>{!n(!0)||t.moveToFront()},void 0,[t]),Me("ctrl+shift+backspace,⌘+shift+backspace",u=>{!n()||(t.settings.isDebugMode&&t.resetDocument(),u.preventDefault())},void 0,[t]),Me("alt+command+l,alt+ctrl+l",u=>{!n(!0)||(t.style({textAlign:"start"}),u.preventDefault())},void 0,[t]),Me("alt+command+t,alt+ctrl+t",u=>{!n(!0)||(t.style({textAlign:"middle"}),u.preventDefault())},void 0,[t]),Me("alt+command+r,alt+ctrl+r",u=>{!n(!0)||(t.style({textAlign:"end"}),u.preventDefault())},void 0,[t])}var Vv=new Map,pp="tldraw-fonts",Mne=` + 0px 0px 16px -12px rgba(0, 0, 0, 0.2)`}}),Qt=fe("hr",{height:0,paddingTop:1,width:"calc(100%+8px)",backgroundColor:"$hover",border:"none",margin:"$2 -4px"}),_u=fe("div",{position:"relative",overflow:"hidden",userSelect:"none",display:"flex",flexDirection:"column",zIndex:99997,minWidth:180,pointerEvents:"all",backgroundColor:"$panel",border:"1px solid $panelContrast",boxShadow:"$panel",padding:"$2 $2",borderRadius:"$3",font:"$ui",maxHeight:"100vh",overflowY:"auto",overflowX:"hidden","&::webkit-scrollbar":{display:"none"},"-ms-overflow-style":"none",scrollbarWidth:"none",variants:{size:{small:{minWidth:72}},overflow:{true:{maxHeight:"60vh"}}}}),dne=()=>N.isDarwin()?"⌘":"Ctrl";function SC({variant:e,children:t}){return l.createElement(hne,{variant:e},t.split("").map((n,r)=>l.createElement("span",{key:r},n.replace("#",dne()))))}var hne=fe("kbd",{marginLeft:"$3",textShadow:"$2",textAlign:"center",fontSize:"$0",fontFamily:"$ui",color:"$text",background:"none",fontWeight:400,gap:"$1",display:"flex",alignItems:"center","& > span":{padding:"$0",borderRadius:"$0",display:"flex",alignItems:"center",justifyContent:"center"},variants:{variant:{tooltip:{"& > span":{color:"$tooltipContrast",background:"$overlayContrast",boxShadow:"$key",width:"20px",height:"20px"}},menu:{}}}}),ao=fe("div",{height:"100%",borderRadius:"4px",marginRight:"1px",width:"fit-content",display:"grid",alignItems:"center",justifyContent:"center",outline:"none",border:"none",pointerEvents:"all",cursor:"pointer",color:"currentColor","& svg":{height:16,width:16,strokeWidth:1},"& > *":{gridRow:1,gridColumn:1}}),Ci={"@initial":"mobile","@micro":"micro","@sm":"small","@md":"medium","@lg":"large"},ur=l.forwardRef((e,t)=>{var n=e,{onClick:r,isActive:i=!1,isWarning:o=!1,hasIndicator:a=!1,hasArrow:s=!1,disabled:u=!1,variant:d,kbd:h,children:p}=n,g=$i(n,["onClick","isActive","isWarning","hasIndicator","hasArrow","disabled","variant","kbd","children"]);return l.createElement(fne,_({ref:t,bp:Ci,isWarning:o,isActive:i,disabled:u,onClick:r,variant:d},g),l.createElement(yT,null,p,h?l.createElement(SC,{variant:"menu"},h):void 0,a&&l.createElement(pI,{dir:"ltr"},l.createElement(ao,null,l.createElement(Pg,null))),s&&l.createElement(ao,null,l.createElement(AY,null))))}),yT=fe("div",{height:"100%",width:"100%",backgroundColor:"$panel",borderRadius:"$2",display:"flex",gap:"$1",flexDirection:"row",alignItems:"center",padding:"0 $3",justifyContent:"space-between",border:"1px solid transparent","& svg":{position:"relative",stroke:"$overlay",strokeWidth:1,zIndex:1},[`& > ${ao}`]:{paddingLeft:"$3"}}),fne=fe("button",{position:"relative",width:"100%",background:"none",border:"none",cursor:"pointer",height:32,minHeight:32,outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",borderRadius:4,userSelect:"none",margin:0,padding:"0 0","&[data-disabled]":{opacity:.3},"&:disabled":{opacity:.3},[`&:focus:not(:disabled) ${yT}`]:{backgroundColor:"$hover"},"& a":{textDecoration:"none",color:"$text"},variants:{bp:{mobile:{},small:{}},variant:{styleMenu:{margin:"$1 0 $1 0"},wide:{gridColumn:"1 / span 4"}},size:{icon:{padding:"4px ",width:"auto"}},isWarning:{true:{color:"$warn"}},isActive:{true:{backgroundColor:"$hover"},false:{}}}});function jt({children:e,label:t,kbd:n,id:r,side:i="top"}){return l.createElement("span",{id:r},l.createElement(xQ,null,l.createElement(AQ,null,l.createElement(kQ,{dir:"ltr",asChild:!0},l.createElement("span",null,e)),l.createElement(pne,{dir:"ltr",side:i,sideOffset:8},t,n?l.createElement(SC,{variant:"tooltip"},n):null,l.createElement(gne,null)))))}var pne=fe(IQ,{borderRadius:3,padding:"$3 $3 $3 $3",fontSize:"$1",backgroundColor:"$tooltip",color:"$tooltipContrast",boxShadow:"$3",display:"flex",alignItems:"center",fontFamily:"$ui",userSelect:"none"}),gne=fe(DQ,{fill:"$tooltip",margin:"0 8px"});function mne(){let e=l.useCallback((o,a)=>Oe(this,null,function*(){a(o.fileSystemHandle?"saveFirstTime":"saveAgain",()=>Oe(this,null,function*(){try{yield o.saveProject(),o.newProject()}catch{}}),()=>Oe(this,null,function*(){o.newProject()}),()=>Oe(this,null,function*(){}))}),[]),t=l.useCallback((o,a)=>Oe(this,null,function*(){a(o.fileSystemHandle?"saveFirstTime":"saveAgain",()=>Oe(this,null,function*(){try{yield o.saveProject(),yield o.openProject()}catch{}}),()=>Oe(this,null,function*(){o.openProject()}),()=>Oe(this,null,function*(){}))}),[]),n=l.useCallback(o=>{o.saveProject()},[]),r=l.useCallback(o=>{o.saveProjectAs()},[]),i=l.useCallback(o=>Oe(this,null,function*(){var a;(a=o.openAsset)==null||a.call(o)}),[]);return{onNewProject:e,onSaveProject:n,onSaveProjectAs:r,onOpenProject:t,onOpenMedia:i}}function ET(){let e=wt(),{openDialog:t}=TT(),n=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onNewProject)==null||d.call(u,e,t)}),[e,t]),r=l.useCallback(s=>{var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onSaveProject)==null||d.call(u,e)},[e]),i=l.useCallback(s=>{var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onSaveProjectAs)==null||d.call(u,e)},[e]),o=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenProject&&s.preventDefault(),(d=(u=e.callbacks).onOpenProject)==null||d.call(u,e,t)}),[e,t]),a=l.useCallback(s=>Oe(this,null,function*(){var u,d;s&&e.callbacks.onOpenMedia&&s.preventDefault(),(d=(u=e.callbacks).onOpenMedia)==null||d.call(u,e)}),[e]);return{onNewProject:n,onSaveProject:r,onSaveProjectAs:i,onOpenProject:o,onOpenMedia:a}}var vne=class{constructor(){S(this,"onPinchStart"),S(this,"onPinchEnd"),S(this,"onPinch"),S(this,"onKeyDown"),S(this,"onKeyUp"),S(this,"onPointerMove"),S(this,"onPointerUp"),S(this,"onPan"),S(this,"onZoom"),S(this,"onPointerDown"),S(this,"onPointCanvas"),S(this,"onDoubleClickCanvas"),S(this,"onRightPointCanvas"),S(this,"onDragCanvas"),S(this,"onReleaseCanvas"),S(this,"onPointShape"),S(this,"onDoubleClickShape"),S(this,"onRightPointShape"),S(this,"onDragShape"),S(this,"onHoverShape"),S(this,"onUnhoverShape"),S(this,"onReleaseShape"),S(this,"onPointBounds"),S(this,"onDoubleClickBounds"),S(this,"onRightPointBounds"),S(this,"onDragBounds"),S(this,"onHoverBounds"),S(this,"onUnhoverBounds"),S(this,"onReleaseBounds"),S(this,"onPointBoundsHandle"),S(this,"onDoubleClickBoundsHandle"),S(this,"onRightPointBoundsHandle"),S(this,"onDragBoundsHandle"),S(this,"onHoverBoundsHandle"),S(this,"onUnhoverBoundsHandle"),S(this,"onReleaseBoundsHandle"),S(this,"onPointHandle"),S(this,"onDoubleClickHandle"),S(this,"onRightPointHandle"),S(this,"onDragHandle"),S(this,"onHoverHandle"),S(this,"onUnhoverHandle"),S(this,"onReleaseHandle"),S(this,"onShapeBlur"),S(this,"onShapeClone")}},CT=(e=>(e.Idle="idle",e.Connecting="connecting",e.Connected="connected",e.Disconnected="disconnected",e))(CT||{}),yne=(e=>(e.Transform="transform",e.Translate="translate",e.TransformSingle="transformSingle",e.Brush="brush",e.Arrow="arrow",e.Draw="draw",e.Erase="erase",e.Rotate="rotate",e.Handle="handle",e.Grid="grid",e.Edit="edit",e))(yne||{}),Ene=(e=>(e.Idle="idle",e.PointingHandle="pointingHandle",e.PointingBounds="pointingBounds",e.PointingBoundsHandle="pointingBoundsHandle",e.TranslatingLabel="translatingLabel",e.TranslatingHandle="translatingHandle",e.Translating="translating",e.Transforming="transforming",e.Rotating="rotating",e.Pinching="pinching",e.Brushing="brushing",e.Creating="creating",e.EditingText="editing-text",e))(Ene||{}),Cne=(e=>(e.Backward="backward",e.Forward="forward",e.ToFront="toFront",e.ToBack="toBack",e))(Cne||{}),bne=(e=>(e.Top="top",e.CenterVertical="centerVertical",e.Bottom="bottom",e.Left="left",e.CenterHorizontal="centerHorizontal",e.Right="right",e))(bne||{}),wne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(wne||{}),Sne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(Sne||{}),xne=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(xne||{}),Ane=(e=>(e.Sticky="sticky",e.Ellipse="ellipse",e.Rectangle="rectangle",e.Triangle="triangle",e.Draw="draw",e.Arrow="arrow",e.Line="line",e.Text="text",e.Group="group",e.Image="image",e.Video="video",e))(Ane||{}),kne=(e=>(e.Arrow="arrow",e))(kne||{}),Ine=(e=>(e.White="white",e.LightGray="lightGray",e.Gray="gray",e.Black="black",e.Green="green",e.Cyan="cyan",e.Blue="blue",e.Indigo="indigo",e.Violet="violet",e.Red="red",e.Orange="orange",e.Yellow="yellow",e))(Ine||{}),bT=(e=>(e.Small="small",e.Medium="medium",e.Large="large",e))(bT||{}),wT=(e=>(e.Draw="draw",e.Solid="solid",e.Dashed="dashed",e.Dotted="dotted",e))(wT||{}),Dne=(e=>(e.Small="small",e.Medium="medium",e.Large="large",e.ExtraLarge="extraLarge",e))(Dne||{}),ST=(e=>(e.Start="start",e.Middle="middle",e.End="end",e.Justify="justify",e))(ST||{}),xT=(e=>(e.Script="script",e.Sans="sans",e.Serif="serif",e.Mono="mono",e))(xT||{}),Tne=(e=>(e.Image="image",e.Video="video",e))(Tne||{}),Pne=(e=>(e.PNG="png",e.JPG="jpeg",e.WEBP="webp",e.SVG="svg",e.JSON="json",e))(Pne||{}),AT=(e=>(e.Transparent="transparent",e.Auto="auto",e.Light="light",e.Dark="dark",e))(AT||{});function Bne(e){let t=wt(),n=l.useCallback((u=!1)=>{let d=e.current;return u&&(t.isMenuOpen||t.settings.keepStyleMenuOpen)?!0:(d==null||d.focus(),d&&(document.activeElement===d||d.contains(document.activeElement)))},[e]);l.useEffect(()=>{if(!t)return;let u=p=>{if(n(!0)){if(t.readOnly){t.copy(void 0,p);return}t.cut(void 0,p)}},d=p=>{!n(!0)||t.copy(void 0,p)},h=p=>{!n(!0)||t.readOnly||t.paste(void 0,p)};return document.addEventListener("cut",u),document.addEventListener("copy",d),document.addEventListener("paste",h),()=>{document.removeEventListener("cut",u),document.removeEventListener("copy",d),document.removeEventListener("paste",h)}},[t]),Me("v,1",()=>{!n(!0)||t.selectTool("select")},[t,e.current]),Me("d,p,2",()=>{!n(!0)||t.selectTool("draw")},void 0,[t]),Me("e,3",()=>{!n(!0)||t.selectTool("erase")},void 0,[t]),Me("r,4",()=>{!n(!0)||t.selectTool("rectangle")},void 0,[t]),Me("o,5",()=>{!n(!0)||t.selectTool("ellipse")},void 0,[t]),Me("g,6",()=>{!n()||t.selectTool("triangle")},void 0,[t]),Me("l,7",()=>{!n(!0)||t.selectTool("line")},void 0,[t]),Me("a,8",()=>{!n(!0)||t.selectTool("arrow")},void 0,[t]),Me("t,9",()=>{!n(!0)||t.selectTool("text")},void 0,[t]),Me("s,0",()=>{!n(!0)||t.selectTool("sticky")},void 0,[t]),Me("ctrl+shift+d,⌘+shift+d",u=>{!n(!0)||(t.toggleDarkMode(),u.preventDefault())},void 0,[t]),Me("ctrl+.,⌘+.",()=>{!n(!0)||t.toggleFocusMode()},void 0,[t]),Me("ctrl+shift+g,⌘+shift+g",()=>{!n(!0)||t.toggleGrid()},void 0,[t]);let{onNewProject:r,onOpenProject:i,onSaveProject:o,onSaveProjectAs:a,onOpenMedia:s}=ET();Me("ctrl+n,⌘+n",u=>{u.preventDefault(),n()&&r(u)},void 0,[t]),Me("ctrl+s,⌘+s",u=>{!n()||o(u)},void 0,[t]),Me("ctrl+shift+s,⌘+shift+s",u=>{!n()||a(u)},void 0,[t]),Me("ctrl+o,⌘+o",u=>{!n()||i(u)},void 0,[t]),Me("ctrl+u,⌘+u",u=>{!n()||s(u)},void 0,[t]),Me("⌘+z,ctrl+z",u=>{u.preventDefault(),n(!0)&&(t.session?t.cancelSession():t.undo())},void 0,[t]),Me("ctrl+shift+z,⌘+shift+z",()=>{!n(!0)||(t.session?t.cancelSession():t.redo())},void 0,[t]),Me("⌘+u,ctrl+u",()=>{!n()||t.undoSelect()},void 0,[t]),Me("ctrl+shift-u,⌘+shift+u",()=>{!n()||t.redoSelect()},void 0,[t]),Me("ctrl+=,⌘+=,ctrl+num_add,⌘+num_add",u=>{!n(!0)||(t.zoomIn(),u.preventDefault())},void 0,[t]),Me("ctrl+-,⌘+-,ctrl+num_subtract,⌘+num_subtract",u=>{!n(!0)||(t.zoomOut(),u.preventDefault())},void 0,[t]),Me("shift+0,ctrl+numpad_0,⌘+numpad_0",()=>{!n(!0)||t.resetZoom()},void 0,[t]),Me("shift+1",()=>{!n(!0)||t.zoomToFit()},void 0,[t]),Me("shift+2",()=>{!n(!0)||t.zoomToSelection()},void 0,[t]),Me("ctrl+d,⌘+d",u=>{!n()||(t.duplicate(),u.preventDefault())},void 0,[t]),Me("shift+h",()=>{!n(!0)||t.flipHorizontal()},void 0,[t]),Me("shift+v",()=>{!n(!0)||t.flipVertical()},void 0,[t]),Me("escape",()=>{!n(!0)||t.cancel()},void 0,[t]),Me("backspace,del",()=>{!n()||t.delete()},void 0,[t]),Me("⌘+a,ctrl+a",()=>{!n(!0)||t.selectAll()},void 0,[t]),Me("up",()=>{!n()||t.nudge([0,-1],!1)},void 0,[t]),Me("right",()=>{!n()||t.nudge([1,0],!1)},void 0,[t]),Me("down",()=>{!n()||t.nudge([0,1],!1)},void 0,[t]),Me("left",()=>{!n()||t.nudge([-1,0],!1)},void 0,[t]),Me("shift+up",()=>{!n()||t.nudge([0,-1],!0)},void 0,[t]),Me("shift+right",()=>{!n()||t.nudge([1,0],!0)},void 0,[t]),Me("shift+down",()=>{!n()||t.nudge([0,1],!0)},void 0,[t]),Me("shift+left",()=>{!n()||t.nudge([-1,0],!0)},void 0,[t]),Me("⌘+shift+l,ctrl+shift+l",()=>{!n()||t.toggleLocked()},void 0,[t]),Me("⌘+shift+c,ctrl+shift+c",u=>{!n()||(t.copySvg(),u.preventDefault())},void 0,[t]),Me("⌘+g,ctrl+g",u=>{!n()||(t.group(),u.preventDefault())},void 0,[t]),Me("⌘+shift+g,ctrl+shift+g",u=>{!n()||(t.ungroup(),u.preventDefault())},void 0,[t]),Me("[",()=>{!n(!0)||t.moveBackward()},void 0,[t]),Me("]",()=>{!n(!0)||t.moveForward()},void 0,[t]),Me("shift+[",()=>{!n(!0)||t.moveToBack()},void 0,[t]),Me("shift+]",()=>{!n(!0)||t.moveToFront()},void 0,[t]),Me("ctrl+shift+backspace,⌘+shift+backspace",u=>{!n()||(t.settings.isDebugMode&&t.resetDocument(),u.preventDefault())},void 0,[t]),Me("alt+command+l,alt+ctrl+l",u=>{!n(!0)||(t.style({textAlign:"start"}),u.preventDefault())},void 0,[t]),Me("alt+command+t,alt+ctrl+t",u=>{!n(!0)||(t.style({textAlign:"middle"}),u.preventDefault())},void 0,[t]),Me("alt+command+r,alt+ctrl+r",u=>{!n(!0)||(t.style({textAlign:"end"}),u.preventDefault())},void 0,[t])}var Gv=new Map,pp="tldraw-fonts",Mne=` @import url('https://fonts.googleapis.com/css2?family=Caveat+Brush&family=Source+Code+Pro&family=Source+Sans+Pro&family=Crimson+Pro&display=block'); @font-face { @@ -491,16 +491,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert- unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } -`;function $ne(){l.useLayoutEffect(()=>{if(Vv.get(pp))return;let e=document.createElement("style");return e.innerHTML=Mne,e.setAttribute("id",pp),document.head.appendChild(e),Vv.set(pp,e),()=>{e&&document.head.contains(e)&&(document.head.removeChild(e),Vv.delete(pp))}},[])}var kT=l.createContext({}),Rne=()=>{let[e,t]=l.useState(0);l.useEffect(()=>t(1))};function wt(){return l.useContext(kT)}var IT=l.createContext({});function Nu(){let e=l.useContext(IT);return Rne(),e}var Fne="اللون",Lne="يملأ",One="متقطع",_ne="حجم",Nne="تبقى مفتوحة",zne="الخط",Hne="محاذاة",jne="الأنماط",Une="تكبير",Kne="تصغير",Vne="إلى",Gne="أدوات",Jne="التحويلات",Wne="ملف",Yne="تحرير",qne="معاينة",Xne="التفضيلات",Zne="تسجيل الدخول",Qne="خروج",ere="كن راعياً",tre="العودة إلى المحتوى",nre="تكبير للتحديد",rre="تكبير لتناسب",ire="تكبير إلى",ore="الوضع الداكن",are="وضع التركيز",sre="وضع التصحيح",ure="اظهر الشبكة",lre="استخدام التحديد CAD",cre="الاحتفاظ بقائمة النمط مفتوحة",dre="إظهار اللقطات دائمًا",hre="تدوير المقابض",fre="مقابض ملزمة",pre="مقابض استنساخ",gre="الغاء",mre="إعادة",vre="قطع",yre="نسح",Ere="لصق",Cre="نسخ الى",bre="صدر الى",wre="اختر الكل",Sre="لا تختر شيء",xre="حذف",Are="مشروع جديد",kre="فتح",Ire="حفظ",Dre="حفظ باسم",Tre="تحميل الوسائط",Pre="إنشاء صفحة",Bre="صفحة جديدة",Mre="اسم الصفحة",$re="نسخ",Rre="الغاء",Fre="نسخ رابط الدعوة",Lre="نسخ رابط دعوة القراءة فقط",Ore="قم بإنشاء مشروع متعدد اللاعبين",_re="نسخ إلى مشروع متعدد اللاعبين",Nre="اختر",zre="ممحاة",Hre="رسم",jre="سهم",Ure="نص",Kre="لاصق",Vre="مربع",Gre="بيضاوي",Jre="مثلث",Wre="خط",Yre="دوّر",qre="قفل نسبة الابعاد",Xre="فتح قفل نسبة الابعاد",Zre="جمّع",Qre="فك التجمع",eie="انتقل إلى الخلف",tie="تحريك للخلف",nie="تحريك للأمام",rie="تحرك للأمام",iie="إعادة ضبط الزاوية",oie="قفل",aie="الغاء القفل",sie="انقل إلى الصفحة",uie="انعكاس أفقي",lie="انعكاس عمودي",cie="حرّك",die="للامام",hie="للخلف",fie="للوراء",pie="خلف",gie="لغة",mie="للمزيد",vie="موقع الادوات",yie="اسفل",Eie="يسار",Cie="يمين",bie="أعلى",wie="صفحة",Sie="اختصارات لوحة المفاتيح",xie="بحث",Aie="{dots}تحميل ",kie="تصدير الخلفية",Iie="شـفاف",Die="ذاتي",Tie="خفيف",Pie="غامق",Bie={"style.menu.color":Fne,"style.menu.fill":Lne,"style.menu.dash":One,"style.menu.size":_ne,"style.menu.keep.open":Nne,"style.menu.font":zne,"style.menu.align":Hne,styles:jne,"zoom.in":Une,"zoom.out":Kne,to:Vne,"menu.tools":Gne,"menu.transform":Jne,"menu.file":Wne,"menu.edit":Yne,"menu.view":qne,"menu.preferences":Xne,"menu.sign.in":Zne,"menu.sign.out":Qne,"become.a.sponsor":ere,"zoom.to.content":tre,"zoom.to.selection":nre,"zoom.to.fit":rre,"zoom.to":ire,"preferences.dark.mode":ore,"preferences.focus.mode":are,"preferences.debug.mode":sre,"preferences.show.grid":ure,"preferences.use.cad.selection":lre,"preferences.keep.stylemenu.open":cre,"preferences.always.show.snaps":dre,"preferences.rotate.handles":hre,"preferences.binding.handles":fre,"preferences.clone.handles":pre,undo:gre,redo:mre,cut:vre,copy:yre,paste:Ere,"copy.as":Cre,"export.as":bre,"select.all":wre,"select.none":Sre,delete:xre,"new.project":Are,open:kre,save:Ire,"save.as":Dre,"upload.media":Tre,"create.page":Pre,"new.page":Bre,"page.name":Mre,duplicate:$re,cancel:Rre,"copy.invite.link":Fre,"copy.readonly.link":Lre,"create.multiplayer.project":Ore,"copy.multiplayer.project":_re,select:Nre,eraser:zre,draw:Hre,arrow:jre,text:Ure,sticky:Kre,rectangle:Vre,ellipse:Gre,triangle:Jre,line:Wre,rotate:Yre,"lock.aspect.ratio":qre,"unlock.aspect.ratio":Xre,group:Zre,ungroup:Qre,"move.to.back":eie,"move.backward":tie,"move.forward":nie,"move.to.front":rie,"reset.angle":iie,lock:oie,unlock:aie,"move.to.page":sie,"flip.horizontal":uie,"flip.vertical":lie,move:cie,"to.front":die,forward:hie,backward:fie,back:pie,language:gie,"translation.link":mie,"dock.position":vie,bottom:yie,left:Eie,right:Cie,top:bie,page:wie,"keyboard.shortcuts":Sie,search:xie,loading:Aie,"export.background":kie,transparent:Iie,auto:Die,light:Tie,dark:Pie},Mie="Farve",$ie="Fyld",Rie="Streg",Fie="Størrelse",Lie="Hold åben",Oie="Skrifttype",_ie="Juster",Nie="Format",zie="Zoom ind",Hie="Zoom ud",jie="til",Uie="Værktøjer",Kie="Transformer",Vie="Fil",Gie="Rediger",Jie="Vis",Wie="Indstillinger",Yie="Log ind",qie="Log ud",Xie="Bliv sponsor",Zie="Zoom til valgte",Qie="Zoom til lærred",eoe="Zoom til",toe="Zoom til indhold",noe="Mørkt udseende",roe="Fokus tilstand",ioe="Debug tilstand",ooe="Vis net",aoe="Brug CAD udvælgelse",soe="Hold formatmenuen åben",uoe="Vis altid snaps",loe="Roteringshåndtag",coe="Bindingshåndtag",doe="Kloningshåndtag",hoe="Fortryd",foe="Gentag",poe="Klip",goe="Kopier",moe="Indsæt",voe="Kopier som",yoe="Eksporter som",Eoe="Vælg alt",Coe="Fravælg alt",boe="Slet",woe="Nyt projekt",Soe="Åben",xoe="Gem",Aoe="Gem som",koe="Upload medie",Ioe="Opret side",Doe="Ny side",Toe="Sidenavn",Poe="Dupliker",Boe="Fortryd",Moe="Kopier invitationslink",$oe="Opret multiplayer projekt",Roe="Kopier til multiplayer projekt",Foe="Vælg",Loe="Viskelæder",Ooe="Tegn",_oe="Pil",Noe="Tekst",zoe="Note",Hoe="Rektangel",joe="Ellipse",Uoe="Trekant",Koe="Linje",Voe="Roter",Goe="Lås billedformat",Joe="Frigør billedformat",Woe="Grupper",Yoe="Opdel gruppe",qoe="Placer bagerst",Xoe="Flyt tilbage",Zoe="Flyt frem",Qoe="Læg forrest",eae="Nulstil vinkel",tae="Lås",nae="Lås op",rae="Flyt til side",iae="Vend vandret",oae="Vend lodret",aae="Flyt",sae="Forrest",uae="Frem",lae="Tilbage",cae="Bagerst",dae="Sprog",hae="Justering nederst",fae="Vandret justering centreret",pae="Lodret justering centreret",gae="Juster / distribuer",mae="Justering til venstre",vae="Justering til højre",yae="Justering øverst",Eae="Kopier skrivebeskyttet link",Cae="Vil du gemme ændringerne til dit projekt?",bae="Vil du gemme dit projekt?",wae="Ja",Sae="Nej",xae="Fortryd",Aae="Skriv filnavn",kae="Vandret distribuering",Iae="Lodret distribuering",Dae="Placering af værktøjslinje",Tae="Nederst",Pae="Venstre",Bae="Højre",Mae="Øverst",$ae="Baggrund ved eksport",Rae="Automatisk",Fae="Lys",Lae="Mørk",Oae="Billede",_ae="Tastaturgenveje",Nae="Indlæser",zae="Side",Hae="Søg",jae="Stræk vandret",Uae="Stræk lodret",Kae="Lær mere",Vae="Gennemsigtig",Gae={"style.menu.color":Mie,"style.menu.fill":$ie,"style.menu.dash":Rie,"style.menu.size":Fie,"style.menu.keep.open":Lie,"style.menu.font":Oie,"style.menu.align":_ie,styles:Nie,"zoom.in":zie,"zoom.out":Hie,to:jie,"menu.tools":Uie,"menu.transform":Kie,"menu.file":Vie,"menu.edit":Gie,"menu.view":Jie,"menu.preferences":Wie,"menu.sign.in":Yie,"menu.sign.out":qie,"become.a.sponsor":Xie,"zoom.to.selection":Zie,"zoom.to.fit":Qie,"zoom.to":eoe,"zoom.to.content":toe,"preferences.dark.mode":noe,"preferences.focus.mode":roe,"preferences.debug.mode":ioe,"preferences.show.grid":ooe,"preferences.use.cad.selection":aoe,"preferences.keep.stylemenu.open":soe,"preferences.always.show.snaps":uoe,"preferences.rotate.handles":loe,"preferences.binding.handles":coe,"preferences.clone.handles":doe,undo:hoe,redo:foe,cut:poe,copy:goe,paste:moe,"copy.as":voe,"export.as":yoe,"select.all":Eoe,"select.none":Coe,delete:boe,"new.project":woe,open:Soe,save:xoe,"save.as":Aoe,"upload.media":koe,"create.page":Ioe,"new.page":Doe,"page.name":Toe,duplicate:Poe,cancel:Boe,"copy.invite.link":Moe,"create.multiplayer.project":$oe,"copy.multiplayer.project":Roe,select:Foe,eraser:Loe,draw:Ooe,arrow:_oe,text:Noe,sticky:zoe,rectangle:Hoe,ellipse:joe,triangle:Uoe,line:Koe,rotate:Voe,"lock.aspect.ratio":Goe,"unlock.aspect.ratio":Joe,group:Woe,ungroup:Yoe,"move.to.back":qoe,"move.backward":Xoe,"move.forward":Zoe,"move.to.front":Qoe,"reset.angle":eae,lock:tae,unlock:nae,"move.to.page":rae,"flip.horizontal":iae,"flip.vertical":oae,move:aae,"to.front":sae,forward:uae,backward:lae,back:cae,language:dae,"align.bottom":hae,"align.center.x":fae,"align.center.y":pae,"align.distribute":gae,"align.left":mae,"align.right":vae,"align.top":yae,"copy.readonly.link":Eae,"dialog.save.again":Cae,"dialog.save.firsttime":bae,"dialog.yes":wae,"dialog.no":Sae,"dialog.cancel":xae,"enter.file.name":Aae,"distribute.x":kae,"distribute.y":Iae,"dock.position":Dae,bottom:Tae,left:Pae,right:Bae,top:Mae,"export.background":$ae,auto:Rae,light:Fae,dark:Lae,image:Oae,"keyboard.shortcuts":_ae,loading:Nae,page:zae,search:Hae,"stretch.x":jae,"stretch.y":Uae,"translation.link":Kae,transparent:Vae},Jae="Farbe",Wae="Füllen",Yae="Strich",qae="Größe",Xae="Offen halten",Zae="Schriftart",Qae="Ausrichten",ese="Stile",tse="Heranzoomen",nse="Herauszoomen",rse="zu",ise="Datei",ose="Bearbeiten",ase="Ansicht",sse="Präferenzen",use="Einloggen",lse="Ausloggen",cse="Sponsor werden",dse="Zur Auswahl zoomen",hse="Zoom anpassen",fse="Zoomen nach",pse="Dunkler Modus",gse="Fokus Modus",mse="Debug Modus",vse="Gitter anzeigen",yse="CAD Auswahl verwenden",Ese="Stilmenü offen halten",Cse="Hilfslinien immer anzeigen",bse="Rotiergriffe",wse="Bindegriffe",Sse="Klongriffe",xse="Rückgängig machen",Ase="Wiederherstellen",kse="Ausschneiden",Ise="Kopieren",Dse="Einfügen",Tse="Kopieren als",Pse="Exportieren als",Bse="Alles auswählen",Mse="Nichts auswählen",$se="Löschen",Rse="Neues Projekt",Fse="Öffnen",Lse="Speichern",Ose="Speichern als",_se="Medien hochladen",Nse="Seite erstellen",zse="Neue Seite",Hse="Seitenname",jse="Duplizieren",Use="Abbrechen",Kse="Einladungslink kopieren",Vse="Mehrspielerprojekt kreieren",Gse="In Mehrspielerprojekt kopieren",Jse="Auswählen",Wse="Radierer",Yse="Malen",qse="Pfeil",Xse="Text",Zse="Notiz",Qse="Rechteck",eue="Ellipse",tue="Dreieck",nue="Linie",rue="Drehen",iue="Seitenverhältnis sperren",oue="Seitenverhältnis entsperren",aue="Gruppieren",sue="Gruppierung aufheben",uue="Nach Hinten verschieben",lue="Rückwärts schieben",cue="Vorwärts schieben",due="Nach Vorne verschieben",hue="Winkel zurücksetzen",fue="Sperren",pue="Entsperren",gue="Zu Seite verschieben",mue="Horizontal spiegeln",vue="Vertikal spiegeln",yue="Verschieben",Eue="Nach Vorne",Cue="Vorwärts",bue="Rückwärts",wue="Hinten",Sue="Sprache",xue={"style.menu.color":Jae,"style.menu.fill":Wae,"style.menu.dash":Yae,"style.menu.size":qae,"style.menu.keep.open":Xae,"style.menu.font":Zae,"style.menu.align":Qae,styles:ese,"zoom.in":tse,"zoom.out":nse,to:rse,"menu.file":ise,"menu.edit":ose,"menu.view":ase,"menu.preferences":sse,"menu.sign.in":use,"menu.sign.out":lse,"become.a.sponsor":cse,"zoom.to.selection":dse,"zoom.to.fit":hse,"zoom.to":fse,"preferences.dark.mode":pse,"preferences.focus.mode":gse,"preferences.debug.mode":mse,"preferences.show.grid":vse,"preferences.use.cad.selection":yse,"preferences.keep.stylemenu.open":Ese,"preferences.always.show.snaps":Cse,"preferences.rotate.handles":bse,"preferences.binding.handles":wse,"preferences.clone.handles":Sse,undo:xse,redo:Ase,cut:kse,copy:Ise,paste:Dse,"copy.as":Tse,"export.as":Pse,"select.all":Bse,"select.none":Mse,delete:$se,"new.project":Rse,open:Fse,save:Lse,"save.as":Ose,"upload.media":_se,"create.page":Nse,"new.page":zse,"page.name":Hse,duplicate:jse,cancel:Use,"copy.invite.link":Kse,"create.multiplayer.project":Vse,"copy.multiplayer.project":Gse,select:Jse,eraser:Wse,draw:Yse,arrow:qse,text:Xse,sticky:Zse,rectangle:Qse,ellipse:eue,triangle:tue,line:nue,rotate:rue,"lock.aspect.ratio":iue,"unlock.aspect.ratio":oue,group:aue,ungroup:sue,"move.to.back":uue,"move.backward":lue,"move.forward":cue,"move.to.front":due,"reset.angle":hue,lock:fue,unlock:pue,"move.to.page":gue,"flip.horizontal":mue,"flip.vertical":vue,move:yue,"to.front":Eue,forward:Cue,backward:bue,back:wue,language:Sue},Aue={},kue="Color",Iue="Relleno",Due="Línea",Tue="Tamaño",Pue="Mantener abierto",Bue="Fuente",Mue="Alineación",$ue="Estilos",Rue="Acercar",Fue="Alejar",Lue="A",Oue="Archivo",_ue="Editar",Nue="Ver",zue="Preferencias",Hue="Iniciar sesión",jue="Cerrar sesión",Uue="Conviértete en patrocinador",Kue="Acercar al contenido",Vue="Acercar a la selección",Gue="Ajustar a la ventana",Jue="Acercar a",Wue="Modo oscuro",Yue="Modo concentración",que="Modo depuración",Xue="Mostrar cuadrícula",Zue="Usar selección CAD",Que="Mantener menú de estilos abierto",ele="Mostrar puntos de ajuste",tle="Control de rotación",nle="Control de vinculación",rle="Control de clonación",ile="Deshacer",ole="Rehacer",ale="Cortar",sle="Copiar",ule="Pegar",lle="Copiar como",cle="Exportar como",dle="Selecionar todo",hle="Selecionar nada",fle="Borrar",ple="Nuevo Proyecto",gle="Abrir",mle="Guardar",vle="Guardar como",yle="Subir medios",Ele="Crear página",Cle="Nueva página",ble="Nombre de página",wle="Duplicar",Sle="Cancelar",xle="Copiar invitación",Ale="Copiar invitación (solo lectura)",kle="Crear proyecto multijugador",Ile="Copiar proyecto multijugador",Dle="Seleccionar",Tle="Borrador",Ple="Dibujar",Ble="Flecha",Mle="Texto",$le="Pegatina",Rle="Rectángulo",Fle="Elipse",Lle="Triángulo",Ole="Línea",_le="Rotar",Nle="Bloquear relación de aspecto",zle="Desbloquear relación de aspecto",Hle="Agrupar",jle="Desagrupar",Ule="Mover al fondo",Kle="Mover atrás",Vle="Mover adelante",Gle="Mover al frente",Jle="Restablecer ángulo",Wle="Bloquear",Yle="Desbloquear",qle="Mover a página",Xle="Voltear horizontalmente",Zle="Voltear verticalmente",Qle="Mover",ece="Al frente",tce="Adelante",nce="Atrás",rce="Fondo",ice="Idioma",oce="Saber más",ace="Posición del dock",sce="Abajo",uce="Atajos de teclado",lce="Cargando{dots}",cce="Izquierda",dce="Derecha",hce="Arriba",fce="Buscar",pce="Página",gce="Imagen",mce={"style.menu.color":kue,"style.menu.fill":Iue,"style.menu.dash":Due,"style.menu.size":Tue,"style.menu.keep.open":Pue,"style.menu.font":Bue,"style.menu.align":Mue,styles:$ue,"zoom.in":Rue,"zoom.out":Fue,to:Lue,"menu.file":Oue,"menu.edit":_ue,"menu.view":Nue,"menu.preferences":zue,"menu.sign.in":Hue,"menu.sign.out":jue,"become.a.sponsor":Uue,"zoom.to.content":Kue,"zoom.to.selection":Vue,"zoom.to.fit":Gue,"zoom.to":Jue,"preferences.dark.mode":Wue,"preferences.focus.mode":Yue,"preferences.debug.mode":que,"preferences.show.grid":Xue,"preferences.use.cad.selection":Zue,"preferences.keep.stylemenu.open":Que,"preferences.always.show.snaps":ele,"preferences.rotate.handles":tle,"preferences.binding.handles":nle,"preferences.clone.handles":rle,undo:ile,redo:ole,cut:ale,copy:sle,paste:ule,"copy.as":lle,"export.as":cle,"select.all":dle,"select.none":hle,delete:fle,"new.project":ple,open:gle,save:mle,"save.as":vle,"upload.media":yle,"create.page":Ele,"new.page":Cle,"page.name":ble,duplicate:wle,cancel:Sle,"copy.invite.link":xle,"copy.readonly.link":Ale,"create.multiplayer.project":kle,"copy.multiplayer.project":Ile,select:Dle,eraser:Tle,draw:Ple,arrow:Ble,text:Mle,sticky:$le,rectangle:Rle,ellipse:Fle,triangle:Lle,line:Ole,rotate:_le,"lock.aspect.ratio":Nle,"unlock.aspect.ratio":zle,group:Hle,ungroup:jle,"move.to.back":Ule,"move.backward":Kle,"move.forward":Vle,"move.to.front":Gle,"reset.angle":Jle,lock:Wle,unlock:Yle,"move.to.page":qle,"flip.horizontal":Xle,"flip.vertical":Zle,move:Qle,"to.front":ece,forward:tce,backward:nce,back:rce,language:ice,"translation.link":oce,"dock.position":ace,bottom:sce,"keyboard.shortcuts":uce,loading:lce,left:cce,right:dce,top:hce,search:fce,page:pce,image:gce},vce="رنگ",yce="توپُر",Ece="خط‌ چین",Cce="اندازه",bce="باز باش",wce="فونت",Sce="تراز",xce="استایل‌ها",Ace="زوم جلو",kce="زوم عقب",Ice="به",Dce="فایل",Tce="ویرایش",Pce="نمایش",Bce="تنظیم‌ها",Mce="ورود",$ce="خروج",Rce=" حامی شو",Fce="نمایش انتخاب‌شده‌ها",Lce="نمایش کل صفحه",Oce="زوم به ",_ce="حالت شب",Nce="حالت تمرکز",zce="حالت عیب‌یایی",Hce="نمایش خطوط راهنما",jce="استفاده از حالت انتخابی CAD",Uce="منوی استایل باز باشه",Kce="راهنمای لبه‌ها رو نشون بده",Vce="دستگیره‌های چرخش رو نشون بده",Gce="دستهٔ لبه‌ها رو نشون بده",Jce="دستگیره‌های کپی رو نشون بده",Wce="یه قدم عقب",Yce="یه قدم جلو",qce="بریدن",Xce="کپی",Zce="جای‌گذاری",Qce="کپی به‌‌عنوان",ede="خروجی با فرمت",tde="انتخاب همه",nde="انتخاب هیچ",rde=" پاک‌کردن",ide="پروژهٔ تازه",ode="باز کن",ade="ذخیره",sde="ذخیره با اسم",ude="آپلود عکس",lde="ساخت صفحه",cde="صفحهٔ تازه",dde="اسم صفحه",hde="کپی درجا",fde="بی‌خیال",pde="کپی لینک دعوت",gde="ساخت پروژهٔ چندنفره",mde="کپی در پروژهٔ چندنفره",vde="انتخاب",yde="پاک‌کن",Ede="رسم",Cde="فلِش",bde="متن",wde="یادداشت",Sde="چارگوش",xde="گردی",Ade="سه‌گوش",kde="خط",Ide="چرخش",Dde="تثبیت نسبت ابعاد",Tde="نسبت ابعاد متغیر",Pde="جمع کن",Bde="جدا کن",Mde="ببر آخر",$de="ببر عقب",Rde="ببر اول",Fde="ببر جلو",Lde="حذف چرخش",Ode="قفل‌ کن",_de="باز کن",Nde="ببر به صفحه",zde="برگردون افقی",Hde="برگردون عمودی",jde="جابه‌جاش کن",Ude="به اول",Kde="به جلو",Vde="به عقب",Gde="به آخر",Jde="زبان",Wde={"style.menu.color":vce,"style.menu.fill":yce,"style.menu.dash":Ece,"style.menu.size":Cce,"style.menu.keep.open":bce,"style.menu.font":wce,"style.menu.align":Sce,styles:xce,"zoom.in":Ace,"zoom.out":kce,to:Ice,"menu.file":Dce,"menu.edit":Tce,"menu.view":Pce,"menu.preferences":Bce,"menu.sign.in":Mce,"menu.sign.out":$ce,"become.a.sponsor":Rce,"zoom.to.selection":Fce,"zoom.to.fit":Lce,"zoom.to":Oce,"preferences.dark.mode":_ce,"preferences.focus.mode":Nce,"preferences.debug.mode":zce,"preferences.show.grid":Hce,"preferences.use.cad.selection":jce,"preferences.keep.stylemenu.open":Uce,"preferences.always.show.snaps":Kce,"preferences.rotate.handles":Vce,"preferences.binding.handles":Gce,"preferences.clone.handles":Jce,undo:Wce,redo:Yce,cut:qce,copy:Xce,paste:Zce,"copy.as":Qce,"export.as":ede,"select.all":tde,"select.none":nde,delete:rde,"new.project":ide,open:ode,save:ade,"save.as":sde,"upload.media":ude,"create.page":lde,"new.page":cde,"page.name":dde,duplicate:hde,cancel:fde,"copy.invite.link":pde,"create.multiplayer.project":gde,"copy.multiplayer.project":mde,select:vde,eraser:yde,draw:Ede,arrow:Cde,text:bde,sticky:wde,rectangle:Sde,ellipse:xde,triangle:Ade,line:kde,rotate:Ide,"lock.aspect.ratio":Dde,"unlock.aspect.ratio":Tde,group:Pde,ungroup:Bde,"move.to.back":Mde,"move.backward":$de,"move.forward":Rde,"move.to.front":Fde,"reset.angle":Lde,lock:Ode,unlock:_de,"move.to.page":Nde,"flip.horizontal":zde,"flip.vertical":Hde,move:jde,"to.front":Ude,forward:Kde,backward:Vde,back:Gde,language:Jde},Yde="Couleur",qde="Remplir",Xde="Bordure",Zde="Taille",Qde="Toujours afficher le menu",e0e="Police",t0e="Alignement",n0e="Styles",r0e="Zoom avant",i0e="Zoom arrière",o0e="À",a0e="Outils",s0e="Transformation",u0e="Fichier",l0e="Édition",c0e="Afficher",d0e="Préférences",h0e="S'authentifier",f0e="Se déconnecter",p0e="Devenir un sponsor",g0e="Retour au contenu",m0e="Ajuster le zoom à la sélection",v0e="Adapter le zoom au contenu",y0e="Rétablir le zoom à",E0e="Mode sombre",C0e="Mode focus",b0e="Afficher la barre développeur",w0e="Afficher la grille",S0e="Utiliser la sélection CAD",x0e="Toujours afficher le menu styles",A0e="Afficher les repères dynamiques",k0e="Manier la rotation",I0e="Manier les liaisons",D0e="Manier le clonage",T0e="Annuler",P0e="Rétablir",B0e="Couper",M0e="Copier",$0e="Coller",R0e="Copier au format",F0e="Exporter au format",L0e="Tout sélectionner",O0e="Tout désélectionner",_0e="Supprimer",N0e="Nouveau project",z0e="Ouvrir",H0e="Enregistrer",j0e="Enregistrer sous",U0e="Importer un média",K0e="Créer une page",V0e="Nouvelle Page",G0e="Nom de la page",J0e="Dupliquer",W0e="Annuler",Y0e="Copier le lien d'invitation",q0e="Copier le lien en lecture seule d'invitation",X0e="Créer un project multi-joueurs",Z0e="Copier dans un projet multi-joueurs",Q0e="Sélection",ehe="Gomme",the="Crayon",nhe="Flèche",rhe="Texte",ihe="Note",ohe="Rectangle",ahe="Cercle",she="Triangle",uhe="Ligne",lhe="Rotation",che="Verrouiller les proportions",dhe="Déverrouiller les proportions",hhe="Grouper",fhe="Dégrouper",phe="Déplacer à l'arrière-plan",ghe="Reculer d'un plan",mhe="Avancer d'un plan",vhe="Placer au premier plan",yhe="Réinitialiser la rotation",Ehe="Verrouiller",Che="Déverrouiller",bhe="Alignement / Répartion",whe="Déplacer vers la page",She="Retourner horizontalement",xhe="Retourner verticalement",Ahe="Disposition",khe="Placer au premier plan",Ihe="Avancer d'un plan",Dhe="Reculer d'un plan",The="Déplacer à l'arrière-plan",Phe="Langage",Bhe="En savoir plus",Mhe="Position du dock",$he="En bas",Rhe="À gauche",Fhe="À droite",Lhe="En haut",Ohe="Page",_he="Raccourcis clavier",Nhe="Rechercher",zhe="Chargement{dots}",Hhe="Couleur d'arrière-plan de l'export",jhe="Transparent",Uhe="Automatique",Khe="Clair",Vhe="Sombre",Ghe={"style.menu.color":Yde,"style.menu.fill":qde,"style.menu.dash":Xde,"style.menu.size":Zde,"style.menu.keep.open":Qde,"style.menu.font":e0e,"style.menu.align":t0e,styles:n0e,"zoom.in":r0e,"zoom.out":i0e,to:o0e,"menu.tools":a0e,"menu.transform":s0e,"menu.file":u0e,"menu.edit":l0e,"menu.view":c0e,"menu.preferences":d0e,"menu.sign.in":h0e,"menu.sign.out":f0e,"become.a.sponsor":p0e,"zoom.to.content":g0e,"zoom.to.selection":m0e,"zoom.to.fit":v0e,"zoom.to":y0e,"preferences.dark.mode":E0e,"preferences.focus.mode":C0e,"preferences.debug.mode":b0e,"preferences.show.grid":w0e,"preferences.use.cad.selection":S0e,"preferences.keep.stylemenu.open":x0e,"preferences.always.show.snaps":A0e,"preferences.rotate.handles":k0e,"preferences.binding.handles":I0e,"preferences.clone.handles":D0e,undo:T0e,redo:P0e,cut:B0e,copy:M0e,paste:$0e,"copy.as":R0e,"export.as":F0e,"select.all":L0e,"select.none":O0e,delete:_0e,"new.project":N0e,open:z0e,save:H0e,"save.as":j0e,"upload.media":U0e,"create.page":K0e,"new.page":V0e,"page.name":G0e,duplicate:J0e,cancel:W0e,"copy.invite.link":Y0e,"copy.readonly.link":q0e,"create.multiplayer.project":X0e,"copy.multiplayer.project":Z0e,select:Q0e,eraser:ehe,draw:the,arrow:nhe,text:rhe,sticky:ihe,rectangle:ohe,ellipse:ahe,triangle:she,line:uhe,rotate:lhe,"lock.aspect.ratio":che,"unlock.aspect.ratio":dhe,group:hhe,ungroup:fhe,"move.to.back":phe,"move.backward":ghe,"move.forward":mhe,"move.to.front":vhe,"reset.angle":yhe,lock:Ehe,unlock:Che,"align.distribute":bhe,"move.to.page":whe,"flip.horizontal":She,"flip.vertical":xhe,move:Ahe,"to.front":khe,forward:Ihe,backward:Dhe,back:The,language:Phe,"translation.link":Bhe,"dock.position":Mhe,bottom:$he,left:Rhe,right:Fhe,top:Lhe,page:Ohe,"keyboard.shortcuts":_he,search:Nhe,loading:zhe,"export.background":Hhe,transparent:jhe,auto:Uhe,light:Khe,dark:Vhe},Jhe="צבע",Whe="מלא",Yhe="גבול",qhe="גודל",Xhe="השאר פתוח",Zhe="גופן",Qhe="יישור",efe="עיצוב",tfe="הגדל תצוגה",nfe="הקטן תצוגה",rfe="ל",ife="קובץ",ofe="עריכה",afe="תצוגה",sfe="מאפיינים",ufe="הירשם",lfe="התנתק",cfe="מתן חסות",dfe="זום לבחירה",hfe="זום להתאמה",ffe="זום ל",pfe="מצב חשוך",gfe="מצב פוקוס",mfe="מצב דיבאג",vfe="(גריד)הראה רשת עימוד",yfe="סימון CAD",Efe="השאר תפריט עיצוב פתוח",Cfe="הראה קווי מתאר",bfe="הראה ידיות סיבוב",wfe="הראה ידיות קשירה",Sfe="הראה ידיות שיכפול",xfe="בטל",Afe="עשה מחדש",kfe="גזור",Ife="העתק",Dfe="הדבק",Tfe="העתק כ",Pfe="ייצא כ",Bfe="בחר הכל",Mfe="בטל בחירה",$fe="מחק",Rfe="פרויקט חדש",Ffe="פתח",Lfe="שמור",Ofe="שמור כ",_fe="העלאת מדיה",Nfe="צור דף",zfe="דף חדש",Hfe="שם הדף",jfe="שכפל",Ufe="בטל",Kfe="העתק קישור הזמנה",Vfe="צור פרויקט רב משתתפים",Gfe="העתק לפרויקט רב משתתפים",Jfe="סמן",Wfe="מחק",Yfe="צייר",qfe="חץ",Xfe="טקסט",Zfe="דביקי",Qfe="מרובע",epe="אליפסה",tpe="משולש",npe="קו",rpe="סובב",ipe="נעל יחס רוחב-גובה",ope="שחרר נעילת יחס רוחב-גובה",ape="קבץ",spe="בטל קיבוץ",upe="הבא לתחתית",lpe="הזז אחורה",cpe="הזז קדימה",dpe="הבא לחזית",hpe="אפס זווית",fpe="נעל",ppe="שחרר נעילה",gpe="הזז לדף",mpe="הפוך אופקית",vpe="הפוך אנכית",ype="הזז",Epe="הבא לקדימה",Cpe="קדימה",bpe="אחורה",wpe="בחזרה",Spe="שפה",xpe={"style.menu.color":Jhe,"style.menu.fill":Whe,"style.menu.dash":Yhe,"style.menu.size":qhe,"style.menu.keep.open":Xhe,"style.menu.font":Zhe,"style.menu.align":Qhe,styles:efe,"zoom.in":tfe,"zoom.out":nfe,to:rfe,"menu.file":ife,"menu.edit":ofe,"menu.view":afe,"menu.preferences":sfe,"menu.sign.in":ufe,"menu.sign.out":lfe,"become.a.sponsor":cfe,"zoom.to.selection":dfe,"zoom.to.fit":hfe,"zoom.to":ffe,"preferences.dark.mode":pfe,"preferences.focus.mode":gfe,"preferences.debug.mode":mfe,"preferences.show.grid":vfe,"preferences.use.cad.selection":yfe,"preferences.keep.stylemenu.open":Efe,"preferences.always.show.snaps":Cfe,"preferences.rotate.handles":bfe,"preferences.binding.handles":wfe,"preferences.clone.handles":Sfe,undo:xfe,redo:Afe,cut:kfe,copy:Ife,paste:Dfe,"copy.as":Tfe,"export.as":Pfe,"select.all":Bfe,"select.none":Mfe,delete:$fe,"new.project":Rfe,open:Ffe,save:Lfe,"save.as":Ofe,"upload.media":_fe,"create.page":Nfe,"new.page":zfe,"page.name":Hfe,duplicate:jfe,cancel:Ufe,"copy.invite.link":Kfe,"create.multiplayer.project":Vfe,"copy.multiplayer.project":Gfe,select:Jfe,eraser:Wfe,draw:Yfe,arrow:qfe,text:Xfe,sticky:Zfe,rectangle:Qfe,ellipse:epe,triangle:tpe,line:npe,rotate:rpe,"lock.aspect.ratio":ipe,"unlock.aspect.ratio":ope,group:ape,ungroup:spe,"move.to.back":upe,"move.backward":lpe,"move.forward":cpe,"move.to.front":dpe,"reset.angle":hpe,lock:fpe,unlock:ppe,"move.to.page":gpe,"flip.horizontal":mpe,"flip.vertical":vpe,move:ype,"to.front":Epe,forward:Cpe,backward:bpe,back:wpe,language:Spe},Ape="Colore",kpe="Riempi",Ipe="Tratteggo",Dpe="Dimensione",Tpe="Mantieni aperto",Ppe="Font",Bpe="Allineamento",Mpe="Stile",$pe="Ingrandisci",Rpe="Rimpicciolisci",Fpe="Imposta",Lpe="File",Ope="Modifica",_pe="Visualizzazione",Npe="Preferenze",zpe="Accedi",Hpe="Esci",jpe="Sponsorizza",Upe="Adatta alla selezione",Kpe="Adatta",Vpe="Ingrandisci",Gpe="Modalità scura",Jpe="Modalità zen",Wpe="Modalità sviluppatore",Ype="Mostra griglia",qpe="Selezione CAD",Xpe="Mantieni menu stile aperto",Zpe="Mostra sempre le guide",Qpe="Controlli d'inclinazione",ege="Controlli d'associazione",tge="Controlli di clonazione",nge="Annulla",rge="Ripristina",ige="Taglia",oge="Copia",age="Incolla",sge="Copia come",uge="Esporta come",lge="Seleziona tutto",cge="Deseleziona tutto",dge="Elimina",hge="Nuovo progetto",fge="Apri",pge="Salva",gge="Salva come",mge="Carica contenuti multimediali",vge="Crea nuova pagina",yge="Nuova pagina",Ege="Nome pagina",Cge="Pagina",bge="Duplica",wge="Chiudi",Sge="Copia link invito",xge="Crea progetto multiplayer",Age="Trasforma in progetto multiplayer",kge="Seleziona",Ige="Gomma",Dge="Matita",Tge="Freccia",Pge="Casella di testo",Bge="Post-it",Mge="Rettangolo",$ge="Ellisse",Rge="Triangolo",Fge="Linea",Lge="Ruota",Oge="Blocca rapporto lati",_ge="Sblocca rapporto lati",Nge="Raggruppa",zge="Separa",Hge="Muovi in fondo",jge="Sposta indietro",Uge="Sposta avanti",Kge="Muovi in fronte",Vge="Reimposta angolo",Gge="Blocca",Jge="Sblocca",Wge="Trasferisci a pagina",Yge="Ribalta orizzontalmente",qge="Ribalta verticalmente",Xge="Sposta",Zge="In primo piano",Qge="Sposta avanti",eme="Sposta indietro",tme="In fondo",nme="Lingua",rme="Posizione dock",ime="In basso",ome="Sinistra",ame="Destra",sme="In Alto",ume={"style.menu.color":Ape,"style.menu.fill":kpe,"style.menu.dash":Ipe,"style.menu.size":Dpe,"style.menu.keep.open":Tpe,"style.menu.font":Ppe,"style.menu.align":Bpe,styles:Mpe,"zoom.in":$pe,"zoom.out":Rpe,to:Fpe,"menu.file":Lpe,"menu.edit":Ope,"menu.view":_pe,"menu.preferences":Npe,"menu.sign.in":zpe,"menu.sign.out":Hpe,"become.a.sponsor":jpe,"zoom.to.selection":Upe,"zoom.to.fit":Kpe,"zoom.to":Vpe,"preferences.dark.mode":Gpe,"preferences.focus.mode":Jpe,"preferences.debug.mode":Wpe,"preferences.show.grid":Ype,"preferences.use.cad.selection":qpe,"preferences.keep.stylemenu.open":Xpe,"preferences.always.show.snaps":Zpe,"preferences.rotate.handles":Qpe,"preferences.binding.handles":ege,"preferences.clone.handles":tge,undo:nge,redo:rge,cut:ige,copy:oge,paste:age,"copy.as":sge,"export.as":uge,"select.all":lge,"select.none":cge,delete:dge,"new.project":hge,open:fge,save:pge,"save.as":gge,"upload.media":mge,"create.page":vge,"new.page":yge,"page.name":Ege,page:Cge,duplicate:bge,cancel:wge,"copy.invite.link":Sge,"create.multiplayer.project":xge,"copy.multiplayer.project":Age,select:kge,eraser:Ige,draw:Dge,arrow:Tge,text:Pge,sticky:Bge,rectangle:Mge,ellipse:$ge,triangle:Rge,line:Fge,rotate:Lge,"lock.aspect.ratio":Oge,"unlock.aspect.ratio":_ge,group:Nge,ungroup:zge,"move.to.back":Hge,"move.backward":jge,"move.forward":Uge,"move.to.front":Kge,"reset.angle":Vge,lock:Gge,unlock:Jge,"move.to.page":Wge,"flip.horizontal":Yge,"flip.vertical":qge,move:Xge,"to.front":Zge,forward:Qge,backward:eme,back:tme,language:nme,"dock.position":rme,bottom:ime,left:ome,right:ame,top:sme},lme="色",cme="塗りつぶし",dme="線",hme="大きさ",fme="常に表示",pme="フォント",gme="配置",mme="スタイル",vme="拡大",yme="縮小",Eme=" ",Cme="ファイル",bme="編集",wme="表示",Sme="設定",xme="サインイン",Ame="サインアウト",kme="支援する",Ime="選択したアイテムに合わせて拡大",Dme="拡大してすべてを表示",Tme=" ",Pme="ダークモード",Bme="フォーカスモード",Mme="デバッグモード",$me="グリッドを表示",Rme="CADの選択法を使用",Fme="スタイルメニューを常に表示",Lme="スナップを常に表示",Ome="回転ハンドルを表示",_me="結合ハンドルを表示",Nme="クローンハンドルを表示",zme="元に戻す",Hme="やり直し",jme="切り取り",Ume="コピー",Kme="貼り付け",Vme="形式を選択してコピー",Gme="形式を選択してエクスポート",Jme="すべて選択",Wme="選択を解除",Yme="削除",qme="新しいプロジェクト",Xme="開く",Zme="保存",Qme="名前をつけて保存",e1e="メディアをアップロード",t1e="ページを作成",n1e="新規ページ",r1e="ページ名",i1e="複製",o1e="キャンセル",a1e="共有リンクをクリップボードにコピー",s1e="マルチプレイヤープロジェクトを作成",u1e="マルチプレイヤープロジェクトにコピー",l1e="選択",c1e="消しゴム",d1e="描画",h1e="矢印",f1e="テキスト",p1e="ふせん",g1e="長方形",m1e="楕円形",v1e="三角形",y1e="線",E1e="回転",C1e="縦横比を固定",b1e="縦横比の固定を解除",w1e="グルーピング",S1e="グループ解除",x1e="最後面に移動",A1e="ひとつ後ろに移動",k1e="ひとつ前に移動",I1e="最背面に移動",D1e="角度を初期化",T1e="ロック",P1e="アンロック",B1e="ページへ移動",M1e="水平方向に反転",$1e="垂直方向に反転",R1e="移動",F1e="最前面へ",L1e="ひとつ前へ",O1e="ひとつ後ろへ",_1e="最背面へ",N1e="言語",z1e={"style.menu.color":lme,"style.menu.fill":cme,"style.menu.dash":dme,"style.menu.size":hme,"style.menu.keep.open":fme,"style.menu.font":pme,"style.menu.align":gme,styles:mme,"zoom.in":vme,"zoom.out":yme,to:Eme,"menu.file":Cme,"menu.edit":bme,"menu.view":wme,"menu.preferences":Sme,"menu.sign.in":xme,"menu.sign.out":Ame,"become.a.sponsor":kme,"zoom.to.selection":Ime,"zoom.to.fit":Dme,"zoom.to":Tme,"preferences.dark.mode":Pme,"preferences.focus.mode":Bme,"preferences.debug.mode":Mme,"preferences.show.grid":$me,"preferences.use.cad.selection":Rme,"preferences.keep.stylemenu.open":Fme,"preferences.always.show.snaps":Lme,"preferences.rotate.handles":Ome,"preferences.binding.handles":_me,"preferences.clone.handles":Nme,undo:zme,redo:Hme,cut:jme,copy:Ume,paste:Kme,"copy.as":Vme,"export.as":Gme,"select.all":Jme,"select.none":Wme,delete:Yme,"new.project":qme,open:Xme,save:Zme,"save.as":Qme,"upload.media":e1e,"create.page":t1e,"new.page":n1e,"page.name":r1e,duplicate:i1e,cancel:o1e,"copy.invite.link":a1e,"create.multiplayer.project":s1e,"copy.multiplayer.project":u1e,select:l1e,eraser:c1e,draw:d1e,arrow:h1e,text:f1e,sticky:p1e,rectangle:g1e,ellipse:m1e,triangle:v1e,line:y1e,rotate:E1e,"lock.aspect.ratio":C1e,"unlock.aspect.ratio":b1e,group:w1e,ungroup:S1e,"move.to.back":x1e,"move.backward":A1e,"move.forward":k1e,"move.to.front":I1e,"reset.angle":D1e,lock:T1e,unlock:P1e,"move.to.page":B1e,"flip.horizontal":M1e,"flip.vertical":$1e,move:R1e,"to.front":F1e,forward:L1e,backward:O1e,back:_1e,language:N1e},H1e="색깔",j1e="채우기",U1e="테두리",K1e="크기",V1e="항상 열기",G1e="글꼴",J1e="정렬",W1e="스타일",Y1e="확대",q1e="축소",X1e="to",Z1e="파일",Q1e="편집",e4e="보기",t4e="설정",n4e="로그인",r4e="로그아웃",i4e="후원자 되기",o4e="선택 요소 맞추기",a4e="전체 맞추기",s4e="맞추기",u4e="다크 모드",l4e="집중 모드",c4e="디버그 모드",d4e="격자 보기",h4e="CAD 선택 사용",f4e="스타일 메뉴 항상 열기",p4e="Snap 항상 열기",g4e="회전 보이기",m4e="Binding Handles",v4e="복제 보이기",y4e="실행 취소",E4e="다시 실행",C4e="자르기",b4e="복사",w4e="붙여넣기",S4e="다른 형식으로 복사하기",x4e="내보내기",A4e="전체 선택",k4e="선택 안함",I4e="삭제하기",D4e="새 프로젝트",T4e="열기",P4e="저장",B4e="다른 이름으로 저장",M4e="미디어 업로드",$4e="새 페이지 만들기",R4e="새 페이지",F4e="페이지 이름",L4e="복제",O4e="취소",_4e="초대 링크 복사하기",N4e="공동 프로젝트 만들기",z4e="공동 프로젝트로 복사하기",H4e="선택",j4e="지우개",U4e="그리기",K4e="화살표",V4e="텍스트",G4e="메모",J4e="사각형",W4e="원",Y4e="삼각형",q4e="선",X4e="회전",Z4e="비율 잠금",Q4e="비율 잠금 해제",eve="그룹화",tve="그룹화 해제",nve="맨 뒤로 보내기",rve="뒤로 보내기",ive="앞으로 가져오기",ove="맨 앞으로 가져오기",ave="회전 초기화",sve="잠구기",uve="잠금 해제하기",lve="페이지로 이동",cve="수평으로 뒤집기",dve="수직으로 뒤집기",hve="순서",fve="맨 앞으로",pve="앞으로",gve="뒤로",mve="맨 뒤로",vve="언어",yve={"style.menu.color":H1e,"style.menu.fill":j1e,"style.menu.dash":U1e,"style.menu.size":K1e,"style.menu.keep.open":V1e,"style.menu.font":G1e,"style.menu.align":J1e,styles:W1e,"zoom.in":Y1e,"zoom.out":q1e,to:X1e,"menu.file":Z1e,"menu.edit":Q1e,"menu.view":e4e,"menu.preferences":t4e,"menu.sign.in":n4e,"menu.sign.out":r4e,"become.a.sponsor":i4e,"zoom.to.selection":o4e,"zoom.to.fit":a4e,"zoom.to":s4e,"preferences.dark.mode":u4e,"preferences.focus.mode":l4e,"preferences.debug.mode":c4e,"preferences.show.grid":d4e,"preferences.use.cad.selection":h4e,"preferences.keep.stylemenu.open":f4e,"preferences.always.show.snaps":p4e,"preferences.rotate.handles":g4e,"preferences.binding.handles":m4e,"preferences.clone.handles":v4e,undo:y4e,redo:E4e,cut:C4e,copy:b4e,paste:w4e,"copy.as":S4e,"export.as":x4e,"select.all":A4e,"select.none":k4e,delete:I4e,"new.project":D4e,open:T4e,save:P4e,"save.as":B4e,"upload.media":M4e,"create.page":$4e,"new.page":R4e,"page.name":F4e,duplicate:L4e,cancel:O4e,"copy.invite.link":_4e,"create.multiplayer.project":N4e,"copy.multiplayer.project":z4e,select:H4e,eraser:j4e,draw:U4e,arrow:K4e,text:V4e,sticky:G4e,rectangle:J4e,ellipse:W4e,triangle:Y4e,line:q4e,rotate:X4e,"lock.aspect.ratio":Z4e,"unlock.aspect.ratio":Q4e,group:eve,ungroup:tve,"move.to.back":nve,"move.backward":rve,"move.forward":ive,"move.to.front":ove,"reset.angle":ave,lock:sve,unlock:uve,"move.to.page":lve,"flip.horizontal":cve,"flip.vertical":dve,move:hve,"to.front":fve,forward:pve,backward:gve,back:mve,language:vve},Eve="Color",Cve="Fill",bve="Dash",wve="Size",Sve="Keep Open",xve="Font",Ave="Align",kve="Styles",Ive="Zoom In",Dve="Zoom Out",Tve="To",Pve="Tools",Bve="Transform",Mve="File",$ve="Edit",Rve="View",Fve="Preferences",Lve="Sign In",Ove="Sign Out",_ve="Become a Sponsor",Nve="Back to content",zve="Zoom to Selection",Hve="Zoom to Fit",jve="Zoom to",Uve="Dark Mode",Kve="Focus Mode",Vve="Debug Mode",Gve="Show Grid",Jve="Use CAD Selection",Wve="Keep Style Menu Open",Yve="Always Show Snaps",qve="Rotate Handles",Xve="Binding Handles",Zve="Clone Handles",Qve="Undo",e2e="Redo",t2e="Cut",n2e="Copy",r2e="Paste",i2e="Copy As",o2e="Export As",a2e="Select All",s2e="Select None",u2e="Delete",l2e="New Project",c2e="Open",d2e="Save",h2e="Save As",f2e="Upload Media",p2e="Create Page",g2e="New Page",m2e="Page Name",v2e="Duplicate",y2e="Cancel",E2e="Copy Invite Link",C2e="Copy ReadOnly Link",b2e="Create a Multiplayer Project",w2e="Copy to Multiplayer Project",S2e="Select",x2e="Eraser",A2e="Draw",k2e="Arrow",I2e="Text",D2e="Sticky",T2e="Rectangle",P2e="Ellipse",B2e="Triangle",M2e="Line",$2e="Rotate",R2e="Lock Aspect Ratio",F2e="Unlock Aspect Ratio",L2e="Group",O2e="Ungroup",_2e="Move to Back",N2e="Move Backward",z2e="Move Forward",H2e="Move to Front",j2e="Reset Angle",U2e="Lock",K2e="Unlock",V2e="Align / Distribute",G2e="Move to Page",J2e="Flip Horizontal",W2e="Flip Vertical",Y2e="Move",q2e="To Front",X2e="Forward",Z2e="Backward",Q2e="To Back",eye="Language",tye="Learn More",nye="Dock Position",rye="Bottom",iye="Left",oye="Right",aye="Top",sye="Page",uye="Keyboard shortcuts",lye="Search",cye="Loading{dots}",dye="Export Background",hye="Transparent",fye="Auto",pye="Light",gye="Dark",mye="Github",vye="Twitter",yye="Discord",Eye="Image",Cye="Align Left",bye="Align Horizontal Center",wye="Align Right",Sye="Align Top",xye="Align Vertical Center",Aye="Align Bottom",kye="Distribute Horizontal",Iye="Distribute Vertical",Dye="Stretch Horizontal",Tye="Stretch Vertical",Pye="Do you want to save your current project?",Bye="Do you want to save changes to your current project?",Mye="Cancel",$ye="No",Rye="Yes",Fye="Enter file name",Lye="Try the new tldraw",Oye={"style.menu.color":Eve,"style.menu.fill":Cve,"style.menu.dash":bve,"style.menu.size":wve,"style.menu.keep.open":Sve,"style.menu.font":xve,"style.menu.align":Ave,styles:kve,"zoom.in":Ive,"zoom.out":Dve,to:Tve,"menu.tools":Pve,"menu.transform":Bve,"menu.file":Mve,"menu.edit":$ve,"menu.view":Rve,"menu.preferences":Fve,"menu.sign.in":Lve,"menu.sign.out":Ove,"become.a.sponsor":_ve,"zoom.to.content":Nve,"zoom.to.selection":zve,"zoom.to.fit":Hve,"zoom.to":jve,"preferences.dark.mode":Uve,"preferences.focus.mode":Kve,"preferences.debug.mode":Vve,"preferences.show.grid":Gve,"preferences.use.cad.selection":Jve,"preferences.keep.stylemenu.open":Wve,"preferences.always.show.snaps":Yve,"preferences.rotate.handles":qve,"preferences.binding.handles":Xve,"preferences.clone.handles":Zve,undo:Qve,redo:e2e,cut:t2e,copy:n2e,paste:r2e,"copy.as":i2e,"export.as":o2e,"select.all":a2e,"select.none":s2e,delete:u2e,"new.project":l2e,open:c2e,save:d2e,"save.as":h2e,"upload.media":f2e,"create.page":p2e,"new.page":g2e,"page.name":m2e,duplicate:v2e,cancel:y2e,"copy.invite.link":E2e,"copy.readonly.link":C2e,"create.multiplayer.project":b2e,"copy.multiplayer.project":w2e,select:S2e,eraser:x2e,draw:A2e,arrow:k2e,text:I2e,sticky:D2e,rectangle:T2e,ellipse:P2e,triangle:B2e,line:M2e,rotate:$2e,"lock.aspect.ratio":R2e,"unlock.aspect.ratio":F2e,group:L2e,ungroup:O2e,"move.to.back":_2e,"move.backward":N2e,"move.forward":z2e,"move.to.front":H2e,"reset.angle":j2e,lock:U2e,unlock:K2e,"align.distribute":V2e,"move.to.page":G2e,"flip.horizontal":J2e,"flip.vertical":W2e,move:Y2e,"to.front":q2e,forward:X2e,backward:Z2e,back:Q2e,language:eye,"translation.link":tye,"dock.position":nye,bottom:rye,left:iye,right:oye,top:aye,page:sye,"keyboard.shortcuts":uye,search:lye,loading:cye,"export.background":dye,transparent:hye,auto:fye,light:pye,dark:gye,github:mye,twitter:vye,discord:yye,image:Eye,"align.left":Cye,"align.center.x":bye,"align.right":wye,"align.top":Sye,"align.center.y":xye,"align.bottom":Aye,"distribute.x":kye,"distribute.y":Iye,"stretch.x":Dye,"stretch.y":Tye,"dialog.save.firsttime":Pye,"dialog.save.again":Bye,"dialog.cancel":Mye,"dialog.no":$ye,"dialog.yes":Rye,"enter.file.name":Fye,"tldraw-beta":Lye},_ye="रंग",Nye="भर्नुहोस्",zye="धर्का",Hye="आकार",jye="खुला राख्नुहोस्",Uye="फन्ट",Kye="पङ्क्तिबद्ध",Vye="शैलीहरू",Gye="जुम इन",Jye="जुम आउट",Wye="टु",Yye="फाइल",qye="सम्पादन गर्नुहोस्",Xye="भ्यू",Zye="प्राथमिकताहरू",Qye="साइन इन गर्नुहोस्",e3e="साइन आउट गर्नुहोस्",t3e="प्रायोजक बन्नुहोस्",n3e="जुम टु सेलेक्सन",r3e="जुम टु फिट",i3e="जुम टु",o3e="अँध्यारो मोड",a3e="फोकस मोड",s3e="डिबग मोड",u3e="ग्रिड देखाउनुहोस्",l3e="CAD सेलेक्सन गर्नुहोस्",c3e="स्टाइल मेनु खुला राख्नुहोस्",d3e="सधैँ स्न्यापहरू देखाउनुहोस्",h3e="ह्यान्डलहरू घुमाउनुहोस्",f3e="बाइन्डिङ ह्यान्डलहरू",p3e="क्लोन ह्यान्डलहरू",g3e="पूर्ववत गर्नुहोस्",m3e="पुनः गर्नुहोस्",v3e="कट गर्नुहोस्",y3e="कपि गर्नुहोस्",E3e="पेस्ट गर्नुहोस्",C3e="कपि एज",b3e="एक्सपोर्ट एज",w3e="सबै छान्नुहोस्",S3e="केहि पनि सेलेक्ट नगर्नुहोस्",x3e="मेटाउनुहोस्",A3e="नयाँ परियोजना",k3e="खोल्नुहोस्",I3e="सुरक्षित गर्नुहोस्",D3e="सेभ एज",T3e="मिडिया अपलोड गर्नुहोस्",P3e="पृष्ठ सिर्जना गर्नुहोस्",B3e="नयाँ पृष्ठ सिर्जना गर्नुहोस्",M3e="पृष्ठको नाम",$3e="अनुलिपि गर्नुहोस्",R3e="रद्द गर्नुहोस्",F3e="निमन्त्रणा लिङ्क कपि गर्नुहोस्",L3e="मल्टिप्लेयर परियोजना सिर्जना गर्नुहोस्",O3e="मल्टिप्लेयर प्रोजेक्टमा कपि गर्नुहोस्",_3e="सेलेक्ट",N3e="इरेजर",z3e="चित्र बनाउनु",H3e="तीर",j3e="शब्द",U3e="टाँसिने",K3e="आयत",V3e="दीर्घवृत्त",G3e="त्रिभुज",J3e="रेखा",W3e="घुमाउनुहोस्",Y3e="आकार अनुपात लक गर्नुहोस्",q3e="आकार अनुपात अनलक गर्नुहोस्",X3e="समूह",Z3e="समूह रद्द गर्नुहोस्",Q3e="पछाडि सार्नुहोस्",eEe="थप पछाडि सार्नुहोस्",tEe="अगाडि सार्नुहोस्",nEe="थप अगाडि सार्नुहोस्",rEe="कोण रिसेट गर्नुहोस्",iEe="लक गर्नुहोस्",oEe="अनलक गर्नुहोस्",aEe="पृष्ठमा सार्नुहोस्",sEe="तेर्सो फ्लिप गर्नुहोस्",uEe="ठाडो फ्लिप गर्नुहोस्",lEe="सार्नुहोस्",cEe="थप अगाडि",dEe="अगाडि",hEe="पछाडि",fEe="थप पछाडि",pEe="भाषा",gEe={"style.menu.color":_ye,"style.menu.fill":Nye,"style.menu.dash":zye,"style.menu.size":Hye,"style.menu.keep.open":jye,"style.menu.font":Uye,"style.menu.align":Kye,styles:Vye,"zoom.in":Gye,"zoom.out":Jye,to:Wye,"menu.file":Yye,"menu.edit":qye,"menu.view":Xye,"menu.preferences":Zye,"menu.sign.in":Qye,"menu.sign.out":e3e,"become.a.sponsor":t3e,"zoom.to.selection":n3e,"zoom.to.fit":r3e,"zoom.to":i3e,"preferences.dark.mode":o3e,"preferences.focus.mode":a3e,"preferences.debug.mode":s3e,"preferences.show.grid":u3e,"preferences.use.cad.selection":l3e,"preferences.keep.stylemenu.open":c3e,"preferences.always.show.snaps":d3e,"preferences.rotate.handles":h3e,"preferences.binding.handles":f3e,"preferences.clone.handles":p3e,undo:g3e,redo:m3e,cut:v3e,copy:y3e,paste:E3e,"copy.as":C3e,"export.as":b3e,"select.all":w3e,"select.none":S3e,delete:x3e,"new.project":A3e,open:k3e,save:I3e,"save.as":D3e,"upload.media":T3e,"create.page":P3e,"new.page":B3e,"page.name":M3e,duplicate:$3e,cancel:R3e,"copy.invite.link":F3e,"create.multiplayer.project":L3e,"copy.multiplayer.project":O3e,select:_3e,eraser:N3e,draw:z3e,arrow:H3e,text:j3e,sticky:U3e,rectangle:K3e,ellipse:V3e,triangle:G3e,line:J3e,rotate:W3e,"lock.aspect.ratio":Y3e,"unlock.aspect.ratio":q3e,group:X3e,ungroup:Z3e,"move.to.back":Q3e,"move.backward":eEe,"move.forward":tEe,"move.to.front":nEe,"reset.angle":rEe,lock:iEe,unlock:oEe,"move.to.page":aEe,"flip.horizontal":sEe,"flip.vertical":uEe,move:lEe,"to.front":cEe,forward:dEe,backward:hEe,back:fEe,language:pEe},mEe="Farge",vEe="Fyll",yEe="Linje",EEe="Størrelse",CEe="Hold åpen",bEe="Teksttype",wEe="Juster",SEe="Stiler",xEe="Zoom inn",AEe="Zoom ut",kEe="til",IEe="Fil",DEe="Rediger",TEe="Vis",PEe="Preferanser",BEe="Logg inn",MEe="Logg ut",$Ee="Bli en sponsor",REe="Zoom til valg",FEe="Zoom for å passe",LEe="Zoom til",OEe="Mørk modus",_Ee="Fokus modus",NEe="Debug modus",zEe="Vis rutenett",HEe="Bruk CAD seleksjon",jEe="Hold stilmeny åpen",UEe="Vis alltid snaps",KEe="Vis roteringshåndtak",VEe="Vis bindingshåndtak",GEe="Vis kloningshåndtak",JEe="Angre",WEe="Gjør om",YEe="Klipp ut",qEe="Kopier",XEe="Lim inn",ZEe="Kopier som",QEe="Eksporter som",eCe="Velg alle",tCe="Velg ingen",nCe="Slett",rCe="Nytt prosjekt",iCe="Åpne",oCe="Lagre",aCe="Lagre som",sCe="Last opp media",uCe="Opprett side",lCe="Ny side",cCe="Sidenavn",dCe="Dupliser",hCe="Avbryt",fCe="Kopier invitasjonslink",pCe="Opprett et flerspiller prosjekt",gCe="Kopier til flerspiller prosjekt",mCe="Velg",vCe="Viskelær",yCe="Tegn",ECe="Pil",CCe="Tekst",bCe="Lapp",wCe="Rektangel",SCe="Ellipse",xCe="Trekant",ACe="Linje",kCe="Roter",ICe="Lås størrelsesforhold",DCe="Lås opp størrelsesforhold",TCe="Grupper",PCe="Avgrupper",BCe="Flytt bakerst",MCe="Flytt bakover",$Ce="Flytt forover",RCe="Flytt til front",FCe="Tilbakestill vinkel",LCe="Lås",OCe="Lås opp",_Ce="Flytt til side",NCe="Snu horisontalt",zCe="Snu vertikalt",HCe="Flytt",jCe="Foran",UCe="Framover",KCe="Bakover",VCe="Bakerst",GCe="Språk",JCe={"style.menu.color":mEe,"style.menu.fill":vEe,"style.menu.dash":yEe,"style.menu.size":EEe,"style.menu.keep.open":CEe,"style.menu.font":bEe,"style.menu.align":wEe,styles:SEe,"zoom.in":xEe,"zoom.out":AEe,to:kEe,"menu.file":IEe,"menu.edit":DEe,"menu.view":TEe,"menu.preferences":PEe,"menu.sign.in":BEe,"menu.sign.out":MEe,"become.a.sponsor":$Ee,"zoom.to.selection":REe,"zoom.to.fit":FEe,"zoom.to":LEe,"preferences.dark.mode":OEe,"preferences.focus.mode":_Ee,"preferences.debug.mode":NEe,"preferences.show.grid":zEe,"preferences.use.cad.selection":HEe,"preferences.keep.stylemenu.open":jEe,"preferences.always.show.snaps":UEe,"preferences.rotate.handles":KEe,"preferences.binding.handles":VEe,"preferences.clone.handles":GEe,undo:JEe,redo:WEe,cut:YEe,copy:qEe,paste:XEe,"copy.as":ZEe,"export.as":QEe,"select.all":eCe,"select.none":tCe,delete:nCe,"new.project":rCe,open:iCe,save:oCe,"save.as":aCe,"upload.media":sCe,"create.page":uCe,"new.page":lCe,"page.name":cCe,duplicate:dCe,cancel:hCe,"copy.invite.link":fCe,"create.multiplayer.project":pCe,"copy.multiplayer.project":gCe,select:mCe,eraser:vCe,draw:yCe,arrow:ECe,text:CCe,sticky:bCe,rectangle:wCe,ellipse:SCe,triangle:xCe,line:ACe,rotate:kCe,"lock.aspect.ratio":ICe,"unlock.aspect.ratio":DCe,group:TCe,ungroup:PCe,"move.to.back":BCe,"move.backward":MCe,"move.forward":$Ce,"move.to.front":RCe,"reset.angle":FCe,lock:LCe,unlock:OCe,"move.to.page":_Ce,"flip.horizontal":NCe,"flip.vertical":zCe,move:HCe,"to.front":jCe,forward:UCe,backward:KCe,back:VCe,language:GCe},WCe="Kolor",YCe="Wypełnienie",qCe="Linia",XCe="Rozmiar",ZCe="Zachowaj otwarte",QCe="Czcionka",e9e="Wyrównanie",t9e="Style",n9e="Przybliż",r9e="Oddal",i9e="do",o9e="Plik",a9e="Edycja",s9e="Widok",u9e="Preferencje",l9e="Zaloguj",c9e="Wyloguj",d9e="Zostań sponsorem",h9e="Przybliż do zaznaczenia",f9e="Wypełnij ekran",p9e="Przybliż do",g9e="Tryb ciemny",m9e="Tryb skupienia",v9e="Tryb debugowania",y9e="Pokaż siatkę",E9e="Użyj zaznaczania CAD",C9e="Zachowaj menu styli otwarte",b9e="Przyciągaj obiekty",w9e="Uchwyty obrotu",S9e="Uchwyty powiązania",x9e="Uchwyty klonujące",A9e="Cofnij",k9e="Powtórz",I9e="Wytnij",D9e="Kopiuj",T9e="Wklej",P9e="Kopiuj jako",B9e="Eksportuj jako",M9e="Zaznacz wszystko",$9e="Odznacz wszystko",R9e="Usuń",F9e="Nowy projekt",L9e="Otwórz",O9e="Zapisz",_9e="Zapisz jako",N9e="Załaduj multimedia",z9e="Utwórz stronę",H9e="Nowa strona",j9e="Nazwa strony",U9e="Powiel",K9e="Anuluj",V9e="Kopiuj link zaproszenia",G9e="Stwórz projekt wieloosobowy",J9e="Kopiuj do projektu wieloosobowego",W9e="Zaznacz",Y9e="Gumka",q9e="Rysuj",X9e="Strzałka",Z9e="Tekst",Q9e="Naklejka",e5e="Prostokąt",t5e="Elipsa",n5e="Trójkąt",r5e="Linia",i5e="Obróć",o5e="Zablokuj proporcje",a5e="Odblokuj proporcje",s5e="Grupuj",u5e="Rozgrupuj",l5e="Przenieś na tył",c5e="Przesuń do tyłu",d5e="Przesuń do przodu",h5e="Przenieś na przód",f5e="Resetuj kąt",p5e="Zablokuj",g5e="Odblokuj",m5e="Przenieś na stronę",v5e="Odwróć w poziomie",y5e="Odwróć w pionie",E5e="Przenieś",C5e="Na wierzch",b5e="Do przodu",w5e="Do tyłu",S5e="Na spód",x5e="Język",A5e={"style.menu.color":WCe,"style.menu.fill":YCe,"style.menu.dash":qCe,"style.menu.size":XCe,"style.menu.keep.open":ZCe,"style.menu.font":QCe,"style.menu.align":e9e,styles:t9e,"zoom.in":n9e,"zoom.out":r9e,to:i9e,"menu.file":o9e,"menu.edit":a9e,"menu.view":s9e,"menu.preferences":u9e,"menu.sign.in":l9e,"menu.sign.out":c9e,"become.a.sponsor":d9e,"zoom.to.selection":h9e,"zoom.to.fit":f9e,"zoom.to":p9e,"preferences.dark.mode":g9e,"preferences.focus.mode":m9e,"preferences.debug.mode":v9e,"preferences.show.grid":y9e,"preferences.use.cad.selection":E9e,"preferences.keep.stylemenu.open":C9e,"preferences.always.show.snaps":b9e,"preferences.rotate.handles":w9e,"preferences.binding.handles":S9e,"preferences.clone.handles":x9e,undo:A9e,redo:k9e,cut:I9e,copy:D9e,paste:T9e,"copy.as":P9e,"export.as":B9e,"select.all":M9e,"select.none":$9e,delete:R9e,"new.project":F9e,open:L9e,save:O9e,"save.as":_9e,"upload.media":N9e,"create.page":z9e,"new.page":H9e,"page.name":j9e,duplicate:U9e,cancel:K9e,"copy.invite.link":V9e,"create.multiplayer.project":G9e,"copy.multiplayer.project":J9e,select:W9e,eraser:Y9e,draw:q9e,arrow:X9e,text:Z9e,sticky:Q9e,rectangle:e5e,ellipse:t5e,triangle:n5e,line:r5e,rotate:i5e,"lock.aspect.ratio":o5e,"unlock.aspect.ratio":a5e,group:s5e,ungroup:u5e,"move.to.back":l5e,"move.backward":c5e,"move.forward":d5e,"move.to.front":h5e,"reset.angle":f5e,lock:p5e,unlock:g5e,"move.to.page":m5e,"flip.horizontal":v5e,"flip.vertical":y5e,move:E5e,"to.front":C5e,forward:b5e,backward:w5e,back:S5e,language:x5e},k5e="Cor",I5e="Preencher",D5e="Traço",T5e="Tamanho",P5e="Manter aberto",B5e="Fonte",M5e="Alinhamento",$5e="Estilos",R5e="Aumentar zoom",F5e="Diminuir zoom",L5e="para",O5e="Arquivo",_5e="Editar",N5e="Visualizar",z5e="Preferências",H5e="Entrar",j5e="Sair",U5e="Torne-se um patrocinador",K5e="Zoom para a seleção",V5e="Zoom para ajuste",G5e="Zoom para",J5e="Modo Escuro",W5e="Modo Foco",Y5e="Modo Debug",q5e="Mostrar Grade",X5e="Usar seleção CAD",Z5e="Manter Menu de Estilos Aberto",Q5e="Mostrar Pontos de Ajuste",ebe="Controle de Rotação",tbe="Controle de Vínculos",nbe="Controle de Clone",rbe="Desfazer",ibe="Refazer",obe="Cortar",abe="Copiar",sbe="Colar",ube="Copiar como",lbe="Exportar como",cbe="Selecionar todos",dbe="Selecionar nenhum",hbe="Deletar",fbe="Novo Projeto",pbe="Abrir",gbe="Salvar",mbe="Salvar Como",vbe="Carregar Mídia",ybe="Página",Ebe="Procurar",Cbe="Carregando{dots}",bbe="Exportar Fundo",wbe="Transparente",Sbe="Automático",xbe="Claro",Abe="Escuro",kbe="Ferramentas",Ibe="Transformar",Dbe="Voltar ao Conteúdo",Tbe="Saiba Mais",Pbe="Copiar Link ReadOnly",Bbe="Alinhar / Distribuir",Mbe="Criar Página",$be="Nova Página",Rbe="Nome da Página",Fbe="Duplicar",Lbe="Cancelar",Obe="Copiar Link de Convite",_be="Criar um Projeto Multijogador",Nbe="Copiar para Projeto Multijogador",zbe="Selecionar",Hbe="Borracha",jbe="Desenhar",Ube="Seta",Kbe="Texto",Vbe="Adesivo",Gbe="Retângulo",Jbe="Elipse",Wbe="Triângulo",Ybe="Linha",qbe="Rotacionar",Xbe="Travar Proporção da Tela",Zbe="Destravar Proporção da Tela",Qbe="Agrupar",ewe="Desagrupar",twe="Recuar",nwe="Enviar para Trás",rwe="Avançar",iwe="Trazer para Frente",owe="Reiniciar Ângulo",awe="Travar",swe="Destravar",uwe="Mover para Página",lwe="Virar Horizontalmente",cwe="Virar Verticalmente",dwe="Mover",hwe="Para Frente",fwe="Avançar",pwe="Recuar",gwe="Voltar",mwe="Idioma",vwe="Imagem",ywe="Atalhos de Teclado",Ewe="Posição de Ferramentas",Cwe="Inferior",bwe="Superior",wwe="Direita",Swe="Esquerda",xwe="Alinhar à esquerda",Awe="Alinhar ao centro na horizontal",kwe="Alinhar à direita",Iwe="Alinhas em cima",Dwe="Alinhar ao centro na vertical",Twe="Alinhar embaixo",Pwe="Distruibuir na horizontal",Bwe="Distruibuir na vertical",Mwe="Esticar na horizontal",$we="Esticar na vertical",Rwe="Você deseja salvar seu projeto atual?",Fwe="Você deseja salvar as mudanças ao projeto atual?",Lwe="Cancelar",Owe="Não",_we="Sim",Nwe="Insira o nome do arquivo",zwe={"style.menu.color":k5e,"style.menu.fill":I5e,"style.menu.dash":D5e,"style.menu.size":T5e,"style.menu.keep.open":P5e,"style.menu.font":B5e,"style.menu.align":M5e,styles:$5e,"zoom.in":R5e,"zoom.out":F5e,to:L5e,"menu.file":O5e,"menu.edit":_5e,"menu.view":N5e,"menu.preferences":z5e,"menu.sign.in":H5e,"menu.sign.out":j5e,"become.a.sponsor":U5e,"zoom.to.selection":K5e,"zoom.to.fit":V5e,"zoom.to":G5e,"preferences.dark.mode":J5e,"preferences.focus.mode":W5e,"preferences.debug.mode":Y5e,"preferences.show.grid":q5e,"preferences.use.cad.selection":X5e,"preferences.keep.stylemenu.open":Z5e,"preferences.always.show.snaps":Q5e,"preferences.rotate.handles":ebe,"preferences.binding.handles":tbe,"preferences.clone.handles":nbe,undo:rbe,redo:ibe,cut:obe,copy:abe,paste:sbe,"copy.as":ube,"export.as":lbe,"select.all":cbe,"select.none":dbe,delete:hbe,"new.project":fbe,open:pbe,save:gbe,"save.as":mbe,"upload.media":vbe,page:ybe,search:Ebe,loading:Cbe,"export.background":bbe,transparent:wbe,auto:Sbe,light:xbe,dark:Abe,"menu.tools":kbe,"menu.transform":Ibe,"zoom.to.content":Dbe,"translation.link":Tbe,"copy.readonly.link":Pbe,"align.distribute":Bbe,"create.page":Mbe,"new.page":$be,"page.name":Rbe,duplicate:Fbe,cancel:Lbe,"copy.invite.link":Obe,"create.multiplayer.project":_be,"copy.multiplayer.project":Nbe,select:zbe,eraser:Hbe,draw:jbe,arrow:Ube,text:Kbe,sticky:Vbe,rectangle:Gbe,ellipse:Jbe,triangle:Wbe,line:Ybe,rotate:qbe,"lock.aspect.ratio":Xbe,"unlock.aspect.ratio":Zbe,group:Qbe,ungroup:ewe,"move.to.back":twe,"move.backward":nwe,"move.forward":rwe,"move.to.front":iwe,"reset.angle":owe,lock:awe,unlock:swe,"move.to.page":uwe,"flip.horizontal":lwe,"flip.vertical":cwe,move:dwe,"to.front":hwe,forward:fwe,backward:pwe,back:gwe,language:mwe,image:vwe,"keyboard.shortcuts":ywe,"dock.position":Ewe,bottom:Cwe,top:bwe,right:wwe,left:Swe,"align.left":xwe,"align.center.x":Awe,"align.right":kwe,"align.top":Iwe,"align.center.y":Dwe,"align.bottom":Twe,"distribute.x":Pwe,"distribute.y":Bwe,"stretch.x":Mwe,"stretch.y":$we,"dialog.save.firsttime":Rwe,"dialog.save.again":Fwe,"dialog.cancel":Lwe,"dialog.no":Owe,"dialog.yes":_we,"enter.file.name":Nwe},Hwe="Cor",jwe="Preencher",Uwe="Traço",Kwe="Tamanho",Vwe="Manter aberto",Gwe="Fonte",Jwe="Alinhamento",Wwe="Estilos",Ywe="Aumentar zoom",qwe="Diminuir zoom",Xwe="para",Zwe="Ficheiro",Qwe="Editar",e6e="Visualizar",t6e="Preferências",n6e="Entrar",r6e="Sair",i6e="Torne-se um patrocinador",o6e="Zoom na seleção",a6e="Zoom para caber",s6e="Zoom para",u6e="Modo Escuro",l6e="Modo Foco",c6e="Modo Debug",d6e="Mostrar Grelha",h6e="Usar seleção CAD",f6e="Manter Menu de Estilos Aberto",p6e="Mostrar Pontos de Ajuste",g6e="Controlo de Rotação",m6e="Controlo de Binds",v6e="Controlo de Clone",y6e="Desfazer",E6e="Refazer",C6e="Cortar",b6e="Copiar",w6e="Colar",S6e="Copiar como",x6e="Exportar como",A6e="Selecionar todos",k6e="Selecionar nenhum",I6e="Apagar",D6e="Novo Projeto",T6e="Abrir",P6e="Salvar",B6e="Salvar Como",M6e="Upload Média",$6e="Criar Página",R6e="Nova Página",F6e="Nome da Página",L6e="Duplicar",O6e="Cancelar",_6e="Copiar Link de Convite",N6e="Criar um Projeto Multi-Utilizador",z6e="Copiar num Projeto Multi-Utilizador",H6e="Selecionar",j6e="Borracha",U6e="Desenhar",K6e="Seta",V6e="Texto",G6e="Post-it",J6e="Retângulo",W6e="Elipse",Y6e="Triângulo",q6e="Linha",X6e="Rodar",Z6e="Trancar a Proporção",Q6e="Destrancar a Proporção",eSe="Agrupar",tSe="Desagrupar",nSe="Colocar no Fundo",rSe="Mover abaixo",iSe="Mover acima",oSe="Colocar à Frente",aSe="Reiniciar Ângulo",sSe="Trancar",uSe="Destrancar",lSe="Mover para Página",cSe="Inverter Horizontalmente",dSe="Inverter Verticalmente",hSe="Mover",fSe="Para Frente",pSe="Avançar",gSe="Recuar",mSe="Voltar",vSe="Língua",ySe={"style.menu.color":Hwe,"style.menu.fill":jwe,"style.menu.dash":Uwe,"style.menu.size":Kwe,"style.menu.keep.open":Vwe,"style.menu.font":Gwe,"style.menu.align":Jwe,styles:Wwe,"zoom.in":Ywe,"zoom.out":qwe,to:Xwe,"menu.file":Zwe,"menu.edit":Qwe,"menu.view":e6e,"menu.preferences":t6e,"menu.sign.in":n6e,"menu.sign.out":r6e,"become.a.sponsor":i6e,"zoom.to.selection":o6e,"zoom.to.fit":a6e,"zoom.to":s6e,"preferences.dark.mode":u6e,"preferences.focus.mode":l6e,"preferences.debug.mode":c6e,"preferences.show.grid":d6e,"preferences.use.cad.selection":h6e,"preferences.keep.stylemenu.open":f6e,"preferences.always.show.snaps":p6e,"preferences.rotate.handles":g6e,"preferences.binding.handles":m6e,"preferences.clone.handles":v6e,undo:y6e,redo:E6e,cut:C6e,copy:b6e,paste:w6e,"copy.as":S6e,"export.as":x6e,"select.all":A6e,"select.none":k6e,delete:I6e,"new.project":D6e,open:T6e,save:P6e,"save.as":B6e,"upload.media":M6e,"create.page":$6e,"new.page":R6e,"page.name":F6e,duplicate:L6e,cancel:O6e,"copy.invite.link":_6e,"create.multiplayer.project":N6e,"copy.multiplayer.project":z6e,select:H6e,eraser:j6e,draw:U6e,arrow:K6e,text:V6e,sticky:G6e,rectangle:J6e,ellipse:W6e,triangle:Y6e,line:q6e,rotate:X6e,"lock.aspect.ratio":Z6e,"unlock.aspect.ratio":Q6e,group:eSe,ungroup:tSe,"move.to.back":nSe,"move.backward":rSe,"move.forward":iSe,"move.to.front":oSe,"reset.angle":aSe,lock:sSe,unlock:uSe,"move.to.page":lSe,"flip.horizontal":cSe,"flip.vertical":dSe,move:hSe,"to.front":fSe,forward:pSe,backward:gSe,back:mSe,language:vSe},ESe="Цвет",CSe="Заполнять",bSe="Штрих",wSe="Размер",SSe="Держать открытым",xSe="Шрифт",ASe="Выравнивание",kSe="Стиль",ISe="Увеличить",DSe="Уменьшить",TSe="к",PSe="Инструменты",BSe="Изменение",MSe="Файл",$Se="Редактирование",RSe="Вид",FSe="Настройки",LSe="Войти",OSe="Выйти",_Se="Стать спонсором",NSe="Вернуться к содержимому",zSe="Масштабировать по выделению",HSe="Масштабировать по размеру экрана",jSe="Масштабировать к",USe="Тёмная тема",KSe="Минималистичный режим",VSe="Режим отладки",GSe="Показать сетку",JSe="Использовать CAD выделение",WSe="Держать меню стилей открытым",YSe="Всегда показывать привязки",qSe="Ручки вращения",XSe="Ручки привязки",ZSe="Ручки клонирования",QSe="Отменить",exe="Повторить",txe="Вырезать",nxe="Копировать",rxe="Вставить",ixe="Копировать как",oxe="Экспортировать как",axe="Выделить всё",sxe="Снять выделение",uxe="Удалить",lxe="Новый проект",cxe="Открыть",dxe="Сохранить",hxe="Сохранить как",fxe="Загрузить медиафайл",pxe="Создать страницу",gxe="Новая страница",mxe="Название страницы",vxe="Дублировать",yxe="Отменить",Exe="Скопировать ссылку приглашения",Cxe="Скопировать ссылку только для чтения",bxe="Создать многопользовательский проект",wxe="Скопировать в многопользовательский проект",Sxe="Выделить",xxe="Ластик",Axe="Рисовать",kxe="Стрелка",Ixe="Текст",Dxe="Заметка",Txe="Прямоугольник",Pxe="Эллипс",Bxe="Треугольник",Mxe="Линия",$xe="Повернуть",Rxe="Заблокировать соотношение сторон",Fxe="Разблокировать соотношение сторон",Lxe="Сгруппировать",Oxe="Разгруппировать",_xe="Переместить назад",Nxe="Переместить на задний план",zxe="Переместить вперёд",Hxe="Переместить на передний план",jxe="Сбросить угол",Uxe="Блокировать",Kxe="Разблокировать",Vxe="Выровнять / распределить",Gxe="Переместить на страницу",Jxe="Перевернуть горизонтально",Wxe="Перевернуть вертикально",Yxe="Переместить",qxe="На передний план",Xxe="Вперед",Zxe="На задний план",Qxe="Назад",e8e="Язык",t8e="Подробнее",n8e="Расположение панели инструментов",r8e="Снизу",i8e="Слева",o8e="Справа",a8e="Сверху",s8e="Страница",u8e="Сочетания клавиш",l8e="Поиск",c8e="Загрузка",d8e="Экспорт фона",h8e="Прозрачный",f8e="Авто",p8e="Светлый",g8e="Тёмный",m8e="Изображение",v8e="Выровнять по левому краю",y8e="Выровнять по центру горизонтально",E8e="Выровнять по правому краю",C8e="Выровнять по верхнему краю",b8e="Выровнять по центру вертикально",w8e="Выровнять по нижнему краю",S8e="Распределить горизонтально",x8e="Распределить вертикально",A8e="Растянуть горизонтально",k8e="Растянуть вертикально",I8e="Поделиться",D8e="Скопировать ссылку на текущую страницу",T8e="Скопировать ссылку на проект",P8e="Данные слишком велики, чтобы закодировать их в ссылке. Не включайте изображение или видео!",B8e="Сохранить текущий проект?",M8e="Сохранить изменения в текущем проекте?",$8e="Отменить",R8e="Нет",F8e="Да",L8e="Введите имя файла",O8e={"style.menu.color":ESe,"style.menu.fill":CSe,"style.menu.dash":bSe,"style.menu.size":wSe,"style.menu.keep.open":SSe,"style.menu.font":xSe,"style.menu.align":ASe,styles:kSe,"zoom.in":ISe,"zoom.out":DSe,to:TSe,"menu.tools":PSe,"menu.transform":BSe,"menu.file":MSe,"menu.edit":$Se,"menu.view":RSe,"menu.preferences":FSe,"menu.sign.in":LSe,"menu.sign.out":OSe,"become.a.sponsor":_Se,"zoom.to.content":NSe,"zoom.to.selection":zSe,"zoom.to.fit":HSe,"zoom.to":jSe,"preferences.dark.mode":USe,"preferences.focus.mode":KSe,"preferences.debug.mode":VSe,"preferences.show.grid":GSe,"preferences.use.cad.selection":JSe,"preferences.keep.stylemenu.open":WSe,"preferences.always.show.snaps":YSe,"preferences.rotate.handles":qSe,"preferences.binding.handles":XSe,"preferences.clone.handles":ZSe,undo:QSe,redo:exe,cut:txe,copy:nxe,paste:rxe,"copy.as":ixe,"export.as":oxe,"select.all":axe,"select.none":sxe,delete:uxe,"new.project":lxe,open:cxe,save:dxe,"save.as":hxe,"upload.media":fxe,"create.page":pxe,"new.page":gxe,"page.name":mxe,duplicate:vxe,cancel:yxe,"copy.invite.link":Exe,"copy.readonly.link":Cxe,"create.multiplayer.project":bxe,"copy.multiplayer.project":wxe,select:Sxe,eraser:xxe,draw:Axe,arrow:kxe,text:Ixe,sticky:Dxe,rectangle:Txe,ellipse:Pxe,triangle:Bxe,line:Mxe,rotate:$xe,"lock.aspect.ratio":Rxe,"unlock.aspect.ratio":Fxe,group:Lxe,ungroup:Oxe,"move.to.back":_xe,"move.backward":Nxe,"move.forward":zxe,"move.to.front":Hxe,"reset.angle":jxe,lock:Uxe,unlock:Kxe,"align.distribute":Vxe,"move.to.page":Gxe,"flip.horizontal":Jxe,"flip.vertical":Wxe,move:Yxe,"to.front":qxe,forward:Xxe,backward:Zxe,back:Qxe,language:e8e,"translation.link":t8e,"dock.position":n8e,bottom:r8e,left:i8e,right:o8e,top:a8e,page:s8e,"keyboard.shortcuts":u8e,search:l8e,loading:c8e,"export.background":d8e,transparent:h8e,auto:f8e,light:p8e,dark:g8e,image:m8e,"align.left":v8e,"align.center.x":y8e,"align.right":E8e,"align.top":C8e,"align.center.y":b8e,"align.bottom":w8e,"distribute.x":S8e,"distribute.y":x8e,"stretch.x":A8e,"stretch.y":k8e,share:I8e,"copy.current.page.link":D8e,"copy.project.link":T8e,"data.too.big.encoded":P8e,"dialog.save.firsttime":B8e,"dialog.save.again":M8e,"dialog.cancel":$8e,"dialog.no":R8e,"dialog.yes":F8e,"enter.file.name":L8e},_8e="Färg",N8e="Ifylld",z8e="Streck",H8e="Storlek",j8e="Håll stilmenyn öppen",U8e="Typsnitt",K8e="Justera",V8e="Utseende",G8e="Zooma in",J8e="Zooma ut",W8e="Till",Y8e="Verktyg",q8e="Transform",X8e="Arkiv",Z8e="Redigera",Q8e="Innehåll",e7e="Inställningar",t7e="Logga in",n7e="Logga ut",r7e="Bli en sponsor",i7e="Anpassa zoom till innehåll",o7e="Anpassa zoom till urval",a7e="Anpassa zoom till skärm",s7e="Zooma till",u7e="Mörkt läge",l7e="Fokusläge",c7e="Debugläge",d7e="Visa rutnät",h7e="Välj som i CAD-mjukvara",f7e="Håll stilmenyn öppen",p7e="Visa alltid fästpunkter",g7e="Rotationshandtag",m7e="Bindningshandtag",v7e="Kloningshandtag",y7e="Ångra",E7e="Gör om",C7e="Klipp ut",b7e="Kopiera",w7e="Klistra in",S7e="Kopiera som",x7e="Exportera till",A7e="Välj alla",k7e="Välj ingen",I7e="Radera",D7e="Nytt projekt",T7e="Öppna",P7e="Spara",B7e="Spara som",M7e="Ladda upp media",$7e="Skapa sida",R7e="Ny sida",F7e="Sidnamn",L7e="Duplicera",O7e="Avbryt",_7e="Kopiera länk med redigeringsrättigheter",N7e="Kopiera länk med läsrättigheter",z7e="Skapa ett Multiplayer-projekt",H7e="Kopiera till Multiplayer-project",j7e="Välj",U7e="Radera",K7e="Rita",V7e="Pil",G7e="Text",J7e="Klisterlapp",W7e="Rektangel",Y7e="Ellips",q7e="Triangel",X7e="Linje",Z7e="Rotera",Q7e="Lås storleksförhållande",eAe="Lås upp storleksförhållande",tAe="Gruppera",nAe="Avgruppera",rAe="Placera längst bak",iAe="Flytta bakåt",oAe="Flytta framåt",aAe="Placera längst fram",sAe="Återställ vinkel",uAe="Lås",lAe="Lås upp",cAe="Justera / Placera",dAe="Flytta till sida",hAe="Vänd horisontellt",fAe="Vänd vertikalt",pAe="Flytta",gAe="Till längst fram",mAe="Framåt",vAe="Bakåt",yAe="Till längst bak",EAe="Språk",CAe="Mer information",bAe="Dockningsposition",wAe="Botten",SAe="Vänster",xAe="Höger",AAe="Topp",kAe="Sida",IAe="Tangentbordsgenvägar",DAe="Sök",TAe="Laddar{dots}",PAe="Exportbakgrund",BAe="Transparent",MAe="Auto",$Ae="Ljus",RAe="Mörk",FAe="Github",LAe="Twitter",OAe="Discord",_Ae="Bild",NAe={"style.menu.color":_8e,"style.menu.fill":N8e,"style.menu.dash":z8e,"style.menu.size":H8e,"style.menu.keep.open":j8e,"style.menu.font":U8e,"style.menu.align":K8e,styles:V8e,"zoom.in":G8e,"zoom.out":J8e,to:W8e,"menu.tools":Y8e,"menu.transform":q8e,"menu.file":X8e,"menu.edit":Z8e,"menu.view":Q8e,"menu.preferences":e7e,"menu.sign.in":t7e,"menu.sign.out":n7e,"become.a.sponsor":r7e,"zoom.to.content":i7e,"zoom.to.selection":o7e,"zoom.to.fit":a7e,"zoom.to":s7e,"preferences.dark.mode":u7e,"preferences.focus.mode":l7e,"preferences.debug.mode":c7e,"preferences.show.grid":d7e,"preferences.use.cad.selection":h7e,"preferences.keep.stylemenu.open":f7e,"preferences.always.show.snaps":p7e,"preferences.rotate.handles":g7e,"preferences.binding.handles":m7e,"preferences.clone.handles":v7e,undo:y7e,redo:E7e,cut:C7e,copy:b7e,paste:w7e,"copy.as":S7e,"export.as":x7e,"select.all":A7e,"select.none":k7e,delete:I7e,"new.project":D7e,open:T7e,save:P7e,"save.as":B7e,"upload.media":M7e,"create.page":$7e,"new.page":R7e,"page.name":F7e,duplicate:L7e,cancel:O7e,"copy.invite.link":_7e,"copy.readonly.link":N7e,"create.multiplayer.project":z7e,"copy.multiplayer.project":H7e,select:j7e,eraser:U7e,draw:K7e,arrow:V7e,text:G7e,sticky:J7e,rectangle:W7e,ellipse:Y7e,triangle:q7e,line:X7e,rotate:Z7e,"lock.aspect.ratio":Q7e,"unlock.aspect.ratio":eAe,group:tAe,ungroup:nAe,"move.to.back":rAe,"move.backward":iAe,"move.forward":oAe,"move.to.front":aAe,"reset.angle":sAe,lock:uAe,unlock:lAe,"align.distribute":cAe,"move.to.page":dAe,"flip.horizontal":hAe,"flip.vertical":fAe,move:pAe,"to.front":gAe,forward:mAe,backward:vAe,back:yAe,language:EAe,"translation.link":CAe,"dock.position":bAe,bottom:wAe,left:SAe,right:xAe,top:AAe,page:kAe,"keyboard.shortcuts":IAe,search:DAe,loading:TAe,"export.background":PAe,transparent:BAe,auto:MAe,light:$Ae,dark:RAe,github:FAe,twitter:LAe,discord:OAe,image:_Ae},zAe="రంగు",HAe="నింపు",jAe="అడ్డ గీత",UAe="పరిమాణం",KAe="తెరిచి ఉంచు",VAe="అక్షరాకృతి",GAe="సరిపరచు",JAe="విధములు",WAe="దగ్గరగా చూపు",YAe="దూరంగా చూపు",qAe="వద్దకు",XAe="పరికరాలు",ZAe="మార్చు",QAe="ఫైల్",eke="పరిష్కరించు",tke="చూపు",nke="ఎంచుకొన్నవి",rke="ప్రవేశించు",ike="నిష్క్రమణ",oke="విరాళదారులు అవ్వండి",ake="విషయాన్నే చూపు",ske="ఎంచుకున్న విషయాన్నే చూపు",uke="సరిపెట్టి చూపు",lke="చూపు",cke="చీకటైన క్రమం",dke="తీక్షణ క్రమం",hke="తప్పులేరు క్రమం",fke="చట్రం చూపు",pke="CADని వాడు",gke="విధముల పత్తి తెరిచివుంచు",mke="ఎప్పుడూ దృశ్యభాగం చూపు",vke="హ్యాండిల్స్ తిప్పు",yke="యాండిల్స్ కట్టు",Eke="యాండిల్స్ నకలు",Cke="మార్పుని తిరుగగొట్టు",bke="మళ్ళీ మార్చు",wke="కత్తిరించు",Ske="నకలు",xke="అతికించు",Ake="నకలుప్రతిగా ఇక్కడికి",kke="ఎగుమతి ఇక్కడికి",Ike="అన్నీ ఎంపికచెయ్యి",Dke="ఎదీ ఎంపికచెయ్యవద్దు",Tke="తొలగించు",Pke="కొత్త ప్రాజెక్టు",Bke="తెరువు",Mke="దాయి",$ke="ఇలా దాయి",Rke="ఎగుమతి మాధ్యం",Fke="పుట కల్పించు",Lke="కొత్త పుట",Oke="పుట పేరు",_ke="మారుప్రతి",Nke="రద్దుచేయి",zke="అహ్వాన లింకు రాయి",Hke="మారనిప్రతి లింకు రాయి",jke="బహుకర్తల ప్రాజెక్టు కల్పించు",Uke="బహుకర్తల ప్రాజెక్టుకు రాయి",Kke="ఎంపికచెయ్యి",Vke="Eraser",Gke="గీయ్యి",Jke="బాణం",Wke="అక్షరములు",Yke="అతుక్కునే",qke="దీర్ఘచతురస్రం",Xke="దీర్ఘవృత్తం",Zke="త్రిభుజం",Qke="గీత",eIe="తిప్పు",tIe="ఆస్పెక్ట్ నిష్పత్తికి తాళంపెట్టు",nIe="ఆస్పెక్ట్ నిష్పత్తి తాళంతెరువు",rIe="గుంపుగా ఏర్పరచు",iIe="గుంపును చెదరగొట్టు",oIe="ఆఖరికి జరుపు",aIe="వెనుకకు జరుపు",sIe="ముందుకు జరుపు",uIe="మొదటికి జరుపు",lIe="కోణం రీసెట్",cIe="తాళం వెయ్యి",dIe="తాళం తియ్యి",hIe=" సరిపరచు/వెదజల్లు",fIe="పుటలోకి జరుపు",pIe="అడ్డంగా పల్టీ",gIe="నిలువుగా పల్టీ",mIe="జరుపు",vIe="మొదటికి",yIe="ముందుకు",EIe="వెనుకకు",CIe="ఆఖరికి",bIe="భాష",wIe="మరి కొన్ని విషయాలు",SIe="మంచ స్థానం",xIe="అడుగున",AIe="ఎడమవైపు",kIe="కుడివైపు",IIe="పైన",DIe="పుత",TIe="కీబోర్డ్ సత్వరమార్గం",PIe="వెతుకు",BIe="Loading{dots}",MIe="నేపథ్యం ఎగుమతి",$Ie="కాంతి భేద్యము",RIe="స్వయంకృతం",FIe="వెలుతురు",LIe="చీకటి",OIe="Github",_Ie="Twitter",NIe="Discord",zIe="చిత్రం",HIe="ఎడమవైపుకు కుదుర్చు",jIe="అడ్డంగా మధ్యలో కుదుర్చు",UIe="కుడివైపుకు కుదుర్చు",KIe="పైకి కుదుర్చు",VIe="నిలువుగా మధ్యలో కుదుర్చు",GIe="అడుగున కుదుర్చు",JIe="అడ్డంగా పంచు",WIe="నిలువుగా పంచు",YIe="అడ్డంగా లాగు",qIe="నిలువుగా లాగు",XIe="మీరు ఈ ప్రాజెక్ట్ భద్రపరచుకోవాలని అనుకుంటున్నారా?",ZIe="మీరు ఈ ప్రాజెక్ట్ భద్రపరచుకోవాలని అనుకుంటున్నారా?",QIe="రద్దుచెయ్యి",eDe="వద్దు",tDe="సరే",nDe="ఫైల్ పెరు చెప్పండి",rDe={"style.menu.color":zAe,"style.menu.fill":HAe,"style.menu.dash":jAe,"style.menu.size":UAe,"style.menu.keep.open":KAe,"style.menu.font":VAe,"style.menu.align":GAe,styles:JAe,"zoom.in":WAe,"zoom.out":YAe,to:qAe,"menu.tools":XAe,"menu.transform":ZAe,"menu.file":QAe,"menu.edit":eke,"menu.view":tke,"menu.preferences":nke,"menu.sign.in":rke,"menu.sign.out":ike,"become.a.sponsor":oke,"zoom.to.content":ake,"zoom.to.selection":ske,"zoom.to.fit":uke,"zoom.to":lke,"preferences.dark.mode":cke,"preferences.focus.mode":dke,"preferences.debug.mode":hke,"preferences.show.grid":fke,"preferences.use.cad.selection":pke,"preferences.keep.stylemenu.open":gke,"preferences.always.show.snaps":mke,"preferences.rotate.handles":vke,"preferences.binding.handles":yke,"preferences.clone.handles":Eke,undo:Cke,redo:bke,cut:wke,copy:Ske,paste:xke,"copy.as":Ake,"export.as":kke,"select.all":Ike,"select.none":Dke,delete:Tke,"new.project":Pke,open:Bke,save:Mke,"save.as":$ke,"upload.media":Rke,"create.page":Fke,"new.page":Lke,"page.name":Oke,duplicate:_ke,cancel:Nke,"copy.invite.link":zke,"copy.readonly.link":Hke,"create.multiplayer.project":jke,"copy.multiplayer.project":Uke,select:Kke,eraser:Vke,draw:Gke,arrow:Jke,text:Wke,sticky:Yke,rectangle:qke,ellipse:Xke,triangle:Zke,line:Qke,rotate:eIe,"lock.aspect.ratio":tIe,"unlock.aspect.ratio":nIe,group:rIe,ungroup:iIe,"move.to.back":oIe,"move.backward":aIe,"move.forward":sIe,"move.to.front":uIe,"reset.angle":lIe,lock:cIe,unlock:dIe,"align.distribute":hIe,"move.to.page":fIe,"flip.horizontal":pIe,"flip.vertical":gIe,move:mIe,"to.front":vIe,forward:yIe,backward:EIe,back:CIe,language:bIe,"translation.link":wIe,"dock.position":SIe,bottom:xIe,left:AIe,right:kIe,top:IIe,page:DIe,"keyboard.shortcuts":TIe,search:PIe,loading:BIe,"export.background":MIe,transparent:$Ie,auto:RIe,light:FIe,dark:LIe,github:OIe,twitter:_Ie,discord:NIe,image:zIe,"align.left":HIe,"align.center.x":jIe,"align.right":UIe,"align.top":KIe,"align.center.y":VIe,"align.bottom":GIe,"distribute.x":JIe,"distribute.y":WIe,"stretch.x":YIe,"stretch.y":qIe,"dialog.save.firsttime":XIe,"dialog.save.again":ZIe,"dialog.cancel":QIe,"dialog.no":eDe,"dialog.yes":tDe,"enter.file.name":nDe},iDe="สี",oDe="เติม",aDe="กรอบ",sDe="ขนาด",uDe="เปิดทิ้งไว้",lDe="แบบอักษร",cDe="จัดตำแหน่ง",dDe="รูปแบบ",hDe="ซูมเข้า",fDe="ซูมออก",pDe="ซูมไปที่",gDe="เครื่องมือ",mDe="แปลง",vDe="ไฟล์",yDe="แก้ไข",EDe="มุมมอง",CDe="การตั้งค่า",bDe="เข้าสู่ระบบ",wDe="ออกจากระบบ",SDe="ร่วมเป็นสปอนเซอร์",xDe="กลับไปยังเนื้อหา",ADe="ซูมไปยังส่วนที่เลือก",kDe="ซูมให้เต็มพอดี",IDe="ซูมไปที่",DDe="โหมดมืด",TDe="โหมดโฟกัส",PDe="โหมดดีบัก",BDe="แสดงตาราง",MDe="การเลือกแบบ CAD",$De="เปิดเมนูรูปแบบทิ้งไว้",RDe="แสดงสแนปตลอด",FDe="แสดงจุดจับการหมุน",LDe="แสดงหมายเลขอ้างอิง",ODe="แสดงตัวโคลน",_De="เลิกทำ",NDe="ทำซ้ำ",zDe="ตัด",HDe="คัดลอก",jDe="วาง",UDe="คัดลอกเป็น",KDe="ส่งออกเป็น",VDe="เลือกทั้งหมด",GDe="ยกเลิกสิ่งที่เลือก",JDe="ลบ",WDe="โปรเจกต์ใหม่",YDe="เปิด",qDe="บันทึก",XDe="บันทึกเป็น",ZDe="อัพโหลดมีเดีย",QDe="สร้างหน้า",eTe="หน้าใหม่",tTe="ชื่อหน้า",nTe="สำเนา",rTe="ยกเลิก",iTe="คัดลอกลิงก์เชิญ",oTe="คัดลอกลิงก์แบบให้อ่านอย่างเดียว",aTe="สร้างโปรเจกต์ผู้ใช้งานหลายคน",sTe="คัดลอกโปรเจกต์ผู้ใช้งานหลายคน",uTe="เลือก",lTe="ยางลบ",cTe="วาด",dTe="ลูกศร",hTe="ข้อความ",fTe="กระดาษโน๊ต",pTe="สี่เหลี่ยมผืนผ้า",gTe="วงรี",mTe="สามเหลี่ยม",vTe="เส้น",yTe="หมุน",ETe="ล็อคอัตราส่วนภาพ",CTe="ปลดล็อกอัตราส่วนภาพ",bTe="กลุ่ม",wTe="ยกเลิกกลุ่ม",STe="ย้ายไปด้านหลัง",xTe="ขยับถอยหลัง",ATe="ขยับไปหน้า",kTe="ย้ายไปด้านหน้า",ITe="รีเซ็ตมุม",DTe="ล็อค",TTe="ปลดล็อค",PTe="จัดตำแหน่ง / กระจาย",BTe="ย้ายไปยังหน้า",MTe="พลิกแนวนอน",$Te="พลิกแนวตั้ง",RTe="ย้าย",FTe="ไปยังด้านหน้า",LTe="ข้างหน้า",OTe="ข้างหลัง",_Te="ไปยังด้านหลัง",NTe="ภาษา",zTe="เรียนรู้เพิ่มเติม",HTe="ตำแหน่งแถบเครื่องมือ",jTe="ข้างล่าง",UTe="ข้างซ้าย",KTe="ข้างขวา",VTe="ข้างบน",GTe="หน้า",JTe="แป้นพิมพ์ลัด",WTe="ค้นหา",YTe="กำลังโหลด{dots}",qTe="ส่งออกพื้นหลัง",XTe="โปร่งใส",ZTe="อัตโนมัติ",QTe="สว่าง",ePe="มืด",tPe="Github",nPe="Twitter",rPe="Discord",iPe="ภาพ",oPe="จัดให้ชิดซ้าย",aPe="จัดให้อยู่กึ่งกลางแนวนอน",sPe="จัดให้ชิดขวา",uPe="จัดให้อยู่ด้านบน",lPe="จัดให้อยู่กึ่งกลางแนวตั้ง",cPe="จัดให้อยู่ด้านล่าง",dPe="กระจายแนวนอน",hPe="กระจายแนวตั้ง",fPe="ยืดแนวนอน",pPe="ยืดแนวตั้ง",gPe="คุณต้องการบันทึกโปรเจ็กต์ปัจจุบันของคุณหรือไม่?",mPe="คุณต้องการบันทึกการเปลี่ยนแปลงในโปรเจ็กต์ปัจจุบันของคุณหรือไม่?",vPe="ยกเลิก",yPe="ไม่",EPe="ใช่",CPe="กรอกชื่อไฟล์",bPe={"style.menu.color":iDe,"style.menu.fill":oDe,"style.menu.dash":aDe,"style.menu.size":sDe,"style.menu.keep.open":uDe,"style.menu.font":lDe,"style.menu.align":cDe,styles:dDe,"zoom.in":hDe,"zoom.out":fDe,to:pDe,"menu.tools":gDe,"menu.transform":mDe,"menu.file":vDe,"menu.edit":yDe,"menu.view":EDe,"menu.preferences":CDe,"menu.sign.in":bDe,"menu.sign.out":wDe,"become.a.sponsor":SDe,"zoom.to.content":xDe,"zoom.to.selection":ADe,"zoom.to.fit":kDe,"zoom.to":IDe,"preferences.dark.mode":DDe,"preferences.focus.mode":TDe,"preferences.debug.mode":PDe,"preferences.show.grid":BDe,"preferences.use.cad.selection":MDe,"preferences.keep.stylemenu.open":$De,"preferences.always.show.snaps":RDe,"preferences.rotate.handles":FDe,"preferences.binding.handles":LDe,"preferences.clone.handles":ODe,undo:_De,redo:NDe,cut:zDe,copy:HDe,paste:jDe,"copy.as":UDe,"export.as":KDe,"select.all":VDe,"select.none":GDe,delete:JDe,"new.project":WDe,open:YDe,save:qDe,"save.as":XDe,"upload.media":ZDe,"create.page":QDe,"new.page":eTe,"page.name":tTe,duplicate:nTe,cancel:rTe,"copy.invite.link":iTe,"copy.readonly.link":oTe,"create.multiplayer.project":aTe,"copy.multiplayer.project":sTe,select:uTe,eraser:lTe,draw:cTe,arrow:dTe,text:hTe,sticky:fTe,rectangle:pTe,ellipse:gTe,triangle:mTe,line:vTe,rotate:yTe,"lock.aspect.ratio":ETe,"unlock.aspect.ratio":CTe,group:bTe,ungroup:wTe,"move.to.back":STe,"move.backward":xTe,"move.forward":ATe,"move.to.front":kTe,"reset.angle":ITe,lock:DTe,unlock:TTe,"align.distribute":PTe,"move.to.page":BTe,"flip.horizontal":MTe,"flip.vertical":$Te,move:RTe,"to.front":FTe,forward:LTe,backward:OTe,back:_Te,language:NTe,"translation.link":zTe,"dock.position":HTe,bottom:jTe,left:UTe,right:KTe,top:VTe,page:GTe,"keyboard.shortcuts":JTe,search:WTe,loading:YTe,"export.background":qTe,transparent:XTe,auto:ZTe,light:QTe,dark:ePe,github:tPe,twitter:nPe,discord:rPe,image:iPe,"align.left":oPe,"align.center.x":aPe,"align.right":sPe,"align.top":uPe,"align.center.y":lPe,"align.bottom":cPe,"distribute.x":dPe,"distribute.y":hPe,"stretch.x":fPe,"stretch.y":pPe,"dialog.save.firsttime":gPe,"dialog.save.again":mPe,"dialog.cancel":vPe,"dialog.no":yPe,"dialog.yes":EPe,"enter.file.name":CPe},wPe="Renk",SPe="Doldur",xPe="Çizgi",APe="Boyut",kPe="Açık Tut",IPe="Yazı Tipi",DPe="Hizala",TPe="Stiller",PPe="Yakınlaştır",BPe="Uzaklaştır",MPe="",$Pe="Dosya",RPe="Düzenle",FPe="Görüntü",LPe="Tercihler",OPe="Giriş Yap",_Pe="Oturumu Kapat",NPe="Sponsor Ol",zPe="Seçime Yakınlaştır",HPe="Sığdırmak için Yakınlaştır",jPe="Yakınlaştır",UPe="Karanlık Mod",KPe="Odak Modu",VPe="Debug Modu",GPe="Izgarayı Göster",JPe="CAD Seçimi Kullan",WPe="Stil Menüsünü Açık Tut",YPe="Hiza Çizgilerini Hep Göster",qPe="Rotasyon Kontrolcüleri",XPe="Bağlama Kontrolcüleri",ZPe="Klon Kontrolcüleri",QPe="Geri Al",eBe="Yinele",tBe="Kes",nBe="Kopyala",rBe="Yapıştır",iBe="Olarak Kopyala",oBe="Olarak Dışarı Aktar",aBe="Hepsini Seç",sBe="Hiçbirini Seçme",uBe="Sil",lBe="Yeni Proje",cBe="Aç",dBe="Kaydet",hBe="Farklı Kaydet",fBe="Medya Yükle",pBe="Sayfa Oluştur",gBe="Yeni Sayfa",mBe="Sayfa İsmi",vBe="Kopya Oluştur",yBe="İptal",EBe="Davet Linkini Kopyala",CBe="Çok Oyunculu Proje Oluştur",bBe="Çok Oyunculu Projeye Kopyala",wBe="Seç",SBe="Silgi",xBe="Çizim",ABe="Ok",kBe="Yazı",IBe="Yapışkan",DBe="Dikdörtgen",TBe="Elips",PBe="Üçgen",BBe="Çizgi",MBe="Döndür",$Be="En Boy Oranını Kilitle",RBe="En Boy Oranı Kilidini Aç",FBe="Grupla",LBe="Gruplamayı Kaldır",OBe="Arkaya Taşı",_Be="En Arkaya Taşı",NBe="En Öne Taşı",zBe="Öne Taşı",HBe="Açıyı Sıfırla",jBe="Kilitle",UBe="Kilidini Aç",KBe="Sayfaya Taşı",VBe="Yatay Çevir",GBe="Dikey Çevir",JBe="Taşı",WBe="Öne",YBe="En Öne",qBe="En Arkaya",XBe="Arkaya",ZBe="Dil",QBe={"style.menu.color":wPe,"style.menu.fill":SPe,"style.menu.dash":xPe,"style.menu.size":APe,"style.menu.keep.open":kPe,"style.menu.font":IPe,"style.menu.align":DPe,styles:TPe,"zoom.in":PPe,"zoom.out":BPe,to:MPe,"menu.file":$Pe,"menu.edit":RPe,"menu.view":FPe,"menu.preferences":LPe,"menu.sign.in":OPe,"menu.sign.out":_Pe,"become.a.sponsor":NPe,"zoom.to.selection":zPe,"zoom.to.fit":HPe,"zoom.to":jPe,"preferences.dark.mode":UPe,"preferences.focus.mode":KPe,"preferences.debug.mode":VPe,"preferences.show.grid":GPe,"preferences.use.cad.selection":JPe,"preferences.keep.stylemenu.open":WPe,"preferences.always.show.snaps":YPe,"preferences.rotate.handles":qPe,"preferences.binding.handles":XPe,"preferences.clone.handles":ZPe,undo:QPe,redo:eBe,cut:tBe,copy:nBe,paste:rBe,"copy.as":iBe,"export.as":oBe,"select.all":aBe,"select.none":sBe,delete:uBe,"new.project":lBe,open:cBe,save:dBe,"save.as":hBe,"upload.media":fBe,"create.page":pBe,"new.page":gBe,"page.name":mBe,duplicate:vBe,cancel:yBe,"copy.invite.link":EBe,"create.multiplayer.project":CBe,"copy.multiplayer.project":bBe,select:wBe,eraser:SBe,draw:xBe,arrow:ABe,text:kBe,sticky:IBe,rectangle:DBe,ellipse:TBe,triangle:PBe,line:BBe,rotate:MBe,"lock.aspect.ratio":$Be,"unlock.aspect.ratio":RBe,group:FBe,ungroup:LBe,"move.to.back":OBe,"move.backward":_Be,"move.forward":NBe,"move.to.front":zBe,"reset.angle":HBe,lock:jBe,unlock:UBe,"move.to.page":KBe,"flip.horizontal":VBe,"flip.vertical":GBe,move:JBe,"to.front":WBe,forward:YBe,backward:qBe,back:XBe,language:ZBe},eMe="Колір",tMe="Заповнювати",nMe="Штрих",rMe="Розмір",iMe="Тримати відкритим",oMe="Шрифт",aMe="Вирівняти",sMe="Стиль",uMe="Збільшити",lMe="Зменшити",cMe="до",dMe="Файл",hMe="Редагування",fMe="Вигляд",pMe="Налаштування",gMe="Увійти",mMe="Вийти",vMe="Стати спонсором",yMe="Наблизити до виділення",EMe="Збільшити за розміром екрану",CMe="Наблизити до",bMe="Темна тема",wMe="Мінімалістичний режим",SMe="Режим налагодження",xMe="Показати сітку",AMe="Використовувати CAD виділення",kMe="Тримати меню стилів відкритим",IMe="Завжди показувати прив'язки",DMe="Ручки обертання",TMe="Ручки прив'язки",PMe="Ручки клонування",BMe="Скасувати",MMe="Повторити",$Me="Вирізати",RMe="Скопіювати",FMe="Вставити",LMe="Скопіювати як",OMe="Експортувати як",_Me="Обрати все",NMe="Зняти виділення",zMe="Видалити",HMe="Новий проект",jMe="Відкрити",UMe="Зберегти",KMe="Зберегти як",VMe="Завантажити медіа",GMe="Створити сторінку",JMe="Нова сторінка",WMe="Назва сторінки",YMe="Дублювати",qMe="Скасувати",XMe="Скопіювати посилання на запрошення",ZMe="Створити багатокористувацький проект",QMe="Скопіювати в багатокористувацький проект",e$e="Вибирати",t$e="Ластик",n$e="Малювати",r$e="Стрілка",i$e="Текст",o$e="Нотатка",a$e="Прямокутник",s$e="Еліпс",u$e="Трикутник",l$e=" Лінія",c$e="Повернути",d$e="Заблокувати співвідношення сторін",h$e=" Розблокувати співвідношення сторін",f$e="Згрупувати",p$e=" Розгрупувати",g$e="Перемістити назад",m$e="Перемістити на задній план",v$e="Перемістити вперед",y$e="Перемістити на передній план",E$e="Скидання кута",C$e="Блокування",b$e=" Розблокування",w$e="Перейти на сторінку",S$e="Перевернути горизонтально",x$e="Перевернути вертикально",A$e="Перемістити",k$e="На передній план",I$e=" Вперед",D$e="На задній план",T$e="Назад",P$e="Мова",B$e={"style.menu.color":eMe,"style.menu.fill":tMe,"style.menu.dash":nMe,"style.menu.size":rMe,"style.menu.keep.open":iMe,"style.menu.font":oMe,"style.menu.align":aMe,styles:sMe,"zoom.in":uMe,"zoom.out":lMe,to:cMe,"menu.file":dMe,"menu.edit":hMe,"menu.view":fMe,"menu.preferences":pMe,"menu.sign.in":gMe,"menu.sign.out":mMe,"become.a.sponsor":vMe,"zoom.to.selection":yMe,"zoom.to.fit":EMe,"zoom.to":CMe,"preferences.dark.mode":bMe,"preferences.focus.mode":wMe,"preferences.debug.mode":SMe,"preferences.show.grid":xMe,"preferences.use.cad.selection":AMe,"preferences.keep.stylemenu.open":kMe,"preferences.always.show.snaps":IMe,"preferences.rotate.handles":DMe,"preferences.binding.handles":TMe,"preferences.clone.handles":PMe,undo:BMe,redo:MMe,cut:$Me,copy:RMe,paste:FMe,"copy.as":LMe,"export.as":OMe,"select.all":_Me,"select.none":NMe,delete:zMe,"new.project":HMe,open:jMe,save:UMe,"save.as":KMe,"upload.media":VMe,"create.page":GMe,"new.page":JMe,"page.name":WMe,duplicate:YMe,cancel:qMe,"copy.invite.link":XMe,"create.multiplayer.project":ZMe,"copy.multiplayer.project":QMe,select:e$e,eraser:t$e,draw:n$e,arrow:r$e,text:i$e,sticky:o$e,rectangle:a$e,ellipse:s$e,triangle:u$e,line:l$e,rotate:c$e,"lock.aspect.ratio":d$e,"unlock.aspect.ratio":h$e,group:f$e,ungroup:p$e,"move.to.back":g$e,"move.backward":m$e,"move.forward":v$e,"move.to.front":y$e,"reset.angle":E$e,lock:C$e,unlock:b$e,"move.to.page":w$e,"flip.horizontal":S$e,"flip.vertical":x$e,move:A$e,"to.front":k$e,forward:I$e,backward:D$e,back:T$e,language:P$e},M$e="颜色",$$e="填充",R$e="边框",F$e="尺寸",L$e="保持常开",O$e="字体",_$e="对齐",N$e="样式",z$e="放大",H$e="缩小",j$e="缩放至",U$e="工具",K$e="转换",V$e="文件",G$e="编辑",J$e="视图",W$e="偏好",Y$e="登录",q$e="登出",X$e="搜索",Z$e="成为赞助者",Q$e="缩放选中",eRe="自适应缩放",tRe="缩放至",nRe="缩放至内容",rRe="暗黑模式",iRe="专注模式",oRe="调试模式",aRe="显示网格",sRe="使用 CAD 选择",uRe="保持样式菜单常开",lRe="总是展示对齐线",cRe="旋转手柄",dRe="捆绑手柄",hRe="克隆手柄",fRe="撤销",pRe="重做",gRe="剪切",mRe="复制",vRe="粘贴",yRe="复制为",ERe="导出为",CRe="选中全部",bRe="取消选中",wRe="删除",SRe="新项目",xRe="打开",ARe="保存",kRe="保存为",IRe="上传媒体文件",DRe="创建页面",TRe="新页面",PRe="页面名称",BRe="复制",MRe="取消",$Re="复制邀请链接",RRe="创建多人项目",FRe="复制到多人项目",LRe="选择",ORe="橡皮",_Re="画笔",NRe="箭头",zRe="文本",HRe="便利贴",jRe="矩形",URe="椭圆形",KRe="三角形",VRe="直线",GRe="旋转",JRe="锁定宽高比",WRe="解锁宽高比",YRe="分组",qRe="取消分组",XRe="置底",ZRe="下移一层",QRe="上移一层",eFe="置顶",tFe="重置旋转角度",nFe="锁定",rFe="解锁",iFe="移动到页面",oFe="水平翻转",aFe="垂直翻转",sFe="移动",uFe="置顶",lFe="上一层",cFe="下一层",dFe="置底",hFe="语言",fFe="键盘快捷键",pFe="了解更多",gFe="页面",mFe="锚点位置",vFe="下面",yFe="左面",EFe="右面",CFe="上面",bFe="导出背景色",wFe="透明",SFe="自动",xFe="明亮",AFe="暗黑",kFe="复制只读链接",IFe="图片",DFe="对齐 / 分散",TFe="您是否想保存当前的项目?",PFe="您是否想保存对当前项目的更改?",BFe="取消",MFe="否",$Fe="是",RFe={"style.menu.color":M$e,"style.menu.fill":$$e,"style.menu.dash":R$e,"style.menu.size":F$e,"style.menu.keep.open":L$e,"style.menu.font":O$e,"style.menu.align":_$e,styles:N$e,"zoom.in":z$e,"zoom.out":H$e,to:j$e,"menu.tools":U$e,"menu.transform":K$e,"menu.file":V$e,"menu.edit":G$e,"menu.view":J$e,"menu.preferences":W$e,"menu.sign.in":Y$e,"menu.sign.out":q$e,search:X$e,"become.a.sponsor":Z$e,"zoom.to.selection":Q$e,"zoom.to.fit":eRe,"zoom.to":tRe,"zoom.to.content":nRe,"preferences.dark.mode":rRe,"preferences.focus.mode":iRe,"preferences.debug.mode":oRe,"preferences.show.grid":aRe,"preferences.use.cad.selection":sRe,"preferences.keep.stylemenu.open":uRe,"preferences.always.show.snaps":lRe,"preferences.rotate.handles":cRe,"preferences.binding.handles":dRe,"preferences.clone.handles":hRe,undo:fRe,redo:pRe,cut:gRe,copy:mRe,paste:vRe,"copy.as":yRe,"export.as":ERe,"select.all":CRe,"select.none":bRe,delete:wRe,"new.project":SRe,open:xRe,save:ARe,"save.as":kRe,"upload.media":IRe,"create.page":DRe,"new.page":TRe,"page.name":PRe,duplicate:BRe,cancel:MRe,"copy.invite.link":$Re,"create.multiplayer.project":RRe,"copy.multiplayer.project":FRe,select:LRe,eraser:ORe,draw:_Re,arrow:NRe,text:zRe,sticky:HRe,rectangle:jRe,ellipse:URe,triangle:KRe,line:VRe,rotate:GRe,"lock.aspect.ratio":JRe,"unlock.aspect.ratio":WRe,group:YRe,ungroup:qRe,"move.to.back":XRe,"move.backward":ZRe,"move.forward":QRe,"move.to.front":eFe,"reset.angle":tFe,lock:nFe,unlock:rFe,"move.to.page":iFe,"flip.horizontal":oFe,"flip.vertical":aFe,move:sFe,"to.front":uFe,forward:lFe,backward:cFe,back:dFe,language:hFe,"keyboard.shortcuts":fFe,"translation.link":pFe,page:gFe,"dock.position":mFe,bottom:vFe,left:yFe,right:EFe,top:CFe,"export.background":bFe,transparent:wFe,auto:SFe,light:xFe,dark:AFe,"copy.readonly.link":kFe,image:IFe,"align.distribute":DFe,"dialog.save.firsttime":TFe,"dialog.save.again":PFe,"dialog.cancel":BFe,"dialog.no":MFe,"dialog.yes":$Fe},FFe="顏色",LFe="填充",OFe="虛線",_Fe="大小",NFe="保持開啟",zFe="字型",HFe="對齊",jFe="樣式",UFe="放大",KFe="縮小",VFe="至",GFe="檔案",JFe="編輯",WFe="檢視",YFe="選項",qFe="登入",XFe="登出",ZFe="成為贊助者",QFe="縮放至選取範圍",eLe="縮放至適當大小",tLe="縮放至",nLe="深色模式",rLe="專注模式",iLe="除錯模式",oLe="顯示網格",aLe="使用 CAD 選取",sLe="樣式選單保持開啟",uLe="永遠顯示對齊線",lLe="旋轉控點",cLe="綁定控點",dLe="複製控點",hLe="復原",fLe="取消復原",pLe="剪下",gLe="複製",mLe="貼上",vLe="複製成",yLe="匯出成",ELe="全選",CLe="取消選取",bLe="刪除",wLe="新專案",SLe="開啟",xLe="儲存",ALe="另存為",kLe="上傳媒體",ILe="建立頁面",DLe="新頁面",TLe="頁面名稱",PLe="複製",BLe="取消",MLe="複製邀請連結",$Le="複製唯讀連結",RLe="建立多人專案",FLe="複製至多人專案",LLe="選取",OLe="橡皮擦",_Le="手繪",NLe="箭頭",zLe="文字",HLe="便利貼",jLe="長方形",ULe="橢圓形",KLe="三角形",VLe="直線",GLe="旋轉",JLe="鎖定長寬比",WLe="解鎖長寬比",YLe="組成群組",qLe="取消群組",XLe="移到最下層",ZLe="下移一層",QLe="上移一層",eOe="移到最上層",tOe="重設角度",nOe="鎖定",rOe="解鎖",iOe="移至頁面",oOe="水平翻轉",aOe="垂直翻轉",sOe="移動",uOe="到最上層",lOe="到上一層",cOe="到下一層",dOe="到最下層",hOe="語言",fOe="了解詳情",pOe="工具列位置",gOe="下方",mOe="左側",vOe="右側",yOe="上方",EOe="頁面",COe={"style.menu.color":FFe,"style.menu.fill":LFe,"style.menu.dash":OFe,"style.menu.size":_Fe,"style.menu.keep.open":NFe,"style.menu.font":zFe,"style.menu.align":HFe,styles:jFe,"zoom.in":UFe,"zoom.out":KFe,to:VFe,"menu.file":GFe,"menu.edit":JFe,"menu.view":WFe,"menu.preferences":YFe,"menu.sign.in":qFe,"menu.sign.out":XFe,"become.a.sponsor":ZFe,"zoom.to.selection":QFe,"zoom.to.fit":eLe,"zoom.to":tLe,"preferences.dark.mode":nLe,"preferences.focus.mode":rLe,"preferences.debug.mode":iLe,"preferences.show.grid":oLe,"preferences.use.cad.selection":aLe,"preferences.keep.stylemenu.open":sLe,"preferences.always.show.snaps":uLe,"preferences.rotate.handles":lLe,"preferences.binding.handles":cLe,"preferences.clone.handles":dLe,undo:hLe,redo:fLe,cut:pLe,copy:gLe,paste:mLe,"copy.as":vLe,"export.as":yLe,"select.all":ELe,"select.none":CLe,delete:bLe,"new.project":wLe,open:SLe,save:xLe,"save.as":ALe,"upload.media":kLe,"create.page":ILe,"new.page":DLe,"page.name":TLe,duplicate:PLe,cancel:BLe,"copy.invite.link":MLe,"copy.readonly.link":$Le,"create.multiplayer.project":RLe,"copy.multiplayer.project":FLe,select:LLe,eraser:OLe,draw:_Le,arrow:NLe,text:zLe,sticky:HLe,rectangle:jLe,ellipse:ULe,triangle:KLe,line:VLe,rotate:GLe,"lock.aspect.ratio":JLe,"unlock.aspect.ratio":WLe,group:YLe,ungroup:qLe,"move.to.back":XLe,"move.backward":ZLe,"move.forward":QLe,"move.to.front":eOe,"reset.angle":tOe,lock:nOe,unlock:rOe,"move.to.page":iOe,"flip.horizontal":oOe,"flip.vertical":aOe,move:sOe,"to.front":uOe,forward:lOe,backward:cOe,back:dOe,language:hOe,"translation.link":fOe,"dock.position":pOe,bottom:gOe,left:mOe,right:vOe,top:yOe,page:EOe},SC=[{locale:"ar",label:"عربي",messages:Bie},{locale:"da",label:"Danish",messages:Gae},{locale:"de",label:"Deutsch",messages:xue},{locale:"en",label:"English",messages:Aue},{locale:"es",label:"Español",messages:mce},{locale:"fa",label:"فارسی",messages:Wde},{locale:"fr",label:"Français",messages:Ghe},{locale:"he",label:"עברית",messages:xpe},{locale:"it",label:"Italiano",messages:ume},{locale:"ja",label:"日本語",messages:z1e},{locale:"ko-kr",label:"한국어",messages:yve},{locale:"ne",label:"नेपाली",messages:gEe},{locale:"no",label:"Norwegian",messages:JCe},{locale:"pl",label:"Polski",messages:A5e},{locale:"pt",label:"Português - Europeu",messages:ySe},{locale:"pt-br",label:"Português - Brasil",messages:zwe},{locale:"ru",label:"Russian",messages:O8e},{locale:"sv",label:"Svenska",messages:NAe},{locale:"te",label:"తెలుగు",messages:rDe},{locale:"tr",label:"Türkçe",messages:QBe},{locale:"uk",label:"Ukrainian",messages:B$e},{locale:"zh-ch",label:"简体中文",messages:RFe},{locale:"zh-tw",label:"繁體中文 (台灣)",messages:COe},{locale:"th",label:"ภาษาไทย",messages:bPe}];SC.sort((e,t)=>e.localer.locale===e);return{locale:e,label:(t=n==null?void 0:n.label)!=null?t:e,messages:_(_({},Oye),n==null?void 0:n.messages)}}function wOe(e){return l.useMemo(()=>bOe(e??navigator.language.split(/[-_]/)[0]),[e])}var DT=l.createContext({}),TT=()=>{let e=l.useContext(DT);if(!e)throw new Error("useCtx must be inside a Provider with a value");return e},st=l.forwardRef((e,t)=>{var n=e,{onSelect:r,onClick:i,onDoubleClick:o,variant:a,children:s,isToolLocked:u=!1,disabled:d=!1,isActive:h=!1,onKeyDown:p,id:g}=n,m=$i(n,["onSelect","onClick","onDoubleClick","variant","children","isToolLocked","disabled","isActive","onKeyDown","id"]);return l.createElement(SOe,_({ref:t,isActive:h,variant:a,onClick:i,disabled:d,onPointerDown:r,onDoubleClick:o,onKeyDown:p,bp:Ci,id:g},m),l.createElement(Hi,null,s),u&&l.createElement(xOe,null))});function Xu(e){var t=e,{label:n,kbd:r,isLocked:i}=t,o=$i(t,["label","kbd","isLocked"]);let a=wt(),s=l.useCallback(()=>{a.toggleToolLock()},[]),u=l.useCallback(d=>{d.key===" "&&a.isForcePanning&&d.preventDefault()},[]);return l.createElement(jt,{label:n[0].toUpperCase()+n.slice(1),kbd:r},l.createElement(st,q(_({},o),{variant:"primary",isToolLocked:i&&o.isActive,onDoubleClick:s,onKeyDown:u})))}var Hi=fe("div",{position:"relative",height:"100%",width:"100%",backgroundColor:"$panel",borderRadius:"$2",margin:"0",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"$ui",color:"inherit",userSelect:"none",boxSizing:"border-box",border:"1px solid transparent","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent"}),SOe=fe("button",{position:"relative",color:"$text",fontSize:"$0",background:"none",margin:"0",padding:"$2",display:"flex",alignItems:"center",justifyContent:"center",outline:"none",cursor:"pointer",pointerEvents:"all",height:"40px",width:"40px",border:"1px solid $panel","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent",[`&:disabled ${Hi}`]:{opacity:.618},variants:{variant:{primary:{marginTop:"0"},icon:{[`& ${Hi}`]:{display:"grid","& > *":{gridRow:1,gridColumn:1}}},text:{width:"auto",[`& ${Hi}`]:{fontSize:"$1",padding:"0 $3",gap:"$3"}},circle:{padding:0,height:32,width:32,border:"none",[`& ${Hi}`]:{border:"1px solid $panelContrast",borderRadius:"100%",boxShadow:"$panel"},[`& ${Hi} > svg`]:{width:14,height:14}}},isActive:{true:{},false:{}},bp:{mobile:{padding:0},small:{}}},compoundVariants:[{variant:"primary",bp:"mobile",css:{height:40,width:36,[`& ${Hi} > svg`]:{width:16,height:16}}},{variant:"primary",bp:"small",css:{height:"44px",width:"44px",[`& ${Hi} > svg`]:{width:20,height:20}}},{isActive:!0,css:{[`${Hi}`]:{backgroundColor:"$selected",color:"$selectedContrast"}}},{isActive:!1,bp:"small",css:{[`&:hover:not(:disabled) ${Hi}`]:{backgroundColor:"$hover"},[`&:focus:not(:disabled) ${Hi}`]:{backgroundColor:"$hover"}}}]}),xOe=fe("div",{position:"absolute",width:10,height:10,backgroundColor:"$selected",borderRadius:"100%",bottom:-2,border:"2px solid $panel",zIndex:100}),AOe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,kOe=e=>e.settings.isDebugMode,IOe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.some(t=>e.document.pages[e.appState.currentPageId].shapes[t].children!==void 0),DOe=e=>e.stopPropagation(),TOe=({onBlur:e,children:t})=>{let n=Nu();return l.createElement(tY,{dir:"ltr"},l.createElement(nY,{dir:"ltr"},t),l.createElement(Ym,{container:n.current},l.createElement(rY,{onEscapeKeyDown:DOe,tabIndex:-1,onBlur:e,asChild:!0},l.createElement(_u,{id:"TD-ContextMenu"},l.createElement(POe,null)))))},POe=l.memo(function(){let e=wt(),t=Wn(),n=e.useStore(AOe),r=e.useStore(kOe),i=e.useStore(IOe),o=l.useCallback(()=>{e.flipHorizontal()},[e]),a=l.useCallback(()=>{e.flipVertical()},[e]),s=l.useCallback(()=>{e.duplicate()},[e]),u=l.useCallback(()=>{e.toggleLocked()},[e]),d=l.useCallback(()=>{e.group()},[e]),h=l.useCallback(()=>{e.moveToBack()},[e]),p=l.useCallback(()=>{e.moveBackward()},[e]),g=l.useCallback(()=>{e.moveForward()},[e]),m=l.useCallback(()=>{e.moveToFront()},[e]),v=l.useCallback(()=>{e.delete()},[e]),E=l.useCallback(()=>{e.cut()},[e]),w=l.useCallback(()=>{e.copy()},[e]),C=l.useCallback(()=>{e.paste()},[e]),b=l.useCallback(()=>{e.copyImage("svg",{scale:1,quality:1,transparentBackground:!1})},[e]),A=l.useCallback(()=>{e.copyImage("png",{scale:2,quality:1,transparentBackground:!0})},[e]),T=l.useCallback(()=>{e.undo()},[e]),B=l.useCallback(()=>{e.redo()},[e]),D=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("png",{scale:2,quality:1})}),[e]),I=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("jpeg",{scale:2,quality:1})}),[e]),M=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("webp",{scale:2,quality:1})}),[e]),O=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("svg",{scale:1,quality:1})}),[e]),z=l.useCallback(()=>Oe(this,null,function*(){e.copyJson()}),[e]),K=l.useCallback(()=>Oe(this,null,function*(){e.exportJson()}),[e]),X=n>0,Z=n>1,pe=n>2;return l.createElement(l.Fragment,null,X?l.createElement(l.Fragment,null,l.createElement(It,{onClick:s,kbd:"#D",id:"TD-ContextMenu-Duplicate"},l.createElement(ge,{id:"duplicate"})),l.createElement(It,{onClick:o,kbd:"⇧H",id:"TD-ContextMenu-Flip_Horizontal"},l.createElement(ge,{id:"flip.horizontal"})),l.createElement(It,{onClick:a,kbd:"⇧V",id:"TD-ContextMenu-Flip_Vertical"},l.createElement(ge,{id:"flip.vertical"})),l.createElement(It,{onClick:u,kbd:"#⇧L",id:"TD-ContextMenu- Lock_Unlock"},l.createElement(ge,{id:"lock"})," / ",l.createElement(ge,{id:"unlock"})),(Z||i)&&l.createElement(Qt,null),Z&&l.createElement(It,{onClick:d,kbd:"#G",id:"TD-ContextMenu-Group"},l.createElement(ge,{id:"group"})),i&&l.createElement(It,{onClick:d,kbd:"#G",id:"TD-ContextMenu-Ungroup"},l.createElement(ge,{id:"ungroup"})),l.createElement(Qt,null),l.createElement(Gv,{label:t.formatMessage({id:"move"}),id:"TD-ContextMenu-Move"},l.createElement(It,{onClick:m,kbd:"⇧]",id:"TD-ContextMenu-Move-To_Front"},l.createElement(ge,{id:"to.front"})),l.createElement(It,{onClick:g,kbd:"]",id:"TD-ContextMenu-Move-Forward"},l.createElement(ge,{id:"forward"})),l.createElement(It,{onClick:p,kbd:"[",id:"TD-ContextMenu-Move-Backward"},l.createElement(ge,{id:"backward"})),l.createElement(It,{onClick:h,kbd:"⇧[",id:"TD-ContextMenu-Move-To_Back"},l.createElement(ge,{id:"back"}))),l.createElement(FOe,null),Z&&l.createElement(BOe,{hasTwoOrMore:Z,hasThreeOrMore:pe}),l.createElement(Qt,null),l.createElement(It,{onClick:E,kbd:"#X",id:"TD-ContextMenu-Cut"},l.createElement(ge,{id:"cut"})),l.createElement(It,{onClick:w,kbd:"#C",id:"TD-ContextMenu-Copy"},l.createElement(ge,{id:"copy"})),l.createElement(It,{onClick:C,kbd:"#V",id:"TD-ContextMenu-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(Qt,null),l.createElement(Gv,{label:`${t.formatMessage({id:"copy.as"})}...`,size:"small",id:"TD-ContextMenu-Copy-As"},l.createElement(It,{onClick:b,id:"TD-ContextMenu-Copy-as-SVG"},"SVG"),l.createElement(It,{onClick:A,id:"TD-ContextMenu-Copy-As-PNG"},"PNG"),r&&l.createElement(It,{onClick:z,id:"TD-ContextMenu-Copy_as_JSON"},"JSON")),l.createElement(Gv,{label:`${t.formatMessage({id:"export.as"})}...`,size:"small",id:"TD-ContextMenu-Export"},l.createElement(It,{onClick:O,id:"TD-ContextMenu-Export-SVG"},"SVG"),l.createElement(It,{onClick:D,id:"TD-ContextMenu-Export-PNG"},"PNG"),l.createElement(It,{onClick:I,id:"TD-ContextMenu-Export-JPG"},"JPG"),l.createElement(It,{onClick:M,id:"TD-ContextMenu-Export-WEBP"},"WEBP"),r&&l.createElement(It,{onClick:K,id:"TD-ContextMenu-Export-JSON"},"JSON")),l.createElement(Qt,null),l.createElement(It,{onClick:v,kbd:"⌫",id:"TD-ContextMenu-Delete"},l.createElement(ge,{id:"delete"}))):l.createElement(l.Fragment,null,l.createElement(It,{onClick:C,kbd:"#V",id:"TD-ContextMenu-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(It,{onClick:T,kbd:"#Z",id:"TD-ContextMenu-Undo"},l.createElement(ge,{id:"undo"})),l.createElement(It,{onClick:B,kbd:"#⇧Z",id:"TD-ContextMenu-Redo"},l.createElement(ge,{id:"redo"}))))});function BOe({hasThreeOrMore:e}){let t=wt(),n=l.useCallback(()=>{t.align("top")},[t]),r=l.useCallback(()=>{t.align("centerVertical")},[t]),i=l.useCallback(()=>{t.align("bottom")},[t]),o=l.useCallback(()=>{t.stretch("vertical")},[t]),a=l.useCallback(()=>{t.distribute("vertical")},[t]),s=l.useCallback(()=>{t.align("left")},[t]),u=l.useCallback(()=>{t.align("centerHorizontal")},[t]),d=l.useCallback(()=>{t.align("right")},[t]),h=l.useCallback(()=>{t.stretch("horizontal")},[t]),p=l.useCallback(()=>{t.distribute("horizontal")},[t]),g=Nu();return l.createElement(OE,null,l.createElement(AC,{id:"TD-ContextMenu-Align-Distribute-Trigger"},l.createElement(ge,{id:"align.distribute"})),l.createElement(Ym,{container:g.current},l.createElement(_E,{asChild:!0,sideOffset:4,alignOffset:-2},l.createElement(MOe,{numberOfSelected:e?"threeOrMore":"twoOrMore"},l.createElement(vo,{onClick:s,id:"TD-ContextMenu-Align_Distribute-AlignLeft"},l.createElement(Zk,null)),l.createElement(vo,{onClick:u,id:"TD-ContextMenu-Align_Distribute-AlignCenterHorizontal"},l.createElement(qk,null)),l.createElement(vo,{onClick:d,id:"TD-ContextMenu-Align_Distribute-AlignRight"},l.createElement(Qk,null)),l.createElement(vo,{onClick:h,id:"TD-ContextMenu-Align_Distribute-StretchHorizontal"},l.createElement(iI,null)),e&&l.createElement(vo,{onClick:p,id:"TD-ContextMenu-Align_Distribute-SpaceEvenlyHorizontal"},l.createElement(nI,null)),l.createElement(vo,{onClick:n,id:"TD-ContextMenu-Align_Distribute-AlignTop"},l.createElement(eI,null)),l.createElement(vo,{onClick:r,id:"TD-ContextMenu-Align_Distribute-AlignCenterVertical"},l.createElement(Xk,null)),l.createElement(vo,{onClick:i,id:"TD-ContextMenu-Align_Distribute-AlignBottom"},l.createElement(Yk,null)),l.createElement(vo,{onClick:o,id:"TD-ContextMenu-Align_Distribute-StretchVertical"},l.createElement(oI,null)),e&&l.createElement(vo,{onClick:a,id:"TD-ContextMenu-Align_Distribute-SpaceEvenlyVertical"},l.createElement(rI,null)),l.createElement(xC,{offset:13})))))}var MOe=fe(_u,{display:"grid",variants:{numberOfSelected:{threeOrMore:{gridTemplateColumns:"repeat(5, auto)"},twoOrMore:{gridTemplateColumns:"repeat(4, auto)"}}}}),$Oe=e=>e.appState.currentPageId,ROe=e=>e.document.pages;function FOe(){let e=wt(),t=e.useStore($Oe),n=e.useStore(ROe),r=Object.values(n).sort((o,a)=>(o.childIndex||0)-(a.childIndex||0)).filter(o=>o.id!==t),i=Nu();return r.length===0?null:l.createElement(OE,null,l.createElement(AC,null,l.createElement(ge,{id:"move.to.page"})),l.createElement(Ym,{container:i.current},l.createElement(_E,{sideOffset:4,alignOffset:-2,asChild:!0},l.createElement(_u,null,r.map(({id:o,name:a},s)=>l.createElement(It,{key:o,disabled:o===t,onClick:()=>e.moveToPage(o)},a||`Page ${s}`)),l.createElement(xC,{offset:13})))))}function Gv({children:e,label:t,size:n,id:r}){let i=Nu();return l.createElement(OE,null,l.createElement(AC,null,t),l.createElement(Ym,{container:i.current},l.createElement(_E,{sideOffset:4,alignOffset:-2,asChild:!0},l.createElement(_u,{size:n},e,l.createElement(xC,{offset:13})))))}var xC=fe(XW,{fill:"$panel"});function vo(e){var t=e,{onSelect:n}=t,r=$i(t,["onSelect"]);return l.createElement(Wk,{dir:"ltr",onSelect:n,asChild:!0},l.createElement(st,_({},r)))}var It=e=>{var t=e,{id:n}=t,r=$i(t,["id"]);return l.createElement(Wk,{asChild:!0,id:n},l.createElement(ur,_({},r)))},AC=e=>{var t=e,{id:n}=t,r=$i(t,["id"]);return l.createElement(iY,{asChild:!0,id:n},l.createElement(ur,_({hasArrow:!0},r)))},LOe=l.memo(TOe);function OOe({error:e,resetErrorBoundary:t}){let n=wt(),r=()=>{window.location.reload(),t()},i=()=>{let s=document.createElement("textarea");s.value=e.message,document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()},o=()=>{n.saveProjectAs()},a=()=>{n.resetDocument(),t()};return l.createElement(_Oe,null,l.createElement(NOe,null,l.createElement("div",null,"We've encountered an error!"),l.createElement("pre",null,l.createElement("code",null,e.message)),l.createElement(zOe,null,l.createElement(ur,{onClick:i},"Copy Error"),l.createElement(ur,{onClick:r},"Refresh Page")),l.createElement(Qt,null),l.createElement("p",null,"Keep getting this error?"," ",l.createElement("a",{onClick:o,title:"Download your project"},"Download your project")," ","as a backup and then"," ",l.createElement("a",{onClick:a,title:"Reset the document"},"reset the document"),".")))}var _Oe=fe("div",{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"$canvas"}),NOe=fe("div",{backgroundColor:"$panel",border:"1px solid $panelContrast",padding:"$5",borderRadius:8,boxShadow:"$panel",maxWidth:320,color:"$text",fontFamily:"$ui",fontSize:"$2",textAlign:"center",display:"flex",flexDirection:"column",gap:"$3","& > pre":{marginTop:"$3",marginBottom:"$3",textAlign:"left",whiteSpace:"pre-wrap",backgroundColor:"$hover",padding:"$4",borderRadius:"$2",fontFamily:'"Menlo", "Monaco", monospace',fontWeight:500},"& p":{fontFamily:"$body",lineHeight:1.7,padding:"$5",margin:0},"& a":{color:"$text",cursor:"pointer",textDecoration:"underline"},"& hr":{marginLeft:"-$5",marginRight:"-$5"}}),zOe=fe("div",{display:"flex","& > button > div":{justifyContent:"center",textAlign:"center"}}),kC=fe("button",{position:"relative",height:"32px",width:"32px",backgroundColor:"$panel",borderRadius:"4px",padding:"0",margin:"0",outline:"none",border:"none",pointerEvents:"all",fontSize:"$0",color:"$text",cursor:"pointer",display:"grid",alignItems:"center",justifyContent:"center","& > *":{gridRow:1,gridColumn:1},"&:disabled":{opacity:"0.5"},"& > span":{width:"100%",height:"100%",display:"flex",alignItems:"center"},variants:{bp:{mobile:{backgroundColor:"transparent"},small:{"&:hover:not(:disabled)":{backgroundColor:"$hover"}}},size:{small:{height:32,width:32,"& svg:nth-of-type(1)":{height:"16px",width:"16px"}},medium:{height:44,width:44,"& svg:nth-of-type(1)":{height:"18px",width:"18px"}},large:{height:44,width:44,"& svg:nth-of-type(1)":{height:"20px",width:"20px"}}},isActive:{true:{color:"$selected"}}}});function HOe({onSelect:e}){return l.createElement(jOe,null,l.createElement(kC,{onClick:e},l.createElement(LY,null)))}var jOe=fe("div",{opacity:1,zIndex:100,backgroundColor:"transparent","& svg":{color:"$text"},"&:hover svg":{color:"$text"}}),UOe=e=>e.appState.isLoading;function KOe(){let e=wt().useStore(UOe);return l.createElement(VOe,{hidden:!e},l.createElement(ge,{id:"loading",values:{dots:"..."}}))}var VOe=fe("div",{position:"absolute",top:0,left:"50%",transform:"translate(-50%, 0)",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",padding:"8px 16px",fontFamily:"var(--fonts-ui)",fontSize:"var(--fontSizes-1)",boxShadow:"var(--shadows-panel)",backgroundColor:"white",zIndex:200,pointerEvents:"none","& > div > *":{pointerEvents:"all"},variants:{transform:{hidden:{transform:"translate(-50%, 100%)"},visible:{transform:"translate(-50%, 0%)"}}}});function GOe({children:e,onClose:t,container:n}){return l.createElement(uC,{container:n},l.createElement(QOe,null),l.createElement(e_e,{onKeyDown:r=>{switch(r.key){case"Escape":t==null||t();break}}},e))}var JOe=fe(kee,{marginBottom:20,color:"$text",fontSize:"$2",lineHeight:1.5,textAlign:"center",maxWidth:"62%",minWidth:0,alignSelf:"center"}),WOe=sC,YOe=GOe,qOe=JOe,AS=Lg,XOe=UD,ZOe=({container:e})=>{let{setDialogState:t,dialogState:n,onCancel:r,onNo:i,onYes:o}=TT(),a=Wn(),s={saveFirstTime:a.formatMessage({id:"dialog.save.firsttime"}),saveAgain:a.formatMessage({id:"dialog.save.again"})};return l.createElement(WOe,{open:n!==null},l.createElement(YOe,{onClose:()=>t(null),container:e},n&&l.createElement(qOe,null,s[n]),l.createElement("div",{style:{width:"100%",gap:"$6",display:"flex",justifyContent:"space-between"}},r&&l.createElement(XOe,{asChild:!0},l.createElement(D0,{css:{color:"$text"},onClick:()=>{r(),t(null)}},l.createElement(ge,{id:"dialog.cancel"}))),l.createElement("div",{style:{flexShrink:0}},i&&l.createElement(AS,{asChild:!0},l.createElement(D0,{onClick:()=>{i(),t(null)}},l.createElement(ge,{id:"dialog.no"}))),o&&l.createElement(AS,{asChild:!0},l.createElement(D0,{css:{backgroundColor:"#2F80ED",color:"White"},onClick:()=>{o(),t(null)}},l.createElement(ge,{id:"dialog.yes"})))))))},QOe=fe(l1,{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, .15)",pointerEvents:"all"});fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0});var e_e=fe(lC,{position:"fixed",font:"$ui",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"max-content",padding:"$3",pointerEvents:"all",backgroundColor:"$panel",borderRadius:"$3",display:"flex",flexDirection:"column",justifyContent:"center",fontFamily:"$ui",border:"1px solid $panelContrast",boxShadow:"$panel"}),D0=fe("button",{all:"unset",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"$2",padding:"0 15px",fontSize:"$1",lineHeight:1,fontWeight:"normal",height:36,color:"$text",cursor:"pointer",minWidth:48}),PT=l.forwardRef((e,t)=>{var n=e,{icon:r}=n,i=$i(n,["icon"]);return l.createElement(t_e,null,l.createElement(n_e,q(_({},i),{ref:t})),r?l.createElement(r_e,null,r):null)}),t_e=fe("div",{position:"relative",width:"100%",height:"min-content"}),n_e=fe("input",{color:"$text",border:"none",textAlign:"left",width:"100%",paddingLeft:"$3",paddingRight:"$6",backgroundColor:"$background",height:"32px",outline:"none",fontFamily:"$ui",fontSize:"$1","&:focus":{backgroundColor:"$hover"},borderRadius:"$2"}),r_e=fe(ao,{top:0,right:0,position:"absolute",paddingLeft:"$3",paddingRight:"$3",pointerEvents:"none",color:"$text"}),i_e=({isOpen:e,onClose:t})=>{let n=wt(),r=Nu(),i=Wn(),[o,a]=l.useState(n.document.name),s=l.useCallback(h=>{let p=h.target.value.trimStart();a(p)},[]);function u(h){h.stopPropagation()}let d=l.useCallback(h=>{switch(h.key){case"Enter":{n.saveProjectAs(o),t();break}case"Escape":{t();break}}},[]);return l.createElement(sC,{open:e},l.createElement(uC,{container:r.current},l.createElement(a_e,{onPointerDown:t}),l.createElement(o_e,{dir:"ltr",onKeyDown:u,onKeyUp:u},l.createElement(u_e,{placeholder:i.formatMessage({id:"enter.file.name"}),value:o,onChange:s,onKeyDown:d,icon:l.createElement(NE,null)}),l.createElement(s_e,null,l.createElement(Lg,{asChild:!0},l.createElement(D0,{onClick:t},l.createElement(ge,{id:"cancel"}))),l.createElement(Lg,{asChild:!0},l.createElement(D0,{css:{backgroundColor:"#2F80ED",color:"White"},onClick:()=>{let h=o.trim().replace(/\.tldr$/,"");n.saveProjectAs(h),t()}},l.createElement(ge,{id:"save"})))))))},o_e=fe(lC,{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",minWidth:300,maxWidth:"fit-content",maxHeight:"85vh",marginTop:"-5vh",pointerEvents:"all",backgroundColor:"$panel",padding:"$3",borderRadius:"$2",font:"$ui",zIndex:999999,"&:focus":{outline:"none"}}),a_e=fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0,zIndex:999998}),s_e=fe("div",{width:"100%",display:"flex",alignItems:"center",gap:8,justifyContent:"flex-end",marginTop:10}),u_e=fe(PT,{background:"$hover"});function tt(e){var t=e,{onSelect:n,id:r}=t,i=$i(t,["onSelect","id"]);return l.createElement(Xm,{dir:"ltr",asChild:!0,onSelect:n,id:r},l.createElement(ur,_({},i)))}var Ut=e=>e.preventDefault();function Vi({checked:e,disabled:t=!1,variant:n,onCheckedChange:r,kbd:i,id:o,children:a}){return l.createElement(kX,{dir:"ltr",onSelect:Ut,onCheckedChange:r,checked:e,disabled:t,asChild:!0,id:o},l.createElement(ur,{kbd:i,variant:n,hasIndicator:!0},a))}var Or=e=>e.stopPropagation();function Ol({sideOffset:e=4,alignOffset:t=0,children:n,align:r,variant:i,id:o,overflow:a=!1,side:s="bottom"}){let u=Nu();return l.createElement(AX,{container:u.current,dir:"ltr"},l.createElement(hI,{align:r,alignOffset:t,sideOffset:e,onEscapeKeyDown:Or,asChild:!0,id:o,side:s},l.createElement(l_e,{variant:i,overflow:a},n)))}var l_e=fe(_u,{width:"fit-content",height:"fit-content",minWidth:0,maxHeight:"100vh",overflowY:"auto",overflowX:"hidden","&::webkit-scrollbar":{display:"none"},"-ms-overflow-style":"none",scrollbarWidth:"none",variants:{variant:{horizontal:{flexDirection:"row"},menu:{minWidth:128}},overflow:{true:{maxHeight:"60vh"}}}});fe(DX,{backgroundColor:"$hover",height:1,marginTop:"$2",marginRight:"-$2",marginBottom:"$2",marginLeft:"-$2"});var gp=fe(fI,{height:"32px",width:"32px",backgroundColor:"$panel",borderRadius:"4px",padding:"0",margin:"0",display:"flex",alignItems:"center",justifyContent:"center",outline:"none",border:"none",pointerEvents:"all",cursor:"pointer",variants:{isActive:{true:{backgroundColor:"$selected",color:"white"},false:{}},bp:{mobile:{},small:{}}},compoundVariants:[{isActive:!1,bp:"small",css:{"&:focus":{backgroundColor:"$hover"},"&:hover:not(:disabled)":{backgroundColor:"$hover"}}}]});function ru({children:e,size:t,overflow:n=!1,disabled:r=!1,label:i,id:o}){return l.createElement(PX,{key:o},l.createElement(BX,{dir:"ltr",asChild:!0},l.createElement(ur,{disabled:r,hasArrow:!0},i)),l.createElement(MX,{asChild:!0,sideOffset:4,alignOffset:-4},l.createElement(_u,{size:t,overflow:n},e,l.createElement(TX,{offset:13}))))}function BT(e){var t=e,{id:n,children:r}=t,i=$i(t,["id","children"]);return l.createElement(Fl,{asChild:!0,id:n},l.createElement(st,_({},i),r))}var c_e=e=>e.settings.dockPosition,d_e=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,h_e=e=>{let t=e.document.pages[e.appState.currentPageId],{selectedIds:n}=e.document.pageStates[e.appState.currentPageId];return n.every(r=>t.shapes[r].isLocked)},f_e=e=>{let t=e.document.pages[e.appState.currentPageId],{selectedIds:n}=e.document.pageStates[e.appState.currentPageId];return n.every(r=>t.shapes[r].isAspectRatioLocked)},p_e=e=>{let t=e.document.pages[e.appState.currentPageId],n=e.document.pageStates[e.appState.currentPageId].selectedIds.map(r=>t.shapes[r]);return n.every(r=>r.children!==void 0||r.parentId===n[0].parentId&&n[0].parentId!==e.appState.currentPageId)},g_e=e=>{let{selectedIds:t}=e.document.pageStates[e.appState.currentPageId];return t.length>0},m_e=e=>{let{selectedIds:t}=e.document.pageStates[e.appState.currentPageId];return t.length>1};function v_e(){let e=wt(),t=Wn(),n=e.useStore(h_e),r=e.useStore(f_e),i=e.useStore(p_e),o=e.useStore(g_e),a=e.useStore(m_e),s=e.useStore(d_e),u=e.useStore(c_e),d=s>1,h=s>2,p=l.useCallback(()=>{e.rotate()},[e]),g=l.useCallback(()=>{e.duplicate()},[e]),m=l.useCallback(()=>{e.toggleLocked()},[e]),v=l.useCallback(()=>{e.toggleAspectRatioLocked()},[e]),E=l.useCallback(()=>{e.group()},[e]),w=l.useCallback(()=>{e.moveToBack()},[e]),C=l.useCallback(()=>{e.moveBackward()},[e]),b=l.useCallback(()=>{e.moveForward()},[e]),A=l.useCallback(()=>{e.moveToFront()},[e]),T=l.useCallback(()=>{e.setShapeProps({rotation:0})},[e]),B=l.useCallback(()=>{e.align("top")},[e]),D=l.useCallback(()=>{e.align("centerVertical")},[e]),I=l.useCallback(()=>{e.align("bottom")},[e]),M=l.useCallback(()=>{e.stretch("vertical")},[e]),O=l.useCallback(()=>{e.distribute("vertical")},[e]),z=l.useCallback(()=>{e.align("left")},[e]),K=l.useCallback(()=>{e.align("centerHorizontal")},[e]),X=l.useCallback(()=>{e.align("right")},[e]),Z=l.useCallback(()=>{e.stretch("horizontal")},[e]),pe=l.useCallback(()=>{e.distribute("horizontal")},[e]),me=l.useCallback(Ce=>{e.setMenuOpen(Ce)},[e]);return l.createElement(Lu,{dir:"ltr",onOpenChange:me},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Tools-Dots"},l.createElement(st,{variant:"circle"},l.createElement(_Y,null))),l.createElement(Ol,{sideOffset:16,side:u==="bottom"||u==="top"?"top":u},l.createElement(l.Fragment,null,l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"duplicate"}),kbd:"#D",id:"TD-Tools-Copy"},l.createElement(st,{disabled:!o,onClick:g},l.createElement(PY,null))),l.createElement(jt,{label:t.formatMessage({id:"rotate"}),id:"TD-Tools-Rotate"},l.createElement(st,{disabled:!o,onClick:p},l.createElement(pq,null))),l.createElement(jt,{label:t.formatMessage({id:n?"unlock":"lock"}),kbd:"#L",id:"TD-Tools-Lock"},l.createElement(st,{disabled:!o,onClick:m},n?l.createElement(XY,null):l.createElement(QY,null))),l.createElement(jt,{label:t.formatMessage({id:r?"unlock.aspect.ratio":"lock.aspect.ratio"}),id:"TD-Tools-AspectRatio"},l.createElement(st,{disabled:!o,onClick:v},r?l.createElement(CY,null):l.createElement(wY,null))),l.createElement(jt,{label:t.formatMessage({id:"group"}),kbd:"#G",id:"TD-Tools-Group"},l.createElement(st,{disabled:!o||!i&&!a,onClick:E},l.createElement(UY,null)))),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"move.to.back"}),kbd:"#⇧[",id:"TD-Tools-PinBottom"},l.createElement(st,{disabled:!o,onClick:w},l.createElement(aq,null))),l.createElement(jt,{label:t.formatMessage({id:"move.backward"}),kbd:"#[",id:"TD-Tools-ArrowDown"},l.createElement(st,{disabled:!o,onClick:C},l.createElement(pY,null))),l.createElement(jt,{label:t.formatMessage({id:"move.forward"}),kbd:"#]",id:"TD-Tools-ArrowUp"},l.createElement(st,{disabled:!o,onClick:b},l.createElement(yY,null))),l.createElement(jt,{label:t.formatMessage({id:"move.to.front"}),kbd:"#⇧]",id:"TD-Tools-PinTop"},l.createElement(st,{disabled:!o,onClick:A},l.createElement(uq,null))),l.createElement(jt,{label:t.formatMessage({id:"reset.angle"}),id:"TD-Tools-ResetAngle"},l.createElement(st,{disabled:!o,onClick:T},l.createElement(hY,null)))),l.createElement(Qt,null),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"align.left"}),id:"TD-Tools-AlignLeft"},l.createElement(st,{disabled:!d,onClick:z},l.createElement(Zk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.center.x"}),id:"TD-Tools-AlignCenterHorizontal"},l.createElement(st,{disabled:!d,onClick:K},l.createElement(qk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.right"}),id:"TD-Tools-AlignRight"},l.createElement(st,{disabled:!d,onClick:X},l.createElement(Qk,null))),l.createElement(jt,{label:t.formatMessage({id:"stretch.x"}),id:"TD-Tools-StretchHorizontal"},l.createElement(st,{disabled:!d,onClick:Z},l.createElement(iI,null))),l.createElement(jt,{label:t.formatMessage({id:"distribute.x"}),id:"TD-Tools-SpaceEvenlyHorizontal"},l.createElement(st,{disabled:!h,onClick:pe},l.createElement(nI,null)))),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"align.top"}),id:"TD-Tools-AlignTop"},l.createElement(st,{disabled:!d,onClick:B},l.createElement(eI,null))),l.createElement(jt,{label:t.formatMessage({id:"align.center.y"}),id:"TD-Tools-AlignCenterVertical"},l.createElement(st,{disabled:!d,onClick:D},l.createElement(Xk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.bottom"}),id:"TD-Tools-AlignBottom"},l.createElement(st,{disabled:!d,onClick:I},l.createElement(Yk,null))),l.createElement(jt,{label:t.formatMessage({id:"stretch.y"}),id:"TD-Tools-StretchVertical"},l.createElement(st,{disabled:!d,onClick:M},l.createElement(oI,null))),l.createElement(jt,{label:t.formatMessage({id:"distribute.y"}),id:"TD-Tools-SpaceEvenlyVertical"},l.createElement(st,{disabled:!h,onClick:O},l.createElement(rI,null)))))))}var mp=fe("div",{position:"relative",display:"flex",width:"100%",background:"none",border:"none",cursor:"pointer",outline:"none",alignItems:"center",justifyContent:"flex-start",padding:0}),y_e=e=>e.appState.isEmptyCanvas&&Object.keys(e.document.pages[e.appState.currentPageId].shapes).length>0,E_e=e=>e.settings.isDebugMode,C_e=e=>e.settings.dockPosition,b_e=l.memo(function(){let e=wt(),t=e.useStore(y_e),n=e.useStore(C_e),r=e.useStore(E_e),i={bottom:n==="bottom"&&r?120:n==="bottom"?80:r?60:20,left:"50%",transform:"translate(-50%,0)"};return t?l.createElement(w_e,{id:"TD-Tools-Back_to_content",style:_({},i)},l.createElement(ur,{onClick:e.zoomToContent},l.createElement(ge,{id:"zoom.to.content"}))):null}),w_e=fe(_u,{pointerEvents:"all",width:"fit-content",minWidth:0,position:"fixed",bottom:0});function kS(e){let t=e,{size:n=16}=t,r=$i(t,["size"]);return l.createElement("svg",_({width:24,height:24},r),l.createElement("circle",{cx:12,cy:12,r:n/2}))}function S_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:50.26548*.1}))}var x_e=`${50.26548*.025} ${50.26548*.1}`;function A_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:x_e}))}function k_e(){return l.createElement("svg",{width:"24",height:"24",viewBox:"1 1.5 21 22",fill:"currentColor",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M10.0162 19.2768C10.0162 19.2768 9.90679 19.2517 9.6879 19.2017C9.46275 19.1454 9.12816 19.0422 8.68413 18.8921C8.23384 18.7358 7.81482 18.545 7.42707 18.3199C7.03307 18.101 6.62343 17.7883 6.19816 17.3818C5.77289 16.9753 5.33511 16.3718 4.88482 15.5713C4.43453 14.7645 4.1531 13.8545 4.04053 12.8414C3.92795 11.822 4.04991 10.8464 4.40639 9.91451C4.76286 8.98266 5.39452 8.10084 6.30135 7.26906C7.21444 6.44353 8.29325 5.83377 9.5378 5.43976C10.7823 5.05202 11.833 4.92068 12.6898 5.04576C13.5466 5.16459 14.3878 5.43664 15.2133 5.86191C16.0388 6.28718 16.7768 6.8688 17.4272 7.60678C18.0714 8.34475 18.5404 9.21406 18.8344 10.2147C19.1283 11.2153 19.1721 12.2598 18.9657 13.348C18.7593 14.4299 18.2872 15.4337 17.5492 16.3593C16.8112 17.2849 15.9263 18.0072 14.8944 18.5263C13.8624 19.0391 12.9056 19.3174 12.0238 19.3612C11.142 19.405 10.2101 19.2705 9.22823 18.9578C8.24635 18.6451 7.35828 18.151 6.56402 17.4756C5.77601 16.8002 6.08871 16.8658 7.50212 17.6726C8.90927 18.4731 10.1444 18.8484 11.2076 18.7983C12.2645 18.7545 13.2965 18.4825 14.3034 17.9822C15.3102 17.4819 16.1264 16.8221 16.7518 16.0028C17.3772 15.1835 17.7681 14.3111 17.9244 13.3855C18.0808 12.4599 18.0401 11.5781 17.8025 10.74C17.5586 9.902 17.1739 9.15464 16.6486 8.49797C16.1233 7.8413 15.2289 7.27844 13.9656 6.80939C12.7086 6.34034 11.4203 6.20901 10.1007 6.41539C8.78732 6.61552 7.69599 7.06893 6.82669 7.77564C5.96363 8.48859 5.34761 9.26409 4.97863 10.1021C4.60964 10.9402 4.45329 11.8376 4.50958 12.7945C4.56586 13.7513 4.79101 14.6238 5.18501 15.4118C5.57276 16.1998 5.96363 16.8002 6.35764 17.2129C6.75164 17.6257 7.13313 17.9509 7.50212 18.1886C7.87736 18.4325 8.28074 18.642 8.71227 18.8171C9.15005 18.9922 9.47839 19.111 9.69728 19.1736C9.91617 19.2361 10.0256 19.2705 10.0256 19.2768H10.0162Z",strokeWidth:"2"}))}function I_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2,strokeLinecap:"round"}))}function D_e(e){return l.createElement("svg",_({width:18,height:18,viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 4.656a.5.5 0 01.5-.5h9.7a.5.5 0 010 1H2.5a.5.5 0 01-.5-.5z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.272 3a.578.578 0 00-.578.578v.578h3.311v-.578A.578.578 0 008.428 3H6.272zm3.733 1.156v-.578A1.578 1.578 0 008.428 2H6.272a1.578 1.578 0 00-1.578 1.578v.578H3.578a.5.5 0 00-.5.5V12.2a1.578 1.578 0 001.577 1.578h5.39a1.578 1.578 0 001.577-1.578V4.656a.5.5 0 00-.5-.5h-1.117zm-5.927 1V12.2a.578.578 0 00.577.578h5.39a.578.578 0 00.577-.578V5.156H4.078z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.272 6.85a.5.5 0 01.5.5v3.233a.5.5 0 11-1 0V7.35a.5.5 0 01.5-.5zM8.428 6.85a.5.5 0 01.5.5v3.233a.5.5 0 11-1 0V7.35a.5.5 0 01.5-.5z"}))}function IS(e){var t=e,{flipHorizontal:n}=t,r=$i(t,["flipHorizontal"]);return l.createElement("svg",_({width:24,height:24,viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"scale(-1, 1)":"scale(1, 1)"}},r),l.createElement("path",{d:"M10.6707 8.5081C10.6707 10.1923 9.3004 11.5625 7.61631 11.5625H6.5351C6.35593 11.5625 6.21074 11.4173 6.21074 11.2382V11.13C6.21074 10.9508 6.35591 10.8057 6.5351 10.8057H7.61631C8.88313 10.8057 9.91387 9.77492 9.91387 8.5081C9.91387 7.24128 8.88313 6.21054 7.61631 6.21054H5.62155L6.99534 7.58433C7.14289 7.73183 7.14289 7.97195 6.99534 8.11944C6.85216 8.26251 6.60298 8.2623 6.46013 8.11944L4.44045 6.09971C4.36898 6.02824 4.32959 5.93321 4.32959 5.8321C4.32959 5.73106 4.36898 5.63598 4.44045 5.56454L6.46024 3.54472C6.60309 3.40176 6.85248 3.40176 6.99535 3.54472C7.14291 3.69218 7.14291 3.93234 6.99535 4.07979L5.62156 5.45368H7.61631C9.3004 5.45368 10.6707 6.82393 10.6707 8.5081Z"}))}function T_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M12.4239 4.62C13.3572 4.62 14.1572 4.73333 14.8239 4.96C15.4906 5.17333 15.9772 5.43333 16.2839 5.74C16.3639 5.82 16.4039 5.94 16.4039 6.1V8.86H14.0639C13.9172 8.86 13.8439 8.78666 13.8439 8.64V7.26C13.4306 7.12666 12.9572 7.06 12.4239 7.06C11.6506 7.06 11.0639 7.18 10.6639 7.42C10.2639 7.66 10.0639 8.04666 10.0639 8.58V9C10.0639 9.38666 10.1639 9.69333 10.3639 9.92C10.5772 10.1333 11.0306 10.3467 11.7239 10.56L13.6439 11.14C14.4706 11.38 15.1172 11.66 15.5839 11.98C16.0506 12.3 16.3772 12.68 16.5639 13.12C16.7639 13.5467 16.8639 14.0733 16.8639 14.7V15.62C16.8639 16.7933 16.4039 17.7133 15.4839 18.38C14.5639 19.0467 13.2839 19.38 11.6439 19.38C10.6706 19.38 9.79723 19.2867 9.0239 19.1C8.2639 18.9133 7.71056 18.6533 7.3639 18.32C7.3239 18.28 7.29056 18.24 7.2639 18.2C7.25056 18.1467 7.2439 18.06 7.2439 17.94V15.74H7.6239C8.2239 16.1533 8.85056 16.4533 9.5039 16.64C10.1572 16.8267 10.9306 16.92 11.8239 16.92C12.6506 16.92 13.2506 16.7867 13.6239 16.52C14.0106 16.2533 14.2039 15.9333 14.2039 15.56V14.88C14.2039 14.6667 14.1639 14.48 14.0839 14.32C14.0172 14.16 13.8706 14.0133 13.6439 13.88C13.4172 13.7467 13.0572 13.6067 12.5639 13.46L10.6639 12.88C9.7839 12.6133 9.11056 12.3 8.6439 11.94C8.17723 11.58 7.85056 11.18 7.6639 10.74C7.49056 10.3 7.4039 9.83333 7.4039 9.34V8.38C7.4039 7.64666 7.61056 7 8.0239 6.44C8.43723 5.88 9.01723 5.44 9.7639 5.12C10.5239 4.78666 11.4106 4.62 12.4239 4.62Z"}))}function P_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M8.16191 19H5.68191C5.53525 19 5.46191 18.9267 5.46191 18.78V5H8.76191C8.88191 5 8.97525 5.03333 9.04191 5.1C9.10858 5.15333 9.17525 5.27333 9.24191 5.46C9.72191 6.59333 10.1686 7.7 10.5819 8.78C11.0086 9.84667 11.4352 10.98 11.8619 12.18H12.1619C12.6019 10.9667 13.0352 9.79333 13.4619 8.66C13.8886 7.52667 14.3552 6.30667 14.8619 5H18.3219C18.4686 5 18.5419 5.07333 18.5419 5.22V19H16.0619C15.9152 19 15.8419 18.9267 15.8419 18.78V16.26C15.8419 15.5267 15.8486 14.8133 15.8619 14.12C15.8886 13.4267 15.9286 12.6867 15.9819 11.9C16.0486 11.1 16.1419 10.1933 16.2619 9.18H15.9019C15.4352 10.3533 14.9486 11.5667 14.4419 12.82C13.9486 14.06 13.4819 15.2333 13.0419 16.34H11.1019C11.0619 16.34 11.0152 16.3333 10.9619 16.32C10.9219 16.2933 10.8886 16.2467 10.8619 16.18C10.4619 15.18 10.0086 14.06 9.50191 12.82C9.00858 11.58 8.53525 10.3667 8.08191 9.18H7.70191C7.83525 10.18 7.93525 11.0733 8.00191 11.86C8.06858 12.6467 8.10858 13.3933 8.12191 14.1C8.14858 14.8067 8.16191 15.5267 8.16191 16.26V19Z"}))}function B_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M7.68191 19C7.53525 19 7.46191 18.9267 7.46191 18.78V5H10.1219C10.2686 5 10.3419 5.07333 10.3419 5.22V16.56H13.4419V15.02H15.7619C15.9086 15.02 15.9819 15.0933 15.9819 15.24V19H7.68191Z"}))}function M_e(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M1.72838 9.33987L8.84935 2.34732C9.23874 1.96494 9.86279 1.96539 10.2516 2.34831L13.5636 5.60975C13.9655 6.00555 13.9607 6.65526 13.553 7.04507L8.13212 12.2278C7.94604 12.4057 7.69851 12.505 7.44107 12.505L6.06722 12.505L3.83772 12.505C3.5673 12.505 3.30842 12.3954 3.12009 12.2014L1.7114 10.7498C1.32837 10.3551 1.33596 9.72521 1.72838 9.33987Z",stroke:"currentColor"}),l.createElement("line",{x1:"6.01807",y1:"12.5",x2:"10.7959",y2:"12.5",stroke:"currentColor",strokeLinecap:"round"}),l.createElement("line",{x1:"5.50834",y1:"5.74606",x2:"10.1984",y2:"10.4361",stroke:"currentColor"}))}function $_e(){return l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},l.createElement("path",{d:"M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612Zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612Z"}))}function R_e(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L11.1464 3.14645C11.3417 2.95118 11.6583 2.95118 11.8536 3.14645C12.0488 3.34171 12.0488 3.65829 11.8536 3.85355L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z"}))}function F_e(){let e=wt(),t=Wn(),n=l.useCallback(()=>{e.delete()},[e]),r=e.useStore(i=>i.appState.status==="idle"&&i.document.pageStates[i.appState.currentPageId].selectedIds.length>0);return l.createElement(jt,{label:t.formatMessage({id:"delete"}),kbd:"⌫",id:"TD-Delete"},l.createElement(st,{variant:"circle",disabled:!r,onSelect:n},l.createElement(D_e,null)))}var L_e=e=>e.settings.language,O_e=()=>{let e=wt(),t=e.useStore(L_e),n=l.useCallback(r=>{e.setSetting("language",r)},[e]);return l.createElement(Ol,{variant:"menu",overflow:!0,id:"language-menu",side:"left",sideOffset:8},SC.map(({locale:r,label:i})=>l.createElement(Vi,{key:r,checked:t===r,onCheckedChange:()=>n(r),id:`TD-MenuItem-Language-${r}`},i)),l.createElement(Qt,null),l.createElement("a",{href:"https://github.com/tldraw/tldraw/blob/main/guides/translation.md",target:"_blank",rel:"nofollow"},l.createElement(tt,{id:"TD-MenuItem-Translation-Link"},l.createElement(ge,{id:"translation.link"}),l.createElement(ao,null,l.createElement(tI,null)))))};function __e({onOpenChange:e}){let t=Wn(),n=Nu(),r={Tools:[{label:t.formatMessage({id:"select"}),kbd:"1"},{label:t.formatMessage({id:"draw"}),kbd:"2"},{label:t.formatMessage({id:"eraser"}),kbd:"3"},{label:t.formatMessage({id:"rectangle"}),kbd:"4"},{label:t.formatMessage({id:"ellipse"}),kbd:"5"},{label:t.formatMessage({id:"triangle"}),kbd:"6"},{label:t.formatMessage({id:"line"}),kbd:"7"},{label:t.formatMessage({id:"arrow"}),kbd:"8"},{label:t.formatMessage({id:"text"}),kbd:"9"},{label:t.formatMessage({id:"sticky"}),kbd:"0"}],View:[{label:t.formatMessage({id:"zoom.in"}),kbd:"#+"},{label:t.formatMessage({id:"zoom.out"}),kbd:"#-"},{label:`${t.formatMessage({id:"zoom.to"})} 100%`,kbd:"⇧+0"},{label:t.formatMessage({id:"zoom.to.fit"}),kbd:"⇧+1"},{label:t.formatMessage({id:"zoom.to.selection"}),kbd:"⇧+2"},{label:t.formatMessage({id:"preferences.dark.mode"}),kbd:"#⇧D"},{label:t.formatMessage({id:"preferences.focus.mode"}),kbd:"#."},{label:t.formatMessage({id:"preferences.show.grid"}),kbd:"#⇧G"}],Transform:[{label:t.formatMessage({id:"flip.horizontal"}),kbd:"⇧H"},{label:t.formatMessage({id:"flip.vertical"}),kbd:"⇧V"},{label:`${t.formatMessage({id:"lock"})} / ${t.formatMessage({id:"unlock"})}`,kbd:"#⇧L"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"to.front"})}`,kbd:"⇧]"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"forward"})}`,kbd:"]"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"backward"})}`,kbd:"["},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"back"})}`,kbd:"⇧["}],File:[{label:t.formatMessage({id:"new.project"}),kbd:"#N"},{label:t.formatMessage({id:"open"}),kbd:"#O"},{label:t.formatMessage({id:"save"}),kbd:"#S"},{label:t.formatMessage({id:"save.as"}),kbd:"#⇧S"},{label:t.formatMessage({id:"upload.media"}),kbd:"#U"}],Edit:[{label:t.formatMessage({id:"undo"}),kbd:"#Z"},{label:t.formatMessage({id:"redo"}),kbd:"#⇧Z"},{label:t.formatMessage({id:"cut"}),kbd:"#X"},{label:t.formatMessage({id:"copy"}),kbd:"#C"},{label:t.formatMessage({id:"paste"}),kbd:"#V"},{label:t.formatMessage({id:"select.all"}),kbd:"#A"},{label:t.formatMessage({id:"delete"}),kbd:"⌫"},{label:t.formatMessage({id:"duplicate"}),kbd:"#D"}]};return l.createElement(AD,{onOpenChange:e},l.createElement(kD,{asChild:!0},l.createElement(ur,{id:"TD-HelpItem-Keyboard",variant:"wide"},l.createElement(ge,{id:"keyboard.shortcuts"}))),l.createElement(ID,{container:n.current},l.createElement(K_e,null),l.createElement(j_e,null,l.createElement(G_e,null,l.createElement(ge,{id:"keyboard.shortcuts"}),l.createElement(aC,{asChild:!0},l.createElement(V_e,null,l.createElement(MY,null)))),l.createElement(U_e,{bp:Ci},Object.entries(r).map(([i,o])=>l.createElement(Ny,{key:i},l.createElement(N_e,null,l.createElement(ge,{id:`menu.${i.toLocaleLowerCase()}`})),l.createElement(z_e,null,o.map(a=>l.createElement(H_e,{key:a.label},a.label,l.createElement(wC,{variant:"menu"},a.kbd))))))))))}var N_e=fe("h3",{fontSize:"$2",color:"$text",fontFamily:"$ui",margin:0,paddingBottom:"$5"}),Ny=fe("div",{breakInside:"avoid",paddingBottom:24}),z_e=fe("ul",{listStyleType:"none",width:"100%",padding:0,margin:0}),H_e=fe("li",{display:"flex",alignItems:"center",justifyContent:"space-between",height:32,minHeight:32,width:"100%",outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",borderRadius:4,userSelect:"none",margin:0,padding:"0 0"}),j_e=fe(TD,{borderRadius:6,boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"fit-content",maxWidth:"90vw",maxHeight:"74vh",overflowY:"auto",padding:25,zIndex:9999,pointerEvents:"all",background:"$panel","&:focus":{outline:"none"}}),U_e=fe("div",{maxWidth:"100%",width:"fit-content",height:"fit-content",overflowY:"auto",columnGap:64,variants:{bp:{mobile:{columns:1,[`& ${Ny}`]:{minWidth:"0px"}},small:{columns:2,[`& ${Ny}`]:{minWidth:"200px"}},medium:{columns:3},large:{columns:3}}}}),K_e=fe(DD,{backgroundColor:"$overlay",position:"fixed",inset:0,zIndex:9998}),V_e=fe(kC,{fontFamily:"inherit",borderRadius:"100%",height:25,width:25,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"$text",cursor:"pointer","&:hover":{backgroundColor:"$hover"}}),G_e=fe(PD,{fontFamily:"$body",fontSize:"$3",color:"$text",paddingBottom:32,display:"flex",alignItems:"center",justifyContent:"space-between",margin:0}),J_e=e=>e.settings.isDebugMode,W_e=e=>e.settings.dockPosition;function Y_e(){let e=wt(),t=e.useStore(J_e),n=e.useStore(W_e),[r,i]=l.useState(!1);return l.createElement(Fee,null,l.createElement(tNe,{dir:"ltr",debug:t,side:n,bp:Ci},l.createElement(Oee,{dir:"ltr",asChild:!0},l.createElement(Q_e,null,l.createElement(hq,null)))),l.createElement(_ee,{dir:"ltr",align:"end",side:"top",alignOffset:10,sideOffset:8,asChild:!0},l.createElement(eNe,{style:{visibility:r?"hidden":"visible"}},l.createElement(q_e,null),l.createElement(__e,{onOpenChange:i}),l.createElement(Qt,null),l.createElement(Z_e,null))))}var q_e=()=>l.createElement(Lu,{dir:"ltr"},l.createElement(Fl,{asChild:!0},l.createElement(ur,{variant:"wide",hasArrow:!0},l.createElement(ge,{id:"language"}))),l.createElement(O_e,null)),X_e=[{id:"tldraw-beta",icon:tI,url:"https://beta.tldraw.com"},{id:"github",icon:HY,url:"https://github.com/tldraw/tldraw"},{id:"twitter",icon:Mq,url:"https://twitter.com/tldraw"},{id:"discord",icon:$_e,url:"https://discord.gg/SBBEVCA4PG"},{id:"become.a.sponsor",icon:JY,url:"https://github.com/sponsors/steveruizok"}],Z_e=()=>l.createElement(l.Fragment,null,X_e.map(e=>l.createElement("a",{key:e.id,href:e.url,target:"_blank",rel:"nofollow"},l.createElement(ur,{id:`TD-Link-${e.id}`,variant:"wide"},l.createElement(ge,{id:e.id}),l.createElement(ao,null,l.createElement(e.icon,null)))))),Q_e=fe("button",{width:32,height:32,borderRadius:"100%",display:"flex",padding:0,justifyContent:"center",alignItems:"center",outline:"none",backgroundColor:"$panel",cursor:"pointer",boxShadow:"$panel",border:"1px solid $panelContrast",color:"$text","& svg":{height:12,width:12}}),eNe=fe(_u,{width:"fit-content",height:"fit-content",minWidth:200,maxHeight:380,overflowY:"auto","& *":{boxSizing:"border-box"},"& a":{outline:"none"},variants:{variant:{horizontal:{flexDirection:"row"},menu:{minWidth:128}}}}),tNe=fe(Lee,{position:"absolute",zIndex:999,right:10,bottom:10,width:32,height:32,variants:{debug:{true:{},false:{}},bp:{mobile:{bottom:64},small:{bottom:10},medium:{},large:{}},side:{top:{},left:{},right:{},bottom:{}}},compoundVariants:[{bp:"mobile",side:"bottom",debug:!0,css:{bottom:104}},{bp:"small",side:"bottom",debug:!0,css:{bottom:50}}]}),Ng=fe("div",{backgroundColor:"$panel",display:"flex",flexDirection:"row",boxShadow:"$panel",padding:"$2",border:"1px solid $panelContrast",gap:0,overflow:"hidden",variants:{side:{center:{borderRadius:9},left:{padding:0,borderTop:0,borderLeft:0,borderTopRightRadius:0,borderBottomRightRadius:9,borderBottomLeftRadius:0},right:{padding:0,borderTop:0,borderRight:0,borderTopLeftRadius:0,borderBottomLeftRadius:9,borderBottomRightRadius:0}}},"& hr":{height:10,width:"100%",backgroundColor:"red",border:"none"}}),Jv=["rectangle","ellipse","triangle","line"],DS={rectangle:l.createElement(yq,null),ellipse:l.createElement(IY,null),triangle:l.createElement(Rq,null),line:l.createElement(R_e,null)},nNe=e=>e.settings.dockPosition,rNe=l.memo(function({activeTool:e,isToolLocked:t}){let n=wt(),r=Wn(),i=n.useStore(nNe),[o,a]=l.useState("rectangle");l.useEffect(()=>{Jv.includes(e)&&o!==e&&a(e)},[e]);let s=l.useCallback(()=>{n.selectTool(o)},[e,n]),u=l.useCallback(()=>{n.toggleToolLock()},[n]),d=l.useCallback(m=>{m.key===" "&&n.shiftKey&&m.preventDefault()},[]),h=Jv.includes(e),p=i==="bottom"||i==="top"?"top":i,g=i==="bottom"||i==="top"?"row":"column";return l.createElement(Lu,{dir:"ltr",onOpenChange:s},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-PrimaryTools-Shapes"},l.createElement(st,{disabled:h&&n.shiftKey,variant:"primary",onDoubleClick:u,isToolLocked:h&&t,isActive:h,onKeyDown:d},DS[o])),l.createElement(hI,{asChild:!0,side:p,sideOffset:12},l.createElement(Ng,{side:"center",style:{flexDirection:g}},Jv.map((m,v)=>l.createElement(jt,{key:m,label:r.formatMessage({id:m}),kbd:(4+v).toString(),id:`TD-PrimaryTools-Shapes-${m}`},l.createElement(Xm,{asChild:!0},l.createElement(st,{variant:"primary",onClick:()=>{n.selectTool(m),a(m)}},DS[m])))))))}),iNe=e=>e.appState.activeTool,oNe=e=>e.appState.isToolLocked,aNe=e=>e.settings.dockPosition,sNe=l.memo(function(){let e=wt(),t=Wn(),n=e.useStore(iNe),r=e.useStore(oNe),i=e.useStore(aNe),o=l.useCallback(()=>{e.selectTool("select")},[e]),a=l.useCallback(()=>{e.selectTool("erase")},[e]),s=l.useCallback(()=>{e.selectTool("draw")},[e]),u=l.useCallback(()=>{e.selectTool("arrow")},[e]),d=l.useCallback(()=>{e.selectTool("text")},[e]),h=l.useCallback(()=>{e.selectTool("sticky")},[e]),p=l.useCallback(()=>Oe(this,null,function*(){e.openAsset()}),[e]);return l.createElement(uNe,{side:"center",id:"TD-PrimaryTools",style:{flexDirection:i==="bottom"||i==="top"?"row":"column"},bp:Ci},l.createElement(Xu,{kbd:"1",label:t.formatMessage({id:"select"}),onClick:o,isActive:n==="select",id:"TD-PrimaryTools-CursorArrow"},l.createElement(RY,null)),l.createElement(Xu,{kbd:"2",label:t.formatMessage({id:"draw"}),onClick:s,isActive:n==="draw",id:"TD-PrimaryTools-Pencil"},l.createElement(NE,null)),l.createElement(Xu,{kbd:"3",label:t.formatMessage({id:"eraser"}),onClick:a,isActive:n==="erase",id:"TD-PrimaryTools-Eraser"},l.createElement(M_e,null)),l.createElement(rNe,{activeTool:n,isToolLocked:r}),l.createElement(Xu,{kbd:"8",label:t.formatMessage({id:"arrow"}),onClick:u,isLocked:r,isActive:n==="arrow",id:"TD-PrimaryTools-ArrowTopRight"},l.createElement(mY,null)),l.createElement(Xu,{kbd:"9",label:t.formatMessage({id:"text"}),onClick:d,isLocked:r,isActive:n==="text",id:"TD-PrimaryTools-Text"},l.createElement(wq,null)),l.createElement(Xu,{kbd:"0",label:t.formatMessage({id:"sticky"}),onClick:h,isActive:n==="sticky",id:"TD-PrimaryTools-Pencil2"},l.createElement(iq,null)),l.createElement(Xu,{label:t.formatMessage({id:"image"}),onClick:p,id:"TD-PrimaryTools-Image"},l.createElement(YY,null)))}),uNe=fe(Ng,{variants:{bp:{mobile:{padding:"$0",borderRadius:"10px"},small:{padding:"$2"}}}}),lNe=e=>e.appState.status,cNe=e=>e.appState.activeTool;function dNe(){let e=wt(),t=e.useStore(lNe),n=e.useStore(cNe);return l.createElement(hNe,{bp:Ci,id:"TD-StatusBar"},l.createElement(fNe,null,n," | ",t))}var hNe=fe("div",{height:40,userSelect:"none",borderTop:"1px solid $panelContrast",gridArea:"status",display:"flex",color:"$text",justifyContent:"space-between",alignItems:"center",backgroundColor:"$panel",gap:8,fontFamily:"$ui",fontSize:"$0",padding:"0 16px",variants:{bp:{small:{fontSize:"$1"}}}}),fNe=fe("div",{whiteSpace:"nowrap",overflow:"hidden"}),pNe=e=>e.settings.isDebugMode,gNe=e=>e.settings.dockPosition,mNe=l.memo(function({onBlur:e}){let t=wt(),n=t.useStore(gNe),r=t.useStore(pNe);return l.createElement(l.Fragment,null,l.createElement(vNe,{side:n,onBlur:e,bp:Ci,debug:r},l.createElement(yNe,{id:"TD-Tools"},l.createElement(b_e,null),l.createElement(CNe,{orientation:n==="bottom"||n==="top"?"horizontal":"vertical"},l.createElement(v_e,null),l.createElement(sNe,null),l.createElement(F_e,null)))),l.createElement(Y_e,null),r&&l.createElement(ENe,null,l.createElement(dNe,null)))}),vNe=fe("div",{position:"absolute",width:"100%",minWidth:0,maxWidth:"100%",height:64,gap:"$4",display:"flex",justifyContent:"center",alignItems:"center",zIndex:200,overflow:"hidden",pointerEvents:"none","& > div > *":{pointerEvents:"all"},variants:{debug:{true:{},false:{}},bp:{mobile:{},small:{},medium:{},large:{}},side:{top:{width:"100%",height:64,left:0,right:0,top:45},right:{width:64,height:"100%",top:0,right:0},bottom:{width:"100%",left:0,right:0,bottom:4},left:{width:64,height:"100%",left:0}}},compoundVariants:[{side:"top",bp:"large",css:{top:0}},{side:"bottom",debug:!0,css:{bottom:44}}]}),yNe=fe("div",{display:"flex",width:"fit-content",height:"fit-content",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:"$4"}),ENe=fe("div",{position:"absolute",bottom:"0px",left:"0px",right:"0px",height:"40px",width:"100%",maxWidth:"100%"}),CNe=fe("div",{position:"relative",display:"flex",alignItems:"center",height:"fit-content",gap:"$3",variants:{orientation:{horizontal:{flexDirection:"row"},vertical:{flexDirection:"column"}}}}),bNe=e=>e.settings,wNe=["bottom","left","right","top"];function SNe(){let e=wt(),t=Wn(),n=e.useStore(bNe),r=l.useCallback(()=>{e.setSetting("isDebugMode",p=>!p)},[e]),i=l.useCallback(()=>{e.setSetting("isDarkMode",p=>!p)},[e]),o=l.useCallback(()=>{e.setSetting("isFocusMode",p=>!p)},[e]),a=l.useCallback(()=>{e.setSetting("showGrid",p=>!p)},[e]),s=l.useCallback(()=>{e.setSetting("keepStyleMenuOpen",p=>!p)},[e]),u=l.useCallback(()=>{e.setSetting("isCadSelectMode",p=>!p)},[e]),d=l.useCallback(p=>{e.setSetting("dockPosition",p)},[e]),h=l.useCallback(p=>{e.setSetting("exportBackground",p)},[e]);return l.createElement(ru,{label:t.formatMessage({id:"menu.preferences"}),id:"TD-MenuItem-Preferences"},l.createElement(Vi,{checked:n.isDarkMode,onCheckedChange:i,kbd:"#⇧D",id:"TD-MenuItem-Preferences-Dark_Mode"},l.createElement(ge,{id:"preferences.dark.mode"})),l.createElement(Vi,{checked:n.isFocusMode,onCheckedChange:o,kbd:"#.",id:"TD-MenuItem-Preferences-Focus_Mode"},l.createElement(ge,{id:"preferences.focus.mode"})),l.createElement(Vi,{checked:n.isDebugMode,onCheckedChange:r,id:"TD-MenuItem-Preferences-Debug_Mode"},l.createElement(ge,{id:"preferences.debug.mode"})),l.createElement(Qt,null),l.createElement(Vi,{checked:n.showGrid,onCheckedChange:a,kbd:"#⇧G",id:"TD-MenuItem-Preferences-Grid"},l.createElement(ge,{id:"preferences.show.grid"})),l.createElement(Vi,{checked:n.isCadSelectMode,onCheckedChange:u,id:"TD-MenuItem-Preferences-Cad_Selection"},l.createElement(ge,{id:"preferences.use.cad.selection"})),l.createElement(Vi,{checked:n.keepStyleMenuOpen,onCheckedChange:s,id:"TD-MenuItem-Preferences-Style_menu"},l.createElement(ge,{id:"preferences.keep.stylemenu.open"})),l.createElement(ru,{label:t.formatMessage({id:"dock.position"})},wNe.map(p=>l.createElement(Vi,{key:p,checked:n.dockPosition===p,onCheckedChange:()=>d(p),id:`TD-MenuItem-DockPosition-${p}`},l.createElement(TS,null,l.createElement(ge,{id:p}))))),l.createElement(ru,{label:t.formatMessage({id:"export.background"})},Object.values(AT).map(p=>l.createElement(Vi,{key:p,checked:n.exportBackground===p,onCheckedChange:()=>h(p),id:`TD-MenuItem-ExportBackground-${p}`},l.createElement(TS,null,l.createElement(ge,{id:p}))))))}var TS=fe("span",{textTransform:"capitalize"}),xNe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,ANe=e=>e.appState.disableAssets,kNe=l.memo(function({readOnly:e}){let t=wt(),n=Wn(),[r,i]=l.useState(!1),o=t.useStore(xNe),a=t.useStore(ANe),[s,u]=l.useState(0);l.useEffect(()=>u(1),[]);let{onNewProject:d,onOpenProject:h,onSaveProject:p,onSaveProjectAs:g}=ET(),m=l.useCallback(()=>{kd?t.saveProjectAs():i(!0)},[t]),v=l.useCallback(()=>{t.delete()},[t]),E=l.useCallback(()=>{t.copyImage("svg",{scale:1,quality:1,transparentBackground:!1})},[t]),w=l.useCallback(()=>{t.copyImage("png",{scale:2,quality:1,transparentBackground:!0})},[t]),C=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("png",{scale:2,quality:1})}),[t]),b=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("jpeg",{scale:2,quality:1})}),[t]),A=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("webp",{scale:2,quality:1})}),[t]),T=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("svg",{scale:2,quality:1})}),[t]),B=l.useCallback(()=>Oe(this,null,function*(){t.copyJson()}),[t]),D=l.useCallback(()=>Oe(this,null,function*(){t.exportJson()}),[t]),I=l.useCallback(()=>{t.cut()},[t]),M=l.useCallback(()=>{t.copy()},[t]),O=l.useCallback(()=>{t.paste()},[t]),z=l.useCallback(()=>{t.selectAll()},[t]),K=l.useCallback(()=>{t.selectNone()},[t]),X=l.useCallback(()=>{t.openAsset()},[t]),Z=l.useCallback(()=>{t.zoomTo(1)},[t]),pe=t.callbacks.onNewProject||t.callbacks.onOpenProject||t.callbacks.onSaveProject||t.callbacks.onSaveProjectAs||t.callbacks.onExport,me=o>0;return l.createElement(l.Fragment,null,l.createElement(Lu,{dir:"ltr"},l.createElement(BT,{id:"TD-MenuIcon"},l.createElement(VY,null)),l.createElement(Ol,{variant:"menu",id:"TD-Menu",side:"bottom",align:"start",sideOffset:4,alignOffset:4},pe&&l.createElement(ru,{label:`${n.formatMessage({id:"menu.file"})}...`,id:"TD-MenuItem-File"},t.callbacks.onNewProject&&l.createElement(tt,{onClick:d,kbd:"#N",id:"TD-MenuItem-File-New_Project"},l.createElement(ge,{id:"new.project"})),t.callbacks.onOpenProject&&l.createElement(tt,{onClick:h,kbd:"#O",id:"TD-MenuItem-File-Open"},l.createElement(ge,{id:"open"}),"..."),t.callbacks.onSaveProject&&l.createElement(tt,{onClick:p,kbd:"#S",id:"TD-MenuItem-File-Save"},l.createElement(ge,{id:"save"})),t.callbacks.onSaveProjectAs&&l.createElement(tt,{onClick:m,kbd:"#⇧S",id:"TD-MenuItem-File-Save_As"},l.createElement(ge,{id:"save.as"}),"..."),!a&&l.createElement(l.Fragment,null,l.createElement(Qt,null),l.createElement(tt,{onClick:X,kbd:"#U",id:"TD-MenuItem-File-Upload_Media"},l.createElement(ge,{id:"upload.media"})))),l.createElement(ru,{label:`${n.formatMessage({id:"menu.edit"})}...`,id:"TD-MenuItem-Edit"},l.createElement(tt,{onSelect:Ut,onClick:t.undo,disabled:e,kbd:"#Z",id:"TD-MenuItem-Edit-Undo"},l.createElement(ge,{id:"undo"})),l.createElement(tt,{onSelect:Ut,onClick:t.redo,disabled:e,kbd:"#⇧Z",id:"TD-MenuItem-Edit-Redo"},l.createElement(ge,{id:"redo"})),l.createElement(Qt,null),l.createElement(tt,{onSelect:Ut,disabled:!me||e,onClick:I,kbd:"#X",id:"TD-MenuItem-Edit-Cut"},l.createElement(ge,{id:"cut"})),l.createElement(tt,{onSelect:Ut,disabled:!me,onClick:M,kbd:"#C",id:"TD-MenuItem-Edit-Copy"},l.createElement(ge,{id:"copy"})),l.createElement(tt,{onSelect:Ut,onClick:O,kbd:"#V",id:"TD-MenuItem-Edit-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(Qt,null),l.createElement(ru,{label:`${n.formatMessage({id:"copy.as"})}...`,size:"small",id:"TD-MenuItem-Copy-As"},l.createElement(tt,{onClick:E,id:"TD-MenuItem-Copy-as-SVG"},"SVG"),l.createElement(tt,{onClick:w,id:"TD-MenuItem-Copy-As-PNG"},"PNG"),l.createElement(tt,{onClick:B,id:"TD-MenuItem-Copy_as_JSON"},"JSON")),l.createElement(ru,{label:`${n.formatMessage({id:"export.as"})}...`,size:"small",id:"TD-MenuItem-Export"},l.createElement(tt,{onClick:T,id:"TD-MenuItem-Export-SVG"},"SVG"),l.createElement(tt,{onClick:C,id:"TD-MenuItem-Export-PNG"},"PNG"),l.createElement(tt,{onClick:b,id:"TD-MenuItem-Export-JPG"},"JPG"),l.createElement(tt,{onClick:A,id:"TD-MenuItem-Export-WEBP"},"WEBP"),l.createElement(tt,{onClick:D,id:"TD-MenuItem-Export-JSON"},"JSON")),l.createElement(Qt,null),l.createElement(tt,{onSelect:Ut,onClick:z,kbd:"#A",id:"TD-MenuItem-Select_All"},l.createElement(ge,{id:"select.all"})),l.createElement(tt,{onSelect:Ut,disabled:!me,onClick:K,id:"TD-MenuItem-Select_None"},l.createElement(ge,{id:"select.none"})),l.createElement(Qt,null),l.createElement(tt,{onSelect:v,disabled:!me,kbd:"⌫",id:"TD-MenuItem-Delete"},l.createElement(ge,{id:"delete"}))),l.createElement(ru,{label:n.formatMessage({id:"menu.view"}),id:"TD-MenuItem-Edit"},l.createElement(tt,{onSelect:Ut,onClick:t.zoomIn,kbd:"#+",id:"TD-MenuItem-View-ZoomIn"},l.createElement(ge,{id:"zoom.in"})),l.createElement(tt,{onSelect:Ut,onClick:t.zoomOut,kbd:"#-",id:"TD-MenuItem-View-ZoomOut"},l.createElement(ge,{id:"zoom.out"})),l.createElement(tt,{onSelect:Ut,onClick:Z,kbd:"⇧+0",id:"TD-MenuItem-View-ZoomTo100"},l.createElement(ge,{id:"zoom.to"})," 100%"),l.createElement(tt,{onSelect:Ut,onClick:t.zoomToFit,kbd:"⇧+1",id:"TD-MenuItem-View-ZoomToFit"},l.createElement(ge,{id:"zoom.to.fit"})),l.createElement(tt,{onSelect:Ut,onClick:t.zoomToSelection,kbd:"⇧+2",id:"TD-MenuItem-View-ZoomToSelection"},l.createElement(ge,{id:"zoom.to.selection"}))),l.createElement(Qt,null),l.createElement(SNe,null))),l.createElement(i_e,{isOpen:r,onClose:()=>i(!1)}))});function INe(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"},l.createElement("path",{d:"M1.36482 4.71089C1.36482 3.21371 2.57853 2 4.07572 2C5.5729 2 6.78661 3.21371 6.78661 4.71089C6.78661 5.76842 6.18106 6.68452 5.29779 7.13136C5.80465 7.24611 6.26407 7.44186 6.66028 7.73182C7.18674 8.11711 7.57215 8.64722 7.81073 9.30983C7.81452 9.30606 7.81832 9.3023 7.82212 9.29855C8.30448 8.82317 8.91325 8.52463 9.60905 8.37275C8.68812 7.922 8.05394 6.97569 8.05394 5.88126C8.05394 4.35017 9.29513 3.10898 10.8262 3.10898C12.3573 3.10898 13.5985 4.35017 13.5985 5.88126C13.5985 6.97561 12.9644 7.92186 12.0436 8.37265C12.7396 8.52449 13.3486 8.82306 13.831 9.29854C14.5795 10.0361 14.9481 11.1249 14.9481 12.5176C14.9481 12.7799 14.7354 12.9926 14.473 12.9926C14.2107 12.9926 13.9981 12.7799 13.9981 12.5175C13.9981 11.2848 13.6738 10.4774 13.1642 9.97518C12.6532 9.4716 11.8802 9.20024 10.8266 9.20024C9.77294 9.20024 8.99993 9.4716 8.48896 9.97518C7.97939 10.4774 7.65513 11.2848 7.65513 12.5176C7.65513 12.7799 7.44247 12.9926 7.18013 12.9926C6.9178 12.9926 6.70513 12.7799 6.70513 12.5176C6.70513 11.6734 6.84053 10.941 7.11384 10.3307C7.0922 10.2895 7.0763 10.2444 7.06737 10.1962C6.91739 9.38749 6.57392 8.84586 6.09923 8.49845C5.61626 8.14499 4.94481 7.95427 4.07574 7.95427C3.05232 7.95427 2.30368 8.21784 1.80952 8.70485C1.31675 9.19047 1.00176 9.97257 1.00176 11.1702C1.00176 11.4326 0.789093 11.6452 0.526758 11.6452C0.264423 11.6452 0.0517578 11.4326 0.0517578 11.1702C0.0517578 9.81263 0.411052 8.74925 1.14268 8.02821C1.60624 7.57137 2.18892 7.28191 2.85378 7.13142C1.97043 6.68461 1.36482 5.76848 1.36482 4.71089ZM4.07572 2.95C3.1032 2.95 2.31482 3.73838 2.31482 4.71089C2.31482 5.68341 3.1032 6.47178 4.07572 6.47178C5.04823 6.47178 5.83661 5.68341 5.83661 4.71089C5.83661 3.73838 5.04823 2.95 4.07572 2.95ZM10.8262 4.05898C9.8198 4.05898 9.00394 4.87484 9.00394 5.88126C9.00394 6.88768 9.8198 7.70355 10.8262 7.70355C11.8326 7.70355 12.6485 6.88768 12.6485 5.88126C12.6485 4.87484 11.8326 4.05898 10.8262 4.05898Z"}))}var kl="-0.03em",IC=[.5,.5],zy=".tldr",d1={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e<=0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e>=1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2},PS=["#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467","#FF802B"],DNe=typeof Window>"u"?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),TNe=typeof Window>"u"?!1:/linux/i.test(navigator.userAgent),MT=[".png",".svg",".jpg",".jpeg",".gif"],$T=DNe?[]:[".mp4",".webm"];function $r(e){if(e===null)return e;if(e instanceof Date)return new Date(e.getTime());if(typeof e=="object")if(typeof e[Symbol.iterator]=="function"){let t=[];if(e.length>0)for(let n of e)t.push($r(n));return t}else{let t=Object.keys(e),n={};if(t.length>0)for(let r of t)n[r]=$r(e[r]);return n}return e}function Id(e,t){let n=N.getFromCache(t,e,()=>{let[r,i]=e.size;return{minX:0,maxX:r,minY:0,maxY:i,width:r,height:i}});return N.translateBounds(n,e.point)}var PNe={start:"left",middle:"center",end:"right",justify:"justify"};function BNe(e="start"){return PNe[e]}var Ys;function MNe(){var e;(e=document.getElementById("__textLabelMeasure"))==null||e.remove();let t=document.createElement("pre");return t.id="__textLabelMeasure",Object.assign(t.style,{whiteSpace:"pre",width:"auto",border:"1px solid transparent",padding:"4px",margin:"0px",letterSpacing:kl,opacity:"0",position:"absolute",top:"-500px",left:"0px",zIndex:"9999",pointerEvents:"none",userSelect:"none",alignmentBaseline:"mathematical",dominantBaseline:"mathematical"}),t.tabIndex=-1,document.body.appendChild(t),t}typeof window<"u"&&(Ys=MNe());var Hy="",BS="",Wv=[0,0];function $Ne(){Hy=""}function T0(e,t){if(!e)return[16,32];if(!Ys)return[10,10];if(Ys.parent||document.body.appendChild(Ys),e===Hy&&t===BS)return Wv;Hy=e,BS=t,Ys.textContent=e,Ys.style.font=t;let n=Ys.offsetWidth||1,r=Ys.offsetHeight||1;return Wv=[n,r],Wv}var RNe=new RegExp(`${[32,160,4961,65792,65793,4153,4241].map(e=>String.fromCodePoint(e)).join("|")}`);function h1(e,t,n,r,i,o=!1){let a="normal",s=kl,u=FNe({text:e,wrap:o,width:i,fontSize:t,fontWeight:a,fontFamily:n,fontStyle:"normal",textAlign:"left",letterSpacing:kl,lineHeight:1}),d=document.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("font-size",t+"px"),d.setAttribute("font-family",n),d.setAttribute("font-weight",a),d.setAttribute("line-height",1*t+"px"),d.setAttribute("letter-spacing",s),d.setAttribute("text-align",r??"left"),d.setAttribute("dominant-baseline","mathematical"),d.setAttribute("alignment-baseline","mathematical");let h=u.map((p,g)=>{let m=document.createElementNS("http://www.w3.org/2000/svg","tspan");return m.textContent=p+` +`;function $ne(){l.useLayoutEffect(()=>{if(Gv.get(pp))return;let e=document.createElement("style");return e.innerHTML=Mne,e.setAttribute("id",pp),document.head.appendChild(e),Gv.set(pp,e),()=>{e&&document.head.contains(e)&&(document.head.removeChild(e),Gv.delete(pp))}},[])}var kT=l.createContext({}),Rne=()=>{let[e,t]=l.useState(0);l.useEffect(()=>t(1))};function wt(){return l.useContext(kT)}var IT=l.createContext({});function Nu(){let e=l.useContext(IT);return Rne(),e}var Fne="اللون",Lne="يملأ",One="متقطع",_ne="حجم",Nne="تبقى مفتوحة",zne="الخط",Hne="محاذاة",jne="الأنماط",Une="تكبير",Kne="تصغير",Vne="إلى",Gne="أدوات",Jne="التحويلات",Wne="ملف",Yne="تحرير",qne="معاينة",Xne="التفضيلات",Zne="تسجيل الدخول",Qne="خروج",ere="كن راعياً",tre="العودة إلى المحتوى",nre="تكبير للتحديد",rre="تكبير لتناسب",ire="تكبير إلى",ore="الوضع الداكن",are="وضع التركيز",sre="وضع التصحيح",ure="اظهر الشبكة",lre="استخدام التحديد CAD",cre="الاحتفاظ بقائمة النمط مفتوحة",dre="إظهار اللقطات دائمًا",hre="تدوير المقابض",fre="مقابض ملزمة",pre="مقابض استنساخ",gre="الغاء",mre="إعادة",vre="قطع",yre="نسح",Ere="لصق",Cre="نسخ الى",bre="صدر الى",wre="اختر الكل",Sre="لا تختر شيء",xre="حذف",Are="مشروع جديد",kre="فتح",Ire="حفظ",Dre="حفظ باسم",Tre="تحميل الوسائط",Pre="إنشاء صفحة",Bre="صفحة جديدة",Mre="اسم الصفحة",$re="نسخ",Rre="الغاء",Fre="نسخ رابط الدعوة",Lre="نسخ رابط دعوة القراءة فقط",Ore="قم بإنشاء مشروع متعدد اللاعبين",_re="نسخ إلى مشروع متعدد اللاعبين",Nre="اختر",zre="ممحاة",Hre="رسم",jre="سهم",Ure="نص",Kre="لاصق",Vre="مربع",Gre="بيضاوي",Jre="مثلث",Wre="خط",Yre="دوّر",qre="قفل نسبة الابعاد",Xre="فتح قفل نسبة الابعاد",Zre="جمّع",Qre="فك التجمع",eie="انتقل إلى الخلف",tie="تحريك للخلف",nie="تحريك للأمام",rie="تحرك للأمام",iie="إعادة ضبط الزاوية",oie="قفل",aie="الغاء القفل",sie="انقل إلى الصفحة",uie="انعكاس أفقي",lie="انعكاس عمودي",cie="حرّك",die="للامام",hie="للخلف",fie="للوراء",pie="خلف",gie="لغة",mie="للمزيد",vie="موقع الادوات",yie="اسفل",Eie="يسار",Cie="يمين",bie="أعلى",wie="صفحة",Sie="اختصارات لوحة المفاتيح",xie="بحث",Aie="{dots}تحميل ",kie="تصدير الخلفية",Iie="شـفاف",Die="ذاتي",Tie="خفيف",Pie="غامق",Bie={"style.menu.color":Fne,"style.menu.fill":Lne,"style.menu.dash":One,"style.menu.size":_ne,"style.menu.keep.open":Nne,"style.menu.font":zne,"style.menu.align":Hne,styles:jne,"zoom.in":Une,"zoom.out":Kne,to:Vne,"menu.tools":Gne,"menu.transform":Jne,"menu.file":Wne,"menu.edit":Yne,"menu.view":qne,"menu.preferences":Xne,"menu.sign.in":Zne,"menu.sign.out":Qne,"become.a.sponsor":ere,"zoom.to.content":tre,"zoom.to.selection":nre,"zoom.to.fit":rre,"zoom.to":ire,"preferences.dark.mode":ore,"preferences.focus.mode":are,"preferences.debug.mode":sre,"preferences.show.grid":ure,"preferences.use.cad.selection":lre,"preferences.keep.stylemenu.open":cre,"preferences.always.show.snaps":dre,"preferences.rotate.handles":hre,"preferences.binding.handles":fre,"preferences.clone.handles":pre,undo:gre,redo:mre,cut:vre,copy:yre,paste:Ere,"copy.as":Cre,"export.as":bre,"select.all":wre,"select.none":Sre,delete:xre,"new.project":Are,open:kre,save:Ire,"save.as":Dre,"upload.media":Tre,"create.page":Pre,"new.page":Bre,"page.name":Mre,duplicate:$re,cancel:Rre,"copy.invite.link":Fre,"copy.readonly.link":Lre,"create.multiplayer.project":Ore,"copy.multiplayer.project":_re,select:Nre,eraser:zre,draw:Hre,arrow:jre,text:Ure,sticky:Kre,rectangle:Vre,ellipse:Gre,triangle:Jre,line:Wre,rotate:Yre,"lock.aspect.ratio":qre,"unlock.aspect.ratio":Xre,group:Zre,ungroup:Qre,"move.to.back":eie,"move.backward":tie,"move.forward":nie,"move.to.front":rie,"reset.angle":iie,lock:oie,unlock:aie,"move.to.page":sie,"flip.horizontal":uie,"flip.vertical":lie,move:cie,"to.front":die,forward:hie,backward:fie,back:pie,language:gie,"translation.link":mie,"dock.position":vie,bottom:yie,left:Eie,right:Cie,top:bie,page:wie,"keyboard.shortcuts":Sie,search:xie,loading:Aie,"export.background":kie,transparent:Iie,auto:Die,light:Tie,dark:Pie},Mie="Farve",$ie="Fyld",Rie="Streg",Fie="Størrelse",Lie="Hold åben",Oie="Skrifttype",_ie="Juster",Nie="Format",zie="Zoom ind",Hie="Zoom ud",jie="til",Uie="Værktøjer",Kie="Transformer",Vie="Fil",Gie="Rediger",Jie="Vis",Wie="Indstillinger",Yie="Log ind",qie="Log ud",Xie="Bliv sponsor",Zie="Zoom til valgte",Qie="Zoom til lærred",eoe="Zoom til",toe="Zoom til indhold",noe="Mørkt udseende",roe="Fokus tilstand",ioe="Debug tilstand",ooe="Vis net",aoe="Brug CAD udvælgelse",soe="Hold formatmenuen åben",uoe="Vis altid snaps",loe="Roteringshåndtag",coe="Bindingshåndtag",doe="Kloningshåndtag",hoe="Fortryd",foe="Gentag",poe="Klip",goe="Kopier",moe="Indsæt",voe="Kopier som",yoe="Eksporter som",Eoe="Vælg alt",Coe="Fravælg alt",boe="Slet",woe="Nyt projekt",Soe="Åben",xoe="Gem",Aoe="Gem som",koe="Upload medie",Ioe="Opret side",Doe="Ny side",Toe="Sidenavn",Poe="Dupliker",Boe="Fortryd",Moe="Kopier invitationslink",$oe="Opret multiplayer projekt",Roe="Kopier til multiplayer projekt",Foe="Vælg",Loe="Viskelæder",Ooe="Tegn",_oe="Pil",Noe="Tekst",zoe="Note",Hoe="Rektangel",joe="Ellipse",Uoe="Trekant",Koe="Linje",Voe="Roter",Goe="Lås billedformat",Joe="Frigør billedformat",Woe="Grupper",Yoe="Opdel gruppe",qoe="Placer bagerst",Xoe="Flyt tilbage",Zoe="Flyt frem",Qoe="Læg forrest",eae="Nulstil vinkel",tae="Lås",nae="Lås op",rae="Flyt til side",iae="Vend vandret",oae="Vend lodret",aae="Flyt",sae="Forrest",uae="Frem",lae="Tilbage",cae="Bagerst",dae="Sprog",hae="Justering nederst",fae="Vandret justering centreret",pae="Lodret justering centreret",gae="Juster / distribuer",mae="Justering til venstre",vae="Justering til højre",yae="Justering øverst",Eae="Kopier skrivebeskyttet link",Cae="Vil du gemme ændringerne til dit projekt?",bae="Vil du gemme dit projekt?",wae="Ja",Sae="Nej",xae="Fortryd",Aae="Skriv filnavn",kae="Vandret distribuering",Iae="Lodret distribuering",Dae="Placering af værktøjslinje",Tae="Nederst",Pae="Venstre",Bae="Højre",Mae="Øverst",$ae="Baggrund ved eksport",Rae="Automatisk",Fae="Lys",Lae="Mørk",Oae="Billede",_ae="Tastaturgenveje",Nae="Indlæser",zae="Side",Hae="Søg",jae="Stræk vandret",Uae="Stræk lodret",Kae="Lær mere",Vae="Gennemsigtig",Gae={"style.menu.color":Mie,"style.menu.fill":$ie,"style.menu.dash":Rie,"style.menu.size":Fie,"style.menu.keep.open":Lie,"style.menu.font":Oie,"style.menu.align":_ie,styles:Nie,"zoom.in":zie,"zoom.out":Hie,to:jie,"menu.tools":Uie,"menu.transform":Kie,"menu.file":Vie,"menu.edit":Gie,"menu.view":Jie,"menu.preferences":Wie,"menu.sign.in":Yie,"menu.sign.out":qie,"become.a.sponsor":Xie,"zoom.to.selection":Zie,"zoom.to.fit":Qie,"zoom.to":eoe,"zoom.to.content":toe,"preferences.dark.mode":noe,"preferences.focus.mode":roe,"preferences.debug.mode":ioe,"preferences.show.grid":ooe,"preferences.use.cad.selection":aoe,"preferences.keep.stylemenu.open":soe,"preferences.always.show.snaps":uoe,"preferences.rotate.handles":loe,"preferences.binding.handles":coe,"preferences.clone.handles":doe,undo:hoe,redo:foe,cut:poe,copy:goe,paste:moe,"copy.as":voe,"export.as":yoe,"select.all":Eoe,"select.none":Coe,delete:boe,"new.project":woe,open:Soe,save:xoe,"save.as":Aoe,"upload.media":koe,"create.page":Ioe,"new.page":Doe,"page.name":Toe,duplicate:Poe,cancel:Boe,"copy.invite.link":Moe,"create.multiplayer.project":$oe,"copy.multiplayer.project":Roe,select:Foe,eraser:Loe,draw:Ooe,arrow:_oe,text:Noe,sticky:zoe,rectangle:Hoe,ellipse:joe,triangle:Uoe,line:Koe,rotate:Voe,"lock.aspect.ratio":Goe,"unlock.aspect.ratio":Joe,group:Woe,ungroup:Yoe,"move.to.back":qoe,"move.backward":Xoe,"move.forward":Zoe,"move.to.front":Qoe,"reset.angle":eae,lock:tae,unlock:nae,"move.to.page":rae,"flip.horizontal":iae,"flip.vertical":oae,move:aae,"to.front":sae,forward:uae,backward:lae,back:cae,language:dae,"align.bottom":hae,"align.center.x":fae,"align.center.y":pae,"align.distribute":gae,"align.left":mae,"align.right":vae,"align.top":yae,"copy.readonly.link":Eae,"dialog.save.again":Cae,"dialog.save.firsttime":bae,"dialog.yes":wae,"dialog.no":Sae,"dialog.cancel":xae,"enter.file.name":Aae,"distribute.x":kae,"distribute.y":Iae,"dock.position":Dae,bottom:Tae,left:Pae,right:Bae,top:Mae,"export.background":$ae,auto:Rae,light:Fae,dark:Lae,image:Oae,"keyboard.shortcuts":_ae,loading:Nae,page:zae,search:Hae,"stretch.x":jae,"stretch.y":Uae,"translation.link":Kae,transparent:Vae},Jae="Farbe",Wae="Füllen",Yae="Strich",qae="Größe",Xae="Offen halten",Zae="Schriftart",Qae="Ausrichten",ese="Stile",tse="Heranzoomen",nse="Herauszoomen",rse="zu",ise="Datei",ose="Bearbeiten",ase="Ansicht",sse="Präferenzen",use="Einloggen",lse="Ausloggen",cse="Sponsor werden",dse="Zur Auswahl zoomen",hse="Zoom anpassen",fse="Zoomen nach",pse="Dunkler Modus",gse="Fokus Modus",mse="Debug Modus",vse="Gitter anzeigen",yse="CAD Auswahl verwenden",Ese="Stilmenü offen halten",Cse="Hilfslinien immer anzeigen",bse="Rotiergriffe",wse="Bindegriffe",Sse="Klongriffe",xse="Rückgängig machen",Ase="Wiederherstellen",kse="Ausschneiden",Ise="Kopieren",Dse="Einfügen",Tse="Kopieren als",Pse="Exportieren als",Bse="Alles auswählen",Mse="Nichts auswählen",$se="Löschen",Rse="Neues Projekt",Fse="Öffnen",Lse="Speichern",Ose="Speichern als",_se="Medien hochladen",Nse="Seite erstellen",zse="Neue Seite",Hse="Seitenname",jse="Duplizieren",Use="Abbrechen",Kse="Einladungslink kopieren",Vse="Mehrspielerprojekt kreieren",Gse="In Mehrspielerprojekt kopieren",Jse="Auswählen",Wse="Radierer",Yse="Malen",qse="Pfeil",Xse="Text",Zse="Notiz",Qse="Rechteck",eue="Ellipse",tue="Dreieck",nue="Linie",rue="Drehen",iue="Seitenverhältnis sperren",oue="Seitenverhältnis entsperren",aue="Gruppieren",sue="Gruppierung aufheben",uue="Nach Hinten verschieben",lue="Rückwärts schieben",cue="Vorwärts schieben",due="Nach Vorne verschieben",hue="Winkel zurücksetzen",fue="Sperren",pue="Entsperren",gue="Zu Seite verschieben",mue="Horizontal spiegeln",vue="Vertikal spiegeln",yue="Verschieben",Eue="Nach Vorne",Cue="Vorwärts",bue="Rückwärts",wue="Hinten",Sue="Sprache",xue={"style.menu.color":Jae,"style.menu.fill":Wae,"style.menu.dash":Yae,"style.menu.size":qae,"style.menu.keep.open":Xae,"style.menu.font":Zae,"style.menu.align":Qae,styles:ese,"zoom.in":tse,"zoom.out":nse,to:rse,"menu.file":ise,"menu.edit":ose,"menu.view":ase,"menu.preferences":sse,"menu.sign.in":use,"menu.sign.out":lse,"become.a.sponsor":cse,"zoom.to.selection":dse,"zoom.to.fit":hse,"zoom.to":fse,"preferences.dark.mode":pse,"preferences.focus.mode":gse,"preferences.debug.mode":mse,"preferences.show.grid":vse,"preferences.use.cad.selection":yse,"preferences.keep.stylemenu.open":Ese,"preferences.always.show.snaps":Cse,"preferences.rotate.handles":bse,"preferences.binding.handles":wse,"preferences.clone.handles":Sse,undo:xse,redo:Ase,cut:kse,copy:Ise,paste:Dse,"copy.as":Tse,"export.as":Pse,"select.all":Bse,"select.none":Mse,delete:$se,"new.project":Rse,open:Fse,save:Lse,"save.as":Ose,"upload.media":_se,"create.page":Nse,"new.page":zse,"page.name":Hse,duplicate:jse,cancel:Use,"copy.invite.link":Kse,"create.multiplayer.project":Vse,"copy.multiplayer.project":Gse,select:Jse,eraser:Wse,draw:Yse,arrow:qse,text:Xse,sticky:Zse,rectangle:Qse,ellipse:eue,triangle:tue,line:nue,rotate:rue,"lock.aspect.ratio":iue,"unlock.aspect.ratio":oue,group:aue,ungroup:sue,"move.to.back":uue,"move.backward":lue,"move.forward":cue,"move.to.front":due,"reset.angle":hue,lock:fue,unlock:pue,"move.to.page":gue,"flip.horizontal":mue,"flip.vertical":vue,move:yue,"to.front":Eue,forward:Cue,backward:bue,back:wue,language:Sue},Aue={},kue="Color",Iue="Relleno",Due="Línea",Tue="Tamaño",Pue="Mantener abierto",Bue="Fuente",Mue="Alineación",$ue="Estilos",Rue="Acercar",Fue="Alejar",Lue="A",Oue="Archivo",_ue="Editar",Nue="Ver",zue="Preferencias",Hue="Iniciar sesión",jue="Cerrar sesión",Uue="Conviértete en patrocinador",Kue="Acercar al contenido",Vue="Acercar a la selección",Gue="Ajustar a la ventana",Jue="Acercar a",Wue="Modo oscuro",Yue="Modo concentración",que="Modo depuración",Xue="Mostrar cuadrícula",Zue="Usar selección CAD",Que="Mantener menú de estilos abierto",ele="Mostrar puntos de ajuste",tle="Control de rotación",nle="Control de vinculación",rle="Control de clonación",ile="Deshacer",ole="Rehacer",ale="Cortar",sle="Copiar",ule="Pegar",lle="Copiar como",cle="Exportar como",dle="Selecionar todo",hle="Selecionar nada",fle="Borrar",ple="Nuevo Proyecto",gle="Abrir",mle="Guardar",vle="Guardar como",yle="Subir medios",Ele="Crear página",Cle="Nueva página",ble="Nombre de página",wle="Duplicar",Sle="Cancelar",xle="Copiar invitación",Ale="Copiar invitación (solo lectura)",kle="Crear proyecto multijugador",Ile="Copiar proyecto multijugador",Dle="Seleccionar",Tle="Borrador",Ple="Dibujar",Ble="Flecha",Mle="Texto",$le="Pegatina",Rle="Rectángulo",Fle="Elipse",Lle="Triángulo",Ole="Línea",_le="Rotar",Nle="Bloquear relación de aspecto",zle="Desbloquear relación de aspecto",Hle="Agrupar",jle="Desagrupar",Ule="Mover al fondo",Kle="Mover atrás",Vle="Mover adelante",Gle="Mover al frente",Jle="Restablecer ángulo",Wle="Bloquear",Yle="Desbloquear",qle="Mover a página",Xle="Voltear horizontalmente",Zle="Voltear verticalmente",Qle="Mover",ece="Al frente",tce="Adelante",nce="Atrás",rce="Fondo",ice="Idioma",oce="Saber más",ace="Posición del dock",sce="Abajo",uce="Atajos de teclado",lce="Cargando{dots}",cce="Izquierda",dce="Derecha",hce="Arriba",fce="Buscar",pce="Página",gce="Imagen",mce={"style.menu.color":kue,"style.menu.fill":Iue,"style.menu.dash":Due,"style.menu.size":Tue,"style.menu.keep.open":Pue,"style.menu.font":Bue,"style.menu.align":Mue,styles:$ue,"zoom.in":Rue,"zoom.out":Fue,to:Lue,"menu.file":Oue,"menu.edit":_ue,"menu.view":Nue,"menu.preferences":zue,"menu.sign.in":Hue,"menu.sign.out":jue,"become.a.sponsor":Uue,"zoom.to.content":Kue,"zoom.to.selection":Vue,"zoom.to.fit":Gue,"zoom.to":Jue,"preferences.dark.mode":Wue,"preferences.focus.mode":Yue,"preferences.debug.mode":que,"preferences.show.grid":Xue,"preferences.use.cad.selection":Zue,"preferences.keep.stylemenu.open":Que,"preferences.always.show.snaps":ele,"preferences.rotate.handles":tle,"preferences.binding.handles":nle,"preferences.clone.handles":rle,undo:ile,redo:ole,cut:ale,copy:sle,paste:ule,"copy.as":lle,"export.as":cle,"select.all":dle,"select.none":hle,delete:fle,"new.project":ple,open:gle,save:mle,"save.as":vle,"upload.media":yle,"create.page":Ele,"new.page":Cle,"page.name":ble,duplicate:wle,cancel:Sle,"copy.invite.link":xle,"copy.readonly.link":Ale,"create.multiplayer.project":kle,"copy.multiplayer.project":Ile,select:Dle,eraser:Tle,draw:Ple,arrow:Ble,text:Mle,sticky:$le,rectangle:Rle,ellipse:Fle,triangle:Lle,line:Ole,rotate:_le,"lock.aspect.ratio":Nle,"unlock.aspect.ratio":zle,group:Hle,ungroup:jle,"move.to.back":Ule,"move.backward":Kle,"move.forward":Vle,"move.to.front":Gle,"reset.angle":Jle,lock:Wle,unlock:Yle,"move.to.page":qle,"flip.horizontal":Xle,"flip.vertical":Zle,move:Qle,"to.front":ece,forward:tce,backward:nce,back:rce,language:ice,"translation.link":oce,"dock.position":ace,bottom:sce,"keyboard.shortcuts":uce,loading:lce,left:cce,right:dce,top:hce,search:fce,page:pce,image:gce},vce="رنگ",yce="توپُر",Ece="خط‌ چین",Cce="اندازه",bce="باز باش",wce="فونت",Sce="تراز",xce="استایل‌ها",Ace="زوم جلو",kce="زوم عقب",Ice="به",Dce="فایل",Tce="ویرایش",Pce="نمایش",Bce="تنظیم‌ها",Mce="ورود",$ce="خروج",Rce=" حامی شو",Fce="نمایش انتخاب‌شده‌ها",Lce="نمایش کل صفحه",Oce="زوم به ",_ce="حالت شب",Nce="حالت تمرکز",zce="حالت عیب‌یایی",Hce="نمایش خطوط راهنما",jce="استفاده از حالت انتخابی CAD",Uce="منوی استایل باز باشه",Kce="راهنمای لبه‌ها رو نشون بده",Vce="دستگیره‌های چرخش رو نشون بده",Gce="دستهٔ لبه‌ها رو نشون بده",Jce="دستگیره‌های کپی رو نشون بده",Wce="یه قدم عقب",Yce="یه قدم جلو",qce="بریدن",Xce="کپی",Zce="جای‌گذاری",Qce="کپی به‌‌عنوان",ede="خروجی با فرمت",tde="انتخاب همه",nde="انتخاب هیچ",rde=" پاک‌کردن",ide="پروژهٔ تازه",ode="باز کن",ade="ذخیره",sde="ذخیره با اسم",ude="آپلود عکس",lde="ساخت صفحه",cde="صفحهٔ تازه",dde="اسم صفحه",hde="کپی درجا",fde="بی‌خیال",pde="کپی لینک دعوت",gde="ساخت پروژهٔ چندنفره",mde="کپی در پروژهٔ چندنفره",vde="انتخاب",yde="پاک‌کن",Ede="رسم",Cde="فلِش",bde="متن",wde="یادداشت",Sde="چارگوش",xde="گردی",Ade="سه‌گوش",kde="خط",Ide="چرخش",Dde="تثبیت نسبت ابعاد",Tde="نسبت ابعاد متغیر",Pde="جمع کن",Bde="جدا کن",Mde="ببر آخر",$de="ببر عقب",Rde="ببر اول",Fde="ببر جلو",Lde="حذف چرخش",Ode="قفل‌ کن",_de="باز کن",Nde="ببر به صفحه",zde="برگردون افقی",Hde="برگردون عمودی",jde="جابه‌جاش کن",Ude="به اول",Kde="به جلو",Vde="به عقب",Gde="به آخر",Jde="زبان",Wde={"style.menu.color":vce,"style.menu.fill":yce,"style.menu.dash":Ece,"style.menu.size":Cce,"style.menu.keep.open":bce,"style.menu.font":wce,"style.menu.align":Sce,styles:xce,"zoom.in":Ace,"zoom.out":kce,to:Ice,"menu.file":Dce,"menu.edit":Tce,"menu.view":Pce,"menu.preferences":Bce,"menu.sign.in":Mce,"menu.sign.out":$ce,"become.a.sponsor":Rce,"zoom.to.selection":Fce,"zoom.to.fit":Lce,"zoom.to":Oce,"preferences.dark.mode":_ce,"preferences.focus.mode":Nce,"preferences.debug.mode":zce,"preferences.show.grid":Hce,"preferences.use.cad.selection":jce,"preferences.keep.stylemenu.open":Uce,"preferences.always.show.snaps":Kce,"preferences.rotate.handles":Vce,"preferences.binding.handles":Gce,"preferences.clone.handles":Jce,undo:Wce,redo:Yce,cut:qce,copy:Xce,paste:Zce,"copy.as":Qce,"export.as":ede,"select.all":tde,"select.none":nde,delete:rde,"new.project":ide,open:ode,save:ade,"save.as":sde,"upload.media":ude,"create.page":lde,"new.page":cde,"page.name":dde,duplicate:hde,cancel:fde,"copy.invite.link":pde,"create.multiplayer.project":gde,"copy.multiplayer.project":mde,select:vde,eraser:yde,draw:Ede,arrow:Cde,text:bde,sticky:wde,rectangle:Sde,ellipse:xde,triangle:Ade,line:kde,rotate:Ide,"lock.aspect.ratio":Dde,"unlock.aspect.ratio":Tde,group:Pde,ungroup:Bde,"move.to.back":Mde,"move.backward":$de,"move.forward":Rde,"move.to.front":Fde,"reset.angle":Lde,lock:Ode,unlock:_de,"move.to.page":Nde,"flip.horizontal":zde,"flip.vertical":Hde,move:jde,"to.front":Ude,forward:Kde,backward:Vde,back:Gde,language:Jde},Yde="Couleur",qde="Remplir",Xde="Bordure",Zde="Taille",Qde="Toujours afficher le menu",e0e="Police",t0e="Alignement",n0e="Styles",r0e="Zoom avant",i0e="Zoom arrière",o0e="À",a0e="Outils",s0e="Transformation",u0e="Fichier",l0e="Édition",c0e="Afficher",d0e="Préférences",h0e="S'authentifier",f0e="Se déconnecter",p0e="Devenir un sponsor",g0e="Retour au contenu",m0e="Ajuster le zoom à la sélection",v0e="Adapter le zoom au contenu",y0e="Rétablir le zoom à",E0e="Mode sombre",C0e="Mode focus",b0e="Afficher la barre développeur",w0e="Afficher la grille",S0e="Utiliser la sélection CAD",x0e="Toujours afficher le menu styles",A0e="Afficher les repères dynamiques",k0e="Manier la rotation",I0e="Manier les liaisons",D0e="Manier le clonage",T0e="Annuler",P0e="Rétablir",B0e="Couper",M0e="Copier",$0e="Coller",R0e="Copier au format",F0e="Exporter au format",L0e="Tout sélectionner",O0e="Tout désélectionner",_0e="Supprimer",N0e="Nouveau project",z0e="Ouvrir",H0e="Enregistrer",j0e="Enregistrer sous",U0e="Importer un média",K0e="Créer une page",V0e="Nouvelle Page",G0e="Nom de la page",J0e="Dupliquer",W0e="Annuler",Y0e="Copier le lien d'invitation",q0e="Copier le lien en lecture seule d'invitation",X0e="Créer un project multi-joueurs",Z0e="Copier dans un projet multi-joueurs",Q0e="Sélection",ehe="Gomme",the="Crayon",nhe="Flèche",rhe="Texte",ihe="Note",ohe="Rectangle",ahe="Cercle",she="Triangle",uhe="Ligne",lhe="Rotation",che="Verrouiller les proportions",dhe="Déverrouiller les proportions",hhe="Grouper",fhe="Dégrouper",phe="Déplacer à l'arrière-plan",ghe="Reculer d'un plan",mhe="Avancer d'un plan",vhe="Placer au premier plan",yhe="Réinitialiser la rotation",Ehe="Verrouiller",Che="Déverrouiller",bhe="Alignement / Répartion",whe="Déplacer vers la page",She="Retourner horizontalement",xhe="Retourner verticalement",Ahe="Disposition",khe="Placer au premier plan",Ihe="Avancer d'un plan",Dhe="Reculer d'un plan",The="Déplacer à l'arrière-plan",Phe="Langage",Bhe="En savoir plus",Mhe="Position du dock",$he="En bas",Rhe="À gauche",Fhe="À droite",Lhe="En haut",Ohe="Page",_he="Raccourcis clavier",Nhe="Rechercher",zhe="Chargement{dots}",Hhe="Couleur d'arrière-plan de l'export",jhe="Transparent",Uhe="Automatique",Khe="Clair",Vhe="Sombre",Ghe={"style.menu.color":Yde,"style.menu.fill":qde,"style.menu.dash":Xde,"style.menu.size":Zde,"style.menu.keep.open":Qde,"style.menu.font":e0e,"style.menu.align":t0e,styles:n0e,"zoom.in":r0e,"zoom.out":i0e,to:o0e,"menu.tools":a0e,"menu.transform":s0e,"menu.file":u0e,"menu.edit":l0e,"menu.view":c0e,"menu.preferences":d0e,"menu.sign.in":h0e,"menu.sign.out":f0e,"become.a.sponsor":p0e,"zoom.to.content":g0e,"zoom.to.selection":m0e,"zoom.to.fit":v0e,"zoom.to":y0e,"preferences.dark.mode":E0e,"preferences.focus.mode":C0e,"preferences.debug.mode":b0e,"preferences.show.grid":w0e,"preferences.use.cad.selection":S0e,"preferences.keep.stylemenu.open":x0e,"preferences.always.show.snaps":A0e,"preferences.rotate.handles":k0e,"preferences.binding.handles":I0e,"preferences.clone.handles":D0e,undo:T0e,redo:P0e,cut:B0e,copy:M0e,paste:$0e,"copy.as":R0e,"export.as":F0e,"select.all":L0e,"select.none":O0e,delete:_0e,"new.project":N0e,open:z0e,save:H0e,"save.as":j0e,"upload.media":U0e,"create.page":K0e,"new.page":V0e,"page.name":G0e,duplicate:J0e,cancel:W0e,"copy.invite.link":Y0e,"copy.readonly.link":q0e,"create.multiplayer.project":X0e,"copy.multiplayer.project":Z0e,select:Q0e,eraser:ehe,draw:the,arrow:nhe,text:rhe,sticky:ihe,rectangle:ohe,ellipse:ahe,triangle:she,line:uhe,rotate:lhe,"lock.aspect.ratio":che,"unlock.aspect.ratio":dhe,group:hhe,ungroup:fhe,"move.to.back":phe,"move.backward":ghe,"move.forward":mhe,"move.to.front":vhe,"reset.angle":yhe,lock:Ehe,unlock:Che,"align.distribute":bhe,"move.to.page":whe,"flip.horizontal":She,"flip.vertical":xhe,move:Ahe,"to.front":khe,forward:Ihe,backward:Dhe,back:The,language:Phe,"translation.link":Bhe,"dock.position":Mhe,bottom:$he,left:Rhe,right:Fhe,top:Lhe,page:Ohe,"keyboard.shortcuts":_he,search:Nhe,loading:zhe,"export.background":Hhe,transparent:jhe,auto:Uhe,light:Khe,dark:Vhe},Jhe="צבע",Whe="מלא",Yhe="גבול",qhe="גודל",Xhe="השאר פתוח",Zhe="גופן",Qhe="יישור",efe="עיצוב",tfe="הגדל תצוגה",nfe="הקטן תצוגה",rfe="ל",ife="קובץ",ofe="עריכה",afe="תצוגה",sfe="מאפיינים",ufe="הירשם",lfe="התנתק",cfe="מתן חסות",dfe="זום לבחירה",hfe="זום להתאמה",ffe="זום ל",pfe="מצב חשוך",gfe="מצב פוקוס",mfe="מצב דיבאג",vfe="(גריד)הראה רשת עימוד",yfe="סימון CAD",Efe="השאר תפריט עיצוב פתוח",Cfe="הראה קווי מתאר",bfe="הראה ידיות סיבוב",wfe="הראה ידיות קשירה",Sfe="הראה ידיות שיכפול",xfe="בטל",Afe="עשה מחדש",kfe="גזור",Ife="העתק",Dfe="הדבק",Tfe="העתק כ",Pfe="ייצא כ",Bfe="בחר הכל",Mfe="בטל בחירה",$fe="מחק",Rfe="פרויקט חדש",Ffe="פתח",Lfe="שמור",Ofe="שמור כ",_fe="העלאת מדיה",Nfe="צור דף",zfe="דף חדש",Hfe="שם הדף",jfe="שכפל",Ufe="בטל",Kfe="העתק קישור הזמנה",Vfe="צור פרויקט רב משתתפים",Gfe="העתק לפרויקט רב משתתפים",Jfe="סמן",Wfe="מחק",Yfe="צייר",qfe="חץ",Xfe="טקסט",Zfe="דביקי",Qfe="מרובע",epe="אליפסה",tpe="משולש",npe="קו",rpe="סובב",ipe="נעל יחס רוחב-גובה",ope="שחרר נעילת יחס רוחב-גובה",ape="קבץ",spe="בטל קיבוץ",upe="הבא לתחתית",lpe="הזז אחורה",cpe="הזז קדימה",dpe="הבא לחזית",hpe="אפס זווית",fpe="נעל",ppe="שחרר נעילה",gpe="הזז לדף",mpe="הפוך אופקית",vpe="הפוך אנכית",ype="הזז",Epe="הבא לקדימה",Cpe="קדימה",bpe="אחורה",wpe="בחזרה",Spe="שפה",xpe={"style.menu.color":Jhe,"style.menu.fill":Whe,"style.menu.dash":Yhe,"style.menu.size":qhe,"style.menu.keep.open":Xhe,"style.menu.font":Zhe,"style.menu.align":Qhe,styles:efe,"zoom.in":tfe,"zoom.out":nfe,to:rfe,"menu.file":ife,"menu.edit":ofe,"menu.view":afe,"menu.preferences":sfe,"menu.sign.in":ufe,"menu.sign.out":lfe,"become.a.sponsor":cfe,"zoom.to.selection":dfe,"zoom.to.fit":hfe,"zoom.to":ffe,"preferences.dark.mode":pfe,"preferences.focus.mode":gfe,"preferences.debug.mode":mfe,"preferences.show.grid":vfe,"preferences.use.cad.selection":yfe,"preferences.keep.stylemenu.open":Efe,"preferences.always.show.snaps":Cfe,"preferences.rotate.handles":bfe,"preferences.binding.handles":wfe,"preferences.clone.handles":Sfe,undo:xfe,redo:Afe,cut:kfe,copy:Ife,paste:Dfe,"copy.as":Tfe,"export.as":Pfe,"select.all":Bfe,"select.none":Mfe,delete:$fe,"new.project":Rfe,open:Ffe,save:Lfe,"save.as":Ofe,"upload.media":_fe,"create.page":Nfe,"new.page":zfe,"page.name":Hfe,duplicate:jfe,cancel:Ufe,"copy.invite.link":Kfe,"create.multiplayer.project":Vfe,"copy.multiplayer.project":Gfe,select:Jfe,eraser:Wfe,draw:Yfe,arrow:qfe,text:Xfe,sticky:Zfe,rectangle:Qfe,ellipse:epe,triangle:tpe,line:npe,rotate:rpe,"lock.aspect.ratio":ipe,"unlock.aspect.ratio":ope,group:ape,ungroup:spe,"move.to.back":upe,"move.backward":lpe,"move.forward":cpe,"move.to.front":dpe,"reset.angle":hpe,lock:fpe,unlock:ppe,"move.to.page":gpe,"flip.horizontal":mpe,"flip.vertical":vpe,move:ype,"to.front":Epe,forward:Cpe,backward:bpe,back:wpe,language:Spe},Ape="Colore",kpe="Riempi",Ipe="Tratteggo",Dpe="Dimensione",Tpe="Mantieni aperto",Ppe="Font",Bpe="Allineamento",Mpe="Stile",$pe="Ingrandisci",Rpe="Rimpicciolisci",Fpe="Imposta",Lpe="File",Ope="Modifica",_pe="Visualizzazione",Npe="Preferenze",zpe="Accedi",Hpe="Esci",jpe="Sponsorizza",Upe="Adatta alla selezione",Kpe="Adatta",Vpe="Ingrandisci",Gpe="Modalità scura",Jpe="Modalità zen",Wpe="Modalità sviluppatore",Ype="Mostra griglia",qpe="Selezione CAD",Xpe="Mantieni menu stile aperto",Zpe="Mostra sempre le guide",Qpe="Controlli d'inclinazione",ege="Controlli d'associazione",tge="Controlli di clonazione",nge="Annulla",rge="Ripristina",ige="Taglia",oge="Copia",age="Incolla",sge="Copia come",uge="Esporta come",lge="Seleziona tutto",cge="Deseleziona tutto",dge="Elimina",hge="Nuovo progetto",fge="Apri",pge="Salva",gge="Salva come",mge="Carica contenuti multimediali",vge="Crea nuova pagina",yge="Nuova pagina",Ege="Nome pagina",Cge="Pagina",bge="Duplica",wge="Chiudi",Sge="Copia link invito",xge="Crea progetto multiplayer",Age="Trasforma in progetto multiplayer",kge="Seleziona",Ige="Gomma",Dge="Matita",Tge="Freccia",Pge="Casella di testo",Bge="Post-it",Mge="Rettangolo",$ge="Ellisse",Rge="Triangolo",Fge="Linea",Lge="Ruota",Oge="Blocca rapporto lati",_ge="Sblocca rapporto lati",Nge="Raggruppa",zge="Separa",Hge="Muovi in fondo",jge="Sposta indietro",Uge="Sposta avanti",Kge="Muovi in fronte",Vge="Reimposta angolo",Gge="Blocca",Jge="Sblocca",Wge="Trasferisci a pagina",Yge="Ribalta orizzontalmente",qge="Ribalta verticalmente",Xge="Sposta",Zge="In primo piano",Qge="Sposta avanti",eme="Sposta indietro",tme="In fondo",nme="Lingua",rme="Posizione dock",ime="In basso",ome="Sinistra",ame="Destra",sme="In Alto",ume={"style.menu.color":Ape,"style.menu.fill":kpe,"style.menu.dash":Ipe,"style.menu.size":Dpe,"style.menu.keep.open":Tpe,"style.menu.font":Ppe,"style.menu.align":Bpe,styles:Mpe,"zoom.in":$pe,"zoom.out":Rpe,to:Fpe,"menu.file":Lpe,"menu.edit":Ope,"menu.view":_pe,"menu.preferences":Npe,"menu.sign.in":zpe,"menu.sign.out":Hpe,"become.a.sponsor":jpe,"zoom.to.selection":Upe,"zoom.to.fit":Kpe,"zoom.to":Vpe,"preferences.dark.mode":Gpe,"preferences.focus.mode":Jpe,"preferences.debug.mode":Wpe,"preferences.show.grid":Ype,"preferences.use.cad.selection":qpe,"preferences.keep.stylemenu.open":Xpe,"preferences.always.show.snaps":Zpe,"preferences.rotate.handles":Qpe,"preferences.binding.handles":ege,"preferences.clone.handles":tge,undo:nge,redo:rge,cut:ige,copy:oge,paste:age,"copy.as":sge,"export.as":uge,"select.all":lge,"select.none":cge,delete:dge,"new.project":hge,open:fge,save:pge,"save.as":gge,"upload.media":mge,"create.page":vge,"new.page":yge,"page.name":Ege,page:Cge,duplicate:bge,cancel:wge,"copy.invite.link":Sge,"create.multiplayer.project":xge,"copy.multiplayer.project":Age,select:kge,eraser:Ige,draw:Dge,arrow:Tge,text:Pge,sticky:Bge,rectangle:Mge,ellipse:$ge,triangle:Rge,line:Fge,rotate:Lge,"lock.aspect.ratio":Oge,"unlock.aspect.ratio":_ge,group:Nge,ungroup:zge,"move.to.back":Hge,"move.backward":jge,"move.forward":Uge,"move.to.front":Kge,"reset.angle":Vge,lock:Gge,unlock:Jge,"move.to.page":Wge,"flip.horizontal":Yge,"flip.vertical":qge,move:Xge,"to.front":Zge,forward:Qge,backward:eme,back:tme,language:nme,"dock.position":rme,bottom:ime,left:ome,right:ame,top:sme},lme="色",cme="塗りつぶし",dme="線",hme="大きさ",fme="常に表示",pme="フォント",gme="配置",mme="スタイル",vme="拡大",yme="縮小",Eme=" ",Cme="ファイル",bme="編集",wme="表示",Sme="設定",xme="サインイン",Ame="サインアウト",kme="支援する",Ime="選択したアイテムに合わせて拡大",Dme="拡大してすべてを表示",Tme=" ",Pme="ダークモード",Bme="フォーカスモード",Mme="デバッグモード",$me="グリッドを表示",Rme="CADの選択法を使用",Fme="スタイルメニューを常に表示",Lme="スナップを常に表示",Ome="回転ハンドルを表示",_me="結合ハンドルを表示",Nme="クローンハンドルを表示",zme="元に戻す",Hme="やり直し",jme="切り取り",Ume="コピー",Kme="貼り付け",Vme="形式を選択してコピー",Gme="形式を選択してエクスポート",Jme="すべて選択",Wme="選択を解除",Yme="削除",qme="新しいプロジェクト",Xme="開く",Zme="保存",Qme="名前をつけて保存",e1e="メディアをアップロード",t1e="ページを作成",n1e="新規ページ",r1e="ページ名",i1e="複製",o1e="キャンセル",a1e="共有リンクをクリップボードにコピー",s1e="マルチプレイヤープロジェクトを作成",u1e="マルチプレイヤープロジェクトにコピー",l1e="選択",c1e="消しゴム",d1e="描画",h1e="矢印",f1e="テキスト",p1e="ふせん",g1e="長方形",m1e="楕円形",v1e="三角形",y1e="線",E1e="回転",C1e="縦横比を固定",b1e="縦横比の固定を解除",w1e="グルーピング",S1e="グループ解除",x1e="最後面に移動",A1e="ひとつ後ろに移動",k1e="ひとつ前に移動",I1e="最背面に移動",D1e="角度を初期化",T1e="ロック",P1e="アンロック",B1e="ページへ移動",M1e="水平方向に反転",$1e="垂直方向に反転",R1e="移動",F1e="最前面へ",L1e="ひとつ前へ",O1e="ひとつ後ろへ",_1e="最背面へ",N1e="言語",z1e={"style.menu.color":lme,"style.menu.fill":cme,"style.menu.dash":dme,"style.menu.size":hme,"style.menu.keep.open":fme,"style.menu.font":pme,"style.menu.align":gme,styles:mme,"zoom.in":vme,"zoom.out":yme,to:Eme,"menu.file":Cme,"menu.edit":bme,"menu.view":wme,"menu.preferences":Sme,"menu.sign.in":xme,"menu.sign.out":Ame,"become.a.sponsor":kme,"zoom.to.selection":Ime,"zoom.to.fit":Dme,"zoom.to":Tme,"preferences.dark.mode":Pme,"preferences.focus.mode":Bme,"preferences.debug.mode":Mme,"preferences.show.grid":$me,"preferences.use.cad.selection":Rme,"preferences.keep.stylemenu.open":Fme,"preferences.always.show.snaps":Lme,"preferences.rotate.handles":Ome,"preferences.binding.handles":_me,"preferences.clone.handles":Nme,undo:zme,redo:Hme,cut:jme,copy:Ume,paste:Kme,"copy.as":Vme,"export.as":Gme,"select.all":Jme,"select.none":Wme,delete:Yme,"new.project":qme,open:Xme,save:Zme,"save.as":Qme,"upload.media":e1e,"create.page":t1e,"new.page":n1e,"page.name":r1e,duplicate:i1e,cancel:o1e,"copy.invite.link":a1e,"create.multiplayer.project":s1e,"copy.multiplayer.project":u1e,select:l1e,eraser:c1e,draw:d1e,arrow:h1e,text:f1e,sticky:p1e,rectangle:g1e,ellipse:m1e,triangle:v1e,line:y1e,rotate:E1e,"lock.aspect.ratio":C1e,"unlock.aspect.ratio":b1e,group:w1e,ungroup:S1e,"move.to.back":x1e,"move.backward":A1e,"move.forward":k1e,"move.to.front":I1e,"reset.angle":D1e,lock:T1e,unlock:P1e,"move.to.page":B1e,"flip.horizontal":M1e,"flip.vertical":$1e,move:R1e,"to.front":F1e,forward:L1e,backward:O1e,back:_1e,language:N1e},H1e="색깔",j1e="채우기",U1e="테두리",K1e="크기",V1e="항상 열기",G1e="글꼴",J1e="정렬",W1e="스타일",Y1e="확대",q1e="축소",X1e="to",Z1e="파일",Q1e="편집",e4e="보기",t4e="설정",n4e="로그인",r4e="로그아웃",i4e="후원자 되기",o4e="선택 요소 맞추기",a4e="전체 맞추기",s4e="맞추기",u4e="다크 모드",l4e="집중 모드",c4e="디버그 모드",d4e="격자 보기",h4e="CAD 선택 사용",f4e="스타일 메뉴 항상 열기",p4e="Snap 항상 열기",g4e="회전 보이기",m4e="Binding Handles",v4e="복제 보이기",y4e="실행 취소",E4e="다시 실행",C4e="자르기",b4e="복사",w4e="붙여넣기",S4e="다른 형식으로 복사하기",x4e="내보내기",A4e="전체 선택",k4e="선택 안함",I4e="삭제하기",D4e="새 프로젝트",T4e="열기",P4e="저장",B4e="다른 이름으로 저장",M4e="미디어 업로드",$4e="새 페이지 만들기",R4e="새 페이지",F4e="페이지 이름",L4e="복제",O4e="취소",_4e="초대 링크 복사하기",N4e="공동 프로젝트 만들기",z4e="공동 프로젝트로 복사하기",H4e="선택",j4e="지우개",U4e="그리기",K4e="화살표",V4e="텍스트",G4e="메모",J4e="사각형",W4e="원",Y4e="삼각형",q4e="선",X4e="회전",Z4e="비율 잠금",Q4e="비율 잠금 해제",eve="그룹화",tve="그룹화 해제",nve="맨 뒤로 보내기",rve="뒤로 보내기",ive="앞으로 가져오기",ove="맨 앞으로 가져오기",ave="회전 초기화",sve="잠구기",uve="잠금 해제하기",lve="페이지로 이동",cve="수평으로 뒤집기",dve="수직으로 뒤집기",hve="순서",fve="맨 앞으로",pve="앞으로",gve="뒤로",mve="맨 뒤로",vve="언어",yve={"style.menu.color":H1e,"style.menu.fill":j1e,"style.menu.dash":U1e,"style.menu.size":K1e,"style.menu.keep.open":V1e,"style.menu.font":G1e,"style.menu.align":J1e,styles:W1e,"zoom.in":Y1e,"zoom.out":q1e,to:X1e,"menu.file":Z1e,"menu.edit":Q1e,"menu.view":e4e,"menu.preferences":t4e,"menu.sign.in":n4e,"menu.sign.out":r4e,"become.a.sponsor":i4e,"zoom.to.selection":o4e,"zoom.to.fit":a4e,"zoom.to":s4e,"preferences.dark.mode":u4e,"preferences.focus.mode":l4e,"preferences.debug.mode":c4e,"preferences.show.grid":d4e,"preferences.use.cad.selection":h4e,"preferences.keep.stylemenu.open":f4e,"preferences.always.show.snaps":p4e,"preferences.rotate.handles":g4e,"preferences.binding.handles":m4e,"preferences.clone.handles":v4e,undo:y4e,redo:E4e,cut:C4e,copy:b4e,paste:w4e,"copy.as":S4e,"export.as":x4e,"select.all":A4e,"select.none":k4e,delete:I4e,"new.project":D4e,open:T4e,save:P4e,"save.as":B4e,"upload.media":M4e,"create.page":$4e,"new.page":R4e,"page.name":F4e,duplicate:L4e,cancel:O4e,"copy.invite.link":_4e,"create.multiplayer.project":N4e,"copy.multiplayer.project":z4e,select:H4e,eraser:j4e,draw:U4e,arrow:K4e,text:V4e,sticky:G4e,rectangle:J4e,ellipse:W4e,triangle:Y4e,line:q4e,rotate:X4e,"lock.aspect.ratio":Z4e,"unlock.aspect.ratio":Q4e,group:eve,ungroup:tve,"move.to.back":nve,"move.backward":rve,"move.forward":ive,"move.to.front":ove,"reset.angle":ave,lock:sve,unlock:uve,"move.to.page":lve,"flip.horizontal":cve,"flip.vertical":dve,move:hve,"to.front":fve,forward:pve,backward:gve,back:mve,language:vve},Eve="Color",Cve="Fill",bve="Dash",wve="Size",Sve="Keep Open",xve="Font",Ave="Align",kve="Styles",Ive="Zoom In",Dve="Zoom Out",Tve="To",Pve="Tools",Bve="Transform",Mve="File",$ve="Edit",Rve="View",Fve="Preferences",Lve="Sign In",Ove="Sign Out",_ve="Become a Sponsor",Nve="Back to content",zve="Zoom to Selection",Hve="Zoom to Fit",jve="Zoom to",Uve="Dark Mode",Kve="Focus Mode",Vve="Debug Mode",Gve="Show Grid",Jve="Use CAD Selection",Wve="Keep Style Menu Open",Yve="Always Show Snaps",qve="Rotate Handles",Xve="Binding Handles",Zve="Clone Handles",Qve="Undo",e2e="Redo",t2e="Cut",n2e="Copy",r2e="Paste",i2e="Copy As",o2e="Export As",a2e="Select All",s2e="Select None",u2e="Delete",l2e="New Project",c2e="Open",d2e="Save",h2e="Save As",f2e="Upload Media",p2e="Create Page",g2e="New Page",m2e="Page Name",v2e="Duplicate",y2e="Cancel",E2e="Copy Invite Link",C2e="Copy ReadOnly Link",b2e="Create a Multiplayer Project",w2e="Copy to Multiplayer Project",S2e="Select",x2e="Eraser",A2e="Draw",k2e="Arrow",I2e="Text",D2e="Sticky",T2e="Rectangle",P2e="Ellipse",B2e="Triangle",M2e="Line",$2e="Rotate",R2e="Lock Aspect Ratio",F2e="Unlock Aspect Ratio",L2e="Group",O2e="Ungroup",_2e="Move to Back",N2e="Move Backward",z2e="Move Forward",H2e="Move to Front",j2e="Reset Angle",U2e="Lock",K2e="Unlock",V2e="Align / Distribute",G2e="Move to Page",J2e="Flip Horizontal",W2e="Flip Vertical",Y2e="Move",q2e="To Front",X2e="Forward",Z2e="Backward",Q2e="To Back",eye="Language",tye="Learn More",nye="Dock Position",rye="Bottom",iye="Left",oye="Right",aye="Top",sye="Page",uye="Keyboard shortcuts",lye="Search",cye="Loading{dots}",dye="Export Background",hye="Transparent",fye="Auto",pye="Light",gye="Dark",mye="Github",vye="Twitter",yye="Discord",Eye="Image",Cye="Align Left",bye="Align Horizontal Center",wye="Align Right",Sye="Align Top",xye="Align Vertical Center",Aye="Align Bottom",kye="Distribute Horizontal",Iye="Distribute Vertical",Dye="Stretch Horizontal",Tye="Stretch Vertical",Pye="Do you want to save your current project?",Bye="Do you want to save changes to your current project?",Mye="Cancel",$ye="No",Rye="Yes",Fye="Enter file name",Lye="Try the new tldraw",Oye={"style.menu.color":Eve,"style.menu.fill":Cve,"style.menu.dash":bve,"style.menu.size":wve,"style.menu.keep.open":Sve,"style.menu.font":xve,"style.menu.align":Ave,styles:kve,"zoom.in":Ive,"zoom.out":Dve,to:Tve,"menu.tools":Pve,"menu.transform":Bve,"menu.file":Mve,"menu.edit":$ve,"menu.view":Rve,"menu.preferences":Fve,"menu.sign.in":Lve,"menu.sign.out":Ove,"become.a.sponsor":_ve,"zoom.to.content":Nve,"zoom.to.selection":zve,"zoom.to.fit":Hve,"zoom.to":jve,"preferences.dark.mode":Uve,"preferences.focus.mode":Kve,"preferences.debug.mode":Vve,"preferences.show.grid":Gve,"preferences.use.cad.selection":Jve,"preferences.keep.stylemenu.open":Wve,"preferences.always.show.snaps":Yve,"preferences.rotate.handles":qve,"preferences.binding.handles":Xve,"preferences.clone.handles":Zve,undo:Qve,redo:e2e,cut:t2e,copy:n2e,paste:r2e,"copy.as":i2e,"export.as":o2e,"select.all":a2e,"select.none":s2e,delete:u2e,"new.project":l2e,open:c2e,save:d2e,"save.as":h2e,"upload.media":f2e,"create.page":p2e,"new.page":g2e,"page.name":m2e,duplicate:v2e,cancel:y2e,"copy.invite.link":E2e,"copy.readonly.link":C2e,"create.multiplayer.project":b2e,"copy.multiplayer.project":w2e,select:S2e,eraser:x2e,draw:A2e,arrow:k2e,text:I2e,sticky:D2e,rectangle:T2e,ellipse:P2e,triangle:B2e,line:M2e,rotate:$2e,"lock.aspect.ratio":R2e,"unlock.aspect.ratio":F2e,group:L2e,ungroup:O2e,"move.to.back":_2e,"move.backward":N2e,"move.forward":z2e,"move.to.front":H2e,"reset.angle":j2e,lock:U2e,unlock:K2e,"align.distribute":V2e,"move.to.page":G2e,"flip.horizontal":J2e,"flip.vertical":W2e,move:Y2e,"to.front":q2e,forward:X2e,backward:Z2e,back:Q2e,language:eye,"translation.link":tye,"dock.position":nye,bottom:rye,left:iye,right:oye,top:aye,page:sye,"keyboard.shortcuts":uye,search:lye,loading:cye,"export.background":dye,transparent:hye,auto:fye,light:pye,dark:gye,github:mye,twitter:vye,discord:yye,image:Eye,"align.left":Cye,"align.center.x":bye,"align.right":wye,"align.top":Sye,"align.center.y":xye,"align.bottom":Aye,"distribute.x":kye,"distribute.y":Iye,"stretch.x":Dye,"stretch.y":Tye,"dialog.save.firsttime":Pye,"dialog.save.again":Bye,"dialog.cancel":Mye,"dialog.no":$ye,"dialog.yes":Rye,"enter.file.name":Fye,"tldraw-beta":Lye},_ye="रंग",Nye="भर्नुहोस्",zye="धर्का",Hye="आकार",jye="खुला राख्नुहोस्",Uye="फन्ट",Kye="पङ्क्तिबद्ध",Vye="शैलीहरू",Gye="जुम इन",Jye="जुम आउट",Wye="टु",Yye="फाइल",qye="सम्पादन गर्नुहोस्",Xye="भ्यू",Zye="प्राथमिकताहरू",Qye="साइन इन गर्नुहोस्",e3e="साइन आउट गर्नुहोस्",t3e="प्रायोजक बन्नुहोस्",n3e="जुम टु सेलेक्सन",r3e="जुम टु फिट",i3e="जुम टु",o3e="अँध्यारो मोड",a3e="फोकस मोड",s3e="डिबग मोड",u3e="ग्रिड देखाउनुहोस्",l3e="CAD सेलेक्सन गर्नुहोस्",c3e="स्टाइल मेनु खुला राख्नुहोस्",d3e="सधैँ स्न्यापहरू देखाउनुहोस्",h3e="ह्यान्डलहरू घुमाउनुहोस्",f3e="बाइन्डिङ ह्यान्डलहरू",p3e="क्लोन ह्यान्डलहरू",g3e="पूर्ववत गर्नुहोस्",m3e="पुनः गर्नुहोस्",v3e="कट गर्नुहोस्",y3e="कपि गर्नुहोस्",E3e="पेस्ट गर्नुहोस्",C3e="कपि एज",b3e="एक्सपोर्ट एज",w3e="सबै छान्नुहोस्",S3e="केहि पनि सेलेक्ट नगर्नुहोस्",x3e="मेटाउनुहोस्",A3e="नयाँ परियोजना",k3e="खोल्नुहोस्",I3e="सुरक्षित गर्नुहोस्",D3e="सेभ एज",T3e="मिडिया अपलोड गर्नुहोस्",P3e="पृष्ठ सिर्जना गर्नुहोस्",B3e="नयाँ पृष्ठ सिर्जना गर्नुहोस्",M3e="पृष्ठको नाम",$3e="अनुलिपि गर्नुहोस्",R3e="रद्द गर्नुहोस्",F3e="निमन्त्रणा लिङ्क कपि गर्नुहोस्",L3e="मल्टिप्लेयर परियोजना सिर्जना गर्नुहोस्",O3e="मल्टिप्लेयर प्रोजेक्टमा कपि गर्नुहोस्",_3e="सेलेक्ट",N3e="इरेजर",z3e="चित्र बनाउनु",H3e="तीर",j3e="शब्द",U3e="टाँसिने",K3e="आयत",V3e="दीर्घवृत्त",G3e="त्रिभुज",J3e="रेखा",W3e="घुमाउनुहोस्",Y3e="आकार अनुपात लक गर्नुहोस्",q3e="आकार अनुपात अनलक गर्नुहोस्",X3e="समूह",Z3e="समूह रद्द गर्नुहोस्",Q3e="पछाडि सार्नुहोस्",eEe="थप पछाडि सार्नुहोस्",tEe="अगाडि सार्नुहोस्",nEe="थप अगाडि सार्नुहोस्",rEe="कोण रिसेट गर्नुहोस्",iEe="लक गर्नुहोस्",oEe="अनलक गर्नुहोस्",aEe="पृष्ठमा सार्नुहोस्",sEe="तेर्सो फ्लिप गर्नुहोस्",uEe="ठाडो फ्लिप गर्नुहोस्",lEe="सार्नुहोस्",cEe="थप अगाडि",dEe="अगाडि",hEe="पछाडि",fEe="थप पछाडि",pEe="भाषा",gEe={"style.menu.color":_ye,"style.menu.fill":Nye,"style.menu.dash":zye,"style.menu.size":Hye,"style.menu.keep.open":jye,"style.menu.font":Uye,"style.menu.align":Kye,styles:Vye,"zoom.in":Gye,"zoom.out":Jye,to:Wye,"menu.file":Yye,"menu.edit":qye,"menu.view":Xye,"menu.preferences":Zye,"menu.sign.in":Qye,"menu.sign.out":e3e,"become.a.sponsor":t3e,"zoom.to.selection":n3e,"zoom.to.fit":r3e,"zoom.to":i3e,"preferences.dark.mode":o3e,"preferences.focus.mode":a3e,"preferences.debug.mode":s3e,"preferences.show.grid":u3e,"preferences.use.cad.selection":l3e,"preferences.keep.stylemenu.open":c3e,"preferences.always.show.snaps":d3e,"preferences.rotate.handles":h3e,"preferences.binding.handles":f3e,"preferences.clone.handles":p3e,undo:g3e,redo:m3e,cut:v3e,copy:y3e,paste:E3e,"copy.as":C3e,"export.as":b3e,"select.all":w3e,"select.none":S3e,delete:x3e,"new.project":A3e,open:k3e,save:I3e,"save.as":D3e,"upload.media":T3e,"create.page":P3e,"new.page":B3e,"page.name":M3e,duplicate:$3e,cancel:R3e,"copy.invite.link":F3e,"create.multiplayer.project":L3e,"copy.multiplayer.project":O3e,select:_3e,eraser:N3e,draw:z3e,arrow:H3e,text:j3e,sticky:U3e,rectangle:K3e,ellipse:V3e,triangle:G3e,line:J3e,rotate:W3e,"lock.aspect.ratio":Y3e,"unlock.aspect.ratio":q3e,group:X3e,ungroup:Z3e,"move.to.back":Q3e,"move.backward":eEe,"move.forward":tEe,"move.to.front":nEe,"reset.angle":rEe,lock:iEe,unlock:oEe,"move.to.page":aEe,"flip.horizontal":sEe,"flip.vertical":uEe,move:lEe,"to.front":cEe,forward:dEe,backward:hEe,back:fEe,language:pEe},mEe="Farge",vEe="Fyll",yEe="Linje",EEe="Størrelse",CEe="Hold åpen",bEe="Teksttype",wEe="Juster",SEe="Stiler",xEe="Zoom inn",AEe="Zoom ut",kEe="til",IEe="Fil",DEe="Rediger",TEe="Vis",PEe="Preferanser",BEe="Logg inn",MEe="Logg ut",$Ee="Bli en sponsor",REe="Zoom til valg",FEe="Zoom for å passe",LEe="Zoom til",OEe="Mørk modus",_Ee="Fokus modus",NEe="Debug modus",zEe="Vis rutenett",HEe="Bruk CAD seleksjon",jEe="Hold stilmeny åpen",UEe="Vis alltid snaps",KEe="Vis roteringshåndtak",VEe="Vis bindingshåndtak",GEe="Vis kloningshåndtak",JEe="Angre",WEe="Gjør om",YEe="Klipp ut",qEe="Kopier",XEe="Lim inn",ZEe="Kopier som",QEe="Eksporter som",eCe="Velg alle",tCe="Velg ingen",nCe="Slett",rCe="Nytt prosjekt",iCe="Åpne",oCe="Lagre",aCe="Lagre som",sCe="Last opp media",uCe="Opprett side",lCe="Ny side",cCe="Sidenavn",dCe="Dupliser",hCe="Avbryt",fCe="Kopier invitasjonslink",pCe="Opprett et flerspiller prosjekt",gCe="Kopier til flerspiller prosjekt",mCe="Velg",vCe="Viskelær",yCe="Tegn",ECe="Pil",CCe="Tekst",bCe="Lapp",wCe="Rektangel",SCe="Ellipse",xCe="Trekant",ACe="Linje",kCe="Roter",ICe="Lås størrelsesforhold",DCe="Lås opp størrelsesforhold",TCe="Grupper",PCe="Avgrupper",BCe="Flytt bakerst",MCe="Flytt bakover",$Ce="Flytt forover",RCe="Flytt til front",FCe="Tilbakestill vinkel",LCe="Lås",OCe="Lås opp",_Ce="Flytt til side",NCe="Snu horisontalt",zCe="Snu vertikalt",HCe="Flytt",jCe="Foran",UCe="Framover",KCe="Bakover",VCe="Bakerst",GCe="Språk",JCe={"style.menu.color":mEe,"style.menu.fill":vEe,"style.menu.dash":yEe,"style.menu.size":EEe,"style.menu.keep.open":CEe,"style.menu.font":bEe,"style.menu.align":wEe,styles:SEe,"zoom.in":xEe,"zoom.out":AEe,to:kEe,"menu.file":IEe,"menu.edit":DEe,"menu.view":TEe,"menu.preferences":PEe,"menu.sign.in":BEe,"menu.sign.out":MEe,"become.a.sponsor":$Ee,"zoom.to.selection":REe,"zoom.to.fit":FEe,"zoom.to":LEe,"preferences.dark.mode":OEe,"preferences.focus.mode":_Ee,"preferences.debug.mode":NEe,"preferences.show.grid":zEe,"preferences.use.cad.selection":HEe,"preferences.keep.stylemenu.open":jEe,"preferences.always.show.snaps":UEe,"preferences.rotate.handles":KEe,"preferences.binding.handles":VEe,"preferences.clone.handles":GEe,undo:JEe,redo:WEe,cut:YEe,copy:qEe,paste:XEe,"copy.as":ZEe,"export.as":QEe,"select.all":eCe,"select.none":tCe,delete:nCe,"new.project":rCe,open:iCe,save:oCe,"save.as":aCe,"upload.media":sCe,"create.page":uCe,"new.page":lCe,"page.name":cCe,duplicate:dCe,cancel:hCe,"copy.invite.link":fCe,"create.multiplayer.project":pCe,"copy.multiplayer.project":gCe,select:mCe,eraser:vCe,draw:yCe,arrow:ECe,text:CCe,sticky:bCe,rectangle:wCe,ellipse:SCe,triangle:xCe,line:ACe,rotate:kCe,"lock.aspect.ratio":ICe,"unlock.aspect.ratio":DCe,group:TCe,ungroup:PCe,"move.to.back":BCe,"move.backward":MCe,"move.forward":$Ce,"move.to.front":RCe,"reset.angle":FCe,lock:LCe,unlock:OCe,"move.to.page":_Ce,"flip.horizontal":NCe,"flip.vertical":zCe,move:HCe,"to.front":jCe,forward:UCe,backward:KCe,back:VCe,language:GCe},WCe="Kolor",YCe="Wypełnienie",qCe="Linia",XCe="Rozmiar",ZCe="Zachowaj otwarte",QCe="Czcionka",e9e="Wyrównanie",t9e="Style",n9e="Przybliż",r9e="Oddal",i9e="do",o9e="Plik",a9e="Edycja",s9e="Widok",u9e="Preferencje",l9e="Zaloguj",c9e="Wyloguj",d9e="Zostań sponsorem",h9e="Przybliż do zaznaczenia",f9e="Wypełnij ekran",p9e="Przybliż do",g9e="Tryb ciemny",m9e="Tryb skupienia",v9e="Tryb debugowania",y9e="Pokaż siatkę",E9e="Użyj zaznaczania CAD",C9e="Zachowaj menu styli otwarte",b9e="Przyciągaj obiekty",w9e="Uchwyty obrotu",S9e="Uchwyty powiązania",x9e="Uchwyty klonujące",A9e="Cofnij",k9e="Powtórz",I9e="Wytnij",D9e="Kopiuj",T9e="Wklej",P9e="Kopiuj jako",B9e="Eksportuj jako",M9e="Zaznacz wszystko",$9e="Odznacz wszystko",R9e="Usuń",F9e="Nowy projekt",L9e="Otwórz",O9e="Zapisz",_9e="Zapisz jako",N9e="Załaduj multimedia",z9e="Utwórz stronę",H9e="Nowa strona",j9e="Nazwa strony",U9e="Powiel",K9e="Anuluj",V9e="Kopiuj link zaproszenia",G9e="Stwórz projekt wieloosobowy",J9e="Kopiuj do projektu wieloosobowego",W9e="Zaznacz",Y9e="Gumka",q9e="Rysuj",X9e="Strzałka",Z9e="Tekst",Q9e="Naklejka",e5e="Prostokąt",t5e="Elipsa",n5e="Trójkąt",r5e="Linia",i5e="Obróć",o5e="Zablokuj proporcje",a5e="Odblokuj proporcje",s5e="Grupuj",u5e="Rozgrupuj",l5e="Przenieś na tył",c5e="Przesuń do tyłu",d5e="Przesuń do przodu",h5e="Przenieś na przód",f5e="Resetuj kąt",p5e="Zablokuj",g5e="Odblokuj",m5e="Przenieś na stronę",v5e="Odwróć w poziomie",y5e="Odwróć w pionie",E5e="Przenieś",C5e="Na wierzch",b5e="Do przodu",w5e="Do tyłu",S5e="Na spód",x5e="Język",A5e={"style.menu.color":WCe,"style.menu.fill":YCe,"style.menu.dash":qCe,"style.menu.size":XCe,"style.menu.keep.open":ZCe,"style.menu.font":QCe,"style.menu.align":e9e,styles:t9e,"zoom.in":n9e,"zoom.out":r9e,to:i9e,"menu.file":o9e,"menu.edit":a9e,"menu.view":s9e,"menu.preferences":u9e,"menu.sign.in":l9e,"menu.sign.out":c9e,"become.a.sponsor":d9e,"zoom.to.selection":h9e,"zoom.to.fit":f9e,"zoom.to":p9e,"preferences.dark.mode":g9e,"preferences.focus.mode":m9e,"preferences.debug.mode":v9e,"preferences.show.grid":y9e,"preferences.use.cad.selection":E9e,"preferences.keep.stylemenu.open":C9e,"preferences.always.show.snaps":b9e,"preferences.rotate.handles":w9e,"preferences.binding.handles":S9e,"preferences.clone.handles":x9e,undo:A9e,redo:k9e,cut:I9e,copy:D9e,paste:T9e,"copy.as":P9e,"export.as":B9e,"select.all":M9e,"select.none":$9e,delete:R9e,"new.project":F9e,open:L9e,save:O9e,"save.as":_9e,"upload.media":N9e,"create.page":z9e,"new.page":H9e,"page.name":j9e,duplicate:U9e,cancel:K9e,"copy.invite.link":V9e,"create.multiplayer.project":G9e,"copy.multiplayer.project":J9e,select:W9e,eraser:Y9e,draw:q9e,arrow:X9e,text:Z9e,sticky:Q9e,rectangle:e5e,ellipse:t5e,triangle:n5e,line:r5e,rotate:i5e,"lock.aspect.ratio":o5e,"unlock.aspect.ratio":a5e,group:s5e,ungroup:u5e,"move.to.back":l5e,"move.backward":c5e,"move.forward":d5e,"move.to.front":h5e,"reset.angle":f5e,lock:p5e,unlock:g5e,"move.to.page":m5e,"flip.horizontal":v5e,"flip.vertical":y5e,move:E5e,"to.front":C5e,forward:b5e,backward:w5e,back:S5e,language:x5e},k5e="Cor",I5e="Preencher",D5e="Traço",T5e="Tamanho",P5e="Manter aberto",B5e="Fonte",M5e="Alinhamento",$5e="Estilos",R5e="Aumentar zoom",F5e="Diminuir zoom",L5e="para",O5e="Arquivo",_5e="Editar",N5e="Visualizar",z5e="Preferências",H5e="Entrar",j5e="Sair",U5e="Torne-se um patrocinador",K5e="Zoom para a seleção",V5e="Zoom para ajuste",G5e="Zoom para",J5e="Modo Escuro",W5e="Modo Foco",Y5e="Modo Debug",q5e="Mostrar Grade",X5e="Usar seleção CAD",Z5e="Manter Menu de Estilos Aberto",Q5e="Mostrar Pontos de Ajuste",ebe="Controle de Rotação",tbe="Controle de Vínculos",nbe="Controle de Clone",rbe="Desfazer",ibe="Refazer",obe="Cortar",abe="Copiar",sbe="Colar",ube="Copiar como",lbe="Exportar como",cbe="Selecionar todos",dbe="Selecionar nenhum",hbe="Deletar",fbe="Novo Projeto",pbe="Abrir",gbe="Salvar",mbe="Salvar Como",vbe="Carregar Mídia",ybe="Página",Ebe="Procurar",Cbe="Carregando{dots}",bbe="Exportar Fundo",wbe="Transparente",Sbe="Automático",xbe="Claro",Abe="Escuro",kbe="Ferramentas",Ibe="Transformar",Dbe="Voltar ao Conteúdo",Tbe="Saiba Mais",Pbe="Copiar Link ReadOnly",Bbe="Alinhar / Distribuir",Mbe="Criar Página",$be="Nova Página",Rbe="Nome da Página",Fbe="Duplicar",Lbe="Cancelar",Obe="Copiar Link de Convite",_be="Criar um Projeto Multijogador",Nbe="Copiar para Projeto Multijogador",zbe="Selecionar",Hbe="Borracha",jbe="Desenhar",Ube="Seta",Kbe="Texto",Vbe="Adesivo",Gbe="Retângulo",Jbe="Elipse",Wbe="Triângulo",Ybe="Linha",qbe="Rotacionar",Xbe="Travar Proporção da Tela",Zbe="Destravar Proporção da Tela",Qbe="Agrupar",ewe="Desagrupar",twe="Recuar",nwe="Enviar para Trás",rwe="Avançar",iwe="Trazer para Frente",owe="Reiniciar Ângulo",awe="Travar",swe="Destravar",uwe="Mover para Página",lwe="Virar Horizontalmente",cwe="Virar Verticalmente",dwe="Mover",hwe="Para Frente",fwe="Avançar",pwe="Recuar",gwe="Voltar",mwe="Idioma",vwe="Imagem",ywe="Atalhos de Teclado",Ewe="Posição de Ferramentas",Cwe="Inferior",bwe="Superior",wwe="Direita",Swe="Esquerda",xwe="Alinhar à esquerda",Awe="Alinhar ao centro na horizontal",kwe="Alinhar à direita",Iwe="Alinhas em cima",Dwe="Alinhar ao centro na vertical",Twe="Alinhar embaixo",Pwe="Distruibuir na horizontal",Bwe="Distruibuir na vertical",Mwe="Esticar na horizontal",$we="Esticar na vertical",Rwe="Você deseja salvar seu projeto atual?",Fwe="Você deseja salvar as mudanças ao projeto atual?",Lwe="Cancelar",Owe="Não",_we="Sim",Nwe="Insira o nome do arquivo",zwe={"style.menu.color":k5e,"style.menu.fill":I5e,"style.menu.dash":D5e,"style.menu.size":T5e,"style.menu.keep.open":P5e,"style.menu.font":B5e,"style.menu.align":M5e,styles:$5e,"zoom.in":R5e,"zoom.out":F5e,to:L5e,"menu.file":O5e,"menu.edit":_5e,"menu.view":N5e,"menu.preferences":z5e,"menu.sign.in":H5e,"menu.sign.out":j5e,"become.a.sponsor":U5e,"zoom.to.selection":K5e,"zoom.to.fit":V5e,"zoom.to":G5e,"preferences.dark.mode":J5e,"preferences.focus.mode":W5e,"preferences.debug.mode":Y5e,"preferences.show.grid":q5e,"preferences.use.cad.selection":X5e,"preferences.keep.stylemenu.open":Z5e,"preferences.always.show.snaps":Q5e,"preferences.rotate.handles":ebe,"preferences.binding.handles":tbe,"preferences.clone.handles":nbe,undo:rbe,redo:ibe,cut:obe,copy:abe,paste:sbe,"copy.as":ube,"export.as":lbe,"select.all":cbe,"select.none":dbe,delete:hbe,"new.project":fbe,open:pbe,save:gbe,"save.as":mbe,"upload.media":vbe,page:ybe,search:Ebe,loading:Cbe,"export.background":bbe,transparent:wbe,auto:Sbe,light:xbe,dark:Abe,"menu.tools":kbe,"menu.transform":Ibe,"zoom.to.content":Dbe,"translation.link":Tbe,"copy.readonly.link":Pbe,"align.distribute":Bbe,"create.page":Mbe,"new.page":$be,"page.name":Rbe,duplicate:Fbe,cancel:Lbe,"copy.invite.link":Obe,"create.multiplayer.project":_be,"copy.multiplayer.project":Nbe,select:zbe,eraser:Hbe,draw:jbe,arrow:Ube,text:Kbe,sticky:Vbe,rectangle:Gbe,ellipse:Jbe,triangle:Wbe,line:Ybe,rotate:qbe,"lock.aspect.ratio":Xbe,"unlock.aspect.ratio":Zbe,group:Qbe,ungroup:ewe,"move.to.back":twe,"move.backward":nwe,"move.forward":rwe,"move.to.front":iwe,"reset.angle":owe,lock:awe,unlock:swe,"move.to.page":uwe,"flip.horizontal":lwe,"flip.vertical":cwe,move:dwe,"to.front":hwe,forward:fwe,backward:pwe,back:gwe,language:mwe,image:vwe,"keyboard.shortcuts":ywe,"dock.position":Ewe,bottom:Cwe,top:bwe,right:wwe,left:Swe,"align.left":xwe,"align.center.x":Awe,"align.right":kwe,"align.top":Iwe,"align.center.y":Dwe,"align.bottom":Twe,"distribute.x":Pwe,"distribute.y":Bwe,"stretch.x":Mwe,"stretch.y":$we,"dialog.save.firsttime":Rwe,"dialog.save.again":Fwe,"dialog.cancel":Lwe,"dialog.no":Owe,"dialog.yes":_we,"enter.file.name":Nwe},Hwe="Cor",jwe="Preencher",Uwe="Traço",Kwe="Tamanho",Vwe="Manter aberto",Gwe="Fonte",Jwe="Alinhamento",Wwe="Estilos",Ywe="Aumentar zoom",qwe="Diminuir zoom",Xwe="para",Zwe="Ficheiro",Qwe="Editar",e6e="Visualizar",t6e="Preferências",n6e="Entrar",r6e="Sair",i6e="Torne-se um patrocinador",o6e="Zoom na seleção",a6e="Zoom para caber",s6e="Zoom para",u6e="Modo Escuro",l6e="Modo Foco",c6e="Modo Debug",d6e="Mostrar Grelha",h6e="Usar seleção CAD",f6e="Manter Menu de Estilos Aberto",p6e="Mostrar Pontos de Ajuste",g6e="Controlo de Rotação",m6e="Controlo de Binds",v6e="Controlo de Clone",y6e="Desfazer",E6e="Refazer",C6e="Cortar",b6e="Copiar",w6e="Colar",S6e="Copiar como",x6e="Exportar como",A6e="Selecionar todos",k6e="Selecionar nenhum",I6e="Apagar",D6e="Novo Projeto",T6e="Abrir",P6e="Salvar",B6e="Salvar Como",M6e="Upload Média",$6e="Criar Página",R6e="Nova Página",F6e="Nome da Página",L6e="Duplicar",O6e="Cancelar",_6e="Copiar Link de Convite",N6e="Criar um Projeto Multi-Utilizador",z6e="Copiar num Projeto Multi-Utilizador",H6e="Selecionar",j6e="Borracha",U6e="Desenhar",K6e="Seta",V6e="Texto",G6e="Post-it",J6e="Retângulo",W6e="Elipse",Y6e="Triângulo",q6e="Linha",X6e="Rodar",Z6e="Trancar a Proporção",Q6e="Destrancar a Proporção",eSe="Agrupar",tSe="Desagrupar",nSe="Colocar no Fundo",rSe="Mover abaixo",iSe="Mover acima",oSe="Colocar à Frente",aSe="Reiniciar Ângulo",sSe="Trancar",uSe="Destrancar",lSe="Mover para Página",cSe="Inverter Horizontalmente",dSe="Inverter Verticalmente",hSe="Mover",fSe="Para Frente",pSe="Avançar",gSe="Recuar",mSe="Voltar",vSe="Língua",ySe={"style.menu.color":Hwe,"style.menu.fill":jwe,"style.menu.dash":Uwe,"style.menu.size":Kwe,"style.menu.keep.open":Vwe,"style.menu.font":Gwe,"style.menu.align":Jwe,styles:Wwe,"zoom.in":Ywe,"zoom.out":qwe,to:Xwe,"menu.file":Zwe,"menu.edit":Qwe,"menu.view":e6e,"menu.preferences":t6e,"menu.sign.in":n6e,"menu.sign.out":r6e,"become.a.sponsor":i6e,"zoom.to.selection":o6e,"zoom.to.fit":a6e,"zoom.to":s6e,"preferences.dark.mode":u6e,"preferences.focus.mode":l6e,"preferences.debug.mode":c6e,"preferences.show.grid":d6e,"preferences.use.cad.selection":h6e,"preferences.keep.stylemenu.open":f6e,"preferences.always.show.snaps":p6e,"preferences.rotate.handles":g6e,"preferences.binding.handles":m6e,"preferences.clone.handles":v6e,undo:y6e,redo:E6e,cut:C6e,copy:b6e,paste:w6e,"copy.as":S6e,"export.as":x6e,"select.all":A6e,"select.none":k6e,delete:I6e,"new.project":D6e,open:T6e,save:P6e,"save.as":B6e,"upload.media":M6e,"create.page":$6e,"new.page":R6e,"page.name":F6e,duplicate:L6e,cancel:O6e,"copy.invite.link":_6e,"create.multiplayer.project":N6e,"copy.multiplayer.project":z6e,select:H6e,eraser:j6e,draw:U6e,arrow:K6e,text:V6e,sticky:G6e,rectangle:J6e,ellipse:W6e,triangle:Y6e,line:q6e,rotate:X6e,"lock.aspect.ratio":Z6e,"unlock.aspect.ratio":Q6e,group:eSe,ungroup:tSe,"move.to.back":nSe,"move.backward":rSe,"move.forward":iSe,"move.to.front":oSe,"reset.angle":aSe,lock:sSe,unlock:uSe,"move.to.page":lSe,"flip.horizontal":cSe,"flip.vertical":dSe,move:hSe,"to.front":fSe,forward:pSe,backward:gSe,back:mSe,language:vSe},ESe="Цвет",CSe="Заполнять",bSe="Штрих",wSe="Размер",SSe="Держать открытым",xSe="Шрифт",ASe="Выравнивание",kSe="Стиль",ISe="Увеличить",DSe="Уменьшить",TSe="к",PSe="Инструменты",BSe="Изменение",MSe="Файл",$Se="Редактирование",RSe="Вид",FSe="Настройки",LSe="Войти",OSe="Выйти",_Se="Стать спонсором",NSe="Вернуться к содержимому",zSe="Масштабировать по выделению",HSe="Масштабировать по размеру экрана",jSe="Масштабировать к",USe="Тёмная тема",KSe="Минималистичный режим",VSe="Режим отладки",GSe="Показать сетку",JSe="Использовать CAD выделение",WSe="Держать меню стилей открытым",YSe="Всегда показывать привязки",qSe="Ручки вращения",XSe="Ручки привязки",ZSe="Ручки клонирования",QSe="Отменить",exe="Повторить",txe="Вырезать",nxe="Копировать",rxe="Вставить",ixe="Копировать как",oxe="Экспортировать как",axe="Выделить всё",sxe="Снять выделение",uxe="Удалить",lxe="Новый проект",cxe="Открыть",dxe="Сохранить",hxe="Сохранить как",fxe="Загрузить медиафайл",pxe="Создать страницу",gxe="Новая страница",mxe="Название страницы",vxe="Дублировать",yxe="Отменить",Exe="Скопировать ссылку приглашения",Cxe="Скопировать ссылку только для чтения",bxe="Создать многопользовательский проект",wxe="Скопировать в многопользовательский проект",Sxe="Выделить",xxe="Ластик",Axe="Рисовать",kxe="Стрелка",Ixe="Текст",Dxe="Заметка",Txe="Прямоугольник",Pxe="Эллипс",Bxe="Треугольник",Mxe="Линия",$xe="Повернуть",Rxe="Заблокировать соотношение сторон",Fxe="Разблокировать соотношение сторон",Lxe="Сгруппировать",Oxe="Разгруппировать",_xe="Переместить назад",Nxe="Переместить на задний план",zxe="Переместить вперёд",Hxe="Переместить на передний план",jxe="Сбросить угол",Uxe="Блокировать",Kxe="Разблокировать",Vxe="Выровнять / распределить",Gxe="Переместить на страницу",Jxe="Перевернуть горизонтально",Wxe="Перевернуть вертикально",Yxe="Переместить",qxe="На передний план",Xxe="Вперед",Zxe="На задний план",Qxe="Назад",e8e="Язык",t8e="Подробнее",n8e="Расположение панели инструментов",r8e="Снизу",i8e="Слева",o8e="Справа",a8e="Сверху",s8e="Страница",u8e="Сочетания клавиш",l8e="Поиск",c8e="Загрузка",d8e="Экспорт фона",h8e="Прозрачный",f8e="Авто",p8e="Светлый",g8e="Тёмный",m8e="Изображение",v8e="Выровнять по левому краю",y8e="Выровнять по центру горизонтально",E8e="Выровнять по правому краю",C8e="Выровнять по верхнему краю",b8e="Выровнять по центру вертикально",w8e="Выровнять по нижнему краю",S8e="Распределить горизонтально",x8e="Распределить вертикально",A8e="Растянуть горизонтально",k8e="Растянуть вертикально",I8e="Поделиться",D8e="Скопировать ссылку на текущую страницу",T8e="Скопировать ссылку на проект",P8e="Данные слишком велики, чтобы закодировать их в ссылке. Не включайте изображение или видео!",B8e="Сохранить текущий проект?",M8e="Сохранить изменения в текущем проекте?",$8e="Отменить",R8e="Нет",F8e="Да",L8e="Введите имя файла",O8e={"style.menu.color":ESe,"style.menu.fill":CSe,"style.menu.dash":bSe,"style.menu.size":wSe,"style.menu.keep.open":SSe,"style.menu.font":xSe,"style.menu.align":ASe,styles:kSe,"zoom.in":ISe,"zoom.out":DSe,to:TSe,"menu.tools":PSe,"menu.transform":BSe,"menu.file":MSe,"menu.edit":$Se,"menu.view":RSe,"menu.preferences":FSe,"menu.sign.in":LSe,"menu.sign.out":OSe,"become.a.sponsor":_Se,"zoom.to.content":NSe,"zoom.to.selection":zSe,"zoom.to.fit":HSe,"zoom.to":jSe,"preferences.dark.mode":USe,"preferences.focus.mode":KSe,"preferences.debug.mode":VSe,"preferences.show.grid":GSe,"preferences.use.cad.selection":JSe,"preferences.keep.stylemenu.open":WSe,"preferences.always.show.snaps":YSe,"preferences.rotate.handles":qSe,"preferences.binding.handles":XSe,"preferences.clone.handles":ZSe,undo:QSe,redo:exe,cut:txe,copy:nxe,paste:rxe,"copy.as":ixe,"export.as":oxe,"select.all":axe,"select.none":sxe,delete:uxe,"new.project":lxe,open:cxe,save:dxe,"save.as":hxe,"upload.media":fxe,"create.page":pxe,"new.page":gxe,"page.name":mxe,duplicate:vxe,cancel:yxe,"copy.invite.link":Exe,"copy.readonly.link":Cxe,"create.multiplayer.project":bxe,"copy.multiplayer.project":wxe,select:Sxe,eraser:xxe,draw:Axe,arrow:kxe,text:Ixe,sticky:Dxe,rectangle:Txe,ellipse:Pxe,triangle:Bxe,line:Mxe,rotate:$xe,"lock.aspect.ratio":Rxe,"unlock.aspect.ratio":Fxe,group:Lxe,ungroup:Oxe,"move.to.back":_xe,"move.backward":Nxe,"move.forward":zxe,"move.to.front":Hxe,"reset.angle":jxe,lock:Uxe,unlock:Kxe,"align.distribute":Vxe,"move.to.page":Gxe,"flip.horizontal":Jxe,"flip.vertical":Wxe,move:Yxe,"to.front":qxe,forward:Xxe,backward:Zxe,back:Qxe,language:e8e,"translation.link":t8e,"dock.position":n8e,bottom:r8e,left:i8e,right:o8e,top:a8e,page:s8e,"keyboard.shortcuts":u8e,search:l8e,loading:c8e,"export.background":d8e,transparent:h8e,auto:f8e,light:p8e,dark:g8e,image:m8e,"align.left":v8e,"align.center.x":y8e,"align.right":E8e,"align.top":C8e,"align.center.y":b8e,"align.bottom":w8e,"distribute.x":S8e,"distribute.y":x8e,"stretch.x":A8e,"stretch.y":k8e,share:I8e,"copy.current.page.link":D8e,"copy.project.link":T8e,"data.too.big.encoded":P8e,"dialog.save.firsttime":B8e,"dialog.save.again":M8e,"dialog.cancel":$8e,"dialog.no":R8e,"dialog.yes":F8e,"enter.file.name":L8e},_8e="Färg",N8e="Ifylld",z8e="Streck",H8e="Storlek",j8e="Håll stilmenyn öppen",U8e="Typsnitt",K8e="Justera",V8e="Utseende",G8e="Zooma in",J8e="Zooma ut",W8e="Till",Y8e="Verktyg",q8e="Transform",X8e="Arkiv",Z8e="Redigera",Q8e="Innehåll",e7e="Inställningar",t7e="Logga in",n7e="Logga ut",r7e="Bli en sponsor",i7e="Anpassa zoom till innehåll",o7e="Anpassa zoom till urval",a7e="Anpassa zoom till skärm",s7e="Zooma till",u7e="Mörkt läge",l7e="Fokusläge",c7e="Debugläge",d7e="Visa rutnät",h7e="Välj som i CAD-mjukvara",f7e="Håll stilmenyn öppen",p7e="Visa alltid fästpunkter",g7e="Rotationshandtag",m7e="Bindningshandtag",v7e="Kloningshandtag",y7e="Ångra",E7e="Gör om",C7e="Klipp ut",b7e="Kopiera",w7e="Klistra in",S7e="Kopiera som",x7e="Exportera till",A7e="Välj alla",k7e="Välj ingen",I7e="Radera",D7e="Nytt projekt",T7e="Öppna",P7e="Spara",B7e="Spara som",M7e="Ladda upp media",$7e="Skapa sida",R7e="Ny sida",F7e="Sidnamn",L7e="Duplicera",O7e="Avbryt",_7e="Kopiera länk med redigeringsrättigheter",N7e="Kopiera länk med läsrättigheter",z7e="Skapa ett Multiplayer-projekt",H7e="Kopiera till Multiplayer-project",j7e="Välj",U7e="Radera",K7e="Rita",V7e="Pil",G7e="Text",J7e="Klisterlapp",W7e="Rektangel",Y7e="Ellips",q7e="Triangel",X7e="Linje",Z7e="Rotera",Q7e="Lås storleksförhållande",eAe="Lås upp storleksförhållande",tAe="Gruppera",nAe="Avgruppera",rAe="Placera längst bak",iAe="Flytta bakåt",oAe="Flytta framåt",aAe="Placera längst fram",sAe="Återställ vinkel",uAe="Lås",lAe="Lås upp",cAe="Justera / Placera",dAe="Flytta till sida",hAe="Vänd horisontellt",fAe="Vänd vertikalt",pAe="Flytta",gAe="Till längst fram",mAe="Framåt",vAe="Bakåt",yAe="Till längst bak",EAe="Språk",CAe="Mer information",bAe="Dockningsposition",wAe="Botten",SAe="Vänster",xAe="Höger",AAe="Topp",kAe="Sida",IAe="Tangentbordsgenvägar",DAe="Sök",TAe="Laddar{dots}",PAe="Exportbakgrund",BAe="Transparent",MAe="Auto",$Ae="Ljus",RAe="Mörk",FAe="Github",LAe="Twitter",OAe="Discord",_Ae="Bild",NAe={"style.menu.color":_8e,"style.menu.fill":N8e,"style.menu.dash":z8e,"style.menu.size":H8e,"style.menu.keep.open":j8e,"style.menu.font":U8e,"style.menu.align":K8e,styles:V8e,"zoom.in":G8e,"zoom.out":J8e,to:W8e,"menu.tools":Y8e,"menu.transform":q8e,"menu.file":X8e,"menu.edit":Z8e,"menu.view":Q8e,"menu.preferences":e7e,"menu.sign.in":t7e,"menu.sign.out":n7e,"become.a.sponsor":r7e,"zoom.to.content":i7e,"zoom.to.selection":o7e,"zoom.to.fit":a7e,"zoom.to":s7e,"preferences.dark.mode":u7e,"preferences.focus.mode":l7e,"preferences.debug.mode":c7e,"preferences.show.grid":d7e,"preferences.use.cad.selection":h7e,"preferences.keep.stylemenu.open":f7e,"preferences.always.show.snaps":p7e,"preferences.rotate.handles":g7e,"preferences.binding.handles":m7e,"preferences.clone.handles":v7e,undo:y7e,redo:E7e,cut:C7e,copy:b7e,paste:w7e,"copy.as":S7e,"export.as":x7e,"select.all":A7e,"select.none":k7e,delete:I7e,"new.project":D7e,open:T7e,save:P7e,"save.as":B7e,"upload.media":M7e,"create.page":$7e,"new.page":R7e,"page.name":F7e,duplicate:L7e,cancel:O7e,"copy.invite.link":_7e,"copy.readonly.link":N7e,"create.multiplayer.project":z7e,"copy.multiplayer.project":H7e,select:j7e,eraser:U7e,draw:K7e,arrow:V7e,text:G7e,sticky:J7e,rectangle:W7e,ellipse:Y7e,triangle:q7e,line:X7e,rotate:Z7e,"lock.aspect.ratio":Q7e,"unlock.aspect.ratio":eAe,group:tAe,ungroup:nAe,"move.to.back":rAe,"move.backward":iAe,"move.forward":oAe,"move.to.front":aAe,"reset.angle":sAe,lock:uAe,unlock:lAe,"align.distribute":cAe,"move.to.page":dAe,"flip.horizontal":hAe,"flip.vertical":fAe,move:pAe,"to.front":gAe,forward:mAe,backward:vAe,back:yAe,language:EAe,"translation.link":CAe,"dock.position":bAe,bottom:wAe,left:SAe,right:xAe,top:AAe,page:kAe,"keyboard.shortcuts":IAe,search:DAe,loading:TAe,"export.background":PAe,transparent:BAe,auto:MAe,light:$Ae,dark:RAe,github:FAe,twitter:LAe,discord:OAe,image:_Ae},zAe="రంగు",HAe="నింపు",jAe="అడ్డ గీత",UAe="పరిమాణం",KAe="తెరిచి ఉంచు",VAe="అక్షరాకృతి",GAe="సరిపరచు",JAe="విధములు",WAe="దగ్గరగా చూపు",YAe="దూరంగా చూపు",qAe="వద్దకు",XAe="పరికరాలు",ZAe="మార్చు",QAe="ఫైల్",eke="పరిష్కరించు",tke="చూపు",nke="ఎంచుకొన్నవి",rke="ప్రవేశించు",ike="నిష్క్రమణ",oke="విరాళదారులు అవ్వండి",ake="విషయాన్నే చూపు",ske="ఎంచుకున్న విషయాన్నే చూపు",uke="సరిపెట్టి చూపు",lke="చూపు",cke="చీకటైన క్రమం",dke="తీక్షణ క్రమం",hke="తప్పులేరు క్రమం",fke="చట్రం చూపు",pke="CADని వాడు",gke="విధముల పత్తి తెరిచివుంచు",mke="ఎప్పుడూ దృశ్యభాగం చూపు",vke="హ్యాండిల్స్ తిప్పు",yke="యాండిల్స్ కట్టు",Eke="యాండిల్స్ నకలు",Cke="మార్పుని తిరుగగొట్టు",bke="మళ్ళీ మార్చు",wke="కత్తిరించు",Ske="నకలు",xke="అతికించు",Ake="నకలుప్రతిగా ఇక్కడికి",kke="ఎగుమతి ఇక్కడికి",Ike="అన్నీ ఎంపికచెయ్యి",Dke="ఎదీ ఎంపికచెయ్యవద్దు",Tke="తొలగించు",Pke="కొత్త ప్రాజెక్టు",Bke="తెరువు",Mke="దాయి",$ke="ఇలా దాయి",Rke="ఎగుమతి మాధ్యం",Fke="పుట కల్పించు",Lke="కొత్త పుట",Oke="పుట పేరు",_ke="మారుప్రతి",Nke="రద్దుచేయి",zke="అహ్వాన లింకు రాయి",Hke="మారనిప్రతి లింకు రాయి",jke="బహుకర్తల ప్రాజెక్టు కల్పించు",Uke="బహుకర్తల ప్రాజెక్టుకు రాయి",Kke="ఎంపికచెయ్యి",Vke="Eraser",Gke="గీయ్యి",Jke="బాణం",Wke="అక్షరములు",Yke="అతుక్కునే",qke="దీర్ఘచతురస్రం",Xke="దీర్ఘవృత్తం",Zke="త్రిభుజం",Qke="గీత",eIe="తిప్పు",tIe="ఆస్పెక్ట్ నిష్పత్తికి తాళంపెట్టు",nIe="ఆస్పెక్ట్ నిష్పత్తి తాళంతెరువు",rIe="గుంపుగా ఏర్పరచు",iIe="గుంపును చెదరగొట్టు",oIe="ఆఖరికి జరుపు",aIe="వెనుకకు జరుపు",sIe="ముందుకు జరుపు",uIe="మొదటికి జరుపు",lIe="కోణం రీసెట్",cIe="తాళం వెయ్యి",dIe="తాళం తియ్యి",hIe=" సరిపరచు/వెదజల్లు",fIe="పుటలోకి జరుపు",pIe="అడ్డంగా పల్టీ",gIe="నిలువుగా పల్టీ",mIe="జరుపు",vIe="మొదటికి",yIe="ముందుకు",EIe="వెనుకకు",CIe="ఆఖరికి",bIe="భాష",wIe="మరి కొన్ని విషయాలు",SIe="మంచ స్థానం",xIe="అడుగున",AIe="ఎడమవైపు",kIe="కుడివైపు",IIe="పైన",DIe="పుత",TIe="కీబోర్డ్ సత్వరమార్గం",PIe="వెతుకు",BIe="Loading{dots}",MIe="నేపథ్యం ఎగుమతి",$Ie="కాంతి భేద్యము",RIe="స్వయంకృతం",FIe="వెలుతురు",LIe="చీకటి",OIe="Github",_Ie="Twitter",NIe="Discord",zIe="చిత్రం",HIe="ఎడమవైపుకు కుదుర్చు",jIe="అడ్డంగా మధ్యలో కుదుర్చు",UIe="కుడివైపుకు కుదుర్చు",KIe="పైకి కుదుర్చు",VIe="నిలువుగా మధ్యలో కుదుర్చు",GIe="అడుగున కుదుర్చు",JIe="అడ్డంగా పంచు",WIe="నిలువుగా పంచు",YIe="అడ్డంగా లాగు",qIe="నిలువుగా లాగు",XIe="మీరు ఈ ప్రాజెక్ట్ భద్రపరచుకోవాలని అనుకుంటున్నారా?",ZIe="మీరు ఈ ప్రాజెక్ట్ భద్రపరచుకోవాలని అనుకుంటున్నారా?",QIe="రద్దుచెయ్యి",eDe="వద్దు",tDe="సరే",nDe="ఫైల్ పెరు చెప్పండి",rDe={"style.menu.color":zAe,"style.menu.fill":HAe,"style.menu.dash":jAe,"style.menu.size":UAe,"style.menu.keep.open":KAe,"style.menu.font":VAe,"style.menu.align":GAe,styles:JAe,"zoom.in":WAe,"zoom.out":YAe,to:qAe,"menu.tools":XAe,"menu.transform":ZAe,"menu.file":QAe,"menu.edit":eke,"menu.view":tke,"menu.preferences":nke,"menu.sign.in":rke,"menu.sign.out":ike,"become.a.sponsor":oke,"zoom.to.content":ake,"zoom.to.selection":ske,"zoom.to.fit":uke,"zoom.to":lke,"preferences.dark.mode":cke,"preferences.focus.mode":dke,"preferences.debug.mode":hke,"preferences.show.grid":fke,"preferences.use.cad.selection":pke,"preferences.keep.stylemenu.open":gke,"preferences.always.show.snaps":mke,"preferences.rotate.handles":vke,"preferences.binding.handles":yke,"preferences.clone.handles":Eke,undo:Cke,redo:bke,cut:wke,copy:Ske,paste:xke,"copy.as":Ake,"export.as":kke,"select.all":Ike,"select.none":Dke,delete:Tke,"new.project":Pke,open:Bke,save:Mke,"save.as":$ke,"upload.media":Rke,"create.page":Fke,"new.page":Lke,"page.name":Oke,duplicate:_ke,cancel:Nke,"copy.invite.link":zke,"copy.readonly.link":Hke,"create.multiplayer.project":jke,"copy.multiplayer.project":Uke,select:Kke,eraser:Vke,draw:Gke,arrow:Jke,text:Wke,sticky:Yke,rectangle:qke,ellipse:Xke,triangle:Zke,line:Qke,rotate:eIe,"lock.aspect.ratio":tIe,"unlock.aspect.ratio":nIe,group:rIe,ungroup:iIe,"move.to.back":oIe,"move.backward":aIe,"move.forward":sIe,"move.to.front":uIe,"reset.angle":lIe,lock:cIe,unlock:dIe,"align.distribute":hIe,"move.to.page":fIe,"flip.horizontal":pIe,"flip.vertical":gIe,move:mIe,"to.front":vIe,forward:yIe,backward:EIe,back:CIe,language:bIe,"translation.link":wIe,"dock.position":SIe,bottom:xIe,left:AIe,right:kIe,top:IIe,page:DIe,"keyboard.shortcuts":TIe,search:PIe,loading:BIe,"export.background":MIe,transparent:$Ie,auto:RIe,light:FIe,dark:LIe,github:OIe,twitter:_Ie,discord:NIe,image:zIe,"align.left":HIe,"align.center.x":jIe,"align.right":UIe,"align.top":KIe,"align.center.y":VIe,"align.bottom":GIe,"distribute.x":JIe,"distribute.y":WIe,"stretch.x":YIe,"stretch.y":qIe,"dialog.save.firsttime":XIe,"dialog.save.again":ZIe,"dialog.cancel":QIe,"dialog.no":eDe,"dialog.yes":tDe,"enter.file.name":nDe},iDe="สี",oDe="เติม",aDe="กรอบ",sDe="ขนาด",uDe="เปิดทิ้งไว้",lDe="แบบอักษร",cDe="จัดตำแหน่ง",dDe="รูปแบบ",hDe="ซูมเข้า",fDe="ซูมออก",pDe="ซูมไปที่",gDe="เครื่องมือ",mDe="แปลง",vDe="ไฟล์",yDe="แก้ไข",EDe="มุมมอง",CDe="การตั้งค่า",bDe="เข้าสู่ระบบ",wDe="ออกจากระบบ",SDe="ร่วมเป็นสปอนเซอร์",xDe="กลับไปยังเนื้อหา",ADe="ซูมไปยังส่วนที่เลือก",kDe="ซูมให้เต็มพอดี",IDe="ซูมไปที่",DDe="โหมดมืด",TDe="โหมดโฟกัส",PDe="โหมดดีบัก",BDe="แสดงตาราง",MDe="การเลือกแบบ CAD",$De="เปิดเมนูรูปแบบทิ้งไว้",RDe="แสดงสแนปตลอด",FDe="แสดงจุดจับการหมุน",LDe="แสดงหมายเลขอ้างอิง",ODe="แสดงตัวโคลน",_De="เลิกทำ",NDe="ทำซ้ำ",zDe="ตัด",HDe="คัดลอก",jDe="วาง",UDe="คัดลอกเป็น",KDe="ส่งออกเป็น",VDe="เลือกทั้งหมด",GDe="ยกเลิกสิ่งที่เลือก",JDe="ลบ",WDe="โปรเจกต์ใหม่",YDe="เปิด",qDe="บันทึก",XDe="บันทึกเป็น",ZDe="อัพโหลดมีเดีย",QDe="สร้างหน้า",eTe="หน้าใหม่",tTe="ชื่อหน้า",nTe="สำเนา",rTe="ยกเลิก",iTe="คัดลอกลิงก์เชิญ",oTe="คัดลอกลิงก์แบบให้อ่านอย่างเดียว",aTe="สร้างโปรเจกต์ผู้ใช้งานหลายคน",sTe="คัดลอกโปรเจกต์ผู้ใช้งานหลายคน",uTe="เลือก",lTe="ยางลบ",cTe="วาด",dTe="ลูกศร",hTe="ข้อความ",fTe="กระดาษโน๊ต",pTe="สี่เหลี่ยมผืนผ้า",gTe="วงรี",mTe="สามเหลี่ยม",vTe="เส้น",yTe="หมุน",ETe="ล็อคอัตราส่วนภาพ",CTe="ปลดล็อกอัตราส่วนภาพ",bTe="กลุ่ม",wTe="ยกเลิกกลุ่ม",STe="ย้ายไปด้านหลัง",xTe="ขยับถอยหลัง",ATe="ขยับไปหน้า",kTe="ย้ายไปด้านหน้า",ITe="รีเซ็ตมุม",DTe="ล็อค",TTe="ปลดล็อค",PTe="จัดตำแหน่ง / กระจาย",BTe="ย้ายไปยังหน้า",MTe="พลิกแนวนอน",$Te="พลิกแนวตั้ง",RTe="ย้าย",FTe="ไปยังด้านหน้า",LTe="ข้างหน้า",OTe="ข้างหลัง",_Te="ไปยังด้านหลัง",NTe="ภาษา",zTe="เรียนรู้เพิ่มเติม",HTe="ตำแหน่งแถบเครื่องมือ",jTe="ข้างล่าง",UTe="ข้างซ้าย",KTe="ข้างขวา",VTe="ข้างบน",GTe="หน้า",JTe="แป้นพิมพ์ลัด",WTe="ค้นหา",YTe="กำลังโหลด{dots}",qTe="ส่งออกพื้นหลัง",XTe="โปร่งใส",ZTe="อัตโนมัติ",QTe="สว่าง",ePe="มืด",tPe="Github",nPe="Twitter",rPe="Discord",iPe="ภาพ",oPe="จัดให้ชิดซ้าย",aPe="จัดให้อยู่กึ่งกลางแนวนอน",sPe="จัดให้ชิดขวา",uPe="จัดให้อยู่ด้านบน",lPe="จัดให้อยู่กึ่งกลางแนวตั้ง",cPe="จัดให้อยู่ด้านล่าง",dPe="กระจายแนวนอน",hPe="กระจายแนวตั้ง",fPe="ยืดแนวนอน",pPe="ยืดแนวตั้ง",gPe="คุณต้องการบันทึกโปรเจ็กต์ปัจจุบันของคุณหรือไม่?",mPe="คุณต้องการบันทึกการเปลี่ยนแปลงในโปรเจ็กต์ปัจจุบันของคุณหรือไม่?",vPe="ยกเลิก",yPe="ไม่",EPe="ใช่",CPe="กรอกชื่อไฟล์",bPe={"style.menu.color":iDe,"style.menu.fill":oDe,"style.menu.dash":aDe,"style.menu.size":sDe,"style.menu.keep.open":uDe,"style.menu.font":lDe,"style.menu.align":cDe,styles:dDe,"zoom.in":hDe,"zoom.out":fDe,to:pDe,"menu.tools":gDe,"menu.transform":mDe,"menu.file":vDe,"menu.edit":yDe,"menu.view":EDe,"menu.preferences":CDe,"menu.sign.in":bDe,"menu.sign.out":wDe,"become.a.sponsor":SDe,"zoom.to.content":xDe,"zoom.to.selection":ADe,"zoom.to.fit":kDe,"zoom.to":IDe,"preferences.dark.mode":DDe,"preferences.focus.mode":TDe,"preferences.debug.mode":PDe,"preferences.show.grid":BDe,"preferences.use.cad.selection":MDe,"preferences.keep.stylemenu.open":$De,"preferences.always.show.snaps":RDe,"preferences.rotate.handles":FDe,"preferences.binding.handles":LDe,"preferences.clone.handles":ODe,undo:_De,redo:NDe,cut:zDe,copy:HDe,paste:jDe,"copy.as":UDe,"export.as":KDe,"select.all":VDe,"select.none":GDe,delete:JDe,"new.project":WDe,open:YDe,save:qDe,"save.as":XDe,"upload.media":ZDe,"create.page":QDe,"new.page":eTe,"page.name":tTe,duplicate:nTe,cancel:rTe,"copy.invite.link":iTe,"copy.readonly.link":oTe,"create.multiplayer.project":aTe,"copy.multiplayer.project":sTe,select:uTe,eraser:lTe,draw:cTe,arrow:dTe,text:hTe,sticky:fTe,rectangle:pTe,ellipse:gTe,triangle:mTe,line:vTe,rotate:yTe,"lock.aspect.ratio":ETe,"unlock.aspect.ratio":CTe,group:bTe,ungroup:wTe,"move.to.back":STe,"move.backward":xTe,"move.forward":ATe,"move.to.front":kTe,"reset.angle":ITe,lock:DTe,unlock:TTe,"align.distribute":PTe,"move.to.page":BTe,"flip.horizontal":MTe,"flip.vertical":$Te,move:RTe,"to.front":FTe,forward:LTe,backward:OTe,back:_Te,language:NTe,"translation.link":zTe,"dock.position":HTe,bottom:jTe,left:UTe,right:KTe,top:VTe,page:GTe,"keyboard.shortcuts":JTe,search:WTe,loading:YTe,"export.background":qTe,transparent:XTe,auto:ZTe,light:QTe,dark:ePe,github:tPe,twitter:nPe,discord:rPe,image:iPe,"align.left":oPe,"align.center.x":aPe,"align.right":sPe,"align.top":uPe,"align.center.y":lPe,"align.bottom":cPe,"distribute.x":dPe,"distribute.y":hPe,"stretch.x":fPe,"stretch.y":pPe,"dialog.save.firsttime":gPe,"dialog.save.again":mPe,"dialog.cancel":vPe,"dialog.no":yPe,"dialog.yes":EPe,"enter.file.name":CPe},wPe="Renk",SPe="Doldur",xPe="Çizgi",APe="Boyut",kPe="Açık Tut",IPe="Yazı Tipi",DPe="Hizala",TPe="Stiller",PPe="Yakınlaştır",BPe="Uzaklaştır",MPe="",$Pe="Dosya",RPe="Düzenle",FPe="Görüntü",LPe="Tercihler",OPe="Giriş Yap",_Pe="Oturumu Kapat",NPe="Sponsor Ol",zPe="Seçime Yakınlaştır",HPe="Sığdırmak için Yakınlaştır",jPe="Yakınlaştır",UPe="Karanlık Mod",KPe="Odak Modu",VPe="Debug Modu",GPe="Izgarayı Göster",JPe="CAD Seçimi Kullan",WPe="Stil Menüsünü Açık Tut",YPe="Hiza Çizgilerini Hep Göster",qPe="Rotasyon Kontrolcüleri",XPe="Bağlama Kontrolcüleri",ZPe="Klon Kontrolcüleri",QPe="Geri Al",eBe="Yinele",tBe="Kes",nBe="Kopyala",rBe="Yapıştır",iBe="Olarak Kopyala",oBe="Olarak Dışarı Aktar",aBe="Hepsini Seç",sBe="Hiçbirini Seçme",uBe="Sil",lBe="Yeni Proje",cBe="Aç",dBe="Kaydet",hBe="Farklı Kaydet",fBe="Medya Yükle",pBe="Sayfa Oluştur",gBe="Yeni Sayfa",mBe="Sayfa İsmi",vBe="Kopya Oluştur",yBe="İptal",EBe="Davet Linkini Kopyala",CBe="Çok Oyunculu Proje Oluştur",bBe="Çok Oyunculu Projeye Kopyala",wBe="Seç",SBe="Silgi",xBe="Çizim",ABe="Ok",kBe="Yazı",IBe="Yapışkan",DBe="Dikdörtgen",TBe="Elips",PBe="Üçgen",BBe="Çizgi",MBe="Döndür",$Be="En Boy Oranını Kilitle",RBe="En Boy Oranı Kilidini Aç",FBe="Grupla",LBe="Gruplamayı Kaldır",OBe="Arkaya Taşı",_Be="En Arkaya Taşı",NBe="En Öne Taşı",zBe="Öne Taşı",HBe="Açıyı Sıfırla",jBe="Kilitle",UBe="Kilidini Aç",KBe="Sayfaya Taşı",VBe="Yatay Çevir",GBe="Dikey Çevir",JBe="Taşı",WBe="Öne",YBe="En Öne",qBe="En Arkaya",XBe="Arkaya",ZBe="Dil",QBe={"style.menu.color":wPe,"style.menu.fill":SPe,"style.menu.dash":xPe,"style.menu.size":APe,"style.menu.keep.open":kPe,"style.menu.font":IPe,"style.menu.align":DPe,styles:TPe,"zoom.in":PPe,"zoom.out":BPe,to:MPe,"menu.file":$Pe,"menu.edit":RPe,"menu.view":FPe,"menu.preferences":LPe,"menu.sign.in":OPe,"menu.sign.out":_Pe,"become.a.sponsor":NPe,"zoom.to.selection":zPe,"zoom.to.fit":HPe,"zoom.to":jPe,"preferences.dark.mode":UPe,"preferences.focus.mode":KPe,"preferences.debug.mode":VPe,"preferences.show.grid":GPe,"preferences.use.cad.selection":JPe,"preferences.keep.stylemenu.open":WPe,"preferences.always.show.snaps":YPe,"preferences.rotate.handles":qPe,"preferences.binding.handles":XPe,"preferences.clone.handles":ZPe,undo:QPe,redo:eBe,cut:tBe,copy:nBe,paste:rBe,"copy.as":iBe,"export.as":oBe,"select.all":aBe,"select.none":sBe,delete:uBe,"new.project":lBe,open:cBe,save:dBe,"save.as":hBe,"upload.media":fBe,"create.page":pBe,"new.page":gBe,"page.name":mBe,duplicate:vBe,cancel:yBe,"copy.invite.link":EBe,"create.multiplayer.project":CBe,"copy.multiplayer.project":bBe,select:wBe,eraser:SBe,draw:xBe,arrow:ABe,text:kBe,sticky:IBe,rectangle:DBe,ellipse:TBe,triangle:PBe,line:BBe,rotate:MBe,"lock.aspect.ratio":$Be,"unlock.aspect.ratio":RBe,group:FBe,ungroup:LBe,"move.to.back":OBe,"move.backward":_Be,"move.forward":NBe,"move.to.front":zBe,"reset.angle":HBe,lock:jBe,unlock:UBe,"move.to.page":KBe,"flip.horizontal":VBe,"flip.vertical":GBe,move:JBe,"to.front":WBe,forward:YBe,backward:qBe,back:XBe,language:ZBe},eMe="Колір",tMe="Заповнювати",nMe="Штрих",rMe="Розмір",iMe="Тримати відкритим",oMe="Шрифт",aMe="Вирівняти",sMe="Стиль",uMe="Збільшити",lMe="Зменшити",cMe="до",dMe="Файл",hMe="Редагування",fMe="Вигляд",pMe="Налаштування",gMe="Увійти",mMe="Вийти",vMe="Стати спонсором",yMe="Наблизити до виділення",EMe="Збільшити за розміром екрану",CMe="Наблизити до",bMe="Темна тема",wMe="Мінімалістичний режим",SMe="Режим налагодження",xMe="Показати сітку",AMe="Використовувати CAD виділення",kMe="Тримати меню стилів відкритим",IMe="Завжди показувати прив'язки",DMe="Ручки обертання",TMe="Ручки прив'язки",PMe="Ручки клонування",BMe="Скасувати",MMe="Повторити",$Me="Вирізати",RMe="Скопіювати",FMe="Вставити",LMe="Скопіювати як",OMe="Експортувати як",_Me="Обрати все",NMe="Зняти виділення",zMe="Видалити",HMe="Новий проект",jMe="Відкрити",UMe="Зберегти",KMe="Зберегти як",VMe="Завантажити медіа",GMe="Створити сторінку",JMe="Нова сторінка",WMe="Назва сторінки",YMe="Дублювати",qMe="Скасувати",XMe="Скопіювати посилання на запрошення",ZMe="Створити багатокористувацький проект",QMe="Скопіювати в багатокористувацький проект",e$e="Вибирати",t$e="Ластик",n$e="Малювати",r$e="Стрілка",i$e="Текст",o$e="Нотатка",a$e="Прямокутник",s$e="Еліпс",u$e="Трикутник",l$e=" Лінія",c$e="Повернути",d$e="Заблокувати співвідношення сторін",h$e=" Розблокувати співвідношення сторін",f$e="Згрупувати",p$e=" Розгрупувати",g$e="Перемістити назад",m$e="Перемістити на задній план",v$e="Перемістити вперед",y$e="Перемістити на передній план",E$e="Скидання кута",C$e="Блокування",b$e=" Розблокування",w$e="Перейти на сторінку",S$e="Перевернути горизонтально",x$e="Перевернути вертикально",A$e="Перемістити",k$e="На передній план",I$e=" Вперед",D$e="На задній план",T$e="Назад",P$e="Мова",B$e={"style.menu.color":eMe,"style.menu.fill":tMe,"style.menu.dash":nMe,"style.menu.size":rMe,"style.menu.keep.open":iMe,"style.menu.font":oMe,"style.menu.align":aMe,styles:sMe,"zoom.in":uMe,"zoom.out":lMe,to:cMe,"menu.file":dMe,"menu.edit":hMe,"menu.view":fMe,"menu.preferences":pMe,"menu.sign.in":gMe,"menu.sign.out":mMe,"become.a.sponsor":vMe,"zoom.to.selection":yMe,"zoom.to.fit":EMe,"zoom.to":CMe,"preferences.dark.mode":bMe,"preferences.focus.mode":wMe,"preferences.debug.mode":SMe,"preferences.show.grid":xMe,"preferences.use.cad.selection":AMe,"preferences.keep.stylemenu.open":kMe,"preferences.always.show.snaps":IMe,"preferences.rotate.handles":DMe,"preferences.binding.handles":TMe,"preferences.clone.handles":PMe,undo:BMe,redo:MMe,cut:$Me,copy:RMe,paste:FMe,"copy.as":LMe,"export.as":OMe,"select.all":_Me,"select.none":NMe,delete:zMe,"new.project":HMe,open:jMe,save:UMe,"save.as":KMe,"upload.media":VMe,"create.page":GMe,"new.page":JMe,"page.name":WMe,duplicate:YMe,cancel:qMe,"copy.invite.link":XMe,"create.multiplayer.project":ZMe,"copy.multiplayer.project":QMe,select:e$e,eraser:t$e,draw:n$e,arrow:r$e,text:i$e,sticky:o$e,rectangle:a$e,ellipse:s$e,triangle:u$e,line:l$e,rotate:c$e,"lock.aspect.ratio":d$e,"unlock.aspect.ratio":h$e,group:f$e,ungroup:p$e,"move.to.back":g$e,"move.backward":m$e,"move.forward":v$e,"move.to.front":y$e,"reset.angle":E$e,lock:C$e,unlock:b$e,"move.to.page":w$e,"flip.horizontal":S$e,"flip.vertical":x$e,move:A$e,"to.front":k$e,forward:I$e,backward:D$e,back:T$e,language:P$e},M$e="颜色",$$e="填充",R$e="边框",F$e="尺寸",L$e="保持常开",O$e="字体",_$e="对齐",N$e="样式",z$e="放大",H$e="缩小",j$e="缩放至",U$e="工具",K$e="转换",V$e="文件",G$e="编辑",J$e="视图",W$e="偏好",Y$e="登录",q$e="登出",X$e="搜索",Z$e="成为赞助者",Q$e="缩放选中",eRe="自适应缩放",tRe="缩放至",nRe="缩放至内容",rRe="暗黑模式",iRe="专注模式",oRe="调试模式",aRe="显示网格",sRe="使用 CAD 选择",uRe="保持样式菜单常开",lRe="总是展示对齐线",cRe="旋转手柄",dRe="捆绑手柄",hRe="克隆手柄",fRe="撤销",pRe="重做",gRe="剪切",mRe="复制",vRe="粘贴",yRe="复制为",ERe="导出为",CRe="选中全部",bRe="取消选中",wRe="删除",SRe="新项目",xRe="打开",ARe="保存",kRe="保存为",IRe="上传媒体文件",DRe="创建页面",TRe="新页面",PRe="页面名称",BRe="复制",MRe="取消",$Re="复制邀请链接",RRe="创建多人项目",FRe="复制到多人项目",LRe="选择",ORe="橡皮",_Re="画笔",NRe="箭头",zRe="文本",HRe="便利贴",jRe="矩形",URe="椭圆形",KRe="三角形",VRe="直线",GRe="旋转",JRe="锁定宽高比",WRe="解锁宽高比",YRe="分组",qRe="取消分组",XRe="置底",ZRe="下移一层",QRe="上移一层",eFe="置顶",tFe="重置旋转角度",nFe="锁定",rFe="解锁",iFe="移动到页面",oFe="水平翻转",aFe="垂直翻转",sFe="移动",uFe="置顶",lFe="上一层",cFe="下一层",dFe="置底",hFe="语言",fFe="键盘快捷键",pFe="了解更多",gFe="页面",mFe="锚点位置",vFe="下面",yFe="左面",EFe="右面",CFe="上面",bFe="导出背景色",wFe="透明",SFe="自动",xFe="明亮",AFe="暗黑",kFe="复制只读链接",IFe="图片",DFe="对齐 / 分散",TFe="您是否想保存当前的项目?",PFe="您是否想保存对当前项目的更改?",BFe="取消",MFe="否",$Fe="是",RFe={"style.menu.color":M$e,"style.menu.fill":$$e,"style.menu.dash":R$e,"style.menu.size":F$e,"style.menu.keep.open":L$e,"style.menu.font":O$e,"style.menu.align":_$e,styles:N$e,"zoom.in":z$e,"zoom.out":H$e,to:j$e,"menu.tools":U$e,"menu.transform":K$e,"menu.file":V$e,"menu.edit":G$e,"menu.view":J$e,"menu.preferences":W$e,"menu.sign.in":Y$e,"menu.sign.out":q$e,search:X$e,"become.a.sponsor":Z$e,"zoom.to.selection":Q$e,"zoom.to.fit":eRe,"zoom.to":tRe,"zoom.to.content":nRe,"preferences.dark.mode":rRe,"preferences.focus.mode":iRe,"preferences.debug.mode":oRe,"preferences.show.grid":aRe,"preferences.use.cad.selection":sRe,"preferences.keep.stylemenu.open":uRe,"preferences.always.show.snaps":lRe,"preferences.rotate.handles":cRe,"preferences.binding.handles":dRe,"preferences.clone.handles":hRe,undo:fRe,redo:pRe,cut:gRe,copy:mRe,paste:vRe,"copy.as":yRe,"export.as":ERe,"select.all":CRe,"select.none":bRe,delete:wRe,"new.project":SRe,open:xRe,save:ARe,"save.as":kRe,"upload.media":IRe,"create.page":DRe,"new.page":TRe,"page.name":PRe,duplicate:BRe,cancel:MRe,"copy.invite.link":$Re,"create.multiplayer.project":RRe,"copy.multiplayer.project":FRe,select:LRe,eraser:ORe,draw:_Re,arrow:NRe,text:zRe,sticky:HRe,rectangle:jRe,ellipse:URe,triangle:KRe,line:VRe,rotate:GRe,"lock.aspect.ratio":JRe,"unlock.aspect.ratio":WRe,group:YRe,ungroup:qRe,"move.to.back":XRe,"move.backward":ZRe,"move.forward":QRe,"move.to.front":eFe,"reset.angle":tFe,lock:nFe,unlock:rFe,"move.to.page":iFe,"flip.horizontal":oFe,"flip.vertical":aFe,move:sFe,"to.front":uFe,forward:lFe,backward:cFe,back:dFe,language:hFe,"keyboard.shortcuts":fFe,"translation.link":pFe,page:gFe,"dock.position":mFe,bottom:vFe,left:yFe,right:EFe,top:CFe,"export.background":bFe,transparent:wFe,auto:SFe,light:xFe,dark:AFe,"copy.readonly.link":kFe,image:IFe,"align.distribute":DFe,"dialog.save.firsttime":TFe,"dialog.save.again":PFe,"dialog.cancel":BFe,"dialog.no":MFe,"dialog.yes":$Fe},FFe="顏色",LFe="填充",OFe="虛線",_Fe="大小",NFe="保持開啟",zFe="字型",HFe="對齊",jFe="樣式",UFe="放大",KFe="縮小",VFe="至",GFe="檔案",JFe="編輯",WFe="檢視",YFe="選項",qFe="登入",XFe="登出",ZFe="成為贊助者",QFe="縮放至選取範圍",eLe="縮放至適當大小",tLe="縮放至",nLe="深色模式",rLe="專注模式",iLe="除錯模式",oLe="顯示網格",aLe="使用 CAD 選取",sLe="樣式選單保持開啟",uLe="永遠顯示對齊線",lLe="旋轉控點",cLe="綁定控點",dLe="複製控點",hLe="復原",fLe="取消復原",pLe="剪下",gLe="複製",mLe="貼上",vLe="複製成",yLe="匯出成",ELe="全選",CLe="取消選取",bLe="刪除",wLe="新專案",SLe="開啟",xLe="儲存",ALe="另存為",kLe="上傳媒體",ILe="建立頁面",DLe="新頁面",TLe="頁面名稱",PLe="複製",BLe="取消",MLe="複製邀請連結",$Le="複製唯讀連結",RLe="建立多人專案",FLe="複製至多人專案",LLe="選取",OLe="橡皮擦",_Le="手繪",NLe="箭頭",zLe="文字",HLe="便利貼",jLe="長方形",ULe="橢圓形",KLe="三角形",VLe="直線",GLe="旋轉",JLe="鎖定長寬比",WLe="解鎖長寬比",YLe="組成群組",qLe="取消群組",XLe="移到最下層",ZLe="下移一層",QLe="上移一層",eOe="移到最上層",tOe="重設角度",nOe="鎖定",rOe="解鎖",iOe="移至頁面",oOe="水平翻轉",aOe="垂直翻轉",sOe="移動",uOe="到最上層",lOe="到上一層",cOe="到下一層",dOe="到最下層",hOe="語言",fOe="了解詳情",pOe="工具列位置",gOe="下方",mOe="左側",vOe="右側",yOe="上方",EOe="頁面",COe={"style.menu.color":FFe,"style.menu.fill":LFe,"style.menu.dash":OFe,"style.menu.size":_Fe,"style.menu.keep.open":NFe,"style.menu.font":zFe,"style.menu.align":HFe,styles:jFe,"zoom.in":UFe,"zoom.out":KFe,to:VFe,"menu.file":GFe,"menu.edit":JFe,"menu.view":WFe,"menu.preferences":YFe,"menu.sign.in":qFe,"menu.sign.out":XFe,"become.a.sponsor":ZFe,"zoom.to.selection":QFe,"zoom.to.fit":eLe,"zoom.to":tLe,"preferences.dark.mode":nLe,"preferences.focus.mode":rLe,"preferences.debug.mode":iLe,"preferences.show.grid":oLe,"preferences.use.cad.selection":aLe,"preferences.keep.stylemenu.open":sLe,"preferences.always.show.snaps":uLe,"preferences.rotate.handles":lLe,"preferences.binding.handles":cLe,"preferences.clone.handles":dLe,undo:hLe,redo:fLe,cut:pLe,copy:gLe,paste:mLe,"copy.as":vLe,"export.as":yLe,"select.all":ELe,"select.none":CLe,delete:bLe,"new.project":wLe,open:SLe,save:xLe,"save.as":ALe,"upload.media":kLe,"create.page":ILe,"new.page":DLe,"page.name":TLe,duplicate:PLe,cancel:BLe,"copy.invite.link":MLe,"copy.readonly.link":$Le,"create.multiplayer.project":RLe,"copy.multiplayer.project":FLe,select:LLe,eraser:OLe,draw:_Le,arrow:NLe,text:zLe,sticky:HLe,rectangle:jLe,ellipse:ULe,triangle:KLe,line:VLe,rotate:GLe,"lock.aspect.ratio":JLe,"unlock.aspect.ratio":WLe,group:YLe,ungroup:qLe,"move.to.back":XLe,"move.backward":ZLe,"move.forward":QLe,"move.to.front":eOe,"reset.angle":tOe,lock:nOe,unlock:rOe,"move.to.page":iOe,"flip.horizontal":oOe,"flip.vertical":aOe,move:sOe,"to.front":uOe,forward:lOe,backward:cOe,back:dOe,language:hOe,"translation.link":fOe,"dock.position":pOe,bottom:gOe,left:mOe,right:vOe,top:yOe,page:EOe},xC=[{locale:"ar",label:"عربي",messages:Bie},{locale:"da",label:"Danish",messages:Gae},{locale:"de",label:"Deutsch",messages:xue},{locale:"en",label:"English",messages:Aue},{locale:"es",label:"Español",messages:mce},{locale:"fa",label:"فارسی",messages:Wde},{locale:"fr",label:"Français",messages:Ghe},{locale:"he",label:"עברית",messages:xpe},{locale:"it",label:"Italiano",messages:ume},{locale:"ja",label:"日本語",messages:z1e},{locale:"ko-kr",label:"한국어",messages:yve},{locale:"ne",label:"नेपाली",messages:gEe},{locale:"no",label:"Norwegian",messages:JCe},{locale:"pl",label:"Polski",messages:A5e},{locale:"pt",label:"Português - Europeu",messages:ySe},{locale:"pt-br",label:"Português - Brasil",messages:zwe},{locale:"ru",label:"Russian",messages:O8e},{locale:"sv",label:"Svenska",messages:NAe},{locale:"te",label:"తెలుగు",messages:rDe},{locale:"tr",label:"Türkçe",messages:QBe},{locale:"uk",label:"Ukrainian",messages:B$e},{locale:"zh-ch",label:"简体中文",messages:RFe},{locale:"zh-tw",label:"繁體中文 (台灣)",messages:COe},{locale:"th",label:"ภาษาไทย",messages:bPe}];xC.sort((e,t)=>e.localer.locale===e);return{locale:e,label:(t=n==null?void 0:n.label)!=null?t:e,messages:_(_({},Oye),n==null?void 0:n.messages)}}function wOe(e){return l.useMemo(()=>bOe(e??navigator.language.split(/[-_]/)[0]),[e])}var DT=l.createContext({}),TT=()=>{let e=l.useContext(DT);if(!e)throw new Error("useCtx must be inside a Provider with a value");return e},st=l.forwardRef((e,t)=>{var n=e,{onSelect:r,onClick:i,onDoubleClick:o,variant:a,children:s,isToolLocked:u=!1,disabled:d=!1,isActive:h=!1,onKeyDown:p,id:g}=n,m=$i(n,["onSelect","onClick","onDoubleClick","variant","children","isToolLocked","disabled","isActive","onKeyDown","id"]);return l.createElement(SOe,_({ref:t,isActive:h,variant:a,onClick:i,disabled:d,onPointerDown:r,onDoubleClick:o,onKeyDown:p,bp:Ci,id:g},m),l.createElement(Hi,null,s),u&&l.createElement(xOe,null))});function Xu(e){var t=e,{label:n,kbd:r,isLocked:i}=t,o=$i(t,["label","kbd","isLocked"]);let a=wt(),s=l.useCallback(()=>{a.toggleToolLock()},[]),u=l.useCallback(d=>{d.key===" "&&a.isForcePanning&&d.preventDefault()},[]);return l.createElement(jt,{label:n[0].toUpperCase()+n.slice(1),kbd:r},l.createElement(st,q(_({},o),{variant:"primary",isToolLocked:i&&o.isActive,onDoubleClick:s,onKeyDown:u})))}var Hi=fe("div",{position:"relative",height:"100%",width:"100%",backgroundColor:"$panel",borderRadius:"$2",margin:"0",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"$ui",color:"inherit",userSelect:"none",boxSizing:"border-box",border:"1px solid transparent","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent"}),SOe=fe("button",{position:"relative",color:"$text",fontSize:"$0",background:"none",margin:"0",padding:"$2",display:"flex",alignItems:"center",justifyContent:"center",outline:"none",cursor:"pointer",pointerEvents:"all",height:"40px",width:"40px",border:"1px solid $panel","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent",[`&:disabled ${Hi}`]:{opacity:.618},variants:{variant:{primary:{marginTop:"0"},icon:{[`& ${Hi}`]:{display:"grid","& > *":{gridRow:1,gridColumn:1}}},text:{width:"auto",[`& ${Hi}`]:{fontSize:"$1",padding:"0 $3",gap:"$3"}},circle:{padding:0,height:32,width:32,border:"none",[`& ${Hi}`]:{border:"1px solid $panelContrast",borderRadius:"100%",boxShadow:"$panel"},[`& ${Hi} > svg`]:{width:14,height:14}}},isActive:{true:{},false:{}},bp:{mobile:{padding:0},small:{}}},compoundVariants:[{variant:"primary",bp:"mobile",css:{height:40,width:36,[`& ${Hi} > svg`]:{width:16,height:16}}},{variant:"primary",bp:"small",css:{height:"44px",width:"44px",[`& ${Hi} > svg`]:{width:20,height:20}}},{isActive:!0,css:{[`${Hi}`]:{backgroundColor:"$selected",color:"$selectedContrast"}}},{isActive:!1,bp:"small",css:{[`&:hover:not(:disabled) ${Hi}`]:{backgroundColor:"$hover"},[`&:focus:not(:disabled) ${Hi}`]:{backgroundColor:"$hover"}}}]}),xOe=fe("div",{position:"absolute",width:10,height:10,backgroundColor:"$selected",borderRadius:"100%",bottom:-2,border:"2px solid $panel",zIndex:100}),AOe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,kOe=e=>e.settings.isDebugMode,IOe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.some(t=>e.document.pages[e.appState.currentPageId].shapes[t].children!==void 0),DOe=e=>e.stopPropagation(),TOe=({onBlur:e,children:t})=>{let n=Nu();return l.createElement(tY,{dir:"ltr"},l.createElement(nY,{dir:"ltr"},t),l.createElement(Ym,{container:n.current},l.createElement(rY,{onEscapeKeyDown:DOe,tabIndex:-1,onBlur:e,asChild:!0},l.createElement(_u,{id:"TD-ContextMenu"},l.createElement(POe,null)))))},POe=l.memo(function(){let e=wt(),t=Wn(),n=e.useStore(AOe),r=e.useStore(kOe),i=e.useStore(IOe),o=l.useCallback(()=>{e.flipHorizontal()},[e]),a=l.useCallback(()=>{e.flipVertical()},[e]),s=l.useCallback(()=>{e.duplicate()},[e]),u=l.useCallback(()=>{e.toggleLocked()},[e]),d=l.useCallback(()=>{e.group()},[e]),h=l.useCallback(()=>{e.moveToBack()},[e]),p=l.useCallback(()=>{e.moveBackward()},[e]),g=l.useCallback(()=>{e.moveForward()},[e]),m=l.useCallback(()=>{e.moveToFront()},[e]),v=l.useCallback(()=>{e.delete()},[e]),E=l.useCallback(()=>{e.cut()},[e]),w=l.useCallback(()=>{e.copy()},[e]),C=l.useCallback(()=>{e.paste()},[e]),b=l.useCallback(()=>{e.copyImage("svg",{scale:1,quality:1,transparentBackground:!1})},[e]),A=l.useCallback(()=>{e.copyImage("png",{scale:2,quality:1,transparentBackground:!0})},[e]),T=l.useCallback(()=>{e.undo()},[e]),B=l.useCallback(()=>{e.redo()},[e]),D=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("png",{scale:2,quality:1})}),[e]),I=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("jpeg",{scale:2,quality:1})}),[e]),M=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("webp",{scale:2,quality:1})}),[e]),O=l.useCallback(()=>Oe(this,null,function*(){e.exportImage("svg",{scale:1,quality:1})}),[e]),z=l.useCallback(()=>Oe(this,null,function*(){e.copyJson()}),[e]),K=l.useCallback(()=>Oe(this,null,function*(){e.exportJson()}),[e]),X=n>0,Z=n>1,pe=n>2;return l.createElement(l.Fragment,null,X?l.createElement(l.Fragment,null,l.createElement(It,{onClick:s,kbd:"#D",id:"TD-ContextMenu-Duplicate"},l.createElement(ge,{id:"duplicate"})),l.createElement(It,{onClick:o,kbd:"⇧H",id:"TD-ContextMenu-Flip_Horizontal"},l.createElement(ge,{id:"flip.horizontal"})),l.createElement(It,{onClick:a,kbd:"⇧V",id:"TD-ContextMenu-Flip_Vertical"},l.createElement(ge,{id:"flip.vertical"})),l.createElement(It,{onClick:u,kbd:"#⇧L",id:"TD-ContextMenu- Lock_Unlock"},l.createElement(ge,{id:"lock"})," / ",l.createElement(ge,{id:"unlock"})),(Z||i)&&l.createElement(Qt,null),Z&&l.createElement(It,{onClick:d,kbd:"#G",id:"TD-ContextMenu-Group"},l.createElement(ge,{id:"group"})),i&&l.createElement(It,{onClick:d,kbd:"#G",id:"TD-ContextMenu-Ungroup"},l.createElement(ge,{id:"ungroup"})),l.createElement(Qt,null),l.createElement(Jv,{label:t.formatMessage({id:"move"}),id:"TD-ContextMenu-Move"},l.createElement(It,{onClick:m,kbd:"⇧]",id:"TD-ContextMenu-Move-To_Front"},l.createElement(ge,{id:"to.front"})),l.createElement(It,{onClick:g,kbd:"]",id:"TD-ContextMenu-Move-Forward"},l.createElement(ge,{id:"forward"})),l.createElement(It,{onClick:p,kbd:"[",id:"TD-ContextMenu-Move-Backward"},l.createElement(ge,{id:"backward"})),l.createElement(It,{onClick:h,kbd:"⇧[",id:"TD-ContextMenu-Move-To_Back"},l.createElement(ge,{id:"back"}))),l.createElement(FOe,null),Z&&l.createElement(BOe,{hasTwoOrMore:Z,hasThreeOrMore:pe}),l.createElement(Qt,null),l.createElement(It,{onClick:E,kbd:"#X",id:"TD-ContextMenu-Cut"},l.createElement(ge,{id:"cut"})),l.createElement(It,{onClick:w,kbd:"#C",id:"TD-ContextMenu-Copy"},l.createElement(ge,{id:"copy"})),l.createElement(It,{onClick:C,kbd:"#V",id:"TD-ContextMenu-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(Qt,null),l.createElement(Jv,{label:`${t.formatMessage({id:"copy.as"})}...`,size:"small",id:"TD-ContextMenu-Copy-As"},l.createElement(It,{onClick:b,id:"TD-ContextMenu-Copy-as-SVG"},"SVG"),l.createElement(It,{onClick:A,id:"TD-ContextMenu-Copy-As-PNG"},"PNG"),r&&l.createElement(It,{onClick:z,id:"TD-ContextMenu-Copy_as_JSON"},"JSON")),l.createElement(Jv,{label:`${t.formatMessage({id:"export.as"})}...`,size:"small",id:"TD-ContextMenu-Export"},l.createElement(It,{onClick:O,id:"TD-ContextMenu-Export-SVG"},"SVG"),l.createElement(It,{onClick:D,id:"TD-ContextMenu-Export-PNG"},"PNG"),l.createElement(It,{onClick:I,id:"TD-ContextMenu-Export-JPG"},"JPG"),l.createElement(It,{onClick:M,id:"TD-ContextMenu-Export-WEBP"},"WEBP"),r&&l.createElement(It,{onClick:K,id:"TD-ContextMenu-Export-JSON"},"JSON")),l.createElement(Qt,null),l.createElement(It,{onClick:v,kbd:"⌫",id:"TD-ContextMenu-Delete"},l.createElement(ge,{id:"delete"}))):l.createElement(l.Fragment,null,l.createElement(It,{onClick:C,kbd:"#V",id:"TD-ContextMenu-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(It,{onClick:T,kbd:"#Z",id:"TD-ContextMenu-Undo"},l.createElement(ge,{id:"undo"})),l.createElement(It,{onClick:B,kbd:"#⇧Z",id:"TD-ContextMenu-Redo"},l.createElement(ge,{id:"redo"}))))});function BOe({hasThreeOrMore:e}){let t=wt(),n=l.useCallback(()=>{t.align("top")},[t]),r=l.useCallback(()=>{t.align("centerVertical")},[t]),i=l.useCallback(()=>{t.align("bottom")},[t]),o=l.useCallback(()=>{t.stretch("vertical")},[t]),a=l.useCallback(()=>{t.distribute("vertical")},[t]),s=l.useCallback(()=>{t.align("left")},[t]),u=l.useCallback(()=>{t.align("centerHorizontal")},[t]),d=l.useCallback(()=>{t.align("right")},[t]),h=l.useCallback(()=>{t.stretch("horizontal")},[t]),p=l.useCallback(()=>{t.distribute("horizontal")},[t]),g=Nu();return l.createElement(_E,null,l.createElement(kC,{id:"TD-ContextMenu-Align-Distribute-Trigger"},l.createElement(ge,{id:"align.distribute"})),l.createElement(Ym,{container:g.current},l.createElement(NE,{asChild:!0,sideOffset:4,alignOffset:-2},l.createElement(MOe,{numberOfSelected:e?"threeOrMore":"twoOrMore"},l.createElement(vo,{onClick:s,id:"TD-ContextMenu-Align_Distribute-AlignLeft"},l.createElement(Zk,null)),l.createElement(vo,{onClick:u,id:"TD-ContextMenu-Align_Distribute-AlignCenterHorizontal"},l.createElement(qk,null)),l.createElement(vo,{onClick:d,id:"TD-ContextMenu-Align_Distribute-AlignRight"},l.createElement(Qk,null)),l.createElement(vo,{onClick:h,id:"TD-ContextMenu-Align_Distribute-StretchHorizontal"},l.createElement(iI,null)),e&&l.createElement(vo,{onClick:p,id:"TD-ContextMenu-Align_Distribute-SpaceEvenlyHorizontal"},l.createElement(nI,null)),l.createElement(vo,{onClick:n,id:"TD-ContextMenu-Align_Distribute-AlignTop"},l.createElement(eI,null)),l.createElement(vo,{onClick:r,id:"TD-ContextMenu-Align_Distribute-AlignCenterVertical"},l.createElement(Xk,null)),l.createElement(vo,{onClick:i,id:"TD-ContextMenu-Align_Distribute-AlignBottom"},l.createElement(Yk,null)),l.createElement(vo,{onClick:o,id:"TD-ContextMenu-Align_Distribute-StretchVertical"},l.createElement(oI,null)),e&&l.createElement(vo,{onClick:a,id:"TD-ContextMenu-Align_Distribute-SpaceEvenlyVertical"},l.createElement(rI,null)),l.createElement(AC,{offset:13})))))}var MOe=fe(_u,{display:"grid",variants:{numberOfSelected:{threeOrMore:{gridTemplateColumns:"repeat(5, auto)"},twoOrMore:{gridTemplateColumns:"repeat(4, auto)"}}}}),$Oe=e=>e.appState.currentPageId,ROe=e=>e.document.pages;function FOe(){let e=wt(),t=e.useStore($Oe),n=e.useStore(ROe),r=Object.values(n).sort((o,a)=>(o.childIndex||0)-(a.childIndex||0)).filter(o=>o.id!==t),i=Nu();return r.length===0?null:l.createElement(_E,null,l.createElement(kC,null,l.createElement(ge,{id:"move.to.page"})),l.createElement(Ym,{container:i.current},l.createElement(NE,{sideOffset:4,alignOffset:-2,asChild:!0},l.createElement(_u,null,r.map(({id:o,name:a},s)=>l.createElement(It,{key:o,disabled:o===t,onClick:()=>e.moveToPage(o)},a||`Page ${s}`)),l.createElement(AC,{offset:13})))))}function Jv({children:e,label:t,size:n,id:r}){let i=Nu();return l.createElement(_E,null,l.createElement(kC,null,t),l.createElement(Ym,{container:i.current},l.createElement(NE,{sideOffset:4,alignOffset:-2,asChild:!0},l.createElement(_u,{size:n},e,l.createElement(AC,{offset:13})))))}var AC=fe(XW,{fill:"$panel"});function vo(e){var t=e,{onSelect:n}=t,r=$i(t,["onSelect"]);return l.createElement(Wk,{dir:"ltr",onSelect:n,asChild:!0},l.createElement(st,_({},r)))}var It=e=>{var t=e,{id:n}=t,r=$i(t,["id"]);return l.createElement(Wk,{asChild:!0,id:n},l.createElement(ur,_({},r)))},kC=e=>{var t=e,{id:n}=t,r=$i(t,["id"]);return l.createElement(iY,{asChild:!0,id:n},l.createElement(ur,_({hasArrow:!0},r)))},LOe=l.memo(TOe);function OOe({error:e,resetErrorBoundary:t}){let n=wt(),r=()=>{window.location.reload(),t()},i=()=>{let s=document.createElement("textarea");s.value=e.message,document.body.appendChild(s),s.select(),document.execCommand("copy"),s.remove()},o=()=>{n.saveProjectAs()},a=()=>{n.resetDocument(),t()};return l.createElement(_Oe,null,l.createElement(NOe,null,l.createElement("div",null,"We've encountered an error!"),l.createElement("pre",null,l.createElement("code",null,e.message)),l.createElement(zOe,null,l.createElement(ur,{onClick:i},"Copy Error"),l.createElement(ur,{onClick:r},"Refresh Page")),l.createElement(Qt,null),l.createElement("p",null,"Keep getting this error?"," ",l.createElement("a",{onClick:o,title:"Download your project"},"Download your project")," ","as a backup and then"," ",l.createElement("a",{onClick:a,title:"Reset the document"},"reset the document"),".")))}var _Oe=fe("div",{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"$canvas"}),NOe=fe("div",{backgroundColor:"$panel",border:"1px solid $panelContrast",padding:"$5",borderRadius:8,boxShadow:"$panel",maxWidth:320,color:"$text",fontFamily:"$ui",fontSize:"$2",textAlign:"center",display:"flex",flexDirection:"column",gap:"$3","& > pre":{marginTop:"$3",marginBottom:"$3",textAlign:"left",whiteSpace:"pre-wrap",backgroundColor:"$hover",padding:"$4",borderRadius:"$2",fontFamily:'"Menlo", "Monaco", monospace',fontWeight:500},"& p":{fontFamily:"$body",lineHeight:1.7,padding:"$5",margin:0},"& a":{color:"$text",cursor:"pointer",textDecoration:"underline"},"& hr":{marginLeft:"-$5",marginRight:"-$5"}}),zOe=fe("div",{display:"flex","& > button > div":{justifyContent:"center",textAlign:"center"}}),IC=fe("button",{position:"relative",height:"32px",width:"32px",backgroundColor:"$panel",borderRadius:"4px",padding:"0",margin:"0",outline:"none",border:"none",pointerEvents:"all",fontSize:"$0",color:"$text",cursor:"pointer",display:"grid",alignItems:"center",justifyContent:"center","& > *":{gridRow:1,gridColumn:1},"&:disabled":{opacity:"0.5"},"& > span":{width:"100%",height:"100%",display:"flex",alignItems:"center"},variants:{bp:{mobile:{backgroundColor:"transparent"},small:{"&:hover:not(:disabled)":{backgroundColor:"$hover"}}},size:{small:{height:32,width:32,"& svg:nth-of-type(1)":{height:"16px",width:"16px"}},medium:{height:44,width:44,"& svg:nth-of-type(1)":{height:"18px",width:"18px"}},large:{height:44,width:44,"& svg:nth-of-type(1)":{height:"20px",width:"20px"}}},isActive:{true:{color:"$selected"}}}});function HOe({onSelect:e}){return l.createElement(jOe,null,l.createElement(IC,{onClick:e},l.createElement(LY,null)))}var jOe=fe("div",{opacity:1,zIndex:100,backgroundColor:"transparent","& svg":{color:"$text"},"&:hover svg":{color:"$text"}}),UOe=e=>e.appState.isLoading;function KOe(){let e=wt().useStore(UOe);return l.createElement(VOe,{hidden:!e},l.createElement(ge,{id:"loading",values:{dots:"..."}}))}var VOe=fe("div",{position:"absolute",top:0,left:"50%",transform:"translate(-50%, 0)",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",padding:"8px 16px",fontFamily:"var(--fonts-ui)",fontSize:"var(--fontSizes-1)",boxShadow:"var(--shadows-panel)",backgroundColor:"white",zIndex:200,pointerEvents:"none","& > div > *":{pointerEvents:"all"},variants:{transform:{hidden:{transform:"translate(-50%, 100%)"},visible:{transform:"translate(-50%, 0%)"}}}});function GOe({children:e,onClose:t,container:n}){return l.createElement(lC,{container:n},l.createElement(QOe,null),l.createElement(e_e,{onKeyDown:r=>{switch(r.key){case"Escape":t==null||t();break}}},e))}var JOe=fe(kee,{marginBottom:20,color:"$text",fontSize:"$2",lineHeight:1.5,textAlign:"center",maxWidth:"62%",minWidth:0,alignSelf:"center"}),WOe=uC,YOe=GOe,qOe=JOe,AS=Lg,XOe=UD,ZOe=({container:e})=>{let{setDialogState:t,dialogState:n,onCancel:r,onNo:i,onYes:o}=TT(),a=Wn(),s={saveFirstTime:a.formatMessage({id:"dialog.save.firsttime"}),saveAgain:a.formatMessage({id:"dialog.save.again"})};return l.createElement(WOe,{open:n!==null},l.createElement(YOe,{onClose:()=>t(null),container:e},n&&l.createElement(qOe,null,s[n]),l.createElement("div",{style:{width:"100%",gap:"$6",display:"flex",justifyContent:"space-between"}},r&&l.createElement(XOe,{asChild:!0},l.createElement(D0,{css:{color:"$text"},onClick:()=>{r(),t(null)}},l.createElement(ge,{id:"dialog.cancel"}))),l.createElement("div",{style:{flexShrink:0}},i&&l.createElement(AS,{asChild:!0},l.createElement(D0,{onClick:()=>{i(),t(null)}},l.createElement(ge,{id:"dialog.no"}))),o&&l.createElement(AS,{asChild:!0},l.createElement(D0,{css:{backgroundColor:"#2F80ED",color:"White"},onClick:()=>{o(),t(null)}},l.createElement(ge,{id:"dialog.yes"})))))))},QOe=fe(l1,{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, .15)",pointerEvents:"all"});fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0});var e_e=fe(cC,{position:"fixed",font:"$ui",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"max-content",padding:"$3",pointerEvents:"all",backgroundColor:"$panel",borderRadius:"$3",display:"flex",flexDirection:"column",justifyContent:"center",fontFamily:"$ui",border:"1px solid $panelContrast",boxShadow:"$panel"}),D0=fe("button",{all:"unset",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"$2",padding:"0 15px",fontSize:"$1",lineHeight:1,fontWeight:"normal",height:36,color:"$text",cursor:"pointer",minWidth:48}),PT=l.forwardRef((e,t)=>{var n=e,{icon:r}=n,i=$i(n,["icon"]);return l.createElement(t_e,null,l.createElement(n_e,q(_({},i),{ref:t})),r?l.createElement(r_e,null,r):null)}),t_e=fe("div",{position:"relative",width:"100%",height:"min-content"}),n_e=fe("input",{color:"$text",border:"none",textAlign:"left",width:"100%",paddingLeft:"$3",paddingRight:"$6",backgroundColor:"$background",height:"32px",outline:"none",fontFamily:"$ui",fontSize:"$1","&:focus":{backgroundColor:"$hover"},borderRadius:"$2"}),r_e=fe(ao,{top:0,right:0,position:"absolute",paddingLeft:"$3",paddingRight:"$3",pointerEvents:"none",color:"$text"}),i_e=({isOpen:e,onClose:t})=>{let n=wt(),r=Nu(),i=Wn(),[o,a]=l.useState(n.document.name),s=l.useCallback(h=>{let p=h.target.value.trimStart();a(p)},[]);function u(h){h.stopPropagation()}let d=l.useCallback(h=>{switch(h.key){case"Enter":{n.saveProjectAs(o),t();break}case"Escape":{t();break}}},[]);return l.createElement(uC,{open:e},l.createElement(lC,{container:r.current},l.createElement(a_e,{onPointerDown:t}),l.createElement(o_e,{dir:"ltr",onKeyDown:u,onKeyUp:u},l.createElement(u_e,{placeholder:i.formatMessage({id:"enter.file.name"}),value:o,onChange:s,onKeyDown:d,icon:l.createElement(zE,null)}),l.createElement(s_e,null,l.createElement(Lg,{asChild:!0},l.createElement(D0,{onClick:t},l.createElement(ge,{id:"cancel"}))),l.createElement(Lg,{asChild:!0},l.createElement(D0,{css:{backgroundColor:"#2F80ED",color:"White"},onClick:()=>{let h=o.trim().replace(/\.tldr$/,"");n.saveProjectAs(h),t()}},l.createElement(ge,{id:"save"})))))))},o_e=fe(cC,{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",minWidth:300,maxWidth:"fit-content",maxHeight:"85vh",marginTop:"-5vh",pointerEvents:"all",backgroundColor:"$panel",padding:"$3",borderRadius:"$2",font:"$ui",zIndex:999999,"&:focus":{outline:"none"}}),a_e=fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0,zIndex:999998}),s_e=fe("div",{width:"100%",display:"flex",alignItems:"center",gap:8,justifyContent:"flex-end",marginTop:10}),u_e=fe(PT,{background:"$hover"});function tt(e){var t=e,{onSelect:n,id:r}=t,i=$i(t,["onSelect","id"]);return l.createElement(Xm,{dir:"ltr",asChild:!0,onSelect:n,id:r},l.createElement(ur,_({},i)))}var Ut=e=>e.preventDefault();function Vi({checked:e,disabled:t=!1,variant:n,onCheckedChange:r,kbd:i,id:o,children:a}){return l.createElement(kX,{dir:"ltr",onSelect:Ut,onCheckedChange:r,checked:e,disabled:t,asChild:!0,id:o},l.createElement(ur,{kbd:i,variant:n,hasIndicator:!0},a))}var Or=e=>e.stopPropagation();function Ol({sideOffset:e=4,alignOffset:t=0,children:n,align:r,variant:i,id:o,overflow:a=!1,side:s="bottom"}){let u=Nu();return l.createElement(AX,{container:u.current,dir:"ltr"},l.createElement(hI,{align:r,alignOffset:t,sideOffset:e,onEscapeKeyDown:Or,asChild:!0,id:o,side:s},l.createElement(l_e,{variant:i,overflow:a},n)))}var l_e=fe(_u,{width:"fit-content",height:"fit-content",minWidth:0,maxHeight:"100vh",overflowY:"auto",overflowX:"hidden","&::webkit-scrollbar":{display:"none"},"-ms-overflow-style":"none",scrollbarWidth:"none",variants:{variant:{horizontal:{flexDirection:"row"},menu:{minWidth:128}},overflow:{true:{maxHeight:"60vh"}}}});fe(DX,{backgroundColor:"$hover",height:1,marginTop:"$2",marginRight:"-$2",marginBottom:"$2",marginLeft:"-$2"});var gp=fe(fI,{height:"32px",width:"32px",backgroundColor:"$panel",borderRadius:"4px",padding:"0",margin:"0",display:"flex",alignItems:"center",justifyContent:"center",outline:"none",border:"none",pointerEvents:"all",cursor:"pointer",variants:{isActive:{true:{backgroundColor:"$selected",color:"white"},false:{}},bp:{mobile:{},small:{}}},compoundVariants:[{isActive:!1,bp:"small",css:{"&:focus":{backgroundColor:"$hover"},"&:hover:not(:disabled)":{backgroundColor:"$hover"}}}]});function ru({children:e,size:t,overflow:n=!1,disabled:r=!1,label:i,id:o}){return l.createElement(PX,{key:o},l.createElement(BX,{dir:"ltr",asChild:!0},l.createElement(ur,{disabled:r,hasArrow:!0},i)),l.createElement(MX,{asChild:!0,sideOffset:4,alignOffset:-4},l.createElement(_u,{size:t,overflow:n},e,l.createElement(TX,{offset:13}))))}function BT(e){var t=e,{id:n,children:r}=t,i=$i(t,["id","children"]);return l.createElement(Fl,{asChild:!0,id:n},l.createElement(st,_({},i),r))}var c_e=e=>e.settings.dockPosition,d_e=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,h_e=e=>{let t=e.document.pages[e.appState.currentPageId],{selectedIds:n}=e.document.pageStates[e.appState.currentPageId];return n.every(r=>t.shapes[r].isLocked)},f_e=e=>{let t=e.document.pages[e.appState.currentPageId],{selectedIds:n}=e.document.pageStates[e.appState.currentPageId];return n.every(r=>t.shapes[r].isAspectRatioLocked)},p_e=e=>{let t=e.document.pages[e.appState.currentPageId],n=e.document.pageStates[e.appState.currentPageId].selectedIds.map(r=>t.shapes[r]);return n.every(r=>r.children!==void 0||r.parentId===n[0].parentId&&n[0].parentId!==e.appState.currentPageId)},g_e=e=>{let{selectedIds:t}=e.document.pageStates[e.appState.currentPageId];return t.length>0},m_e=e=>{let{selectedIds:t}=e.document.pageStates[e.appState.currentPageId];return t.length>1};function v_e(){let e=wt(),t=Wn(),n=e.useStore(h_e),r=e.useStore(f_e),i=e.useStore(p_e),o=e.useStore(g_e),a=e.useStore(m_e),s=e.useStore(d_e),u=e.useStore(c_e),d=s>1,h=s>2,p=l.useCallback(()=>{e.rotate()},[e]),g=l.useCallback(()=>{e.duplicate()},[e]),m=l.useCallback(()=>{e.toggleLocked()},[e]),v=l.useCallback(()=>{e.toggleAspectRatioLocked()},[e]),E=l.useCallback(()=>{e.group()},[e]),w=l.useCallback(()=>{e.moveToBack()},[e]),C=l.useCallback(()=>{e.moveBackward()},[e]),b=l.useCallback(()=>{e.moveForward()},[e]),A=l.useCallback(()=>{e.moveToFront()},[e]),T=l.useCallback(()=>{e.setShapeProps({rotation:0})},[e]),B=l.useCallback(()=>{e.align("top")},[e]),D=l.useCallback(()=>{e.align("centerVertical")},[e]),I=l.useCallback(()=>{e.align("bottom")},[e]),M=l.useCallback(()=>{e.stretch("vertical")},[e]),O=l.useCallback(()=>{e.distribute("vertical")},[e]),z=l.useCallback(()=>{e.align("left")},[e]),K=l.useCallback(()=>{e.align("centerHorizontal")},[e]),X=l.useCallback(()=>{e.align("right")},[e]),Z=l.useCallback(()=>{e.stretch("horizontal")},[e]),pe=l.useCallback(()=>{e.distribute("horizontal")},[e]),me=l.useCallback(Ce=>{e.setMenuOpen(Ce)},[e]);return l.createElement(Lu,{dir:"ltr",onOpenChange:me},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Tools-Dots"},l.createElement(st,{variant:"circle"},l.createElement(_Y,null))),l.createElement(Ol,{sideOffset:16,side:u==="bottom"||u==="top"?"top":u},l.createElement(l.Fragment,null,l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"duplicate"}),kbd:"#D",id:"TD-Tools-Copy"},l.createElement(st,{disabled:!o,onClick:g},l.createElement(PY,null))),l.createElement(jt,{label:t.formatMessage({id:"rotate"}),id:"TD-Tools-Rotate"},l.createElement(st,{disabled:!o,onClick:p},l.createElement(pq,null))),l.createElement(jt,{label:t.formatMessage({id:n?"unlock":"lock"}),kbd:"#L",id:"TD-Tools-Lock"},l.createElement(st,{disabled:!o,onClick:m},n?l.createElement(XY,null):l.createElement(QY,null))),l.createElement(jt,{label:t.formatMessage({id:r?"unlock.aspect.ratio":"lock.aspect.ratio"}),id:"TD-Tools-AspectRatio"},l.createElement(st,{disabled:!o,onClick:v},r?l.createElement(CY,null):l.createElement(wY,null))),l.createElement(jt,{label:t.formatMessage({id:"group"}),kbd:"#G",id:"TD-Tools-Group"},l.createElement(st,{disabled:!o||!i&&!a,onClick:E},l.createElement(UY,null)))),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"move.to.back"}),kbd:"#⇧[",id:"TD-Tools-PinBottom"},l.createElement(st,{disabled:!o,onClick:w},l.createElement(aq,null))),l.createElement(jt,{label:t.formatMessage({id:"move.backward"}),kbd:"#[",id:"TD-Tools-ArrowDown"},l.createElement(st,{disabled:!o,onClick:C},l.createElement(pY,null))),l.createElement(jt,{label:t.formatMessage({id:"move.forward"}),kbd:"#]",id:"TD-Tools-ArrowUp"},l.createElement(st,{disabled:!o,onClick:b},l.createElement(yY,null))),l.createElement(jt,{label:t.formatMessage({id:"move.to.front"}),kbd:"#⇧]",id:"TD-Tools-PinTop"},l.createElement(st,{disabled:!o,onClick:A},l.createElement(uq,null))),l.createElement(jt,{label:t.formatMessage({id:"reset.angle"}),id:"TD-Tools-ResetAngle"},l.createElement(st,{disabled:!o,onClick:T},l.createElement(hY,null)))),l.createElement(Qt,null),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"align.left"}),id:"TD-Tools-AlignLeft"},l.createElement(st,{disabled:!d,onClick:z},l.createElement(Zk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.center.x"}),id:"TD-Tools-AlignCenterHorizontal"},l.createElement(st,{disabled:!d,onClick:K},l.createElement(qk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.right"}),id:"TD-Tools-AlignRight"},l.createElement(st,{disabled:!d,onClick:X},l.createElement(Qk,null))),l.createElement(jt,{label:t.formatMessage({id:"stretch.x"}),id:"TD-Tools-StretchHorizontal"},l.createElement(st,{disabled:!d,onClick:Z},l.createElement(iI,null))),l.createElement(jt,{label:t.formatMessage({id:"distribute.x"}),id:"TD-Tools-SpaceEvenlyHorizontal"},l.createElement(st,{disabled:!h,onClick:pe},l.createElement(nI,null)))),l.createElement(mp,null,l.createElement(jt,{label:t.formatMessage({id:"align.top"}),id:"TD-Tools-AlignTop"},l.createElement(st,{disabled:!d,onClick:B},l.createElement(eI,null))),l.createElement(jt,{label:t.formatMessage({id:"align.center.y"}),id:"TD-Tools-AlignCenterVertical"},l.createElement(st,{disabled:!d,onClick:D},l.createElement(Xk,null))),l.createElement(jt,{label:t.formatMessage({id:"align.bottom"}),id:"TD-Tools-AlignBottom"},l.createElement(st,{disabled:!d,onClick:I},l.createElement(Yk,null))),l.createElement(jt,{label:t.formatMessage({id:"stretch.y"}),id:"TD-Tools-StretchVertical"},l.createElement(st,{disabled:!d,onClick:M},l.createElement(oI,null))),l.createElement(jt,{label:t.formatMessage({id:"distribute.y"}),id:"TD-Tools-SpaceEvenlyVertical"},l.createElement(st,{disabled:!h,onClick:O},l.createElement(rI,null)))))))}var mp=fe("div",{position:"relative",display:"flex",width:"100%",background:"none",border:"none",cursor:"pointer",outline:"none",alignItems:"center",justifyContent:"flex-start",padding:0}),y_e=e=>e.appState.isEmptyCanvas&&Object.keys(e.document.pages[e.appState.currentPageId].shapes).length>0,E_e=e=>e.settings.isDebugMode,C_e=e=>e.settings.dockPosition,b_e=l.memo(function(){let e=wt(),t=e.useStore(y_e),n=e.useStore(C_e),r=e.useStore(E_e),i={bottom:n==="bottom"&&r?120:n==="bottom"?80:r?60:20,left:"50%",transform:"translate(-50%,0)"};return t?l.createElement(w_e,{id:"TD-Tools-Back_to_content",style:_({},i)},l.createElement(ur,{onClick:e.zoomToContent},l.createElement(ge,{id:"zoom.to.content"}))):null}),w_e=fe(_u,{pointerEvents:"all",width:"fit-content",minWidth:0,position:"fixed",bottom:0});function kS(e){let t=e,{size:n=16}=t,r=$i(t,["size"]);return l.createElement("svg",_({width:24,height:24},r),l.createElement("circle",{cx:12,cy:12,r:n/2}))}function S_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:50.26548*.1}))}var x_e=`${50.26548*.025} ${50.26548*.1}`;function A_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:x_e}))}function k_e(){return l.createElement("svg",{width:"24",height:"24",viewBox:"1 1.5 21 22",fill:"currentColor",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M10.0162 19.2768C10.0162 19.2768 9.90679 19.2517 9.6879 19.2017C9.46275 19.1454 9.12816 19.0422 8.68413 18.8921C8.23384 18.7358 7.81482 18.545 7.42707 18.3199C7.03307 18.101 6.62343 17.7883 6.19816 17.3818C5.77289 16.9753 5.33511 16.3718 4.88482 15.5713C4.43453 14.7645 4.1531 13.8545 4.04053 12.8414C3.92795 11.822 4.04991 10.8464 4.40639 9.91451C4.76286 8.98266 5.39452 8.10084 6.30135 7.26906C7.21444 6.44353 8.29325 5.83377 9.5378 5.43976C10.7823 5.05202 11.833 4.92068 12.6898 5.04576C13.5466 5.16459 14.3878 5.43664 15.2133 5.86191C16.0388 6.28718 16.7768 6.8688 17.4272 7.60678C18.0714 8.34475 18.5404 9.21406 18.8344 10.2147C19.1283 11.2153 19.1721 12.2598 18.9657 13.348C18.7593 14.4299 18.2872 15.4337 17.5492 16.3593C16.8112 17.2849 15.9263 18.0072 14.8944 18.5263C13.8624 19.0391 12.9056 19.3174 12.0238 19.3612C11.142 19.405 10.2101 19.2705 9.22823 18.9578C8.24635 18.6451 7.35828 18.151 6.56402 17.4756C5.77601 16.8002 6.08871 16.8658 7.50212 17.6726C8.90927 18.4731 10.1444 18.8484 11.2076 18.7983C12.2645 18.7545 13.2965 18.4825 14.3034 17.9822C15.3102 17.4819 16.1264 16.8221 16.7518 16.0028C17.3772 15.1835 17.7681 14.3111 17.9244 13.3855C18.0808 12.4599 18.0401 11.5781 17.8025 10.74C17.5586 9.902 17.1739 9.15464 16.6486 8.49797C16.1233 7.8413 15.2289 7.27844 13.9656 6.80939C12.7086 6.34034 11.4203 6.20901 10.1007 6.41539C8.78732 6.61552 7.69599 7.06893 6.82669 7.77564C5.96363 8.48859 5.34761 9.26409 4.97863 10.1021C4.60964 10.9402 4.45329 11.8376 4.50958 12.7945C4.56586 13.7513 4.79101 14.6238 5.18501 15.4118C5.57276 16.1998 5.96363 16.8002 6.35764 17.2129C6.75164 17.6257 7.13313 17.9509 7.50212 18.1886C7.87736 18.4325 8.28074 18.642 8.71227 18.8171C9.15005 18.9922 9.47839 19.111 9.69728 19.1736C9.91617 19.2361 10.0256 19.2705 10.0256 19.2768H10.0162Z",strokeWidth:"2"}))}function I_e(){return l.createElement("svg",{width:"24",height:"24",stroke:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("circle",{cx:12,cy:12,r:8,fill:"none",strokeWidth:2,strokeLinecap:"round"}))}function D_e(e){return l.createElement("svg",_({width:18,height:18,viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 4.656a.5.5 0 01.5-.5h9.7a.5.5 0 010 1H2.5a.5.5 0 01-.5-.5z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.272 3a.578.578 0 00-.578.578v.578h3.311v-.578A.578.578 0 008.428 3H6.272zm3.733 1.156v-.578A1.578 1.578 0 008.428 2H6.272a1.578 1.578 0 00-1.578 1.578v.578H3.578a.5.5 0 00-.5.5V12.2a1.578 1.578 0 001.577 1.578h5.39a1.578 1.578 0 001.577-1.578V4.656a.5.5 0 00-.5-.5h-1.117zm-5.927 1V12.2a.578.578 0 00.577.578h5.39a.578.578 0 00.577-.578V5.156H4.078z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.272 6.85a.5.5 0 01.5.5v3.233a.5.5 0 11-1 0V7.35a.5.5 0 01.5-.5zM8.428 6.85a.5.5 0 01.5.5v3.233a.5.5 0 11-1 0V7.35a.5.5 0 01.5-.5z"}))}function IS(e){var t=e,{flipHorizontal:n}=t,r=$i(t,["flipHorizontal"]);return l.createElement("svg",_({width:24,height:24,viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"scale(-1, 1)":"scale(1, 1)"}},r),l.createElement("path",{d:"M10.6707 8.5081C10.6707 10.1923 9.3004 11.5625 7.61631 11.5625H6.5351C6.35593 11.5625 6.21074 11.4173 6.21074 11.2382V11.13C6.21074 10.9508 6.35591 10.8057 6.5351 10.8057H7.61631C8.88313 10.8057 9.91387 9.77492 9.91387 8.5081C9.91387 7.24128 8.88313 6.21054 7.61631 6.21054H5.62155L6.99534 7.58433C7.14289 7.73183 7.14289 7.97195 6.99534 8.11944C6.85216 8.26251 6.60298 8.2623 6.46013 8.11944L4.44045 6.09971C4.36898 6.02824 4.32959 5.93321 4.32959 5.8321C4.32959 5.73106 4.36898 5.63598 4.44045 5.56454L6.46024 3.54472C6.60309 3.40176 6.85248 3.40176 6.99535 3.54472C7.14291 3.69218 7.14291 3.93234 6.99535 4.07979L5.62156 5.45368H7.61631C9.3004 5.45368 10.6707 6.82393 10.6707 8.5081Z"}))}function T_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M12.4239 4.62C13.3572 4.62 14.1572 4.73333 14.8239 4.96C15.4906 5.17333 15.9772 5.43333 16.2839 5.74C16.3639 5.82 16.4039 5.94 16.4039 6.1V8.86H14.0639C13.9172 8.86 13.8439 8.78666 13.8439 8.64V7.26C13.4306 7.12666 12.9572 7.06 12.4239 7.06C11.6506 7.06 11.0639 7.18 10.6639 7.42C10.2639 7.66 10.0639 8.04666 10.0639 8.58V9C10.0639 9.38666 10.1639 9.69333 10.3639 9.92C10.5772 10.1333 11.0306 10.3467 11.7239 10.56L13.6439 11.14C14.4706 11.38 15.1172 11.66 15.5839 11.98C16.0506 12.3 16.3772 12.68 16.5639 13.12C16.7639 13.5467 16.8639 14.0733 16.8639 14.7V15.62C16.8639 16.7933 16.4039 17.7133 15.4839 18.38C14.5639 19.0467 13.2839 19.38 11.6439 19.38C10.6706 19.38 9.79723 19.2867 9.0239 19.1C8.2639 18.9133 7.71056 18.6533 7.3639 18.32C7.3239 18.28 7.29056 18.24 7.2639 18.2C7.25056 18.1467 7.2439 18.06 7.2439 17.94V15.74H7.6239C8.2239 16.1533 8.85056 16.4533 9.5039 16.64C10.1572 16.8267 10.9306 16.92 11.8239 16.92C12.6506 16.92 13.2506 16.7867 13.6239 16.52C14.0106 16.2533 14.2039 15.9333 14.2039 15.56V14.88C14.2039 14.6667 14.1639 14.48 14.0839 14.32C14.0172 14.16 13.8706 14.0133 13.6439 13.88C13.4172 13.7467 13.0572 13.6067 12.5639 13.46L10.6639 12.88C9.7839 12.6133 9.11056 12.3 8.6439 11.94C8.17723 11.58 7.85056 11.18 7.6639 10.74C7.49056 10.3 7.4039 9.83333 7.4039 9.34V8.38C7.4039 7.64666 7.61056 7 8.0239 6.44C8.43723 5.88 9.01723 5.44 9.7639 5.12C10.5239 4.78666 11.4106 4.62 12.4239 4.62Z"}))}function P_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M8.16191 19H5.68191C5.53525 19 5.46191 18.9267 5.46191 18.78V5H8.76191C8.88191 5 8.97525 5.03333 9.04191 5.1C9.10858 5.15333 9.17525 5.27333 9.24191 5.46C9.72191 6.59333 10.1686 7.7 10.5819 8.78C11.0086 9.84667 11.4352 10.98 11.8619 12.18H12.1619C12.6019 10.9667 13.0352 9.79333 13.4619 8.66C13.8886 7.52667 14.3552 6.30667 14.8619 5H18.3219C18.4686 5 18.5419 5.07333 18.5419 5.22V19H16.0619C15.9152 19 15.8419 18.9267 15.8419 18.78V16.26C15.8419 15.5267 15.8486 14.8133 15.8619 14.12C15.8886 13.4267 15.9286 12.6867 15.9819 11.9C16.0486 11.1 16.1419 10.1933 16.2619 9.18H15.9019C15.4352 10.3533 14.9486 11.5667 14.4419 12.82C13.9486 14.06 13.4819 15.2333 13.0419 16.34H11.1019C11.0619 16.34 11.0152 16.3333 10.9619 16.32C10.9219 16.2933 10.8886 16.2467 10.8619 16.18C10.4619 15.18 10.0086 14.06 9.50191 12.82C9.00858 11.58 8.53525 10.3667 8.08191 9.18H7.70191C7.83525 10.18 7.93525 11.0733 8.00191 11.86C8.06858 12.6467 8.10858 13.3933 8.12191 14.1C8.14858 14.8067 8.16191 15.5267 8.16191 16.26V19Z"}))}function B_e(e){return l.createElement("svg",_({width:24,height:24,viewBox:"-2 -2 28 28",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},e),l.createElement("path",{d:"M7.68191 19C7.53525 19 7.46191 18.9267 7.46191 18.78V5H10.1219C10.2686 5 10.3419 5.07333 10.3419 5.22V16.56H13.4419V15.02H15.7619C15.9086 15.02 15.9819 15.0933 15.9819 15.24V19H7.68191Z"}))}function M_e(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M1.72838 9.33987L8.84935 2.34732C9.23874 1.96494 9.86279 1.96539 10.2516 2.34831L13.5636 5.60975C13.9655 6.00555 13.9607 6.65526 13.553 7.04507L8.13212 12.2278C7.94604 12.4057 7.69851 12.505 7.44107 12.505L6.06722 12.505L3.83772 12.505C3.5673 12.505 3.30842 12.3954 3.12009 12.2014L1.7114 10.7498C1.32837 10.3551 1.33596 9.72521 1.72838 9.33987Z",stroke:"currentColor"}),l.createElement("line",{x1:"6.01807",y1:"12.5",x2:"10.7959",y2:"12.5",stroke:"currentColor",strokeLinecap:"round"}),l.createElement("line",{x1:"5.50834",y1:"5.74606",x2:"10.1984",y2:"10.4361",stroke:"currentColor"}))}function $_e(){return l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},l.createElement("path",{d:"M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612Zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612Z"}))}function R_e(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},l.createElement("path",{d:"M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L11.1464 3.14645C11.3417 2.95118 11.6583 2.95118 11.8536 3.14645C12.0488 3.34171 12.0488 3.65829 11.8536 3.85355L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z"}))}function F_e(){let e=wt(),t=Wn(),n=l.useCallback(()=>{e.delete()},[e]),r=e.useStore(i=>i.appState.status==="idle"&&i.document.pageStates[i.appState.currentPageId].selectedIds.length>0);return l.createElement(jt,{label:t.formatMessage({id:"delete"}),kbd:"⌫",id:"TD-Delete"},l.createElement(st,{variant:"circle",disabled:!r,onSelect:n},l.createElement(D_e,null)))}var L_e=e=>e.settings.language,O_e=()=>{let e=wt(),t=e.useStore(L_e),n=l.useCallback(r=>{e.setSetting("language",r)},[e]);return l.createElement(Ol,{variant:"menu",overflow:!0,id:"language-menu",side:"left",sideOffset:8},xC.map(({locale:r,label:i})=>l.createElement(Vi,{key:r,checked:t===r,onCheckedChange:()=>n(r),id:`TD-MenuItem-Language-${r}`},i)),l.createElement(Qt,null),l.createElement("a",{href:"https://github.com/tldraw/tldraw/blob/main/guides/translation.md",target:"_blank",rel:"nofollow"},l.createElement(tt,{id:"TD-MenuItem-Translation-Link"},l.createElement(ge,{id:"translation.link"}),l.createElement(ao,null,l.createElement(tI,null)))))};function __e({onOpenChange:e}){let t=Wn(),n=Nu(),r={Tools:[{label:t.formatMessage({id:"select"}),kbd:"1"},{label:t.formatMessage({id:"draw"}),kbd:"2"},{label:t.formatMessage({id:"eraser"}),kbd:"3"},{label:t.formatMessage({id:"rectangle"}),kbd:"4"},{label:t.formatMessage({id:"ellipse"}),kbd:"5"},{label:t.formatMessage({id:"triangle"}),kbd:"6"},{label:t.formatMessage({id:"line"}),kbd:"7"},{label:t.formatMessage({id:"arrow"}),kbd:"8"},{label:t.formatMessage({id:"text"}),kbd:"9"},{label:t.formatMessage({id:"sticky"}),kbd:"0"}],View:[{label:t.formatMessage({id:"zoom.in"}),kbd:"#+"},{label:t.formatMessage({id:"zoom.out"}),kbd:"#-"},{label:`${t.formatMessage({id:"zoom.to"})} 100%`,kbd:"⇧+0"},{label:t.formatMessage({id:"zoom.to.fit"}),kbd:"⇧+1"},{label:t.formatMessage({id:"zoom.to.selection"}),kbd:"⇧+2"},{label:t.formatMessage({id:"preferences.dark.mode"}),kbd:"#⇧D"},{label:t.formatMessage({id:"preferences.focus.mode"}),kbd:"#."},{label:t.formatMessage({id:"preferences.show.grid"}),kbd:"#⇧G"}],Transform:[{label:t.formatMessage({id:"flip.horizontal"}),kbd:"⇧H"},{label:t.formatMessage({id:"flip.vertical"}),kbd:"⇧V"},{label:`${t.formatMessage({id:"lock"})} / ${t.formatMessage({id:"unlock"})}`,kbd:"#⇧L"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"to.front"})}`,kbd:"⇧]"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"forward"})}`,kbd:"]"},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"backward"})}`,kbd:"["},{label:`${t.formatMessage({id:"move"})} ${t.formatMessage({id:"back"})}`,kbd:"⇧["}],File:[{label:t.formatMessage({id:"new.project"}),kbd:"#N"},{label:t.formatMessage({id:"open"}),kbd:"#O"},{label:t.formatMessage({id:"save"}),kbd:"#S"},{label:t.formatMessage({id:"save.as"}),kbd:"#⇧S"},{label:t.formatMessage({id:"upload.media"}),kbd:"#U"}],Edit:[{label:t.formatMessage({id:"undo"}),kbd:"#Z"},{label:t.formatMessage({id:"redo"}),kbd:"#⇧Z"},{label:t.formatMessage({id:"cut"}),kbd:"#X"},{label:t.formatMessage({id:"copy"}),kbd:"#C"},{label:t.formatMessage({id:"paste"}),kbd:"#V"},{label:t.formatMessage({id:"select.all"}),kbd:"#A"},{label:t.formatMessage({id:"delete"}),kbd:"⌫"},{label:t.formatMessage({id:"duplicate"}),kbd:"#D"}]};return l.createElement(AD,{onOpenChange:e},l.createElement(kD,{asChild:!0},l.createElement(ur,{id:"TD-HelpItem-Keyboard",variant:"wide"},l.createElement(ge,{id:"keyboard.shortcuts"}))),l.createElement(ID,{container:n.current},l.createElement(K_e,null),l.createElement(j_e,null,l.createElement(G_e,null,l.createElement(ge,{id:"keyboard.shortcuts"}),l.createElement(sC,{asChild:!0},l.createElement(V_e,null,l.createElement(MY,null)))),l.createElement(U_e,{bp:Ci},Object.entries(r).map(([i,o])=>l.createElement(zy,{key:i},l.createElement(N_e,null,l.createElement(ge,{id:`menu.${i.toLocaleLowerCase()}`})),l.createElement(z_e,null,o.map(a=>l.createElement(H_e,{key:a.label},a.label,l.createElement(SC,{variant:"menu"},a.kbd))))))))))}var N_e=fe("h3",{fontSize:"$2",color:"$text",fontFamily:"$ui",margin:0,paddingBottom:"$5"}),zy=fe("div",{breakInside:"avoid",paddingBottom:24}),z_e=fe("ul",{listStyleType:"none",width:"100%",padding:0,margin:0}),H_e=fe("li",{display:"flex",alignItems:"center",justifyContent:"space-between",height:32,minHeight:32,width:"100%",outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",borderRadius:4,userSelect:"none",margin:0,padding:"0 0"}),j_e=fe(TD,{borderRadius:6,boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"fit-content",maxWidth:"90vw",maxHeight:"74vh",overflowY:"auto",padding:25,zIndex:9999,pointerEvents:"all",background:"$panel","&:focus":{outline:"none"}}),U_e=fe("div",{maxWidth:"100%",width:"fit-content",height:"fit-content",overflowY:"auto",columnGap:64,variants:{bp:{mobile:{columns:1,[`& ${zy}`]:{minWidth:"0px"}},small:{columns:2,[`& ${zy}`]:{minWidth:"200px"}},medium:{columns:3},large:{columns:3}}}}),K_e=fe(DD,{backgroundColor:"$overlay",position:"fixed",inset:0,zIndex:9998}),V_e=fe(IC,{fontFamily:"inherit",borderRadius:"100%",height:25,width:25,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"$text",cursor:"pointer","&:hover":{backgroundColor:"$hover"}}),G_e=fe(PD,{fontFamily:"$body",fontSize:"$3",color:"$text",paddingBottom:32,display:"flex",alignItems:"center",justifyContent:"space-between",margin:0}),J_e=e=>e.settings.isDebugMode,W_e=e=>e.settings.dockPosition;function Y_e(){let e=wt(),t=e.useStore(J_e),n=e.useStore(W_e),[r,i]=l.useState(!1);return l.createElement(Fee,null,l.createElement(tNe,{dir:"ltr",debug:t,side:n,bp:Ci},l.createElement(Oee,{dir:"ltr",asChild:!0},l.createElement(Q_e,null,l.createElement(hq,null)))),l.createElement(_ee,{dir:"ltr",align:"end",side:"top",alignOffset:10,sideOffset:8,asChild:!0},l.createElement(eNe,{style:{visibility:r?"hidden":"visible"}},l.createElement(q_e,null),l.createElement(__e,{onOpenChange:i}),l.createElement(Qt,null),l.createElement(Z_e,null))))}var q_e=()=>l.createElement(Lu,{dir:"ltr"},l.createElement(Fl,{asChild:!0},l.createElement(ur,{variant:"wide",hasArrow:!0},l.createElement(ge,{id:"language"}))),l.createElement(O_e,null)),X_e=[{id:"tldraw-beta",icon:tI,url:"https://beta.tldraw.com"},{id:"github",icon:HY,url:"https://github.com/tldraw/tldraw"},{id:"twitter",icon:Mq,url:"https://twitter.com/tldraw"},{id:"discord",icon:$_e,url:"https://discord.gg/SBBEVCA4PG"},{id:"become.a.sponsor",icon:JY,url:"https://github.com/sponsors/steveruizok"}],Z_e=()=>l.createElement(l.Fragment,null,X_e.map(e=>l.createElement("a",{key:e.id,href:e.url,target:"_blank",rel:"nofollow"},l.createElement(ur,{id:`TD-Link-${e.id}`,variant:"wide"},l.createElement(ge,{id:e.id}),l.createElement(ao,null,l.createElement(e.icon,null)))))),Q_e=fe("button",{width:32,height:32,borderRadius:"100%",display:"flex",padding:0,justifyContent:"center",alignItems:"center",outline:"none",backgroundColor:"$panel",cursor:"pointer",boxShadow:"$panel",border:"1px solid $panelContrast",color:"$text","& svg":{height:12,width:12}}),eNe=fe(_u,{width:"fit-content",height:"fit-content",minWidth:200,maxHeight:380,overflowY:"auto","& *":{boxSizing:"border-box"},"& a":{outline:"none"},variants:{variant:{horizontal:{flexDirection:"row"},menu:{minWidth:128}}}}),tNe=fe(Lee,{position:"absolute",zIndex:999,right:10,bottom:10,width:32,height:32,variants:{debug:{true:{},false:{}},bp:{mobile:{bottom:64},small:{bottom:10},medium:{},large:{}},side:{top:{},left:{},right:{},bottom:{}}},compoundVariants:[{bp:"mobile",side:"bottom",debug:!0,css:{bottom:104}},{bp:"small",side:"bottom",debug:!0,css:{bottom:50}}]}),Ng=fe("div",{backgroundColor:"$panel",display:"flex",flexDirection:"row",boxShadow:"$panel",padding:"$2",border:"1px solid $panelContrast",gap:0,overflow:"hidden",variants:{side:{center:{borderRadius:9},left:{padding:0,borderTop:0,borderLeft:0,borderTopRightRadius:0,borderBottomRightRadius:9,borderBottomLeftRadius:0},right:{padding:0,borderTop:0,borderRight:0,borderTopLeftRadius:0,borderBottomLeftRadius:9,borderBottomRightRadius:0}}},"& hr":{height:10,width:"100%",backgroundColor:"red",border:"none"}}),Wv=["rectangle","ellipse","triangle","line"],DS={rectangle:l.createElement(yq,null),ellipse:l.createElement(IY,null),triangle:l.createElement(Rq,null),line:l.createElement(R_e,null)},nNe=e=>e.settings.dockPosition,rNe=l.memo(function({activeTool:e,isToolLocked:t}){let n=wt(),r=Wn(),i=n.useStore(nNe),[o,a]=l.useState("rectangle");l.useEffect(()=>{Wv.includes(e)&&o!==e&&a(e)},[e]);let s=l.useCallback(()=>{n.selectTool(o)},[e,n]),u=l.useCallback(()=>{n.toggleToolLock()},[n]),d=l.useCallback(m=>{m.key===" "&&n.shiftKey&&m.preventDefault()},[]),h=Wv.includes(e),p=i==="bottom"||i==="top"?"top":i,g=i==="bottom"||i==="top"?"row":"column";return l.createElement(Lu,{dir:"ltr",onOpenChange:s},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-PrimaryTools-Shapes"},l.createElement(st,{disabled:h&&n.shiftKey,variant:"primary",onDoubleClick:u,isToolLocked:h&&t,isActive:h,onKeyDown:d},DS[o])),l.createElement(hI,{asChild:!0,side:p,sideOffset:12},l.createElement(Ng,{side:"center",style:{flexDirection:g}},Wv.map((m,v)=>l.createElement(jt,{key:m,label:r.formatMessage({id:m}),kbd:(4+v).toString(),id:`TD-PrimaryTools-Shapes-${m}`},l.createElement(Xm,{asChild:!0},l.createElement(st,{variant:"primary",onClick:()=>{n.selectTool(m),a(m)}},DS[m])))))))}),iNe=e=>e.appState.activeTool,oNe=e=>e.appState.isToolLocked,aNe=e=>e.settings.dockPosition,sNe=l.memo(function(){let e=wt(),t=Wn(),n=e.useStore(iNe),r=e.useStore(oNe),i=e.useStore(aNe),o=l.useCallback(()=>{e.selectTool("select")},[e]),a=l.useCallback(()=>{e.selectTool("erase")},[e]),s=l.useCallback(()=>{e.selectTool("draw")},[e]),u=l.useCallback(()=>{e.selectTool("arrow")},[e]),d=l.useCallback(()=>{e.selectTool("text")},[e]),h=l.useCallback(()=>{e.selectTool("sticky")},[e]),p=l.useCallback(()=>Oe(this,null,function*(){e.openAsset()}),[e]);return l.createElement(uNe,{side:"center",id:"TD-PrimaryTools",style:{flexDirection:i==="bottom"||i==="top"?"row":"column"},bp:Ci},l.createElement(Xu,{kbd:"1",label:t.formatMessage({id:"select"}),onClick:o,isActive:n==="select",id:"TD-PrimaryTools-CursorArrow"},l.createElement(RY,null)),l.createElement(Xu,{kbd:"2",label:t.formatMessage({id:"draw"}),onClick:s,isActive:n==="draw",id:"TD-PrimaryTools-Pencil"},l.createElement(zE,null)),l.createElement(Xu,{kbd:"3",label:t.formatMessage({id:"eraser"}),onClick:a,isActive:n==="erase",id:"TD-PrimaryTools-Eraser"},l.createElement(M_e,null)),l.createElement(rNe,{activeTool:n,isToolLocked:r}),l.createElement(Xu,{kbd:"8",label:t.formatMessage({id:"arrow"}),onClick:u,isLocked:r,isActive:n==="arrow",id:"TD-PrimaryTools-ArrowTopRight"},l.createElement(mY,null)),l.createElement(Xu,{kbd:"9",label:t.formatMessage({id:"text"}),onClick:d,isLocked:r,isActive:n==="text",id:"TD-PrimaryTools-Text"},l.createElement(wq,null)),l.createElement(Xu,{kbd:"0",label:t.formatMessage({id:"sticky"}),onClick:h,isActive:n==="sticky",id:"TD-PrimaryTools-Pencil2"},l.createElement(iq,null)),l.createElement(Xu,{label:t.formatMessage({id:"image"}),onClick:p,id:"TD-PrimaryTools-Image"},l.createElement(YY,null)))}),uNe=fe(Ng,{variants:{bp:{mobile:{padding:"$0",borderRadius:"10px"},small:{padding:"$2"}}}}),lNe=e=>e.appState.status,cNe=e=>e.appState.activeTool;function dNe(){let e=wt(),t=e.useStore(lNe),n=e.useStore(cNe);return l.createElement(hNe,{bp:Ci,id:"TD-StatusBar"},l.createElement(fNe,null,n," | ",t))}var hNe=fe("div",{height:40,userSelect:"none",borderTop:"1px solid $panelContrast",gridArea:"status",display:"flex",color:"$text",justifyContent:"space-between",alignItems:"center",backgroundColor:"$panel",gap:8,fontFamily:"$ui",fontSize:"$0",padding:"0 16px",variants:{bp:{small:{fontSize:"$1"}}}}),fNe=fe("div",{whiteSpace:"nowrap",overflow:"hidden"}),pNe=e=>e.settings.isDebugMode,gNe=e=>e.settings.dockPosition,mNe=l.memo(function({onBlur:e}){let t=wt(),n=t.useStore(gNe),r=t.useStore(pNe);return l.createElement(l.Fragment,null,l.createElement(vNe,{side:n,onBlur:e,bp:Ci,debug:r},l.createElement(yNe,{id:"TD-Tools"},l.createElement(b_e,null),l.createElement(CNe,{orientation:n==="bottom"||n==="top"?"horizontal":"vertical"},l.createElement(v_e,null),l.createElement(sNe,null),l.createElement(F_e,null)))),l.createElement(Y_e,null),r&&l.createElement(ENe,null,l.createElement(dNe,null)))}),vNe=fe("div",{position:"absolute",width:"100%",minWidth:0,maxWidth:"100%",height:64,gap:"$4",display:"flex",justifyContent:"center",alignItems:"center",zIndex:200,overflow:"hidden",pointerEvents:"none","& > div > *":{pointerEvents:"all"},variants:{debug:{true:{},false:{}},bp:{mobile:{},small:{},medium:{},large:{}},side:{top:{width:"100%",height:64,left:0,right:0,top:45},right:{width:64,height:"100%",top:0,right:0},bottom:{width:"100%",left:0,right:0,bottom:4},left:{width:64,height:"100%",left:0}}},compoundVariants:[{side:"top",bp:"large",css:{top:0}},{side:"bottom",debug:!0,css:{bottom:44}}]}),yNe=fe("div",{display:"flex",width:"fit-content",height:"fit-content",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:"$4"}),ENe=fe("div",{position:"absolute",bottom:"0px",left:"0px",right:"0px",height:"40px",width:"100%",maxWidth:"100%"}),CNe=fe("div",{position:"relative",display:"flex",alignItems:"center",height:"fit-content",gap:"$3",variants:{orientation:{horizontal:{flexDirection:"row"},vertical:{flexDirection:"column"}}}}),bNe=e=>e.settings,wNe=["bottom","left","right","top"];function SNe(){let e=wt(),t=Wn(),n=e.useStore(bNe),r=l.useCallback(()=>{e.setSetting("isDebugMode",p=>!p)},[e]),i=l.useCallback(()=>{e.setSetting("isDarkMode",p=>!p)},[e]),o=l.useCallback(()=>{e.setSetting("isFocusMode",p=>!p)},[e]),a=l.useCallback(()=>{e.setSetting("showGrid",p=>!p)},[e]),s=l.useCallback(()=>{e.setSetting("keepStyleMenuOpen",p=>!p)},[e]),u=l.useCallback(()=>{e.setSetting("isCadSelectMode",p=>!p)},[e]),d=l.useCallback(p=>{e.setSetting("dockPosition",p)},[e]),h=l.useCallback(p=>{e.setSetting("exportBackground",p)},[e]);return l.createElement(ru,{label:t.formatMessage({id:"menu.preferences"}),id:"TD-MenuItem-Preferences"},l.createElement(Vi,{checked:n.isDarkMode,onCheckedChange:i,kbd:"#⇧D",id:"TD-MenuItem-Preferences-Dark_Mode"},l.createElement(ge,{id:"preferences.dark.mode"})),l.createElement(Vi,{checked:n.isFocusMode,onCheckedChange:o,kbd:"#.",id:"TD-MenuItem-Preferences-Focus_Mode"},l.createElement(ge,{id:"preferences.focus.mode"})),l.createElement(Vi,{checked:n.isDebugMode,onCheckedChange:r,id:"TD-MenuItem-Preferences-Debug_Mode"},l.createElement(ge,{id:"preferences.debug.mode"})),l.createElement(Qt,null),l.createElement(Vi,{checked:n.showGrid,onCheckedChange:a,kbd:"#⇧G",id:"TD-MenuItem-Preferences-Grid"},l.createElement(ge,{id:"preferences.show.grid"})),l.createElement(Vi,{checked:n.isCadSelectMode,onCheckedChange:u,id:"TD-MenuItem-Preferences-Cad_Selection"},l.createElement(ge,{id:"preferences.use.cad.selection"})),l.createElement(Vi,{checked:n.keepStyleMenuOpen,onCheckedChange:s,id:"TD-MenuItem-Preferences-Style_menu"},l.createElement(ge,{id:"preferences.keep.stylemenu.open"})),l.createElement(ru,{label:t.formatMessage({id:"dock.position"})},wNe.map(p=>l.createElement(Vi,{key:p,checked:n.dockPosition===p,onCheckedChange:()=>d(p),id:`TD-MenuItem-DockPosition-${p}`},l.createElement(TS,null,l.createElement(ge,{id:p}))))),l.createElement(ru,{label:t.formatMessage({id:"export.background"})},Object.values(AT).map(p=>l.createElement(Vi,{key:p,checked:n.exportBackground===p,onCheckedChange:()=>h(p),id:`TD-MenuItem-ExportBackground-${p}`},l.createElement(TS,null,l.createElement(ge,{id:p}))))))}var TS=fe("span",{textTransform:"capitalize"}),xNe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds.length,ANe=e=>e.appState.disableAssets,kNe=l.memo(function({readOnly:e}){let t=wt(),n=Wn(),[r,i]=l.useState(!1),o=t.useStore(xNe),a=t.useStore(ANe),[s,u]=l.useState(0);l.useEffect(()=>u(1),[]);let{onNewProject:d,onOpenProject:h,onSaveProject:p,onSaveProjectAs:g}=ET(),m=l.useCallback(()=>{kd?t.saveProjectAs():i(!0)},[t]),v=l.useCallback(()=>{t.delete()},[t]),E=l.useCallback(()=>{t.copyImage("svg",{scale:1,quality:1,transparentBackground:!1})},[t]),w=l.useCallback(()=>{t.copyImage("png",{scale:2,quality:1,transparentBackground:!0})},[t]),C=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("png",{scale:2,quality:1})}),[t]),b=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("jpeg",{scale:2,quality:1})}),[t]),A=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("webp",{scale:2,quality:1})}),[t]),T=l.useCallback(()=>Oe(this,null,function*(){t.exportImage("svg",{scale:2,quality:1})}),[t]),B=l.useCallback(()=>Oe(this,null,function*(){t.copyJson()}),[t]),D=l.useCallback(()=>Oe(this,null,function*(){t.exportJson()}),[t]),I=l.useCallback(()=>{t.cut()},[t]),M=l.useCallback(()=>{t.copy()},[t]),O=l.useCallback(()=>{t.paste()},[t]),z=l.useCallback(()=>{t.selectAll()},[t]),K=l.useCallback(()=>{t.selectNone()},[t]),X=l.useCallback(()=>{t.openAsset()},[t]),Z=l.useCallback(()=>{t.zoomTo(1)},[t]),pe=t.callbacks.onNewProject||t.callbacks.onOpenProject||t.callbacks.onSaveProject||t.callbacks.onSaveProjectAs||t.callbacks.onExport,me=o>0;return l.createElement(l.Fragment,null,l.createElement(Lu,{dir:"ltr"},l.createElement(BT,{id:"TD-MenuIcon"},l.createElement(VY,null)),l.createElement(Ol,{variant:"menu",id:"TD-Menu",side:"bottom",align:"start",sideOffset:4,alignOffset:4},pe&&l.createElement(ru,{label:`${n.formatMessage({id:"menu.file"})}...`,id:"TD-MenuItem-File"},t.callbacks.onNewProject&&l.createElement(tt,{onClick:d,kbd:"#N",id:"TD-MenuItem-File-New_Project"},l.createElement(ge,{id:"new.project"})),t.callbacks.onOpenProject&&l.createElement(tt,{onClick:h,kbd:"#O",id:"TD-MenuItem-File-Open"},l.createElement(ge,{id:"open"}),"..."),t.callbacks.onSaveProject&&l.createElement(tt,{onClick:p,kbd:"#S",id:"TD-MenuItem-File-Save"},l.createElement(ge,{id:"save"})),t.callbacks.onSaveProjectAs&&l.createElement(tt,{onClick:m,kbd:"#⇧S",id:"TD-MenuItem-File-Save_As"},l.createElement(ge,{id:"save.as"}),"..."),!a&&l.createElement(l.Fragment,null,l.createElement(Qt,null),l.createElement(tt,{onClick:X,kbd:"#U",id:"TD-MenuItem-File-Upload_Media"},l.createElement(ge,{id:"upload.media"})))),l.createElement(ru,{label:`${n.formatMessage({id:"menu.edit"})}...`,id:"TD-MenuItem-Edit"},l.createElement(tt,{onSelect:Ut,onClick:t.undo,disabled:e,kbd:"#Z",id:"TD-MenuItem-Edit-Undo"},l.createElement(ge,{id:"undo"})),l.createElement(tt,{onSelect:Ut,onClick:t.redo,disabled:e,kbd:"#⇧Z",id:"TD-MenuItem-Edit-Redo"},l.createElement(ge,{id:"redo"})),l.createElement(Qt,null),l.createElement(tt,{onSelect:Ut,disabled:!me||e,onClick:I,kbd:"#X",id:"TD-MenuItem-Edit-Cut"},l.createElement(ge,{id:"cut"})),l.createElement(tt,{onSelect:Ut,disabled:!me,onClick:M,kbd:"#C",id:"TD-MenuItem-Edit-Copy"},l.createElement(ge,{id:"copy"})),l.createElement(tt,{onSelect:Ut,onClick:O,kbd:"#V",id:"TD-MenuItem-Edit-Paste"},l.createElement(ge,{id:"paste"})),l.createElement(Qt,null),l.createElement(ru,{label:`${n.formatMessage({id:"copy.as"})}...`,size:"small",id:"TD-MenuItem-Copy-As"},l.createElement(tt,{onClick:E,id:"TD-MenuItem-Copy-as-SVG"},"SVG"),l.createElement(tt,{onClick:w,id:"TD-MenuItem-Copy-As-PNG"},"PNG"),l.createElement(tt,{onClick:B,id:"TD-MenuItem-Copy_as_JSON"},"JSON")),l.createElement(ru,{label:`${n.formatMessage({id:"export.as"})}...`,size:"small",id:"TD-MenuItem-Export"},l.createElement(tt,{onClick:T,id:"TD-MenuItem-Export-SVG"},"SVG"),l.createElement(tt,{onClick:C,id:"TD-MenuItem-Export-PNG"},"PNG"),l.createElement(tt,{onClick:b,id:"TD-MenuItem-Export-JPG"},"JPG"),l.createElement(tt,{onClick:A,id:"TD-MenuItem-Export-WEBP"},"WEBP"),l.createElement(tt,{onClick:D,id:"TD-MenuItem-Export-JSON"},"JSON")),l.createElement(Qt,null),l.createElement(tt,{onSelect:Ut,onClick:z,kbd:"#A",id:"TD-MenuItem-Select_All"},l.createElement(ge,{id:"select.all"})),l.createElement(tt,{onSelect:Ut,disabled:!me,onClick:K,id:"TD-MenuItem-Select_None"},l.createElement(ge,{id:"select.none"})),l.createElement(Qt,null),l.createElement(tt,{onSelect:v,disabled:!me,kbd:"⌫",id:"TD-MenuItem-Delete"},l.createElement(ge,{id:"delete"}))),l.createElement(ru,{label:n.formatMessage({id:"menu.view"}),id:"TD-MenuItem-Edit"},l.createElement(tt,{onSelect:Ut,onClick:t.zoomIn,kbd:"#+",id:"TD-MenuItem-View-ZoomIn"},l.createElement(ge,{id:"zoom.in"})),l.createElement(tt,{onSelect:Ut,onClick:t.zoomOut,kbd:"#-",id:"TD-MenuItem-View-ZoomOut"},l.createElement(ge,{id:"zoom.out"})),l.createElement(tt,{onSelect:Ut,onClick:Z,kbd:"⇧+0",id:"TD-MenuItem-View-ZoomTo100"},l.createElement(ge,{id:"zoom.to"})," 100%"),l.createElement(tt,{onSelect:Ut,onClick:t.zoomToFit,kbd:"⇧+1",id:"TD-MenuItem-View-ZoomToFit"},l.createElement(ge,{id:"zoom.to.fit"})),l.createElement(tt,{onSelect:Ut,onClick:t.zoomToSelection,kbd:"⇧+2",id:"TD-MenuItem-View-ZoomToSelection"},l.createElement(ge,{id:"zoom.to.selection"}))),l.createElement(Qt,null),l.createElement(SNe,null))),l.createElement(i_e,{isOpen:r,onClose:()=>i(!1)}))});function INe(){return l.createElement("svg",{width:"15",height:"15",viewBox:"0 0 15 15",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"},l.createElement("path",{d:"M1.36482 4.71089C1.36482 3.21371 2.57853 2 4.07572 2C5.5729 2 6.78661 3.21371 6.78661 4.71089C6.78661 5.76842 6.18106 6.68452 5.29779 7.13136C5.80465 7.24611 6.26407 7.44186 6.66028 7.73182C7.18674 8.11711 7.57215 8.64722 7.81073 9.30983C7.81452 9.30606 7.81832 9.3023 7.82212 9.29855C8.30448 8.82317 8.91325 8.52463 9.60905 8.37275C8.68812 7.922 8.05394 6.97569 8.05394 5.88126C8.05394 4.35017 9.29513 3.10898 10.8262 3.10898C12.3573 3.10898 13.5985 4.35017 13.5985 5.88126C13.5985 6.97561 12.9644 7.92186 12.0436 8.37265C12.7396 8.52449 13.3486 8.82306 13.831 9.29854C14.5795 10.0361 14.9481 11.1249 14.9481 12.5176C14.9481 12.7799 14.7354 12.9926 14.473 12.9926C14.2107 12.9926 13.9981 12.7799 13.9981 12.5175C13.9981 11.2848 13.6738 10.4774 13.1642 9.97518C12.6532 9.4716 11.8802 9.20024 10.8266 9.20024C9.77294 9.20024 8.99993 9.4716 8.48896 9.97518C7.97939 10.4774 7.65513 11.2848 7.65513 12.5176C7.65513 12.7799 7.44247 12.9926 7.18013 12.9926C6.9178 12.9926 6.70513 12.7799 6.70513 12.5176C6.70513 11.6734 6.84053 10.941 7.11384 10.3307C7.0922 10.2895 7.0763 10.2444 7.06737 10.1962C6.91739 9.38749 6.57392 8.84586 6.09923 8.49845C5.61626 8.14499 4.94481 7.95427 4.07574 7.95427C3.05232 7.95427 2.30368 8.21784 1.80952 8.70485C1.31675 9.19047 1.00176 9.97257 1.00176 11.1702C1.00176 11.4326 0.789093 11.6452 0.526758 11.6452C0.264423 11.6452 0.0517578 11.4326 0.0517578 11.1702C0.0517578 9.81263 0.411052 8.74925 1.14268 8.02821C1.60624 7.57137 2.18892 7.28191 2.85378 7.13142C1.97043 6.68461 1.36482 5.76848 1.36482 4.71089ZM4.07572 2.95C3.1032 2.95 2.31482 3.73838 2.31482 4.71089C2.31482 5.68341 3.1032 6.47178 4.07572 6.47178C5.04823 6.47178 5.83661 5.68341 5.83661 4.71089C5.83661 3.73838 5.04823 2.95 4.07572 2.95ZM10.8262 4.05898C9.8198 4.05898 9.00394 4.87484 9.00394 5.88126C9.00394 6.88768 9.8198 7.70355 10.8262 7.70355C11.8326 7.70355 12.6485 6.88768 12.6485 5.88126C12.6485 4.87484 11.8326 4.05898 10.8262 4.05898Z"}))}var kl="-0.03em",DC=[.5,.5],Hy=".tldr",d1={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e<=0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e>=1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2},PS=["#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467","#FF802B"],DNe=typeof Window>"u"?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),TNe=typeof Window>"u"?!1:/linux/i.test(navigator.userAgent),MT=[".png",".svg",".jpg",".jpeg",".gif"],$T=DNe?[]:[".mp4",".webm"];function $r(e){if(e===null)return e;if(e instanceof Date)return new Date(e.getTime());if(typeof e=="object")if(typeof e[Symbol.iterator]=="function"){let t=[];if(e.length>0)for(let n of e)t.push($r(n));return t}else{let t=Object.keys(e),n={};if(t.length>0)for(let r of t)n[r]=$r(e[r]);return n}return e}function Id(e,t){let n=N.getFromCache(t,e,()=>{let[r,i]=e.size;return{minX:0,maxX:r,minY:0,maxY:i,width:r,height:i}});return N.translateBounds(n,e.point)}var PNe={start:"left",middle:"center",end:"right",justify:"justify"};function BNe(e="start"){return PNe[e]}var Ys;function MNe(){var e;(e=document.getElementById("__textLabelMeasure"))==null||e.remove();let t=document.createElement("pre");return t.id="__textLabelMeasure",Object.assign(t.style,{whiteSpace:"pre",width:"auto",border:"1px solid transparent",padding:"4px",margin:"0px",letterSpacing:kl,opacity:"0",position:"absolute",top:"-500px",left:"0px",zIndex:"9999",pointerEvents:"none",userSelect:"none",alignmentBaseline:"mathematical",dominantBaseline:"mathematical"}),t.tabIndex=-1,document.body.appendChild(t),t}typeof window<"u"&&(Ys=MNe());var jy="",BS="",Yv=[0,0];function $Ne(){jy=""}function T0(e,t){if(!e)return[16,32];if(!Ys)return[10,10];if(Ys.parent||document.body.appendChild(Ys),e===jy&&t===BS)return Yv;jy=e,BS=t,Ys.textContent=e,Ys.style.font=t;let n=Ys.offsetWidth||1,r=Ys.offsetHeight||1;return Yv=[n,r],Yv}var RNe=new RegExp(`${[32,160,4961,65792,65793,4153,4241].map(e=>String.fromCodePoint(e)).join("|")}`);function h1(e,t,n,r,i,o=!1){let a="normal",s=kl,u=FNe({text:e,wrap:o,width:i,fontSize:t,fontWeight:a,fontFamily:n,fontStyle:"normal",textAlign:"left",letterSpacing:kl,lineHeight:1}),d=document.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("font-size",t+"px"),d.setAttribute("font-family",n),d.setAttribute("font-weight",a),d.setAttribute("line-height",1*t+"px"),d.setAttribute("letter-spacing",s),d.setAttribute("text-align",r??"left"),d.setAttribute("dominant-baseline","mathematical"),d.setAttribute("alignment-baseline","mathematical");let h=u.map((p,g)=>{let m=document.createElementNS("http://www.w3.org/2000/svg","tspan");return m.textContent=p+` `,m.setAttribute("y",1*t*(g+.5)+"px"),d.appendChild(m),m});switch(r){case"middle":{d.setAttribute("text-align","center"),d.setAttribute("text-anchor","middle"),h.forEach(p=>p.setAttribute("x",i/2+""));break}case"end":{d.setAttribute("text-align","right"),d.setAttribute("text-anchor","end"),h.forEach(p=>p.setAttribute("x",-4+i+""));break}default:d.setAttribute("text-align","left"),d.setAttribute("text-anchor","start"),h.forEach(p=>p.setAttribute("x","4"))}return d}function FNe(e){let t=document.createElement("div");t.style.setProperty("position","absolute"),t.style.setProperty("top","-9999px"),t.style.setProperty("left","-9999px"),t.style.setProperty("width",e.width+"px"),t.style.setProperty("height","min-content"),t.style.setProperty("font-size",e.fontSize+"px"),t.style.setProperty("font-family",e.fontFamily),t.style.setProperty("font-weight",e.fontWeight),t.style.setProperty("line-height",e.lineHeight*e.fontSize+"px"),t.style.setProperty("letter-spacing",e.letterSpacing),t.style.setProperty("text-align",e.textAlign),document.body.appendChild(t);let n=e.text.split(RNe).flatMap(a=>a.replace(` `,` -`)).join(" ").split(" ");t.innerText=n[0];let r=t.offsetHeight,i=[n[0]],o=[i];for(let a=1;ar&&(r=u,i=[],o.push(i)),i.push(s)}return t.remove(),o.map(a=>a.join(" "))}function LNe({id:e,bounds:t,labelSize:n,offset:r,scale:i=1}){return l.createElement("defs",null,l.createElement("mask",{id:e+"_clip"},l.createElement("rect",{x:-100,y:-100,width:t.width+200,height:t.height+200,fill:"white"}),l.createElement("rect",{x:t.width/2-n[0]/2*i+((r==null?void 0:r[0])||0),y:t.height/2-n[1]/2*i+((r==null?void 0:r[1])||0),width:n[0]*i,height:n[1]*i,rx:4*i,ry:4*i,fill:"black",opacity:Math.max(i,.8)})))}var vp=Math.PI*2,ri=class{static inwardEdgeNormal(e){let t=se.sub(e[1],e[0]),n=se.len2(t);return[-t[0]/n,t[1]/n]}static outwardEdgeNormal(e){return se.neg(ri.inwardEdgeNormal(e))}static isReflexVertex(e,t){let n=e.length,r=e[(t+n-1)%n],i=e[t],o=e[(t+1)%n];return ri.leftSide(r,o,i)<0}static getEdges(e){return e.map((t,n)=>[t,e[(n+1)%e.length]])}static edgesIntersection([e,t],[n,r]){let i=(r[1]-n[1])*(t[0]-e[0])-(r[0]-n[0])*(t[1]-e[1]);if(i==0)return null;let o=((r[0]-n[0])*(e[1]-n[1])-(r[1]-n[1])*(e[0]-n[0]))/i,a=((t[0]-e[0])*(e[1]-n[1])-(t[1]-e[1])*(e[0]-n[0]))/i;return o<0||a<0||o>1||a>1?null:[e[0]+o*(t[0]-e[0]),e[1]+o*(t[1]-e[1])]}static appendArc(e,t,n,r,i,o=!1){let a=[...e],s=Math.atan2(r[1]-t[1],r[0]-t[0]),u=Math.atan2(i[1]-t[1],i[0]-t[0]);s<0&&(s+=vp),u<0&&(u+=vp);let d=5,h=s>u?s-u:s+vp-u,p=(o?-h:vp-h)/d;a.push(r);for(let g=1;gse.add(n,t))}static getOffsetPolygon(e,t=0){let n=ri.getEdges(e),r=n.map(o=>ri.createOffsetEdge(o,se.mul(ri.outwardEdgeNormal(o),t))),i=[];for(let o=0;ori.createOffsetEdge(i,ri.inwardEdgeNormal(i))),r=[];for(let i=0;i[r,e[(i+1)%n]]).map(([r,i])=>{let o=se.mul(se.per(se.uni(se.sub(i,r))),t);return[se.add(r,o),se.add(i,o)]}).map((r,i,o)=>{let a=ote(r,o[(i+1)%o.length]);if(a===void 0)throw Error("Expected an intersection");return a})}var RT="#fafafa",DC="#343d45",id={white:"#f0f1f3",lightGray:"#c6cbd1",gray:"#788492",black:"#1d1d1d",green:"#36b24d",cyan:"#0e98ad",blue:"#1c7ed6",indigo:"#4263eb",violet:"#7746f1",red:"#ff2133",orange:"#ff9433",yellow:"#ffc936"},NNe={light:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,RT,.45)]))),{white:"#ffffff",black:"#3d3d3d"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(N.lerpColor(t,"#999999",.3),DC,.4)]))),{white:"#1d1d1d",black:"#bbbbbb"})},P0={light:q(_({},id),{white:"#1d1d1d"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,DC,.1)]))),{white:"#cecece",black:"#cecece"})},jy={light:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,RT,.82)]))),{white:"#fefefe"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,DC,.82)]))),{white:"rgb(30,33,37)",black:"#1e1e1f"})},zNe={small:2,medium:3.5,large:5},HNe={small:28,medium:48,large:96,auto:"auto"},jNe={script:'"Caveat Brush"',sans:'"Source Sans Pro"',serif:'"Crimson Pro"',mono:'"Source Code Pro"'},UNe={script:1,sans:1,serif:1,mono:1},KNe={small:24,medium:36,large:48,auto:"auto"};function VNe(e){return zNe[e]}function f1(e,t="script"){return HNe[e]*UNe[t]}function Dd(e="script"){return jNe[e]}function FT(e){return KNe[e]}function ms(e){let t=f1(e.size,e.font),n=Dd(e.font),{scale:r=1}=e;return`${t*r}px/1 ${n}`}function GNe(e){let t=FT(e.size),n=Dd(e.font),{scale:r=1}=e;return`${t*r}px/1 ${n}`}function MS(e,t=!1){let{color:n}=e,r=t?"dark":"light",i=n==="white"||n==="black"?"yellow":n;return{fill:NNe[r][i],stroke:P0[r][i],color:t?"#1d1d1d":"#0d0d0d"}}function bt(e,t){let{color:n,size:r,isFilled:i}=e,o=VNe(r),a=t?"dark":"light";return{stroke:P0[a][n],fill:i?jy[a][n]:"none",strokeWidth:o}}var Vo={color:"black",size:"small",isFilled:!1,dash:"draw",scale:1},TC=q(_({},Vo),{font:"script",textAlign:"middle"}),$S=" ",rr=class{static insertTextFirefox(e,t){e.setRangeText(t,e.selectionStart||0,e.selectionEnd||0,"end"),e.dispatchEvent(new InputEvent("input",{data:t,inputType:"insertText",isComposing:!1}))}static insert(e,t){let n=e.ownerDocument,r=n.activeElement;r!==e&&e.focus(),n.execCommand("insertText",!1,t)||rr.insertTextFirefox(e,t),r===n.body?e.blur():r instanceof HTMLElement&&r!==e&&r.focus()}static set(e,t){e.select(),rr.insert(e,t)}static getSelection(e){let{selectionStart:t,selectionEnd:n}=e;return e.value.slice(t||void 0,n||void 0)}static wrapSelection(e,t,n){let{selectionStart:r,selectionEnd:i}=e,o=rr.getSelection(e);rr.insert(e,t+o+(n??t)),e.selectionStart=(r||0)+t.length,e.selectionEnd=(i||0)+t.length}static replace(e,t,n){let r=0;e.value.replace(t,(...i)=>{let o=r+i[i.length-2],a=i[0].length;e.selectionStart=o,e.selectionEnd=o+a;let s=typeof n=="string"?n:n(...i);return rr.insert(e,s),e.selectionStart=o,r+=s.length-a,s})}static findLineEnd(e,t){let n=e.lastIndexOf(` +`)).join(" ").split(" ");t.innerText=n[0];let r=t.offsetHeight,i=[n[0]],o=[i];for(let a=1;ar&&(r=u,i=[],o.push(i)),i.push(s)}return t.remove(),o.map(a=>a.join(" "))}function LNe({id:e,bounds:t,labelSize:n,offset:r,scale:i=1}){return l.createElement("defs",null,l.createElement("mask",{id:e+"_clip"},l.createElement("rect",{x:-100,y:-100,width:t.width+200,height:t.height+200,fill:"white"}),l.createElement("rect",{x:t.width/2-n[0]/2*i+((r==null?void 0:r[0])||0),y:t.height/2-n[1]/2*i+((r==null?void 0:r[1])||0),width:n[0]*i,height:n[1]*i,rx:4*i,ry:4*i,fill:"black",opacity:Math.max(i,.8)})))}var vp=Math.PI*2,ri=class{static inwardEdgeNormal(e){let t=se.sub(e[1],e[0]),n=se.len2(t);return[-t[0]/n,t[1]/n]}static outwardEdgeNormal(e){return se.neg(ri.inwardEdgeNormal(e))}static isReflexVertex(e,t){let n=e.length,r=e[(t+n-1)%n],i=e[t],o=e[(t+1)%n];return ri.leftSide(r,o,i)<0}static getEdges(e){return e.map((t,n)=>[t,e[(n+1)%e.length]])}static edgesIntersection([e,t],[n,r]){let i=(r[1]-n[1])*(t[0]-e[0])-(r[0]-n[0])*(t[1]-e[1]);if(i==0)return null;let o=((r[0]-n[0])*(e[1]-n[1])-(r[1]-n[1])*(e[0]-n[0]))/i,a=((t[0]-e[0])*(e[1]-n[1])-(t[1]-e[1])*(e[0]-n[0]))/i;return o<0||a<0||o>1||a>1?null:[e[0]+o*(t[0]-e[0]),e[1]+o*(t[1]-e[1])]}static appendArc(e,t,n,r,i,o=!1){let a=[...e],s=Math.atan2(r[1]-t[1],r[0]-t[0]),u=Math.atan2(i[1]-t[1],i[0]-t[0]);s<0&&(s+=vp),u<0&&(u+=vp);let d=5,h=s>u?s-u:s+vp-u,p=(o?-h:vp-h)/d;a.push(r);for(let g=1;gse.add(n,t))}static getOffsetPolygon(e,t=0){let n=ri.getEdges(e),r=n.map(o=>ri.createOffsetEdge(o,se.mul(ri.outwardEdgeNormal(o),t))),i=[];for(let o=0;ori.createOffsetEdge(i,ri.inwardEdgeNormal(i))),r=[];for(let i=0;i[r,e[(i+1)%n]]).map(([r,i])=>{let o=se.mul(se.per(se.uni(se.sub(i,r))),t);return[se.add(r,o),se.add(i,o)]}).map((r,i,o)=>{let a=ote(r,o[(i+1)%o.length]);if(a===void 0)throw Error("Expected an intersection");return a})}var RT="#fafafa",TC="#343d45",id={white:"#f0f1f3",lightGray:"#c6cbd1",gray:"#788492",black:"#1d1d1d",green:"#36b24d",cyan:"#0e98ad",blue:"#1c7ed6",indigo:"#4263eb",violet:"#7746f1",red:"#ff2133",orange:"#ff9433",yellow:"#ffc936"},NNe={light:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,RT,.45)]))),{white:"#ffffff",black:"#3d3d3d"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(N.lerpColor(t,"#999999",.3),TC,.4)]))),{white:"#1d1d1d",black:"#bbbbbb"})},P0={light:q(_({},id),{white:"#1d1d1d"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,TC,.1)]))),{white:"#cecece",black:"#cecece"})},Uy={light:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,RT,.82)]))),{white:"#fefefe"}),dark:q(_({},Object.fromEntries(Object.entries(id).map(([e,t])=>[e,N.lerpColor(t,TC,.82)]))),{white:"rgb(30,33,37)",black:"#1e1e1f"})},zNe={small:2,medium:3.5,large:5},HNe={small:28,medium:48,large:96,auto:"auto"},jNe={script:'"Caveat Brush"',sans:'"Source Sans Pro"',serif:'"Crimson Pro"',mono:'"Source Code Pro"'},UNe={script:1,sans:1,serif:1,mono:1},KNe={small:24,medium:36,large:48,auto:"auto"};function VNe(e){return zNe[e]}function f1(e,t="script"){return HNe[e]*UNe[t]}function Dd(e="script"){return jNe[e]}function FT(e){return KNe[e]}function ms(e){let t=f1(e.size,e.font),n=Dd(e.font),{scale:r=1}=e;return`${t*r}px/1 ${n}`}function GNe(e){let t=FT(e.size),n=Dd(e.font),{scale:r=1}=e;return`${t*r}px/1 ${n}`}function MS(e,t=!1){let{color:n}=e,r=t?"dark":"light",i=n==="white"||n==="black"?"yellow":n;return{fill:NNe[r][i],stroke:P0[r][i],color:t?"#1d1d1d":"#0d0d0d"}}function bt(e,t){let{color:n,size:r,isFilled:i}=e,o=VNe(r),a=t?"dark":"light";return{stroke:P0[a][n],fill:i?Uy[a][n]:"none",strokeWidth:o}}var Vo={color:"black",size:"small",isFilled:!1,dash:"draw",scale:1},PC=q(_({},Vo),{font:"script",textAlign:"middle"}),$S=" ",rr=class{static insertTextFirefox(e,t){e.setRangeText(t,e.selectionStart||0,e.selectionEnd||0,"end"),e.dispatchEvent(new InputEvent("input",{data:t,inputType:"insertText",isComposing:!1}))}static insert(e,t){let n=e.ownerDocument,r=n.activeElement;r!==e&&e.focus(),n.execCommand("insertText",!1,t)||rr.insertTextFirefox(e,t),r===n.body?e.blur():r instanceof HTMLElement&&r!==e&&r.focus()}static set(e,t){e.select(),rr.insert(e,t)}static getSelection(e){let{selectionStart:t,selectionEnd:n}=e;return e.value.slice(t||void 0,n||void 0)}static wrapSelection(e,t,n){let{selectionStart:r,selectionEnd:i}=e,o=rr.getSelection(e);rr.insert(e,t+o+(n??t)),e.selectionStart=(r||0)+t.length,e.selectionEnd=(i||0)+t.length}static replace(e,t,n){let r=0;e.value.replace(t,(...i)=>{let o=r+i[i.length-2],a=i[0].length;e.selectionStart=o,e.selectionEnd=o+a;let s=typeof n=="string"?n:n(...i);return rr.insert(e,s),e.selectionStart=o,r+=s.length-a,s})}static findLineEnd(e,t){let n=e.lastIndexOf(` `,t-1)+1;return e.charAt(n)!==" "?t:n+1}static indent(e){var t;let{selectionStart:n,selectionEnd:r,value:i}=e,o=i.slice(n,r),a=(t=/\n/g.exec(o))==null?void 0:t.length;if(a&&a>0){let s=i.lastIndexOf(` `,n-1)+1,u=e.value.slice(s,r-1),d=u.replace(/^|\n/g,`$&${$S}`),h=d.length-u.length;e.setSelectionRange(s,r-1),rr.insert(e,d),e.setSelectionRange(n+1,r+h)}else rr.insert(e,$S)}static unindent(e){let{selectionStart:t,selectionEnd:n,value:r}=e,i=r.lastIndexOf(` -`,t-1)+1,o=rr.findLineEnd(r,n),a=e.value.slice(i,o),s=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=a.length-s.length;e.setSelectionRange(i,o),rr.insert(e,s);let d=/\t| {1,2}/.exec(r.slice(i,t)),h=d?d[0].length:0,p=t-h;e.setSelectionRange(t-h,Math.max(p,n-u))}},p1=l.memo(function({font:e,text:t,color:n,offsetX:r=0,offsetY:i=0,scale:o=1,isEditing:a=!1,onBlur:s,onChange:u}){let d=l.useRef(null),h=l.useRef(!1),p=l.useCallback(b=>{u(Q.normalizeText(b.currentTarget.value))},[u]),g=l.useCallback(b=>{if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),s==null||s();return}if(b.key==="Tab"&&t.length===0){b.preventDefault();return}if(!(b.key==="Meta"||b.metaKey))b.stopPropagation();else if(b.key==="z"&&b.metaKey){b.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),b.stopPropagation(),b.preventDefault();return}(b.metaKey||b.ctrlKey)&&b.key==="="&&b.preventDefault(),b.key==="Tab"&&(b.preventDefault(),b.shiftKey?rr.unindent(b.currentTarget):rr.indent(b.currentTarget),u==null||u(Q.normalizeText(b.currentTarget.value)))},[u]),m=l.useCallback(b=>{b.currentTarget.setSelectionRange(0,0),s==null||s()},[s]),v=l.useCallback(b=>{!a||!h.current||document.activeElement===b.currentTarget&&b.currentTarget.select()},[a]),E=l.useCallback(b=>{a&&b.stopPropagation()},[a]),w=l.useRef(a);l.useEffect(()=>{a?(w.current=!0,requestAnimationFrame(()=>{h.current=!0;let b=d.current;b&&(b.focus(),b.select())})):w.current&&(s==null||s(),w.current=!1)},[a,s]);let C=l.useRef(null);return l.useLayoutEffect(()=>{let b=C.current;if(!b)return;let A=T0(t,e);b.style.transform=`scale(${o}, ${o}) translate(${r}px, ${i}px)`,b.style.width=A[0]+1+"px",b.style.height=A[1]+1+"px"},[t,e,i,r,o]),l.createElement(JNe,null,l.createElement(WNe,{ref:C,hasText:!!t,isEditing:a,style:{font:e,color:n}},a?l.createElement(YNe,{ref:d,style:{font:e,color:n},name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:t,color:n,onFocus:v,onChange:p,onKeyDown:g,onBlur:m,onPointerDown:E,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or}):t,"​"))}),JNe=fe("div",{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",userSelect:"none",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}}}}),LT={whiteSpace:"pre-wrap",overflowWrap:"break-word",letterSpacing:kl},WNe=fe("div",_({position:"absolute",padding:"4px",zIndex:1,minHeight:1,minWidth:1,lineHeight:1,outline:0,fontWeight:"500",textAlign:"center",backfaceVisibility:"hidden",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",variants:{hasText:{false:{pointerEvents:"none"},true:{pointerEvents:"all"}},isEditing:{false:{userSelect:"none"},true:{background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"}}}},LT)),YNe=fe("textarea",q(_({position:"absolute",top:0,left:0,zIndex:1,width:"100%",height:"100%",border:"none",padding:"4px",resize:"none",textAlign:"inherit",minHeight:"inherit",minWidth:"inherit",lineHeight:"inherit",outline:0,fontWeight:"inherit",overflow:"hidden",backfaceVisibility:"hidden",display:"inline-block",pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text",fontSmooth:"always",WebkitFontSmoothing:"subpixel-antialiased",MozOsxFontSmoothing:"auto"},LT),{"&:focus":{outline:"none",border:"none"}}));function g1(e,t,{initialShape:n,transformOrigin:r,scaleX:i,scaleY:o}){if(e.rotation||n.isAspectRatioLocked){let a=se.toFixed(se.mul(n.size,Math.min(Math.abs(i),Math.abs(o)))),s=se.toFixed([t.minX+(t.width-e.size[0])*(i<0?1-r[0]:r[0]),t.minY+(t.height-e.size[1])*(o<0?1-r[1]:r[1])]),u=i<0&&o>=0||o<0&&i>=0?n.rotation?-n.rotation:0:n.rotation;return{size:a,point:s,rotation:u}}else return{point:se.toFixed([t.minX,t.minY]),size:se.toFixed([t.width,t.height])}}function m1(e,t){return{size:se.toFixed([t.width,t.height]),point:se.toFixed([t.minX,t.minY])}}var gt=class extends oy{constructor(){super(...arguments),S(this,"canBind",!1),S(this,"canEdit",!1),S(this,"canClone",!1),S(this,"isAspectRatioLocked",!1),S(this,"hideResizeHandles",!1),S(this,"bindingDistance",16),S(this,"hitTestPoint",(e,t)=>N.pointInBounds(t,this.getRotatedBounds(e))),S(this,"hitTestLineSegment",(e,t,n)=>{let r=N.getBoundsFromPoints([t,n]),i=this.getBounds(e);return N.boundsContain(i,r)||e.rotation?vC(t,n,N.getRotatedCorners(this.getBounds(e))).didIntersect:mC(t,n,this.getBounds(e)).length>0}),S(this,"create",e=>(this.refMap.set(e.id,l.createRef()),this.getShape(e))),S(this,"getCenter",e=>N.getBoundsCenter(this.getBounds(e))),S(this,"getExpandedBounds",e=>N.expandBounds(this.getBounds(e),this.bindingDistance)),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{let a=this.getBounds(e),s=this.getExpandedBounds(e);if(!N.pointInBounds(n,s))return;let u=Kp(r,i,s).filter(E=>E.didIntersect).map(E=>E.points[0]);if(!u.length)return;let d=this.getCenter(e),h=u.sort((E,w)=>$.dist(w,r)-$.dist(E,r))[0],p=$.med(n,h),g,m;o?(g=$.dist(n,d)<16/2?d:n,m=0):($.distanceToLineSegment(n,p,d)<16/2?g=d:g=p,N.pointInBounds(n,a)?m=this.bindingDistance:m=Math.max(this.bindingDistance,N.getBoundsSides(a).map(E=>$.distanceToLineSegment(E[1][0],E[1][1],n)).sort((E,w)=>E-w)[0]));let v=$.divV($.sub(g,[s.minX,s.minY]),[s.width,s.height]);return{point:$.clampV(v,0,1),distance:m}}),S(this,"mutate",(e,t)=>t),S(this,"transform",(e,t,n)=>q(_({},e),{point:[t.minX,t.minY]})),S(this,"transformSingle",(e,t,n)=>this.transform(e,t,n)),S(this,"updateChildren"),S(this,"onChildrenChange"),S(this,"onHandleChange"),S(this,"onRightPointHandle"),S(this,"onDoubleClickHandle"),S(this,"onDoubleClickBoundsHandle"),S(this,"onSessionComplete"),S(this,"getSvgElement",(e,t)=>{var n,r,i,o,a;let s=(n=document.getElementById(e.id+"_svg"))==null?void 0:n.cloneNode(!0);if(s){if((o=(i=(r=e.label)==null?void 0:r.trim())==null?void 0:i.length)!=null&&o){let u=e,d=document.createElementNS("http://www.w3.org/2000/svg","g"),h=ms(e.style),p=T0(e.label,h),g=f1(e.style.size,e.style.font)*((a=e.style.scale)!=null?a:1),m=Dd(e.style.font).slice(1,-1),v=h1(u.label,g,m,"middle",p[0],!1),E=this.getBounds(e);return v.setAttribute("transform",`translate(${E.width/2-p[0]/2}, ${E.height/2-p[1]/2})`),v.setAttribute("fill",bt(e.style,t).stroke),v.setAttribute("transform-origin","center center"),d.setAttribute("text-align","center"),d.setAttribute("text-anchor","middle"),d.appendChild(s),d.appendChild(v),d}return s}})}};function qNe(e,t,n,r){return["M",e[0],e[1],"A",n[2],n[2],0,0,r<0?0:1,t[0],t[1]].join(" ")}function yp(e,t){let{start:n,end:r}=e,i=se.dist(n.point,r.point),o=se.med(n.point,r.point),a=i/2*t,s=se.uni(se.vec(n.point,r.point));return se.toFixed(Math.abs(a)<10?o:se.add(o,se.mul(se.per(s),a)))}function XNe(e,t,n,r,i,o){let a=N.rng(e),s=bt(t).strokeWidth,u=i?se.nudge(n,r,s):n,d=o?se.nudge(r,n,s):r,h=Ah([u,d],{size:s,thinning:.618+a()*.2,easing:d1.easeOutQuad,simulatePressure:!0,streamline:0,last:!0});return N.getSvgPathFromStroke(h)}function ZNe(e,t,n,r,i,o,a,s,u,d){let h=N.rng(e),p=bt(t).strokeWidth,g=i?se.rotWith(n,a,p/u):n,m=o?se.rotWith(r,a,-(p/u)):r,v=se.angle(a,g),E=se.angle(a,m),w=[],C=8+Math.floor(Math.abs(u)/20*1+h()/2);for(let A=0;A0?"1":"0"} ${r}`),i&&d.push(RS(t,u,p,g,m<0)),o&&d.push(RS(r,u,p,g,m>=0))}return d.join(" ")}function Ep(e,t,n){if(se.dist2(t,se.med(e,n))<=4)return[e,n];let r=[],i=sl(e,t,n),o=[i[0],i[1]],a=i[2],s=se.angle(o,e),u=se.angle(o,n);for(let d=0;d<20;d++){let h=d/19,p=N.lerpAngles(s,u,h);r.push(se.nudgeAtAngle(o,p,a))}return r}function eze(e,t,n){if(n===e||n===t)return!0;let r=Math.PI*2,i=(t-e+r)%r,o=(n-e+r)%r;return i<=Math.PI!=o>i}function B0(e,t,n,r){let i=N.getSweep(e,n,r);return t*(2*Math.PI)*(i/(2*Math.PI))}function zg({left:e,middle:t,right:n,stroke:r,strokeWidth:i}){return l.createElement("g",null,l.createElement("path",{className:"tl-stroke-hitarea",d:`M ${e} L ${t} ${n}`}),l.createElement("path",{d:`M ${e} L ${t} ${n}`,fill:"none",stroke:r,strokeWidth:i,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"}))}var tze=l.memo(function({id:e,style:t,start:n,bend:r,end:i,arrowBend:o,decorationStart:a,decorationEnd:s,isDraw:u,isDarkMode:d}){let h=se.dist(n,i);if(h<2)return null;let p=bt(t,d),{strokeWidth:g}=p,m=1+g*1.618,v=sl(n,r,i),E=[v[0],v[1]],w=v[2],C=B0(E,w,n,i),b=N.rng(e),A=d1[b()>0?"easeInOutSine":"easeInOutCubic"],T=u?ZNe(e,t,n,i,a,s,E,w,C,A):qNe(n,i,v,o),{strokeDasharray:B,strokeDashoffset:D}=N.getPerfectDashProps(Math.abs(C),m,t.dash,2,!1),I=Math.min(h/3,g*8),M=a?Uy(n,I,E,w,C<0):null,O=s?Uy(i,I,E,w,C>=0):null;return l.createElement(l.Fragment,null,l.createElement("path",{className:"tl-stroke-hitarea",d:T}),l.createElement("path",{d:T,fill:u?p.stroke:"none",stroke:p.stroke,strokeWidth:u?0:m,strokeDasharray:B,strokeDashoffset:D,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"}),M&&l.createElement(zg,{left:M.left,middle:n,right:M.right,stroke:p.stroke,strokeWidth:m}),O&&l.createElement(zg,{left:O.left,middle:i,right:O.right,stroke:p.stroke,strokeWidth:m}))}),nze=l.memo(function({id:e,style:t,start:n,end:r,decorationStart:i,decorationEnd:o,isDraw:a,isDarkMode:s}){let u=se.dist(n,r);if(u<2)return null;let d=bt(t,s),{strokeWidth:h}=d,p=1+h*1.618,g=a?XNe(e,t,n,r,i,o):"M"+se.toFixed(n)+"L"+se.toFixed(r),{strokeDasharray:m,strokeDashoffset:v}=N.getPerfectDashProps(u,h*1.618,t.dash,2,!1),E=Math.min(u/3,h*8),w=i?Ky(n,r,E):null,C=o?Ky(r,n,E):null;return l.createElement(l.Fragment,null,l.createElement("path",{className:"tl-stroke-hitarea",d:g}),l.createElement("path",{d:g,fill:d.stroke,stroke:d.stroke,strokeWidth:a?p/2:p,strokeDasharray:m,strokeDashoffset:v,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"stroke"}),w&&l.createElement(zg,{left:w.left,middle:n,right:w.right,stroke:d.stroke,strokeWidth:p}),C&&l.createElement(zg,{left:C.left,middle:r,right:C.right,stroke:d.stroke,strokeWidth:p}))}),rze=class extends gt{constructor(){super(...arguments),S(this,"type","arrow"),S(this,"hideBounds",!0),S(this,"canEdit",!0),S(this,"pathCache",new WeakMap),S(this,"getShape",e=>{var t,n,r,i;return _({id:"id",type:"arrow",name:"Arrow",parentId:"page",childIndex:1,point:[0,0],rotation:0,bend:0,handles:{start:_({id:"start",index:0,point:[0,0],canBind:!0},(t=e.handles)==null?void 0:t.start),end:_({id:"end",index:1,point:[1,1],canBind:!0},(n=e.handles)==null?void 0:n.end),bend:_({id:"bend",index:2,point:[.5,.5]},(r=e.handles)==null?void 0:r.bend)},decorations:(i=e.decorations)!=null?i:{end:"arrow"},style:_(q(_({},Vo),{isFilled:!1}),e.style),label:"",labelPoint:[.5,.5]},e)}),S(this,"Component",gt.Component(({shape:e,isEditing:t,isGhost:n,meta:r,events:i,onShapeChange:o,onShapeBlur:a},s)=>{var u,d;let{id:h,label:p="",handles:{start:g,bend:m,end:v},decorations:E={},style:w}=e,C=(d=(u=p==null?void 0:p.trim())==null?void 0:u.length)!=null?d:!1,b=$.dist(m.point,$.toFixed($.med(g.point,v.point)))<1,A=ms(w),T=bt(w,r.isDarkMode),B=C||t?T0(p,A):[0,0],D=this.getBounds(e),I=l.useMemo(()=>{let{start:X,bend:Z,end:pe}=e.handles;if(b)return $.dist(X.point,pe.point);let me=sl(X.point,Z.point,pe.point),Ce=me.slice(0,2),W=me[2],U=B0(Ce,W,X.point,pe.point);return Math.abs(U)},[e.handles]),M=Math.max(.5,Math.min(1,Math.max(I/(B[1]+128),I/(B[0]+128)))),O=l.useMemo(()=>{let X=this.getBounds(e);return $.sub(e.handles.bend.point,$.toFixed([X.width/2,X.height/2]))},[e,M]),z=l.useCallback(X=>{o==null||o({id:h,label:X})},[o]),K=b?nze:tze;return l.createElement(ize,_({ref:s},i),l.createElement(p1,{font:A,text:p,color:T.stroke,offsetX:O[0],offsetY:O[1],scale:M,isEditing:t,onChange:z,onBlur:a}),l.createElement(xi,{id:e.id+"_svg"},l.createElement("defs",null,l.createElement("mask",{id:e.id+"_clip"},l.createElement("rect",{x:-100,y:-100,width:D.width+200,height:D.height+200,fill:"white"}),l.createElement("rect",{x:D.width/2-B[0]/2*M+O[0],y:D.height/2-B[1]/2*M+O[1],width:B[0]*M,height:B[1]*M,rx:4*M,ry:4*M,fill:"black",opacity:1}))),l.createElement("g",{pointerEvents:"none",opacity:n?.3:1,mask:C||t?`url(#${e.id}_clip)`:""},l.createElement(K,{id:h,style:w,start:g.point,end:v.point,bend:m.point,arrowBend:e.bend,decorationStart:E==null?void 0:E.start,decorationEnd:E==null?void 0:E.end,isDraw:w.dash==="draw",isDarkMode:r.isDarkMode}))))})),S(this,"Indicator",gt.Indicator(({shape:e,bounds:t})=>{var n,r;let{style:i,decorations:o,label:a,handles:{start:s,bend:u,end:d}}=e,h=(r=(n=a==null?void 0:a.trim())==null?void 0:n.length)!=null?r:!1,p=ms(i),g=h?T0(a,p):[0,0],m=$.dist(u.point,$.toFixed($.med(s.point,d.point)))<1,v=l.useMemo(()=>{let{start:C,bend:b,end:A}=e.handles;if(m)return $.dist(C.point,A.point);let T=sl(C.point,b.point,A.point),B=T.slice(0,2),D=T[2],I=B0(B,D,C.point,A.point);return Math.abs(I)},[e.handles]),E=Math.max(.5,Math.min(1,Math.max(v/(g[1]+128),v/(g[0]+128)))),w=l.useMemo(()=>{let C=this.getBounds(e);return $.sub(e.handles.bend.point,[C.width/2,C.height/2])},[e,E]);return l.createElement(l.Fragment,null,h&&l.createElement(LNe,{id:e.id,scale:E,offset:w,bounds:t,labelSize:g}),l.createElement("path",{d:QNe(i,s.point,u.point,d.point,o==null?void 0:o.start,o==null?void 0:o.end),mask:h?`url(#${e.id}_clip)`:""}),h&&l.createElement("rect",{x:t.width/2-g[0]/2*E+w[0],y:t.height/2-g[1]/2*E+w[1],width:g[0]*E,height:g[1]*E,rx:4*E,ry:4*E,fill:"transparent"}))})),S(this,"getBounds",e=>{let t=N.getFromCache(this.boundsCache,e,()=>{let{handles:{start:n,bend:r,end:i}}=e;return N.getBoundsFromPoints(Ep(n.point,r.point,i.point))});return N.translateBounds(t,e.point)}),S(this,"getRotatedBounds",e=>{let{handles:{start:t,bend:n,end:r}}=e,i=Ep(t.point,n.point,r.point),{minX:o,minY:a,maxX:s,maxY:u}=N.getBoundsFromPoints(i);return e.rotation!==0&&(i=i.map(d=>$.rotWith(d,[(o+s)/2,(a+u)/2],e.rotation||0))),N.translateBounds(N.getBoundsFromPoints(i),e.point)}),S(this,"getCenter",e=>{let{start:t,end:n}=e.handles;return $.add(e.point,$.med(t.point,n.point))}),S(this,"shouldRender",(e,t)=>t.decorations!==e.decorations||t.handles!==e.handles||t.style!==e.style||t.label!==e.label),S(this,"hitTestPoint",(e,t)=>{let{handles:{start:n,bend:r,end:i}}=e,o=$.sub(t,e.point),a=Ep(n.point,r.point,i.point);for(let s=1;s{let{handles:{start:r,bend:i,end:o}}=e,a=$.sub(t,e.point),s=$.sub(n,e.point),u=Ep(r.point,i.point,o.point);for(let d=1;d{let{start:n,end:r,bend:i}=e.handles,o=$.add(e.point,n.point),a=$.add(e.point,r.point);if(N.pointInBounds(o,t)||N.pointInBounds(a,t))return!0;if($.isEqual($.med(n.point,r.point),i.point))return mC(o,a,t).length>0;{let[s,u,d]=sl(n.point,i.point,r.point),h=$.add(e.point,[s,u]);return Ete(h,d,o,a,t).length>0}}),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let o=this.getBounds(n),a=["start","end"],s=_({},n.handles);a.forEach(h=>{if(h==="bend")return;let[p,g]=s[h].point,m=p/o.width,v=g/o.height;s[h]=q(_({},s[h]),{point:[t.width*(r<0?1-m:m),t.height*(i<0?1-v:v)]})});let u=r>0&&i<0||r<0&&i>0?-n.bend:n.bend,d=yp(s,u);return s.bend.point=d,{point:$.toFixed([t.minX,t.minY]),handles:s,bend:u}}),S(this,"onDoubleClickHandle",(e,t)=>{var n,r;switch(t){case"bend":return{bend:0,handles:q(_({},e.handles),{bend:q(_({},e.handles.bend),{point:yp(e.handles,e.bend)})})};case"start":return{decorations:q(_({},e.decorations),{start:(n=e.decorations)!=null&&n.start?void 0:"arrow"})};case"end":return{decorations:q(_({},e.decorations),{end:(r=e.decorations)!=null&&r.end?void 0:"arrow"})}}return this}),S(this,"onHandleChange",(e,t)=>{let n=N.deepMerge(e.handles,t),r=e.bend;if(n=N.deepMerge(n,{start:{point:$.toFixed(n.start.point)},end:{point:$.toFixed(n.end.point)}}),$.isEqual(n.start.point,n.end.point))return;if("bend"in t){let{start:u,end:d,bend:h}=n,p=$.dist(u.point,d.point),g=$.med(u.point,d.point),m=$.angle(u.point,d.point),v=$.uni($.vec(u.point,d.point)),E=$.add(g,$.mul($.per(v),p)),w=$.sub(g,$.mul($.per(v),p)),C=$.nearestPointOnLineSegment(E,w,h.point,!0),b=$.dist(g,C)/(p/2);r=N.clamp(b,-.99,.99);let A=$.angle(u.point,C);$.isEqual(g,yp(n,r))?r=0:eze(m,m+Math.PI,A)&&(r*=-1)}let i={point:e.point,bend:r,handles:q(_({},n),{bend:q(_({},n.bend),{point:yp(n,r)})})},o=e.point,a=this.getBounds(_({},i)),s=$.sub([a.minX,a.minY],o);return $.isEqual(s,[0,0])||(Object.values(i.handles).forEach(u=>{u.point=$.toFixed($.sub(u.point,s))}),i.point=$.toFixed($.add(i.point,s))),i}),S(this,"getSvgElement",(e,t)=>{var n,r,i,o,a;let s=(n=document.getElementById(e.id+"_svg"))==null?void 0:n.cloneNode(!0);if(s){if((o=(i=(r=e.label)==null?void 0:r.trim())==null?void 0:i.length)!=null&&o){let u=e,d=document.createElementNS("http://www.w3.org/2000/svg","g"),h=ms(e.style),p=T0(e.label,h),g=f1(e.style.size,e.style.font)*((a=e.style.scale)!=null?a:1),m=Dd(e.style.font).slice(1,-1),v=h1(u.label,g,m,"start",p[0],!1),E,{start:w,bend:C,end:b}=e.handles;if($.dist(C.point,$.toFixed($.med(w.point,b.point)))<1)E=$.dist(w.point,b.point);else{let M=sl(w.point,C.point,b.point),O=M.slice(0,2),z=M[2],K=B0(O,z,w.point,b.point);E=Math.abs(K)}let A=Math.max(.5,Math.min(1,Math.max(E/(p[1]+128),E/(p[0]+128)))),T=this.getBounds(e),B=$.sub(e.handles.bend.point,[T.width/2,T.height/2]),D=T.width/2-p[0]/2*A+B[0],I=T.height/2-p[1]/2*A+B[1];return v.setAttribute("transform",`translate(${D}, ${I})`),v.setAttribute("fill",bt(e.style,t).stroke),v.setAttribute("transform-origin","center center"),d.setAttribute("text-align","center"),d.setAttribute("text-anchor","middle"),d.appendChild(s),d.appendChild(v),d}return s}})}},ize=fe("div",{width:"100%",height:"100%"}),oze={easing:e=>Math.sin(e*Math.PI/2),simulatePressure:!0},aze={easing:e=>e*e,simulatePressure:!1};function PC(e){let t=bt(e.style);return q(_({size:1+t.strokeWidth*1.5,thinning:.65,streamline:.65,smoothing:.65},e.points[1][2]===.5?oze:aze),{last:e.isComplete})}function sze(e){return e.points.length<2?"":N.getSvgPathFromStroke(vd(e.points,PC(e)).map(t=>t.point))}function OT(e,t){return vd(e.points,t)}function uze(e){if(e.points.length<2)return"";let t=PC(e),n=OT(e,t);return N.getSvgPathFromStroke(yE(n,t))}function LS(e){let{points:t}=e;if(t.length<2)return"M 0 0 L 0 0";let n=PC(e),r=OT(e,n),i=t[t.length-1];return se.isEqual(r[0].point,i)||r.push({point:i}),N.getSvgPathFromStrokePoints(r)}var lze=class extends gt{constructor(){super(...arguments),S(this,"type","draw"),S(this,"pointsBoundsCache",new WeakMap([])),S(this,"shapeBoundsCache",new Map),S(this,"rotatedCache",new WeakMap([])),S(this,"pointCache",{}),S(this,"canClone",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"draw",name:"Draw",parentId:"page",childIndex:1,point:[0,0],rotation:0,style:Vo,points:[],isComplete:!1},e)),S(this,"Component",gt.Component(({shape:e,meta:t,isSelected:n,isGhost:r,events:i},o)=>{let{points:a,style:s,isComplete:u}=e,d=l.useMemo(()=>sze(e),[a,s.size]),h=l.useMemo(()=>s.dash==="draw"?uze(e):LS(e),[a,s.size,s.dash,u]),p=bt(s,t.isDarkMode),{stroke:g,fill:m,strokeWidth:v}=p,E=this.getBounds(e);if(E.width<=v/2&&E.height<=v/2){let T=1+v;return l.createElement(xi,_({ref:o,id:e.id+"_svg"},i),l.createElement("circle",{r:T,fill:g,stroke:g,pointerEvents:"all",opacity:r?.3:1}))}let w=s.isFilled&&a.length>3&&$.dist(a[0],a[a.length-1]){let{points:t}=e,n=l.useMemo(()=>LS(e),[t]),r=this.getBounds(e);return r.width<4&&r.height<4?l.createElement("circle",{x:r.width/2,y:r.height/2,r:1}):l.createElement("path",{d:n})})),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let o=N.getFromCache(this.boundsCache,n,()=>N.getBoundsFromPoints(n.points)),a=n.points.map(([d,h,p])=>[t.width*(r<0?1-d/o.width:d/o.width),t.height*(i<0?1-h/o.height:h/o.height),p]),s=N.getBoundsFromPoints(e.points),u=$.sub([t.minX,t.minY],[s.minX,s.minY]);return{points:a,point:u}}),S(this,"getBounds",e=>{let t=!this.pointsBoundsCache.has(e.points),n=this.pointCache[e.id]!==e.point;if(t){let r=N.getBoundsFromPoints(e.points);this.pointsBoundsCache.set(e.points,r),this.shapeBoundsCache.set(e.id,N.translateBounds(r,e.point)),this.pointCache[e.id]=e.point}else n&&!t&&(this.pointCache[e.id]=e.point,this.shapeBoundsCache.set(e.id,N.translateBounds(this.pointsBoundsCache.get(e.points),e.point)));return this.shapeBoundsCache.get(e.id)}),S(this,"shouldRender",(e,t)=>t.points!==e.points||t.style!==e.style||t.isComplete!==e.isComplete),S(this,"hitTestPoint",(e,t)=>{let n=$.sub(t,e.point);return N.pointInPolyline(n,e.points)}),S(this,"hitTestLineSegment",(e,t,n)=>{let{points:r,point:i}=e,o=$.sub(t,i),a=$.sub(n,i),s=this.getBounds(e);if(s.width<8&&s.height<8)return $.distanceToLineSegment(t,n,N.getBoundsCenter(s))<5;if(mC(o,a,s)){for(let u=1;u{if(!e.rotation){let i=this.getBounds(e);return N.boundsContain(t,i)||(N.boundsContain(i,t)||kte(i,t).length>0)&&CS(N.translateBounds(t,$.neg(e.point)),e.points).length>0}let n=this.getRotatedBounds(e),r=N.getFromCache(this.rotatedCache,e,()=>{let i=N.getBoundsCenter(N.getBoundsFromPoints(e.points));return e.points.map(o=>$.rotWith(o,i,e.rotation||0))});return N.boundsContain(t,n)||CS(N.translateBounds(t,$.neg(e.point)),r).length>0})}},cze=l.memo(function({radius:e,style:t,isSelected:n,isDarkMode:r}){let{stroke:i,strokeWidth:o,fill:a}=bt(t,r),s=1+o*1.618,u=Math.max(0,e[0]-s/2),d=Math.max(0,e[1]-s/2),h=N.perimeterOfEllipse(u,d),{strokeDasharray:p,strokeDashoffset:g}=N.getPerfectDashProps(h<64?h*2:h,o*1.618,t.dash,4);return l.createElement(l.Fragment,null,l.createElement("ellipse",{className:t.isFilled||n?"tl-fill-hitarea":"tl-stroke-hitarea",cx:e[0],cy:e[1],rx:e[0],ry:e[1]}),l.createElement("ellipse",{cx:e[0],cy:e[1],rx:u,ry:d,fill:a,stroke:i,strokeWidth:s,strokeDasharray:p,strokeDashoffset:g,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round"}))});function _T(e,t,n){let{strokeWidth:r}=bt(n),i=N.rng(e),o=t[0]+i()*r*2,a=t[1]+i()*r*2,s=N.perimeterOfEllipse(o,a),u=[],d=Math.PI+Math.PI*i(),h=Math.abs(i()),p=Math.max(16,s/10);for(let g=0;gN.deepMerge({id:"id",type:"ellipse",name:"Ellipse",parentId:"page",childIndex:1,point:[0,0],radius:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,isGhost:t,isSelected:n,isBinding:r,isEditing:i,meta:o,bounds:a,events:s,onShapeChange:u,onShapeBlur:d},h)=>{let{id:p,radius:g,style:m,label:v="",labelPoint:E=IC}=e,w=ms(e.style),C=bt(m,o.isDarkMode),b=C.strokeWidth,A=1+b*1.618,T=Math.max(0,g[0]-A/2),B=Math.max(0,g[1]-A/2),D=m.dash==="draw"?hze:cze,I=l.useCallback(M=>u==null?void 0:u({id:p,label:M}),[u]);return l.createElement(pze,_({ref:h},s),l.createElement(p1,{isEditing:i,onChange:I,onBlur:d,font:w,text:v,color:C.stroke,offsetX:(E[0]-.5)*a.width,offsetY:(E[1]-.5)*a.height}),l.createElement(xi,{id:e.id+"_svg",opacity:t?.3:1},r&&l.createElement("ellipse",{className:"tl-binding-indicator",cx:g[0],cy:g[1],rx:T,ry:B,strokeWidth:this.bindingDistance}),l.createElement(D,{id:p,radius:g,style:m,isSelected:n,isDarkMode:o.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,radius:n,style:r}=e,i=bt(r).strokeWidth,o=1+i*1.618,a=Math.max(0,n[0]-o/2),s=Math.max(0,n[1]-o/2);return r.dash==="draw"?l.createElement("path",{d:NT(t,n,r)}):l.createElement("ellipse",{cx:n[0],cy:n[1],rx:a,ry:s})})),S(this,"hitTestPoint",(e,t)=>N.pointInBounds(t,this.getRotatedBounds(e))&&N.pointInEllipse(t,this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0)),S(this,"hitTestLineSegment",(e,t,n)=>zc(t,n,this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0).didIntersect),S(this,"getBounds",e=>N.getFromCache(this.boundsCache,e,()=>N.getRotatedEllipseBounds(e.point[0],e.point[1],e.radius[0],e.radius[1],0))),S(this,"getRotatedBounds",e=>N.getRotatedEllipseBounds(e.point[0],e.point[1],e.radius[0],e.radius[1],e.rotation)),S(this,"hitTestBounds",(e,t)=>{let n=this.getBounds(e);return N.boundsContained(n,t)||xte(this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0,t).length>0}),S(this,"shouldRender",(e,t)=>t.radius!==e.radius||t.style!==e.style||t.label!==e.label),S(this,"getCenter",e=>$.add(e.point,e.radius)),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{{let a=this.getExpandedBounds(e),s=this.getCenter(e),u,d;if(!N.pointInEllipse(n,s,e.radius[0]+this.bindingDistance,e.radius[1]+this.bindingDistance))return;if(o)$.dist(n,this.getCenter(e))<12?u=[.5,.5]:u=$.divV($.sub(n,[a.minX,a.minY]),[a.width,a.height]),d=0;else{let h=uT(r,i,s,e.radius[0],e.radius[1],e.rotation||0).points.sort((g,m)=>$.dist(g,r)-$.dist(m,r))[0];if(h||(h=zc(n,s,s,e.radius[0],e.radius[1],e.rotation||0).points.sort((g,m)=>$.dist(g,n)-$.dist(m,n))[0]),!h)return;let p=$.med(n,h);if($.distanceToLineSegment(n,p,this.getCenter(e))<12?u=[.5,.5]:u=$.divV($.sub(p,[a.minX,a.minY]),[a.width,a.height]),N.pointInEllipse(n,s,e.radius[0],e.radius[1],e.rotation||0))d=this.bindingDistance/2;else{let g=zc(n,s,s,e.radius[0],e.radius[1],e.rotation||0).points[0];if(!g)return;d=Math.max(this.bindingDistance/2,$.dist(n,g))}}return{point:u,distance:d}}}),S(this,"transform",(e,t,{scaleX:n,scaleY:r,initialShape:i})=>{let{rotation:o=0}=i;return{point:[t.minX,t.minY],radius:[t.width/2,t.height/2],rotation:n<0&&r>=0||r<0&&n>=0?-(o||0):o||0}}),S(this,"transformSingle",(e,t)=>({point:$.toFixed([t.minX,t.minY]),radius:$.div([t.width,t.height],2)}))}},pze=fe("div",{width:"100%",height:"100%"}),gze=class extends gt{constructor(){super(...arguments),S(this,"type","group"),S(this,"canBind",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"group",name:"Group",parentId:"page",childIndex:1,point:[0,0],size:[100,100],rotation:0,children:[],style:Vo},e)),S(this,"Component",gt.Component(({shape:e,isBinding:t,isGhost:n,isHovered:r,isSelected:i,events:o},a)=>{let{id:s,size:u}=e,d=2,h=Math.max(0,u[0]-d/2),p=Math.max(0,u[1]-d/2),g=[[[d/2,d/2],[h,d/2],h-d/2],[[h,d/2],[h,p],p-d/2],[[h,p],[d/2,p],h-d/2],[[d/2,p],[d/2,d/2],p-d/2]].map(([m,v],E)=>l.createElement("line",{key:s+"_"+E,x1:m[0],y1:m[1],x2:v[0],y2:v[1]}));return l.createElement(xi,_({ref:a},o),t&&l.createElement("rect",{className:"tl-binding-indicator",strokeWidth:this.bindingDistance}),l.createElement("g",{opacity:n?.3:1},l.createElement("rect",{x:0,y:0,width:u[0],height:u[1],fill:"transparent",pointerEvents:"all"}),l.createElement(OS,{stroke:"black",opacity:r||i?1:0,strokeLinecap:"round",pointerEvents:"stroke"},g)))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,size:n}=e,r=2,i=Math.max(0,n[0]-r/2),o=Math.max(0,n[1]-r/2),a=[[[r/2,r/2],[i,r/2],i-r/2],[[i,r/2],[i,o],o-r/2],[[i,o],[r/2,o],i-r/2],[[r/2,o],[r/2,r/2],o-r/2]].map(([s,u],d)=>l.createElement("line",{key:t+"_"+d,x1:s[0],y1:s[1],x2:u[0],y2:u[1]}));return l.createElement(OS,{strokeLinecap:"round",pointerEvents:"stroke"},a)})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style)}},OS=fe("g",{strokeWidth:"calc(1.5px * var(--tl-scale))",strokeDasharray:"calc(1px * var(--tl-scale)), calc(3px * var(--tl-scale))"}),mze=class extends gt{constructor(){super(...arguments),S(this,"type","image"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"isAspectRatioLocked",!0),S(this,"showCloneHandles",!1),S(this,"getShape",e=>N.deepMerge({id:"image",type:"image",name:"Image",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:q(_({},Vo),{isFilled:!0}),assetId:"assetId"},e)),S(this,"Component",gt.Component(({shape:e,asset:t={src:""},isBinding:n,isGhost:r,meta:i,events:o,onShapeChange:a},s)=>{let{size:u,style:d}=e,{bindingDistance:h}=this,p=l.useRef(null),g=l.useRef(null);return l.useLayoutEffect(()=>{let m=g.current;if(!m)return;let[v,E]=u;m.style.width=`${v}px`,m.style.height=`${E}px`},[u]),l.createElement(Tm,_({ref:s},o),n&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:`calc(${-h}px * var(--tl-zoom))`,left:`calc(${-h}px * var(--tl-zoom))`,width:`calc(100% + ${h*2}px * var(--tl-zoom))`,height:`calc(100% + ${h*2}px * var(--tl-zoom))`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(vze,{ref:g,isDarkMode:i.isDarkMode,isFilled:d.isFilled,isGhost:r},l.createElement(yze,{id:e.id+"_image",ref:p,src:t.src,alt:"tl_image_asset",draggable:!1})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:2,ry:2,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style),S(this,"transform",g1),S(this,"transformSingle",m1),S(this,"getSvgElement",e=>{let t=this.getBounds(e),n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttribute("width",`${t.width}`),n.setAttribute("height",`${t.height}`),n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),n})}},vze=qm("div",{pointerEvents:"all",position:"relative",fontFamily:"sans-serif",fontSize:"2em",height:"100%",width:"100%",borderRadius:"3px",perspective:"800px",overflow:"hidden",p:{userSelect:"none"},img:{userSelect:"none"},variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isFilled:{true:{},false:{}},isDarkMode:{true:{},false:{}}},compoundVariants:[{isFilled:!0,isDarkMode:!0,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"}},{isFilled:!0,isDarkMode:!1,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}]}),yze=qm("img",{position:"absolute",top:0,left:0,width:"100%",height:"100%",maxWidth:"100%",minWidth:"100%",pointerEvents:"none",objectFit:"cover",userSelect:"none",borderRadius:2});function Eze({strokeWidth:e,size:t}){return l.createElement("rect",{className:"tl-binding-indicator",x:e,y:e,width:Math.max(0,t[0]-e/2),height:Math.max(0,t[1]-e/2),strokeWidth:16*2})}var Cze=l.memo(function({id:e,style:t,size:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(t,i),u=1+a*1.618,d=Math.max(0,n[0]-u/2),h=Math.max(0,n[1]-u/2),p=[[[u/2,u/2],[d,u/2],d-u/2],[[d,u/2],[d,h],h-u/2],[[d,h],[u/2,h],d-u/2],[[u/2,h],[u/2,u/2],h-u/2]].map(([g,m,v],E)=>{let{strokeDasharray:w,strokeDashoffset:C}=N.getPerfectDashProps(v,a*1.618,t.dash);return l.createElement("line",{key:e+"_"+E,x1:g[0],y1:g[1],x2:m[0],y2:m[1],strokeDasharray:w,strokeDashoffset:C})});return l.createElement(l.Fragment,null,l.createElement("rect",{className:r||t.isFilled?"tl-fill-hitarea":"tl-stroke-hitarea",x:u/2,y:u/2,width:d,height:h,strokeWidth:16}),t.isFilled&&l.createElement("rect",{x:u/2,y:u/2,width:d,height:h,fill:s,pointerEvents:"none"}),l.createElement("g",{pointerEvents:"none",stroke:o,strokeWidth:u,strokeLinecap:"round"},p))});function bze(e,t,n){let r=bt(t),i=N.rng(e),o=r.strokeWidth,a=Math.max(0,n[0]),s=Math.max(0,n[1]),u=Array.from(Array(4)).map(()=>[i()*o*.75,i()*o*.75]),d=se.add([o/2,o/2],u[0]),h=se.add([a-o/2,o/2],u[1]),p=se.add([a-o/2,s-o/2],u[2]),g=se.add([o/2,s-o/2],u[3]),m=Math.round(Math.abs(i()*2*4)),v=Math.min(a/4,o*2),E=Math.min(s/4,o*2),w=Math.max(8,Math.floor(a/16)),C=Math.max(8,Math.floor(s/16)),b=N.rotateArray([se.pointsBetween(se.add(d,[v,0]),se.sub(h,[v,0]),w),se.pointsBetween(se.add(h,[0,E]),se.sub(p,[0,E]),C),se.pointsBetween(se.sub(p,[v,0]),se.add(g,[v,0]),w),se.pointsBetween(se.sub(g,[0,E]),se.add(d,[0,E]),C)],m);return{points:[...b.flat(),...b[0]].slice(5,Math.floor((m%2===0?w:C)/-2)+3)}}function zT(e,t,n){let{points:r}=bze(e,t,n),{strokeWidth:i}=bt(t);return{points:r,options:{size:i,thinning:.65,streamline:.3,smoothing:1,simulatePressure:!1,last:!0}}}function wze(e,t,n){let{points:r,options:i}=zT(e,t,n),o=Ah(r,i);return N.getSvgPathFromStroke(o)}function HT(e,t,n){let{points:r,options:i}=zT(e,t,n);return N.getSvgPathFromStrokePoints(vd(r,i))}var Sze=l.memo(function({id:e,style:t,size:n,isSelected:r,isDarkMode:i}){let{isFilled:o}=t,{stroke:a,strokeWidth:s,fill:u}=bt(t,i),d=wze(e,t,n),h=HT(e,t,n);return l.createElement(l.Fragment,null,l.createElement("path",{className:t.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",d:h}),o&&l.createElement("path",{d:h,fill:u,pointerEvents:"none"}),l.createElement("path",{d,fill:a,stroke:a,strokeWidth:s,pointerEvents:"none"}))}),xze=class extends gt{constructor(){super(...arguments),S(this,"type","rectangle"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"canEdit",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"rectangle",name:"Rectangle",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,isEditing:t,isBinding:n,isSelected:r,isGhost:i,meta:o,bounds:a,events:s,onShapeBlur:u,onShapeChange:d},h)=>{let{id:p,size:g,style:m,label:v="",labelPoint:E=IC}=e,w=ms(m),C=bt(m,o.isDarkMode),b=m.dash==="draw"?Sze:Cze,A=l.useCallback(T=>d==null?void 0:d({id:p,label:T}),[d]);return l.createElement(Aze,_({ref:h},s),l.createElement(p1,{isEditing:t,onChange:A,onBlur:u,font:w,text:v,color:C.stroke,offsetX:(E[0]-.5)*a.width,offsetY:(E[1]-.5)*a.height}),l.createElement(xi,{id:e.id+"_svg",opacity:i?.3:1},n&&l.createElement(Eze,{strokeWidth:C.strokeWidth,size:g}),l.createElement(b,{id:p,style:m,size:g,isSelected:r,isDarkMode:o.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,style:n,size:r}=e,i=bt(n,!1).strokeWidth;return n.dash==="draw"?l.createElement("path",{d:HT(t,n,r)}):l.createElement("rect",{x:i,y:i,rx:1,ry:1,width:Math.max(1,r[0]-i*2),height:Math.max(1,r[1]-i*2)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.label!==e.label),S(this,"transform",g1),S(this,"transformSingle",m1)}},Aze=fe("div",{width:"100%",height:"100%"}),kze=class extends gt{constructor(){super(...arguments),S(this,"type","sticky"),S(this,"canBind",!0),S(this,"canEdit",!0),S(this,"canClone",!0),S(this,"hideResizeHandles",!0),S(this,"showCloneHandles",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"sticky",name:"Sticky",parentId:"page",childIndex:1,point:[0,0],size:[200,200],text:"",rotation:0,style:TC},e)),S(this,"Component",gt.Component(({shape:e,meta:t,events:n,isGhost:r,isBinding:i,isEditing:o,onShapeBlur:a,onShapeChange:s},u)=>{let d=GNe(e.style),{color:h,fill:p}=MS(e.style,t.isDarkMode),g=l.useRef(null),m=l.useRef(null),v=l.useRef(null),E=l.useRef(!1),w=l.useCallback(I=>{I.stopPropagation()},[]),C=l.useCallback(I=>{s==null||s({id:e.id,type:e.type,text:Q.normalizeText(I)})},[e.id]),b=l.useCallback(I=>{C(I.currentTarget.value)},[s,C]),A=l.useCallback(I=>{if(I.key==="Escape"){I.preventDefault(),I.stopPropagation(),a==null||a();return}if(I.key==="Tab"&&e.text.length===0){I.preventDefault();return}if(!(I.key==="Meta"||I.metaKey))I.stopPropagation();else if(I.key==="z"&&I.metaKey){I.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),I.stopPropagation(),I.preventDefault();return}(I.metaKey||I.ctrlKey)&&I.key==="="&&I.preventDefault(),I.key==="Tab"&&(I.preventDefault(),I.shiftKey?rr.unindent(I.currentTarget):rr.indent(I.currentTarget),s==null||s(q(_({},e),{text:Q.normalizeText(I.currentTarget.value)})))},[e,s]),T=l.useCallback(I=>{I.currentTarget.setSelectionRange(0,0),a==null||a()},[]),B=l.useCallback(I=>{!o||!E.current||I.currentTarget.select()},[o]);l.useEffect(()=>{if(o){E.current=!0;let I=m.current;I.focus(),I.select()}},[o]),l.useEffect(()=>{let I=v.current,{size:M}=e,{offsetHeight:O}=I,z=Yv-xo*2,K=M[1]-xo*2;if(O===K)return;if(O>z){s==null||s({id:e.id,size:[M[0],O+xo*2]});return}if(OYv){s==null||s({id:e.id,size:[M[0],Yv]});return}let X=m.current;X==null||X.focus()},[e.text,e.size[1],e.style]);let D={font:d,color:h,textShadow:t.isDarkMode?"0.5px 0.5px 2px rgba(255, 255, 255,.25)":"0.5px 0.5px 2px rgba(255, 255, 255,.5)"};return l.createElement(Tm,_({ref:u},n),l.createElement(Ize,{ref:g,isDarkMode:t.isDarkMode,isGhost:r,style:_({backgroundColor:p},D)},i&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(Dze,{ref:v,isEditing:o,alignment:e.style.textAlign},e.text,"​"),o&&l.createElement(Tze,{ref:m,onPointerDown:w,value:e.text,onChange:b,onKeyDown:A,onFocus:B,onBlur:T,tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,spellCheck:!0,alignment:e.style.textAlign,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:3,ry:3,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.text!==e.text),S(this,"transform",(e,t,{scaleX:n,scaleY:r,transformOrigin:i})=>({point:$.toFixed([t.minX+(t.width-e.size[0])*(n<0?1-i[0]:i[0]),t.minY+(t.height-e.size[1])*(r<0?1-i[1]:i[1])])})),S(this,"transformSingle",e=>e),S(this,"getSvgElement",(e,t)=>{var n,r;let i=this.getBounds(e),o=MS(e.style,t),a=FT(e.style.size)*((n=e.style.scale)!=null?n:1),s=Dd(e.style.font).slice(1,-1),u=(r=e.style.textAlign)!=null?r:"start",d=h1(e.text,a,s,u,i.width-xo*2,!0);d.setAttribute("fill",o.color),d.setAttribute("transform",`translate(${xo}, ${xo})`);let h=document.createElementNS("http://www.w3.org/2000/svg","g"),p=document.createElementNS("http://www.w3.org/2000/svg","rect");return p.setAttribute("width",i.width+""),p.setAttribute("height",i.height+""),p.setAttribute("fill",o.fill),p.setAttribute("rx","3"),p.setAttribute("ry","3"),h.appendChild(p),h.appendChild(d),h})}},xo=16,Yv=200,Ize=fe("div",{pointerEvents:"all",position:"relative",backgroundColor:"rgba(255, 220, 100)",fontFamily:"sans-serif",height:"100%",width:"100%",padding:xo+"px",borderRadius:"3px",perspective:"800px",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isDarkMode:{true:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"},false:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}}}),jT={whiteSpace:"pre-wrap",overflowWrap:"break-word",letterSpacing:kl},Dze=fe("div",_({position:"absolute",top:xo,left:xo,width:`calc(100% - ${xo*2}px)`,height:"fit-content",font:"inherit",pointerEvents:"none",userSelect:"none",variants:{isEditing:{true:{opacity:1},false:{opacity:1}},alignment:{start:{textAlign:"left"},middle:{textAlign:"center"},end:{textAlign:"right"},justify:{textAlign:"justify"}}}},jT)),Tze=fe("textarea",q(_({width:"100%",height:"100%",border:"none",overflow:"hidden",background:"none",outline:"none",textAlign:"left",font:"inherit",padding:0,color:"transparent",verticalAlign:"top",resize:"none",caretColor:"black"},jT),{variants:{alignment:{start:{textAlign:"left"},middle:{textAlign:"center"},end:{textAlign:"right"},justify:{textAlign:"justify"}}},"&:focus":{outline:"none",border:"none"}})),Pze=class extends gt{constructor(){super(...arguments),S(this,"type","text"),S(this,"isAspectRatioLocked",!0),S(this,"canEdit",!0),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"bindingDistance",16/2),S(this,"getShape",e=>N.deepMerge({id:"id",type:"text",name:"Text",parentId:"page",childIndex:1,point:[0,0],rotation:0,text:" ",style:TC},e)),S(this,"texts",new Map),S(this,"Component",gt.Component(({shape:e,isBinding:t,isGhost:n,isEditing:r,onShapeBlur:i,onShapeChange:o,meta:a,events:s},u)=>{let{text:d,style:h}=e,p=bt(h,a.isDarkMode),g=ms(e.style),m=l.useRef(null),v=l.useRef(!1),E=l.useRef(d);l.useLayoutEffect(()=>{if(d!==E.current){let D=[0,0];this.texts.set(e.id,d);let I=this.getBounds(e),M=this.getBounds(e);switch(e.style.textAlign){case"start":break;case"middle":{D=$.div([M.width-I.width,0],2);break}case"end":{D=[M.width-I.width,0];break}}E.current=d,o==null||o(q(_({},e),{id:e.id,point:$.sub(e.point,D),text:d}))}},[d]);let w=l.useCallback(D=>{let I=[0,0],M=Q.normalizeText(D.currentTarget.value),O=this.getBounds(e);this.texts.set(e.id,M);let z=this.getBounds(q(_({},e),{text:M}));switch(e.style.textAlign){case"start":break;case"middle":{I=$.div([z.width-O.width,0],2);break}case"end":{I=[z.width-O.width,0];break}}E.current=M,o==null||o(q(_({},e),{id:e.id,point:$.sub(e.point,I),text:M}))},[e.id,e.point]),C=l.useCallback(D=>{if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),i==null||i();return}if(D.key==="Tab"&&e.text.length===0){D.preventDefault();return}if(D.key==="Enter"&&(D.metaKey||D.ctrlKey)){D.preventDefault(),D.stopPropagation(),m.current.blur();return}if(!(D.key==="Meta"||D.metaKey))D.stopPropagation();else if(D.key==="z"&&D.metaKey){D.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),D.stopPropagation(),D.preventDefault();return}(D.metaKey||D.ctrlKey)&&D.key==="="&&D.preventDefault(),D.key==="Tab"&&(D.preventDefault(),D.shiftKey?rr.unindent(D.currentTarget):rr.indent(D.currentTarget),o==null||o(q(_({},e),{text:Q.normalizeText(D.currentTarget.value)})))},[e,o]),b=l.useCallback(D=>{D.currentTarget.setSelectionRange(0,0),i==null||i()},[]),A=l.useCallback(D=>{!r||!v.current||document.activeElement===D.currentTarget&&D.currentTarget.select()},[r]),T=l.useCallback(D=>{r&&D.stopPropagation()},[r]),B=l.useRef(r);return l.useEffect(()=>{r?(B.current=!0,this.texts.set(e.id,d),requestAnimationFrame(()=>{v.current=!0;let D=m.current;D&&(D.focus(),D.select())})):B.current&&(B.current=!1,i==null||i())},[r]),l.createElement(Tm,_({ref:u},s),l.createElement(Mze,{isGhost:n,isEditing:r,onPointerDown:T},l.createElement($ze,{style:{font:g,color:p.stroke,textAlign:BNe(h.textAlign)}},t&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),r?l.createElement(Rze,{ref:m,style:{font:g,color:p.stroke},name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:d,color:p.stroke,onFocus:A,onChange:w,onKeyDown:C,onBlur:b,onPointerDown:T,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or}):d,"​")))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{width:t,height:n}=this.getBounds(e);return l.createElement("rect",{x:0,y:0,width:t,height:n})})),S(this,"getBounds",e=>{let t=N.getFromCache(this.boundsCache,e,()=>{var n;if(!qs)return{minX:0,minY:0,maxX:10,maxY:10,width:10,height:10};qs.parentNode||document.body.appendChild(qs),qs.style.font=ms(e.style),qs.textContent=(n=this.texts.get(e.id))!=null?n:e.text;let r=qs.offsetWidth||1,i=qs.offsetHeight||1;return{minX:0,maxX:r,minY:0,maxY:i,width:r,height:i}});return N.translateBounds(t,e.point)}),S(this,"shouldRender",(e,t)=>t.text!==e.text||t.style.scale!==e.style.scale||t.style!==e.style),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let{rotation:o=0,style:{scale:a=1}}=n,s=a*Math.abs(Math.min(r,i));return{point:[t.minX,t.minY],rotation:r<0&&i>=0||i<0&&r>=0?-(o||0):o,style:q(_({},n.style),{scale:s})}}),S(this,"transformSingle",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let{style:{scale:o=1}}=n;return{point:$.toFixed([t.minX,t.minY]),style:q(_({},n.style),{scale:o*Math.max(Math.abs(i),Math.abs(r))})}}),S(this,"onDoubleClickBoundsHandle",e=>{let t=this.getCenter(e),n=this.getCenter(q(_({},e),{style:q(_({},e.style),{scale:1})}));return{style:q(_({},e.style),{scale:1}),point:$.toFixed($.add(e.point,$.sub(t,n)))}}),S(this,"getSvgElement",(e,t)=>{var n,r;let i=this.getBounds(e),o=bt(e.style,t),a=f1(e.style.size,e.style.font)*((n=e.style.scale)!=null?n:1),s=Dd(e.style.font).slice(1,-1),u=(r=e.style.textAlign)!=null?r:"middle",d=h1(e.text,a,s,u,i.width,!1);return d.setAttribute("fill",o.stroke),d})}},qs;function Bze(){var e;(e=document.getElementById("__textMeasure"))==null||e.remove();let t=document.createElement("pre");return t.id="__textMeasure",Object.assign(t.style,{whiteSpace:"pre",width:"auto",border:"1px solid transparent",padding:"4px",margin:"0px",letterSpacing:kl,opacity:"0",position:"absolute",top:"-500px",left:"0px",zIndex:"9999",pointerEvents:"none",userSelect:"none",alignmentBaseline:"mathematical",dominantBaseline:"mathematical"}),t.tabIndex=-1,document.body.appendChild(t),t}typeof window<"u"&&(qs=Bze());var Mze=fe("div",{width:"100%",height:"100%",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isEditing:{false:{pointerEvents:"all",userSelect:"all"},true:{pointerEvents:"none",userSelect:"none"}}}}),UT={whiteSpace:"pre-wrap",overflowWrap:"break-word"},$ze=fe("div",_({position:"absolute",width:"100%",height:"100%",padding:"4px",zIndex:1,minHeight:1,minWidth:1,lineHeight:1,letterSpacing:kl,outline:0,fontWeight:"500",backfaceVisibility:"hidden",userSelect:"none",pointerEvents:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",isEditing:{false:{},true:{pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"}}},UT)),Rze=fe("textarea",q(_({position:"absolute",top:0,left:0,zIndex:1,width:"100%",height:"100%",border:"none",padding:"4px",resize:"none",textAlign:"inherit",minHeight:"inherit",minWidth:"inherit",lineHeight:"inherit",letterSpacing:"inherit",outline:0,fontWeight:"inherit",overflow:"hidden",backfaceVisibility:"hidden",display:"inline-block",pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"},UT),{"&:focus":{outline:"none",border:"none"}}));function ul(e,t=0,n=0){let[r,i]=e,o=[[r/2,0],[r,i],[0,i]];return t&&(o=_Ne(o,t)),n&&(o=o.map(a=>se.rotWith(a,[r/2,i/2],n))),o}function _S(e){let[t,n]=e,r=[[t/2,0],[t,n],[0,n]];return[(r[0][0]+r[1][0]+r[2][0])/3,(r[0][1]+r[1][1]+r[2][1])/3]}function Fze(e,t,n){let[r,i]=t,o=N.rng(e),a=Array.from(Array(3)).map(()=>[o()*n*.75,o()*n*.75]),s=[se.add([r/2,0],a[0]),se.add([r,i],a[1]),se.add([0,i],a[2])],u=Math.round(Math.abs(o()*2*3)),d=N.rotateArray([se.pointsBetween(s[0],s[1],32),se.pointsBetween(s[1],s[2],32),se.pointsBetween(s[2],s[0],32)],u);return{points:[...d.flat(),...d[0]]}}function KT(e,t,n){let{strokeWidth:r}=bt(n),{points:i}=Fze(e,t,r);return{points:i,options:{size:r,thinning:.65,streamline:.3,smoothing:1,simulatePressure:!1,last:!0}}}function Lze(e,t,n){let{points:r,options:i}=KT(e,t,n),o=Ah(r,i);return N.getSvgPathFromStroke(o)}function Oze(e,t,n){let{points:r,options:i}=KT(e,t,n);return N.getSvgPathFromStrokePoints(vd(r,i))}var _ze=l.memo(function({id:e,size:t,style:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(n,i),u=1+a*1.618,d=ul(t),h=N.pointsToLineSegments(d,!0).map(([g,m],v)=>{let{strokeDasharray:E,strokeDashoffset:w}=N.getPerfectDashProps(se.dist(g,m),a*1.618,n.dash);return l.createElement("line",{key:e+"_"+v,x1:g[0],y1:g[1],x2:m[0],y2:m[1],stroke:o,strokeWidth:u,strokeLinecap:"round",strokeDasharray:E,strokeDashoffset:w})}),p=d.join();return l.createElement(l.Fragment,null,l.createElement("polygon",{className:n.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",points:p}),n.isFilled&&l.createElement("polygon",{fill:s,points:p,pointerEvents:"none"}),l.createElement("g",{pointerEvents:"stroke"},h))}),Nze=l.memo(function({id:e,size:t,style:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(n,i),u=Lze(e,t,n),d=Oze(e,t,n);return l.createElement(l.Fragment,null,l.createElement("path",{className:n.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",d}),n.isFilled&&l.createElement("path",{d,fill:s,pointerEvents:"none"}),l.createElement("path",{d:u,fill:o,stroke:o,strokeWidth:a,pointerEvents:"none"}))});function zze({size:e}){let t=ul(e).join();return l.createElement("polygon",{className:"tl-binding-indicator",points:t,strokeWidth:16*2})}var Hze=class extends gt{constructor(){super(...arguments),S(this,"type","triangle"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"canEdit",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"triangle",name:"Triangle",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,bounds:t,isBinding:n,isEditing:r,isSelected:i,isGhost:o,meta:a,events:s,onShapeChange:u,onShapeBlur:d},h)=>{let{id:p,label:g="",size:m,style:v,labelPoint:E=IC}=e,w=ms(v),C=bt(v,a.isDarkMode),b=v.dash==="draw"?Nze:_ze,A=l.useCallback(B=>u==null?void 0:u({id:p,label:B}),[u]),T=l.useMemo(()=>{let B=se.div(m,2);return(_S(m)[1]-B[1])*.72},[m]);return l.createElement(jze,_({ref:h},s),l.createElement(p1,{font:w,text:g,color:C.stroke,offsetX:(E[0]-.5)*t.width,offsetY:T+(E[1]-.5)*t.height,isEditing:r,onChange:A,onBlur:d}),l.createElement(xi,{id:e.id+"_svg",opacity:o?.3:1},n&&l.createElement(zze,{size:m}),l.createElement(b,{id:p,style:v,size:m,isSelected:i,isDarkMode:a.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:t}=e;return l.createElement("polygon",{points:ul(t).join()})})),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.label!==e.label),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"getExpandedBounds",e=>N.getBoundsFromPoints(ul(e.size,this.bindingDistance).map(t=>se.add(t,e.point)))),S(this,"hitTestLineSegment",(e,t,n)=>vC(t,n,this.getPoints(e)).didIntersect),S(this,"hitTestBounds",(e,t)=>N.boundsContained(this.getBounds(e),t)||Ite(t,this.getPoints(e)).length>0),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{let a=this.getExpandedBounds(e);if(!N.pointInBounds(n,a))return;let s=ul(e.size).map(C=>se.add(C,e.point)),u=ul(e.size,this.bindingDistance).map(C=>se.add(C,e.point)),d=N.pointsToLineSegments(s,!0).map(([C,b])=>se.distanceToLineSegment(C,b,n)).sort((C,b)=>C-b)[0];if(!(N.pointInPolygon(n,u)||dpC(r,i,C[0],C[1])).filter(C=>C.didIntersect).flatMap(C=>C.points);if(!h.length)return;let p=se.add(_S(e.size),e.point),g=h.sort((C,b)=>se.dist(b,r)-se.dist(C,r))[0],m=se.med(n,g),v,E;o?(v=se.dist(n,p)<16/2?p:n,E=0):(se.distanceToLineSegment(n,m,p)<16/2?v=p:v=m,N.pointInPolygon(n,s)?E=this.bindingDistance:E=Math.max(this.bindingDistance,d));let w=se.divV(se.sub(v,[a.minX,a.minY]),[a.width,a.height]);return{point:se.clampV(w,0,1),distance:E}}),S(this,"transform",g1),S(this,"transformSingle",m1)}getPoints(e){let{rotation:t=0,point:[n,r],size:[i,o]}=e;return[[n+i/2,r],[n,r+o],[n+i,r+o]].map(a=>se.rotWith(a,this.getCenter(e),t))}},jze=fe("div",{width:"100%",height:"100%"}),Uze=class extends gt{constructor(){super(...arguments),S(this,"type","video"),S(this,"canBind",!0),S(this,"canEdit",!0),S(this,"canClone",!0),S(this,"isAspectRatioLocked",!0),S(this,"showCloneHandles",!1),S(this,"isStateful",!0),S(this,"getShape",e=>N.deepMerge({id:"video",type:"video",name:"Video",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,assetId:"assetId",isPlaying:!0,currentTime:0},e)),S(this,"Component",gt.Component(({shape:e,asset:t={src:""},isBinding:n,isEditing:r,isGhost:i,meta:o,events:a,onShapeChange:s},u)=>{let d=l.useRef(null),h=l.useRef(null),{currentTime:p=0,size:g,isPlaying:m,style:v}=e;l.useLayoutEffect(()=>{let b=h.current;if(!b)return;let[A,T]=g;b.style.width=`${A}px`,b.style.height=`${T}px`},[g]),l.useLayoutEffect(()=>{let b=d.current;!b||(m?b.play():b.pause())},[m]),l.useLayoutEffect(()=>{let b=d.current;!b||p!==b.currentTime&&(b.currentTime=p)},[p]);let E=l.useCallback(()=>{s==null||s({id:e.id,isPlaying:!0})},[]),w=l.useCallback(()=>{s==null||s({id:e.id,isPlaying:!1})},[]),C=l.useCallback(()=>{let b=d.current;!b||!r||s==null||s({id:e.id,currentTime:b.currentTime})},[r]);return l.createElement(Tm,_({ref:u},a),n&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(Kze,{ref:h,isDarkMode:o.isDarkMode,isGhost:i,isFilled:v.isFilled},l.createElement(Vze,{ref:d,id:e.id+"_video",muted:!0,loop:!0,playsInline:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:r,autoPlay:m,onPlay:E,onPause:w,onTimeUpdate:C},l.createElement("source",{src:t.src}))))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:2,ry:2,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.isPlaying!==e.isPlaying),S(this,"getSvgElement",e=>{let t=this.getBounds(e),n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttribute("width",`${t.width}`),n.setAttribute("height",`${t.height}`),n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),n}),S(this,"transform",g1),S(this,"transformSingle",m1)}},Kze=qm("div",{pointerEvents:"all",position:"relative",fontFamily:"sans-serif",fontSize:"2em",height:"100%",width:"100%",borderRadius:"3px",perspective:"800px",overflow:"hidden",p:{userSelect:"none"},img:{userSelect:"none"},variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isFilled:{true:{},false:{}},isDarkMode:{true:{},false:{}}},compoundVariants:[{isFilled:!0,isDarkMode:!0,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"}},{isFilled:!0,isDarkMode:!1,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}]}),Vze=qm("video",{position:"absolute",top:0,left:0,width:"100%",height:"100%",maxWidth:"100%",minWidth:"100%",pointerEvents:"none",objectFit:"cover",userSelect:"none",borderRadius:2}),VT=new xze,GT=new Hze,JT=new fze,WT=new lze,BC=new rze,Gze=new Pze,Jze=new gze,Vy=new kze,Wze=new mze,Yze=new Uze,od={rectangle:VT,triangle:GT,ellipse:JT,draw:WT,arrow:BC,text:Gze,group:Jze,sticky:Vy,image:Wze,video:Yze},qze=e=>typeof e=="string"?od[e]:od[e.type],Be=class{static getShapeUtil(e){return qze(e)}static getSelectedShapes(e,t){let n=Be.getPage(e,t);return Be.getSelectedIds(e,t).map(r=>n.shapes[r])}static screenToWorld(e,t){let n=Be.getPageState(e,e.appState.currentPageId).camera;return $.sub($.div(t,n.zoom),n.point)}static getCameraZoom(e){return N.clamp(e,.1,5)}static getPage(e,t){return e.document.pages[t]}static getPageState(e,t){return e.document.pageStates[t]}static getSelectedIds(e,t){return Be.getPageState(e,t).selectedIds}static getShapes(e,t){return Object.values(Be.getPage(e,t).shapes)}static getCamera(e,t){return Be.getPageState(e,t).camera}static getShape(e,t,n){return Be.getPage(e,n).shapes[t]}static getCenter(e){return Be.getShapeUtil(e).getCenter(e)}static getBounds(e){return Be.getShapeUtil(e).getBounds(e)}static getRotatedBounds(e){return Be.getShapeUtil(e).getRotatedBounds(e)}static getSelectedBounds(e){return N.getCommonBounds(Be.getSelectedShapes(e,e.appState.currentPageId).map(t=>Be.getShapeUtil(t).getBounds(t)))}static getParentId(e,t,n){return Be.getShape(e,t,n).parentId}static getDocumentBranch(e,t,n){let r=Be.getShape(e,t,n);return r.children===void 0?[t]:[t,...r.children.flatMap(i=>Be.getDocumentBranch(e,i,n))]}static getSelectedBranchSnapshot(e,t,n){let r=Be.getPage(e,t),i=Be.getSelectedIds(e,t).flatMap(o=>Be.getDocumentBranch(e,o,t).map(a=>r.shapes[a])).filter(o=>!o.isLocked).map(N.deepClone);return n!==void 0?i.map(o=>_({id:o.id},n(o))):i}static getSelectedShapeSnapshot(e,t,n){let r=Be.getSelectedShapes(e,t).filter(i=>!i.isLocked).map(N.deepClone);return n!==void 0?r.map(i=>_({id:i.id},n(i))):r}static getAllEffectedShapeIds(e,t,n){let r=Be.getPage(e,n),i=new Set(t);return t.forEach(o=>{let a=r.shapes[o];function s(d){d.children!==void 0&&d.children.filter(h=>!i.has(h)).forEach(h=>{i.add(h),s(r.shapes[h])})}s(a);function u(d){let h=d.parentId;h!==r.id&&(i.has(h)||(i.add(h),u(r.shapes[h])))}u(a),i.forEach(d=>{Object.values(r.bindings).filter(h=>h.fromId===d||h.toId===d).forEach(h=>i.add(h.fromId===d?h.toId:h.fromId))})}),Array.from(i.values())}static getLinkedShapeIds(e,t,n,r=!0){let i=Be.getSelectedIds(e,t),o=Be.getPage(e,t),a=new Set(i),s=new Set,u=[...i],d=new Set(Object.values(o.shapes).filter(h=>{var p;return h.type==="arrow"&&(h.handles.start.bindingId||((p=h.handles)==null?void 0:p.end.bindingId))}));for(;u.length;){let h=u.pop();if(!(h&&d.size))break;s.has(h)||(s.add(h),d.forEach(p=>{var g,m;let{handles:{start:{bindingId:v},end:{bindingId:E}}}=p,w=v?o.bindings[v]:null,C=E?o.bindings[E]:null,b=!1;w&&w.toId===h?(n==="center"?b=!0:(g=p.decorations)!=null&&g.start&&C?b=n==="left":b=n==="right",b&&(r&&a.add(p.id),a.add(h),C&&(a.add(C.toId),u.push(C.toId)))):C&&C.toId===h&&(n==="center"?b=!0:(m=p.decorations)!=null&&m.end&&w?b=n==="left":b=n==="right",b&&(r&&a.add(p.id),a.add(h),w&&(a.add(w.toId),u.push(w.toId)))),(!w||a.has(w.toId))&&(!C||a.has(C.toId))&&d.delete(p)}))}return Array.from(a.values())}static getChildIndexAbove(e,t,n){let r=e.document.pages[n],i=r.shapes[t],o;if(i.parentId===r.id)o=Object.values(r.shapes).filter(u=>u.parentId===r.id).sort((u,d)=>u.childIndex-d.childIndex);else{let u=r.shapes[i.parentId];if(!u.children)throw Error("No children in parent!");o=u.children.map(d=>r.shapes[d]).sort((d,h)=>d.childIndex-h.childIndex)}let a=o.indexOf(i),s=o[a+1];return s?s.childIndex:i.childIndex+1}static getBeforeShape(e,t){return Object.fromEntries(Object.keys(t).map(n=>[n,e[n]]))}static mutateShapes(e,t,n,r,i=!1){let o={},a={};t.forEach((u,d)=>{let h=Be.getShape(e,u,r);if(h.isLocked)return;(h==null?void 0:h.type)==="group"&&(t.length===1||i)&&h.children.forEach((g,m)=>{let v=Be.getShape(e,g,r);if(v.isLocked)return;let E=n(v,m);E&&(o[g]=Be.getBeforeShape(v,E),a[g]=E)});let p=n(h,d);p&&(o[u]=Be.getBeforeShape(h,p),a[u]=p)});let s=N.deepMerge(e,{document:{pages:{[e.appState.currentPageId]:{shapes:a}}}});return{before:o,after:a,data:s}}static createShapes(e,t,n){let r={document:{pages:{[n]:{shapes:_({},Object.fromEntries(t.flatMap(o=>{let a=[[o.id,void 0]];if(o.parentId!==n){let s=Be.getShape(e,o.parentId,n);if(!s.children)throw Error("No children in parent!");a.push([s.id,{children:s.children}])}return a})))}}}},i={document:{pages:{[n]:{shapes:{shapes:_({},Object.fromEntries(t.flatMap(o=>{let a=[[o.id,o]];if(o.parentId!==n){let s=Be.getShape(e,o.parentId,n);if(!s.children)throw Error("No children in parent!");a.push([s.id,{children:[...s.children,o.id]}])}return a})))}}}}};return{before:r,after:i}}static deleteShapes(e,t,n){n=n||e.appState.currentPageId;let r=Be.getPage(e,n),i=typeof t[0]=="string"?t:t.map(s=>s.id),o={document:{pages:{[n]:{shapes:_({},Object.fromEntries(i.flatMap(s=>{let u=r.shapes[s],d=[[u.id,u]];if(u.parentId!==n){let h=r.shapes[u.parentId];if(!h.children)throw Error("No children in parent!");d.push([h.id,{children:h.children}])}return d}))),bindings:_({},Object.fromEntries(Object.values(r.bindings).filter(s=>i.includes(s.fromId)||i.includes(s.toId)).map(s=>[s.id,s])))}}}},a={document:{pages:{[n]:{shapes:_({},Object.fromEntries(i.flatMap(s=>{let u=r.shapes[s],d=[[u.id,void 0]];if(u.parentId!==r.id){let h=r.shapes[u.parentId];if(!h.children)throw Error("No children in parent!");d.push([h.id,{children:h.children.filter(p=>p!==u.id)}])}return d})))}}}};return{before:o,after:a}}static onSessionComplete(e){var t,n;let r=(n=(t=Be.getShapeUtil(e)).onSessionComplete)==null?void 0:n.call(t,e);return r?_(_({},e),r):e}static onChildrenChange(e,t,n){var r,i;if(!t.children)return;let o=(i=(r=Be.getShapeUtil(t)).onChildrenChange)==null?void 0:i.call(r,t,t.children.map(a=>Be.getShape(e,a,n)));return o?_(_({},t),o):t}static updateArrowBindings(e,t){var n,r,i,o,a,s;let u={start:$r(t.handles.start),end:$r(t.handles.end)},d={isBound:!1,handle:t.handles.start,point:$.add(t.handles.start.point,t.point)},h={isBound:!1,handle:t.handles.end,point:$.add(t.handles.end.point,t.point)};if(t.handles.start.bindingId){let p=((n=t.decorations)==null?void 0:n.start)!==void 0,g=t.handles.start,m=e.bindings[t.handles.start.bindingId];if(!m)throw Error("Could not find a binding to match the start handle's bindingId: "+t.handles.start.bindingId);let v=e.shapes[m.toId],E=Be.getShapeUtil(v),w=E.getBounds(v),C=E.getExpandedBounds(v),b=p?N.expandBounds(w,m.distance):w,{minX:A,minY:T,width:B,height:D}=C,I=$.add([A,T],$.mulV([B,D],$.rotWith(m.point,[.5,.5],v.rotation||0)));d={isBound:!0,hasDecoration:p,binding:m,handle:g,point:I,util:E,target:v,bounds:w,expandedBounds:C,intersectBounds:b,center:E.getCenter(v)}}if(t.handles.end.bindingId){let p=((r=t.decorations)==null?void 0:r.end)!==void 0,g=t.handles.end,m=e.bindings[t.handles.end.bindingId];if(!m)throw Error("Could not find a binding to match the end handle's bindingId");let v=e.shapes[m.toId],E=Be.getShapeUtil(v),w=E.getBounds(v),C=E.getExpandedBounds(v),b=p?N.expandBounds(w,m.distance):w,{minX:A,minY:T,width:B,height:D}=C,I=$.add([A,T],$.mulV([B,D],$.rotWith(m.point,[.5,.5],v.rotation||0)));h={isBound:!0,hasDecoration:p,binding:m,handle:g,point:I,util:E,target:v,bounds:w,expandedBounds:C,intersectBounds:b,center:E.getCenter(v)}}for(let p of["end","start"]){let g=p==="start"?d:h,m=p==="start"?h:d;if(g.isBound)if(!g.binding.distance)u[p].point=$.sub(g.point,t.point);else{let v=$.uni($.sub(g.point,m.point));switch(g.target.type){case"ellipse":{let E=uT(m.point,v,g.center,g.target.radius[0]+(g.hasDecoration?g.binding.distance:0),g.target.radius[1]+(g.hasDecoration?g.binding.distance:0),g.target.rotation||0).points.sort((w,C)=>$.dist(w,m.point)-$.dist(C,m.point));E[0]!==void 0&&(u[p].point=$.toFixed($.sub(E[0],t.point)));break}case"triangle":{let E=g.target.point,w=ul(g.target.size,g.hasDecoration?16:0,g.target.rotation).map(b=>$.add(b,E)),C=N.pointsToLineSegments(w,!0).map(([b,A])=>pC(m.point,v,b,A)).filter(b=>b.didIntersect).flatMap(b=>b.points).sort((b,A)=>$.dist(b,m.point)-$.dist(A,m.point));C[0]!==void 0&&(u[p].point=$.toFixed($.sub(C[0],t.point)));break}default:{let E=Kp(m.point,v,g.intersectBounds,g.target.rotation).filter(C=>C.didIntersect).map(C=>C.points[0]).sort((C,b)=>$.dist(C,m.point)-$.dist(b,m.point));if(!E[0])continue;let w;if(m.isBound&&(w=Kp(m.point,v,m.intersectBounds,m.target.rotation).filter(C=>C.didIntersect).map(C=>C.points[0]).sort((C,b)=>$.dist(C,m.point)-$.dist(b,m.point))[0]),m.isBound&&(E.length<2||w&&E[0]&&Math.ceil($.dist(E[0],w))<16*2.5||N.boundsContain(g.expandedBounds,m.expandedBounds)||N.boundsCollide(g.expandedBounds,m.expandedBounds))){let C=$.uni($.sub(m.point,g.point)),b=Kp(g.point,C,g.bounds,g.target.rotation).filter(A=>A.didIntersect).map(A=>A.points[0]);if(!b[0])continue;u[p].point=$.toFixed($.sub(b[0],t.point)),u[p==="start"?"end":"start"].point=$.toFixed($.add($.sub(b[0],t.point),$.mul(C,Math.min($.dist(b[0],m.point),16*2.5*(N.boundsContain(m.bounds,g.intersectBounds)?-1:1)))))}else if(!m.isBound&&(E[0]&&$.dist(E[0],m.point)<16*2.5||N.pointInBounds(m.point,g.intersectBounds))){let C=$.uni($.sub(g.center,m.point));return(o=(i=Be.getShapeUtil(t)).onHandleChange)==null?void 0:o.call(i,t,{[p]:q(_({},t.handles[p]),{point:$.toFixed($.add($.sub(m.point,t.point),$.mul(C,16*2.5)))})})}else E[0]&&(u[p].point=$.toFixed($.sub(E[0],t.point)))}}}}return(s=(a=Be.getShapeUtil(t)).onHandleChange)==null?void 0:s.call(a,t,u)}static transform(e,t,n){let r=Be.getShapeUtil(e).transform(e,t,n);return r?_(_({},e),r):e}static transformSingle(e,t,n){let r=Be.getShapeUtil(e).transformSingle(e,t,n);return r?_(_({},e),r):e}static getRotatedShapeMutation(e,t,n,r){var i,o;let a=$.sub(t,e.point),s=$.rotWith(t,n,r),u=$.toFixed($.sub(s,a));if(e.handles!==void 0)return(o=(i=this.getShapeUtil(e)).onHandleChange)==null?void 0:o.call(i,q(_({},e),{point:u}),Object.fromEntries(Object.entries(e.handles).map(([h,p])=>{let g=$.toFixed($.rotWith(p.point,a,r));return[h,q(_({},p),{point:g})]})));let d=N.clampRadians((e.rotation||0)+r);return{point:u,rotation:d}}static updateParents(e,t,n){let r=Be.getPage(e,t);if(n.length===0)return;let{shapes:i}=Be.getPage(e,t),o=Array.from(new Set(n.map(a=>i[a].parentId).values())).filter(a=>a!==r.id);for(let a of o){let s=i[a];if(!s.children)throw Error("A shape is parented to a shape without a children array.");Be.onChildrenChange(e,s,t)}Be.updateParents(e,t,o)}static getBinding(e,t,n){return Be.getPage(e,n).bindings[t]}static getBindings(e,t){let n=Be.getPage(e,t);return Object.values(n.bindings)}static getBindableShapeIds(e){return Be.getShapes(e,e.appState.currentPageId).filter(t=>Be.getShapeUtil(t).canBind).sort((t,n)=>n.childIndex-t.childIndex).map(t=>t.id)}static getBindingsWithShapeIds(e,t,n){return Array.from(new Set(Be.getBindings(e,n).filter(r=>t.includes(r.toId)||t.includes(r.fromId))).values())}static getRelatedBindings(e,t,n){let r=new Set(t),i=Be.getPage(e,n),o=Object.values(i.bindings),a=new Set(o.filter(d=>r.has(d.toId)||r.has(d.fromId))),s=a.size,u=-1;for(;u!==0;)a.forEach(d=>{let h=d.fromId;for(let p of o)p.fromId===h&&a.add(p),p.toId===h&&a.add(p)}),u=a.size-s,s=a.size;return Array.from(a.values())}static normalizeText(e){return e.replace(Be.fixNewLines,` +`,t-1)+1,o=rr.findLineEnd(r,n),a=e.value.slice(i,o),s=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=a.length-s.length;e.setSelectionRange(i,o),rr.insert(e,s);let d=/\t| {1,2}/.exec(r.slice(i,t)),h=d?d[0].length:0,p=t-h;e.setSelectionRange(t-h,Math.max(p,n-u))}},p1=l.memo(function({font:e,text:t,color:n,offsetX:r=0,offsetY:i=0,scale:o=1,isEditing:a=!1,onBlur:s,onChange:u}){let d=l.useRef(null),h=l.useRef(!1),p=l.useCallback(b=>{u(Q.normalizeText(b.currentTarget.value))},[u]),g=l.useCallback(b=>{if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),s==null||s();return}if(b.key==="Tab"&&t.length===0){b.preventDefault();return}if(!(b.key==="Meta"||b.metaKey))b.stopPropagation();else if(b.key==="z"&&b.metaKey){b.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),b.stopPropagation(),b.preventDefault();return}(b.metaKey||b.ctrlKey)&&b.key==="="&&b.preventDefault(),b.key==="Tab"&&(b.preventDefault(),b.shiftKey?rr.unindent(b.currentTarget):rr.indent(b.currentTarget),u==null||u(Q.normalizeText(b.currentTarget.value)))},[u]),m=l.useCallback(b=>{b.currentTarget.setSelectionRange(0,0),s==null||s()},[s]),v=l.useCallback(b=>{!a||!h.current||document.activeElement===b.currentTarget&&b.currentTarget.select()},[a]),E=l.useCallback(b=>{a&&b.stopPropagation()},[a]),w=l.useRef(a);l.useEffect(()=>{a?(w.current=!0,requestAnimationFrame(()=>{h.current=!0;let b=d.current;b&&(b.focus(),b.select())})):w.current&&(s==null||s(),w.current=!1)},[a,s]);let C=l.useRef(null);return l.useLayoutEffect(()=>{let b=C.current;if(!b)return;let A=T0(t,e);b.style.transform=`scale(${o}, ${o}) translate(${r}px, ${i}px)`,b.style.width=A[0]+1+"px",b.style.height=A[1]+1+"px"},[t,e,i,r,o]),l.createElement(JNe,null,l.createElement(WNe,{ref:C,hasText:!!t,isEditing:a,style:{font:e,color:n}},a?l.createElement(YNe,{ref:d,style:{font:e,color:n},name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:t,color:n,onFocus:v,onChange:p,onKeyDown:g,onBlur:m,onPointerDown:E,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or}):t,"​"))}),JNe=fe("div",{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",userSelect:"none",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}}}}),LT={whiteSpace:"pre-wrap",overflowWrap:"break-word",letterSpacing:kl},WNe=fe("div",_({position:"absolute",padding:"4px",zIndex:1,minHeight:1,minWidth:1,lineHeight:1,outline:0,fontWeight:"500",textAlign:"center",backfaceVisibility:"hidden",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",variants:{hasText:{false:{pointerEvents:"none"},true:{pointerEvents:"all"}},isEditing:{false:{userSelect:"none"},true:{background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"}}}},LT)),YNe=fe("textarea",q(_({position:"absolute",top:0,left:0,zIndex:1,width:"100%",height:"100%",border:"none",padding:"4px",resize:"none",textAlign:"inherit",minHeight:"inherit",minWidth:"inherit",lineHeight:"inherit",outline:0,fontWeight:"inherit",overflow:"hidden",backfaceVisibility:"hidden",display:"inline-block",pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text",fontSmooth:"always",WebkitFontSmoothing:"subpixel-antialiased",MozOsxFontSmoothing:"auto"},LT),{"&:focus":{outline:"none",border:"none"}}));function g1(e,t,{initialShape:n,transformOrigin:r,scaleX:i,scaleY:o}){if(e.rotation||n.isAspectRatioLocked){let a=se.toFixed(se.mul(n.size,Math.min(Math.abs(i),Math.abs(o)))),s=se.toFixed([t.minX+(t.width-e.size[0])*(i<0?1-r[0]:r[0]),t.minY+(t.height-e.size[1])*(o<0?1-r[1]:r[1])]),u=i<0&&o>=0||o<0&&i>=0?n.rotation?-n.rotation:0:n.rotation;return{size:a,point:s,rotation:u}}else return{point:se.toFixed([t.minX,t.minY]),size:se.toFixed([t.width,t.height])}}function m1(e,t){return{size:se.toFixed([t.width,t.height]),point:se.toFixed([t.minX,t.minY])}}var gt=class extends ay{constructor(){super(...arguments),S(this,"canBind",!1),S(this,"canEdit",!1),S(this,"canClone",!1),S(this,"isAspectRatioLocked",!1),S(this,"hideResizeHandles",!1),S(this,"bindingDistance",16),S(this,"hitTestPoint",(e,t)=>N.pointInBounds(t,this.getRotatedBounds(e))),S(this,"hitTestLineSegment",(e,t,n)=>{let r=N.getBoundsFromPoints([t,n]),i=this.getBounds(e);return N.boundsContain(i,r)||e.rotation?yC(t,n,N.getRotatedCorners(this.getBounds(e))).didIntersect:vC(t,n,this.getBounds(e)).length>0}),S(this,"create",e=>(this.refMap.set(e.id,l.createRef()),this.getShape(e))),S(this,"getCenter",e=>N.getBoundsCenter(this.getBounds(e))),S(this,"getExpandedBounds",e=>N.expandBounds(this.getBounds(e),this.bindingDistance)),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{let a=this.getBounds(e),s=this.getExpandedBounds(e);if(!N.pointInBounds(n,s))return;let u=Kp(r,i,s).filter(E=>E.didIntersect).map(E=>E.points[0]);if(!u.length)return;let d=this.getCenter(e),h=u.sort((E,w)=>$.dist(w,r)-$.dist(E,r))[0],p=$.med(n,h),g,m;o?(g=$.dist(n,d)<16/2?d:n,m=0):($.distanceToLineSegment(n,p,d)<16/2?g=d:g=p,N.pointInBounds(n,a)?m=this.bindingDistance:m=Math.max(this.bindingDistance,N.getBoundsSides(a).map(E=>$.distanceToLineSegment(E[1][0],E[1][1],n)).sort((E,w)=>E-w)[0]));let v=$.divV($.sub(g,[s.minX,s.minY]),[s.width,s.height]);return{point:$.clampV(v,0,1),distance:m}}),S(this,"mutate",(e,t)=>t),S(this,"transform",(e,t,n)=>q(_({},e),{point:[t.minX,t.minY]})),S(this,"transformSingle",(e,t,n)=>this.transform(e,t,n)),S(this,"updateChildren"),S(this,"onChildrenChange"),S(this,"onHandleChange"),S(this,"onRightPointHandle"),S(this,"onDoubleClickHandle"),S(this,"onDoubleClickBoundsHandle"),S(this,"onSessionComplete"),S(this,"getSvgElement",(e,t)=>{var n,r,i,o,a;let s=(n=document.getElementById(e.id+"_svg"))==null?void 0:n.cloneNode(!0);if(s){if((o=(i=(r=e.label)==null?void 0:r.trim())==null?void 0:i.length)!=null&&o){let u=e,d=document.createElementNS("http://www.w3.org/2000/svg","g"),h=ms(e.style),p=T0(e.label,h),g=f1(e.style.size,e.style.font)*((a=e.style.scale)!=null?a:1),m=Dd(e.style.font).slice(1,-1),v=h1(u.label,g,m,"middle",p[0],!1),E=this.getBounds(e);return v.setAttribute("transform",`translate(${E.width/2-p[0]/2}, ${E.height/2-p[1]/2})`),v.setAttribute("fill",bt(e.style,t).stroke),v.setAttribute("transform-origin","center center"),d.setAttribute("text-align","center"),d.setAttribute("text-anchor","middle"),d.appendChild(s),d.appendChild(v),d}return s}})}};function qNe(e,t,n,r){return["M",e[0],e[1],"A",n[2],n[2],0,0,r<0?0:1,t[0],t[1]].join(" ")}function yp(e,t){let{start:n,end:r}=e,i=se.dist(n.point,r.point),o=se.med(n.point,r.point),a=i/2*t,s=se.uni(se.vec(n.point,r.point));return se.toFixed(Math.abs(a)<10?o:se.add(o,se.mul(se.per(s),a)))}function XNe(e,t,n,r,i,o){let a=N.rng(e),s=bt(t).strokeWidth,u=i?se.nudge(n,r,s):n,d=o?se.nudge(r,n,s):r,h=Ah([u,d],{size:s,thinning:.618+a()*.2,easing:d1.easeOutQuad,simulatePressure:!0,streamline:0,last:!0});return N.getSvgPathFromStroke(h)}function ZNe(e,t,n,r,i,o,a,s,u,d){let h=N.rng(e),p=bt(t).strokeWidth,g=i?se.rotWith(n,a,p/u):n,m=o?se.rotWith(r,a,-(p/u)):r,v=se.angle(a,g),E=se.angle(a,m),w=[],C=8+Math.floor(Math.abs(u)/20*1+h()/2);for(let A=0;A0?"1":"0"} ${r}`),i&&d.push(RS(t,u,p,g,m<0)),o&&d.push(RS(r,u,p,g,m>=0))}return d.join(" ")}function Ep(e,t,n){if(se.dist2(t,se.med(e,n))<=4)return[e,n];let r=[],i=sl(e,t,n),o=[i[0],i[1]],a=i[2],s=se.angle(o,e),u=se.angle(o,n);for(let d=0;d<20;d++){let h=d/19,p=N.lerpAngles(s,u,h);r.push(se.nudgeAtAngle(o,p,a))}return r}function eze(e,t,n){if(n===e||n===t)return!0;let r=Math.PI*2,i=(t-e+r)%r,o=(n-e+r)%r;return i<=Math.PI!=o>i}function B0(e,t,n,r){let i=N.getSweep(e,n,r);return t*(2*Math.PI)*(i/(2*Math.PI))}function zg({left:e,middle:t,right:n,stroke:r,strokeWidth:i}){return l.createElement("g",null,l.createElement("path",{className:"tl-stroke-hitarea",d:`M ${e} L ${t} ${n}`}),l.createElement("path",{d:`M ${e} L ${t} ${n}`,fill:"none",stroke:r,strokeWidth:i,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"}))}var tze=l.memo(function({id:e,style:t,start:n,bend:r,end:i,arrowBend:o,decorationStart:a,decorationEnd:s,isDraw:u,isDarkMode:d}){let h=se.dist(n,i);if(h<2)return null;let p=bt(t,d),{strokeWidth:g}=p,m=1+g*1.618,v=sl(n,r,i),E=[v[0],v[1]],w=v[2],C=B0(E,w,n,i),b=N.rng(e),A=d1[b()>0?"easeInOutSine":"easeInOutCubic"],T=u?ZNe(e,t,n,i,a,s,E,w,C,A):qNe(n,i,v,o),{strokeDasharray:B,strokeDashoffset:D}=N.getPerfectDashProps(Math.abs(C),m,t.dash,2,!1),I=Math.min(h/3,g*8),M=a?Ky(n,I,E,w,C<0):null,O=s?Ky(i,I,E,w,C>=0):null;return l.createElement(l.Fragment,null,l.createElement("path",{className:"tl-stroke-hitarea",d:T}),l.createElement("path",{d:T,fill:u?p.stroke:"none",stroke:p.stroke,strokeWidth:u?0:m,strokeDasharray:B,strokeDashoffset:D,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"none"}),M&&l.createElement(zg,{left:M.left,middle:n,right:M.right,stroke:p.stroke,strokeWidth:m}),O&&l.createElement(zg,{left:O.left,middle:i,right:O.right,stroke:p.stroke,strokeWidth:m}))}),nze=l.memo(function({id:e,style:t,start:n,end:r,decorationStart:i,decorationEnd:o,isDraw:a,isDarkMode:s}){let u=se.dist(n,r);if(u<2)return null;let d=bt(t,s),{strokeWidth:h}=d,p=1+h*1.618,g=a?XNe(e,t,n,r,i,o):"M"+se.toFixed(n)+"L"+se.toFixed(r),{strokeDasharray:m,strokeDashoffset:v}=N.getPerfectDashProps(u,h*1.618,t.dash,2,!1),E=Math.min(u/3,h*8),w=i?Vy(n,r,E):null,C=o?Vy(r,n,E):null;return l.createElement(l.Fragment,null,l.createElement("path",{className:"tl-stroke-hitarea",d:g}),l.createElement("path",{d:g,fill:d.stroke,stroke:d.stroke,strokeWidth:a?p/2:p,strokeDasharray:m,strokeDashoffset:v,strokeLinecap:"round",strokeLinejoin:"round",pointerEvents:"stroke"}),w&&l.createElement(zg,{left:w.left,middle:n,right:w.right,stroke:d.stroke,strokeWidth:p}),C&&l.createElement(zg,{left:C.left,middle:r,right:C.right,stroke:d.stroke,strokeWidth:p}))}),rze=class extends gt{constructor(){super(...arguments),S(this,"type","arrow"),S(this,"hideBounds",!0),S(this,"canEdit",!0),S(this,"pathCache",new WeakMap),S(this,"getShape",e=>{var t,n,r,i;return _({id:"id",type:"arrow",name:"Arrow",parentId:"page",childIndex:1,point:[0,0],rotation:0,bend:0,handles:{start:_({id:"start",index:0,point:[0,0],canBind:!0},(t=e.handles)==null?void 0:t.start),end:_({id:"end",index:1,point:[1,1],canBind:!0},(n=e.handles)==null?void 0:n.end),bend:_({id:"bend",index:2,point:[.5,.5]},(r=e.handles)==null?void 0:r.bend)},decorations:(i=e.decorations)!=null?i:{end:"arrow"},style:_(q(_({},Vo),{isFilled:!1}),e.style),label:"",labelPoint:[.5,.5]},e)}),S(this,"Component",gt.Component(({shape:e,isEditing:t,isGhost:n,meta:r,events:i,onShapeChange:o,onShapeBlur:a},s)=>{var u,d;let{id:h,label:p="",handles:{start:g,bend:m,end:v},decorations:E={},style:w}=e,C=(d=(u=p==null?void 0:p.trim())==null?void 0:u.length)!=null?d:!1,b=$.dist(m.point,$.toFixed($.med(g.point,v.point)))<1,A=ms(w),T=bt(w,r.isDarkMode),B=C||t?T0(p,A):[0,0],D=this.getBounds(e),I=l.useMemo(()=>{let{start:X,bend:Z,end:pe}=e.handles;if(b)return $.dist(X.point,pe.point);let me=sl(X.point,Z.point,pe.point),Ce=me.slice(0,2),W=me[2],U=B0(Ce,W,X.point,pe.point);return Math.abs(U)},[e.handles]),M=Math.max(.5,Math.min(1,Math.max(I/(B[1]+128),I/(B[0]+128)))),O=l.useMemo(()=>{let X=this.getBounds(e);return $.sub(e.handles.bend.point,$.toFixed([X.width/2,X.height/2]))},[e,M]),z=l.useCallback(X=>{o==null||o({id:h,label:X})},[o]),K=b?nze:tze;return l.createElement(ize,_({ref:s},i),l.createElement(p1,{font:A,text:p,color:T.stroke,offsetX:O[0],offsetY:O[1],scale:M,isEditing:t,onChange:z,onBlur:a}),l.createElement(xi,{id:e.id+"_svg"},l.createElement("defs",null,l.createElement("mask",{id:e.id+"_clip"},l.createElement("rect",{x:-100,y:-100,width:D.width+200,height:D.height+200,fill:"white"}),l.createElement("rect",{x:D.width/2-B[0]/2*M+O[0],y:D.height/2-B[1]/2*M+O[1],width:B[0]*M,height:B[1]*M,rx:4*M,ry:4*M,fill:"black",opacity:1}))),l.createElement("g",{pointerEvents:"none",opacity:n?.3:1,mask:C||t?`url(#${e.id}_clip)`:""},l.createElement(K,{id:h,style:w,start:g.point,end:v.point,bend:m.point,arrowBend:e.bend,decorationStart:E==null?void 0:E.start,decorationEnd:E==null?void 0:E.end,isDraw:w.dash==="draw",isDarkMode:r.isDarkMode}))))})),S(this,"Indicator",gt.Indicator(({shape:e,bounds:t})=>{var n,r;let{style:i,decorations:o,label:a,handles:{start:s,bend:u,end:d}}=e,h=(r=(n=a==null?void 0:a.trim())==null?void 0:n.length)!=null?r:!1,p=ms(i),g=h?T0(a,p):[0,0],m=$.dist(u.point,$.toFixed($.med(s.point,d.point)))<1,v=l.useMemo(()=>{let{start:C,bend:b,end:A}=e.handles;if(m)return $.dist(C.point,A.point);let T=sl(C.point,b.point,A.point),B=T.slice(0,2),D=T[2],I=B0(B,D,C.point,A.point);return Math.abs(I)},[e.handles]),E=Math.max(.5,Math.min(1,Math.max(v/(g[1]+128),v/(g[0]+128)))),w=l.useMemo(()=>{let C=this.getBounds(e);return $.sub(e.handles.bend.point,[C.width/2,C.height/2])},[e,E]);return l.createElement(l.Fragment,null,h&&l.createElement(LNe,{id:e.id,scale:E,offset:w,bounds:t,labelSize:g}),l.createElement("path",{d:QNe(i,s.point,u.point,d.point,o==null?void 0:o.start,o==null?void 0:o.end),mask:h?`url(#${e.id}_clip)`:""}),h&&l.createElement("rect",{x:t.width/2-g[0]/2*E+w[0],y:t.height/2-g[1]/2*E+w[1],width:g[0]*E,height:g[1]*E,rx:4*E,ry:4*E,fill:"transparent"}))})),S(this,"getBounds",e=>{let t=N.getFromCache(this.boundsCache,e,()=>{let{handles:{start:n,bend:r,end:i}}=e;return N.getBoundsFromPoints(Ep(n.point,r.point,i.point))});return N.translateBounds(t,e.point)}),S(this,"getRotatedBounds",e=>{let{handles:{start:t,bend:n,end:r}}=e,i=Ep(t.point,n.point,r.point),{minX:o,minY:a,maxX:s,maxY:u}=N.getBoundsFromPoints(i);return e.rotation!==0&&(i=i.map(d=>$.rotWith(d,[(o+s)/2,(a+u)/2],e.rotation||0))),N.translateBounds(N.getBoundsFromPoints(i),e.point)}),S(this,"getCenter",e=>{let{start:t,end:n}=e.handles;return $.add(e.point,$.med(t.point,n.point))}),S(this,"shouldRender",(e,t)=>t.decorations!==e.decorations||t.handles!==e.handles||t.style!==e.style||t.label!==e.label),S(this,"hitTestPoint",(e,t)=>{let{handles:{start:n,bend:r,end:i}}=e,o=$.sub(t,e.point),a=Ep(n.point,r.point,i.point);for(let s=1;s{let{handles:{start:r,bend:i,end:o}}=e,a=$.sub(t,e.point),s=$.sub(n,e.point),u=Ep(r.point,i.point,o.point);for(let d=1;d{let{start:n,end:r,bend:i}=e.handles,o=$.add(e.point,n.point),a=$.add(e.point,r.point);if(N.pointInBounds(o,t)||N.pointInBounds(a,t))return!0;if($.isEqual($.med(n.point,r.point),i.point))return vC(o,a,t).length>0;{let[s,u,d]=sl(n.point,i.point,r.point),h=$.add(e.point,[s,u]);return Ete(h,d,o,a,t).length>0}}),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let o=this.getBounds(n),a=["start","end"],s=_({},n.handles);a.forEach(h=>{if(h==="bend")return;let[p,g]=s[h].point,m=p/o.width,v=g/o.height;s[h]=q(_({},s[h]),{point:[t.width*(r<0?1-m:m),t.height*(i<0?1-v:v)]})});let u=r>0&&i<0||r<0&&i>0?-n.bend:n.bend,d=yp(s,u);return s.bend.point=d,{point:$.toFixed([t.minX,t.minY]),handles:s,bend:u}}),S(this,"onDoubleClickHandle",(e,t)=>{var n,r;switch(t){case"bend":return{bend:0,handles:q(_({},e.handles),{bend:q(_({},e.handles.bend),{point:yp(e.handles,e.bend)})})};case"start":return{decorations:q(_({},e.decorations),{start:(n=e.decorations)!=null&&n.start?void 0:"arrow"})};case"end":return{decorations:q(_({},e.decorations),{end:(r=e.decorations)!=null&&r.end?void 0:"arrow"})}}return this}),S(this,"onHandleChange",(e,t)=>{let n=N.deepMerge(e.handles,t),r=e.bend;if(n=N.deepMerge(n,{start:{point:$.toFixed(n.start.point)},end:{point:$.toFixed(n.end.point)}}),$.isEqual(n.start.point,n.end.point))return;if("bend"in t){let{start:u,end:d,bend:h}=n,p=$.dist(u.point,d.point),g=$.med(u.point,d.point),m=$.angle(u.point,d.point),v=$.uni($.vec(u.point,d.point)),E=$.add(g,$.mul($.per(v),p)),w=$.sub(g,$.mul($.per(v),p)),C=$.nearestPointOnLineSegment(E,w,h.point,!0),b=$.dist(g,C)/(p/2);r=N.clamp(b,-.99,.99);let A=$.angle(u.point,C);$.isEqual(g,yp(n,r))?r=0:eze(m,m+Math.PI,A)&&(r*=-1)}let i={point:e.point,bend:r,handles:q(_({},n),{bend:q(_({},n.bend),{point:yp(n,r)})})},o=e.point,a=this.getBounds(_({},i)),s=$.sub([a.minX,a.minY],o);return $.isEqual(s,[0,0])||(Object.values(i.handles).forEach(u=>{u.point=$.toFixed($.sub(u.point,s))}),i.point=$.toFixed($.add(i.point,s))),i}),S(this,"getSvgElement",(e,t)=>{var n,r,i,o,a;let s=(n=document.getElementById(e.id+"_svg"))==null?void 0:n.cloneNode(!0);if(s){if((o=(i=(r=e.label)==null?void 0:r.trim())==null?void 0:i.length)!=null&&o){let u=e,d=document.createElementNS("http://www.w3.org/2000/svg","g"),h=ms(e.style),p=T0(e.label,h),g=f1(e.style.size,e.style.font)*((a=e.style.scale)!=null?a:1),m=Dd(e.style.font).slice(1,-1),v=h1(u.label,g,m,"start",p[0],!1),E,{start:w,bend:C,end:b}=e.handles;if($.dist(C.point,$.toFixed($.med(w.point,b.point)))<1)E=$.dist(w.point,b.point);else{let M=sl(w.point,C.point,b.point),O=M.slice(0,2),z=M[2],K=B0(O,z,w.point,b.point);E=Math.abs(K)}let A=Math.max(.5,Math.min(1,Math.max(E/(p[1]+128),E/(p[0]+128)))),T=this.getBounds(e),B=$.sub(e.handles.bend.point,[T.width/2,T.height/2]),D=T.width/2-p[0]/2*A+B[0],I=T.height/2-p[1]/2*A+B[1];return v.setAttribute("transform",`translate(${D}, ${I})`),v.setAttribute("fill",bt(e.style,t).stroke),v.setAttribute("transform-origin","center center"),d.setAttribute("text-align","center"),d.setAttribute("text-anchor","middle"),d.appendChild(s),d.appendChild(v),d}return s}})}},ize=fe("div",{width:"100%",height:"100%"}),oze={easing:e=>Math.sin(e*Math.PI/2),simulatePressure:!0},aze={easing:e=>e*e,simulatePressure:!1};function BC(e){let t=bt(e.style);return q(_({size:1+t.strokeWidth*1.5,thinning:.65,streamline:.65,smoothing:.65},e.points[1][2]===.5?oze:aze),{last:e.isComplete})}function sze(e){return e.points.length<2?"":N.getSvgPathFromStroke(vd(e.points,BC(e)).map(t=>t.point))}function OT(e,t){return vd(e.points,t)}function uze(e){if(e.points.length<2)return"";let t=BC(e),n=OT(e,t);return N.getSvgPathFromStroke(EE(n,t))}function LS(e){let{points:t}=e;if(t.length<2)return"M 0 0 L 0 0";let n=BC(e),r=OT(e,n),i=t[t.length-1];return se.isEqual(r[0].point,i)||r.push({point:i}),N.getSvgPathFromStrokePoints(r)}var lze=class extends gt{constructor(){super(...arguments),S(this,"type","draw"),S(this,"pointsBoundsCache",new WeakMap([])),S(this,"shapeBoundsCache",new Map),S(this,"rotatedCache",new WeakMap([])),S(this,"pointCache",{}),S(this,"canClone",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"draw",name:"Draw",parentId:"page",childIndex:1,point:[0,0],rotation:0,style:Vo,points:[],isComplete:!1},e)),S(this,"Component",gt.Component(({shape:e,meta:t,isSelected:n,isGhost:r,events:i},o)=>{let{points:a,style:s,isComplete:u}=e,d=l.useMemo(()=>sze(e),[a,s.size]),h=l.useMemo(()=>s.dash==="draw"?uze(e):LS(e),[a,s.size,s.dash,u]),p=bt(s,t.isDarkMode),{stroke:g,fill:m,strokeWidth:v}=p,E=this.getBounds(e);if(E.width<=v/2&&E.height<=v/2){let T=1+v;return l.createElement(xi,_({ref:o,id:e.id+"_svg"},i),l.createElement("circle",{r:T,fill:g,stroke:g,pointerEvents:"all",opacity:r?.3:1}))}let w=s.isFilled&&a.length>3&&$.dist(a[0],a[a.length-1]){let{points:t}=e,n=l.useMemo(()=>LS(e),[t]),r=this.getBounds(e);return r.width<4&&r.height<4?l.createElement("circle",{x:r.width/2,y:r.height/2,r:1}):l.createElement("path",{d:n})})),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let o=N.getFromCache(this.boundsCache,n,()=>N.getBoundsFromPoints(n.points)),a=n.points.map(([d,h,p])=>[t.width*(r<0?1-d/o.width:d/o.width),t.height*(i<0?1-h/o.height:h/o.height),p]),s=N.getBoundsFromPoints(e.points),u=$.sub([t.minX,t.minY],[s.minX,s.minY]);return{points:a,point:u}}),S(this,"getBounds",e=>{let t=!this.pointsBoundsCache.has(e.points),n=this.pointCache[e.id]!==e.point;if(t){let r=N.getBoundsFromPoints(e.points);this.pointsBoundsCache.set(e.points,r),this.shapeBoundsCache.set(e.id,N.translateBounds(r,e.point)),this.pointCache[e.id]=e.point}else n&&!t&&(this.pointCache[e.id]=e.point,this.shapeBoundsCache.set(e.id,N.translateBounds(this.pointsBoundsCache.get(e.points),e.point)));return this.shapeBoundsCache.get(e.id)}),S(this,"shouldRender",(e,t)=>t.points!==e.points||t.style!==e.style||t.isComplete!==e.isComplete),S(this,"hitTestPoint",(e,t)=>{let n=$.sub(t,e.point);return N.pointInPolyline(n,e.points)}),S(this,"hitTestLineSegment",(e,t,n)=>{let{points:r,point:i}=e,o=$.sub(t,i),a=$.sub(n,i),s=this.getBounds(e);if(s.width<8&&s.height<8)return $.distanceToLineSegment(t,n,N.getBoundsCenter(s))<5;if(vC(o,a,s)){for(let u=1;u{if(!e.rotation){let i=this.getBounds(e);return N.boundsContain(t,i)||(N.boundsContain(i,t)||kte(i,t).length>0)&&CS(N.translateBounds(t,$.neg(e.point)),e.points).length>0}let n=this.getRotatedBounds(e),r=N.getFromCache(this.rotatedCache,e,()=>{let i=N.getBoundsCenter(N.getBoundsFromPoints(e.points));return e.points.map(o=>$.rotWith(o,i,e.rotation||0))});return N.boundsContain(t,n)||CS(N.translateBounds(t,$.neg(e.point)),r).length>0})}},cze=l.memo(function({radius:e,style:t,isSelected:n,isDarkMode:r}){let{stroke:i,strokeWidth:o,fill:a}=bt(t,r),s=1+o*1.618,u=Math.max(0,e[0]-s/2),d=Math.max(0,e[1]-s/2),h=N.perimeterOfEllipse(u,d),{strokeDasharray:p,strokeDashoffset:g}=N.getPerfectDashProps(h<64?h*2:h,o*1.618,t.dash,4);return l.createElement(l.Fragment,null,l.createElement("ellipse",{className:t.isFilled||n?"tl-fill-hitarea":"tl-stroke-hitarea",cx:e[0],cy:e[1],rx:e[0],ry:e[1]}),l.createElement("ellipse",{cx:e[0],cy:e[1],rx:u,ry:d,fill:a,stroke:i,strokeWidth:s,strokeDasharray:p,strokeDashoffset:g,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round"}))});function _T(e,t,n){let{strokeWidth:r}=bt(n),i=N.rng(e),o=t[0]+i()*r*2,a=t[1]+i()*r*2,s=N.perimeterOfEllipse(o,a),u=[],d=Math.PI+Math.PI*i(),h=Math.abs(i()),p=Math.max(16,s/10);for(let g=0;gN.deepMerge({id:"id",type:"ellipse",name:"Ellipse",parentId:"page",childIndex:1,point:[0,0],radius:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,isGhost:t,isSelected:n,isBinding:r,isEditing:i,meta:o,bounds:a,events:s,onShapeChange:u,onShapeBlur:d},h)=>{let{id:p,radius:g,style:m,label:v="",labelPoint:E=DC}=e,w=ms(e.style),C=bt(m,o.isDarkMode),b=C.strokeWidth,A=1+b*1.618,T=Math.max(0,g[0]-A/2),B=Math.max(0,g[1]-A/2),D=m.dash==="draw"?hze:cze,I=l.useCallback(M=>u==null?void 0:u({id:p,label:M}),[u]);return l.createElement(pze,_({ref:h},s),l.createElement(p1,{isEditing:i,onChange:I,onBlur:d,font:w,text:v,color:C.stroke,offsetX:(E[0]-.5)*a.width,offsetY:(E[1]-.5)*a.height}),l.createElement(xi,{id:e.id+"_svg",opacity:t?.3:1},r&&l.createElement("ellipse",{className:"tl-binding-indicator",cx:g[0],cy:g[1],rx:T,ry:B,strokeWidth:this.bindingDistance}),l.createElement(D,{id:p,radius:g,style:m,isSelected:n,isDarkMode:o.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,radius:n,style:r}=e,i=bt(r).strokeWidth,o=1+i*1.618,a=Math.max(0,n[0]-o/2),s=Math.max(0,n[1]-o/2);return r.dash==="draw"?l.createElement("path",{d:NT(t,n,r)}):l.createElement("ellipse",{cx:n[0],cy:n[1],rx:a,ry:s})})),S(this,"hitTestPoint",(e,t)=>N.pointInBounds(t,this.getRotatedBounds(e))&&N.pointInEllipse(t,this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0)),S(this,"hitTestLineSegment",(e,t,n)=>zc(t,n,this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0).didIntersect),S(this,"getBounds",e=>N.getFromCache(this.boundsCache,e,()=>N.getRotatedEllipseBounds(e.point[0],e.point[1],e.radius[0],e.radius[1],0))),S(this,"getRotatedBounds",e=>N.getRotatedEllipseBounds(e.point[0],e.point[1],e.radius[0],e.radius[1],e.rotation)),S(this,"hitTestBounds",(e,t)=>{let n=this.getBounds(e);return N.boundsContained(n,t)||xte(this.getCenter(e),e.radius[0],e.radius[1],e.rotation||0,t).length>0}),S(this,"shouldRender",(e,t)=>t.radius!==e.radius||t.style!==e.style||t.label!==e.label),S(this,"getCenter",e=>$.add(e.point,e.radius)),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{{let a=this.getExpandedBounds(e),s=this.getCenter(e),u,d;if(!N.pointInEllipse(n,s,e.radius[0]+this.bindingDistance,e.radius[1]+this.bindingDistance))return;if(o)$.dist(n,this.getCenter(e))<12?u=[.5,.5]:u=$.divV($.sub(n,[a.minX,a.minY]),[a.width,a.height]),d=0;else{let h=uT(r,i,s,e.radius[0],e.radius[1],e.rotation||0).points.sort((g,m)=>$.dist(g,r)-$.dist(m,r))[0];if(h||(h=zc(n,s,s,e.radius[0],e.radius[1],e.rotation||0).points.sort((g,m)=>$.dist(g,n)-$.dist(m,n))[0]),!h)return;let p=$.med(n,h);if($.distanceToLineSegment(n,p,this.getCenter(e))<12?u=[.5,.5]:u=$.divV($.sub(p,[a.minX,a.minY]),[a.width,a.height]),N.pointInEllipse(n,s,e.radius[0],e.radius[1],e.rotation||0))d=this.bindingDistance/2;else{let g=zc(n,s,s,e.radius[0],e.radius[1],e.rotation||0).points[0];if(!g)return;d=Math.max(this.bindingDistance/2,$.dist(n,g))}}return{point:u,distance:d}}}),S(this,"transform",(e,t,{scaleX:n,scaleY:r,initialShape:i})=>{let{rotation:o=0}=i;return{point:[t.minX,t.minY],radius:[t.width/2,t.height/2],rotation:n<0&&r>=0||r<0&&n>=0?-(o||0):o||0}}),S(this,"transformSingle",(e,t)=>({point:$.toFixed([t.minX,t.minY]),radius:$.div([t.width,t.height],2)}))}},pze=fe("div",{width:"100%",height:"100%"}),gze=class extends gt{constructor(){super(...arguments),S(this,"type","group"),S(this,"canBind",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"group",name:"Group",parentId:"page",childIndex:1,point:[0,0],size:[100,100],rotation:0,children:[],style:Vo},e)),S(this,"Component",gt.Component(({shape:e,isBinding:t,isGhost:n,isHovered:r,isSelected:i,events:o},a)=>{let{id:s,size:u}=e,d=2,h=Math.max(0,u[0]-d/2),p=Math.max(0,u[1]-d/2),g=[[[d/2,d/2],[h,d/2],h-d/2],[[h,d/2],[h,p],p-d/2],[[h,p],[d/2,p],h-d/2],[[d/2,p],[d/2,d/2],p-d/2]].map(([m,v],E)=>l.createElement("line",{key:s+"_"+E,x1:m[0],y1:m[1],x2:v[0],y2:v[1]}));return l.createElement(xi,_({ref:a},o),t&&l.createElement("rect",{className:"tl-binding-indicator",strokeWidth:this.bindingDistance}),l.createElement("g",{opacity:n?.3:1},l.createElement("rect",{x:0,y:0,width:u[0],height:u[1],fill:"transparent",pointerEvents:"all"}),l.createElement(OS,{stroke:"black",opacity:r||i?1:0,strokeLinecap:"round",pointerEvents:"stroke"},g)))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,size:n}=e,r=2,i=Math.max(0,n[0]-r/2),o=Math.max(0,n[1]-r/2),a=[[[r/2,r/2],[i,r/2],i-r/2],[[i,r/2],[i,o],o-r/2],[[i,o],[r/2,o],i-r/2],[[r/2,o],[r/2,r/2],o-r/2]].map(([s,u],d)=>l.createElement("line",{key:t+"_"+d,x1:s[0],y1:s[1],x2:u[0],y2:u[1]}));return l.createElement(OS,{strokeLinecap:"round",pointerEvents:"stroke"},a)})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style)}},OS=fe("g",{strokeWidth:"calc(1.5px * var(--tl-scale))",strokeDasharray:"calc(1px * var(--tl-scale)), calc(3px * var(--tl-scale))"}),mze=class extends gt{constructor(){super(...arguments),S(this,"type","image"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"isAspectRatioLocked",!0),S(this,"showCloneHandles",!1),S(this,"getShape",e=>N.deepMerge({id:"image",type:"image",name:"Image",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:q(_({},Vo),{isFilled:!0}),assetId:"assetId"},e)),S(this,"Component",gt.Component(({shape:e,asset:t={src:""},isBinding:n,isGhost:r,meta:i,events:o,onShapeChange:a},s)=>{let{size:u,style:d}=e,{bindingDistance:h}=this,p=l.useRef(null),g=l.useRef(null);return l.useLayoutEffect(()=>{let m=g.current;if(!m)return;let[v,E]=u;m.style.width=`${v}px`,m.style.height=`${E}px`},[u]),l.createElement(Tm,_({ref:s},o),n&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:`calc(${-h}px * var(--tl-zoom))`,left:`calc(${-h}px * var(--tl-zoom))`,width:`calc(100% + ${h*2}px * var(--tl-zoom))`,height:`calc(100% + ${h*2}px * var(--tl-zoom))`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(vze,{ref:g,isDarkMode:i.isDarkMode,isFilled:d.isFilled,isGhost:r},l.createElement(yze,{id:e.id+"_image",ref:p,src:t.src,alt:"tl_image_asset",draggable:!1})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:2,ry:2,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style),S(this,"transform",g1),S(this,"transformSingle",m1),S(this,"getSvgElement",e=>{let t=this.getBounds(e),n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttribute("width",`${t.width}`),n.setAttribute("height",`${t.height}`),n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),n})}},vze=qm("div",{pointerEvents:"all",position:"relative",fontFamily:"sans-serif",fontSize:"2em",height:"100%",width:"100%",borderRadius:"3px",perspective:"800px",overflow:"hidden",p:{userSelect:"none"},img:{userSelect:"none"},variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isFilled:{true:{},false:{}},isDarkMode:{true:{},false:{}}},compoundVariants:[{isFilled:!0,isDarkMode:!0,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"}},{isFilled:!0,isDarkMode:!1,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}]}),yze=qm("img",{position:"absolute",top:0,left:0,width:"100%",height:"100%",maxWidth:"100%",minWidth:"100%",pointerEvents:"none",objectFit:"cover",userSelect:"none",borderRadius:2});function Eze({strokeWidth:e,size:t}){return l.createElement("rect",{className:"tl-binding-indicator",x:e,y:e,width:Math.max(0,t[0]-e/2),height:Math.max(0,t[1]-e/2),strokeWidth:16*2})}var Cze=l.memo(function({id:e,style:t,size:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(t,i),u=1+a*1.618,d=Math.max(0,n[0]-u/2),h=Math.max(0,n[1]-u/2),p=[[[u/2,u/2],[d,u/2],d-u/2],[[d,u/2],[d,h],h-u/2],[[d,h],[u/2,h],d-u/2],[[u/2,h],[u/2,u/2],h-u/2]].map(([g,m,v],E)=>{let{strokeDasharray:w,strokeDashoffset:C}=N.getPerfectDashProps(v,a*1.618,t.dash);return l.createElement("line",{key:e+"_"+E,x1:g[0],y1:g[1],x2:m[0],y2:m[1],strokeDasharray:w,strokeDashoffset:C})});return l.createElement(l.Fragment,null,l.createElement("rect",{className:r||t.isFilled?"tl-fill-hitarea":"tl-stroke-hitarea",x:u/2,y:u/2,width:d,height:h,strokeWidth:16}),t.isFilled&&l.createElement("rect",{x:u/2,y:u/2,width:d,height:h,fill:s,pointerEvents:"none"}),l.createElement("g",{pointerEvents:"none",stroke:o,strokeWidth:u,strokeLinecap:"round"},p))});function bze(e,t,n){let r=bt(t),i=N.rng(e),o=r.strokeWidth,a=Math.max(0,n[0]),s=Math.max(0,n[1]),u=Array.from(Array(4)).map(()=>[i()*o*.75,i()*o*.75]),d=se.add([o/2,o/2],u[0]),h=se.add([a-o/2,o/2],u[1]),p=se.add([a-o/2,s-o/2],u[2]),g=se.add([o/2,s-o/2],u[3]),m=Math.round(Math.abs(i()*2*4)),v=Math.min(a/4,o*2),E=Math.min(s/4,o*2),w=Math.max(8,Math.floor(a/16)),C=Math.max(8,Math.floor(s/16)),b=N.rotateArray([se.pointsBetween(se.add(d,[v,0]),se.sub(h,[v,0]),w),se.pointsBetween(se.add(h,[0,E]),se.sub(p,[0,E]),C),se.pointsBetween(se.sub(p,[v,0]),se.add(g,[v,0]),w),se.pointsBetween(se.sub(g,[0,E]),se.add(d,[0,E]),C)],m);return{points:[...b.flat(),...b[0]].slice(5,Math.floor((m%2===0?w:C)/-2)+3)}}function zT(e,t,n){let{points:r}=bze(e,t,n),{strokeWidth:i}=bt(t);return{points:r,options:{size:i,thinning:.65,streamline:.3,smoothing:1,simulatePressure:!1,last:!0}}}function wze(e,t,n){let{points:r,options:i}=zT(e,t,n),o=Ah(r,i);return N.getSvgPathFromStroke(o)}function HT(e,t,n){let{points:r,options:i}=zT(e,t,n);return N.getSvgPathFromStrokePoints(vd(r,i))}var Sze=l.memo(function({id:e,style:t,size:n,isSelected:r,isDarkMode:i}){let{isFilled:o}=t,{stroke:a,strokeWidth:s,fill:u}=bt(t,i),d=wze(e,t,n),h=HT(e,t,n);return l.createElement(l.Fragment,null,l.createElement("path",{className:t.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",d:h}),o&&l.createElement("path",{d:h,fill:u,pointerEvents:"none"}),l.createElement("path",{d,fill:a,stroke:a,strokeWidth:s,pointerEvents:"none"}))}),xze=class extends gt{constructor(){super(...arguments),S(this,"type","rectangle"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"canEdit",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"rectangle",name:"Rectangle",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,isEditing:t,isBinding:n,isSelected:r,isGhost:i,meta:o,bounds:a,events:s,onShapeBlur:u,onShapeChange:d},h)=>{let{id:p,size:g,style:m,label:v="",labelPoint:E=DC}=e,w=ms(m),C=bt(m,o.isDarkMode),b=m.dash==="draw"?Sze:Cze,A=l.useCallback(T=>d==null?void 0:d({id:p,label:T}),[d]);return l.createElement(Aze,_({ref:h},s),l.createElement(p1,{isEditing:t,onChange:A,onBlur:u,font:w,text:v,color:C.stroke,offsetX:(E[0]-.5)*a.width,offsetY:(E[1]-.5)*a.height}),l.createElement(xi,{id:e.id+"_svg",opacity:i?.3:1},n&&l.createElement(Eze,{strokeWidth:C.strokeWidth,size:g}),l.createElement(b,{id:p,style:m,size:g,isSelected:r,isDarkMode:o.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{id:t,style:n,size:r}=e,i=bt(n,!1).strokeWidth;return n.dash==="draw"?l.createElement("path",{d:HT(t,n,r)}):l.createElement("rect",{x:i,y:i,rx:1,ry:1,width:Math.max(1,r[0]-i*2),height:Math.max(1,r[1]-i*2)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.label!==e.label),S(this,"transform",g1),S(this,"transformSingle",m1)}},Aze=fe("div",{width:"100%",height:"100%"}),kze=class extends gt{constructor(){super(...arguments),S(this,"type","sticky"),S(this,"canBind",!0),S(this,"canEdit",!0),S(this,"canClone",!0),S(this,"hideResizeHandles",!0),S(this,"showCloneHandles",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"sticky",name:"Sticky",parentId:"page",childIndex:1,point:[0,0],size:[200,200],text:"",rotation:0,style:PC},e)),S(this,"Component",gt.Component(({shape:e,meta:t,events:n,isGhost:r,isBinding:i,isEditing:o,onShapeBlur:a,onShapeChange:s},u)=>{let d=GNe(e.style),{color:h,fill:p}=MS(e.style,t.isDarkMode),g=l.useRef(null),m=l.useRef(null),v=l.useRef(null),E=l.useRef(!1),w=l.useCallback(I=>{I.stopPropagation()},[]),C=l.useCallback(I=>{s==null||s({id:e.id,type:e.type,text:Q.normalizeText(I)})},[e.id]),b=l.useCallback(I=>{C(I.currentTarget.value)},[s,C]),A=l.useCallback(I=>{if(I.key==="Escape"){I.preventDefault(),I.stopPropagation(),a==null||a();return}if(I.key==="Tab"&&e.text.length===0){I.preventDefault();return}if(!(I.key==="Meta"||I.metaKey))I.stopPropagation();else if(I.key==="z"&&I.metaKey){I.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),I.stopPropagation(),I.preventDefault();return}(I.metaKey||I.ctrlKey)&&I.key==="="&&I.preventDefault(),I.key==="Tab"&&(I.preventDefault(),I.shiftKey?rr.unindent(I.currentTarget):rr.indent(I.currentTarget),s==null||s(q(_({},e),{text:Q.normalizeText(I.currentTarget.value)})))},[e,s]),T=l.useCallback(I=>{I.currentTarget.setSelectionRange(0,0),a==null||a()},[]),B=l.useCallback(I=>{!o||!E.current||I.currentTarget.select()},[o]);l.useEffect(()=>{if(o){E.current=!0;let I=m.current;I.focus(),I.select()}},[o]),l.useEffect(()=>{let I=v.current,{size:M}=e,{offsetHeight:O}=I,z=qv-xo*2,K=M[1]-xo*2;if(O===K)return;if(O>z){s==null||s({id:e.id,size:[M[0],O+xo*2]});return}if(Oqv){s==null||s({id:e.id,size:[M[0],qv]});return}let X=m.current;X==null||X.focus()},[e.text,e.size[1],e.style]);let D={font:d,color:h,textShadow:t.isDarkMode?"0.5px 0.5px 2px rgba(255, 255, 255,.25)":"0.5px 0.5px 2px rgba(255, 255, 255,.5)"};return l.createElement(Tm,_({ref:u},n),l.createElement(Ize,{ref:g,isDarkMode:t.isDarkMode,isGhost:r,style:_({backgroundColor:p},D)},i&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(Dze,{ref:v,isEditing:o,alignment:e.style.textAlign},e.text,"​"),o&&l.createElement(Tze,{ref:m,onPointerDown:w,value:e.text,onChange:b,onKeyDown:A,onFocus:B,onBlur:T,tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,spellCheck:!0,alignment:e.style.textAlign,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:3,ry:3,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.text!==e.text),S(this,"transform",(e,t,{scaleX:n,scaleY:r,transformOrigin:i})=>({point:$.toFixed([t.minX+(t.width-e.size[0])*(n<0?1-i[0]:i[0]),t.minY+(t.height-e.size[1])*(r<0?1-i[1]:i[1])])})),S(this,"transformSingle",e=>e),S(this,"getSvgElement",(e,t)=>{var n,r;let i=this.getBounds(e),o=MS(e.style,t),a=FT(e.style.size)*((n=e.style.scale)!=null?n:1),s=Dd(e.style.font).slice(1,-1),u=(r=e.style.textAlign)!=null?r:"start",d=h1(e.text,a,s,u,i.width-xo*2,!0);d.setAttribute("fill",o.color),d.setAttribute("transform",`translate(${xo}, ${xo})`);let h=document.createElementNS("http://www.w3.org/2000/svg","g"),p=document.createElementNS("http://www.w3.org/2000/svg","rect");return p.setAttribute("width",i.width+""),p.setAttribute("height",i.height+""),p.setAttribute("fill",o.fill),p.setAttribute("rx","3"),p.setAttribute("ry","3"),h.appendChild(p),h.appendChild(d),h})}},xo=16,qv=200,Ize=fe("div",{pointerEvents:"all",position:"relative",backgroundColor:"rgba(255, 220, 100)",fontFamily:"sans-serif",height:"100%",width:"100%",padding:xo+"px",borderRadius:"3px",perspective:"800px",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isDarkMode:{true:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"},false:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}}}),jT={whiteSpace:"pre-wrap",overflowWrap:"break-word",letterSpacing:kl},Dze=fe("div",_({position:"absolute",top:xo,left:xo,width:`calc(100% - ${xo*2}px)`,height:"fit-content",font:"inherit",pointerEvents:"none",userSelect:"none",variants:{isEditing:{true:{opacity:1},false:{opacity:1}},alignment:{start:{textAlign:"left"},middle:{textAlign:"center"},end:{textAlign:"right"},justify:{textAlign:"justify"}}}},jT)),Tze=fe("textarea",q(_({width:"100%",height:"100%",border:"none",overflow:"hidden",background:"none",outline:"none",textAlign:"left",font:"inherit",padding:0,color:"transparent",verticalAlign:"top",resize:"none",caretColor:"black"},jT),{variants:{alignment:{start:{textAlign:"left"},middle:{textAlign:"center"},end:{textAlign:"right"},justify:{textAlign:"justify"}}},"&:focus":{outline:"none",border:"none"}})),Pze=class extends gt{constructor(){super(...arguments),S(this,"type","text"),S(this,"isAspectRatioLocked",!0),S(this,"canEdit",!0),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"bindingDistance",16/2),S(this,"getShape",e=>N.deepMerge({id:"id",type:"text",name:"Text",parentId:"page",childIndex:1,point:[0,0],rotation:0,text:" ",style:PC},e)),S(this,"texts",new Map),S(this,"Component",gt.Component(({shape:e,isBinding:t,isGhost:n,isEditing:r,onShapeBlur:i,onShapeChange:o,meta:a,events:s},u)=>{let{text:d,style:h}=e,p=bt(h,a.isDarkMode),g=ms(e.style),m=l.useRef(null),v=l.useRef(!1),E=l.useRef(d);l.useLayoutEffect(()=>{if(d!==E.current){let D=[0,0];this.texts.set(e.id,d);let I=this.getBounds(e),M=this.getBounds(e);switch(e.style.textAlign){case"start":break;case"middle":{D=$.div([M.width-I.width,0],2);break}case"end":{D=[M.width-I.width,0];break}}E.current=d,o==null||o(q(_({},e),{id:e.id,point:$.sub(e.point,D),text:d}))}},[d]);let w=l.useCallback(D=>{let I=[0,0],M=Q.normalizeText(D.currentTarget.value),O=this.getBounds(e);this.texts.set(e.id,M);let z=this.getBounds(q(_({},e),{text:M}));switch(e.style.textAlign){case"start":break;case"middle":{I=$.div([z.width-O.width,0],2);break}case"end":{I=[z.width-O.width,0];break}}E.current=M,o==null||o(q(_({},e),{id:e.id,point:$.sub(e.point,I),text:M}))},[e.id,e.point]),C=l.useCallback(D=>{if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),i==null||i();return}if(D.key==="Tab"&&e.text.length===0){D.preventDefault();return}if(D.key==="Enter"&&(D.metaKey||D.ctrlKey)){D.preventDefault(),D.stopPropagation(),m.current.blur();return}if(!(D.key==="Meta"||D.metaKey))D.stopPropagation();else if(D.key==="z"&&D.metaKey){D.shiftKey?document.execCommand("redo",!1):document.execCommand("undo",!1),D.stopPropagation(),D.preventDefault();return}(D.metaKey||D.ctrlKey)&&D.key==="="&&D.preventDefault(),D.key==="Tab"&&(D.preventDefault(),D.shiftKey?rr.unindent(D.currentTarget):rr.indent(D.currentTarget),o==null||o(q(_({},e),{text:Q.normalizeText(D.currentTarget.value)})))},[e,o]),b=l.useCallback(D=>{D.currentTarget.setSelectionRange(0,0),i==null||i()},[]),A=l.useCallback(D=>{!r||!v.current||document.activeElement===D.currentTarget&&D.currentTarget.select()},[r]),T=l.useCallback(D=>{r&&D.stopPropagation()},[r]),B=l.useRef(r);return l.useEffect(()=>{r?(B.current=!0,this.texts.set(e.id,d),requestAnimationFrame(()=>{v.current=!0;let D=m.current;D&&(D.focus(),D.select())})):B.current&&(B.current=!1,i==null||i())},[r]),l.createElement(Tm,_({ref:u},s),l.createElement(Mze,{isGhost:n,isEditing:r,onPointerDown:T},l.createElement($ze,{style:{font:g,color:p.stroke,textAlign:BNe(h.textAlign)}},t&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),r?l.createElement(Rze,{ref:m,style:{font:g,color:p.stroke},name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:d,color:p.stroke,onFocus:A,onChange:w,onKeyDown:C,onBlur:b,onPointerDown:T,onContextMenu:Or,onCopy:Or,onPaste:Or,onCut:Or}):d,"​")))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{width:t,height:n}=this.getBounds(e);return l.createElement("rect",{x:0,y:0,width:t,height:n})})),S(this,"getBounds",e=>{let t=N.getFromCache(this.boundsCache,e,()=>{var n;if(!qs)return{minX:0,minY:0,maxX:10,maxY:10,width:10,height:10};qs.parentNode||document.body.appendChild(qs),qs.style.font=ms(e.style),qs.textContent=(n=this.texts.get(e.id))!=null?n:e.text;let r=qs.offsetWidth||1,i=qs.offsetHeight||1;return{minX:0,maxX:r,minY:0,maxY:i,width:r,height:i}});return N.translateBounds(t,e.point)}),S(this,"shouldRender",(e,t)=>t.text!==e.text||t.style.scale!==e.style.scale||t.style!==e.style),S(this,"transform",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let{rotation:o=0,style:{scale:a=1}}=n,s=a*Math.abs(Math.min(r,i));return{point:[t.minX,t.minY],rotation:r<0&&i>=0||i<0&&r>=0?-(o||0):o,style:q(_({},n.style),{scale:s})}}),S(this,"transformSingle",(e,t,{initialShape:n,scaleX:r,scaleY:i})=>{let{style:{scale:o=1}}=n;return{point:$.toFixed([t.minX,t.minY]),style:q(_({},n.style),{scale:o*Math.max(Math.abs(i),Math.abs(r))})}}),S(this,"onDoubleClickBoundsHandle",e=>{let t=this.getCenter(e),n=this.getCenter(q(_({},e),{style:q(_({},e.style),{scale:1})}));return{style:q(_({},e.style),{scale:1}),point:$.toFixed($.add(e.point,$.sub(t,n)))}}),S(this,"getSvgElement",(e,t)=>{var n,r;let i=this.getBounds(e),o=bt(e.style,t),a=f1(e.style.size,e.style.font)*((n=e.style.scale)!=null?n:1),s=Dd(e.style.font).slice(1,-1),u=(r=e.style.textAlign)!=null?r:"middle",d=h1(e.text,a,s,u,i.width,!1);return d.setAttribute("fill",o.stroke),d})}},qs;function Bze(){var e;(e=document.getElementById("__textMeasure"))==null||e.remove();let t=document.createElement("pre");return t.id="__textMeasure",Object.assign(t.style,{whiteSpace:"pre",width:"auto",border:"1px solid transparent",padding:"4px",margin:"0px",letterSpacing:kl,opacity:"0",position:"absolute",top:"-500px",left:"0px",zIndex:"9999",pointerEvents:"none",userSelect:"none",alignmentBaseline:"mathematical",dominantBaseline:"mathematical"}),t.tabIndex=-1,document.body.appendChild(t),t}typeof window<"u"&&(qs=Bze());var Mze=fe("div",{width:"100%",height:"100%",variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isEditing:{false:{pointerEvents:"all",userSelect:"all"},true:{pointerEvents:"none",userSelect:"none"}}}}),UT={whiteSpace:"pre-wrap",overflowWrap:"break-word"},$ze=fe("div",_({position:"absolute",width:"100%",height:"100%",padding:"4px",zIndex:1,minHeight:1,minWidth:1,lineHeight:1,letterSpacing:kl,outline:0,fontWeight:"500",backfaceVisibility:"hidden",userSelect:"none",pointerEvents:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",isEditing:{false:{},true:{pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"}}},UT)),Rze=fe("textarea",q(_({position:"absolute",top:0,left:0,zIndex:1,width:"100%",height:"100%",border:"none",padding:"4px",resize:"none",textAlign:"inherit",minHeight:"inherit",minWidth:"inherit",lineHeight:"inherit",letterSpacing:"inherit",outline:0,fontWeight:"inherit",overflow:"hidden",backfaceVisibility:"hidden",display:"inline-block",pointerEvents:"all",background:"$boundsBg",userSelect:"text",WebkitUserSelect:"text"},UT),{"&:focus":{outline:"none",border:"none"}}));function ul(e,t=0,n=0){let[r,i]=e,o=[[r/2,0],[r,i],[0,i]];return t&&(o=_Ne(o,t)),n&&(o=o.map(a=>se.rotWith(a,[r/2,i/2],n))),o}function _S(e){let[t,n]=e,r=[[t/2,0],[t,n],[0,n]];return[(r[0][0]+r[1][0]+r[2][0])/3,(r[0][1]+r[1][1]+r[2][1])/3]}function Fze(e,t,n){let[r,i]=t,o=N.rng(e),a=Array.from(Array(3)).map(()=>[o()*n*.75,o()*n*.75]),s=[se.add([r/2,0],a[0]),se.add([r,i],a[1]),se.add([0,i],a[2])],u=Math.round(Math.abs(o()*2*3)),d=N.rotateArray([se.pointsBetween(s[0],s[1],32),se.pointsBetween(s[1],s[2],32),se.pointsBetween(s[2],s[0],32)],u);return{points:[...d.flat(),...d[0]]}}function KT(e,t,n){let{strokeWidth:r}=bt(n),{points:i}=Fze(e,t,r);return{points:i,options:{size:r,thinning:.65,streamline:.3,smoothing:1,simulatePressure:!1,last:!0}}}function Lze(e,t,n){let{points:r,options:i}=KT(e,t,n),o=Ah(r,i);return N.getSvgPathFromStroke(o)}function Oze(e,t,n){let{points:r,options:i}=KT(e,t,n);return N.getSvgPathFromStrokePoints(vd(r,i))}var _ze=l.memo(function({id:e,size:t,style:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(n,i),u=1+a*1.618,d=ul(t),h=N.pointsToLineSegments(d,!0).map(([g,m],v)=>{let{strokeDasharray:E,strokeDashoffset:w}=N.getPerfectDashProps(se.dist(g,m),a*1.618,n.dash);return l.createElement("line",{key:e+"_"+v,x1:g[0],y1:g[1],x2:m[0],y2:m[1],stroke:o,strokeWidth:u,strokeLinecap:"round",strokeDasharray:E,strokeDashoffset:w})}),p=d.join();return l.createElement(l.Fragment,null,l.createElement("polygon",{className:n.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",points:p}),n.isFilled&&l.createElement("polygon",{fill:s,points:p,pointerEvents:"none"}),l.createElement("g",{pointerEvents:"stroke"},h))}),Nze=l.memo(function({id:e,size:t,style:n,isSelected:r,isDarkMode:i}){let{stroke:o,strokeWidth:a,fill:s}=bt(n,i),u=Lze(e,t,n),d=Oze(e,t,n);return l.createElement(l.Fragment,null,l.createElement("path",{className:n.isFilled||r?"tl-fill-hitarea":"tl-stroke-hitarea",d}),n.isFilled&&l.createElement("path",{d,fill:s,pointerEvents:"none"}),l.createElement("path",{d:u,fill:o,stroke:o,strokeWidth:a,pointerEvents:"none"}))});function zze({size:e}){let t=ul(e).join();return l.createElement("polygon",{className:"tl-binding-indicator",points:t,strokeWidth:16*2})}var Hze=class extends gt{constructor(){super(...arguments),S(this,"type","triangle"),S(this,"canBind",!0),S(this,"canClone",!0),S(this,"canEdit",!0),S(this,"getShape",e=>N.deepMerge({id:"id",type:"triangle",name:"Triangle",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,label:"",labelPoint:[.5,.5]},e)),S(this,"Component",gt.Component(({shape:e,bounds:t,isBinding:n,isEditing:r,isSelected:i,isGhost:o,meta:a,events:s,onShapeChange:u,onShapeBlur:d},h)=>{let{id:p,label:g="",size:m,style:v,labelPoint:E=DC}=e,w=ms(v),C=bt(v,a.isDarkMode),b=v.dash==="draw"?Nze:_ze,A=l.useCallback(B=>u==null?void 0:u({id:p,label:B}),[u]),T=l.useMemo(()=>{let B=se.div(m,2);return(_S(m)[1]-B[1])*.72},[m]);return l.createElement(jze,_({ref:h},s),l.createElement(p1,{font:w,text:g,color:C.stroke,offsetX:(E[0]-.5)*t.width,offsetY:T+(E[1]-.5)*t.height,isEditing:r,onChange:A,onBlur:d}),l.createElement(xi,{id:e.id+"_svg",opacity:o?.3:1},n&&l.createElement(zze,{size:m}),l.createElement(b,{id:p,style:v,size:m,isSelected:i,isDarkMode:a.isDarkMode})))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:t}=e;return l.createElement("polygon",{points:ul(t).join()})})),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.label!==e.label),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"getExpandedBounds",e=>N.getBoundsFromPoints(ul(e.size,this.bindingDistance).map(t=>se.add(t,e.point)))),S(this,"hitTestLineSegment",(e,t,n)=>yC(t,n,this.getPoints(e)).didIntersect),S(this,"hitTestBounds",(e,t)=>N.boundsContained(this.getBounds(e),t)||Ite(t,this.getPoints(e)).length>0),S(this,"getBindingPoint",(e,t,n,r,i,o)=>{let a=this.getExpandedBounds(e);if(!N.pointInBounds(n,a))return;let s=ul(e.size).map(C=>se.add(C,e.point)),u=ul(e.size,this.bindingDistance).map(C=>se.add(C,e.point)),d=N.pointsToLineSegments(s,!0).map(([C,b])=>se.distanceToLineSegment(C,b,n)).sort((C,b)=>C-b)[0];if(!(N.pointInPolygon(n,u)||dgC(r,i,C[0],C[1])).filter(C=>C.didIntersect).flatMap(C=>C.points);if(!h.length)return;let p=se.add(_S(e.size),e.point),g=h.sort((C,b)=>se.dist(b,r)-se.dist(C,r))[0],m=se.med(n,g),v,E;o?(v=se.dist(n,p)<16/2?p:n,E=0):(se.distanceToLineSegment(n,m,p)<16/2?v=p:v=m,N.pointInPolygon(n,s)?E=this.bindingDistance:E=Math.max(this.bindingDistance,d));let w=se.divV(se.sub(v,[a.minX,a.minY]),[a.width,a.height]);return{point:se.clampV(w,0,1),distance:E}}),S(this,"transform",g1),S(this,"transformSingle",m1)}getPoints(e){let{rotation:t=0,point:[n,r],size:[i,o]}=e;return[[n+i/2,r],[n,r+o],[n+i,r+o]].map(a=>se.rotWith(a,this.getCenter(e),t))}},jze=fe("div",{width:"100%",height:"100%"}),Uze=class extends gt{constructor(){super(...arguments),S(this,"type","video"),S(this,"canBind",!0),S(this,"canEdit",!0),S(this,"canClone",!0),S(this,"isAspectRatioLocked",!0),S(this,"showCloneHandles",!1),S(this,"isStateful",!0),S(this,"getShape",e=>N.deepMerge({id:"video",type:"video",name:"Video",parentId:"page",childIndex:1,point:[0,0],size:[1,1],rotation:0,style:Vo,assetId:"assetId",isPlaying:!0,currentTime:0},e)),S(this,"Component",gt.Component(({shape:e,asset:t={src:""},isBinding:n,isEditing:r,isGhost:i,meta:o,events:a,onShapeChange:s},u)=>{let d=l.useRef(null),h=l.useRef(null),{currentTime:p=0,size:g,isPlaying:m,style:v}=e;l.useLayoutEffect(()=>{let b=h.current;if(!b)return;let[A,T]=g;b.style.width=`${A}px`,b.style.height=`${T}px`},[g]),l.useLayoutEffect(()=>{let b=d.current;!b||(m?b.play():b.pause())},[m]),l.useLayoutEffect(()=>{let b=d.current;!b||p!==b.currentTime&&(b.currentTime=p)},[p]);let E=l.useCallback(()=>{s==null||s({id:e.id,isPlaying:!0})},[]),w=l.useCallback(()=>{s==null||s({id:e.id,isPlaying:!1})},[]),C=l.useCallback(()=>{let b=d.current;!b||!r||s==null||s({id:e.id,currentTime:b.currentTime})},[r]);return l.createElement(Tm,_({ref:u},a),n&&l.createElement("div",{className:"tl-binding-indicator",style:{position:"absolute",top:-this.bindingDistance,left:-this.bindingDistance,width:`calc(100% + ${this.bindingDistance*2}px)`,height:`calc(100% + ${this.bindingDistance*2}px)`,backgroundColor:"var(--tl-selectFill)"}}),l.createElement(Kze,{ref:h,isDarkMode:o.isDarkMode,isGhost:i,isFilled:v.isFilled},l.createElement(Vze,{ref:d,id:e.id+"_video",muted:!0,loop:!0,playsInline:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:r,autoPlay:m,onPlay:E,onPause:w,onTimeUpdate:C},l.createElement("source",{src:t.src}))))})),S(this,"Indicator",gt.Indicator(({shape:e})=>{let{size:[t,n]}=e;return l.createElement("rect",{x:0,y:0,rx:2,ry:2,width:Math.max(1,t),height:Math.max(1,n)})})),S(this,"getBounds",e=>Id(e,this.boundsCache)),S(this,"shouldRender",(e,t)=>t.size!==e.size||t.style!==e.style||t.isPlaying!==e.isPlaying),S(this,"getSvgElement",e=>{let t=this.getBounds(e),n=document.createElementNS("http://www.w3.org/2000/svg","image");return n.setAttribute("width",`${t.width}`),n.setAttribute("height",`${t.height}`),n.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),n}),S(this,"transform",g1),S(this,"transformSingle",m1)}},Kze=qm("div",{pointerEvents:"all",position:"relative",fontFamily:"sans-serif",fontSize:"2em",height:"100%",width:"100%",borderRadius:"3px",perspective:"800px",overflow:"hidden",p:{userSelect:"none"},img:{userSelect:"none"},variants:{isGhost:{false:{opacity:1},true:{transition:"opacity .2s",opacity:.3}},isFilled:{true:{},false:{}},isDarkMode:{true:{},false:{}}},compoundVariants:[{isFilled:!0,isDarkMode:!0,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.3), 1px 1px 4px rgba(0,0,0,.3), 1px 1px 2px rgba(0,0,0,.3)"}},{isFilled:!0,isDarkMode:!1,css:{boxShadow:"2px 3px 12px -2px rgba(0,0,0,.2), 1px 1px 4px rgba(0,0,0,.16), 1px 1px 2px rgba(0,0,0,.16)"}}]}),Vze=qm("video",{position:"absolute",top:0,left:0,width:"100%",height:"100%",maxWidth:"100%",minWidth:"100%",pointerEvents:"none",objectFit:"cover",userSelect:"none",borderRadius:2}),VT=new xze,GT=new Hze,JT=new fze,WT=new lze,MC=new rze,Gze=new Pze,Jze=new gze,Gy=new kze,Wze=new mze,Yze=new Uze,od={rectangle:VT,triangle:GT,ellipse:JT,draw:WT,arrow:MC,text:Gze,group:Jze,sticky:Gy,image:Wze,video:Yze},qze=e=>typeof e=="string"?od[e]:od[e.type],Be=class{static getShapeUtil(e){return qze(e)}static getSelectedShapes(e,t){let n=Be.getPage(e,t);return Be.getSelectedIds(e,t).map(r=>n.shapes[r])}static screenToWorld(e,t){let n=Be.getPageState(e,e.appState.currentPageId).camera;return $.sub($.div(t,n.zoom),n.point)}static getCameraZoom(e){return N.clamp(e,.1,5)}static getPage(e,t){return e.document.pages[t]}static getPageState(e,t){return e.document.pageStates[t]}static getSelectedIds(e,t){return Be.getPageState(e,t).selectedIds}static getShapes(e,t){return Object.values(Be.getPage(e,t).shapes)}static getCamera(e,t){return Be.getPageState(e,t).camera}static getShape(e,t,n){return Be.getPage(e,n).shapes[t]}static getCenter(e){return Be.getShapeUtil(e).getCenter(e)}static getBounds(e){return Be.getShapeUtil(e).getBounds(e)}static getRotatedBounds(e){return Be.getShapeUtil(e).getRotatedBounds(e)}static getSelectedBounds(e){return N.getCommonBounds(Be.getSelectedShapes(e,e.appState.currentPageId).map(t=>Be.getShapeUtil(t).getBounds(t)))}static getParentId(e,t,n){return Be.getShape(e,t,n).parentId}static getDocumentBranch(e,t,n){let r=Be.getShape(e,t,n);return r.children===void 0?[t]:[t,...r.children.flatMap(i=>Be.getDocumentBranch(e,i,n))]}static getSelectedBranchSnapshot(e,t,n){let r=Be.getPage(e,t),i=Be.getSelectedIds(e,t).flatMap(o=>Be.getDocumentBranch(e,o,t).map(a=>r.shapes[a])).filter(o=>!o.isLocked).map(N.deepClone);return n!==void 0?i.map(o=>_({id:o.id},n(o))):i}static getSelectedShapeSnapshot(e,t,n){let r=Be.getSelectedShapes(e,t).filter(i=>!i.isLocked).map(N.deepClone);return n!==void 0?r.map(i=>_({id:i.id},n(i))):r}static getAllEffectedShapeIds(e,t,n){let r=Be.getPage(e,n),i=new Set(t);return t.forEach(o=>{let a=r.shapes[o];function s(d){d.children!==void 0&&d.children.filter(h=>!i.has(h)).forEach(h=>{i.add(h),s(r.shapes[h])})}s(a);function u(d){let h=d.parentId;h!==r.id&&(i.has(h)||(i.add(h),u(r.shapes[h])))}u(a),i.forEach(d=>{Object.values(r.bindings).filter(h=>h.fromId===d||h.toId===d).forEach(h=>i.add(h.fromId===d?h.toId:h.fromId))})}),Array.from(i.values())}static getLinkedShapeIds(e,t,n,r=!0){let i=Be.getSelectedIds(e,t),o=Be.getPage(e,t),a=new Set(i),s=new Set,u=[...i],d=new Set(Object.values(o.shapes).filter(h=>{var p;return h.type==="arrow"&&(h.handles.start.bindingId||((p=h.handles)==null?void 0:p.end.bindingId))}));for(;u.length;){let h=u.pop();if(!(h&&d.size))break;s.has(h)||(s.add(h),d.forEach(p=>{var g,m;let{handles:{start:{bindingId:v},end:{bindingId:E}}}=p,w=v?o.bindings[v]:null,C=E?o.bindings[E]:null,b=!1;w&&w.toId===h?(n==="center"?b=!0:(g=p.decorations)!=null&&g.start&&C?b=n==="left":b=n==="right",b&&(r&&a.add(p.id),a.add(h),C&&(a.add(C.toId),u.push(C.toId)))):C&&C.toId===h&&(n==="center"?b=!0:(m=p.decorations)!=null&&m.end&&w?b=n==="left":b=n==="right",b&&(r&&a.add(p.id),a.add(h),w&&(a.add(w.toId),u.push(w.toId)))),(!w||a.has(w.toId))&&(!C||a.has(C.toId))&&d.delete(p)}))}return Array.from(a.values())}static getChildIndexAbove(e,t,n){let r=e.document.pages[n],i=r.shapes[t],o;if(i.parentId===r.id)o=Object.values(r.shapes).filter(u=>u.parentId===r.id).sort((u,d)=>u.childIndex-d.childIndex);else{let u=r.shapes[i.parentId];if(!u.children)throw Error("No children in parent!");o=u.children.map(d=>r.shapes[d]).sort((d,h)=>d.childIndex-h.childIndex)}let a=o.indexOf(i),s=o[a+1];return s?s.childIndex:i.childIndex+1}static getBeforeShape(e,t){return Object.fromEntries(Object.keys(t).map(n=>[n,e[n]]))}static mutateShapes(e,t,n,r,i=!1){let o={},a={};t.forEach((u,d)=>{let h=Be.getShape(e,u,r);if(h.isLocked)return;(h==null?void 0:h.type)==="group"&&(t.length===1||i)&&h.children.forEach((g,m)=>{let v=Be.getShape(e,g,r);if(v.isLocked)return;let E=n(v,m);E&&(o[g]=Be.getBeforeShape(v,E),a[g]=E)});let p=n(h,d);p&&(o[u]=Be.getBeforeShape(h,p),a[u]=p)});let s=N.deepMerge(e,{document:{pages:{[e.appState.currentPageId]:{shapes:a}}}});return{before:o,after:a,data:s}}static createShapes(e,t,n){let r={document:{pages:{[n]:{shapes:_({},Object.fromEntries(t.flatMap(o=>{let a=[[o.id,void 0]];if(o.parentId!==n){let s=Be.getShape(e,o.parentId,n);if(!s.children)throw Error("No children in parent!");a.push([s.id,{children:s.children}])}return a})))}}}},i={document:{pages:{[n]:{shapes:{shapes:_({},Object.fromEntries(t.flatMap(o=>{let a=[[o.id,o]];if(o.parentId!==n){let s=Be.getShape(e,o.parentId,n);if(!s.children)throw Error("No children in parent!");a.push([s.id,{children:[...s.children,o.id]}])}return a})))}}}}};return{before:r,after:i}}static deleteShapes(e,t,n){n=n||e.appState.currentPageId;let r=Be.getPage(e,n),i=typeof t[0]=="string"?t:t.map(s=>s.id),o={document:{pages:{[n]:{shapes:_({},Object.fromEntries(i.flatMap(s=>{let u=r.shapes[s],d=[[u.id,u]];if(u.parentId!==n){let h=r.shapes[u.parentId];if(!h.children)throw Error("No children in parent!");d.push([h.id,{children:h.children}])}return d}))),bindings:_({},Object.fromEntries(Object.values(r.bindings).filter(s=>i.includes(s.fromId)||i.includes(s.toId)).map(s=>[s.id,s])))}}}},a={document:{pages:{[n]:{shapes:_({},Object.fromEntries(i.flatMap(s=>{let u=r.shapes[s],d=[[u.id,void 0]];if(u.parentId!==r.id){let h=r.shapes[u.parentId];if(!h.children)throw Error("No children in parent!");d.push([h.id,{children:h.children.filter(p=>p!==u.id)}])}return d})))}}}};return{before:o,after:a}}static onSessionComplete(e){var t,n;let r=(n=(t=Be.getShapeUtil(e)).onSessionComplete)==null?void 0:n.call(t,e);return r?_(_({},e),r):e}static onChildrenChange(e,t,n){var r,i;if(!t.children)return;let o=(i=(r=Be.getShapeUtil(t)).onChildrenChange)==null?void 0:i.call(r,t,t.children.map(a=>Be.getShape(e,a,n)));return o?_(_({},t),o):t}static updateArrowBindings(e,t){var n,r,i,o,a,s;let u={start:$r(t.handles.start),end:$r(t.handles.end)},d={isBound:!1,handle:t.handles.start,point:$.add(t.handles.start.point,t.point)},h={isBound:!1,handle:t.handles.end,point:$.add(t.handles.end.point,t.point)};if(t.handles.start.bindingId){let p=((n=t.decorations)==null?void 0:n.start)!==void 0,g=t.handles.start,m=e.bindings[t.handles.start.bindingId];if(!m)throw Error("Could not find a binding to match the start handle's bindingId: "+t.handles.start.bindingId);let v=e.shapes[m.toId],E=Be.getShapeUtil(v),w=E.getBounds(v),C=E.getExpandedBounds(v),b=p?N.expandBounds(w,m.distance):w,{minX:A,minY:T,width:B,height:D}=C,I=$.add([A,T],$.mulV([B,D],$.rotWith(m.point,[.5,.5],v.rotation||0)));d={isBound:!0,hasDecoration:p,binding:m,handle:g,point:I,util:E,target:v,bounds:w,expandedBounds:C,intersectBounds:b,center:E.getCenter(v)}}if(t.handles.end.bindingId){let p=((r=t.decorations)==null?void 0:r.end)!==void 0,g=t.handles.end,m=e.bindings[t.handles.end.bindingId];if(!m)throw Error("Could not find a binding to match the end handle's bindingId");let v=e.shapes[m.toId],E=Be.getShapeUtil(v),w=E.getBounds(v),C=E.getExpandedBounds(v),b=p?N.expandBounds(w,m.distance):w,{minX:A,minY:T,width:B,height:D}=C,I=$.add([A,T],$.mulV([B,D],$.rotWith(m.point,[.5,.5],v.rotation||0)));h={isBound:!0,hasDecoration:p,binding:m,handle:g,point:I,util:E,target:v,bounds:w,expandedBounds:C,intersectBounds:b,center:E.getCenter(v)}}for(let p of["end","start"]){let g=p==="start"?d:h,m=p==="start"?h:d;if(g.isBound)if(!g.binding.distance)u[p].point=$.sub(g.point,t.point);else{let v=$.uni($.sub(g.point,m.point));switch(g.target.type){case"ellipse":{let E=uT(m.point,v,g.center,g.target.radius[0]+(g.hasDecoration?g.binding.distance:0),g.target.radius[1]+(g.hasDecoration?g.binding.distance:0),g.target.rotation||0).points.sort((w,C)=>$.dist(w,m.point)-$.dist(C,m.point));E[0]!==void 0&&(u[p].point=$.toFixed($.sub(E[0],t.point)));break}case"triangle":{let E=g.target.point,w=ul(g.target.size,g.hasDecoration?16:0,g.target.rotation).map(b=>$.add(b,E)),C=N.pointsToLineSegments(w,!0).map(([b,A])=>gC(m.point,v,b,A)).filter(b=>b.didIntersect).flatMap(b=>b.points).sort((b,A)=>$.dist(b,m.point)-$.dist(A,m.point));C[0]!==void 0&&(u[p].point=$.toFixed($.sub(C[0],t.point)));break}default:{let E=Kp(m.point,v,g.intersectBounds,g.target.rotation).filter(C=>C.didIntersect).map(C=>C.points[0]).sort((C,b)=>$.dist(C,m.point)-$.dist(b,m.point));if(!E[0])continue;let w;if(m.isBound&&(w=Kp(m.point,v,m.intersectBounds,m.target.rotation).filter(C=>C.didIntersect).map(C=>C.points[0]).sort((C,b)=>$.dist(C,m.point)-$.dist(b,m.point))[0]),m.isBound&&(E.length<2||w&&E[0]&&Math.ceil($.dist(E[0],w))<16*2.5||N.boundsContain(g.expandedBounds,m.expandedBounds)||N.boundsCollide(g.expandedBounds,m.expandedBounds))){let C=$.uni($.sub(m.point,g.point)),b=Kp(g.point,C,g.bounds,g.target.rotation).filter(A=>A.didIntersect).map(A=>A.points[0]);if(!b[0])continue;u[p].point=$.toFixed($.sub(b[0],t.point)),u[p==="start"?"end":"start"].point=$.toFixed($.add($.sub(b[0],t.point),$.mul(C,Math.min($.dist(b[0],m.point),16*2.5*(N.boundsContain(m.bounds,g.intersectBounds)?-1:1)))))}else if(!m.isBound&&(E[0]&&$.dist(E[0],m.point)<16*2.5||N.pointInBounds(m.point,g.intersectBounds))){let C=$.uni($.sub(g.center,m.point));return(o=(i=Be.getShapeUtil(t)).onHandleChange)==null?void 0:o.call(i,t,{[p]:q(_({},t.handles[p]),{point:$.toFixed($.add($.sub(m.point,t.point),$.mul(C,16*2.5)))})})}else E[0]&&(u[p].point=$.toFixed($.sub(E[0],t.point)))}}}}return(s=(a=Be.getShapeUtil(t)).onHandleChange)==null?void 0:s.call(a,t,u)}static transform(e,t,n){let r=Be.getShapeUtil(e).transform(e,t,n);return r?_(_({},e),r):e}static transformSingle(e,t,n){let r=Be.getShapeUtil(e).transformSingle(e,t,n);return r?_(_({},e),r):e}static getRotatedShapeMutation(e,t,n,r){var i,o;let a=$.sub(t,e.point),s=$.rotWith(t,n,r),u=$.toFixed($.sub(s,a));if(e.handles!==void 0)return(o=(i=this.getShapeUtil(e)).onHandleChange)==null?void 0:o.call(i,q(_({},e),{point:u}),Object.fromEntries(Object.entries(e.handles).map(([h,p])=>{let g=$.toFixed($.rotWith(p.point,a,r));return[h,q(_({},p),{point:g})]})));let d=N.clampRadians((e.rotation||0)+r);return{point:u,rotation:d}}static updateParents(e,t,n){let r=Be.getPage(e,t);if(n.length===0)return;let{shapes:i}=Be.getPage(e,t),o=Array.from(new Set(n.map(a=>i[a].parentId).values())).filter(a=>a!==r.id);for(let a of o){let s=i[a];if(!s.children)throw Error("A shape is parented to a shape without a children array.");Be.onChildrenChange(e,s,t)}Be.updateParents(e,t,o)}static getBinding(e,t,n){return Be.getPage(e,n).bindings[t]}static getBindings(e,t){let n=Be.getPage(e,t);return Object.values(n.bindings)}static getBindableShapeIds(e){return Be.getShapes(e,e.appState.currentPageId).filter(t=>Be.getShapeUtil(t).canBind).sort((t,n)=>n.childIndex-t.childIndex).map(t=>t.id)}static getBindingsWithShapeIds(e,t,n){return Array.from(new Set(Be.getBindings(e,n).filter(r=>t.includes(r.toId)||t.includes(r.fromId))).values())}static getRelatedBindings(e,t,n){let r=new Set(t),i=Be.getPage(e,n),o=Object.values(i.bindings),a=new Set(o.filter(d=>r.has(d.toId)||r.has(d.fromId))),s=a.size,u=-1;for(;u!==0;)a.forEach(d=>{let h=d.fromId;for(let p of o)p.fromId===h&&a.add(p),p.toId===h&&a.add(p)}),u=a.size-s,s=a.size;return Array.from(a.values())}static normalizeText(e){return e.replace(Be.fixNewLines,` `).split(` `).map(t=>t||" ").join(` -`)}static assertShapeHasProperty(e,t){if(e[t]===void 0)throw new Error}static warn(e){}static error(e){}static getSvgString(e,t=1){let n=e.cloneNode(!0);return e.setAttribute("width",+e.getAttribute("width")*t+""),e.setAttribute("height",+e.getAttribute("height")*t+""),new XMLSerializer().serializeToString(n).replaceAll(" ","").replaceAll(/((\s|")[0-9]*\.[0-9]{2})([0-9]*)(\b|"|\))/g,"$1")}static getSvgAsDataUrl(e,t=1){let n=Be.getSvgString(e,t);return`data:image/svg+xml;base64,${window.btoa(unescape(n))}`}static getImageForSvg(e){return Oe(this,arguments,function*(t,n="png",r={}){let{scale:i=2,quality:o=1}=r,a=Be.getSvgString(t,i),s=+t.getAttribute("width"),u=+t.getAttribute("height");if(!a)return;let d=yield new Promise(h=>{let p=new Image;p.crossOrigin="anonymous";let g=`data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(a)))}`;p.onload=()=>{let m=document.createElement("canvas"),v=m.getContext("2d");m.width=s,m.height=u,v.drawImage(p,0,0,s,u),URL.revokeObjectURL(g),h(m)},p.onerror=()=>{console.warn("Could not convert that SVG to an image.")},p.src=g});return yield new Promise(h=>d.toBlob(p=>h(p),"image/"+n,o))})}},Q=Be;S(Q,"copyStringToClipboard",e=>{try{navigator.clipboard&&navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"})})])}catch{let n=document.createElement("textarea");n.setAttribute("position","fixed"),n.setAttribute("top","0"),n.setAttribute("readonly","true"),n.setAttribute("contenteditable","true"),n.style.position="fixed",n.value=e,document.body.appendChild(n),n.focus(),n.select();try{let r=document.createRange();r.selectNodeContents(n);let i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r),n.setSelectionRange(0,n.value.length)),document.execCommand("copy")}catch{}finally{document.body.removeChild(n)}}}),S(Q,"flattenShape",(e,t)=>{var n;return[t,...((n=t.children)!=null?n:[]).map(r=>Be.getShape(e,r,e.appState.currentPageId)).sort((r,i)=>r.childIndex-i.childIndex).flatMap(r=>Be.flattenShape(e,r))]}),S(Q,"flattenPage",(e,t)=>Object.values(e.document.pages[t].shapes).sort((n,r)=>n.childIndex-r.childIndex).reduce((n,r)=>[...n,...Be.flattenShape(e,r)],[])),S(Q,"getTopChildIndex",(e,t)=>{let n=Be.getShapes(e,t);return n.length===0?1:n.filter(r=>r.parentId===t).sort((r,i)=>i.childIndex-r.childIndex)[0].childIndex+1}),S(Q,"fixNewLines",/\r?\n|\r/g);var Xze=e=>e.room,Zze=function(){let e=wt(),t=e.useStore(Xze),[n,r]=l.useState(!1),i=l.useRef(0),o=l.useCallback(()=>{r(!0),Q.copyStringToClipboard(window.location.href),clearTimeout(i.current),i.current=setTimeout(()=>r(!1),1200)},[]),a=l.useCallback(()=>{r(!0);let d=window.location.href.split("/");d[d.length-2]="v",d[d.length-1]=N.lns(d[d.length-1]),Q.copyStringToClipboard(d.join("/")),clearTimeout(i.current),i.current=setTimeout(()=>r(!1),1200)},[]),s=l.useCallback(()=>Oe(this,null,function*(){e.isDirty?e.fileSystemHandle?window.confirm("Do you want to save changes to your current project?")&&(yield e.saveProject()):window.confirm("Do you want to save your current project?")&&(yield e.saveProject()):e.fileSystemHandle||window.confirm("Do you want to save your current project?")&&(yield e.saveProject())}),[]),u=l.useCallback(()=>Oe(this,null,function*(){var d;let h=N.deepClone(e.document);e.setIsLoading(!0);try{if(e.callbacks.onAssetUpload)for(let g in h.assets){let m=h.assets[g];if(m.src.includes("base64")){let v=Qze(m.src,((d=m.fileName)!=null?d:m.type==="video")?"image.png":"image.mp4"),E=yield e.callbacks.onAssetUpload(e,v,g);E?m.src=E:m.src=""}}let p=yield fetch("/api/create",{method:"POST",mode:"no-cors",headers:{"Access-Control-Allow-Origin":"*","Content-Type":"application/json"},body:JSON.stringify({roomId:N.uniqueId(),pageId:e.currentPageId,document:h})}).then(g=>g.json());p!=null&&p.url?window.location.href=p.url:Q.warn(p==null?void 0:p.message)}catch(p){Q.warn(p.message)}e.setIsLoading(!1)}),[]);return l.createElement(Lu,{dir:"ltr"},l.createElement(BT,{id:"TD-MultiplayerMenuIcon",isActive:!!t},l.createElement(INe,null)),l.createElement(Ol,{variant:"menu",id:"TD-MultiplayerMenu",side:"bottom",align:"start",sideOffset:4},l.createElement(tt,{id:"TD-Multiplayer-CopyInviteLink",onClick:o,disabled:!t},l.createElement(ge,{id:"copy.invite.link"}),l.createElement(ao,null,n?l.createElement(Pg,null):l.createElement(j6,null))),l.createElement(tt,{id:"TD-Multiplayer-CopyReadOnlyLink",onClick:a,disabled:!t},l.createElement(ge,{id:"copy.readonly.link"}),l.createElement(ao,null,n?l.createElement(Pg,null):l.createElement(j6,null))),l.createElement(Qt,null),l.createElement(tt,{id:"TD-Multiplayer-CreateMultiplayerProject",onClick:s},l.createElement("a",{href:"https://tldraw.com/r"},l.createElement(ge,{id:"create.multiplayer.project"}))),l.createElement(tt,{id:"TD-Multiplayer-CopyToMultiplayerProject",onClick:u},l.createElement(ge,{id:"copy.multiplayer.project"}))))};function Qze(e,t){var n,r;let i=e.split(","),o=(r=(n=i[0])==null?void 0:n.match(/:(.*?);/))==null?void 0:r[1],a=window.atob(i[1]),s=a.length,u=new Uint8Array(s);for(;s--;)u[s]=a.charCodeAt(s);return new File([u],t,{type:o})}var eHe=e=>Object.keys(e.document.pages).length>1;function tHe({page:e,onOpen:t,onClose:n}){let r=wt(),i=Wn(),[o,a]=l.useState(!1),[s,u]=l.useState(e.name||"Page"),d=r.useStore(eHe),h=l.useRef(null),p=l.useCallback(()=>{a(!1)},[]),g=l.useCallback(()=>{r.duplicatePage(e.id)},[r]),m=l.useCallback(()=>{window.confirm("Are you sure you want to delete this page?")&&r.deletePage(e.id)},[r]),v=l.useCallback(D=>{if(a(D),D){t==null||t();return}},[r]);function E(D){D.stopPropagation()}let w=l.useRef(e.name||"Page"),C=l.useRef(w.current),b=l.useCallback(D=>{let I=D.target.value.trimStart();C.current=I,u(I)},[]),A=l.useCallback(D=>{switch(D.key){case"Enter":{C.current===w.current||(w.current=C.current,r.renamePage(e.id,C.current.trim())),a(!1);break}case"Escape":{if(C.current===w.current){a(!1);return}C.current=w.current,u(w.current),requestAnimationFrame(()=>{let I=h.current;I&&(I.focus(),I.setSelectionRange(0,I.value.length))});break}}},[]),T=l.useRef(!1);l.useEffect(()=>(o?(T.current=!0,w.current=e.name||"Page",C.current=w.current,requestAnimationFrame(()=>{let D=h.current;D&&(D.focus(),D.setSelectionRange(0,D.value.length))})):T.current&&(n==null||n()),()=>{C.current!==w.current&&(w.current=C.current,r.renamePage(e.id,C.current))}),[o]);let B=Nu();return l.createElement(sC,{open:o,onOpenChange:v},l.createElement(Aee,{asChild:!0,"data-shy":"true"},l.createElement(kC,{bp:Ci},l.createElement(ao,null,l.createElement(tq,null)))),l.createElement(uC,{container:B.current},l.createElement(rHe,{onPointerDown:p}),l.createElement(nHe,{dir:"ltr",onKeyDown:E,onKeyUp:E},l.createElement(PT,{ref:h,placeholder:i.formatMessage({id:"page.name"}),value:s,onChange:b,onKeyDown:A,icon:l.createElement(NE,null)}),l.createElement(Qt,null),l.createElement(NS,{onSelect:g},l.createElement(ge,{id:"duplicate"})),l.createElement(NS,{disabled:!d,onSelect:m},l.createElement(ge,{id:"delete"})),l.createElement(Qt,null),l.createElement(UD,{asChild:!0},l.createElement(ur,null,l.createElement(ge,{id:"cancel"}))))))}var nHe=fe(lC,{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",minWidth:240,maxWidth:"fit-content",maxHeight:"85vh",marginTop:"-5vh",pointerEvents:"all",backgroundColor:"$panel",padding:"$1",borderRadius:"$2",font:"$ui",zIndex:999999,"&:focus":{outline:"none"}}),rHe=fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0,zIndex:999998});function NS(e){var t=e,{onSelect:n}=t,r=$i(t,["onSelect"]);return l.createElement(Lg,{asChild:!0,onClick:n,onSelect:n},l.createElement(ur,_({},r)))}var iHe=e=>Object.values(e.document.pages).sort((t,n)=>(t.childIndex||0)-(n.childIndex||0)),oHe=e=>e.document.pages[e.appState.currentPageId].name,aHe=e=>e.document.pages[e.appState.currentPageId].id;function sHe(){let e=wt(),t=Wn(),n=l.useRef(!1),[r,i]=l.useState(!1);l.useEffect(()=>{n.current!==r&&(n.current=r)},[r]);let o=l.useCallback(()=>{i(!1)},[i]),a=l.useCallback(u=>{n.current!==u&&i(u)},[i]),s=e.useStore(oHe);return l.createElement(Lu,{dir:"ltr",open:r,onOpenChange:a},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Page"},l.createElement(st,{variant:"text"},s||t.formatMessage({id:"page"}))),l.createElement(Ol,{variant:"menu",align:"start",sideOffset:4},r&&l.createElement(uHe,{onClose:o})))}function uHe({onClose:e}){let t=wt(),n=Wn(),r=t.useStore(iHe),i=t.useStore(aHe),o=n.formatMessage({id:"page"}),a=l.useCallback(()=>{let E=o+" "+(Object.keys(t.document.pages).length+1);t.createPage(void 0,E)},[t]),s=l.useCallback(E=>{e(),t.changePage(E)},[t]),[u,d]=l.useState(null),[h,p]=l.useState(null),g=l.useCallback(E=>{d(E.currentTarget.id),p(r.findIndex(w=>w.id===E.currentTarget.id)),E.dataTransfer.effectAllowed="move"},[]),m=l.useCallback(E=>{E.preventDefault();let w=r.findIndex(b=>b.id===E.currentTarget.id),C=E.currentTarget.getBoundingClientRect();w=(E.clientY-C.top)/C.height<.5?w:w+1,p(w)},[u,r]),v=l.useCallback(()=>{u!==null&&h!==null&&t.movePage(u,h),d(null),p(null)},[u,h]);return l.createElement(l.Fragment,null,l.createElement(IX,{dir:"ltr",value:i,onValueChange:s},r.map((E,w)=>l.createElement(lHe,{key:E.id,isDropAbove:w===h&&w===0,isDropBelow:h!==null&&w===h-1},l.createElement(fI,{title:E.name||o,value:E.id,key:E.id,id:E.id,asChild:!0,onDragOver:m,onDragStart:g,onDrop:v,draggable:!0},l.createElement(cHe,null,l.createElement("span",{id:E.id},E.name||o),l.createElement(pI,null,l.createElement(ao,null,l.createElement(Pg,null))))),l.createElement(tHe,{page:E,onClose:e})))),l.createElement(Qt,null),l.createElement(Xm,{onSelect:a,asChild:!0},l.createElement(ur,null,l.createElement("span",null,l.createElement(ge,{id:"create.page"})),l.createElement(ao,null,l.createElement(cq,null)))))}var lHe=fe("div",{position:"relative",display:"grid",gridTemplateColumns:"1fr auto",gridAutoFlow:"column",margin:0,'& > *[data-shy="true"]':{opacity:0},'&:hover > *[data-shy="true"]':{opacity:1},variants:{isDropAbove:{true:{"&::after":{content:"",display:"block",position:"absolute",top:0,width:"100%",height:"1px",backgroundColor:"$selected",zIndex:999,pointerEvents:"none"}}},isDropBelow:{true:{"&::after":{content:"",display:"block",position:"absolute",width:"100%",height:"1px",top:"100%",backgroundColor:"$selected",zIndex:999,pointerEvents:"none"}}}}}),cHe=fe(ur,{minWidth:128}),dHe=e=>e.appState.currentStyle,hHe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds,fHe=Object.keys(TC),zS={draw:l.createElement(k_e,null),solid:l.createElement(I_e,null),dashed:l.createElement(S_e,null),dotted:l.createElement(A_e,null)},pHe={small:l.createElement(T_e,null),medium:l.createElement(P_e,null),large:l.createElement(B_e,null)},gHe={start:l.createElement(Dq,null),middle:l.createElement(xq,null),end:l.createElement(Pq,null),justify:l.createElement(kq,null)},mHe=e=>e.settings.isDarkMode?"dark":"light",vHe=e=>e.settings.keepStyleMenuOpen,yHe=e=>{let{activeTool:t,currentPageId:n}=e.appState;switch(t){case"select":{let r=e.document.pages[n],i=!1,o=!1;for(let a of e.document.pageStates[n].selectedIds)"text"in r.shapes[a]&&(i=!0),"label"in r.shapes[a]&&(o=!0);return i?"text":o?"label":""}case"text":return"text";case"rectangle":return"label";case"ellipse":return"label";case"triangle":return"label";case"arrow":return"label";case"line":return"label"}return!1},EHe=l.memo(function(){let e=wt(),t=e.useStore(mHe),n=e.useStore(vHe),r=e.useStore(yHe),i=e.useStore(dHe),o=e.useStore(hHe),[a,s]=l.useState(i),u=l.useRef(i);l.useEffect(()=>{let{appState:{currentStyle:w},page:C,selectedIds:b}=e,A={};if(b.length<=0)A=w;else{let T=new Set([]);e.selectedIds.map(B=>C.shapes[B]).forEach(B=>{fHe.forEach(D=>{if(!T.has(D))if(A[D]===void 0)A[D]=B.style[D];else{if(A[D]===B.style[D])return;A[D]=B.style[D],T.add(D)}})})}JSON.stringify(A)!==JSON.stringify(u.current)&&(u.current=A,s(A))},[i,o]);let d=l.useCallback(w=>{e.setSetting("keepStyleMenuOpen",w)},[]),h=l.useCallback(w=>{e.style({isFilled:w})},[]),p=l.useCallback(w=>{e.style({dash:w})},[]),g=l.useCallback(w=>{e.style({size:w})},[]),m=l.useCallback(w=>{e.style({font:w})},[]),v=l.useCallback(w=>{e.style({textAlign:w})},[]),E=l.useCallback(w=>{e.setMenuOpen(w)},[e]);return l.createElement(Lu,{dir:"ltr",onOpenChange:E,open:n?!0:void 0,modal:!1},l.createElement(Fl,{asChild:!0,id:"TD-Styles"},l.createElement(st,{variant:"text"},l.createElement(ge,{id:"styles"}),l.createElement(bHe,{style:{color:P0[t][a.color]}},a.isFilled&&l.createElement(kS,{size:16,stroke:"none",fill:jy[t][a.color]}),zS[a.dash]))),l.createElement(Ol,{id:"language-menu",side:"bottom",align:"end",sideOffset:4,alignOffset:4},l.createElement(o0,{variant:"tall",id:"TD-Styles-Color-Container"},l.createElement("span",null,l.createElement(ge,{id:"style.menu.color"})),l.createElement(CHe,null,Object.keys(P0.light).map(w=>l.createElement(Xm,{key:w,onSelect:Ut,asChild:!0,id:`TD-Styles-Color-Swatch-${w}`},l.createElement(st,{variant:"icon",isActive:a.color===w,onClick:()=>e.style({color:w})},l.createElement(kS,{size:18,strokeWidth:2.5,fill:a.isFilled?jy[t][w]:"transparent",stroke:P0.light[w]})))))),l.createElement(Vi,{variant:"styleMenu",checked:!!a.isFilled,onCheckedChange:h,id:"TD-Styles-Fill"},l.createElement(ge,{id:"style.menu.fill"})),l.createElement(o0,{id:"TD-Styles-Dash-Container"},l.createElement(ge,{id:"style.menu.dash"}),l.createElement(Cp,{dir:"ltr",value:a.dash,onValueChange:p},Object.values(wT).map(w=>l.createElement(gp,{key:w,isActive:w===a.dash,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Dash-${w}`},zS[w])))),l.createElement(o0,{id:"TD-Styles-Size-Container"},l.createElement(ge,{id:"style.menu.size"}),l.createElement(Cp,{dir:"ltr",value:a.size,onValueChange:g},Object.values(bT).map(w=>l.createElement(gp,{key:w,isActive:w===a.size,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Dash-${w}`},pHe[w])))),(r==="text"||r==="label")&&l.createElement(l.Fragment,null,l.createElement(Qt,null),l.createElement(o0,{id:"TD-Styles-Font-Container"},l.createElement(ge,{id:"style.menu.font"}),l.createElement(Cp,{dir:"ltr",value:a.font,onValueChange:m},Object.values(xT).map(w=>l.createElement(gp,{key:w,isActive:w===a.font,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Font-${w}`},l.createElement(wHe,{fontStyle:w},"Aa"))))),r==="text"&&l.createElement(o0,{id:"TD-Styles-Align-Container"},l.createElement(ge,{id:"style.menu.align"}),l.createElement(Cp,{dir:"ltr",value:a.textAlign,onValueChange:v},Object.values(ST).map(w=>l.createElement(gp,{key:w,isActive:w===a.textAlign,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Align-${w}`},gHe[w]))))),l.createElement(Qt,null),l.createElement(Vi,{variant:"styleMenu",checked:n,onCheckedChange:d,id:"TD-Styles-Keep-Open"},l.createElement(ge,{id:"style.menu.keep.open"}))))}),CHe=fe("div",{display:"grid",gridTemplateColumns:"repeat(4, auto)",gap:0}),o0=fe("div",{position:"relative",width:"100%",background:"none",border:"none",cursor:"pointer",minHeight:"32px",outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",padding:"$2 0 $2 $3",borderRadius:4,userSelect:"none",margin:0,display:"flex",gap:"$3",flexDirection:"row",alignItems:"center",justifyContent:"space-between",variants:{variant:{tall:{alignItems:"flex-start",padding:"0 0 0 $3","& > span":{paddingTop:"$4"}}}}}),Cp=fe(dI,{display:"flex",flexDirection:"row",gap:"$1"}),bHe=fe("div",{display:"grid","& > *":{gridColumn:1,gridRow:1}}),wHe=fe("div",{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"$3",variants:{fontStyle:{script:{fontFamily:"Caveat Brush"},sans:{fontFamily:"Recursive"},serif:{fontFamily:"Georgia"},mono:{fontFamily:"Recursive Mono"}}}}),SHe=e=>e.document.pageStates[e.appState.currentPageId].camera.zoom,xHe=function(){let e=wt(),t=e.useStore(SHe);return l.createElement(Lu,{dir:"ltr"},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Zoom"},l.createElement(AHe,{onDoubleClick:e.resetZoom,variant:"text"},Math.round(t*100),"%")),l.createElement(Ol,{align:"end"},l.createElement(tt,{onSelect:Ut,onClick:e.zoomIn,kbd:"#+",id:"TD-Zoom-Zoom_In"},l.createElement(ge,{id:"zoom.in"})),l.createElement(tt,{onSelect:Ut,onClick:e.zoomOut,kbd:"#−",id:"TD-Zoom-Zoom_Out"},l.createElement(ge,{id:"zoom.out"})),l.createElement(tt,{onSelect:Ut,onClick:e.resetZoom,kbd:"⇧0",id:"TD-Zoom-Zoom_To_100%"},l.createElement(ge,{id:"zoom.to"})," 100%"),l.createElement(tt,{onSelect:Ut,onClick:e.zoomToFit,kbd:"⇧1",id:"TD-Zoom-To_Fit"},l.createElement(ge,{id:"zoom.to.fit"})),l.createElement(tt,{onSelect:Ut,onClick:e.zoomToSelection,kbd:"⇧2",id:"TD-Zoom-To_Selection"},l.createElement(ge,{id:"zoom.to.selection"}))))},AHe=fe(st,{minWidth:56});function kHe({readOnly:e,showPages:t,showMenu:n,showStyles:r,showZoom:i,showMultiplayerMenu:o}){let a=wt();return l.createElement(IHe,null,(n||t)&&l.createElement(Ng,{side:"left",id:"TD-MenuPanel"},n&&l.createElement(kNe,{readOnly:e}),o&&l.createElement(Zze,null),t&&l.createElement(sHe,null)),l.createElement(DHe,null),(r||i)&&l.createElement(Ng,{side:"right"},a.readOnly?l.createElement(THe,null,"Read Only"):l.createElement(l.Fragment,null,l.createElement(st,null,l.createElement(IS,{onClick:a.undo})),l.createElement(st,null,l.createElement(IS,{onClick:a.redo,flipHorizontal:!0}))),i&&l.createElement(xHe,null),r&&!e&&l.createElement(EHe,null)))}var IHe=fe("div",{width:"100%",position:"absolute",top:0,left:0,right:0,display:"flex",flexDirection:"row",pointerEvents:"none","& > *":{pointerEvents:"all"}}),DHe=fe("div",{flexGrow:2,pointerEvents:"none"}),THe=fe("div",{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"$ui",fontSize:"$1",paddingLeft:"$4",paddingRight:"$1",userSelect:"none"}),PHe=l.memo(kHe);function BHe(e){Kt.useEffect(()=>{let t=!1,n=!1,r=e.current;if(!r)return;let i=u=>{u.key===" "&&!n&&(n=!0,t?r.setAttribute("style","cursor: grabbing !important"):r.setAttribute("style","cursor: grab !important"))},o=u=>{u.key===" "&&(n=!1,r.setAttribute("style","cursor: initial"))},a=u=>{t=!0,u.button===1&&r.setAttribute("style","cursor: grabbing !important"),u.button===0&&n&&r.setAttribute("style","cursor: grabbing !important")},s=()=>{t=!1,n?r.setAttribute("style","cursor: grab !important"):r.setAttribute("style","cursor: initial")};return r.addEventListener("keydown",i),r.addEventListener("keyup",o),r.addEventListener("pointerdown",a),r.addEventListener("pointerup",s),()=>{r.removeEventListener("keydown",i),r.removeEventListener("keyup",o),r.removeEventListener("pointerdown",a),r.removeEventListener("pointerup",s)}},[e.current])}var YT="tldraw_clipboard";function MHe(){return Oe(this,null,function*(){return Og(YT)})}function $He(e){return Oe(this,null,function*(){return I0(YT,e)})}var RHe=class{constructor(e,t,n,r){S(this,"_idbId"),S(this,"initialState"),S(this,"store"),S(this,"pointer",-1),S(this,"_state"),S(this,"_status","loading"),S(this,"stack",[]),S(this,"_snapshot"),S(this,"useStore"),S(this,"ready"),S(this,"isPaused",!1),S(this,"persist",(i,o)=>{if(this._status==="ready"&&(this.onPersist&&this.onPersist(this._state,i,o),this._idbId))return I0(this._idbId,this._state).catch(a=>console.error(a))}),S(this,"applyPatch",(i,o)=>{let a=this._state,s=N.deepMerge(this._state,i),u=this.cleanup(s,a,i,o);return this.onStateWillChange&&this.onStateWillChange(u,o),this._state=u,this.store.setState(this._state,!0),this.onStateDidChange&&this.onStateDidChange(this._state,o),this}),S(this,"migrate",i=>i),S(this,"cleanup",(i,o,a,s)=>i),S(this,"onStateWillChange"),S(this,"onStateDidChange"),S(this,"patchState",(i,o)=>(this.applyPatch(i,o),this.onPatch&&this.onPatch(this._state,i,o),this)),S(this,"replaceState",(i,o)=>{let a=this.cleanup(i,this._state,i,o);return this.onStateWillChange&&this.onStateWillChange(a,"replace"),this._state=a,this.store.setState(this._state,!0),this.onStateDidChange&&this.onStateDidChange(this._state,"replace"),this}),S(this,"setState",(i,o=i.id)=>(this.pointer(this.onStateWillChange&&this.onStateWillChange(this.initialState,"reset"),this._state=this.initialState,this.store.setState(this._state,!0),this.resetHistory(),this.persist({},"reset"),this.onStateDidChange&&this.onStateDidChange(this._state,"reset"),this.onReset&&this.onReset(this._state),this)),S(this,"replaceHistory",(i,o=i.length-1)=>(this.stack=i,this.pointer=o,this.onReplace&&this.onReplace(this._state),this)),S(this,"resetHistory",()=>(this.stack=[],this.pointer=-1,this.onResetHistory&&this.onResetHistory(this._state),this)),S(this,"undo",()=>{if(!this.isPaused){if(!this.canUndo)return this;let i=this.stack[this.pointer];this.pointer--,this.applyPatch(i.before,"undo"),this.persist(i.before,"undo")}return this.onUndo&&this.onUndo(this._state),this}),S(this,"redo",()=>{if(!this.isPaused){if(!this.canRedo)return this;this.pointer++;let i=this.stack[this.pointer];this.applyPatch(i.after,"redo"),this.persist(i.after,"undo")}return this.onRedo&&this.onRedo(this._state),this}),S(this,"setSnapshot",()=>(this._snapshot=_({},this._state),this)),S(this,"forceUpdate",()=>{this.store.setState(this._state,!0)}),this._idbId=t,this._state=$r(e),this._snapshot=$r(e),this.initialState=$r(e),this.store=Bte(()=>this._state),this.useStore=rne(this.store),this.ready=new Promise(i=>{let o="none";this._idbId?(o="restored",Og(this._idbId).then(a=>Oe(this,null,function*(){if(a){let s=a;if(n){let d=yield Og(t+"_version");d&&dconsole.error(a))):(this._status="ready",i(o))}).then(i=>(this.onReady&&this.onReady(i),i))}pause(){this.isPaused=!0}resume(){this.isPaused=!1}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointere.getShape(g)),o=i.map(g=>({id:g.id,point:[...g.point],bounds:Q.getBounds(g)})),a=N.getCommonBounds(o.map(({bounds:g})=>g)),s=a.minX+a.width/2,u=a.minY+a.height/2,d=Object.fromEntries(o.map(({id:g,point:m,bounds:v})=>[g,{prev:m,next:{top:[m[0],a.minY],centerVertical:[m[0],u-v.height/2],bottom:[m[0],a.maxY-v.height],left:[a.minX,m[1]],centerHorizontal:[s-v.width/2,m[1]],right:[a.maxX-v.width,m[1]]}[n]}])),{before:h,after:p}=Q.mutateShapes(e.state,t,g=>d[g.id]?{point:d[g.id].next}:g,r,!1);return i.forEach(g=>{if(g.type==="group"){let m=$.sub(p[g.id].point,h[g.id].point);g.children.forEach(v=>{let E=e.getShape(v);h[E.id]={point:E.point},p[E.id]={point:$.add(E.point,m)}}),delete h[g.id],delete p[g.id]}}),{id:"align",before:{document:{pages:{[r]:{shapes:h}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:p}},pageStates:{[r]:{selectedIds:t}}}}}}function LHe(e,t){return{id:"change_page",before:{appState:{currentPageId:e.currentPageId}},after:{appState:{currentPageId:t}}}}function OHe(e,t){var n;let r=e,i=new Set(t);for(;i.has(r);)r=(n=/^.*(\d+)$/.exec(r))!=null&&n[1]?r.replace(/(\d+)(?=\D?)$/,o=>(+o+1).toString()):`${r} 1`;return r}function _He(e,t,n){let r={shapes:{},bindings:{}},i={shapes:{},bindings:{}},o=[],a=new Set,s=new Set;t.filter(d=>!Q.getShape(e,d,n).isLocked).forEach(d=>{a.add(d);let h=Q.getShape(e,d,n);r.shapes[d]=h,i.shapes[d]=void 0,h.children!==void 0&&h.children.forEach(p=>{a.add(p);let g=Q.getShape(e,p,n);r.shapes[p]=g,i.shapes[p]=void 0}),h.parentId!==n&&o.push(Q.getShape(e,h.parentId,n)),h.assetId&&s.add(h.assetId)}),o.forEach(d=>{var h;t.includes(d.id)||(a.add(d.id),r.shapes[d.id]={children:d.children},i.shapes[d.id]={children:d.children.filter(p=>!t.includes(p))},((h=i.shapes[d.id])==null?void 0:h.children.length)===0&&(i.shapes[d.id]=void 0,r.shapes[d.id]=Q.getShape(e,d.id,n)))});let u=Q.getPage(e,n);return Object.values(u.bindings).filter(d=>a.has(d.fromId)||a.has(d.toId)).forEach(d=>{for(let h of[d.toId,d.fromId])if(i.shapes[h]===void 0){r.bindings[d.id]=d,i.bindings[d.id]=void 0;let p=u.shapes[h];p&&p.handles&&Object.values(p.handles).filter(g=>g.bindingId===d.id).forEach(g=>{var m,v,E,w,C,b;r.shapes[h]=q(_({},r.shapes[h]),{handles:q(_({},(m=r.shapes[h])==null?void 0:m.handles),{[g.id]:q(_({},(E=(v=r.shapes[h])==null?void 0:v.handles)==null?void 0:E[g.id]),{bindingId:d.id})})}),a.has(h)||(i.shapes[h]=q(_({},i.shapes[h]),{handles:q(_({},(w=i.shapes[h])==null?void 0:w.handles),{[g.id]:q(_({},(b=(C=i.shapes[h])==null?void 0:C.handles)==null?void 0:b[g.id]),{bindingId:void 0})})}))})}}),Object.values(e.document.pages).flatMap(d=>Object.values(d.shapes)).forEach(d=>{"assetId"in d&&d.assetId&&!a.has(d.id)&&s.delete(d.assetId)}),{before:r,after:i,assetsToRemove:Array.from(s)}}function NHe(e,t,n=N.uniqueId(),r="Page"){let{currentPageId:i}=e,o=Object.values(e.state.document.pages).sort((h,p)=>{var g,m;return((g=h.childIndex)!=null?g:0)-((m=p.childIndex)!=null?m:0)}),a=o[o.length-1],s=a!=null&&a.childIndex?(a==null?void 0:a.childIndex)+1:1,u={id:n,name:OHe(r,o.map(h=>{var p;return(p=h.name)!=null?p:""})),childIndex:s,shapes:{},bindings:{}},d={id:n,selectedIds:[],camera:{point:t,zoom:1},editingId:void 0,bindingId:void 0,hoveredId:void 0,pointedId:void 0};return{id:"create_page",before:{appState:{currentPageId:i},document:{pages:{[n]:void 0},pageStates:{[n]:void 0}}},after:{appState:{currentPageId:u.id},document:{pages:{[n]:u},pageStates:{[n]:d}}}}}function HS(e,t,n=[]){let{currentPageId:r}=e,i={},o={};t.forEach(u=>{i[u.id]=void 0,o[u.id]=u});let a={},s={};return n.forEach(u=>{a[u.id]=void 0,s[u.id]=u}),{id:"create",before:{document:{pages:{[r]:{shapes:i,bindings:a}},pageStates:{[r]:{selectedIds:[...e.selectedIds]}}}},after:{document:{pages:{[r]:{shapes:o,bindings:s}},pageStates:{[r]:{selectedIds:t.map(u=>u.id)}}}}}}function zHe(e,t){let{currentPageId:n,document:{pages:r,pageStates:i}}=e,o=Object.values(r).sort((u,d)=>(u.childIndex||0)-(d.childIndex||0)),a=o.findIndex(u=>u.id===t),s;return t===n?a===o.length-1?s=o[o.length-2].id:s=o[a+1].id:s=n,{id:"delete_page",before:{appState:{currentPageId:t},document:{pages:{[t]:_({},r[t])},pageStates:{[t]:_({},i[t])}}},after:{appState:{currentPageId:s},document:{pages:{[t]:void 0},pageStates:{[t]:void 0}}}}}var HHe=(e,t)=>{let n=_({},e);return t.forEach(r=>n[r]=void 0),n};function jS(e,t,n=e.currentPageId){let{pageState:r,selectedIds:i,document:{assets:o}}=e,{before:a,after:s,assetsToRemove:u}=_He(e.state,t,n),d=HHe(o,u);return{id:"delete",before:{document:{assets:o,pages:{[n]:a},pageStates:{[n]:{selectedIds:[...e.selectedIds]}}}},after:{document:{assets:d,pages:{[n]:s},pageStates:{[n]:{selectedIds:i.filter(h=>!t.includes(h)),hoveredId:r.hoveredId&&t.includes(r.hoveredId)?void 0:r.hoveredId}}}}}}function jHe(e,t,n){let{currentPageId:r}=e,i=t.map(u=>e.getShape(u)),o=Object.fromEntries(UHe(i,n).map(u=>[u.id,u])),{before:a,after:s}=Q.mutateShapes(e.state,t.filter(u=>o[u]!==void 0),u=>{var d;return{point:(d=o[u.id])==null?void 0:d.next}},r);return i.forEach(u=>{if(u.type==="group"){let d=se.sub(s[u.id].point,a[u.id].point);u.children.forEach(h=>{let p=e.getShape(h);a[p.id]={point:p.point},s[p.id]={point:se.add(p.point,d)}}),delete a[u.id],delete s[u.id]}}),{id:"distribute",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}}}}}function UHe(e,t){let n=e.map(a=>{let s=Q.getShapeUtil(a);return{id:a.id,point:[...a.point],bounds:s.getBounds(a),center:s.getCenter(a)}}),r=n.length,i=N.getCommonBounds(n.map(({bounds:a})=>a)),o=[];switch(t){case"horizontal":{let a=n.reduce((s,u)=>s+u.bounds.width,0);if(a>i.width){let s=n.sort((g,m)=>g.bounds.minX-m.bounds.minX)[0],u=n.sort((g,m)=>m.bounds.maxX-g.bounds.maxX)[0],d=n.filter(g=>g!==s&&g!==u).sort((g,m)=>g.center[0]-m.center[0]),h=(u.center[0]-s.center[0])/(r-1),p=s.center[0]+h;d.forEach(({id:g,point:m,bounds:v},E)=>{o.push({id:g,prev:m,next:[p+h*E-v.width/2,v.minY]})})}else{let s=n.sort((h,p)=>h.center[0]-p.center[0]),u=i.minX,d=(i.width-a)/(r-1);s.forEach(({id:h,point:p,bounds:g})=>{o.push({id:h,prev:p,next:[u,g.minY]}),u+=g.width+d})}break}case"vertical":{let a=n.reduce((s,u)=>s+u.bounds.height,0);if(a>i.height){let s=n.sort((g,m)=>g.bounds.minY-m.bounds.minY)[0],u=n.sort((g,m)=>m.bounds.maxY-g.bounds.maxY)[0],d=n.filter(g=>g!==s&&g!==u).sort((g,m)=>g.center[1]-m.center[1]),h=(u.center[1]-s.center[1])/(r-1),p=s.center[1]+h;d.forEach(({id:g,point:m,bounds:v},E)=>{o.push({id:g,prev:m,next:[v.minX,p+h*E-v.height/2]})})}else{let s=n.sort((h,p)=>h.center[1]-p.center[1]),u=i.minY,d=(i.height-a)/(r-1);s.forEach(({id:h,point:p,bounds:g})=>{o.push({id:h,prev:p,next:[g.minX,u]}),u+=g.height+d})}break}}return o}function KHe(e,t){let{currentPageId:n,pageState:{camera:r}}=e,i=e.document.pages[t],o=N.uniqueId(),a=q(_({},i),{id:o,name:i.name+" Copy",shapes:Object.fromEntries(Object.entries(i.shapes).map(([s,u])=>[s,q(_({},u),{parentId:u.parentId===i.id?o:u.parentId})]))});return{id:"duplicate_page",before:{appState:{currentPageId:n},document:{pages:{[o]:void 0},pageStates:{[o]:void 0}}},after:{appState:{currentPageId:o},document:{pages:{[o]:a},pageStates:{[o]:q(_({},i),{id:o,selectedIds:[],camera:_({},r),editingId:void 0,bindingId:void 0,hoveredId:void 0,pointedId:void 0})}}}}}function VHe(e,t,n){let{selectedIds:r,currentPageId:i,page:o,shapes:a}=e,s={shapes:{},bindings:{}},u={shapes:{},bindings:{}},d={},h=t.map(m=>e.getShape(m)).filter(m=>!t.includes(m.parentId));h.forEach(m=>{let v=N.uniqueId();if(s.shapes[v]=void 0,u.shapes[v]=q(_({},N.deepClone(m)),{id:v,childIndex:Q.getChildIndexAbove(e.state,m.id,i)}),m.children&&(u.shapes[v].children=[]),m.parentId!==i){let E=e.getShape(m.parentId);s.shapes[E.id]=q(_({},s.shapes[E.id]),{children:E.children}),u.shapes[E.id]=q(_({},u.shapes[E.id]),{children:[...(u.shapes[E.id]||E).children,v]})}d[m.id]=v}),h.forEach(m=>{m.children&&m.children.forEach(v=>{var E,w;let C=e.getShape(v),b=N.uniqueId(),A=d[m.id];s.shapes[b]=void 0,u.shapes[b]=q(_({},N.deepClone(C)),{id:b,parentId:A,childIndex:Q.getChildIndexAbove(e.state,C.id,i)}),d[v]=b,(w=(E=u.shapes[d[m.id]])==null?void 0:E.children)==null||w.push(b)})});let p=new Set(Object.keys(d));Object.values(o.bindings).filter(m=>p.has(m.fromId)||p.has(m.toId)).forEach(m=>{if(p.has(m.fromId))if(p.has(m.toId)){let v=N.uniqueId(),E=q(_({},N.deepClone(m)),{id:v,fromId:d[m.fromId],toId:d[m.toId]});s.bindings[v]=void 0,u.bindings[v]=E;let w=u.shapes[E.fromId];Object.values(w.handles).forEach(C=>{C.bindingId===m.id&&(C.bindingId=v)})}else{let v=u.shapes[d[m.fromId]];Object.values(v.handles).forEach(E=>{E.bindingId===m.id&&(E.bindingId=void 0)})}});let g=Object.values(u.shapes);if(n){let m=N.getCommonBounds(g.map(E=>Q.getBounds(E))),v=N.getBoundsCenter(m);g.forEach(E=>{!E.point||(E.point=$.sub(n,$.sub(v,E.point)))})}else{let m=[16,16];g.forEach(v=>{!v.point||(v.point=$.add(v.point,m))})}return g.forEach(m=>{m.isLocked&&(m.isLocked=!1)}),{id:"duplicate",before:{document:{pages:{[i]:s},pageStates:{[i]:{selectedIds:r}}}},after:{document:{pages:{[i]:u},pageStates:{[i]:{selectedIds:Array.from(p.values()).map(m=>d[m])}}}}}}function US(e,t,n){let{selectedIds:r,currentPageId:i,page:{shapes:o}}=e,a=t.map(p=>Q.getBounds(o[p])),s=t.length===1&&o[t[0]].type==="group",u=N.getCommonBounds(a),{before:d,after:h}=Q.mutateShapes(e.state,t,p=>{let g=Q.getBounds(p),m=p.parentId!==i;switch(n){case"horizontal":{if(m&&!s){let E=Q.getBounds(o[p.parentId]),w=N.getRelativeTransformedBoundingBox(u,u,E,!0,!1).minX-E.minX;return Q.getShapeUtil(p).transform(p,q(_({},g),{minX:g.minX+w,maxX:g.maxX+w}),{type:Yi.TopLeft,scaleX:1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}let v=N.getRelativeTransformedBoundingBox(u,u,g,!0,!1);return Q.getShapeUtil(p).transform(p,v,{type:Yi.TopLeft,scaleX:-1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}case"vertical":{if(m&&!s){let E=Q.getBounds(o[p.parentId]),w=N.getRelativeTransformedBoundingBox(u,u,E,!1,!0).minY-E.minY;return Q.getShapeUtil(p).transform(p,q(_({},g),{minY:g.minY+w,maxY:g.maxY+w}),{type:Yi.TopLeft,scaleX:1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}let v=N.getRelativeTransformedBoundingBox(u,u,g,!1,!0);return Q.getShapeUtil(p).transform(p,v,{type:Yi.TopLeft,scaleX:1,scaleY:-1,initialShape:p,transformOrigin:[.5,.5]})}}},i,!0);return{id:"flip",before:{document:{pages:{[i]:{shapes:d}},pageStates:{[i]:{selectedIds:r}}}},after:{document:{pages:{[i]:{shapes:h}},pageStates:{[i]:{selectedIds:t}}}}}}function GHe(e,t,n,r){var i,o;if(t.length<2)return;let a={},s={},u={},d={},h=[...t],p=[],g=[],m=[];for(let D of t){let I=e.getShape(D);if(!I.isLocked)if(I.children===void 0)p.push(I);else{let M=I.children.filter(O=>!e.getShape(O).isLocked);m.push(I),h.push(...M),p.push(...M.map(O=>e.getShape(O)).filter(Boolean))}}if(p.every(D=>D.parentId===p[0].parentId)&&p[0].parentId!==r&&((i=e.getShape(p[0].parentId).children)==null?void 0:i.length)===h.length)return;let v=Q.flattenPage(e.state,r),E=Object.fromEntries(p.map(D=>[D.id,v.indexOf(D)])),w=p.sort((D,I)=>E[D.id]-E[I.id]),C=r,b=(w.filter(D=>D.parentId===r)[0]||w[0]).childIndex,A=N.getCommonBounds(p.map(D=>Q.getBounds(D)));for(a[n]=void 0,s[n]=Q.getShapeUtil("group").create({id:n,childIndex:b,parentId:C,point:[A.minX,A.minY],size:[A.width,A.height],children:w.map(D=>D.id)}),w.forEach((D,I)=>{if(D.parentId!==r){let M=e.getShape(D.parentId);m.push(M)}a[D.id]=q(_({},a[D.id]),{parentId:D.parentId,childIndex:D.childIndex}),s[D.id]=q(_({},s[D.id]),{parentId:n,childIndex:I+1})});m.length>0;){let D=m.pop();if(!D)break;let I=(((o=a[D.id])==null?void 0:o.children)||D.children).filter(M=>M&&!(h.includes(M)||g.includes(M)));I.length===0?(a[D.id]=D,s[D.id]=void 0,D.parentId!==r&&(g.push(D.id),m.push(e.getShape(D.parentId)))):(a[D.id]=q(_({},a[D.id]),{children:D.children}),s[D.id]=q(_({},s[D.id]),{children:I}))}let{bindings:T}=e,B=new Set(g);return T.forEach(D=>{for(let I of[D.toId,D.fromId])if(B.has(I)){u[D.id]=D,d[D.id]=void 0;let M=e.getShape(I);M.handles&&Object.values(M.handles).filter(O=>O.bindingId===D.id).forEach(O=>{var z,K;a[I]=q(_({},a[I]),{handles:q(_({},(z=a[I])==null?void 0:z.handles),{[O.id]:{bindingId:D.id}})}),g.includes(I)||(s[I]=q(_({},s[I]),{handles:q(_({},(K=s[I])==null?void 0:K.handles),{[O.id]:{bindingId:void 0}})}))})}}),{id:"group",before:{document:{pages:{[r]:{shapes:a,bindings:u}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s,bindings:u}},pageStates:{[r]:{selectedIds:[n]}}}}}}function JHe(e,t,n,r,i){let{page:o}=e,a={before:{shapes:{},bindings:{}},after:{shapes:{},bindings:{}}},s={before:{shapes:{},bindings:{}},after:{shapes:{},bindings:{}}},u=new Set,d=new Set;t.map(b=>e.getShape(b,r)).filter(b=>!b.isLocked).forEach(b=>{u.add(b.id),d.add(b),b.children!==void 0&&b.children.forEach(A=>{u.add(A),d.add(e.getShape(A,r))})});let h=Q.getTopChildIndex(e.state,i),p=Array.from(d.values());p.forEach((b,A)=>{if(a.before.shapes[b.id]=b,a.after.shapes[b.id]=void 0,s.before.shapes[b.id]=void 0,s.after.shapes[b.id]=b,!u.has(b.parentId)&&(s.after.shapes[b.id]=q(_({},b),{parentId:i,childIndex:h+A}),b.parentId!==r)){let T=e.getShape(b.parentId,r);a.before.shapes[T.id]={children:T.children},a.after.shapes[T.id]={children:T.children.filter(B=>B!==b.id)}}}),Object.values(o.bindings).filter(b=>u.has(b.fromId)||u.has(b.toId)).forEach(b=>{a.before.bindings[b.id]=b,a.after.bindings[b.id]=void 0;let A=e.getShape(b.fromId,r);if(u.has(b.fromId)&&u.has(b.toId))s.before.bindings[b.id]=void 0,s.after.bindings[b.id]=b;else if(u.has(b.fromId)){let T=e.getShape(b.fromId,r),B=Object.values(A.handles).find(I=>I.bindingId===b.id).id,D=s.after.shapes[T.id];D.handles=q(_({},D.handles),{[B]:q(_({},D.handles[B]),{bindingId:void 0})})}else{let T=e.getShape(b.fromId,r),B=Object.values(A.handles).find(D=>D.bindingId===b.id);a.before.shapes[T.id]={handles:{[B.id]:{bindingId:b.id}}},a.after.shapes[T.id]={handles:{[B.id]:{bindingId:void 0}}}}});let g=e.state.document.pageStates[i],m=N.getCommonBounds(p.map(b=>Q.getBounds(b))),v=Q.getCameraZoom(n.width{var h,p;return((h=u.childIndex)!=null?h:0)-((p=d.childIndex)!=null?p:0)}),a=o.indexOf(i),s=[...o];return s.splice(a,1),s.splice(n>a?n-1:n,0,i),{id:"move_page",before:{document:{pages:Object.fromEntries(o.map(u=>[u.id,{childIndex:u.childIndex}]))}},after:{document:{pages:Object.fromEntries(s.map((u,d)=>[u.id,{childIndex:d}]))}}}}function bp(e,t,n){let{currentPageId:r,page:i}=e,o=new Set(t.map(h=>e.getShape(h).parentId)),a={before:{},after:{}},s,u,d;return Array.from(o.values()).forEach(h=>{let p=[];if(h===i.id)p=Object.values(i.shapes).sort((v,E)=>v.childIndex-E.childIndex);else{let v=e.getShape(h);if(!v.children)throw Error("No children in parent!");p=v.children.map(E=>e.getShape(E)).sort((E,w)=>E.childIndex-w.childIndex)}let g=p.map(v=>v.id),m=t.filter(v=>g.includes(v)).map(v=>g.indexOf(v)).sort((v,E)=>v-E);if(m.length!==g.length)switch(n){case"toBack":{for(let v=0;vp[v].id).reverse(),(v,E)=>({childIndex:u-(E+1)*d}),r);break}case"toFront":{for(let v=g.length-1;v>=0;v--)if(!m.includes(v)){s=v;break}u=p[s].childIndex,d=1,a=Q.mutateShapes(e.state,m.map(v=>p[v].id),(v,E)=>({childIndex:u+(E+1)}),r);break}case"backward":{let v={};for(let E=g.length-1;E>=0;E--)if(m.includes(E)){for(let w=E;w>=0;w--)if(!m.includes(w)){let C=p[w].childIndex,b,A;w===0?(b=C/2,A=C/2/(E-w+1)):(b=p[w-1].childIndex,A=(C-b)/(E-w+1),b+=A);for(let T=0;T0&&(a=Q.mutateShapes(e.state,m.map(E=>p[E].id),E=>({childIndex:v[E.id]}),r));break}case"forward":{let v={};for(let E=0;E0&&(a=Q.mutateShapes(e.state,m.map(E=>p[E].id),E=>({childIndex:v[E.id]}),r));break}}}),{id:"move",before:{document:{pages:{[r]:{shapes:a.before}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:a.after}},pageStates:{[r]:{selectedIds:t}}}}}}function YHe(e,t,n){let{page:r}=e;return{id:"rename_page",before:{document:{pages:{[t]:{name:r.name}}}},after:{document:{pages:{[t]:{name:n}}}}}}function KS(e,t,n){let{currentPageId:r}=e,{before:i,after:o}=Q.mutateShapes(e.state,t,a=>{var s,u;return(u=(s=e.getShapeUtil(a)).onDoubleClickBoundsHandle)==null?void 0:u.call(s,a)},n);return{id:"reset_bounds",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:t}}}}}}var qHe=Math.PI*2;function XHe(e,t,n=-qHe/4){let{currentPageId:r}=e,i={},o={},a=t.flatMap(u=>{let d=e.getShape(u);return d.children?d.children.map(h=>e.getShape(h)):d}).filter(u=>!u.isLocked),s=N.getBoundsCenter(N.getCommonBounds(a.map(u=>Q.getBounds(u))));return a.forEach(u=>{let d=Q.getRotatedShapeMutation(u,Q.getCenter(u),s,n);!d||(i[u.id]=Q.getBeforeShape(u,d),o[u.id]=d)}),{id:"rotate",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:t}}}}}}function ZHe(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.map(p=>e.getShape(p)),a=o.map(p=>Q.getBounds(p)),s=N.getCommonBounds(a),u=t.flatMap(p=>{let g=e.getShape(p);return g.children?g.children:g.id}).filter(p=>!e.getShape(p).isLocked),{before:d,after:h}=Q.mutateShapes(e.state,u,p=>{let g=Q.getBounds(p);switch(n){case"horizontal":{let m=q(_({},g),{minX:s.minX,maxX:s.maxX,width:s.width});return Q.getShapeUtil(p).transformSingle(p,m,{type:Yi.TopLeft,scaleX:m.width/g.width,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}case"vertical":{let m=q(_({},g),{minY:s.minY,maxY:s.maxY,height:s.height});return Q.getShapeUtil(p).transformSingle(p,m,{type:Yi.TopLeft,scaleX:1,scaleY:m.height/g.height,initialShape:p,transformOrigin:[.5,.5]})}}},r);return o.forEach(p=>{p.type==="group"&&(delete d[p.id],delete h[p.id])}),{id:"stretch",before:{document:{pages:{[r]:{shapes:d}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:h}},pageStates:{[r]:{selectedIds:t}}}}}}function QHe(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.flatMap(u=>Q.getDocumentBranch(e.state,u,r)).filter(u=>!e.getShape(u).isLocked),a={},s={};return o.map(u=>e.getShape(u)).filter(u=>!u.isLocked).forEach(u=>{a[u.id]={style:_({},Object.fromEntries(Object.keys(n).map(d=>[d,u.style[d]])))},s[u.id]={style:n},u.type==="text"&&(a[u.id].point=u.point,s[u.id].point=$.toFixed($.add(u.point,$.sub(e.getShapeUtil(u).getCenter(u),e.getShapeUtil(u).getCenter(q(_({},u),{style:_(_({},u.style),n)}))))))}),{id:"style",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:i}}},appState:{currentStyle:_({},e.appState.currentStyle)}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}},appState:{currentStyle:n}}}}function eje(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=Object.fromEntries(t.map(s=>{var u;return[s,{decorations:{[n]:(u=e.getShape(s).decorations)==null?void 0:u[n]}}]})),a=Object.fromEntries(t.filter(s=>!e.getShape(s).isLocked).map(s=>{var u;return[s,{decorations:{[n]:(u=e.getShape(s).decorations)!=null&&u[n]?void 0:"arrow"}}]}));return{id:"toggle_decorations",before:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}}}}function qv(e,t,n){let{currentPageId:r}=e,i=t.map(u=>e.getShape(u)).filter(u=>n==="isLocked"?!0:!u.isLocked),o=i.every(u=>u[n]),a={},s={};return i.forEach(u=>{a[u.id]={[n]:u[n]},s[u.id]={[n]:!o}}),{id:"toggle",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}}}}}function tje(e,t,n){let{currentPageId:r,selectedIds:i}=e;e.rotationInfo.selectedIds=[...i];let o={shapes:{},bindings:{}},a={shapes:{},bindings:{}},s=t.flatMap(d=>{let h=e.getShape(d);return h.children?h.children:h.id}).filter(d=>!e.getShape(d).isLocked),u=Q.mutateShapes(e.state,s,d=>({point:$.toFixed($.add(d.point,n))}),r);return o.shapes=u.before,a.shapes=u.after,Q.getBindings(e.state,r).filter(d=>t.includes(d.fromId)&&!t.includes(d.toId)).forEach(d=>{o.bindings[d.id]=d,a.bindings[d.id]=void 0;for(let h of[d.toId,d.fromId]){let p=e.getShape(h);!p.handles||Object.values(p.handles).filter(g=>g.bindingId===d.id).forEach(g=>{var m,v;o.shapes[h]=q(_({},o.shapes[h]),{handles:q(_({},(m=o.shapes[h])==null?void 0:m.handles),{[g.id]:{bindingId:d.id}})}),a.shapes[h]=q(_({},a.shapes[h]),{handles:q(_({},(v=a.shapes[h])==null?void 0:v.handles),{[g.id]:{bindingId:void 0}})})})}}),{id:"translate",before:{document:{pages:{[r]:o},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:a},pageStates:{[r]:{selectedIds:t}}}}}}function nje(e,t,n,r){let{bindings:i}=e,o={},a={},s={},u={},d=t,h=t.filter(p=>!n.find(g=>g.id===p));return n.filter(p=>!p.isLocked).forEach(p=>{let g=[],m=[];o[p.id]=p,a[p.id]=void 0,p.children.forEach(w=>{h.push(w);let C=e.getShape(w,r);g.push(C)});let v=p.childIndex,E=(Q.getChildIndexAbove(e.state,p.id,r)-v)/g.length;g.sort((w,C)=>w.childIndex-C.childIndex).forEach((w,C)=>{o[w.id]={parentId:w.parentId,childIndex:w.childIndex},a[w.id]={parentId:r,childIndex:v+E*C}}),i.filter(w=>w.toId===p.id||w.fromId===p.id).forEach(w=>{for(let C of[w.toId,w.fromId])if(a[C]===void 0){s[w.id]=w,u[w.id]=void 0;let b=e.getShape(C,r);b.handles&&Object.values(b.handles).filter(A=>A.bindingId===w.id).forEach(A=>{var T,B;o[C]=q(_({},o[C]),{handles:q(_({},(T=o[C])==null?void 0:T.handles),{[A.id]:{bindingId:w.id}})}),m.includes(C)||(a[C]=q(_({},a[C]),{handles:q(_({},(B=a[C])==null?void 0:B.handles),{[A.id]:{bindingId:void 0}})}))})}})}),{id:"ungroup",before:{document:{pages:{[r]:{shapes:o,bindings:s}},pageStates:{[r]:{selectedIds:d}}}},after:{document:{pages:{[r]:{shapes:a,bindings:s}},pageStates:{[r]:{selectedIds:h}}}}}}function VS(e,t,n){let r=t.map(o=>o.id),i=Q.mutateShapes(e.state,r.filter(o=>!e.getShape(o,n).isLocked),(o,a)=>t[a],n);return{id:"update",before:{document:{pages:{[n]:{shapes:i.before}}}},after:{document:{pages:{[n]:{shapes:i.after}}}}}}function rje(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.map(d=>e.getShape(d)).filter(d=>n.isLocked?!0:!d.isLocked),a={},s={},u=Object.keys(n);return o.forEach(d=>{a[d.id]=Object.fromEntries(u.map(h=>[h,d[h]])),s[d.id]=n}),{id:"set_props",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:i}}}}}}function ije(e,t,n={}){let{currentPageId:r}=e,{point:i,select:o,overwrite:a}=n,s=e.document.pages[r],u={shapes:{},bindings:{}},d={},h={shapes:{},bindings:{}};if(a){for(let g of t.shapes)u.shapes[g.id]=s.shapes[g.id],h.shapes[g.id]=g;if(t.bindings)for(let g of t.bindings)u.bindings[g.id]=s.bindings[g.id],h.bindings[g.id]=g;if(t.assets)for(let g of t.assets)d[g.id]=g}else{let g={},m=Q.getTopChildIndex(e.state,r),v=t.shapes.sort((C,b)=>C.childIndex-b.childIndex).map(C=>{let b=N.uniqueId();return g[C.id]=b,q(_({},N.deepClone(C)),{id:b})}),E=new Set;for(;v.length>0;){let C=v.shift();if(!C)break;if(E.add(C.id),C.parentId==="currentPageId")C.parentId=r,C.childIndex=m++;else{C.parentId=g[C.parentId];let b=h.shapes[C.parentId];if(!b){E.has(C.id)&&(C.parentId="currentPageId"),v.push(C);continue}b.children.push(C.id)}C.children&&(C.children=[]),u.shapes[C.id]=void 0,h.shapes[C.id]=C}Object.values(h.shapes).forEach(C=>{C.children&&C.children.length===0&&(delete u.shapes[C.id],delete h.shapes[C.id])}),t.bindings&&t.bindings.forEach(C=>{let b=N.uniqueId();g[C.id]=b;let A=g[C.toId],T=g[C.fromId];if(!A||!T){if(T){let I=h.shapes[T].handles;I&&Object.values(I).forEach(M=>{M.bindingId===C.id&&(M.bindingId=void 0)})}if(A){let I=h.shapes[A].handles;I&&Object.values(I).forEach(M=>{M.bindingId===C.id&&(M.bindingId=void 0)})}return}let B=h.shapes[T].handles;B&&Object.values(B).forEach(I=>{I.bindingId===C.id&&(I.bindingId=b)}),h.shapes[A].handles&&Object.values(h.shapes[A].handles).forEach(I=>{I.bindingId===C.id&&(I.bindingId=b)});let D=q(_({},N.deepClone(C)),{id:b,toId:A,fromId:T});u.bindings[D.id]=void 0,h.bindings[D.id]=D});let w=Object.values(h.shapes);if(w.length>0)if(i){let C=N.getCommonBounds(w.map(A=>Q.getBounds(A))),b=N.getBoundsCenter(C);w.forEach(A=>{!A.point||(A.point=$.sub(i,$.sub(b,A.point)))})}else{let C=N.getCommonBounds(w.map(Q.getBounds));if(!(N.boundsContain(e.viewport,C)||N.boundsCollide(e.viewport,C))){let b=$.toFixed(e.getPagePoint(e.centerPoint)),A=N.centerBounds(C,b),T=$.sub(N.getBoundsCenter(A),N.getBoundsCenter(C));w.forEach(B=>{B.point=$.toFixed($.add(B.point,T))})}}if(t.assets)for(let C of t.assets)d[C.id]=C}let p=document.createElement("textarea");return Object.values(h.shapes).forEach(g=>{"text"in g&&(p.innerHTML=g.text,g.text=p.value),"label"in g&&(p.innerHTML=g.label,g.label=p.value)}),p.remove(),{id:"insert",before:{document:{pages:{[r]:u},pageStates:{[r]:{selectedIds:[...e.selectedIds]}}}},after:{document:{pages:{[r]:h},assets:d,pageStates:{[r]:{selectedIds:o?Object.keys(h.shapes):[...e.selectedIds]}}}}}}var qT={};une(qT,{fileToBase64:()=>eP,fileToText:()=>tP,getImageSizeFromSrc:()=>nP,getVideoSizeFromSrc:()=>rP,loadFileHandle:()=>XT,migrate:()=>ia,openAssetsFromFileSystem:()=>QT,openFromFileSystem:()=>ZT,saveFileHandle:()=>MC,saveToFileSystem:()=>Gy});function ia(e,t){let{document:n,settings:r}=e,{version:i=0}=n;"assets"in n||(n.assets={});let o=new Set;return Object.values(n.pages).forEach(a=>Object.values(a.shapes).forEach(s=>{let{parentId:u,children:d,assetId:h}=s;h&&o.add(h),u!==a.id&&!a.shapes[u]&&(console.warn("Encountered a shape with a missing parent!"),s.parentId=a.id),s.type==="group"&&d&&d.forEach(p=>{a.shapes[p]||(console.warn("Encountered a parent with a missing child!",s.id,p),d==null||d.splice(d.indexOf(p),1))})})),Object.keys(n.assets).forEach(a=>{o.has(a)||delete n.assets[a]}),i!==t&&(i<14&&Object.values(n.pages).forEach(a=>{Object.values(a.shapes).filter(s=>s.type==="text").forEach(s=>s.style.font==="script")}),i<=13&&Object.values(n.pages).forEach(a=>{Object.values(a.bindings).forEach(s=>{Object.assign(s,s.meta)}),Object.values(a.shapes).forEach(s=>{Object.entries(s.style).forEach(([u,d])=>{typeof d=="string"&&(s.style[u]=d.toLowerCase())}),s.type==="arrow"&&s.decorations&&Object.entries(s.decorations).forEach(([u,d])=>{d==="Arrow"&&(s.decorations=q(_({},s.decorations),{[u]:"arrow"}))})})}),i<=13.1&&(n.name="New Document"),i<15&&(n.assets={}),Object.values(n.pages).forEach(a=>{Object.values(a.shapes).forEach(s=>{i<15.2&&(s.type==="image"||s.type==="video")&&(s.style.isFilled=!0),i<15.3&&(s.type==="rectangle"||s.type==="triangle"||s.type==="ellipse"||s.type==="arrow")&&(s.label=s.text||"",s.labelPoint=[.5,.5])})}),i<15.4&&(r.dockPosition="bottom"),i<15.5&&(r.exportBackground="transparent")),Object.values(n.pageStates).forEach(a=>{a.selectedIds=a.selectedIds.filter(s=>n.pages[a.id].shapes[s]!==void 0),a.bindingId=void 0,a.editingId=void 0,a.hoveredId=void 0,a.pointedId=void 0}),n.version=t,e}var GS={mode:"readwrite"},oje=e=>Oe(void 0,null,function*(){return(yield e.queryPermission(GS))==="granted"||(yield e.requestPermission(GS))==="granted"});function XT(){return Oe(this,null,function*(){return typeof Window>"u"||!("_location"in Window)?void 0:(yield Og(`Tldraw_file_handle_${window.location.origin}`))||null})}function MC(e){return Oe(this,null,function*(){return I0(`Tldraw_file_handle_${window.location.origin}`,e)})}function Gy(e,t,n){return Oe(this,null,function*(){let r={name:e.name||"New Document",fileHandle:t??null,document:e,assets:{}},i=JSON.stringify(r),o=new Blob([i],{type:"application/vnd.Tldraw+json"});if(t&&!(yield oje(t)))return null;let a=!kd&&(n!=null&&n.length)?n:`${r.name}`,s=yield eT(o,{fileName:`${a}${zy}`,description:"Tldraw File",extensions:[`${zy}`]},t);return yield MC(s),s})}function ZT(){return Oe(this,null,function*(){var e;let t=yield dC({description:"Tldraw File",extensions:[`${zy}`],multiple:!1});if(!t)return null;let n=yield new Promise(o=>{let a=new FileReader;a.onloadend=()=>{a.readyState===FileReader.DONE&&o(a.result)},a.readAsText(t,"utf8")}),r=JSON.parse(n),i=(e=t.handle)!=null?e:null;return yield MC(i),{fileHandle:i,document:r.document}})}function QT(){return Oe(this,null,function*(){return dC({description:"Image or Video",extensions:[...MT,...$T],multiple:!0})})}function eP(e){return new Promise((t,n)=>{if(e){let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=i=>n(i),r.onabort=i=>n(i)}})}function tP(e){return new Promise((t,n)=>{if(e){let r=new FileReader;r.readAsText(e),r.onload=()=>t(r.result),r.onerror=i=>n(i),r.onabort=i=>n(i)}})}function nP(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t([r.width,r.height]),r.onerror=()=>n(new Error("Could not get image size")),r.src=e})}function rP(e){return new Promise((t,n)=>{let r=document.createElement("video");r.onloadedmetadata=()=>t([r.videoWidth,r.videoHeight]),r.onerror=()=>n(new Error("Could not get video size")),r.src=e})}lne(qT,qee);var lo=class{constructor(e){this.app=e}},aje=class extends lo{constructor(e,t,n,r=!1){super(e),S(this,"type","arrow"),S(this,"performanceMode"),S(this,"status","translatingHandle"),S(this,"newStartBindingId",N.uniqueId()),S(this,"draggedBindingId",N.uniqueId()),S(this,"didBind",!1),S(this,"initialShape"),S(this,"handleId"),S(this,"bindableShapeIds"),S(this,"initialBinding"),S(this,"startBindingShapeId"),S(this,"isCreate"),S(this,"start",()=>{}),S(this,"update",()=>{var p,g,m;let{initialShape:v}=this,{currentPoint:E,shiftKey:w,altKey:C,metaKey:b,currentGrid:A,settings:{showGrid:T}}=this.app,B=this.app.getShape(v.id);if(B.isLocked)return;let{handles:D}=v,I=this.handleId;if(!D[I].canBind)return;let M=$.sub(E,$.add(D[I].point,v.point));if(w){let U=C?$.med(D.start.point,D.end.point):D[I==="start"?"end":"start"].point,ne=D[I].point,le=$.add(ne,M),Ae=$.angle(U,le),we=$.rotWith(le,U,N.snapAngleToSegments(Ae,24)-Ae);M=$.add(M,$.sub(we,le))}let O=$.add(D[I].point,M),z={[I]:q(_({},D[I]),{point:T?$.snap(O,A):$.toFixed(O),bindingId:void 0})},K=od.arrow,X=(p=K.onHandleChange)==null?void 0:p.call(K,v,z);if(!X)return;let Z={shape:N.deepMerge(B,X),bindings:{}},pe,me=Z.shape.handles[this.handleId],Ce=Z.shape.handles[this.handleId==="start"?"end":"start"];if(this.startBindingShapeId){let U,ne=this.app.page.shapes[this.startBindingShapeId],le=Q.getShapeUtil(ne),Ae=le.getCenter(ne),we=Z.shape.handles.start,ft=Z.shape.handles.end,Ze=$.add(we.point,Z.shape.point);$.isEqual(Ze,Ae)&&Ze[1]++;let qe=Ae,Ge=le.hitTestPoint(ne,E),At=$.uni($.sub(Ze,qe)),dt=this.app.getBinding(this.newStartBindingId)!==void 0;!b&&!le.hitTestPoint(ne,$.add(Z.shape.point,ft.point))&&(U=this.findBindingPoint(B,ne,"start",this.newStartBindingId,Ae,qe,At,Ge)),U&&!dt?(this.didBind=!0,Z.bindings[this.newStartBindingId]=U,Z.shape=N.deepMerge(Z.shape,{handles:{start:{bindingId:U.id}}})):!U&&dt&&(this.didBind=!1,Z.bindings[this.newStartBindingId]=void 0,Z.shape=N.deepMerge(v,{handles:{start:{bindingId:void 0}}}))}if(!b){let U=$.add(Ce.point,Z.shape.point),ne=$.add(me.point,Z.shape.point),le=$.uni($.sub(ne,U)),Ae=$.add(Z.shape.point,Z.shape.handles.start.point),we=$.add(Z.shape.point,Z.shape.handles.end.point),ft=this.bindableShapeIds.map(Ze=>this.app.page.shapes[Ze]).sort((Ze,qe)=>qe.childIndex-Ze.childIndex).filter(Ze=>{if(Ze.isLocked)return!1;let qe=Q.getShapeUtil(Ze);return![Ae,we].every(Ge=>qe.hitTestPoint(Ze,Ge))});for(let Ze of ft)if(pe=this.findBindingPoint(B,Ze,this.handleId,this.draggedBindingId,ne,U,le,C),pe)break}if(pe)this.didBind=!0,Z.bindings[this.draggedBindingId]=pe,Z.shape=N.deepMerge(Z.shape,{handles:{[this.handleId]:{bindingId:this.draggedBindingId}}});else{this.didBind=this.didBind||!1;let U=B.handles[this.handleId].bindingId;U!==void 0&&(Z.bindings[U]=void 0,Z.shape=N.deepMerge(Z.shape,{handles:{[this.handleId]:{bindingId:void 0}}}))}let W=(m=(g=Q.getShapeUtil(Z.shape)).onHandleChange)==null?void 0:m.call(g,Z.shape,Z.shape.handles);return{document:{pages:{[this.app.currentPageId]:{shapes:{[B.id]:_(_({},Z.shape),W??{})},bindings:Z.bindings}},pageStates:{[this.app.currentPageId]:{bindingId:Z.shape.handles[I].bindingId}}}}}),S(this,"cancel",()=>{let{initialShape:p,initialBinding:g,newStartBindingId:m,draggedBindingId:v}=this,E=Q.onSessionComplete(this.app.page.shapes[p.id]),w=this.isCreate||$.dist(E.handles.start.point,E.handles.end.point)<4,C={};return C[v]=void 0,g&&(C[g.id]=w?void 0:g),m&&(C[m]=void 0),{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:w?void 0:p},bindings:C}},pageStates:{[this.app.currentPageId]:{selectedIds:w?[]:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}}}),S(this,"complete",()=>{let{initialShape:p,initialBinding:g,newStartBindingId:m,startBindingShapeId:v,handleId:E}=this,w=Q.onSessionComplete(this.app.page.shapes[p.id]),C=w.handles[E].bindingId,b=$.dist(w.handles.start.point,w.handles.end.point);if(!(C||g)&&b<4)return this.cancel();let A={},T={};return g&&(A[g.id]=this.isCreate?void 0:g,T[g.id]=void 0),C&&(A[C]=void 0,T[C]=this.app.page.bindings[C]),v&&(A[m]=void 0,T[m]=this.app.page.bindings[m]),{id:"arrow",before:{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:this.isCreate?void 0:p},bindings:A}},pageStates:{[this.app.currentPageId]:{selectedIds:this.isCreate?[]:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}},after:{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:w},bindings:T}},pageStates:{[this.app.currentPageId]:{selectedIds:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}}}}),S(this,"findBindingPoint",(p,g,m,v,E,w,C,b)=>{let A=Q.getShapeUtil(g.type).getBindingPoint(g,p,E,w,C,b);if(A)return{id:v,type:"arrow",fromId:p.id,toId:g.id,handleId:m,point:$.toFixed(A.point),distance:A.distance}});var i,o,a;this.isCreate=r;let{currentPageId:s}=e.state.appState,u=e.state.document.pages[s];this.handleId=n,this.initialShape=$r(u.shapes[t]),this.bindableShapeIds=Q.getBindableShapeIds(e.state).filter(p=>!(p===this.initialShape.id||p===this.initialShape.parentId));let d=(i=this.initialShape.handles[n==="start"?"end":"start"])==null?void 0:i.bindingId;if(d){let p=(o=u.bindings[d])==null?void 0:o.toId;p&&(this.bindableShapeIds=this.bindableShapeIds.filter(g=>g!==p))}let{originPoint:h}=this.app;if(this.isCreate)this.startBindingShapeId=(a=this.bindableShapeIds.map(p=>u.shapes[p]).filter(p=>!p.isLocked&&N.pointInBounds(h,Q.getShapeUtil(p).getBounds(p))).sort((p,g)=>g.childIndex-p.childIndex)[0])==null?void 0:a.id,this.startBindingShapeId&&this.bindableShapeIds.splice(this.bindableShapeIds.indexOf(this.startBindingShapeId),1);else{let p=this.initialShape.handles[this.handleId].bindingId;p?this.initialBinding=u.bindings[p]:this.initialShape.handles[this.handleId].bindingId=void 0}}},sje=class extends lo{constructor(e){super(e),S(this,"type","brush"),S(this,"performanceMode"),S(this,"status","brushing"),S(this,"initialSelectedIds"),S(this,"shapesToTest"),S(this,"start",()=>{}),S(this,"update",()=>{let{initialSelectedIds:n,shapesToTest:r,app:{metaKey:i,settings:o,originPoint:a,currentPoint:s}}=this,u=N.getBoundsFromPoints([a,s]),d=o.isCadSelectMode?!i&&a[0]{let C=this.app.getShape(E);if(!h.has(w)){let b=this.app.getShapeUtil(C);(d?N.boundsContain(u,b.getBounds(C)):b.hitTestBounds(C,u))?(h.add(w),p.has(w)||p.add(w)):p.has(w)&&p.delete(w)}});let g=this.app.selectedIds,m=p.size!==g.length||g.some(E=>!p.has(E)),v=m?Array.from(p.values()):g;return m?{appState:{selectByContain:d},document:{pageStates:{[this.app.currentPageId]:{brush:u,selectedIds:v}}}}:{appState:{selectByContain:d},document:{pageStates:{[this.app.currentPageId]:{brush:u}}}}}),S(this,"cancel",()=>({appState:{selectByContain:!1},document:{pageStates:{[this.app.currentPageId]:{brush:null,selectedIds:Array.from(this.initialSelectedIds.values())}}}})),S(this,"complete",()=>({appState:{selectByContain:!1},document:{pageStates:{[this.app.currentPageId]:{brush:null,selectedIds:[...this.app.selectedIds]}}}}));let{currentPageId:t}=e;this.initialSelectedIds=new Set(this.app.selectedIds),this.shapesToTest=this.app.shapes.filter(n=>!(n.isLocked||n.isHidden||n.parentId!==t||this.initialSelectedIds.has(n.id)||this.initialSelectedIds.has(n.parentId))).map(n=>({id:n.id,bounds:this.app.getShapeUtil(n).getBounds(n),selectId:n.id})),this.update()}},uje=class extends lo{constructor(e,t){super(e),S(this,"type","draw"),S(this,"performanceMode"),S(this,"status","creating"),S(this,"topLeft"),S(this,"points"),S(this,"initialShape"),S(this,"lastAdjustedPoint"),S(this,"shiftedPoints",[]),S(this,"shapeId"),S(this,"isLocked"),S(this,"isExtending"),S(this,"lockedDirection"),S(this,"start",()=>{var u;let d=this.app.originPoint,h=[0,0,(u=d[2])!=null?u:.5];this.points.push(h);let p=[Math.min(this.topLeft[0],d[0]),Math.min(this.topLeft[1],d[1])],g=$.sub(p,d);return this.topLeft=p,this.shiftedPoints=this.points.map(m=>$.toFixed($.sub(m,g)).concat(m[2])),{document:{pages:{[this.app.currentPageId]:{shapes:{[this.shapeId]:{point:this.topLeft,points:this.shiftedPoints}}}},pageStates:{[this.app.currentPageId]:{selectedIds:[this.shapeId]}}}}}),S(this,"update",()=>{let{shapeId:u}=this,{currentPoint:d,originPoint:h,shiftKey:p,zoom:g}=this.app;if(!this.lockedDirection&&this.points.length>1){let v=$.sub(d,h);$.len(v)>3/g&&(this.lockedDirection=Math.abs(v[0])>Math.abs(v[1])?"horizontal":"vertical")}if(p){if(!this.isLocked&&this.points.length>2){if(!this.lockedDirection){let E=$.sub(d,h);$.len(E)>3/g&&(this.lockedDirection=Math.abs(E[0])>Math.abs(E[1])?"horizontal":"vertical")}this.isLocked=!0;let v=[...this.lastAdjustedPoint];this.lockedDirection==="vertical"?v[0]=0:v[1]=0,this.points.push(v.concat(d[2]))}}else this.isLocked&&(this.isLocked=!1);this.isLocked&&(this.lockedDirection==="vertical"?d[0]=h[0]:d[1]=h[1]);let m=this.addPoint(d);if(m)return{document:{pages:{[this.app.currentPageId]:{shapes:{[u]:m}}},pageStates:{[this.app.currentPageId]:{selectedIds:[u]}}}}}),S(this,"cancel",()=>{let{shapeId:u}=this,d=this.app.currentPageId;return{document:{pages:{[d]:{shapes:{[u]:this.isExtending?this.initialShape:void 0}}},pageStates:{[d]:{selectedIds:[]}}}}}),S(this,"complete",()=>{let{shapeId:u}=this,d=this.app.currentPageId,h=this.app.getShape(u);return{id:"create_draw",before:{document:{pages:{[d]:{shapes:{[u]:this.isExtending?this.initialShape:void 0}}},pageStates:{[d]:{selectedIds:[]}}}},after:{document:{pages:{[d]:{shapes:{[u]:q(_({},h),{point:$.toFixed(h.point),points:h.points.map(p=>$.toFixed(p)),isComplete:!0})}}},pageStates:{[this.app.currentPageId]:{selectedIds:[]}}}}}}),S(this,"addPoint",u=>{let{originPoint:d}=this.app,h=$.toFixed($.sub(u,d)).concat(u[2]);if($.isEqual(this.lastAdjustedPoint,h))return;this.points.push(h),this.lastAdjustedPoint=h;let p=[...this.topLeft],g=[Math.min(this.topLeft[0],u[0]),Math.min(this.topLeft[1],u[1])],m=$.sub(g,d),v;return p[0]!==g[0]||p[1]!==g[1]?(this.topLeft=g,v=this.points.map(E=>$.toFixed($.sub(E,m)).concat(E[2]))):v=[...this.shiftedPoints,$.sub(h,m).concat(h[2])],this.shiftedPoints=v,{point:this.topLeft,points:v}});var n;let{originPoint:r}=this.app;this.shapeId=t,this.initialShape=this.app.getShape(t),this.topLeft=[...this.initialShape.point];let i=[0,0,(n=r[2])!=null?n:.5],o=$.sub(r,this.topLeft),a=this.initialShape.points.map(u=>$.sub(u,o).concat(u[2]));this.isExtending=a.length>0;let s=[];if(this.isExtending){let u=a[a.length-1];if(u){s.push(u,u);let d=Math.floor($.dist(u,i)/16);if(d>1)for(let h=0;h$.add(u,o).concat(u[2])),this.lastAdjustedPoint=this.points[this.points.length-1]}},lje=class extends lo{constructor(e,t,n){super(e),S(this,"type","edit"),S(this,"performanceMode"),S(this,"initialShape"),S(this,"initialSelectedIds"),S(this,"currentPageId"),S(this,"isCreating"),S(this,"start",()=>{}),S(this,"update",()=>{}),S(this,"cancel",()=>({document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:this.isCreating?void 0:this.initialShape}}},pageStates:{[this.currentPageId]:{selectedIds:this.isCreating?[]:this.initialSelectedIds,editingId:void 0}}}})),S(this,"complete",()=>{let r=this.app.getShape(this.initialShape.id);return{id:"edit",before:{document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:this.isCreating?void 0:this.initialShape}}},pageStates:{[this.currentPageId]:{selectedIds:this.isCreating?[]:this.initialSelectedIds,editingId:void 0}}}},after:{document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:r}}},pageStates:{[this.currentPageId]:{selectedIds:[r.id],editingId:void 0}}}}}}),this.initialShape=e.getShape(t,e.currentPageId),this.currentPageId=e.currentPageId,this.isCreating=n,this.initialSelectedIds=[...e.selectedIds]}},cje=class extends lo{constructor(e){super(e),S(this,"type","draw"),S(this,"performanceMode"),S(this,"status","creating"),S(this,"isLocked"),S(this,"lockedDirection"),S(this,"erasedShapes",new Set),S(this,"erasedBindings",new Set),S(this,"initialSelectedShapes"),S(this,"erasableShapes"),S(this,"prevPoint"),S(this,"prevEraseShapesSize",0),S(this,"interval"),S(this,"timestamp1",0),S(this,"timestamp2",0),S(this,"prevErasePoint",[]),S(this,"loop",()=>{let t=Date.now(),n=t-this.timestamp1,r=t-this.timestamp2,{eraseLine:i}=this.app.appState,o=[...i],a=!1;n>16&&this.prevErasePoint!==this.prevPoint&&(a=!0,o=[...i,this.prevPoint],this.prevErasePoint=this.prevPoint),r>32&&o.length>1&&(a=!0,o.splice(0,Math.ceil(o.length*.1)),this.timestamp2=t),a&&this.app.patchState({appState:{eraseLine:o}},"eraseline"),this.interval=requestAnimationFrame(this.loop)}),S(this,"start",()=>{}),S(this,"update",()=>{let{page:t,shiftKey:n,originPoint:r,currentPoint:i,zoom:o}=this.app;if(n){let d=$.sub(i,r);if(!this.isLocked&&$.len(d)>3/o){if(!this.lockedDirection){let h=$.sub(i,r);this.lockedDirection=Math.abs(h[0])>Math.abs(h[1])?"horizontal":"vertical"}this.isLocked=!0}}else this.isLocked&&(this.isLocked=!1);this.isLocked&&(this.lockedDirection==="vertical"?i[0]=r[0]:i[1]=r[1]);let a=$.toFixed($.add(r,$.sub(i,r))),s=new Set([]);this.erasableShapes.forEach(d=>{if(!this.erasedShapes.has(d)&&this.app.getShapeUtil(d).hitTestLineSegment(d,this.prevPoint,a)&&(this.erasedShapes.add(d),s.add(d.id),d.children!==void 0))for(let h of d.children)this.erasedShapes.add(this.app.getShape(h)),s.add(h)}),Object.values(t.bindings).forEach(d=>{for(let h of[d.toId,d.fromId])s.has(h)&&this.erasedBindings.add(d)}),this.erasedShapes.forEach(d=>{this.app.getShape(d.id)||(this.erasedShapes.delete(d),this.erasableShapes.delete(d),s.delete(d.id))});let u=Array.from(this.erasedShapes.values());if(this.prevPoint=a,u.length!==this.prevEraseShapesSize)return this.prevEraseShapesSize=u.length,{document:{pages:{[t.id]:{shapes:Object.fromEntries(u.map(d=>[d.id,{isGhost:!0}]))}}}}}),S(this,"cancel",()=>{let{page:t}=this.app;cancelAnimationFrame(this.interval),this.erasedShapes.forEach(r=>{this.app.getShape(r.id)||(this.erasedShapes.delete(r),this.erasableShapes.delete(r))});let n=Array.from(this.erasedShapes.values());return{document:{pages:{[t.id]:{shapes:Object.fromEntries(n.map(r=>[r.id,{isGhost:!1}]))}},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.map(r=>r.id)}}},appState:{eraseLine:[]}}}),S(this,"complete",()=>{let{page:t}=this.app;cancelAnimationFrame(this.interval),this.erasedShapes.forEach(u=>{this.app.getShape(u.id)||(this.erasedShapes.delete(u),this.erasableShapes.delete(u))}),this.erasedBindings.forEach(u=>{this.app.getBinding(u.id)||this.erasedBindings.delete(u)});let n=Array.from(this.erasedShapes.values()),r=Array.from(this.erasedBindings.values()),i=n.map(u=>u.id),o=r.map(u=>u.id),a={shapes:Object.fromEntries(n.map(u=>[u.id,u])),bindings:Object.fromEntries(r.map(u=>[u.id,u]))},s={shapes:Object.fromEntries(n.map(u=>[u.id,void 0])),bindings:Object.fromEntries(r.map(u=>[u.id,void 0]))};return this.app.shapes.forEach(u=>{u.handles&&!s.shapes[u.id]&&Object.values(u.handles).forEach(d=>{var h,p;d.bindingId&&o.includes(d.bindingId)&&(a.shapes[u.id]=q(_({},a.shapes[u.id]),{handles:q(_({},(h=a.shapes[u.id])==null?void 0:h.handles),{[d.id]:d})}),i.includes(u.id)||(s.shapes[u.id]=q(_({},s.shapes[u.id]),{handles:q(_({},(p=s.shapes[u.id])==null?void 0:p.handles),{[d.id]:q(_({},d),{bindingId:void 0})})})))})}),{id:"erase",before:{document:{pages:{[t.id]:a},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.filter(u=>!!this.app.getShape(u.id)).map(u=>u.id)}}},appState:{eraseLine:[]}},after:{document:{pages:{[t.id]:s},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.filter(u=>!!this.app.getShape(u.id)).filter(u=>!i.includes(u.id)).map(u=>u.id)}}},appState:{eraseLine:[]}}}}),this.prevPoint=[...e.originPoint],this.initialSelectedShapes=this.app.selectedIds.map(t=>this.app.getShape(t)),this.erasableShapes=new Set(this.app.shapes.filter(t=>!t.isLocked)),this.interval=this.loop()}},dje=class extends lo{constructor(e,t){super(e),S(this,"type","grid"),S(this,"performanceMode"),S(this,"status","translating"),S(this,"shape"),S(this,"bounds"),S(this,"initialSelectedIds"),S(this,"initialSiblings"),S(this,"grid",{}),S(this,"columns",1),S(this,"rows",1),S(this,"isCopying",!1),S(this,"start",()=>{}),S(this,"update",()=>{let{currentPageId:r,altKey:i,shiftKey:o,currentPoint:a}=this.app,s={},u={},d=N.getBoundsCenter(this.bounds),h=$.sub(a,d);o&&(Math.abs(h[0])B!==this.shape.id).forEach(B=>s[B]=void 0),this.grid={"0_0":this.shape.id},this.isCopying=T);for(let B=E;B{A.has(B)||(s[D]=void 0,delete this.grid[B])}),Object.values(s).length!==0)return this.initialSiblings&&(s[this.shape.parentId]={children:[...this.initialSiblings,...Object.values(this.grid)]}),{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:u}}}}),S(this,"cancel",()=>{let{currentPageId:r}=this.app,i={};return Object.values(this.grid).forEach(o=>{i[o]=void 0}),i[this.shape.id]=q(_({},i[this.shape.id]),{point:this.shape.point}),this.initialSiblings&&(i[this.shape.parentId]={children:[...this.initialSiblings,this.shape.id]}),{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:[this.shape.id]}}}}}),S(this,"complete",()=>{let{currentPageId:r}=this.app,i={},o={},a=[];if(Object.values(this.grid).forEach(s=>{i[s]=void 0,o[s]=this.app.getShape(s),a.push(s)}),i[this.shape.id]=this.shape,this.initialSiblings&&(i[this.shape.parentId]={children:[...this.initialSiblings,this.shape.id]},o[this.shape.parentId]={children:[...this.initialSiblings,...Object.values(this.grid)]}),a.length!==1)return{id:"grid",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:[],hoveredId:void 0}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:a,hoveredId:void 0}}}}}}),S(this,"getClone",(r,i)=>{let o=q(_({},this.shape),{id:N.uniqueId(),point:r});return i||o.type==="sticky"&&(o.text=""),o});var n;this.shape=this.app.getShape(t),this.grid["0_0"]=this.shape.id,this.bounds=this.app.getShapeBounds(t),this.initialSelectedIds=[...this.app.selectedIds],this.shape.parentId!==this.app.currentPageId&&(this.initialSiblings=(n=this.app.getShape(this.shape.parentId).children)==null?void 0:n.filter(r=>r!==this.shape.id))}},hje=class extends lo{constructor(e,t,n,r="move_handle"){super(e),S(this,"type","handle"),S(this,"performanceMode"),S(this,"status","translatingHandle"),S(this,"commandId"),S(this,"topLeft"),S(this,"shiftKey",!1),S(this,"initialShape"),S(this,"handleId"),S(this,"start",()=>{}),S(this,"update",()=>{var o,a;let{initialShape:s,app:{currentPageId:u,currentPoint:d}}=this,h=this.app.getShape(s.id);if(h.isLocked)return;let p=h.handles,g=this.handleId,m=$.sub(d,p[g].point),v={[g]:q(_({},p[g]),{point:$.sub($.add(p[g].point,m),h.point)})},E=(a=(o=Q.getShapeUtil(h)).onHandleChange)==null?void 0:a.call(o,h,v);if(E)return{document:{pages:{[u]:{shapes:{[h.id]:E}}}}}}),S(this,"cancel",()=>{let{initialShape:o,app:{currentPageId:a}}=this;return{document:{pages:{[a]:{shapes:{[o.id]:o}}}}}}),S(this,"complete",()=>{let{initialShape:o,app:{currentPageId:a}}=this;return{id:this.commandId,before:{document:{pages:{[a]:{shapes:{[o.id]:o}}}}},after:{document:{pages:{[a]:{shapes:{[o.id]:Q.onSessionComplete(this.app.getShape(this.initialShape.id))}}}}}}});let{originPoint:i}=e;this.topLeft=[...i],this.handleId=n,this.initialShape=this.app.getShape(t),this.commandId=r}},fje=class extends lo{constructor(e){super(e),S(this,"type","rotate"),S(this,"status","transforming"),S(this,"performanceMode"),S(this,"delta",[0,0]),S(this,"commonBoundsCenter"),S(this,"initialAngle"),S(this,"initialShapes"),S(this,"changes",{}),S(this,"start",()=>{}),S(this,"update",()=>{let{commonBoundsCenter:o,initialShapes:a,app:{currentPageId:s,currentPoint:u,shiftKey:d}}=this,h={},p=$.angle(o,u)-this.initialAngle;return d&&(p=N.snapAngleToSegments(p,24)),a.forEach(({center:g,shape:m})=>{let{rotation:v=0}=m,E=0;d&&(E=N.snapAngleToSegments(v,24)-v);let w=Q.getRotatedShapeMutation(m,g,o,d?p+E:p);w&&(h[m.id]=w)}),this.changes=h,{document:{pages:{[s]:{shapes:h}}}}}),S(this,"cancel",()=>{let{initialShapes:o,app:{currentPageId:a}}=this,s={};return o.forEach(({shape:u})=>s[u.id]=u),{document:{pages:{[a]:{shapes:s}}}}}),S(this,"complete",()=>{let{initialShapes:o,app:{currentPageId:a}}=this,s={},u=this.changes;return o.forEach(({shape:{id:d,point:h,rotation:p,handles:g}})=>{s[d]={point:h,rotation:p,handles:g}}),{id:"rotate",before:{document:{pages:{[a]:{shapes:s}}}},after:{document:{pages:{[a]:{shapes:u}}}}}});let{app:{currentPageId:t,pageState:n,originPoint:r}}=this,i=Q.getSelectedBranchSnapshot(e.state,t).filter(o=>!o.isLocked);if(i.length===0)throw Error("No selected shapes!");if(e.rotationInfo.selectedIds===n.selectedIds){if(e.rotationInfo.center===void 0)throw Error("We should have a center for rotation!");this.commonBoundsCenter=e.rotationInfo.center}else this.commonBoundsCenter=N.getBoundsCenter(N.getCommonBounds(i.map(Q.getBounds))),e.rotationInfo.selectedIds=n.selectedIds,e.rotationInfo.center=this.commonBoundsCenter;this.initialShapes=i.filter(o=>o.children===void 0).map(o=>({shape:o,center:this.app.getShapeUtil(o).getCenter(o)})),this.initialAngle=$.angle(this.commonBoundsCenter,r)}},pje=class extends lo{constructor(e,t=Yi.BottomRight,n=!1){super(e),this.transformType=t,this.isCreate=n,S(this,"type","transform"),S(this,"performanceMode"),S(this,"status","transforming"),S(this,"scaleX",1),S(this,"scaleY",1),S(this,"initialShapes"),S(this,"initialShapeIds"),S(this,"initialSelectedIds"),S(this,"shapeBounds"),S(this,"hasUnlockedShapes"),S(this,"isAllAspectRatioLocked"),S(this,"initialCommonBounds"),S(this,"snapInfo",{state:"empty"}),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"start",()=>{this.snapInfo={state:"ready",bounds:this.app.shapes.filter(a=>!this.initialShapeIds.includes(a.id)).map(a=>N.getBoundsWithCenter(Q.getRotatedBounds(a)))}}),S(this,"update",()=>{let{transformType:a,shapeBounds:s,initialCommonBounds:u,isAllAspectRatioLocked:d,app:{currentPageId:h,pageState:{camera:p},viewport:g,currentPoint:m,previousPoint:v,originPoint:E,shiftKey:w,altKey:C,metaKey:b,currentGrid:A,settings:{isSnapping:T,showGrid:B}}}=this,D={},I=C?$.mul($.sub(m,E),2):$.sub(m,E),M=N.getTransformedBoundingBox(u,a,I,0,w||d);C&&(M=_(_({},M),N.centerBounds(M,N.getBoundsCenter(u)))),B&&(M=_(_({},M),N.snapBoundsToGrid(M,A)));let O=$.dist(m,v)-this.speed;this.speed=this.speed+O*(O>1?.5:.15);let z=[];if((T&&!b||!T&&b)&&this.speed*p.zoom<10&&this.snapInfo.state==="ready"){let K=N.getSnapPoints(N.getBoundsWithCenter(M),this.snapInfo.bounds.filter(X=>N.boundsContain(g,X)||N.boundsCollide(g,X)),5/p.zoom);K&&(z=K.snapLines,M=N.getTransformedBoundingBox(u,a,$.sub(I,K.offset),0,w||d))}return this.scaleX=M.scaleX,this.scaleY=M.scaleY,s.forEach(({initialShape:K,initialShapeBounds:X,transformOrigin:Z})=>{let pe=N.getRelativeTransformedBoundingBox(M,u,X,this.scaleX<0,this.scaleY<0);B&&(pe=N.snapBoundsToGrid(pe,A));let me=Q.transform(this.app.getShape(K.id),pe,{type:this.transformType,initialShape:K,scaleX:this.scaleX,scaleY:this.scaleY,transformOrigin:Z});D[K.id]=me}),{appState:{snapLines:z},document:{pages:{[h]:{shapes:D}}}}}),S(this,"cancel",()=>{let{shapeBounds:a,app:{currentPageId:s}}=this,u={};return this.isCreate?a.forEach(d=>u[d.initialShape.id]=void 0):a.forEach(d=>u[d.initialShape.id]=d.initialShape),{appState:{snapLines:[]},document:{pages:{[s]:{shapes:u}},pageStates:{[s]:{selectedIds:this.isCreate?[]:a.map(d=>d.initialShape.id)}}}}}),S(this,"complete",()=>{let{isCreate:a,shapeBounds:s,hasUnlockedShapes:u,app:{currentPageId:d}}=this;if(!u)return;if(this.isCreate&&$.dist(this.app.originPoint,this.app.currentPoint)<2)return this.cancel();let h={},p={},g,m;return a?(g=[],m=[],s.forEach(({initialShape:v})=>{h[v.id]=void 0,p[v.id]=this.app.getShape(v.id)})):(g=this.initialSelectedIds,m=this.initialSelectedIds,s.forEach(({initialShape:v})=>{h[v.id]=v,p[v.id]=this.app.getShape(v.id)})),{id:"transform",before:{appState:{snapLines:[]},document:{pages:{[d]:{shapes:h}},pageStates:{[d]:{selectedIds:g,hoveredId:void 0,editingId:void 0}}}},after:{appState:{snapLines:[]},document:{pages:{[d]:{shapes:p}},pageStates:{[d]:{selectedIds:m,hoveredId:void 0,editingId:void 0}}}}}}),this.initialSelectedIds=[...this.app.selectedIds],this.app.rotationInfo.selectedIds=[...this.initialSelectedIds],this.initialShapes=Q.getSelectedBranchSnapshot(this.app.state,this.app.currentPageId).filter(a=>!a.isLocked),this.initialShapeIds=this.initialShapes.map(a=>a.id),this.hasUnlockedShapes=this.initialShapes.length>0,this.isAllAspectRatioLocked=this.initialShapes.every(a=>a.isAspectRatioLocked||Q.getShapeUtil(a).isAspectRatioLocked);let r=Object.fromEntries(this.initialShapes.map(a=>[a.id,Q.getBounds(a)])),i=Object.values(r);this.initialCommonBounds=N.getCommonBounds(i);let o=N.getBoundsFromPoints(i.map(N.getBoundsCenter));this.shapeBounds=this.initialShapes.map(a=>{let s=r[a.id],u=N.getBoundsCenter(s),d=(u[0]-o.minX)/o.width,h=(u[1]-o.minY)/o.height;return{initialShape:a,initialShapeBounds:s,transformOrigin:[d,h]}})}},gje=class extends lo{constructor(e,t,n,r=!1){super(e),S(this,"type","transformSingle"),S(this,"status","transforming"),S(this,"performanceMode"),S(this,"transformType"),S(this,"scaleX",1),S(this,"scaleY",1),S(this,"isCreate"),S(this,"initialShape"),S(this,"initialShapeBounds"),S(this,"initialCommonBounds"),S(this,"snapInfo",{state:"empty"}),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"start",()=>{this.snapInfo={state:"ready",bounds:this.app.shapes.filter(o=>o.id!==this.initialShape.id).map(o=>N.getBoundsWithCenter(Q.getRotatedBounds(o)))}}),S(this,"update",()=>{let{transformType:o,initialShape:a,initialShapeBounds:s,app:{settings:{isSnapping:u,showGrid:d},currentPageId:h,pageState:{camera:p},viewport:g,currentPoint:m,previousPoint:v,originPoint:E,currentGrid:w,shiftKey:C,altKey:b,metaKey:A}}=this;if(a.isLocked)return;let T={},B=b?$.mul($.sub(m,E),2):$.sub(m,E),D=this.app.getShape(a.id),I=Q.getShapeUtil(D),M=N.getTransformedBoundingBox(s,o,B,D.rotation,C||D.isAspectRatioLocked||I.isAspectRatioLocked);b&&(M=_(_({},M),N.centerBounds(M,N.getBoundsCenter(s)))),d&&(M=_(_({},M),N.snapBoundsToGrid(M,w)));let O=$.dist(m,v)-this.speed;this.speed=this.speed+O*(O>1?.5:.15);let z=[];if((u&&!A||!u&&A)&&!a.rotation&&this.speed*p.zoom<10&&this.snapInfo.state==="ready"){let X=N.getSnapPoints(N.getBoundsWithCenter(M),this.snapInfo.bounds.filter(Z=>N.boundsContain(g,Z)||N.boundsCollide(g,Z)),5/p.zoom);X&&(z=X.snapLines,M=N.getTransformedBoundingBox(s,o,$.sub(B,X.offset),D.rotation,C||D.isAspectRatioLocked||I.isAspectRatioLocked))}let K=Q.getShapeUtil(D).transformSingle(D,M,{initialShape:a,type:this.transformType,scaleX:M.scaleX,scaleY:M.scaleY,transformOrigin:[.5,.5]});return K&&(T[D.id]=K),d&&K&&K.point&&(K.point=$.snap(K.point,w)),{appState:{snapLines:z},document:{pages:{[h]:{shapes:T}}}}}),S(this,"cancel",()=>{let{initialShape:o,app:{currentPageId:a}}=this,s={};return this.isCreate?s[o.id]=void 0:s[o.id]=o,{appState:{snapLines:[]},document:{pages:{[a]:{shapes:s}},pageStates:{[a]:{selectedIds:this.isCreate?[]:[o.id]}}}}}),S(this,"complete",()=>{let{initialShape:o,app:{currentPageId:a}}=this;if(o.isLocked)return;if(this.isCreate&&$.dist(this.app.originPoint,this.app.currentPoint)<2)return this.cancel();let s={},u={};return s[o.id]=this.isCreate?void 0:o,u[o.id]=Q.onSessionComplete(this.app.getShape(o.id)),{id:"transform_single",before:{appState:{snapLines:[]},document:{pages:{[a]:{shapes:s}},pageStates:{[a]:{selectedIds:this.isCreate?[]:[o.id],editingId:void 0,hoveredId:void 0}}}},after:{appState:{snapLines:[]},document:{pages:{[a]:{shapes:u}},pageStates:{[a]:{selectedIds:[o.id],editingId:void 0,hoveredId:void 0}}}}}}),this.isCreate=r,this.transformType=n;let i=this.app.getShape(t);this.initialShape=i,this.initialShapeBounds=Q.getBounds(i),this.initialCommonBounds=Q.getRotatedBounds(i),this.app.rotationInfo.selectedIds=[i.id]}},mje=class extends lo{constructor(e,t=!1,n=!1){super(e),S(this,"performanceMode"),S(this,"type","translate"),S(this,"status","translating"),S(this,"delta",[0,0]),S(this,"prev",[0,0]),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"cloneInfo",{state:"empty"}),S(this,"snapInfo",{state:"empty"}),S(this,"snapLines",[]),S(this,"isCloning",!1),S(this,"isCreate"),S(this,"link"),S(this,"initialIds"),S(this,"hasUnlockedShapes"),S(this,"initialSelectedIds"),S(this,"initialCommonBounds"),S(this,"initialShapes"),S(this,"initialParentChildren"),S(this,"bindingsToDelete"),S(this,"start",()=>{let{bindingsToDelete:u,initialIds:d,app:{currentPageId:h,page:p}}=this,g=[],m=[];if(Object.values(p.shapes).forEach(w=>{let C=N.getBoundsWithCenter(Q.getRotatedBounds(w));g.push(C),d.has(w.id)||m.push(C)}),this.snapInfo={state:"ready",bounds:g,others:m},u.length===0)return;let v={},E={};return u.forEach(w=>{v[w.id]=void 0;let C=this.app.getShape(w.fromId);E[w.fromId]={handles:q(_({},C.handles),{[w.handleId]:q(_({},C.handles[w.handleId]),{bindingId:void 0})})}}),{document:{pages:{[h]:{bindings:v,shapes:E}}}}}),S(this,"update",()=>{let{initialParentChildren:u,initialShapes:d,initialCommonBounds:h,bindingsToDelete:p,app:{pageState:{camera:g},settings:{isSnapping:m,showGrid:v},currentPageId:E,viewport:w,selectedIds:C,currentPoint:b,previousPoint:A,originPoint:T,altKey:B,shiftKey:D,metaKey:I,currentGrid:M}}=this,O={},z={},K={},X=$.sub(b,T),Z=!1;this.isCreate||(B&&!this.isCloning?(this.isCloning=!0,Z=!0):!B&&this.isCloning&&(this.isCloning=!1,Z=!0)),D&&(Math.abs(X[0])1?.5:.15),this.snapLines=[],(m&&!I||!m&&I)&&this.speed*g.zoom<10&&this.snapInfo.state==="ready"){let me=N.getSnapPoints(N.getBoundsWithCenter(v?N.snapBoundsToGrid(N.translateBounds(h,X),M):N.translateBounds(h,X)),(this.isCloning?this.snapInfo.bounds:this.snapInfo.others).filter(Ce=>N.boundsContain(w,Ce)||N.boundsCollide(w,Ce)),5/g.zoom);me&&(this.snapLines=me.snapLines,X=$.sub(X,me.offset))}if(this.prev=X,this.isCloning)if(Z){if(this.cloneInfo.state==="empty"&&this.createCloneInfo(),this.cloneInfo.state==="empty")throw Error;let{clones:me,clonedBindings:Ce}=this.cloneInfo;this.isCloning=!0,p.forEach(W=>O[W.id]=W),d.forEach(W=>z[W.id]={point:W.point}),me.forEach(W=>{var U;if(z[W.id]=_({},W),W.parentId!==E&&!C.includes(W.parentId)){let ne=((U=z[W.parentId])==null?void 0:U.children)||u[W.parentId];ne.includes(W.id)||(z[W.parentId]=q(_({},z[W.parentId]),{children:[...ne,W.id]}))}});for(let W of Ce)O[W.id]=W;K.selectedIds=me.map(W=>W.id),me.forEach(W=>{z[W.id]=q(_({},W),{point:v?$.snap($.toFixed($.add(W.point,X)),M):$.toFixed($.add(W.point,X))})})}else{if(this.cloneInfo.state==="empty")throw Error;let{clones:me}=this.cloneInfo;me.forEach(Ce=>{z[Ce.id]={point:v?$.snap($.toFixed($.add(Ce.point,X)),M):$.toFixed($.add(Ce.point,X))}})}else if(Z){if(this.cloneInfo.state==="empty")throw Error;let{clones:me,clonedBindings:Ce}=this.cloneInfo;this.isCloning=!1,p.forEach(W=>O[W.id]=void 0),me.forEach(W=>{W.parentId!==E&&(z[W.parentId]=q(_({},z[W.parentId]),{children:u[W.parentId]}))}),me.forEach(W=>z[W.id]=void 0),d.forEach(W=>{z[W.id]={point:v?$.snap($.toFixed($.add(W.point,X)),M):$.toFixed($.add(W.point,X))}});for(let W of Ce)O[W.id]=void 0;K.selectedIds=d.map(W=>W.id)}else d.forEach(me=>{z[me.id]={point:v?$.snap($.toFixed($.add(me.point,X)),M):$.toFixed($.add(me.point,X))}});return{appState:{snapLines:this.snapLines},document:{pages:{[E]:{shapes:z,bindings:O}},pageStates:{[E]:K}}}}),S(this,"cancel",()=>{let{initialShapes:u,initialSelectedIds:d,bindingsToDelete:h,app:{currentPageId:p}}=this,g={},m={},v={editingId:void 0,hoveredId:void 0};if(this.isCreate?(u.forEach(({id:E})=>m[E]=void 0),v.selectedIds=[]):(u.forEach(({id:E,point:w,handles:C})=>m[E]=C?q(_({},m[E]),{point:w,handles:C}):q(_({},m[E]),{point:w})),v.selectedIds=d,h.forEach(E=>{g[E.id]=E})),this.cloneInfo.state==="ready"){let{clones:E,clonedBindings:w}=this.cloneInfo;E.forEach(C=>m[C.id]=void 0),w.forEach(C=>g[C.id]=void 0)}return{appState:{snapLines:[]},document:{pages:{[p]:{shapes:m,bindings:g}},pageStates:{[p]:v}}}}),S(this,"complete",()=>{let{initialShapes:u,initialParentChildren:d,bindingsToDelete:h,app:{currentPageId:p}}=this,g={},m={},v={},E={};if(this.isCloning){if(this.cloneInfo.state==="empty"&&this.createCloneInfo(),this.cloneInfo.state!=="ready")throw Error;let{clones:w,clonedBindings:C}=this.cloneInfo;w.forEach(b=>{m[b.id]=void 0,E[b.id]=this.app.getShape(b.id),b.parentId!==p&&(m[b.parentId]=q(_({},m[b.parentId]),{children:d[b.parentId]}),E[b.parentId]=q(_({},E[b.parentId]),{children:this.app.getShape(b.parentId).children}))}),C.forEach(b=>{g[b.id]=void 0,v[b.id]=this.app.getBinding(b.id)})}else u.forEach(w=>{m[w.id]=this.isCreate?void 0:q(_({},m[w.id]),{point:w.point}),E[w.id]=_(_({},E[w.id]),this.isCreate?this.app.getShape(w.id):{point:this.app.getShape(w.id).point})});return h.forEach(w=>{var C,b,A,T,B;g[w.id]=w,m[w.fromId]=q(_({},m[w.fromId]),{id:w.fromId,handles:q(_({},(C=m[w.fromId])==null?void 0:C.handles),{[w.handleId]:q(_({},(A=(b=m[w.fromId])==null?void 0:b.handles)==null?void 0:A[w.handleId]),{bindingId:w.id})})}),E[w.fromId]=q(_({},E[w.fromId]),{id:w.fromId,handles:q(_({},E[w.fromId].handles),{[w.handleId]:q(_({},(B=(T=E[w.fromId])==null?void 0:T.handles)==null?void 0:B[w.handleId]),{bindingId:void 0})})})}),h.forEach(w=>v[w.id]=void 0),{id:"translate",before:{appState:{snapLines:[]},document:{pages:{[p]:{shapes:m,bindings:g}},pageStates:{[p]:{selectedIds:this.isCreate?[]:[...this.initialSelectedIds]}}}},after:{appState:{snapLines:[]},document:{pages:{[p]:{shapes:E,bindings:v}},pageStates:{[p]:{selectedIds:[...this.app.selectedIds]}}}}}}),S(this,"createCloneInfo",()=>{let{initialShapes:u,initialParentChildren:d,app:{selectedIds:h,currentPageId:p,page:g}}=this,m={},v={},E=[],w=[];u.forEach(b=>{let A=N.uniqueId();d[A]=d[b.id],m[b.id]=A;let T=q(_({},N.deepClone(b)),{id:A,parentId:b.parentId,childIndex:Q.getChildIndexAbove(this.app.state,b.id,p)});if(T.type==="video"){let B=document.getElementById(b.id+"_video");B&&(T.currentTime=(B.currentTime+16)%B.duration)}w.push(T)}),w.forEach(b=>{b.children!==void 0&&(b.children=b.children.map(A=>m[A]))}),w.forEach(b=>{h.includes(b.parentId)&&(b.parentId=m[b.parentId])});let C=new Set(Object.keys(m));Object.values(g.bindings).filter(b=>C.has(b.fromId)||C.has(b.toId)).forEach(b=>{if(C.has(b.fromId)&&C.has(b.toId)){let A=N.uniqueId(),T=q(_({},N.deepClone(b)),{id:A,fromId:m[b.fromId]||b.fromId,toId:m[b.toId]||b.toId});v[b.id]=A,E.push(T)}}),w.forEach(b=>{if(b.handles&&b.handles)for(let A in b.handles){let T=b.handles[A];T.bindingId=T.bindingId?v[T.bindingId]:void 0}}),w.forEach(b=>{if(g.shapes[b.id])throw Error("uh oh, we didn't clone correctly")}),this.cloneInfo={state:"ready",clones:w,cloneMap:m,clonedBindings:E}}),this.isCreate=t,this.link=n;let{currentPageId:r,selectedIds:i,page:o}=this.app;this.initialSelectedIds=[...i];let a=(n?Q.getLinkedShapeIds(this.app.state,r,n,!1):i).map(u=>this.app.getShape(u)).filter(u=>!u.isLocked),s=new Set(a.map(u=>u.id));this.hasUnlockedShapes=a.length>0,this.initialShapes=Array.from(new Set(a.filter(u=>!s.has(u.parentId)).flatMap(u=>u.children?[u,...u.children.map(d=>this.app.getShape(d))]:[u])).values()),this.initialIds=new Set(this.initialShapes.map(u=>u.id)),this.bindingsToDelete=[],Object.values(o.bindings).filter(u=>this.initialIds.has(u.fromId)||this.initialIds.has(u.toId)).forEach(u=>{this.initialIds.has(u.fromId)&&(this.initialIds.has(u.toId)||this.bindingsToDelete.push(u))}),this.initialParentChildren={},this.initialShapes.map(u=>u.parentId).filter(u=>u!==o.id).forEach(u=>{this.initialParentChildren[u]=this.app.getShape(u).children}),this.initialCommonBounds=N.getCommonBounds(this.initialShapes.map(Q.getRotatedBounds)),this.app.rotationInfo.selectedIds=[...this.app.selectedIds]}},vje={arrow:aje,brush:sje,draw:uje,erase:cje,handle:hje,rotate:fje,transform:pje,transformSingle:gje,translate:mje,grid:dje,edit:lje},yje=e=>vje[e],Go=class extends vne{constructor(e){super(),this.app=e,S(this,"type","select"),S(this,"previous"),S(this,"status","idle"),S(this,"setStatus",t=>{this.status=t,this.app.setStatus(this.status)}),S(this,"onEnter",()=>{this.setStatus("idle")}),S(this,"onExit",()=>{this.setStatus("idle")}),S(this,"onCancel",()=>{this.status==="idle"?this.app.selectTool("select"):this.setStatus("idle"),this.app.cancelSession()}),S(this,"getNextChildIndex",()=>{let{shapes:t,appState:{currentPageId:n}}=this.app;return t.length===0?1:t.filter(r=>r.parentId===n).sort((r,i)=>i.childIndex-r.childIndex)[0].childIndex+1}),S(this,"onPinchStart",()=>{this.app.cancelSession(),this.setStatus("pinching")}),S(this,"onPinchEnd",()=>{N.isMobileSafari()&&this.app.undoSelect(),this.setStatus("idle")}),S(this,"onPinch",(t,n)=>{var r;this.status==="pinching"&&(isNaN(t.delta[0])||isNaN(t.delta[1])||(this.app.pinchZoom(t.point,t.delta,t.delta[2]),(r=this.onPointerMove)==null||r.call(this,t,n)))}),S(this,"onKeyDown",t=>{if(t==="Escape"){this.onCancel();return}if(t==="Meta"||t==="Control"||t==="Alt"){this.app.updateSession();return}}),S(this,"onKeyUp",t=>{if(t==="Meta"||t==="Control"||t==="Alt"){this.app.updateSession();return}}),S(this,"onPointerMove",()=>{this.status==="creating"&&this.app.updateSession()}),S(this,"onPointerUp",()=>{if(this.status==="creating"){this.app.completeSession();let{isToolLocked:t}=this.app.appState;t||this.app.selectTool("select")}this.setStatus("idle")})}},Eje=class extends Go{constructor(){super(...arguments),S(this,"type","arrow"),S(this,"onPointerDown",()=>{if(this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=BC.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("arrow",s.id,"end",!0),this.setStatus("creating")})}},Cje=class extends Go{constructor(){super(...arguments),S(this,"type","draw"),S(this,"lastShapeId"),S(this,"onEnter",()=>{this.lastShapeId=void 0}),S(this,"onCancel",()=>{switch(this.status){case"idle":{this.app.selectTool("select");break}default:{this.setStatus("idle");break}}this.app.cancelSession()}),S(this,"onPointerDown",e=>{if(this.status!=="idle"||this.app.readOnly)return;let{currentPoint:t,appState:{currentPageId:n,currentStyle:r}}=this.app,i=this.lastShapeId&&this.app.getShape(this.lastShapeId);if(e.shiftKey&&i)this.app.startSession("draw",i.id),this.setStatus("extending");else{let o=this.getNextChildIndex(),a=N.uniqueId(),s=WT.create({id:a,parentId:n,childIndex:o,point:t,style:_({},r)});this.lastShapeId=a,this.app.patchCreate([s]),this.app.startSession("draw",a),this.setStatus("creating")}}),S(this,"onPointerMove",()=>{if(!this.app.readOnly)switch(this.status){case"extending":case"creating":this.app.updateSession()}}),S(this,"onPointerUp",()=>{this.app.completeSession(),this.setStatus("idle")})}},bje=class extends Go{constructor(){super(...arguments),S(this,"type","ellipse"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=JT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},wje=class extends Go{constructor(){super(...arguments),S(this,"type","erase"),S(this,"status","idle"),S(this,"onPointerDown",()=>{this.app.readOnly||this.status==="idle"&&this.setStatus("pointing")}),S(this,"onPointerMove",e=>{if(!this.app.readOnly)switch(this.status){case"pointing":{se.dist(e.origin,e.point)>3&&(this.app.startSession("erase"),this.app.updateSession(),this.setStatus("erasing"));break}case"erasing":this.app.updateSession()}}),S(this,"onPointerUp",()=>{if(!this.app.readOnly){switch(this.status){case"pointing":{let e=this.app.shapes.filter(t=>!t.isLocked).filter(t=>this.app.getShapeUtil(t).hitTestPoint(t,this.app.currentPoint)).flatMap(t=>t.children?[t.id,...t.children]:t.id);this.app.delete(e);break}case"erasing":this.app.completeSession()}this.setStatus("idle")}}),S(this,"onCancel",()=>{this.status==="idle"?this.previous?this.app.selectTool(this.previous):this.app.selectTool("select"):this.setStatus("idle"),this.app.cancelSession()})}},Sje=class extends Go{constructor(){super(...arguments),S(this,"type","line"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=BC.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,decorations:{start:void 0,end:void 0},style:_({},i)});this.app.patchCreate([s]),this.app.startSession("arrow",s.id,"end",!0),this.setStatus("creating")})}},xje=class extends Go{constructor(){super(...arguments),S(this,"type","rectangle"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=VT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},Aje=class extends Go{constructor(){super(...arguments),S(this,"type","select"),S(this,"pointedId"),S(this,"selectedGroupId"),S(this,"pointedHandleId"),S(this,"pointedBoundsHandle"),S(this,"pointedLinkHandleId"),S(this,"onEnter",()=>{this.setStatus("idle")}),S(this,"onExit",()=>{this.setStatus("idle")}),S(this,"clonePaint",e=>{if(this.app.selectedIds.length===0)return;let t=this.app.selectedIds.map(s=>this.app.getShape(s)),n=N.expandBounds(N.getCommonBounds(t.map(Q.getBounds)),16),r=N.getBoundsCenter(n),i=[n.width,n.height],o=[r[0]+i[0]*Math.floor((e[0]+i[0]/2-r[0])/i[0]),r[1]+i[1]*Math.floor((e[1]+i[1]/2-r[1])/i[1])],a=N.centerBounds(n,o);this.app.shapes.some(s=>Q.getShapeUtil(s).hitTestBounds(s,a))||this.app.duplicate(this.app.selectedIds,o)}),S(this,"getShapeClone",(e,t)=>{let n=this.app.getShape(e),r=Q.getShapeUtil(n);if(r.canClone){let i=r.getBounds(n),o=r.getCenter(n),a={top:[i.minX,i.minY-(i.height+32)],right:[i.maxX+32,i.minY],bottom:[i.minX,i.maxY+32],left:[i.minX-(i.width+32),i.minY],topLeft:[i.minX-(i.width+32),i.minY-(i.height+32)],topRight:[i.maxX+32,i.minY-(i.height+32)],bottomLeft:[i.minX-(i.width+32),i.maxY+32],bottomRight:[i.maxX+32,i.maxY+32]}[t];if(n.rotation!==0){let d=se.add(a,[i.width/2,i.height/2]),h=se.rotWith(d,o,n.rotation||0);a=se.sub(h,[i.width/2,i.height/2])}let s=N.uniqueId(),u=q(_({},n),{id:s,point:a});return u.type==="sticky"&&(u.text=""),u}}),S(this,"onCancel",()=>{this.app.session?this.app.cancelSession():this.selectNone(),this.setStatus("idle")}),S(this,"onKeyDown",(e,t,n)=>{switch(e){case"Escape":{this.onCancel();break}case"Tab":{if(this.app.readOnly)return;if(!this.app.pageState.editingId&&this.status==="idle"&&this.app.selectedIds.length===1){let[r]=this.app.selectedIds,i=this.getShapeClone(r,"right");i&&(this.app.createShapes(i),this.setStatus("idle"),i.type==="sticky"&&(this.app.select(i.id),this.app.setEditingId(i.id)))}break}case"Meta":case"Control":case"Alt":{this.app.updateSession();break}case"Enter":{if(this.app.readOnly)return;let{pageState:r}=this.app;r.selectedIds.length===1&&!r.editingId&&(this.app.setEditingId(r.selectedIds[0]),n.preventDefault())}}}),S(this,"onKeyUp",(e,t)=>{if(this.status==="clonePainting"&&!(t.altKey&&t.shiftKey)){this.setStatus("idle");return}if(e==="Meta"||e==="Control"||e==="Alt"){this.app.updateSession();return}}),S(this,"onPointerMove",()=>{let{originPoint:e,currentPoint:t}=this.app;if(this.app.readOnly&&this.app.isPointing){this.app.session?this.app.updateSession():se.dist(e,t)>3&&(this.app.startSession("brush"),this.setStatus("brushing"));return}switch(this.status){case"pointingBoundsHandle":{if(!this.pointedBoundsHandle)throw Error("No pointed bounds handle");if(se.dist(e,t)>3){if(this.pointedBoundsHandle==="rotate")this.setStatus("rotating"),this.app.startSession("rotate");else if(this.pointedBoundsHandle==="center"||this.pointedBoundsHandle==="left"||this.pointedBoundsHandle==="right")this.setStatus("translating"),this.app.startSession("translate",!1,this.pointedBoundsHandle);else{this.setStatus("transforming");let n=this.app.selectedIds.flatMap(r=>Q.getDocumentBranch(this.app.state,r,this.app.currentPageId));n.length===1?this.app.startSession("transformSingle",n[0],this.pointedBoundsHandle):this.app.startSession("transform",this.pointedBoundsHandle)}this.app.updateSession()}break}case"pointingCanvas":{se.dist(e,t)>3&&(this.app.startSession("brush"),this.setStatus("brushing"));break}case"pointingClone":{se.dist(e,t)>3&&(this.setStatus("translatingClone"),this.app.startSession("translate"),this.app.updateSession());break}case"pointingBounds":{se.dist(e,t)>3&&(this.setStatus("translating"),this.app.startSession("translate"),this.app.updateSession());break}case"pointingHandle":{if(!this.pointedHandleId)throw Error("No pointed handle");if(se.dist(e,t)>3){this.setStatus("translatingHandle");let n=this.app.getShape(this.app.selectedIds[0]);n&&(this.pointedHandleId==="bend"?(this.app.startSession("handle",n.id,this.pointedHandleId),this.app.updateSession()):(this.app.startSession("arrow",n.id,this.pointedHandleId,!1),this.app.updateSession()))}break}case"clonePainting":{this.clonePaint(t);break}default:if(this.app.session){this.app.updateSession();break}}}),S(this,"onPointerDown",(e,t)=>{if(e.target==="canvas"&&this.status==="idle"){let{currentPoint:n}=this.app;if(e.spaceKey&&t.buttons===1)return;if(this.status==="idle"&&e.altKey&&e.shiftKey){this.setStatus("clonePainting"),this.clonePaint(n);return}if(!e.shiftKey){if(this.app.onShapeBlur(),e.altKey&&this.app.selectedIds.length>0){this.app.duplicate(this.app.selectedIds,n);return}this.selectNone()}this.setStatus("pointingCanvas")}}),S(this,"onPointerUp",e=>{var t;if(this.status==="translatingClone"||this.status==="pointingClone"){this.pointedId&&(this.app.completeSession(),this.app.setEditingId(this.pointedId)),this.setStatus("idle"),this.pointedId=void 0;return}if(this.status==="pointingBounds"){if(e.target==="bounds")this.selectNone();else if(this.app.isSelected(e.target))e.shiftKey?this.pointedId!==e.target&&this.deselect(e.target):this.pointedId!==e.target&&this.app.selectedIds.length>1&&this.select(e.target);else if(this.pointedId===e.target){if(this.app.getShape(e.target).isLocked)return;e.shiftKey?this.pushSelect(e.target):this.select(e.target)}}this.setStatus("idle"),this.pointedBoundsHandle=void 0,this.pointedHandleId=void 0,this.pointedId=void 0,((t=this.app.session)==null?void 0:t.type)!=="edit"&&this.app.completeSession()}),S(this,"onDoubleClickCanvas",()=>{this.app.readOnly}),S(this,"onPointShape",(e,t)=>{if(e.spaceKey&&t.buttons===1||this.app.getShape(e.target).isLocked)return;let{editingId:n,hoveredId:r}=this.app.pageState;if(n&&e.target!==n&&this.app.onShapeBlur(),(this.status==="idle"||this.status==="pointingBounds")&&e.metaKey&&e.shiftKey&&r){this.pointedId=r,this.app.isSelected(r)?this.deselect(r):(this.pushSelect(r),this.setStatus("pointingBounds"));return}if(this.status==="pointingBounds"){let{parentId:i}=this.app.getShape(e.target);this.pointedId=i===this.app.currentPageId?e.target:i;return}if(this.status==="idle"){if(this.setStatus("pointingBounds"),e.metaKey){e.shiftKey||this.selectNone(),this.app.startSession("brush"),this.setStatus("brushing");return}let i,{parentId:o}=this.app.getShape(e.target);o===this.app.currentPageId?(i=e.target,this.selectedGroupId=void 0):o===this.selectedGroupId?i=e.target:(i=o,this.selectedGroupId=void 0),this.app.isSelected(i)||(this.pointedId=i,e.shiftKey?this.pushSelect(i):this.select(i))}}),S(this,"onDoubleClickShape",e=>{if(this.app.readOnly)return;let t=this.app.getShape(e.target);if(t.isLocked){this.app.select(e.target);return}Q.getShapeUtil(t.type).canEdit&&(t.parentId===this.app.currentPageId||t.parentId===this.selectedGroupId)&&this.app.setEditingId(e.target),t.parentId!==this.app.currentPageId&&(this.selectedGroupId=t.parentId),this.app.select(e.target)}),S(this,"onRightPointShape",e=>{this.app.isSelected(e.target)||this.app.select(e.target)}),S(this,"onHoverShape",e=>{this.app.setHoveredId(e.target)}),S(this,"onUnhoverShape",e=>{let{currentPageId:t}=this.app;requestAnimationFrame(()=>{t===this.app.currentPageId&&this.app.pageState.hoveredId===e.target&&this.app.setHoveredId(void 0)})}),S(this,"onPointBounds",e=>{if(e.metaKey){e.shiftKey||this.selectNone(),this.app.startSession("brush"),this.setStatus("brushing");return}this.setStatus("pointingBounds")}),S(this,"onRightPointBounds",(e,t)=>{t.stopPropagation()}),S(this,"onReleaseBounds",()=>{(this.status==="translating"||this.status==="brushing")&&this.app.completeSession(),this.setStatus("idle")}),S(this,"onPointBoundsHandle",e=>{this.pointedBoundsHandle=e.target,this.setStatus("pointingBoundsHandle")}),S(this,"onDoubleClickBoundsHandle",e=>{switch(e.target){case"center":case"left":case"right":{this.app.select(...Q.getLinkedShapeIds(this.app.state,this.app.currentPageId,e.target,e.shiftKey));break}default:if(this.app.selectedIds.length===1){this.app.resetBounds(this.app.selectedIds);let t=this.app.getShape(this.app.selectedIds[0]);"label"in t&&this.app.setEditingId(t.id)}}}),S(this,"onReleaseBoundsHandle",()=>{this.setStatus("idle")}),S(this,"onPointHandle",e=>{this.pointedHandleId=e.target,this.setStatus("pointingHandle")}),S(this,"onDoubleClickHandle",e=>{if(e.target==="bend"){let{selectedIds:t}=this.app;if(t.length!==1)return;let n=this.app.getShape(t[0]);Q.getShapeUtil(n.type).canEdit&&(n.parentId===this.app.currentPageId||n.parentId===this.selectedGroupId)&&this.app.setEditingId(n.id);return}this.app.toggleDecoration(e.target)}),S(this,"onReleaseHandle",()=>{this.setStatus("idle")}),S(this,"onShapeClone",e=>{let t=this.app.selectedIds[0],n=this.getShapeClone(t,e.target);e.target==="left"||e.target==="right"||e.target==="top"||e.target==="bottom"?n&&(this.app.createShapes(n),this.pointedId=n.id,this.setStatus("pointingClone")):(this.setStatus("gridCloning"),this.app.startSession("grid",t))})}deselect(e){this.app.select(...this.app.selectedIds.filter(t=>t!==e))}select(e){this.app.select(e)}pushSelect(e){let t=this.app.getShape(e);this.app.select(...this.app.selectedIds.filter(n=>n!==t.parentId),e)}selectNone(){this.app.selectNone()}},kje=class extends Go{constructor(){super(...arguments),S(this,"type","sticky"),S(this,"shapeId"),S(this,"onPointerDown",()=>{if(!this.app.readOnly){if(this.status==="creating"){this.setStatus("idle"),this.app.appState.isToolLocked||this.app.selectTool("select");return}if(this.status==="idle"){let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId();this.shapeId=a;let s=Vy.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)}),u=Vy.getBounds(s);s.point=se.sub(s.point,[u.width/2,u.height/2]),this.app.patchCreate([s]),this.app.startSession("translate"),this.setStatus("creating")}}}),S(this,"onPointerUp",()=>{this.app.readOnly||this.status==="creating"&&(this.setStatus("idle"),this.app.completeSession(),this.app.selectTool("select"),this.app.setEditingId(this.shapeId))})}},Ije=class extends Go{constructor(){super(...arguments),S(this,"type","text"),S(this,"stopEditingShape",()=>{this.setStatus("idle"),this.app.appState.isToolLocked||this.app.selectTool("select")}),S(this,"onKeyUp",()=>{}),S(this,"onKeyDown",()=>{}),S(this,"onPointerDown",()=>{if(this.status==="creating"){this.stopEditingShape();return}if(this.status==="idle"){let{currentPoint:e,currentGrid:t,settings:{showGrid:n}}=this.app;this.app.createTextShapeAtPoint(n?se.snap(e,t):e,void 0,!0),this.setStatus("creating");return}}),S(this,"onPointerUp",()=>{}),S(this,"onPointShape",e=>{if(this.app.readOnly)return;let t=this.app.getShape(e.target);t.type==="text"&&(this.setStatus("idle"),this.app.setEditingId(t.id))}),S(this,"onShapeBlur",()=>{this.app.readOnly||this.stopEditingShape()})}},Dje=class extends Go{constructor(){super(...arguments),S(this,"type","triangle"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=GT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},Xv=N.uniqueId(),yn=class extends RHe{constructor(e,t={}){super(yn.defaultState,e,yn.version,(n,r,i)=>ia(q(_({},r),{document:q(_(_({},r.document),n.document),{version:i})}),yn.version)),S(this,"callbacks",{}),S(this,"tools",{select:new Aje(this),erase:new wje(this),text:new Ije(this),draw:new Cje(this),ellipse:new bje(this),rectangle:new xje(this),triangle:new Dje(this),line:new Sje(this),arrow:new Eje(this),sticky:new kje(this)}),S(this,"currentTool",this.tools.select),S(this,"session"),S(this,"readOnly",!1),S(this,"isDirty",!1),S(this,"isCreating",!1),S(this,"originPoint",[0,0]),S(this,"currentPoint",[0,0]),S(this,"previousPoint",[0,0]),S(this,"shiftKey",!1),S(this,"altKey",!1),S(this,"metaKey",!1),S(this,"ctrlKey",!1),S(this,"spaceKey",!1),S(this,"isPointing",!1),S(this,"isForcePanning",!1),S(this,"isErasingWithPen",!1),S(this,"isPastePrevented",!1),S(this,"editingStartTime",-1),S(this,"fileSystemHandle",null),S(this,"viewport",N.getBoundsFromPoints([[0,0],[100,100]])),S(this,"rendererBounds",N.getBoundsFromPoints([[0,0],[100,100]])),S(this,"selectHistory",{stack:[[]],pointer:0}),S(this,"clipboard"),S(this,"rotationInfo",{selectedIds:[],center:[0,0]}),S(this,"migrate",n=>ia(n,yn.version)),S(this,"onReady",()=>{var n,r;this.loadDocument(this.document),XT().then(i=>{this.fileSystemHandle=i});try{this.patchState(q(_({},ia(this.state,yn.version)),{appState:{status:"idle"}}))}catch(i){console.error("The data appears to be corrupted. Resetting!",i),localStorage.setItem(this.document.id+"_corrupted",JSON.stringify(this.document)),this.patchState(q(_({},yn.defaultState),{appState:q(_({},yn.defaultState.appState),{status:"idle"})}))}(r=(n=this.callbacks).onMount)==null||r.call(n,this)}),S(this,"cleanup",(n,r)=>{var i;let o=_({},n);o.document!==r.document&&Object.entries(o.document.pages).forEach(([u,d])=>{if(d===void 0){delete o.document.pages[u],delete o.document.pageStates[u];return}let h=r.document.pages[u],p={};if(!h||d.shapes!==h.shapes||d.bindings!==h.bindings){d.shapes=_({},d.shapes),d.bindings=_({},d.bindings);let m=new Set;Object.entries(d.shapes).forEach(([w,C])=>{var b;let A;C?A=C.parentId:(A=(b=h==null?void 0:h.shapes[w])==null?void 0:b.parentId,delete d.shapes[w]),d.id===o.appState.currentPageId&&(h==null?void 0:h.shapes[w])!==C&&(p[w]=C),A&&A!==u&&d.shapes[A]!==void 0&&m.add(d.shapes[A])}),Object.keys(d.bindings).forEach(w=>{d.bindings[w]||delete d.bindings[w]}),o.document.pages[u]=d;let v=Q.getRelatedBindings(o,Object.keys(p),u),E=new Set;v.forEach(w=>{if(!d.bindings[w.id])return;let C=d.shapes[w.toId],b=d.shapes[w.fromId];if(!(C&&b)){delete o.document.pages[u].bindings[w.id];return}if(E.has(b))return;let A=Q.updateArrowBindings(d,b);if(E.add(b),A){let T=_(_({},b),A);d.shapes[b.id]=T}}),m.forEach(w=>{if(!w)throw Error("no group!");let C=w.children.filter(A=>d.shapes[A]!==void 0),b=N.getCommonBounds(C.map(A=>d.shapes[A]).filter(Boolean).map(A=>Q.getRotatedBounds(A)));d.shapes[w.id]=q(_({},w),{point:[b.minX,b.minY],size:[b.width,b.height],children:C})})}let g=_({},o.document.pageStates[u]);g.brush||delete g.brush,g.hoveredId&&!d.shapes[g.hoveredId]&&delete g.hoveredId,g.bindingId&&!d.bindings[g.bindingId]&&(Q.warn(`Could not find the binding of ${u}`),delete g.bindingId),g.editingId&&!d.shapes[g.editingId]&&(Q.warn("Could not find the editing shape!"),delete g.editingId),o.document.pageStates[u]=g}),Object.keys((i=o.document.assets)!=null?i:{}).forEach(u=>{var d,h;(d=o.document.assets)!=null&&d[u]||(h=o.document.assets)==null||delete h[u]});let a=o.appState.currentPageId,s=o.document.pageStates[a];if(o.room&&o.room!==r.room){let u=q(_({},o.room),{users:_({},o.room.users)});r.room&&Object.values(r.room.users).filter(Boolean).forEach(d=>{u.users[d.id]===void 0&&delete u.users[d.id]}),o.room=u}return o.room&&(o.room.users[o.room.userId]=q(_({},o.room.users[o.room.userId]),{point:this.currentPoint,selectedIds:s.selectedIds})),this.readOnly&&(o.document.pages=r.document.pages),o}),S(this,"broadcastPatch",(n,r)=>{var i,o,a,s,u,d,h,p,g;let m={},v={},E={},w=(a=(o=(i=n==null?void 0:n.document)==null?void 0:i.pages)==null?void 0:o[this.currentPageId])==null?void 0:a.shapes,C=(d=(u=(s=n==null?void 0:n.document)==null?void 0:s.pages)==null?void 0:u[this.currentPageId])==null?void 0:d.bindings,b=(h=n==null?void 0:n.document)==null?void 0:h.assets;w&&Object.keys(w).forEach(A=>{m[A]=this.getShape(A,this.currentPageId)}),C&&Object.keys(C).forEach(A=>{v[A]=this.getBinding(A,this.currentPageId)}),b&&Object.keys(b).forEach(A=>{E[A]=this.document.assets[A]}),(g=(p=this.callbacks).onChangePage)==null||g.call(p,this,m,v,E,r)}),S(this,"onPatch",(n,r,i)=>{var o,a,s,u,d,h;(this.callbacks.onChangePage&&((a=(o=r==null?void 0:r.document)==null?void 0:o.pages)!=null&&a[this.currentPageId])||(s=r==null?void 0:r.document)!=null&&s.assets)&&((u=r==null?void 0:r.document)!=null&&u.assets||this.session&&this.session.type!=="brush"&&this.session.type!=="erase"&&this.session.type!=="draw")&&this.broadcastPatch(r,!1),(h=(d=this.callbacks).onPatch)==null||h.call(d,this,r,i)}),S(this,"onCommand",(n,r,i)=>{var o,a;this.clearSelectHistory(),this.isDirty=!0,(a=(o=this.callbacks).onCommand)==null||a.call(o,this,r,i)}),S(this,"onReplace",()=>{this.clearSelectHistory(),this.isDirty=!1}),S(this,"onUndo",()=>{var n,r;this.rotationInfo.selectedIds=[...this.selectedIds],(r=(n=this.callbacks).onUndo)==null||r.call(n,this)}),S(this,"onRedo",()=>{var n,r;this.rotationInfo.selectedIds=[...this.selectedIds],(r=(n=this.callbacks).onRedo)==null||r.call(n,this)}),S(this,"onPersist",(n,r)=>{var i,o;(o=(i=this.callbacks).onPersist)==null||o.call(i,this),this.broadcastPatch(r,!0)}),S(this,"prevSelectedIds",this.selectedIds),S(this,"onStateDidChange",(n,r)=>{var i,o,a,s;(o=(i=this.callbacks).onChange)==null||o.call(i,this,r),this.room&&this.selectedIds!==this.prevSelectedIds&&((s=(a=this.callbacks).onChangePresence)==null||s.call(a,this,q(_({},this.room.users[this.room.userId]),{selectedIds:this.selectedIds,session:!!this.session})),this.prevSelectedIds=this.selectedIds)}),S(this,"preventPaste",()=>{if(this.isPastePrevented)return;let n=i=>i.stopImmediatePropagation(),r=()=>{setTimeout(()=>{document.removeEventListener("paste",n,{capture:!0}),this.isPastePrevented=!1},50)};document.addEventListener("paste",n,{capture:!0}),window.addEventListener("pointerup",r,{once:!0}),this.isPastePrevented=!0}),S(this,"justSent",!1),S(this,"getReservedContent",(n,r=this.currentPageId)=>{let{bindings:i}=this.document.pages[r],o={},a={},s=Object.values(i),u=new Map(s.map(v=>[v.toId,v])),d=new Map(s.map(v=>[v.fromId,v])),h=[u,d],p=[];this.session&&n.forEach(v=>p.push(v)),this.pageState.editingId&&p.push(this.pageState.editingId);let g=new Set(p),m=new Set;for(;p.length>0;){let v=p.pop();if(!v)break;if(m.has(v))continue;m.add(v);let E=this.getShape(v);o[v]=E,E.parentId!==r&&p.push(E.parentId),E.children&&p.push(...E.children),h.map(w=>w.get(E.id)).filter(Boolean).forEach(w=>{a[w.id]=w,p.push(w.toId,w.fromId)})}return{reservedShapes:o,reservedBindings:a,strongReservedShapeIds:g}}),S(this,"replacePageContent",(n,r,i,o=this.currentPageId)=>{if(this.justSent)return this.justSent=!1,this;let a=this.document.pages[this.currentPageId];return Object.values(n).forEach(s=>{s.parentId!==o&&!(a.shapes[s.parentId]||n[s.parentId])&&(console.warn("Added a shape without a parent on the page"),s.parentId=o)}),this.useStore.setState(s=>{let{hoveredId:u,editingId:d,bindingId:h,selectedIds:p}=s.document.pageStates[o],g=[...p],m=d&&s.document.pages[this.currentPageId].shapes[d];m&&g.push(m.id);let{reservedShapes:v,reservedBindings:E,strongReservedShapeIds:w}=this.getReservedContent(g,this.currentPageId);Object.values(v).filter(M=>!("text"in M)).forEach(M=>{let O=n[M.id];if(O){if(!(M.type==="arrow"||w.has(M.id))){n[M.id]=O;return}"decorations"in O&&"decorations"in M&&(n[M.id]=q(_({},M),{decorations:O.decorations})),M.style=O.style}});let C=_(_({},n),v);m&&(C[m.id]=m);let b=_(_({},r),E),A=_({},i),T=q(_({},s),{document:q(_({},s.document),{pages:{[o]:q(_({},s.document.pages[o]),{shapes:C,bindings:b})},assets:A,pageStates:q(_({},s.document.pageStates),{[o]:q(_({},s.document.pageStates[o]),{selectedIds:p.filter(M=>C[M]!==void 0),hoveredId:u?C[u]===void 0?void 0:u:void 0,editingId:d,bindingId:h?b[h]===void 0?void 0:h:void 0})})})}),B=T.document.pages[o],D=Q.getRelatedBindings(T,Object.keys(C),o),I=new Set;return D.forEach(M=>{if(!B.bindings[M.id])return;let O=B.shapes[M.fromId];if(I.has(O))return;let z=Q.updateArrowBindings(B,O);if(I.add(O),z){let K=_(_({},O),z);B.shapes[O.id]=K}}),Object.values(C).forEach(M=>{if(M.type!=="group")return;let O=M.children.filter(K=>B.shapes[K]!==void 0),z=N.getCommonBounds(O.map(K=>B.shapes[K]).filter(Boolean).map(K=>Q.getRotatedBounds(K)));B.shapes[M.id]=q(_({},M),{point:[z.minX,z.minY],size:[z.width,z.height],children:O})}),this.state.document=T.document,T},!0),this}),S(this,"updateBounds",n=>{this.rendererBounds=n;let{point:r,zoom:i}=this.camera;this.updateViewport(r,i),!this.readOnly&&this.session&&this.session.update()}),S(this,"updateViewport",(n,r)=>{let{width:i,height:o}=this.rendererBounds,[a,s]=$.sub($.div([0,0],r),n),[u,d]=$.sub($.div([i,o],r),n);this.viewport={minX:a,minY:s,maxX:u,maxY:d,height:u-a,width:d-s}}),S(this,"setEditingId",(n,r=!1)=>{if(!this.readOnly){if(n)this.startSession("edit",n,r);else{if(!this.pageState.editingId)return;this.completeSession()}this.editingStartTime=performance.now(),this.patchState({document:{pageStates:{[this.currentPageId]:{editingId:n}}}},"set_editing_id")}}),S(this,"setHoveredId",n=>{this.patchState({document:{pageStates:{[this.currentPageId]:{hoveredId:n}}}},"set_hovered_id")}),S(this,"setSetting",(n,r)=>{if(this.session)return this;let i={settings:{[n]:typeof r=="function"?r(this.settings[n]):r}};return this.patchState(i,`settings:${n}`),this.persist(i),this}),S(this,"toggleFocusMode",()=>{if(this.session)return this;let n={settings:{isFocusMode:!this.settings.isFocusMode}};return this.patchState(n,"settings:toggled_focus_mode"),this.persist(n),this}),S(this,"togglePenMode",()=>{if(this.session)return this;let n={settings:{isPenMode:!this.settings.isPenMode}};return this.patchState(n,"settings:toggled_pen_mode"),this.persist(n),this}),S(this,"toggleDarkMode",()=>{if(this.session)return this;let n={settings:{isDarkMode:!this.settings.isDarkMode}};return this.patchState(n,"settings:toggled_dark_mode"),this.persist(n),this}),S(this,"toggleZoomSnap",()=>{if(this.session)return this;let n={settings:{isZoomSnap:!this.settings.isZoomSnap}};return this.patchState(n,"settings:toggled_zoom_snap"),this.persist(n),this}),S(this,"toggleDebugMode",()=>{if(this.session)return this;let n={settings:{isDebugMode:!this.settings.isDebugMode}};return this.patchState(n,"settings:toggled_debug"),this.persist(n),this}),S(this,"setMenuOpen",n=>{let r={appState:{isMenuOpen:n}};return this.patchState(r,"ui:toggled_menu_opened"),this.persist(r),this}),S(this,"setIsLoading",n=>{let r={appState:{isLoading:n}};return this.patchState(r,"ui:toggled_is_loading"),this.persist(r),this}),S(this,"setDisableAssets",n=>(this.patchState({appState:{disableAssets:n}},"ui:toggled_disable_images"),this)),S(this,"toggleGrid",()=>{if(this.session)return this;let n={settings:{showGrid:!this.settings.showGrid}};return this.patchState(n,"settings:toggled_grid"),this.persist(n),this}),S(this,"selectTool",n=>{if(this.readOnly||this.session)return this;this.isPointing=!1;let r=this.tools[n];return r===this.currentTool?(this.patchState({appState:{isToolLocked:!1}}),this):(this.currentTool.onExit(),r.previous=this.currentTool.type,this.currentTool=r,this.currentTool.onEnter(),this.patchState({appState:{activeTool:n,isToolLocked:!1}},`selected_tool:${n}`))}),S(this,"toggleToolLock",()=>this.session?this:this.patchState({appState:{isToolLocked:!this.appState.isToolLocked}},"toggled_tool_lock")),S(this,"resetDocument",()=>{if(this.session)return this;this.session=void 0,this.currentTool=this.tools.select;let n=yn.defaultDocument;return n.pages.page.name="Page 1",this.resetHistory().clearSelectHistory().loadDocument(yn.defaultDocument).persist({}),this}),S(this,"updateUsers",(n,r=!1)=>{this.patchState({room:{users:Object.fromEntries(n.map(i=>[i.id,i]))}},r?"room:self:update":"room:user:update")}),S(this,"removeUser",n=>{this.patchState({room:{users:{[n]:void 0}}})}),S(this,"mergeDocument",n=>{if(this.document.id!==n.id)return this.replaceState(q(_({},ia(q(_({},this.state),{document:n}),yn.version)),{appState:q(_({},this.appState),{currentPageId:Object.keys(n.pages)[0]})})),this;let r=_({},this.document.pageStates),i=q(_({},this.appState),{currentPageId:n.pages[this.currentPageId]?this.currentPageId:Object.keys(n.pages)[0],pages:Object.values(n.pages).map((a,s)=>({id:a.id,name:a.name,childIndex:a.childIndex||s}))});this.resetHistory(),Object.keys(this.document.pages).forEach(a=>{n.pages[a]||(a===this.appState.currentPageId&&(this.cancelSession(),this.selectNone()),r[a]=void 0)}),this.session&&this.selectedIds.filter(a=>!n.pages[this.currentPageId].shapes[a]).forEach(a=>n.pages[this.currentPageId].shapes[a]=this.page.shapes[a]),Object.entries(r).forEach(([a,s])=>{s.selectedIds=s.selectedIds.filter(u=>!!n.pages[a].shapes[u])});let{editingId:o}=this.pageState;return o&&(n.pages[this.currentPageId].shapes[o]=this.page.shapes[o],r[this.currentPageId].selectedIds=[o]),this.replaceState(q(_({},ia(q(_({},this.state),{document:q(_({},n),{pageStates:r})}),yn.version)),{appState:i}),"merge")}),S(this,"updateDocument",(n,r="updated_document")=>{let i=this.state,o=q(_({},i),{document:q(_({},i.document),{assets:n.assets})});n.pages[this.currentPageId]||(o.appState=q(_({},i.appState),{currentPageId:Object.keys(n.pages)[0]}));let a=1;for(let s of Object.values(n.pages))s!==i.document.pages[s.id]&&(o.document.pages[s.id]=s,s.name||(o.document.pages[s.id].name=`Page ${a+1}`,a++));for(let s of Object.values(n.pageStates))if(s!==i.document.pageStates[s.id]){o.document.pageStates[s.id]=s;let u=n.pages[s.id],d=["bindingId","editingId","hoveredId","pointedId"];for(let h of d)u.shapes[h]||(s[h]=void 0);s.selectedIds=s.selectedIds.filter(h=>!!n.pages[u.id].shapes[h])}return this.replaceState(ia(o,o.document.version||0),`${r}:${n.id}`)}),S(this,"loadRoom",n=>(this.patchState({room:{id:n,userId:Xv,users:{[Xv]:{id:Xv,color:PS[Math.floor(Math.random()*PS.length)],point:[100,100],selectedIds:[],activeShapes:[]}}}}),this)),S(this,"loadDocument",n=>{this.setIsLoading(!0),this.selectNone(),this.resetHistory(),this.clearSelectHistory(),this.session=void 0;let r=q(_({},yn.defaultState),{settings:_({},this.state.settings),document:n,appState:q(_(_({},yn.defaultState.appState),this.state.appState),{currentPageId:Object.keys(n.pages)[0],disableAssets:this.disableAssets})});this.replaceState(ia(r,yn.version),"loaded_document");let{point:i,zoom:o}=this.camera;return this.updateViewport(i,o),this.setIsLoading(!1),this}),S(this,"loadPageFromURL",(n,r)=>{let i=n.id,o=q(_({},this.state.document),{pageStates:q(_({},this.state.document.pageStates),{[i]:r}),pages:q(_({},this.document.pages),{[i]:n})});this.loadDocument(o),this.persist({})}),S(this,"newProject",()=>{!this.isLocal||(this.fileSystemHandle=null,this.resetDocument())}),S(this,"saveProject",()=>Oe(this,null,function*(){if(this.readOnly)return;let n=yield Gy(ia(this.state,yn.version).document,this.fileSystemHandle);return this.fileSystemHandle=n,this.persist({}),this.isDirty=!1,this})),S(this,"saveProjectAs",n=>Oe(this,null,function*(){try{let r=yield Gy(this.document,null,n);this.fileSystemHandle=r,this.persist({}),this.isDirty=!1}catch(r){console.error(r.message)}return this})),S(this,"openProject",()=>Oe(this,null,function*(){if(this.isLocal)try{let n=yield ZT();if(!n)throw Error();let{fileHandle:r,document:i}=n;this.loadDocument(i),this.fileSystemHandle=r,this.zoomToFit(),this.persist({})}catch(n){console.error(n)}finally{this.persist({})}})),S(this,"openAsset",()=>Oe(this,null,function*(){if(!this.disableAssets)try{let n=yield QT();if(Array.isArray(n))this.addMediaFromFiles(n,this.centerPoint);else{if(!n)return;this.addMediaFromFiles([n])}}catch(n){console.error(n)}finally{this.persist({})}})),S(this,"signOut",()=>{}),S(this,"getAppState",()=>this.appState),S(this,"getPage",(n=this.currentPageId)=>Q.getPage(this.state,n||this.currentPageId)),S(this,"getShapes",(n=this.currentPageId)=>Q.getShapes(this.state,n||this.currentPageId)),S(this,"getBindings",(n=this.currentPageId)=>Q.getBindings(this.state,n||this.currentPageId)),S(this,"getShape",(n,r=this.currentPageId)=>Q.getShape(this.state,n,r)),S(this,"getShapeBounds",(n,r=this.currentPageId)=>Q.getBounds(this.getShape(n,r))),S(this,"getBinding",(n,r=this.currentPageId)=>Q.getBinding(this.state,n,r)),S(this,"getPageState",(n=this.currentPageId)=>Q.getPageState(this.state,n||this.currentPageId)),S(this,"getPagePoint",(n,r=this.currentPageId)=>{let{camera:i}=this.getPageState(r);return $.sub($.div(n,i.zoom),i.point)}),S(this,"createPage",(n,r)=>{if(this.readOnly)return this;let{width:i,height:o}=this.rendererBounds;return this.setState(NHe(this,[-i/2,-o/2],n,r))}),S(this,"changePage",n=>this.setState(LHe(this,n))),S(this,"movePage",(n,r)=>this.readOnly?this:this.setState(WHe(this,n,r))),S(this,"renamePage",(n,r)=>this.readOnly?this:this.setState(YHe(this,n,r))),S(this,"duplicatePage",n=>this.readOnly?this:this.setState(KHe(this,n))),S(this,"deletePage",n=>this.readOnly?this:Object.values(this.document.pages).length<=1?this:this.setState(zHe(this,n||this.currentPageId))),S(this,"cut",(n=this.selectedIds,r)=>(r==null||r.preventDefault(),this.copy(n,r),this.readOnly||this.delete(n),this)),S(this,"copy",(n=this.selectedIds,r)=>{var i;r==null||r.preventDefault(),this.clipboard=this.getContent(n);let o=`${JSON.stringify(_({type:"tldr/clipboard"},this.clipboard))}`;return $He(o),r&&((i=r.clipboardData)==null||i.setData("text/html",o)),navigator.clipboard&&window.ClipboardItem&&navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"})})]),this}),S(this,"paste",(n,r)=>Oe(this,null,function*(){var i,o;if(this.readOnly)return;let a=[],s=[],u,d=g=>Oe(this,null,function*(){let m=document.createElement("div");m.innerHTML=g;let v=m.firstChild;v.style.setProperty("background-color","transparent");let E=yield Q.getImageForSvg(v,"svg",{scale:1,quality:1});if(E){let w=new File([E],"image.svg");a.push(w)}else h(g)}),h=g=>{let m=this.getPagePoint(n??this.centerPoint,this.currentPageId),v=g.includes(` +`)}static assertShapeHasProperty(e,t){if(e[t]===void 0)throw new Error}static warn(e){}static error(e){}static getSvgString(e,t=1){let n=e.cloneNode(!0);return e.setAttribute("width",+e.getAttribute("width")*t+""),e.setAttribute("height",+e.getAttribute("height")*t+""),new XMLSerializer().serializeToString(n).replaceAll(" ","").replaceAll(/((\s|")[0-9]*\.[0-9]{2})([0-9]*)(\b|"|\))/g,"$1")}static getSvgAsDataUrl(e,t=1){let n=Be.getSvgString(e,t);return`data:image/svg+xml;base64,${window.btoa(unescape(n))}`}static getImageForSvg(e){return Oe(this,arguments,function*(t,n="png",r={}){let{scale:i=2,quality:o=1}=r,a=Be.getSvgString(t,i),s=+t.getAttribute("width"),u=+t.getAttribute("height");if(!a)return;let d=yield new Promise(h=>{let p=new Image;p.crossOrigin="anonymous";let g=`data:image/svg+xml;base64,${window.btoa(unescape(encodeURIComponent(a)))}`;p.onload=()=>{let m=document.createElement("canvas"),v=m.getContext("2d");m.width=s,m.height=u,v.drawImage(p,0,0,s,u),URL.revokeObjectURL(g),h(m)},p.onerror=()=>{console.warn("Could not convert that SVG to an image.")},p.src=g});return yield new Promise(h=>d.toBlob(p=>h(p),"image/"+n,o))})}},Q=Be;S(Q,"copyStringToClipboard",e=>{try{navigator.clipboard&&navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"})})])}catch{let n=document.createElement("textarea");n.setAttribute("position","fixed"),n.setAttribute("top","0"),n.setAttribute("readonly","true"),n.setAttribute("contenteditable","true"),n.style.position="fixed",n.value=e,document.body.appendChild(n),n.focus(),n.select();try{let r=document.createRange();r.selectNodeContents(n);let i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r),n.setSelectionRange(0,n.value.length)),document.execCommand("copy")}catch{}finally{document.body.removeChild(n)}}}),S(Q,"flattenShape",(e,t)=>{var n;return[t,...((n=t.children)!=null?n:[]).map(r=>Be.getShape(e,r,e.appState.currentPageId)).sort((r,i)=>r.childIndex-i.childIndex).flatMap(r=>Be.flattenShape(e,r))]}),S(Q,"flattenPage",(e,t)=>Object.values(e.document.pages[t].shapes).sort((n,r)=>n.childIndex-r.childIndex).reduce((n,r)=>[...n,...Be.flattenShape(e,r)],[])),S(Q,"getTopChildIndex",(e,t)=>{let n=Be.getShapes(e,t);return n.length===0?1:n.filter(r=>r.parentId===t).sort((r,i)=>i.childIndex-r.childIndex)[0].childIndex+1}),S(Q,"fixNewLines",/\r?\n|\r/g);var Xze=e=>e.room,Zze=function(){let e=wt(),t=e.useStore(Xze),[n,r]=l.useState(!1),i=l.useRef(0),o=l.useCallback(()=>{r(!0),Q.copyStringToClipboard(window.location.href),clearTimeout(i.current),i.current=setTimeout(()=>r(!1),1200)},[]),a=l.useCallback(()=>{r(!0);let d=window.location.href.split("/");d[d.length-2]="v",d[d.length-1]=N.lns(d[d.length-1]),Q.copyStringToClipboard(d.join("/")),clearTimeout(i.current),i.current=setTimeout(()=>r(!1),1200)},[]),s=l.useCallback(()=>Oe(this,null,function*(){e.isDirty?e.fileSystemHandle?window.confirm("Do you want to save changes to your current project?")&&(yield e.saveProject()):window.confirm("Do you want to save your current project?")&&(yield e.saveProject()):e.fileSystemHandle||window.confirm("Do you want to save your current project?")&&(yield e.saveProject())}),[]),u=l.useCallback(()=>Oe(this,null,function*(){var d;let h=N.deepClone(e.document);e.setIsLoading(!0);try{if(e.callbacks.onAssetUpload)for(let g in h.assets){let m=h.assets[g];if(m.src.includes("base64")){let v=Qze(m.src,((d=m.fileName)!=null?d:m.type==="video")?"image.png":"image.mp4"),E=yield e.callbacks.onAssetUpload(e,v,g);E?m.src=E:m.src=""}}let p=yield fetch("/api/create",{method:"POST",mode:"no-cors",headers:{"Access-Control-Allow-Origin":"*","Content-Type":"application/json"},body:JSON.stringify({roomId:N.uniqueId(),pageId:e.currentPageId,document:h})}).then(g=>g.json());p!=null&&p.url?window.location.href=p.url:Q.warn(p==null?void 0:p.message)}catch(p){Q.warn(p.message)}e.setIsLoading(!1)}),[]);return l.createElement(Lu,{dir:"ltr"},l.createElement(BT,{id:"TD-MultiplayerMenuIcon",isActive:!!t},l.createElement(INe,null)),l.createElement(Ol,{variant:"menu",id:"TD-MultiplayerMenu",side:"bottom",align:"start",sideOffset:4},l.createElement(tt,{id:"TD-Multiplayer-CopyInviteLink",onClick:o,disabled:!t},l.createElement(ge,{id:"copy.invite.link"}),l.createElement(ao,null,n?l.createElement(Pg,null):l.createElement(j6,null))),l.createElement(tt,{id:"TD-Multiplayer-CopyReadOnlyLink",onClick:a,disabled:!t},l.createElement(ge,{id:"copy.readonly.link"}),l.createElement(ao,null,n?l.createElement(Pg,null):l.createElement(j6,null))),l.createElement(Qt,null),l.createElement(tt,{id:"TD-Multiplayer-CreateMultiplayerProject",onClick:s},l.createElement("a",{href:"https://tldraw.com/r"},l.createElement(ge,{id:"create.multiplayer.project"}))),l.createElement(tt,{id:"TD-Multiplayer-CopyToMultiplayerProject",onClick:u},l.createElement(ge,{id:"copy.multiplayer.project"}))))};function Qze(e,t){var n,r;let i=e.split(","),o=(r=(n=i[0])==null?void 0:n.match(/:(.*?);/))==null?void 0:r[1],a=window.atob(i[1]),s=a.length,u=new Uint8Array(s);for(;s--;)u[s]=a.charCodeAt(s);return new File([u],t,{type:o})}var eHe=e=>Object.keys(e.document.pages).length>1;function tHe({page:e,onOpen:t,onClose:n}){let r=wt(),i=Wn(),[o,a]=l.useState(!1),[s,u]=l.useState(e.name||"Page"),d=r.useStore(eHe),h=l.useRef(null),p=l.useCallback(()=>{a(!1)},[]),g=l.useCallback(()=>{r.duplicatePage(e.id)},[r]),m=l.useCallback(()=>{window.confirm("Are you sure you want to delete this page?")&&r.deletePage(e.id)},[r]),v=l.useCallback(D=>{if(a(D),D){t==null||t();return}},[r]);function E(D){D.stopPropagation()}let w=l.useRef(e.name||"Page"),C=l.useRef(w.current),b=l.useCallback(D=>{let I=D.target.value.trimStart();C.current=I,u(I)},[]),A=l.useCallback(D=>{switch(D.key){case"Enter":{C.current===w.current||(w.current=C.current,r.renamePage(e.id,C.current.trim())),a(!1);break}case"Escape":{if(C.current===w.current){a(!1);return}C.current=w.current,u(w.current),requestAnimationFrame(()=>{let I=h.current;I&&(I.focus(),I.setSelectionRange(0,I.value.length))});break}}},[]),T=l.useRef(!1);l.useEffect(()=>(o?(T.current=!0,w.current=e.name||"Page",C.current=w.current,requestAnimationFrame(()=>{let D=h.current;D&&(D.focus(),D.setSelectionRange(0,D.value.length))})):T.current&&(n==null||n()),()=>{C.current!==w.current&&(w.current=C.current,r.renamePage(e.id,C.current))}),[o]);let B=Nu();return l.createElement(uC,{open:o,onOpenChange:v},l.createElement(Aee,{asChild:!0,"data-shy":"true"},l.createElement(IC,{bp:Ci},l.createElement(ao,null,l.createElement(tq,null)))),l.createElement(lC,{container:B.current},l.createElement(rHe,{onPointerDown:p}),l.createElement(nHe,{dir:"ltr",onKeyDown:E,onKeyUp:E},l.createElement(PT,{ref:h,placeholder:i.formatMessage({id:"page.name"}),value:s,onChange:b,onKeyDown:A,icon:l.createElement(zE,null)}),l.createElement(Qt,null),l.createElement(NS,{onSelect:g},l.createElement(ge,{id:"duplicate"})),l.createElement(NS,{disabled:!d,onSelect:m},l.createElement(ge,{id:"delete"})),l.createElement(Qt,null),l.createElement(UD,{asChild:!0},l.createElement(ur,null,l.createElement(ge,{id:"cancel"}))))))}var nHe=fe(cC,{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",minWidth:240,maxWidth:"fit-content",maxHeight:"85vh",marginTop:"-5vh",pointerEvents:"all",backgroundColor:"$panel",padding:"$1",borderRadius:"$2",font:"$ui",zIndex:999999,"&:focus":{outline:"none"}}),rHe=fe(l1,{backgroundColor:"rgba(0, 0, 0, .15)",position:"absolute",pointerEvents:"all",inset:0,zIndex:999998});function NS(e){var t=e,{onSelect:n}=t,r=$i(t,["onSelect"]);return l.createElement(Lg,{asChild:!0,onClick:n,onSelect:n},l.createElement(ur,_({},r)))}var iHe=e=>Object.values(e.document.pages).sort((t,n)=>(t.childIndex||0)-(n.childIndex||0)),oHe=e=>e.document.pages[e.appState.currentPageId].name,aHe=e=>e.document.pages[e.appState.currentPageId].id;function sHe(){let e=wt(),t=Wn(),n=l.useRef(!1),[r,i]=l.useState(!1);l.useEffect(()=>{n.current!==r&&(n.current=r)},[r]);let o=l.useCallback(()=>{i(!1)},[i]),a=l.useCallback(u=>{n.current!==u&&i(u)},[i]),s=e.useStore(oHe);return l.createElement(Lu,{dir:"ltr",open:r,onOpenChange:a},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Page"},l.createElement(st,{variant:"text"},s||t.formatMessage({id:"page"}))),l.createElement(Ol,{variant:"menu",align:"start",sideOffset:4},r&&l.createElement(uHe,{onClose:o})))}function uHe({onClose:e}){let t=wt(),n=Wn(),r=t.useStore(iHe),i=t.useStore(aHe),o=n.formatMessage({id:"page"}),a=l.useCallback(()=>{let E=o+" "+(Object.keys(t.document.pages).length+1);t.createPage(void 0,E)},[t]),s=l.useCallback(E=>{e(),t.changePage(E)},[t]),[u,d]=l.useState(null),[h,p]=l.useState(null),g=l.useCallback(E=>{d(E.currentTarget.id),p(r.findIndex(w=>w.id===E.currentTarget.id)),E.dataTransfer.effectAllowed="move"},[]),m=l.useCallback(E=>{E.preventDefault();let w=r.findIndex(b=>b.id===E.currentTarget.id),C=E.currentTarget.getBoundingClientRect();w=(E.clientY-C.top)/C.height<.5?w:w+1,p(w)},[u,r]),v=l.useCallback(()=>{u!==null&&h!==null&&t.movePage(u,h),d(null),p(null)},[u,h]);return l.createElement(l.Fragment,null,l.createElement(IX,{dir:"ltr",value:i,onValueChange:s},r.map((E,w)=>l.createElement(lHe,{key:E.id,isDropAbove:w===h&&w===0,isDropBelow:h!==null&&w===h-1},l.createElement(fI,{title:E.name||o,value:E.id,key:E.id,id:E.id,asChild:!0,onDragOver:m,onDragStart:g,onDrop:v,draggable:!0},l.createElement(cHe,null,l.createElement("span",{id:E.id},E.name||o),l.createElement(pI,null,l.createElement(ao,null,l.createElement(Pg,null))))),l.createElement(tHe,{page:E,onClose:e})))),l.createElement(Qt,null),l.createElement(Xm,{onSelect:a,asChild:!0},l.createElement(ur,null,l.createElement("span",null,l.createElement(ge,{id:"create.page"})),l.createElement(ao,null,l.createElement(cq,null)))))}var lHe=fe("div",{position:"relative",display:"grid",gridTemplateColumns:"1fr auto",gridAutoFlow:"column",margin:0,'& > *[data-shy="true"]':{opacity:0},'&:hover > *[data-shy="true"]':{opacity:1},variants:{isDropAbove:{true:{"&::after":{content:"",display:"block",position:"absolute",top:0,width:"100%",height:"1px",backgroundColor:"$selected",zIndex:999,pointerEvents:"none"}}},isDropBelow:{true:{"&::after":{content:"",display:"block",position:"absolute",width:"100%",height:"1px",top:"100%",backgroundColor:"$selected",zIndex:999,pointerEvents:"none"}}}}}),cHe=fe(ur,{minWidth:128}),dHe=e=>e.appState.currentStyle,hHe=e=>e.document.pageStates[e.appState.currentPageId].selectedIds,fHe=Object.keys(PC),zS={draw:l.createElement(k_e,null),solid:l.createElement(I_e,null),dashed:l.createElement(S_e,null),dotted:l.createElement(A_e,null)},pHe={small:l.createElement(T_e,null),medium:l.createElement(P_e,null),large:l.createElement(B_e,null)},gHe={start:l.createElement(Dq,null),middle:l.createElement(xq,null),end:l.createElement(Pq,null),justify:l.createElement(kq,null)},mHe=e=>e.settings.isDarkMode?"dark":"light",vHe=e=>e.settings.keepStyleMenuOpen,yHe=e=>{let{activeTool:t,currentPageId:n}=e.appState;switch(t){case"select":{let r=e.document.pages[n],i=!1,o=!1;for(let a of e.document.pageStates[n].selectedIds)"text"in r.shapes[a]&&(i=!0),"label"in r.shapes[a]&&(o=!0);return i?"text":o?"label":""}case"text":return"text";case"rectangle":return"label";case"ellipse":return"label";case"triangle":return"label";case"arrow":return"label";case"line":return"label"}return!1},EHe=l.memo(function(){let e=wt(),t=e.useStore(mHe),n=e.useStore(vHe),r=e.useStore(yHe),i=e.useStore(dHe),o=e.useStore(hHe),[a,s]=l.useState(i),u=l.useRef(i);l.useEffect(()=>{let{appState:{currentStyle:w},page:C,selectedIds:b}=e,A={};if(b.length<=0)A=w;else{let T=new Set([]);e.selectedIds.map(B=>C.shapes[B]).forEach(B=>{fHe.forEach(D=>{if(!T.has(D))if(A[D]===void 0)A[D]=B.style[D];else{if(A[D]===B.style[D])return;A[D]=B.style[D],T.add(D)}})})}JSON.stringify(A)!==JSON.stringify(u.current)&&(u.current=A,s(A))},[i,o]);let d=l.useCallback(w=>{e.setSetting("keepStyleMenuOpen",w)},[]),h=l.useCallback(w=>{e.style({isFilled:w})},[]),p=l.useCallback(w=>{e.style({dash:w})},[]),g=l.useCallback(w=>{e.style({size:w})},[]),m=l.useCallback(w=>{e.style({font:w})},[]),v=l.useCallback(w=>{e.style({textAlign:w})},[]),E=l.useCallback(w=>{e.setMenuOpen(w)},[e]);return l.createElement(Lu,{dir:"ltr",onOpenChange:E,open:n?!0:void 0,modal:!1},l.createElement(Fl,{asChild:!0,id:"TD-Styles"},l.createElement(st,{variant:"text"},l.createElement(ge,{id:"styles"}),l.createElement(bHe,{style:{color:P0[t][a.color]}},a.isFilled&&l.createElement(kS,{size:16,stroke:"none",fill:Uy[t][a.color]}),zS[a.dash]))),l.createElement(Ol,{id:"language-menu",side:"bottom",align:"end",sideOffset:4,alignOffset:4},l.createElement(o0,{variant:"tall",id:"TD-Styles-Color-Container"},l.createElement("span",null,l.createElement(ge,{id:"style.menu.color"})),l.createElement(CHe,null,Object.keys(P0.light).map(w=>l.createElement(Xm,{key:w,onSelect:Ut,asChild:!0,id:`TD-Styles-Color-Swatch-${w}`},l.createElement(st,{variant:"icon",isActive:a.color===w,onClick:()=>e.style({color:w})},l.createElement(kS,{size:18,strokeWidth:2.5,fill:a.isFilled?Uy[t][w]:"transparent",stroke:P0.light[w]})))))),l.createElement(Vi,{variant:"styleMenu",checked:!!a.isFilled,onCheckedChange:h,id:"TD-Styles-Fill"},l.createElement(ge,{id:"style.menu.fill"})),l.createElement(o0,{id:"TD-Styles-Dash-Container"},l.createElement(ge,{id:"style.menu.dash"}),l.createElement(Cp,{dir:"ltr",value:a.dash,onValueChange:p},Object.values(wT).map(w=>l.createElement(gp,{key:w,isActive:w===a.dash,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Dash-${w}`},zS[w])))),l.createElement(o0,{id:"TD-Styles-Size-Container"},l.createElement(ge,{id:"style.menu.size"}),l.createElement(Cp,{dir:"ltr",value:a.size,onValueChange:g},Object.values(bT).map(w=>l.createElement(gp,{key:w,isActive:w===a.size,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Dash-${w}`},pHe[w])))),(r==="text"||r==="label")&&l.createElement(l.Fragment,null,l.createElement(Qt,null),l.createElement(o0,{id:"TD-Styles-Font-Container"},l.createElement(ge,{id:"style.menu.font"}),l.createElement(Cp,{dir:"ltr",value:a.font,onValueChange:m},Object.values(xT).map(w=>l.createElement(gp,{key:w,isActive:w===a.font,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Font-${w}`},l.createElement(wHe,{fontStyle:w},"Aa"))))),r==="text"&&l.createElement(o0,{id:"TD-Styles-Align-Container"},l.createElement(ge,{id:"style.menu.align"}),l.createElement(Cp,{dir:"ltr",value:a.textAlign,onValueChange:v},Object.values(ST).map(w=>l.createElement(gp,{key:w,isActive:w===a.textAlign,value:w,onSelect:Ut,bp:Ci,id:`TD-Styles-Align-${w}`},gHe[w]))))),l.createElement(Qt,null),l.createElement(Vi,{variant:"styleMenu",checked:n,onCheckedChange:d,id:"TD-Styles-Keep-Open"},l.createElement(ge,{id:"style.menu.keep.open"}))))}),CHe=fe("div",{display:"grid",gridTemplateColumns:"repeat(4, auto)",gap:0}),o0=fe("div",{position:"relative",width:"100%",background:"none",border:"none",cursor:"pointer",minHeight:"32px",outline:"none",color:"$text",fontFamily:"$ui",fontWeight:400,fontSize:"$1",padding:"$2 0 $2 $3",borderRadius:4,userSelect:"none",margin:0,display:"flex",gap:"$3",flexDirection:"row",alignItems:"center",justifyContent:"space-between",variants:{variant:{tall:{alignItems:"flex-start",padding:"0 0 0 $3","& > span":{paddingTop:"$4"}}}}}),Cp=fe(dI,{display:"flex",flexDirection:"row",gap:"$1"}),bHe=fe("div",{display:"grid","& > *":{gridColumn:1,gridRow:1}}),wHe=fe("div",{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"$3",variants:{fontStyle:{script:{fontFamily:"Caveat Brush"},sans:{fontFamily:"Recursive"},serif:{fontFamily:"Georgia"},mono:{fontFamily:"Recursive Mono"}}}}),SHe=e=>e.document.pageStates[e.appState.currentPageId].camera.zoom,xHe=function(){let e=wt(),t=e.useStore(SHe);return l.createElement(Lu,{dir:"ltr"},l.createElement(Fl,{dir:"ltr",asChild:!0,id:"TD-Zoom"},l.createElement(AHe,{onDoubleClick:e.resetZoom,variant:"text"},Math.round(t*100),"%")),l.createElement(Ol,{align:"end"},l.createElement(tt,{onSelect:Ut,onClick:e.zoomIn,kbd:"#+",id:"TD-Zoom-Zoom_In"},l.createElement(ge,{id:"zoom.in"})),l.createElement(tt,{onSelect:Ut,onClick:e.zoomOut,kbd:"#−",id:"TD-Zoom-Zoom_Out"},l.createElement(ge,{id:"zoom.out"})),l.createElement(tt,{onSelect:Ut,onClick:e.resetZoom,kbd:"⇧0",id:"TD-Zoom-Zoom_To_100%"},l.createElement(ge,{id:"zoom.to"})," 100%"),l.createElement(tt,{onSelect:Ut,onClick:e.zoomToFit,kbd:"⇧1",id:"TD-Zoom-To_Fit"},l.createElement(ge,{id:"zoom.to.fit"})),l.createElement(tt,{onSelect:Ut,onClick:e.zoomToSelection,kbd:"⇧2",id:"TD-Zoom-To_Selection"},l.createElement(ge,{id:"zoom.to.selection"}))))},AHe=fe(st,{minWidth:56});function kHe({readOnly:e,showPages:t,showMenu:n,showStyles:r,showZoom:i,showMultiplayerMenu:o}){let a=wt();return l.createElement(IHe,null,(n||t)&&l.createElement(Ng,{side:"left",id:"TD-MenuPanel"},n&&l.createElement(kNe,{readOnly:e}),o&&l.createElement(Zze,null),t&&l.createElement(sHe,null)),l.createElement(DHe,null),(r||i)&&l.createElement(Ng,{side:"right"},a.readOnly?l.createElement(THe,null,"Read Only"):l.createElement(l.Fragment,null,l.createElement(st,null,l.createElement(IS,{onClick:a.undo})),l.createElement(st,null,l.createElement(IS,{onClick:a.redo,flipHorizontal:!0}))),i&&l.createElement(xHe,null),r&&!e&&l.createElement(EHe,null)))}var IHe=fe("div",{width:"100%",position:"absolute",top:0,left:0,right:0,display:"flex",flexDirection:"row",pointerEvents:"none","& > *":{pointerEvents:"all"}}),DHe=fe("div",{flexGrow:2,pointerEvents:"none"}),THe=fe("div",{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"$ui",fontSize:"$1",paddingLeft:"$4",paddingRight:"$1",userSelect:"none"}),PHe=l.memo(kHe);function BHe(e){Kt.useEffect(()=>{let t=!1,n=!1,r=e.current;if(!r)return;let i=u=>{u.key===" "&&!n&&(n=!0,t?r.setAttribute("style","cursor: grabbing !important"):r.setAttribute("style","cursor: grab !important"))},o=u=>{u.key===" "&&(n=!1,r.setAttribute("style","cursor: initial"))},a=u=>{t=!0,u.button===1&&r.setAttribute("style","cursor: grabbing !important"),u.button===0&&n&&r.setAttribute("style","cursor: grabbing !important")},s=()=>{t=!1,n?r.setAttribute("style","cursor: grab !important"):r.setAttribute("style","cursor: initial")};return r.addEventListener("keydown",i),r.addEventListener("keyup",o),r.addEventListener("pointerdown",a),r.addEventListener("pointerup",s),()=>{r.removeEventListener("keydown",i),r.removeEventListener("keyup",o),r.removeEventListener("pointerdown",a),r.removeEventListener("pointerup",s)}},[e.current])}var YT="tldraw_clipboard";function MHe(){return Oe(this,null,function*(){return Og(YT)})}function $He(e){return Oe(this,null,function*(){return I0(YT,e)})}var RHe=class{constructor(e,t,n,r){S(this,"_idbId"),S(this,"initialState"),S(this,"store"),S(this,"pointer",-1),S(this,"_state"),S(this,"_status","loading"),S(this,"stack",[]),S(this,"_snapshot"),S(this,"useStore"),S(this,"ready"),S(this,"isPaused",!1),S(this,"persist",(i,o)=>{if(this._status==="ready"&&(this.onPersist&&this.onPersist(this._state,i,o),this._idbId))return I0(this._idbId,this._state).catch(a=>console.error(a))}),S(this,"applyPatch",(i,o)=>{let a=this._state,s=N.deepMerge(this._state,i),u=this.cleanup(s,a,i,o);return this.onStateWillChange&&this.onStateWillChange(u,o),this._state=u,this.store.setState(this._state,!0),this.onStateDidChange&&this.onStateDidChange(this._state,o),this}),S(this,"migrate",i=>i),S(this,"cleanup",(i,o,a,s)=>i),S(this,"onStateWillChange"),S(this,"onStateDidChange"),S(this,"patchState",(i,o)=>(this.applyPatch(i,o),this.onPatch&&this.onPatch(this._state,i,o),this)),S(this,"replaceState",(i,o)=>{let a=this.cleanup(i,this._state,i,o);return this.onStateWillChange&&this.onStateWillChange(a,"replace"),this._state=a,this.store.setState(this._state,!0),this.onStateDidChange&&this.onStateDidChange(this._state,"replace"),this}),S(this,"setState",(i,o=i.id)=>(this.pointer(this.onStateWillChange&&this.onStateWillChange(this.initialState,"reset"),this._state=this.initialState,this.store.setState(this._state,!0),this.resetHistory(),this.persist({},"reset"),this.onStateDidChange&&this.onStateDidChange(this._state,"reset"),this.onReset&&this.onReset(this._state),this)),S(this,"replaceHistory",(i,o=i.length-1)=>(this.stack=i,this.pointer=o,this.onReplace&&this.onReplace(this._state),this)),S(this,"resetHistory",()=>(this.stack=[],this.pointer=-1,this.onResetHistory&&this.onResetHistory(this._state),this)),S(this,"undo",()=>{if(!this.isPaused){if(!this.canUndo)return this;let i=this.stack[this.pointer];this.pointer--,this.applyPatch(i.before,"undo"),this.persist(i.before,"undo")}return this.onUndo&&this.onUndo(this._state),this}),S(this,"redo",()=>{if(!this.isPaused){if(!this.canRedo)return this;this.pointer++;let i=this.stack[this.pointer];this.applyPatch(i.after,"redo"),this.persist(i.after,"undo")}return this.onRedo&&this.onRedo(this._state),this}),S(this,"setSnapshot",()=>(this._snapshot=_({},this._state),this)),S(this,"forceUpdate",()=>{this.store.setState(this._state,!0)}),this._idbId=t,this._state=$r(e),this._snapshot=$r(e),this.initialState=$r(e),this.store=Bte(()=>this._state),this.useStore=rne(this.store),this.ready=new Promise(i=>{let o="none";this._idbId?(o="restored",Og(this._idbId).then(a=>Oe(this,null,function*(){if(a){let s=a;if(n){let d=yield Og(t+"_version");d&&dconsole.error(a))):(this._status="ready",i(o))}).then(i=>(this.onReady&&this.onReady(i),i))}pause(){this.isPaused=!0}resume(){this.isPaused=!1}get canUndo(){return this.pointer>-1}get canRedo(){return this.pointere.getShape(g)),o=i.map(g=>({id:g.id,point:[...g.point],bounds:Q.getBounds(g)})),a=N.getCommonBounds(o.map(({bounds:g})=>g)),s=a.minX+a.width/2,u=a.minY+a.height/2,d=Object.fromEntries(o.map(({id:g,point:m,bounds:v})=>[g,{prev:m,next:{top:[m[0],a.minY],centerVertical:[m[0],u-v.height/2],bottom:[m[0],a.maxY-v.height],left:[a.minX,m[1]],centerHorizontal:[s-v.width/2,m[1]],right:[a.maxX-v.width,m[1]]}[n]}])),{before:h,after:p}=Q.mutateShapes(e.state,t,g=>d[g.id]?{point:d[g.id].next}:g,r,!1);return i.forEach(g=>{if(g.type==="group"){let m=$.sub(p[g.id].point,h[g.id].point);g.children.forEach(v=>{let E=e.getShape(v);h[E.id]={point:E.point},p[E.id]={point:$.add(E.point,m)}}),delete h[g.id],delete p[g.id]}}),{id:"align",before:{document:{pages:{[r]:{shapes:h}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:p}},pageStates:{[r]:{selectedIds:t}}}}}}function LHe(e,t){return{id:"change_page",before:{appState:{currentPageId:e.currentPageId}},after:{appState:{currentPageId:t}}}}function OHe(e,t){var n;let r=e,i=new Set(t);for(;i.has(r);)r=(n=/^.*(\d+)$/.exec(r))!=null&&n[1]?r.replace(/(\d+)(?=\D?)$/,o=>(+o+1).toString()):`${r} 1`;return r}function _He(e,t,n){let r={shapes:{},bindings:{}},i={shapes:{},bindings:{}},o=[],a=new Set,s=new Set;t.filter(d=>!Q.getShape(e,d,n).isLocked).forEach(d=>{a.add(d);let h=Q.getShape(e,d,n);r.shapes[d]=h,i.shapes[d]=void 0,h.children!==void 0&&h.children.forEach(p=>{a.add(p);let g=Q.getShape(e,p,n);r.shapes[p]=g,i.shapes[p]=void 0}),h.parentId!==n&&o.push(Q.getShape(e,h.parentId,n)),h.assetId&&s.add(h.assetId)}),o.forEach(d=>{var h;t.includes(d.id)||(a.add(d.id),r.shapes[d.id]={children:d.children},i.shapes[d.id]={children:d.children.filter(p=>!t.includes(p))},((h=i.shapes[d.id])==null?void 0:h.children.length)===0&&(i.shapes[d.id]=void 0,r.shapes[d.id]=Q.getShape(e,d.id,n)))});let u=Q.getPage(e,n);return Object.values(u.bindings).filter(d=>a.has(d.fromId)||a.has(d.toId)).forEach(d=>{for(let h of[d.toId,d.fromId])if(i.shapes[h]===void 0){r.bindings[d.id]=d,i.bindings[d.id]=void 0;let p=u.shapes[h];p&&p.handles&&Object.values(p.handles).filter(g=>g.bindingId===d.id).forEach(g=>{var m,v,E,w,C,b;r.shapes[h]=q(_({},r.shapes[h]),{handles:q(_({},(m=r.shapes[h])==null?void 0:m.handles),{[g.id]:q(_({},(E=(v=r.shapes[h])==null?void 0:v.handles)==null?void 0:E[g.id]),{bindingId:d.id})})}),a.has(h)||(i.shapes[h]=q(_({},i.shapes[h]),{handles:q(_({},(w=i.shapes[h])==null?void 0:w.handles),{[g.id]:q(_({},(b=(C=i.shapes[h])==null?void 0:C.handles)==null?void 0:b[g.id]),{bindingId:void 0})})}))})}}),Object.values(e.document.pages).flatMap(d=>Object.values(d.shapes)).forEach(d=>{"assetId"in d&&d.assetId&&!a.has(d.id)&&s.delete(d.assetId)}),{before:r,after:i,assetsToRemove:Array.from(s)}}function NHe(e,t,n=N.uniqueId(),r="Page"){let{currentPageId:i}=e,o=Object.values(e.state.document.pages).sort((h,p)=>{var g,m;return((g=h.childIndex)!=null?g:0)-((m=p.childIndex)!=null?m:0)}),a=o[o.length-1],s=a!=null&&a.childIndex?(a==null?void 0:a.childIndex)+1:1,u={id:n,name:OHe(r,o.map(h=>{var p;return(p=h.name)!=null?p:""})),childIndex:s,shapes:{},bindings:{}},d={id:n,selectedIds:[],camera:{point:t,zoom:1},editingId:void 0,bindingId:void 0,hoveredId:void 0,pointedId:void 0};return{id:"create_page",before:{appState:{currentPageId:i},document:{pages:{[n]:void 0},pageStates:{[n]:void 0}}},after:{appState:{currentPageId:u.id},document:{pages:{[n]:u},pageStates:{[n]:d}}}}}function HS(e,t,n=[]){let{currentPageId:r}=e,i={},o={};t.forEach(u=>{i[u.id]=void 0,o[u.id]=u});let a={},s={};return n.forEach(u=>{a[u.id]=void 0,s[u.id]=u}),{id:"create",before:{document:{pages:{[r]:{shapes:i,bindings:a}},pageStates:{[r]:{selectedIds:[...e.selectedIds]}}}},after:{document:{pages:{[r]:{shapes:o,bindings:s}},pageStates:{[r]:{selectedIds:t.map(u=>u.id)}}}}}}function zHe(e,t){let{currentPageId:n,document:{pages:r,pageStates:i}}=e,o=Object.values(r).sort((u,d)=>(u.childIndex||0)-(d.childIndex||0)),a=o.findIndex(u=>u.id===t),s;return t===n?a===o.length-1?s=o[o.length-2].id:s=o[a+1].id:s=n,{id:"delete_page",before:{appState:{currentPageId:t},document:{pages:{[t]:_({},r[t])},pageStates:{[t]:_({},i[t])}}},after:{appState:{currentPageId:s},document:{pages:{[t]:void 0},pageStates:{[t]:void 0}}}}}var HHe=(e,t)=>{let n=_({},e);return t.forEach(r=>n[r]=void 0),n};function jS(e,t,n=e.currentPageId){let{pageState:r,selectedIds:i,document:{assets:o}}=e,{before:a,after:s,assetsToRemove:u}=_He(e.state,t,n),d=HHe(o,u);return{id:"delete",before:{document:{assets:o,pages:{[n]:a},pageStates:{[n]:{selectedIds:[...e.selectedIds]}}}},after:{document:{assets:d,pages:{[n]:s},pageStates:{[n]:{selectedIds:i.filter(h=>!t.includes(h)),hoveredId:r.hoveredId&&t.includes(r.hoveredId)?void 0:r.hoveredId}}}}}}function jHe(e,t,n){let{currentPageId:r}=e,i=t.map(u=>e.getShape(u)),o=Object.fromEntries(UHe(i,n).map(u=>[u.id,u])),{before:a,after:s}=Q.mutateShapes(e.state,t.filter(u=>o[u]!==void 0),u=>{var d;return{point:(d=o[u.id])==null?void 0:d.next}},r);return i.forEach(u=>{if(u.type==="group"){let d=se.sub(s[u.id].point,a[u.id].point);u.children.forEach(h=>{let p=e.getShape(h);a[p.id]={point:p.point},s[p.id]={point:se.add(p.point,d)}}),delete a[u.id],delete s[u.id]}}),{id:"distribute",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}}}}}function UHe(e,t){let n=e.map(a=>{let s=Q.getShapeUtil(a);return{id:a.id,point:[...a.point],bounds:s.getBounds(a),center:s.getCenter(a)}}),r=n.length,i=N.getCommonBounds(n.map(({bounds:a})=>a)),o=[];switch(t){case"horizontal":{let a=n.reduce((s,u)=>s+u.bounds.width,0);if(a>i.width){let s=n.sort((g,m)=>g.bounds.minX-m.bounds.minX)[0],u=n.sort((g,m)=>m.bounds.maxX-g.bounds.maxX)[0],d=n.filter(g=>g!==s&&g!==u).sort((g,m)=>g.center[0]-m.center[0]),h=(u.center[0]-s.center[0])/(r-1),p=s.center[0]+h;d.forEach(({id:g,point:m,bounds:v},E)=>{o.push({id:g,prev:m,next:[p+h*E-v.width/2,v.minY]})})}else{let s=n.sort((h,p)=>h.center[0]-p.center[0]),u=i.minX,d=(i.width-a)/(r-1);s.forEach(({id:h,point:p,bounds:g})=>{o.push({id:h,prev:p,next:[u,g.minY]}),u+=g.width+d})}break}case"vertical":{let a=n.reduce((s,u)=>s+u.bounds.height,0);if(a>i.height){let s=n.sort((g,m)=>g.bounds.minY-m.bounds.minY)[0],u=n.sort((g,m)=>m.bounds.maxY-g.bounds.maxY)[0],d=n.filter(g=>g!==s&&g!==u).sort((g,m)=>g.center[1]-m.center[1]),h=(u.center[1]-s.center[1])/(r-1),p=s.center[1]+h;d.forEach(({id:g,point:m,bounds:v},E)=>{o.push({id:g,prev:m,next:[v.minX,p+h*E-v.height/2]})})}else{let s=n.sort((h,p)=>h.center[1]-p.center[1]),u=i.minY,d=(i.height-a)/(r-1);s.forEach(({id:h,point:p,bounds:g})=>{o.push({id:h,prev:p,next:[g.minX,u]}),u+=g.height+d})}break}}return o}function KHe(e,t){let{currentPageId:n,pageState:{camera:r}}=e,i=e.document.pages[t],o=N.uniqueId(),a=q(_({},i),{id:o,name:i.name+" Copy",shapes:Object.fromEntries(Object.entries(i.shapes).map(([s,u])=>[s,q(_({},u),{parentId:u.parentId===i.id?o:u.parentId})]))});return{id:"duplicate_page",before:{appState:{currentPageId:n},document:{pages:{[o]:void 0},pageStates:{[o]:void 0}}},after:{appState:{currentPageId:o},document:{pages:{[o]:a},pageStates:{[o]:q(_({},i),{id:o,selectedIds:[],camera:_({},r),editingId:void 0,bindingId:void 0,hoveredId:void 0,pointedId:void 0})}}}}}function VHe(e,t,n){let{selectedIds:r,currentPageId:i,page:o,shapes:a}=e,s={shapes:{},bindings:{}},u={shapes:{},bindings:{}},d={},h=t.map(m=>e.getShape(m)).filter(m=>!t.includes(m.parentId));h.forEach(m=>{let v=N.uniqueId();if(s.shapes[v]=void 0,u.shapes[v]=q(_({},N.deepClone(m)),{id:v,childIndex:Q.getChildIndexAbove(e.state,m.id,i)}),m.children&&(u.shapes[v].children=[]),m.parentId!==i){let E=e.getShape(m.parentId);s.shapes[E.id]=q(_({},s.shapes[E.id]),{children:E.children}),u.shapes[E.id]=q(_({},u.shapes[E.id]),{children:[...(u.shapes[E.id]||E).children,v]})}d[m.id]=v}),h.forEach(m=>{m.children&&m.children.forEach(v=>{var E,w;let C=e.getShape(v),b=N.uniqueId(),A=d[m.id];s.shapes[b]=void 0,u.shapes[b]=q(_({},N.deepClone(C)),{id:b,parentId:A,childIndex:Q.getChildIndexAbove(e.state,C.id,i)}),d[v]=b,(w=(E=u.shapes[d[m.id]])==null?void 0:E.children)==null||w.push(b)})});let p=new Set(Object.keys(d));Object.values(o.bindings).filter(m=>p.has(m.fromId)||p.has(m.toId)).forEach(m=>{if(p.has(m.fromId))if(p.has(m.toId)){let v=N.uniqueId(),E=q(_({},N.deepClone(m)),{id:v,fromId:d[m.fromId],toId:d[m.toId]});s.bindings[v]=void 0,u.bindings[v]=E;let w=u.shapes[E.fromId];Object.values(w.handles).forEach(C=>{C.bindingId===m.id&&(C.bindingId=v)})}else{let v=u.shapes[d[m.fromId]];Object.values(v.handles).forEach(E=>{E.bindingId===m.id&&(E.bindingId=void 0)})}});let g=Object.values(u.shapes);if(n){let m=N.getCommonBounds(g.map(E=>Q.getBounds(E))),v=N.getBoundsCenter(m);g.forEach(E=>{!E.point||(E.point=$.sub(n,$.sub(v,E.point)))})}else{let m=[16,16];g.forEach(v=>{!v.point||(v.point=$.add(v.point,m))})}return g.forEach(m=>{m.isLocked&&(m.isLocked=!1)}),{id:"duplicate",before:{document:{pages:{[i]:s},pageStates:{[i]:{selectedIds:r}}}},after:{document:{pages:{[i]:u},pageStates:{[i]:{selectedIds:Array.from(p.values()).map(m=>d[m])}}}}}}function US(e,t,n){let{selectedIds:r,currentPageId:i,page:{shapes:o}}=e,a=t.map(p=>Q.getBounds(o[p])),s=t.length===1&&o[t[0]].type==="group",u=N.getCommonBounds(a),{before:d,after:h}=Q.mutateShapes(e.state,t,p=>{let g=Q.getBounds(p),m=p.parentId!==i;switch(n){case"horizontal":{if(m&&!s){let E=Q.getBounds(o[p.parentId]),w=N.getRelativeTransformedBoundingBox(u,u,E,!0,!1).minX-E.minX;return Q.getShapeUtil(p).transform(p,q(_({},g),{minX:g.minX+w,maxX:g.maxX+w}),{type:Yi.TopLeft,scaleX:1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}let v=N.getRelativeTransformedBoundingBox(u,u,g,!0,!1);return Q.getShapeUtil(p).transform(p,v,{type:Yi.TopLeft,scaleX:-1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}case"vertical":{if(m&&!s){let E=Q.getBounds(o[p.parentId]),w=N.getRelativeTransformedBoundingBox(u,u,E,!1,!0).minY-E.minY;return Q.getShapeUtil(p).transform(p,q(_({},g),{minY:g.minY+w,maxY:g.maxY+w}),{type:Yi.TopLeft,scaleX:1,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}let v=N.getRelativeTransformedBoundingBox(u,u,g,!1,!0);return Q.getShapeUtil(p).transform(p,v,{type:Yi.TopLeft,scaleX:1,scaleY:-1,initialShape:p,transformOrigin:[.5,.5]})}}},i,!0);return{id:"flip",before:{document:{pages:{[i]:{shapes:d}},pageStates:{[i]:{selectedIds:r}}}},after:{document:{pages:{[i]:{shapes:h}},pageStates:{[i]:{selectedIds:t}}}}}}function GHe(e,t,n,r){var i,o;if(t.length<2)return;let a={},s={},u={},d={},h=[...t],p=[],g=[],m=[];for(let D of t){let I=e.getShape(D);if(!I.isLocked)if(I.children===void 0)p.push(I);else{let M=I.children.filter(O=>!e.getShape(O).isLocked);m.push(I),h.push(...M),p.push(...M.map(O=>e.getShape(O)).filter(Boolean))}}if(p.every(D=>D.parentId===p[0].parentId)&&p[0].parentId!==r&&((i=e.getShape(p[0].parentId).children)==null?void 0:i.length)===h.length)return;let v=Q.flattenPage(e.state,r),E=Object.fromEntries(p.map(D=>[D.id,v.indexOf(D)])),w=p.sort((D,I)=>E[D.id]-E[I.id]),C=r,b=(w.filter(D=>D.parentId===r)[0]||w[0]).childIndex,A=N.getCommonBounds(p.map(D=>Q.getBounds(D)));for(a[n]=void 0,s[n]=Q.getShapeUtil("group").create({id:n,childIndex:b,parentId:C,point:[A.minX,A.minY],size:[A.width,A.height],children:w.map(D=>D.id)}),w.forEach((D,I)=>{if(D.parentId!==r){let M=e.getShape(D.parentId);m.push(M)}a[D.id]=q(_({},a[D.id]),{parentId:D.parentId,childIndex:D.childIndex}),s[D.id]=q(_({},s[D.id]),{parentId:n,childIndex:I+1})});m.length>0;){let D=m.pop();if(!D)break;let I=(((o=a[D.id])==null?void 0:o.children)||D.children).filter(M=>M&&!(h.includes(M)||g.includes(M)));I.length===0?(a[D.id]=D,s[D.id]=void 0,D.parentId!==r&&(g.push(D.id),m.push(e.getShape(D.parentId)))):(a[D.id]=q(_({},a[D.id]),{children:D.children}),s[D.id]=q(_({},s[D.id]),{children:I}))}let{bindings:T}=e,B=new Set(g);return T.forEach(D=>{for(let I of[D.toId,D.fromId])if(B.has(I)){u[D.id]=D,d[D.id]=void 0;let M=e.getShape(I);M.handles&&Object.values(M.handles).filter(O=>O.bindingId===D.id).forEach(O=>{var z,K;a[I]=q(_({},a[I]),{handles:q(_({},(z=a[I])==null?void 0:z.handles),{[O.id]:{bindingId:D.id}})}),g.includes(I)||(s[I]=q(_({},s[I]),{handles:q(_({},(K=s[I])==null?void 0:K.handles),{[O.id]:{bindingId:void 0}})}))})}}),{id:"group",before:{document:{pages:{[r]:{shapes:a,bindings:u}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s,bindings:u}},pageStates:{[r]:{selectedIds:[n]}}}}}}function JHe(e,t,n,r,i){let{page:o}=e,a={before:{shapes:{},bindings:{}},after:{shapes:{},bindings:{}}},s={before:{shapes:{},bindings:{}},after:{shapes:{},bindings:{}}},u=new Set,d=new Set;t.map(b=>e.getShape(b,r)).filter(b=>!b.isLocked).forEach(b=>{u.add(b.id),d.add(b),b.children!==void 0&&b.children.forEach(A=>{u.add(A),d.add(e.getShape(A,r))})});let h=Q.getTopChildIndex(e.state,i),p=Array.from(d.values());p.forEach((b,A)=>{if(a.before.shapes[b.id]=b,a.after.shapes[b.id]=void 0,s.before.shapes[b.id]=void 0,s.after.shapes[b.id]=b,!u.has(b.parentId)&&(s.after.shapes[b.id]=q(_({},b),{parentId:i,childIndex:h+A}),b.parentId!==r)){let T=e.getShape(b.parentId,r);a.before.shapes[T.id]={children:T.children},a.after.shapes[T.id]={children:T.children.filter(B=>B!==b.id)}}}),Object.values(o.bindings).filter(b=>u.has(b.fromId)||u.has(b.toId)).forEach(b=>{a.before.bindings[b.id]=b,a.after.bindings[b.id]=void 0;let A=e.getShape(b.fromId,r);if(u.has(b.fromId)&&u.has(b.toId))s.before.bindings[b.id]=void 0,s.after.bindings[b.id]=b;else if(u.has(b.fromId)){let T=e.getShape(b.fromId,r),B=Object.values(A.handles).find(I=>I.bindingId===b.id).id,D=s.after.shapes[T.id];D.handles=q(_({},D.handles),{[B]:q(_({},D.handles[B]),{bindingId:void 0})})}else{let T=e.getShape(b.fromId,r),B=Object.values(A.handles).find(D=>D.bindingId===b.id);a.before.shapes[T.id]={handles:{[B.id]:{bindingId:b.id}}},a.after.shapes[T.id]={handles:{[B.id]:{bindingId:void 0}}}}});let g=e.state.document.pageStates[i],m=N.getCommonBounds(p.map(b=>Q.getBounds(b))),v=Q.getCameraZoom(n.width{var h,p;return((h=u.childIndex)!=null?h:0)-((p=d.childIndex)!=null?p:0)}),a=o.indexOf(i),s=[...o];return s.splice(a,1),s.splice(n>a?n-1:n,0,i),{id:"move_page",before:{document:{pages:Object.fromEntries(o.map(u=>[u.id,{childIndex:u.childIndex}]))}},after:{document:{pages:Object.fromEntries(s.map((u,d)=>[u.id,{childIndex:d}]))}}}}function bp(e,t,n){let{currentPageId:r,page:i}=e,o=new Set(t.map(h=>e.getShape(h).parentId)),a={before:{},after:{}},s,u,d;return Array.from(o.values()).forEach(h=>{let p=[];if(h===i.id)p=Object.values(i.shapes).sort((v,E)=>v.childIndex-E.childIndex);else{let v=e.getShape(h);if(!v.children)throw Error("No children in parent!");p=v.children.map(E=>e.getShape(E)).sort((E,w)=>E.childIndex-w.childIndex)}let g=p.map(v=>v.id),m=t.filter(v=>g.includes(v)).map(v=>g.indexOf(v)).sort((v,E)=>v-E);if(m.length!==g.length)switch(n){case"toBack":{for(let v=0;vp[v].id).reverse(),(v,E)=>({childIndex:u-(E+1)*d}),r);break}case"toFront":{for(let v=g.length-1;v>=0;v--)if(!m.includes(v)){s=v;break}u=p[s].childIndex,d=1,a=Q.mutateShapes(e.state,m.map(v=>p[v].id),(v,E)=>({childIndex:u+(E+1)}),r);break}case"backward":{let v={};for(let E=g.length-1;E>=0;E--)if(m.includes(E)){for(let w=E;w>=0;w--)if(!m.includes(w)){let C=p[w].childIndex,b,A;w===0?(b=C/2,A=C/2/(E-w+1)):(b=p[w-1].childIndex,A=(C-b)/(E-w+1),b+=A);for(let T=0;T0&&(a=Q.mutateShapes(e.state,m.map(E=>p[E].id),E=>({childIndex:v[E.id]}),r));break}case"forward":{let v={};for(let E=0;E0&&(a=Q.mutateShapes(e.state,m.map(E=>p[E].id),E=>({childIndex:v[E.id]}),r));break}}}),{id:"move",before:{document:{pages:{[r]:{shapes:a.before}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:a.after}},pageStates:{[r]:{selectedIds:t}}}}}}function YHe(e,t,n){let{page:r}=e;return{id:"rename_page",before:{document:{pages:{[t]:{name:r.name}}}},after:{document:{pages:{[t]:{name:n}}}}}}function KS(e,t,n){let{currentPageId:r}=e,{before:i,after:o}=Q.mutateShapes(e.state,t,a=>{var s,u;return(u=(s=e.getShapeUtil(a)).onDoubleClickBoundsHandle)==null?void 0:u.call(s,a)},n);return{id:"reset_bounds",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:t}}}}}}var qHe=Math.PI*2;function XHe(e,t,n=-qHe/4){let{currentPageId:r}=e,i={},o={},a=t.flatMap(u=>{let d=e.getShape(u);return d.children?d.children.map(h=>e.getShape(h)):d}).filter(u=>!u.isLocked),s=N.getBoundsCenter(N.getCommonBounds(a.map(u=>Q.getBounds(u))));return a.forEach(u=>{let d=Q.getRotatedShapeMutation(u,Q.getCenter(u),s,n);!d||(i[u.id]=Q.getBeforeShape(u,d),o[u.id]=d)}),{id:"rotate",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:t}}}}}}function ZHe(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.map(p=>e.getShape(p)),a=o.map(p=>Q.getBounds(p)),s=N.getCommonBounds(a),u=t.flatMap(p=>{let g=e.getShape(p);return g.children?g.children:g.id}).filter(p=>!e.getShape(p).isLocked),{before:d,after:h}=Q.mutateShapes(e.state,u,p=>{let g=Q.getBounds(p);switch(n){case"horizontal":{let m=q(_({},g),{minX:s.minX,maxX:s.maxX,width:s.width});return Q.getShapeUtil(p).transformSingle(p,m,{type:Yi.TopLeft,scaleX:m.width/g.width,scaleY:1,initialShape:p,transformOrigin:[.5,.5]})}case"vertical":{let m=q(_({},g),{minY:s.minY,maxY:s.maxY,height:s.height});return Q.getShapeUtil(p).transformSingle(p,m,{type:Yi.TopLeft,scaleX:1,scaleY:m.height/g.height,initialShape:p,transformOrigin:[.5,.5]})}}},r);return o.forEach(p=>{p.type==="group"&&(delete d[p.id],delete h[p.id])}),{id:"stretch",before:{document:{pages:{[r]:{shapes:d}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:h}},pageStates:{[r]:{selectedIds:t}}}}}}function QHe(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.flatMap(u=>Q.getDocumentBranch(e.state,u,r)).filter(u=>!e.getShape(u).isLocked),a={},s={};return o.map(u=>e.getShape(u)).filter(u=>!u.isLocked).forEach(u=>{a[u.id]={style:_({},Object.fromEntries(Object.keys(n).map(d=>[d,u.style[d]])))},s[u.id]={style:n},u.type==="text"&&(a[u.id].point=u.point,s[u.id].point=$.toFixed($.add(u.point,$.sub(e.getShapeUtil(u).getCenter(u),e.getShapeUtil(u).getCenter(q(_({},u),{style:_(_({},u.style),n)}))))))}),{id:"style",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:i}}},appState:{currentStyle:_({},e.appState.currentStyle)}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}},appState:{currentStyle:n}}}}function eje(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=Object.fromEntries(t.map(s=>{var u;return[s,{decorations:{[n]:(u=e.getShape(s).decorations)==null?void 0:u[n]}}]})),a=Object.fromEntries(t.filter(s=>!e.getShape(s).isLocked).map(s=>{var u;return[s,{decorations:{[n]:(u=e.getShape(s).decorations)!=null&&u[n]?void 0:"arrow"}}]}));return{id:"toggle_decorations",before:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}}}}function Xv(e,t,n){let{currentPageId:r}=e,i=t.map(u=>e.getShape(u)).filter(u=>n==="isLocked"?!0:!u.isLocked),o=i.every(u=>u[n]),a={},s={};return i.forEach(u=>{a[u.id]={[n]:u[n]},s[u.id]={[n]:!o}}),{id:"toggle",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:t}}}}}}function tje(e,t,n){let{currentPageId:r,selectedIds:i}=e;e.rotationInfo.selectedIds=[...i];let o={shapes:{},bindings:{}},a={shapes:{},bindings:{}},s=t.flatMap(d=>{let h=e.getShape(d);return h.children?h.children:h.id}).filter(d=>!e.getShape(d).isLocked),u=Q.mutateShapes(e.state,s,d=>({point:$.toFixed($.add(d.point,n))}),r);return o.shapes=u.before,a.shapes=u.after,Q.getBindings(e.state,r).filter(d=>t.includes(d.fromId)&&!t.includes(d.toId)).forEach(d=>{o.bindings[d.id]=d,a.bindings[d.id]=void 0;for(let h of[d.toId,d.fromId]){let p=e.getShape(h);!p.handles||Object.values(p.handles).filter(g=>g.bindingId===d.id).forEach(g=>{var m,v;o.shapes[h]=q(_({},o.shapes[h]),{handles:q(_({},(m=o.shapes[h])==null?void 0:m.handles),{[g.id]:{bindingId:d.id}})}),a.shapes[h]=q(_({},a.shapes[h]),{handles:q(_({},(v=a.shapes[h])==null?void 0:v.handles),{[g.id]:{bindingId:void 0}})})})}}),{id:"translate",before:{document:{pages:{[r]:o},pageStates:{[r]:{selectedIds:t}}}},after:{document:{pages:{[r]:a},pageStates:{[r]:{selectedIds:t}}}}}}function nje(e,t,n,r){let{bindings:i}=e,o={},a={},s={},u={},d=t,h=t.filter(p=>!n.find(g=>g.id===p));return n.filter(p=>!p.isLocked).forEach(p=>{let g=[],m=[];o[p.id]=p,a[p.id]=void 0,p.children.forEach(w=>{h.push(w);let C=e.getShape(w,r);g.push(C)});let v=p.childIndex,E=(Q.getChildIndexAbove(e.state,p.id,r)-v)/g.length;g.sort((w,C)=>w.childIndex-C.childIndex).forEach((w,C)=>{o[w.id]={parentId:w.parentId,childIndex:w.childIndex},a[w.id]={parentId:r,childIndex:v+E*C}}),i.filter(w=>w.toId===p.id||w.fromId===p.id).forEach(w=>{for(let C of[w.toId,w.fromId])if(a[C]===void 0){s[w.id]=w,u[w.id]=void 0;let b=e.getShape(C,r);b.handles&&Object.values(b.handles).filter(A=>A.bindingId===w.id).forEach(A=>{var T,B;o[C]=q(_({},o[C]),{handles:q(_({},(T=o[C])==null?void 0:T.handles),{[A.id]:{bindingId:w.id}})}),m.includes(C)||(a[C]=q(_({},a[C]),{handles:q(_({},(B=a[C])==null?void 0:B.handles),{[A.id]:{bindingId:void 0}})}))})}})}),{id:"ungroup",before:{document:{pages:{[r]:{shapes:o,bindings:s}},pageStates:{[r]:{selectedIds:d}}}},after:{document:{pages:{[r]:{shapes:a,bindings:s}},pageStates:{[r]:{selectedIds:h}}}}}}function VS(e,t,n){let r=t.map(o=>o.id),i=Q.mutateShapes(e.state,r.filter(o=>!e.getShape(o,n).isLocked),(o,a)=>t[a],n);return{id:"update",before:{document:{pages:{[n]:{shapes:i.before}}}},after:{document:{pages:{[n]:{shapes:i.after}}}}}}function rje(e,t,n){let{currentPageId:r,selectedIds:i}=e,o=t.map(d=>e.getShape(d)).filter(d=>n.isLocked?!0:!d.isLocked),a={},s={},u=Object.keys(n);return o.forEach(d=>{a[d.id]=Object.fromEntries(u.map(h=>[h,d[h]])),s[d.id]=n}),{id:"set_props",before:{document:{pages:{[r]:{shapes:a}},pageStates:{[r]:{selectedIds:i}}}},after:{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:{selectedIds:i}}}}}}function ije(e,t,n={}){let{currentPageId:r}=e,{point:i,select:o,overwrite:a}=n,s=e.document.pages[r],u={shapes:{},bindings:{}},d={},h={shapes:{},bindings:{}};if(a){for(let g of t.shapes)u.shapes[g.id]=s.shapes[g.id],h.shapes[g.id]=g;if(t.bindings)for(let g of t.bindings)u.bindings[g.id]=s.bindings[g.id],h.bindings[g.id]=g;if(t.assets)for(let g of t.assets)d[g.id]=g}else{let g={},m=Q.getTopChildIndex(e.state,r),v=t.shapes.sort((C,b)=>C.childIndex-b.childIndex).map(C=>{let b=N.uniqueId();return g[C.id]=b,q(_({},N.deepClone(C)),{id:b})}),E=new Set;for(;v.length>0;){let C=v.shift();if(!C)break;if(E.add(C.id),C.parentId==="currentPageId")C.parentId=r,C.childIndex=m++;else{C.parentId=g[C.parentId];let b=h.shapes[C.parentId];if(!b){E.has(C.id)&&(C.parentId="currentPageId"),v.push(C);continue}b.children.push(C.id)}C.children&&(C.children=[]),u.shapes[C.id]=void 0,h.shapes[C.id]=C}Object.values(h.shapes).forEach(C=>{C.children&&C.children.length===0&&(delete u.shapes[C.id],delete h.shapes[C.id])}),t.bindings&&t.bindings.forEach(C=>{let b=N.uniqueId();g[C.id]=b;let A=g[C.toId],T=g[C.fromId];if(!A||!T){if(T){let I=h.shapes[T].handles;I&&Object.values(I).forEach(M=>{M.bindingId===C.id&&(M.bindingId=void 0)})}if(A){let I=h.shapes[A].handles;I&&Object.values(I).forEach(M=>{M.bindingId===C.id&&(M.bindingId=void 0)})}return}let B=h.shapes[T].handles;B&&Object.values(B).forEach(I=>{I.bindingId===C.id&&(I.bindingId=b)}),h.shapes[A].handles&&Object.values(h.shapes[A].handles).forEach(I=>{I.bindingId===C.id&&(I.bindingId=b)});let D=q(_({},N.deepClone(C)),{id:b,toId:A,fromId:T});u.bindings[D.id]=void 0,h.bindings[D.id]=D});let w=Object.values(h.shapes);if(w.length>0)if(i){let C=N.getCommonBounds(w.map(A=>Q.getBounds(A))),b=N.getBoundsCenter(C);w.forEach(A=>{!A.point||(A.point=$.sub(i,$.sub(b,A.point)))})}else{let C=N.getCommonBounds(w.map(Q.getBounds));if(!(N.boundsContain(e.viewport,C)||N.boundsCollide(e.viewport,C))){let b=$.toFixed(e.getPagePoint(e.centerPoint)),A=N.centerBounds(C,b),T=$.sub(N.getBoundsCenter(A),N.getBoundsCenter(C));w.forEach(B=>{B.point=$.toFixed($.add(B.point,T))})}}if(t.assets)for(let C of t.assets)d[C.id]=C}let p=document.createElement("textarea");return Object.values(h.shapes).forEach(g=>{"text"in g&&(p.innerHTML=g.text,g.text=p.value),"label"in g&&(p.innerHTML=g.label,g.label=p.value)}),p.remove(),{id:"insert",before:{document:{pages:{[r]:u},pageStates:{[r]:{selectedIds:[...e.selectedIds]}}}},after:{document:{pages:{[r]:h},assets:d,pageStates:{[r]:{selectedIds:o?Object.keys(h.shapes):[...e.selectedIds]}}}}}}var qT={};une(qT,{fileToBase64:()=>eP,fileToText:()=>tP,getImageSizeFromSrc:()=>nP,getVideoSizeFromSrc:()=>rP,loadFileHandle:()=>XT,migrate:()=>ia,openAssetsFromFileSystem:()=>QT,openFromFileSystem:()=>ZT,saveFileHandle:()=>$C,saveToFileSystem:()=>Jy});function ia(e,t){let{document:n,settings:r}=e,{version:i=0}=n;"assets"in n||(n.assets={});let o=new Set;return Object.values(n.pages).forEach(a=>Object.values(a.shapes).forEach(s=>{let{parentId:u,children:d,assetId:h}=s;h&&o.add(h),u!==a.id&&!a.shapes[u]&&(console.warn("Encountered a shape with a missing parent!"),s.parentId=a.id),s.type==="group"&&d&&d.forEach(p=>{a.shapes[p]||(console.warn("Encountered a parent with a missing child!",s.id,p),d==null||d.splice(d.indexOf(p),1))})})),Object.keys(n.assets).forEach(a=>{o.has(a)||delete n.assets[a]}),i!==t&&(i<14&&Object.values(n.pages).forEach(a=>{Object.values(a.shapes).filter(s=>s.type==="text").forEach(s=>s.style.font==="script")}),i<=13&&Object.values(n.pages).forEach(a=>{Object.values(a.bindings).forEach(s=>{Object.assign(s,s.meta)}),Object.values(a.shapes).forEach(s=>{Object.entries(s.style).forEach(([u,d])=>{typeof d=="string"&&(s.style[u]=d.toLowerCase())}),s.type==="arrow"&&s.decorations&&Object.entries(s.decorations).forEach(([u,d])=>{d==="Arrow"&&(s.decorations=q(_({},s.decorations),{[u]:"arrow"}))})})}),i<=13.1&&(n.name="New Document"),i<15&&(n.assets={}),Object.values(n.pages).forEach(a=>{Object.values(a.shapes).forEach(s=>{i<15.2&&(s.type==="image"||s.type==="video")&&(s.style.isFilled=!0),i<15.3&&(s.type==="rectangle"||s.type==="triangle"||s.type==="ellipse"||s.type==="arrow")&&(s.label=s.text||"",s.labelPoint=[.5,.5])})}),i<15.4&&(r.dockPosition="bottom"),i<15.5&&(r.exportBackground="transparent")),Object.values(n.pageStates).forEach(a=>{a.selectedIds=a.selectedIds.filter(s=>n.pages[a.id].shapes[s]!==void 0),a.bindingId=void 0,a.editingId=void 0,a.hoveredId=void 0,a.pointedId=void 0}),n.version=t,e}var GS={mode:"readwrite"},oje=e=>Oe(void 0,null,function*(){return(yield e.queryPermission(GS))==="granted"||(yield e.requestPermission(GS))==="granted"});function XT(){return Oe(this,null,function*(){return typeof Window>"u"||!("_location"in Window)?void 0:(yield Og(`Tldraw_file_handle_${window.location.origin}`))||null})}function $C(e){return Oe(this,null,function*(){return I0(`Tldraw_file_handle_${window.location.origin}`,e)})}function Jy(e,t,n){return Oe(this,null,function*(){let r={name:e.name||"New Document",fileHandle:t??null,document:e,assets:{}},i=JSON.stringify(r),o=new Blob([i],{type:"application/vnd.Tldraw+json"});if(t&&!(yield oje(t)))return null;let a=!kd&&(n!=null&&n.length)?n:`${r.name}`,s=yield eT(o,{fileName:`${a}${Hy}`,description:"Tldraw File",extensions:[`${Hy}`]},t);return yield $C(s),s})}function ZT(){return Oe(this,null,function*(){var e;let t=yield hC({description:"Tldraw File",extensions:[`${Hy}`],multiple:!1});if(!t)return null;let n=yield new Promise(o=>{let a=new FileReader;a.onloadend=()=>{a.readyState===FileReader.DONE&&o(a.result)},a.readAsText(t,"utf8")}),r=JSON.parse(n),i=(e=t.handle)!=null?e:null;return yield $C(i),{fileHandle:i,document:r.document}})}function QT(){return Oe(this,null,function*(){return hC({description:"Image or Video",extensions:[...MT,...$T],multiple:!0})})}function eP(e){return new Promise((t,n)=>{if(e){let r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=i=>n(i),r.onabort=i=>n(i)}})}function tP(e){return new Promise((t,n)=>{if(e){let r=new FileReader;r.readAsText(e),r.onload=()=>t(r.result),r.onerror=i=>n(i),r.onabort=i=>n(i)}})}function nP(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t([r.width,r.height]),r.onerror=()=>n(new Error("Could not get image size")),r.src=e})}function rP(e){return new Promise((t,n)=>{let r=document.createElement("video");r.onloadedmetadata=()=>t([r.videoWidth,r.videoHeight]),r.onerror=()=>n(new Error("Could not get video size")),r.src=e})}lne(qT,qee);var lo=class{constructor(e){this.app=e}},aje=class extends lo{constructor(e,t,n,r=!1){super(e),S(this,"type","arrow"),S(this,"performanceMode"),S(this,"status","translatingHandle"),S(this,"newStartBindingId",N.uniqueId()),S(this,"draggedBindingId",N.uniqueId()),S(this,"didBind",!1),S(this,"initialShape"),S(this,"handleId"),S(this,"bindableShapeIds"),S(this,"initialBinding"),S(this,"startBindingShapeId"),S(this,"isCreate"),S(this,"start",()=>{}),S(this,"update",()=>{var p,g,m;let{initialShape:v}=this,{currentPoint:E,shiftKey:w,altKey:C,metaKey:b,currentGrid:A,settings:{showGrid:T}}=this.app,B=this.app.getShape(v.id);if(B.isLocked)return;let{handles:D}=v,I=this.handleId;if(!D[I].canBind)return;let M=$.sub(E,$.add(D[I].point,v.point));if(w){let U=C?$.med(D.start.point,D.end.point):D[I==="start"?"end":"start"].point,ne=D[I].point,le=$.add(ne,M),Ae=$.angle(U,le),we=$.rotWith(le,U,N.snapAngleToSegments(Ae,24)-Ae);M=$.add(M,$.sub(we,le))}let O=$.add(D[I].point,M),z={[I]:q(_({},D[I]),{point:T?$.snap(O,A):$.toFixed(O),bindingId:void 0})},K=od.arrow,X=(p=K.onHandleChange)==null?void 0:p.call(K,v,z);if(!X)return;let Z={shape:N.deepMerge(B,X),bindings:{}},pe,me=Z.shape.handles[this.handleId],Ce=Z.shape.handles[this.handleId==="start"?"end":"start"];if(this.startBindingShapeId){let U,ne=this.app.page.shapes[this.startBindingShapeId],le=Q.getShapeUtil(ne),Ae=le.getCenter(ne),we=Z.shape.handles.start,ft=Z.shape.handles.end,Ze=$.add(we.point,Z.shape.point);$.isEqual(Ze,Ae)&&Ze[1]++;let qe=Ae,Ge=le.hitTestPoint(ne,E),At=$.uni($.sub(Ze,qe)),dt=this.app.getBinding(this.newStartBindingId)!==void 0;!b&&!le.hitTestPoint(ne,$.add(Z.shape.point,ft.point))&&(U=this.findBindingPoint(B,ne,"start",this.newStartBindingId,Ae,qe,At,Ge)),U&&!dt?(this.didBind=!0,Z.bindings[this.newStartBindingId]=U,Z.shape=N.deepMerge(Z.shape,{handles:{start:{bindingId:U.id}}})):!U&&dt&&(this.didBind=!1,Z.bindings[this.newStartBindingId]=void 0,Z.shape=N.deepMerge(v,{handles:{start:{bindingId:void 0}}}))}if(!b){let U=$.add(Ce.point,Z.shape.point),ne=$.add(me.point,Z.shape.point),le=$.uni($.sub(ne,U)),Ae=$.add(Z.shape.point,Z.shape.handles.start.point),we=$.add(Z.shape.point,Z.shape.handles.end.point),ft=this.bindableShapeIds.map(Ze=>this.app.page.shapes[Ze]).sort((Ze,qe)=>qe.childIndex-Ze.childIndex).filter(Ze=>{if(Ze.isLocked)return!1;let qe=Q.getShapeUtil(Ze);return![Ae,we].every(Ge=>qe.hitTestPoint(Ze,Ge))});for(let Ze of ft)if(pe=this.findBindingPoint(B,Ze,this.handleId,this.draggedBindingId,ne,U,le,C),pe)break}if(pe)this.didBind=!0,Z.bindings[this.draggedBindingId]=pe,Z.shape=N.deepMerge(Z.shape,{handles:{[this.handleId]:{bindingId:this.draggedBindingId}}});else{this.didBind=this.didBind||!1;let U=B.handles[this.handleId].bindingId;U!==void 0&&(Z.bindings[U]=void 0,Z.shape=N.deepMerge(Z.shape,{handles:{[this.handleId]:{bindingId:void 0}}}))}let W=(m=(g=Q.getShapeUtil(Z.shape)).onHandleChange)==null?void 0:m.call(g,Z.shape,Z.shape.handles);return{document:{pages:{[this.app.currentPageId]:{shapes:{[B.id]:_(_({},Z.shape),W??{})},bindings:Z.bindings}},pageStates:{[this.app.currentPageId]:{bindingId:Z.shape.handles[I].bindingId}}}}}),S(this,"cancel",()=>{let{initialShape:p,initialBinding:g,newStartBindingId:m,draggedBindingId:v}=this,E=Q.onSessionComplete(this.app.page.shapes[p.id]),w=this.isCreate||$.dist(E.handles.start.point,E.handles.end.point)<4,C={};return C[v]=void 0,g&&(C[g.id]=w?void 0:g),m&&(C[m]=void 0),{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:w?void 0:p},bindings:C}},pageStates:{[this.app.currentPageId]:{selectedIds:w?[]:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}}}),S(this,"complete",()=>{let{initialShape:p,initialBinding:g,newStartBindingId:m,startBindingShapeId:v,handleId:E}=this,w=Q.onSessionComplete(this.app.page.shapes[p.id]),C=w.handles[E].bindingId,b=$.dist(w.handles.start.point,w.handles.end.point);if(!(C||g)&&b<4)return this.cancel();let A={},T={};return g&&(A[g.id]=this.isCreate?void 0:g,T[g.id]=void 0),C&&(A[C]=void 0,T[C]=this.app.page.bindings[C]),v&&(A[m]=void 0,T[m]=this.app.page.bindings[m]),{id:"arrow",before:{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:this.isCreate?void 0:p},bindings:A}},pageStates:{[this.app.currentPageId]:{selectedIds:this.isCreate?[]:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}},after:{document:{pages:{[this.app.currentPageId]:{shapes:{[p.id]:w},bindings:T}},pageStates:{[this.app.currentPageId]:{selectedIds:[p.id],bindingId:void 0,hoveredId:void 0,editingId:void 0}}}}}}),S(this,"findBindingPoint",(p,g,m,v,E,w,C,b)=>{let A=Q.getShapeUtil(g.type).getBindingPoint(g,p,E,w,C,b);if(A)return{id:v,type:"arrow",fromId:p.id,toId:g.id,handleId:m,point:$.toFixed(A.point),distance:A.distance}});var i,o,a;this.isCreate=r;let{currentPageId:s}=e.state.appState,u=e.state.document.pages[s];this.handleId=n,this.initialShape=$r(u.shapes[t]),this.bindableShapeIds=Q.getBindableShapeIds(e.state).filter(p=>!(p===this.initialShape.id||p===this.initialShape.parentId));let d=(i=this.initialShape.handles[n==="start"?"end":"start"])==null?void 0:i.bindingId;if(d){let p=(o=u.bindings[d])==null?void 0:o.toId;p&&(this.bindableShapeIds=this.bindableShapeIds.filter(g=>g!==p))}let{originPoint:h}=this.app;if(this.isCreate)this.startBindingShapeId=(a=this.bindableShapeIds.map(p=>u.shapes[p]).filter(p=>!p.isLocked&&N.pointInBounds(h,Q.getShapeUtil(p).getBounds(p))).sort((p,g)=>g.childIndex-p.childIndex)[0])==null?void 0:a.id,this.startBindingShapeId&&this.bindableShapeIds.splice(this.bindableShapeIds.indexOf(this.startBindingShapeId),1);else{let p=this.initialShape.handles[this.handleId].bindingId;p?this.initialBinding=u.bindings[p]:this.initialShape.handles[this.handleId].bindingId=void 0}}},sje=class extends lo{constructor(e){super(e),S(this,"type","brush"),S(this,"performanceMode"),S(this,"status","brushing"),S(this,"initialSelectedIds"),S(this,"shapesToTest"),S(this,"start",()=>{}),S(this,"update",()=>{let{initialSelectedIds:n,shapesToTest:r,app:{metaKey:i,settings:o,originPoint:a,currentPoint:s}}=this,u=N.getBoundsFromPoints([a,s]),d=o.isCadSelectMode?!i&&a[0]{let C=this.app.getShape(E);if(!h.has(w)){let b=this.app.getShapeUtil(C);(d?N.boundsContain(u,b.getBounds(C)):b.hitTestBounds(C,u))?(h.add(w),p.has(w)||p.add(w)):p.has(w)&&p.delete(w)}});let g=this.app.selectedIds,m=p.size!==g.length||g.some(E=>!p.has(E)),v=m?Array.from(p.values()):g;return m?{appState:{selectByContain:d},document:{pageStates:{[this.app.currentPageId]:{brush:u,selectedIds:v}}}}:{appState:{selectByContain:d},document:{pageStates:{[this.app.currentPageId]:{brush:u}}}}}),S(this,"cancel",()=>({appState:{selectByContain:!1},document:{pageStates:{[this.app.currentPageId]:{brush:null,selectedIds:Array.from(this.initialSelectedIds.values())}}}})),S(this,"complete",()=>({appState:{selectByContain:!1},document:{pageStates:{[this.app.currentPageId]:{brush:null,selectedIds:[...this.app.selectedIds]}}}}));let{currentPageId:t}=e;this.initialSelectedIds=new Set(this.app.selectedIds),this.shapesToTest=this.app.shapes.filter(n=>!(n.isLocked||n.isHidden||n.parentId!==t||this.initialSelectedIds.has(n.id)||this.initialSelectedIds.has(n.parentId))).map(n=>({id:n.id,bounds:this.app.getShapeUtil(n).getBounds(n),selectId:n.id})),this.update()}},uje=class extends lo{constructor(e,t){super(e),S(this,"type","draw"),S(this,"performanceMode"),S(this,"status","creating"),S(this,"topLeft"),S(this,"points"),S(this,"initialShape"),S(this,"lastAdjustedPoint"),S(this,"shiftedPoints",[]),S(this,"shapeId"),S(this,"isLocked"),S(this,"isExtending"),S(this,"lockedDirection"),S(this,"start",()=>{var u;let d=this.app.originPoint,h=[0,0,(u=d[2])!=null?u:.5];this.points.push(h);let p=[Math.min(this.topLeft[0],d[0]),Math.min(this.topLeft[1],d[1])],g=$.sub(p,d);return this.topLeft=p,this.shiftedPoints=this.points.map(m=>$.toFixed($.sub(m,g)).concat(m[2])),{document:{pages:{[this.app.currentPageId]:{shapes:{[this.shapeId]:{point:this.topLeft,points:this.shiftedPoints}}}},pageStates:{[this.app.currentPageId]:{selectedIds:[this.shapeId]}}}}}),S(this,"update",()=>{let{shapeId:u}=this,{currentPoint:d,originPoint:h,shiftKey:p,zoom:g}=this.app;if(!this.lockedDirection&&this.points.length>1){let v=$.sub(d,h);$.len(v)>3/g&&(this.lockedDirection=Math.abs(v[0])>Math.abs(v[1])?"horizontal":"vertical")}if(p){if(!this.isLocked&&this.points.length>2){if(!this.lockedDirection){let E=$.sub(d,h);$.len(E)>3/g&&(this.lockedDirection=Math.abs(E[0])>Math.abs(E[1])?"horizontal":"vertical")}this.isLocked=!0;let v=[...this.lastAdjustedPoint];this.lockedDirection==="vertical"?v[0]=0:v[1]=0,this.points.push(v.concat(d[2]))}}else this.isLocked&&(this.isLocked=!1);this.isLocked&&(this.lockedDirection==="vertical"?d[0]=h[0]:d[1]=h[1]);let m=this.addPoint(d);if(m)return{document:{pages:{[this.app.currentPageId]:{shapes:{[u]:m}}},pageStates:{[this.app.currentPageId]:{selectedIds:[u]}}}}}),S(this,"cancel",()=>{let{shapeId:u}=this,d=this.app.currentPageId;return{document:{pages:{[d]:{shapes:{[u]:this.isExtending?this.initialShape:void 0}}},pageStates:{[d]:{selectedIds:[]}}}}}),S(this,"complete",()=>{let{shapeId:u}=this,d=this.app.currentPageId,h=this.app.getShape(u);return{id:"create_draw",before:{document:{pages:{[d]:{shapes:{[u]:this.isExtending?this.initialShape:void 0}}},pageStates:{[d]:{selectedIds:[]}}}},after:{document:{pages:{[d]:{shapes:{[u]:q(_({},h),{point:$.toFixed(h.point),points:h.points.map(p=>$.toFixed(p)),isComplete:!0})}}},pageStates:{[this.app.currentPageId]:{selectedIds:[]}}}}}}),S(this,"addPoint",u=>{let{originPoint:d}=this.app,h=$.toFixed($.sub(u,d)).concat(u[2]);if($.isEqual(this.lastAdjustedPoint,h))return;this.points.push(h),this.lastAdjustedPoint=h;let p=[...this.topLeft],g=[Math.min(this.topLeft[0],u[0]),Math.min(this.topLeft[1],u[1])],m=$.sub(g,d),v;return p[0]!==g[0]||p[1]!==g[1]?(this.topLeft=g,v=this.points.map(E=>$.toFixed($.sub(E,m)).concat(E[2]))):v=[...this.shiftedPoints,$.sub(h,m).concat(h[2])],this.shiftedPoints=v,{point:this.topLeft,points:v}});var n;let{originPoint:r}=this.app;this.shapeId=t,this.initialShape=this.app.getShape(t),this.topLeft=[...this.initialShape.point];let i=[0,0,(n=r[2])!=null?n:.5],o=$.sub(r,this.topLeft),a=this.initialShape.points.map(u=>$.sub(u,o).concat(u[2]));this.isExtending=a.length>0;let s=[];if(this.isExtending){let u=a[a.length-1];if(u){s.push(u,u);let d=Math.floor($.dist(u,i)/16);if(d>1)for(let h=0;h$.add(u,o).concat(u[2])),this.lastAdjustedPoint=this.points[this.points.length-1]}},lje=class extends lo{constructor(e,t,n){super(e),S(this,"type","edit"),S(this,"performanceMode"),S(this,"initialShape"),S(this,"initialSelectedIds"),S(this,"currentPageId"),S(this,"isCreating"),S(this,"start",()=>{}),S(this,"update",()=>{}),S(this,"cancel",()=>({document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:this.isCreating?void 0:this.initialShape}}},pageStates:{[this.currentPageId]:{selectedIds:this.isCreating?[]:this.initialSelectedIds,editingId:void 0}}}})),S(this,"complete",()=>{let r=this.app.getShape(this.initialShape.id);return{id:"edit",before:{document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:this.isCreating?void 0:this.initialShape}}},pageStates:{[this.currentPageId]:{selectedIds:this.isCreating?[]:this.initialSelectedIds,editingId:void 0}}}},after:{document:{pages:{[this.currentPageId]:{shapes:{[this.initialShape.id]:r}}},pageStates:{[this.currentPageId]:{selectedIds:[r.id],editingId:void 0}}}}}}),this.initialShape=e.getShape(t,e.currentPageId),this.currentPageId=e.currentPageId,this.isCreating=n,this.initialSelectedIds=[...e.selectedIds]}},cje=class extends lo{constructor(e){super(e),S(this,"type","draw"),S(this,"performanceMode"),S(this,"status","creating"),S(this,"isLocked"),S(this,"lockedDirection"),S(this,"erasedShapes",new Set),S(this,"erasedBindings",new Set),S(this,"initialSelectedShapes"),S(this,"erasableShapes"),S(this,"prevPoint"),S(this,"prevEraseShapesSize",0),S(this,"interval"),S(this,"timestamp1",0),S(this,"timestamp2",0),S(this,"prevErasePoint",[]),S(this,"loop",()=>{let t=Date.now(),n=t-this.timestamp1,r=t-this.timestamp2,{eraseLine:i}=this.app.appState,o=[...i],a=!1;n>16&&this.prevErasePoint!==this.prevPoint&&(a=!0,o=[...i,this.prevPoint],this.prevErasePoint=this.prevPoint),r>32&&o.length>1&&(a=!0,o.splice(0,Math.ceil(o.length*.1)),this.timestamp2=t),a&&this.app.patchState({appState:{eraseLine:o}},"eraseline"),this.interval=requestAnimationFrame(this.loop)}),S(this,"start",()=>{}),S(this,"update",()=>{let{page:t,shiftKey:n,originPoint:r,currentPoint:i,zoom:o}=this.app;if(n){let d=$.sub(i,r);if(!this.isLocked&&$.len(d)>3/o){if(!this.lockedDirection){let h=$.sub(i,r);this.lockedDirection=Math.abs(h[0])>Math.abs(h[1])?"horizontal":"vertical"}this.isLocked=!0}}else this.isLocked&&(this.isLocked=!1);this.isLocked&&(this.lockedDirection==="vertical"?i[0]=r[0]:i[1]=r[1]);let a=$.toFixed($.add(r,$.sub(i,r))),s=new Set([]);this.erasableShapes.forEach(d=>{if(!this.erasedShapes.has(d)&&this.app.getShapeUtil(d).hitTestLineSegment(d,this.prevPoint,a)&&(this.erasedShapes.add(d),s.add(d.id),d.children!==void 0))for(let h of d.children)this.erasedShapes.add(this.app.getShape(h)),s.add(h)}),Object.values(t.bindings).forEach(d=>{for(let h of[d.toId,d.fromId])s.has(h)&&this.erasedBindings.add(d)}),this.erasedShapes.forEach(d=>{this.app.getShape(d.id)||(this.erasedShapes.delete(d),this.erasableShapes.delete(d),s.delete(d.id))});let u=Array.from(this.erasedShapes.values());if(this.prevPoint=a,u.length!==this.prevEraseShapesSize)return this.prevEraseShapesSize=u.length,{document:{pages:{[t.id]:{shapes:Object.fromEntries(u.map(d=>[d.id,{isGhost:!0}]))}}}}}),S(this,"cancel",()=>{let{page:t}=this.app;cancelAnimationFrame(this.interval),this.erasedShapes.forEach(r=>{this.app.getShape(r.id)||(this.erasedShapes.delete(r),this.erasableShapes.delete(r))});let n=Array.from(this.erasedShapes.values());return{document:{pages:{[t.id]:{shapes:Object.fromEntries(n.map(r=>[r.id,{isGhost:!1}]))}},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.map(r=>r.id)}}},appState:{eraseLine:[]}}}),S(this,"complete",()=>{let{page:t}=this.app;cancelAnimationFrame(this.interval),this.erasedShapes.forEach(u=>{this.app.getShape(u.id)||(this.erasedShapes.delete(u),this.erasableShapes.delete(u))}),this.erasedBindings.forEach(u=>{this.app.getBinding(u.id)||this.erasedBindings.delete(u)});let n=Array.from(this.erasedShapes.values()),r=Array.from(this.erasedBindings.values()),i=n.map(u=>u.id),o=r.map(u=>u.id),a={shapes:Object.fromEntries(n.map(u=>[u.id,u])),bindings:Object.fromEntries(r.map(u=>[u.id,u]))},s={shapes:Object.fromEntries(n.map(u=>[u.id,void 0])),bindings:Object.fromEntries(r.map(u=>[u.id,void 0]))};return this.app.shapes.forEach(u=>{u.handles&&!s.shapes[u.id]&&Object.values(u.handles).forEach(d=>{var h,p;d.bindingId&&o.includes(d.bindingId)&&(a.shapes[u.id]=q(_({},a.shapes[u.id]),{handles:q(_({},(h=a.shapes[u.id])==null?void 0:h.handles),{[d.id]:d})}),i.includes(u.id)||(s.shapes[u.id]=q(_({},s.shapes[u.id]),{handles:q(_({},(p=s.shapes[u.id])==null?void 0:p.handles),{[d.id]:q(_({},d),{bindingId:void 0})})})))})}),{id:"erase",before:{document:{pages:{[t.id]:a},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.filter(u=>!!this.app.getShape(u.id)).map(u=>u.id)}}},appState:{eraseLine:[]}},after:{document:{pages:{[t.id]:s},pageStates:{[t.id]:{selectedIds:this.initialSelectedShapes.filter(u=>!!this.app.getShape(u.id)).filter(u=>!i.includes(u.id)).map(u=>u.id)}}},appState:{eraseLine:[]}}}}),this.prevPoint=[...e.originPoint],this.initialSelectedShapes=this.app.selectedIds.map(t=>this.app.getShape(t)),this.erasableShapes=new Set(this.app.shapes.filter(t=>!t.isLocked)),this.interval=this.loop()}},dje=class extends lo{constructor(e,t){super(e),S(this,"type","grid"),S(this,"performanceMode"),S(this,"status","translating"),S(this,"shape"),S(this,"bounds"),S(this,"initialSelectedIds"),S(this,"initialSiblings"),S(this,"grid",{}),S(this,"columns",1),S(this,"rows",1),S(this,"isCopying",!1),S(this,"start",()=>{}),S(this,"update",()=>{let{currentPageId:r,altKey:i,shiftKey:o,currentPoint:a}=this.app,s={},u={},d=N.getBoundsCenter(this.bounds),h=$.sub(a,d);o&&(Math.abs(h[0])B!==this.shape.id).forEach(B=>s[B]=void 0),this.grid={"0_0":this.shape.id},this.isCopying=T);for(let B=E;B{A.has(B)||(s[D]=void 0,delete this.grid[B])}),Object.values(s).length!==0)return this.initialSiblings&&(s[this.shape.parentId]={children:[...this.initialSiblings,...Object.values(this.grid)]}),{document:{pages:{[r]:{shapes:s}},pageStates:{[r]:u}}}}),S(this,"cancel",()=>{let{currentPageId:r}=this.app,i={};return Object.values(this.grid).forEach(o=>{i[o]=void 0}),i[this.shape.id]=q(_({},i[this.shape.id]),{point:this.shape.point}),this.initialSiblings&&(i[this.shape.parentId]={children:[...this.initialSiblings,this.shape.id]}),{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:[this.shape.id]}}}}}),S(this,"complete",()=>{let{currentPageId:r}=this.app,i={},o={},a=[];if(Object.values(this.grid).forEach(s=>{i[s]=void 0,o[s]=this.app.getShape(s),a.push(s)}),i[this.shape.id]=this.shape,this.initialSiblings&&(i[this.shape.parentId]={children:[...this.initialSiblings,this.shape.id]},o[this.shape.parentId]={children:[...this.initialSiblings,...Object.values(this.grid)]}),a.length!==1)return{id:"grid",before:{document:{pages:{[r]:{shapes:i}},pageStates:{[r]:{selectedIds:[],hoveredId:void 0}}}},after:{document:{pages:{[r]:{shapes:o}},pageStates:{[r]:{selectedIds:a,hoveredId:void 0}}}}}}),S(this,"getClone",(r,i)=>{let o=q(_({},this.shape),{id:N.uniqueId(),point:r});return i||o.type==="sticky"&&(o.text=""),o});var n;this.shape=this.app.getShape(t),this.grid["0_0"]=this.shape.id,this.bounds=this.app.getShapeBounds(t),this.initialSelectedIds=[...this.app.selectedIds],this.shape.parentId!==this.app.currentPageId&&(this.initialSiblings=(n=this.app.getShape(this.shape.parentId).children)==null?void 0:n.filter(r=>r!==this.shape.id))}},hje=class extends lo{constructor(e,t,n,r="move_handle"){super(e),S(this,"type","handle"),S(this,"performanceMode"),S(this,"status","translatingHandle"),S(this,"commandId"),S(this,"topLeft"),S(this,"shiftKey",!1),S(this,"initialShape"),S(this,"handleId"),S(this,"start",()=>{}),S(this,"update",()=>{var o,a;let{initialShape:s,app:{currentPageId:u,currentPoint:d}}=this,h=this.app.getShape(s.id);if(h.isLocked)return;let p=h.handles,g=this.handleId,m=$.sub(d,p[g].point),v={[g]:q(_({},p[g]),{point:$.sub($.add(p[g].point,m),h.point)})},E=(a=(o=Q.getShapeUtil(h)).onHandleChange)==null?void 0:a.call(o,h,v);if(E)return{document:{pages:{[u]:{shapes:{[h.id]:E}}}}}}),S(this,"cancel",()=>{let{initialShape:o,app:{currentPageId:a}}=this;return{document:{pages:{[a]:{shapes:{[o.id]:o}}}}}}),S(this,"complete",()=>{let{initialShape:o,app:{currentPageId:a}}=this;return{id:this.commandId,before:{document:{pages:{[a]:{shapes:{[o.id]:o}}}}},after:{document:{pages:{[a]:{shapes:{[o.id]:Q.onSessionComplete(this.app.getShape(this.initialShape.id))}}}}}}});let{originPoint:i}=e;this.topLeft=[...i],this.handleId=n,this.initialShape=this.app.getShape(t),this.commandId=r}},fje=class extends lo{constructor(e){super(e),S(this,"type","rotate"),S(this,"status","transforming"),S(this,"performanceMode"),S(this,"delta",[0,0]),S(this,"commonBoundsCenter"),S(this,"initialAngle"),S(this,"initialShapes"),S(this,"changes",{}),S(this,"start",()=>{}),S(this,"update",()=>{let{commonBoundsCenter:o,initialShapes:a,app:{currentPageId:s,currentPoint:u,shiftKey:d}}=this,h={},p=$.angle(o,u)-this.initialAngle;return d&&(p=N.snapAngleToSegments(p,24)),a.forEach(({center:g,shape:m})=>{let{rotation:v=0}=m,E=0;d&&(E=N.snapAngleToSegments(v,24)-v);let w=Q.getRotatedShapeMutation(m,g,o,d?p+E:p);w&&(h[m.id]=w)}),this.changes=h,{document:{pages:{[s]:{shapes:h}}}}}),S(this,"cancel",()=>{let{initialShapes:o,app:{currentPageId:a}}=this,s={};return o.forEach(({shape:u})=>s[u.id]=u),{document:{pages:{[a]:{shapes:s}}}}}),S(this,"complete",()=>{let{initialShapes:o,app:{currentPageId:a}}=this,s={},u=this.changes;return o.forEach(({shape:{id:d,point:h,rotation:p,handles:g}})=>{s[d]={point:h,rotation:p,handles:g}}),{id:"rotate",before:{document:{pages:{[a]:{shapes:s}}}},after:{document:{pages:{[a]:{shapes:u}}}}}});let{app:{currentPageId:t,pageState:n,originPoint:r}}=this,i=Q.getSelectedBranchSnapshot(e.state,t).filter(o=>!o.isLocked);if(i.length===0)throw Error("No selected shapes!");if(e.rotationInfo.selectedIds===n.selectedIds){if(e.rotationInfo.center===void 0)throw Error("We should have a center for rotation!");this.commonBoundsCenter=e.rotationInfo.center}else this.commonBoundsCenter=N.getBoundsCenter(N.getCommonBounds(i.map(Q.getBounds))),e.rotationInfo.selectedIds=n.selectedIds,e.rotationInfo.center=this.commonBoundsCenter;this.initialShapes=i.filter(o=>o.children===void 0).map(o=>({shape:o,center:this.app.getShapeUtil(o).getCenter(o)})),this.initialAngle=$.angle(this.commonBoundsCenter,r)}},pje=class extends lo{constructor(e,t=Yi.BottomRight,n=!1){super(e),this.transformType=t,this.isCreate=n,S(this,"type","transform"),S(this,"performanceMode"),S(this,"status","transforming"),S(this,"scaleX",1),S(this,"scaleY",1),S(this,"initialShapes"),S(this,"initialShapeIds"),S(this,"initialSelectedIds"),S(this,"shapeBounds"),S(this,"hasUnlockedShapes"),S(this,"isAllAspectRatioLocked"),S(this,"initialCommonBounds"),S(this,"snapInfo",{state:"empty"}),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"start",()=>{this.snapInfo={state:"ready",bounds:this.app.shapes.filter(a=>!this.initialShapeIds.includes(a.id)).map(a=>N.getBoundsWithCenter(Q.getRotatedBounds(a)))}}),S(this,"update",()=>{let{transformType:a,shapeBounds:s,initialCommonBounds:u,isAllAspectRatioLocked:d,app:{currentPageId:h,pageState:{camera:p},viewport:g,currentPoint:m,previousPoint:v,originPoint:E,shiftKey:w,altKey:C,metaKey:b,currentGrid:A,settings:{isSnapping:T,showGrid:B}}}=this,D={},I=C?$.mul($.sub(m,E),2):$.sub(m,E),M=N.getTransformedBoundingBox(u,a,I,0,w||d);C&&(M=_(_({},M),N.centerBounds(M,N.getBoundsCenter(u)))),B&&(M=_(_({},M),N.snapBoundsToGrid(M,A)));let O=$.dist(m,v)-this.speed;this.speed=this.speed+O*(O>1?.5:.15);let z=[];if((T&&!b||!T&&b)&&this.speed*p.zoom<10&&this.snapInfo.state==="ready"){let K=N.getSnapPoints(N.getBoundsWithCenter(M),this.snapInfo.bounds.filter(X=>N.boundsContain(g,X)||N.boundsCollide(g,X)),5/p.zoom);K&&(z=K.snapLines,M=N.getTransformedBoundingBox(u,a,$.sub(I,K.offset),0,w||d))}return this.scaleX=M.scaleX,this.scaleY=M.scaleY,s.forEach(({initialShape:K,initialShapeBounds:X,transformOrigin:Z})=>{let pe=N.getRelativeTransformedBoundingBox(M,u,X,this.scaleX<0,this.scaleY<0);B&&(pe=N.snapBoundsToGrid(pe,A));let me=Q.transform(this.app.getShape(K.id),pe,{type:this.transformType,initialShape:K,scaleX:this.scaleX,scaleY:this.scaleY,transformOrigin:Z});D[K.id]=me}),{appState:{snapLines:z},document:{pages:{[h]:{shapes:D}}}}}),S(this,"cancel",()=>{let{shapeBounds:a,app:{currentPageId:s}}=this,u={};return this.isCreate?a.forEach(d=>u[d.initialShape.id]=void 0):a.forEach(d=>u[d.initialShape.id]=d.initialShape),{appState:{snapLines:[]},document:{pages:{[s]:{shapes:u}},pageStates:{[s]:{selectedIds:this.isCreate?[]:a.map(d=>d.initialShape.id)}}}}}),S(this,"complete",()=>{let{isCreate:a,shapeBounds:s,hasUnlockedShapes:u,app:{currentPageId:d}}=this;if(!u)return;if(this.isCreate&&$.dist(this.app.originPoint,this.app.currentPoint)<2)return this.cancel();let h={},p={},g,m;return a?(g=[],m=[],s.forEach(({initialShape:v})=>{h[v.id]=void 0,p[v.id]=this.app.getShape(v.id)})):(g=this.initialSelectedIds,m=this.initialSelectedIds,s.forEach(({initialShape:v})=>{h[v.id]=v,p[v.id]=this.app.getShape(v.id)})),{id:"transform",before:{appState:{snapLines:[]},document:{pages:{[d]:{shapes:h}},pageStates:{[d]:{selectedIds:g,hoveredId:void 0,editingId:void 0}}}},after:{appState:{snapLines:[]},document:{pages:{[d]:{shapes:p}},pageStates:{[d]:{selectedIds:m,hoveredId:void 0,editingId:void 0}}}}}}),this.initialSelectedIds=[...this.app.selectedIds],this.app.rotationInfo.selectedIds=[...this.initialSelectedIds],this.initialShapes=Q.getSelectedBranchSnapshot(this.app.state,this.app.currentPageId).filter(a=>!a.isLocked),this.initialShapeIds=this.initialShapes.map(a=>a.id),this.hasUnlockedShapes=this.initialShapes.length>0,this.isAllAspectRatioLocked=this.initialShapes.every(a=>a.isAspectRatioLocked||Q.getShapeUtil(a).isAspectRatioLocked);let r=Object.fromEntries(this.initialShapes.map(a=>[a.id,Q.getBounds(a)])),i=Object.values(r);this.initialCommonBounds=N.getCommonBounds(i);let o=N.getBoundsFromPoints(i.map(N.getBoundsCenter));this.shapeBounds=this.initialShapes.map(a=>{let s=r[a.id],u=N.getBoundsCenter(s),d=(u[0]-o.minX)/o.width,h=(u[1]-o.minY)/o.height;return{initialShape:a,initialShapeBounds:s,transformOrigin:[d,h]}})}},gje=class extends lo{constructor(e,t,n,r=!1){super(e),S(this,"type","transformSingle"),S(this,"status","transforming"),S(this,"performanceMode"),S(this,"transformType"),S(this,"scaleX",1),S(this,"scaleY",1),S(this,"isCreate"),S(this,"initialShape"),S(this,"initialShapeBounds"),S(this,"initialCommonBounds"),S(this,"snapInfo",{state:"empty"}),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"start",()=>{this.snapInfo={state:"ready",bounds:this.app.shapes.filter(o=>o.id!==this.initialShape.id).map(o=>N.getBoundsWithCenter(Q.getRotatedBounds(o)))}}),S(this,"update",()=>{let{transformType:o,initialShape:a,initialShapeBounds:s,app:{settings:{isSnapping:u,showGrid:d},currentPageId:h,pageState:{camera:p},viewport:g,currentPoint:m,previousPoint:v,originPoint:E,currentGrid:w,shiftKey:C,altKey:b,metaKey:A}}=this;if(a.isLocked)return;let T={},B=b?$.mul($.sub(m,E),2):$.sub(m,E),D=this.app.getShape(a.id),I=Q.getShapeUtil(D),M=N.getTransformedBoundingBox(s,o,B,D.rotation,C||D.isAspectRatioLocked||I.isAspectRatioLocked);b&&(M=_(_({},M),N.centerBounds(M,N.getBoundsCenter(s)))),d&&(M=_(_({},M),N.snapBoundsToGrid(M,w)));let O=$.dist(m,v)-this.speed;this.speed=this.speed+O*(O>1?.5:.15);let z=[];if((u&&!A||!u&&A)&&!a.rotation&&this.speed*p.zoom<10&&this.snapInfo.state==="ready"){let X=N.getSnapPoints(N.getBoundsWithCenter(M),this.snapInfo.bounds.filter(Z=>N.boundsContain(g,Z)||N.boundsCollide(g,Z)),5/p.zoom);X&&(z=X.snapLines,M=N.getTransformedBoundingBox(s,o,$.sub(B,X.offset),D.rotation,C||D.isAspectRatioLocked||I.isAspectRatioLocked))}let K=Q.getShapeUtil(D).transformSingle(D,M,{initialShape:a,type:this.transformType,scaleX:M.scaleX,scaleY:M.scaleY,transformOrigin:[.5,.5]});return K&&(T[D.id]=K),d&&K&&K.point&&(K.point=$.snap(K.point,w)),{appState:{snapLines:z},document:{pages:{[h]:{shapes:T}}}}}),S(this,"cancel",()=>{let{initialShape:o,app:{currentPageId:a}}=this,s={};return this.isCreate?s[o.id]=void 0:s[o.id]=o,{appState:{snapLines:[]},document:{pages:{[a]:{shapes:s}},pageStates:{[a]:{selectedIds:this.isCreate?[]:[o.id]}}}}}),S(this,"complete",()=>{let{initialShape:o,app:{currentPageId:a}}=this;if(o.isLocked)return;if(this.isCreate&&$.dist(this.app.originPoint,this.app.currentPoint)<2)return this.cancel();let s={},u={};return s[o.id]=this.isCreate?void 0:o,u[o.id]=Q.onSessionComplete(this.app.getShape(o.id)),{id:"transform_single",before:{appState:{snapLines:[]},document:{pages:{[a]:{shapes:s}},pageStates:{[a]:{selectedIds:this.isCreate?[]:[o.id],editingId:void 0,hoveredId:void 0}}}},after:{appState:{snapLines:[]},document:{pages:{[a]:{shapes:u}},pageStates:{[a]:{selectedIds:[o.id],editingId:void 0,hoveredId:void 0}}}}}}),this.isCreate=r,this.transformType=n;let i=this.app.getShape(t);this.initialShape=i,this.initialShapeBounds=Q.getBounds(i),this.initialCommonBounds=Q.getRotatedBounds(i),this.app.rotationInfo.selectedIds=[i.id]}},mje=class extends lo{constructor(e,t=!1,n=!1){super(e),S(this,"performanceMode"),S(this,"type","translate"),S(this,"status","translating"),S(this,"delta",[0,0]),S(this,"prev",[0,0]),S(this,"prevPoint",[0,0]),S(this,"speed",1),S(this,"cloneInfo",{state:"empty"}),S(this,"snapInfo",{state:"empty"}),S(this,"snapLines",[]),S(this,"isCloning",!1),S(this,"isCreate"),S(this,"link"),S(this,"initialIds"),S(this,"hasUnlockedShapes"),S(this,"initialSelectedIds"),S(this,"initialCommonBounds"),S(this,"initialShapes"),S(this,"initialParentChildren"),S(this,"bindingsToDelete"),S(this,"start",()=>{let{bindingsToDelete:u,initialIds:d,app:{currentPageId:h,page:p}}=this,g=[],m=[];if(Object.values(p.shapes).forEach(w=>{let C=N.getBoundsWithCenter(Q.getRotatedBounds(w));g.push(C),d.has(w.id)||m.push(C)}),this.snapInfo={state:"ready",bounds:g,others:m},u.length===0)return;let v={},E={};return u.forEach(w=>{v[w.id]=void 0;let C=this.app.getShape(w.fromId);E[w.fromId]={handles:q(_({},C.handles),{[w.handleId]:q(_({},C.handles[w.handleId]),{bindingId:void 0})})}}),{document:{pages:{[h]:{bindings:v,shapes:E}}}}}),S(this,"update",()=>{let{initialParentChildren:u,initialShapes:d,initialCommonBounds:h,bindingsToDelete:p,app:{pageState:{camera:g},settings:{isSnapping:m,showGrid:v},currentPageId:E,viewport:w,selectedIds:C,currentPoint:b,previousPoint:A,originPoint:T,altKey:B,shiftKey:D,metaKey:I,currentGrid:M}}=this,O={},z={},K={},X=$.sub(b,T),Z=!1;this.isCreate||(B&&!this.isCloning?(this.isCloning=!0,Z=!0):!B&&this.isCloning&&(this.isCloning=!1,Z=!0)),D&&(Math.abs(X[0])1?.5:.15),this.snapLines=[],(m&&!I||!m&&I)&&this.speed*g.zoom<10&&this.snapInfo.state==="ready"){let me=N.getSnapPoints(N.getBoundsWithCenter(v?N.snapBoundsToGrid(N.translateBounds(h,X),M):N.translateBounds(h,X)),(this.isCloning?this.snapInfo.bounds:this.snapInfo.others).filter(Ce=>N.boundsContain(w,Ce)||N.boundsCollide(w,Ce)),5/g.zoom);me&&(this.snapLines=me.snapLines,X=$.sub(X,me.offset))}if(this.prev=X,this.isCloning)if(Z){if(this.cloneInfo.state==="empty"&&this.createCloneInfo(),this.cloneInfo.state==="empty")throw Error;let{clones:me,clonedBindings:Ce}=this.cloneInfo;this.isCloning=!0,p.forEach(W=>O[W.id]=W),d.forEach(W=>z[W.id]={point:W.point}),me.forEach(W=>{var U;if(z[W.id]=_({},W),W.parentId!==E&&!C.includes(W.parentId)){let ne=((U=z[W.parentId])==null?void 0:U.children)||u[W.parentId];ne.includes(W.id)||(z[W.parentId]=q(_({},z[W.parentId]),{children:[...ne,W.id]}))}});for(let W of Ce)O[W.id]=W;K.selectedIds=me.map(W=>W.id),me.forEach(W=>{z[W.id]=q(_({},W),{point:v?$.snap($.toFixed($.add(W.point,X)),M):$.toFixed($.add(W.point,X))})})}else{if(this.cloneInfo.state==="empty")throw Error;let{clones:me}=this.cloneInfo;me.forEach(Ce=>{z[Ce.id]={point:v?$.snap($.toFixed($.add(Ce.point,X)),M):$.toFixed($.add(Ce.point,X))}})}else if(Z){if(this.cloneInfo.state==="empty")throw Error;let{clones:me,clonedBindings:Ce}=this.cloneInfo;this.isCloning=!1,p.forEach(W=>O[W.id]=void 0),me.forEach(W=>{W.parentId!==E&&(z[W.parentId]=q(_({},z[W.parentId]),{children:u[W.parentId]}))}),me.forEach(W=>z[W.id]=void 0),d.forEach(W=>{z[W.id]={point:v?$.snap($.toFixed($.add(W.point,X)),M):$.toFixed($.add(W.point,X))}});for(let W of Ce)O[W.id]=void 0;K.selectedIds=d.map(W=>W.id)}else d.forEach(me=>{z[me.id]={point:v?$.snap($.toFixed($.add(me.point,X)),M):$.toFixed($.add(me.point,X))}});return{appState:{snapLines:this.snapLines},document:{pages:{[E]:{shapes:z,bindings:O}},pageStates:{[E]:K}}}}),S(this,"cancel",()=>{let{initialShapes:u,initialSelectedIds:d,bindingsToDelete:h,app:{currentPageId:p}}=this,g={},m={},v={editingId:void 0,hoveredId:void 0};if(this.isCreate?(u.forEach(({id:E})=>m[E]=void 0),v.selectedIds=[]):(u.forEach(({id:E,point:w,handles:C})=>m[E]=C?q(_({},m[E]),{point:w,handles:C}):q(_({},m[E]),{point:w})),v.selectedIds=d,h.forEach(E=>{g[E.id]=E})),this.cloneInfo.state==="ready"){let{clones:E,clonedBindings:w}=this.cloneInfo;E.forEach(C=>m[C.id]=void 0),w.forEach(C=>g[C.id]=void 0)}return{appState:{snapLines:[]},document:{pages:{[p]:{shapes:m,bindings:g}},pageStates:{[p]:v}}}}),S(this,"complete",()=>{let{initialShapes:u,initialParentChildren:d,bindingsToDelete:h,app:{currentPageId:p}}=this,g={},m={},v={},E={};if(this.isCloning){if(this.cloneInfo.state==="empty"&&this.createCloneInfo(),this.cloneInfo.state!=="ready")throw Error;let{clones:w,clonedBindings:C}=this.cloneInfo;w.forEach(b=>{m[b.id]=void 0,E[b.id]=this.app.getShape(b.id),b.parentId!==p&&(m[b.parentId]=q(_({},m[b.parentId]),{children:d[b.parentId]}),E[b.parentId]=q(_({},E[b.parentId]),{children:this.app.getShape(b.parentId).children}))}),C.forEach(b=>{g[b.id]=void 0,v[b.id]=this.app.getBinding(b.id)})}else u.forEach(w=>{m[w.id]=this.isCreate?void 0:q(_({},m[w.id]),{point:w.point}),E[w.id]=_(_({},E[w.id]),this.isCreate?this.app.getShape(w.id):{point:this.app.getShape(w.id).point})});return h.forEach(w=>{var C,b,A,T,B;g[w.id]=w,m[w.fromId]=q(_({},m[w.fromId]),{id:w.fromId,handles:q(_({},(C=m[w.fromId])==null?void 0:C.handles),{[w.handleId]:q(_({},(A=(b=m[w.fromId])==null?void 0:b.handles)==null?void 0:A[w.handleId]),{bindingId:w.id})})}),E[w.fromId]=q(_({},E[w.fromId]),{id:w.fromId,handles:q(_({},E[w.fromId].handles),{[w.handleId]:q(_({},(B=(T=E[w.fromId])==null?void 0:T.handles)==null?void 0:B[w.handleId]),{bindingId:void 0})})})}),h.forEach(w=>v[w.id]=void 0),{id:"translate",before:{appState:{snapLines:[]},document:{pages:{[p]:{shapes:m,bindings:g}},pageStates:{[p]:{selectedIds:this.isCreate?[]:[...this.initialSelectedIds]}}}},after:{appState:{snapLines:[]},document:{pages:{[p]:{shapes:E,bindings:v}},pageStates:{[p]:{selectedIds:[...this.app.selectedIds]}}}}}}),S(this,"createCloneInfo",()=>{let{initialShapes:u,initialParentChildren:d,app:{selectedIds:h,currentPageId:p,page:g}}=this,m={},v={},E=[],w=[];u.forEach(b=>{let A=N.uniqueId();d[A]=d[b.id],m[b.id]=A;let T=q(_({},N.deepClone(b)),{id:A,parentId:b.parentId,childIndex:Q.getChildIndexAbove(this.app.state,b.id,p)});if(T.type==="video"){let B=document.getElementById(b.id+"_video");B&&(T.currentTime=(B.currentTime+16)%B.duration)}w.push(T)}),w.forEach(b=>{b.children!==void 0&&(b.children=b.children.map(A=>m[A]))}),w.forEach(b=>{h.includes(b.parentId)&&(b.parentId=m[b.parentId])});let C=new Set(Object.keys(m));Object.values(g.bindings).filter(b=>C.has(b.fromId)||C.has(b.toId)).forEach(b=>{if(C.has(b.fromId)&&C.has(b.toId)){let A=N.uniqueId(),T=q(_({},N.deepClone(b)),{id:A,fromId:m[b.fromId]||b.fromId,toId:m[b.toId]||b.toId});v[b.id]=A,E.push(T)}}),w.forEach(b=>{if(b.handles&&b.handles)for(let A in b.handles){let T=b.handles[A];T.bindingId=T.bindingId?v[T.bindingId]:void 0}}),w.forEach(b=>{if(g.shapes[b.id])throw Error("uh oh, we didn't clone correctly")}),this.cloneInfo={state:"ready",clones:w,cloneMap:m,clonedBindings:E}}),this.isCreate=t,this.link=n;let{currentPageId:r,selectedIds:i,page:o}=this.app;this.initialSelectedIds=[...i];let a=(n?Q.getLinkedShapeIds(this.app.state,r,n,!1):i).map(u=>this.app.getShape(u)).filter(u=>!u.isLocked),s=new Set(a.map(u=>u.id));this.hasUnlockedShapes=a.length>0,this.initialShapes=Array.from(new Set(a.filter(u=>!s.has(u.parentId)).flatMap(u=>u.children?[u,...u.children.map(d=>this.app.getShape(d))]:[u])).values()),this.initialIds=new Set(this.initialShapes.map(u=>u.id)),this.bindingsToDelete=[],Object.values(o.bindings).filter(u=>this.initialIds.has(u.fromId)||this.initialIds.has(u.toId)).forEach(u=>{this.initialIds.has(u.fromId)&&(this.initialIds.has(u.toId)||this.bindingsToDelete.push(u))}),this.initialParentChildren={},this.initialShapes.map(u=>u.parentId).filter(u=>u!==o.id).forEach(u=>{this.initialParentChildren[u]=this.app.getShape(u).children}),this.initialCommonBounds=N.getCommonBounds(this.initialShapes.map(Q.getRotatedBounds)),this.app.rotationInfo.selectedIds=[...this.app.selectedIds]}},vje={arrow:aje,brush:sje,draw:uje,erase:cje,handle:hje,rotate:fje,transform:pje,transformSingle:gje,translate:mje,grid:dje,edit:lje},yje=e=>vje[e],Go=class extends vne{constructor(e){super(),this.app=e,S(this,"type","select"),S(this,"previous"),S(this,"status","idle"),S(this,"setStatus",t=>{this.status=t,this.app.setStatus(this.status)}),S(this,"onEnter",()=>{this.setStatus("idle")}),S(this,"onExit",()=>{this.setStatus("idle")}),S(this,"onCancel",()=>{this.status==="idle"?this.app.selectTool("select"):this.setStatus("idle"),this.app.cancelSession()}),S(this,"getNextChildIndex",()=>{let{shapes:t,appState:{currentPageId:n}}=this.app;return t.length===0?1:t.filter(r=>r.parentId===n).sort((r,i)=>i.childIndex-r.childIndex)[0].childIndex+1}),S(this,"onPinchStart",()=>{this.app.cancelSession(),this.setStatus("pinching")}),S(this,"onPinchEnd",()=>{N.isMobileSafari()&&this.app.undoSelect(),this.setStatus("idle")}),S(this,"onPinch",(t,n)=>{var r;this.status==="pinching"&&(isNaN(t.delta[0])||isNaN(t.delta[1])||(this.app.pinchZoom(t.point,t.delta,t.delta[2]),(r=this.onPointerMove)==null||r.call(this,t,n)))}),S(this,"onKeyDown",t=>{if(t==="Escape"){this.onCancel();return}if(t==="Meta"||t==="Control"||t==="Alt"){this.app.updateSession();return}}),S(this,"onKeyUp",t=>{if(t==="Meta"||t==="Control"||t==="Alt"){this.app.updateSession();return}}),S(this,"onPointerMove",()=>{this.status==="creating"&&this.app.updateSession()}),S(this,"onPointerUp",()=>{if(this.status==="creating"){this.app.completeSession();let{isToolLocked:t}=this.app.appState;t||this.app.selectTool("select")}this.setStatus("idle")})}},Eje=class extends Go{constructor(){super(...arguments),S(this,"type","arrow"),S(this,"onPointerDown",()=>{if(this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=MC.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("arrow",s.id,"end",!0),this.setStatus("creating")})}},Cje=class extends Go{constructor(){super(...arguments),S(this,"type","draw"),S(this,"lastShapeId"),S(this,"onEnter",()=>{this.lastShapeId=void 0}),S(this,"onCancel",()=>{switch(this.status){case"idle":{this.app.selectTool("select");break}default:{this.setStatus("idle");break}}this.app.cancelSession()}),S(this,"onPointerDown",e=>{if(this.status!=="idle"||this.app.readOnly)return;let{currentPoint:t,appState:{currentPageId:n,currentStyle:r}}=this.app,i=this.lastShapeId&&this.app.getShape(this.lastShapeId);if(e.shiftKey&&i)this.app.startSession("draw",i.id),this.setStatus("extending");else{let o=this.getNextChildIndex(),a=N.uniqueId(),s=WT.create({id:a,parentId:n,childIndex:o,point:t,style:_({},r)});this.lastShapeId=a,this.app.patchCreate([s]),this.app.startSession("draw",a),this.setStatus("creating")}}),S(this,"onPointerMove",()=>{if(!this.app.readOnly)switch(this.status){case"extending":case"creating":this.app.updateSession()}}),S(this,"onPointerUp",()=>{this.app.completeSession(),this.setStatus("idle")})}},bje=class extends Go{constructor(){super(...arguments),S(this,"type","ellipse"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=JT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},wje=class extends Go{constructor(){super(...arguments),S(this,"type","erase"),S(this,"status","idle"),S(this,"onPointerDown",()=>{this.app.readOnly||this.status==="idle"&&this.setStatus("pointing")}),S(this,"onPointerMove",e=>{if(!this.app.readOnly)switch(this.status){case"pointing":{se.dist(e.origin,e.point)>3&&(this.app.startSession("erase"),this.app.updateSession(),this.setStatus("erasing"));break}case"erasing":this.app.updateSession()}}),S(this,"onPointerUp",()=>{if(!this.app.readOnly){switch(this.status){case"pointing":{let e=this.app.shapes.filter(t=>!t.isLocked).filter(t=>this.app.getShapeUtil(t).hitTestPoint(t,this.app.currentPoint)).flatMap(t=>t.children?[t.id,...t.children]:t.id);this.app.delete(e);break}case"erasing":this.app.completeSession()}this.setStatus("idle")}}),S(this,"onCancel",()=>{this.status==="idle"?this.previous?this.app.selectTool(this.previous):this.app.selectTool("select"):this.setStatus("idle"),this.app.cancelSession()})}},Sje=class extends Go{constructor(){super(...arguments),S(this,"type","line"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=MC.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,decorations:{start:void 0,end:void 0},style:_({},i)});this.app.patchCreate([s]),this.app.startSession("arrow",s.id,"end",!0),this.setStatus("creating")})}},xje=class extends Go{constructor(){super(...arguments),S(this,"type","rectangle"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=VT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},Aje=class extends Go{constructor(){super(...arguments),S(this,"type","select"),S(this,"pointedId"),S(this,"selectedGroupId"),S(this,"pointedHandleId"),S(this,"pointedBoundsHandle"),S(this,"pointedLinkHandleId"),S(this,"onEnter",()=>{this.setStatus("idle")}),S(this,"onExit",()=>{this.setStatus("idle")}),S(this,"clonePaint",e=>{if(this.app.selectedIds.length===0)return;let t=this.app.selectedIds.map(s=>this.app.getShape(s)),n=N.expandBounds(N.getCommonBounds(t.map(Q.getBounds)),16),r=N.getBoundsCenter(n),i=[n.width,n.height],o=[r[0]+i[0]*Math.floor((e[0]+i[0]/2-r[0])/i[0]),r[1]+i[1]*Math.floor((e[1]+i[1]/2-r[1])/i[1])],a=N.centerBounds(n,o);this.app.shapes.some(s=>Q.getShapeUtil(s).hitTestBounds(s,a))||this.app.duplicate(this.app.selectedIds,o)}),S(this,"getShapeClone",(e,t)=>{let n=this.app.getShape(e),r=Q.getShapeUtil(n);if(r.canClone){let i=r.getBounds(n),o=r.getCenter(n),a={top:[i.minX,i.minY-(i.height+32)],right:[i.maxX+32,i.minY],bottom:[i.minX,i.maxY+32],left:[i.minX-(i.width+32),i.minY],topLeft:[i.minX-(i.width+32),i.minY-(i.height+32)],topRight:[i.maxX+32,i.minY-(i.height+32)],bottomLeft:[i.minX-(i.width+32),i.maxY+32],bottomRight:[i.maxX+32,i.maxY+32]}[t];if(n.rotation!==0){let d=se.add(a,[i.width/2,i.height/2]),h=se.rotWith(d,o,n.rotation||0);a=se.sub(h,[i.width/2,i.height/2])}let s=N.uniqueId(),u=q(_({},n),{id:s,point:a});return u.type==="sticky"&&(u.text=""),u}}),S(this,"onCancel",()=>{this.app.session?this.app.cancelSession():this.selectNone(),this.setStatus("idle")}),S(this,"onKeyDown",(e,t,n)=>{switch(e){case"Escape":{this.onCancel();break}case"Tab":{if(this.app.readOnly)return;if(!this.app.pageState.editingId&&this.status==="idle"&&this.app.selectedIds.length===1){let[r]=this.app.selectedIds,i=this.getShapeClone(r,"right");i&&(this.app.createShapes(i),this.setStatus("idle"),i.type==="sticky"&&(this.app.select(i.id),this.app.setEditingId(i.id)))}break}case"Meta":case"Control":case"Alt":{this.app.updateSession();break}case"Enter":{if(this.app.readOnly)return;let{pageState:r}=this.app;r.selectedIds.length===1&&!r.editingId&&(this.app.setEditingId(r.selectedIds[0]),n.preventDefault())}}}),S(this,"onKeyUp",(e,t)=>{if(this.status==="clonePainting"&&!(t.altKey&&t.shiftKey)){this.setStatus("idle");return}if(e==="Meta"||e==="Control"||e==="Alt"){this.app.updateSession();return}}),S(this,"onPointerMove",()=>{let{originPoint:e,currentPoint:t}=this.app;if(this.app.readOnly&&this.app.isPointing){this.app.session?this.app.updateSession():se.dist(e,t)>3&&(this.app.startSession("brush"),this.setStatus("brushing"));return}switch(this.status){case"pointingBoundsHandle":{if(!this.pointedBoundsHandle)throw Error("No pointed bounds handle");if(se.dist(e,t)>3){if(this.pointedBoundsHandle==="rotate")this.setStatus("rotating"),this.app.startSession("rotate");else if(this.pointedBoundsHandle==="center"||this.pointedBoundsHandle==="left"||this.pointedBoundsHandle==="right")this.setStatus("translating"),this.app.startSession("translate",!1,this.pointedBoundsHandle);else{this.setStatus("transforming");let n=this.app.selectedIds.flatMap(r=>Q.getDocumentBranch(this.app.state,r,this.app.currentPageId));n.length===1?this.app.startSession("transformSingle",n[0],this.pointedBoundsHandle):this.app.startSession("transform",this.pointedBoundsHandle)}this.app.updateSession()}break}case"pointingCanvas":{se.dist(e,t)>3&&(this.app.startSession("brush"),this.setStatus("brushing"));break}case"pointingClone":{se.dist(e,t)>3&&(this.setStatus("translatingClone"),this.app.startSession("translate"),this.app.updateSession());break}case"pointingBounds":{se.dist(e,t)>3&&(this.setStatus("translating"),this.app.startSession("translate"),this.app.updateSession());break}case"pointingHandle":{if(!this.pointedHandleId)throw Error("No pointed handle");if(se.dist(e,t)>3){this.setStatus("translatingHandle");let n=this.app.getShape(this.app.selectedIds[0]);n&&(this.pointedHandleId==="bend"?(this.app.startSession("handle",n.id,this.pointedHandleId),this.app.updateSession()):(this.app.startSession("arrow",n.id,this.pointedHandleId,!1),this.app.updateSession()))}break}case"clonePainting":{this.clonePaint(t);break}default:if(this.app.session){this.app.updateSession();break}}}),S(this,"onPointerDown",(e,t)=>{if(e.target==="canvas"&&this.status==="idle"){let{currentPoint:n}=this.app;if(e.spaceKey&&t.buttons===1)return;if(this.status==="idle"&&e.altKey&&e.shiftKey){this.setStatus("clonePainting"),this.clonePaint(n);return}if(!e.shiftKey){if(this.app.onShapeBlur(),e.altKey&&this.app.selectedIds.length>0){this.app.duplicate(this.app.selectedIds,n);return}this.selectNone()}this.setStatus("pointingCanvas")}}),S(this,"onPointerUp",e=>{var t;if(this.status==="translatingClone"||this.status==="pointingClone"){this.pointedId&&(this.app.completeSession(),this.app.setEditingId(this.pointedId)),this.setStatus("idle"),this.pointedId=void 0;return}if(this.status==="pointingBounds"){if(e.target==="bounds")this.selectNone();else if(this.app.isSelected(e.target))e.shiftKey?this.pointedId!==e.target&&this.deselect(e.target):this.pointedId!==e.target&&this.app.selectedIds.length>1&&this.select(e.target);else if(this.pointedId===e.target){if(this.app.getShape(e.target).isLocked)return;e.shiftKey?this.pushSelect(e.target):this.select(e.target)}}this.setStatus("idle"),this.pointedBoundsHandle=void 0,this.pointedHandleId=void 0,this.pointedId=void 0,((t=this.app.session)==null?void 0:t.type)!=="edit"&&this.app.completeSession()}),S(this,"onDoubleClickCanvas",()=>{this.app.readOnly}),S(this,"onPointShape",(e,t)=>{if(e.spaceKey&&t.buttons===1||this.app.getShape(e.target).isLocked)return;let{editingId:n,hoveredId:r}=this.app.pageState;if(n&&e.target!==n&&this.app.onShapeBlur(),(this.status==="idle"||this.status==="pointingBounds")&&e.metaKey&&e.shiftKey&&r){this.pointedId=r,this.app.isSelected(r)?this.deselect(r):(this.pushSelect(r),this.setStatus("pointingBounds"));return}if(this.status==="pointingBounds"){let{parentId:i}=this.app.getShape(e.target);this.pointedId=i===this.app.currentPageId?e.target:i;return}if(this.status==="idle"){if(this.setStatus("pointingBounds"),e.metaKey){e.shiftKey||this.selectNone(),this.app.startSession("brush"),this.setStatus("brushing");return}let i,{parentId:o}=this.app.getShape(e.target);o===this.app.currentPageId?(i=e.target,this.selectedGroupId=void 0):o===this.selectedGroupId?i=e.target:(i=o,this.selectedGroupId=void 0),this.app.isSelected(i)||(this.pointedId=i,e.shiftKey?this.pushSelect(i):this.select(i))}}),S(this,"onDoubleClickShape",e=>{if(this.app.readOnly)return;let t=this.app.getShape(e.target);if(t.isLocked){this.app.select(e.target);return}Q.getShapeUtil(t.type).canEdit&&(t.parentId===this.app.currentPageId||t.parentId===this.selectedGroupId)&&this.app.setEditingId(e.target),t.parentId!==this.app.currentPageId&&(this.selectedGroupId=t.parentId),this.app.select(e.target)}),S(this,"onRightPointShape",e=>{this.app.isSelected(e.target)||this.app.select(e.target)}),S(this,"onHoverShape",e=>{this.app.setHoveredId(e.target)}),S(this,"onUnhoverShape",e=>{let{currentPageId:t}=this.app;requestAnimationFrame(()=>{t===this.app.currentPageId&&this.app.pageState.hoveredId===e.target&&this.app.setHoveredId(void 0)})}),S(this,"onPointBounds",e=>{if(e.metaKey){e.shiftKey||this.selectNone(),this.app.startSession("brush"),this.setStatus("brushing");return}this.setStatus("pointingBounds")}),S(this,"onRightPointBounds",(e,t)=>{t.stopPropagation()}),S(this,"onReleaseBounds",()=>{(this.status==="translating"||this.status==="brushing")&&this.app.completeSession(),this.setStatus("idle")}),S(this,"onPointBoundsHandle",e=>{this.pointedBoundsHandle=e.target,this.setStatus("pointingBoundsHandle")}),S(this,"onDoubleClickBoundsHandle",e=>{switch(e.target){case"center":case"left":case"right":{this.app.select(...Q.getLinkedShapeIds(this.app.state,this.app.currentPageId,e.target,e.shiftKey));break}default:if(this.app.selectedIds.length===1){this.app.resetBounds(this.app.selectedIds);let t=this.app.getShape(this.app.selectedIds[0]);"label"in t&&this.app.setEditingId(t.id)}}}),S(this,"onReleaseBoundsHandle",()=>{this.setStatus("idle")}),S(this,"onPointHandle",e=>{this.pointedHandleId=e.target,this.setStatus("pointingHandle")}),S(this,"onDoubleClickHandle",e=>{if(e.target==="bend"){let{selectedIds:t}=this.app;if(t.length!==1)return;let n=this.app.getShape(t[0]);Q.getShapeUtil(n.type).canEdit&&(n.parentId===this.app.currentPageId||n.parentId===this.selectedGroupId)&&this.app.setEditingId(n.id);return}this.app.toggleDecoration(e.target)}),S(this,"onReleaseHandle",()=>{this.setStatus("idle")}),S(this,"onShapeClone",e=>{let t=this.app.selectedIds[0],n=this.getShapeClone(t,e.target);e.target==="left"||e.target==="right"||e.target==="top"||e.target==="bottom"?n&&(this.app.createShapes(n),this.pointedId=n.id,this.setStatus("pointingClone")):(this.setStatus("gridCloning"),this.app.startSession("grid",t))})}deselect(e){this.app.select(...this.app.selectedIds.filter(t=>t!==e))}select(e){this.app.select(e)}pushSelect(e){let t=this.app.getShape(e);this.app.select(...this.app.selectedIds.filter(n=>n!==t.parentId),e)}selectNone(){this.app.selectNone()}},kje=class extends Go{constructor(){super(...arguments),S(this,"type","sticky"),S(this,"shapeId"),S(this,"onPointerDown",()=>{if(!this.app.readOnly){if(this.status==="creating"){this.setStatus("idle"),this.app.appState.isToolLocked||this.app.selectTool("select");return}if(this.status==="idle"){let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId();this.shapeId=a;let s=Gy.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)}),u=Gy.getBounds(s);s.point=se.sub(s.point,[u.width/2,u.height/2]),this.app.patchCreate([s]),this.app.startSession("translate"),this.setStatus("creating")}}}),S(this,"onPointerUp",()=>{this.app.readOnly||this.status==="creating"&&(this.setStatus("idle"),this.app.completeSession(),this.app.selectTool("select"),this.app.setEditingId(this.shapeId))})}},Ije=class extends Go{constructor(){super(...arguments),S(this,"type","text"),S(this,"stopEditingShape",()=>{this.setStatus("idle"),this.app.appState.isToolLocked||this.app.selectTool("select")}),S(this,"onKeyUp",()=>{}),S(this,"onKeyDown",()=>{}),S(this,"onPointerDown",()=>{if(this.status==="creating"){this.stopEditingShape();return}if(this.status==="idle"){let{currentPoint:e,currentGrid:t,settings:{showGrid:n}}=this.app;this.app.createTextShapeAtPoint(n?se.snap(e,t):e,void 0,!0),this.setStatus("creating");return}}),S(this,"onPointerUp",()=>{}),S(this,"onPointShape",e=>{if(this.app.readOnly)return;let t=this.app.getShape(e.target);t.type==="text"&&(this.setStatus("idle"),this.app.setEditingId(t.id))}),S(this,"onShapeBlur",()=>{this.app.readOnly||this.stopEditingShape()})}},Dje=class extends Go{constructor(){super(...arguments),S(this,"type","triangle"),S(this,"onPointerDown",()=>{if(this.app.readOnly||this.status!=="idle")return;let{currentPoint:e,currentGrid:t,settings:{showGrid:n},appState:{currentPageId:r,currentStyle:i}}=this.app,o=this.getNextChildIndex(),a=N.uniqueId(),s=GT.create({id:a,parentId:r,childIndex:o,point:n?se.snap(e,t):e,style:_({},i)});this.app.patchCreate([s]),this.app.startSession("transformSingle",s.id,Yi.BottomRight,!0),this.setStatus("creating")})}},Zv=N.uniqueId(),yn=class extends RHe{constructor(e,t={}){super(yn.defaultState,e,yn.version,(n,r,i)=>ia(q(_({},r),{document:q(_(_({},r.document),n.document),{version:i})}),yn.version)),S(this,"callbacks",{}),S(this,"tools",{select:new Aje(this),erase:new wje(this),text:new Ije(this),draw:new Cje(this),ellipse:new bje(this),rectangle:new xje(this),triangle:new Dje(this),line:new Sje(this),arrow:new Eje(this),sticky:new kje(this)}),S(this,"currentTool",this.tools.select),S(this,"session"),S(this,"readOnly",!1),S(this,"isDirty",!1),S(this,"isCreating",!1),S(this,"originPoint",[0,0]),S(this,"currentPoint",[0,0]),S(this,"previousPoint",[0,0]),S(this,"shiftKey",!1),S(this,"altKey",!1),S(this,"metaKey",!1),S(this,"ctrlKey",!1),S(this,"spaceKey",!1),S(this,"isPointing",!1),S(this,"isForcePanning",!1),S(this,"isErasingWithPen",!1),S(this,"isPastePrevented",!1),S(this,"editingStartTime",-1),S(this,"fileSystemHandle",null),S(this,"viewport",N.getBoundsFromPoints([[0,0],[100,100]])),S(this,"rendererBounds",N.getBoundsFromPoints([[0,0],[100,100]])),S(this,"selectHistory",{stack:[[]],pointer:0}),S(this,"clipboard"),S(this,"rotationInfo",{selectedIds:[],center:[0,0]}),S(this,"migrate",n=>ia(n,yn.version)),S(this,"onReady",()=>{var n,r;this.loadDocument(this.document),XT().then(i=>{this.fileSystemHandle=i});try{this.patchState(q(_({},ia(this.state,yn.version)),{appState:{status:"idle"}}))}catch(i){console.error("The data appears to be corrupted. Resetting!",i),localStorage.setItem(this.document.id+"_corrupted",JSON.stringify(this.document)),this.patchState(q(_({},yn.defaultState),{appState:q(_({},yn.defaultState.appState),{status:"idle"})}))}(r=(n=this.callbacks).onMount)==null||r.call(n,this)}),S(this,"cleanup",(n,r)=>{var i;let o=_({},n);o.document!==r.document&&Object.entries(o.document.pages).forEach(([u,d])=>{if(d===void 0){delete o.document.pages[u],delete o.document.pageStates[u];return}let h=r.document.pages[u],p={};if(!h||d.shapes!==h.shapes||d.bindings!==h.bindings){d.shapes=_({},d.shapes),d.bindings=_({},d.bindings);let m=new Set;Object.entries(d.shapes).forEach(([w,C])=>{var b;let A;C?A=C.parentId:(A=(b=h==null?void 0:h.shapes[w])==null?void 0:b.parentId,delete d.shapes[w]),d.id===o.appState.currentPageId&&(h==null?void 0:h.shapes[w])!==C&&(p[w]=C),A&&A!==u&&d.shapes[A]!==void 0&&m.add(d.shapes[A])}),Object.keys(d.bindings).forEach(w=>{d.bindings[w]||delete d.bindings[w]}),o.document.pages[u]=d;let v=Q.getRelatedBindings(o,Object.keys(p),u),E=new Set;v.forEach(w=>{if(!d.bindings[w.id])return;let C=d.shapes[w.toId],b=d.shapes[w.fromId];if(!(C&&b)){delete o.document.pages[u].bindings[w.id];return}if(E.has(b))return;let A=Q.updateArrowBindings(d,b);if(E.add(b),A){let T=_(_({},b),A);d.shapes[b.id]=T}}),m.forEach(w=>{if(!w)throw Error("no group!");let C=w.children.filter(A=>d.shapes[A]!==void 0),b=N.getCommonBounds(C.map(A=>d.shapes[A]).filter(Boolean).map(A=>Q.getRotatedBounds(A)));d.shapes[w.id]=q(_({},w),{point:[b.minX,b.minY],size:[b.width,b.height],children:C})})}let g=_({},o.document.pageStates[u]);g.brush||delete g.brush,g.hoveredId&&!d.shapes[g.hoveredId]&&delete g.hoveredId,g.bindingId&&!d.bindings[g.bindingId]&&(Q.warn(`Could not find the binding of ${u}`),delete g.bindingId),g.editingId&&!d.shapes[g.editingId]&&(Q.warn("Could not find the editing shape!"),delete g.editingId),o.document.pageStates[u]=g}),Object.keys((i=o.document.assets)!=null?i:{}).forEach(u=>{var d,h;(d=o.document.assets)!=null&&d[u]||(h=o.document.assets)==null||delete h[u]});let a=o.appState.currentPageId,s=o.document.pageStates[a];if(o.room&&o.room!==r.room){let u=q(_({},o.room),{users:_({},o.room.users)});r.room&&Object.values(r.room.users).filter(Boolean).forEach(d=>{u.users[d.id]===void 0&&delete u.users[d.id]}),o.room=u}return o.room&&(o.room.users[o.room.userId]=q(_({},o.room.users[o.room.userId]),{point:this.currentPoint,selectedIds:s.selectedIds})),this.readOnly&&(o.document.pages=r.document.pages),o}),S(this,"broadcastPatch",(n,r)=>{var i,o,a,s,u,d,h,p,g;let m={},v={},E={},w=(a=(o=(i=n==null?void 0:n.document)==null?void 0:i.pages)==null?void 0:o[this.currentPageId])==null?void 0:a.shapes,C=(d=(u=(s=n==null?void 0:n.document)==null?void 0:s.pages)==null?void 0:u[this.currentPageId])==null?void 0:d.bindings,b=(h=n==null?void 0:n.document)==null?void 0:h.assets;w&&Object.keys(w).forEach(A=>{m[A]=this.getShape(A,this.currentPageId)}),C&&Object.keys(C).forEach(A=>{v[A]=this.getBinding(A,this.currentPageId)}),b&&Object.keys(b).forEach(A=>{E[A]=this.document.assets[A]}),(g=(p=this.callbacks).onChangePage)==null||g.call(p,this,m,v,E,r)}),S(this,"onPatch",(n,r,i)=>{var o,a,s,u,d,h;(this.callbacks.onChangePage&&((a=(o=r==null?void 0:r.document)==null?void 0:o.pages)!=null&&a[this.currentPageId])||(s=r==null?void 0:r.document)!=null&&s.assets)&&((u=r==null?void 0:r.document)!=null&&u.assets||this.session&&this.session.type!=="brush"&&this.session.type!=="erase"&&this.session.type!=="draw")&&this.broadcastPatch(r,!1),(h=(d=this.callbacks).onPatch)==null||h.call(d,this,r,i)}),S(this,"onCommand",(n,r,i)=>{var o,a;this.clearSelectHistory(),this.isDirty=!0,(a=(o=this.callbacks).onCommand)==null||a.call(o,this,r,i)}),S(this,"onReplace",()=>{this.clearSelectHistory(),this.isDirty=!1}),S(this,"onUndo",()=>{var n,r;this.rotationInfo.selectedIds=[...this.selectedIds],(r=(n=this.callbacks).onUndo)==null||r.call(n,this)}),S(this,"onRedo",()=>{var n,r;this.rotationInfo.selectedIds=[...this.selectedIds],(r=(n=this.callbacks).onRedo)==null||r.call(n,this)}),S(this,"onPersist",(n,r)=>{var i,o;(o=(i=this.callbacks).onPersist)==null||o.call(i,this),this.broadcastPatch(r,!0)}),S(this,"prevSelectedIds",this.selectedIds),S(this,"onStateDidChange",(n,r)=>{var i,o,a,s;(o=(i=this.callbacks).onChange)==null||o.call(i,this,r),this.room&&this.selectedIds!==this.prevSelectedIds&&((s=(a=this.callbacks).onChangePresence)==null||s.call(a,this,q(_({},this.room.users[this.room.userId]),{selectedIds:this.selectedIds,session:!!this.session})),this.prevSelectedIds=this.selectedIds)}),S(this,"preventPaste",()=>{if(this.isPastePrevented)return;let n=i=>i.stopImmediatePropagation(),r=()=>{setTimeout(()=>{document.removeEventListener("paste",n,{capture:!0}),this.isPastePrevented=!1},50)};document.addEventListener("paste",n,{capture:!0}),window.addEventListener("pointerup",r,{once:!0}),this.isPastePrevented=!0}),S(this,"justSent",!1),S(this,"getReservedContent",(n,r=this.currentPageId)=>{let{bindings:i}=this.document.pages[r],o={},a={},s=Object.values(i),u=new Map(s.map(v=>[v.toId,v])),d=new Map(s.map(v=>[v.fromId,v])),h=[u,d],p=[];this.session&&n.forEach(v=>p.push(v)),this.pageState.editingId&&p.push(this.pageState.editingId);let g=new Set(p),m=new Set;for(;p.length>0;){let v=p.pop();if(!v)break;if(m.has(v))continue;m.add(v);let E=this.getShape(v);o[v]=E,E.parentId!==r&&p.push(E.parentId),E.children&&p.push(...E.children),h.map(w=>w.get(E.id)).filter(Boolean).forEach(w=>{a[w.id]=w,p.push(w.toId,w.fromId)})}return{reservedShapes:o,reservedBindings:a,strongReservedShapeIds:g}}),S(this,"replacePageContent",(n,r,i,o=this.currentPageId)=>{if(this.justSent)return this.justSent=!1,this;let a=this.document.pages[this.currentPageId];return Object.values(n).forEach(s=>{s.parentId!==o&&!(a.shapes[s.parentId]||n[s.parentId])&&(console.warn("Added a shape without a parent on the page"),s.parentId=o)}),this.useStore.setState(s=>{let{hoveredId:u,editingId:d,bindingId:h,selectedIds:p}=s.document.pageStates[o],g=[...p],m=d&&s.document.pages[this.currentPageId].shapes[d];m&&g.push(m.id);let{reservedShapes:v,reservedBindings:E,strongReservedShapeIds:w}=this.getReservedContent(g,this.currentPageId);Object.values(v).filter(M=>!("text"in M)).forEach(M=>{let O=n[M.id];if(O){if(!(M.type==="arrow"||w.has(M.id))){n[M.id]=O;return}"decorations"in O&&"decorations"in M&&(n[M.id]=q(_({},M),{decorations:O.decorations})),M.style=O.style}});let C=_(_({},n),v);m&&(C[m.id]=m);let b=_(_({},r),E),A=_({},i),T=q(_({},s),{document:q(_({},s.document),{pages:{[o]:q(_({},s.document.pages[o]),{shapes:C,bindings:b})},assets:A,pageStates:q(_({},s.document.pageStates),{[o]:q(_({},s.document.pageStates[o]),{selectedIds:p.filter(M=>C[M]!==void 0),hoveredId:u?C[u]===void 0?void 0:u:void 0,editingId:d,bindingId:h?b[h]===void 0?void 0:h:void 0})})})}),B=T.document.pages[o],D=Q.getRelatedBindings(T,Object.keys(C),o),I=new Set;return D.forEach(M=>{if(!B.bindings[M.id])return;let O=B.shapes[M.fromId];if(I.has(O))return;let z=Q.updateArrowBindings(B,O);if(I.add(O),z){let K=_(_({},O),z);B.shapes[O.id]=K}}),Object.values(C).forEach(M=>{if(M.type!=="group")return;let O=M.children.filter(K=>B.shapes[K]!==void 0),z=N.getCommonBounds(O.map(K=>B.shapes[K]).filter(Boolean).map(K=>Q.getRotatedBounds(K)));B.shapes[M.id]=q(_({},M),{point:[z.minX,z.minY],size:[z.width,z.height],children:O})}),this.state.document=T.document,T},!0),this}),S(this,"updateBounds",n=>{this.rendererBounds=n;let{point:r,zoom:i}=this.camera;this.updateViewport(r,i),!this.readOnly&&this.session&&this.session.update()}),S(this,"updateViewport",(n,r)=>{let{width:i,height:o}=this.rendererBounds,[a,s]=$.sub($.div([0,0],r),n),[u,d]=$.sub($.div([i,o],r),n);this.viewport={minX:a,minY:s,maxX:u,maxY:d,height:u-a,width:d-s}}),S(this,"setEditingId",(n,r=!1)=>{if(!this.readOnly){if(n)this.startSession("edit",n,r);else{if(!this.pageState.editingId)return;this.completeSession()}this.editingStartTime=performance.now(),this.patchState({document:{pageStates:{[this.currentPageId]:{editingId:n}}}},"set_editing_id")}}),S(this,"setHoveredId",n=>{this.patchState({document:{pageStates:{[this.currentPageId]:{hoveredId:n}}}},"set_hovered_id")}),S(this,"setSetting",(n,r)=>{if(this.session)return this;let i={settings:{[n]:typeof r=="function"?r(this.settings[n]):r}};return this.patchState(i,`settings:${n}`),this.persist(i),this}),S(this,"toggleFocusMode",()=>{if(this.session)return this;let n={settings:{isFocusMode:!this.settings.isFocusMode}};return this.patchState(n,"settings:toggled_focus_mode"),this.persist(n),this}),S(this,"togglePenMode",()=>{if(this.session)return this;let n={settings:{isPenMode:!this.settings.isPenMode}};return this.patchState(n,"settings:toggled_pen_mode"),this.persist(n),this}),S(this,"toggleDarkMode",()=>{if(this.session)return this;let n={settings:{isDarkMode:!this.settings.isDarkMode}};return this.patchState(n,"settings:toggled_dark_mode"),this.persist(n),this}),S(this,"toggleZoomSnap",()=>{if(this.session)return this;let n={settings:{isZoomSnap:!this.settings.isZoomSnap}};return this.patchState(n,"settings:toggled_zoom_snap"),this.persist(n),this}),S(this,"toggleDebugMode",()=>{if(this.session)return this;let n={settings:{isDebugMode:!this.settings.isDebugMode}};return this.patchState(n,"settings:toggled_debug"),this.persist(n),this}),S(this,"setMenuOpen",n=>{let r={appState:{isMenuOpen:n}};return this.patchState(r,"ui:toggled_menu_opened"),this.persist(r),this}),S(this,"setIsLoading",n=>{let r={appState:{isLoading:n}};return this.patchState(r,"ui:toggled_is_loading"),this.persist(r),this}),S(this,"setDisableAssets",n=>(this.patchState({appState:{disableAssets:n}},"ui:toggled_disable_images"),this)),S(this,"toggleGrid",()=>{if(this.session)return this;let n={settings:{showGrid:!this.settings.showGrid}};return this.patchState(n,"settings:toggled_grid"),this.persist(n),this}),S(this,"selectTool",n=>{if(this.readOnly||this.session)return this;this.isPointing=!1;let r=this.tools[n];return r===this.currentTool?(this.patchState({appState:{isToolLocked:!1}}),this):(this.currentTool.onExit(),r.previous=this.currentTool.type,this.currentTool=r,this.currentTool.onEnter(),this.patchState({appState:{activeTool:n,isToolLocked:!1}},`selected_tool:${n}`))}),S(this,"toggleToolLock",()=>this.session?this:this.patchState({appState:{isToolLocked:!this.appState.isToolLocked}},"toggled_tool_lock")),S(this,"resetDocument",()=>{if(this.session)return this;this.session=void 0,this.currentTool=this.tools.select;let n=yn.defaultDocument;return n.pages.page.name="Page 1",this.resetHistory().clearSelectHistory().loadDocument(yn.defaultDocument).persist({}),this}),S(this,"updateUsers",(n,r=!1)=>{this.patchState({room:{users:Object.fromEntries(n.map(i=>[i.id,i]))}},r?"room:self:update":"room:user:update")}),S(this,"removeUser",n=>{this.patchState({room:{users:{[n]:void 0}}})}),S(this,"mergeDocument",n=>{if(this.document.id!==n.id)return this.replaceState(q(_({},ia(q(_({},this.state),{document:n}),yn.version)),{appState:q(_({},this.appState),{currentPageId:Object.keys(n.pages)[0]})})),this;let r=_({},this.document.pageStates),i=q(_({},this.appState),{currentPageId:n.pages[this.currentPageId]?this.currentPageId:Object.keys(n.pages)[0],pages:Object.values(n.pages).map((a,s)=>({id:a.id,name:a.name,childIndex:a.childIndex||s}))});this.resetHistory(),Object.keys(this.document.pages).forEach(a=>{n.pages[a]||(a===this.appState.currentPageId&&(this.cancelSession(),this.selectNone()),r[a]=void 0)}),this.session&&this.selectedIds.filter(a=>!n.pages[this.currentPageId].shapes[a]).forEach(a=>n.pages[this.currentPageId].shapes[a]=this.page.shapes[a]),Object.entries(r).forEach(([a,s])=>{s.selectedIds=s.selectedIds.filter(u=>!!n.pages[a].shapes[u])});let{editingId:o}=this.pageState;return o&&(n.pages[this.currentPageId].shapes[o]=this.page.shapes[o],r[this.currentPageId].selectedIds=[o]),this.replaceState(q(_({},ia(q(_({},this.state),{document:q(_({},n),{pageStates:r})}),yn.version)),{appState:i}),"merge")}),S(this,"updateDocument",(n,r="updated_document")=>{let i=this.state,o=q(_({},i),{document:q(_({},i.document),{assets:n.assets})});n.pages[this.currentPageId]||(o.appState=q(_({},i.appState),{currentPageId:Object.keys(n.pages)[0]}));let a=1;for(let s of Object.values(n.pages))s!==i.document.pages[s.id]&&(o.document.pages[s.id]=s,s.name||(o.document.pages[s.id].name=`Page ${a+1}`,a++));for(let s of Object.values(n.pageStates))if(s!==i.document.pageStates[s.id]){o.document.pageStates[s.id]=s;let u=n.pages[s.id],d=["bindingId","editingId","hoveredId","pointedId"];for(let h of d)u.shapes[h]||(s[h]=void 0);s.selectedIds=s.selectedIds.filter(h=>!!n.pages[u.id].shapes[h])}return this.replaceState(ia(o,o.document.version||0),`${r}:${n.id}`)}),S(this,"loadRoom",n=>(this.patchState({room:{id:n,userId:Zv,users:{[Zv]:{id:Zv,color:PS[Math.floor(Math.random()*PS.length)],point:[100,100],selectedIds:[],activeShapes:[]}}}}),this)),S(this,"loadDocument",n=>{this.setIsLoading(!0),this.selectNone(),this.resetHistory(),this.clearSelectHistory(),this.session=void 0;let r=q(_({},yn.defaultState),{settings:_({},this.state.settings),document:n,appState:q(_(_({},yn.defaultState.appState),this.state.appState),{currentPageId:Object.keys(n.pages)[0],disableAssets:this.disableAssets})});this.replaceState(ia(r,yn.version),"loaded_document");let{point:i,zoom:o}=this.camera;return this.updateViewport(i,o),this.setIsLoading(!1),this}),S(this,"loadPageFromURL",(n,r)=>{let i=n.id,o=q(_({},this.state.document),{pageStates:q(_({},this.state.document.pageStates),{[i]:r}),pages:q(_({},this.document.pages),{[i]:n})});this.loadDocument(o),this.persist({})}),S(this,"newProject",()=>{!this.isLocal||(this.fileSystemHandle=null,this.resetDocument())}),S(this,"saveProject",()=>Oe(this,null,function*(){if(this.readOnly)return;let n=yield Jy(ia(this.state,yn.version).document,this.fileSystemHandle);return this.fileSystemHandle=n,this.persist({}),this.isDirty=!1,this})),S(this,"saveProjectAs",n=>Oe(this,null,function*(){try{let r=yield Jy(this.document,null,n);this.fileSystemHandle=r,this.persist({}),this.isDirty=!1}catch(r){console.error(r.message)}return this})),S(this,"openProject",()=>Oe(this,null,function*(){if(this.isLocal)try{let n=yield ZT();if(!n)throw Error();let{fileHandle:r,document:i}=n;this.loadDocument(i),this.fileSystemHandle=r,this.zoomToFit(),this.persist({})}catch(n){console.error(n)}finally{this.persist({})}})),S(this,"openAsset",()=>Oe(this,null,function*(){if(!this.disableAssets)try{let n=yield QT();if(Array.isArray(n))this.addMediaFromFiles(n,this.centerPoint);else{if(!n)return;this.addMediaFromFiles([n])}}catch(n){console.error(n)}finally{this.persist({})}})),S(this,"signOut",()=>{}),S(this,"getAppState",()=>this.appState),S(this,"getPage",(n=this.currentPageId)=>Q.getPage(this.state,n||this.currentPageId)),S(this,"getShapes",(n=this.currentPageId)=>Q.getShapes(this.state,n||this.currentPageId)),S(this,"getBindings",(n=this.currentPageId)=>Q.getBindings(this.state,n||this.currentPageId)),S(this,"getShape",(n,r=this.currentPageId)=>Q.getShape(this.state,n,r)),S(this,"getShapeBounds",(n,r=this.currentPageId)=>Q.getBounds(this.getShape(n,r))),S(this,"getBinding",(n,r=this.currentPageId)=>Q.getBinding(this.state,n,r)),S(this,"getPageState",(n=this.currentPageId)=>Q.getPageState(this.state,n||this.currentPageId)),S(this,"getPagePoint",(n,r=this.currentPageId)=>{let{camera:i}=this.getPageState(r);return $.sub($.div(n,i.zoom),i.point)}),S(this,"createPage",(n,r)=>{if(this.readOnly)return this;let{width:i,height:o}=this.rendererBounds;return this.setState(NHe(this,[-i/2,-o/2],n,r))}),S(this,"changePage",n=>this.setState(LHe(this,n))),S(this,"movePage",(n,r)=>this.readOnly?this:this.setState(WHe(this,n,r))),S(this,"renamePage",(n,r)=>this.readOnly?this:this.setState(YHe(this,n,r))),S(this,"duplicatePage",n=>this.readOnly?this:this.setState(KHe(this,n))),S(this,"deletePage",n=>this.readOnly?this:Object.values(this.document.pages).length<=1?this:this.setState(zHe(this,n||this.currentPageId))),S(this,"cut",(n=this.selectedIds,r)=>(r==null||r.preventDefault(),this.copy(n,r),this.readOnly||this.delete(n),this)),S(this,"copy",(n=this.selectedIds,r)=>{var i;r==null||r.preventDefault(),this.clipboard=this.getContent(n);let o=`${JSON.stringify(_({type:"tldr/clipboard"},this.clipboard))}`;return $He(o),r&&((i=r.clipboardData)==null||i.setData("text/html",o)),navigator.clipboard&&window.ClipboardItem&&navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"})})]),this}),S(this,"paste",(n,r)=>Oe(this,null,function*(){var i,o;if(this.readOnly)return;let a=[],s=[],u,d=g=>Oe(this,null,function*(){let m=document.createElement("div");m.innerHTML=g;let v=m.firstChild;v.style.setProperty("background-color","transparent");let E=yield Q.getImageForSvg(v,"svg",{scale:1,quality:1});if(E){let w=new File([E],"image.svg");a.push(w)}else h(g)}),h=g=>{let m=this.getPagePoint(n??this.centerPoint,this.currentPageId),v=g.includes(` `);s.push(Q.getShapeUtil("text").getShape({id:N.uniqueId(),type:"text",parentId:this.appState.currentPageId,text:Q.normalizeText(g.trim()),point:m,style:q(_({},this.appState.currentStyle),{textAlign:v?"start":this.appState.currentStyle.textAlign})}))},p=g=>{var m;try{let v=(m=g.match(/(.*)<\/tldraw>/))==null?void 0:m[1];if(!v)return;let E=JSON.parse(v);if(E.type==="tldr/clipboard"){u=E;return}else throw Error("Not tldraw data!")}catch{h(g)}};if(r!==void 0){let g=Array.from((o=(i=r.clipboardData)==null?void 0:i.items)!=null?o:[]);yield Promise.all(g.map(m=>Oe(this,null,function*(){var v;let{type:E,kind:w}=m;switch(w){case"string":{let C=yield new Promise(b=>m.getAsString(b));switch(E){case"text/html":{if((v=C.match(/(.*)<\/tldraw>/))!=null&&v[1]){p(C);return}break}case"text/plain":{C.startsWith("{let w=Q.getBounds(v);E===0&&(m[0]-=w.width/2,m[1]-=w.height/2),v.point=[...m],m[0]+=w.width}),this.createShapes(...s),this}return this.clipboard?this.insertContent(this.clipboard):MHe().then(g=>{g&&p(g)}),this})),S(this,"getSvg",(...n)=>Oe(this,[...n],function*(r=this.selectedIds.length?this.selectedIds:Object.keys(this.page.shapes),i={}){if(r.length===0)return;let o=document.createElementNS("http://www.w3.org/2000/svg","svg"),a=document.createElementNS("http://www.w3.org/2000/svg","defs"),s=document.createElementNS("http://www.w3.org/2000/svg","style");if(typeof window<"u"&&window.focus(),i.includeFonts)try{let{fonts:v}=yield fetch(yn.assetSrc,{mode:"no-cors"}).then(E=>E.json());s.textContent=` @font-face { font-family: 'Caveat Brush'; @@ -526,9 +526,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert- font-weight: 500; font-style: normal; } - `}catch{Q.warn("Could not find tldraw-assets.json file.")}else s.textContent="@import url('https://fonts.googleapis.com/css2?family=Caveat+Brush&family=Source+Code+Pro&family=Source+Sans+Pro&family=Crimson+Pro&display=block');";a.append(s),o.append(a);let u=r.map(v=>this.getShape(v,this.currentPageId)).sort((v,E)=>v.childIndex-E.childIndex),d=N.getCommonBounds(u.map(Q.getRotatedBounds)),h=v=>{let E=Q.getShapeUtil(v),w=E.getBounds(v),C=E.getSvgElement(v,this.settings.isDarkMode);if(C)return v.type==="image"?C.setAttribute("xlink:href",this.document.assets[v.assetId].src):v.type==="video"&&C.setAttribute("xlink:href",this.serializeVideo(v.id)),C.setAttribute("transform",`translate(${(16+v.point[0]-d.minX).toFixed(2)}, ${(16+v.point[1]-d.minY).toFixed(2)}) rotate(${((v.rotation||0)*180/Math.PI).toFixed(2)}, ${(w.width/2).toFixed(2)}, ${(w.height/2).toFixed(2)})`),C};u.forEach(v=>{var E;if((E=v.children)!=null&&E.length){let C=document.createElementNS("http://www.w3.org/2000/svg","g");v.children.forEach(b=>{let A=this.getShape(b,this.currentPageId),T=h(A);T&&C.append(T)}),o.append(C);return}let w=h(v);w&&o.append(w)}),o.setAttribute("viewBox",[0,0,d.width+16*2,d.height+16*2].join(" ")),o.setAttribute("width",(d.width+16*2).toString()),o.setAttribute("height",(d.height+16*2).toString());let p=this.settings.exportBackground,g="#212529",m="rgb(248, 249, 250)";switch(p){case"auto":{o.style.setProperty("background-color",this.settings.isDarkMode?g:m);break}case"dark":{o.style.setProperty("background-color",g);break}case"light":{o.style.setProperty("background-color",m);break}case"transparent":default:{o.style.setProperty("background-color","transparent");break}}return o.querySelectorAll(".tl-fill-hitarea, .tl-stroke-hitarea, .tl-binding-indicator").forEach(v=>v.remove()),o})),S(this,"copySvg",(...n)=>Oe(this,[...n],function*(r=this.selectedIds.length?this.selectedIds:Object.keys(this.page.shapes)){if(r.length===0)return;let i=yield this.getSvg(r);if(!i)return;let o=Q.getSvgString(i,1);this.clipboard=this.getContent(r);let a=JSON.stringify(_({type:"tldr/clipboard"},this.clipboard));return navigator.clipboard&&window.ClipboardItem&&navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([a],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})]),o})),S(this,"getContent",n=>{let r=this.getPage(this.currentPageId);if(n&&n.length===0||(n||(n=this.selectedIds),n.length===0&&(n=Object.keys(r.shapes)),n.length===0))return;let i=n.map(u=>r.shapes[u]).flatMap(u=>{var d;return[u,...((d=u.children)!=null?d:[]).map(h=>r.shapes[h])]}).map($r),o=new Set(i.map(u=>u.id));i.forEach(u=>{u.parentId===this.currentPageId&&(u.parentId="currentPageId")});let a=Object.values(r.bindings).filter(u=>{if(o.has(u.fromId)||o.has(u.toId))return!0;if(o.has(u.fromId)){let d=i.find(h=>h.id===u.fromId).handles;d&&Object.values(d).forEach(h=>{h.bindingId===u.id&&(h.bindingId=void 0)})}if(o.has(u.toId)){let d=i.find(h=>h.id===u.toId).handles;d&&Object.values(d).forEach(h=>{h.bindingId===u.id&&(h.bindingId=void 0)})}return!1}).map($r),s=[...new Set(i.map(u=>{if(u.assetId)return this.document.assets[u.assetId]}).filter(Boolean).map($r))];return{shapes:i,bindings:a,assets:s}}),S(this,"copyJson",(n=this.selectedIds)=>{let r=this.getContent(n);return r&&Q.copyStringToClipboard(JSON.stringify(r)),this}),S(this,"exportJson",(n=this.selectedIds)=>{let r=this.getContent(n);if(r){let i=new Blob([JSON.stringify(r)],{type:"application/json"}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download="export.json",a.click()}return this}),S(this,"insertContent",(n,r={})=>this.setState(ije(this,n,r),"insert_content")),S(this,"getImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){let{ids:o=this.selectedIds.length?this.selectedIds:Object.keys(this.page.shapes)}=i,a=yield this.getSvg(o,{includeFonts:r!=="svg"});if(!a)return;if(r==="svg"){let u=Q.getSvgString(a,1);return new Blob([u],{type:"image/svg+xml"})}let s=yield Q.getImageForSvg(a,r,i);if(s)return s})),S(this,"copyImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){if(r==="svg"){this.copySvg(i.ids);return}if(!(navigator.clipboard&&window.ClipboardItem)){console.warn("Sorry, your browser does not support copying images.");return}let o=yield this.getImage(r,i);!o||navigator.clipboard.write([new ClipboardItem({[o.type]:o})])})),S(this,"exportImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){var o;let{pageId:a=this.currentPageId}=i,s=yield this.getImage(r,i);if(!s)return;let u=(o=this.document.pages[a].name)!=null?o:"export";if(this.callbacks.onExport)this.callbacks.onExport(this,{name:u,type:r,blob:s});else{let d=URL.createObjectURL(s),h=document.createElement("a");h.href=d,h.download=`${u}.${r}`,h.click()}})),S(this,"setCamera",(n,r,i)=>(this.updateViewport(n,r),this.patchState({document:{pageStates:{[this.currentPageId]:{camera:{point:n,zoom:r}}}}},i),this)),S(this,"resetCamera",()=>this.setCamera(this.centerPoint,1,"reset_camera")),S(this,"pan",n=>{let{camera:r}=this.pageState;return this.setCamera($.toFixed($.sub(r.point,n)),r.zoom,"panned")}),S(this,"pinchZoom",(n,r,i)=>{let{camera:o}=this.pageState,a=$.sub(o.point,$.div(r,o.zoom)),s=i,u=$.sub($.div(n,o.zoom),a),d=$.sub($.div(n,s),a);return this.setCamera($.toFixed($.add(a,$.sub(d,u))),s,"pinch_zoomed")}),S(this,"zoomTo",(n,r=this.centerPoint)=>{let{zoom:i,point:o}=this.camera,a=$.sub($.div(r,i),o),s=$.sub($.div(r,n),o);return this.setCamera($.toFixed($.add(o,$.sub(s,a))),n,"zoomed_camera")}),S(this,"zoomIn",()=>{let n=Math.round(this.camera.zoom*100/25),r=Q.getCameraZoom((n+1)*.25);return this.zoomTo(r)}),S(this,"zoomOut",()=>{let n=Math.round(this.camera.zoom*100/25),r=Q.getCameraZoom((n-1)*.25);return this.zoomTo(r)}),S(this,"zoomToFit",()=>{let{shapes:n,pageState:{camera:r}}=this;if(n.length===0)return this;let{rendererBounds:i}=this,o=N.getCommonBounds(n.map(Q.getBounds)),a=Q.getCameraZoom(Math.min((i.width-128)/o.width,(i.height-128)/o.height));a=r.zoom===a||r.zoom<1?Math.min(1,a):a;let s=(i.width-o.width*a)/2/a,u=(i.height-o.height*a)/2/a;return this.setCamera($.toFixed($.sub([s,u],[o.minX,o.minY])),a,"zoomed_to_fit")}),S(this,"zoomToSelection",()=>{if(this.selectedIds.length===0)return this;let{rendererBounds:n}=this,r=Q.getSelectedBounds(this.state),i=Q.getCameraZoom(Math.min((n.width-128)/r.width,(n.height-128)/r.height));i=this.camera.zoom===i||this.camera.zoom<1?Math.min(1,i):i;let o=(n.width-r.width*i)/2/i,a=(n.height-r.height*i)/2/i;return this.setCamera($.toFixed($.sub([o,a],[r.minX,r.minY])),i,"zoomed_to_selection")}),S(this,"zoomToContent",()=>{let n=this.shapes,r=this.pageState;if(n.length===0)return this;let{rendererBounds:i}=this,{zoom:o}=r.camera,a=N.getCommonBounds(n.map(Q.getBounds)),s=(i.width-a.width*o)/2/o,u=(i.height-a.height*o)/2/o;return this.setCamera($.toFixed($.sub([s,u],[a.minX,a.minY])),this.camera.zoom,"zoomed_to_content")}),S(this,"resetZoom",()=>this.zoomTo(1)),S(this,"zoomBy",N.throttle((n,r)=>{let{zoom:i}=this.camera,o=Q.getCameraZoom(i-n*i);return this.zoomTo(o,r)},16)),S(this,"clearSelectHistory",()=>(this.selectHistory.pointer=0,this.selectHistory.stack=[this.selectedIds],this)),S(this,"addToSelectHistory",n=>(this.selectHistory.pointer{let i=r?[...this.pageState.selectedIds,...n]:[...n];return this.patchState({appState:{activeTool:"select"},document:{pageStates:{[this.currentPageId]:{selectedIds:i}}}},"selected")}),S(this,"undoSelect",()=>(this.selectHistory.pointer>0&&(this.selectHistory.pointer--,this.setSelectedIds(this.selectHistory.stack[this.selectHistory.pointer])),this)),S(this,"redoSelect",()=>(this.selectHistory.pointer(n.forEach(r=>{if(!this.page.shapes[r])throw Error(`That shape does not exist on page ${this.currentPageId}`)}),this.setSelectedIds(n),this.addToSelectHistory(n),this)),S(this,"selectAll",(n=this.currentPageId)=>this.session?this:(this.setSelectedIds(Object.values(this.document.pages[n].shapes).filter(r=>r.parentId===n).map(r=>r.id)),this.addToSelectHistory(this.selectedIds),this.selectTool("select"),this)),S(this,"selectNone",()=>(this.setSelectedIds([]),this.addToSelectHistory(this.selectedIds),this)),S(this,"startSession",(n,...r)=>{var i,o;if(this.readOnly&&n!=="brush")return this;this.session&&(Q.warn(`Already in a session! (${this.session.constructor.name})`),this.cancelSession());let a=yje(n);this.session=new a(this,...r);let s=this.session.start();return s&&this.patchState(s,`session:start_${this.session.constructor.name}`),(o=(i=this.callbacks).onSessionStart)==null||o.call(i,this,this.session.constructor.name),this}),S(this,"updateSession",()=>{let{session:n}=this;if(!n)return this;let r=n.update();return r?this.patchState(r,`session:${n==null?void 0:n.constructor.name}`):this}),S(this,"cancelSession",()=>{var n,r;let{session:i}=this;if(!i)return this;this.session=void 0;let o=i.cancel();return o&&this.patchState(o,`session:cancel:${i.constructor.name}`),this.setEditingId(),(r=(n=this.callbacks).onSessionEnd)==null||r.call(n,this,i.constructor.name),this}),S(this,"completeSession",()=>{var n,r,i,o,a,s,u,d,h;let{session:p}=this;if(!p)return this;this.session=void 0;let g=p.complete();if(g===void 0)this.isCreating=!1,this.patchState({appState:{status:"idle"},document:{pageStates:{[this.currentPageId]:{editingId:void 0,bindingId:void 0,hoveredId:void 0}}}},`session:complete:${p.constructor.name}`);else if("after"in g){if(this.isCreating){if(g.before={appState:q(_({},g.before.appState),{status:"idle"}),document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(this.selectedIds.map(m=>[m,void 0]))}},pageStates:{[this.currentPageId]:{selectedIds:[],editingId:null,bindingId:null,hoveredId:null}}}},this.appState.isToolLocked){let m=((i=(r=(n=g.after)==null?void 0:n.document)==null?void 0:r.pageStates)==null?void 0:i[this.currentPageId])||{};m.selectedIds=[]}this.isCreating=!1}g.after.appState=q(_({},g.after.appState),{status:"idle"}),g.after.document=q(_({},g.after.document),{pageStates:q(_({},(o=g.after.document)==null?void 0:o.pageStates),{[this.currentPageId]:q(_({},(((a=g.after.document)==null?void 0:a.pageStates)||{})[this.currentPageId]),{editingId:null})})}),this.setState(g,`session:complete:${p.constructor.name}`)}else this.patchState(q(_({},g),{appState:q(_({},g.appState),{status:"idle"}),document:q(_({},g.document),{pageStates:{[this.currentPageId]:q(_({},(u=(s=g.document)==null?void 0:s.pageStates)==null?void 0:u[this.currentPageId]),{editingId:null})}})}),`session:complete:${p.constructor.name}`);return(h=(d=this.callbacks).onSessionEnd)==null||h.call(d,this,p.constructor.name),this}),S(this,"createShapes",(...n)=>n.length===0?this:this.create(n.map(r=>Q.getShapeUtil(r.type).create(_({parentId:this.currentPageId},r))))),S(this,"updateShapes",(...n)=>{let r=this.document.pages[this.currentPageId].shapes,i=n.filter(o=>r[o.id]);return i.length===0?this:this.setState(VS(this,i,this.currentPageId),"updated_shapes")}),S(this,"create",(n=[],r=[])=>n.length===0?this:this.setState(HS(this,n,r))),S(this,"patchCreate",(n=[],r=[])=>n.length===0?this:this.patchState(HS(this,n,r).after)),S(this,"delete",(n=this.selectedIds)=>{var r,i;if(n.length===0)return this;if(this.session)return this;let o=jS(this,n);if(this.callbacks.onAssetDelete&&((r=o.before.document)!=null&&r.assets)&&((i=o.after.document)!=null&&i.assets)){let a=Object.keys(o.before.document.assets).filter(u=>!!o.before.document.assets[u]),s=Object.keys(o.after.document.assets).filter(u=>!!o.after.document.assets[u]);a.filter(u=>!s.includes(u)).forEach(u=>this.callbacks.onAssetDelete(this,u))}return this.setState(o)}),S(this,"deleteAll",()=>(this.selectAll(),this.delete(),this)),S(this,"style",(n,r=this.selectedIds)=>this.setState(QHe(this,r,n))),S(this,"align",(n,r=this.selectedIds)=>r.length<2?this:this.setState(FHe(this,r,n))),S(this,"distribute",(n,r=this.selectedIds)=>r.length<3?this:this.setState(jHe(this,r,n))),S(this,"stretch",(n,r=this.selectedIds)=>r.length<2?this:this.setState(ZHe(this,r,n))),S(this,"flipHorizontal",(n=this.selectedIds)=>n.length===0?this:this.setState(US(this,n,"horizontal"))),S(this,"flipVertical",(n=this.selectedIds)=>n.length===0?this:this.setState(US(this,n,"vertical"))),S(this,"moveToPage",(n,r=this.currentPageId,i=this.selectedIds)=>{if(i.length===0)return this;let{rendererBounds:o}=this;return this.setState(JHe(this,i,o,r,n)),this}),S(this,"moveToBack",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"toBack"))),S(this,"moveBackward",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"backward"))),S(this,"moveForward",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"forward"))),S(this,"moveToFront",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"toFront"))),S(this,"nudge",(n,r=!1,i=this.selectedIds)=>{if(i.length===0)return this;let o=r?this.settings.showGrid?this.currentGrid*4:10:this.settings.showGrid?this.currentGrid:1;return this.setState(tje(this,i,$.mul(n,o)))}),S(this,"duplicate",(n=this.selectedIds,r)=>this.readOnly?this:n.length===0?this:this.setState(VHe(this,n,r))),S(this,"resetBounds",(n=this.selectedIds)=>{let r=KS(this,n,this.currentPageId);return this.setState(KS(this,n,this.currentPageId),r.id)}),S(this,"toggleHidden",(n=this.selectedIds)=>n.length===0?this:this.setState(qv(this,n,"isHidden"))),S(this,"toggleLocked",(n=this.selectedIds)=>n.length===0?this:this.setState(qv(this,n,"isLocked"))),S(this,"toggleAspectRatioLocked",(n=this.selectedIds)=>n.length===0?this:this.setState(qv(this,n,"isAspectRatioLocked"))),S(this,"toggleDecoration",(n,r=this.selectedIds)=>r.length===0||!(n==="start"||n==="end")?this:this.setState(eje(this,r,n))),S(this,"setShapeProps",(n,r=this.selectedIds)=>this.setState(rje(this,r,n))),S(this,"rotate",(n=Math.PI*-.5,r=this.selectedIds)=>{if(r.length===0)return this;let i=XHe(this,r,n);return i?this.setState(i):this}),S(this,"group",(n=this.selectedIds,r=N.uniqueId(),i=this.currentPageId)=>{if(this.readOnly)return this;if(n.length===1&&this.getShape(n[0],i).type==="group")return this.ungroup(n,i);if(n.length<2)return this;let o=GHe(this,n,r,i);return o?this.setState(o):this}),S(this,"ungroup",(n=this.selectedIds,r=this.currentPageId)=>{if(this.readOnly)return this;let i=n.map(a=>this.getShape(a,r)).filter(a=>a.type==="group");if(i.length===0)return this;let o=nje(this,n,i,r);return o?this.setState(o):this}),S(this,"cancel",()=>{var n,r;return(r=(n=this.currentTool).onCancel)==null||r.call(n),this}),S(this,"addMediaFromFiles",(n,...r)=>Oe(this,[n,...r],function*(i,o=this.centerPoint){this.setIsLoading(!0);let a=[],s=this.getPagePoint(o);for(let u of i){let d=N.uniqueId(),h=u.name.match(/\.[0-9a-z]+$/i);if(!h)throw Error("No extension");let p=MT.includes(h[0].toLowerCase()),g=$T.includes(h[0].toLowerCase());if(!(p||g))throw Error("Wrong extension");let m=p?"image":"video",v=p?"image":"video",E;try{if(this.callbacks.onAssetCreate){let w=yield this.callbacks.onAssetCreate(this,u,d);if(!w)throw Error("Asset creation callback returned false");E=w}else E=yield eP(u);if(typeof E=="string"){let w=[0,0];if(p){if(h[0]==".svg"){let A,T=yield tP(u),B=this.getViewboxFromSVG(T);B&&(A=B.split(" "),w[0]=parseFloat(A[2]),w[1]=parseFloat(A[3]))}$.isEqual(w,[0,0])&&(w=yield nP(E))}else w=yield rP(E);let C=Object.values(this.document.assets).find(A=>A.type===v&&A.src===E),b;if(C)b=C.id;else{b=d;let A={id:b,type:v,name:u.name,src:E,size:w};this.patchState({document:{assets:{[b]:A}}})}a.push(this.getImageOrVideoShapeAtPoint(d,m,o,w,b))}}catch(w){console.warn(w)}}if(a.length){let u=$.add(s,[0,0]);a.forEach((h,p)=>{let g=Q.getBounds(h);p===0&&(u[0]-=g.width/2,u[1]-=g.height/2),h.point=[...u],u[0]+=g.width});let d=N.getCommonBounds(a.map(Q.getBounds));this.createShapes(...a),N.boundsContain(this.viewport,d)||(this.zoomToSelection(),this.zoom>1&&this.resetZoom())}return this.setIsLoading(!1),this})),S(this,"getViewboxFromSVG",n=>{let r=/.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/;if(typeof n=="string"){let i=n.match(r);return i&&i.length>=2?i[1]:null}return this.setIsLoading(!1),null}),S(this,"onKeyDown",(n,r,i)=>{var o,a;switch(i.key){case"/":{if(this.status==="idle"&&!this.pageState.editingId){let{shiftKey:s,metaKey:u,altKey:d,ctrlKey:h,spaceKey:p}=this;this.onPointerDown({target:"canvas",pointerId:0,origin:r.point,point:r.point,delta:[0,0],pressure:.5,shiftKey:s,ctrlKey:h,metaKey:u,altKey:d,spaceKey:p},{shiftKey:s,altKey:d,ctrlKey:h,pointerId:0,clientX:r.point[0],clientY:r.point[1]})}break}case"Escape":{this.cancel();break}case"Meta":{this.metaKey=!0;break}case"Alt":{this.altKey=!0;break}case"Control":{this.ctrlKey=!0;break}case" ":{this.isForcePanning=!0,this.spaceKey=!0;break}}return(a=(o=this.currentTool).onKeyDown)==null||a.call(o,n,r,i),this}),S(this,"onKeyUp",(n,r,i)=>{var o,a;if(r){switch(i.key){case"/":{let{currentPoint:s,shiftKey:u,metaKey:d,altKey:h,ctrlKey:p,spaceKey:g}=this;this.onPointerUp({target:"canvas",pointerId:0,origin:s,point:s,delta:[0,0],pressure:.5,shiftKey:u,ctrlKey:p,metaKey:d,altKey:h,spaceKey:g},{shiftKey:u,altKey:h,ctrlKey:p,pointerId:0,clientX:s[0],clientY:s[1]});break}case"Meta":{this.metaKey=!1;break}case"Alt":{this.altKey=!1;break}case"Control":{this.ctrlKey=!1;break}case" ":{this.isForcePanning=!1,this.spaceKey=!1;break}}(a=(o=this.currentTool).onKeyUp)==null||a.call(o,n,r,i)}}),S(this,"refreshBoundingBoxes",()=>{let n=this.shapes.map(i=>[i.id,_({point:[...i.point]},"label"in i&&{label:""})]),r=this.shapes.map(i=>[i.id,_({point:[...i.point]},"label"in i&&{label:i.label})]);$Ne(),this.patchState({document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(n)}}}}),this.patchState({document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(r)}}}})}),S(this,"onDragOver",n=>{n.preventDefault()}),S(this,"onDrop",n=>Oe(this,null,function*(){var r;return n.preventDefault(),this.disableAssets?this:((r=n.dataTransfer.files)!=null&&r.length&&this.addMediaFromFiles(Object.values(n.dataTransfer.files),[n.clientX,n.clientY]),this)})),S(this,"onPinchStart",(n,r)=>{var i,o;(o=(i=this.currentTool).onPinchStart)==null||o.call(i,n,r)}),S(this,"onPinchEnd",(n,r)=>{var i,o;return(o=(i=this.currentTool).onPinchEnd)==null?void 0:o.call(i,n,r)}),S(this,"onPinch",(n,r)=>{var i,o;return(o=(i=this.currentTool).onPinch)==null?void 0:o.call(i,n,r)}),S(this,"onPan",(n,r)=>{if(this.appState.status==="pinching")return;let i=$.div(n.delta,this.camera.zoom),o=this.camera.point,a=$.sub(o,i);$.isEqual(a,o)||(this.pan(i),this.isForcePanning||this.onPointerMove(n,r),TNe&&this.isForcePanning&&this.preventPaste())}),S(this,"onZoom",(n,r)=>{if(this.state.appState.status!=="idle")return;let i=n.delta[2]/50;this.zoomBy(i,n.point),this.onPointerMove(n,r)}),S(this,"updateInputs",n=>{this.currentPoint=this.getPagePoint(n.point).concat(n.pressure),this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.ctrlKey=n.ctrlKey,this.metaKey=n.metaKey}),S(this,"onPointerMove",(n,r)=>{var i,o,a,s,u;if(this.previousPoint=this.currentPoint,this.updateInputs(n,r),this.isForcePanning&&this.isPointing){(i=this.onPan)==null||i.call(this,q(_({},n),{delta:$.neg(n.delta)}),r);return}if((a=(o=this.currentTool).onPointerMove)==null||a.call(o,n,r),this.state.room){let{users:d,userId:h}=this.state.room;(u=(s=this.callbacks).onChangePresence)==null||u.call(s,this,q(_({},d[h]),{point:this.getPagePoint(n.point),session:!!this.session}))}}),S(this,"onPointerDown",(n,r)=>{var i,o;if(r.buttons===4)this.isForcePanning=!0;else if(this.isPointing)return;this.isPointing=!0,this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),!this.isForcePanning&&(this.currentTool.type==="draw"&&r.pointerType==="pen"&&r.button===5&&(this.selectTool("erase"),this.isErasingWithPen=!0),(o=(i=this.currentTool).onPointerDown)==null||o.call(i,n,r))}),S(this,"onPointerUp",(n,r)=>{var i,o;this.isPointing=!1,this.shiftKey||(this.isForcePanning=!1),this.updateInputs(n,r),(o=(i=this.currentTool).onPointerUp)==null||o.call(i,n,r),this.isErasingWithPen&&r.pointerType==="pen"&&r.button===5&&(this.selectTool("draw"),this.isErasingWithPen=!1)}),S(this,"onPointCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onPointCanvas)==null||o.call(i,n,r)}),S(this,"onDoubleClickCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickCanvas)==null||o.call(i,n,r)}),S(this,"onRightPointCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointCanvas)==null||o.call(i,n,r)}),S(this,"onDragCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragCanvas)==null||o.call(i,n,r)}),S(this,"onReleaseCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseCanvas)==null||o.call(i,n,r)}),S(this,"onPointShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointShape)==null||o.call(i,n,r)}),S(this,"onReleaseShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseShape)==null||o.call(i,n,r)}),S(this,"onDoubleClickShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickShape)==null||o.call(i,n,r)}),S(this,"onRightPointShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointShape)==null||o.call(i,n,r)}),S(this,"onDragShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragShape)==null||o.call(i,n,r)}),S(this,"onHoverShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverShape)==null||o.call(i,n,r)}),S(this,"onUnhoverShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverShape)==null||o.call(i,n,r)}),S(this,"onPointBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointBounds)==null||o.call(i,n,r)}),S(this,"onDoubleClickBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickBounds)==null||o.call(i,n,r)}),S(this,"onRightPointBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointBounds)==null||o.call(i,n,r)}),S(this,"onDragBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragBounds)==null||o.call(i,n,r)}),S(this,"onHoverBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverBounds)==null||o.call(i,n,r)}),S(this,"onUnhoverBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverBounds)==null||o.call(i,n,r)}),S(this,"onReleaseBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseBounds)==null||o.call(i,n,r)}),S(this,"onPointBoundsHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointBoundsHandle)==null||o.call(i,n,r)}),S(this,"onDoubleClickBoundsHandle",(n,r)=>{var i,o;if(this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickBoundsHandle)==null||o.call(i,n,r),this.selectedIds.length!==1)return;let a=this.getShape(this.selectedIds[0]);if(a.type==="image"||a.type==="video"){let s=this.document.assets[a.assetId],u=Q.getShapeUtil(a),d=u.getCenter(a),h=u.getCenter(q(_({},a),{size:s.size})),p=$.sub(h,d);this.updateShapes({id:a.id,point:$.sub(a.point,p),size:s.size})}}),S(this,"onRightPointBoundsHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointBoundsHandle)==null||o.call(i,n,r)}),S(this,"onDragBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragBoundsHandle)==null||o.call(i,n,r)}),S(this,"onHoverBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverBoundsHandle)==null||o.call(i,n,r)}),S(this,"onUnhoverBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverBoundsHandle)==null||o.call(i,n,r)}),S(this,"onReleaseBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseBoundsHandle)==null||o.call(i,n,r)}),S(this,"onPointHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointHandle)==null||o.call(i,n,r)}),S(this,"onDoubleClickHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickHandle)==null||o.call(i,n,r)}),S(this,"onRightPointHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointHandle)==null||o.call(i,n,r)}),S(this,"onDragHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragHandle)==null||o.call(i,n,r)}),S(this,"onHoverHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverHandle)==null||o.call(i,n,r)}),S(this,"onUnhoverHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverHandle)==null||o.call(i,n,r)}),S(this,"onReleaseHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseHandle)==null||o.call(i,n,r)}),S(this,"onShapeChange",n=>{let r=this.document.pages[this.currentPageId].shapes,i=_(_({},r[n.id]),n),o=VS(this,[i],this.currentPageId).after;return this.patchState(o,"patched_shapes")}),S(this,"onShapeBlur",()=>{var n,r;if(performance.now()-this.editingStartTime<50)return;let{editingId:i}=this.pageState,{isToolLocked:o}=this.getAppState();if(i){let a=this.getShape(i);this.setEditingId(),a.type==="text"&&(a.text.trim().length<=0?this.patchState(jS(this,[i]).after,"delete_empty_text"):o||this.select(i))}(r=(n=this.currentTool).onShapeBlur)==null||r.call(n)}),S(this,"onShapeClone",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onShapeClone)==null||o.call(i,n,r)}),S(this,"onRenderCountChange",n=>{let r=this.getAppState();r.isEmptyCanvas&&n.length>0?this.patchState({appState:{isEmptyCanvas:!1}},"empty_canvas:false"):!r.isEmptyCanvas&&n.length<=0&&this.patchState({appState:{isEmptyCanvas:!0}},"empty_canvas:true")}),S(this,"onError",()=>{}),S(this,"getShapeUtil",Q.getShapeUtil),this.callbacks=t}setStatus(e){return this.patchState({appState:{status:e}},`set_status:${e}`)}get isMenuOpen(){return this.appState.isMenuOpen}get isLoading(){return this.appState.isLoading}get disableAssets(){return this.appState.disableAssets}get history(){return this.stack.slice(0,this.pointer+1)}set history(e){this.replaceHistory(e)}get document(){return this.state.document}get settings(){return this.state.settings}get appState(){return this.state.appState}get currentPageId(){return this.state.appState.currentPageId}get page(){return this.state.document.pages[this.currentPageId]}get shapes(){return Object.values(this.page.shapes)}get bindings(){return Object.values(this.page.bindings)}get assets(){return Object.values(this.document.assets)}get pageState(){return this.state.document.pageStates[this.currentPageId]}get camera(){return this.pageState.camera}get zoom(){return this.pageState.camera.zoom}get selectedIds(){return this.pageState.selectedIds}createTextShapeAtPoint(e,t,n){let{shapes:r,appState:{currentPageId:i,currentStyle:o}}=this,a=r.length===0?1:r.filter(h=>h.parentId===i).sort((h,p)=>p.childIndex-h.childIndex)[0].childIndex+1,s=od.text,u=s.create({id:t||N.uniqueId(),parentId:i,childIndex:a,point:e,style:_({},o)}),d=s.getBounds(u);return u.point=$.sub(u.point,[d.width/2,d.height/2]),n?this.patchCreate([Q.getShapeUtil(u.type).create(u)]):this.createShapes(u),this.setEditingId(u.id,!0),this}getImageOrVideoShapeAtPoint(e,t,n,r,i){let{shapes:o,appState:{currentPageId:a,currentStyle:s}}=this,u=o.length===0?1:o.filter(h=>h.parentId===a).sort((h,p)=>p.childIndex-h.childIndex)[0].childIndex+1,d=od[t];if(r[0]>this.viewport.width){let h=r[1]/r[0];r[0]=this.viewport.width-128/this.camera.zoom*2,r[1]=r[0]*h,(r[1]<32||r[1]<32)&&(r[1]=32,r[0]=r[1]/h)}else if(r[1]>this.viewport.height){let h=r[0]/r[1];r[1]=this.viewport.height-128/this.camera.zoom*2,r[0]=r[1]*h,(r[1]<32||r[1]<32)&&(r[0]=32,r[1]=r[0]/h)}return d.create({id:e,parentId:a,childIndex:u,point:n,size:r,style:_({},s),assetId:i})}isSelected(e){return this.selectedIds.includes(e)}serializeVideo(e){let t=document.getElementById(e+"_video");if(t){let n=document.createElement("canvas");return n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0),n.toDataURL("image/png")}else throw new Error("Video with id "+e+" not found")}serializeImage(e){let t=document.getElementById(e+"_image");if(t){let n=document.createElement("canvas");return n.width=t.width,n.height=t.height,n.getContext("2d").drawImage(t,0,0),n.toDataURL("image/png")}else throw new Error("Image with id "+e+" not found")}patchAssets(e){this.document.assets=_(_({},this.document.assets),e)}get room(){return this.state.room}get isLocal(){return this.state.room===void 0||this.state.room.id==="local"}get status(){return this.appState.status}get currentUser(){if(this.state.room)return this.state.room.users[this.state.room.userId]}get centerPoint(){let{width:e,height:t}=this.rendererBounds;return $.toFixed([e/2,t/2])}get currentGrid(){let{zoom:e}=this.camera;return e<.15?8*16:e<1?8*4:8*1}},Dc=yn;S(Dc,"version",15.5),S(Dc,"defaultDocument",{id:"doc",name:"New Document",version:yn.version,pages:{page:{id:"page",name:"Page 1",childIndex:1,shapes:{},bindings:{}}},pageStates:{page:{id:"page",selectedIds:[],camera:{point:[0,0],zoom:1}}},assets:{}}),S(Dc,"defaultState",{settings:{isCadSelectMode:!1,isPenMode:!1,isDarkMode:!1,isZoomSnap:!1,isFocusMode:!1,isSnapping:!1,isDebugMode:!1,isReadonlyMode:!1,keepStyleMenuOpen:!1,nudgeDistanceLarge:16,nudgeDistanceSmall:1,showRotateHandles:!0,showBindingHandles:!0,showCloneHandles:!1,showGrid:!1,language:"en",dockPosition:"bottom",exportBackground:"transparent"},appState:{status:"idle",activeTool:"select",hoveredId:void 0,currentPageId:"page",currentStyle:Vo,isToolLocked:!1,isMenuOpen:!1,isEmptyCanvas:!1,eraseLine:[],snapLines:[],isLoading:!1,disableAssets:!1},document:yn.defaultDocument}),S(Dc,"assetSrc","tldraw-assets.json");var Tje=EK,Pje=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1;function Bje({id:e,document:t,currentPageId:n,autofocus:r=!0,showMenu:i=!0,showMultiplayerMenu:o=!0,showPages:a=!0,showTools:s=!0,showZoom:u=!0,showStyles:d=!0,showUI:h=!0,readOnly:p=!1,disableAssets:g=!1,darkMode:m=Pje,components:v,onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetCreate:Z,onAssetDelete:pe,onAssetUpload:me,onSessionStart:Ce,onSessionEnd:W,onExport:U,hideCursors:ne}){let[le,Ae]=l.useState(e),[we,ft]=l.useState(()=>new Dc(e,{onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onSessionStart:Ce,onSessionEnd:W})),[Ze,qe]=l.useState(null),[Ge,At]=l.useState(null),[dt,pn]=l.useState(null),[Dn,On]=l.useState(null),_n=l.useCallback((Tn,tn,Ri,zu)=>{On(()=>Tn),qe(()=>zu),At(()=>tn),pn(()=>Ri)},[]);return l.useLayoutEffect(()=>{if(e===le)return;let Tn=new Dc(e,{onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onExport:U,onSessionStart:Ce,onSessionEnd:W});Ae(e),ft(Tn)},[le,e]),l.useEffect(()=>{!t||(t.id===we.document.id?we.updateDocument(t):we.loadDocument(t))},[t,we]),l.useEffect(()=>{we.setDisableAssets(g)},[we,g]),l.useEffect(()=>{!n||we.changePage(n)},[n,we]),l.useEffect(()=>{we.readOnly=p,p||(we.selectNone(),we.cancelSession(),we.setEditingId())},[we,p]),l.useEffect(()=>{m!==we.settings.isDarkMode&&we.toggleDarkMode()},[we,m]),l.useEffect(()=>{we.callbacks={onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onExport:U,onSessionStart:Ce,onSessionEnd:W}},[E,w,C,b,A,T,B,D,I,M,O,z,K,X,pe,Z,me,U,Ce,W]),l.useLayoutEffect(()=>{var Tn;if(typeof window>"u"||!((Tn=window.document)!=null&&Tn.fonts))return;function tn(){we.refreshBoundingBoxes()}return window.document.fonts.addEventListener("loadingdone",tn),()=>{window.document.fonts.removeEventListener("loadingdone",tn)}},[we]),l.createElement(kT.Provider,{value:we},l.createElement(DT.Provider,{value:{onYes:Ge,onCancel:Ze,onNo:dt,dialogState:Dn,setDialogState:On,openDialog:_n}},l.createElement(Mje,{key:le||"Tldraw",id:le,autofocus:r,showPages:a,showMenu:i,showMultiplayerMenu:o,showStyles:d,showZoom:u,showTools:s,showUI:h,readOnly:p,components:v,hideCursors:ne})))}var Mje=l.memo(function({id:e,autofocus:t,showPages:n,showMenu:r,showMultiplayerMenu:i,showZoom:o,showStyles:a,showTools:s,readOnly:u,showUI:d,components:h,hideCursors:p}){var g,m;let v=wt(),[E,w]=l.useState(null),C=l.useRef(null),b=v.useStore(),{document:A,settings:T,appState:B,room:D}=b,I=b.appState.activeTool==="select",M=A.pages[B.currentPageId],O=A.pageStates[M.id],z=A.assets,{selectedIds:K}=O,X=K.length===1&&M.shapes[K[0]]&&Q.getShapeUtil(M.shapes[K[0]].type).hideBounds,Z=K.length===1&&M.shapes[K[0]]&&Q.getShapeUtil(M.shapes[K[0]].type).hideResizeHandles,pe=l.useMemo(()=>({isDarkMode:T.isDarkMode}),[T.isDarkMode]),me=T.isCadSelectMode?!B.selectByContain:B.selectByContain,Ce=l.useMemo(()=>{let{selectByContain:ft}=B,{isDarkMode:Ze,isCadSelectMode:qe}=T;if(Ze){let At=qe?ft?"69, 155, 255":"105, 209, 73":"180, 180, 180";return{brushFill:`rgba(${At}, ${qe?.08:.05})`,brushStroke:`rgba(${At}, ${qe?.5:.25})`,brushDashStroke:`rgba(${At}, .6)`,selected:"rgba(38, 150, 255, 1.000)",selectFill:"rgba(38, 150, 255, 0.05)",background:"#212529",foreground:"#49555f"}}let Ge=qe?ft?"0, 89, 242":"51, 163, 23":"0,0,0";return{brushFill:`rgba(${Ge}, ${qe?.08:.05})`,brushStroke:`rgba(${Ge}, ${qe?.4:.25})`,brushDashStroke:`rgba(${Ge}, .6)`}},[T.isDarkMode,T.isCadSelectMode,B.selectByContain]),W=v.session!==void 0,U=W&&((g=v.session)==null?void 0:g.constructor.name)!=="BrushSession"||!I||X||!!O.editingId,ne=W||!I,le=W&&b.appState.status!=="brushing"||!I,Ae=W||!I||O.camera.zoom<.2,we=wOe(T.language);return l.useLayoutEffect(()=>{let ft=C.current;!ft||(T.isDarkMode?ft.classList.add(xS):ft.classList.remove(xS))},[T.isDarkMode]),BHe(C),l.createElement(IT.Provider,{value:C},l.createElement(JV,{locale:we.locale,messages:we.messages},l.createElement(ZOe,{container:E}),l.createElement(Rje,{ref:C,tabIndex:-0},l.createElement(KOe,null),l.createElement($je,{focusableRef:C,autofocus:t}),l.createElement(LOe,null,l.createElement(Tje,{FallbackComponent:OOe},l.createElement(mK,{id:e,containerRef:C,shapeUtils:od,page:M,pageState:O,assets:z,snapLines:B.snapLines,eraseLine:B.eraseLine,grid:8,users:D==null?void 0:D.users,userId:D==null?void 0:D.userId,theme:Ce,meta:pe,components:h,hideCursors:p,hideBounds:U,hideHandles:ne,hideResizeHandles:Z,hideIndicators:le,hideBindingHandles:!T.showBindingHandles,hideCloneHandles:Ae,hideRotateHandles:!T.showRotateHandles,hideGrid:!T.showGrid,showDashedBrush:me,performanceMode:(m=v.session)==null?void 0:m.performanceMode,onPinchStart:v.onPinchStart,onPinchEnd:v.onPinchEnd,onPinch:v.onPinch,onPan:v.onPan,onZoom:v.onZoom,onPointerDown:v.onPointerDown,onPointerMove:v.onPointerMove,onPointerUp:v.onPointerUp,onPointCanvas:v.onPointCanvas,onDoubleClickCanvas:v.onDoubleClickCanvas,onRightPointCanvas:v.onRightPointCanvas,onDragCanvas:v.onDragCanvas,onReleaseCanvas:v.onReleaseCanvas,onPointShape:v.onPointShape,onDoubleClickShape:v.onDoubleClickShape,onRightPointShape:v.onRightPointShape,onDragShape:v.onDragShape,onHoverShape:v.onHoverShape,onUnhoverShape:v.onUnhoverShape,onReleaseShape:v.onReleaseShape,onPointBounds:v.onPointBounds,onDoubleClickBounds:v.onDoubleClickBounds,onRightPointBounds:v.onRightPointBounds,onDragBounds:v.onDragBounds,onHoverBounds:v.onHoverBounds,onUnhoverBounds:v.onUnhoverBounds,onReleaseBounds:v.onReleaseBounds,onPointBoundsHandle:v.onPointBoundsHandle,onDoubleClickBoundsHandle:v.onDoubleClickBoundsHandle,onRightPointBoundsHandle:v.onRightPointBoundsHandle,onDragBoundsHandle:v.onDragBoundsHandle,onHoverBoundsHandle:v.onHoverBoundsHandle,onUnhoverBoundsHandle:v.onUnhoverBoundsHandle,onReleaseBoundsHandle:v.onReleaseBoundsHandle,onPointHandle:v.onPointHandle,onDoubleClickHandle:v.onDoubleClickHandle,onRightPointHandle:v.onRightPointHandle,onDragHandle:v.onDragHandle,onHoverHandle:v.onHoverHandle,onUnhoverHandle:v.onUnhoverHandle,onReleaseHandle:v.onReleaseHandle,onError:v.onError,onRenderCountChange:v.onRenderCountChange,onShapeChange:v.onShapeChange,onShapeBlur:v.onShapeBlur,onShapeClone:v.onShapeClone,onBoundsChange:v.updateBounds,onKeyDown:v.onKeyDown,onKeyUp:v.onKeyUp,onDragOver:v.onDragOver,onDrop:v.onDrop}))),d&&l.createElement(Fje,{ref:w},T.isFocusMode?l.createElement(HOe,{onSelect:v.toggleFocusMode}):l.createElement(l.Fragment,null,l.createElement(PHe,{readOnly:u,showPages:n,showMenu:r,showMultiplayerMenu:i,showStyles:a,showZoom:o}),l.createElement(Lje,null),s&&!u&&l.createElement(mNe,null))))))}),$je=l.memo(function({focusableRef:e,autofocus:t}){return Bne(e),$ne(),l.useEffect(()=>{var n;t&&((n=e.current)==null||n.focus())},[t]),null}),Rje=fe("div",{position:"absolute",height:"100%",width:"100%",minHeight:0,minWidth:0,maxHeight:"100%",maxWidth:"100%",overflow:"hidden",boxSizing:"border-box",outline:"none","& .tl-container":{position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:1},"& input, textarea, button, select, label, button":{webkitTouchCallout:"none",webkitUserSelect:"none","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent"}}),Fje=fe("div",{position:"absolute",top:0,left:0,height:"100%",width:"100%",padding:"8px 8px 0 8px",display:"flex",alignItems:"flex-start",justifyContent:"flex-start",pointerEvents:"none",zIndex:2,"& > *":{pointerEvents:"all"}}),Lje=fe("div",{flexGrow:2});const Oje=e=>{const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),t},_je=typeof performance<"u"?performance:Date,Nje=()=>_je.now();function JS(e,t=30,n=!1){const r=Oje(e),i=1e3/t,o=l.useRef(0),a=l.useRef(),s=()=>a.current&&clearTimeout(a.current),u=[t,n,r];function d(){o.current=0,s()}return l.useEffect(()=>d,u),l.useCallback(function(){const h=arguments,p=Nje(),g=()=>{o.current=p,s(),r.current.apply(null,h)},m=o.current;if(n&&m===0)return g();if(p-m>i){if(m>0)return g();o.current=p}s(),a.current=setTimeout(()=>{g(),o.current=0},i)},u)}var vt;(function(e){e[e.Canceled=1]="Canceled",e[e.Unknown=2]="Unknown",e[e.InvalidArgument=3]="InvalidArgument",e[e.DeadlineExceeded=4]="DeadlineExceeded",e[e.NotFound=5]="NotFound",e[e.AlreadyExists=6]="AlreadyExists",e[e.PermissionDenied=7]="PermissionDenied",e[e.ResourceExhausted=8]="ResourceExhausted",e[e.FailedPrecondition=9]="FailedPrecondition",e[e.Aborted=10]="Aborted",e[e.OutOfRange=11]="OutOfRange",e[e.Unimplemented=12]="Unimplemented",e[e.Internal=13]="Internal",e[e.Unavailable=14]="Unavailable",e[e.DataLoss=15]="DataLoss",e[e.Unauthenticated=16]="Unauthenticated"})(vt||(vt={}));function WS(e){const t=vt[e];return typeof t!="string"?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}class Nt extends Error{constructor(t,n=vt.Unknown,r,i,o){super(zje(t,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=n,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=o}static from(t,n=vt.Unknown){return t instanceof Nt?t:t instanceof Error?t.name=="AbortError"?new Nt(t.message,vt.Canceled):new Nt(t.message,n,void 0,void 0,t):new Nt(String(t),n,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===Nt.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const n="typeName"in t?{findMessage:i=>i===t.typeName?t:void 0}:t,r=[];for(const i of this.details){if("getType"in i){n.findMessage(i.getType().typeName)&&r.push(i);continue}const o=n.findMessage(i.type);if(o)try{r.push(o.fromBinary(i.value))}catch{}}return r}}function zje(e,t){return e.length?`[${WS(t)}] ${e}`:`[${WS(t)}]`}function en(e,t){if(!e)throw new Error(t)}const Hje=34028234663852886e22,jje=-34028234663852886e22,Uje=4294967295,Kje=2147483647,Vje=-2147483648;function Vp(e){if(typeof e!="number")throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>Kje||eUje||e<0)throw new Error("invalid uint 32: "+e)}function iP(e){if(typeof e!="number")throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>Hje||e({no:i.no,name:i.name,localName:e[i.no]})))}function sP(e,t,n){const r=Object.create(null),i=Object.create(null),o=[];for(const a of t){const s=uP(a);o.push(s),r[a.name]=s,i[a.no]=s}return{typeName:e,values:o,findName(a){return r[a]},findNumber(a){return i[a]}}}function Jje(e,t,n){const r={};for(const i of t){const o=uP(i);r[o.localName]=o.no,r[o.no]=o.localName}return aP(r,e,t),r}function uP(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class ve{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,n){const r=this.getType(),i=r.runtime.bin,o=i.makeReadOptions(n);return i.readMessage(this,o.readerFactory(t),t.byteLength,o),this}fromJson(t,n){const r=this.getType(),i=r.runtime.json,o=i.makeReadOptions(n);return i.readMessage(r,t,o,this),this}fromJsonString(t,n){let r;try{r=JSON.parse(t)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,n)}toBinary(t){const n=this.getType(),r=n.runtime.bin,i=r.makeWriteOptions(t),o=i.writerFactory();return r.writeMessage(this,o,i),o.finish()}toJson(t){const n=this.getType(),r=n.runtime.json,i=r.makeWriteOptions(t);return r.writeMessage(this,i)}toJsonString(t){var n;const r=this.toJson(t);return JSON.stringify(r,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Wje(e,t,n,r){var i;const o=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:t.substring(t.lastIndexOf(".")+1),a={[o]:function(s){e.util.initFields(this),e.util.initPartial(s,this)}}[o];return Object.setPrototypeOf(a.prototype,new ve),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary(s,u){return new a().fromBinary(s,u)},fromJson(s,u){return new a().fromJson(s,u)},fromJsonString(s,u){return new a().fromJsonString(s,u)},equals(s,u){return e.util.equals(a,s,u)}}),a}function Yje(){let e=0,t=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>4,!(n&128))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(t|=(i&127)<>>o,s=!(!(a>>>7)&&t==0),u=(s?a|128:a)&255;if(n.push(u),!s)return}const r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),!!i){for(let o=3;o<31;o=o+7){const a=t>>>o,s=!!(a>>>7),u=(s?a|128:a)&255;if(n.push(u),!s)return}n.push(t>>>31&1)}}const Gp=4294967296;function YS(e){const t=e[0]==="-";t&&(e=e.slice(1));const n=1e6;let r=0,i=0;function o(a,s){const u=Number(e.slice(a,s));i*=n,r=r*n+u,r>=Gp&&(i=i+(r/Gp|0),r=r%Gp)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?cP(r,i):$C(r,i)}function qje(e,t){let n=$C(e,t);const r=n.hi&2147483648;r&&(n=cP(n.lo,n.hi));const i=lP(n.lo,n.hi);return r?"-"+i:i}function lP(e,t){if({lo:e,hi:t}=Xje(e,t),t<=2097151)return String(Gp*t+e);const n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535;let o=n+r*6777216+i*6710656,a=r+i*8147497,s=i*2;const u=1e7;return o>=u&&(a+=Math.floor(o/u),o%=u),a>=u&&(s+=Math.floor(a/u),a%=u),s.toString()+qS(a)+qS(o)}function Xje(e,t){return{lo:e>>>0,hi:t>>>0}}function $C(e,t){return{lo:e|0,hi:t|0}}function cP(e,t){return t=~t,e?e=~e+1:t+=1,$C(e,t)}const qS=e=>{const t=String(e);return"0000000".slice(t.length)+t};function XS(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e=e>>7;t.push(1)}}function Zje(){let e=this.buf[this.pos++],t=e&127;if(!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let n=5;e&128&&n<10;n++)e=this.buf[this.pos++];if(e&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var ZS={};function Qje(){const e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||typeof ZS!="object"||ZS.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),a=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const d=typeof u=="bigint"?u:BigInt(u);if(d>o||ds||den(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>en(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),n(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),n(i),YS(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),YS(i)},dec(i,o){return qje(i,o)},uDec(i,o){return lP(i,o)}}}const zt=Qje();var re;(function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"})(re||(re={}));var Iu;(function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"})(Iu||(Iu={}));function Js(e,t,n){if(t===n)return!0;if(e==re.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let r=0;r>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Jy(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Vp(t),XS(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let n=this.textEncoder.encode(t);return this.uint32(n.byteLength),this.raw(n)}float(t){iP(t);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,t,!0),this.raw(n)}double(t){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,t,!0),this.raw(n)}fixed32(t){Jy(t);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t,!0),this.raw(n)}sfixed32(t){Vp(t);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,t,!0),this.raw(n)}sint32(t){return Vp(t),t=(t<<1^t>>31)>>>0,XS(t,this.buf),this}sfixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),i=zt.enc(t);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}fixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),i=zt.uEnc(t);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}int64(t){let n=zt.enc(t);return Zv(n.lo,n.hi,this.buf),this}sint64(t){let n=zt.enc(t),r=n.hi>>31,i=n.lo<<1^r,o=(n.hi<<1|n.lo>>>31)^r;return Zv(i,o,this.buf),this}uint64(t){let n=zt.uEnc(t);return Zv(n.lo,n.hi,this.buf),this}}class tUe{constructor(t,n){this.varint64=Yje,this.uint32=Zje,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=n??new TextDecoder}tag(){let t=this.uint32(),n=t>>>3,r=t&7;if(n<=0||r<0||r>5)throw new Error("illegal tag: field no "+n+" wire type "+r);return[n,r]}skip(t,n){let r=this.pos;switch(t){case sn.Varint:for(;this.buf[this.pos++]&128;);break;case sn.Bit64:this.pos+=4;case sn.Bit32:this.pos+=4;break;case sn.LengthDelimited:let i=this.uint32();this.pos+=i;break;case sn.StartGroup:for(;;){const[o,a]=this.tag();if(a===sn.EndGroup){if(n!==void 0&&o!==n)throw new Error("invalid end group tag");break}this.skip(a,o)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return zt.dec(...this.varint64())}uint64(){return zt.uDec(...this.varint64())}sint64(){let[t,n]=this.varint64(),r=-(t&1);return t=(t>>>1|(n&1)<<31)^r,n=n>>>1^r,zt.dec(t,n)}bool(){let[t,n]=this.varint64();return t!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),n=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(n,n+t)}string(){return this.textDecoder.decode(this.bytes())}}function nUe(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){const o=typeof r=="function"?r():r;o.name=t.split(".").pop(),o.jsonName=`[${t}]`,i=e.util.newFieldList([o]).list()[0]}return i},runtime:e}}function hP(e){const t=e.field.localName,n=Object.create(null);return n[t]=rUe(e),[n,()=>n[t]]}function rUe(e){const t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return ad(t.T,t.L);case"message":const n=t.T,r=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function iUe(e,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(n=>n.no===t.no)}let ss="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),v1=[];for(let e=0;e>4,a=o,i=2;break;case 2:n[r++]=(a&15)<<4|(o&60)>>2,a=o,i=3;break;case 3:n[r++]=(a&3)<<6|o,i=0;break}}if(i==1)throw Error("invalid base64 string.");return n.subarray(0,r)},enc(e){let t="",n=0,r,i=0;for(let o=0;o>2],i=(r&3)<<4,n=1;break;case 1:t+=ss[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=ss[i|r>>6],t+=ss[r&63],n=0;break}return n&&(t+=ss[i],t+="=",n==1&&(t+="=")),t}};function oUe(e,t,n){pP(t,e);const r=t.runtime.bin.makeReadOptions(n),i=iUe(e.getType().runtime.bin.listUnknownFields(e),t.field),[o,a]=hP(t);for(const s of i)t.runtime.bin.readField(o,r.readerFactory(s.data),t.field,s.wireType,r);return a()}function aUe(e,t,n,r){pP(t,e);const i=t.runtime.bin.makeReadOptions(r),o=t.runtime.bin.makeWriteOptions(r);if(fP(e,t)){const d=e.getType().runtime.bin.listUnknownFields(e).filter(h=>h.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(const h of d)e.getType().runtime.bin.onUnknownField(e,h.no,h.wireType,h.data)}const a=o.writerFactory();let s=t.field;!s.opt&&!s.repeated&&(s.kind=="enum"||s.kind=="scalar")&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,a,o);const u=i.readerFactory(a.finish());for(;u.posr.no==t.field.no)}function pP(e,t){en(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function gP(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?t[n]!==void 0:e.kind=="enum"?t[n]!==e.T.values[0].no:!dP(e.T,t[n]);case"message":return t[n]!==void 0;case"map":return Object.keys(t[n]).length>0}}function QS(e,t){const n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=r?e.T.values[0].no:void 0;break;case"scalar":t[n]=r?ad(e.T,e.L):void 0;break;case"message":t[n]=void 0;break}}function gl(e,t){if(e===null||typeof e!="object"||!Object.getOwnPropertyNames(ve.prototype).every(r=>r in e&&typeof e[r]=="function"))return!1;const n=e.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:t===void 0?!0:n.typeName==t.typeName}function mP(e,t){return gl(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}re.DOUBLE,re.FLOAT,re.INT64,re.UINT64,re.INT32,re.UINT32,re.BOOL,re.STRING,re.BYTES;const ex={ignoreUnknownFields:!1},tx={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function sUe(e){return e?Object.assign(Object.assign({},ex),e):ex}function uUe(e){return e?Object.assign(Object.assign({},tx),e):tx}const Hg=Symbol(),Jp=Symbol();function lUe(){return{makeReadOptions:sUe,makeWriteOptions:uUe,readMessage(e,t,n,r){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${e.typeName} from JSON: ${So(t)}`);r=r??new e;const i=new Map,o=n.typeRegistry;for(const[a,s]of Object.entries(t)){const u=e.fields.findJsonName(a);if(u){if(u.oneof){if(s===null&&u.kind=="scalar")continue;const d=i.get(u.oneof);if(d!==void 0)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${d}", "${a}"`);i.set(u.oneof,a)}nx(r,s,u,n,e)}else{let d=!1;if(o!=null&&o.findExtension&&a.startsWith("[")&&a.endsWith("]")){const h=o.findExtension(a.substring(1,a.length-1));if(h&&h.extendee.typeName==e.typeName){d=!0;const[p,g]=hP(h);nx(p,s,h.field,n,h),aUe(r,h,g(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${a}" is unknown`)}}return r},writeMessage(e,t){const n=e.getType(),r={};let i;try{for(i of n.fields.byNumber()){if(!gP(i,e)){if(i.req)throw"required field not set";if(!t.emitDefaultValues||!dUe(i))continue}const a=i.oneof?e[i.oneof.localName].value:e[i.localName],s=rx(i,a,t);s!==void 0&&(r[t.useProtoFieldName?i.name:i.jsonName]=s)}const o=t.typeRegistry;if(o!=null&&o.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(e)){const s=o.findExtensionFor(n.typeName,a.no);if(s&&fP(e,s)){const u=oUe(e,s,t),d=rx(s.field,u,t);d!==void 0&&(r[s.field.jsonName]=d)}}}catch(o){const a=i?`cannot encode field ${n.typeName}.${i.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,s=o instanceof Error?o.message:String(o);throw new Error(a+(s.length>0?`: ${s}`:""))}return r},readScalar(e,t,n){return M0(e,t,n??Iu.BIGINT,!0)},writeScalar(e,t,n){if(t!==void 0&&(n||dP(e,t)))return Wp(e,t)},debug:So}}function So(e){if(e===null)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function nx(e,t,n,r,i){let o=n.localName;if(n.repeated){if(en(n.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`);const a=e[o];for(const s of t){if(s===null)throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(s)}`);switch(n.kind){case"message":a.push(n.T.fromJson(s,r));break;case"enum":const u=Qv(n.T,s,r.ignoreUnknownFields,!0);u!==Jp&&a.push(u);break;case"scalar":try{a.push(M0(n.T,s,n.L,!0))}catch(d){let h=`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(s)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}break}}}else if(n.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`);const a=e[o];for(const[s,u]of Object.entries(t)){if(u===null)throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: map value null`);let d;try{d=cUe(n.K,s)}catch(h){let p=`cannot decode map key for field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw h instanceof Error&&h.message.length>0&&(p+=`: ${h.message}`),new Error(p)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(u,r);break;case"enum":const h=Qv(n.V.T,u,r.ignoreUnknownFields,!0);h!==Jp&&(a[d]=h);break;case"scalar":try{a[d]=M0(n.V.T,u,Iu.BIGINT,!0)}catch(p){let g=`cannot decode map value for field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw p instanceof Error&&p.message.length>0&&(g+=`: ${p.message}`),new Error(g)}break}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:o},o="value"),n.kind){case"message":const a=n.T;if(t===null&&a.typeName!="google.protobuf.Value")return;let s=e[o];gl(s)?s.fromJson(t,r):(e[o]=s=a.fromJson(t,r),a.fieldWrapper&&!n.oneof&&(e[o]=a.fieldWrapper.unwrapField(s)));break;case"enum":const u=Qv(n.T,t,r.ignoreUnknownFields,!1);switch(u){case Hg:QS(n,e);break;case Jp:break;default:e[o]=u;break}break;case"scalar":try{const d=M0(n.T,t,n.L,!1);switch(d){case Hg:QS(n,e);break;default:e[o]=d;break}}catch(d){let h=`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}break}}function cUe(e,t){if(e===re.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return M0(e,t,Iu.BIGINT,!0).toString()}function M0(e,t,n,r){if(t===null)return r?ad(e,n):Hg;switch(e){case re.DOUBLE:case re.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const i=Number(t);if(Number.isNaN(i)||!Number.isFinite(i))break;return e==re.FLOAT&&iP(i),i;case re.INT32:case re.FIXED32:case re.SFIXED32:case re.SINT32:case re.UINT32:let o;if(typeof t=="number"?o=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),o===void 0)break;return e==re.UINT32||e==re.FIXED32?Jy(o):Vp(o),o;case re.INT64:case re.SFIXED64:case re.SINT64:if(typeof t!="number"&&typeof t!="string")break;const a=zt.parse(t);return n?a.toString():a;case re.FIXED64:case re.UINT64:if(typeof t!="number"&&typeof t!="string")break;const s=zt.uParse(t);return n?s.toString():s;case re.BOOL:if(typeof t!="boolean")break;return t;case re.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case re.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return RC.dec(t)}throw new Error}function Qv(e,t,n,r){if(t===null)return e.typeName=="google.protobuf.NullValue"?0:r?e.values[0].no:Hg;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const i=e.findName(t);if(i!==void 0)return i.no;if(n)return Jp;break}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${So(t)}`)}function dUe(e){return e.repeated||e.kind=="map"?!0:!(e.oneof||e.kind=="message"||e.opt||e.req)}function rx(e,t,n){if(e.kind=="map"){en(typeof t=="object"&&t!=null);const r={},i=Object.entries(t);switch(e.V.kind){case"scalar":for(const[a,s]of i)r[a.toString()]=Wp(e.V.T,s);break;case"message":for(const[a,s]of i)r[a.toString()]=s.toJson(n);break;case"enum":const o=e.V.T;for(const[a,s]of i)r[a.toString()]=e2(o,s,n.enumAsInteger);break}return n.emitDefaultValues||i.length>0?r:void 0}if(e.repeated){en(Array.isArray(t));const r=[];switch(e.kind){case"scalar":for(let i=0;i0?r:void 0}switch(e.kind){case"scalar":return Wp(e.T,t);case"enum":return e2(e.T,t,n.enumAsInteger);case"message":return mP(e.T,t).toJson(n)}}function e2(e,t,n){var r;if(en(typeof t=="number"),e.typeName=="google.protobuf.NullValue")return null;if(n)return t;const i=e.findNumber(t);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:t}function Wp(e,t){switch(e){case re.INT32:case re.SFIXED32:case re.SINT32:case re.FIXED32:case re.UINT32:return en(typeof t=="number"),t;case re.FLOAT:case re.DOUBLE:return en(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case re.STRING:return en(typeof t=="string"),t;case re.BOOL:return en(typeof t=="boolean"),t;case re.UINT64:case re.FIXED64:case re.INT64:case re.SFIXED64:case re.SINT64:return en(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case re.BYTES:return en(t instanceof Uint8Array),RC.enc(t)}}const cc=Symbol("@bufbuild/protobuf/unknown-fields"),ix={readUnknownFields:!0,readerFactory:e=>new tUe(e)},ox={writeUnknownFields:!0,writerFactory:()=>new eUe};function hUe(e){return e?Object.assign(Object.assign({},ix),e):ix}function fUe(e){return e?Object.assign(Object.assign({},ox),e):ox}function pUe(){return{makeReadOptions:hUe,makeWriteOptions:fUe,listUnknownFields(e){var t;return(t=e[cc])!==null&&t!==void 0?t:[]},discardUnknownFields(e){delete e[cc]},writeUnknownFields(e,t){const r=e[cc];if(r)for(const i of r)t.tag(i.no,i.wireType).raw(i.data)},onUnknownField(e,t,n,r){const i=e;Array.isArray(i[cc])||(i[cc]=[]),i[cc].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,i){const o=e.getType(),a=i?t.len:t.pos+n;let s,u;for(;t.pos0&&(u=mUe),o){let g=e[a];if(r==sn.LengthDelimited&&s!=re.STRING&&s!=re.BYTES){let v=t.uint32()+t.pos;for(;t.posgl(g,p)?g:new p(g));else{const g=a[i];p.fieldWrapper?p.typeName==="google.protobuf.BytesValue"?o[i]=a0(g):o[i]=g:o[i]=gl(g,p)?g:new p(g)}break}}},equals(e,t,n){return t===n?!0:!t||!n?!1:e.fields.byMember().every(r=>{const i=t[r.localName],o=n[r.localName];if(r.repeated){if(i.length!==o.length)return!1;switch(r.kind){case"message":return i.every((a,s)=>r.T.equals(a,o[s]));case"scalar":return i.every((a,s)=>Js(r.T,a,o[s]));case"enum":return i.every((a,s)=>Js(re.INT32,a,o[s]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,o);case"enum":return Js(re.INT32,i,o);case"scalar":return Js(r.T,i,o);case"oneof":if(i.case!==o.case)return!1;const a=r.findField(i.case);if(a===void 0)return!0;switch(a.kind){case"message":return a.T.equals(i.value,o.value);case"enum":return Js(re.INT32,i.value,o.value);case"scalar":return Js(a.T,i.value,o.value)}throw new Error(`oneof cannot contain ${a.kind}`);case"map":const s=Object.keys(i).concat(Object.keys(o));switch(r.V.kind){case"message":const u=r.V.T;return s.every(h=>u.equals(i[h],o[h]));case"enum":return s.every(h=>Js(re.INT32,i[h],o[h]));case"scalar":const d=r.V.T;return s.every(h=>Js(d,i[h],o[h]))}break}})},clone(e){const t=e.getType(),n=new t,r=n;for(const i of t.fields.byMember()){const o=e[i.localName];let a;if(i.repeated)a=o.map(wp);else if(i.kind=="map"){a=r[i.localName];for(const[s,u]of Object.entries(o))a[s]=wp(u)}else i.kind=="oneof"?a=i.findField(o.case)?{case:o.case,value:wp(o.value)}:{case:void 0}:a=wp(o);r[i.localName]=a}for(const i of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return n}}}function wp(e){if(e===void 0)return e;if(gl(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function a0(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function CUe(e,t,n){return{syntax:e,json:lUe(),bin:pUe(),util:Object.assign(Object.assign({},EUe()),{newFieldList:t,initFields:n}),makeMessageType(r,i,o){return Wje(this,r,i,o)},makeEnum:Jje,makeEnumType:sP,getEnumType:Gje,makeExtension(r,i,o){return nUe(this,r,i,o)}}}class bUe{constructor(t,n){this._fields=t,this._normalizer=n}findJsonName(t){if(!this.jsonNames){const n={};for(const r of this.list())n[r.jsonName]=n[r.name]=r;this.jsonNames=n}return this.jsonNames[t]}find(t){if(!this.numbers){const n={};for(const r of this.list())n[r.no]=r;this.numbers=n}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,n)=>t.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let n;for(const r of this.list())r.oneof?r.oneof!==n&&(n=r.oneof,t.push(n)):t.push(r)}return this.members}}function yP(e,t){const n=EP(e);return t?n:IUe(kUe(n))}function wUe(e){return yP(e,!1)}const SUe=EP;function EP(e){let t=!1;const n=[];for(let r=0;r`${e}$`,kUe=e=>AUe.has(e)?CP(e):e,IUe=e=>xUe.has(e)?CP(e):e;class DUe{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=wUe(t)}addField(t){en(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;nnew bUe(e,t=>TUe(t)),e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,r=e;if(t.repeated){r[n]=[];continue}switch(t.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=ad(t.T,t.L);break}}});var ir;(function(e){e[e.Unary=0]="Unary",e[e.ServerStreaming=1]="ServerStreaming",e[e.ClientStreaming=2]="ClientStreaming",e[e.BiDiStreaming=3]="BiDiStreaming"})(ir||(ir={}));var lx;(function(e){e[e.NoSideEffects=1]="NoSideEffects",e[e.Idempotent=2]="Idempotent"})(lx||(lx={}));class Vn extends ve{constructor(t){super(),this.seconds=zt.zero,this.nanos=0,R.util.initPartial(t,this)}fromJson(t,n){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${R.json.debug(t)}`);const r=t.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=zt.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(t){const n=Number(this.seconds)*1e3;if(nDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(n).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Vn.fromDate(new Date)}static fromDate(t){const n=t.getTime();return new Vn({seconds:zt.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(t,n){return new Vn().fromBinary(t,n)}static fromJson(t,n){return new Vn().fromJson(t,n)}static fromJsonString(t,n){return new Vn().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Vn,t,n)}}Vn.runtime=R;Vn.typeName="google.protobuf.Timestamp";Vn.fields=R.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class cs extends ve{constructor(t){super(),this.seconds=zt.zero,this.nanos=0,R.util.initPartial(t,this)}fromJson(t,n){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);const r=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);if(this.seconds=zt.parse(i),typeof r[2]=="string"){const o=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(o),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let n=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),n+="."+r,this.nanos<0&&Number(this.seconds)==0&&(n="-"+n)}return n+"s"}static fromBinary(t,n){return new cs().fromBinary(t,n)}static fromJson(t,n){return new cs().fromJson(t,n)}static fromJsonString(t,n){return new cs().fromJsonString(t,n)}static equals(t,n){return R.util.equals(cs,t,n)}}cs.runtime=R;cs.typeName="google.protobuf.Duration";cs.fields=R.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class ko extends ve{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),R.util.initPartial(t,this)}toJson(t){var n;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(n=t==null?void 0:t.typeRegistry)===null||n===void 0?void 0:n.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let a=i.fromBinary(this.value).toJson(t);return(r.startsWith("google.protobuf.")||a===null||Array.isArray(a)||typeof a!="object")&&(a={value:a}),a["@type"]=this.typeUrl,a}fromJson(t,n){var r;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const i=t["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const o=this.typeUrlToName(i),a=(r=n==null?void 0:n.typeRegistry)===null||r===void 0?void 0:r.findMessage(o);if(!a)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let s;if(o.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))s=a.fromJson(t.value,n);else{const u=Object.assign({},t);delete u["@type"],s=a.fromJson(u,n)}return this.packFrom(s),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const n=t.findMessage(this.typeUrlToName(this.typeUrl));if(n)return n.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const n=this.typeUrlToName(this.typeUrl);let r="";return typeof t=="string"?r=t:r=t.typeName,n===r}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const n=t.lastIndexOf("/"),r=n>=0?t.substring(n+1):t;if(!r.length)throw new Error(`invalid type url: ${t}`);return r}static pack(t){const n=new ko;return n.packFrom(t),n}static fromBinary(t,n){return new ko().fromBinary(t,n)}static fromJson(t,n){return new ko().fromJson(t,n)}static fromJsonString(t,n){return new ko().fromJsonString(t,n)}static equals(t,n){return R.util.equals(ko,t,n)}}ko.runtime=R;ko.typeName="google.protobuf.Any";ko.fields=R.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class To extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.DOUBLE,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.DOUBLE,t)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new To().fromBinary(t,n)}static fromJson(t,n){return new To().fromJson(t,n)}static fromJsonString(t,n){return new To().fromJsonString(t,n)}static equals(t,n){return R.util.equals(To,t,n)}}To.runtime=R;To.typeName="google.protobuf.DoubleValue";To.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);To.fieldWrapper={wrapField(e){return new To({value:e})},unwrapField(e){return e.value}};class Po extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.FLOAT,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.FLOAT,t)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Po().fromBinary(t,n)}static fromJson(t,n){return new Po().fromJson(t,n)}static fromJsonString(t,n){return new Po().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Po,t,n)}}Po.runtime=R;Po.typeName="google.protobuf.FloatValue";Po.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Po.fieldWrapper={wrapField(e){return new Po({value:e})},unwrapField(e){return e.value}};class Bo extends ve{constructor(t){super(),this.value=zt.zero,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.INT64,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.INT64,t)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Bo().fromBinary(t,n)}static fromJson(t,n){return new Bo().fromJson(t,n)}static fromJsonString(t,n){return new Bo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Bo,t,n)}}Bo.runtime=R;Bo.typeName="google.protobuf.Int64Value";Bo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Bo.fieldWrapper={wrapField(e){return new Bo({value:e})},unwrapField(e){return e.value}};class Mo extends ve{constructor(t){super(),this.value=zt.zero,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.UINT64,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.UINT64,t)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Mo().fromBinary(t,n)}static fromJson(t,n){return new Mo().fromJson(t,n)}static fromJsonString(t,n){return new Mo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Mo,t,n)}}Mo.runtime=R;Mo.typeName="google.protobuf.UInt64Value";Mo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Mo.fieldWrapper={wrapField(e){return new Mo({value:e})},unwrapField(e){return e.value}};class $o extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.INT32,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.INT32,t)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new $o().fromBinary(t,n)}static fromJson(t,n){return new $o().fromJson(t,n)}static fromJsonString(t,n){return new $o().fromJsonString(t,n)}static equals(t,n){return R.util.equals($o,t,n)}}$o.runtime=R;$o.typeName="google.protobuf.Int32Value";$o.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);$o.fieldWrapper={wrapField(e){return new $o({value:e})},unwrapField(e){return e.value}};class Ro extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.UINT32,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.UINT32,t)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Ro().fromBinary(t,n)}static fromJson(t,n){return new Ro().fromJson(t,n)}static fromJsonString(t,n){return new Ro().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Ro,t,n)}}Ro.runtime=R;Ro.typeName="google.protobuf.UInt32Value";Ro.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Ro.fieldWrapper={wrapField(e){return new Ro({value:e})},unwrapField(e){return e.value}};class Fo extends ve{constructor(t){super(),this.value=!1,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.BOOL,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.BOOL,t)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Fo().fromBinary(t,n)}static fromJson(t,n){return new Fo().fromJson(t,n)}static fromJsonString(t,n){return new Fo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Fo,t,n)}}Fo.runtime=R;Fo.typeName="google.protobuf.BoolValue";Fo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Fo.fieldWrapper={wrapField(e){return new Fo({value:e})},unwrapField(e){return e.value}};class _r extends ve{constructor(t){super(),this.value="",R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.STRING,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.STRING,t)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new _r().fromBinary(t,n)}static fromJson(t,n){return new _r().fromJson(t,n)}static fromJsonString(t,n){return new _r().fromJsonString(t,n)}static equals(t,n){return R.util.equals(_r,t,n)}}_r.runtime=R;_r.typeName="google.protobuf.StringValue";_r.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);_r.fieldWrapper={wrapField(e){return new _r({value:e})},unwrapField(e){return e.value}};class Lo extends ve{constructor(t){super(),this.value=new Uint8Array(0),R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.BYTES,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.BYTES,t)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Lo().fromBinary(t,n)}static fromJson(t,n){return new Lo().fromJson(t,n)}static fromJsonString(t,n){return new Lo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Lo,t,n)}}Lo.runtime=R;Lo.typeName="google.protobuf.BytesValue";Lo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Lo.fieldWrapper={wrapField(e){return new Lo({value:e})},unwrapField(e){return e.value}};function PUe(e,t,n){try{const r=RC.dec(e);return t?t.fromBinary(r,n):r}catch(r){throw Nt.from(r,vt.DataLoss)}}function BUe(e,t){const n={};for(const[r,i]of Object.entries(e.methods)){const o=t(Object.assign(Object.assign({},i),{localName:r,service:e}));o!=null&&(n[r]=o)}return n}function cx(e){let t,n=new Uint8Array(0);function r(i){const o=new Uint8Array(n.length+i.length);o.set(n),o.set(i,n.length),n=o}return new ReadableStream({start(){t=e.getReader()},async pull(i){let o;for(;;){if(o===void 0&&n.byteLength>=5){let u=0;for(let d=1;d<5;d++)u=(u<<8)+n[d];o={flags:n[0],length:u}}if(o!==void 0&&n.byteLength>=o.length+5)break;const s=await t.read();if(s.done)break;r(s.value)}if(o===void 0){if(n.byteLength==0){i.close();return}i.error(new Nt("premature end of stream",vt.DataLoss));return}const a=n.subarray(5,5+o.length);n=n.subarray(5+o.length),i.enqueue({flags:o.flags,data:a})}})}function dx(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}var MUe=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(s,u){a=e[o](a),i(s,u,a.done,a.value)})}}function i(o,a,s,u){Promise.resolve(u).then(function(d){o({value:d,done:s})},a)}},sh=function(e){return this instanceof sh?(this.v=e,this):new sh(e)},$Ue=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof sh?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}},RUe=function(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,o){t[i]=e[i]?function(a){return(n=!n)?{value:sh(e[i](a)),done:!1}:o?o(a):a}:o}};function FUe(e){return $Ue(this,arguments,function*(){yield sh(yield*RUe(MUe(e)))})}var bP=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(s,u){a=e[o](a),i(s,u,a.done,a.value)})}}function i(o,a,s,u){Promise.resolve(u).then(function(d){o({value:d,done:s})},a)}},sd=function(e){return this instanceof sd?(this.v=e,this):new sd(e)},LUe=function(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,o){t[i]=e[i]?function(a){return(n=!n)?{value:sd(e[i](a)),done:!1}:o?o(a):a}:o}},OUe=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof sd?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}};function _Ue(e,t){return BUe(e,n=>{switch(n.kind){case ir.Unary:return NUe(t,e,n);case ir.ServerStreaming:return zUe(t,e,n);case ir.ClientStreaming:return HUe(t,e,n);case ir.BiDiStreaming:return jUe(t,e,n);default:return null}})}function NUe(e,t,n){return async function(r,i){var o,a;const s=await e.unary(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(o=i==null?void 0:i.onHeader)===null||o===void 0||o.call(i,s.header),(a=i==null?void 0:i.onTrailer)===null||a===void 0||a.call(i,s.trailer),s.message}}function zUe(e,t,n){return function(r,i){return wP(e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,FUe([r]),i==null?void 0:i.contextValues),i)}}function HUe(e,t,n){return async function(r,i){var o,a,s,u,d,h;const p=await e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(d=i==null?void 0:i.onHeader)===null||d===void 0||d.call(i,p.header);let g;try{for(var m=!0,v=bP(p.message),E;E=await v.next(),o=E.done,!o;m=!0)u=E.value,m=!1,g=u}catch(w){a={error:w}}finally{try{!m&&!o&&(s=v.return)&&await s.call(v)}finally{if(a)throw a.error}}if(!g)throw new Nt("protocol error: missing response message",vt.Internal);return(h=i==null?void 0:i.onTrailer)===null||h===void 0||h.call(i,p.trailer),g}}function jUe(e,t,n){return function(r,i){return wP(e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function wP(e,t){const n=function(){var r,i;return OUe(this,arguments,function*(){const o=yield sd(e);(r=t==null?void 0:t.onHeader)===null||r===void 0||r.call(t,o.header),yield sd(yield*LUe(bP(o.message))),(i=t==null?void 0:t.onTrailer)===null||i===void 0||i.call(t,o.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function UUe(...e){const t=new AbortController,n=e.filter(i=>i!==void 0).concat(t.signal);for(const i of n){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(SP(this));for(const i of n)i.removeEventListener("abort",r)}return t}function KUe(e){const t=new AbortController,n=()=>{t.abort(new Nt("the operation timed out",vt.DeadlineExceeded))};let r;return e!==void 0&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function SP(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function hx(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}const t2=128;function fx(e){const t=new Headers,n=new TextDecoder().decode(e).split(`\r -`);for(const r of n){if(r==="")continue;const i=r.indexOf(":");if(i>0){const o=r.substring(0,i).trim(),a=r.substring(i+1).trim();t.append(o,a)}}return t}const VUe="Content-Type",GUe="Grpc-Timeout",xP="Grpc-Status",AP="Grpc-Message",JUe="Grpc-Status-Details-Bin",WUe="X-User-Agent",YUe="X-Grpc-Web",qUe="application/grpc-web+proto",XUe="application/grpc-web+json";class ds extends ve{constructor(t){super(),this.code=0,this.message="",this.details=[],R.util.initPartial(t,this)}static fromBinary(t,n){return new ds().fromBinary(t,n)}static fromJson(t,n){return new ds().fromJson(t,n)}static fromJsonString(t,n){return new ds().fromJsonString(t,n)}static equals(t,n){return R.util.equals(ds,t,n)}}ds.runtime=R;ds.typeName="google.rpc.Status";ds.fields=R.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:ko,repeated:!0}]);const ZUe="0";function kP(e){var t;const n=e.get(JUe);if(n!=null){const i=PUe(n,ds);if(i.code==0)return;const o=new Nt(i.message,i.code,e);return o.details=i.details.map(a=>({type:a.typeUrl.substring(a.typeUrl.lastIndexOf("/")+1),value:a.value})),o}const r=e.get(xP);if(r!=null){if(r===ZUe)return;const i=parseInt(r,10);return i in vt?new Nt(decodeURIComponent((t=e.get(AP))!==null&&t!==void 0?t:""),i,e):new Nt(`invalid grpc-status: ${r}`,vt.Internal,e)}}function px(e,t,n){const r=typeof t=="string"?t:t.typeName,i=typeof n=="string"?n:n.name;return e.toString().replace(/\/?$/,`/${r}/${i}`)}function IP(e,t){return t instanceof e?t:new e(t)}function QUe(e,t){function n(r){return r.done===!0?r:{done:r.done,value:IP(e,r.value)}}return{[Symbol.asyncIterator](){const r=t[Symbol.asyncIterator](),i={next:()=>r.next().then(n)};return r.throw!==void 0&&(i.throw=o=>r.throw(o).then(n)),r.return!==void 0&&(i.return=o=>r.return(o).then(n)),i}}}function DP(e,t){var n;return(n=t==null?void 0:t.concat().reverse().reduce((r,i)=>i(r),e))!==null&&n!==void 0?n:e}function eKe(e){var t;const n=Object.assign({},e);return(t=n.ignoreUnknownFields)!==null&&t!==void 0||(n.ignoreUnknownFields=!0),n}function gx(e,t,n,r){const i=t?mx(e.I,r):vx(e.I,n);return{parse:(t?mx(e.O,r):vx(e.O,n)).parse,serialize:i.serialize}}function mx(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(r){const i=r instanceof Error?r.message:String(r);throw new Nt(`parse binary: ${i}`,vt.InvalidArgument)}},serialize(n){try{return n.toBinary(t)}catch(r){const i=r instanceof Error?r.message:String(r);throw new Nt(`serialize binary: ${i}`,vt.Internal)}}}}function vx(e,t){var n,r;const i=(n=t==null?void 0:t.textEncoder)!==null&&n!==void 0?n:new TextEncoder,o=(r=t==null?void 0:t.textDecoder)!==null&&r!==void 0?r:new TextDecoder,a=eKe(t);return{parse(s){try{const u=o.decode(s);return e.fromJsonString(u,a)}catch(u){throw Nt.from(u,vt.InvalidArgument)}},serialize(s){try{const u=s.toJsonString(a);return i.encode(u)}catch(u){throw Nt.from(u,vt.Internal)}}}}function tKe(e){const t=DP(e.next,e.interceptors),[n,r,i]=TP(e),o=Object.assign(Object.assign({},e.req),{message:IP(e.req.method.I,e.req.message),signal:n});return t(o).then(a=>(i(),a),r)}function nKe(e){const t=DP(e.next,e.interceptors),[n,r,i]=TP(e),o=Object.assign(Object.assign({},e.req),{message:QUe(e.req.method.I,e.req.message),signal:n});let a=!1;return n.addEventListener("abort",function(){var s,u;const d=e.req.message[Symbol.asyncIterator]();a||(s=d.throw)===null||s===void 0||s.call(d,this.reason).catch(()=>{}),(u=d.return)===null||u===void 0||u.call(d).catch(()=>{})}),t(o).then(s=>Object.assign(Object.assign({},s),{message:{[Symbol.asyncIterator](){const u=s.message[Symbol.asyncIterator]();return{next(){return u.next().then(d=>(d.done==!0&&(a=!0,i()),d),r)}}}}}),r)}function TP(e){const{signal:t,cleanup:n}=KUe(e.timeoutMs),r=UUe(e.signal,t);return[r.signal,function(o){const a=Nt.from(t.aborted?SP(t):o);return r.abort(a),n(),Promise.reject(a)},function(){n(),r.abort()}]}function rKe(){try{new Headers}catch{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.")}}function yx(e,t){const n=kP(e);if(n)throw t.forEach((r,i)=>{n.metadata.append(i,r)}),n}function Ex(e,t,n,r){const i=new Headers(n??{});return i.set(VUe,e?qUe:XUe),i.set(YUe,"1"),i.set(WUe,"connect-es/1.4.0"),t!==void 0&&i.set(GUe,`${t}m`),i}function iKe(e){switch(e){case 400:return vt.Internal;case 401:return vt.Unauthenticated;case 403:return vt.PermissionDenied;case 404:return vt.Unimplemented;case 429:return vt.Unavailable;case 502:return vt.Unavailable;case 503:return vt.Unavailable;case 504:return vt.Unavailable;default:return vt.Unknown}}function Cx(e,t){var n;if(e>=200&&e<300){const r=kP(t);if(r)throw r;return{foundStatus:t.has(xP)}}throw new Nt(decodeURIComponent((n=t.get(AP))!==null&&n!==void 0?n:`HTTP ${e}`),iKe(e),t)}var ll=function(e){return this instanceof ll?(this.v=e,this):new ll(e)},oKe=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof ll?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}};function aKe(e){var t;rKe();const n=(t=e.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(r,i,o,a,s,u,d){var h;const{serialize:p,parse:g}=gx(i,n,e.jsonOptions,e.binaryOptions);return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await tKe({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!1,service:r,method:i,url:px(e.baseUrl,r,i),init:{method:"POST",credentials:(h=e.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Ex(n,a,s),contextValues:d??hx(),message:u},next:async m=>{var v;const w=await((v=e.fetch)!==null&&v!==void 0?v:globalThis.fetch)(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:dx(0,p(m.message))}));if(Cx(w.status,w.headers),!w.body)throw"missing response body";const C=cx(w.body).getReader();let b,A;for(;;){const T=await C.read();if(T.done)break;const{flags:B,data:D}=T.value;if(B===t2){if(b!==void 0)throw"extra trailer";b=fx(D);continue}if(A!==void 0)throw"extra message";A=g(D)}if(b===void 0)throw"missing trailer";if(yx(b,w.headers),A===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:w.headers,message:A,trailer:b}}})},async stream(r,i,o,a,s,u,d){var h;const{serialize:p,parse:g}=gx(i,n,e.jsonOptions,e.binaryOptions);function m(E,w,C,b){return oKe(this,arguments,function*(){const T=cx(E).getReader();if(w){if(!(yield ll(T.read())).done)throw"extra data for trailers-only";return yield ll(void 0)}let B=!1;for(;;){const D=yield ll(T.read());if(D.done)break;const{flags:I,data:M}=D.value;if((I&t2)===t2){if(B)throw"extra trailer";B=!0;const O=fx(M);yx(O,b),O.forEach((z,K)=>C.set(K,z));continue}if(B)throw"extra message";yield yield ll(g(M))}if(!B)throw"missing trailer"})}async function v(E){if(i.kind!=ir.ServerStreaming)throw"The fetch API does not support streaming request bodies";const w=await E[Symbol.asyncIterator]().next();if(w.done==!0)throw"missing request message";return dx(0,p(w.value))}return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,nKe({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!0,service:r,method:i,url:px(e.baseUrl,r,i),init:{method:"POST",credentials:(h=e.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Ex(n,a,s),contextValues:d??hx(),message:u},next:async E=>{var w;const b=await((w=e.fetch)!==null&&w!==void 0?w:globalThis.fetch)(E.url,Object.assign(Object.assign({},E.init),{headers:E.header,signal:E.signal,body:await v(E.message)})),{foundStatus:A}=Cx(b.status,b.headers);if(!b.body)throw"missing response body";const T=new Headers;return Object.assign(Object.assign({},E),{header:b.headers,trailer:T,message:m(b.body,A,T,b.headers)})}})}}}var Ve=(e=>(e[e.NULL=0]="NULL",e[e.BOOLEAN=1]="BOOLEAN",e[e.INTEGER=2]="INTEGER",e[e.LONG=3]="LONG",e[e.DOUBLE=4]="DOUBLE",e[e.STRING=5]="STRING",e[e.BYTES=6]="BYTES",e[e.DATE=7]="DATE",e[e.JSON_OBJECT=8]="JSON_OBJECT",e[e.JSON_ARRAY=9]="JSON_ARRAY",e[e.TEXT=10]="TEXT",e[e.INTEGER_CNT=11]="INTEGER_CNT",e[e.LONG_CNT=12]="LONG_CNT",e[e.TREE=13]="TREE",e))(Ve||{});R.util.setEnumType(Ve,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var ml=(e=>(e[e.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",e[e.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",e[e.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",e[e.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",e))(ml||{});R.util.setEnumType(ml,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const aa=class aa extends ve{constructor(n){super();k(this,"root");k(this,"presences",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new aa().fromBinary(n,r)}static fromJson(n,r){return new aa().fromJson(n,r)}static fromJsonString(n,r){return new aa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(aa,n,r)}};k(aa,"runtime",R),k(aa,"typeName","yorkie.v1.Snapshot"),k(aa,"fields",R.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:Sr},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:LC}}]));let Wy=aa;var ci;let Rs=(ci=class extends ve{constructor(n){super();k(this,"documentKey","");k(this,"checkpoint");k(this,"snapshot",new Uint8Array(0));k(this,"changes",[]);k(this,"minSyncedTicket");k(this,"isRemoved",!1);k(this,"versionVector");R.util.initPartial(n,this)}static fromBinary(n,r){return new ci().fromBinary(n,r)}static fromJson(n,r){return new ci().fromJson(n,r)}static fromJsonString(n,r){return new ci().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ci,n,r)}},k(ci,"runtime",R),k(ci,"typeName","yorkie.v1.ChangePack"),k(ci,"fields",R.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:MP},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:PP,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:Ie},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:E1}])),ci);var di;let PP=(di=class extends ve{constructor(n){super();k(this,"id");k(this,"message","");k(this,"operations",[]);k(this,"presenceChange");R.util.initPartial(n,this)}static fromBinary(n,r){return new di().fromBinary(n,r)}static fromJson(n,r){return new di().fromJson(n,r)}static fromJsonString(n,r){return new di().fromJsonString(n,r)}static equals(n,r){return R.util.equals(di,n,r)}},k(di,"runtime",R),k(di,"typeName","yorkie.v1.Change"),k(di,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:y1},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:FC,repeated:!0},{no:4,name:"presence_change",kind:"message",T:ch}])),di);var hi;let y1=(hi=class extends ve{constructor(n){super();k(this,"clientSeq",0);k(this,"serverSeq",zt.zero);k(this,"lamport",zt.zero);k(this,"actorId",new Uint8Array(0));k(this,"versionVector");R.util.initPartial(n,this)}static fromBinary(n,r){return new hi().fromBinary(n,r)}static fromJson(n,r){return new hi().fromJson(n,r)}static fromJsonString(n,r){return new hi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(hi,n,r)}},k(hi,"runtime",R),k(hi,"typeName","yorkie.v1.ChangeID"),k(hi,"fields",R.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:E1}])),hi);var fi;let E1=(fi=class extends ve{constructor(n){super();k(this,"vector",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new fi().fromBinary(n,r)}static fromJson(n,r){return new fi().fromJson(n,r)}static fromJsonString(n,r){return new fi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(fi,n,r)}},k(fi,"runtime",R),k(fi,"typeName","yorkie.v1.VersionVector"),k(fi,"fields",R.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),fi);var pi;let FC=(pi=class extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new pi().fromBinary(n,r)}static fromJson(n,r){return new pi().fromJson(n,r)}static fromJsonString(n,r){return new pi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(pi,n,r)}},k(pi,"runtime",R),k(pi,"typeName","yorkie.v1.Operation"),k(pi,"fields",R.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Ug,oneof:"body"},{no:2,name:"add",kind:"message",T:Kg,oneof:"body"},{no:3,name:"move",kind:"message",T:Vg,oneof:"body"},{no:4,name:"remove",kind:"message",T:Gg,oneof:"body"},{no:5,name:"edit",kind:"message",T:Jg,oneof:"body"},{no:6,name:"select",kind:"message",T:Yy,oneof:"body"},{no:7,name:"style",kind:"message",T:Wg,oneof:"body"},{no:8,name:"increase",kind:"message",T:Yg,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:qg,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:Xg,oneof:"body"},{no:11,name:"array_set",kind:"message",T:qy,oneof:"body"}])),pi);const sa=class sa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"key","");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new sa().fromBinary(n,r)}static fromJson(n,r){return new sa().fromJson(n,r)}static fromJsonString(n,r){return new sa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(sa,n,r)}};k(sa,"runtime",R),k(sa,"typeName","yorkie.v1.Operation.Set"),k(sa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Ug=sa;const ua=class ua extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"prevCreatedAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ua().fromBinary(n,r)}static fromJson(n,r){return new ua().fromJson(n,r)}static fromJsonString(n,r){return new ua().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ua,n,r)}};k(ua,"runtime",R),k(ua,"typeName","yorkie.v1.Operation.Add"),k(ua,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"prev_created_at",kind:"message",T:Ie},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Kg=ua;const la=class la extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"prevCreatedAt");k(this,"createdAt");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new la().fromBinary(n,r)}static fromJson(n,r){return new la().fromJson(n,r)}static fromJsonString(n,r){return new la().fromJsonString(n,r)}static equals(n,r){return R.util.equals(la,n,r)}};k(la,"runtime",R),k(la,"typeName","yorkie.v1.Operation.Move"),k(la,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"prev_created_at",kind:"message",T:Ie},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Vg=la;const ca=class ca extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"createdAt");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ca().fromBinary(n,r)}static fromJson(n,r){return new ca().fromJson(n,r)}static fromJsonString(n,r){return new ca().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ca,n,r)}};k(ca,"runtime",R),k(ca,"typeName","yorkie.v1.Operation.Remove"),k(ca,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"executed_at",kind:"message",T:Ie}]));let Gg=ca;const da=class da extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"createdAtMapByActor",{});k(this,"content","");k(this,"executedAt");k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new da().fromBinary(n,r)}static fromJson(n,r){return new da().fromJson(n,r)}static fromJsonString(n,r){return new da().fromJsonString(n,r)}static equals(n,r){return R.util.equals(da,n,r)}};k(da,"runtime",R),k(da,"typeName","yorkie.v1.Operation.Edit"),k(da,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:Ie},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let Jg=da;const ha=class ha extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ha().fromBinary(n,r)}static fromJson(n,r){return new ha().fromJson(n,r)}static fromJsonString(n,r){return new ha().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ha,n,r)}};k(ha,"runtime",R),k(ha,"typeName","yorkie.v1.Operation.Select"),k(ha,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Yy=ha;const fa=class fa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"attributes",{});k(this,"executedAt");k(this,"createdAtMapByActor",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new fa().fromBinary(n,r)}static fromJson(n,r){return new fa().fromJson(n,r)}static fromJsonString(n,r){return new fa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(fa,n,r)}};k(fa,"runtime",R),k(fa,"typeName","yorkie.v1.Operation.Style"),k(fa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:Ie},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}}]));let Wg=fa;const pa=class pa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new pa().fromBinary(n,r)}static fromJson(n,r){return new pa().fromJson(n,r)}static fromJsonString(n,r){return new pa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(pa,n,r)}};k(pa,"runtime",R),k(pa,"typeName","yorkie.v1.Operation.Increase"),k(pa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"value",kind:"message",T:li},{no:3,name:"executed_at",kind:"message",T:Ie}]));let Yg=pa;const ga=class ga extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"createdAtMapByActor",{});k(this,"contents",[]);k(this,"splitLevel",0);k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ga().fromBinary(n,r)}static fromJson(n,r){return new ga().fromJson(n,r)}static fromJsonString(n,r){return new ga().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ga,n,r)}};k(ga,"runtime",R),k(ga,"typeName","yorkie.v1.Operation.TreeEdit"),k(ga,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Il},{no:3,name:"to",kind:"message",T:Il},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}},{no:5,name:"contents",kind:"message",T:am,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:Ie}]));let qg=ga;const ma=class ma extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"attributes",{});k(this,"executedAt");k(this,"attributesToRemove",[]);k(this,"createdAtMapByActor",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new ma().fromBinary(n,r)}static fromJson(n,r){return new ma().fromJson(n,r)}static fromJsonString(n,r){return new ma().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ma,n,r)}};k(ma,"runtime",R),k(ma,"typeName","yorkie.v1.Operation.TreeStyle"),k(ma,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Il},{no:3,name:"to",kind:"message",T:Il},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:Ie},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}}]));let Xg=ma;const va=class va extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"createdAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new va().fromBinary(n,r)}static fromJson(n,r){return new va().fromJson(n,r)}static fromJsonString(n,r){return new va().fromJsonString(n,r)}static equals(n,r){return R.util.equals(va,n,r)}};k(va,"runtime",R),k(va,"typeName","yorkie.v1.Operation.ArraySet"),k(va,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let qy=va;const ya=class ya extends ve{constructor(n){super();k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");k(this,"type",0);k(this,"value",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new ya().fromBinary(n,r)}static fromJson(n,r){return new ya().fromJson(n,r)}static fromJsonString(n,r){return new ya().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ya,n,r)}};k(ya,"runtime",R),k(ya,"typeName","yorkie.v1.JSONElementSimple"),k(ya,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"moved_at",kind:"message",T:Ie},{no:3,name:"removed_at",kind:"message",T:Ie},{no:4,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:5,name:"value",kind:"scalar",T:12}]));let li=ya;const Ea=class Ea extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ea().fromBinary(n,r)}static fromJson(n,r){return new Ea().fromJson(n,r)}static fromJsonString(n,r){return new Ea().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ea,n,r)}};k(Ea,"runtime",R),k(Ea,"typeName","yorkie.v1.JSONElement"),k(Ea,"fields",R.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Zg,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Qg,oneof:"body"},{no:3,name:"primitive",kind:"message",T:em,oneof:"body"},{no:5,name:"text",kind:"message",T:tm,oneof:"body"},{no:6,name:"counter",kind:"message",T:nm,oneof:"body"},{no:7,name:"tree",kind:"message",T:rm,oneof:"body"}]));let Sr=Ea;const Ca=class Ca extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ca().fromBinary(n,r)}static fromJson(n,r){return new Ca().fromJson(n,r)}static fromJsonString(n,r){return new Ca().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ca,n,r)}};k(Ca,"runtime",R),k(Ca,"typeName","yorkie.v1.JSONElement.JSONObject"),k(Ca,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:BP,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let Zg=Ca;const ba=class ba extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ba().fromBinary(n,r)}static fromJson(n,r){return new ba().fromJson(n,r)}static fromJsonString(n,r){return new ba().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ba,n,r)}};k(ba,"runtime",R),k(ba,"typeName","yorkie.v1.JSONElement.JSONArray"),k(ba,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:im,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let Qg=ba;const wa=class wa extends ve{constructor(n){super();k(this,"type",0);k(this,"value",new Uint8Array(0));k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new wa().fromBinary(n,r)}static fromJson(n,r){return new wa().fromJson(n,r)}static fromJsonString(n,r){return new wa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(wa,n,r)}};k(wa,"runtime",R),k(wa,"typeName","yorkie.v1.JSONElement.Primitive"),k(wa,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"moved_at",kind:"message",T:Ie},{no:5,name:"removed_at",kind:"message",T:Ie}]));let em=wa;const Sa=class Sa extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Sa().fromBinary(n,r)}static fromJson(n,r){return new Sa().fromJson(n,r)}static fromJsonString(n,r){return new Sa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Sa,n,r)}};k(Sa,"runtime",R),k(Sa,"typeName","yorkie.v1.JSONElement.Text"),k(Sa,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:om,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let tm=Sa;const xa=class xa extends ve{constructor(n){super();k(this,"type",0);k(this,"value",new Uint8Array(0));k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new xa().fromBinary(n,r)}static fromJson(n,r){return new xa().fromJson(n,r)}static fromJsonString(n,r){return new xa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(xa,n,r)}};k(xa,"runtime",R),k(xa,"typeName","yorkie.v1.JSONElement.Counter"),k(xa,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"moved_at",kind:"message",T:Ie},{no:5,name:"removed_at",kind:"message",T:Ie}]));let nm=xa;const Aa=class Aa extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Aa().fromBinary(n,r)}static fromJson(n,r){return new Aa().fromJson(n,r)}static fromJsonString(n,r){return new Aa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Aa,n,r)}};k(Aa,"runtime",R),k(Aa,"typeName","yorkie.v1.JSONElement.Tree"),k(Aa,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:lh,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let rm=Aa;var gi;let BP=(gi=class extends ve{constructor(n){super();k(this,"key","");k(this,"element");R.util.initPartial(n,this)}static fromBinary(n,r){return new gi().fromBinary(n,r)}static fromJson(n,r){return new gi().fromJson(n,r)}static fromJsonString(n,r){return new gi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(gi,n,r)}},k(gi,"runtime",R),k(gi,"typeName","yorkie.v1.RHTNode"),k(gi,"fields",R.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:Sr}])),gi);const Co=class Co extends ve{constructor(n){super();k(this,"next");k(this,"element");R.util.initPartial(n,this)}static fromBinary(n,r){return new Co().fromBinary(n,r)}static fromJson(n,r){return new Co().fromJson(n,r)}static fromJsonString(n,r){return new Co().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Co,n,r)}};k(Co,"runtime",R),k(Co,"typeName","yorkie.v1.RGANode"),k(Co,"fields",R.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Co},{no:2,name:"element",kind:"message",T:Sr}]));let im=Co;const ka=class ka extends ve{constructor(n){super();k(this,"value","");k(this,"updatedAt");k(this,"isRemoved",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new ka().fromBinary(n,r)}static fromJson(n,r){return new ka().fromJson(n,r)}static fromJsonString(n,r){return new ka().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ka,n,r)}};k(ka,"runtime",R),k(ka,"typeName","yorkie.v1.NodeAttr"),k(ka,"fields",R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:Ie},{no:3,name:"is_removed",kind:"scalar",T:8}]));let ud=ka;const Ia=class Ia extends ve{constructor(n){super();k(this,"id");k(this,"value","");k(this,"removedAt");k(this,"insPrevId");k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ia().fromBinary(n,r)}static fromJson(n,r){return new Ia().fromJson(n,r)}static fromJsonString(n,r){return new Ia().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ia,n,r)}};k(Ia,"runtime",R),k(Ia,"typeName","yorkie.v1.TextNode"),k(Ia,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:uh},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:Ie},{no:4,name:"ins_prev_id",kind:"message",T:uh},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ud}}]));let om=Ia;const Da=class Da extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Da().fromBinary(n,r)}static fromJson(n,r){return new Da().fromJson(n,r)}static fromJsonString(n,r){return new Da().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Da,n,r)}};k(Da,"runtime",R),k(Da,"typeName","yorkie.v1.TextNodeID"),k(Da,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5}]));let uh=Da;const Ta=class Ta extends ve{constructor(n){super();k(this,"id");k(this,"type","");k(this,"value","");k(this,"removedAt");k(this,"insPrevId");k(this,"insNextId");k(this,"depth",0);k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ta().fromBinary(n,r)}static fromJson(n,r){return new Ta().fromJson(n,r)}static fromJsonString(n,r){return new Ta().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ta,n,r)}};k(Ta,"runtime",R),k(Ta,"typeName","yorkie.v1.TreeNode"),k(Ta,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:mu},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:Ie},{no:5,name:"ins_prev_id",kind:"message",T:mu},{no:6,name:"ins_next_id",kind:"message",T:mu},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ud}}]));let lh=Ta;const Pa=class Pa extends ve{constructor(n){super();k(this,"content",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new Pa().fromBinary(n,r)}static fromJson(n,r){return new Pa().fromJson(n,r)}static fromJsonString(n,r){return new Pa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Pa,n,r)}};k(Pa,"runtime",R),k(Pa,"typeName","yorkie.v1.TreeNodes"),k(Pa,"fields",R.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:lh,repeated:!0}]));let am=Pa;const Ba=class Ba extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Ba().fromBinary(n,r)}static fromJson(n,r){return new Ba().fromJson(n,r)}static fromJsonString(n,r){return new Ba().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ba,n,r)}};k(Ba,"runtime",R),k(Ba,"typeName","yorkie.v1.TreeNodeID"),k(Ba,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5}]));let mu=Ba;const Ma=class Ma extends ve{constructor(n){super();k(this,"parentId");k(this,"leftSiblingId");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ma().fromBinary(n,r)}static fromJson(n,r){return new Ma().fromJson(n,r)}static fromJsonString(n,r){return new Ma().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ma,n,r)}};k(Ma,"runtime",R),k(Ma,"typeName","yorkie.v1.TreePos"),k(Ma,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:mu},{no:2,name:"left_sibling_id",kind:"message",T:mu}]));let Il=Ma;const $a=class $a extends ve{constructor(n){super();k(this,"id","");k(this,"username","");k(this,"createdAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new $a().fromBinary(n,r)}static fromJson(n,r){return new $a().fromJson(n,r)}static fromJsonString(n,r){return new $a().fromJsonString(n,r)}static equals(n,r){return R.util.equals($a,n,r)}};k($a,"runtime",R),k($a,"typeName","yorkie.v1.User"),k($a,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Vn}]));let bx=$a;const Ra=class Ra extends ve{constructor(n){super();k(this,"id","");k(this,"name","");k(this,"publicKey","");k(this,"secretKey","");k(this,"authWebhookUrl","");k(this,"authWebhookMethods",[]);k(this,"clientDeactivateThreshold","");k(this,"createdAt");k(this,"updatedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ra().fromBinary(n,r)}static fromJson(n,r){return new Ra().fromJson(n,r)}static fromJsonString(n,r){return new Ra().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ra,n,r)}};k(Ra,"runtime",R),k(Ra,"typeName","yorkie.v1.Project"),k(Ra,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Vn},{no:9,name:"updated_at",kind:"message",T:Vn}]));let wx=Ra;const Fa=class Fa extends ve{constructor(n){super();k(this,"name");k(this,"authWebhookUrl");k(this,"authWebhookMethods");k(this,"clientDeactivateThreshold");R.util.initPartial(n,this)}static fromBinary(n,r){return new Fa().fromBinary(n,r)}static fromJson(n,r){return new Fa().fromJson(n,r)}static fromJsonString(n,r){return new Fa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Fa,n,r)}};k(Fa,"runtime",R),k(Fa,"typeName","yorkie.v1.UpdatableProjectFields"),k(Fa,"fields",R.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:_r},{no:2,name:"auth_webhook_url",kind:"message",T:_r},{no:3,name:"auth_webhook_methods",kind:"message",T:Xy},{no:4,name:"client_deactivate_threshold",kind:"message",T:_r}]));let Sx=Fa;const La=class La extends ve{constructor(n){super();k(this,"methods",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new La().fromBinary(n,r)}static fromJson(n,r){return new La().fromJson(n,r)}static fromJsonString(n,r){return new La().fromJsonString(n,r)}static equals(n,r){return R.util.equals(La,n,r)}};k(La,"runtime",R),k(La,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),k(La,"fields",R.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Xy=La;const Oa=class Oa extends ve{constructor(n){super();k(this,"id","");k(this,"key","");k(this,"snapshot","");k(this,"createdAt");k(this,"accessedAt");k(this,"updatedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Oa().fromBinary(n,r)}static fromJson(n,r){return new Oa().fromJson(n,r)}static fromJsonString(n,r){return new Oa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Oa,n,r)}};k(Oa,"runtime",R),k(Oa,"typeName","yorkie.v1.DocumentSummary"),k(Oa,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Vn},{no:5,name:"accessed_at",kind:"message",T:Vn},{no:6,name:"updated_at",kind:"message",T:Vn}]));let xx=Oa;const _a=class _a extends ve{constructor(n){super();k(this,"type",0);k(this,"presence");R.util.initPartial(n,this)}static fromBinary(n,r){return new _a().fromBinary(n,r)}static fromJson(n,r){return new _a().fromJson(n,r)}static fromJsonString(n,r){return new _a().fromJsonString(n,r)}static equals(n,r){return R.util.equals(_a,n,r)}};k(_a,"runtime",R),k(_a,"typeName","yorkie.v1.PresenceChange"),k(_a,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Dl)},{no:2,name:"presence",kind:"message",T:LC}]));let ch=_a;var Dl=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.PUT=1]="PUT",e[e.DELETE=2]="DELETE",e[e.CLEAR=3]="CLEAR",e))(Dl||{});R.util.setEnumType(Dl,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var mi;let LC=(mi=class extends ve{constructor(n){super();k(this,"data",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new mi().fromBinary(n,r)}static fromJson(n,r){return new mi().fromJson(n,r)}static fromJsonString(n,r){return new mi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(mi,n,r)}},k(mi,"runtime",R),k(mi,"typeName","yorkie.v1.Presence"),k(mi,"fields",R.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),mi);var vi;let MP=(vi=class extends ve{constructor(n){super();k(this,"serverSeq",zt.zero);k(this,"clientSeq",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new vi().fromBinary(n,r)}static fromJson(n,r){return new vi().fromJson(n,r)}static fromJsonString(n,r){return new vi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(vi,n,r)}},k(vi,"runtime",R),k(vi,"typeName","yorkie.v1.Checkpoint"),k(vi,"fields",R.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),vi);const Na=class Na extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);k(this,"relativeOffset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Na().fromBinary(n,r)}static fromJson(n,r){return new Na().fromJson(n,r)}static fromJsonString(n,r){return new Na().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Na,n,r)}};k(Na,"runtime",R),k(Na,"typeName","yorkie.v1.TextNodePos"),k(Na,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Is=Na;var yi;let Ie=(yi=class extends ve{constructor(n){super();k(this,"lamport",zt.zero);k(this,"delimiter",0);k(this,"actorId",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new yi().fromBinary(n,r)}static fromJson(n,r){return new yi().fromJson(n,r)}static fromJsonString(n,r){return new yi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(yi,n,r)}},k(yi,"runtime",R),k(yi,"typeName","yorkie.v1.TimeTicket"),k(yi,"fields",R.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),yi);const za=class za extends ve{constructor(n){super();k(this,"topic","");k(this,"payload",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new za().fromBinary(n,r)}static fromJson(n,r){return new za().fromJson(n,r)}static fromJsonString(n,r){return new za().fromJsonString(n,r)}static equals(n,r){return R.util.equals(za,n,r)}};k(za,"runtime",R),k(za,"typeName","yorkie.v1.DocEventBody"),k(za,"fields",R.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Zy=za;const Ha=class Ha extends ve{constructor(n){super();k(this,"type",0);k(this,"publisher","");k(this,"body");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ha().fromBinary(n,r)}static fromJson(n,r){return new Ha().fromJson(n,r)}static fromJsonString(n,r){return new Ha().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ha,n,r)}};k(Ha,"runtime",R),k(Ha,"typeName","yorkie.v1.DocEvent"),k(Ha,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(ml)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Zy}]));let Qy=Ha;const ja=class ja extends ve{constructor(n){super();k(this,"clientKey","");R.util.initPartial(n,this)}static fromBinary(n,r){return new ja().fromBinary(n,r)}static fromJson(n,r){return new ja().fromJson(n,r)}static fromJsonString(n,r){return new ja().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ja,n,r)}};k(ja,"runtime",R),k(ja,"typeName","yorkie.v1.ActivateClientRequest"),k(ja,"fields",R.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let e3=ja;const Ua=class Ua extends ve{constructor(n){super();k(this,"clientId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ua().fromBinary(n,r)}static fromJson(n,r){return new Ua().fromJson(n,r)}static fromJsonString(n,r){return new Ua().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ua,n,r)}};k(Ua,"runtime",R),k(Ua,"typeName","yorkie.v1.ActivateClientResponse"),k(Ua,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let t3=Ua;const Ka=class Ka extends ve{constructor(n){super();k(this,"clientId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ka().fromBinary(n,r)}static fromJson(n,r){return new Ka().fromJson(n,r)}static fromJsonString(n,r){return new Ka().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ka,n,r)}};k(Ka,"runtime",R),k(Ka,"typeName","yorkie.v1.DeactivateClientRequest"),k(Ka,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let n3=Ka;const Va=class Va extends ve{constructor(t){super(),R.util.initPartial(t,this)}static fromBinary(t,n){return new Va().fromBinary(t,n)}static fromJson(t,n){return new Va().fromJson(t,n)}static fromJsonString(t,n){return new Va().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Va,t,n)}};k(Va,"runtime",R),k(Va,"typeName","yorkie.v1.DeactivateClientResponse"),k(Va,"fields",R.util.newFieldList(()=>[]));let r3=Va;const Ga=class Ga extends ve{constructor(n){super();k(this,"clientId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ga().fromBinary(n,r)}static fromJson(n,r){return new Ga().fromJson(n,r)}static fromJsonString(n,r){return new Ga().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ga,n,r)}};k(Ga,"runtime",R),k(Ga,"typeName","yorkie.v1.AttachDocumentRequest"),k(Ga,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Rs}]));let i3=Ga;const Ja=class Ja extends ve{constructor(n){super();k(this,"documentId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ja().fromBinary(n,r)}static fromJson(n,r){return new Ja().fromJson(n,r)}static fromJsonString(n,r){return new Ja().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ja,n,r)}};k(Ja,"runtime",R),k(Ja,"typeName","yorkie.v1.AttachDocumentResponse"),k(Ja,"fields",R.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Rs}]));let o3=Ja;const Wa=class Wa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");k(this,"removeIfNotAttached",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new Wa().fromBinary(n,r)}static fromJson(n,r){return new Wa().fromJson(n,r)}static fromJsonString(n,r){return new Wa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Wa,n,r)}};k(Wa,"runtime",R),k(Wa,"typeName","yorkie.v1.DetachDocumentRequest"),k(Wa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let a3=Wa;const Ya=class Ya extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ya().fromBinary(n,r)}static fromJson(n,r){return new Ya().fromJson(n,r)}static fromJsonString(n,r){return new Ya().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ya,n,r)}};k(Ya,"runtime",R),k(Ya,"typeName","yorkie.v1.DetachDocumentResponse"),k(Ya,"fields",R.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Rs}]));let s3=Ya;const qa=class qa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new qa().fromBinary(n,r)}static fromJson(n,r){return new qa().fromJson(n,r)}static fromJsonString(n,r){return new qa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(qa,n,r)}};k(qa,"runtime",R),k(qa,"typeName","yorkie.v1.WatchDocumentRequest"),k(qa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let u3=qa;const Xa=class Xa extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new Xa().fromBinary(n,r)}static fromJson(n,r){return new Xa().fromJson(n,r)}static fromJsonString(n,r){return new Xa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Xa,n,r)}};k(Xa,"runtime",R),k(Xa,"typeName","yorkie.v1.WatchDocumentResponse"),k(Xa,"fields",R.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:c3,oneof:"body"},{no:2,name:"event",kind:"message",T:Qy,oneof:"body"}]));let l3=Xa;const Za=class Za extends ve{constructor(n){super();k(this,"clientIds",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new Za().fromBinary(n,r)}static fromJson(n,r){return new Za().fromJson(n,r)}static fromJsonString(n,r){return new Za().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Za,n,r)}};k(Za,"runtime",R),k(Za,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),k(Za,"fields",R.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let c3=Za;const Qa=class Qa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Qa().fromBinary(n,r)}static fromJson(n,r){return new Qa().fromJson(n,r)}static fromJsonString(n,r){return new Qa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Qa,n,r)}};k(Qa,"runtime",R),k(Qa,"typeName","yorkie.v1.RemoveDocumentRequest"),k(Qa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs}]));let d3=Qa;const es=class es extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new es().fromBinary(n,r)}static fromJson(n,r){return new es().fromJson(n,r)}static fromJsonString(n,r){return new es().fromJsonString(n,r)}static equals(n,r){return R.util.equals(es,n,r)}};k(es,"runtime",R),k(es,"typeName","yorkie.v1.RemoveDocumentResponse"),k(es,"fields",R.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Rs}]));let h3=es;const ts=class ts extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");k(this,"pushOnly",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new ts().fromBinary(n,r)}static fromJson(n,r){return new ts().fromJson(n,r)}static fromJsonString(n,r){return new ts().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ts,n,r)}};k(ts,"runtime",R),k(ts,"typeName","yorkie.v1.PushPullChangesRequest"),k(ts,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs},{no:4,name:"push_only",kind:"scalar",T:8}]));let f3=ts;const ns=class ns extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new ns().fromBinary(n,r)}static fromJson(n,r){return new ns().fromJson(n,r)}static fromJsonString(n,r){return new ns().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ns,n,r)}};k(ns,"runtime",R),k(ns,"typeName","yorkie.v1.PushPullChangesResponse"),k(ns,"fields",R.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Rs}]));let p3=ns;const rs=class rs extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"topic","");k(this,"payload",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new rs().fromBinary(n,r)}static fromJson(n,r){return new rs().fromJson(n,r)}static fromJsonString(n,r){return new rs().fromJsonString(n,r)}static equals(n,r){return R.util.equals(rs,n,r)}};k(rs,"runtime",R),k(rs,"typeName","yorkie.v1.BroadcastRequest"),k(rs,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let g3=rs;const is=class is extends ve{constructor(t){super(),R.util.initPartial(t,this)}static fromBinary(t,n){return new is().fromBinary(t,n)}static fromJson(t,n){return new is().fromJson(t,n)}static fromJsonString(t,n){return new is().fromJsonString(t,n)}static equals(t,n){return R.util.equals(is,t,n)}};k(is,"runtime",R),k(is,"typeName","yorkie.v1.BroadcastResponse"),k(is,"fields",R.util.newFieldList(()=>[]));let m3=is;const sKe={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:e3,O:t3,kind:ir.Unary},deactivateClient:{name:"DeactivateClient",I:n3,O:r3,kind:ir.Unary},attachDocument:{name:"AttachDocument",I:i3,O:o3,kind:ir.Unary},detachDocument:{name:"DetachDocument",I:a3,O:s3,kind:ir.Unary},removeDocument:{name:"RemoveDocument",I:d3,O:h3,kind:ir.Unary},pushPullChanges:{name:"PushPullChanges",I:f3,O:p3,kind:ir.Unary},watchDocument:{name:"WatchDocument",I:u3,O:l3,kind:ir.ServerStreaming},broadcast:{name:"Broadcast",I:g3,O:m3,kind:ir.Unary}}},uKe=R.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);R.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:cs}]);R.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:lKe,repeated:!0}]);const lKe=R.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});R.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:cKe,repeated:!0}]);const cKe=R.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});R.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:dKe,repeated:!0}]);const dKe=R.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});R.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:hKe,repeated:!0}]);const hKe=R.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});R.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var J=(e=>(e.Ok="ok",e.ErrClientNotActivated="ErrClientNotActivated",e.ErrClientNotFound="ErrClientNotFound",e.ErrUnimplemented="ErrUnimplemented",e.ErrInvalidType="ErrInvalidType",e.ErrDummy="ErrDummy",e.ErrDocumentNotAttached="ErrDocumentNotAttached",e.ErrDocumentNotDetached="ErrDocumentNotDetached",e.ErrDocumentRemoved="ErrDocumentRemoved",e.ErrInvalidObjectKey="ErrInvalidObjectKey",e.ErrInvalidArgument="ErrInvalidArgument",e.ErrNotInitialized="ErrNotInitialized",e.ErrNotReady="ErrNotReady",e.ErrRefused="ErrRefused",e.ErrContextNotProvided="ErrContextNotProvided",e.ErrPermissionDenied="ErrPermissionDenied",e.ErrUnauthenticated="ErrUnauthenticated",e))(J||{});class Y extends Error{constructor(n,r){super(r);k(this,"name","YorkieError");k(this,"stack");this.code=n,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Gi(e){if(e instanceof Map){const t=Array.from(e);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(e))}const $P=e=>e?Object.entries(e).length===0:!0,ld=e=>{const t={};for(const[n,r]of Object.entries(e))t[n]=JSON.stringify(r);return t},Hc=e=>{const t={};for(const[n,r]of Object.entries(e))t[n]=JSON.parse(r);return t};var Du=(e=>(e.Put="put",e.Clear="clear",e))(Du||{});class n2{constructor(t,n){k(this,"context");k(this,"presence");this.context=t,this.presence=n}set(t,n){for(const r of Object.keys(t))this.presence[r]=t[r];this.context.setPresenceChange({type:"put",presence:Gi(this.presence)}),this.context.setReversePresence(t,n)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const OC="000000000000000000000000";class Ai{constructor(t,n,r){k(this,"lamport");k(this,"delimiter");k(this,"actorID");this.lamport=t,this.delimiter=n,this.actorID=r}static of(t,n,r){return new Ai(t,n,r)}static fromStruct(t){return Ai.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new Ai(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const n=this.actorID.localeCompare(t.actorID);return n!==0?n:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const RP=0,R0=9223372036854775807n,to=new Ai(0n,RP,OC);function Oo(e){return e.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` + `}catch{Q.warn("Could not find tldraw-assets.json file.")}else s.textContent="@import url('https://fonts.googleapis.com/css2?family=Caveat+Brush&family=Source+Code+Pro&family=Source+Sans+Pro&family=Crimson+Pro&display=block');";a.append(s),o.append(a);let u=r.map(v=>this.getShape(v,this.currentPageId)).sort((v,E)=>v.childIndex-E.childIndex),d=N.getCommonBounds(u.map(Q.getRotatedBounds)),h=v=>{let E=Q.getShapeUtil(v),w=E.getBounds(v),C=E.getSvgElement(v,this.settings.isDarkMode);if(C)return v.type==="image"?C.setAttribute("xlink:href",this.document.assets[v.assetId].src):v.type==="video"&&C.setAttribute("xlink:href",this.serializeVideo(v.id)),C.setAttribute("transform",`translate(${(16+v.point[0]-d.minX).toFixed(2)}, ${(16+v.point[1]-d.minY).toFixed(2)}) rotate(${((v.rotation||0)*180/Math.PI).toFixed(2)}, ${(w.width/2).toFixed(2)}, ${(w.height/2).toFixed(2)})`),C};u.forEach(v=>{var E;if((E=v.children)!=null&&E.length){let C=document.createElementNS("http://www.w3.org/2000/svg","g");v.children.forEach(b=>{let A=this.getShape(b,this.currentPageId),T=h(A);T&&C.append(T)}),o.append(C);return}let w=h(v);w&&o.append(w)}),o.setAttribute("viewBox",[0,0,d.width+16*2,d.height+16*2].join(" ")),o.setAttribute("width",(d.width+16*2).toString()),o.setAttribute("height",(d.height+16*2).toString());let p=this.settings.exportBackground,g="#212529",m="rgb(248, 249, 250)";switch(p){case"auto":{o.style.setProperty("background-color",this.settings.isDarkMode?g:m);break}case"dark":{o.style.setProperty("background-color",g);break}case"light":{o.style.setProperty("background-color",m);break}case"transparent":default:{o.style.setProperty("background-color","transparent");break}}return o.querySelectorAll(".tl-fill-hitarea, .tl-stroke-hitarea, .tl-binding-indicator").forEach(v=>v.remove()),o})),S(this,"copySvg",(...n)=>Oe(this,[...n],function*(r=this.selectedIds.length?this.selectedIds:Object.keys(this.page.shapes)){if(r.length===0)return;let i=yield this.getSvg(r);if(!i)return;let o=Q.getSvgString(i,1);this.clipboard=this.getContent(r);let a=JSON.stringify(_({type:"tldr/clipboard"},this.clipboard));return navigator.clipboard&&window.ClipboardItem&&navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([a],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})]),o})),S(this,"getContent",n=>{let r=this.getPage(this.currentPageId);if(n&&n.length===0||(n||(n=this.selectedIds),n.length===0&&(n=Object.keys(r.shapes)),n.length===0))return;let i=n.map(u=>r.shapes[u]).flatMap(u=>{var d;return[u,...((d=u.children)!=null?d:[]).map(h=>r.shapes[h])]}).map($r),o=new Set(i.map(u=>u.id));i.forEach(u=>{u.parentId===this.currentPageId&&(u.parentId="currentPageId")});let a=Object.values(r.bindings).filter(u=>{if(o.has(u.fromId)||o.has(u.toId))return!0;if(o.has(u.fromId)){let d=i.find(h=>h.id===u.fromId).handles;d&&Object.values(d).forEach(h=>{h.bindingId===u.id&&(h.bindingId=void 0)})}if(o.has(u.toId)){let d=i.find(h=>h.id===u.toId).handles;d&&Object.values(d).forEach(h=>{h.bindingId===u.id&&(h.bindingId=void 0)})}return!1}).map($r),s=[...new Set(i.map(u=>{if(u.assetId)return this.document.assets[u.assetId]}).filter(Boolean).map($r))];return{shapes:i,bindings:a,assets:s}}),S(this,"copyJson",(n=this.selectedIds)=>{let r=this.getContent(n);return r&&Q.copyStringToClipboard(JSON.stringify(r)),this}),S(this,"exportJson",(n=this.selectedIds)=>{let r=this.getContent(n);if(r){let i=new Blob([JSON.stringify(r)],{type:"application/json"}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download="export.json",a.click()}return this}),S(this,"insertContent",(n,r={})=>this.setState(ije(this,n,r),"insert_content")),S(this,"getImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){let{ids:o=this.selectedIds.length?this.selectedIds:Object.keys(this.page.shapes)}=i,a=yield this.getSvg(o,{includeFonts:r!=="svg"});if(!a)return;if(r==="svg"){let u=Q.getSvgString(a,1);return new Blob([u],{type:"image/svg+xml"})}let s=yield Q.getImageForSvg(a,r,i);if(s)return s})),S(this,"copyImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){if(r==="svg"){this.copySvg(i.ids);return}if(!(navigator.clipboard&&window.ClipboardItem)){console.warn("Sorry, your browser does not support copying images.");return}let o=yield this.getImage(r,i);!o||navigator.clipboard.write([new ClipboardItem({[o.type]:o})])})),S(this,"exportImage",(...n)=>Oe(this,[...n],function*(r="png",i={}){var o;let{pageId:a=this.currentPageId}=i,s=yield this.getImage(r,i);if(!s)return;let u=(o=this.document.pages[a].name)!=null?o:"export";if(this.callbacks.onExport)this.callbacks.onExport(this,{name:u,type:r,blob:s});else{let d=URL.createObjectURL(s),h=document.createElement("a");h.href=d,h.download=`${u}.${r}`,h.click()}})),S(this,"setCamera",(n,r,i)=>(this.updateViewport(n,r),this.patchState({document:{pageStates:{[this.currentPageId]:{camera:{point:n,zoom:r}}}}},i),this)),S(this,"resetCamera",()=>this.setCamera(this.centerPoint,1,"reset_camera")),S(this,"pan",n=>{let{camera:r}=this.pageState;return this.setCamera($.toFixed($.sub(r.point,n)),r.zoom,"panned")}),S(this,"pinchZoom",(n,r,i)=>{let{camera:o}=this.pageState,a=$.sub(o.point,$.div(r,o.zoom)),s=i,u=$.sub($.div(n,o.zoom),a),d=$.sub($.div(n,s),a);return this.setCamera($.toFixed($.add(a,$.sub(d,u))),s,"pinch_zoomed")}),S(this,"zoomTo",(n,r=this.centerPoint)=>{let{zoom:i,point:o}=this.camera,a=$.sub($.div(r,i),o),s=$.sub($.div(r,n),o);return this.setCamera($.toFixed($.add(o,$.sub(s,a))),n,"zoomed_camera")}),S(this,"zoomIn",()=>{let n=Math.round(this.camera.zoom*100/25),r=Q.getCameraZoom((n+1)*.25);return this.zoomTo(r)}),S(this,"zoomOut",()=>{let n=Math.round(this.camera.zoom*100/25),r=Q.getCameraZoom((n-1)*.25);return this.zoomTo(r)}),S(this,"zoomToFit",()=>{let{shapes:n,pageState:{camera:r}}=this;if(n.length===0)return this;let{rendererBounds:i}=this,o=N.getCommonBounds(n.map(Q.getBounds)),a=Q.getCameraZoom(Math.min((i.width-128)/o.width,(i.height-128)/o.height));a=r.zoom===a||r.zoom<1?Math.min(1,a):a;let s=(i.width-o.width*a)/2/a,u=(i.height-o.height*a)/2/a;return this.setCamera($.toFixed($.sub([s,u],[o.minX,o.minY])),a,"zoomed_to_fit")}),S(this,"zoomToSelection",()=>{if(this.selectedIds.length===0)return this;let{rendererBounds:n}=this,r=Q.getSelectedBounds(this.state),i=Q.getCameraZoom(Math.min((n.width-128)/r.width,(n.height-128)/r.height));i=this.camera.zoom===i||this.camera.zoom<1?Math.min(1,i):i;let o=(n.width-r.width*i)/2/i,a=(n.height-r.height*i)/2/i;return this.setCamera($.toFixed($.sub([o,a],[r.minX,r.minY])),i,"zoomed_to_selection")}),S(this,"zoomToContent",()=>{let n=this.shapes,r=this.pageState;if(n.length===0)return this;let{rendererBounds:i}=this,{zoom:o}=r.camera,a=N.getCommonBounds(n.map(Q.getBounds)),s=(i.width-a.width*o)/2/o,u=(i.height-a.height*o)/2/o;return this.setCamera($.toFixed($.sub([s,u],[a.minX,a.minY])),this.camera.zoom,"zoomed_to_content")}),S(this,"resetZoom",()=>this.zoomTo(1)),S(this,"zoomBy",N.throttle((n,r)=>{let{zoom:i}=this.camera,o=Q.getCameraZoom(i-n*i);return this.zoomTo(o,r)},16)),S(this,"clearSelectHistory",()=>(this.selectHistory.pointer=0,this.selectHistory.stack=[this.selectedIds],this)),S(this,"addToSelectHistory",n=>(this.selectHistory.pointer{let i=r?[...this.pageState.selectedIds,...n]:[...n];return this.patchState({appState:{activeTool:"select"},document:{pageStates:{[this.currentPageId]:{selectedIds:i}}}},"selected")}),S(this,"undoSelect",()=>(this.selectHistory.pointer>0&&(this.selectHistory.pointer--,this.setSelectedIds(this.selectHistory.stack[this.selectHistory.pointer])),this)),S(this,"redoSelect",()=>(this.selectHistory.pointer(n.forEach(r=>{if(!this.page.shapes[r])throw Error(`That shape does not exist on page ${this.currentPageId}`)}),this.setSelectedIds(n),this.addToSelectHistory(n),this)),S(this,"selectAll",(n=this.currentPageId)=>this.session?this:(this.setSelectedIds(Object.values(this.document.pages[n].shapes).filter(r=>r.parentId===n).map(r=>r.id)),this.addToSelectHistory(this.selectedIds),this.selectTool("select"),this)),S(this,"selectNone",()=>(this.setSelectedIds([]),this.addToSelectHistory(this.selectedIds),this)),S(this,"startSession",(n,...r)=>{var i,o;if(this.readOnly&&n!=="brush")return this;this.session&&(Q.warn(`Already in a session! (${this.session.constructor.name})`),this.cancelSession());let a=yje(n);this.session=new a(this,...r);let s=this.session.start();return s&&this.patchState(s,`session:start_${this.session.constructor.name}`),(o=(i=this.callbacks).onSessionStart)==null||o.call(i,this,this.session.constructor.name),this}),S(this,"updateSession",()=>{let{session:n}=this;if(!n)return this;let r=n.update();return r?this.patchState(r,`session:${n==null?void 0:n.constructor.name}`):this}),S(this,"cancelSession",()=>{var n,r;let{session:i}=this;if(!i)return this;this.session=void 0;let o=i.cancel();return o&&this.patchState(o,`session:cancel:${i.constructor.name}`),this.setEditingId(),(r=(n=this.callbacks).onSessionEnd)==null||r.call(n,this,i.constructor.name),this}),S(this,"completeSession",()=>{var n,r,i,o,a,s,u,d,h;let{session:p}=this;if(!p)return this;this.session=void 0;let g=p.complete();if(g===void 0)this.isCreating=!1,this.patchState({appState:{status:"idle"},document:{pageStates:{[this.currentPageId]:{editingId:void 0,bindingId:void 0,hoveredId:void 0}}}},`session:complete:${p.constructor.name}`);else if("after"in g){if(this.isCreating){if(g.before={appState:q(_({},g.before.appState),{status:"idle"}),document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(this.selectedIds.map(m=>[m,void 0]))}},pageStates:{[this.currentPageId]:{selectedIds:[],editingId:null,bindingId:null,hoveredId:null}}}},this.appState.isToolLocked){let m=((i=(r=(n=g.after)==null?void 0:n.document)==null?void 0:r.pageStates)==null?void 0:i[this.currentPageId])||{};m.selectedIds=[]}this.isCreating=!1}g.after.appState=q(_({},g.after.appState),{status:"idle"}),g.after.document=q(_({},g.after.document),{pageStates:q(_({},(o=g.after.document)==null?void 0:o.pageStates),{[this.currentPageId]:q(_({},(((a=g.after.document)==null?void 0:a.pageStates)||{})[this.currentPageId]),{editingId:null})})}),this.setState(g,`session:complete:${p.constructor.name}`)}else this.patchState(q(_({},g),{appState:q(_({},g.appState),{status:"idle"}),document:q(_({},g.document),{pageStates:{[this.currentPageId]:q(_({},(u=(s=g.document)==null?void 0:s.pageStates)==null?void 0:u[this.currentPageId]),{editingId:null})}})}),`session:complete:${p.constructor.name}`);return(h=(d=this.callbacks).onSessionEnd)==null||h.call(d,this,p.constructor.name),this}),S(this,"createShapes",(...n)=>n.length===0?this:this.create(n.map(r=>Q.getShapeUtil(r.type).create(_({parentId:this.currentPageId},r))))),S(this,"updateShapes",(...n)=>{let r=this.document.pages[this.currentPageId].shapes,i=n.filter(o=>r[o.id]);return i.length===0?this:this.setState(VS(this,i,this.currentPageId),"updated_shapes")}),S(this,"create",(n=[],r=[])=>n.length===0?this:this.setState(HS(this,n,r))),S(this,"patchCreate",(n=[],r=[])=>n.length===0?this:this.patchState(HS(this,n,r).after)),S(this,"delete",(n=this.selectedIds)=>{var r,i;if(n.length===0)return this;if(this.session)return this;let o=jS(this,n);if(this.callbacks.onAssetDelete&&((r=o.before.document)!=null&&r.assets)&&((i=o.after.document)!=null&&i.assets)){let a=Object.keys(o.before.document.assets).filter(u=>!!o.before.document.assets[u]),s=Object.keys(o.after.document.assets).filter(u=>!!o.after.document.assets[u]);a.filter(u=>!s.includes(u)).forEach(u=>this.callbacks.onAssetDelete(this,u))}return this.setState(o)}),S(this,"deleteAll",()=>(this.selectAll(),this.delete(),this)),S(this,"style",(n,r=this.selectedIds)=>this.setState(QHe(this,r,n))),S(this,"align",(n,r=this.selectedIds)=>r.length<2?this:this.setState(FHe(this,r,n))),S(this,"distribute",(n,r=this.selectedIds)=>r.length<3?this:this.setState(jHe(this,r,n))),S(this,"stretch",(n,r=this.selectedIds)=>r.length<2?this:this.setState(ZHe(this,r,n))),S(this,"flipHorizontal",(n=this.selectedIds)=>n.length===0?this:this.setState(US(this,n,"horizontal"))),S(this,"flipVertical",(n=this.selectedIds)=>n.length===0?this:this.setState(US(this,n,"vertical"))),S(this,"moveToPage",(n,r=this.currentPageId,i=this.selectedIds)=>{if(i.length===0)return this;let{rendererBounds:o}=this;return this.setState(JHe(this,i,o,r,n)),this}),S(this,"moveToBack",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"toBack"))),S(this,"moveBackward",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"backward"))),S(this,"moveForward",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"forward"))),S(this,"moveToFront",(n=this.selectedIds)=>n.length===0?this:this.setState(bp(this,n,"toFront"))),S(this,"nudge",(n,r=!1,i=this.selectedIds)=>{if(i.length===0)return this;let o=r?this.settings.showGrid?this.currentGrid*4:10:this.settings.showGrid?this.currentGrid:1;return this.setState(tje(this,i,$.mul(n,o)))}),S(this,"duplicate",(n=this.selectedIds,r)=>this.readOnly?this:n.length===0?this:this.setState(VHe(this,n,r))),S(this,"resetBounds",(n=this.selectedIds)=>{let r=KS(this,n,this.currentPageId);return this.setState(KS(this,n,this.currentPageId),r.id)}),S(this,"toggleHidden",(n=this.selectedIds)=>n.length===0?this:this.setState(Xv(this,n,"isHidden"))),S(this,"toggleLocked",(n=this.selectedIds)=>n.length===0?this:this.setState(Xv(this,n,"isLocked"))),S(this,"toggleAspectRatioLocked",(n=this.selectedIds)=>n.length===0?this:this.setState(Xv(this,n,"isAspectRatioLocked"))),S(this,"toggleDecoration",(n,r=this.selectedIds)=>r.length===0||!(n==="start"||n==="end")?this:this.setState(eje(this,r,n))),S(this,"setShapeProps",(n,r=this.selectedIds)=>this.setState(rje(this,r,n))),S(this,"rotate",(n=Math.PI*-.5,r=this.selectedIds)=>{if(r.length===0)return this;let i=XHe(this,r,n);return i?this.setState(i):this}),S(this,"group",(n=this.selectedIds,r=N.uniqueId(),i=this.currentPageId)=>{if(this.readOnly)return this;if(n.length===1&&this.getShape(n[0],i).type==="group")return this.ungroup(n,i);if(n.length<2)return this;let o=GHe(this,n,r,i);return o?this.setState(o):this}),S(this,"ungroup",(n=this.selectedIds,r=this.currentPageId)=>{if(this.readOnly)return this;let i=n.map(a=>this.getShape(a,r)).filter(a=>a.type==="group");if(i.length===0)return this;let o=nje(this,n,i,r);return o?this.setState(o):this}),S(this,"cancel",()=>{var n,r;return(r=(n=this.currentTool).onCancel)==null||r.call(n),this}),S(this,"addMediaFromFiles",(n,...r)=>Oe(this,[n,...r],function*(i,o=this.centerPoint){this.setIsLoading(!0);let a=[],s=this.getPagePoint(o);for(let u of i){let d=N.uniqueId(),h=u.name.match(/\.[0-9a-z]+$/i);if(!h)throw Error("No extension");let p=MT.includes(h[0].toLowerCase()),g=$T.includes(h[0].toLowerCase());if(!(p||g))throw Error("Wrong extension");let m=p?"image":"video",v=p?"image":"video",E;try{if(this.callbacks.onAssetCreate){let w=yield this.callbacks.onAssetCreate(this,u,d);if(!w)throw Error("Asset creation callback returned false");E=w}else E=yield eP(u);if(typeof E=="string"){let w=[0,0];if(p){if(h[0]==".svg"){let A,T=yield tP(u),B=this.getViewboxFromSVG(T);B&&(A=B.split(" "),w[0]=parseFloat(A[2]),w[1]=parseFloat(A[3]))}$.isEqual(w,[0,0])&&(w=yield nP(E))}else w=yield rP(E);let C=Object.values(this.document.assets).find(A=>A.type===v&&A.src===E),b;if(C)b=C.id;else{b=d;let A={id:b,type:v,name:u.name,src:E,size:w};this.patchState({document:{assets:{[b]:A}}})}a.push(this.getImageOrVideoShapeAtPoint(d,m,o,w,b))}}catch(w){console.warn(w)}}if(a.length){let u=$.add(s,[0,0]);a.forEach((h,p)=>{let g=Q.getBounds(h);p===0&&(u[0]-=g.width/2,u[1]-=g.height/2),h.point=[...u],u[0]+=g.width});let d=N.getCommonBounds(a.map(Q.getBounds));this.createShapes(...a),N.boundsContain(this.viewport,d)||(this.zoomToSelection(),this.zoom>1&&this.resetZoom())}return this.setIsLoading(!1),this})),S(this,"getViewboxFromSVG",n=>{let r=/.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/;if(typeof n=="string"){let i=n.match(r);return i&&i.length>=2?i[1]:null}return this.setIsLoading(!1),null}),S(this,"onKeyDown",(n,r,i)=>{var o,a;switch(i.key){case"/":{if(this.status==="idle"&&!this.pageState.editingId){let{shiftKey:s,metaKey:u,altKey:d,ctrlKey:h,spaceKey:p}=this;this.onPointerDown({target:"canvas",pointerId:0,origin:r.point,point:r.point,delta:[0,0],pressure:.5,shiftKey:s,ctrlKey:h,metaKey:u,altKey:d,spaceKey:p},{shiftKey:s,altKey:d,ctrlKey:h,pointerId:0,clientX:r.point[0],clientY:r.point[1]})}break}case"Escape":{this.cancel();break}case"Meta":{this.metaKey=!0;break}case"Alt":{this.altKey=!0;break}case"Control":{this.ctrlKey=!0;break}case" ":{this.isForcePanning=!0,this.spaceKey=!0;break}}return(a=(o=this.currentTool).onKeyDown)==null||a.call(o,n,r,i),this}),S(this,"onKeyUp",(n,r,i)=>{var o,a;if(r){switch(i.key){case"/":{let{currentPoint:s,shiftKey:u,metaKey:d,altKey:h,ctrlKey:p,spaceKey:g}=this;this.onPointerUp({target:"canvas",pointerId:0,origin:s,point:s,delta:[0,0],pressure:.5,shiftKey:u,ctrlKey:p,metaKey:d,altKey:h,spaceKey:g},{shiftKey:u,altKey:h,ctrlKey:p,pointerId:0,clientX:s[0],clientY:s[1]});break}case"Meta":{this.metaKey=!1;break}case"Alt":{this.altKey=!1;break}case"Control":{this.ctrlKey=!1;break}case" ":{this.isForcePanning=!1,this.spaceKey=!1;break}}(a=(o=this.currentTool).onKeyUp)==null||a.call(o,n,r,i)}}),S(this,"refreshBoundingBoxes",()=>{let n=this.shapes.map(i=>[i.id,_({point:[...i.point]},"label"in i&&{label:""})]),r=this.shapes.map(i=>[i.id,_({point:[...i.point]},"label"in i&&{label:i.label})]);$Ne(),this.patchState({document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(n)}}}}),this.patchState({document:{pages:{[this.currentPageId]:{shapes:Object.fromEntries(r)}}}})}),S(this,"onDragOver",n=>{n.preventDefault()}),S(this,"onDrop",n=>Oe(this,null,function*(){var r;return n.preventDefault(),this.disableAssets?this:((r=n.dataTransfer.files)!=null&&r.length&&this.addMediaFromFiles(Object.values(n.dataTransfer.files),[n.clientX,n.clientY]),this)})),S(this,"onPinchStart",(n,r)=>{var i,o;(o=(i=this.currentTool).onPinchStart)==null||o.call(i,n,r)}),S(this,"onPinchEnd",(n,r)=>{var i,o;return(o=(i=this.currentTool).onPinchEnd)==null?void 0:o.call(i,n,r)}),S(this,"onPinch",(n,r)=>{var i,o;return(o=(i=this.currentTool).onPinch)==null?void 0:o.call(i,n,r)}),S(this,"onPan",(n,r)=>{if(this.appState.status==="pinching")return;let i=$.div(n.delta,this.camera.zoom),o=this.camera.point,a=$.sub(o,i);$.isEqual(a,o)||(this.pan(i),this.isForcePanning||this.onPointerMove(n,r),TNe&&this.isForcePanning&&this.preventPaste())}),S(this,"onZoom",(n,r)=>{if(this.state.appState.status!=="idle")return;let i=n.delta[2]/50;this.zoomBy(i,n.point),this.onPointerMove(n,r)}),S(this,"updateInputs",n=>{this.currentPoint=this.getPagePoint(n.point).concat(n.pressure),this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.ctrlKey=n.ctrlKey,this.metaKey=n.metaKey}),S(this,"onPointerMove",(n,r)=>{var i,o,a,s,u;if(this.previousPoint=this.currentPoint,this.updateInputs(n,r),this.isForcePanning&&this.isPointing){(i=this.onPan)==null||i.call(this,q(_({},n),{delta:$.neg(n.delta)}),r);return}if((a=(o=this.currentTool).onPointerMove)==null||a.call(o,n,r),this.state.room){let{users:d,userId:h}=this.state.room;(u=(s=this.callbacks).onChangePresence)==null||u.call(s,this,q(_({},d[h]),{point:this.getPagePoint(n.point),session:!!this.session}))}}),S(this,"onPointerDown",(n,r)=>{var i,o;if(r.buttons===4)this.isForcePanning=!0;else if(this.isPointing)return;this.isPointing=!0,this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),!this.isForcePanning&&(this.currentTool.type==="draw"&&r.pointerType==="pen"&&r.button===5&&(this.selectTool("erase"),this.isErasingWithPen=!0),(o=(i=this.currentTool).onPointerDown)==null||o.call(i,n,r))}),S(this,"onPointerUp",(n,r)=>{var i,o;this.isPointing=!1,this.shiftKey||(this.isForcePanning=!1),this.updateInputs(n,r),(o=(i=this.currentTool).onPointerUp)==null||o.call(i,n,r),this.isErasingWithPen&&r.pointerType==="pen"&&r.button===5&&(this.selectTool("draw"),this.isErasingWithPen=!1)}),S(this,"onPointCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onPointCanvas)==null||o.call(i,n,r)}),S(this,"onDoubleClickCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickCanvas)==null||o.call(i,n,r)}),S(this,"onRightPointCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointCanvas)==null||o.call(i,n,r)}),S(this,"onDragCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragCanvas)==null||o.call(i,n,r)}),S(this,"onReleaseCanvas",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseCanvas)==null||o.call(i,n,r)}),S(this,"onPointShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointShape)==null||o.call(i,n,r)}),S(this,"onReleaseShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseShape)==null||o.call(i,n,r)}),S(this,"onDoubleClickShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickShape)==null||o.call(i,n,r)}),S(this,"onRightPointShape",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointShape)==null||o.call(i,n,r)}),S(this,"onDragShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragShape)==null||o.call(i,n,r)}),S(this,"onHoverShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverShape)==null||o.call(i,n,r)}),S(this,"onUnhoverShape",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverShape)==null||o.call(i,n,r)}),S(this,"onPointBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointBounds)==null||o.call(i,n,r)}),S(this,"onDoubleClickBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickBounds)==null||o.call(i,n,r)}),S(this,"onRightPointBounds",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointBounds)==null||o.call(i,n,r)}),S(this,"onDragBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragBounds)==null||o.call(i,n,r)}),S(this,"onHoverBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverBounds)==null||o.call(i,n,r)}),S(this,"onUnhoverBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverBounds)==null||o.call(i,n,r)}),S(this,"onReleaseBounds",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseBounds)==null||o.call(i,n,r)}),S(this,"onPointBoundsHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointBoundsHandle)==null||o.call(i,n,r)}),S(this,"onDoubleClickBoundsHandle",(n,r)=>{var i,o;if(this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickBoundsHandle)==null||o.call(i,n,r),this.selectedIds.length!==1)return;let a=this.getShape(this.selectedIds[0]);if(a.type==="image"||a.type==="video"){let s=this.document.assets[a.assetId],u=Q.getShapeUtil(a),d=u.getCenter(a),h=u.getCenter(q(_({},a),{size:s.size})),p=$.sub(h,d);this.updateShapes({id:a.id,point:$.sub(a.point,p),size:s.size})}}),S(this,"onRightPointBoundsHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointBoundsHandle)==null||o.call(i,n,r)}),S(this,"onDragBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragBoundsHandle)==null||o.call(i,n,r)}),S(this,"onHoverBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverBoundsHandle)==null||o.call(i,n,r)}),S(this,"onUnhoverBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverBoundsHandle)==null||o.call(i,n,r)}),S(this,"onReleaseBoundsHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseBoundsHandle)==null||o.call(i,n,r)}),S(this,"onPointHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onPointHandle)==null||o.call(i,n,r)}),S(this,"onDoubleClickHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onDoubleClickHandle)==null||o.call(i,n,r)}),S(this,"onRightPointHandle",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onRightPointHandle)==null||o.call(i,n,r)}),S(this,"onDragHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onDragHandle)==null||o.call(i,n,r)}),S(this,"onHoverHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onHoverHandle)==null||o.call(i,n,r)}),S(this,"onUnhoverHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onUnhoverHandle)==null||o.call(i,n,r)}),S(this,"onReleaseHandle",(n,r)=>{var i,o;this.updateInputs(n,r),(o=(i=this.currentTool).onReleaseHandle)==null||o.call(i,n,r)}),S(this,"onShapeChange",n=>{let r=this.document.pages[this.currentPageId].shapes,i=_(_({},r[n.id]),n),o=VS(this,[i],this.currentPageId).after;return this.patchState(o,"patched_shapes")}),S(this,"onShapeBlur",()=>{var n,r;if(performance.now()-this.editingStartTime<50)return;let{editingId:i}=this.pageState,{isToolLocked:o}=this.getAppState();if(i){let a=this.getShape(i);this.setEditingId(),a.type==="text"&&(a.text.trim().length<=0?this.patchState(jS(this,[i]).after,"delete_empty_text"):o||this.select(i))}(r=(n=this.currentTool).onShapeBlur)==null||r.call(n)}),S(this,"onShapeClone",(n,r)=>{var i,o;this.originPoint=this.getPagePoint(n.point).concat(n.pressure),this.updateInputs(n,r),(o=(i=this.currentTool).onShapeClone)==null||o.call(i,n,r)}),S(this,"onRenderCountChange",n=>{let r=this.getAppState();r.isEmptyCanvas&&n.length>0?this.patchState({appState:{isEmptyCanvas:!1}},"empty_canvas:false"):!r.isEmptyCanvas&&n.length<=0&&this.patchState({appState:{isEmptyCanvas:!0}},"empty_canvas:true")}),S(this,"onError",()=>{}),S(this,"getShapeUtil",Q.getShapeUtil),this.callbacks=t}setStatus(e){return this.patchState({appState:{status:e}},`set_status:${e}`)}get isMenuOpen(){return this.appState.isMenuOpen}get isLoading(){return this.appState.isLoading}get disableAssets(){return this.appState.disableAssets}get history(){return this.stack.slice(0,this.pointer+1)}set history(e){this.replaceHistory(e)}get document(){return this.state.document}get settings(){return this.state.settings}get appState(){return this.state.appState}get currentPageId(){return this.state.appState.currentPageId}get page(){return this.state.document.pages[this.currentPageId]}get shapes(){return Object.values(this.page.shapes)}get bindings(){return Object.values(this.page.bindings)}get assets(){return Object.values(this.document.assets)}get pageState(){return this.state.document.pageStates[this.currentPageId]}get camera(){return this.pageState.camera}get zoom(){return this.pageState.camera.zoom}get selectedIds(){return this.pageState.selectedIds}createTextShapeAtPoint(e,t,n){let{shapes:r,appState:{currentPageId:i,currentStyle:o}}=this,a=r.length===0?1:r.filter(h=>h.parentId===i).sort((h,p)=>p.childIndex-h.childIndex)[0].childIndex+1,s=od.text,u=s.create({id:t||N.uniqueId(),parentId:i,childIndex:a,point:e,style:_({},o)}),d=s.getBounds(u);return u.point=$.sub(u.point,[d.width/2,d.height/2]),n?this.patchCreate([Q.getShapeUtil(u.type).create(u)]):this.createShapes(u),this.setEditingId(u.id,!0),this}getImageOrVideoShapeAtPoint(e,t,n,r,i){let{shapes:o,appState:{currentPageId:a,currentStyle:s}}=this,u=o.length===0?1:o.filter(h=>h.parentId===a).sort((h,p)=>p.childIndex-h.childIndex)[0].childIndex+1,d=od[t];if(r[0]>this.viewport.width){let h=r[1]/r[0];r[0]=this.viewport.width-128/this.camera.zoom*2,r[1]=r[0]*h,(r[1]<32||r[1]<32)&&(r[1]=32,r[0]=r[1]/h)}else if(r[1]>this.viewport.height){let h=r[0]/r[1];r[1]=this.viewport.height-128/this.camera.zoom*2,r[0]=r[1]*h,(r[1]<32||r[1]<32)&&(r[0]=32,r[1]=r[0]/h)}return d.create({id:e,parentId:a,childIndex:u,point:n,size:r,style:_({},s),assetId:i})}isSelected(e){return this.selectedIds.includes(e)}serializeVideo(e){let t=document.getElementById(e+"_video");if(t){let n=document.createElement("canvas");return n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0),n.toDataURL("image/png")}else throw new Error("Video with id "+e+" not found")}serializeImage(e){let t=document.getElementById(e+"_image");if(t){let n=document.createElement("canvas");return n.width=t.width,n.height=t.height,n.getContext("2d").drawImage(t,0,0),n.toDataURL("image/png")}else throw new Error("Image with id "+e+" not found")}patchAssets(e){this.document.assets=_(_({},this.document.assets),e)}get room(){return this.state.room}get isLocal(){return this.state.room===void 0||this.state.room.id==="local"}get status(){return this.appState.status}get currentUser(){if(this.state.room)return this.state.room.users[this.state.room.userId]}get centerPoint(){let{width:e,height:t}=this.rendererBounds;return $.toFixed([e/2,t/2])}get currentGrid(){let{zoom:e}=this.camera;return e<.15?8*16:e<1?8*4:8*1}},Dc=yn;S(Dc,"version",15.5),S(Dc,"defaultDocument",{id:"doc",name:"New Document",version:yn.version,pages:{page:{id:"page",name:"Page 1",childIndex:1,shapes:{},bindings:{}}},pageStates:{page:{id:"page",selectedIds:[],camera:{point:[0,0],zoom:1}}},assets:{}}),S(Dc,"defaultState",{settings:{isCadSelectMode:!1,isPenMode:!1,isDarkMode:!1,isZoomSnap:!1,isFocusMode:!1,isSnapping:!1,isDebugMode:!1,isReadonlyMode:!1,keepStyleMenuOpen:!1,nudgeDistanceLarge:16,nudgeDistanceSmall:1,showRotateHandles:!0,showBindingHandles:!0,showCloneHandles:!1,showGrid:!1,language:"en",dockPosition:"bottom",exportBackground:"transparent"},appState:{status:"idle",activeTool:"select",hoveredId:void 0,currentPageId:"page",currentStyle:Vo,isToolLocked:!1,isMenuOpen:!1,isEmptyCanvas:!1,eraseLine:[],snapLines:[],isLoading:!1,disableAssets:!1},document:yn.defaultDocument}),S(Dc,"assetSrc","tldraw-assets.json");var Tje=EK,Pje=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1;function Bje({id:e,document:t,currentPageId:n,autofocus:r=!0,showMenu:i=!0,showMultiplayerMenu:o=!0,showPages:a=!0,showTools:s=!0,showZoom:u=!0,showStyles:d=!0,showUI:h=!0,readOnly:p=!1,disableAssets:g=!1,darkMode:m=Pje,components:v,onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetCreate:Z,onAssetDelete:pe,onAssetUpload:me,onSessionStart:Ce,onSessionEnd:W,onExport:U,hideCursors:ne}){let[le,Ae]=l.useState(e),[we,ft]=l.useState(()=>new Dc(e,{onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onSessionStart:Ce,onSessionEnd:W})),[Ze,qe]=l.useState(null),[Ge,At]=l.useState(null),[dt,pn]=l.useState(null),[Dn,On]=l.useState(null),_n=l.useCallback((Tn,tn,Ri,zu)=>{On(()=>Tn),qe(()=>zu),At(()=>tn),pn(()=>Ri)},[]);return l.useLayoutEffect(()=>{if(e===le)return;let Tn=new Dc(e,{onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onExport:U,onSessionStart:Ce,onSessionEnd:W});Ae(e),ft(Tn)},[le,e]),l.useEffect(()=>{!t||(t.id===we.document.id?we.updateDocument(t):we.loadDocument(t))},[t,we]),l.useEffect(()=>{we.setDisableAssets(g)},[we,g]),l.useEffect(()=>{!n||we.changePage(n)},[n,we]),l.useEffect(()=>{we.readOnly=p,p||(we.selectNone(),we.cancelSession(),we.setEditingId())},[we,p]),l.useEffect(()=>{m!==we.settings.isDarkMode&&we.toggleDarkMode()},[we,m]),l.useEffect(()=>{we.callbacks={onMount:E,onChange:w,onChangePresence:C,onNewProject:b,onSaveProject:A,onSaveProjectAs:T,onOpenProject:B,onOpenMedia:D,onUndo:I,onRedo:M,onPersist:O,onPatch:z,onCommand:K,onChangePage:X,onAssetDelete:pe,onAssetCreate:Z,onAssetUpload:me,onExport:U,onSessionStart:Ce,onSessionEnd:W}},[E,w,C,b,A,T,B,D,I,M,O,z,K,X,pe,Z,me,U,Ce,W]),l.useLayoutEffect(()=>{var Tn;if(typeof window>"u"||!((Tn=window.document)!=null&&Tn.fonts))return;function tn(){we.refreshBoundingBoxes()}return window.document.fonts.addEventListener("loadingdone",tn),()=>{window.document.fonts.removeEventListener("loadingdone",tn)}},[we]),l.createElement(kT.Provider,{value:we},l.createElement(DT.Provider,{value:{onYes:Ge,onCancel:Ze,onNo:dt,dialogState:Dn,setDialogState:On,openDialog:_n}},l.createElement(Mje,{key:le||"Tldraw",id:le,autofocus:r,showPages:a,showMenu:i,showMultiplayerMenu:o,showStyles:d,showZoom:u,showTools:s,showUI:h,readOnly:p,components:v,hideCursors:ne})))}var Mje=l.memo(function({id:e,autofocus:t,showPages:n,showMenu:r,showMultiplayerMenu:i,showZoom:o,showStyles:a,showTools:s,readOnly:u,showUI:d,components:h,hideCursors:p}){var g,m;let v=wt(),[E,w]=l.useState(null),C=l.useRef(null),b=v.useStore(),{document:A,settings:T,appState:B,room:D}=b,I=b.appState.activeTool==="select",M=A.pages[B.currentPageId],O=A.pageStates[M.id],z=A.assets,{selectedIds:K}=O,X=K.length===1&&M.shapes[K[0]]&&Q.getShapeUtil(M.shapes[K[0]].type).hideBounds,Z=K.length===1&&M.shapes[K[0]]&&Q.getShapeUtil(M.shapes[K[0]].type).hideResizeHandles,pe=l.useMemo(()=>({isDarkMode:T.isDarkMode}),[T.isDarkMode]),me=T.isCadSelectMode?!B.selectByContain:B.selectByContain,Ce=l.useMemo(()=>{let{selectByContain:ft}=B,{isDarkMode:Ze,isCadSelectMode:qe}=T;if(Ze){let At=qe?ft?"69, 155, 255":"105, 209, 73":"180, 180, 180";return{brushFill:`rgba(${At}, ${qe?.08:.05})`,brushStroke:`rgba(${At}, ${qe?.5:.25})`,brushDashStroke:`rgba(${At}, .6)`,selected:"rgba(38, 150, 255, 1.000)",selectFill:"rgba(38, 150, 255, 0.05)",background:"#212529",foreground:"#49555f"}}let Ge=qe?ft?"0, 89, 242":"51, 163, 23":"0,0,0";return{brushFill:`rgba(${Ge}, ${qe?.08:.05})`,brushStroke:`rgba(${Ge}, ${qe?.4:.25})`,brushDashStroke:`rgba(${Ge}, .6)`}},[T.isDarkMode,T.isCadSelectMode,B.selectByContain]),W=v.session!==void 0,U=W&&((g=v.session)==null?void 0:g.constructor.name)!=="BrushSession"||!I||X||!!O.editingId,ne=W||!I,le=W&&b.appState.status!=="brushing"||!I,Ae=W||!I||O.camera.zoom<.2,we=wOe(T.language);return l.useLayoutEffect(()=>{let ft=C.current;!ft||(T.isDarkMode?ft.classList.add(xS):ft.classList.remove(xS))},[T.isDarkMode]),BHe(C),l.createElement(IT.Provider,{value:C},l.createElement(JV,{locale:we.locale,messages:we.messages},l.createElement(ZOe,{container:E}),l.createElement(Rje,{ref:C,tabIndex:-0},l.createElement(KOe,null),l.createElement($je,{focusableRef:C,autofocus:t}),l.createElement(LOe,null,l.createElement(Tje,{FallbackComponent:OOe},l.createElement(mK,{id:e,containerRef:C,shapeUtils:od,page:M,pageState:O,assets:z,snapLines:B.snapLines,eraseLine:B.eraseLine,grid:8,users:D==null?void 0:D.users,userId:D==null?void 0:D.userId,theme:Ce,meta:pe,components:h,hideCursors:p,hideBounds:U,hideHandles:ne,hideResizeHandles:Z,hideIndicators:le,hideBindingHandles:!T.showBindingHandles,hideCloneHandles:Ae,hideRotateHandles:!T.showRotateHandles,hideGrid:!T.showGrid,showDashedBrush:me,performanceMode:(m=v.session)==null?void 0:m.performanceMode,onPinchStart:v.onPinchStart,onPinchEnd:v.onPinchEnd,onPinch:v.onPinch,onPan:v.onPan,onZoom:v.onZoom,onPointerDown:v.onPointerDown,onPointerMove:v.onPointerMove,onPointerUp:v.onPointerUp,onPointCanvas:v.onPointCanvas,onDoubleClickCanvas:v.onDoubleClickCanvas,onRightPointCanvas:v.onRightPointCanvas,onDragCanvas:v.onDragCanvas,onReleaseCanvas:v.onReleaseCanvas,onPointShape:v.onPointShape,onDoubleClickShape:v.onDoubleClickShape,onRightPointShape:v.onRightPointShape,onDragShape:v.onDragShape,onHoverShape:v.onHoverShape,onUnhoverShape:v.onUnhoverShape,onReleaseShape:v.onReleaseShape,onPointBounds:v.onPointBounds,onDoubleClickBounds:v.onDoubleClickBounds,onRightPointBounds:v.onRightPointBounds,onDragBounds:v.onDragBounds,onHoverBounds:v.onHoverBounds,onUnhoverBounds:v.onUnhoverBounds,onReleaseBounds:v.onReleaseBounds,onPointBoundsHandle:v.onPointBoundsHandle,onDoubleClickBoundsHandle:v.onDoubleClickBoundsHandle,onRightPointBoundsHandle:v.onRightPointBoundsHandle,onDragBoundsHandle:v.onDragBoundsHandle,onHoverBoundsHandle:v.onHoverBoundsHandle,onUnhoverBoundsHandle:v.onUnhoverBoundsHandle,onReleaseBoundsHandle:v.onReleaseBoundsHandle,onPointHandle:v.onPointHandle,onDoubleClickHandle:v.onDoubleClickHandle,onRightPointHandle:v.onRightPointHandle,onDragHandle:v.onDragHandle,onHoverHandle:v.onHoverHandle,onUnhoverHandle:v.onUnhoverHandle,onReleaseHandle:v.onReleaseHandle,onError:v.onError,onRenderCountChange:v.onRenderCountChange,onShapeChange:v.onShapeChange,onShapeBlur:v.onShapeBlur,onShapeClone:v.onShapeClone,onBoundsChange:v.updateBounds,onKeyDown:v.onKeyDown,onKeyUp:v.onKeyUp,onDragOver:v.onDragOver,onDrop:v.onDrop}))),d&&l.createElement(Fje,{ref:w},T.isFocusMode?l.createElement(HOe,{onSelect:v.toggleFocusMode}):l.createElement(l.Fragment,null,l.createElement(PHe,{readOnly:u,showPages:n,showMenu:r,showMultiplayerMenu:i,showStyles:a,showZoom:o}),l.createElement(Lje,null),s&&!u&&l.createElement(mNe,null))))))}),$je=l.memo(function({focusableRef:e,autofocus:t}){return Bne(e),$ne(),l.useEffect(()=>{var n;t&&((n=e.current)==null||n.focus())},[t]),null}),Rje=fe("div",{position:"absolute",height:"100%",width:"100%",minHeight:0,minWidth:0,maxHeight:"100%",maxWidth:"100%",overflow:"hidden",boxSizing:"border-box",outline:"none","& .tl-container":{position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:1},"& input, textarea, button, select, label, button":{webkitTouchCallout:"none",webkitUserSelect:"none","-webkit-tap-highlight-color":"transparent","tap-highlight-color":"transparent"}}),Fje=fe("div",{position:"absolute",top:0,left:0,height:"100%",width:"100%",padding:"8px 8px 0 8px",display:"flex",alignItems:"flex-start",justifyContent:"flex-start",pointerEvents:"none",zIndex:2,"& > *":{pointerEvents:"all"}}),Lje=fe("div",{flexGrow:2});const Oje=e=>{const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),t},_je=typeof performance<"u"?performance:Date,Nje=()=>_je.now();function JS(e,t=30,n=!1){const r=Oje(e),i=1e3/t,o=l.useRef(0),a=l.useRef(),s=()=>a.current&&clearTimeout(a.current),u=[t,n,r];function d(){o.current=0,s()}return l.useEffect(()=>d,u),l.useCallback(function(){const h=arguments,p=Nje(),g=()=>{o.current=p,s(),r.current.apply(null,h)},m=o.current;if(n&&m===0)return g();if(p-m>i){if(m>0)return g();o.current=p}s(),a.current=setTimeout(()=>{g(),o.current=0},i)},u)}var vt;(function(e){e[e.Canceled=1]="Canceled",e[e.Unknown=2]="Unknown",e[e.InvalidArgument=3]="InvalidArgument",e[e.DeadlineExceeded=4]="DeadlineExceeded",e[e.NotFound=5]="NotFound",e[e.AlreadyExists=6]="AlreadyExists",e[e.PermissionDenied=7]="PermissionDenied",e[e.ResourceExhausted=8]="ResourceExhausted",e[e.FailedPrecondition=9]="FailedPrecondition",e[e.Aborted=10]="Aborted",e[e.OutOfRange=11]="OutOfRange",e[e.Unimplemented=12]="Unimplemented",e[e.Internal=13]="Internal",e[e.Unavailable=14]="Unavailable",e[e.DataLoss=15]="DataLoss",e[e.Unauthenticated=16]="Unauthenticated"})(vt||(vt={}));function WS(e){const t=vt[e];return typeof t!="string"?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}class Nt extends Error{constructor(t,n=vt.Unknown,r,i,o){super(zje(t,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=n,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=o}static from(t,n=vt.Unknown){return t instanceof Nt?t:t instanceof Error?t.name=="AbortError"?new Nt(t.message,vt.Canceled):new Nt(t.message,n,void 0,void 0,t):new Nt(String(t),n,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===Nt.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const n="typeName"in t?{findMessage:i=>i===t.typeName?t:void 0}:t,r=[];for(const i of this.details){if("getType"in i){n.findMessage(i.getType().typeName)&&r.push(i);continue}const o=n.findMessage(i.type);if(o)try{r.push(o.fromBinary(i.value))}catch{}}return r}}function zje(e,t){return e.length?`[${WS(t)}] ${e}`:`[${WS(t)}]`}function en(e,t){if(!e)throw new Error(t)}const Hje=34028234663852886e22,jje=-34028234663852886e22,Uje=4294967295,Kje=2147483647,Vje=-2147483648;function Vp(e){if(typeof e!="number")throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>Kje||eUje||e<0)throw new Error("invalid uint 32: "+e)}function iP(e){if(typeof e!="number")throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>Hje||e({no:i.no,name:i.name,localName:e[i.no]})))}function sP(e,t,n){const r=Object.create(null),i=Object.create(null),o=[];for(const a of t){const s=uP(a);o.push(s),r[a.name]=s,i[a.no]=s}return{typeName:e,values:o,findName(a){return r[a]},findNumber(a){return i[a]}}}function Jje(e,t,n){const r={};for(const i of t){const o=uP(i);r[o.localName]=o.no,r[o.no]=o.localName}return aP(r,e,t),r}function uP(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class ve{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,n){const r=this.getType(),i=r.runtime.bin,o=i.makeReadOptions(n);return i.readMessage(this,o.readerFactory(t),t.byteLength,o),this}fromJson(t,n){const r=this.getType(),i=r.runtime.json,o=i.makeReadOptions(n);return i.readMessage(r,t,o,this),this}fromJsonString(t,n){let r;try{r=JSON.parse(t)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,n)}toBinary(t){const n=this.getType(),r=n.runtime.bin,i=r.makeWriteOptions(t),o=i.writerFactory();return r.writeMessage(this,o,i),o.finish()}toJson(t){const n=this.getType(),r=n.runtime.json,i=r.makeWriteOptions(t);return r.writeMessage(this,i)}toJsonString(t){var n;const r=this.toJson(t);return JSON.stringify(r,null,(n=t==null?void 0:t.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Wje(e,t,n,r){var i;const o=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:t.substring(t.lastIndexOf(".")+1),a={[o]:function(s){e.util.initFields(this),e.util.initPartial(s,this)}}[o];return Object.setPrototypeOf(a.prototype,new ve),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary(s,u){return new a().fromBinary(s,u)},fromJson(s,u){return new a().fromJson(s,u)},fromJsonString(s,u){return new a().fromJsonString(s,u)},equals(s,u){return e.util.equals(a,s,u)}}),a}function Yje(){let e=0,t=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>4,!(n&128))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(t|=(i&127)<>>o,s=!(!(a>>>7)&&t==0),u=(s?a|128:a)&255;if(n.push(u),!s)return}const r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),!!i){for(let o=3;o<31;o=o+7){const a=t>>>o,s=!!(a>>>7),u=(s?a|128:a)&255;if(n.push(u),!s)return}n.push(t>>>31&1)}}const Gp=4294967296;function YS(e){const t=e[0]==="-";t&&(e=e.slice(1));const n=1e6;let r=0,i=0;function o(a,s){const u=Number(e.slice(a,s));i*=n,r=r*n+u,r>=Gp&&(i=i+(r/Gp|0),r=r%Gp)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?cP(r,i):RC(r,i)}function qje(e,t){let n=RC(e,t);const r=n.hi&2147483648;r&&(n=cP(n.lo,n.hi));const i=lP(n.lo,n.hi);return r?"-"+i:i}function lP(e,t){if({lo:e,hi:t}=Xje(e,t),t<=2097151)return String(Gp*t+e);const n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535;let o=n+r*6777216+i*6710656,a=r+i*8147497,s=i*2;const u=1e7;return o>=u&&(a+=Math.floor(o/u),o%=u),a>=u&&(s+=Math.floor(a/u),a%=u),s.toString()+qS(a)+qS(o)}function Xje(e,t){return{lo:e>>>0,hi:t>>>0}}function RC(e,t){return{lo:e|0,hi:t|0}}function cP(e,t){return t=~t,e?e=~e+1:t+=1,RC(e,t)}const qS=e=>{const t=String(e);return"0000000".slice(t.length)+t};function XS(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e=e>>7;t.push(1)}}function Zje(){let e=this.buf[this.pos++],t=e&127;if(!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let n=5;e&128&&n<10;n++)e=this.buf[this.pos++];if(e&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var ZS={};function Qje(){const e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||typeof ZS!="object"||ZS.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),a=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const d=typeof u=="bigint"?u:BigInt(u);if(d>o||ds||den(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>en(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),n(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),n(i),YS(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),YS(i)},dec(i,o){return qje(i,o)},uDec(i,o){return lP(i,o)}}}const zt=Qje();var re;(function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"})(re||(re={}));var Iu;(function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"})(Iu||(Iu={}));function Js(e,t,n){if(t===n)return!0;if(e==re.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let r=0;r>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Wy(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Vp(t),XS(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let n=this.textEncoder.encode(t);return this.uint32(n.byteLength),this.raw(n)}float(t){iP(t);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,t,!0),this.raw(n)}double(t){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,t,!0),this.raw(n)}fixed32(t){Wy(t);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t,!0),this.raw(n)}sfixed32(t){Vp(t);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,t,!0),this.raw(n)}sint32(t){return Vp(t),t=(t<<1^t>>31)>>>0,XS(t,this.buf),this}sfixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),i=zt.enc(t);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}fixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),i=zt.uEnc(t);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}int64(t){let n=zt.enc(t);return Qv(n.lo,n.hi,this.buf),this}sint64(t){let n=zt.enc(t),r=n.hi>>31,i=n.lo<<1^r,o=(n.hi<<1|n.lo>>>31)^r;return Qv(i,o,this.buf),this}uint64(t){let n=zt.uEnc(t);return Qv(n.lo,n.hi,this.buf),this}}class tUe{constructor(t,n){this.varint64=Yje,this.uint32=Zje,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=n??new TextDecoder}tag(){let t=this.uint32(),n=t>>>3,r=t&7;if(n<=0||r<0||r>5)throw new Error("illegal tag: field no "+n+" wire type "+r);return[n,r]}skip(t,n){let r=this.pos;switch(t){case sn.Varint:for(;this.buf[this.pos++]&128;);break;case sn.Bit64:this.pos+=4;case sn.Bit32:this.pos+=4;break;case sn.LengthDelimited:let i=this.uint32();this.pos+=i;break;case sn.StartGroup:for(;;){const[o,a]=this.tag();if(a===sn.EndGroup){if(n!==void 0&&o!==n)throw new Error("invalid end group tag");break}this.skip(a,o)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return zt.dec(...this.varint64())}uint64(){return zt.uDec(...this.varint64())}sint64(){let[t,n]=this.varint64(),r=-(t&1);return t=(t>>>1|(n&1)<<31)^r,n=n>>>1^r,zt.dec(t,n)}bool(){let[t,n]=this.varint64();return t!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),n=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(n,n+t)}string(){return this.textDecoder.decode(this.bytes())}}function nUe(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){const o=typeof r=="function"?r():r;o.name=t.split(".").pop(),o.jsonName=`[${t}]`,i=e.util.newFieldList([o]).list()[0]}return i},runtime:e}}function hP(e){const t=e.field.localName,n=Object.create(null);return n[t]=rUe(e),[n,()=>n[t]]}function rUe(e){const t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return ad(t.T,t.L);case"message":const n=t.T,r=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function iUe(e,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(n=>n.no===t.no)}let ss="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),v1=[];for(let e=0;e>4,a=o,i=2;break;case 2:n[r++]=(a&15)<<4|(o&60)>>2,a=o,i=3;break;case 3:n[r++]=(a&3)<<6|o,i=0;break}}if(i==1)throw Error("invalid base64 string.");return n.subarray(0,r)},enc(e){let t="",n=0,r,i=0;for(let o=0;o>2],i=(r&3)<<4,n=1;break;case 1:t+=ss[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=ss[i|r>>6],t+=ss[r&63],n=0;break}return n&&(t+=ss[i],t+="=",n==1&&(t+="=")),t}};function oUe(e,t,n){pP(t,e);const r=t.runtime.bin.makeReadOptions(n),i=iUe(e.getType().runtime.bin.listUnknownFields(e),t.field),[o,a]=hP(t);for(const s of i)t.runtime.bin.readField(o,r.readerFactory(s.data),t.field,s.wireType,r);return a()}function aUe(e,t,n,r){pP(t,e);const i=t.runtime.bin.makeReadOptions(r),o=t.runtime.bin.makeWriteOptions(r);if(fP(e,t)){const d=e.getType().runtime.bin.listUnknownFields(e).filter(h=>h.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(const h of d)e.getType().runtime.bin.onUnknownField(e,h.no,h.wireType,h.data)}const a=o.writerFactory();let s=t.field;!s.opt&&!s.repeated&&(s.kind=="enum"||s.kind=="scalar")&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,a,o);const u=i.readerFactory(a.finish());for(;u.posr.no==t.field.no)}function pP(e,t){en(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function gP(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?t[n]!==void 0:e.kind=="enum"?t[n]!==e.T.values[0].no:!dP(e.T,t[n]);case"message":return t[n]!==void 0;case"map":return Object.keys(t[n]).length>0}}function QS(e,t){const n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=r?e.T.values[0].no:void 0;break;case"scalar":t[n]=r?ad(e.T,e.L):void 0;break;case"message":t[n]=void 0;break}}function gl(e,t){if(e===null||typeof e!="object"||!Object.getOwnPropertyNames(ve.prototype).every(r=>r in e&&typeof e[r]=="function"))return!1;const n=e.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:t===void 0?!0:n.typeName==t.typeName}function mP(e,t){return gl(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}re.DOUBLE,re.FLOAT,re.INT64,re.UINT64,re.INT32,re.UINT32,re.BOOL,re.STRING,re.BYTES;const ex={ignoreUnknownFields:!1},tx={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function sUe(e){return e?Object.assign(Object.assign({},ex),e):ex}function uUe(e){return e?Object.assign(Object.assign({},tx),e):tx}const Hg=Symbol(),Jp=Symbol();function lUe(){return{makeReadOptions:sUe,makeWriteOptions:uUe,readMessage(e,t,n,r){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${e.typeName} from JSON: ${So(t)}`);r=r??new e;const i=new Map,o=n.typeRegistry;for(const[a,s]of Object.entries(t)){const u=e.fields.findJsonName(a);if(u){if(u.oneof){if(s===null&&u.kind=="scalar")continue;const d=i.get(u.oneof);if(d!==void 0)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${d}", "${a}"`);i.set(u.oneof,a)}nx(r,s,u,n,e)}else{let d=!1;if(o!=null&&o.findExtension&&a.startsWith("[")&&a.endsWith("]")){const h=o.findExtension(a.substring(1,a.length-1));if(h&&h.extendee.typeName==e.typeName){d=!0;const[p,g]=hP(h);nx(p,s,h.field,n,h),aUe(r,h,g(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${a}" is unknown`)}}return r},writeMessage(e,t){const n=e.getType(),r={};let i;try{for(i of n.fields.byNumber()){if(!gP(i,e)){if(i.req)throw"required field not set";if(!t.emitDefaultValues||!dUe(i))continue}const a=i.oneof?e[i.oneof.localName].value:e[i.localName],s=rx(i,a,t);s!==void 0&&(r[t.useProtoFieldName?i.name:i.jsonName]=s)}const o=t.typeRegistry;if(o!=null&&o.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(e)){const s=o.findExtensionFor(n.typeName,a.no);if(s&&fP(e,s)){const u=oUe(e,s,t),d=rx(s.field,u,t);d!==void 0&&(r[s.field.jsonName]=d)}}}catch(o){const a=i?`cannot encode field ${n.typeName}.${i.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,s=o instanceof Error?o.message:String(o);throw new Error(a+(s.length>0?`: ${s}`:""))}return r},readScalar(e,t,n){return M0(e,t,n??Iu.BIGINT,!0)},writeScalar(e,t,n){if(t!==void 0&&(n||dP(e,t)))return Wp(e,t)},debug:So}}function So(e){if(e===null)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function nx(e,t,n,r,i){let o=n.localName;if(n.repeated){if(en(n.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`);const a=e[o];for(const s of t){if(s===null)throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(s)}`);switch(n.kind){case"message":a.push(n.T.fromJson(s,r));break;case"enum":const u=e2(n.T,s,r.ignoreUnknownFields,!0);u!==Jp&&a.push(u);break;case"scalar":try{a.push(M0(n.T,s,n.L,!0))}catch(d){let h=`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(s)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}break}}}else if(n.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`);const a=e[o];for(const[s,u]of Object.entries(t)){if(u===null)throw new Error(`cannot decode field ${i.typeName}.${n.name} from JSON: map value null`);let d;try{d=cUe(n.K,s)}catch(h){let p=`cannot decode map key for field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw h instanceof Error&&h.message.length>0&&(p+=`: ${h.message}`),new Error(p)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(u,r);break;case"enum":const h=e2(n.V.T,u,r.ignoreUnknownFields,!0);h!==Jp&&(a[d]=h);break;case"scalar":try{a[d]=M0(n.V.T,u,Iu.BIGINT,!0)}catch(p){let g=`cannot decode map value for field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw p instanceof Error&&p.message.length>0&&(g+=`: ${p.message}`),new Error(g)}break}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:o},o="value"),n.kind){case"message":const a=n.T;if(t===null&&a.typeName!="google.protobuf.Value")return;let s=e[o];gl(s)?s.fromJson(t,r):(e[o]=s=a.fromJson(t,r),a.fieldWrapper&&!n.oneof&&(e[o]=a.fieldWrapper.unwrapField(s)));break;case"enum":const u=e2(n.T,t,r.ignoreUnknownFields,!1);switch(u){case Hg:QS(n,e);break;case Jp:break;default:e[o]=u;break}break;case"scalar":try{const d=M0(n.T,t,n.L,!1);switch(d){case Hg:QS(n,e);break;default:e[o]=d;break}}catch(d){let h=`cannot decode field ${i.typeName}.${n.name} from JSON: ${So(t)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}break}}function cUe(e,t){if(e===re.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return M0(e,t,Iu.BIGINT,!0).toString()}function M0(e,t,n,r){if(t===null)return r?ad(e,n):Hg;switch(e){case re.DOUBLE:case re.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const i=Number(t);if(Number.isNaN(i)||!Number.isFinite(i))break;return e==re.FLOAT&&iP(i),i;case re.INT32:case re.FIXED32:case re.SFIXED32:case re.SINT32:case re.UINT32:let o;if(typeof t=="number"?o=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),o===void 0)break;return e==re.UINT32||e==re.FIXED32?Wy(o):Vp(o),o;case re.INT64:case re.SFIXED64:case re.SINT64:if(typeof t!="number"&&typeof t!="string")break;const a=zt.parse(t);return n?a.toString():a;case re.FIXED64:case re.UINT64:if(typeof t!="number"&&typeof t!="string")break;const s=zt.uParse(t);return n?s.toString():s;case re.BOOL:if(typeof t!="boolean")break;return t;case re.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case re.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return FC.dec(t)}throw new Error}function e2(e,t,n,r){if(t===null)return e.typeName=="google.protobuf.NullValue"?0:r?e.values[0].no:Hg;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const i=e.findName(t);if(i!==void 0)return i.no;if(n)return Jp;break}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${So(t)}`)}function dUe(e){return e.repeated||e.kind=="map"?!0:!(e.oneof||e.kind=="message"||e.opt||e.req)}function rx(e,t,n){if(e.kind=="map"){en(typeof t=="object"&&t!=null);const r={},i=Object.entries(t);switch(e.V.kind){case"scalar":for(const[a,s]of i)r[a.toString()]=Wp(e.V.T,s);break;case"message":for(const[a,s]of i)r[a.toString()]=s.toJson(n);break;case"enum":const o=e.V.T;for(const[a,s]of i)r[a.toString()]=t2(o,s,n.enumAsInteger);break}return n.emitDefaultValues||i.length>0?r:void 0}if(e.repeated){en(Array.isArray(t));const r=[];switch(e.kind){case"scalar":for(let i=0;i0?r:void 0}switch(e.kind){case"scalar":return Wp(e.T,t);case"enum":return t2(e.T,t,n.enumAsInteger);case"message":return mP(e.T,t).toJson(n)}}function t2(e,t,n){var r;if(en(typeof t=="number"),e.typeName=="google.protobuf.NullValue")return null;if(n)return t;const i=e.findNumber(t);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:t}function Wp(e,t){switch(e){case re.INT32:case re.SFIXED32:case re.SINT32:case re.FIXED32:case re.UINT32:return en(typeof t=="number"),t;case re.FLOAT:case re.DOUBLE:return en(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case re.STRING:return en(typeof t=="string"),t;case re.BOOL:return en(typeof t=="boolean"),t;case re.UINT64:case re.FIXED64:case re.INT64:case re.SFIXED64:case re.SINT64:return en(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case re.BYTES:return en(t instanceof Uint8Array),FC.enc(t)}}const cc=Symbol("@bufbuild/protobuf/unknown-fields"),ix={readUnknownFields:!0,readerFactory:e=>new tUe(e)},ox={writeUnknownFields:!0,writerFactory:()=>new eUe};function hUe(e){return e?Object.assign(Object.assign({},ix),e):ix}function fUe(e){return e?Object.assign(Object.assign({},ox),e):ox}function pUe(){return{makeReadOptions:hUe,makeWriteOptions:fUe,listUnknownFields(e){var t;return(t=e[cc])!==null&&t!==void 0?t:[]},discardUnknownFields(e){delete e[cc]},writeUnknownFields(e,t){const r=e[cc];if(r)for(const i of r)t.tag(i.no,i.wireType).raw(i.data)},onUnknownField(e,t,n,r){const i=e;Array.isArray(i[cc])||(i[cc]=[]),i[cc].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,i){const o=e.getType(),a=i?t.len:t.pos+n;let s,u;for(;t.pos0&&(u=mUe),o){let g=e[a];if(r==sn.LengthDelimited&&s!=re.STRING&&s!=re.BYTES){let v=t.uint32()+t.pos;for(;t.posgl(g,p)?g:new p(g));else{const g=a[i];p.fieldWrapper?p.typeName==="google.protobuf.BytesValue"?o[i]=a0(g):o[i]=g:o[i]=gl(g,p)?g:new p(g)}break}}},equals(e,t,n){return t===n?!0:!t||!n?!1:e.fields.byMember().every(r=>{const i=t[r.localName],o=n[r.localName];if(r.repeated){if(i.length!==o.length)return!1;switch(r.kind){case"message":return i.every((a,s)=>r.T.equals(a,o[s]));case"scalar":return i.every((a,s)=>Js(r.T,a,o[s]));case"enum":return i.every((a,s)=>Js(re.INT32,a,o[s]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,o);case"enum":return Js(re.INT32,i,o);case"scalar":return Js(r.T,i,o);case"oneof":if(i.case!==o.case)return!1;const a=r.findField(i.case);if(a===void 0)return!0;switch(a.kind){case"message":return a.T.equals(i.value,o.value);case"enum":return Js(re.INT32,i.value,o.value);case"scalar":return Js(a.T,i.value,o.value)}throw new Error(`oneof cannot contain ${a.kind}`);case"map":const s=Object.keys(i).concat(Object.keys(o));switch(r.V.kind){case"message":const u=r.V.T;return s.every(h=>u.equals(i[h],o[h]));case"enum":return s.every(h=>Js(re.INT32,i[h],o[h]));case"scalar":const d=r.V.T;return s.every(h=>Js(d,i[h],o[h]))}break}})},clone(e){const t=e.getType(),n=new t,r=n;for(const i of t.fields.byMember()){const o=e[i.localName];let a;if(i.repeated)a=o.map(wp);else if(i.kind=="map"){a=r[i.localName];for(const[s,u]of Object.entries(o))a[s]=wp(u)}else i.kind=="oneof"?a=i.findField(o.case)?{case:o.case,value:wp(o.value)}:{case:void 0}:a=wp(o);r[i.localName]=a}for(const i of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return n}}}function wp(e){if(e===void 0)return e;if(gl(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function a0(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function CUe(e,t,n){return{syntax:e,json:lUe(),bin:pUe(),util:Object.assign(Object.assign({},EUe()),{newFieldList:t,initFields:n}),makeMessageType(r,i,o){return Wje(this,r,i,o)},makeEnum:Jje,makeEnumType:sP,getEnumType:Gje,makeExtension(r,i,o){return nUe(this,r,i,o)}}}class bUe{constructor(t,n){this._fields=t,this._normalizer=n}findJsonName(t){if(!this.jsonNames){const n={};for(const r of this.list())n[r.jsonName]=n[r.name]=r;this.jsonNames=n}return this.jsonNames[t]}find(t){if(!this.numbers){const n={};for(const r of this.list())n[r.no]=r;this.numbers=n}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,n)=>t.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let n;for(const r of this.list())r.oneof?r.oneof!==n&&(n=r.oneof,t.push(n)):t.push(r)}return this.members}}function yP(e,t){const n=EP(e);return t?n:IUe(kUe(n))}function wUe(e){return yP(e,!1)}const SUe=EP;function EP(e){let t=!1;const n=[];for(let r=0;r`${e}$`,kUe=e=>AUe.has(e)?CP(e):e,IUe=e=>xUe.has(e)?CP(e):e;class DUe{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=wUe(t)}addField(t){en(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;nnew bUe(e,t=>TUe(t)),e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,r=e;if(t.repeated){r[n]=[];continue}switch(t.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=ad(t.T,t.L);break}}});var ir;(function(e){e[e.Unary=0]="Unary",e[e.ServerStreaming=1]="ServerStreaming",e[e.ClientStreaming=2]="ClientStreaming",e[e.BiDiStreaming=3]="BiDiStreaming"})(ir||(ir={}));var lx;(function(e){e[e.NoSideEffects=1]="NoSideEffects",e[e.Idempotent=2]="Idempotent"})(lx||(lx={}));class Vn extends ve{constructor(t){super(),this.seconds=zt.zero,this.nanos=0,R.util.initPartial(t,this)}fromJson(t,n){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${R.json.debug(t)}`);const r=t.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=zt.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(t){const n=Number(this.seconds)*1e3;if(nDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(n).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Vn.fromDate(new Date)}static fromDate(t){const n=t.getTime();return new Vn({seconds:zt.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(t,n){return new Vn().fromBinary(t,n)}static fromJson(t,n){return new Vn().fromJson(t,n)}static fromJsonString(t,n){return new Vn().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Vn,t,n)}}Vn.runtime=R;Vn.typeName="google.protobuf.Timestamp";Vn.fields=R.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class cs extends ve{constructor(t){super(),this.seconds=zt.zero,this.nanos=0,R.util.initPartial(t,this)}fromJson(t,n){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);const r=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${R.json.debug(t)}`);if(this.seconds=zt.parse(i),typeof r[2]=="string"){const o=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(o),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let n=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),n+="."+r,this.nanos<0&&Number(this.seconds)==0&&(n="-"+n)}return n+"s"}static fromBinary(t,n){return new cs().fromBinary(t,n)}static fromJson(t,n){return new cs().fromJson(t,n)}static fromJsonString(t,n){return new cs().fromJsonString(t,n)}static equals(t,n){return R.util.equals(cs,t,n)}}cs.runtime=R;cs.typeName="google.protobuf.Duration";cs.fields=R.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class ko extends ve{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),R.util.initPartial(t,this)}toJson(t){var n;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(n=t==null?void 0:t.typeRegistry)===null||n===void 0?void 0:n.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let a=i.fromBinary(this.value).toJson(t);return(r.startsWith("google.protobuf.")||a===null||Array.isArray(a)||typeof a!="object")&&(a={value:a}),a["@type"]=this.typeUrl,a}fromJson(t,n){var r;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const i=t["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const o=this.typeUrlToName(i),a=(r=n==null?void 0:n.typeRegistry)===null||r===void 0?void 0:r.findMessage(o);if(!a)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let s;if(o.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))s=a.fromJson(t.value,n);else{const u=Object.assign({},t);delete u["@type"],s=a.fromJson(u,n)}return this.packFrom(s),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const n=t.findMessage(this.typeUrlToName(this.typeUrl));if(n)return n.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const n=this.typeUrlToName(this.typeUrl);let r="";return typeof t=="string"?r=t:r=t.typeName,n===r}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const n=t.lastIndexOf("/"),r=n>=0?t.substring(n+1):t;if(!r.length)throw new Error(`invalid type url: ${t}`);return r}static pack(t){const n=new ko;return n.packFrom(t),n}static fromBinary(t,n){return new ko().fromBinary(t,n)}static fromJson(t,n){return new ko().fromJson(t,n)}static fromJsonString(t,n){return new ko().fromJsonString(t,n)}static equals(t,n){return R.util.equals(ko,t,n)}}ko.runtime=R;ko.typeName="google.protobuf.Any";ko.fields=R.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class To extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.DOUBLE,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.DOUBLE,t)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new To().fromBinary(t,n)}static fromJson(t,n){return new To().fromJson(t,n)}static fromJsonString(t,n){return new To().fromJsonString(t,n)}static equals(t,n){return R.util.equals(To,t,n)}}To.runtime=R;To.typeName="google.protobuf.DoubleValue";To.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);To.fieldWrapper={wrapField(e){return new To({value:e})},unwrapField(e){return e.value}};class Po extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.FLOAT,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.FLOAT,t)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Po().fromBinary(t,n)}static fromJson(t,n){return new Po().fromJson(t,n)}static fromJsonString(t,n){return new Po().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Po,t,n)}}Po.runtime=R;Po.typeName="google.protobuf.FloatValue";Po.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Po.fieldWrapper={wrapField(e){return new Po({value:e})},unwrapField(e){return e.value}};class Bo extends ve{constructor(t){super(),this.value=zt.zero,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.INT64,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.INT64,t)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Bo().fromBinary(t,n)}static fromJson(t,n){return new Bo().fromJson(t,n)}static fromJsonString(t,n){return new Bo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Bo,t,n)}}Bo.runtime=R;Bo.typeName="google.protobuf.Int64Value";Bo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Bo.fieldWrapper={wrapField(e){return new Bo({value:e})},unwrapField(e){return e.value}};class Mo extends ve{constructor(t){super(),this.value=zt.zero,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.UINT64,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.UINT64,t)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Mo().fromBinary(t,n)}static fromJson(t,n){return new Mo().fromJson(t,n)}static fromJsonString(t,n){return new Mo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Mo,t,n)}}Mo.runtime=R;Mo.typeName="google.protobuf.UInt64Value";Mo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Mo.fieldWrapper={wrapField(e){return new Mo({value:e})},unwrapField(e){return e.value}};class $o extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.INT32,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.INT32,t)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new $o().fromBinary(t,n)}static fromJson(t,n){return new $o().fromJson(t,n)}static fromJsonString(t,n){return new $o().fromJsonString(t,n)}static equals(t,n){return R.util.equals($o,t,n)}}$o.runtime=R;$o.typeName="google.protobuf.Int32Value";$o.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);$o.fieldWrapper={wrapField(e){return new $o({value:e})},unwrapField(e){return e.value}};class Ro extends ve{constructor(t){super(),this.value=0,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.UINT32,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.UINT32,t)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Ro().fromBinary(t,n)}static fromJson(t,n){return new Ro().fromJson(t,n)}static fromJsonString(t,n){return new Ro().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Ro,t,n)}}Ro.runtime=R;Ro.typeName="google.protobuf.UInt32Value";Ro.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Ro.fieldWrapper={wrapField(e){return new Ro({value:e})},unwrapField(e){return e.value}};class Fo extends ve{constructor(t){super(),this.value=!1,R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.BOOL,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.BOOL,t)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Fo().fromBinary(t,n)}static fromJson(t,n){return new Fo().fromJson(t,n)}static fromJsonString(t,n){return new Fo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Fo,t,n)}}Fo.runtime=R;Fo.typeName="google.protobuf.BoolValue";Fo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Fo.fieldWrapper={wrapField(e){return new Fo({value:e})},unwrapField(e){return e.value}};class _r extends ve{constructor(t){super(),this.value="",R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.STRING,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.STRING,t)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new _r().fromBinary(t,n)}static fromJson(t,n){return new _r().fromJson(t,n)}static fromJsonString(t,n){return new _r().fromJsonString(t,n)}static equals(t,n){return R.util.equals(_r,t,n)}}_r.runtime=R;_r.typeName="google.protobuf.StringValue";_r.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);_r.fieldWrapper={wrapField(e){return new _r({value:e})},unwrapField(e){return e.value}};class Lo extends ve{constructor(t){super(),this.value=new Uint8Array(0),R.util.initPartial(t,this)}toJson(t){return R.json.writeScalar(re.BYTES,this.value,!0)}fromJson(t,n){try{this.value=R.json.readScalar(re.BYTES,t)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(t,n){return new Lo().fromBinary(t,n)}static fromJson(t,n){return new Lo().fromJson(t,n)}static fromJsonString(t,n){return new Lo().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Lo,t,n)}}Lo.runtime=R;Lo.typeName="google.protobuf.BytesValue";Lo.fields=R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Lo.fieldWrapper={wrapField(e){return new Lo({value:e})},unwrapField(e){return e.value}};function PUe(e,t,n){try{const r=FC.dec(e);return t?t.fromBinary(r,n):r}catch(r){throw Nt.from(r,vt.DataLoss)}}function BUe(e,t){const n={};for(const[r,i]of Object.entries(e.methods)){const o=t(Object.assign(Object.assign({},i),{localName:r,service:e}));o!=null&&(n[r]=o)}return n}function cx(e){let t,n=new Uint8Array(0);function r(i){const o=new Uint8Array(n.length+i.length);o.set(n),o.set(i,n.length),n=o}return new ReadableStream({start(){t=e.getReader()},async pull(i){let o;for(;;){if(o===void 0&&n.byteLength>=5){let u=0;for(let d=1;d<5;d++)u=(u<<8)+n[d];o={flags:n[0],length:u}}if(o!==void 0&&n.byteLength>=o.length+5)break;const s=await t.read();if(s.done)break;r(s.value)}if(o===void 0){if(n.byteLength==0){i.close();return}i.error(new Nt("premature end of stream",vt.DataLoss));return}const a=n.subarray(5,5+o.length);n=n.subarray(5+o.length),i.enqueue({flags:o.flags,data:a})}})}function dx(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}var MUe=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(s,u){a=e[o](a),i(s,u,a.done,a.value)})}}function i(o,a,s,u){Promise.resolve(u).then(function(d){o({value:d,done:s})},a)}},sh=function(e){return this instanceof sh?(this.v=e,this):new sh(e)},$Ue=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof sh?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}},RUe=function(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,o){t[i]=e[i]?function(a){return(n=!n)?{value:sh(e[i](a)),done:!1}:o?o(a):a}:o}};function FUe(e){return $Ue(this,arguments,function*(){yield sh(yield*RUe(MUe(e)))})}var bP=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(a){return new Promise(function(s,u){a=e[o](a),i(s,u,a.done,a.value)})}}function i(o,a,s,u){Promise.resolve(u).then(function(d){o({value:d,done:s})},a)}},sd=function(e){return this instanceof sd?(this.v=e,this):new sd(e)},LUe=function(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,o){t[i]=e[i]?function(a){return(n=!n)?{value:sd(e[i](a)),done:!1}:o?o(a):a}:o}},OUe=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof sd?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}};function _Ue(e,t){return BUe(e,n=>{switch(n.kind){case ir.Unary:return NUe(t,e,n);case ir.ServerStreaming:return zUe(t,e,n);case ir.ClientStreaming:return HUe(t,e,n);case ir.BiDiStreaming:return jUe(t,e,n);default:return null}})}function NUe(e,t,n){return async function(r,i){var o,a;const s=await e.unary(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(o=i==null?void 0:i.onHeader)===null||o===void 0||o.call(i,s.header),(a=i==null?void 0:i.onTrailer)===null||a===void 0||a.call(i,s.trailer),s.message}}function zUe(e,t,n){return function(r,i){return wP(e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,FUe([r]),i==null?void 0:i.contextValues),i)}}function HUe(e,t,n){return async function(r,i){var o,a,s,u,d,h;const p=await e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(d=i==null?void 0:i.onHeader)===null||d===void 0||d.call(i,p.header);let g;try{for(var m=!0,v=bP(p.message),E;E=await v.next(),o=E.done,!o;m=!0)u=E.value,m=!1,g=u}catch(w){a={error:w}}finally{try{!m&&!o&&(s=v.return)&&await s.call(v)}finally{if(a)throw a.error}}if(!g)throw new Nt("protocol error: missing response message",vt.Internal);return(h=i==null?void 0:i.onTrailer)===null||h===void 0||h.call(i,p.trailer),g}}function jUe(e,t,n){return function(r,i){return wP(e.stream(t,n,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function wP(e,t){const n=function(){var r,i;return OUe(this,arguments,function*(){const o=yield sd(e);(r=t==null?void 0:t.onHeader)===null||r===void 0||r.call(t,o.header),yield sd(yield*LUe(bP(o.message))),(i=t==null?void 0:t.onTrailer)===null||i===void 0||i.call(t,o.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function UUe(...e){const t=new AbortController,n=e.filter(i=>i!==void 0).concat(t.signal);for(const i of n){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(SP(this));for(const i of n)i.removeEventListener("abort",r)}return t}function KUe(e){const t=new AbortController,n=()=>{t.abort(new Nt("the operation timed out",vt.DeadlineExceeded))};let r;return e!==void 0&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function SP(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function hx(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}const n2=128;function fx(e){const t=new Headers,n=new TextDecoder().decode(e).split(`\r +`);for(const r of n){if(r==="")continue;const i=r.indexOf(":");if(i>0){const o=r.substring(0,i).trim(),a=r.substring(i+1).trim();t.append(o,a)}}return t}const VUe="Content-Type",GUe="Grpc-Timeout",xP="Grpc-Status",AP="Grpc-Message",JUe="Grpc-Status-Details-Bin",WUe="X-User-Agent",YUe="X-Grpc-Web",qUe="application/grpc-web+proto",XUe="application/grpc-web+json";class ds extends ve{constructor(t){super(),this.code=0,this.message="",this.details=[],R.util.initPartial(t,this)}static fromBinary(t,n){return new ds().fromBinary(t,n)}static fromJson(t,n){return new ds().fromJson(t,n)}static fromJsonString(t,n){return new ds().fromJsonString(t,n)}static equals(t,n){return R.util.equals(ds,t,n)}}ds.runtime=R;ds.typeName="google.rpc.Status";ds.fields=R.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:ko,repeated:!0}]);const ZUe="0";function kP(e){var t;const n=e.get(JUe);if(n!=null){const i=PUe(n,ds);if(i.code==0)return;const o=new Nt(i.message,i.code,e);return o.details=i.details.map(a=>({type:a.typeUrl.substring(a.typeUrl.lastIndexOf("/")+1),value:a.value})),o}const r=e.get(xP);if(r!=null){if(r===ZUe)return;const i=parseInt(r,10);return i in vt?new Nt(decodeURIComponent((t=e.get(AP))!==null&&t!==void 0?t:""),i,e):new Nt(`invalid grpc-status: ${r}`,vt.Internal,e)}}function px(e,t,n){const r=typeof t=="string"?t:t.typeName,i=typeof n=="string"?n:n.name;return e.toString().replace(/\/?$/,`/${r}/${i}`)}function IP(e,t){return t instanceof e?t:new e(t)}function QUe(e,t){function n(r){return r.done===!0?r:{done:r.done,value:IP(e,r.value)}}return{[Symbol.asyncIterator](){const r=t[Symbol.asyncIterator](),i={next:()=>r.next().then(n)};return r.throw!==void 0&&(i.throw=o=>r.throw(o).then(n)),r.return!==void 0&&(i.return=o=>r.return(o).then(n)),i}}}function DP(e,t){var n;return(n=t==null?void 0:t.concat().reverse().reduce((r,i)=>i(r),e))!==null&&n!==void 0?n:e}function eKe(e){var t;const n=Object.assign({},e);return(t=n.ignoreUnknownFields)!==null&&t!==void 0||(n.ignoreUnknownFields=!0),n}function gx(e,t,n,r){const i=t?mx(e.I,r):vx(e.I,n);return{parse:(t?mx(e.O,r):vx(e.O,n)).parse,serialize:i.serialize}}function mx(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(r){const i=r instanceof Error?r.message:String(r);throw new Nt(`parse binary: ${i}`,vt.InvalidArgument)}},serialize(n){try{return n.toBinary(t)}catch(r){const i=r instanceof Error?r.message:String(r);throw new Nt(`serialize binary: ${i}`,vt.Internal)}}}}function vx(e,t){var n,r;const i=(n=t==null?void 0:t.textEncoder)!==null&&n!==void 0?n:new TextEncoder,o=(r=t==null?void 0:t.textDecoder)!==null&&r!==void 0?r:new TextDecoder,a=eKe(t);return{parse(s){try{const u=o.decode(s);return e.fromJsonString(u,a)}catch(u){throw Nt.from(u,vt.InvalidArgument)}},serialize(s){try{const u=s.toJsonString(a);return i.encode(u)}catch(u){throw Nt.from(u,vt.Internal)}}}}function tKe(e){const t=DP(e.next,e.interceptors),[n,r,i]=TP(e),o=Object.assign(Object.assign({},e.req),{message:IP(e.req.method.I,e.req.message),signal:n});return t(o).then(a=>(i(),a),r)}function nKe(e){const t=DP(e.next,e.interceptors),[n,r,i]=TP(e),o=Object.assign(Object.assign({},e.req),{message:QUe(e.req.method.I,e.req.message),signal:n});let a=!1;return n.addEventListener("abort",function(){var s,u;const d=e.req.message[Symbol.asyncIterator]();a||(s=d.throw)===null||s===void 0||s.call(d,this.reason).catch(()=>{}),(u=d.return)===null||u===void 0||u.call(d).catch(()=>{})}),t(o).then(s=>Object.assign(Object.assign({},s),{message:{[Symbol.asyncIterator](){const u=s.message[Symbol.asyncIterator]();return{next(){return u.next().then(d=>(d.done==!0&&(a=!0,i()),d),r)}}}}}),r)}function TP(e){const{signal:t,cleanup:n}=KUe(e.timeoutMs),r=UUe(e.signal,t);return[r.signal,function(o){const a=Nt.from(t.aborted?SP(t):o);return r.abort(a),n(),Promise.reject(a)},function(){n(),r.abort()}]}function rKe(){try{new Headers}catch{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.")}}function yx(e,t){const n=kP(e);if(n)throw t.forEach((r,i)=>{n.metadata.append(i,r)}),n}function Ex(e,t,n,r){const i=new Headers(n??{});return i.set(VUe,e?qUe:XUe),i.set(YUe,"1"),i.set(WUe,"connect-es/1.4.0"),t!==void 0&&i.set(GUe,`${t}m`),i}function iKe(e){switch(e){case 400:return vt.Internal;case 401:return vt.Unauthenticated;case 403:return vt.PermissionDenied;case 404:return vt.Unimplemented;case 429:return vt.Unavailable;case 502:return vt.Unavailable;case 503:return vt.Unavailable;case 504:return vt.Unavailable;default:return vt.Unknown}}function Cx(e,t){var n;if(e>=200&&e<300){const r=kP(t);if(r)throw r;return{foundStatus:t.has(xP)}}throw new Nt(decodeURIComponent((n=t.get(AP))!==null&&n!==void 0?n:`HTTP ${e}`),iKe(e),t)}var ll=function(e){return this instanceof ll?(this.v=e,this):new ll(e)},oKe=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(m){return function(v){return Promise.resolve(v).then(m,p)}}function s(m,v){r[m]&&(i[m]=function(E){return new Promise(function(w,C){o.push([m,E,w,C])>1||u(m,E)})},v&&(i[m]=v(i[m])))}function u(m,v){try{d(r[m](v))}catch(E){g(o[0][3],E)}}function d(m){m.value instanceof ll?Promise.resolve(m.value.v).then(h,p):g(o[0][2],m)}function h(m){u("next",m)}function p(m){u("throw",m)}function g(m,v){m(v),o.shift(),o.length&&u(o[0][0],o[0][1])}};function aKe(e){var t;rKe();const n=(t=e.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(r,i,o,a,s,u,d){var h;const{serialize:p,parse:g}=gx(i,n,e.jsonOptions,e.binaryOptions);return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,await tKe({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!1,service:r,method:i,url:px(e.baseUrl,r,i),init:{method:"POST",credentials:(h=e.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Ex(n,a,s),contextValues:d??hx(),message:u},next:async m=>{var v;const w=await((v=e.fetch)!==null&&v!==void 0?v:globalThis.fetch)(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:dx(0,p(m.message))}));if(Cx(w.status,w.headers),!w.body)throw"missing response body";const C=cx(w.body).getReader();let b,A;for(;;){const T=await C.read();if(T.done)break;const{flags:B,data:D}=T.value;if(B===n2){if(b!==void 0)throw"extra trailer";b=fx(D);continue}if(A!==void 0)throw"extra message";A=g(D)}if(b===void 0)throw"missing trailer";if(yx(b,w.headers),A===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:w.headers,message:A,trailer:b}}})},async stream(r,i,o,a,s,u,d){var h;const{serialize:p,parse:g}=gx(i,n,e.jsonOptions,e.binaryOptions);function m(E,w,C,b){return oKe(this,arguments,function*(){const T=cx(E).getReader();if(w){if(!(yield ll(T.read())).done)throw"extra data for trailers-only";return yield ll(void 0)}let B=!1;for(;;){const D=yield ll(T.read());if(D.done)break;const{flags:I,data:M}=D.value;if((I&n2)===n2){if(B)throw"extra trailer";B=!0;const O=fx(M);yx(O,b),O.forEach((z,K)=>C.set(K,z));continue}if(B)throw"extra message";yield yield ll(g(M))}if(!B)throw"missing trailer"})}async function v(E){if(i.kind!=ir.ServerStreaming)throw"The fetch API does not support streaming request bodies";const w=await E[Symbol.asyncIterator]().next();if(w.done==!0)throw"missing request message";return dx(0,p(w.value))}return a=a===void 0?e.defaultTimeoutMs:a<=0?void 0:a,nKe({interceptors:e.interceptors,signal:o,timeoutMs:a,req:{stream:!0,service:r,method:i,url:px(e.baseUrl,r,i),init:{method:"POST",credentials:(h=e.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Ex(n,a,s),contextValues:d??hx(),message:u},next:async E=>{var w;const b=await((w=e.fetch)!==null&&w!==void 0?w:globalThis.fetch)(E.url,Object.assign(Object.assign({},E.init),{headers:E.header,signal:E.signal,body:await v(E.message)})),{foundStatus:A}=Cx(b.status,b.headers);if(!b.body)throw"missing response body";const T=new Headers;return Object.assign(Object.assign({},E),{header:b.headers,trailer:T,message:m(b.body,A,T,b.headers)})}})}}}var Ve=(e=>(e[e.NULL=0]="NULL",e[e.BOOLEAN=1]="BOOLEAN",e[e.INTEGER=2]="INTEGER",e[e.LONG=3]="LONG",e[e.DOUBLE=4]="DOUBLE",e[e.STRING=5]="STRING",e[e.BYTES=6]="BYTES",e[e.DATE=7]="DATE",e[e.JSON_OBJECT=8]="JSON_OBJECT",e[e.JSON_ARRAY=9]="JSON_ARRAY",e[e.TEXT=10]="TEXT",e[e.INTEGER_CNT=11]="INTEGER_CNT",e[e.LONG_CNT=12]="LONG_CNT",e[e.TREE=13]="TREE",e))(Ve||{});R.util.setEnumType(Ve,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var ml=(e=>(e[e.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",e[e.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",e[e.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",e[e.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",e))(ml||{});R.util.setEnumType(ml,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const aa=class aa extends ve{constructor(n){super();k(this,"root");k(this,"presences",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new aa().fromBinary(n,r)}static fromJson(n,r){return new aa().fromJson(n,r)}static fromJsonString(n,r){return new aa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(aa,n,r)}};k(aa,"runtime",R),k(aa,"typeName","yorkie.v1.Snapshot"),k(aa,"fields",R.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:Sr},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:OC}}]));let Yy=aa;var ci;let Rs=(ci=class extends ve{constructor(n){super();k(this,"documentKey","");k(this,"checkpoint");k(this,"snapshot",new Uint8Array(0));k(this,"changes",[]);k(this,"minSyncedTicket");k(this,"isRemoved",!1);k(this,"versionVector");R.util.initPartial(n,this)}static fromBinary(n,r){return new ci().fromBinary(n,r)}static fromJson(n,r){return new ci().fromJson(n,r)}static fromJsonString(n,r){return new ci().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ci,n,r)}},k(ci,"runtime",R),k(ci,"typeName","yorkie.v1.ChangePack"),k(ci,"fields",R.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:MP},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:PP,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:Ie},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:E1}])),ci);var di;let PP=(di=class extends ve{constructor(n){super();k(this,"id");k(this,"message","");k(this,"operations",[]);k(this,"presenceChange");R.util.initPartial(n,this)}static fromBinary(n,r){return new di().fromBinary(n,r)}static fromJson(n,r){return new di().fromJson(n,r)}static fromJsonString(n,r){return new di().fromJsonString(n,r)}static equals(n,r){return R.util.equals(di,n,r)}},k(di,"runtime",R),k(di,"typeName","yorkie.v1.Change"),k(di,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:y1},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:LC,repeated:!0},{no:4,name:"presence_change",kind:"message",T:ch}])),di);var hi;let y1=(hi=class extends ve{constructor(n){super();k(this,"clientSeq",0);k(this,"serverSeq",zt.zero);k(this,"lamport",zt.zero);k(this,"actorId",new Uint8Array(0));k(this,"versionVector");R.util.initPartial(n,this)}static fromBinary(n,r){return new hi().fromBinary(n,r)}static fromJson(n,r){return new hi().fromJson(n,r)}static fromJsonString(n,r){return new hi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(hi,n,r)}},k(hi,"runtime",R),k(hi,"typeName","yorkie.v1.ChangeID"),k(hi,"fields",R.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:E1}])),hi);var fi;let E1=(fi=class extends ve{constructor(n){super();k(this,"vector",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new fi().fromBinary(n,r)}static fromJson(n,r){return new fi().fromJson(n,r)}static fromJsonString(n,r){return new fi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(fi,n,r)}},k(fi,"runtime",R),k(fi,"typeName","yorkie.v1.VersionVector"),k(fi,"fields",R.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),fi);var pi;let LC=(pi=class extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new pi().fromBinary(n,r)}static fromJson(n,r){return new pi().fromJson(n,r)}static fromJsonString(n,r){return new pi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(pi,n,r)}},k(pi,"runtime",R),k(pi,"typeName","yorkie.v1.Operation"),k(pi,"fields",R.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Ug,oneof:"body"},{no:2,name:"add",kind:"message",T:Kg,oneof:"body"},{no:3,name:"move",kind:"message",T:Vg,oneof:"body"},{no:4,name:"remove",kind:"message",T:Gg,oneof:"body"},{no:5,name:"edit",kind:"message",T:Jg,oneof:"body"},{no:6,name:"select",kind:"message",T:qy,oneof:"body"},{no:7,name:"style",kind:"message",T:Wg,oneof:"body"},{no:8,name:"increase",kind:"message",T:Yg,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:qg,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:Xg,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Xy,oneof:"body"}])),pi);const sa=class sa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"key","");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new sa().fromBinary(n,r)}static fromJson(n,r){return new sa().fromJson(n,r)}static fromJsonString(n,r){return new sa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(sa,n,r)}};k(sa,"runtime",R),k(sa,"typeName","yorkie.v1.Operation.Set"),k(sa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Ug=sa;const ua=class ua extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"prevCreatedAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ua().fromBinary(n,r)}static fromJson(n,r){return new ua().fromJson(n,r)}static fromJsonString(n,r){return new ua().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ua,n,r)}};k(ua,"runtime",R),k(ua,"typeName","yorkie.v1.Operation.Add"),k(ua,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"prev_created_at",kind:"message",T:Ie},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Kg=ua;const la=class la extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"prevCreatedAt");k(this,"createdAt");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new la().fromBinary(n,r)}static fromJson(n,r){return new la().fromJson(n,r)}static fromJsonString(n,r){return new la().fromJsonString(n,r)}static equals(n,r){return R.util.equals(la,n,r)}};k(la,"runtime",R),k(la,"typeName","yorkie.v1.Operation.Move"),k(la,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"prev_created_at",kind:"message",T:Ie},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Vg=la;const ca=class ca extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"createdAt");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ca().fromBinary(n,r)}static fromJson(n,r){return new ca().fromJson(n,r)}static fromJsonString(n,r){return new ca().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ca,n,r)}};k(ca,"runtime",R),k(ca,"typeName","yorkie.v1.Operation.Remove"),k(ca,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"executed_at",kind:"message",T:Ie}]));let Gg=ca;const da=class da extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"createdAtMapByActor",{});k(this,"content","");k(this,"executedAt");k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new da().fromBinary(n,r)}static fromJson(n,r){return new da().fromJson(n,r)}static fromJsonString(n,r){return new da().fromJsonString(n,r)}static equals(n,r){return R.util.equals(da,n,r)}};k(da,"runtime",R),k(da,"typeName","yorkie.v1.Operation.Edit"),k(da,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:Ie},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let Jg=da;const ha=class ha extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ha().fromBinary(n,r)}static fromJson(n,r){return new ha().fromJson(n,r)}static fromJsonString(n,r){return new ha().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ha,n,r)}};k(ha,"runtime",R),k(ha,"typeName","yorkie.v1.Operation.Select"),k(ha,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"executed_at",kind:"message",T:Ie}]));let qy=ha;const fa=class fa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"attributes",{});k(this,"executedAt");k(this,"createdAtMapByActor",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new fa().fromBinary(n,r)}static fromJson(n,r){return new fa().fromJson(n,r)}static fromJsonString(n,r){return new fa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(fa,n,r)}};k(fa,"runtime",R),k(fa,"typeName","yorkie.v1.Operation.Style"),k(fa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Is},{no:3,name:"to",kind:"message",T:Is},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:Ie},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}}]));let Wg=fa;const pa=class pa extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new pa().fromBinary(n,r)}static fromJson(n,r){return new pa().fromJson(n,r)}static fromJsonString(n,r){return new pa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(pa,n,r)}};k(pa,"runtime",R),k(pa,"typeName","yorkie.v1.Operation.Increase"),k(pa,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"value",kind:"message",T:li},{no:3,name:"executed_at",kind:"message",T:Ie}]));let Yg=pa;const ga=class ga extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"createdAtMapByActor",{});k(this,"contents",[]);k(this,"splitLevel",0);k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ga().fromBinary(n,r)}static fromJson(n,r){return new ga().fromJson(n,r)}static fromJsonString(n,r){return new ga().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ga,n,r)}};k(ga,"runtime",R),k(ga,"typeName","yorkie.v1.Operation.TreeEdit"),k(ga,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Il},{no:3,name:"to",kind:"message",T:Il},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}},{no:5,name:"contents",kind:"message",T:am,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:Ie}]));let qg=ga;const ma=class ma extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"from");k(this,"to");k(this,"attributes",{});k(this,"executedAt");k(this,"attributesToRemove",[]);k(this,"createdAtMapByActor",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new ma().fromBinary(n,r)}static fromJson(n,r){return new ma().fromJson(n,r)}static fromJsonString(n,r){return new ma().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ma,n,r)}};k(ma,"runtime",R),k(ma,"typeName","yorkie.v1.Operation.TreeStyle"),k(ma,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"from",kind:"message",T:Il},{no:3,name:"to",kind:"message",T:Il},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:Ie},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:Ie}}]));let Xg=ma;const va=class va extends ve{constructor(n){super();k(this,"parentCreatedAt");k(this,"createdAt");k(this,"value");k(this,"executedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new va().fromBinary(n,r)}static fromJson(n,r){return new va().fromJson(n,r)}static fromJsonString(n,r){return new va().fromJsonString(n,r)}static equals(n,r){return R.util.equals(va,n,r)}};k(va,"runtime",R),k(va,"typeName","yorkie.v1.Operation.ArraySet"),k(va,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:Ie},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"value",kind:"message",T:li},{no:4,name:"executed_at",kind:"message",T:Ie}]));let Xy=va;const ya=class ya extends ve{constructor(n){super();k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");k(this,"type",0);k(this,"value",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new ya().fromBinary(n,r)}static fromJson(n,r){return new ya().fromJson(n,r)}static fromJsonString(n,r){return new ya().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ya,n,r)}};k(ya,"runtime",R),k(ya,"typeName","yorkie.v1.JSONElementSimple"),k(ya,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"moved_at",kind:"message",T:Ie},{no:3,name:"removed_at",kind:"message",T:Ie},{no:4,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:5,name:"value",kind:"scalar",T:12}]));let li=ya;const Ea=class Ea extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ea().fromBinary(n,r)}static fromJson(n,r){return new Ea().fromJson(n,r)}static fromJsonString(n,r){return new Ea().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ea,n,r)}};k(Ea,"runtime",R),k(Ea,"typeName","yorkie.v1.JSONElement"),k(Ea,"fields",R.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Zg,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Qg,oneof:"body"},{no:3,name:"primitive",kind:"message",T:em,oneof:"body"},{no:5,name:"text",kind:"message",T:tm,oneof:"body"},{no:6,name:"counter",kind:"message",T:nm,oneof:"body"},{no:7,name:"tree",kind:"message",T:rm,oneof:"body"}]));let Sr=Ea;const Ca=class Ca extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ca().fromBinary(n,r)}static fromJson(n,r){return new Ca().fromJson(n,r)}static fromJsonString(n,r){return new Ca().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ca,n,r)}};k(Ca,"runtime",R),k(Ca,"typeName","yorkie.v1.JSONElement.JSONObject"),k(Ca,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:BP,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let Zg=Ca;const ba=class ba extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new ba().fromBinary(n,r)}static fromJson(n,r){return new ba().fromJson(n,r)}static fromJsonString(n,r){return new ba().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ba,n,r)}};k(ba,"runtime",R),k(ba,"typeName","yorkie.v1.JSONElement.JSONArray"),k(ba,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:im,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let Qg=ba;const wa=class wa extends ve{constructor(n){super();k(this,"type",0);k(this,"value",new Uint8Array(0));k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new wa().fromBinary(n,r)}static fromJson(n,r){return new wa().fromJson(n,r)}static fromJsonString(n,r){return new wa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(wa,n,r)}};k(wa,"runtime",R),k(wa,"typeName","yorkie.v1.JSONElement.Primitive"),k(wa,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"moved_at",kind:"message",T:Ie},{no:5,name:"removed_at",kind:"message",T:Ie}]));let em=wa;const Sa=class Sa extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Sa().fromBinary(n,r)}static fromJson(n,r){return new Sa().fromJson(n,r)}static fromJsonString(n,r){return new Sa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Sa,n,r)}};k(Sa,"runtime",R),k(Sa,"typeName","yorkie.v1.JSONElement.Text"),k(Sa,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:om,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let tm=Sa;const xa=class xa extends ve{constructor(n){super();k(this,"type",0);k(this,"value",new Uint8Array(0));k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new xa().fromBinary(n,r)}static fromJson(n,r){return new xa().fromJson(n,r)}static fromJsonString(n,r){return new xa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(xa,n,r)}};k(xa,"runtime",R),k(xa,"typeName","yorkie.v1.JSONElement.Counter"),k(xa,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Ve)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:Ie},{no:4,name:"moved_at",kind:"message",T:Ie},{no:5,name:"removed_at",kind:"message",T:Ie}]));let nm=xa;const Aa=class Aa extends ve{constructor(n){super();k(this,"nodes",[]);k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Aa().fromBinary(n,r)}static fromJson(n,r){return new Aa().fromJson(n,r)}static fromJsonString(n,r){return new Aa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Aa,n,r)}};k(Aa,"runtime",R),k(Aa,"typeName","yorkie.v1.JSONElement.Tree"),k(Aa,"fields",R.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:lh,repeated:!0},{no:2,name:"created_at",kind:"message",T:Ie},{no:3,name:"moved_at",kind:"message",T:Ie},{no:4,name:"removed_at",kind:"message",T:Ie}]));let rm=Aa;var gi;let BP=(gi=class extends ve{constructor(n){super();k(this,"key","");k(this,"element");R.util.initPartial(n,this)}static fromBinary(n,r){return new gi().fromBinary(n,r)}static fromJson(n,r){return new gi().fromJson(n,r)}static fromJsonString(n,r){return new gi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(gi,n,r)}},k(gi,"runtime",R),k(gi,"typeName","yorkie.v1.RHTNode"),k(gi,"fields",R.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:Sr}])),gi);const Co=class Co extends ve{constructor(n){super();k(this,"next");k(this,"element");R.util.initPartial(n,this)}static fromBinary(n,r){return new Co().fromBinary(n,r)}static fromJson(n,r){return new Co().fromJson(n,r)}static fromJsonString(n,r){return new Co().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Co,n,r)}};k(Co,"runtime",R),k(Co,"typeName","yorkie.v1.RGANode"),k(Co,"fields",R.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Co},{no:2,name:"element",kind:"message",T:Sr}]));let im=Co;const ka=class ka extends ve{constructor(n){super();k(this,"value","");k(this,"updatedAt");k(this,"isRemoved",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new ka().fromBinary(n,r)}static fromJson(n,r){return new ka().fromJson(n,r)}static fromJsonString(n,r){return new ka().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ka,n,r)}};k(ka,"runtime",R),k(ka,"typeName","yorkie.v1.NodeAttr"),k(ka,"fields",R.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:Ie},{no:3,name:"is_removed",kind:"scalar",T:8}]));let ud=ka;const Ia=class Ia extends ve{constructor(n){super();k(this,"id");k(this,"value","");k(this,"removedAt");k(this,"insPrevId");k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ia().fromBinary(n,r)}static fromJson(n,r){return new Ia().fromJson(n,r)}static fromJsonString(n,r){return new Ia().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ia,n,r)}};k(Ia,"runtime",R),k(Ia,"typeName","yorkie.v1.TextNode"),k(Ia,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:uh},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:Ie},{no:4,name:"ins_prev_id",kind:"message",T:uh},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ud}}]));let om=Ia;const Da=class Da extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Da().fromBinary(n,r)}static fromJson(n,r){return new Da().fromJson(n,r)}static fromJsonString(n,r){return new Da().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Da,n,r)}};k(Da,"runtime",R),k(Da,"typeName","yorkie.v1.TextNodeID"),k(Da,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5}]));let uh=Da;const Ta=class Ta extends ve{constructor(n){super();k(this,"id");k(this,"type","");k(this,"value","");k(this,"removedAt");k(this,"insPrevId");k(this,"insNextId");k(this,"depth",0);k(this,"attributes",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new Ta().fromBinary(n,r)}static fromJson(n,r){return new Ta().fromJson(n,r)}static fromJsonString(n,r){return new Ta().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ta,n,r)}};k(Ta,"runtime",R),k(Ta,"typeName","yorkie.v1.TreeNode"),k(Ta,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:mu},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:Ie},{no:5,name:"ins_prev_id",kind:"message",T:mu},{no:6,name:"ins_next_id",kind:"message",T:mu},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ud}}]));let lh=Ta;const Pa=class Pa extends ve{constructor(n){super();k(this,"content",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new Pa().fromBinary(n,r)}static fromJson(n,r){return new Pa().fromJson(n,r)}static fromJsonString(n,r){return new Pa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Pa,n,r)}};k(Pa,"runtime",R),k(Pa,"typeName","yorkie.v1.TreeNodes"),k(Pa,"fields",R.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:lh,repeated:!0}]));let am=Pa;const Ba=class Ba extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Ba().fromBinary(n,r)}static fromJson(n,r){return new Ba().fromJson(n,r)}static fromJsonString(n,r){return new Ba().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ba,n,r)}};k(Ba,"runtime",R),k(Ba,"typeName","yorkie.v1.TreeNodeID"),k(Ba,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5}]));let mu=Ba;const Ma=class Ma extends ve{constructor(n){super();k(this,"parentId");k(this,"leftSiblingId");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ma().fromBinary(n,r)}static fromJson(n,r){return new Ma().fromJson(n,r)}static fromJsonString(n,r){return new Ma().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ma,n,r)}};k(Ma,"runtime",R),k(Ma,"typeName","yorkie.v1.TreePos"),k(Ma,"fields",R.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:mu},{no:2,name:"left_sibling_id",kind:"message",T:mu}]));let Il=Ma;const $a=class $a extends ve{constructor(n){super();k(this,"id","");k(this,"username","");k(this,"createdAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new $a().fromBinary(n,r)}static fromJson(n,r){return new $a().fromJson(n,r)}static fromJsonString(n,r){return new $a().fromJsonString(n,r)}static equals(n,r){return R.util.equals($a,n,r)}};k($a,"runtime",R),k($a,"typeName","yorkie.v1.User"),k($a,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Vn}]));let bx=$a;const Ra=class Ra extends ve{constructor(n){super();k(this,"id","");k(this,"name","");k(this,"publicKey","");k(this,"secretKey","");k(this,"authWebhookUrl","");k(this,"authWebhookMethods",[]);k(this,"clientDeactivateThreshold","");k(this,"createdAt");k(this,"updatedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ra().fromBinary(n,r)}static fromJson(n,r){return new Ra().fromJson(n,r)}static fromJsonString(n,r){return new Ra().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ra,n,r)}};k(Ra,"runtime",R),k(Ra,"typeName","yorkie.v1.Project"),k(Ra,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Vn},{no:9,name:"updated_at",kind:"message",T:Vn}]));let wx=Ra;const Fa=class Fa extends ve{constructor(n){super();k(this,"name");k(this,"authWebhookUrl");k(this,"authWebhookMethods");k(this,"clientDeactivateThreshold");R.util.initPartial(n,this)}static fromBinary(n,r){return new Fa().fromBinary(n,r)}static fromJson(n,r){return new Fa().fromJson(n,r)}static fromJsonString(n,r){return new Fa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Fa,n,r)}};k(Fa,"runtime",R),k(Fa,"typeName","yorkie.v1.UpdatableProjectFields"),k(Fa,"fields",R.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:_r},{no:2,name:"auth_webhook_url",kind:"message",T:_r},{no:3,name:"auth_webhook_methods",kind:"message",T:Zy},{no:4,name:"client_deactivate_threshold",kind:"message",T:_r}]));let Sx=Fa;const La=class La extends ve{constructor(n){super();k(this,"methods",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new La().fromBinary(n,r)}static fromJson(n,r){return new La().fromJson(n,r)}static fromJsonString(n,r){return new La().fromJsonString(n,r)}static equals(n,r){return R.util.equals(La,n,r)}};k(La,"runtime",R),k(La,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),k(La,"fields",R.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Zy=La;const Oa=class Oa extends ve{constructor(n){super();k(this,"id","");k(this,"key","");k(this,"snapshot","");k(this,"createdAt");k(this,"accessedAt");k(this,"updatedAt");R.util.initPartial(n,this)}static fromBinary(n,r){return new Oa().fromBinary(n,r)}static fromJson(n,r){return new Oa().fromJson(n,r)}static fromJsonString(n,r){return new Oa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Oa,n,r)}};k(Oa,"runtime",R),k(Oa,"typeName","yorkie.v1.DocumentSummary"),k(Oa,"fields",R.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Vn},{no:5,name:"accessed_at",kind:"message",T:Vn},{no:6,name:"updated_at",kind:"message",T:Vn}]));let xx=Oa;const _a=class _a extends ve{constructor(n){super();k(this,"type",0);k(this,"presence");R.util.initPartial(n,this)}static fromBinary(n,r){return new _a().fromBinary(n,r)}static fromJson(n,r){return new _a().fromJson(n,r)}static fromJsonString(n,r){return new _a().fromJsonString(n,r)}static equals(n,r){return R.util.equals(_a,n,r)}};k(_a,"runtime",R),k(_a,"typeName","yorkie.v1.PresenceChange"),k(_a,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(Dl)},{no:2,name:"presence",kind:"message",T:OC}]));let ch=_a;var Dl=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.PUT=1]="PUT",e[e.DELETE=2]="DELETE",e[e.CLEAR=3]="CLEAR",e))(Dl||{});R.util.setEnumType(Dl,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var mi;let OC=(mi=class extends ve{constructor(n){super();k(this,"data",{});R.util.initPartial(n,this)}static fromBinary(n,r){return new mi().fromBinary(n,r)}static fromJson(n,r){return new mi().fromJson(n,r)}static fromJsonString(n,r){return new mi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(mi,n,r)}},k(mi,"runtime",R),k(mi,"typeName","yorkie.v1.Presence"),k(mi,"fields",R.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),mi);var vi;let MP=(vi=class extends ve{constructor(n){super();k(this,"serverSeq",zt.zero);k(this,"clientSeq",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new vi().fromBinary(n,r)}static fromJson(n,r){return new vi().fromJson(n,r)}static fromJsonString(n,r){return new vi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(vi,n,r)}},k(vi,"runtime",R),k(vi,"typeName","yorkie.v1.Checkpoint"),k(vi,"fields",R.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),vi);const Na=class Na extends ve{constructor(n){super();k(this,"createdAt");k(this,"offset",0);k(this,"relativeOffset",0);R.util.initPartial(n,this)}static fromBinary(n,r){return new Na().fromBinary(n,r)}static fromJson(n,r){return new Na().fromJson(n,r)}static fromJsonString(n,r){return new Na().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Na,n,r)}};k(Na,"runtime",R),k(Na,"typeName","yorkie.v1.TextNodePos"),k(Na,"fields",R.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:Ie},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Is=Na;var yi;let Ie=(yi=class extends ve{constructor(n){super();k(this,"lamport",zt.zero);k(this,"delimiter",0);k(this,"actorId",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new yi().fromBinary(n,r)}static fromJson(n,r){return new yi().fromJson(n,r)}static fromJsonString(n,r){return new yi().fromJsonString(n,r)}static equals(n,r){return R.util.equals(yi,n,r)}},k(yi,"runtime",R),k(yi,"typeName","yorkie.v1.TimeTicket"),k(yi,"fields",R.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),yi);const za=class za extends ve{constructor(n){super();k(this,"topic","");k(this,"payload",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new za().fromBinary(n,r)}static fromJson(n,r){return new za().fromJson(n,r)}static fromJsonString(n,r){return new za().fromJsonString(n,r)}static equals(n,r){return R.util.equals(za,n,r)}};k(za,"runtime",R),k(za,"typeName","yorkie.v1.DocEventBody"),k(za,"fields",R.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Qy=za;const Ha=class Ha extends ve{constructor(n){super();k(this,"type",0);k(this,"publisher","");k(this,"body");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ha().fromBinary(n,r)}static fromJson(n,r){return new Ha().fromJson(n,r)}static fromJsonString(n,r){return new Ha().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ha,n,r)}};k(Ha,"runtime",R),k(Ha,"typeName","yorkie.v1.DocEvent"),k(Ha,"fields",R.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:R.getEnumType(ml)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Qy}]));let e3=Ha;const ja=class ja extends ve{constructor(n){super();k(this,"clientKey","");R.util.initPartial(n,this)}static fromBinary(n,r){return new ja().fromBinary(n,r)}static fromJson(n,r){return new ja().fromJson(n,r)}static fromJsonString(n,r){return new ja().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ja,n,r)}};k(ja,"runtime",R),k(ja,"typeName","yorkie.v1.ActivateClientRequest"),k(ja,"fields",R.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let t3=ja;const Ua=class Ua extends ve{constructor(n){super();k(this,"clientId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ua().fromBinary(n,r)}static fromJson(n,r){return new Ua().fromJson(n,r)}static fromJsonString(n,r){return new Ua().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ua,n,r)}};k(Ua,"runtime",R),k(Ua,"typeName","yorkie.v1.ActivateClientResponse"),k(Ua,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let n3=Ua;const Ka=class Ka extends ve{constructor(n){super();k(this,"clientId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ka().fromBinary(n,r)}static fromJson(n,r){return new Ka().fromJson(n,r)}static fromJsonString(n,r){return new Ka().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ka,n,r)}};k(Ka,"runtime",R),k(Ka,"typeName","yorkie.v1.DeactivateClientRequest"),k(Ka,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let r3=Ka;const Va=class Va extends ve{constructor(t){super(),R.util.initPartial(t,this)}static fromBinary(t,n){return new Va().fromBinary(t,n)}static fromJson(t,n){return new Va().fromJson(t,n)}static fromJsonString(t,n){return new Va().fromJsonString(t,n)}static equals(t,n){return R.util.equals(Va,t,n)}};k(Va,"runtime",R),k(Va,"typeName","yorkie.v1.DeactivateClientResponse"),k(Va,"fields",R.util.newFieldList(()=>[]));let i3=Va;const Ga=class Ga extends ve{constructor(n){super();k(this,"clientId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ga().fromBinary(n,r)}static fromJson(n,r){return new Ga().fromJson(n,r)}static fromJsonString(n,r){return new Ga().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ga,n,r)}};k(Ga,"runtime",R),k(Ga,"typeName","yorkie.v1.AttachDocumentRequest"),k(Ga,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Rs}]));let o3=Ga;const Ja=class Ja extends ve{constructor(n){super();k(this,"documentId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ja().fromBinary(n,r)}static fromJson(n,r){return new Ja().fromJson(n,r)}static fromJsonString(n,r){return new Ja().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ja,n,r)}};k(Ja,"runtime",R),k(Ja,"typeName","yorkie.v1.AttachDocumentResponse"),k(Ja,"fields",R.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Rs}]));let a3=Ja;const Wa=class Wa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");k(this,"removeIfNotAttached",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new Wa().fromBinary(n,r)}static fromJson(n,r){return new Wa().fromJson(n,r)}static fromJsonString(n,r){return new Wa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Wa,n,r)}};k(Wa,"runtime",R),k(Wa,"typeName","yorkie.v1.DetachDocumentRequest"),k(Wa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let s3=Wa;const Ya=class Ya extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Ya().fromBinary(n,r)}static fromJson(n,r){return new Ya().fromJson(n,r)}static fromJsonString(n,r){return new Ya().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Ya,n,r)}};k(Ya,"runtime",R),k(Ya,"typeName","yorkie.v1.DetachDocumentResponse"),k(Ya,"fields",R.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Rs}]));let u3=Ya;const qa=class qa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");R.util.initPartial(n,this)}static fromBinary(n,r){return new qa().fromBinary(n,r)}static fromJson(n,r){return new qa().fromJson(n,r)}static fromJsonString(n,r){return new qa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(qa,n,r)}};k(qa,"runtime",R),k(qa,"typeName","yorkie.v1.WatchDocumentRequest"),k(qa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let l3=qa;const Xa=class Xa extends ve{constructor(n){super();k(this,"body",{case:void 0});R.util.initPartial(n,this)}static fromBinary(n,r){return new Xa().fromBinary(n,r)}static fromJson(n,r){return new Xa().fromJson(n,r)}static fromJsonString(n,r){return new Xa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Xa,n,r)}};k(Xa,"runtime",R),k(Xa,"typeName","yorkie.v1.WatchDocumentResponse"),k(Xa,"fields",R.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:d3,oneof:"body"},{no:2,name:"event",kind:"message",T:e3,oneof:"body"}]));let c3=Xa;const Za=class Za extends ve{constructor(n){super();k(this,"clientIds",[]);R.util.initPartial(n,this)}static fromBinary(n,r){return new Za().fromBinary(n,r)}static fromJson(n,r){return new Za().fromJson(n,r)}static fromJsonString(n,r){return new Za().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Za,n,r)}};k(Za,"runtime",R),k(Za,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),k(Za,"fields",R.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let d3=Za;const Qa=class Qa extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new Qa().fromBinary(n,r)}static fromJson(n,r){return new Qa().fromJson(n,r)}static fromJsonString(n,r){return new Qa().fromJsonString(n,r)}static equals(n,r){return R.util.equals(Qa,n,r)}};k(Qa,"runtime",R),k(Qa,"typeName","yorkie.v1.RemoveDocumentRequest"),k(Qa,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs}]));let h3=Qa;const es=class es extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new es().fromBinary(n,r)}static fromJson(n,r){return new es().fromJson(n,r)}static fromJsonString(n,r){return new es().fromJsonString(n,r)}static equals(n,r){return R.util.equals(es,n,r)}};k(es,"runtime",R),k(es,"typeName","yorkie.v1.RemoveDocumentResponse"),k(es,"fields",R.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Rs}]));let f3=es;const ts=class ts extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"changePack");k(this,"pushOnly",!1);R.util.initPartial(n,this)}static fromBinary(n,r){return new ts().fromBinary(n,r)}static fromJson(n,r){return new ts().fromJson(n,r)}static fromJsonString(n,r){return new ts().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ts,n,r)}};k(ts,"runtime",R),k(ts,"typeName","yorkie.v1.PushPullChangesRequest"),k(ts,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Rs},{no:4,name:"push_only",kind:"scalar",T:8}]));let p3=ts;const ns=class ns extends ve{constructor(n){super();k(this,"changePack");R.util.initPartial(n,this)}static fromBinary(n,r){return new ns().fromBinary(n,r)}static fromJson(n,r){return new ns().fromJson(n,r)}static fromJsonString(n,r){return new ns().fromJsonString(n,r)}static equals(n,r){return R.util.equals(ns,n,r)}};k(ns,"runtime",R),k(ns,"typeName","yorkie.v1.PushPullChangesResponse"),k(ns,"fields",R.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Rs}]));let g3=ns;const rs=class rs extends ve{constructor(n){super();k(this,"clientId","");k(this,"documentId","");k(this,"topic","");k(this,"payload",new Uint8Array(0));R.util.initPartial(n,this)}static fromBinary(n,r){return new rs().fromBinary(n,r)}static fromJson(n,r){return new rs().fromJson(n,r)}static fromJsonString(n,r){return new rs().fromJsonString(n,r)}static equals(n,r){return R.util.equals(rs,n,r)}};k(rs,"runtime",R),k(rs,"typeName","yorkie.v1.BroadcastRequest"),k(rs,"fields",R.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let m3=rs;const is=class is extends ve{constructor(t){super(),R.util.initPartial(t,this)}static fromBinary(t,n){return new is().fromBinary(t,n)}static fromJson(t,n){return new is().fromJson(t,n)}static fromJsonString(t,n){return new is().fromJsonString(t,n)}static equals(t,n){return R.util.equals(is,t,n)}};k(is,"runtime",R),k(is,"typeName","yorkie.v1.BroadcastResponse"),k(is,"fields",R.util.newFieldList(()=>[]));let v3=is;const sKe={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:t3,O:n3,kind:ir.Unary},deactivateClient:{name:"DeactivateClient",I:r3,O:i3,kind:ir.Unary},attachDocument:{name:"AttachDocument",I:o3,O:a3,kind:ir.Unary},detachDocument:{name:"DetachDocument",I:s3,O:u3,kind:ir.Unary},removeDocument:{name:"RemoveDocument",I:h3,O:f3,kind:ir.Unary},pushPullChanges:{name:"PushPullChanges",I:p3,O:g3,kind:ir.Unary},watchDocument:{name:"WatchDocument",I:l3,O:c3,kind:ir.ServerStreaming},broadcast:{name:"Broadcast",I:m3,O:v3,kind:ir.Unary}}},uKe=R.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);R.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:cs}]);R.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:lKe,repeated:!0}]);const lKe=R.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});R.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:cKe,repeated:!0}]);const cKe=R.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});R.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:dKe,repeated:!0}]);const dKe=R.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});R.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);R.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:hKe,repeated:!0}]);const hKe=R.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});R.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var J=(e=>(e.Ok="ok",e.ErrClientNotActivated="ErrClientNotActivated",e.ErrClientNotFound="ErrClientNotFound",e.ErrUnimplemented="ErrUnimplemented",e.ErrInvalidType="ErrInvalidType",e.ErrDummy="ErrDummy",e.ErrDocumentNotAttached="ErrDocumentNotAttached",e.ErrDocumentNotDetached="ErrDocumentNotDetached",e.ErrDocumentRemoved="ErrDocumentRemoved",e.ErrInvalidObjectKey="ErrInvalidObjectKey",e.ErrInvalidArgument="ErrInvalidArgument",e.ErrNotInitialized="ErrNotInitialized",e.ErrNotReady="ErrNotReady",e.ErrRefused="ErrRefused",e.ErrContextNotProvided="ErrContextNotProvided",e.ErrPermissionDenied="ErrPermissionDenied",e.ErrUnauthenticated="ErrUnauthenticated",e))(J||{});class Y extends Error{constructor(n,r){super(r);k(this,"name","YorkieError");k(this,"stack");this.code=n,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Gi(e){if(e instanceof Map){const t=Array.from(e);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(e))}const $P=e=>e?Object.entries(e).length===0:!0,ld=e=>{const t={};for(const[n,r]of Object.entries(e))t[n]=JSON.stringify(r);return t},Hc=e=>{const t={};for(const[n,r]of Object.entries(e))t[n]=JSON.parse(r);return t};var Du=(e=>(e.Put="put",e.Clear="clear",e))(Du||{});class r2{constructor(t,n){k(this,"context");k(this,"presence");this.context=t,this.presence=n}set(t,n){for(const r of Object.keys(t))this.presence[r]=t[r];this.context.setPresenceChange({type:"put",presence:Gi(this.presence)}),this.context.setReversePresence(t,n)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const C1="000000000000000000000000";class Ai{constructor(t,n,r){k(this,"lamport");k(this,"delimiter");k(this,"actorID");this.lamport=t,this.delimiter=n,this.actorID=r}static of(t,n,r){return new Ai(t,n,r)}static fromStruct(t){return Ai.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new Ai(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const n=this.actorID.localeCompare(t.actorID);return n!==0?n:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const RP=0,R0=9223372036854775807n,to=new Ai(0n,RP,C1);function Oo(e){return e.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return t}})}class Oh{constructor(t){k(this,"createdAt");k(this,"movedAt");k(this,"removedAt");this.createdAt=t}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(t){return!this.movedAt||t&&t.after(this.movedAt)?(this.movedAt=t,!0):!1}setRemovedAt(t){this.removedAt=t}remove(t){return t&&t.after(this.getPositionedAt())&&(!this.removedAt||t.after(this.removedAt))?(this.removedAt=t,!0):!1}isRemoved(){return!!this.removedAt}}class vu extends Oh{constructor(t){super(t)}}class _C{constructor(t,n){k(this,"strKey");k(this,"value");this.strKey=t,this.value=n}static of(t,n){return new _C(t,n)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(t){return this.value.remove(t)}}class dh{constructor(){k(this,"nodeMapByKey");k(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new dh}set(t,n,r){let i;const o=this.nodeMapByKey.get(t);o!=null&&!o.isRemoved()&&o.remove(r)&&(i=o.getValue());const a=_C.of(t,n);return this.nodeMapByCreatedAt.set(n.getCreatedAt().toIDString(),a),(o==null||r.after(o.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(t,a),n.setMovedAt(r)),i}delete(t,n){if(!this.nodeMapByCreatedAt.has(t.toIDString()))throw new Y(J.ErrInvalidArgument,`fail to find ${t.toIDString()}`);const r=this.nodeMapByCreatedAt.get(t.toIDString());return r.remove(n),r.getValue()}subPathOf(t){const n=this.nodeMapByCreatedAt.get(t.toIDString());if(n)return n.getStrKey()}purge(t){const n=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!n)throw new Y(J.ErrInvalidArgument,`fail to find ${t.getCreatedAt().toIDString()}`);const r=this.nodeMapByKey.get(n.getStrKey());n===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(n.getValue().getCreatedAt().toIDString())}deleteByKey(t,n){const r=this.nodeMapByKey.get(t);if(r!=null&&r.remove(n))return r.getValue()}has(t){const n=this.nodeMapByKey.get(t);return n==null?!1:!n.isRemoved()}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}get(t){const n=this.nodeMapByKey.get(t);if(!(!n||n.isRemoved()))return n}*[Symbol.iterator](){for(const[,t]of this.nodeMapByKey)yield t}}class wr extends vu{constructor(n,r){super(n);k(this,"memberNodes");this.memberNodes=r}static create(n,r){if(!r)return new wr(n,dh.create());const i=dh.create();for(const[o,a]of Object.entries(r))i.set(o,a.deepcopy(),a.getCreatedAt());return new wr(n,i)}subPathOf(n){return this.memberNodes.subPathOf(n)}purge(n){this.memberNodes.purge(n)}set(n,r,i){return this.memberNodes.set(n,r,i)}delete(n,r){return this.memberNodes.delete(n,r)}deleteByKey(n,r){return this.memberNodes.deleteByKey(n,r)}get(n){const r=this.memberNodes.get(n);return r==null?void 0:r.getValue()}getByID(n){const r=this.memberNodes.getByID(n);return r==null?void 0:r.getValue()}has(n){return this.memberNodes.has(n)}toJSON(){const n=[];for(const[r,i]of this)n.push(`"${Oo(r)}":${i.toJSON()}`);return`{${n.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const n={};for(const[r,i]of this){const{createdAt:o,value:a,type:s}=i.toJSForTest();n[r]={key:r,createdAt:o,value:a,type:s}}return{createdAt:this.getCreatedAt().toTestString(),value:n,type:"YORKIE_OBJECT"}}getKeys(){const n=Array();for(const[r]of this)n.push(r);return n}toSortedJSON(){var i;const n=Array();for(const[o]of this)n.push(o);const r=[];for(const o of n.sort()){const a=(i=this.memberNodes.get(o))==null?void 0:i.getValue();r.push(`"${Oo(o)}":${a.toSortedJSON()}`)}return`{${r.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const n=wr.create(this.getCreatedAt());for(const r of this.memberNodes)n.memberNodes.set(r.getStrKey(),r.getValue().deepcopy(),this.getPositionedAt());return n.remove(this.getRemovedAt()),n}getDescendants(n){for(const r of this.memberNodes){const i=r.getValue();if(n(i,this))return;i instanceof vu&&i.getDescendants(n)}}*[Symbol.iterator](){const n=new Set;for(const r of this.memberNodes)n.has(r.getStrKey())||(n.add(r.getStrKey()),r.isRemoved()||(yield[r.getStrKey(),r.getValue()]))}}var xt=(e=>(e.Local="local",e.Remote="remote",e.UndoRedo="undoredo",e))(xt||{});class so{constructor(t,n){k(this,"parentCreatedAt");k(this,"executedAt");this.parentCreatedAt=t,this.executedAt=n}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new Y(J.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(t){this.executedAt&&(this.executedAt=this.executedAt.setActor(t))}setExecutedAt(t){this.executedAt=t}}class FP{constructor(t){k(this,"value");k(this,"left");k(this,"right");k(this,"parent");k(this,"weight");this.value=t,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(t){this.left=t}setRight(t){this.right=t}setParent(t){this.parent=t}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(t){this.weight+=t}initWeight(){this.weight=this.getLength()}}class hh{constructor(t){k(this,"root");this.root=t}get length(){return this.root?this.root.getWeight():0}find(t){if(!this.root||t<0)return[void 0,0];let n=this.root;for(;;)if(n.hasLeft()&&t<=n.getLeftWeight())n=n.getLeft();else if(n.hasRight()&&n.getLeftWeight()+n.getLength()n.getLength())throw new Y(J.ErrInvalidArgument,`out of index range: pos: ${t} > node.length: ${n.getLength()}`);return this.splayNode(n),[n,t]}indexOf(t){return!t||t!==this.root&&!t.hasLinks()?-1:(this.splayNode(t),this.root.getLeftWeight())}getRoot(){return this.root}insert(t){return this.insertAfter(this.root,t)}insertAfter(t,n){return t?(this.splayNode(t),this.root=n,n.setRight(t.getRight()),t.hasRight()&&t.getRight().setParent(n),n.setLeft(t),t.setParent(n),t.setRight(),this.updateWeight(t),this.updateWeight(n),n):(this.root=n,n)}updateWeight(t){t.initWeight(),t.hasLeft()&&t.increaseWeight(t.getLeftWeight()),t.hasRight()&&t.increaseWeight(t.getRightWeight())}updateTreeWeight(t){for(;t;)this.updateWeight(t),t=t.getParent()}splayNode(t){if(t)for(;;)if(this.isLeftChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t),this.rotateLeft(t);else if(this.isLeftChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t.getParent()),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t.getParent()),this.rotateLeft(t);else{this.isLeftChild(t)?this.rotateRight(t):this.isRightChild(t)&&this.rotateLeft(t),this.updateWeight(t);return}}delete(t){this.splayNode(t);const n=new hh(t.getLeft());n.root&&n.root.setParent();const r=new hh(t.getRight());if(r.root&&r.root.setParent(),n.root){const i=n.getRightmost();n.splayNode(i),n.root.setRight(r.root),r.root&&r.root.setParent(n.root),this.root=n.root}else this.root=r.root;t.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(t,n){if(!n){this.splayNode(t),this.cutOffRight(t);return}this.splayNode(t),this.splayNode(n),n.getLeft()!=t&&this.rotateRight(t),this.cutOffRight(t)}cutOffRight(t){const n=[];this.traversePostorder(t.getRight(),n);for(const r of n)r.initWeight();this.updateTreeWeight(t)}toTestString(){const t=[];return this.traverseInorder(this.root,t),t.map(n=>`[${n.getWeight()},${n.getLength()}]${n.getValue()||""}`).join("")}checkWeight(){const t=[];this.traverseInorder(this.root,t);for(const n of t)if(n.getWeight()!=n.getLength()+n.getLeftWeight()+n.getRightWeight())return!1;return!0}getRightmost(){let t=this.root;for(;t.hasRight();)t=t.getRight();return t}traverseInorder(t,n){t&&(this.traverseInorder(t.getLeft(),n),n.push(t),this.traverseInorder(t.getRight(),n))}traversePostorder(t,n){t&&(this.traversePostorder(t.getLeft(),n),this.traversePostorder(t.getRight(),n),n.push(t))}rotateLeft(t){const n=t.getParent();n.hasParent()?n===n.getParent().getLeft()?n.getParent().setLeft(t):n.getParent().setRight(t):this.root=t,t.setParent(n.getParent()),n.setRight(t.getLeft()),n.hasRight()&&n.getRight().setParent(n),t.setLeft(n),t.getLeft().setParent(t),this.updateWeight(n),this.updateWeight(t)}rotateRight(t){const n=t.getParent();n.hasParent()?n===n.getParent().getLeft()?n.getParent().setLeft(t):n.getParent().setRight(t):this.root=t,t.setParent(n.getParent()),n.setLeft(t.getRight()),n.hasLeft()&&n.getLeft().setParent(n),t.setRight(n),t.getRight().setParent(t),this.updateWeight(n),this.updateWeight(t)}isLeftChild(t){return t&&t.hasParent()?t.getParent().getLeft()===t:!1}isRightChild(t){return t&&t.hasParent()?t.getParent().getRight()===t:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -547,8 +547,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert- * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var bi=null;try{bi=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function at(e,t,n){this.low=e|0,this.high=t|0,this.unsigned=!!n}at.prototype.__isLong__;Object.defineProperty(at.prototype,"__isLong__",{value:!0});function qn(e){return(e&&e.__isLong__)===!0}function Ax(e){var t=Math.clz32(e&-e);return e?31-t:t}at.isLong=qn;var kx={},Ix={};function _l(e,t){var n,r,i;return t?(e>>>=0,(i=0<=e&&e<256)&&(r=Ix[e],r)?r:(n=ct(e,0,!0),i&&(Ix[e]=n),n)):(e|=0,(i=-128<=e&&e<128)&&(r=kx[e],r)?r:(n=ct(e,e<0?-1:0,!1),i&&(kx[e]=n),n))}at.fromInt=_l;function wi(e,t){if(isNaN(e))return t?hs:qi;if(t){if(e<0)return hs;if(e>=LP)return NP}else{if(e<=-Tx)return yr;if(e+1>=Tx)return _P}return e<0?wi(-e,t).neg():ct(e%cd|0,e/cd|0,t)}at.fromNumber=wi;function ct(e,t,n){return new at(e,t,n)}at.fromBits=ct;var sm=Math.pow;function NC(e,t,n){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?hs:qi;if(n=n||10,n<2||360)throw Error("interior hyphen");if(r===0)return NC(e.substring(1),t,n).neg();for(var i=wi(sm(n,8)),o=qi,a=0;a>>0:this.low};he.toNumber=function(){return this.unsigned?(this.high>>>0)*cd+(this.low>>>0):this.high*cd+(this.low>>>0)};he.toString=function(t){if(t=t||10,t<2||36>>0,h=d.toString(t);if(a=u,a.isZero())return h+s;for(;h.length<6;)h="0"+h;s=""+h+s}};he.getHighBits=function(){return this.high};he.getHighBitsUnsigned=function(){return this.high>>>0};he.getLowBits=function(){return this.low};he.getLowBitsUnsigned=function(){return this.low>>>0};he.getNumBitsAbs=function(){if(this.isNegative())return this.eq(yr)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,n=31;n>0&&!(t&1<=0};he.isOdd=function(){return(this.low&1)===1};he.isEven=function(){return(this.low&1)===0};he.equals=function(t){return qn(t)||(t=co(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};he.eq=he.equals;he.notEquals=function(t){return!this.eq(t)};he.neq=he.notEquals;he.ne=he.notEquals;he.lessThan=function(t){return this.comp(t)<0};he.lt=he.lessThan;he.lessThanOrEqual=function(t){return this.comp(t)<=0};he.lte=he.lessThanOrEqual;he.le=he.lessThanOrEqual;he.greaterThan=function(t){return this.comp(t)>0};he.gt=he.greaterThan;he.greaterThanOrEqual=function(t){return this.comp(t)>=0};he.gte=he.greaterThanOrEqual;he.ge=he.greaterThanOrEqual;he.compare=function(t){if(qn(t)||(t=co(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};he.comp=he.compare;he.negate=function(){return!this.unsigned&&this.eq(yr)?yr:this.not().add(Tc)};he.neg=he.negate;he.add=function(t){qn(t)||(t=co(t));var n=this.high>>>16,r=this.high&65535,i=this.low>>>16,o=this.low&65535,a=t.high>>>16,s=t.high&65535,u=t.low>>>16,d=t.low&65535,h=0,p=0,g=0,m=0;return m+=o+d,g+=m>>>16,m&=65535,g+=i+u,p+=g>>>16,g&=65535,p+=r+s,h+=p>>>16,p&=65535,h+=n+a,h&=65535,ct(g<<16|m,h<<16|p,this.unsigned)};he.subtract=function(t){return qn(t)||(t=co(t)),this.add(t.neg())};he.sub=he.subtract;he.multiply=function(t){if(this.isZero())return this;if(qn(t)||(t=co(t)),bi){var n=bi.mul(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?hs:qi;if(this.eq(yr))return t.isOdd()?yr:qi;if(t.eq(yr))return this.isOdd()?yr:qi;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Px)&&t.lt(Px))return wi(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,o=this.low>>>16,a=this.low&65535,s=t.high>>>16,u=t.high&65535,d=t.low>>>16,h=t.low&65535,p=0,g=0,m=0,v=0;return v+=a*h,m+=v>>>16,v&=65535,m+=o*h,g+=m>>>16,m&=65535,m+=a*d,g+=m>>>16,m&=65535,g+=i*h,p+=g>>>16,g&=65535,g+=o*d,p+=g>>>16,g&=65535,g+=a*u,p+=g>>>16,g&=65535,p+=r*h+i*d+o*u+a*s,p&=65535,ct(m<<16|v,p<<16|g,this.unsigned)};he.mul=he.multiply;he.divide=function(t){if(qn(t)||(t=co(t)),t.isZero())throw Error("division by zero");if(bi){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?bi.div_u:bi.div_s)(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?hs:qi;var r,i,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return hs;if(t.gt(this.shru(1)))return OP;o=hs}else{if(this.eq(yr)){if(t.eq(Tc)||t.eq(v3))return yr;if(t.eq(yr))return Tc;var a=this.shr(1);return r=a.div(t).shl(1),r.eq(qi)?t.isNegative()?Tc:v3:(i=this.sub(t.mul(r)),o=r.add(i.div(t)),o)}else if(t.eq(yr))return this.unsigned?hs:qi;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=qi}for(i=this;i.gte(t);){r=Math.max(1,Math.floor(i.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:sm(2,s-48),d=wi(r),h=d.mul(t);h.isNegative()||h.gt(i);)r-=u,d=wi(r,this.unsigned),h=d.mul(t);d.isZero()&&(d=Tc),o=o.add(d),i=i.sub(h)}return o};he.div=he.divide;he.modulo=function(t){if(qn(t)||(t=co(t)),bi){var n=(this.unsigned?bi.rem_u:bi.rem_s)(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};he.mod=he.modulo;he.rem=he.modulo;he.not=function(){return ct(~this.low,~this.high,this.unsigned)};he.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};he.clz=he.countLeadingZeros;he.countTrailingZeros=function(){return this.low?Ax(this.low):Ax(this.high)+32};he.ctz=he.countTrailingZeros;he.and=function(t){return qn(t)||(t=co(t)),ct(this.low&t.low,this.high&t.high,this.unsigned)};he.or=function(t){return qn(t)||(t=co(t)),ct(this.low|t.low,this.high|t.high,this.unsigned)};he.xor=function(t){return qn(t)||(t=co(t)),ct(this.low^t.low,this.high^t.high,this.unsigned)};he.shiftLeft=function(t){return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?ct(this.low<>>32-t,this.unsigned):ct(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):ct(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};he.shr=he.shiftRight;he.shiftRightUnsigned=function(t){return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?ct(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?ct(this.high,0,this.unsigned):ct(this.high>>>t-32,0,this.unsigned)};he.shru=he.shiftRightUnsigned;he.shr_u=he.shiftRightUnsigned;he.rotateLeft=function(t){var n;return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?ct(this.high,this.low,this.unsigned):t<32?(n=32-t,ct(this.low<>>n,this.high<>>n,this.unsigned)):(t-=32,n=32-t,ct(this.high<>>n,this.low<>>n,this.unsigned))};he.rotl=he.rotateLeft;he.rotateRight=function(t){var n;return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?ct(this.high,this.low,this.unsigned):t<32?(n=32-t,ct(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,n=32-t,ct(this.low<>>t,this.high<>>t,this.unsigned))};he.rotr=he.rotateRight;he.toSigned=function(){return this.unsigned?ct(this.low,this.high,!1):this};he.toUnsigned=function(){return this.unsigned?this:ct(this.low,this.high,!0)};he.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};he.toBytesLE=function(){var t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};he.toBytesBE=function(){var t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};at.fromBytes=function(t,n,r){return r?at.fromBytesLE(t,n):at.fromBytesBE(t,n)};at.fromBytesLE=function(t,n){return new at(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};at.fromBytesBE=function(t,n){return new at(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};var Cn=(e=>(e[e.Null=0]="Null",e[e.Boolean=1]="Boolean",e[e.Integer=2]="Integer",e[e.Long=3]="Long",e[e.Double=4]="Double",e[e.String=5]="String",e[e.Bytes=6]="Bytes",e[e.Date=7]="Date",e))(Cn||{});class Jt extends Oh{constructor(n,r){super(r);k(this,"valueType");k(this,"value");this.valueType=Jt.getPrimitiveType(n),this.value=n===void 0?null:n}static of(n,r){return new Jt(n,r)}static valueFromBytes(n,r){switch(n){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(o,a){i.setUint8(a,o)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return at.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(at.fromBytesLE(Array.from(r),!0).toNumber());default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}toJSON(){return this.valueType===5?`"${Oo(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const n=Jt.of(this.value,this.getCreatedAt());return n.setMovedAt(this.getMovedAt()),n.setRemovedAt(this.getRemovedAt()),n}getType(){return this.valueType}static getPrimitiveType(n){switch(typeof n){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(n)?2:4;case"string":return 5;case"object":if(n===null)return 0;if(n instanceof at)return 3;if(n instanceof Uint8Array)return 6;if(n instanceof Date)return 7}}static isSupport(n){return Jt.getPrimitiveType(n)!==void 0}static isInteger(n){return n%1===0}isNumericType(){const n=this.valueType;return n===2||n===3||n===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const n=this.value;return new Uint8Array([n&255,n>>8&255,n>>16&255,n>>24&255])}case 4:{const n=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,n,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const n=this.value,r=at.fromNumber(n.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class um extends FP{constructor(n){super(n);k(this,"prev");k(this,"next");this.value=n}static createAfter(n,r){const i=new um(r),o=n.next;return n.next=i,i.prev=n,i.next=o,o&&(o.prev=i),i}remove(n){return this.value.remove(n)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class fh{constructor(){k(this,"dummyHead");k(this,"last");k(this,"nodeMapByIndex");k(this,"nodeMapByCreatedAt");const t=Jt.of(0,to);t.setRemovedAt(to),this.dummyHead=new um(t),this.last=this.dummyHead,this.nodeMapByIndex=new hh,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new fh}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,n){let r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(n);)r=r.getNext();return r}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,n,r=n.getCreatedAt()){const i=this.findNextBeforeExecutedAt(t,r),o=um.createAfter(i,n);i===this.last&&(this.last=o),this.nodeMapByIndex.insertAfter(i,o),this.nodeMapByCreatedAt.set(o.getCreatedAt().toIDString(),o)}moveAfter(t,n,r){const i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const o=this.nodeMapByCreatedAt.get(n.toIDString());if(!o)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${n.toIDString()}`);i!==o&&(!o.getValue().getMovedAt()||r.after(o.getValue().getMovedAt()))&&(this.release(o),this.insertAfter(i.getCreatedAt(),o.getValue(),r),o.getValue().setMovedAt(r))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const n=this.nodeMapByCreatedAt.get(t.toIDString());if(n)return String(this.nodeMapByIndex.indexOf(n))}purge(t){const n=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!n)throw new Y(J.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(n)}getByIndex(t){if(t>=this.length)return;const[n,r]=this.nodeMapByIndex.find(t);let i=n;if(t===0&&n===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(t){let n=this.nodeMapByCreatedAt.get(t.toIDString());do n=n.getPrev();while(this.dummyHead!==n&&n.isRemoved());return n.getValue().getCreatedAt()}delete(t,n){const r=this.nodeMapByCreatedAt.get(t.toIDString()),i=r.isRemoved();return r.remove(n)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(t,n){const r=this.getByIndex(t);if(r)return r.remove(n)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const n of this){const r=`${n.getCreatedAt().toIDString()}:${n.getValue().toJSON()}`;n.isRemoved()?t.push(`{${r}}`):t.push(`[${r}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class jr extends vu{constructor(n,r){super(n);k(this,"elements");this.elements=r}static create(n,r){if(!r)return new jr(n,fh.create());const i=fh.create();for(const o of r)i.insertAfter(i.getLastCreatedAt(),o.deepcopy());return new jr(n,i)}subPathOf(n){return this.elements.subPathOf(n)}purge(n){this.elements.purge(n)}insertAfter(n,r){this.elements.insertAfter(n,r)}moveAfter(n,r,i){this.elements.moveAfter(n,r,i)}get(n){const r=this.elements.getByIndex(n);return r==null?void 0:r.getValue()}getByID(n){const r=this.elements.getByID(n);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(n){return this.elements.getPrevCreatedAt(n)}delete(n,r){return this.elements.delete(n,r)}deleteByIndex(n,r){return this.elements.deleteByIndex(n,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const n of this.elements)n.isRemoved()||(yield n.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(n){for(const r of this.elements){const i=r.getValue();if(n(i,this))return;i instanceof vu&&i.getDescendants(n)}}toJSON(){const n=[];for(const r of this)n.push(r.toJSON());return`[${n.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const n={};for(let r=0;r({...v,value:v.value?{attributes:Hc(v.value.getAttributes()),content:v.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[h,m,p,[d,d]]}setStyle(n,r,i,o,a){const[,s]=this.rgaTreeSplit.findNodeWithSplit(n[1],i),[,u]=this.rgaTreeSplit.findNodeWithSplit(n[0],i),d=[],h=this.rgaTreeSplit.findBetween(u,s),p=new Map,g=[];for(const v of h){const E=v.getCreatedAt().getActorID();let w,C=0n;if(a===void 0&&o===void 0?C=R0:a.size()>0?C=a.get(E)?a.get(E):0n:w=o.has(E)?o.get(E):to,v.canStyle(i,w,C)){const b=p.get(E),A=v.getCreatedAt();(!b||A.after(b))&&p.set(E,A),g.push(v)}}const m=[];for(const v of g){if(v.isRemoved())continue;const[E,w]=this.rgaTreeSplit.findIndexesFromRange(v.createPosRange());d.push({type:"style",actor:i.getActorID(),from:E,to:w,value:{attributes:Hc(r)}});for(const[C,b]of Object.entries(r)){const[A]=v.getValue().setAttr(C,b,i);A!==void 0&&m.push({parent:v.getValue(),child:A})}}return[p,m,d]}indexRangeToPosRange(n,r){const i=this.rgaTreeSplit.indexToPos(n);return n===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const n=[];for(const r of this.rgaTreeSplit)r.isRemoved()||n.push(r.getValue().toJSON());return`[${n.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const n=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();n.push({attributes:Hc(i.getAttributes()),content:i.getContent()})}return n}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const n=new Ti(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return n.remove(this.getRemovedAt()),n}findIndexesFromRange(n){return this.rgaTreeSplit.findIndexesFromRange(n)}getGCPairs(){const n=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&n.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())n.push(i)}return n}}class Nh extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"content");k(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.content=a,this.attributes=s}static create(n,r,i,o,a,s,u){return new Nh(n,r,i,o,a,s,u)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Ti))throw new Y(J.ErrInvalidArgument,"fail to execute, only Text can execute edit");const a=o,[,s,u]=a.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const d of u)n.registerGCPair(d);return{opInfos:s.map(({from:d,to:h,value:p})=>({type:"edit",from:d,to:h,value:p,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),o=this.content;return`${n}.EDIT(${r},${i},${o})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class zh extends so{constructor(n,r,i,o,a,s){super(n,s);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.attributes=a}static create(n,r,i,o,a,s){return new zh(n,r,i,o,a,s)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Ti))throw new Y(J.ErrInvalidArgument,"fail to execute, only Text can execute edit");const a=o,[,s,u]=a.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const d of s)n.registerGCPair(d);return{opInfos:u.map(({from:d,to:h,value:p})=>({type:"style",from:d,to:h,value:p,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),o=this.attributes;return`${n}.STYL(${r},${i},${JSON.stringify(o)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const pKe=2,gKe="root",vs="text";function s0(e,t){let n=0;const r=e.children;for(let i=0;i0)throw new Y(J.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const n=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*n,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const n of this._children){const r=n.updateDescendantsSize();n.isRemoved||(t+=r)}return this.size+=t,this.paddedSize}get isText(){return this.type===vs}get paddedSize(){return this.size+(this.isText?0:pKe)}isAncestorOf(t){return vKe(this,t)}get nextSibling(){const t=this.parent.findOffset(this),n=this.parent.children[t+1];if(n)return n}get prevSibling(){const t=this.parent.findOffset(this),n=this.parent.children[t-1];if(n)return n}splitText(t,n){if(t===0||t===this.size)return;const r=this.value.slice(0,t),i=this.value.slice(t);if(!i.length)return;this.value=r;const o=this.cloneText(t+n);return o.value=i,this.parent.insertAfterInternal(o,this),o}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const n of t)n.parent=this,n.updateAncestorsSize()}prepend(...t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const n of t)n.parent=this}insertBefore(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r),t.updateAncestorsSize()}insertAfter(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1),t.updateAncestorsSize()}insertAt(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,n),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(t);if(n===-1)throw new Y(J.ErrInvalidArgument,"child not found");this._children.splice(n,1),t.parent=void 0}splitElement(t,n){const r=this.cloneElement(n);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,t),o=this.children.slice(t);this._children=i,r._children=o,this.size=this._children.reduce((a,s)=>a+s.paddedSize,0),r.size=r._children.reduce((a,s)=>a+s.paddedSize,0);for(const a of r._children)a.parent=r;return r}insertAfterInternal(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1)}insertAtInternal(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.splice(n,0,t),t.parent=this}findOffset(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");if(t.isRemoved){const n=this._children.indexOf(t);return this.allChildren.splice(0,n).filter(i=>!i.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");let n=t;for(;n;){const r=this._children.indexOf(n);if(r!==-1)return r;n=n.parent}return-1}}function vKe(e,t){if(e===t)return!1;for(;t.parent;){if(t.parent===e)return!0;t=t.parent}return!1}var un=(e=>(e.Start="Start",e.End="End",e.Text="Text",e))(un||{});function zP(e,t,n,r){if(t>n)throw new Y(J.ErrInvalidArgument,`from is greater than to: ${t} > ${n}`);if(t>e.size)throw new Y(J.ErrInvalidArgument,`from is out of range: ${t} > ${e.size}`);if(n>e.size)throw new Y(J.ErrInvalidArgument,`to is out of range: ${n} > ${e.size}`);if(t===n)return;let i=0;for(const o of e.children){if(t-o.paddedSizeo.size;(o.isText||u)&&r([o,o.isText?"Text":"Start"],d),zP(o,Math.max(0,a),Math.min(s,o.size),r),d&&r([o,"End"],d)}i+=o.paddedSize}}function HP(e,t,n=0){for(const r of e.children)HP(r,t,n+1);t(e,n)}function C1(e,t,n=0){for(const r of e._children)C1(r,t,n+1);t(e,n)}function y3(e,t,n=!0){if(t>e.size)throw new Y(J.ErrInvalidArgument,`index is out of range: ${t} > ${e.size}`);if(e.isText)return{node:e,offset:t};let r=0,i=0;for(const o of e.children){if(n&&o.isText&&o.size>=t-i)return y3(o,t-i,n);if(t===i)return{node:e,offset:r};if(!n&&o.paddedSize===t-i)return{node:e,offset:r+1};if(o.paddedSize>t-i)return y3(o,t-i-1,n);i+=o.paddedSize,r+=1}return{node:e,offset:r}}function jP(e){return e.isText||e.children.length===0?e:jP(e.children[0])}function yKe(e,t){if(e.sizee===t?0:e0)if(n.right)n.right.parent=n,n=n.right;else return n;else if(r<0)if(n.left)n.left.parent=n,n=n.left;else{let i=n.parent,o=n;for(;i&&o===i.left;)o=i,i=i.parent;return i}else return n}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,n){for(;n;){const r=this.comparator(t,n.key);if(r===0)return n;r<0?n=n.left:r>0&&(n=n.right)}}putInternal(t,n,r){if(!r)return this.counter+=1,new bKe(t,n,!0);const i=this.comparator(t,r.key);return i<0?r.left=this.putInternal(t,n,r.left):i>0?r.right=this.putInternal(t,n,r.right):r.value=n,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(t,n){if(this.comparator(n,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,n);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(n,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(n,t.key)===0){this.counter-=1;const r=this.min(t.right);t.value=r.value,t.key=r.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,n)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const n=t.right;return t.right=n.left,n.left=t,n.isRed=n.left.isRed,n.left.isRed=!0,n}rotateRight(t){const n=t.left;return t.left=n.right,n.right=t,n.isRed=n.right.isRed,n.right.isRed=!0,n}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class Xi{constructor(t,n){k(this,"parentID");k(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=n}static of(t,n){return new Xi(t,n)}static fromTreePos(t){const{offset:n}=t;let{node:r}=t,i;return r.isText?(r.parent.children[0]===r&&n===0?i=r.parent:i=r,r=r.parent):n===0?i=r:i=r.children[n-1],Xi.of(r.id,Fn.of(i.getCreatedAt(),i.getOffset()+n))}getParentID(){return this.parentID}static fromStruct(t){return Xi.of(Fn.of(Ai.fromStruct(t.parentID.createdAt),t.parentID.offset),Fn.of(Ai.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const n=this.getParentID(),r=this.getLeftSiblingID(),i=t.findFloorNode(n);let o=t.findFloorNode(r);if(!i||!o)throw new Y(J.ErrRefused,`cannot find node of CRDTTreePos(${n.toTestString()}, ${r.toTestString()})`);return!r.equals(n)&&r.getOffset()>0&&r.getOffset()===o.id.getOffset()&&o.insPrevID&&(o=t.findFloorNode(o.insPrevID)),[i,o]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class Fn{constructor(t,n){k(this,"createdAt");k(this,"offset");this.createdAt=t,this.offset=n}static of(t,n){return new Fn(t,n)}static fromStruct(t){return Fn.of(Ai.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,n)=>{const r=t.getCreatedAt().compare(n.getCreatedAt());return r!==0?r:t.getOffset()>n.getOffset()?1:t.getOffset(){const o=i.deepcopy();return o.parent=n,o}),n.insPrevID=this.insPrevID,n.insNextID=this.insNextID,n}get value(){if(!this.isText)throw new Y(J.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(n){if(!this.isText)throw new Y(J.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=n,this.size=n.length}get isRemoved(){return!!this.removedAt}remove(n){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(n)>0)&&(this.removedAt=n),r&&this.updateAncestorsSize()}cloneText(n){return new Nr(Fn.of(this.id.getCreatedAt(),n),this.type,void 0,void 0,this.removedAt)}cloneElement(n){return new Nr(Fn.of(n(),0),this.type,void 0,void 0,this.removedAt)}split(n,r,i){const o=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(o){if(o.insPrevID=this.id,this.insNextID){const a=n.findFloorNode(this.insNextID);a.insPrevID=o.id,o.insNextID=this.insNextID}this.insNextID=o.id,n.registerNode(o)}return o}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(n,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||n.after(this.removedAt))}canStyle(n,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||n.after(this.removedAt))}setAttrs(n,r){this.attrs||(this.attrs=new Ds);const i=[];for(const[o,a]of Object.entries(n))i.push(this.attrs.set(o,a,r));return i}purge(n){this.attrs&&this.attrs.purge(n)}getGCPairs(){const n=[];if(!this.attrs)return n;for(const r of this.attrs)r.getRemovedAt()&&n.push({parent:this,child:r});return n}}function E3(e){var n;if(e.isText){const r=e;return{type:r.type,value:r.value}}const t={type:e.type,children:e.children.map(E3)};return e.attrs&&(t.attributes=Hc((n=e.attrs)==null?void 0:n.toObject())),t}function zC(e){if(e.isText)return e.value;let t="";return e.attrs&&e.attrs.size()&&(t=" "+Array.from(e.attrs).filter(n=>!n.isRemoved()).sort((n,r)=>n.getKey().localeCompare(r.getKey())).map(n=>{const r=JSON.parse(n.getValue());return typeof r=="string"?`${n.getKey()}="${r}"`:`${n.getKey()}="${Oo(n.getValue())}"`}).join(" ")),`<${e.type}${t}>${e.children.map(n=>zC(n)).join("")}`}function KP(e){if(e.isText){const t=e;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:e.type,children:e.children.map(KP),size:e.size,isRemoved:e.isRemoved}}class Pi extends Oh{constructor(n,r){super(r);k(this,"indexTree");k(this,"nodeMapByID");this.indexTree=new EKe(n),this.nodeMapByID=new UP(Fn.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(n,r){return new Pi(n,r)}findFloorNode(n){const r=this.nodeMapByID.floorEntry(n);if(!(!r||!r.key.getCreatedAt().equals(n.getCreatedAt())))return r.value}registerNode(n){this.nodeMapByID.put(n.id,n)}findNodesAndSplitText(n,r){const[i,o]=n.toTreeNodePair(this);let a=o;const s=i===a,u=a.parent&&!s?a.parent:i;if(a.isText&&a.split(this,n.getLeftSiblingID().getOffset()-a.id.getOffset()),r){const d=u.allChildren,h=s?0:d.indexOf(a)+1;for(let p=h;p{const w=E.getCreatedAt().getActorID();let C,b=0n;if(a===void 0&&o===void 0?b=R0:a.size()>0?b=a.get(w)?a.get(w):0n:C=o.has(w)?o.get(w):to,E.canStyle(i,C,b)&&r){const A=m.get(w),T=E.getCreatedAt();(!A||T.after(A))&&m.set(w,T);const B=E.setAttrs(r,i),D=B.reduce((O,[,z])=>(z&&(O[z.getKey()]=g[z.getKey()]),O),{}),I=E.parent,M=E.prevSibling||E.parent;Object.keys(D).length>0&&p.push({type:"style",from:this.toIndex(I,M),to:this.toIndex(E,E),fromPath:this.toPath(I,M),toPath:this.toPath(E,E),actor:i.getActorID(),value:D});for(const[O]of B)O&&v.push({parent:E,child:O})}}),[m,v,p]}removeStyle(n,r,i,o,a){const[s,u]=this.findNodesAndSplitText(n[0],i),[d,h]=this.findNodesAndSplitText(n[1],i),p=[],g=new Map,m=[];return this.traverseInPosRange(s,u,d,h,([v])=>{const E=v.getCreatedAt().getActorID();let w,C=0n;if(a===void 0&&o===void 0?C=R0:a.size()>0?C=a.get(E)?a.get(E):0n:w=o.has(E)?o.get(E):to,v.canStyle(i,w,C)&&r){const b=g.get(E),A=v.getCreatedAt();(!b||A.after(b))&&g.set(E,A),v.attrs||(v.attrs=new Ds);for(const D of r){const I=v.attrs.remove(D,i);for(const M of I)m.push({parent:v,child:M})}const T=v.parent,B=v.prevSibling||v.parent;p.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(T,B),to:this.toIndex(v,v),fromPath:this.toPath(T,B),toPath:this.toPath(v,v),value:r})}}),[g,m,p]}edit(n,r,i,o,a,s,u){const[d,h]=this.findNodesAndSplitText(n[0],o),[p,g]=this.findNodesAndSplitText(n[1],o),m=this.toIndex(d,h),v=this.toPath(d,h),E=[],w=[],C=[],b=new Map;this.traverseInPosRange(d,h,p,g,([B,D],I)=>{if(D===un.Start&&!I)for(const K of B.children)C.push(K);const M=B.getCreatedAt().getActorID();let O,z=0n;if(u===void 0&&s===void 0?z=R0:u.size()>0?z=u.get(M)?u.get(M):0n:O=s.has(M)?s.get(M):to,B.canDelete(o,O,z)||E.includes(B.parent)){const K=b.get(M),X=B.getCreatedAt();(!K||X.after(K))&&b.set(M,X),(D===un.Text||D===un.Start)&&E.push(B),w.push([B,D])}});const A=this.makeDeletionChanges(w,o),T=[];for(const B of E)B.remove(o),B.isRemoved&&T.push({parent:this,child:B});for(const B of C)B.removedAt||d.append(B);if(i>0){let B=0,D=d,I=h;for(;B{d.isRemoved&&(M.remove(o),T.push({parent:this,child:M})),this.nodeMapByID.put(M.id,M)}),I.isRemoved||B.push(I);if(B.length){const I=B.map(M=>E3(M));A.length&&A[A.length-1].from===m?A[A.length-1].value=I:A.push({type:"content",from:m,to:m,fromPath:v,toPath:v,actor:o.getActorID(),value:I})}}return[A,T,b]}editT(n,r,i,o,a){const s=this.findPos(n[0]),u=this.findPos(n[1]);this.edit([s,u],r,i,o,a)}move(n,r,i){throw new Y(J.ErrUnimplemented,`not implemented: ${n}, ${r}, ${i}`)}purge(n){var o;(o=n.parent)==null||o.removeChild(n),this.nodeMapByID.remove(n.id);const r=n.insPrevID,i=n.insNextID;if(r){const a=this.findFloorNode(r);a.insNextID=i}if(i){const a=this.findFloorNode(i);a.insPrevID=r}n.insPrevID=void 0,n.insNextID=void 0}getGCPairs(){const n=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&n.push({parent:this,child:r});for(const i of r.getGCPairs())n.push(i)}),n}findPos(n,r=!0){const i=this.indexTree.findTreePos(n,r);return Xi.fromTreePos(i)}pathToPosRange(n){const r=this.pathToIndex(n);return[this.findPos(r),this.findPos(r+1)]}pathToPos(n){const r=this.indexTree.pathToIndex(n);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return zC(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const n=this.indexTree.getRoot(),r=(i,o=void 0,a=void 0,s=0)=>{var m,v,E,w;let u,d,h;const p=i.isText?{node:i,offset:0}:o&&a?this.toTreePos(o,a):null;p&&(u=this.indexTree.indexOf(p),d=this.indexTree.treePosToPath(p),h=Xi.fromTreePos(p).toStruct());const g={type:i.type,parent:o==null?void 0:o.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(m=i.removedAt)==null?void 0:m.toTestString(),insPrev:(v=i.insPrevID)==null?void 0:v.toTestString(),insNext:(E=i.insNextID)==null?void 0:E.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:s,attributes:i.attrs?Hc((w=i.attrs)==null?void 0:w.toObject()):void 0,index:u,path:d,pos:h};for(let C=0;C0&&C===i[i.length-1].to?(i[i.length-1].to=b,i[i.length-1].toPath=this.toPath(w,m)):i.push({type:"content",from:C,to:b,fromPath:this.toPath(E,p),toPath:this.toPath(w,m),actor:r.getActorID()}))}return i.reverse()}findRightToken([n,r]){if(r===un.Start){const u=n.allChildren;return u.length>0?[u[0],u[0].isText?un.Text:un.Start]:[n,un.End]}const i=n.parent,o=i.allChildren,a=o.indexOf(n);if(i&&a===o.length-1)return[i,un.End];const s=o[a+1];return[s,s.isText?un.Text:un.Start]}findLeftToken([n,r]){if(r===un.End){const u=n.allChildren;if(u.length>0){const d=u[u.length-1];return[d,d.isText?un.Text:un.End]}return[n,un.Start]}const i=n.parent,o=i.allChildren,a=o.indexOf(n);if(i&&a===0)return[i,un.Start];const s=o[a-1];return[s,s.isText?un.Text:un.End]}}class Hh extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"contents");k(this,"splitLevel");k(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=o,this.splitLevel=a,this.maxCreatedAtMapByActor=s}static create(n,r,i,o,a,s,u){return new Hh(n,r,i,o,a,s,u)}execute(n,r,i){var h;const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Pi))throw new Y(J.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const a=this.getExecutedAt(),s=o,[u,d]=s.edit([this.fromPos,this.toPos],(h=this.contents)==null?void 0:h.map(p=>p.deepcopy()),this.splitLevel,a,(()=>{let p=a.getDelimiter();return this.contents!==void 0&&(p+=this.contents.length),()=>Ai.of(a.getLamport(),++p,a.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const p of d)n.registerGCPair(p);return{opInfos:u.map(({from:p,to:g,value:m,splitLevel:v,fromPath:E,toPath:w})=>({type:"tree-edit",path:n.createPath(this.getParentCreatedAt()),from:p,to:g,value:m,splitLevel:v,fromPath:E,toPath:w}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,o=this.contents||[];return`${n}.EDIT(${r},${i},${o.map(a=>zC(a)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class jc{constructor(t){k(this,"vector");this.vector=t||new Map}set(t,n){this.vector.set(t,n)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,n]of this)n>t&&(t=n);return t}max(t){const n=new Map;for(const[r,i]of t){const o=this.vector.get(r),a=o&&o>i?o:i;n.set(r,a)}for(const[r,i]of this){const o=t.get(r),a=o&&o>i?o:i;n.set(r,a)}return new jc(n)}afterOrEqual(t){const n=this.vector.get(t.getActorID());return n===void 0?!1:n>=t.getLamport()}deepcopy(){const t=new Map;for(const[n,r]of this.vector)t.set(n,r);return new jc(t)}filter(t){const n=new Map;for(const[r]of t){const i=this.vector.get(r);i!==void 0&&n.set(r,i)}return new jc(n)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,n]of this.vector)yield[t,n]}}const SKe=new jc(new Map);class as{constructor(t,n,r,i,o){k(this,"clientSeq");k(this,"serverSeq");k(this,"lamport");k(this,"actor");k(this,"versionVector");this.clientSeq=t,this.serverSeq=o,this.lamport=n,this.versionVector=i,this.actor=r}static of(t,n,r,i,o){return new as(t,n,r,i,o)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new as(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const n=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n,r=this.versionVector.max(t.versionVector),i=new as(this.clientSeq,n,this.actor,r);return i.versionVector.set(this.actor,n),i}setClocks(t,n){const r=t>this.lamport?t:this.lamport+1n,i=this.versionVector.max(n);return i.set(this.actor,r),as.of(this.clientSeq,r,this.actor,i)}createTimeTicket(t){return Ai.of(this.lamport,t,this.actor)}setActor(t){return new as(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new as(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const xKe=new as(0,0n,OC,SKe);class dd{constructor({id:t,operations:n,presenceChange:r,message:i}){k(this,"id");k(this,"operations");k(this,"presenceChange");k(this,"message");this.id=t,this.operations=n||[],this.presenceChange=r,this.message=i}static create({id:t,operations:n,presenceChange:r,message:i}){return new dd({id:t,operations:n,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const n of this.operations)n.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,n,r){const i=[],o=[];for(const a of this.operations){const s=a.execute(t,r,this.id.getVersionVector());if(!s)continue;const{opInfos:u,reverseOp:d}=s;i.push(...u),d&&o.unshift(d)}return this.presenceChange&&(this.presenceChange.type===Du.Put?n.set(this.id.getActorID(),Gi(this.presenceChange.presence)):n.delete(this.id.getActorID())),{opInfos:i,reverseOps:o}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:on.bytesToHex(on.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>on.bytesToHex(on.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:n,operations:r,presenceChange:i,message:o}=t;return dd.create({id:on.bytesToChangeID(on.hexToBytes(n)),operations:r==null?void 0:r.map(a=>on.bytesToOperation(on.hexToBytes(a))),presenceChange:i,message:o})}}class b1{constructor(t,n,r,i,o,a,s){k(this,"documentKey");k(this,"checkpoint");k(this,"isRemoved");k(this,"changes");k(this,"snapshot");k(this,"minSyncedTicket");k(this,"versionVector");this.documentKey=t,this.checkpoint=n,this.isRemoved=r,this.changes=i,this.snapshot=a,this.minSyncedTicket=s,this.versionVector=o}static create(t,n,r,i,o,a,s){return new b1(t,n,r,i,o,a,s)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Uc{constructor(t,n){k(this,"serverSeq");k(this,"clientSeq");this.serverSeq=t,this.clientSeq=n}static of(t,n){return new Uc(t,n)}increaseClientSeq(t){return t===0?this:new Uc(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const n=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,r=Math.max(this.clientSeq,t.clientSeq);return Uc.of(n,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const AKe=new Uc(0n,0);class zo{constructor(t,n){k(this,"createdAt");k(this,"offset");this.createdAt=t,this.offset=n}static of(t,n){return new zo(t,n)}static fromStruct(t){return zo.of(Ai.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new zo(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const kKe=zo.of(to,0);class no{constructor(t,n){k(this,"id");k(this,"relativeOffset");this.id=t,this.relativeOffset=n}static of(t,n){return new no(t,n)}static fromStruct(t){const n=zo.fromStruct(t.id);return no.of(n,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return zo.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class yu extends FP{constructor(n,r,i){super(r);k(this,"id");k(this,"removedAt");k(this,"prev");k(this,"next");k(this,"insPrev");k(this,"insNext");this.id=n,this.removedAt=i}static create(n,r){return new yu(n,r)}static createComparator(){return(n,r)=>{const i=n.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:n.getOffset()>r.getOffset()?1:n.getOffset()0&&n.getID().getOffset()==t.getOffset()){if(!n.hasInsPrev())return n;n=n.getInsPrev()}return n}findFloorNode(t){const n=this.treeByID.floorEntry(t);if(n&&!(!n.key.equals(t)&&!n.key.hasSameCreatedAt(t)))return n.value}findBetween(t,n){const r=[];let i=t;for(;i&&i!==n;)r.push(i),i=i.getNext();return r}splitNode(t,n){if(n>t.getContentLength())throw new Y(J.ErrInvalidArgument,"offset should be less than or equal to length");if(n===0)return t;if(n===t.getContentLength())return t.getNext();const r=t.split(n);this.treeByIndex.updateWeight(r),this.insertAfter(t,r);const i=t.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(t),r}deleteNodes(t,n,r,i){if(!t.length)return[[],new Map,new Map];const[o,a]=this.filterNodes(t,n,r,i),s=new Map,u=new Map,d=this.makeChanges(a,n);for(const h of o){const p=h.getCreatedAt().getActorID();(!s.has(p)||h.getID().getCreatedAt().after(s.get(p)))&&s.set(p,h.getID().getCreatedAt()),u.set(h.getID().toIDString(),h),h.remove(n)}return this.deleteIndexNodes(a),[d,s,u]}filterNodes(t,n,r,i){const o=[],a=[],[s,u]=this.findEdgesOfCandidates(t);a.push(s);for(const d of t){const h=d.getCreatedAt().getActorID();let p,g=0n;i===void 0&&r===void 0?g=R0:i.size()>0?g=i.get(h)?i.get(h):0n:p=r.has(h)?r.get(h):to,d.canDelete(n,p,g)?o.push(d):a.push(d)}return a.push(u),[o,a]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,n){const r=[];let i,o;for(let a=0;ae<0?Math.ceil(e):Math.floor(e);var Ko=(e=>(e[e.IntegerCnt=0]="IntegerCnt",e[e.LongCnt=1]="LongCnt",e))(Ko||{});class Ur extends Oh{constructor(n,r,i){super(i);k(this,"valueType");k(this,"value");switch(this.valueType=n,n){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=at.fromNumber(r).toInt():this.value=Bx(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=at.fromNumber(r):this.value=r;break;default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}static create(n,r,i){return new Ur(n,r,i)}static valueFromBytes(n,r){switch(n){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return at.fromBytesLE(Array.from(r));default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const n=Ur.create(this.valueType,this.value,this.getCreatedAt());return n.setMovedAt(this.getMovedAt()),n}getType(){return this.valueType}static getCounterType(n){switch(typeof n){case"object":return n instanceof at?1:void 0;case"number":return n>Math.pow(2,31)-1||n<-Math.pow(2,31)?1:0;default:return}}static isSupport(n){return!!Ur.getCounterType(n)}static isInteger(n){return n%1===0}isNumericType(){const n=this.valueType;return n===0||n===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const n=this.value;return new Uint8Array([n&255,n>>8&255,n>>16&255,n>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(n){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(n),this.valueType===1?this.value=this.value.add(n.getValue()):n.getType()===Cn.Long?this.value=this.value+n.getValue().toInt():this.value=at.fromNumber(this.value+Bx(n.getValue())).toInt(),this}}class fd extends so{constructor(n,r,i){super(n,i);k(this,"value");this.value=r}static create(n,r,i){return new fd(n,r,i)}execute(n){const r=n.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof Ur))throw new Y(J.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,o=this.value.deepcopy();return i.increase(o),{opInfos:[{type:"increase",path:n.createPath(this.getParentCreatedAt()),value:o.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const n=this.value.deepcopy(),i=n.getType()===Cn.Long?n.getValue().multiply(-1):n.getValue()*-1;return fd.create(this.getParentCreatedAt(),Jt.of(i,n.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class ys extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"attributes");k(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.attributes=a,this.attributesToRemove=s}static create(n,r,i,o,a,s){return new ys(n,r,i,o,a,[],s)}static createTreeRemoveStyleOperation(n,r,i,o,a,s){return new ys(n,r,i,o,new Map,a,s)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Pi))throw new Y(J.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const a=o;let s,u;if(this.attributes.size){const d={};[...this.attributes].forEach(([h,p])=>d[h]=p),[,u,s]=a.style([this.fromPos,this.toPos],d,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const d=this.attributesToRemove;[,u,s]=a.removeStyle([this.fromPos,this.toPos],d,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const d of u)n.registerGCPair(d);return{opInfos:s.map(({from:d,to:h,value:p,fromPath:g,toPath:m})=>({type:"tree-style",from:d,to:h,value:this.attributes.size?{attributes:p}:{attributesToRemove:p},fromPath:g,toPath:m,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${n}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([o,a])=>`${o}:"${a}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function IKe(e){const t=new LC,n=t.data;for(const[r,i]of Object.entries(e))n[r]=JSON.stringify(i);return t}function DKe(e){if(e.type===Du.Put)return new ch({type:Dl.PUT,presence:IKe(e.presence)});if(e.type===Du.Clear)return new ch({type:Dl.CLEAR});throw new Y(J.ErrUnimplemented,"unimplemented type")}function TKe(e){return new MP({serverSeq:e.getServerSeq(),clientSeq:e.getClientSeq()})}function VP(e){return new y1({clientSeq:e.getClientSeq(),lamport:e.getLamport(),actorId:XC(e.getActorID()),versionVector:HC(e.getVersionVector())})}function Te(e){if(e)return new Ie({lamport:e.getLamport(),delimiter:e.getDelimiter(),actorId:XC(e.getActorID())})}function HC(e){if(!e)return;const t=new E1;for(const[n,r]of e)t.vector[n]=BigInt(r.toString());return t}function GP(e){switch(e){case Cn.Null:return Ve.NULL;case Cn.Boolean:return Ve.BOOLEAN;case Cn.Integer:return Ve.INTEGER;case Cn.Long:return Ve.LONG;case Cn.Double:return Ve.DOUBLE;case Cn.String:return Ve.STRING;case Cn.Bytes:return Ve.BYTES;case Cn.Date:return Ve.DATE;default:throw new Y(J.ErrInvalidType,`unsupported type: ${e}`)}}function JP(e){switch(e){case Ko.IntegerCnt:return Ve.INTEGER_CNT;case Ko.LongCnt:return Ve.LONG_CNT;default:throw new Y(J.ErrInvalidType,`unsupported type: ${e}`)}}function r2(e){if(e instanceof wr)return new li({type:Ve.JSON_OBJECT,createdAt:Te(e.getCreatedAt()),value:aB(e)});if(e instanceof jr)return new li({type:Ve.JSON_ARRAY,createdAt:Te(e.getCreatedAt()),value:aVe(e)});if(e instanceof Ti)return new li({type:Ve.TEXT,createdAt:Te(e.getCreatedAt())});if(e instanceof Jt)return new li({type:GP(e.getType()),createdAt:Te(e.getCreatedAt()),value:e.toBytes()});if(e instanceof Ur)return new li({type:JP(e.getType()),createdAt:Te(e.getCreatedAt()),value:e.toBytes()});if(e instanceof Pi)return new li({type:Ve.TREE,createdAt:Te(e.getCreatedAt()),value:uVe(e)});throw new Y(J.ErrUnimplemented,"unimplemented element")}function PKe(e){return new uh({createdAt:Te(e.getCreatedAt()),offset:e.getOffset()})}function Sp(e){return new Is({createdAt:Te(e.getID().getCreatedAt()),offset:e.getID().getOffset(),relativeOffset:e.getRelativeOffset()})}function xp(e){return new Il({parentId:F0(e.getParentID()),leftSiblingId:F0(e.getLeftSiblingID())})}function F0(e){return new mu({createdAt:Te(e.getCreatedAt()),offset:e.getOffset()})}function WP(e){const t=new FC;if(e instanceof Tl){const n=e,r=new Ug;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.key=n.getKey(),r.value=r2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="set",t.body.value=r}else if(e instanceof _h){const n=e,r=new Kg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.prevCreatedAt=Te(n.getPrevCreatedAt()),r.value=r2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="add",t.body.value=r}else if(e instanceof au){const n=e,r=new Vg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.prevCreatedAt=Te(n.getPrevCreatedAt()),r.createdAt=Te(n.getCreatedAt()),r.executedAt=Te(n.getExecutedAt()),t.body.case="move",t.body.value=r}else if(e instanceof Tu){const n=e,r=new Gg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.createdAt=Te(n.getCreatedAt()),r.executedAt=Te(n.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(e instanceof Nh){const n=e,r=new Jg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=Sp(n.getFromPos()),r.to=Sp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);r.content=n.getContent();const o=r.attributes;for(const[a,s]of n.getAttributes())o[a]=s;r.executedAt=Te(n.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(e instanceof zh){const n=e,r=new Wg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=Sp(n.getFromPos()),r.to=Sp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);const o=r.attributes;for(const[a,s]of n.getAttributes())o[a]=s;r.executedAt=Te(n.getExecutedAt()),t.body.case="style",t.body.value=r}else if(e instanceof fd){const n=e,r=new Yg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.value=r2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(e instanceof Hh){const n=e,r=new qg,i=r.createdAtMapByActor;for(const[o,a]of n.getMaxCreatedAtMapByActor())i[o]=Te(a);r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=xp(n.getFromPos()),r.to=xp(n.getToPos()),r.contents=OKe(n.getContents()),r.splitLevel=n.getSplitLevel(),r.executedAt=Te(n.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(e instanceof ys){const n=e,r=new Xg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=xp(n.getFromPos()),r.to=xp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);const o=n.getAttributesToRemove();if(o.length>0)r.attributesToRemove=o;else{const a=r.attributes;for(const[s,u]of n.getAttributes())a[s]=u}r.executedAt=Te(n.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new Y(J.ErrUnimplemented,"unimplemented operation");return t}function BKe(e){const t=[];for(const n of e)t.push(WP(n));return t}function MKe(e){const t=new PP({id:VP(e.getID()),message:e.getMessage()});return e.hasOperations()&&(t.operations=BKe(e.getOperations())),e.hasPresenceChange()&&(t.presenceChange=DKe(e.getPresenceChange())),t}function $Ke(e){const t=[];for(const n of e)t.push(MKe(n));return t}function RKe(e){const t=[];for(const n of e)t.push(new BP({key:n.getStrKey(),element:UC(n.getValue())}));return t}function FKe(e){const t=[];for(const n of e)t.push(new im({element:UC(n.getValue())}));return t}function LKe(e){const t=[];for(const n of e){const r=new om;r.id=PKe(n.getID()),r.value=n.getValue().getContent(),r.removedAt=Te(n.getRemovedAt());const i=r.attributes,o=n.getValue().getAttrs();for(const a of o){const s=new ud;s.value=a.getValue(),s.updatedAt=Te(a.getUpdatedAt()),i[a.getKey()]=s}t.push(r)}return t}function OKe(e){const t=[];if(!e||!e.length)return t;for(const n of e)t.push(new am({content:jC(n)}));return t}function _Ke(e){const t={};for(const n of e)t[n.getKey()]=new ud({value:n.getValue(),updatedAt:Te(n.getUpdatedAt()),isRemoved:n.isRemoved()});return t}function jC(e){if(!e)return[];const t=[];return C1(e,(n,r)=>{const i=new lh({id:F0(n.id),type:n.type,removedAt:Te(n.removedAt),depth:r});n.isText&&(i.value=n.value),n.insPrevID&&(i.insPrevId=F0(n.insPrevID)),n.insNextID&&(i.insNextId=F0(n.insNextID)),n.attrs&&(i.attributes=_Ke(n.attrs)),t.push(i)}),t}function NKe(e){const t=new Sr;return t.body.case="jsonObject",t.body.value=new Zg({nodes:RKe(e.getRHT()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function YP(e){const t=new Sr;return t.body.case="jsonArray",t.body.value=new Qg({nodes:FKe(e.getElements()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function zKe(e){const t=new Sr;return t.body.case="primitive",t.body.value=new em({type:GP(e.getType()),value:e.toBytes(),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function HKe(e){const t=new Sr;return t.body.case="text",t.body.value=new tm({nodes:LKe(e.getRGATreeSplit()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function jKe(e){const t=new Sr;return t.body.case="counter",t.body.value=new nm({type:JP(e.getType()),value:e.toBytes(),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function qP(e){const t=new Sr;return t.body.case="tree",t.body.value=new rm({nodes:jC(e.getRoot()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function UC(e){if(e instanceof wr)return NKe(e);if(e instanceof jr)return YP(e);if(e instanceof Jt)return zKe(e);if(e instanceof Ti)return HKe(e);if(e instanceof Ur)return jKe(e);if(e instanceof Pi)return qP(e);throw new Y(J.ErrUnimplemented,"unimplemented element")}function UKe(e){return new Rs({documentKey:e.getDocumentKey(),checkpoint:TKe(e.getCheckpoint()),isRemoved:e.getIsRemoved(),changes:$Ke(e.getChanges()),snapshot:e.getSnapshot(),versionVector:HC(e.getVersionVector()),minSyncedTicket:Te(e.getMinSyncedTicket())})}function f0(e){if(!(e instanceof Nt))return{};const t=e.findDetails(uKe);for(const n of t)return n.metadata;return{}}function dc(e){return f0(e).code??""}function XP(e){return as.of(e.clientSeq,BigInt(e.lamport),YC(e.actorId),KC(e.versionVector),BigInt(e.serverSeq))}function KC(e){if(!e)return;const t=new jc;return Object.entries(e.vector).forEach(([n,r])=>{t.set(n,BigInt(r.toString()))}),t}function Pe(e){if(e)return Ai.of(BigInt(e.lamport),e.delimiter,YC(e.actorId))}function VC(e){const t={};return Object.entries(e.data).forEach(([n,r])=>{t[n]=JSON.parse(r)}),t}function KKe(e){const t=e.type;if(t===Dl.PUT){const n=VC(e.presence);return{type:Du.Put,presence:n}}if(t===Dl.CLEAR)return{type:Du.Clear};throw new Y(J.ErrInvalidType,`unsupported type: ${t}`)}function VKe(e){const t=new Map;return Object.entries(e).forEach(([n,r])=>{t.set(n,VC(r))}),t}function ZP(e){switch(e){case Ve.NULL:return Cn.Null;case Ve.BOOLEAN:return Cn.Boolean;case Ve.INTEGER:return Cn.Integer;case Ve.LONG:return Cn.Long;case Ve.DOUBLE:return Cn.Double;case Ve.STRING:return Cn.String;case Ve.BYTES:return Cn.Bytes;case Ve.DATE:return Cn.Date}throw new Y(J.ErrUnimplemented,`unimplemented value type: ${e}`)}function lm(e){switch(e){case Ve.INTEGER_CNT:return Ko.IntegerCnt;case Ve.LONG_CNT:return Ko.LongCnt}throw new Y(J.ErrUnimplemented,`unimplemented value type: ${e}`)}function i2(e){switch(e.type){case Ve.JSON_OBJECT:return e.value?oB(e.value):wr.create(Pe(e.createdAt));case Ve.JSON_ARRAY:return e.value?oVe(e.value):jr.create(Pe(e.createdAt));case Ve.TEXT:return Ti.create(hd.create(),Pe(e.createdAt));case Ve.TREE:return sVe(e.value);case Ve.NULL:case Ve.BOOLEAN:case Ve.INTEGER:case Ve.LONG:case Ve.DOUBLE:case Ve.STRING:case Ve.BYTES:case Ve.DATE:return Jt.of(Jt.valueFromBytes(ZP(e.type),e.value),Pe(e.createdAt));case Ve.INTEGER_CNT:case Ve.LONG_CNT:return Ur.create(lm(e.type),Ur.valueFromBytes(lm(e.type),e.value),Pe(e.createdAt))}}function Ap(e){return no.of(zo.of(Pe(e.createdAt),e.offset),e.relativeOffset)}function QP(e){return zo.of(Pe(e.createdAt),e.offset)}function GKe(e){const t=ph.create(e.value);Object.entries(e.attributes).forEach(([r,i])=>{t.setAttr(r,i.value,Pe(i.updatedAt))});const n=yu.create(QP(e.id),t);return n.remove(Pe(e.removedAt)),n}function hc(e){return Xi.of(L0(e.parentId),L0(e.leftSiblingId))}function L0(e){return Fn.of(Pe(e.createdAt),e.offset)}function JKe(e){if(!e.length)return;const t=[];return e.forEach(n=>{const r=GC(n.content);t.push(r)}),t}function GC(e){if(e.length===0)return;const t=[];for(const i of e)t.push(YKe(i));const n=t[t.length-1],r=new Map;r.set(e[t.length-1].depth,t[t.length-1]);for(let i=t.length-2;i>=0;i--)r.get(e[i].depth-1).prepend(t[i]),r.set(e[i].depth,t[i]);return n.updateDescendantsSize(),Pi.create(n,to).getRoot()}function WKe(e){const t=Ds.create();for(const[n,r]of Object.entries(e))t.setInternal(n,r.value,Pe(r.updatedAt),r.isRemoved);return t}function YKe(e){const t=L0(e.id),n=Nr.create(t,e.type),r=Object.entries(e.attributes);return n.isText?n.value=e.value:r.length&&(n.attrs=WKe(e.attributes)),e.insPrevId&&(n.insPrevID=L0(e.insPrevId)),e.insNextId&&(n.insNextID=L0(e.insNextId)),n.removedAt=Pe(e.removedAt),n}function eB(e){if(e.body.case==="set"){const t=e.body.value;return Tl.create(t.key,i2(t.value),Pe(t.parentCreatedAt),Pe(t.executedAt))}else if(e.body.case==="add"){const t=e.body.value;return _h.create(Pe(t.parentCreatedAt),Pe(t.prevCreatedAt),i2(t.value),Pe(t.executedAt))}else if(e.body.case==="move"){const t=e.body.value;return au.create(Pe(t.parentCreatedAt),Pe(t.prevCreatedAt),Pe(t.createdAt),Pe(t.executedAt))}else if(e.body.case==="remove"){const t=e.body.value;return Tu.create(Pe(t.parentCreatedAt),Pe(t.createdAt),Pe(t.executedAt))}else if(e.body.case==="edit"){const t=e.body.value,n=new Map;Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{n.set(i,Pe(o))});const r=new Map;return Object.entries(t.attributes).forEach(([i,o])=>{r.set(i,o)}),Nh.create(Pe(t.parentCreatedAt),Ap(t.from),Ap(t.to),n,t.content,r,Pe(t.executedAt))}else if(e.body.case==="style"){const t=e.body.value,n=new Map;Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{n.set(i,Pe(o))});const r=new Map;return Object.entries(t.attributes).forEach(([i,o])=>{r.set(i,o)}),zh.create(Pe(t.parentCreatedAt),Ap(t.from),Ap(t.to),n,r,Pe(t.executedAt))}else{if(e.body.case==="select")return;if(e.body.case==="increase"){const t=e.body.value;return fd.create(Pe(t.parentCreatedAt),i2(t.value),Pe(t.executedAt))}else if(e.body.case==="treeEdit"){const t=e.body.value,n=new Map;return Object.entries(t.createdAtMapByActor).forEach(([r,i])=>{n.set(r,Pe(i))}),Hh.create(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),JKe(t.contents),t.splitLevel,n,Pe(t.executedAt))}else if(e.body.case==="treeStyle"){const t=e.body.value,n=new Map,r=t.attributesToRemove,i=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([o,a])=>{i.set(o,Pe(a))}),(r==null?void 0:r.length)>0?ys.createTreeRemoveStyleOperation(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),i,r,Pe(t.executedAt)):(Object.entries(t.attributes).forEach(([o,a])=>{n.set(o,a)}),ys.create(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),i,n,Pe(t.executedAt)))}else throw new Y(J.ErrUnimplemented,"unimplemented operation")}}function qKe(e){const t=[];for(const n of e){const r=eB(n);r&&t.push(r)}return t}function tB(e){const t=[];for(const n of e)t.push(dd.create({id:XP(n.id),operations:qKe(n.operations),presenceChange:n.presenceChange?KKe(n.presenceChange):void 0,message:n.message}));return t}function XKe(e){return Uc.of(BigInt(e.serverSeq),e.clientSeq)}function ZKe(e){return b1.create(e.documentKey,XKe(e.checkpoint),e.isRemoved,tB(e.changes),KC(e.versionVector),e.snapshot,Pe(e.minSyncedTicket))}function nB(e){const t=new dh;for(const r of e.nodes){const i=JC(r.element);t.set(r.key,i,i.getPositionedAt())}const n=new wr(Pe(e.createdAt),t);return n.setMovedAt(Pe(e.movedAt)),n.setRemovedAt(Pe(e.removedAt)),n}function rB(e){const t=new fh;for(const r of e.nodes)t.insert(JC(r.element));const n=new jr(Pe(e.createdAt),t);return n.setMovedAt(Pe(e.movedAt)),n.setRemovedAt(Pe(e.removedAt)),n}function QKe(e){const t=Jt.of(Jt.valueFromBytes(ZP(e.type),e.value),Pe(e.createdAt));return t.setMovedAt(Pe(e.movedAt)),t.setRemovedAt(Pe(e.removedAt)),t}function eVe(e){const t=new hd;let n=t.getHead();for(const i of e.nodes){const o=t.insertAfter(n,GKe(i));i.insPrevId&&o.setInsPrev(t.findNode(QP(i.insPrevId))),n=o}const r=new Ti(t,Pe(e.createdAt));return r.setMovedAt(Pe(e.movedAt)),r.setRemovedAt(Pe(e.removedAt)),r}function tVe(e){const t=Ur.create(lm(e.type),Ur.valueFromBytes(lm(e.type),e.value),Pe(e.createdAt));return t.setMovedAt(Pe(e.movedAt)),t.setRemovedAt(Pe(e.removedAt)),t}function iB(e){const t=GC(e.nodes);return Pi.create(t,Pe(e.createdAt))}function JC(e){if(e.body.case==="jsonObject")return nB(e.body.value);if(e.body.case==="jsonArray")return rB(e.body.value);if(e.body.case==="primitive")return QKe(e.body.value);if(e.body.case==="text")return eVe(e.body.value);if(e.body.case==="counter")return tVe(e.body.value);if(e.body.case==="tree")return iB(e.body.value);throw new Y(J.ErrUnimplemented,"unimplemented element")}function nVe(e){if(!e)return{root:wr.create(to),presences:new Map};const t=Wy.fromBinary(e);return{root:JC(t.root),presences:VKe(t.presences)}}function rVe(e){const t=HC(e);return WC(t.toBinary())}function iVe(e){const t=qC(e),n=E1.fromBinary(t);return KC(n)}function oB(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return nB(t.body.value)}function aB(e){return UC(e).toBinary()}function oVe(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return rB(t.body.value)}function aVe(e){return YP(e).toBinary()}function sVe(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return iB(t.body.value)}function uVe(e){return qP(e).toBinary()}function WC(e){return e?Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function YC(e){return WC(e)}function qC(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function XC(e){return qC(e)}function lVe(e){const t=y1.fromBinary(e);return XP(t)}function cVe(e){const t=FC.fromBinary(e);return eB(t)}const on={fromPresence:VC,toChangePack:UKe,fromChangePack:ZKe,fromChanges:tB,toTreeNodes:jC,fromTreeNodes:GC,objectToBytes:aB,bytesToObject:oB,bytesToSnapshot:nVe,bytesToHex:WC,hexToBytes:qC,toHexString:YC,toUint8Array:XC,toOperation:WP,toChangeID:VP,PbChangeID:y1,bytesToChangeID:lVe,bytesToOperation:cVe,versionVectorToHex:rVe,hexToVersionVector:iVe};var or=(e=>(e[e.Trivial=0]="Trivial",e[e.Debug=1]="Debug",e[e.Info=2]="Info",e[e.Warn=3]="Warn",e[e.Error=4]="Error",e[e.Fatal=5]="Fatal",e))(or||{});let tl=3;function sB(e){tl=e}const $e={trivial:(...e)=>{tl>0||typeof console<"u"&&console.log("YORKIE T:",...e)},debug:(...e)=>{tl>1||typeof console<"u"&&console.log("YORKIE D:",...e)},info:(...e)=>{tl>2||typeof console<"u"&&console.log("YORKIE I:",...e)},warn:(...e)=>{tl>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...e):console.log("YORKIE W:",...e))},error:(...e)=>{tl>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...e):console.log("YORKIE E:",...e))},fatal:(...e)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...e):console.log("YORKIE F:",...e))},isEnabled:e=>tl<=e};function uB(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class dVe{constructor(t,n,r,i,o){k(this,"reconnectStreamDelay");k(this,"doc");k(this,"docID");k(this,"syncMode");k(this,"remoteChangeEventReceived");k(this,"watchStream");k(this,"watchLoopTimerID");k(this,"watchAbortController");k(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=n,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=o}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===Xp.RealtimeSyncOff?!1:this.syncMode===Xp.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Xp.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const n=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(n,this.reconnectStreamDelay)})}catch{}};await n()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const o2=()=>{};class hVe{constructor(t){k(this,"finalized",!1);k(this,"observers",[]);k(this,"finalError");try{t(this)}catch(n){this.error(n)}}next(t){this.forEachObserver(n=>{n.next(t)})}error(t){this.forEachObserver(n=>{n.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,n,r){let i;if(!t)throw new Y(J.ErrInvalidArgument,"missing observer");if(this.finalized)throw new Y(J.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?i=t:i={next:t,error:n,complete:r},i.next===void 0&&(i.next=o2),i.error===void 0&&(i.error=o2),i.complete===void 0&&(i.complete=o2);const o=uB(),a=this.unsubscribeOne.bind(this,o);if(this.observers.push({subscriptionID:o,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(s){$e.warn(s)}return a}unsubscribeOne(t){var n;this.observers=(n=this.observers)==null?void 0:n.filter(r=>r.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let n=0;nt}}class Pc{constructor(t,n,r,i){k(this,"id");k(this,"delimiter");k(this,"message");k(this,"root");k(this,"operations");k(this,"presenceChange");k(this,"previousPresence");k(this,"reversePresenceKeys");this.id=t,this.delimiter=RP,this.root=n,this.operations=[],this.previousPresence=Gi(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(t,n,r,i){return new Pc(t,n,r,i)}push(t){this.operations.push(t)}registerElement(t,n){this.root.registerElement(t,n)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return dd.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,n){for(const r of Object.keys(t))n!=null&&n.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const n of this.reversePresenceKeys)t[n]=this.previousPresence[n];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class gh{constructor(t){k(this,"rootObject");k(this,"elementPairMapByCreatedAt");k(this,"gcElementSetByCreatedAt");k(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(n=>{if(n.getRemovedAt()&&this.registerRemovedElement(n),n instanceof Ti||n instanceof Pi)for(const r of n.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new gh(wr.create(to))}findByCreatedAt(t){const n=this.elementPairMapByCreatedAt.get(t.toIDString());if(n)return n.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let n=this.elementPairMapByCreatedAt.get(t.toIDString());if(!n)return[];const r=[];for(;n.parent;){const i=n.element.getCreatedAt(),o=n.parent.subPathOf(i);if(o===void 0)throw new Y(J.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(o),n=this.elementPairMapByCreatedAt.get(n.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,n){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:n,element:t}),t instanceof vu&&t.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(t){let n=0;const r=i=>{const o=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(o),this.gcElementSetByCreatedAt.delete(o),n++};return r(t),t instanceof vu&&t.getDescendants(i=>(r(i),!1)),n}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const n of this.gcElementSetByCreatedAt){t.add(n);const r=this.elementPairMapByCreatedAt.get(n);r.element instanceof vu&&r.element.getDescendants(i=>(t.add(i.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new gh(this.rootObject.deepcopy())}garbageCollect(t){let n=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),o=i.element.getRemovedAt();o&&(t!=null&&t.afterOrEqual(o))&&(i.parent.purge(i.element),n+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(t!=null&&t.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),n+=1)}return n}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function lB(e,t){const n=new mh(e);return new Proxy(t,n.getHandlers())}class mh{constructor(t){k(this,"context");k(this,"handlers");this.context=t,this.handlers={set:(n,r,i)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]=${JSON.stringify(i)}`),mh.setInternal(t,n,r,i),!0),get:(n,r)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]`),r==="getID"?()=>n.getCreatedAt():r==="toJSON"||r==="toString"?()=>n.toJSON():r==="toJS"?()=>n.toJS():r==="toJSForTest"?()=>n.toJSForTest():nl(t,n.get(r))),ownKeys:n=>n.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(n,r)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]`),mh.deleteInternal(t,n,r),!0)}}static setInternal(t,n,r,i){if(r.includes("."))throw new Y(J.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),a=cm(t,i,o),s=n.set(r,a,o);t.registerElement(a,n),s&&t.registerRemovedElement(s),t.push(Tl.create(r,a.deepcopy(),n.getCreatedAt(),o))}static buildObjectMembers(t,n){const r={};for(const[i,o]of Object.entries(n)){if(i.includes("."))throw new Y(J.ErrInvalidObjectKey,"key must not contain the '.'.");const a=t.issueTimeTicket(),s=cm(t,o,a);r[i]=s}return r}static deleteInternal(t,n,r){const i=t.issueTimeTicket(),o=n.deleteByKey(r,i);o&&(t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o))}getHandlers(){return this.handlers}}function pVe(e,t){const n=new Xt(e,t);return new Proxy(t,n.getHandlers())}function gVe(e){return typeof e=="string"||e instanceof String?!isNaN(e):!1}function mVe(e){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(e)}class Xt{constructor(t,n){k(this,"context");k(this,"handlers");k(this,"array");this.context=t,this.array=n,this.handlers={get:(r,i,o)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?a=>{const s=r.getByID(a);if(!(!s||s.isRemoved()))return Xs(t,s)}:i==="getElementByIndex"?a=>{const s=r.get(a);return Xs(t,s)}:i==="getLast"?()=>Xs(t,r.getLast()):i==="deleteByID"?a=>{const s=Xt.deleteInternalByID(t,r,a);return Xs(t,s)}:i==="insertAfter"?(a,s)=>{const u=Xt.insertAfterInternal(t,r,a,s);return Xs(t,u)}:i==="insertBefore"?(a,s)=>{const u=Xt.insertBeforeInternal(t,r,a,s);return Xs(t,u)}:i==="moveBefore"?(a,s)=>{Xt.moveBeforeInternal(t,r,a,s)}:i==="moveAfter"?(a,s)=>{Xt.moveAfterInternal(t,r,a,s)}:i==="moveFront"?a=>{Xt.moveFrontInternal(t,r,a)}:i==="moveLast"?a=>{Xt.moveLastInternal(t,r,a)}:gVe(i)?nl(t,r.get(Number(i))):i==="push"?a=>Xt.pushInternal(t,r,a):i==="splice"?(a,s,...u)=>Xt.splice(t,r,a,s,...u):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?Xt.iteratorInternal.bind(this,t,r):i==="includes"?(a,s)=>Xt.includes(t,r,a,s):i==="indexOf"?(a,s)=>Xt.indexOf(t,r,a,s):i==="lastIndexOf"?(a,s)=>Xt.lastIndexOf(t,r,a,s):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>Xt.toTestString(r):typeof i=="string"&&mVe(i)?(...a)=>{const s=Array.from(r).map(u=>nl(t,u));return Array.prototype[i].apply(s,a)}:Reflect.get(r,i,o),deleteProperty:(r,i)=>($e.isEnabled(or.Trivial)&&$e.trivial(`array[${i}]`),Xt.deleteInternalByIndex(t,r,Number.parseInt(i)),!0)}}static*iteratorInternal(t,n){for(const r of n)yield Xs(t,r)}static buildArrayElements(t,n){const r=[];for(const i of n){const o=t.issueTimeTicket(),a=cm(t,i,o);r.push(a)}return r}static pushInternal(t,n,r){return Xt.insertAfterInternal(t,n,n.getLastCreatedAt(),r),n.length}static moveBeforeInternal(t,n,r,i){const o=t.issueTimeTicket(),a=n.getPrevCreatedAt(r);n.moveAfter(a,i,o),t.push(au.create(n.getCreatedAt(),a,i,o))}static moveAfterInternal(t,n,r,i){const o=t.issueTimeTicket();n.moveAfter(r,i,o),t.push(au.create(n.getCreatedAt(),r,i,o))}static moveFrontInternal(t,n,r){const i=t.issueTimeTicket(),o=n.getHead();n.moveAfter(o.getCreatedAt(),r,i),t.push(au.create(n.getCreatedAt(),o.getCreatedAt(),r,i))}static moveLastInternal(t,n,r){const i=t.issueTimeTicket(),o=n.getLastCreatedAt();n.moveAfter(o,r,i),t.push(au.create(n.getCreatedAt(),o,r,i))}static insertAfterInternal(t,n,r,i){const o=t.issueTimeTicket(),a=cm(t,i,o);return n.insertAfter(r,a),t.registerElement(a,n),t.push(_h.create(n.getCreatedAt(),r,a.deepcopy(),o)),a}static insertBeforeInternal(t,n,r,i){return Xt.insertAfterInternal(t,n,n.getPrevCreatedAt(r),i)}static deleteInternalByIndex(t,n,r){const i=t.issueTimeTicket(),o=n.deleteByIndex(r,i);if(o)return t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o),o}static deleteInternalByID(t,n,r){const i=t.issueTimeTicket(),o=n.delete(r,i);return t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o),o}static splice(t,n,r,i,...o){const a=n.length,s=r>=0?Math.min(r,a):Math.max(a+r,0),u=i===void 0?a:i<0?s:Math.min(s+i,a),d=[];for(let h=s;h=o)return!1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).includes(r,a);for(let u=a;u=o)return-1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).indexOf(r,a);for(let u=a;u=o?o-1:i<0?i+o:i;if(a<0)return-1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).lastIndexOf(r,a);for(let u=a;u>0;u--)if(((s=n.get(u))==null?void 0:s.getID())===r.getID())return u;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}class w1{constructor(t,n){k(this,"context");k(this,"text");this.context=t,this.text=n}initialize(t,n){this.context=t,this.text=n}getID(){return this.text.getID()}edit(t,n,r,i){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.text.indexRangeToPosRange(t,n);$e.isEnabled(or.Debug)&&$e.debug(`EDIT: f:${t}->${o[0].toTestString()}, t:${n}->${o[1].toTestString()} c:${r}`);const a=i?ld(i):void 0,s=this.context.issueTimeTicket(),[u,,d,h]=this.text.edit(o,r,s,a);for(const p of d)this.context.registerGCPair(p);return this.context.push(new Nh(this.text.getCreatedAt(),o[0],o[1],u,r,a?new Map(Object.entries(a)):new Map,s)),this.text.findIndexesFromRange(h)}delete(t,n){return this.edit(t,n,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,n,r){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(t,n);$e.isEnabled(or.Debug)&&$e.debug(`STYL: f:${t}->${i[0].toTestString()}, t:${n}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const o=ld(r),a=this.context.issueTimeTicket(),[s,u]=this.text.setStyle(i,o,a);for(const d of u)this.context.registerGCPair(d);return this.context.push(new zh(this.text.getCreatedAt(),i[0],i[1],s,new Map(Object.entries(o)),a)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");const n=this.text.indexRangeToPosRange(t[0],t[1]);return[n[0].toStruct(),n[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");const n=this.text.findIndexesFromRange([no.fromStruct(t[0]),no.fromStruct(t[1])]);return[n[0],n[1]]}toTestString(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,n){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,n)}}class S1{constructor(t,n){k(this,"valueType");k(this,"value");k(this,"context");k(this,"counter");this.valueType=t,this.value=n}initialize(t,n){this.valueType=n.getValueType(),this.context=t,this.counter=n,this.value=n.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new Y(J.ErrNotInitialized,"Counter is not initialized yet");const n=this.context.issueTimeTicket(),r=Jt.of(t,n);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(fd.create(this.counter.getCreatedAt(),r,n)),this}toJSForTest(){if(!this.context||!this.counter)throw new Y(J.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function ZC(e,t,n){const{type:r}=e,i=n.issueTimeTicket();if(r===vs){cB(e);const{value:o}=e,a=Nr.create(Fn.of(i,0),r,o);t.append(a)}else{const{children:o=[]}=e,{attributes:a}=e;let s;if(typeof a=="object"&&!$P(a)){const d=ld(a);s=new Ds;for(const[h,p]of Object.entries(d))s.set(h,p,i)}const u=Nr.create(Fn.of(i,0),r,void 0,s);t.append(u);for(const d of o)ZC(d,u,n)}}function vVe(e,t){const{type:n}=t,r=e.issueTimeTicket();let i;if(t.type===vs){const{value:o}=t;i=Nr.create(Fn.of(r,0),n,o)}else if(t){const{children:o=[]}=t,{attributes:a}=t;let s;if(typeof a=="object"&&!$P(a)){const u=ld(a);s=new Ds;for(const[d,h]of Object.entries(u))s.set(d,h,r)}i=Nr.create(Fn.of(e.issueTimeTicket(),0),n,void 0,s);for(const u of o)ZC(u,i,e)}return i}function cB(e){if(!e.value.length)throw new Y(J.ErrInvalidArgument,"text node cannot have empty value");return!0}function Mx(e){if(!e.length)return!0;if(e[0].type===vs)for(const n of e){const{type:r}=n;if(r!==vs)throw new Y(J.ErrInvalidArgument,"element node and text node cannot be passed together");cB(n)}else for(const n of e){const{type:r}=n;if(r===vs)throw new Y(J.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class x1{constructor(t){k(this,"initialRoot");k(this,"context");k(this,"tree");this.initialRoot=t}initialize(t,n){this.context=t,this.tree=n}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return Nr.create(Fn.of(t.issueTimeTicket(),0),gKe);const n=Nr.create(Fn.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)ZC(r,n,t);return n}getSize(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,n){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(t),o=this.context.issueTimeTicket(),a=n?ld(n):void 0,[s]=this.tree.style([r,i],a,o);this.context.push(ys.create(this.tree.getCreatedAt(),r,i,s,a?new Map(Object.entries(a)):new Map,o))}style(t,n,r){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(n),a=this.context.issueTimeTicket(),s=r?ld(r):void 0,[u,d]=this.tree.style([i,o],s,a);for(const h of d)this.context.registerGCPair(h);this.context.push(ys.create(this.tree.getCreatedAt(),i,o,u,s?new Map(Object.entries(s)):new Map,a))}removeStyle(t,n,r){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(n),a=this.context.issueTimeTicket(),[s,u]=this.tree.removeStyle([i,o],r,a);for(const d of u)this.context.registerGCPair(d);this.context.push(ys.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,o,s,r,a))}editInternal(t,n,r,i=0){var d;if(r.length!==0&&r[0]&&(Mx(r),r[0].type!==vs))for(const h of r){const{children:p=[]}=h;Mx(p)}const o=this.context.getLastTimeTicket();let a=new Array;if(((d=r[0])==null?void 0:d.type)===vs){let h="";for(const p of r){const{value:g}=p;h+=g}a.push(Nr.create(Fn.of(this.context.issueTimeTicket(),0),vs,h))}else a=r.map(h=>h&&vVe(this.context,h)).filter(h=>h);const[,s,u]=this.tree.edit([t,n],a.length?a.map(h=>h==null?void 0:h.deepcopy()):void 0,i,o,()=>this.context.issueTimeTicket());for(const h of s)this.context.registerGCPair(h);return this.context.push(Hh.create(this.tree.getCreatedAt(),t,n,a.length?a:void 0,i,u,o)),!0}editByPath(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==n.length)throw new Y(J.ErrInvalidArgument,"path length should be equal");if(!t.length||!n.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),a=this.tree.pathToPos(n);return this.editInternal(o,a,r?[r]:[],i)}editBulkByPath(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==n.length)throw new Y(J.ErrInvalidArgument,"path length should be equal");if(!t.length||!n.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),a=this.tree.pathToPos(n);return this.editInternal(o,a,r,i)}edit(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),a=this.tree.findPos(n);return this.editInternal(o,a,r?[r]:[],i)}editBulk(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),a=this.tree.findPos(n);return this.editInternal(o,a,r,i)}toXML(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],r=this.tree.indexRangeToPosRange(n);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[Xi.fromStruct(t[0]),Xi.fromStruct(t[1])];return this.tree.posRangeToIndexRange(n)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[Xi.fromStruct(t[0]),Xi.fromStruct(t[1])];return this.tree.posRangeToPathRange(n)}}function $x(e,t){return lB(e,t)}function Xs(e,t){if(t){if(t instanceof Jt)return t;if(t instanceof wr)return lB(e,t);if(t instanceof jr)return pVe(e,t);if(t instanceof Ti)return new w1(e,t);if(t instanceof Ur){const n=new S1(Ko.IntegerCnt,0);return n.initialize(e,t),n}else if(t instanceof Pi){const n=new x1;return n.initialize(e,t),n}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function nl(e,t){const n=Xs(e,t);return n instanceof Jt?n.getValue():n}function cm(e,t,n){let r;if(Jt.isSupport(t))r=Jt.of(t,n);else if(Array.isArray(t))r=jr.create(n,Xt.buildArrayElements(e,t));else if(typeof t=="object")t instanceof w1?(r=Ti.create(hd.create(),n),t.initialize(e,r)):t instanceof S1?(r=Ur.create(t.getValueType(),t.getValue(),n),t.initialize(e,r)):t instanceof x1?(r=Pi.create(t.buildRoot(e),n),t.initialize(e,r)):r=wr.create(n,mh.buildObjectMembers(e,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return r}const Rx=50;class yVe{constructor(){k(this,"undoStack",[]);k(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Rx&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Rx&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const EVe="yorkie-devtools-panel",CVe="yorkie-devtools-sdk";let pc="disconnected";const Fx=new Map,qp=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=qp);function kp(e,t){(t!=null&&t.force||pc!=="disconnected")&&window.postMessage({source:CVe,...e},"*")}function bVe(e){if(!e.isEnableDevtools()||typeof window>"u"||Fx.has(e.getKey()))return;qp.set(e.getKey(),[]);const t=e.subscribe("all",n=>{n.some(r=>r.type!==bn.StatusChanged&&r.type!==bn.Snapshot&&r.type!==bn.LocalChange&&r.type!==bn.RemoteChange&&r.type!==bn.Initialized&&r.type!==bn.Watched&&r.type!==bn.Unwatched&&r.type!==bn.PresenceChanged)||(qp.get(e.getKey()).push(n),pc==="synced"&&kp({msg:"doc::sync::partial",docKey:e.getKey(),event:n}))});Fx.set(e.getKey(),[t]),kp({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",n=>{var i;if(((i=n.data)==null?void 0:i.source)!==EVe)return;switch(n.data.msg){case"devtools::connect":if(pc!=="disconnected")break;pc="connected",kp({msg:"doc::available",docKey:e.getKey()}),$e.info(`[YD] Devtools connected. Doc: ${e.getKey()}`);break;case"devtools::disconnect":pc="disconnected",$e.info(`[YD] Devtools disconnected. Doc: ${e.getKey()}`);break;case"devtools::subscribe":pc="synced",kp({msg:"doc::sync::full",docKey:e.getKey(),events:qp.get(e.getKey())}),$e.info(`[YD] Devtools subscribed. Doc: ${e.getKey()}`);break}})}var Zs=(e=>(e.Detached="detached",e.Attached="attached",e.Removed="removed",e))(Zs||{}),bn=(e=>(e.StatusChanged="status-changed",e.ConnectionChanged="connection-changed",e.SyncStatusChanged="sync-status-changed",e.Snapshot="snapshot",e.LocalChange="local-change",e.RemoteChange="remote-change",e.Initialized="initialized",e.Watched="watched",e.Unwatched="unwatched",e.PresenceChanged="presence-changed",e.Broadcast="broadcast",e.LocalBroadcast="local-broadcast",e.AuthError="auth-error",e))(bn||{}),C3=(e=>(e.Connected="connected",e.Disconnected="disconnected",e))(C3||{}),b3=(e=>(e.Synced="synced",e.SyncFailed="sync-failed",e))(b3||{});class QC{constructor(t,n){k(this,"key");k(this,"status");k(this,"opts");k(this,"changeID");k(this,"checkpoint");k(this,"localChanges");k(this,"root");k(this,"clone");k(this,"eventStream");k(this,"eventStreamObserver");k(this,"onlineClients");k(this,"presences");k(this,"history");k(this,"internalHistory");k(this,"isUpdating");this.opts=n||{},this.key=t,this.status="detached",this.root=gh.create(),this.changeID=xKe,this.checkpoint=AKe,this.localChanges=[],this.eventStream=fVe(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new yVe,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},bVe(this)}update(t,n){if(this.getStatus()==="removed")throw new Y(J.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},n);try{const o=$x(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,t(o,new n2(i,this.clone.presences.get(r)))}catch(o){throw this.clone=void 0,o}finally{this.isUpdating=!1}if(i.hasChange()){$e.isEnabled(or.Trivial)&&$e.trivial(`trying to update a local change: ${this.toJSON()}`);const o=i.getChange(),{opInfos:a,reverseOps:s}=o.execute(this.root,this.presences,xt.Local),u=i.getReversePresence();u&&s.push({type:"presence",value:u}),this.localChanges.push(o),s.length>0&&this.internalHistory.pushUndo(s),a.length>0&&this.internalHistory.clearRedo(),this.changeID=o.getID();const d=[];a.length>0&&d.push({type:"local-change",source:xt.Local,value:{message:o.getMessage()||"",operations:a,actor:r,clientSeq:o.getID().getClientSeq(),serverSeq:o.getID().getServerSeq()},rawChange:this.isEnableDevtools()?o.toStruct():void 0}),o.hasPresenceChange()&&d.push({type:"presence-changed",source:xt.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(d),$e.isEnabled(or.Trivial)&&$e.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,n,r,i){if(typeof t=="string"){if(typeof n!="function")throw new Y(J.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="initialized"&&d.type!=="watched"&&d.type!=="unwatched"&&d.type!=="presence-changed"||s(d)},r,i)}if(t==="my-presence"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="initialized"&&d.type!=="presence-changed"||d.type==="presence-changed"&&d.value.clientID!==this.changeID.getActorID()||s(d)},r,i)}if(t==="others"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="watched"&&d.type!=="unwatched"&&d.type!=="presence-changed"||d.value.clientID!==this.changeID.getActorID()&&s(d)},r,i)}if(t==="connection"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="connection-changed"&&s(d)},r,i)}if(t==="status"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="status-changed"&&s(d)},r,i)}if(t==="sync"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="sync-status-changed"&&s(d)},r,i)}if(t==="local-broadcast"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="local-broadcast"&&s(d)},r)}if(t==="broadcast"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="broadcast"&&s(d)},r)}if(t==="auth-error"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="auth-error"&&s(d)},r)}if(t==="all"){const s=n;return this.eventStream.subscribe(s,r,i)}const o=t,a=n;return this.eventStream.subscribe(s=>{for(const u of s){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const d=[];for(const h of u.value.operations)this.isSameElementOrChildOf(h.path,o)&&d.push(h);d.length&&a({...u,value:{...u.value,operations:d}})}},r,i)}if(typeof t=="function"){const o=t,a=n,s=r;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="snapshot"&&d.type!=="local-change"&&d.type!=="remote-change"||o(d)},a,s)}throw new Y(J.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,n){if(n===t)return!0;const r=t.split(".");return n.split(".").every((o,a)=>o===r[a])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const n=t.hasSnapshot();n?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),xt.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),n||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),$e.isEnabled(or.Trivial)&&$e.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Gi(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),n=this.checkpoint.increaseClientSeq(t.length);return b1.create(this.key,n,!1,t,this.getVersionVector())}setActor(t){for(const n of this.localChanges)n.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return $x(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,n,r,i=-1){const{root:o,presences:a}=on.bytesToSnapshot(r);this.root=new gh(o),this.presences=a,this.changeID=this.changeID.setClocks(t,n),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,xt.Local),this.publish([{type:"snapshot",source:xt.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?on.bytesToHex(r):void 0,snapshotVector:on.versionVectorToHex(n)}}])}applyChanges(t,n){$e.isEnabled(or.Debug)&&$e.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),$e.isEnabled(or.Trivial)&&$e.trivial(t.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` -`));for(const r of t)this.applyChange(r,n);$e.isEnabled(or.Debug)&&$e.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,n){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,n);const r=[],i=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(i)){const a=t.getPresenceChange();switch(a.type){case Du.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:n,value:{clientID:i,presence:a.presence}}:{type:"watched",source:xt.Remote,value:{clientID:i,presence:a.presence}});break;case Du.Clear:r.push({type:"unwatched",source:xt.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:o}=t.execute(this.root,this.presences,n);if(this.changeID=this.changeID.syncClocks(t.getID()),o.length>0){const a=this.isEnableDevtools()?t.toStruct():void 0;r.push(n===xt.Remote?{type:"remote-change",source:n,value:{actor:i,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:a}:{type:"local-change",source:n,value:{actor:i,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:a})}r.length>0&&this.publish(r)}applyWatchStream(t){if(t.body.case==="initialization"){const n=t.body.value.clientIds,r=new Set;for(const i of n)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:xt.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:n,publisher:r}=t.body.value,i=[];if(n===ml.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:xt.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(n===ml.DOCUMENT_UNWATCHED){const o=this.getPresence(r);this.removeOnlineClient(r),o&&i.push({type:"unwatched",source:xt.Remote,value:{clientID:r,presence:o}})}else if(n===ml.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:o,payload:a}=t.body.value.body,s=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:o,payload:JSON.parse(s.decode(a))}})}i.length>0&&this.publish(i)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(OC),this.publish([{source:t==="removed"?xt.Remote:xt.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:n,serverSeq:r,snapshotVector:i}=t.value;if(!n)return;this.applySnapshot(BigInt(r),on.hexToVersionVector(i),on.hexToBytes(n));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const n=dd.fromStruct(t.rawChange);this.applyChange(n,t.source)}if(t.type==="initialized"){const n=new Set;for(const{clientID:r,presence:i}of t.value)n.add(r),this.presences.set(r,i);this.setOnlineClients(n);return}if(t.type==="watched"){const{clientID:n,presence:r}=t.value;this.addOnlineClient(n),this.presences.set(n,r);return}if(t.type==="unwatched"){const{clientID:n}=t.value;this.removeOnlineClient(n),this.presences.delete(n)}if(t.type==="presence-changed"){const{clientID:n,presence:r}=t.value;this.presences.set(n,r)}}applyTransactionEvent(t){for(const n of t)this.applyDocEvent(n)}getValueByPath(t){if(!t.startsWith("$"))throw new Y(J.ErrInvalidArgument,'path must start with "$"');const n=t.split(".");n.shift();let r=this.getRoot();for(const i of n)if(r=r[i],r===void 0)return;return r}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?Gi(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const n=this.presences.get(t);return n?Gi(n):void 0}getPresenceForTest(t){const n=this.presences.get(t);return n?Gi(n):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:Gi(this.getMyPresence())});for(const n of this.onlineClients)this.presences.has(n)&&t.push({clientID:n,presence:Gi(this.presences.get(n))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(n=>n.clientID!==t).sort((n,r)=>n.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const r=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new Y(J.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new Y(J.ErrRefused,"There is no operation to be undone");this.ensureClone();const n=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const d of t){if(!(d instanceof so)){new n2(n,Gi(this.clone.presences.get(this.changeID.getActorID()))).set(d.value,{addToHistory:!0});continue}const h=n.issueTimeTicket();d.setExecutedAt(h),n.push(d)}const r=n.getChange();r.execute(this.clone.root,this.clone.presences,xt.UndoRedo);const{opInfos:i,reverseOps:o}=r.execute(this.root,this.presences,xt.UndoRedo),a=n.getReversePresence();if(a&&o.push({type:"presence",value:a}),o.length>0&&this.internalHistory.pushRedo(o),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const s=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:xt.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:s,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:xt.UndoRedo,value:{clientID:s,presence:this.getPresence(s)}}),this.publish(u)}redo(){if(this.isUpdating)throw new Y(J.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new Y(J.ErrRefused,"There is no operation to be redone");this.ensureClone();const n=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const d of t){if(!(d instanceof so)){new n2(n,Gi(this.clone.presences.get(this.changeID.getActorID()))).set(d.value,{addToHistory:!0});continue}const h=n.issueTimeTicket();d.setExecutedAt(h),n.push(d)}const r=n.getChange();r.execute(this.clone.root,this.clone.presences,xt.UndoRedo);const{opInfos:i,reverseOps:o}=r.execute(this.root,this.presences,xt.UndoRedo),a=n.getReversePresence();if(a&&o.push({type:"presence",value:a}),o.length>0&&this.internalHistory.pushUndo(o),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const s=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:xt.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:s,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:xt.UndoRedo,value:{clientID:s,presence:this.getPresence(s)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,n,r){const i={type:"local-broadcast",value:{topic:t,payload:n},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function wVe(e,t){let n=t;return{authInterceptor:o=>async a=>(e&&a.header.set("x-api-key",e),n&&a.header.set("authorization",n),await o(a)),setToken:o=>{n=o}}}const SVe="yorkie-js-sdk",xVe="0.5.6",AVe="Yorkie JS SDK",kVe="./src/yorkie.ts",IVe={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},DVe=["dist"],TVe={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},PVe={node:">=18.0.0",npm:">=7.1.0"},BVe={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},MVe={name:"hackerwins",email:"susukang98@gmail.com"},$Ve="Apache-2.0",RVe={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},FVe="https://github.com/yorkie-team/yorkie-js-sdk#readme",LVe={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},OVe={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Lx={name:SVe,version:xVe,description:AVe,main:kVe,publishConfig:IVe,files:DVe,scripts:TVe,engines:PVe,repository:BVe,author:MVe,license:$Ve,bugs:RVe,homepage:FVe,devDependencies:LVe,dependencies:OVe};function _Ve(){return e=>async t=>(t.header.set("x-yorkie-user-agent",Lx.name+"/"+Lx.version),await e(t))}const NVe=e=>{try{if(JSON.stringify(e)===void 0)return!1}catch{return!1}return!0};var Xp=(e=>(e.Manual="manual",e.Realtime="realtime",e.RealtimePushOnly="realtime-pushonly",e.RealtimeSyncOff="realtime-syncoff",e))(Xp||{});const Ip={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},a2={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class e9{constructor(t,n){k(this,"id");k(this,"key");k(this,"status");k(this,"attachmentMap");k(this,"apiKey");k(this,"authTokenInjector");k(this,"conditions");k(this,"syncLoopDuration");k(this,"reconnectStreamDelay");k(this,"retrySyncLoopDelay");k(this,"rpcClient");k(this,"setAuthToken");k(this,"taskQueue");k(this,"processing",!1);k(this,"keepalive",!1);n=n||Ip,this.key=n.key?n.key:uB(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=n.apiKey||"",this.authTokenInjector=n.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=n.syncLoopDuration??Ip.syncLoopDuration,this.reconnectStreamDelay=n.reconnectStreamDelay??Ip.reconnectStreamDelay,this.retrySyncLoopDelay=n.retrySyncLoopDelay??Ip.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=wVe(this.apiKey);this.setAuthToken=i,this.rpcClient=_Ue(sKe,aKe({baseUrl:t,interceptors:[r,_Ve()],fetch:(o,a)=>{const s={...a,keepalive:this.keepalive};return fetch(o,s)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),$e.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw $e.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const n=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),$e.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw $e.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(t.keepalive){this.keepalive=!0;const r=n();return this.keepalive=!1,r}return this.enqueueTask(n)}attach(t,n={}){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==Zs.Detached)throw new Y(J.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((o,a)=>a.set(n.initialPresence||{}));const r=t.subscribe("local-broadcast",async o=>{var h;const{topic:a,payload:s}=o.value,u=(h=o.options)==null?void 0:h.error,d=o.options;try{await this.broadcast(t.getKey(),a,s,d)}catch(p){p instanceof Error&&(u==null||u(p))}}),i=n.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:on.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async o=>{const a=on.fromChangePack(o.changePack);if(t.applyChangePack(a),t.getStatus()===Zs.Removed)return t;t.applyStatus(Zs.Attached),this.attachmentMap.set(t.getKey(),new dVe(this.reconnectStreamDelay,t,o.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(t.getKey()),$e.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const s=t.getRootObject();if(n.initialRoot){const u=n.initialRoot;t.update(d=>{for(const[h,p]of Object.entries(u))if(!s.has(h)){const g=h;d[g]=p}})}return t}).catch(async o=>{throw $e.error(`[AD] c:"${this.getKey()}" err :`,o),await this.handleConnectError(o),o}))}detach(t,n={}){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((i,o)=>o.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:on.toChangePack(t.createChangePack()),removeIfNotAttached:n.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(i=>{const o=on.fromChangePack(i.changePack);return t.applyChangePack(o),t.getStatus()!==Zs.Removed&&t.applyStatus(Zs.Detached),this.detachInternal(t.getKey()),$e.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async i=>{throw $e.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(t,n){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const i=r.syncMode;return i===n?t:(r.changeSyncMode(n),n==="manual"?(r.cancelWatchStream(),t):(n==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);if(t){const n=this.attachmentMap.get(t.getKey());if(!n)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(n,"realtime").catch(async r=>{throw $e.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const n=[];for(const[,r]of this.attachmentMap)n.push(this.syncInternal(r,r.syncMode));return Promise.all(n).catch(async r=>{throw $e.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(t){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const r=on.toChangePack(t.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:n.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(i=>{const o=on.fromChangePack(i.changePack);t.applyChangePack(o),this.detachInternal(t.getKey()),$e.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async i=>{throw $e.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,n,r,i){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const o=this.attachmentMap.get(t);if(!o)throw new Y(J.ErrDocumentNotAttached,`${t} is not attached`);if(!NVe(r))throw new Y(J.ErrInvalidArgument,"payload is not serializable");const a=(i==null?void 0:i.maxRetries)??a2.maxRetries,s=a2.maxBackoff;let u=0;const d=p=>Math.min(a2.initialRetryInterval*2**p,s),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:o.docID,topic:n,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{$e.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${n}"`)}).catch(async p=>{if($e.error(`[BC] c:"${this.getKey()}" err:`,p),await this.handleConnectError(p))if(p instanceof Nt&&dc(p)===J.ErrUnauthenticated&&o.doc.publish([{type:bn.AuthError,value:{reason:f0(p).reason,method:"Broadcast"}}]),uh(),d(u-1)),$e.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${a}`);else throw $e.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),p;else throw p}));return h()}runSyncLoop(){const t=()=>{if(!this.isActive()){$e.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const n=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,n.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof Nt&&dc(i)===J.ErrUnauthenticated&&r.doc.publish([{type:bn.AuthError,value:{reason:f0(i).reason,method:"PushPull"}}]),i})));Promise.all(n).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async r=>{$e.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};$e.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const n=this.attachmentMap.get(t);if(!n)throw new Y(J.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,n.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new Y(J.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,o=this.rpcClient.watchDocument({clientId:this.id,documentId:n.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:i.signal});return n.doc.publish([{type:bn.ConnectionChanged,value:C3.Connected}]),$e.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((a,s)=>{(async()=>{try{for await(const d of o)this.handleWatchDocumentsResponse(n,d),d.body.case==="initialization"&&a([o,i])}catch(d){n.doc.resetOnlineClients(),n.doc.publish([{type:bn.Initialized,source:xt.Local,value:n.doc.getPresences()}]),n.doc.publish([{type:bn.ConnectionChanged,value:C3.Disconnected}]),$e.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(d)?(d instanceof Nt&&dc(d)===J.ErrUnauthenticated&&n.doc.publish([{type:bn.AuthError,value:{reason:f0(d).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,s(d)}})()})})}handleWatchDocumentsResponse(t,n){if(n.body.case==="event"&&n.body.value.type===ml.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(n)}deactivateInternal(){this.status="deactivated";for(const[t,n]of this.attachmentMap)this.detachInternal(t),n.doc.applyStatus(Zs.Detached)}detachInternal(t){const n=this.attachmentMap.get(t);n&&(n.cancelWatchStream(),n.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,n){const{doc:r,docID:i}=t,o=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:on.toChangePack(o),pushOnly:n==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(a=>{const s=on.fromChangePack(a.changePack);if(s.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return r;r.applyChangePack(s),t.doc.publish([{type:bn.SyncStatusChanged,value:b3.Synced}]),r.getStatus()===Zs.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),d=s.getChangeSize();return $e.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${o.getChangeSize()} pull:${d} cp:${s.getCheckpoint().toTestString()}`),r}).catch(async a=>{throw r.publish([{type:bn.SyncStatusChanged,value:b3.SyncFailed}]),$e.error(`[PP] c:"${this.getKey()}" err :`,a),a})}async handleConnectError(t){if(!(t instanceof Nt))return!1;if(t.code===vt.Canceled||t.code===vt.Unknown||t.code===vt.ResourceExhausted||t.code===vt.Unavailable)return!0;if(dc(t)===J.ErrUnauthenticated){if(this.authTokenInjector){const n=await this.authTokenInjector(f0(t).reason);this.setAuthToken(n)}return!0}return(dc(t)===J.ErrClientNotActivated||dc(t)===J.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((n,r)=>{this.taskQueue.push(()=>t().then(n).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{$e.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}Ko.IntegerCnt,Ko.LongCnt;typeof globalThis<"u"&&(globalThis.yorkie={Client:e9,Document:QC,Primitive:Jt,Text:w1,Counter:S1,Tree:x1,LogLevel:or,setLogLevel:sB,IntType:Ko.IntegerCnt,LongType:Ko.LongCnt});var w3={exports:{}};(function(e,t){(function(n,r){{var i=r();e&&e.exports&&(t=e.exports=i),t.randomColor=i}})(fc,function(){var n=null,r={};C();var i=[],o=function(I){if(I=I||{},I.seed!==void 0&&I.seed!==null&&I.seed===parseInt(I.seed,10))n=I.seed;else if(typeof I.seed=="string")n=B(I.seed);else{if(I.seed!==void 0&&I.seed!==null)throw new TypeError("The seed value must be an integer or string");n=null}var M,O,z;if(I.count!==null&&I.count!==void 0){for(var K=I.count,X=[],Z=0;ZX.length;){var pe=o(I);n!==null&&(I.seed=n),X.push(pe)}return I.count=K,X}return M=a(I),O=s(M,I),z=u(M,O,I),d([M,O,z],I)};function a(I){if(i.length>0){var M=D(I.hue),O=v(M),z=(M[1]-M[0])/i.length,K=parseInt((O-M[0])/z);i[K]===!0?K=(K+2)%i.length:i[K]=!0;var X=(M[0]+K*z)%359,Z=(M[0]+(K+1)*z)%359;return M=[X,Z],O=v(M),O<0&&(O=360+O),O}else{var M=p(I.hue);return O=v(M),O<0&&(O=360+O),O}}function s(I,M){if(M.hue==="monochrome")return 0;if(M.luminosity==="random")return v([0,100]);var O=g(I),z=O[0],K=O[1];switch(M.luminosity){case"bright":z=55;break;case"dark":z=K-10;break;case"light":K=55;break}return v([z,K])}function u(I,M,O){var z=h(I,M),K=100;switch(O.luminosity){case"dark":K=z+20;break;case"light":z=(K+z)/2;break;case"random":z=0,K=100;break}return v([z,K])}function d(I,M){switch(M.format){case"hsvArray":return I;case"hslArray":return T(I);case"hsl":var O=T(I);return"hsl("+O[0]+", "+O[1]+"%, "+O[2]+"%)";case"hsla":var z=T(I),Z=M.alpha||Math.random();return"hsla("+z[0]+", "+z[1]+"%, "+z[2]+"%, "+Z+")";case"rgbArray":return b(I);case"rgb":var K=b(I);return"rgb("+K.join(", ")+")";case"rgba":var X=b(I),Z=M.alpha||Math.random();return"rgba("+X.join(", ")+", "+Z+")";default:return E(I)}}function h(I,M){for(var O=m(I).lowerBounds,z=0;z=K&&M<=Z){var me=(pe-X)/(Z-K),Ce=X-me*K;return me*M+Ce}}return 0}function p(I){if(typeof parseInt(I)=="number"){var M=parseInt(I);if(M<360&&M>0)return[M,M]}if(typeof I=="string"){if(r[I]){var O=r[I];if(O.hueRange)return O.hueRange}else if(I.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)){var z=A(I)[0];return[z,z]}}return[0,360]}function g(I){return m(I).saturationRange}function m(I){I>=334&&I<=360&&(I-=360);for(var M in r){var O=r[M];if(O.hueRange&&I>=O.hueRange[0]&&I<=O.hueRange[1])return r[M]}return"Color not found"}function v(I){if(n===null){var M=.618033988749895,O=Math.random();return O+=M,O%=1,Math.floor(I[0]+O*(I[1]+1-I[0]))}else{var z=I[1]||1,K=I[0]||0;n=(n*9301+49297)%233280;var X=n/233280;return Math.floor(K+X*(z-K))}}function E(I){var M=b(I);function O(K){var X=K.toString(16);return X.length==1?"0"+X:X}var z="#"+O(M[0])+O(M[1])+O(M[2]);return z}function w(I,M,O){var z=O[0][0],K=O[O.length-1][0],X=O[O.length-1][1],Z=O[0][1];r[I]={hueRange:M,lowerBounds:O,saturationRange:[z,K],brightnessRange:[X,Z]}}function C(){w("monochrome",null,[[0,0],[100,0]]),w("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),w("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),w("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),w("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),w("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),w("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),w("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]])}function b(I){var M=I[0];M===0&&(M=1),M===360&&(M=359),M=M/360;var O=I[1]/100,z=I[2]/100,K=Math.floor(M*6),X=M*6-K,Z=z*(1-O),pe=z*(1-X*O),me=z*(1-(1-X)*O),Ce=256,W=256,U=256;switch(K){case 0:Ce=z,W=me,U=Z;break;case 1:Ce=pe,W=z,U=Z;break;case 2:Ce=Z,W=z,U=me;break;case 3:Ce=Z,W=pe,U=z;break;case 4:Ce=me,W=Z,U=z;break;case 5:Ce=z,W=Z,U=pe;break}var ne=[Math.floor(Ce*255),Math.floor(W*255),Math.floor(U*255)];return ne}function A(I){I=I.replace(/^#/,""),I=I.length===3?I.replace(/(.)/g,"$1$1"):I;var M=parseInt(I.substr(0,2),16)/255,O=parseInt(I.substr(2,2),16)/255,z=parseInt(I.substr(4,2),16)/255,K=Math.max(M,O,z),X=K-Math.min(M,O,z),Z=K?X/K:0;switch(K){case M:return[60*((O-z)/X%6)||0,Z,K];case O:return[60*((z-M)/X+2)||0,Z,K];case z:return[60*((M-O)/X+4)||0,Z,K]}}function T(I){var M=I[0],O=I[1]/100,z=I[2]/100,K=(2-O)*z;return[M,Math.round(O*z/(K<1?K:2-K)*1e4)/100,K/2*100]}function B(I){for(var M=0,O=0;O!==I.length&&!(M>=Number.MAX_SAFE_INTEGER);O++)M+=I.charCodeAt(O);return M}function D(I){if(isNaN(I)){if(typeof I=="string"){if(r[I]){var O=r[I];if(O.hueRange)return O.hueRange}else if(I.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)){var z=A(I)[0];return m(z).hueRange}}}else{var M=parseInt(I);if(M<360&&M>0)return m(I).hueRange}return[0,360]}return o})})(w3,w3.exports);var zVe=w3.exports;const HVe=vh(zVe),Ox=e=>{e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296};class jVe{constructor(t){this.dictionaries=void 0,this.length=void 0,this.separator=void 0,this.style=void 0,this.seed=void 0;const{length:n,separator:r,dictionaries:i,style:o,seed:a}=t;this.dictionaries=i,this.separator=r,this.length=n,this.style=o,this.seed=a}generate(){if(!this.dictionaries)throw new Error('Cannot find any dictionary. Please provide at least one, or leave the "dictionary" field empty in the config object');if(this.length<=0)throw new Error("Invalid length provided");if(this.length>this.dictionaries.length)throw new Error(`The length cannot be bigger than the number of dictionaries. + */var bi=null;try{bi=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function at(e,t,n){this.low=e|0,this.high=t|0,this.unsigned=!!n}at.prototype.__isLong__;Object.defineProperty(at.prototype,"__isLong__",{value:!0});function qn(e){return(e&&e.__isLong__)===!0}function Ax(e){var t=Math.clz32(e&-e);return e?31-t:t}at.isLong=qn;var kx={},Ix={};function _l(e,t){var n,r,i;return t?(e>>>=0,(i=0<=e&&e<256)&&(r=Ix[e],r)?r:(n=ct(e,0,!0),i&&(Ix[e]=n),n)):(e|=0,(i=-128<=e&&e<128)&&(r=kx[e],r)?r:(n=ct(e,e<0?-1:0,!1),i&&(kx[e]=n),n))}at.fromInt=_l;function wi(e,t){if(isNaN(e))return t?hs:qi;if(t){if(e<0)return hs;if(e>=LP)return NP}else{if(e<=-Tx)return yr;if(e+1>=Tx)return _P}return e<0?wi(-e,t).neg():ct(e%cd|0,e/cd|0,t)}at.fromNumber=wi;function ct(e,t,n){return new at(e,t,n)}at.fromBits=ct;var sm=Math.pow;function NC(e,t,n){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?hs:qi;if(n=n||10,n<2||360)throw Error("interior hyphen");if(r===0)return NC(e.substring(1),t,n).neg();for(var i=wi(sm(n,8)),o=qi,a=0;a>>0:this.low};he.toNumber=function(){return this.unsigned?(this.high>>>0)*cd+(this.low>>>0):this.high*cd+(this.low>>>0)};he.toString=function(t){if(t=t||10,t<2||36>>0,h=d.toString(t);if(a=u,a.isZero())return h+s;for(;h.length<6;)h="0"+h;s=""+h+s}};he.getHighBits=function(){return this.high};he.getHighBitsUnsigned=function(){return this.high>>>0};he.getLowBits=function(){return this.low};he.getLowBitsUnsigned=function(){return this.low>>>0};he.getNumBitsAbs=function(){if(this.isNegative())return this.eq(yr)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,n=31;n>0&&!(t&1<=0};he.isOdd=function(){return(this.low&1)===1};he.isEven=function(){return(this.low&1)===0};he.equals=function(t){return qn(t)||(t=co(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};he.eq=he.equals;he.notEquals=function(t){return!this.eq(t)};he.neq=he.notEquals;he.ne=he.notEquals;he.lessThan=function(t){return this.comp(t)<0};he.lt=he.lessThan;he.lessThanOrEqual=function(t){return this.comp(t)<=0};he.lte=he.lessThanOrEqual;he.le=he.lessThanOrEqual;he.greaterThan=function(t){return this.comp(t)>0};he.gt=he.greaterThan;he.greaterThanOrEqual=function(t){return this.comp(t)>=0};he.gte=he.greaterThanOrEqual;he.ge=he.greaterThanOrEqual;he.compare=function(t){if(qn(t)||(t=co(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};he.comp=he.compare;he.negate=function(){return!this.unsigned&&this.eq(yr)?yr:this.not().add(Tc)};he.neg=he.negate;he.add=function(t){qn(t)||(t=co(t));var n=this.high>>>16,r=this.high&65535,i=this.low>>>16,o=this.low&65535,a=t.high>>>16,s=t.high&65535,u=t.low>>>16,d=t.low&65535,h=0,p=0,g=0,m=0;return m+=o+d,g+=m>>>16,m&=65535,g+=i+u,p+=g>>>16,g&=65535,p+=r+s,h+=p>>>16,p&=65535,h+=n+a,h&=65535,ct(g<<16|m,h<<16|p,this.unsigned)};he.subtract=function(t){return qn(t)||(t=co(t)),this.add(t.neg())};he.sub=he.subtract;he.multiply=function(t){if(this.isZero())return this;if(qn(t)||(t=co(t)),bi){var n=bi.mul(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?hs:qi;if(this.eq(yr))return t.isOdd()?yr:qi;if(t.eq(yr))return this.isOdd()?yr:qi;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Px)&&t.lt(Px))return wi(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,o=this.low>>>16,a=this.low&65535,s=t.high>>>16,u=t.high&65535,d=t.low>>>16,h=t.low&65535,p=0,g=0,m=0,v=0;return v+=a*h,m+=v>>>16,v&=65535,m+=o*h,g+=m>>>16,m&=65535,m+=a*d,g+=m>>>16,m&=65535,g+=i*h,p+=g>>>16,g&=65535,g+=o*d,p+=g>>>16,g&=65535,g+=a*u,p+=g>>>16,g&=65535,p+=r*h+i*d+o*u+a*s,p&=65535,ct(m<<16|v,p<<16|g,this.unsigned)};he.mul=he.multiply;he.divide=function(t){if(qn(t)||(t=co(t)),t.isZero())throw Error("division by zero");if(bi){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?bi.div_u:bi.div_s)(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?hs:qi;var r,i,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return hs;if(t.gt(this.shru(1)))return OP;o=hs}else{if(this.eq(yr)){if(t.eq(Tc)||t.eq(y3))return yr;if(t.eq(yr))return Tc;var a=this.shr(1);return r=a.div(t).shl(1),r.eq(qi)?t.isNegative()?Tc:y3:(i=this.sub(t.mul(r)),o=r.add(i.div(t)),o)}else if(t.eq(yr))return this.unsigned?hs:qi;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=qi}for(i=this;i.gte(t);){r=Math.max(1,Math.floor(i.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:sm(2,s-48),d=wi(r),h=d.mul(t);h.isNegative()||h.gt(i);)r-=u,d=wi(r,this.unsigned),h=d.mul(t);d.isZero()&&(d=Tc),o=o.add(d),i=i.sub(h)}return o};he.div=he.divide;he.modulo=function(t){if(qn(t)||(t=co(t)),bi){var n=(this.unsigned?bi.rem_u:bi.rem_s)(this.low,this.high,t.low,t.high);return ct(n,bi.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};he.mod=he.modulo;he.rem=he.modulo;he.not=function(){return ct(~this.low,~this.high,this.unsigned)};he.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};he.clz=he.countLeadingZeros;he.countTrailingZeros=function(){return this.low?Ax(this.low):Ax(this.high)+32};he.ctz=he.countTrailingZeros;he.and=function(t){return qn(t)||(t=co(t)),ct(this.low&t.low,this.high&t.high,this.unsigned)};he.or=function(t){return qn(t)||(t=co(t)),ct(this.low|t.low,this.high|t.high,this.unsigned)};he.xor=function(t){return qn(t)||(t=co(t)),ct(this.low^t.low,this.high^t.high,this.unsigned)};he.shiftLeft=function(t){return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?ct(this.low<>>32-t,this.unsigned):ct(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):ct(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};he.shr=he.shiftRight;he.shiftRightUnsigned=function(t){return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?ct(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?ct(this.high,0,this.unsigned):ct(this.high>>>t-32,0,this.unsigned)};he.shru=he.shiftRightUnsigned;he.shr_u=he.shiftRightUnsigned;he.rotateLeft=function(t){var n;return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?ct(this.high,this.low,this.unsigned):t<32?(n=32-t,ct(this.low<>>n,this.high<>>n,this.unsigned)):(t-=32,n=32-t,ct(this.high<>>n,this.low<>>n,this.unsigned))};he.rotl=he.rotateLeft;he.rotateRight=function(t){var n;return qn(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?ct(this.high,this.low,this.unsigned):t<32?(n=32-t,ct(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,n=32-t,ct(this.low<>>t,this.high<>>t,this.unsigned))};he.rotr=he.rotateRight;he.toSigned=function(){return this.unsigned?ct(this.low,this.high,!1):this};he.toUnsigned=function(){return this.unsigned?this:ct(this.low,this.high,!0)};he.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};he.toBytesLE=function(){var t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};he.toBytesBE=function(){var t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};at.fromBytes=function(t,n,r){return r?at.fromBytesLE(t,n):at.fromBytesBE(t,n)};at.fromBytesLE=function(t,n){return new at(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};at.fromBytesBE=function(t,n){return new at(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};var Cn=(e=>(e[e.Null=0]="Null",e[e.Boolean=1]="Boolean",e[e.Integer=2]="Integer",e[e.Long=3]="Long",e[e.Double=4]="Double",e[e.String=5]="String",e[e.Bytes=6]="Bytes",e[e.Date=7]="Date",e))(Cn||{});class Jt extends Oh{constructor(n,r){super(r);k(this,"valueType");k(this,"value");this.valueType=Jt.getPrimitiveType(n),this.value=n===void 0?null:n}static of(n,r){return new Jt(n,r)}static valueFromBytes(n,r){switch(n){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(o,a){i.setUint8(a,o)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return at.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(at.fromBytesLE(Array.from(r),!0).toNumber());default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}toJSON(){return this.valueType===5?`"${Oo(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const n=Jt.of(this.value,this.getCreatedAt());return n.setMovedAt(this.getMovedAt()),n.setRemovedAt(this.getRemovedAt()),n}getType(){return this.valueType}static getPrimitiveType(n){switch(typeof n){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(n)?2:4;case"string":return 5;case"object":if(n===null)return 0;if(n instanceof at)return 3;if(n instanceof Uint8Array)return 6;if(n instanceof Date)return 7}}static isSupport(n){return Jt.getPrimitiveType(n)!==void 0}static isInteger(n){return n%1===0}isNumericType(){const n=this.valueType;return n===2||n===3||n===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const n=this.value;return new Uint8Array([n&255,n>>8&255,n>>16&255,n>>24&255])}case 4:{const n=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,n,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const n=this.value,r=at.fromNumber(n.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class um extends FP{constructor(n){super(n);k(this,"prev");k(this,"next");this.value=n}static createAfter(n,r){const i=new um(r),o=n.next;return n.next=i,i.prev=n,i.next=o,o&&(o.prev=i),i}remove(n){return this.value.remove(n)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class fh{constructor(){k(this,"dummyHead");k(this,"last");k(this,"nodeMapByIndex");k(this,"nodeMapByCreatedAt");const t=Jt.of(0,to);t.setRemovedAt(to),this.dummyHead=new um(t),this.last=this.dummyHead,this.nodeMapByIndex=new hh,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new fh}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,n){let r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(n);)r=r.getNext();return r}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,n,r=n.getCreatedAt()){const i=this.findNextBeforeExecutedAt(t,r),o=um.createAfter(i,n);i===this.last&&(this.last=o),this.nodeMapByIndex.insertAfter(i,o),this.nodeMapByCreatedAt.set(o.getCreatedAt().toIDString(),o)}moveAfter(t,n,r){const i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const o=this.nodeMapByCreatedAt.get(n.toIDString());if(!o)throw new Y(J.ErrInvalidArgument,`cant find the given node: ${n.toIDString()}`);i!==o&&(!o.getValue().getMovedAt()||r.after(o.getValue().getMovedAt()))&&(this.release(o),this.insertAfter(i.getCreatedAt(),o.getValue(),r),o.getValue().setMovedAt(r))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const n=this.nodeMapByCreatedAt.get(t.toIDString());if(n)return String(this.nodeMapByIndex.indexOf(n))}purge(t){const n=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!n)throw new Y(J.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(n)}getByIndex(t){if(t>=this.length)return;const[n,r]=this.nodeMapByIndex.find(t);let i=n;if(t===0&&n===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(t){let n=this.nodeMapByCreatedAt.get(t.toIDString());do n=n.getPrev();while(this.dummyHead!==n&&n.isRemoved());return n.getValue().getCreatedAt()}delete(t,n){const r=this.nodeMapByCreatedAt.get(t.toIDString()),i=r.isRemoved();return r.remove(n)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(t,n){const r=this.getByIndex(t);if(r)return r.remove(n)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const n of this){const r=`${n.getCreatedAt().toIDString()}:${n.getValue().toJSON()}`;n.isRemoved()?t.push(`{${r}}`):t.push(`[${r}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class jr extends vu{constructor(n,r){super(n);k(this,"elements");this.elements=r}static create(n,r){if(!r)return new jr(n,fh.create());const i=fh.create();for(const o of r)i.insertAfter(i.getLastCreatedAt(),o.deepcopy());return new jr(n,i)}subPathOf(n){return this.elements.subPathOf(n)}purge(n){this.elements.purge(n)}insertAfter(n,r){this.elements.insertAfter(n,r)}moveAfter(n,r,i){this.elements.moveAfter(n,r,i)}get(n){const r=this.elements.getByIndex(n);return r==null?void 0:r.getValue()}getByID(n){const r=this.elements.getByID(n);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(n){return this.elements.getPrevCreatedAt(n)}delete(n,r){return this.elements.delete(n,r)}deleteByIndex(n,r){return this.elements.deleteByIndex(n,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const n of this.elements)n.isRemoved()||(yield n.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(n){for(const r of this.elements){const i=r.getValue();if(n(i,this))return;i instanceof vu&&i.getDescendants(n)}}toJSON(){const n=[];for(const r of this)n.push(r.toJSON());return`[${n.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const n={};for(let r=0;r({...v,value:v.value?{attributes:Hc(v.value.getAttributes()),content:v.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[h,m,p,[d,d]]}setStyle(n,r,i,o,a){const[,s]=this.rgaTreeSplit.findNodeWithSplit(n[1],i),[,u]=this.rgaTreeSplit.findNodeWithSplit(n[0],i),d=[],h=this.rgaTreeSplit.findBetween(u,s),p=new Map,g=[];for(const v of h){const E=v.getCreatedAt().getActorID();let w,C=0n;if(a===void 0&&o===void 0?C=R0:a.size()>0?C=a.get(E)?a.get(E):0n:w=o.has(E)?o.get(E):to,v.canStyle(i,w,C)){const b=p.get(E),A=v.getCreatedAt();(!b||A.after(b))&&p.set(E,A),g.push(v)}}const m=[];for(const v of g){if(v.isRemoved())continue;const[E,w]=this.rgaTreeSplit.findIndexesFromRange(v.createPosRange());d.push({type:"style",actor:i.getActorID(),from:E,to:w,value:{attributes:Hc(r)}});for(const[C,b]of Object.entries(r)){const[A]=v.getValue().setAttr(C,b,i);A!==void 0&&m.push({parent:v.getValue(),child:A})}}return[p,m,d]}indexRangeToPosRange(n,r){const i=this.rgaTreeSplit.indexToPos(n);return n===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const n=[];for(const r of this.rgaTreeSplit)r.isRemoved()||n.push(r.getValue().toJSON());return`[${n.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const n=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();n.push({attributes:Hc(i.getAttributes()),content:i.getContent()})}return n}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const n=new Ti(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return n.remove(this.getRemovedAt()),n}findIndexesFromRange(n){return this.rgaTreeSplit.findIndexesFromRange(n)}getGCPairs(){const n=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&n.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())n.push(i)}return n}}class Nh extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"content");k(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.content=a,this.attributes=s}static create(n,r,i,o,a,s,u){return new Nh(n,r,i,o,a,s,u)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Ti))throw new Y(J.ErrInvalidArgument,"fail to execute, only Text can execute edit");const a=o,[,s,u]=a.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const d of u)n.registerGCPair(d);return{opInfos:s.map(({from:d,to:h,value:p})=>({type:"edit",from:d,to:h,value:p,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),o=this.content;return`${n}.EDIT(${r},${i},${o})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class zh extends so{constructor(n,r,i,o,a,s){super(n,s);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.attributes=a}static create(n,r,i,o,a,s){return new zh(n,r,i,o,a,s)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Ti))throw new Y(J.ErrInvalidArgument,"fail to execute, only Text can execute edit");const a=o,[,s,u]=a.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const d of s)n.registerGCPair(d);return{opInfos:u.map(({from:d,to:h,value:p})=>({type:"style",from:d,to:h,value:p,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),o=this.attributes;return`${n}.STYL(${r},${i},${JSON.stringify(o)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const pKe=2,gKe="root",vs="text";function s0(e,t){let n=0;const r=e.children;for(let i=0;i0)throw new Y(J.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const n=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*n,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const n of this._children){const r=n.updateDescendantsSize();n.isRemoved||(t+=r)}return this.size+=t,this.paddedSize}get isText(){return this.type===vs}get paddedSize(){return this.size+(this.isText?0:pKe)}isAncestorOf(t){return vKe(this,t)}get nextSibling(){const t=this.parent.findOffset(this),n=this.parent.children[t+1];if(n)return n}get prevSibling(){const t=this.parent.findOffset(this),n=this.parent.children[t-1];if(n)return n}splitText(t,n){if(t===0||t===this.size)return;const r=this.value.slice(0,t),i=this.value.slice(t);if(!i.length)return;this.value=r;const o=this.cloneText(t+n);return o.value=i,this.parent.insertAfterInternal(o,this),o}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const n of t)n.parent=this,n.updateAncestorsSize()}prepend(...t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const n of t)n.parent=this}insertBefore(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r),t.updateAncestorsSize()}insertAfter(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1),t.updateAncestorsSize()}insertAt(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,n),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(t);if(n===-1)throw new Y(J.ErrInvalidArgument,"child not found");this._children.splice(n,1),t.parent=void 0}splitElement(t,n){const r=this.cloneElement(n);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,t),o=this.children.slice(t);this._children=i,r._children=o,this.size=this._children.reduce((a,s)=>a+s.paddedSize,0),r.size=r._children.reduce((a,s)=>a+s.paddedSize,0);for(const a of r._children)a.parent=r;return r}insertAfterInternal(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(n);if(r===-1)throw new Y(J.ErrInvalidArgument,"child not found");this.insertAtInternal(t,r+1)}insertAtInternal(t,n){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");this._children.splice(n,0,t),t.parent=this}findOffset(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");if(t.isRemoved){const n=this._children.indexOf(t);return this.allChildren.splice(0,n).filter(i=>!i.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new Y(J.ErrRefused,"Text node cannot have children");let n=t;for(;n;){const r=this._children.indexOf(n);if(r!==-1)return r;n=n.parent}return-1}}function vKe(e,t){if(e===t)return!1;for(;t.parent;){if(t.parent===e)return!0;t=t.parent}return!1}var un=(e=>(e.Start="Start",e.End="End",e.Text="Text",e))(un||{});function zP(e,t,n,r){if(t>n)throw new Y(J.ErrInvalidArgument,`from is greater than to: ${t} > ${n}`);if(t>e.size)throw new Y(J.ErrInvalidArgument,`from is out of range: ${t} > ${e.size}`);if(n>e.size)throw new Y(J.ErrInvalidArgument,`to is out of range: ${n} > ${e.size}`);if(t===n)return;let i=0;for(const o of e.children){if(t-o.paddedSizeo.size;(o.isText||u)&&r([o,o.isText?"Text":"Start"],d),zP(o,Math.max(0,a),Math.min(s,o.size),r),d&&r([o,"End"],d)}i+=o.paddedSize}}function HP(e,t,n=0){for(const r of e.children)HP(r,t,n+1);t(e,n)}function b1(e,t,n=0){for(const r of e._children)b1(r,t,n+1);t(e,n)}function E3(e,t,n=!0){if(t>e.size)throw new Y(J.ErrInvalidArgument,`index is out of range: ${t} > ${e.size}`);if(e.isText)return{node:e,offset:t};let r=0,i=0;for(const o of e.children){if(n&&o.isText&&o.size>=t-i)return E3(o,t-i,n);if(t===i)return{node:e,offset:r};if(!n&&o.paddedSize===t-i)return{node:e,offset:r+1};if(o.paddedSize>t-i)return E3(o,t-i-1,n);i+=o.paddedSize,r+=1}return{node:e,offset:r}}function jP(e){return e.isText||e.children.length===0?e:jP(e.children[0])}function yKe(e,t){if(e.sizee===t?0:e0)if(n.right)n.right.parent=n,n=n.right;else return n;else if(r<0)if(n.left)n.left.parent=n,n=n.left;else{let i=n.parent,o=n;for(;i&&o===i.left;)o=i,i=i.parent;return i}else return n}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,n){for(;n;){const r=this.comparator(t,n.key);if(r===0)return n;r<0?n=n.left:r>0&&(n=n.right)}}putInternal(t,n,r){if(!r)return this.counter+=1,new bKe(t,n,!0);const i=this.comparator(t,r.key);return i<0?r.left=this.putInternal(t,n,r.left):i>0?r.right=this.putInternal(t,n,r.right):r.value=n,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(t,n){if(this.comparator(n,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,n);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(n,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(n,t.key)===0){this.counter-=1;const r=this.min(t.right);t.value=r.value,t.key=r.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,n)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const n=t.right;return t.right=n.left,n.left=t,n.isRed=n.left.isRed,n.left.isRed=!0,n}rotateRight(t){const n=t.left;return t.left=n.right,n.right=t,n.isRed=n.right.isRed,n.right.isRed=!0,n}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class Xi{constructor(t,n){k(this,"parentID");k(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=n}static of(t,n){return new Xi(t,n)}static fromTreePos(t){const{offset:n}=t;let{node:r}=t,i;return r.isText?(r.parent.children[0]===r&&n===0?i=r.parent:i=r,r=r.parent):n===0?i=r:i=r.children[n-1],Xi.of(r.id,Fn.of(i.getCreatedAt(),i.getOffset()+n))}getParentID(){return this.parentID}static fromStruct(t){return Xi.of(Fn.of(Ai.fromStruct(t.parentID.createdAt),t.parentID.offset),Fn.of(Ai.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const n=this.getParentID(),r=this.getLeftSiblingID(),i=t.findFloorNode(n);let o=t.findFloorNode(r);if(!i||!o)throw new Y(J.ErrRefused,`cannot find node of CRDTTreePos(${n.toTestString()}, ${r.toTestString()})`);return!r.equals(n)&&r.getOffset()>0&&r.getOffset()===o.id.getOffset()&&o.insPrevID&&(o=t.findFloorNode(o.insPrevID)),[i,o]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class Fn{constructor(t,n){k(this,"createdAt");k(this,"offset");this.createdAt=t,this.offset=n}static of(t,n){return new Fn(t,n)}static fromStruct(t){return Fn.of(Ai.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,n)=>{const r=t.getCreatedAt().compare(n.getCreatedAt());return r!==0?r:t.getOffset()>n.getOffset()?1:t.getOffset(){const o=i.deepcopy();return o.parent=n,o}),n.insPrevID=this.insPrevID,n.insNextID=this.insNextID,n}get value(){if(!this.isText)throw new Y(J.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(n){if(!this.isText)throw new Y(J.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=n,this.size=n.length}get isRemoved(){return!!this.removedAt}remove(n){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(n)>0)&&(this.removedAt=n),r&&this.updateAncestorsSize()}cloneText(n){return new Nr(Fn.of(this.id.getCreatedAt(),n),this.type,void 0,void 0,this.removedAt)}cloneElement(n){return new Nr(Fn.of(n(),0),this.type,void 0,void 0,this.removedAt)}split(n,r,i){const o=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(o){if(o.insPrevID=this.id,this.insNextID){const a=n.findFloorNode(this.insNextID);a.insPrevID=o.id,o.insNextID=this.insNextID}this.insNextID=o.id,n.registerNode(o)}return o}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(n,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||n.after(this.removedAt))}canStyle(n,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||n.after(this.removedAt))}setAttrs(n,r){this.attrs||(this.attrs=new Ds);const i=[];for(const[o,a]of Object.entries(n))i.push(this.attrs.set(o,a,r));return i}purge(n){this.attrs&&this.attrs.purge(n)}getGCPairs(){const n=[];if(!this.attrs)return n;for(const r of this.attrs)r.getRemovedAt()&&n.push({parent:this,child:r});return n}}function C3(e){var n;if(e.isText){const r=e;return{type:r.type,value:r.value}}const t={type:e.type,children:e.children.map(C3)};return e.attrs&&(t.attributes=Hc((n=e.attrs)==null?void 0:n.toObject())),t}function zC(e){if(e.isText)return e.value;let t="";return e.attrs&&e.attrs.size()&&(t=" "+Array.from(e.attrs).filter(n=>!n.isRemoved()).sort((n,r)=>n.getKey().localeCompare(r.getKey())).map(n=>{const r=JSON.parse(n.getValue());return typeof r=="string"?`${n.getKey()}="${r}"`:`${n.getKey()}="${Oo(n.getValue())}"`}).join(" ")),`<${e.type}${t}>${e.children.map(n=>zC(n)).join("")}`}function KP(e){if(e.isText){const t=e;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:e.type,children:e.children.map(KP),size:e.size,isRemoved:e.isRemoved}}class Pi extends Oh{constructor(n,r){super(r);k(this,"indexTree");k(this,"nodeMapByID");this.indexTree=new EKe(n),this.nodeMapByID=new UP(Fn.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(n,r){return new Pi(n,r)}findFloorNode(n){const r=this.nodeMapByID.floorEntry(n);if(!(!r||!r.key.getCreatedAt().equals(n.getCreatedAt())))return r.value}registerNode(n){this.nodeMapByID.put(n.id,n)}findNodesAndSplitText(n,r){const[i,o]=n.toTreeNodePair(this);let a=o;const s=i===a,u=a.parent&&!s?a.parent:i;if(a.isText&&a.split(this,n.getLeftSiblingID().getOffset()-a.id.getOffset()),r){const d=u.allChildren,h=s?0:d.indexOf(a)+1;for(let p=h;p{const w=E.getCreatedAt().getActorID();let C,b=0n;if(a===void 0&&o===void 0?b=R0:a.size()>0?b=a.get(w)?a.get(w):0n:C=o.has(w)?o.get(w):to,E.canStyle(i,C,b)&&r){const A=m.get(w),T=E.getCreatedAt();(!A||T.after(A))&&m.set(w,T);const B=E.setAttrs(r,i),D=B.reduce((O,[,z])=>(z&&(O[z.getKey()]=g[z.getKey()]),O),{}),I=E.parent,M=E.prevSibling||E.parent;Object.keys(D).length>0&&p.push({type:"style",from:this.toIndex(I,M),to:this.toIndex(E,E),fromPath:this.toPath(I,M),toPath:this.toPath(E,E),actor:i.getActorID(),value:D});for(const[O]of B)O&&v.push({parent:E,child:O})}}),[m,v,p]}removeStyle(n,r,i,o,a){const[s,u]=this.findNodesAndSplitText(n[0],i),[d,h]=this.findNodesAndSplitText(n[1],i),p=[],g=new Map,m=[];return this.traverseInPosRange(s,u,d,h,([v])=>{const E=v.getCreatedAt().getActorID();let w,C=0n;if(a===void 0&&o===void 0?C=R0:a.size()>0?C=a.get(E)?a.get(E):0n:w=o.has(E)?o.get(E):to,v.canStyle(i,w,C)&&r){const b=g.get(E),A=v.getCreatedAt();(!b||A.after(b))&&g.set(E,A),v.attrs||(v.attrs=new Ds);for(const D of r){const I=v.attrs.remove(D,i);for(const M of I)m.push({parent:v,child:M})}const T=v.parent,B=v.prevSibling||v.parent;p.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(T,B),to:this.toIndex(v,v),fromPath:this.toPath(T,B),toPath:this.toPath(v,v),value:r})}}),[g,m,p]}edit(n,r,i,o,a,s,u){const[d,h]=this.findNodesAndSplitText(n[0],o),[p,g]=this.findNodesAndSplitText(n[1],o),m=this.toIndex(d,h),v=this.toPath(d,h),E=[],w=[],C=[],b=new Map;this.traverseInPosRange(d,h,p,g,([B,D],I)=>{if(D===un.Start&&!I)for(const K of B.children)C.push(K);const M=B.getCreatedAt().getActorID();let O,z=0n;if(u===void 0&&s===void 0?z=R0:u.size()>0?z=u.get(M)?u.get(M):0n:O=s.has(M)?s.get(M):to,B.canDelete(o,O,z)||E.includes(B.parent)){const K=b.get(M),X=B.getCreatedAt();(!K||X.after(K))&&b.set(M,X),(D===un.Text||D===un.Start)&&E.push(B),w.push([B,D])}});const A=this.makeDeletionChanges(w,o),T=[];for(const B of E)B.remove(o),B.isRemoved&&T.push({parent:this,child:B});for(const B of C)B.removedAt||d.append(B);if(i>0){let B=0,D=d,I=h;for(;B{d.isRemoved&&(M.remove(o),T.push({parent:this,child:M})),this.nodeMapByID.put(M.id,M)}),I.isRemoved||B.push(I);if(B.length){const I=B.map(M=>C3(M));A.length&&A[A.length-1].from===m?A[A.length-1].value=I:A.push({type:"content",from:m,to:m,fromPath:v,toPath:v,actor:o.getActorID(),value:I})}}return[A,T,b]}editT(n,r,i,o,a){const s=this.findPos(n[0]),u=this.findPos(n[1]);this.edit([s,u],r,i,o,a)}move(n,r,i){throw new Y(J.ErrUnimplemented,`not implemented: ${n}, ${r}, ${i}`)}purge(n){var o;(o=n.parent)==null||o.removeChild(n),this.nodeMapByID.remove(n.id);const r=n.insPrevID,i=n.insNextID;if(r){const a=this.findFloorNode(r);a.insNextID=i}if(i){const a=this.findFloorNode(i);a.insPrevID=r}n.insPrevID=void 0,n.insNextID=void 0}getGCPairs(){const n=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&n.push({parent:this,child:r});for(const i of r.getGCPairs())n.push(i)}),n}findPos(n,r=!0){const i=this.indexTree.findTreePos(n,r);return Xi.fromTreePos(i)}pathToPosRange(n){const r=this.pathToIndex(n);return[this.findPos(r),this.findPos(r+1)]}pathToPos(n){const r=this.indexTree.pathToIndex(n);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return zC(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const n=this.indexTree.getRoot(),r=(i,o=void 0,a=void 0,s=0)=>{var m,v,E,w;let u,d,h;const p=i.isText?{node:i,offset:0}:o&&a?this.toTreePos(o,a):null;p&&(u=this.indexTree.indexOf(p),d=this.indexTree.treePosToPath(p),h=Xi.fromTreePos(p).toStruct());const g={type:i.type,parent:o==null?void 0:o.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(m=i.removedAt)==null?void 0:m.toTestString(),insPrev:(v=i.insPrevID)==null?void 0:v.toTestString(),insNext:(E=i.insNextID)==null?void 0:E.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:s,attributes:i.attrs?Hc((w=i.attrs)==null?void 0:w.toObject()):void 0,index:u,path:d,pos:h};for(let C=0;C0&&C===i[i.length-1].to?(i[i.length-1].to=b,i[i.length-1].toPath=this.toPath(w,m)):i.push({type:"content",from:C,to:b,fromPath:this.toPath(E,p),toPath:this.toPath(w,m),actor:r.getActorID()}))}return i.reverse()}findRightToken([n,r]){if(r===un.Start){const u=n.allChildren;return u.length>0?[u[0],u[0].isText?un.Text:un.Start]:[n,un.End]}const i=n.parent,o=i.allChildren,a=o.indexOf(n);if(i&&a===o.length-1)return[i,un.End];const s=o[a+1];return[s,s.isText?un.Text:un.Start]}findLeftToken([n,r]){if(r===un.End){const u=n.allChildren;if(u.length>0){const d=u[u.length-1];return[d,d.isText?un.Text:un.End]}return[n,un.Start]}const i=n.parent,o=i.allChildren,a=o.indexOf(n);if(i&&a===0)return[i,un.Start];const s=o[a-1];return[s,s.isText?un.Text:un.End]}}class Hh extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"contents");k(this,"splitLevel");k(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=o,this.splitLevel=a,this.maxCreatedAtMapByActor=s}static create(n,r,i,o,a,s,u){return new Hh(n,r,i,o,a,s,u)}execute(n,r,i){var h;const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Pi))throw new Y(J.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const a=this.getExecutedAt(),s=o,[u,d]=s.edit([this.fromPos,this.toPos],(h=this.contents)==null?void 0:h.map(p=>p.deepcopy()),this.splitLevel,a,(()=>{let p=a.getDelimiter();return this.contents!==void 0&&(p+=this.contents.length),()=>Ai.of(a.getLamport(),++p,a.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const p of d)n.registerGCPair(p);return{opInfos:u.map(({from:p,to:g,value:m,splitLevel:v,fromPath:E,toPath:w})=>({type:"tree-edit",path:n.createPath(this.getParentCreatedAt()),from:p,to:g,value:m,splitLevel:v,fromPath:E,toPath:w}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,o=this.contents||[];return`${n}.EDIT(${r},${i},${o.map(a=>zC(a)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class jc{constructor(t){k(this,"vector");this.vector=t||new Map}set(t,n){this.vector.set(t,n)}unset(t){this.vector.delete(t)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,n]of this)n>t&&(t=n);return t}max(t){const n=new Map;for(const[r,i]of t){const o=this.vector.get(r),a=o&&o>i?o:i;n.set(r,a)}for(const[r,i]of this){const o=t.get(r),a=o&&o>i?o:i;n.set(r,a)}return new jc(n)}afterOrEqual(t){const n=this.vector.get(t.getActorID());return n===void 0?!1:n>=t.getLamport()}deepcopy(){const t=new Map;for(const[n,r]of this.vector)t.set(n,r);return new jc(t)}filter(t){const n=new Map;for(const[r]of t){const i=this.vector.get(r);i!==void 0&&n.set(r,i)}return new jc(n)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,n]of this.vector)yield[t,n]}}const SKe=new jc(new Map);class as{constructor(t,n,r,i,o){k(this,"clientSeq");k(this,"serverSeq");k(this,"lamport");k(this,"actor");k(this,"versionVector");this.clientSeq=t,this.serverSeq=o,this.lamport=n,this.versionVector=i,this.actor=r}static of(t,n,r,i,o){return new as(t,n,r,i,o)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new as(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const n=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n;let r=t.versionVector;r.size()===0&&(r=r.deepcopy(),r.set(t.actor,t.lamport));const i=this.versionVector.max(r),o=new as(this.clientSeq,n,this.actor,i);return o.versionVector.set(this.actor,n),o}setClocks(t,n){const r=t>this.lamport?t+1n:this.lamport+1n;n.unset(C1);const i=this.versionVector.max(n);return i.set(this.actor,r),as.of(this.clientSeq,r,this.actor,i)}createTimeTicket(t){return Ai.of(this.lamport,t,this.actor)}setActor(t){return new as(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new as(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const xKe=new as(0,0n,C1,SKe);class dd{constructor({id:t,operations:n,presenceChange:r,message:i}){k(this,"id");k(this,"operations");k(this,"presenceChange");k(this,"message");this.id=t,this.operations=n||[],this.presenceChange=r,this.message=i}static create({id:t,operations:n,presenceChange:r,message:i}){return new dd({id:t,operations:n,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const n of this.operations)n.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,n,r){const i=[],o=[];for(const a of this.operations){const s=a.execute(t,r,this.id.getVersionVector());if(!s)continue;const{opInfos:u,reverseOp:d}=s;i.push(...u),d&&o.unshift(d)}return this.presenceChange&&(this.presenceChange.type===Du.Put?n.set(this.id.getActorID(),Gi(this.presenceChange.presence)):n.delete(this.id.getActorID())),{opInfos:i,reverseOps:o}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:on.bytesToHex(on.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>on.bytesToHex(on.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:n,operations:r,presenceChange:i,message:o}=t;return dd.create({id:on.bytesToChangeID(on.hexToBytes(n)),operations:r==null?void 0:r.map(a=>on.bytesToOperation(on.hexToBytes(a))),presenceChange:i,message:o})}}class w1{constructor(t,n,r,i,o,a,s){k(this,"documentKey");k(this,"checkpoint");k(this,"isRemoved");k(this,"changes");k(this,"snapshot");k(this,"minSyncedTicket");k(this,"versionVector");this.documentKey=t,this.checkpoint=n,this.isRemoved=r,this.changes=i,this.snapshot=a,this.minSyncedTicket=s,this.versionVector=o}static create(t,n,r,i,o,a,s){return new w1(t,n,r,i,o,a,s)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Uc{constructor(t,n){k(this,"serverSeq");k(this,"clientSeq");this.serverSeq=t,this.clientSeq=n}static of(t,n){return new Uc(t,n)}increaseClientSeq(t){return t===0?this:new Uc(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const n=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,r=Math.max(this.clientSeq,t.clientSeq);return Uc.of(n,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const AKe=new Uc(0n,0);class zo{constructor(t,n){k(this,"createdAt");k(this,"offset");this.createdAt=t,this.offset=n}static of(t,n){return new zo(t,n)}static fromStruct(t){return zo.of(Ai.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new zo(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const kKe=zo.of(to,0);class no{constructor(t,n){k(this,"id");k(this,"relativeOffset");this.id=t,this.relativeOffset=n}static of(t,n){return new no(t,n)}static fromStruct(t){const n=zo.fromStruct(t.id);return no.of(n,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return zo.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class yu extends FP{constructor(n,r,i){super(r);k(this,"id");k(this,"removedAt");k(this,"prev");k(this,"next");k(this,"insPrev");k(this,"insNext");this.id=n,this.removedAt=i}static create(n,r){return new yu(n,r)}static createComparator(){return(n,r)=>{const i=n.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:n.getOffset()>r.getOffset()?1:n.getOffset()0&&n.getID().getOffset()==t.getOffset()){if(!n.hasInsPrev())return n;n=n.getInsPrev()}return n}findFloorNode(t){const n=this.treeByID.floorEntry(t);if(n&&!(!n.key.equals(t)&&!n.key.hasSameCreatedAt(t)))return n.value}findBetween(t,n){const r=[];let i=t;for(;i&&i!==n;)r.push(i),i=i.getNext();return r}splitNode(t,n){if(n>t.getContentLength())throw new Y(J.ErrInvalidArgument,"offset should be less than or equal to length");if(n===0)return t;if(n===t.getContentLength())return t.getNext();const r=t.split(n);this.treeByIndex.updateWeight(r),this.insertAfter(t,r);const i=t.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(t),r}deleteNodes(t,n,r,i){if(!t.length)return[[],new Map,new Map];const[o,a]=this.filterNodes(t,n,r,i),s=new Map,u=new Map,d=this.makeChanges(a,n);for(const h of o){const p=h.getCreatedAt().getActorID();(!s.has(p)||h.getID().getCreatedAt().after(s.get(p)))&&s.set(p,h.getID().getCreatedAt()),u.set(h.getID().toIDString(),h),h.remove(n)}return this.deleteIndexNodes(a),[d,s,u]}filterNodes(t,n,r,i){const o=[],a=[],[s,u]=this.findEdgesOfCandidates(t);a.push(s);for(const d of t){const h=d.getCreatedAt().getActorID();let p,g=0n;i===void 0&&r===void 0?g=R0:i.size()>0?g=i.get(h)?i.get(h):0n:p=r.has(h)?r.get(h):to,d.canDelete(n,p,g)?o.push(d):a.push(d)}return a.push(u),[o,a]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,n){const r=[];let i,o;for(let a=0;ae<0?Math.ceil(e):Math.floor(e);var Ko=(e=>(e[e.IntegerCnt=0]="IntegerCnt",e[e.LongCnt=1]="LongCnt",e))(Ko||{});class Ur extends Oh{constructor(n,r,i){super(i);k(this,"valueType");k(this,"value");switch(this.valueType=n,n){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=at.fromNumber(r).toInt():this.value=Bx(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=at.fromNumber(r):this.value=r;break;default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}static create(n,r,i){return new Ur(n,r,i)}static valueFromBytes(n,r){switch(n){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return at.fromBytesLE(Array.from(r));default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${n}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const n=Ur.create(this.valueType,this.value,this.getCreatedAt());return n.setMovedAt(this.getMovedAt()),n}getType(){return this.valueType}static getCounterType(n){switch(typeof n){case"object":return n instanceof at?1:void 0;case"number":return n>Math.pow(2,31)-1||n<-Math.pow(2,31)?1:0;default:return}}static isSupport(n){return!!Ur.getCounterType(n)}static isInteger(n){return n%1===0}isNumericType(){const n=this.valueType;return n===0||n===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const n=this.value;return new Uint8Array([n&255,n>>8&255,n>>16&255,n>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new Y(J.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(n){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(n),this.valueType===1?this.value=this.value.add(n.getValue()):n.getType()===Cn.Long?this.value=this.value+n.getValue().toInt():this.value=at.fromNumber(this.value+Bx(n.getValue())).toInt(),this}}class fd extends so{constructor(n,r,i){super(n,i);k(this,"value");this.value=r}static create(n,r,i){return new fd(n,r,i)}execute(n){const r=n.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof Ur))throw new Y(J.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,o=this.value.deepcopy();return i.increase(o),{opInfos:[{type:"increase",path:n.createPath(this.getParentCreatedAt()),value:o.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const n=this.value.deepcopy(),i=n.getType()===Cn.Long?n.getValue().multiply(-1):n.getValue()*-1;return fd.create(this.getParentCreatedAt(),Jt.of(i,n.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class ys extends so{constructor(n,r,i,o,a,s,u){super(n,u);k(this,"fromPos");k(this,"toPos");k(this,"maxCreatedAtMapByActor");k(this,"attributes");k(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=o,this.attributes=a,this.attributesToRemove=s}static create(n,r,i,o,a,s){return new ys(n,r,i,o,a,[],s)}static createTreeRemoveStyleOperation(n,r,i,o,a,s){return new ys(n,r,i,o,new Map,a,s)}execute(n,r,i){const o=n.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new Y(J.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Pi))throw new Y(J.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const a=o;let s,u;if(this.attributes.size){const d={};[...this.attributes].forEach(([h,p])=>d[h]=p),[,u,s]=a.style([this.fromPos,this.toPos],d,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const d=this.attributesToRemove;[,u,s]=a.removeStyle([this.fromPos,this.toPos],d,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const d of u)n.registerGCPair(d);return{opInfos:s.map(({from:d,to:h,value:p,fromPath:g,toPath:m})=>({type:"tree-style",from:d,to:h,value:this.attributes.size?{attributes:p}:{attributesToRemove:p},fromPath:g,toPath:m,path:n.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const n=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${n}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([o,a])=>`${o}:"${a}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function IKe(e){const t=new OC,n=t.data;for(const[r,i]of Object.entries(e))n[r]=JSON.stringify(i);return t}function DKe(e){if(e.type===Du.Put)return new ch({type:Dl.PUT,presence:IKe(e.presence)});if(e.type===Du.Clear)return new ch({type:Dl.CLEAR});throw new Y(J.ErrUnimplemented,"unimplemented type")}function TKe(e){return new MP({serverSeq:e.getServerSeq(),clientSeq:e.getClientSeq()})}function VP(e){return new y1({clientSeq:e.getClientSeq(),lamport:e.getLamport(),actorId:XC(e.getActorID()),versionVector:HC(e.getVersionVector())})}function Te(e){if(e)return new Ie({lamport:e.getLamport(),delimiter:e.getDelimiter(),actorId:XC(e.getActorID())})}function HC(e){if(!e)return;const t=new E1;for(const[n,r]of e)t.vector[n]=BigInt(r.toString());return t}function GP(e){switch(e){case Cn.Null:return Ve.NULL;case Cn.Boolean:return Ve.BOOLEAN;case Cn.Integer:return Ve.INTEGER;case Cn.Long:return Ve.LONG;case Cn.Double:return Ve.DOUBLE;case Cn.String:return Ve.STRING;case Cn.Bytes:return Ve.BYTES;case Cn.Date:return Ve.DATE;default:throw new Y(J.ErrInvalidType,`unsupported type: ${e}`)}}function JP(e){switch(e){case Ko.IntegerCnt:return Ve.INTEGER_CNT;case Ko.LongCnt:return Ve.LONG_CNT;default:throw new Y(J.ErrInvalidType,`unsupported type: ${e}`)}}function i2(e){if(e instanceof wr)return new li({type:Ve.JSON_OBJECT,createdAt:Te(e.getCreatedAt()),value:aB(e)});if(e instanceof jr)return new li({type:Ve.JSON_ARRAY,createdAt:Te(e.getCreatedAt()),value:aVe(e)});if(e instanceof Ti)return new li({type:Ve.TEXT,createdAt:Te(e.getCreatedAt())});if(e instanceof Jt)return new li({type:GP(e.getType()),createdAt:Te(e.getCreatedAt()),value:e.toBytes()});if(e instanceof Ur)return new li({type:JP(e.getType()),createdAt:Te(e.getCreatedAt()),value:e.toBytes()});if(e instanceof Pi)return new li({type:Ve.TREE,createdAt:Te(e.getCreatedAt()),value:uVe(e)});throw new Y(J.ErrUnimplemented,"unimplemented element")}function PKe(e){return new uh({createdAt:Te(e.getCreatedAt()),offset:e.getOffset()})}function Sp(e){return new Is({createdAt:Te(e.getID().getCreatedAt()),offset:e.getID().getOffset(),relativeOffset:e.getRelativeOffset()})}function xp(e){return new Il({parentId:F0(e.getParentID()),leftSiblingId:F0(e.getLeftSiblingID())})}function F0(e){return new mu({createdAt:Te(e.getCreatedAt()),offset:e.getOffset()})}function WP(e){const t=new LC;if(e instanceof Tl){const n=e,r=new Ug;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.key=n.getKey(),r.value=i2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="set",t.body.value=r}else if(e instanceof _h){const n=e,r=new Kg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.prevCreatedAt=Te(n.getPrevCreatedAt()),r.value=i2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="add",t.body.value=r}else if(e instanceof au){const n=e,r=new Vg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.prevCreatedAt=Te(n.getPrevCreatedAt()),r.createdAt=Te(n.getCreatedAt()),r.executedAt=Te(n.getExecutedAt()),t.body.case="move",t.body.value=r}else if(e instanceof Tu){const n=e,r=new Gg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.createdAt=Te(n.getCreatedAt()),r.executedAt=Te(n.getExecutedAt()),t.body.case="remove",t.body.value=r}else if(e instanceof Nh){const n=e,r=new Jg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=Sp(n.getFromPos()),r.to=Sp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);r.content=n.getContent();const o=r.attributes;for(const[a,s]of n.getAttributes())o[a]=s;r.executedAt=Te(n.getExecutedAt()),t.body.case="edit",t.body.value=r}else if(e instanceof zh){const n=e,r=new Wg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=Sp(n.getFromPos()),r.to=Sp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);const o=r.attributes;for(const[a,s]of n.getAttributes())o[a]=s;r.executedAt=Te(n.getExecutedAt()),t.body.case="style",t.body.value=r}else if(e instanceof fd){const n=e,r=new Yg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.value=i2(n.getValue()),r.executedAt=Te(n.getExecutedAt()),t.body.case="increase",t.body.value=r}else if(e instanceof Hh){const n=e,r=new qg,i=r.createdAtMapByActor;for(const[o,a]of n.getMaxCreatedAtMapByActor())i[o]=Te(a);r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=xp(n.getFromPos()),r.to=xp(n.getToPos()),r.contents=OKe(n.getContents()),r.splitLevel=n.getSplitLevel(),r.executedAt=Te(n.getExecutedAt()),t.body.case="treeEdit",t.body.value=r}else if(e instanceof ys){const n=e,r=new Xg;r.parentCreatedAt=Te(n.getParentCreatedAt()),r.from=xp(n.getFromPos()),r.to=xp(n.getToPos());const i=r.createdAtMapByActor;for(const[a,s]of n.getMaxCreatedAtMapByActor())i[a]=Te(s);const o=n.getAttributesToRemove();if(o.length>0)r.attributesToRemove=o;else{const a=r.attributes;for(const[s,u]of n.getAttributes())a[s]=u}r.executedAt=Te(n.getExecutedAt()),t.body.case="treeStyle",t.body.value=r}else throw new Y(J.ErrUnimplemented,"unimplemented operation");return t}function BKe(e){const t=[];for(const n of e)t.push(WP(n));return t}function MKe(e){const t=new PP({id:VP(e.getID()),message:e.getMessage()});return e.hasOperations()&&(t.operations=BKe(e.getOperations())),e.hasPresenceChange()&&(t.presenceChange=DKe(e.getPresenceChange())),t}function $Ke(e){const t=[];for(const n of e)t.push(MKe(n));return t}function RKe(e){const t=[];for(const n of e)t.push(new BP({key:n.getStrKey(),element:UC(n.getValue())}));return t}function FKe(e){const t=[];for(const n of e)t.push(new im({element:UC(n.getValue())}));return t}function LKe(e){const t=[];for(const n of e){const r=new om;r.id=PKe(n.getID()),r.value=n.getValue().getContent(),r.removedAt=Te(n.getRemovedAt());const i=r.attributes,o=n.getValue().getAttrs();for(const a of o){const s=new ud;s.value=a.getValue(),s.updatedAt=Te(a.getUpdatedAt()),i[a.getKey()]=s}t.push(r)}return t}function OKe(e){const t=[];if(!e||!e.length)return t;for(const n of e)t.push(new am({content:jC(n)}));return t}function _Ke(e){const t={};for(const n of e)t[n.getKey()]=new ud({value:n.getValue(),updatedAt:Te(n.getUpdatedAt()),isRemoved:n.isRemoved()});return t}function jC(e){if(!e)return[];const t=[];return b1(e,(n,r)=>{const i=new lh({id:F0(n.id),type:n.type,removedAt:Te(n.removedAt),depth:r});n.isText&&(i.value=n.value),n.insPrevID&&(i.insPrevId=F0(n.insPrevID)),n.insNextID&&(i.insNextId=F0(n.insNextID)),n.attrs&&(i.attributes=_Ke(n.attrs)),t.push(i)}),t}function NKe(e){const t=new Sr;return t.body.case="jsonObject",t.body.value=new Zg({nodes:RKe(e.getRHT()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function YP(e){const t=new Sr;return t.body.case="jsonArray",t.body.value=new Qg({nodes:FKe(e.getElements()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function zKe(e){const t=new Sr;return t.body.case="primitive",t.body.value=new em({type:GP(e.getType()),value:e.toBytes(),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function HKe(e){const t=new Sr;return t.body.case="text",t.body.value=new tm({nodes:LKe(e.getRGATreeSplit()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function jKe(e){const t=new Sr;return t.body.case="counter",t.body.value=new nm({type:JP(e.getType()),value:e.toBytes(),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function qP(e){const t=new Sr;return t.body.case="tree",t.body.value=new rm({nodes:jC(e.getRoot()),createdAt:Te(e.getCreatedAt()),movedAt:Te(e.getMovedAt()),removedAt:Te(e.getRemovedAt())}),t}function UC(e){if(e instanceof wr)return NKe(e);if(e instanceof jr)return YP(e);if(e instanceof Jt)return zKe(e);if(e instanceof Ti)return HKe(e);if(e instanceof Ur)return jKe(e);if(e instanceof Pi)return qP(e);throw new Y(J.ErrUnimplemented,"unimplemented element")}function UKe(e){return new Rs({documentKey:e.getDocumentKey(),checkpoint:TKe(e.getCheckpoint()),isRemoved:e.getIsRemoved(),changes:$Ke(e.getChanges()),snapshot:e.getSnapshot(),versionVector:HC(e.getVersionVector()),minSyncedTicket:Te(e.getMinSyncedTicket())})}function f0(e){if(!(e instanceof Nt))return{};const t=e.findDetails(uKe);for(const n of t)return n.metadata;return{}}function dc(e){return f0(e).code??""}function XP(e){return as.of(e.clientSeq,BigInt(e.lamport),YC(e.actorId),KC(e.versionVector),BigInt(e.serverSeq))}function KC(e){if(!e)return;const t=new jc;return Object.entries(e.vector).forEach(([n,r])=>{t.set(n,BigInt(r.toString()))}),t}function Pe(e){if(e)return Ai.of(BigInt(e.lamport),e.delimiter,YC(e.actorId))}function VC(e){const t={};return Object.entries(e.data).forEach(([n,r])=>{t[n]=JSON.parse(r)}),t}function KKe(e){const t=e.type;if(t===Dl.PUT){const n=VC(e.presence);return{type:Du.Put,presence:n}}if(t===Dl.CLEAR)return{type:Du.Clear};throw new Y(J.ErrInvalidType,`unsupported type: ${t}`)}function VKe(e){const t=new Map;return Object.entries(e).forEach(([n,r])=>{t.set(n,VC(r))}),t}function ZP(e){switch(e){case Ve.NULL:return Cn.Null;case Ve.BOOLEAN:return Cn.Boolean;case Ve.INTEGER:return Cn.Integer;case Ve.LONG:return Cn.Long;case Ve.DOUBLE:return Cn.Double;case Ve.STRING:return Cn.String;case Ve.BYTES:return Cn.Bytes;case Ve.DATE:return Cn.Date}throw new Y(J.ErrUnimplemented,`unimplemented value type: ${e}`)}function lm(e){switch(e){case Ve.INTEGER_CNT:return Ko.IntegerCnt;case Ve.LONG_CNT:return Ko.LongCnt}throw new Y(J.ErrUnimplemented,`unimplemented value type: ${e}`)}function o2(e){switch(e.type){case Ve.JSON_OBJECT:return e.value?oB(e.value):wr.create(Pe(e.createdAt));case Ve.JSON_ARRAY:return e.value?oVe(e.value):jr.create(Pe(e.createdAt));case Ve.TEXT:return Ti.create(hd.create(),Pe(e.createdAt));case Ve.TREE:return sVe(e.value);case Ve.NULL:case Ve.BOOLEAN:case Ve.INTEGER:case Ve.LONG:case Ve.DOUBLE:case Ve.STRING:case Ve.BYTES:case Ve.DATE:return Jt.of(Jt.valueFromBytes(ZP(e.type),e.value),Pe(e.createdAt));case Ve.INTEGER_CNT:case Ve.LONG_CNT:return Ur.create(lm(e.type),Ur.valueFromBytes(lm(e.type),e.value),Pe(e.createdAt))}}function Ap(e){return no.of(zo.of(Pe(e.createdAt),e.offset),e.relativeOffset)}function QP(e){return zo.of(Pe(e.createdAt),e.offset)}function GKe(e){const t=ph.create(e.value);Object.entries(e.attributes).forEach(([r,i])=>{t.setAttr(r,i.value,Pe(i.updatedAt))});const n=yu.create(QP(e.id),t);return n.remove(Pe(e.removedAt)),n}function hc(e){return Xi.of(L0(e.parentId),L0(e.leftSiblingId))}function L0(e){return Fn.of(Pe(e.createdAt),e.offset)}function JKe(e){if(!e.length)return;const t=[];return e.forEach(n=>{const r=GC(n.content);t.push(r)}),t}function GC(e){if(e.length===0)return;const t=[];for(const i of e)t.push(YKe(i));const n=t[t.length-1],r=new Map;r.set(e[t.length-1].depth,t[t.length-1]);for(let i=t.length-2;i>=0;i--)r.get(e[i].depth-1).prepend(t[i]),r.set(e[i].depth,t[i]);return n.updateDescendantsSize(),Pi.create(n,to).getRoot()}function WKe(e){const t=Ds.create();for(const[n,r]of Object.entries(e))t.setInternal(n,r.value,Pe(r.updatedAt),r.isRemoved);return t}function YKe(e){const t=L0(e.id),n=Nr.create(t,e.type),r=Object.entries(e.attributes);return n.isText?n.value=e.value:r.length&&(n.attrs=WKe(e.attributes)),e.insPrevId&&(n.insPrevID=L0(e.insPrevId)),e.insNextId&&(n.insNextID=L0(e.insNextId)),n.removedAt=Pe(e.removedAt),n}function eB(e){if(e.body.case==="set"){const t=e.body.value;return Tl.create(t.key,o2(t.value),Pe(t.parentCreatedAt),Pe(t.executedAt))}else if(e.body.case==="add"){const t=e.body.value;return _h.create(Pe(t.parentCreatedAt),Pe(t.prevCreatedAt),o2(t.value),Pe(t.executedAt))}else if(e.body.case==="move"){const t=e.body.value;return au.create(Pe(t.parentCreatedAt),Pe(t.prevCreatedAt),Pe(t.createdAt),Pe(t.executedAt))}else if(e.body.case==="remove"){const t=e.body.value;return Tu.create(Pe(t.parentCreatedAt),Pe(t.createdAt),Pe(t.executedAt))}else if(e.body.case==="edit"){const t=e.body.value,n=new Map;Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{n.set(i,Pe(o))});const r=new Map;return Object.entries(t.attributes).forEach(([i,o])=>{r.set(i,o)}),Nh.create(Pe(t.parentCreatedAt),Ap(t.from),Ap(t.to),n,t.content,r,Pe(t.executedAt))}else if(e.body.case==="style"){const t=e.body.value,n=new Map;Object.entries(t.createdAtMapByActor).forEach(([i,o])=>{n.set(i,Pe(o))});const r=new Map;return Object.entries(t.attributes).forEach(([i,o])=>{r.set(i,o)}),zh.create(Pe(t.parentCreatedAt),Ap(t.from),Ap(t.to),n,r,Pe(t.executedAt))}else{if(e.body.case==="select")return;if(e.body.case==="increase"){const t=e.body.value;return fd.create(Pe(t.parentCreatedAt),o2(t.value),Pe(t.executedAt))}else if(e.body.case==="treeEdit"){const t=e.body.value,n=new Map;return Object.entries(t.createdAtMapByActor).forEach(([r,i])=>{n.set(r,Pe(i))}),Hh.create(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),JKe(t.contents),t.splitLevel,n,Pe(t.executedAt))}else if(e.body.case==="treeStyle"){const t=e.body.value,n=new Map,r=t.attributesToRemove,i=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([o,a])=>{i.set(o,Pe(a))}),(r==null?void 0:r.length)>0?ys.createTreeRemoveStyleOperation(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),i,r,Pe(t.executedAt)):(Object.entries(t.attributes).forEach(([o,a])=>{n.set(o,a)}),ys.create(Pe(t.parentCreatedAt),hc(t.from),hc(t.to),i,n,Pe(t.executedAt)))}else throw new Y(J.ErrUnimplemented,"unimplemented operation")}}function qKe(e){const t=[];for(const n of e){const r=eB(n);r&&t.push(r)}return t}function tB(e){const t=[];for(const n of e)t.push(dd.create({id:XP(n.id),operations:qKe(n.operations),presenceChange:n.presenceChange?KKe(n.presenceChange):void 0,message:n.message}));return t}function XKe(e){return Uc.of(BigInt(e.serverSeq),e.clientSeq)}function ZKe(e){return w1.create(e.documentKey,XKe(e.checkpoint),e.isRemoved,tB(e.changes),KC(e.versionVector),e.snapshot,Pe(e.minSyncedTicket))}function nB(e){const t=new dh;for(const r of e.nodes){const i=JC(r.element);t.set(r.key,i,i.getPositionedAt())}const n=new wr(Pe(e.createdAt),t);return n.setMovedAt(Pe(e.movedAt)),n.setRemovedAt(Pe(e.removedAt)),n}function rB(e){const t=new fh;for(const r of e.nodes)t.insert(JC(r.element));const n=new jr(Pe(e.createdAt),t);return n.setMovedAt(Pe(e.movedAt)),n.setRemovedAt(Pe(e.removedAt)),n}function QKe(e){const t=Jt.of(Jt.valueFromBytes(ZP(e.type),e.value),Pe(e.createdAt));return t.setMovedAt(Pe(e.movedAt)),t.setRemovedAt(Pe(e.removedAt)),t}function eVe(e){const t=new hd;let n=t.getHead();for(const i of e.nodes){const o=t.insertAfter(n,GKe(i));i.insPrevId&&o.setInsPrev(t.findNode(QP(i.insPrevId))),n=o}const r=new Ti(t,Pe(e.createdAt));return r.setMovedAt(Pe(e.movedAt)),r.setRemovedAt(Pe(e.removedAt)),r}function tVe(e){const t=Ur.create(lm(e.type),Ur.valueFromBytes(lm(e.type),e.value),Pe(e.createdAt));return t.setMovedAt(Pe(e.movedAt)),t.setRemovedAt(Pe(e.removedAt)),t}function iB(e){const t=GC(e.nodes);return Pi.create(t,Pe(e.createdAt))}function JC(e){if(e.body.case==="jsonObject")return nB(e.body.value);if(e.body.case==="jsonArray")return rB(e.body.value);if(e.body.case==="primitive")return QKe(e.body.value);if(e.body.case==="text")return eVe(e.body.value);if(e.body.case==="counter")return tVe(e.body.value);if(e.body.case==="tree")return iB(e.body.value);throw new Y(J.ErrUnimplemented,"unimplemented element")}function nVe(e){if(!e)return{root:wr.create(to),presences:new Map};const t=Yy.fromBinary(e);return{root:JC(t.root),presences:VKe(t.presences)}}function rVe(e){const t=HC(e);return WC(t.toBinary())}function iVe(e){const t=qC(e),n=E1.fromBinary(t);return KC(n)}function oB(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return nB(t.body.value)}function aB(e){return UC(e).toBinary()}function oVe(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return rB(t.body.value)}function aVe(e){return YP(e).toBinary()}function sVe(e){if(!e)throw new Y(J.ErrInvalidArgument,"bytes is empty");const t=Sr.fromBinary(e);return iB(t.body.value)}function uVe(e){return qP(e).toBinary()}function WC(e){return e?Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function YC(e){return WC(e)}function qC(e){return new Uint8Array(e.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function XC(e){return qC(e)}function lVe(e){const t=y1.fromBinary(e);return XP(t)}function cVe(e){const t=LC.fromBinary(e);return eB(t)}const on={fromPresence:VC,toChangePack:UKe,fromChangePack:ZKe,fromChanges:tB,toTreeNodes:jC,fromTreeNodes:GC,objectToBytes:aB,bytesToObject:oB,bytesToSnapshot:nVe,bytesToHex:WC,hexToBytes:qC,toHexString:YC,toUint8Array:XC,toOperation:WP,toChangeID:VP,PbChangeID:y1,bytesToChangeID:lVe,bytesToOperation:cVe,versionVectorToHex:rVe,hexToVersionVector:iVe};var or=(e=>(e[e.Trivial=0]="Trivial",e[e.Debug=1]="Debug",e[e.Info=2]="Info",e[e.Warn=3]="Warn",e[e.Error=4]="Error",e[e.Fatal=5]="Fatal",e))(or||{});let tl=3;function sB(e){tl=e}const $e={trivial:(...e)=>{tl>0||typeof console<"u"&&console.log("YORKIE T:",...e)},debug:(...e)=>{tl>1||typeof console<"u"&&console.log("YORKIE D:",...e)},info:(...e)=>{tl>2||typeof console<"u"&&console.log("YORKIE I:",...e)},warn:(...e)=>{tl>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...e):console.log("YORKIE W:",...e))},error:(...e)=>{tl>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...e):console.log("YORKIE E:",...e))},fatal:(...e)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...e):console.log("YORKIE F:",...e))},isEnabled:e=>tl<=e};function uB(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class dVe{constructor(t,n,r,i,o){k(this,"reconnectStreamDelay");k(this,"doc");k(this,"docID");k(this,"syncMode");k(this,"remoteChangeEventReceived");k(this,"watchStream");k(this,"watchLoopTimerID");k(this,"watchAbortController");k(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=n,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=o}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===Xp.RealtimeSyncOff?!1:this.syncMode===Xp.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Xp.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const n=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(n,this.reconnectStreamDelay)})}catch{}};await n()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const a2=()=>{};class hVe{constructor(t){k(this,"finalized",!1);k(this,"observers",[]);k(this,"finalError");try{t(this)}catch(n){this.error(n)}}next(t){this.forEachObserver(n=>{n.next(t)})}error(t){this.forEachObserver(n=>{n.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,n,r){let i;if(!t)throw new Y(J.ErrInvalidArgument,"missing observer");if(this.finalized)throw new Y(J.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?i=t:i={next:t,error:n,complete:r},i.next===void 0&&(i.next=a2),i.error===void 0&&(i.error=a2),i.complete===void 0&&(i.complete=a2);const o=uB(),a=this.unsubscribeOne.bind(this,o);if(this.observers.push({subscriptionID:o,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(s){$e.warn(s)}return a}unsubscribeOne(t){var n;this.observers=(n=this.observers)==null?void 0:n.filter(r=>r.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let n=0;nt}}class Pc{constructor(t,n,r,i){k(this,"id");k(this,"delimiter");k(this,"message");k(this,"root");k(this,"operations");k(this,"presenceChange");k(this,"previousPresence");k(this,"reversePresenceKeys");this.id=t,this.delimiter=RP,this.root=n,this.operations=[],this.previousPresence=Gi(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(t,n,r,i){return new Pc(t,n,r,i)}push(t){this.operations.push(t)}registerElement(t,n){this.root.registerElement(t,n)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return dd.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,n){for(const r of Object.keys(t))n!=null&&n.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const n of this.reversePresenceKeys)t[n]=this.previousPresence[n];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class gh{constructor(t){k(this,"rootObject");k(this,"elementPairMapByCreatedAt");k(this,"gcElementSetByCreatedAt");k(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(n=>{if(n.getRemovedAt()&&this.registerRemovedElement(n),n instanceof Ti||n instanceof Pi)for(const r of n.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new gh(wr.create(to))}findByCreatedAt(t){const n=this.elementPairMapByCreatedAt.get(t.toIDString());if(n)return n.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let n=this.elementPairMapByCreatedAt.get(t.toIDString());if(!n)return[];const r=[];for(;n.parent;){const i=n.element.getCreatedAt(),o=n.parent.subPathOf(i);if(o===void 0)throw new Y(J.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(o),n=this.elementPairMapByCreatedAt.get(n.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,n){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:n,element:t}),t instanceof vu&&t.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(t){let n=0;const r=i=>{const o=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(o),this.gcElementSetByCreatedAt.delete(o),n++};return r(t),t instanceof vu&&t.getDescendants(i=>(r(i),!1)),n}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const n of this.gcElementSetByCreatedAt){t.add(n);const r=this.elementPairMapByCreatedAt.get(n);r.element instanceof vu&&r.element.getDescendants(i=>(t.add(i.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new gh(this.rootObject.deepcopy())}garbageCollect(t){let n=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),o=i.element.getRemovedAt();o&&(t!=null&&t.afterOrEqual(o))&&(i.parent.purge(i.element),n+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(t!=null&&t.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),n+=1)}return n}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function lB(e,t){const n=new mh(e);return new Proxy(t,n.getHandlers())}class mh{constructor(t){k(this,"context");k(this,"handlers");this.context=t,this.handlers={set:(n,r,i)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]=${JSON.stringify(i)}`),mh.setInternal(t,n,r,i),!0),get:(n,r)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]`),r==="getID"?()=>n.getCreatedAt():r==="toJSON"||r==="toString"?()=>n.toJSON():r==="toJS"?()=>n.toJS():r==="toJSForTest"?()=>n.toJSForTest():nl(t,n.get(r))),ownKeys:n=>n.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(n,r)=>($e.isEnabled(or.Trivial)&&$e.trivial(`obj[${r}]`),mh.deleteInternal(t,n,r),!0)}}static setInternal(t,n,r,i){if(r.includes("."))throw new Y(J.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),a=cm(t,i,o),s=n.set(r,a,o);t.registerElement(a,n),s&&t.registerRemovedElement(s),t.push(Tl.create(r,a.deepcopy(),n.getCreatedAt(),o))}static buildObjectMembers(t,n){const r={};for(const[i,o]of Object.entries(n)){if(i.includes("."))throw new Y(J.ErrInvalidObjectKey,"key must not contain the '.'.");const a=t.issueTimeTicket(),s=cm(t,o,a);r[i]=s}return r}static deleteInternal(t,n,r){const i=t.issueTimeTicket(),o=n.deleteByKey(r,i);o&&(t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o))}getHandlers(){return this.handlers}}function pVe(e,t){const n=new Xt(e,t);return new Proxy(t,n.getHandlers())}function gVe(e){return typeof e=="string"||e instanceof String?!isNaN(e):!1}function mVe(e){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(e)}class Xt{constructor(t,n){k(this,"context");k(this,"handlers");k(this,"array");this.context=t,this.array=n,this.handlers={get:(r,i,o)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?a=>{const s=r.getByID(a);if(!(!s||s.isRemoved()))return Xs(t,s)}:i==="getElementByIndex"?a=>{const s=r.get(a);return Xs(t,s)}:i==="getLast"?()=>Xs(t,r.getLast()):i==="deleteByID"?a=>{const s=Xt.deleteInternalByID(t,r,a);return Xs(t,s)}:i==="insertAfter"?(a,s)=>{const u=Xt.insertAfterInternal(t,r,a,s);return Xs(t,u)}:i==="insertBefore"?(a,s)=>{const u=Xt.insertBeforeInternal(t,r,a,s);return Xs(t,u)}:i==="moveBefore"?(a,s)=>{Xt.moveBeforeInternal(t,r,a,s)}:i==="moveAfter"?(a,s)=>{Xt.moveAfterInternal(t,r,a,s)}:i==="moveFront"?a=>{Xt.moveFrontInternal(t,r,a)}:i==="moveLast"?a=>{Xt.moveLastInternal(t,r,a)}:gVe(i)?nl(t,r.get(Number(i))):i==="push"?a=>Xt.pushInternal(t,r,a):i==="splice"?(a,s,...u)=>Xt.splice(t,r,a,s,...u):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?Xt.iteratorInternal.bind(this,t,r):i==="includes"?(a,s)=>Xt.includes(t,r,a,s):i==="indexOf"?(a,s)=>Xt.indexOf(t,r,a,s):i==="lastIndexOf"?(a,s)=>Xt.lastIndexOf(t,r,a,s):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>Xt.toTestString(r):typeof i=="string"&&mVe(i)?(...a)=>{const s=Array.from(r).map(u=>nl(t,u));return Array.prototype[i].apply(s,a)}:Reflect.get(r,i,o),deleteProperty:(r,i)=>($e.isEnabled(or.Trivial)&&$e.trivial(`array[${i}]`),Xt.deleteInternalByIndex(t,r,Number.parseInt(i)),!0)}}static*iteratorInternal(t,n){for(const r of n)yield Xs(t,r)}static buildArrayElements(t,n){const r=[];for(const i of n){const o=t.issueTimeTicket(),a=cm(t,i,o);r.push(a)}return r}static pushInternal(t,n,r){return Xt.insertAfterInternal(t,n,n.getLastCreatedAt(),r),n.length}static moveBeforeInternal(t,n,r,i){const o=t.issueTimeTicket(),a=n.getPrevCreatedAt(r);n.moveAfter(a,i,o),t.push(au.create(n.getCreatedAt(),a,i,o))}static moveAfterInternal(t,n,r,i){const o=t.issueTimeTicket();n.moveAfter(r,i,o),t.push(au.create(n.getCreatedAt(),r,i,o))}static moveFrontInternal(t,n,r){const i=t.issueTimeTicket(),o=n.getHead();n.moveAfter(o.getCreatedAt(),r,i),t.push(au.create(n.getCreatedAt(),o.getCreatedAt(),r,i))}static moveLastInternal(t,n,r){const i=t.issueTimeTicket(),o=n.getLastCreatedAt();n.moveAfter(o,r,i),t.push(au.create(n.getCreatedAt(),o,r,i))}static insertAfterInternal(t,n,r,i){const o=t.issueTimeTicket(),a=cm(t,i,o);return n.insertAfter(r,a),t.registerElement(a,n),t.push(_h.create(n.getCreatedAt(),r,a.deepcopy(),o)),a}static insertBeforeInternal(t,n,r,i){return Xt.insertAfterInternal(t,n,n.getPrevCreatedAt(r),i)}static deleteInternalByIndex(t,n,r){const i=t.issueTimeTicket(),o=n.deleteByIndex(r,i);if(o)return t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o),o}static deleteInternalByID(t,n,r){const i=t.issueTimeTicket(),o=n.delete(r,i);return t.push(Tu.create(n.getCreatedAt(),o.getCreatedAt(),i)),t.registerRemovedElement(o),o}static splice(t,n,r,i,...o){const a=n.length,s=r>=0?Math.min(r,a):Math.max(a+r,0),u=i===void 0?a:i<0?s:Math.min(s+i,a),d=[];for(let h=s;h=o)return!1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).includes(r,a);for(let u=a;u=o)return-1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).indexOf(r,a);for(let u=a;u=o?o-1:i<0?i+o:i;if(a<0)return-1;if(Jt.isSupport(r))return Array.from(n).map(d=>nl(t,d)).lastIndexOf(r,a);for(let u=a;u>0;u--)if(((s=n.get(u))==null?void 0:s.getID())===r.getID())return u;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}class S1{constructor(t,n){k(this,"context");k(this,"text");this.context=t,this.text=n}initialize(t,n){this.context=t,this.text=n}getID(){return this.text.getID()}edit(t,n,r,i){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.text.indexRangeToPosRange(t,n);$e.isEnabled(or.Debug)&&$e.debug(`EDIT: f:${t}->${o[0].toTestString()}, t:${n}->${o[1].toTestString()} c:${r}`);const a=i?ld(i):void 0,s=this.context.issueTimeTicket(),[u,,d,h]=this.text.edit(o,r,s,a);for(const p of d)this.context.registerGCPair(p);return this.context.push(new Nh(this.text.getCreatedAt(),o[0],o[1],u,r,a?new Map(Object.entries(a)):new Map,s)),this.text.findIndexesFromRange(h)}delete(t,n){return this.edit(t,n,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,n,r){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(t,n);$e.isEnabled(or.Debug)&&$e.debug(`STYL: f:${t}->${i[0].toTestString()}, t:${n}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const o=ld(r),a=this.context.issueTimeTicket(),[s,u]=this.text.setStyle(i,o,a);for(const d of u)this.context.registerGCPair(d);return this.context.push(new zh(this.text.getCreatedAt(),i[0],i[1],s,new Map(Object.entries(o)),a)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");const n=this.text.indexRangeToPosRange(t[0],t[1]);return[n[0].toStruct(),n[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");const n=this.text.findIndexesFromRange([no.fromStruct(t[0]),no.fromStruct(t[1])]);return[n[0],n[1]]}toTestString(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,n){if(!this.context||!this.text)throw new Y(J.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,n)}}class x1{constructor(t,n){k(this,"valueType");k(this,"value");k(this,"context");k(this,"counter");this.valueType=t,this.value=n}initialize(t,n){this.valueType=n.getValueType(),this.context=t,this.counter=n,this.value=n.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new Y(J.ErrNotInitialized,"Counter is not initialized yet");const n=this.context.issueTimeTicket(),r=Jt.of(t,n);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(fd.create(this.counter.getCreatedAt(),r,n)),this}toJSForTest(){if(!this.context||!this.counter)throw new Y(J.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function ZC(e,t,n){const{type:r}=e,i=n.issueTimeTicket();if(r===vs){cB(e);const{value:o}=e,a=Nr.create(Fn.of(i,0),r,o);t.append(a)}else{const{children:o=[]}=e,{attributes:a}=e;let s;if(typeof a=="object"&&!$P(a)){const d=ld(a);s=new Ds;for(const[h,p]of Object.entries(d))s.set(h,p,i)}const u=Nr.create(Fn.of(i,0),r,void 0,s);t.append(u);for(const d of o)ZC(d,u,n)}}function vVe(e,t){const{type:n}=t,r=e.issueTimeTicket();let i;if(t.type===vs){const{value:o}=t;i=Nr.create(Fn.of(r,0),n,o)}else if(t){const{children:o=[]}=t,{attributes:a}=t;let s;if(typeof a=="object"&&!$P(a)){const u=ld(a);s=new Ds;for(const[d,h]of Object.entries(u))s.set(d,h,r)}i=Nr.create(Fn.of(e.issueTimeTicket(),0),n,void 0,s);for(const u of o)ZC(u,i,e)}return i}function cB(e){if(!e.value.length)throw new Y(J.ErrInvalidArgument,"text node cannot have empty value");return!0}function Mx(e){if(!e.length)return!0;if(e[0].type===vs)for(const n of e){const{type:r}=n;if(r!==vs)throw new Y(J.ErrInvalidArgument,"element node and text node cannot be passed together");cB(n)}else for(const n of e){const{type:r}=n;if(r===vs)throw new Y(J.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class A1{constructor(t){k(this,"initialRoot");k(this,"context");k(this,"tree");this.initialRoot=t}initialize(t,n){this.context=t,this.tree=n}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return Nr.create(Fn.of(t.issueTimeTicket(),0),gKe);const n=Nr.create(Fn.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)ZC(r,n,t);return n}getSize(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,n){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(t),o=this.context.issueTimeTicket(),a=n?ld(n):void 0,[s]=this.tree.style([r,i],a,o);this.context.push(ys.create(this.tree.getCreatedAt(),r,i,s,a?new Map(Object.entries(a)):new Map,o))}style(t,n,r){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(n),a=this.context.issueTimeTicket(),s=r?ld(r):void 0,[u,d]=this.tree.style([i,o],s,a);for(const h of d)this.context.registerGCPair(h);this.context.push(ys.create(this.tree.getCreatedAt(),i,o,u,s?new Map(Object.entries(s)):new Map,a))}removeStyle(t,n,r){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(t),o=this.tree.findPos(n),a=this.context.issueTimeTicket(),[s,u]=this.tree.removeStyle([i,o],r,a);for(const d of u)this.context.registerGCPair(d);this.context.push(ys.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,o,s,r,a))}editInternal(t,n,r,i=0){var d;if(r.length!==0&&r[0]&&(Mx(r),r[0].type!==vs))for(const h of r){const{children:p=[]}=h;Mx(p)}const o=this.context.getLastTimeTicket();let a=new Array;if(((d=r[0])==null?void 0:d.type)===vs){let h="";for(const p of r){const{value:g}=p;h+=g}a.push(Nr.create(Fn.of(this.context.issueTimeTicket(),0),vs,h))}else a=r.map(h=>h&&vVe(this.context,h)).filter(h=>h);const[,s,u]=this.tree.edit([t,n],a.length?a.map(h=>h==null?void 0:h.deepcopy()):void 0,i,o,()=>this.context.issueTimeTicket());for(const h of s)this.context.registerGCPair(h);return this.context.push(Hh.create(this.tree.getCreatedAt(),t,n,a.length?a:void 0,i,u,o)),!0}editByPath(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==n.length)throw new Y(J.ErrInvalidArgument,"path length should be equal");if(!t.length||!n.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),a=this.tree.pathToPos(n);return this.editInternal(o,a,r?[r]:[],i)}editBulkByPath(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==n.length)throw new Y(J.ErrInvalidArgument,"path length should be equal");if(!t.length||!n.length)throw new Y(J.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),a=this.tree.pathToPos(n);return this.editInternal(o,a,r,i)}edit(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),a=this.tree.findPos(n);return this.editInternal(o,a,r?[r]:[],i)}editBulk(t,n,r,i=0){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");if(t>n)throw new Y(J.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),a=this.tree.findPos(n);return this.editInternal(o,a,r,i)}toXML(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],r=this.tree.indexRangeToPosRange(n);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[Xi.fromStruct(t[0]),Xi.fromStruct(t[1])];return this.tree.posRangeToIndexRange(n)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new Y(J.ErrNotInitialized,"Tree is not initialized yet");const n=[Xi.fromStruct(t[0]),Xi.fromStruct(t[1])];return this.tree.posRangeToPathRange(n)}}function $x(e,t){return lB(e,t)}function Xs(e,t){if(t){if(t instanceof Jt)return t;if(t instanceof wr)return lB(e,t);if(t instanceof jr)return pVe(e,t);if(t instanceof Ti)return new S1(e,t);if(t instanceof Ur){const n=new x1(Ko.IntegerCnt,0);return n.initialize(e,t),n}else if(t instanceof Pi){const n=new A1;return n.initialize(e,t),n}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function nl(e,t){const n=Xs(e,t);return n instanceof Jt?n.getValue():n}function cm(e,t,n){let r;if(Jt.isSupport(t))r=Jt.of(t,n);else if(Array.isArray(t))r=jr.create(n,Xt.buildArrayElements(e,t));else if(typeof t=="object")t instanceof S1?(r=Ti.create(hd.create(),n),t.initialize(e,r)):t instanceof x1?(r=Ur.create(t.getValueType(),t.getValue(),n),t.initialize(e,r)):t instanceof A1?(r=Pi.create(t.buildRoot(e),n),t.initialize(e,r)):r=wr.create(n,mh.buildObjectMembers(e,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return r}const Rx=50;class yVe{constructor(){k(this,"undoStack",[]);k(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Rx&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Rx&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const EVe="yorkie-devtools-panel",CVe="yorkie-devtools-sdk";let pc="disconnected";const Fx=new Map,qp=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=qp);function kp(e,t){(t!=null&&t.force||pc!=="disconnected")&&window.postMessage({source:CVe,...e},"*")}function bVe(e){if(!e.isEnableDevtools()||typeof window>"u"||Fx.has(e.getKey()))return;qp.set(e.getKey(),[]);const t=e.subscribe("all",n=>{n.some(r=>r.type!==bn.StatusChanged&&r.type!==bn.Snapshot&&r.type!==bn.LocalChange&&r.type!==bn.RemoteChange&&r.type!==bn.Initialized&&r.type!==bn.Watched&&r.type!==bn.Unwatched&&r.type!==bn.PresenceChanged)||(qp.get(e.getKey()).push(n),pc==="synced"&&kp({msg:"doc::sync::partial",docKey:e.getKey(),event:n}))});Fx.set(e.getKey(),[t]),kp({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",n=>{var i;if(((i=n.data)==null?void 0:i.source)!==EVe)return;switch(n.data.msg){case"devtools::connect":if(pc!=="disconnected")break;pc="connected",kp({msg:"doc::available",docKey:e.getKey()}),$e.info(`[YD] Devtools connected. Doc: ${e.getKey()}`);break;case"devtools::disconnect":pc="disconnected",$e.info(`[YD] Devtools disconnected. Doc: ${e.getKey()}`);break;case"devtools::subscribe":pc="synced",kp({msg:"doc::sync::full",docKey:e.getKey(),events:qp.get(e.getKey())}),$e.info(`[YD] Devtools subscribed. Doc: ${e.getKey()}`);break}})}var Zs=(e=>(e.Detached="detached",e.Attached="attached",e.Removed="removed",e))(Zs||{}),bn=(e=>(e.StatusChanged="status-changed",e.ConnectionChanged="connection-changed",e.SyncStatusChanged="sync-status-changed",e.Snapshot="snapshot",e.LocalChange="local-change",e.RemoteChange="remote-change",e.Initialized="initialized",e.Watched="watched",e.Unwatched="unwatched",e.PresenceChanged="presence-changed",e.Broadcast="broadcast",e.LocalBroadcast="local-broadcast",e.AuthError="auth-error",e))(bn||{}),b3=(e=>(e.Connected="connected",e.Disconnected="disconnected",e))(b3||{}),w3=(e=>(e.Synced="synced",e.SyncFailed="sync-failed",e))(w3||{});class QC{constructor(t,n){k(this,"key");k(this,"status");k(this,"opts");k(this,"changeID");k(this,"checkpoint");k(this,"localChanges");k(this,"root");k(this,"clone");k(this,"eventStream");k(this,"eventStreamObserver");k(this,"onlineClients");k(this,"presences");k(this,"history");k(this,"internalHistory");k(this,"isUpdating");this.opts=n||{},this.key=t,this.status="detached",this.root=gh.create(),this.changeID=xKe,this.checkpoint=AKe,this.localChanges=[],this.eventStream=fVe(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new yVe,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},bVe(this)}update(t,n){if(this.getStatus()==="removed")throw new Y(J.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},n);try{const o=$x(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,t(o,new r2(i,this.clone.presences.get(r)))}catch(o){throw this.clone=void 0,o}finally{this.isUpdating=!1}if(i.hasChange()){$e.isEnabled(or.Trivial)&&$e.trivial(`trying to update a local change: ${this.toJSON()}`);const o=i.getChange(),{opInfos:a,reverseOps:s}=o.execute(this.root,this.presences,xt.Local),u=i.getReversePresence();u&&s.push({type:"presence",value:u}),this.localChanges.push(o),s.length>0&&this.internalHistory.pushUndo(s),a.length>0&&this.internalHistory.clearRedo(),this.changeID=o.getID();const d=[];a.length>0&&d.push({type:"local-change",source:xt.Local,value:{message:o.getMessage()||"",operations:a,actor:r,clientSeq:o.getID().getClientSeq(),serverSeq:o.getID().getServerSeq()},rawChange:this.isEnableDevtools()?o.toStruct():void 0}),o.hasPresenceChange()&&d.push({type:"presence-changed",source:xt.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(d),$e.isEnabled(or.Trivial)&&$e.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,n,r,i){if(typeof t=="string"){if(typeof n!="function")throw new Y(J.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="initialized"&&d.type!=="watched"&&d.type!=="unwatched"&&d.type!=="presence-changed"||s(d)},r,i)}if(t==="my-presence"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="initialized"&&d.type!=="presence-changed"||d.type==="presence-changed"&&d.value.clientID!==this.changeID.getActorID()||s(d)},r,i)}if(t==="others"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="watched"&&d.type!=="unwatched"&&d.type!=="presence-changed"||d.value.clientID!==this.changeID.getActorID()&&s(d)},r,i)}if(t==="connection"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="connection-changed"&&s(d)},r,i)}if(t==="status"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="status-changed"&&s(d)},r,i)}if(t==="sync"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="sync-status-changed"&&s(d)},r,i)}if(t==="local-broadcast"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="local-broadcast"&&s(d)},r)}if(t==="broadcast"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="broadcast"&&s(d)},r)}if(t==="auth-error"){const s=n;return this.eventStream.subscribe(u=>{for(const d of u)d.type==="auth-error"&&s(d)},r)}if(t==="all"){const s=n;return this.eventStream.subscribe(s,r,i)}const o=t,a=n;return this.eventStream.subscribe(s=>{for(const u of s){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const d=[];for(const h of u.value.operations)this.isSameElementOrChildOf(h.path,o)&&d.push(h);d.length&&a({...u,value:{...u.value,operations:d}})}},r,i)}if(typeof t=="function"){const o=t,a=n,s=r;return this.eventStream.subscribe(u=>{for(const d of u)d.type!=="snapshot"&&d.type!=="local-change"&&d.type!=="remote-change"||o(d)},a,s)}throw new Y(J.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,n){if(n===t)return!0;const r=t.split(".");return n.split(".").every((o,a)=>o===r[a])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const n=t.hasSnapshot();n?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),xt.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),n||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),$e.isEnabled(or.Trivial)&&$e.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Gi(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),n=this.checkpoint.increaseClientSeq(t.length);return w1.create(this.key,n,!1,t,this.getVersionVector())}setActor(t){for(const n of this.localChanges)n.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return $x(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,n,r,i=-1){const{root:o,presences:a}=on.bytesToSnapshot(r);this.root=new gh(o),this.presences=a,this.changeID=this.changeID.setClocks(n.maxLamport(),n),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,xt.Local),this.publish([{type:"snapshot",source:xt.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?on.bytesToHex(r):void 0,snapshotVector:on.versionVectorToHex(n)}}])}applyChanges(t,n){$e.isEnabled(or.Debug)&&$e.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),$e.isEnabled(or.Trivial)&&$e.trivial(t.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` +`));for(const r of t)this.applyChange(r,n);$e.isEnabled(or.Debug)&&$e.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,n){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,n);const r=[],i=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(i)){const a=t.getPresenceChange();switch(a.type){case Du.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:n,value:{clientID:i,presence:a.presence}}:{type:"watched",source:xt.Remote,value:{clientID:i,presence:a.presence}});break;case Du.Clear:r.push({type:"unwatched",source:xt.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:o}=t.execute(this.root,this.presences,n);if(this.changeID=this.changeID.syncClocks(t.getID()),o.length>0){const a=this.isEnableDevtools()?t.toStruct():void 0;r.push(n===xt.Remote?{type:"remote-change",source:n,value:{actor:i,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:a}:{type:"local-change",source:n,value:{actor:i,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:a})}r.length>0&&this.publish(r)}applyWatchStream(t){if(t.body.case==="initialization"){const n=t.body.value.clientIds,r=new Set;for(const i of n)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:xt.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:n,publisher:r}=t.body.value,i=[];if(n===ml.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:xt.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(n===ml.DOCUMENT_UNWATCHED){const o=this.getPresence(r);this.removeOnlineClient(r),o&&i.push({type:"unwatched",source:xt.Remote,value:{clientID:r,presence:o}})}else if(n===ml.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:o,payload:a}=t.body.value.body,s=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:o,payload:JSON.parse(s.decode(a))}})}i.length>0&&this.publish(i)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(C1),this.publish([{source:t==="removed"?xt.Remote:xt.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:n,serverSeq:r,snapshotVector:i}=t.value;if(!n)return;this.applySnapshot(BigInt(r),on.hexToVersionVector(i),on.hexToBytes(n));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const n=dd.fromStruct(t.rawChange);this.applyChange(n,t.source)}if(t.type==="initialized"){const n=new Set;for(const{clientID:r,presence:i}of t.value)n.add(r),this.presences.set(r,i);this.setOnlineClients(n);return}if(t.type==="watched"){const{clientID:n,presence:r}=t.value;this.addOnlineClient(n),this.presences.set(n,r);return}if(t.type==="unwatched"){const{clientID:n}=t.value;this.removeOnlineClient(n),this.presences.delete(n)}if(t.type==="presence-changed"){const{clientID:n,presence:r}=t.value;this.presences.set(n,r)}}applyTransactionEvent(t){for(const n of t)this.applyDocEvent(n)}getValueByPath(t){if(!t.startsWith("$"))throw new Y(J.ErrInvalidArgument,'path must start with "$"');const n=t.split(".");n.shift();let r=this.getRoot();for(const i of n)if(r=r[i],r===void 0)return;return r}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?Gi(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const n=this.presences.get(t);return n?Gi(n):void 0}getPresenceForTest(t){const n=this.presences.get(t);return n?Gi(n):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:Gi(this.getMyPresence())});for(const n of this.onlineClients)this.presences.has(n)&&t.push({clientID:n,presence:Gi(this.presences.get(n))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(n=>n.clientID!==t).sort((n,r)=>n.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const r=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new Y(J.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new Y(J.ErrRefused,"There is no operation to be undone");this.ensureClone();const n=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const d of t){if(!(d instanceof so)){new r2(n,Gi(this.clone.presences.get(this.changeID.getActorID()))).set(d.value,{addToHistory:!0});continue}const h=n.issueTimeTicket();d.setExecutedAt(h),n.push(d)}const r=n.getChange();r.execute(this.clone.root,this.clone.presences,xt.UndoRedo);const{opInfos:i,reverseOps:o}=r.execute(this.root,this.presences,xt.UndoRedo),a=n.getReversePresence();if(a&&o.push({type:"presence",value:a}),o.length>0&&this.internalHistory.pushRedo(o),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const s=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:xt.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:s,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:xt.UndoRedo,value:{clientID:s,presence:this.getPresence(s)}}),this.publish(u)}redo(){if(this.isUpdating)throw new Y(J.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new Y(J.ErrRefused,"There is no operation to be redone");this.ensureClone();const n=Pc.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const d of t){if(!(d instanceof so)){new r2(n,Gi(this.clone.presences.get(this.changeID.getActorID()))).set(d.value,{addToHistory:!0});continue}const h=n.issueTimeTicket();d.setExecutedAt(h),n.push(d)}const r=n.getChange();r.execute(this.clone.root,this.clone.presences,xt.UndoRedo);const{opInfos:i,reverseOps:o}=r.execute(this.root,this.presences,xt.UndoRedo),a=n.getReversePresence();if(a&&o.push({type:"presence",value:a}),o.length>0&&this.internalHistory.pushUndo(o),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const s=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:xt.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:s,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:xt.UndoRedo,value:{clientID:s,presence:this.getPresence(s)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,n,r){const i={type:"local-broadcast",value:{topic:t,payload:n},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function wVe(e,t){let n=t;return{authInterceptor:o=>async a=>(e&&a.header.set("x-api-key",e),n&&a.header.set("authorization",n),await o(a)),setToken:o=>{n=o}}}const SVe="yorkie-js-sdk",xVe="0.5.6",AVe="Yorkie JS SDK",kVe="./src/yorkie.ts",IVe={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},DVe=["dist"],TVe={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},PVe={node:">=18.0.0",npm:">=7.1.0"},BVe={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},MVe={name:"hackerwins",email:"susukang98@gmail.com"},$Ve="Apache-2.0",RVe={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},FVe="https://github.com/yorkie-team/yorkie-js-sdk#readme",LVe={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},OVe={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Lx={name:SVe,version:xVe,description:AVe,main:kVe,publishConfig:IVe,files:DVe,scripts:TVe,engines:PVe,repository:BVe,author:MVe,license:$Ve,bugs:RVe,homepage:FVe,devDependencies:LVe,dependencies:OVe};function _Ve(){return e=>async t=>(t.header.set("x-yorkie-user-agent",Lx.name+"/"+Lx.version),await e(t))}const NVe=e=>{try{if(JSON.stringify(e)===void 0)return!1}catch{return!1}return!0};var Xp=(e=>(e.Manual="manual",e.Realtime="realtime",e.RealtimePushOnly="realtime-pushonly",e.RealtimeSyncOff="realtime-syncoff",e))(Xp||{});const Ip={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},s2={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class e9{constructor(t,n){k(this,"id");k(this,"key");k(this,"status");k(this,"attachmentMap");k(this,"apiKey");k(this,"authTokenInjector");k(this,"conditions");k(this,"syncLoopDuration");k(this,"reconnectStreamDelay");k(this,"retrySyncLoopDelay");k(this,"rpcClient");k(this,"setAuthToken");k(this,"taskQueue");k(this,"processing",!1);k(this,"keepalive",!1);n=n||Ip,this.key=n.key?n.key:uB(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=n.apiKey||"",this.authTokenInjector=n.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=n.syncLoopDuration??Ip.syncLoopDuration,this.reconnectStreamDelay=n.reconnectStreamDelay??Ip.reconnectStreamDelay,this.retrySyncLoopDelay=n.retrySyncLoopDelay??Ip.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=wVe(this.apiKey);this.setAuthToken=i,this.rpcClient=_Ue(sKe,aKe({baseUrl:t,interceptors:[r,_Ve()],fetch:(o,a)=>{const s={...a,keepalive:this.keepalive};return fetch(o,s)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),$e.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw $e.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const n=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),$e.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw $e.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(t.keepalive){this.keepalive=!0;const r=n();return this.keepalive=!1,r}return this.enqueueTask(n)}attach(t,n={}){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==Zs.Detached)throw new Y(J.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((o,a)=>a.set(n.initialPresence||{}));const r=t.subscribe("local-broadcast",async o=>{var h;const{topic:a,payload:s}=o.value,u=(h=o.options)==null?void 0:h.error,d=o.options;try{await this.broadcast(t.getKey(),a,s,d)}catch(p){p instanceof Error&&(u==null||u(p))}}),i=n.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:on.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async o=>{const a=on.fromChangePack(o.changePack);if(t.applyChangePack(a),t.getStatus()===Zs.Removed)return t;t.applyStatus(Zs.Attached),this.attachmentMap.set(t.getKey(),new dVe(this.reconnectStreamDelay,t,o.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(t.getKey()),$e.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const s=t.getRootObject();if(n.initialRoot){const u=n.initialRoot;t.update(d=>{for(const[h,p]of Object.entries(u))if(!s.has(h)){const g=h;d[g]=p}})}return t}).catch(async o=>{throw $e.error(`[AD] c:"${this.getKey()}" err :`,o),await this.handleConnectError(o),o}))}detach(t,n={}){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((i,o)=>o.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:on.toChangePack(t.createChangePack()),removeIfNotAttached:n.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(i=>{const o=on.fromChangePack(i.changePack);return t.applyChangePack(o),t.getStatus()!==Zs.Removed&&t.applyStatus(Zs.Detached),this.detachInternal(t.getKey()),$e.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async i=>{throw $e.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(t,n){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(t.getKey());if(!r)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const i=r.syncMode;return i===n?t:(r.changeSyncMode(n),n==="manual"?(r.cancelWatchStream(),t):(n==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);if(t){const n=this.attachmentMap.get(t.getKey());if(!n)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(n,"realtime").catch(async r=>{throw $e.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const n=[];for(const[,r]of this.attachmentMap)n.push(this.syncInternal(r,r.syncMode));return Promise.all(n).catch(async r=>{throw $e.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(t){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new Y(J.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const r=on.toChangePack(t.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:n.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(i=>{const o=on.fromChangePack(i.changePack);t.applyChangePack(o),this.detachInternal(t.getKey()),$e.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async i=>{throw $e.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,n,r,i){if(!this.isActive())throw new Y(J.ErrClientNotActivated,`${this.key} is not active`);const o=this.attachmentMap.get(t);if(!o)throw new Y(J.ErrDocumentNotAttached,`${t} is not attached`);if(!NVe(r))throw new Y(J.ErrInvalidArgument,"payload is not serializable");const a=(i==null?void 0:i.maxRetries)??s2.maxRetries,s=s2.maxBackoff;let u=0;const d=p=>Math.min(s2.initialRetryInterval*2**p,s),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:o.docID,topic:n,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{$e.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${n}"`)}).catch(async p=>{if($e.error(`[BC] c:"${this.getKey()}" err:`,p),await this.handleConnectError(p))if(p instanceof Nt&&dc(p)===J.ErrUnauthenticated&&o.doc.publish([{type:bn.AuthError,value:{reason:f0(p).reason,method:"Broadcast"}}]),uh(),d(u-1)),$e.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${a}`);else throw $e.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),p;else throw p}));return h()}runSyncLoop(){const t=()=>{if(!this.isActive()){$e.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const n=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,n.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof Nt&&dc(i)===J.ErrUnauthenticated&&r.doc.publish([{type:bn.AuthError,value:{reason:f0(i).reason,method:"PushPull"}}]),i})));Promise.all(n).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async r=>{$e.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};$e.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const n=this.attachmentMap.get(t);if(!n)throw new Y(J.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,n.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new Y(J.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,o=this.rpcClient.watchDocument({clientId:this.id,documentId:n.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:i.signal});return n.doc.publish([{type:bn.ConnectionChanged,value:b3.Connected}]),$e.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((a,s)=>{(async()=>{try{for await(const d of o)this.handleWatchDocumentsResponse(n,d),d.body.case==="initialization"&&a([o,i])}catch(d){n.doc.resetOnlineClients(),n.doc.publish([{type:bn.Initialized,source:xt.Local,value:n.doc.getPresences()}]),n.doc.publish([{type:bn.ConnectionChanged,value:b3.Disconnected}]),$e.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(d)?(d instanceof Nt&&dc(d)===J.ErrUnauthenticated&&n.doc.publish([{type:bn.AuthError,value:{reason:f0(d).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,s(d)}})()})})}handleWatchDocumentsResponse(t,n){if(n.body.case==="event"&&n.body.value.type===ml.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(n)}deactivateInternal(){this.status="deactivated";for(const[t,n]of this.attachmentMap)this.detachInternal(t),n.doc.applyStatus(Zs.Detached)}detachInternal(t){const n=this.attachmentMap.get(t);n&&(n.cancelWatchStream(),n.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,n){const{doc:r,docID:i}=t,o=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:on.toChangePack(o),pushOnly:n==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(a=>{const s=on.fromChangePack(a.changePack);if(s.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return r;r.applyChangePack(s),t.doc.publish([{type:bn.SyncStatusChanged,value:w3.Synced}]),r.getStatus()===Zs.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),d=s.getChangeSize();return $e.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${o.getChangeSize()} pull:${d} cp:${s.getCheckpoint().toTestString()}`),r}).catch(async a=>{throw r.publish([{type:bn.SyncStatusChanged,value:w3.SyncFailed}]),$e.error(`[PP] c:"${this.getKey()}" err :`,a),a})}async handleConnectError(t){if(!(t instanceof Nt))return!1;if(t.code===vt.Canceled||t.code===vt.Unknown||t.code===vt.ResourceExhausted||t.code===vt.Unavailable)return!0;if(dc(t)===J.ErrUnauthenticated){if(this.authTokenInjector){const n=await this.authTokenInjector(f0(t).reason);this.setAuthToken(n)}return!0}return(dc(t)===J.ErrClientNotActivated||dc(t)===J.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((n,r)=>{this.taskQueue.push(()=>t().then(n).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{$e.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}Ko.IntegerCnt,Ko.LongCnt;typeof globalThis<"u"&&(globalThis.yorkie={Client:e9,Document:QC,Primitive:Jt,Text:S1,Counter:x1,Tree:A1,LogLevel:or,setLogLevel:sB,IntType:Ko.IntegerCnt,LongType:Ko.LongCnt});var S3={exports:{}};(function(e,t){(function(n,r){{var i=r();e&&e.exports&&(t=e.exports=i),t.randomColor=i}})(fc,function(){var n=null,r={};C();var i=[],o=function(I){if(I=I||{},I.seed!==void 0&&I.seed!==null&&I.seed===parseInt(I.seed,10))n=I.seed;else if(typeof I.seed=="string")n=B(I.seed);else{if(I.seed!==void 0&&I.seed!==null)throw new TypeError("The seed value must be an integer or string");n=null}var M,O,z;if(I.count!==null&&I.count!==void 0){for(var K=I.count,X=[],Z=0;ZX.length;){var pe=o(I);n!==null&&(I.seed=n),X.push(pe)}return I.count=K,X}return M=a(I),O=s(M,I),z=u(M,O,I),d([M,O,z],I)};function a(I){if(i.length>0){var M=D(I.hue),O=v(M),z=(M[1]-M[0])/i.length,K=parseInt((O-M[0])/z);i[K]===!0?K=(K+2)%i.length:i[K]=!0;var X=(M[0]+K*z)%359,Z=(M[0]+(K+1)*z)%359;return M=[X,Z],O=v(M),O<0&&(O=360+O),O}else{var M=p(I.hue);return O=v(M),O<0&&(O=360+O),O}}function s(I,M){if(M.hue==="monochrome")return 0;if(M.luminosity==="random")return v([0,100]);var O=g(I),z=O[0],K=O[1];switch(M.luminosity){case"bright":z=55;break;case"dark":z=K-10;break;case"light":K=55;break}return v([z,K])}function u(I,M,O){var z=h(I,M),K=100;switch(O.luminosity){case"dark":K=z+20;break;case"light":z=(K+z)/2;break;case"random":z=0,K=100;break}return v([z,K])}function d(I,M){switch(M.format){case"hsvArray":return I;case"hslArray":return T(I);case"hsl":var O=T(I);return"hsl("+O[0]+", "+O[1]+"%, "+O[2]+"%)";case"hsla":var z=T(I),Z=M.alpha||Math.random();return"hsla("+z[0]+", "+z[1]+"%, "+z[2]+"%, "+Z+")";case"rgbArray":return b(I);case"rgb":var K=b(I);return"rgb("+K.join(", ")+")";case"rgba":var X=b(I),Z=M.alpha||Math.random();return"rgba("+X.join(", ")+", "+Z+")";default:return E(I)}}function h(I,M){for(var O=m(I).lowerBounds,z=0;z=K&&M<=Z){var me=(pe-X)/(Z-K),Ce=X-me*K;return me*M+Ce}}return 0}function p(I){if(typeof parseInt(I)=="number"){var M=parseInt(I);if(M<360&&M>0)return[M,M]}if(typeof I=="string"){if(r[I]){var O=r[I];if(O.hueRange)return O.hueRange}else if(I.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)){var z=A(I)[0];return[z,z]}}return[0,360]}function g(I){return m(I).saturationRange}function m(I){I>=334&&I<=360&&(I-=360);for(var M in r){var O=r[M];if(O.hueRange&&I>=O.hueRange[0]&&I<=O.hueRange[1])return r[M]}return"Color not found"}function v(I){if(n===null){var M=.618033988749895,O=Math.random();return O+=M,O%=1,Math.floor(I[0]+O*(I[1]+1-I[0]))}else{var z=I[1]||1,K=I[0]||0;n=(n*9301+49297)%233280;var X=n/233280;return Math.floor(K+X*(z-K))}}function E(I){var M=b(I);function O(K){var X=K.toString(16);return X.length==1?"0"+X:X}var z="#"+O(M[0])+O(M[1])+O(M[2]);return z}function w(I,M,O){var z=O[0][0],K=O[O.length-1][0],X=O[O.length-1][1],Z=O[0][1];r[I]={hueRange:M,lowerBounds:O,saturationRange:[z,K],brightnessRange:[X,Z]}}function C(){w("monochrome",null,[[0,0],[100,0]]),w("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),w("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),w("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),w("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),w("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),w("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),w("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]])}function b(I){var M=I[0];M===0&&(M=1),M===360&&(M=359),M=M/360;var O=I[1]/100,z=I[2]/100,K=Math.floor(M*6),X=M*6-K,Z=z*(1-O),pe=z*(1-X*O),me=z*(1-(1-X)*O),Ce=256,W=256,U=256;switch(K){case 0:Ce=z,W=me,U=Z;break;case 1:Ce=pe,W=z,U=Z;break;case 2:Ce=Z,W=z,U=me;break;case 3:Ce=Z,W=pe,U=z;break;case 4:Ce=me,W=Z,U=z;break;case 5:Ce=z,W=Z,U=pe;break}var ne=[Math.floor(Ce*255),Math.floor(W*255),Math.floor(U*255)];return ne}function A(I){I=I.replace(/^#/,""),I=I.length===3?I.replace(/(.)/g,"$1$1"):I;var M=parseInt(I.substr(0,2),16)/255,O=parseInt(I.substr(2,2),16)/255,z=parseInt(I.substr(4,2),16)/255,K=Math.max(M,O,z),X=K-Math.min(M,O,z),Z=K?X/K:0;switch(K){case M:return[60*((O-z)/X%6)||0,Z,K];case O:return[60*((z-M)/X+2)||0,Z,K];case z:return[60*((M-O)/X+4)||0,Z,K]}}function T(I){var M=I[0],O=I[1]/100,z=I[2]/100,K=(2-O)*z;return[M,Math.round(O*z/(K<1?K:2-K)*1e4)/100,K/2*100]}function B(I){for(var M=0,O=0;O!==I.length&&!(M>=Number.MAX_SAFE_INTEGER);O++)M+=I.charCodeAt(O);return M}function D(I){if(isNaN(I)){if(typeof I=="string"){if(r[I]){var O=r[I];if(O.hueRange)return O.hueRange}else if(I.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)){var z=A(I)[0];return m(z).hueRange}}}else{var M=parseInt(I);if(M<360&&M>0)return m(I).hueRange}return[0,360]}return o})})(S3,S3.exports);var zVe=S3.exports;const HVe=vh(zVe),Ox=e=>{e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296};class jVe{constructor(t){this.dictionaries=void 0,this.length=void 0,this.separator=void 0,this.style=void 0,this.seed=void 0;const{length:n,separator:r,dictionaries:i,style:o,seed:a}=t;this.dictionaries=i,this.separator=r,this.length=n,this.style=o,this.seed=a}generate(){if(!this.dictionaries)throw new Error('Cannot find any dictionary. Please provide at least one, or leave the "dictionary" field empty in the config object');if(this.length<=0)throw new Error("Invalid length provided");if(this.length>this.dictionaries.length)throw new Error(`The length cannot be bigger than the number of dictionaries. Length provided: ${this.length}. Number of dictionaries provided: ${this.dictionaries.length}`);let t=this.seed;return this.dictionaries.slice(0,this.length).reduce((n,r)=>{let i;t?(i=(a=>{if(typeof a=="string"){const s=a.split("").map(d=>d.charCodeAt(0)).reduce((d,h)=>d+h,1),u=Math.floor(Number(s));return Ox(u)}return Ox(a)})(t),t=4294967296*i):i=Math.random();let o=r[Math.floor(i*r.length)]||"";if(this.style==="lowerCase")o=o.toLowerCase();else if(this.style==="capital"){const[a,...s]=o.split("");o=a.toUpperCase()+s.join("")}else this.style==="upperCase"&&(o=o.toUpperCase());return n?`${n}${this.separator}${o}`:`${o}`},"")}}const _x={separator:"_",dictionaries:[]},UVe=e=>{const t=[...e&&e.dictionaries||_x.dictionaries],n={..._x,...e,length:e&&e.length||t.length,dictionaries:t};if(!e||!e.dictionaries||!e.dictionaries.length)throw new Error('A "dictionaries" array must be provided. This is a breaking change introduced starting from Unique Name Generator v4. Read more about the breaking change here: https://github.com/andreasonny83/unique-names-generator#migration-guide');return new jVe(n).generate()};var KVe=["Aaren","Aarika","Abagael","Abagail","Abbe","Abbey","Abbi","Abbie","Abby","Abbye","Abigael","Abigail","Abigale","Abra","Ada","Adah","Adaline","Adan","Adara","Adda","Addi","Addia","Addie","Addy","Adel","Adela","Adelaida","Adelaide","Adele","Adelheid","Adelice","Adelina","Adelind","Adeline","Adella","Adelle","Adena","Adey","Adi","Adiana","Adina","Adora","Adore","Adoree","Adorne","Adrea","Adria","Adriaens","Adrian","Adriana","Adriane","Adrianna","Adrianne","Adriena","Adrienne","Aeriel","Aeriela","Aeriell","Afton","Ag","Agace","Agata","Agatha","Agathe","Aggi","Aggie","Aggy","Agna","Agnella","Agnes","Agnese","Agnesse","Agneta","Agnola","Agretha","Aida","Aidan","Aigneis","Aila","Aile","Ailee","Aileen","Ailene","Ailey","Aili","Ailina","Ailis","Ailsun","Ailyn","Aime","Aimee","Aimil","Aindrea","Ainslee","Ainsley","Ainslie","Ajay","Alaine","Alameda","Alana","Alanah","Alane","Alanna","Alayne","Alberta","Albertina","Albertine","Albina","Alecia","Aleda","Aleece","Aleen","Alejandra","Alejandrina","Alena","Alene","Alessandra","Aleta","Alethea","Alex","Alexa","Alexandra","Alexandrina","Alexi","Alexia","Alexina","Alexine","Alexis","Alfi","Alfie","Alfreda","Alfy","Ali","Alia","Alica","Alice","Alicea","Alicia","Alida","Alidia","Alie","Alika","Alikee","Alina","Aline","Alis","Alisa","Alisha","Alison","Alissa","Alisun","Alix","Aliza","Alla","Alleen","Allegra","Allene","Alli","Allianora","Allie","Allina","Allis","Allison","Allissa","Allix","Allsun","Allx","Ally","Allyce","Allyn","Allys","Allyson","Alma","Almeda","Almeria","Almeta","Almira","Almire","Aloise","Aloisia","Aloysia","Alta","Althea","Alvera","Alverta","Alvina","Alvinia","Alvira","Alyce","Alyda","Alys","Alysa","Alyse","Alysia","Alyson","Alyss","Alyssa","Amabel","Amabelle","Amalea","Amalee","Amaleta","Amalia","Amalie","Amalita","Amalle","Amanda","Amandi","Amandie","Amandy","Amara","Amargo","Amata","Amber","Amberly","Ambur","Ame","Amelia","Amelie","Amelina","Ameline","Amelita","Ami","Amie","Amii","Amil","Amitie","Amity","Ammamaria","Amy","Amye","Ana","Anabal","Anabel","Anabella","Anabelle","Analiese","Analise","Anallese","Anallise","Anastasia","Anastasie","Anastassia","Anatola","Andee","Andeee","Anderea","Andi","Andie","Andra","Andrea","Andreana","Andree","Andrei","Andria","Andriana","Andriette","Andromache","Andy","Anestassia","Anet","Anett","Anetta","Anette","Ange","Angel","Angela","Angele","Angelia","Angelica","Angelika","Angelina","Angeline","Angelique","Angelita","Angelle","Angie","Angil","Angy","Ania","Anica","Anissa","Anita","Anitra","Anjanette","Anjela","Ann","Ann-marie","Anna","Anna-diana","Anna-diane","Anna-maria","Annabal","Annabel","Annabela","Annabell","Annabella","Annabelle","Annadiana","Annadiane","Annalee","Annaliese","Annalise","Annamaria","Annamarie","Anne","Anne-corinne","Anne-marie","Annecorinne","Anneliese","Annelise","Annemarie","Annetta","Annette","Anni","Annice","Annie","Annis","Annissa","Annmaria","Annmarie","Annnora","Annora","Anny","Anselma","Ansley","Anstice","Anthe","Anthea","Anthia","Anthiathia","Antoinette","Antonella","Antonetta","Antonia","Antonie","Antonietta","Antonina","Anya","Appolonia","April","Aprilette","Ara","Arabel","Arabela","Arabele","Arabella","Arabelle","Arda","Ardath","Ardeen","Ardelia","Ardelis","Ardella","Ardelle","Arden","Ardene","Ardenia","Ardine","Ardis","Ardisj","Ardith","Ardra","Ardyce","Ardys","Ardyth","Aretha","Ariadne","Ariana","Aridatha","Ariel","Ariela","Ariella","Arielle","Arlana","Arlee","Arleen","Arlen","Arlena","Arlene","Arleta","Arlette","Arleyne","Arlie","Arliene","Arlina","Arlinda","Arline","Arluene","Arly","Arlyn","Arlyne","Aryn","Ashely","Ashia","Ashien","Ashil","Ashla","Ashlan","Ashlee","Ashleigh","Ashlen","Ashley","Ashli","Ashlie","Ashly","Asia","Astra","Astrid","Astrix","Atalanta","Athena","Athene","Atlanta","Atlante","Auberta","Aubine","Aubree","Aubrette","Aubrey","Aubrie","Aubry","Audi","Audie","Audra","Audre","Audrey","Audrie","Audry","Audrye","Audy","Augusta","Auguste","Augustina","Augustine","Aundrea","Aura","Aurea","Aurel","Aurelea","Aurelia","Aurelie","Auria","Aurie","Aurilia","Aurlie","Auroora","Aurora","Aurore","Austin","Austina","Austine","Ava","Aveline","Averil","Averyl","Avie","Avis","Aviva","Avivah","Avril","Avrit","Ayn","Bab","Babara","Babb","Babbette","Babbie","Babette","Babita","Babs","Bambi","Bambie","Bamby","Barb","Barbabra","Barbara","Barbara-anne","Barbaraanne","Barbe","Barbee","Barbette","Barbey","Barbi","Barbie","Barbra","Barby","Bari","Barrie","Barry","Basia","Bathsheba","Batsheva","Bea","Beatrice","Beatrisa","Beatrix","Beatriz","Bebe","Becca","Becka","Becki","Beckie","Becky","Bee","Beilul","Beitris","Bekki","Bel","Belia","Belicia","Belinda","Belita","Bell","Bella","Bellanca","Belle","Bellina","Belva","Belvia","Bendite","Benedetta","Benedicta","Benedikta","Benetta","Benita","Benni","Bennie","Benny","Benoite","Berenice","Beret","Berget","Berna","Bernadene","Bernadette","Bernadina","Bernadine","Bernardina","Bernardine","Bernelle","Bernete","Bernetta","Bernette","Berni","Bernice","Bernie","Bernita","Berny","Berri","Berrie","Berry","Bert","Berta","Berte","Bertha","Berthe","Berti","Bertie","Bertina","Bertine","Berty","Beryl","Beryle","Bess","Bessie","Bessy","Beth","Bethanne","Bethany","Bethena","Bethina","Betsey","Betsy","Betta","Bette","Bette-ann","Betteann","Betteanne","Betti","Bettina","Bettine","Betty","Bettye","Beulah","Bev","Beverie","Beverlee","Beverley","Beverlie","Beverly","Bevvy","Bianca","Bianka","Bibbie","Bibby","Bibbye","Bibi","Biddie","Biddy","Bidget","Bili","Bill","Billi","Billie","Billy","Billye","Binni","Binnie","Binny","Bird","Birdie","Birgit","Birgitta","Blair","Blaire","Blake","Blakelee","Blakeley","Blanca","Blanch","Blancha","Blanche","Blinni","Blinnie","Blinny","Bliss","Blisse","Blithe","Blondell","Blondelle","Blondie","Blondy","Blythe","Bobbe","Bobbee","Bobbette","Bobbi","Bobbie","Bobby","Bobbye","Bobette","Bobina","Bobine","Bobinette","Bonita","Bonnee","Bonni","Bonnibelle","Bonnie","Bonny","Brana","Brandais","Brande","Brandea","Brandi","Brandice","Brandie","Brandise","Brandy","Breanne","Brear","Bree","Breena","Bren","Brena","Brenda","Brenn","Brenna","Brett","Bria","Briana","Brianna","Brianne","Bride","Bridget","Bridgette","Bridie","Brier","Brietta","Brigid","Brigida","Brigit","Brigitta","Brigitte","Brina","Briney","Brinn","Brinna","Briny","Brit","Brita","Britney","Britni","Britt","Britta","Brittan","Brittaney","Brittani","Brittany","Britte","Britteny","Brittne","Brittney","Brittni","Brook","Brooke","Brooks","Brunhilda","Brunhilde","Bryana","Bryn","Bryna","Brynn","Brynna","Brynne","Buffy","Bunni","Bunnie","Bunny","Cacilia","Cacilie","Cahra","Cairistiona","Caitlin","Caitrin","Cal","Calida","Calla","Calley","Calli","Callida","Callie","Cally","Calypso","Cam","Camala","Camel","Camella","Camellia","Cami","Camila","Camile","Camilla","Camille","Cammi","Cammie","Cammy","Candace","Candi","Candice","Candida","Candide","Candie","Candis","Candra","Candy","Caprice","Cara","Caralie","Caren","Carena","Caresa","Caressa","Caresse","Carey","Cari","Caria","Carie","Caril","Carilyn","Carin","Carina","Carine","Cariotta","Carissa","Carita","Caritta","Carla","Carlee","Carleen","Carlen","Carlene","Carley","Carlie","Carlin","Carlina","Carline","Carlita","Carlota","Carlotta","Carly","Carlye","Carlyn","Carlynn","Carlynne","Carma","Carmel","Carmela","Carmelia","Carmelina","Carmelita","Carmella","Carmelle","Carmen","Carmencita","Carmina","Carmine","Carmita","Carmon","Caro","Carol","Carol-jean","Carola","Carolan","Carolann","Carole","Carolee","Carolin","Carolina","Caroline","Caroljean","Carolyn","Carolyne","Carolynn","Caron","Carree","Carri","Carrie","Carrissa","Carroll","Carry","Cary","Caryl","Caryn","Casandra","Casey","Casi","Casie","Cass","Cassandra","Cassandre","Cassandry","Cassaundra","Cassey","Cassi","Cassie","Cassondra","Cassy","Catarina","Cate","Caterina","Catha","Catharina","Catharine","Cathe","Cathee","Catherin","Catherina","Catherine","Cathi","Cathie","Cathleen","Cathlene","Cathrin","Cathrine","Cathryn","Cathy","Cathyleen","Cati","Catie","Catina","Catlaina","Catlee","Catlin","Catrina","Catriona","Caty","Caye","Cayla","Cecelia","Cecil","Cecile","Ceciley","Cecilia","Cecilla","Cecily","Ceil","Cele","Celene","Celesta","Celeste","Celestia","Celestina","Celestine","Celestyn","Celestyna","Celia","Celie","Celina","Celinda","Celine","Celinka","Celisse","Celka","Celle","Cesya","Chad","Chanda","Chandal","Chandra","Channa","Chantal","Chantalle","Charil","Charin","Charis","Charissa","Charisse","Charita","Charity","Charla","Charlean","Charleen","Charlena","Charlene","Charline","Charlot","Charlotta","Charlotte","Charmain","Charmaine","Charmane","Charmian","Charmine","Charmion","Charo","Charyl","Chastity","Chelsae","Chelsea","Chelsey","Chelsie","Chelsy","Cher","Chere","Cherey","Cheri","Cherianne","Cherice","Cherida","Cherie","Cherilyn","Cherilynn","Cherin","Cherise","Cherish","Cherlyn","Cherri","Cherrita","Cherry","Chery","Cherye","Cheryl","Cheslie","Chiarra","Chickie","Chicky","Chiquia","Chiquita","Chlo","Chloe","Chloette","Chloris","Chris","Chrissie","Chrissy","Christa","Christabel","Christabella","Christal","Christalle","Christan","Christean","Christel","Christen","Christi","Christian","Christiana","Christiane","Christie","Christin","Christina","Christine","Christy","Christye","Christyna","Chrysa","Chrysler","Chrystal","Chryste","Chrystel","Cicely","Cicily","Ciel","Cilka","Cinda","Cindee","Cindelyn","Cinderella","Cindi","Cindie","Cindra","Cindy","Cinnamon","Cissiee","Cissy","Clair","Claire","Clara","Clarabelle","Clare","Claresta","Clareta","Claretta","Clarette","Clarey","Clari","Claribel","Clarice","Clarie","Clarinda","Clarine","Clarissa","Clarisse","Clarita","Clary","Claude","Claudelle","Claudetta","Claudette","Claudia","Claudie","Claudina","Claudine","Clea","Clem","Clemence","Clementia","Clementina","Clementine","Clemmie","Clemmy","Cleo","Cleopatra","Clerissa","Clio","Clo","Cloe","Cloris","Clotilda","Clovis","Codee","Codi","Codie","Cody","Coleen","Colene","Coletta","Colette","Colleen","Collen","Collete","Collette","Collie","Colline","Colly","Con","Concettina","Conchita","Concordia","Conni","Connie","Conny","Consolata","Constance","Constancia","Constancy","Constanta","Constantia","Constantina","Constantine","Consuela","Consuelo","Cookie","Cora","Corabel","Corabella","Corabelle","Coral","Coralie","Coraline","Coralyn","Cordelia","Cordelie","Cordey","Cordi","Cordie","Cordula","Cordy","Coreen","Corella","Corenda","Corene","Coretta","Corette","Corey","Cori","Corie","Corilla","Corina","Corine","Corinna","Corinne","Coriss","Corissa","Corliss","Corly","Cornela","Cornelia","Cornelle","Cornie","Corny","Correna","Correy","Corri","Corrianne","Corrie","Corrina","Corrine","Corrinne","Corry","Cortney","Cory","Cosetta","Cosette","Costanza","Courtenay","Courtnay","Courtney","Crin","Cris","Crissie","Crissy","Crista","Cristabel","Cristal","Cristen","Cristi","Cristie","Cristin","Cristina","Cristine","Cristionna","Cristy","Crysta","Crystal","Crystie","Cthrine","Cyb","Cybil","Cybill","Cymbre","Cynde","Cyndi","Cyndia","Cyndie","Cyndy","Cynthea","Cynthia","Cynthie","Cynthy","Dacey","Dacia","Dacie","Dacy","Dael","Daffi","Daffie","Daffy","Dagmar","Dahlia","Daile","Daisey","Daisi","Daisie","Daisy","Dale","Dalenna","Dalia","Dalila","Dallas","Daloris","Damara","Damaris","Damita","Dana","Danell","Danella","Danette","Dani","Dania","Danica","Danice","Daniela","Daniele","Daniella","Danielle","Danika","Danila","Danit","Danita","Danna","Danni","Dannie","Danny","Dannye","Danya","Danyelle","Danyette","Daphene","Daphna","Daphne","Dara","Darb","Darbie","Darby","Darcee","Darcey","Darci","Darcie","Darcy","Darda","Dareen","Darell","Darelle","Dari","Daria","Darice","Darla","Darleen","Darlene","Darline","Darlleen","Daron","Darrelle","Darryl","Darsey","Darsie","Darya","Daryl","Daryn","Dasha","Dasi","Dasie","Dasya","Datha","Daune","Daveen","Daveta","Davida","Davina","Davine","Davita","Dawn","Dawna","Dayle","Dayna","Ddene","De","Deana","Deane","Deanna","Deanne","Deb","Debbi","Debbie","Debby","Debee","Debera","Debi","Debor","Debora","Deborah","Debra","Dede","Dedie","Dedra","Dee","Deeann","Deeanne","Deedee","Deena","Deerdre","Deeyn","Dehlia","Deidre","Deina","Deirdre","Del","Dela","Delcina","Delcine","Delia","Delila","Delilah","Delinda","Dell","Della","Delly","Delora","Delores","Deloria","Deloris","Delphine","Delphinia","Demeter","Demetra","Demetria","Demetris","Dena","Deni","Denice","Denise","Denna","Denni","Dennie","Denny","Deny","Denys","Denyse","Deonne","Desdemona","Desirae","Desiree","Desiri","Deva","Devan","Devi","Devin","Devina","Devinne","Devon","Devondra","Devonna","Devonne","Devora","Di","Diahann","Dian","Diana","Diandra","Diane","Diane-marie","Dianemarie","Diann","Dianna","Dianne","Diannne","Didi","Dido","Diena","Dierdre","Dina","Dinah","Dinnie","Dinny","Dion","Dione","Dionis","Dionne","Dita","Dix","Dixie","Dniren","Dode","Dodi","Dodie","Dody","Doe","Doll","Dolley","Dolli","Dollie","Dolly","Dolores","Dolorita","Doloritas","Domeniga","Dominga","Domini","Dominica","Dominique","Dona","Donella","Donelle","Donetta","Donia","Donica","Donielle","Donna","Donnamarie","Donni","Donnie","Donny","Dora","Doralia","Doralin","Doralyn","Doralynn","Doralynne","Dore","Doreen","Dorelia","Dorella","Dorelle","Dorena","Dorene","Doretta","Dorette","Dorey","Dori","Doria","Dorian","Dorice","Dorie","Dorine","Doris","Dorisa","Dorise","Dorita","Doro","Dorolice","Dorolisa","Dorotea","Doroteya","Dorothea","Dorothee","Dorothy","Dorree","Dorri","Dorrie","Dorris","Dorry","Dorthea","Dorthy","Dory","Dosi","Dot","Doti","Dotti","Dottie","Dotty","Dre","Dreddy","Dredi","Drona","Dru","Druci","Drucie","Drucill","Drucy","Drusi","Drusie","Drusilla","Drusy","Dulce","Dulcea","Dulci","Dulcia","Dulciana","Dulcie","Dulcine","Dulcinea","Dulcy","Dulsea","Dusty","Dyan","Dyana","Dyane","Dyann","Dyanna","Dyanne","Dyna","Dynah","Eachelle","Eada","Eadie","Eadith","Ealasaid","Eartha","Easter","Eba","Ebba","Ebonee","Ebony","Eda","Eddi","Eddie","Eddy","Ede","Edee","Edeline","Eden","Edi","Edie","Edin","Edita","Edith","Editha","Edithe","Ediva","Edna","Edwina","Edy","Edyth","Edythe","Effie","Eileen","Eilis","Eimile","Eirena","Ekaterina","Elaina","Elaine","Elana","Elane","Elayne","Elberta","Elbertina","Elbertine","Eleanor","Eleanora","Eleanore","Electra","Eleen","Elena","Elene","Eleni","Elenore","Eleonora","Eleonore","Elfie","Elfreda","Elfrida","Elfrieda","Elga","Elianora","Elianore","Elicia","Elie","Elinor","Elinore","Elisa","Elisabet","Elisabeth","Elisabetta","Elise","Elisha","Elissa","Elita","Eliza","Elizabet","Elizabeth","Elka","Elke","Ella","Elladine","Elle","Ellen","Ellene","Ellette","Elli","Ellie","Ellissa","Elly","Ellyn","Ellynn","Elmira","Elna","Elnora","Elnore","Eloisa","Eloise","Elonore","Elora","Elsa","Elsbeth","Else","Elset","Elsey","Elsi","Elsie","Elsinore","Elspeth","Elsy","Elva","Elvera","Elvina","Elvira","Elwira","Elyn","Elyse","Elysee","Elysha","Elysia","Elyssa","Em","Ema","Emalee","Emalia","Emelda","Emelia","Emelina","Emeline","Emelita","Emelyne","Emera","Emilee","Emili","Emilia","Emilie","Emiline","Emily","Emlyn","Emlynn","Emlynne","Emma","Emmalee","Emmaline","Emmalyn","Emmalynn","Emmalynne","Emmeline","Emmey","Emmi","Emmie","Emmy","Emmye","Emogene","Emyle","Emylee","Engracia","Enid","Enrica","Enrichetta","Enrika","Enriqueta","Eolanda","Eolande","Eran","Erda","Erena","Erica","Ericha","Ericka","Erika","Erin","Erina","Erinn","Erinna","Erma","Ermengarde","Ermentrude","Ermina","Erminia","Erminie","Erna","Ernaline","Ernesta","Ernestine","Ertha","Eryn","Esma","Esmaria","Esme","Esmeralda","Essa","Essie","Essy","Esta","Estel","Estele","Estell","Estella","Estelle","Ester","Esther","Estrella","Estrellita","Ethel","Ethelda","Ethelin","Ethelind","Etheline","Ethelyn","Ethyl","Etta","Etti","Ettie","Etty","Eudora","Eugenia","Eugenie","Eugine","Eula","Eulalie","Eunice","Euphemia","Eustacia","Eva","Evaleen","Evangelia","Evangelin","Evangelina","Evangeline","Evania","Evanne","Eve","Eveleen","Evelina","Eveline","Evelyn","Evey","Evie","Evita","Evonne","Evvie","Evvy","Evy","Eyde","Eydie","Ezmeralda","Fae","Faina","Faith","Fallon","Fan","Fanchette","Fanchon","Fancie","Fancy","Fanechka","Fania","Fanni","Fannie","Fanny","Fanya","Fara","Farah","Farand","Farica","Farra","Farrah","Farrand","Faun","Faunie","Faustina","Faustine","Fawn","Fawne","Fawnia","Fay","Faydra","Faye","Fayette","Fayina","Fayre","Fayth","Faythe","Federica","Fedora","Felecia","Felicdad","Felice","Felicia","Felicity","Felicle","Felipa","Felisha","Felita","Feliza","Fenelia","Feodora","Ferdinanda","Ferdinande","Fern","Fernanda","Fernande","Fernandina","Ferne","Fey","Fiann","Fianna","Fidela","Fidelia","Fidelity","Fifi","Fifine","Filia","Filide","Filippa","Fina","Fiona","Fionna","Fionnula","Fiorenze","Fleur","Fleurette","Flo","Flor","Flora","Florance","Flore","Florella","Florence","Florencia","Florentia","Florenza","Florette","Flori","Floria","Florida","Florie","Florina","Florinda","Floris","Florri","Florrie","Florry","Flory","Flossi","Flossie","Flossy","Flss","Fran","Francene","Frances","Francesca","Francine","Francisca","Franciska","Francoise","Francyne","Frank","Frankie","Franky","Franni","Frannie","Franny","Frayda","Fred","Freda","Freddi","Freddie","Freddy","Fredelia","Frederica","Fredericka","Frederique","Fredi","Fredia","Fredra","Fredrika","Freida","Frieda","Friederike","Fulvia","Gabbey","Gabbi","Gabbie","Gabey","Gabi","Gabie","Gabriel","Gabriela","Gabriell","Gabriella","Gabrielle","Gabriellia","Gabrila","Gaby","Gae","Gael","Gail","Gale","Galina","Garland","Garnet","Garnette","Gates","Gavra","Gavrielle","Gay","Gaye","Gayel","Gayla","Gayle","Gayleen","Gaylene","Gaynor","Gelya","Gena","Gene","Geneva","Genevieve","Genevra","Genia","Genna","Genni","Gennie","Gennifer","Genny","Genovera","Genvieve","George","Georgeanna","Georgeanne","Georgena","Georgeta","Georgetta","Georgette","Georgia","Georgiana","Georgianna","Georgianne","Georgie","Georgina","Georgine","Geralda","Geraldine","Gerda","Gerhardine","Geri","Gerianna","Gerianne","Gerladina","Germain","Germaine","Germana","Gerri","Gerrie","Gerrilee","Gerry","Gert","Gerta","Gerti","Gertie","Gertrud","Gertruda","Gertrude","Gertrudis","Gerty","Giacinta","Giana","Gianina","Gianna","Gigi","Gilberta","Gilberte","Gilbertina","Gilbertine","Gilda","Gilemette","Gill","Gillan","Gilli","Gillian","Gillie","Gilligan","Gilly","Gina","Ginelle","Ginevra","Ginger","Ginni","Ginnie","Ginnifer","Ginny","Giorgia","Giovanna","Gipsy","Giralda","Gisela","Gisele","Gisella","Giselle","Giuditta","Giulia","Giulietta","Giustina","Gizela","Glad","Gladi","Gladys","Gleda","Glen","Glenda","Glenine","Glenn","Glenna","Glennie","Glennis","Glori","Gloria","Gloriana","Gloriane","Glory","Glyn","Glynda","Glynis","Glynnis","Gnni","Godiva","Golda","Goldarina","Goldi","Goldia","Goldie","Goldina","Goldy","Grace","Gracia","Gracie","Grata","Gratia","Gratiana","Gray","Grayce","Grazia","Greer","Greta","Gretal","Gretchen","Grete","Gretel","Grethel","Gretna","Gretta","Grier","Griselda","Grissel","Guendolen","Guenevere","Guenna","Guglielma","Gui","Guillema","Guillemette","Guinevere","Guinna","Gunilla","Gus","Gusella","Gussi","Gussie","Gussy","Gusta","Gusti","Gustie","Gusty","Gwen","Gwendolen","Gwendolin","Gwendolyn","Gweneth","Gwenette","Gwenneth","Gwenni","Gwennie","Gwenny","Gwenora","Gwenore","Gwyn","Gwyneth","Gwynne","Gypsy","Hadria","Hailee","Haily","Haleigh","Halette","Haley","Hali","Halie","Halimeda","Halley","Halli","Hallie","Hally","Hana","Hanna","Hannah","Hanni","Hannie","Hannis","Hanny","Happy","Harlene","Harley","Harli","Harlie","Harmonia","Harmonie","Harmony","Harri","Harrie","Harriet","Harriett","Harrietta","Harriette","Harriot","Harriott","Hatti","Hattie","Hatty","Hayley","Hazel","Heath","Heather","Heda","Hedda","Heddi","Heddie","Hedi","Hedvig","Hedvige","Hedwig","Hedwiga","Hedy","Heida","Heidi","Heidie","Helaina","Helaine","Helen","Helen-elizabeth","Helena","Helene","Helenka","Helga","Helge","Helli","Heloise","Helsa","Helyn","Hendrika","Henka","Henrie","Henrieta","Henrietta","Henriette","Henryetta","Hephzibah","Hermia","Hermina","Hermine","Herminia","Hermione","Herta","Hertha","Hester","Hesther","Hestia","Hetti","Hettie","Hetty","Hilary","Hilda","Hildagard","Hildagarde","Hilde","Hildegaard","Hildegarde","Hildy","Hillary","Hilliary","Hinda","Holli","Hollie","Holly","Holly-anne","Hollyanne","Honey","Honor","Honoria","Hope","Horatia","Hortense","Hortensia","Hulda","Hyacinth","Hyacintha","Hyacinthe","Hyacinthia","Hyacinthie","Hynda","Ianthe","Ibbie","Ibby","Ida","Idalia","Idalina","Idaline","Idell","Idelle","Idette","Ileana","Ileane","Ilene","Ilise","Ilka","Illa","Ilsa","Ilse","Ilysa","Ilyse","Ilyssa","Imelda","Imogen","Imogene","Imojean","Ina","Indira","Ines","Inesita","Inessa","Inez","Inga","Ingaberg","Ingaborg","Inge","Ingeberg","Ingeborg","Inger","Ingrid","Ingunna","Inna","Iolande","Iolanthe","Iona","Iormina","Ira","Irena","Irene","Irina","Iris","Irita","Irma","Isa","Isabel","Isabelita","Isabella","Isabelle","Isadora","Isahella","Iseabal","Isidora","Isis","Isobel","Issi","Issie","Issy","Ivett","Ivette","Ivie","Ivonne","Ivory","Ivy","Izabel","Jacenta","Jacinda","Jacinta","Jacintha","Jacinthe","Jackelyn","Jacki","Jackie","Jacklin","Jacklyn","Jackquelin","Jackqueline","Jacky","Jaclin","Jaclyn","Jacquelin","Jacqueline","Jacquelyn","Jacquelynn","Jacquenetta","Jacquenette","Jacquetta","Jacquette","Jacqui","Jacquie","Jacynth","Jada","Jade","Jaime","Jaimie","Jaine","Jami","Jamie","Jamima","Jammie","Jan","Jana","Janaya","Janaye","Jandy","Jane","Janean","Janeczka","Janeen","Janel","Janela","Janella","Janelle","Janene","Janenna","Janessa","Janet","Janeta","Janetta","Janette","Janeva","Janey","Jania","Janice","Janie","Janifer","Janina","Janine","Janis","Janith","Janka","Janna","Jannel","Jannelle","Janot","Jany","Jaquelin","Jaquelyn","Jaquenetta","Jaquenette","Jaquith","Jasmin","Jasmina","Jasmine","Jayme","Jaymee","Jayne","Jaynell","Jazmin","Jean","Jeana","Jeane","Jeanelle","Jeanette","Jeanie","Jeanine","Jeanna","Jeanne","Jeannette","Jeannie","Jeannine","Jehanna","Jelene","Jemie","Jemima","Jemimah","Jemmie","Jemmy","Jen","Jena","Jenda","Jenelle","Jeni","Jenica","Jeniece","Jenifer","Jeniffer","Jenilee","Jenine","Jenn","Jenna","Jennee","Jennette","Jenni","Jennica","Jennie","Jennifer","Jennilee","Jennine","Jenny","Jeralee","Jere","Jeri","Jermaine","Jerrie","Jerrilee","Jerrilyn","Jerrine","Jerry","Jerrylee","Jess","Jessa","Jessalin","Jessalyn","Jessamine","Jessamyn","Jesse","Jesselyn","Jessi","Jessica","Jessie","Jessika","Jessy","Jewel","Jewell","Jewelle","Jill","Jillana","Jillane","Jillayne","Jilleen","Jillene","Jilli","Jillian","Jillie","Jilly","Jinny","Jo","Jo-ann","Jo-anne","Joan","Joana","Joane","Joanie","Joann","Joanna","Joanne","Joannes","Jobey","Jobi","Jobie","Jobina","Joby","Jobye","Jobyna","Jocelin","Joceline","Jocelyn","Jocelyne","Jodee","Jodi","Jodie","Jody","Joeann","Joela","Joelie","Joell","Joella","Joelle","Joellen","Joelly","Joellyn","Joelynn","Joete","Joey","Johanna","Johannah","Johna","Johnath","Johnette","Johnna","Joice","Jojo","Jolee","Joleen","Jolene","Joletta","Joli","Jolie","Joline","Joly","Jolyn","Jolynn","Jonell","Joni","Jonie","Jonis","Jordain","Jordan","Jordana","Jordanna","Jorey","Jori","Jorie","Jorrie","Jorry","Joscelin","Josee","Josefa","Josefina","Josepha","Josephina","Josephine","Josey","Josi","Josie","Josselyn","Josy","Jourdan","Joy","Joya","Joyan","Joyann","Joyce","Joycelin","Joye","Jsandye","Juana","Juanita","Judi","Judie","Judith","Juditha","Judy","Judye","Juieta","Julee","Juli","Julia","Juliana","Juliane","Juliann","Julianna","Julianne","Julie","Julienne","Juliet","Julieta","Julietta","Juliette","Julina","Juline","Julissa","Julita","June","Junette","Junia","Junie","Junina","Justina","Justine","Justinn","Jyoti","Kacey","Kacie","Kacy","Kaela","Kai","Kaia","Kaila","Kaile","Kailey","Kaitlin","Kaitlyn","Kaitlynn","Kaja","Kakalina","Kala","Kaleena","Kali","Kalie","Kalila","Kalina","Kalinda","Kalindi","Kalli","Kally","Kameko","Kamila","Kamilah","Kamillah","Kandace","Kandy","Kania","Kanya","Kara","Kara-lynn","Karalee","Karalynn","Kare","Karee","Karel","Karen","Karena","Kari","Karia","Karie","Karil","Karilynn","Karin","Karina","Karine","Kariotta","Karisa","Karissa","Karita","Karla","Karlee","Karleen","Karlen","Karlene","Karlie","Karlotta","Karlotte","Karly","Karlyn","Karmen","Karna","Karol","Karola","Karole","Karolina","Karoline","Karoly","Karon","Karrah","Karrie","Karry","Kary","Karyl","Karylin","Karyn","Kasey","Kass","Kassandra","Kassey","Kassi","Kassia","Kassie","Kat","Kata","Katalin","Kate","Katee","Katerina","Katerine","Katey","Kath","Katha","Katharina","Katharine","Katharyn","Kathe","Katherina","Katherine","Katheryn","Kathi","Kathie","Kathleen","Kathlin","Kathrine","Kathryn","Kathryne","Kathy","Kathye","Kati","Katie","Katina","Katine","Katinka","Katleen","Katlin","Katrina","Katrine","Katrinka","Katti","Kattie","Katuscha","Katusha","Katy","Katya","Kay","Kaycee","Kaye","Kayla","Kayle","Kaylee","Kayley","Kaylil","Kaylyn","Keeley","Keelia","Keely","Kelcey","Kelci","Kelcie","Kelcy","Kelila","Kellen","Kelley","Kelli","Kellia","Kellie","Kellina","Kellsie","Kelly","Kellyann","Kelsey","Kelsi","Kelsy","Kendra","Kendre","Kenna","Keri","Keriann","Kerianne","Kerri","Kerrie","Kerrill","Kerrin","Kerry","Kerstin","Kesley","Keslie","Kessia","Kessiah","Ketti","Kettie","Ketty","Kevina","Kevyn","Ki","Kiah","Kial","Kiele","Kiersten","Kikelia","Kiley","Kim","Kimberlee","Kimberley","Kimberli","Kimberly","Kimberlyn","Kimbra","Kimmi","Kimmie","Kimmy","Kinna","Kip","Kipp","Kippie","Kippy","Kira","Kirbee","Kirbie","Kirby","Kiri","Kirsten","Kirsteni","Kirsti","Kirstin","Kirstyn","Kissee","Kissiah","Kissie","Kit","Kitti","Kittie","Kitty","Kizzee","Kizzie","Klara","Klarika","Klarrisa","Konstance","Konstanze","Koo","Kora","Koral","Koralle","Kordula","Kore","Korella","Koren","Koressa","Kori","Korie","Korney","Korrie","Korry","Kris","Krissie","Krissy","Krista","Kristal","Kristan","Kriste","Kristel","Kristen","Kristi","Kristien","Kristin","Kristina","Kristine","Kristy","Kristyn","Krysta","Krystal","Krystalle","Krystle","Krystyna","Kyla","Kyle","Kylen","Kylie","Kylila","Kylynn","Kym","Kynthia","Kyrstin","Lacee","Lacey","Lacie","Lacy","Ladonna","Laetitia","Laina","Lainey","Lana","Lanae","Lane","Lanette","Laney","Lani","Lanie","Lanita","Lanna","Lanni","Lanny","Lara","Laraine","Lari","Larina","Larine","Larisa","Larissa","Lark","Laryssa","Latashia","Latia","Latisha","Latrena","Latrina","Laura","Lauraine","Laural","Lauralee","Laure","Lauree","Laureen","Laurel","Laurella","Lauren","Laurena","Laurene","Lauretta","Laurette","Lauri","Laurianne","Laurice","Laurie","Lauryn","Lavena","Laverna","Laverne","Lavina","Lavinia","Lavinie","Layla","Layne","Layney","Lea","Leah","Leandra","Leann","Leanna","Leanor","Leanora","Lebbie","Leda","Lee","Leeann","Leeanne","Leela","Leelah","Leena","Leesa","Leese","Legra","Leia","Leigh","Leigha","Leila","Leilah","Leisha","Lela","Lelah","Leland","Lelia","Lena","Lenee","Lenette","Lenka","Lenna","Lenora","Lenore","Leodora","Leoine","Leola","Leoline","Leona","Leonanie","Leone","Leonelle","Leonie","Leonora","Leonore","Leontine","Leontyne","Leora","Leshia","Lesley","Lesli","Leslie","Lesly","Lesya","Leta","Lethia","Leticia","Letisha","Letitia","Letizia","Letta","Letti","Lettie","Letty","Lexi","Lexie","Lexine","Lexis","Lexy","Leyla","Lezlie","Lia","Lian","Liana","Liane","Lianna","Lianne","Lib","Libbey","Libbi","Libbie","Libby","Licha","Lida","Lidia","Liesa","Lil","Lila","Lilah","Lilas","Lilia","Lilian","Liliane","Lilias","Lilith","Lilla","Lilli","Lillian","Lillis","Lilllie","Lilly","Lily","Lilyan","Lin","Lina","Lind","Linda","Lindi","Lindie","Lindsay","Lindsey","Lindsy","Lindy","Linea","Linell","Linet","Linette","Linn","Linnea","Linnell","Linnet","Linnie","Linzy","Lira","Lisa","Lisabeth","Lisbeth","Lise","Lisetta","Lisette","Lisha","Lishe","Lissa","Lissi","Lissie","Lissy","Lita","Liuka","Liv","Liva","Livia","Livvie","Livvy","Livvyy","Livy","Liz","Liza","Lizabeth","Lizbeth","Lizette","Lizzie","Lizzy","Loella","Lois","Loise","Lola","Loleta","Lolita","Lolly","Lona","Lonee","Loni","Lonna","Lonni","Lonnie","Lora","Lorain","Loraine","Loralee","Loralie","Loralyn","Loree","Loreen","Lorelei","Lorelle","Loren","Lorena","Lorene","Lorenza","Loretta","Lorette","Lori","Loria","Lorianna","Lorianne","Lorie","Lorilee","Lorilyn","Lorinda","Lorine","Lorita","Lorna","Lorne","Lorraine","Lorrayne","Lorri","Lorrie","Lorrin","Lorry","Lory","Lotta","Lotte","Lotti","Lottie","Lotty","Lou","Louella","Louisa","Louise","Louisette","Loutitia","Lu","Luce","Luci","Lucia","Luciana","Lucie","Lucienne","Lucila","Lucilia","Lucille","Lucina","Lucinda","Lucine","Lucita","Lucky","Lucretia","Lucy","Ludovika","Luella","Luelle","Luisa","Luise","Lula","Lulita","Lulu","Lura","Lurette","Lurleen","Lurlene","Lurline","Lusa","Luz","Lyda","Lydia","Lydie","Lyn","Lynda","Lynde","Lyndel","Lyndell","Lyndsay","Lyndsey","Lyndsie","Lyndy","Lynea","Lynelle","Lynett","Lynette","Lynn","Lynna","Lynne","Lynnea","Lynnell","Lynnelle","Lynnet","Lynnett","Lynnette","Lynsey","Lyssa","Mab","Mabel","Mabelle","Mable","Mada","Madalena","Madalyn","Maddalena","Maddi","Maddie","Maddy","Madel","Madelaine","Madeleine","Madelena","Madelene","Madelin","Madelina","Madeline","Madella","Madelle","Madelon","Madelyn","Madge","Madlen","Madlin","Madonna","Mady","Mae","Maegan","Mag","Magda","Magdaia","Magdalen","Magdalena","Magdalene","Maggee","Maggi","Maggie","Maggy","Mahala","Mahalia","Maia","Maible","Maiga","Maighdiln","Mair","Maire","Maisey","Maisie","Maitilde","Mala","Malanie","Malena","Malia","Malina","Malinda","Malinde","Malissa","Malissia","Mallissa","Mallorie","Mallory","Malorie","Malory","Malva","Malvina","Malynda","Mame","Mamie","Manda","Mandi","Mandie","Mandy","Manon","Manya","Mara","Marabel","Marcela","Marcelia","Marcella","Marcelle","Marcellina","Marcelline","Marchelle","Marci","Marcia","Marcie","Marcile","Marcille","Marcy","Mareah","Maren","Marena","Maressa","Marga","Margalit","Margalo","Margaret","Margareta","Margarete","Margaretha","Margarethe","Margaretta","Margarette","Margarita","Margaux","Marge","Margeaux","Margery","Marget","Margette","Margi","Margie","Margit","Margo","Margot","Margret","Marguerite","Margy","Mari","Maria","Mariam","Marian","Mariana","Mariann","Marianna","Marianne","Maribel","Maribelle","Maribeth","Marice","Maridel","Marie","Marie-ann","Marie-jeanne","Marieann","Mariejeanne","Mariel","Mariele","Marielle","Mariellen","Marietta","Mariette","Marigold","Marijo","Marika","Marilee","Marilin","Marillin","Marilyn","Marin","Marina","Marinna","Marion","Mariquilla","Maris","Marisa","Mariska","Marissa","Marita","Maritsa","Mariya","Marj","Marja","Marje","Marji","Marjie","Marjorie","Marjory","Marjy","Marketa","Marla","Marlane","Marleah","Marlee","Marleen","Marlena","Marlene","Marley","Marlie","Marline","Marlo","Marlyn","Marna","Marne","Marney","Marni","Marnia","Marnie","Marquita","Marrilee","Marris","Marrissa","Marsha","Marsiella","Marta","Martelle","Martguerita","Martha","Marthe","Marthena","Marti","Martica","Martie","Martina","Martita","Marty","Martynne","Mary","Marya","Maryann","Maryanna","Maryanne","Marybelle","Marybeth","Maryellen","Maryjane","Maryjo","Maryl","Marylee","Marylin","Marylinda","Marylou","Marylynne","Maryrose","Marys","Marysa","Masha","Matelda","Mathilda","Mathilde","Matilda","Matilde","Matti","Mattie","Matty","Maud","Maude","Maudie","Maura","Maure","Maureen","Maureene","Maurene","Maurine","Maurise","Maurita","Maurizia","Mavis","Mavra","Max","Maxi","Maxie","Maxine","Maxy","May","Maybelle","Maye","Mead","Meade","Meagan","Meaghan","Meara","Mechelle","Meg","Megan","Megen","Meggi","Meggie","Meggy","Meghan","Meghann","Mehetabel","Mei","Mel","Mela","Melamie","Melania","Melanie","Melantha","Melany","Melba","Melesa","Melessa","Melicent","Melina","Melinda","Melinde","Melisa","Melisande","Melisandra","Melisenda","Melisent","Melissa","Melisse","Melita","Melitta","Mella","Melli","Mellicent","Mellie","Mellisa","Mellisent","Melloney","Melly","Melodee","Melodie","Melody","Melonie","Melony","Melosa","Melva","Mercedes","Merci","Mercie","Mercy","Meredith","Meredithe","Meridel","Meridith","Meriel","Merilee","Merilyn","Meris","Merissa","Merl","Merla","Merle","Merlina","Merline","Merna","Merola","Merralee","Merridie","Merrie","Merrielle","Merrile","Merrilee","Merrili","Merrill","Merrily","Merry","Mersey","Meryl","Meta","Mia","Micaela","Michaela","Michaelina","Michaeline","Michaella","Michal","Michel","Michele","Michelina","Micheline","Michell","Michelle","Micki","Mickie","Micky","Midge","Mignon","Mignonne","Miguela","Miguelita","Mikaela","Mil","Mildred","Mildrid","Milena","Milicent","Milissent","Milka","Milli","Millicent","Millie","Millisent","Milly","Milzie","Mimi","Min","Mina","Minda","Mindy","Minerva","Minetta","Minette","Minna","Minnaminnie","Minne","Minni","Minnie","Minnnie","Minny","Minta","Miquela","Mira","Mirabel","Mirabella","Mirabelle","Miran","Miranda","Mireielle","Mireille","Mirella","Mirelle","Miriam","Mirilla","Mirna","Misha","Missie","Missy","Misti","Misty","Mitzi","Modesta","Modestia","Modestine","Modesty","Moina","Moira","Moll","Mollee","Molli","Mollie","Molly","Mommy","Mona","Monah","Monica","Monika","Monique","Mora","Moreen","Morena","Morgan","Morgana","Morganica","Morganne","Morgen","Moria","Morissa","Morna","Moselle","Moyna","Moyra","Mozelle","Muffin","Mufi","Mufinella","Muire","Mureil","Murial","Muriel","Murielle","Myra","Myrah","Myranda","Myriam","Myrilla","Myrle","Myrlene","Myrna","Myrta","Myrtia","Myrtice","Myrtie","Myrtle","Nada","Nadean","Nadeen","Nadia","Nadine","Nadiya","Nady","Nadya","Nalani","Nan","Nana","Nananne","Nance","Nancee","Nancey","Nanci","Nancie","Nancy","Nanete","Nanette","Nani","Nanice","Nanine","Nannette","Nanni","Nannie","Nanny","Nanon","Naoma","Naomi","Nara","Nari","Nariko","Nat","Nata","Natala","Natalee","Natalie","Natalina","Nataline","Natalya","Natasha","Natassia","Nathalia","Nathalie","Natividad","Natka","Natty","Neala","Neda","Nedda","Nedi","Neely","Neila","Neile","Neilla","Neille","Nelia","Nelie","Nell","Nelle","Nelli","Nellie","Nelly","Nerissa","Nerita","Nert","Nerta","Nerte","Nerti","Nertie","Nerty","Nessa","Nessi","Nessie","Nessy","Nesta","Netta","Netti","Nettie","Nettle","Netty","Nevsa","Neysa","Nichol","Nichole","Nicholle","Nicki","Nickie","Nicky","Nicol","Nicola","Nicole","Nicolea","Nicolette","Nicoli","Nicolina","Nicoline","Nicolle","Nikaniki","Nike","Niki","Nikki","Nikkie","Nikoletta","Nikolia","Nina","Ninetta","Ninette","Ninnetta","Ninnette","Ninon","Nissa","Nisse","Nissie","Nissy","Nita","Nixie","Noami","Noel","Noelani","Noell","Noella","Noelle","Noellyn","Noelyn","Noemi","Nola","Nolana","Nolie","Nollie","Nomi","Nona","Nonah","Noni","Nonie","Nonna","Nonnah","Nora","Norah","Norean","Noreen","Norene","Norina","Norine","Norma","Norri","Norrie","Norry","Novelia","Nydia","Nyssa","Octavia","Odele","Odelia","Odelinda","Odella","Odelle","Odessa","Odetta","Odette","Odilia","Odille","Ofelia","Ofella","Ofilia","Ola","Olenka","Olga","Olia","Olimpia","Olive","Olivette","Olivia","Olivie","Oliy","Ollie","Olly","Olva","Olwen","Olympe","Olympia","Olympie","Ondrea","Oneida","Onida","Oona","Opal","Opalina","Opaline","Ophelia","Ophelie","Ora","Oralee","Oralia","Oralie","Oralla","Oralle","Orel","Orelee","Orelia","Orelie","Orella","Orelle","Oriana","Orly","Orsa","Orsola","Ortensia","Otha","Othelia","Othella","Othilia","Othilie","Ottilie","Page","Paige","Paloma","Pam","Pamela","Pamelina","Pamella","Pammi","Pammie","Pammy","Pandora","Pansie","Pansy","Paola","Paolina","Papagena","Pat","Patience","Patrica","Patrice","Patricia","Patrizia","Patsy","Patti","Pattie","Patty","Paula","Paule","Pauletta","Paulette","Pauli","Paulie","Paulina","Pauline","Paulita","Pauly","Pavia","Pavla","Pearl","Pearla","Pearle","Pearline","Peg","Pegeen","Peggi","Peggie","Peggy","Pen","Penelopa","Penelope","Penni","Pennie","Penny","Pepi","Pepita","Peri","Peria","Perl","Perla","Perle","Perri","Perrine","Perry","Persis","Pet","Peta","Petra","Petrina","Petronella","Petronia","Petronilla","Petronille","Petunia","Phaedra","Phaidra","Phebe","Phedra","Phelia","Phil","Philipa","Philippa","Philippe","Philippine","Philis","Phillida","Phillie","Phillis","Philly","Philomena","Phoebe","Phylis","Phyllida","Phyllis","Phyllys","Phylys","Pia","Pier","Pierette","Pierrette","Pietra","Piper","Pippa","Pippy","Polly","Pollyanna","Pooh","Poppy","Portia","Pris","Prisca","Priscella","Priscilla","Prissie","Pru","Prudence","Prudi","Prudy","Prue","Queenie","Quentin","Querida","Quinn","Quinta","Quintana","Quintilla","Quintina","Rachael","Rachel","Rachele","Rachelle","Rae","Raeann","Raf","Rafa","Rafaela","Rafaelia","Rafaelita","Rahal","Rahel","Raina","Raine","Rakel","Ralina","Ramona","Ramonda","Rana","Randa","Randee","Randene","Randi","Randie","Randy","Ranee","Rani","Rania","Ranice","Ranique","Ranna","Raphaela","Raquel","Raquela","Rasia","Rasla","Raven","Ray","Raychel","Raye","Rayna","Raynell","Rayshell","Rea","Reba","Rebbecca","Rebe","Rebeca","Rebecca","Rebecka","Rebeka","Rebekah","Rebekkah","Ree","Reeba","Reena","Reeta","Reeva","Regan","Reggi","Reggie","Regina","Regine","Reiko","Reina","Reine","Remy","Rena","Renae","Renata","Renate","Rene","Renee","Renell","Renelle","Renie","Rennie","Reta","Retha","Revkah","Rey","Reyna","Rhea","Rheba","Rheta","Rhetta","Rhiamon","Rhianna","Rhianon","Rhoda","Rhodia","Rhodie","Rhody","Rhona","Rhonda","Riane","Riannon","Rianon","Rica","Ricca","Rici","Ricki","Rickie","Ricky","Riki","Rikki","Rina","Risa","Rita","Riva","Rivalee","Rivi","Rivkah","Rivy","Roana","Roanna","Roanne","Robbi","Robbie","Robbin","Robby","Robbyn","Robena","Robenia","Roberta","Robin","Robina","Robinet","Robinett","Robinetta","Robinette","Robinia","Roby","Robyn","Roch","Rochell","Rochella","Rochelle","Rochette","Roda","Rodi","Rodie","Rodina","Rois","Romola","Romona","Romonda","Romy","Rona","Ronalda","Ronda","Ronica","Ronna","Ronni","Ronnica","Ronnie","Ronny","Roobbie","Rora","Rori","Rorie","Rory","Ros","Rosa","Rosabel","Rosabella","Rosabelle","Rosaleen","Rosalia","Rosalie","Rosalind","Rosalinda","Rosalinde","Rosaline","Rosalyn","Rosalynd","Rosamond","Rosamund","Rosana","Rosanna","Rosanne","Rose","Roseann","Roseanna","Roseanne","Roselia","Roselin","Roseline","Rosella","Roselle","Rosemaria","Rosemarie","Rosemary","Rosemonde","Rosene","Rosetta","Rosette","Roshelle","Rosie","Rosina","Rosita","Roslyn","Rosmunda","Rosy","Row","Rowe","Rowena","Roxana","Roxane","Roxanna","Roxanne","Roxi","Roxie","Roxine","Roxy","Roz","Rozalie","Rozalin","Rozamond","Rozanna","Rozanne","Roze","Rozele","Rozella","Rozelle","Rozina","Rubetta","Rubi","Rubia","Rubie","Rubina","Ruby","Ruperta","Ruth","Ruthann","Ruthanne","Ruthe","Ruthi","Ruthie","Ruthy","Ryann","Rycca","Saba","Sabina","Sabine","Sabra","Sabrina","Sacha","Sada","Sadella","Sadie","Sadye","Saidee","Sal","Salaidh","Sallee","Salli","Sallie","Sally","Sallyann","Sallyanne","Saloma","Salome","Salomi","Sam","Samantha","Samara","Samaria","Sammy","Sande","Sandi","Sandie","Sandra","Sandy","Sandye","Sapphira","Sapphire","Sara","Sara-ann","Saraann","Sarah","Sarajane","Saree","Sarena","Sarene","Sarette","Sari","Sarina","Sarine","Sarita","Sascha","Sasha","Sashenka","Saudra","Saundra","Savina","Sayre","Scarlet","Scarlett","Sean","Seana","Seka","Sela","Selena","Selene","Selestina","Selia","Selie","Selina","Selinda","Seline","Sella","Selle","Selma","Sena","Sephira","Serena","Serene","Shae","Shaina","Shaine","Shalna","Shalne","Shana","Shanda","Shandee","Shandeigh","Shandie","Shandra","Shandy","Shane","Shani","Shanie","Shanna","Shannah","Shannen","Shannon","Shanon","Shanta","Shantee","Shara","Sharai","Shari","Sharia","Sharity","Sharl","Sharla","Sharleen","Sharlene","Sharline","Sharon","Sharona","Sharron","Sharyl","Shaun","Shauna","Shawn","Shawna","Shawnee","Shay","Shayla","Shaylah","Shaylyn","Shaylynn","Shayna","Shayne","Shea","Sheba","Sheela","Sheelagh","Sheelah","Sheena","Sheeree","Sheila","Sheila-kathryn","Sheilah","Shel","Shela","Shelagh","Shelba","Shelbi","Shelby","Shelia","Shell","Shelley","Shelli","Shellie","Shelly","Shena","Sher","Sheree","Sheri","Sherie","Sherill","Sherilyn","Sherline","Sherri","Sherrie","Sherry","Sherye","Sheryl","Shina","Shir","Shirl","Shirlee","Shirleen","Shirlene","Shirley","Shirline","Shoshana","Shoshanna","Siana","Sianna","Sib","Sibbie","Sibby","Sibeal","Sibel","Sibella","Sibelle","Sibilla","Sibley","Sibyl","Sibylla","Sibylle","Sidoney","Sidonia","Sidonnie","Sigrid","Sile","Sileas","Silva","Silvana","Silvia","Silvie","Simona","Simone","Simonette","Simonne","Sindee","Siobhan","Sioux","Siouxie","Sisely","Sisile","Sissie","Sissy","Siusan","Sofia","Sofie","Sondra","Sonia","Sonja","Sonni","Sonnie","Sonnnie","Sonny","Sonya","Sophey","Sophi","Sophia","Sophie","Sophronia","Sorcha","Sosanna","Stace","Stacee","Stacey","Staci","Stacia","Stacie","Stacy","Stafani","Star","Starla","Starlene","Starlin","Starr","Stefa","Stefania","Stefanie","Steffane","Steffi","Steffie","Stella","Stepha","Stephana","Stephani","Stephanie","Stephannie","Stephenie","Stephi","Stephie","Stephine","Stesha","Stevana","Stevena","Stoddard","Storm","Stormi","Stormie","Stormy","Sue","Suellen","Sukey","Suki","Sula","Sunny","Sunshine","Susan","Susana","Susanetta","Susann","Susanna","Susannah","Susanne","Susette","Susi","Susie","Susy","Suzann","Suzanna","Suzanne","Suzette","Suzi","Suzie","Suzy","Sybil","Sybila","Sybilla","Sybille","Sybyl","Sydel","Sydelle","Sydney","Sylvia","Tabatha","Tabbatha","Tabbi","Tabbie","Tabbitha","Tabby","Tabina","Tabitha","Taffy","Talia","Tallia","Tallie","Tallou","Tallulah","Tally","Talya","Talyah","Tamar","Tamara","Tamarah","Tamarra","Tamera","Tami","Tamiko","Tamma","Tammara","Tammi","Tammie","Tammy","Tamqrah","Tamra","Tana","Tandi","Tandie","Tandy","Tanhya","Tani","Tania","Tanitansy","Tansy","Tanya","Tara","Tarah","Tarra","Tarrah","Taryn","Tasha","Tasia","Tate","Tatiana","Tatiania","Tatum","Tawnya","Tawsha","Ted","Tedda","Teddi","Teddie","Teddy","Tedi","Tedra","Teena","Teirtza","Teodora","Tera","Teresa","Terese","Teresina","Teresita","Teressa","Teri","Teriann","Terra","Terri","Terrie","Terrijo","Terry","Terrye","Tersina","Terza","Tess","Tessa","Tessi","Tessie","Tessy","Thalia","Thea","Theadora","Theda","Thekla","Thelma","Theo","Theodora","Theodosia","Theresa","Therese","Theresina","Theresita","Theressa","Therine","Thia","Thomasa","Thomasin","Thomasina","Thomasine","Tiena","Tierney","Tiertza","Tiff","Tiffani","Tiffanie","Tiffany","Tiffi","Tiffie","Tiffy","Tilda","Tildi","Tildie","Tildy","Tillie","Tilly","Tim","Timi","Timmi","Timmie","Timmy","Timothea","Tina","Tine","Tiphani","Tiphanie","Tiphany","Tish","Tisha","Tobe","Tobey","Tobi","Toby","Tobye","Toinette","Toma","Tomasina","Tomasine","Tomi","Tommi","Tommie","Tommy","Toni","Tonia","Tonie","Tony","Tonya","Tonye","Tootsie","Torey","Tori","Torie","Torrie","Tory","Tova","Tove","Tracee","Tracey","Traci","Tracie","Tracy","Trenna","Tresa","Trescha","Tressa","Tricia","Trina","Trish","Trisha","Trista","Trix","Trixi","Trixie","Trixy","Truda","Trude","Trudey","Trudi","Trudie","Trudy","Trula","Tuesday","Twila","Twyla","Tybi","Tybie","Tyne","Ula","Ulla","Ulrica","Ulrika","Ulrikaumeko","Ulrike","Umeko","Una","Ursa","Ursala","Ursola","Ursula","Ursulina","Ursuline","Uta","Val","Valaree","Valaria","Vale","Valeda","Valencia","Valene","Valenka","Valentia","Valentina","Valentine","Valera","Valeria","Valerie","Valery","Valerye","Valida","Valina","Valli","Vallie","Vally","Valma","Valry","Van","Vanda","Vanessa","Vania","Vanna","Vanni","Vannie","Vanny","Vanya","Veda","Velma","Velvet","Venita","Venus","Vera","Veradis","Vere","Verena","Verene","Veriee","Verile","Verina","Verine","Verla","Verna","Vernice","Veronica","Veronika","Veronike","Veronique","Vevay","Vi","Vicki","Vickie","Vicky","Victoria","Vida","Viki","Vikki","Vikky","Vilhelmina","Vilma","Vin","Vina","Vinita","Vinni","Vinnie","Vinny","Viola","Violante","Viole","Violet","Violetta","Violette","Virgie","Virgina","Virginia","Virginie","Vita","Vitia","Vitoria","Vittoria","Viv","Viva","Vivi","Vivia","Vivian","Viviana","Vivianna","Vivianne","Vivie","Vivien","Viviene","Vivienne","Viviyan","Vivyan","Vivyanne","Vonni","Vonnie","Vonny","Vyky","Wallie","Wallis","Walliw","Wally","Waly","Wanda","Wandie","Wandis","Waneta","Wanids","Wenda","Wendeline","Wendi","Wendie","Wendy","Wendye","Wenona","Wenonah","Whitney","Wileen","Wilhelmina","Wilhelmine","Wilie","Willa","Willabella","Willamina","Willetta","Willette","Willi","Willie","Willow","Willy","Willyt","Wilma","Wilmette","Wilona","Wilone","Wilow","Windy","Wini","Winifred","Winna","Winnah","Winne","Winni","Winnie","Winnifred","Winny","Winona","Winonah","Wren","Wrennie","Wylma","Wynn","Wynne","Wynnie","Wynny","Xaviera","Xena","Xenia","Xylia","Xylina","Yalonda","Yasmeen","Yasmin","Yelena","Yetta","Yettie","Yetty","Yevette","Ynes","Ynez","Yoko","Yolanda","Yolande","Yolane","Yolanthe","Yoshi","Yoshiko","Yovonnda","Ysabel","Yvette","Yvonne","Zabrina","Zahara","Zandra","Zaneta","Zara","Zarah","Zaria","Zarla","Zea","Zelda","Zelma","Zena","Zenia","Zia","Zilvia","Zita","Zitella","Zoe","Zola","Zonda","Zondra","Zonnya","Zora","Zorah","Zorana","Zorina","Zorine","Zsazsa","Zulema","Zuzana"],dm={exports:{}};/** * @license * Lodash @@ -556,9 +556,9 @@ Length provided: ${this.length}. Number of dictionaries provided: ${this.diction * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */dm.exports;(function(e,t){(function(){var n,r="4.17.21",i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",s="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,g=2,m=4,v=1,E=2,w=1,C=2,b=4,A=8,T=16,B=32,D=64,I=128,M=256,O=512,z=30,K="...",X=800,Z=16,pe=1,me=2,Ce=3,W=1/0,U=9007199254740991,ne=17976931348623157e292,le=NaN,Ae=4294967295,we=Ae-1,ft=Ae>>>1,Ze=[["ary",I],["bind",w],["bindKey",C],["curry",A],["curryRight",T],["flip",O],["partial",B],["partialRight",D],["rearg",M]],qe="[object Arguments]",Ge="[object Array]",At="[object AsyncFunction]",dt="[object Boolean]",pn="[object Date]",Dn="[object DOMException]",On="[object Error]",_n="[object Function]",Tn="[object GeneratorFunction]",tn="[object Map]",Ri="[object Number]",zu="[object Null]",Sn="[object Object]",ho="[object Promise]",Jo="[object Proxy]",Wo="[object RegExp]",Fi="[object Set]",Td="[object String]",jh="[object Symbol]",dB="[object Undefined]",Pd="[object WeakMap]",hB="[object WeakSet]",Bd="[object ArrayBuffer]",Nl="[object DataView]",A1="[object Float32Array]",k1="[object Float64Array]",I1="[object Int8Array]",D1="[object Int16Array]",T1="[object Int32Array]",P1="[object Uint8Array]",B1="[object Uint8ClampedArray]",M1="[object Uint16Array]",$1="[object Uint32Array]",fB=/\b__p \+= '';/g,pB=/\b(__p \+=) '' \+/g,gB=/(__e\(.*?\)|\b__t\)) \+\n'';/g,t9=/&(?:amp|lt|gt|quot|#39);/g,n9=/[&<>"']/g,mB=RegExp(t9.source),vB=RegExp(n9.source),yB=/<%-([\s\S]+?)%>/g,EB=/<%([\s\S]+?)%>/g,r9=/<%=([\s\S]+?)%>/g,CB=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bB=/^\w*$/,wB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,R1=/[\\^$.*+?()[\]{}|]/g,SB=RegExp(R1.source),F1=/^\s+/,xB=/\s/,AB=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,kB=/\{\n\/\* \[wrapped with (.+)\] \*/,IB=/,? & /,DB=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,TB=/[()=,{}\[\]\/\s]/,PB=/\\(\\)?/g,BB=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,i9=/\w*$/,MB=/^[-+]0x[0-9a-f]+$/i,$B=/^0b[01]+$/i,RB=/^\[object .+?Constructor\]$/,FB=/^0o[0-7]+$/i,LB=/^(?:0|[1-9]\d*)$/,OB=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Uh=/($^)/,_B=/['\n\r\u2028\u2029\\]/g,Kh="\\ud800-\\udfff",NB="\\u0300-\\u036f",zB="\\ufe20-\\ufe2f",HB="\\u20d0-\\u20ff",o9=NB+zB+HB,a9="\\u2700-\\u27bf",s9="a-z\\xdf-\\xf6\\xf8-\\xff",jB="\\xac\\xb1\\xd7\\xf7",UB="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",KB="\\u2000-\\u206f",VB=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u9="A-Z\\xc0-\\xd6\\xd8-\\xde",l9="\\ufe0e\\ufe0f",c9=jB+UB+KB+VB,L1="['’]",GB="["+Kh+"]",d9="["+c9+"]",Vh="["+o9+"]",h9="\\d+",JB="["+a9+"]",f9="["+s9+"]",p9="[^"+Kh+c9+h9+a9+s9+u9+"]",O1="\\ud83c[\\udffb-\\udfff]",WB="(?:"+Vh+"|"+O1+")",g9="[^"+Kh+"]",_1="(?:\\ud83c[\\udde6-\\uddff]){2}",N1="[\\ud800-\\udbff][\\udc00-\\udfff]",zl="["+u9+"]",m9="\\u200d",v9="(?:"+f9+"|"+p9+")",YB="(?:"+zl+"|"+p9+")",y9="(?:"+L1+"(?:d|ll|m|re|s|t|ve))?",E9="(?:"+L1+"(?:D|LL|M|RE|S|T|VE))?",C9=WB+"?",b9="["+l9+"]?",qB="(?:"+m9+"(?:"+[g9,_1,N1].join("|")+")"+b9+C9+")*",XB="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ZB="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",w9=b9+C9+qB,QB="(?:"+[JB,_1,N1].join("|")+")"+w9,eM="(?:"+[g9+Vh+"?",Vh,_1,N1,GB].join("|")+")",tM=RegExp(L1,"g"),nM=RegExp(Vh,"g"),z1=RegExp(O1+"(?="+O1+")|"+eM+w9,"g"),rM=RegExp([zl+"?"+f9+"+"+y9+"(?="+[d9,zl,"$"].join("|")+")",YB+"+"+E9+"(?="+[d9,zl+v9,"$"].join("|")+")",zl+"?"+v9+"+"+y9,zl+"+"+E9,ZB,XB,h9,QB].join("|"),"g"),iM=RegExp("["+m9+Kh+o9+l9+"]"),oM=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,aM=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],sM=-1,Pt={};Pt[A1]=Pt[k1]=Pt[I1]=Pt[D1]=Pt[T1]=Pt[P1]=Pt[B1]=Pt[M1]=Pt[$1]=!0,Pt[qe]=Pt[Ge]=Pt[Bd]=Pt[dt]=Pt[Nl]=Pt[pn]=Pt[On]=Pt[_n]=Pt[tn]=Pt[Ri]=Pt[Sn]=Pt[Wo]=Pt[Fi]=Pt[Td]=Pt[Pd]=!1;var kt={};kt[qe]=kt[Ge]=kt[Bd]=kt[Nl]=kt[dt]=kt[pn]=kt[A1]=kt[k1]=kt[I1]=kt[D1]=kt[T1]=kt[tn]=kt[Ri]=kt[Sn]=kt[Wo]=kt[Fi]=kt[Td]=kt[jh]=kt[P1]=kt[B1]=kt[M1]=kt[$1]=!0,kt[On]=kt[_n]=kt[Pd]=!1;var uM={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},lM={"&":"&","<":"<",">":">",'"':""","'":"'"},cM={"&":"&","<":"<",">":">",""":'"',"'":"'"},dM={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},hM=parseFloat,fM=parseInt,S9=typeof fc=="object"&&fc&&fc.Object===Object&&fc,pM=typeof self=="object"&&self&&self.Object===Object&&self,Pn=S9||pM||Function("return this")(),H1=t&&!t.nodeType&&t,Hu=H1&&!0&&e&&!e.nodeType&&e,x9=Hu&&Hu.exports===H1,j1=x9&&S9.process,Yr=function(){try{var V=Hu&&Hu.require&&Hu.require("util").types;return V||j1&&j1.binding&&j1.binding("util")}catch{}}(),A9=Yr&&Yr.isArrayBuffer,k9=Yr&&Yr.isDate,I9=Yr&&Yr.isMap,D9=Yr&&Yr.isRegExp,T9=Yr&&Yr.isSet,P9=Yr&&Yr.isTypedArray;function Ar(V,ie,ee){switch(ee.length){case 0:return V.call(ie);case 1:return V.call(ie,ee[0]);case 2:return V.call(ie,ee[0],ee[1]);case 3:return V.call(ie,ee[0],ee[1],ee[2])}return V.apply(ie,ee)}function gM(V,ie,ee,be){for(var Ue=-1,ht=V==null?0:V.length;++Ue-1}function U1(V,ie,ee){for(var be=-1,Ue=V==null?0:V.length;++be-1;);return ee}function _9(V,ie){for(var ee=V.length;ee--&&Hl(ie,V[ee],0)>-1;);return ee}function xM(V,ie){for(var ee=V.length,be=0;ee--;)V[ee]===ie&&++be;return be}var AM=J1(uM),kM=J1(lM);function IM(V){return"\\"+dM[V]}function DM(V,ie){return V==null?n:V[ie]}function jl(V){return iM.test(V)}function TM(V){return oM.test(V)}function PM(V){for(var ie,ee=[];!(ie=V.next()).done;)ee.push(ie.value);return ee}function X1(V){var ie=-1,ee=Array(V.size);return V.forEach(function(be,Ue){ee[++ie]=[Ue,be]}),ee}function N9(V,ie){return function(ee){return V(ie(ee))}}function Os(V,ie){for(var ee=-1,be=V.length,Ue=0,ht=[];++ee-1}function v$(c,f){var y=this.__data__,x=cf(y,c);return x<0?(++this.size,y.push([c,f])):y[x][1]=f,this}Yo.prototype.clear=f$,Yo.prototype.delete=p$,Yo.prototype.get=g$,Yo.prototype.has=m$,Yo.prototype.set=v$;function qo(c){var f=-1,y=c==null?0:c.length;for(this.clear();++f=f?c:f)),c}function Qr(c,f,y,x,P,L){var H,j=f&p,G=f&g,oe=f&m;if(y&&(H=P?y(c,x,P,L):y(c)),H!==n)return H;if(!Ht(c))return c;var ae=Ke(c);if(ae){if(H=bR(c),!j)return hr(c,H)}else{var ue=zn(c),ye=ue==_n||ue==Tn;if(Us(c))return b5(c,j);if(ue==Sn||ue==qe||ye&&!P){if(H=G||ye?{}:z5(c),!j)return G?cR(c,$$(H,c)):lR(c,X9(H,c))}else{if(!kt[ue])return P?c:{};H=wR(c,ue,j)}}L||(L=new Oi);var ke=L.get(c);if(ke)return ke;L.set(c,H),gb(c)?c.forEach(function(Ne){H.add(Qr(Ne,f,y,Ne,c,L))}):fb(c)&&c.forEach(function(Ne,Qe){H.set(Qe,Qr(Ne,f,y,Qe,c,L))});var _e=oe?G?S4:w4:G?pr:xn,We=ae?n:_e(c);return qr(We||c,function(Ne,Qe){We&&(Qe=Ne,Ne=c[Qe]),_d(H,Qe,Qr(Ne,f,y,Qe,c,L))}),H}function R$(c){var f=xn(c);return function(y){return Z9(y,c,f)}}function Z9(c,f,y){var x=y.length;if(c==null)return!x;for(c=St(c);x--;){var P=y[x],L=f[P],H=c[P];if(H===n&&!(P in c)||!L(H))return!1}return!0}function Q9(c,f,y){if(typeof c!="function")throw new Xr(a);return Vd(function(){c.apply(n,y)},f)}function Nd(c,f,y,x){var P=-1,L=Gh,H=!0,j=c.length,G=[],oe=f.length;if(!j)return G;y&&(f=Ft(f,kr(y))),x?(L=U1,H=!1):f.length>=i&&(L=Md,H=!1,f=new Ku(f));e:for(;++PP?0:P+y),x=x===n||x>P?P:Je(x),x<0&&(x+=P),x=y>x?0:vb(x);y0&&y(j)?f>1?Bn(j,f-1,y,x,P):Ls(P,j):x||(P[P.length]=j)}return P}var i4=I5(),n5=I5(!0);function fo(c,f){return c&&i4(c,f,xn)}function o4(c,f){return c&&n5(c,f,xn)}function hf(c,f){return Fs(f,function(y){return ta(c[y])})}function Gu(c,f){f=Hs(f,c);for(var y=0,x=f.length;c!=null&&yf}function O$(c,f){return c!=null&&mt.call(c,f)}function _$(c,f){return c!=null&&f in St(c)}function N$(c,f,y){return c>=Nn(f,y)&&c=120&&ae.length>=120)?new Ku(H&&ae):n}ae=c[0];var ue=-1,ye=j[0];e:for(;++ue-1;)j!==c&&nf.call(j,G,1),nf.call(c,G,1);return c}function f5(c,f){for(var y=c?f.length:0,x=y-1;y--;){var P=f[y];if(y==x||P!==L){var L=P;ea(P)?nf.call(c,P,1):g4(c,P)}}return c}function h4(c,f){return c+af(J9()*(f-c+1))}function Z$(c,f,y,x){for(var P=-1,L=mn(of((f-c)/(y||1)),0),H=ee(L);L--;)H[x?L:++P]=c,c+=y;return H}function f4(c,f){var y="";if(!c||f<1||f>U)return y;do f%2&&(y+=c),f=af(f/2),f&&(c+=c);while(f);return y}function Ye(c,f){return P4(U5(c,f,gr),c+"")}function Q$(c){return q9(Ql(c))}function eR(c,f){var y=Ql(c);return Sf(y,Vu(f,0,y.length))}function jd(c,f,y,x){if(!Ht(c))return c;f=Hs(f,c);for(var P=-1,L=f.length,H=L-1,j=c;j!=null&&++PP?0:P+f),y=y>P?P:y,y<0&&(y+=P),P=f>y?0:y-f>>>0,f>>>=0;for(var L=ee(P);++x>>1,H=c[L];H!==null&&!Dr(H)&&(y?H<=f:H=i){var oe=f?null:pR(c);if(oe)return Wh(oe);H=!1,P=Md,G=new Ku}else G=f?[]:j;e:for(;++x=x?c:ei(c,f,y)}var C5=VM||function(c){return Pn.clearTimeout(c)};function b5(c,f){if(f)return c.slice();var y=c.length,x=j9?j9(y):new c.constructor(y);return c.copy(x),x}function E4(c){var f=new c.constructor(c.byteLength);return new ef(f).set(new ef(c)),f}function oR(c,f){var y=f?E4(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function aR(c){var f=new c.constructor(c.source,i9.exec(c));return f.lastIndex=c.lastIndex,f}function sR(c){return Od?St(Od.call(c)):{}}function w5(c,f){var y=f?E4(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function S5(c,f){if(c!==f){var y=c!==n,x=c===null,P=c===c,L=Dr(c),H=f!==n,j=f===null,G=f===f,oe=Dr(f);if(!j&&!oe&&!L&&c>f||L&&H&&G&&!j&&!oe||x&&H&&G||!y&&G||!P)return 1;if(!x&&!L&&!oe&&c=j)return G;var oe=y[x];return G*(oe=="desc"?-1:1)}}return c.index-f.index}function x5(c,f,y,x){for(var P=-1,L=c.length,H=y.length,j=-1,G=f.length,oe=mn(L-H,0),ae=ee(G+oe),ue=!x;++j1?y[P-1]:n,H=P>2?y[2]:n;for(L=c.length>3&&typeof L=="function"?(P--,L):n,H&&Zn(y[0],y[1],H)&&(L=P<3?n:L,P=1),f=St(f);++x-1?P[L?f[H]:H]:n}}function P5(c){return Qo(function(f){var y=f.length,x=y,P=Zr.prototype.thru;for(c&&f.reverse();x--;){var L=f[x];if(typeof L!="function")throw new Xr(a);if(P&&!H&&bf(L)=="wrapper")var H=new Zr([],!0)}for(x=H?x:y;++x1&&rt.reverse(),ae&&Gj))return!1;var oe=L.get(c),ae=L.get(f);if(oe&&ae)return oe==f&&ae==c;var ue=-1,ye=!0,ke=y&E?new Ku:n;for(L.set(c,f),L.set(f,c);++ue1?"& ":"")+f[x],f=f.join(y>2?", ":" "),c.replace(AB,`{ + */dm.exports;(function(e,t){(function(){var n,r="4.17.21",i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",s="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,g=2,m=4,v=1,E=2,w=1,C=2,b=4,A=8,T=16,B=32,D=64,I=128,M=256,O=512,z=30,K="...",X=800,Z=16,pe=1,me=2,Ce=3,W=1/0,U=9007199254740991,ne=17976931348623157e292,le=NaN,Ae=4294967295,we=Ae-1,ft=Ae>>>1,Ze=[["ary",I],["bind",w],["bindKey",C],["curry",A],["curryRight",T],["flip",O],["partial",B],["partialRight",D],["rearg",M]],qe="[object Arguments]",Ge="[object Array]",At="[object AsyncFunction]",dt="[object Boolean]",pn="[object Date]",Dn="[object DOMException]",On="[object Error]",_n="[object Function]",Tn="[object GeneratorFunction]",tn="[object Map]",Ri="[object Number]",zu="[object Null]",Sn="[object Object]",ho="[object Promise]",Jo="[object Proxy]",Wo="[object RegExp]",Fi="[object Set]",Td="[object String]",jh="[object Symbol]",dB="[object Undefined]",Pd="[object WeakMap]",hB="[object WeakSet]",Bd="[object ArrayBuffer]",Nl="[object DataView]",k1="[object Float32Array]",I1="[object Float64Array]",D1="[object Int8Array]",T1="[object Int16Array]",P1="[object Int32Array]",B1="[object Uint8Array]",M1="[object Uint8ClampedArray]",$1="[object Uint16Array]",R1="[object Uint32Array]",fB=/\b__p \+= '';/g,pB=/\b(__p \+=) '' \+/g,gB=/(__e\(.*?\)|\b__t\)) \+\n'';/g,t9=/&(?:amp|lt|gt|quot|#39);/g,n9=/[&<>"']/g,mB=RegExp(t9.source),vB=RegExp(n9.source),yB=/<%-([\s\S]+?)%>/g,EB=/<%([\s\S]+?)%>/g,r9=/<%=([\s\S]+?)%>/g,CB=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bB=/^\w*$/,wB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,F1=/[\\^$.*+?()[\]{}|]/g,SB=RegExp(F1.source),L1=/^\s+/,xB=/\s/,AB=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,kB=/\{\n\/\* \[wrapped with (.+)\] \*/,IB=/,? & /,DB=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,TB=/[()=,{}\[\]\/\s]/,PB=/\\(\\)?/g,BB=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,i9=/\w*$/,MB=/^[-+]0x[0-9a-f]+$/i,$B=/^0b[01]+$/i,RB=/^\[object .+?Constructor\]$/,FB=/^0o[0-7]+$/i,LB=/^(?:0|[1-9]\d*)$/,OB=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Uh=/($^)/,_B=/['\n\r\u2028\u2029\\]/g,Kh="\\ud800-\\udfff",NB="\\u0300-\\u036f",zB="\\ufe20-\\ufe2f",HB="\\u20d0-\\u20ff",o9=NB+zB+HB,a9="\\u2700-\\u27bf",s9="a-z\\xdf-\\xf6\\xf8-\\xff",jB="\\xac\\xb1\\xd7\\xf7",UB="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",KB="\\u2000-\\u206f",VB=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u9="A-Z\\xc0-\\xd6\\xd8-\\xde",l9="\\ufe0e\\ufe0f",c9=jB+UB+KB+VB,O1="['’]",GB="["+Kh+"]",d9="["+c9+"]",Vh="["+o9+"]",h9="\\d+",JB="["+a9+"]",f9="["+s9+"]",p9="[^"+Kh+c9+h9+a9+s9+u9+"]",_1="\\ud83c[\\udffb-\\udfff]",WB="(?:"+Vh+"|"+_1+")",g9="[^"+Kh+"]",N1="(?:\\ud83c[\\udde6-\\uddff]){2}",z1="[\\ud800-\\udbff][\\udc00-\\udfff]",zl="["+u9+"]",m9="\\u200d",v9="(?:"+f9+"|"+p9+")",YB="(?:"+zl+"|"+p9+")",y9="(?:"+O1+"(?:d|ll|m|re|s|t|ve))?",E9="(?:"+O1+"(?:D|LL|M|RE|S|T|VE))?",C9=WB+"?",b9="["+l9+"]?",qB="(?:"+m9+"(?:"+[g9,N1,z1].join("|")+")"+b9+C9+")*",XB="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ZB="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",w9=b9+C9+qB,QB="(?:"+[JB,N1,z1].join("|")+")"+w9,eM="(?:"+[g9+Vh+"?",Vh,N1,z1,GB].join("|")+")",tM=RegExp(O1,"g"),nM=RegExp(Vh,"g"),H1=RegExp(_1+"(?="+_1+")|"+eM+w9,"g"),rM=RegExp([zl+"?"+f9+"+"+y9+"(?="+[d9,zl,"$"].join("|")+")",YB+"+"+E9+"(?="+[d9,zl+v9,"$"].join("|")+")",zl+"?"+v9+"+"+y9,zl+"+"+E9,ZB,XB,h9,QB].join("|"),"g"),iM=RegExp("["+m9+Kh+o9+l9+"]"),oM=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,aM=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],sM=-1,Pt={};Pt[k1]=Pt[I1]=Pt[D1]=Pt[T1]=Pt[P1]=Pt[B1]=Pt[M1]=Pt[$1]=Pt[R1]=!0,Pt[qe]=Pt[Ge]=Pt[Bd]=Pt[dt]=Pt[Nl]=Pt[pn]=Pt[On]=Pt[_n]=Pt[tn]=Pt[Ri]=Pt[Sn]=Pt[Wo]=Pt[Fi]=Pt[Td]=Pt[Pd]=!1;var kt={};kt[qe]=kt[Ge]=kt[Bd]=kt[Nl]=kt[dt]=kt[pn]=kt[k1]=kt[I1]=kt[D1]=kt[T1]=kt[P1]=kt[tn]=kt[Ri]=kt[Sn]=kt[Wo]=kt[Fi]=kt[Td]=kt[jh]=kt[B1]=kt[M1]=kt[$1]=kt[R1]=!0,kt[On]=kt[_n]=kt[Pd]=!1;var uM={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},lM={"&":"&","<":"<",">":">",'"':""","'":"'"},cM={"&":"&","<":"<",">":">",""":'"',"'":"'"},dM={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},hM=parseFloat,fM=parseInt,S9=typeof fc=="object"&&fc&&fc.Object===Object&&fc,pM=typeof self=="object"&&self&&self.Object===Object&&self,Pn=S9||pM||Function("return this")(),j1=t&&!t.nodeType&&t,Hu=j1&&!0&&e&&!e.nodeType&&e,x9=Hu&&Hu.exports===j1,U1=x9&&S9.process,Yr=function(){try{var V=Hu&&Hu.require&&Hu.require("util").types;return V||U1&&U1.binding&&U1.binding("util")}catch{}}(),A9=Yr&&Yr.isArrayBuffer,k9=Yr&&Yr.isDate,I9=Yr&&Yr.isMap,D9=Yr&&Yr.isRegExp,T9=Yr&&Yr.isSet,P9=Yr&&Yr.isTypedArray;function Ar(V,ie,ee){switch(ee.length){case 0:return V.call(ie);case 1:return V.call(ie,ee[0]);case 2:return V.call(ie,ee[0],ee[1]);case 3:return V.call(ie,ee[0],ee[1],ee[2])}return V.apply(ie,ee)}function gM(V,ie,ee,be){for(var Ue=-1,ht=V==null?0:V.length;++Ue-1}function K1(V,ie,ee){for(var be=-1,Ue=V==null?0:V.length;++be-1;);return ee}function _9(V,ie){for(var ee=V.length;ee--&&Hl(ie,V[ee],0)>-1;);return ee}function xM(V,ie){for(var ee=V.length,be=0;ee--;)V[ee]===ie&&++be;return be}var AM=W1(uM),kM=W1(lM);function IM(V){return"\\"+dM[V]}function DM(V,ie){return V==null?n:V[ie]}function jl(V){return iM.test(V)}function TM(V){return oM.test(V)}function PM(V){for(var ie,ee=[];!(ie=V.next()).done;)ee.push(ie.value);return ee}function Z1(V){var ie=-1,ee=Array(V.size);return V.forEach(function(be,Ue){ee[++ie]=[Ue,be]}),ee}function N9(V,ie){return function(ee){return V(ie(ee))}}function Os(V,ie){for(var ee=-1,be=V.length,Ue=0,ht=[];++ee-1}function v$(c,f){var y=this.__data__,x=cf(y,c);return x<0?(++this.size,y.push([c,f])):y[x][1]=f,this}Yo.prototype.clear=f$,Yo.prototype.delete=p$,Yo.prototype.get=g$,Yo.prototype.has=m$,Yo.prototype.set=v$;function qo(c){var f=-1,y=c==null?0:c.length;for(this.clear();++f=f?c:f)),c}function Qr(c,f,y,x,P,L){var H,j=f&p,G=f&g,oe=f&m;if(y&&(H=P?y(c,x,P,L):y(c)),H!==n)return H;if(!Ht(c))return c;var ae=Ke(c);if(ae){if(H=bR(c),!j)return hr(c,H)}else{var ue=zn(c),ye=ue==_n||ue==Tn;if(Us(c))return b5(c,j);if(ue==Sn||ue==qe||ye&&!P){if(H=G||ye?{}:z5(c),!j)return G?cR(c,$$(H,c)):lR(c,X9(H,c))}else{if(!kt[ue])return P?c:{};H=wR(c,ue,j)}}L||(L=new Oi);var ke=L.get(c);if(ke)return ke;L.set(c,H),gb(c)?c.forEach(function(Ne){H.add(Qr(Ne,f,y,Ne,c,L))}):fb(c)&&c.forEach(function(Ne,Qe){H.set(Qe,Qr(Ne,f,y,Qe,c,L))});var _e=oe?G?x4:S4:G?pr:xn,We=ae?n:_e(c);return qr(We||c,function(Ne,Qe){We&&(Qe=Ne,Ne=c[Qe]),_d(H,Qe,Qr(Ne,f,y,Qe,c,L))}),H}function R$(c){var f=xn(c);return function(y){return Z9(y,c,f)}}function Z9(c,f,y){var x=y.length;if(c==null)return!x;for(c=St(c);x--;){var P=y[x],L=f[P],H=c[P];if(H===n&&!(P in c)||!L(H))return!1}return!0}function Q9(c,f,y){if(typeof c!="function")throw new Xr(a);return Vd(function(){c.apply(n,y)},f)}function Nd(c,f,y,x){var P=-1,L=Gh,H=!0,j=c.length,G=[],oe=f.length;if(!j)return G;y&&(f=Ft(f,kr(y))),x?(L=K1,H=!1):f.length>=i&&(L=Md,H=!1,f=new Ku(f));e:for(;++PP?0:P+y),x=x===n||x>P?P:Je(x),x<0&&(x+=P),x=y>x?0:vb(x);y0&&y(j)?f>1?Bn(j,f-1,y,x,P):Ls(P,j):x||(P[P.length]=j)}return P}var o4=I5(),n5=I5(!0);function fo(c,f){return c&&o4(c,f,xn)}function a4(c,f){return c&&n5(c,f,xn)}function hf(c,f){return Fs(f,function(y){return ta(c[y])})}function Gu(c,f){f=Hs(f,c);for(var y=0,x=f.length;c!=null&&yf}function O$(c,f){return c!=null&&mt.call(c,f)}function _$(c,f){return c!=null&&f in St(c)}function N$(c,f,y){return c>=Nn(f,y)&&c=120&&ae.length>=120)?new Ku(H&&ae):n}ae=c[0];var ue=-1,ye=j[0];e:for(;++ue-1;)j!==c&&nf.call(j,G,1),nf.call(c,G,1);return c}function f5(c,f){for(var y=c?f.length:0,x=y-1;y--;){var P=f[y];if(y==x||P!==L){var L=P;ea(P)?nf.call(c,P,1):m4(c,P)}}return c}function f4(c,f){return c+af(J9()*(f-c+1))}function Z$(c,f,y,x){for(var P=-1,L=mn(of((f-c)/(y||1)),0),H=ee(L);L--;)H[x?L:++P]=c,c+=y;return H}function p4(c,f){var y="";if(!c||f<1||f>U)return y;do f%2&&(y+=c),f=af(f/2),f&&(c+=c);while(f);return y}function Ye(c,f){return B4(U5(c,f,gr),c+"")}function Q$(c){return q9(Ql(c))}function eR(c,f){var y=Ql(c);return Sf(y,Vu(f,0,y.length))}function jd(c,f,y,x){if(!Ht(c))return c;f=Hs(f,c);for(var P=-1,L=f.length,H=L-1,j=c;j!=null&&++PP?0:P+f),y=y>P?P:y,y<0&&(y+=P),P=f>y?0:y-f>>>0,f>>>=0;for(var L=ee(P);++x>>1,H=c[L];H!==null&&!Dr(H)&&(y?H<=f:H=i){var oe=f?null:pR(c);if(oe)return Wh(oe);H=!1,P=Md,G=new Ku}else G=f?[]:j;e:for(;++x=x?c:ei(c,f,y)}var C5=VM||function(c){return Pn.clearTimeout(c)};function b5(c,f){if(f)return c.slice();var y=c.length,x=j9?j9(y):new c.constructor(y);return c.copy(x),x}function C4(c){var f=new c.constructor(c.byteLength);return new ef(f).set(new ef(c)),f}function oR(c,f){var y=f?C4(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function aR(c){var f=new c.constructor(c.source,i9.exec(c));return f.lastIndex=c.lastIndex,f}function sR(c){return Od?St(Od.call(c)):{}}function w5(c,f){var y=f?C4(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function S5(c,f){if(c!==f){var y=c!==n,x=c===null,P=c===c,L=Dr(c),H=f!==n,j=f===null,G=f===f,oe=Dr(f);if(!j&&!oe&&!L&&c>f||L&&H&&G&&!j&&!oe||x&&H&&G||!y&&G||!P)return 1;if(!x&&!L&&!oe&&c=j)return G;var oe=y[x];return G*(oe=="desc"?-1:1)}}return c.index-f.index}function x5(c,f,y,x){for(var P=-1,L=c.length,H=y.length,j=-1,G=f.length,oe=mn(L-H,0),ae=ee(G+oe),ue=!x;++j1?y[P-1]:n,H=P>2?y[2]:n;for(L=c.length>3&&typeof L=="function"?(P--,L):n,H&&Zn(y[0],y[1],H)&&(L=P<3?n:L,P=1),f=St(f);++x-1?P[L?f[H]:H]:n}}function P5(c){return Qo(function(f){var y=f.length,x=y,P=Zr.prototype.thru;for(c&&f.reverse();x--;){var L=f[x];if(typeof L!="function")throw new Xr(a);if(P&&!H&&bf(L)=="wrapper")var H=new Zr([],!0)}for(x=H?x:y;++x1&&rt.reverse(),ae&&Gj))return!1;var oe=L.get(c),ae=L.get(f);if(oe&&ae)return oe==f&&ae==c;var ue=-1,ye=!0,ke=y&E?new Ku:n;for(L.set(c,f),L.set(f,c);++ue1?"& ":"")+f[x],f=f.join(y>2?", ":" "),c.replace(AB,`{ /* [wrapped with `+f+`] */ -`)}function xR(c){return Ke(c)||Yu(c)||!!(V9&&c&&c[V9])}function ea(c,f){var y=typeof c;return f=f??U,!!f&&(y=="number"||y!="symbol"&&LB.test(c))&&c>-1&&c%1==0&&c0){if(++f>=X)return arguments[0]}else f=0;return c.apply(n,arguments)}}function Sf(c,f){var y=-1,x=c.length,P=x-1;for(f=f===n?x:f;++y1?c[f-1]:n;return y=typeof y=="function"?(c.pop(),y):n,tb(c,y)});function nb(c){var f=F(c);return f.__chain__=!0,f}function FF(c,f){return f(c),c}function xf(c,f){return f(c)}var LF=Qo(function(c){var f=c.length,y=f?c[0]:0,x=this.__wrapped__,P=function(L){return r4(L,c)};return f>1||this.__actions__.length||!(x instanceof et)||!ea(y)?this.thru(P):(x=x.slice(y,+y+(f?1:0)),x.__actions__.push({func:xf,args:[P],thisArg:n}),new Zr(x,this.__chain__).thru(function(L){return f&&!L.length&&L.push(n),L}))});function OF(){return nb(this)}function _F(){return new Zr(this.value(),this.__chain__)}function NF(){this.__values__===n&&(this.__values__=mb(this.value()));var c=this.__index__>=this.__values__.length,f=c?n:this.__values__[this.__index__++];return{done:c,value:f}}function zF(){return this}function HF(c){for(var f,y=this;y instanceof lf;){var x=Y5(y);x.__index__=0,x.__values__=n,f?P.__wrapped__=x:f=x;var P=x;y=y.__wrapped__}return P.__wrapped__=c,f}function jF(){var c=this.__wrapped__;if(c instanceof et){var f=c;return this.__actions__.length&&(f=new et(this)),f=f.reverse(),f.__actions__.push({func:xf,args:[B4],thisArg:n}),new Zr(f,this.__chain__)}return this.thru(B4)}function UF(){return y5(this.__wrapped__,this.__actions__)}var KF=mf(function(c,f,y){mt.call(c,y)?++c[y]:Xo(c,y,1)});function VF(c,f,y){var x=Ke(c)?B9:F$;return y&&Zn(c,f,y)&&(f=n),x(c,Le(f,3))}function GF(c,f){var y=Ke(c)?Fs:t5;return y(c,Le(f,3))}var JF=T5(q5),WF=T5(X5);function YF(c,f){return Bn(Af(c,f),1)}function qF(c,f){return Bn(Af(c,f),W)}function XF(c,f,y){return y=y===n?1:Je(y),Bn(Af(c,f),y)}function rb(c,f){var y=Ke(c)?qr:Ns;return y(c,Le(f,3))}function ib(c,f){var y=Ke(c)?mM:e5;return y(c,Le(f,3))}var ZF=mf(function(c,f,y){mt.call(c,y)?c[y].push(f):Xo(c,y,[f])});function QF(c,f,y,x){c=fr(c)?c:Ql(c),y=y&&!x?Je(y):0;var P=c.length;return y<0&&(y=mn(P+y,0)),Pf(c)?y<=P&&c.indexOf(f,y)>-1:!!P&&Hl(c,f,y)>-1}var eL=Ye(function(c,f,y){var x=-1,P=typeof f=="function",L=fr(c)?ee(c.length):[];return Ns(c,function(H){L[++x]=P?Ar(f,H,y):zd(H,f,y)}),L}),tL=mf(function(c,f,y){Xo(c,y,f)});function Af(c,f){var y=Ke(c)?Ft:s5;return y(c,Le(f,3))}function nL(c,f,y,x){return c==null?[]:(Ke(f)||(f=f==null?[]:[f]),y=x?n:y,Ke(y)||(y=y==null?[]:[y]),d5(c,f,y))}var rL=mf(function(c,f,y){c[y?0:1].push(f)},function(){return[[],[]]});function iL(c,f,y){var x=Ke(c)?K1:F9,P=arguments.length<3;return x(c,Le(f,4),y,P,Ns)}function oL(c,f,y){var x=Ke(c)?vM:F9,P=arguments.length<3;return x(c,Le(f,4),y,P,e5)}function aL(c,f){var y=Ke(c)?Fs:t5;return y(c,Df(Le(f,3)))}function sL(c){var f=Ke(c)?q9:Q$;return f(c)}function uL(c,f,y){(y?Zn(c,f,y):f===n)?f=1:f=Je(f);var x=Ke(c)?P$:eR;return x(c,f)}function lL(c){var f=Ke(c)?B$:nR;return f(c)}function cL(c){if(c==null)return 0;if(fr(c))return Pf(c)?Ul(c):c.length;var f=zn(c);return f==tn||f==Fi?c.size:l4(c).length}function dL(c,f,y){var x=Ke(c)?V1:rR;return y&&Zn(c,f,y)&&(f=n),x(c,Le(f,3))}var hL=Ye(function(c,f){if(c==null)return[];var y=f.length;return y>1&&Zn(c,f[0],f[1])?f=[]:y>2&&Zn(f[0],f[1],f[2])&&(f=[f[0]]),d5(c,Bn(f,1),[])}),kf=GM||function(){return Pn.Date.now()};function fL(c,f){if(typeof f!="function")throw new Xr(a);return c=Je(c),function(){if(--c<1)return f.apply(this,arguments)}}function ob(c,f,y){return f=y?n:f,f=c&&f==null?c.length:f,Zo(c,I,n,n,n,n,f)}function ab(c,f){var y;if(typeof f!="function")throw new Xr(a);return c=Je(c),function(){return--c>0&&(y=f.apply(this,arguments)),c<=1&&(f=n),y}}var $4=Ye(function(c,f,y){var x=w;if(y.length){var P=Os(y,Xl($4));x|=B}return Zo(c,x,f,y,P)}),sb=Ye(function(c,f,y){var x=w|C;if(y.length){var P=Os(y,Xl(sb));x|=B}return Zo(f,x,c,y,P)});function ub(c,f,y){f=y?n:f;var x=Zo(c,A,n,n,n,n,n,f);return x.placeholder=ub.placeholder,x}function lb(c,f,y){f=y?n:f;var x=Zo(c,T,n,n,n,n,n,f);return x.placeholder=lb.placeholder,x}function cb(c,f,y){var x,P,L,H,j,G,oe=0,ae=!1,ue=!1,ye=!0;if(typeof c!="function")throw new Xr(a);f=ni(f)||0,Ht(y)&&(ae=!!y.leading,ue="maxWait"in y,L=ue?mn(ni(y.maxWait)||0,f):L,ye="trailing"in y?!!y.trailing:ye);function ke(rn){var Ni=x,ra=P;return x=P=n,oe=rn,H=c.apply(ra,Ni),H}function _e(rn){return oe=rn,j=Vd(Qe,f),ae?ke(rn):H}function We(rn){var Ni=rn-G,ra=rn-oe,Tb=f-Ni;return ue?Nn(Tb,L-ra):Tb}function Ne(rn){var Ni=rn-G,ra=rn-oe;return G===n||Ni>=f||Ni<0||ue&&ra>=L}function Qe(){var rn=kf();if(Ne(rn))return rt(rn);j=Vd(Qe,We(rn))}function rt(rn){return j=n,ye&&x?ke(rn):(x=P=n,H)}function Tr(){j!==n&&C5(j),oe=0,x=G=P=j=n}function Qn(){return j===n?H:rt(kf())}function Pr(){var rn=kf(),Ni=Ne(rn);if(x=arguments,P=this,G=rn,Ni){if(j===n)return _e(G);if(ue)return C5(j),j=Vd(Qe,f),ke(G)}return j===n&&(j=Vd(Qe,f)),H}return Pr.cancel=Tr,Pr.flush=Qn,Pr}var pL=Ye(function(c,f){return Q9(c,1,f)}),gL=Ye(function(c,f,y){return Q9(c,ni(f)||0,y)});function mL(c){return Zo(c,O)}function If(c,f){if(typeof c!="function"||f!=null&&typeof f!="function")throw new Xr(a);var y=function(){var x=arguments,P=f?f.apply(this,x):x[0],L=y.cache;if(L.has(P))return L.get(P);var H=c.apply(this,x);return y.cache=L.set(P,H)||L,H};return y.cache=new(If.Cache||qo),y}If.Cache=qo;function Df(c){if(typeof c!="function")throw new Xr(a);return function(){var f=arguments;switch(f.length){case 0:return!c.call(this);case 1:return!c.call(this,f[0]);case 2:return!c.call(this,f[0],f[1]);case 3:return!c.call(this,f[0],f[1],f[2])}return!c.apply(this,f)}}function vL(c){return ab(2,c)}var yL=iR(function(c,f){f=f.length==1&&Ke(f[0])?Ft(f[0],kr(Le())):Ft(Bn(f,1),kr(Le()));var y=f.length;return Ye(function(x){for(var P=-1,L=Nn(x.length,y);++P=f}),Yu=i5(function(){return arguments}())?i5:function(c){return qt(c)&&mt.call(c,"callee")&&!K9.call(c,"callee")},Ke=ee.isArray,$L=A9?kr(A9):H$;function fr(c){return c!=null&&Tf(c.length)&&!ta(c)}function nn(c){return qt(c)&&fr(c)}function RL(c){return c===!0||c===!1||qt(c)&&Xn(c)==dt}var Us=WM||V4,FL=k9?kr(k9):j$;function LL(c){return qt(c)&&c.nodeType===1&&!Gd(c)}function OL(c){if(c==null)return!0;if(fr(c)&&(Ke(c)||typeof c=="string"||typeof c.splice=="function"||Us(c)||Zl(c)||Yu(c)))return!c.length;var f=zn(c);if(f==tn||f==Fi)return!c.size;if(Kd(c))return!l4(c).length;for(var y in c)if(mt.call(c,y))return!1;return!0}function _L(c,f){return Hd(c,f)}function NL(c,f,y){y=typeof y=="function"?y:n;var x=y?y(c,f):n;return x===n?Hd(c,f,n,y):!!x}function F4(c){if(!qt(c))return!1;var f=Xn(c);return f==On||f==Dn||typeof c.message=="string"&&typeof c.name=="string"&&!Gd(c)}function zL(c){return typeof c=="number"&&G9(c)}function ta(c){if(!Ht(c))return!1;var f=Xn(c);return f==_n||f==Tn||f==At||f==Jo}function hb(c){return typeof c=="number"&&c==Je(c)}function Tf(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=U}function Ht(c){var f=typeof c;return c!=null&&(f=="object"||f=="function")}function qt(c){return c!=null&&typeof c=="object"}var fb=I9?kr(I9):K$;function HL(c,f){return c===f||u4(c,f,A4(f))}function jL(c,f,y){return y=typeof y=="function"?y:n,u4(c,f,A4(f),y)}function UL(c){return pb(c)&&c!=+c}function KL(c){if(IR(c))throw new Ue(o);return o5(c)}function VL(c){return c===null}function GL(c){return c==null}function pb(c){return typeof c=="number"||qt(c)&&Xn(c)==Ri}function Gd(c){if(!qt(c)||Xn(c)!=Sn)return!1;var f=tf(c);if(f===null)return!0;var y=mt.call(f,"constructor")&&f.constructor;return typeof y=="function"&&y instanceof y&&Xh.call(y)==jM}var L4=D9?kr(D9):V$;function JL(c){return hb(c)&&c>=-U&&c<=U}var gb=T9?kr(T9):G$;function Pf(c){return typeof c=="string"||!Ke(c)&&qt(c)&&Xn(c)==Td}function Dr(c){return typeof c=="symbol"||qt(c)&&Xn(c)==jh}var Zl=P9?kr(P9):J$;function WL(c){return c===n}function YL(c){return qt(c)&&zn(c)==Pd}function qL(c){return qt(c)&&Xn(c)==hB}var XL=Cf(c4),ZL=Cf(function(c,f){return c<=f});function mb(c){if(!c)return[];if(fr(c))return Pf(c)?Li(c):hr(c);if($d&&c[$d])return PM(c[$d]());var f=zn(c),y=f==tn?X1:f==Fi?Wh:Ql;return y(c)}function na(c){if(!c)return c===0?c:0;if(c=ni(c),c===W||c===-W){var f=c<0?-1:1;return f*ne}return c===c?c:0}function Je(c){var f=na(c),y=f%1;return f===f?y?f-y:f:0}function vb(c){return c?Vu(Je(c),0,Ae):0}function ni(c){if(typeof c=="number")return c;if(Dr(c))return le;if(Ht(c)){var f=typeof c.valueOf=="function"?c.valueOf():c;c=Ht(f)?f+"":f}if(typeof c!="string")return c===0?c:+c;c=L9(c);var y=$B.test(c);return y||FB.test(c)?fM(c.slice(2),y?2:8):MB.test(c)?le:+c}function yb(c){return po(c,pr(c))}function QL(c){return c?Vu(Je(c),-U,U):c===0?c:0}function pt(c){return c==null?"":Ir(c)}var eO=Yl(function(c,f){if(Kd(f)||fr(f)){po(f,xn(f),c);return}for(var y in f)mt.call(f,y)&&_d(c,y,f[y])}),Eb=Yl(function(c,f){po(f,pr(f),c)}),Bf=Yl(function(c,f,y,x){po(f,pr(f),c,x)}),tO=Yl(function(c,f,y,x){po(f,xn(f),c,x)}),nO=Qo(r4);function rO(c,f){var y=Wl(c);return f==null?y:X9(y,f)}var iO=Ye(function(c,f){c=St(c);var y=-1,x=f.length,P=x>2?f[2]:n;for(P&&Zn(f[0],f[1],P)&&(x=1);++y1),L}),po(c,S4(c),y),x&&(y=Qr(y,p|g|m,gR));for(var P=f.length;P--;)g4(y,f[P]);return y});function wO(c,f){return bb(c,Df(Le(f)))}var SO=Qo(function(c,f){return c==null?{}:q$(c,f)});function bb(c,f){if(c==null)return{};var y=Ft(S4(c),function(x){return[x]});return f=Le(f),h5(c,y,function(x,P){return f(x,P[0])})}function xO(c,f,y){f=Hs(f,c);var x=-1,P=f.length;for(P||(P=1,c=n);++xf){var x=c;c=f,f=x}if(y||c%1||f%1){var P=J9();return Nn(c+P*(f-c+hM("1e-"+((P+"").length-1))),f)}return h4(c,f)}var FO=ql(function(c,f,y){return f=f.toLowerCase(),c+(y?xb(f):f)});function xb(c){return N4(pt(c).toLowerCase())}function Ab(c){return c=pt(c),c&&c.replace(OB,AM).replace(nM,"")}function LO(c,f,y){c=pt(c),f=Ir(f);var x=c.length;y=y===n?x:Vu(Je(y),0,x);var P=y;return y-=f.length,y>=0&&c.slice(y,P)==f}function OO(c){return c=pt(c),c&&vB.test(c)?c.replace(n9,kM):c}function _O(c){return c=pt(c),c&&SB.test(c)?c.replace(R1,"\\$&"):c}var NO=ql(function(c,f,y){return c+(y?"-":"")+f.toLowerCase()}),zO=ql(function(c,f,y){return c+(y?" ":"")+f.toLowerCase()}),HO=D5("toLowerCase");function jO(c,f,y){c=pt(c),f=Je(f);var x=f?Ul(c):0;if(!f||x>=f)return c;var P=(f-x)/2;return Ef(af(P),y)+c+Ef(of(P),y)}function UO(c,f,y){c=pt(c),f=Je(f);var x=f?Ul(c):0;return f&&x>>0,y?(c=pt(c),c&&(typeof f=="string"||f!=null&&!L4(f))&&(f=Ir(f),!f&&jl(c))?js(Li(c),0,y):c.split(f,y)):[]}var qO=ql(function(c,f,y){return c+(y?" ":"")+N4(f)});function XO(c,f,y){return c=pt(c),y=y==null?0:Vu(Je(y),0,c.length),f=Ir(f),c.slice(y,y+f.length)==f}function ZO(c,f,y){var x=F.templateSettings;y&&Zn(c,f,y)&&(f=n),c=pt(c),f=Bf({},f,x,F5);var P=Bf({},f.imports,x.imports,F5),L=xn(P),H=q1(P,L),j,G,oe=0,ae=f.interpolate||Uh,ue="__p += '",ye=Z1((f.escape||Uh).source+"|"+ae.source+"|"+(ae===r9?BB:Uh).source+"|"+(f.evaluate||Uh).source+"|$","g"),ke="//# sourceURL="+(mt.call(f,"sourceURL")?(f.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sM+"]")+` +`)}function xR(c){return Ke(c)||Yu(c)||!!(V9&&c&&c[V9])}function ea(c,f){var y=typeof c;return f=f??U,!!f&&(y=="number"||y!="symbol"&&LB.test(c))&&c>-1&&c%1==0&&c0){if(++f>=X)return arguments[0]}else f=0;return c.apply(n,arguments)}}function Sf(c,f){var y=-1,x=c.length,P=x-1;for(f=f===n?x:f;++y1?c[f-1]:n;return y=typeof y=="function"?(c.pop(),y):n,tb(c,y)});function nb(c){var f=F(c);return f.__chain__=!0,f}function FF(c,f){return f(c),c}function xf(c,f){return f(c)}var LF=Qo(function(c){var f=c.length,y=f?c[0]:0,x=this.__wrapped__,P=function(L){return i4(L,c)};return f>1||this.__actions__.length||!(x instanceof et)||!ea(y)?this.thru(P):(x=x.slice(y,+y+(f?1:0)),x.__actions__.push({func:xf,args:[P],thisArg:n}),new Zr(x,this.__chain__).thru(function(L){return f&&!L.length&&L.push(n),L}))});function OF(){return nb(this)}function _F(){return new Zr(this.value(),this.__chain__)}function NF(){this.__values__===n&&(this.__values__=mb(this.value()));var c=this.__index__>=this.__values__.length,f=c?n:this.__values__[this.__index__++];return{done:c,value:f}}function zF(){return this}function HF(c){for(var f,y=this;y instanceof lf;){var x=Y5(y);x.__index__=0,x.__values__=n,f?P.__wrapped__=x:f=x;var P=x;y=y.__wrapped__}return P.__wrapped__=c,f}function jF(){var c=this.__wrapped__;if(c instanceof et){var f=c;return this.__actions__.length&&(f=new et(this)),f=f.reverse(),f.__actions__.push({func:xf,args:[M4],thisArg:n}),new Zr(f,this.__chain__)}return this.thru(M4)}function UF(){return y5(this.__wrapped__,this.__actions__)}var KF=mf(function(c,f,y){mt.call(c,y)?++c[y]:Xo(c,y,1)});function VF(c,f,y){var x=Ke(c)?B9:F$;return y&&Zn(c,f,y)&&(f=n),x(c,Le(f,3))}function GF(c,f){var y=Ke(c)?Fs:t5;return y(c,Le(f,3))}var JF=T5(q5),WF=T5(X5);function YF(c,f){return Bn(Af(c,f),1)}function qF(c,f){return Bn(Af(c,f),W)}function XF(c,f,y){return y=y===n?1:Je(y),Bn(Af(c,f),y)}function rb(c,f){var y=Ke(c)?qr:Ns;return y(c,Le(f,3))}function ib(c,f){var y=Ke(c)?mM:e5;return y(c,Le(f,3))}var ZF=mf(function(c,f,y){mt.call(c,y)?c[y].push(f):Xo(c,y,[f])});function QF(c,f,y,x){c=fr(c)?c:Ql(c),y=y&&!x?Je(y):0;var P=c.length;return y<0&&(y=mn(P+y,0)),Pf(c)?y<=P&&c.indexOf(f,y)>-1:!!P&&Hl(c,f,y)>-1}var eL=Ye(function(c,f,y){var x=-1,P=typeof f=="function",L=fr(c)?ee(c.length):[];return Ns(c,function(H){L[++x]=P?Ar(f,H,y):zd(H,f,y)}),L}),tL=mf(function(c,f,y){Xo(c,y,f)});function Af(c,f){var y=Ke(c)?Ft:s5;return y(c,Le(f,3))}function nL(c,f,y,x){return c==null?[]:(Ke(f)||(f=f==null?[]:[f]),y=x?n:y,Ke(y)||(y=y==null?[]:[y]),d5(c,f,y))}var rL=mf(function(c,f,y){c[y?0:1].push(f)},function(){return[[],[]]});function iL(c,f,y){var x=Ke(c)?V1:F9,P=arguments.length<3;return x(c,Le(f,4),y,P,Ns)}function oL(c,f,y){var x=Ke(c)?vM:F9,P=arguments.length<3;return x(c,Le(f,4),y,P,e5)}function aL(c,f){var y=Ke(c)?Fs:t5;return y(c,Df(Le(f,3)))}function sL(c){var f=Ke(c)?q9:Q$;return f(c)}function uL(c,f,y){(y?Zn(c,f,y):f===n)?f=1:f=Je(f);var x=Ke(c)?P$:eR;return x(c,f)}function lL(c){var f=Ke(c)?B$:nR;return f(c)}function cL(c){if(c==null)return 0;if(fr(c))return Pf(c)?Ul(c):c.length;var f=zn(c);return f==tn||f==Fi?c.size:c4(c).length}function dL(c,f,y){var x=Ke(c)?G1:rR;return y&&Zn(c,f,y)&&(f=n),x(c,Le(f,3))}var hL=Ye(function(c,f){if(c==null)return[];var y=f.length;return y>1&&Zn(c,f[0],f[1])?f=[]:y>2&&Zn(f[0],f[1],f[2])&&(f=[f[0]]),d5(c,Bn(f,1),[])}),kf=GM||function(){return Pn.Date.now()};function fL(c,f){if(typeof f!="function")throw new Xr(a);return c=Je(c),function(){if(--c<1)return f.apply(this,arguments)}}function ob(c,f,y){return f=y?n:f,f=c&&f==null?c.length:f,Zo(c,I,n,n,n,n,f)}function ab(c,f){var y;if(typeof f!="function")throw new Xr(a);return c=Je(c),function(){return--c>0&&(y=f.apply(this,arguments)),c<=1&&(f=n),y}}var R4=Ye(function(c,f,y){var x=w;if(y.length){var P=Os(y,Xl(R4));x|=B}return Zo(c,x,f,y,P)}),sb=Ye(function(c,f,y){var x=w|C;if(y.length){var P=Os(y,Xl(sb));x|=B}return Zo(f,x,c,y,P)});function ub(c,f,y){f=y?n:f;var x=Zo(c,A,n,n,n,n,n,f);return x.placeholder=ub.placeholder,x}function lb(c,f,y){f=y?n:f;var x=Zo(c,T,n,n,n,n,n,f);return x.placeholder=lb.placeholder,x}function cb(c,f,y){var x,P,L,H,j,G,oe=0,ae=!1,ue=!1,ye=!0;if(typeof c!="function")throw new Xr(a);f=ni(f)||0,Ht(y)&&(ae=!!y.leading,ue="maxWait"in y,L=ue?mn(ni(y.maxWait)||0,f):L,ye="trailing"in y?!!y.trailing:ye);function ke(rn){var Ni=x,ra=P;return x=P=n,oe=rn,H=c.apply(ra,Ni),H}function _e(rn){return oe=rn,j=Vd(Qe,f),ae?ke(rn):H}function We(rn){var Ni=rn-G,ra=rn-oe,Tb=f-Ni;return ue?Nn(Tb,L-ra):Tb}function Ne(rn){var Ni=rn-G,ra=rn-oe;return G===n||Ni>=f||Ni<0||ue&&ra>=L}function Qe(){var rn=kf();if(Ne(rn))return rt(rn);j=Vd(Qe,We(rn))}function rt(rn){return j=n,ye&&x?ke(rn):(x=P=n,H)}function Tr(){j!==n&&C5(j),oe=0,x=G=P=j=n}function Qn(){return j===n?H:rt(kf())}function Pr(){var rn=kf(),Ni=Ne(rn);if(x=arguments,P=this,G=rn,Ni){if(j===n)return _e(G);if(ue)return C5(j),j=Vd(Qe,f),ke(G)}return j===n&&(j=Vd(Qe,f)),H}return Pr.cancel=Tr,Pr.flush=Qn,Pr}var pL=Ye(function(c,f){return Q9(c,1,f)}),gL=Ye(function(c,f,y){return Q9(c,ni(f)||0,y)});function mL(c){return Zo(c,O)}function If(c,f){if(typeof c!="function"||f!=null&&typeof f!="function")throw new Xr(a);var y=function(){var x=arguments,P=f?f.apply(this,x):x[0],L=y.cache;if(L.has(P))return L.get(P);var H=c.apply(this,x);return y.cache=L.set(P,H)||L,H};return y.cache=new(If.Cache||qo),y}If.Cache=qo;function Df(c){if(typeof c!="function")throw new Xr(a);return function(){var f=arguments;switch(f.length){case 0:return!c.call(this);case 1:return!c.call(this,f[0]);case 2:return!c.call(this,f[0],f[1]);case 3:return!c.call(this,f[0],f[1],f[2])}return!c.apply(this,f)}}function vL(c){return ab(2,c)}var yL=iR(function(c,f){f=f.length==1&&Ke(f[0])?Ft(f[0],kr(Le())):Ft(Bn(f,1),kr(Le()));var y=f.length;return Ye(function(x){for(var P=-1,L=Nn(x.length,y);++P=f}),Yu=i5(function(){return arguments}())?i5:function(c){return qt(c)&&mt.call(c,"callee")&&!K9.call(c,"callee")},Ke=ee.isArray,$L=A9?kr(A9):H$;function fr(c){return c!=null&&Tf(c.length)&&!ta(c)}function nn(c){return qt(c)&&fr(c)}function RL(c){return c===!0||c===!1||qt(c)&&Xn(c)==dt}var Us=WM||G4,FL=k9?kr(k9):j$;function LL(c){return qt(c)&&c.nodeType===1&&!Gd(c)}function OL(c){if(c==null)return!0;if(fr(c)&&(Ke(c)||typeof c=="string"||typeof c.splice=="function"||Us(c)||Zl(c)||Yu(c)))return!c.length;var f=zn(c);if(f==tn||f==Fi)return!c.size;if(Kd(c))return!c4(c).length;for(var y in c)if(mt.call(c,y))return!1;return!0}function _L(c,f){return Hd(c,f)}function NL(c,f,y){y=typeof y=="function"?y:n;var x=y?y(c,f):n;return x===n?Hd(c,f,n,y):!!x}function L4(c){if(!qt(c))return!1;var f=Xn(c);return f==On||f==Dn||typeof c.message=="string"&&typeof c.name=="string"&&!Gd(c)}function zL(c){return typeof c=="number"&&G9(c)}function ta(c){if(!Ht(c))return!1;var f=Xn(c);return f==_n||f==Tn||f==At||f==Jo}function hb(c){return typeof c=="number"&&c==Je(c)}function Tf(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=U}function Ht(c){var f=typeof c;return c!=null&&(f=="object"||f=="function")}function qt(c){return c!=null&&typeof c=="object"}var fb=I9?kr(I9):K$;function HL(c,f){return c===f||l4(c,f,k4(f))}function jL(c,f,y){return y=typeof y=="function"?y:n,l4(c,f,k4(f),y)}function UL(c){return pb(c)&&c!=+c}function KL(c){if(IR(c))throw new Ue(o);return o5(c)}function VL(c){return c===null}function GL(c){return c==null}function pb(c){return typeof c=="number"||qt(c)&&Xn(c)==Ri}function Gd(c){if(!qt(c)||Xn(c)!=Sn)return!1;var f=tf(c);if(f===null)return!0;var y=mt.call(f,"constructor")&&f.constructor;return typeof y=="function"&&y instanceof y&&Xh.call(y)==jM}var O4=D9?kr(D9):V$;function JL(c){return hb(c)&&c>=-U&&c<=U}var gb=T9?kr(T9):G$;function Pf(c){return typeof c=="string"||!Ke(c)&&qt(c)&&Xn(c)==Td}function Dr(c){return typeof c=="symbol"||qt(c)&&Xn(c)==jh}var Zl=P9?kr(P9):J$;function WL(c){return c===n}function YL(c){return qt(c)&&zn(c)==Pd}function qL(c){return qt(c)&&Xn(c)==hB}var XL=Cf(d4),ZL=Cf(function(c,f){return c<=f});function mb(c){if(!c)return[];if(fr(c))return Pf(c)?Li(c):hr(c);if($d&&c[$d])return PM(c[$d]());var f=zn(c),y=f==tn?Z1:f==Fi?Wh:Ql;return y(c)}function na(c){if(!c)return c===0?c:0;if(c=ni(c),c===W||c===-W){var f=c<0?-1:1;return f*ne}return c===c?c:0}function Je(c){var f=na(c),y=f%1;return f===f?y?f-y:f:0}function vb(c){return c?Vu(Je(c),0,Ae):0}function ni(c){if(typeof c=="number")return c;if(Dr(c))return le;if(Ht(c)){var f=typeof c.valueOf=="function"?c.valueOf():c;c=Ht(f)?f+"":f}if(typeof c!="string")return c===0?c:+c;c=L9(c);var y=$B.test(c);return y||FB.test(c)?fM(c.slice(2),y?2:8):MB.test(c)?le:+c}function yb(c){return po(c,pr(c))}function QL(c){return c?Vu(Je(c),-U,U):c===0?c:0}function pt(c){return c==null?"":Ir(c)}var eO=Yl(function(c,f){if(Kd(f)||fr(f)){po(f,xn(f),c);return}for(var y in f)mt.call(f,y)&&_d(c,y,f[y])}),Eb=Yl(function(c,f){po(f,pr(f),c)}),Bf=Yl(function(c,f,y,x){po(f,pr(f),c,x)}),tO=Yl(function(c,f,y,x){po(f,xn(f),c,x)}),nO=Qo(i4);function rO(c,f){var y=Wl(c);return f==null?y:X9(y,f)}var iO=Ye(function(c,f){c=St(c);var y=-1,x=f.length,P=x>2?f[2]:n;for(P&&Zn(f[0],f[1],P)&&(x=1);++y1),L}),po(c,x4(c),y),x&&(y=Qr(y,p|g|m,gR));for(var P=f.length;P--;)m4(y,f[P]);return y});function wO(c,f){return bb(c,Df(Le(f)))}var SO=Qo(function(c,f){return c==null?{}:q$(c,f)});function bb(c,f){if(c==null)return{};var y=Ft(x4(c),function(x){return[x]});return f=Le(f),h5(c,y,function(x,P){return f(x,P[0])})}function xO(c,f,y){f=Hs(f,c);var x=-1,P=f.length;for(P||(P=1,c=n);++xf){var x=c;c=f,f=x}if(y||c%1||f%1){var P=J9();return Nn(c+P*(f-c+hM("1e-"+((P+"").length-1))),f)}return f4(c,f)}var FO=ql(function(c,f,y){return f=f.toLowerCase(),c+(y?xb(f):f)});function xb(c){return z4(pt(c).toLowerCase())}function Ab(c){return c=pt(c),c&&c.replace(OB,AM).replace(nM,"")}function LO(c,f,y){c=pt(c),f=Ir(f);var x=c.length;y=y===n?x:Vu(Je(y),0,x);var P=y;return y-=f.length,y>=0&&c.slice(y,P)==f}function OO(c){return c=pt(c),c&&vB.test(c)?c.replace(n9,kM):c}function _O(c){return c=pt(c),c&&SB.test(c)?c.replace(F1,"\\$&"):c}var NO=ql(function(c,f,y){return c+(y?"-":"")+f.toLowerCase()}),zO=ql(function(c,f,y){return c+(y?" ":"")+f.toLowerCase()}),HO=D5("toLowerCase");function jO(c,f,y){c=pt(c),f=Je(f);var x=f?Ul(c):0;if(!f||x>=f)return c;var P=(f-x)/2;return Ef(af(P),y)+c+Ef(of(P),y)}function UO(c,f,y){c=pt(c),f=Je(f);var x=f?Ul(c):0;return f&&x>>0,y?(c=pt(c),c&&(typeof f=="string"||f!=null&&!O4(f))&&(f=Ir(f),!f&&jl(c))?js(Li(c),0,y):c.split(f,y)):[]}var qO=ql(function(c,f,y){return c+(y?" ":"")+z4(f)});function XO(c,f,y){return c=pt(c),y=y==null?0:Vu(Je(y),0,c.length),f=Ir(f),c.slice(y,y+f.length)==f}function ZO(c,f,y){var x=F.templateSettings;y&&Zn(c,f,y)&&(f=n),c=pt(c),f=Bf({},f,x,F5);var P=Bf({},f.imports,x.imports,F5),L=xn(P),H=X1(P,L),j,G,oe=0,ae=f.interpolate||Uh,ue="__p += '",ye=Q1((f.escape||Uh).source+"|"+ae.source+"|"+(ae===r9?BB:Uh).source+"|"+(f.evaluate||Uh).source+"|$","g"),ke="//# sourceURL="+(mt.call(f,"sourceURL")?(f.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sM+"]")+` `;c.replace(ye,function(Ne,Qe,rt,Tr,Qn,Pr){return rt||(rt=Tr),ue+=c.slice(oe,Pr).replace(_B,IM),Qe&&(j=!0,ue+=`' + __e(`+Qe+`) + '`),Qn&&(G=!0,ue+=`'; @@ -575,4 +575,4 @@ __p += '`),rt&&(ue+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+ue+`return __p -}`;var We=Ib(function(){return ht(L,ke+"return "+ue).apply(n,H)});if(We.source=ue,F4(We))throw We;return We}function QO(c){return pt(c).toLowerCase()}function e_(c){return pt(c).toUpperCase()}function t_(c,f,y){if(c=pt(c),c&&(y||f===n))return L9(c);if(!c||!(f=Ir(f)))return c;var x=Li(c),P=Li(f),L=O9(x,P),H=_9(x,P)+1;return js(x,L,H).join("")}function n_(c,f,y){if(c=pt(c),c&&(y||f===n))return c.slice(0,z9(c)+1);if(!c||!(f=Ir(f)))return c;var x=Li(c),P=_9(x,Li(f))+1;return js(x,0,P).join("")}function r_(c,f,y){if(c=pt(c),c&&(y||f===n))return c.replace(F1,"");if(!c||!(f=Ir(f)))return c;var x=Li(c),P=O9(x,Li(f));return js(x,P).join("")}function i_(c,f){var y=z,x=K;if(Ht(f)){var P="separator"in f?f.separator:P;y="length"in f?Je(f.length):y,x="omission"in f?Ir(f.omission):x}c=pt(c);var L=c.length;if(jl(c)){var H=Li(c);L=H.length}if(y>=L)return c;var j=y-Ul(x);if(j<1)return x;var G=H?js(H,0,j).join(""):c.slice(0,j);if(P===n)return G+x;if(H&&(j+=G.length-j),L4(P)){if(c.slice(j).search(P)){var oe,ae=G;for(P.global||(P=Z1(P.source,pt(i9.exec(P))+"g")),P.lastIndex=0;oe=P.exec(ae);)var ue=oe.index;G=G.slice(0,ue===n?j:ue)}}else if(c.indexOf(Ir(P),j)!=j){var ye=G.lastIndexOf(P);ye>-1&&(G=G.slice(0,ye))}return G+x}function o_(c){return c=pt(c),c&&mB.test(c)?c.replace(t9,RM):c}var a_=ql(function(c,f,y){return c+(y?" ":"")+f.toUpperCase()}),N4=D5("toUpperCase");function kb(c,f,y){return c=pt(c),f=y?n:f,f===n?TM(c)?OM(c):CM(c):c.match(f)||[]}var Ib=Ye(function(c,f){try{return Ar(c,n,f)}catch(y){return F4(y)?y:new Ue(y)}}),s_=Qo(function(c,f){return qr(f,function(y){y=go(y),Xo(c,y,$4(c[y],c))}),c});function u_(c){var f=c==null?0:c.length,y=Le();return c=f?Ft(c,function(x){if(typeof x[1]!="function")throw new Xr(a);return[y(x[0]),x[1]]}):[],Ye(function(x){for(var P=-1;++PU)return[];var y=Ae,x=Nn(c,Ae);f=Le(f),c-=Ae;for(var P=Y1(x,f);++y0||f<0)?new et(y):(c<0?y=y.takeRight(-c):c&&(y=y.drop(c)),f!==n&&(f=Je(f),y=f<0?y.dropRight(-f):y.take(f-c)),y)},et.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},et.prototype.toArray=function(){return this.take(Ae)},fo(et.prototype,function(c,f){var y=/^(?:filter|find|map|reject)|While$/.test(f),x=/^(?:head|last)$/.test(f),P=F[x?"take"+(f=="last"?"Right":""):f],L=x||/^find/.test(f);P&&(F.prototype[f]=function(){var H=this.__wrapped__,j=x?[1]:arguments,G=H instanceof et,oe=j[0],ae=G||Ke(H),ue=function(Qe){var rt=P.apply(F,Ls([Qe],j));return x&&ye?rt[0]:rt};ae&&y&&typeof oe=="function"&&oe.length!=1&&(G=ae=!1);var ye=this.__chain__,ke=!!this.__actions__.length,_e=L&&!ye,We=G&&!ke;if(!L&&ae){H=We?H:new et(this);var Ne=c.apply(H,j);return Ne.__actions__.push({func:xf,args:[ue],thisArg:n}),new Zr(Ne,ye)}return _e&&We?c.apply(this,j):(Ne=this.thru(ue),_e?x?Ne.value()[0]:Ne.value():Ne)})}),qr(["pop","push","shift","sort","splice","unshift"],function(c){var f=Yh[c],y=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",x=/^(?:pop|shift)$/.test(c);F.prototype[c]=function(){var P=arguments;if(x&&!this.__chain__){var L=this.value();return f.apply(Ke(L)?L:[],P)}return this[y](function(H){return f.apply(Ke(H)?H:[],P)})}}),fo(et.prototype,function(c,f){var y=F[f];if(y){var x=y.name+"";mt.call(Jl,x)||(Jl[x]=[]),Jl[x].push({name:f,func:y})}}),Jl[vf(n,C).name]=[{name:"wrapper",func:n}],et.prototype.clone=o$,et.prototype.reverse=a$,et.prototype.value=s$,F.prototype.at=LF,F.prototype.chain=OF,F.prototype.commit=_F,F.prototype.next=NF,F.prototype.plant=HF,F.prototype.reverse=jF,F.prototype.toJSON=F.prototype.valueOf=F.prototype.value=UF,F.prototype.first=F.prototype.head,$d&&(F.prototype[$d]=zF),F},Kl=_M();Hu?((Hu.exports=Kl)._=Kl,H1._=Kl):Pn._=Kl}).call(fc)})(dm,dm.exports);var VVe=dm.exports;const GVe=vh(VVe);let yo,Un;function JVe(e){const[t,n]=l.useState(),[r,i]=l.useState(!0),o=l.useCallback(u=>{u.loadRoom(e),u.setIsLoading(!0),u.pause(),n(u);const d=UVe({dictionaries:[KVe]});u.updateUsers([{id:u.currentUser.id,point:[0,0],color:HVe(),status:CT.Connected,activeShapes:[],selectedIds:[],metadata:{name:d}}])},[e]),a=JS((u,d,h)=>{if(!u||yo===void 0||Un===void 0)return;const p=(g,m)=>Object.keys(g).filter(v=>!GVe.isEqual(g[v],m[v]));Object.entries(d).forEach(([g,m])=>{Un.update(v=>{m?v.shapes[g]?p(m,v.shapes[g].toJS()).forEach(w=>{const C=m[w];v.shapes[g][w]=C}):v.shapes[g]=m:delete v.shapes[g]})}),Object.entries(h).forEach(([g,m])=>{Un.update(v=>{m?v.bindings[g]?p(m,v.bindings[g].toJS()).forEach(w=>{const C=m[w];v.bindings[g][w]=C}):v.bindings[g]=m:delete v.bindings[g]})}),Object.entries(u.assets).forEach(([,g])=>{Un.update(m=>{g.id?m.assets[g.id]?m.assets[g.id]=g:p(g,m.assets[g.id].toJS()).forEach(E=>{const w=g[E];m.assets[g.id][E]=w}):delete m.assets[g.id]})})},60,!1),s=JS((u,d)=>{!u||yo===void 0||!yo.isActive()||Un.update((h,p)=>{p.set({tdUser:d})})},60,!1);return l.useEffect(()=>{if(!t)return;function u(){yo===void 0||Un===void 0||(yo.detach(Un),yo.deactivate())}window.addEventListener("beforeunload",u);function d(){const g=Un.getRoot(),m=JSON.parse(g.shapes.toJSON()),v=JSON.parse(g.bindings.toJSON()),E=JSON.parse(g.assets.toJSON());t==null||t.replacePageContent(m,v,E)}let h=!0;async function p(){try{const g={apiKey:"cedaovjuioqlk4pjqn6g",syncLoopDuration:0,reconnectStreamDelay:1e3};yo=new e9("https://api.yorkie.dev",g),await yo.activate(),Un=new QC(e,{enableDevtools:!0}),Un.subscribe("my-presence",v=>{if(v.type===bn.Initialized){const E=Un.getPresences().map(w=>w.presence.tdUser);t==null||t.updateUsers(E)}}),Un.subscribe("others",v=>{v.type===bn.Unwatched&&(t==null||t.removeUser(v.value.presence.tdUser.id));const E=Un.getPresences().map(w=>w.presence.tdUser);t==null||t.updateUsers(E)});const m=(t==null?void 0:t.currentUser)&&{initialPresence:{tdUser:t.currentUser}};await yo.attach(Un,m),Un.update(v=>{v.shapes||(v.shapes={}),v.bindings||(v.bindings={}),v.assets||(v.assets={})},"create shapes/bindings/assets object if not exists"),Un.subscribe(v=>{v.type==="remote-change"&&d()}),await yo.sync(),h&&(d(),t&&(t.zoomToFit(),t.zoom>1&&t.resetZoom(),t.setIsLoading(!1)),i(!1))}catch(g){console.error(g)}}return p(),()=>{window.removeEventListener("beforeunload",u),h=!1}},[t]),{onMount:o,onChangePage:a,loading:r,onChangePresence:s}}const WVe=({color:e,metadata:t})=>ce.jsxs("div",{style:{display:"flex",width:"fit-content",alignItems:"center",gap:8},children:[ce.jsx("div",{style:{width:12,height:12,background:e,borderRadius:"100%"}}),ce.jsx("div",{style:{background:"white",padding:"4px 8px",borderRadius:4,whiteSpace:"nowrap"},children:t.name})]});function YVe(){const e=mne(),{...t}=JVe(`tldraw-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`),n={Cursor:WVe};return ce.jsx("div",{className:"tldraw",children:ce.jsx(Bje,{components:n,autofocus:!0,disableAssets:!0,showPages:!1,...e,...t})})}s2.createRoot(document.getElementById("root")).render(ce.jsx(Kt.StrictMode,{children:ce.jsx(YVe,{})})); +}`;var We=Ib(function(){return ht(L,ke+"return "+ue).apply(n,H)});if(We.source=ue,L4(We))throw We;return We}function QO(c){return pt(c).toLowerCase()}function e_(c){return pt(c).toUpperCase()}function t_(c,f,y){if(c=pt(c),c&&(y||f===n))return L9(c);if(!c||!(f=Ir(f)))return c;var x=Li(c),P=Li(f),L=O9(x,P),H=_9(x,P)+1;return js(x,L,H).join("")}function n_(c,f,y){if(c=pt(c),c&&(y||f===n))return c.slice(0,z9(c)+1);if(!c||!(f=Ir(f)))return c;var x=Li(c),P=_9(x,Li(f))+1;return js(x,0,P).join("")}function r_(c,f,y){if(c=pt(c),c&&(y||f===n))return c.replace(L1,"");if(!c||!(f=Ir(f)))return c;var x=Li(c),P=O9(x,Li(f));return js(x,P).join("")}function i_(c,f){var y=z,x=K;if(Ht(f)){var P="separator"in f?f.separator:P;y="length"in f?Je(f.length):y,x="omission"in f?Ir(f.omission):x}c=pt(c);var L=c.length;if(jl(c)){var H=Li(c);L=H.length}if(y>=L)return c;var j=y-Ul(x);if(j<1)return x;var G=H?js(H,0,j).join(""):c.slice(0,j);if(P===n)return G+x;if(H&&(j+=G.length-j),O4(P)){if(c.slice(j).search(P)){var oe,ae=G;for(P.global||(P=Q1(P.source,pt(i9.exec(P))+"g")),P.lastIndex=0;oe=P.exec(ae);)var ue=oe.index;G=G.slice(0,ue===n?j:ue)}}else if(c.indexOf(Ir(P),j)!=j){var ye=G.lastIndexOf(P);ye>-1&&(G=G.slice(0,ye))}return G+x}function o_(c){return c=pt(c),c&&mB.test(c)?c.replace(t9,RM):c}var a_=ql(function(c,f,y){return c+(y?" ":"")+f.toUpperCase()}),z4=D5("toUpperCase");function kb(c,f,y){return c=pt(c),f=y?n:f,f===n?TM(c)?OM(c):CM(c):c.match(f)||[]}var Ib=Ye(function(c,f){try{return Ar(c,n,f)}catch(y){return L4(y)?y:new Ue(y)}}),s_=Qo(function(c,f){return qr(f,function(y){y=go(y),Xo(c,y,R4(c[y],c))}),c});function u_(c){var f=c==null?0:c.length,y=Le();return c=f?Ft(c,function(x){if(typeof x[1]!="function")throw new Xr(a);return[y(x[0]),x[1]]}):[],Ye(function(x){for(var P=-1;++PU)return[];var y=Ae,x=Nn(c,Ae);f=Le(f),c-=Ae;for(var P=q1(x,f);++y0||f<0)?new et(y):(c<0?y=y.takeRight(-c):c&&(y=y.drop(c)),f!==n&&(f=Je(f),y=f<0?y.dropRight(-f):y.take(f-c)),y)},et.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},et.prototype.toArray=function(){return this.take(Ae)},fo(et.prototype,function(c,f){var y=/^(?:filter|find|map|reject)|While$/.test(f),x=/^(?:head|last)$/.test(f),P=F[x?"take"+(f=="last"?"Right":""):f],L=x||/^find/.test(f);P&&(F.prototype[f]=function(){var H=this.__wrapped__,j=x?[1]:arguments,G=H instanceof et,oe=j[0],ae=G||Ke(H),ue=function(Qe){var rt=P.apply(F,Ls([Qe],j));return x&&ye?rt[0]:rt};ae&&y&&typeof oe=="function"&&oe.length!=1&&(G=ae=!1);var ye=this.__chain__,ke=!!this.__actions__.length,_e=L&&!ye,We=G&&!ke;if(!L&&ae){H=We?H:new et(this);var Ne=c.apply(H,j);return Ne.__actions__.push({func:xf,args:[ue],thisArg:n}),new Zr(Ne,ye)}return _e&&We?c.apply(this,j):(Ne=this.thru(ue),_e?x?Ne.value()[0]:Ne.value():Ne)})}),qr(["pop","push","shift","sort","splice","unshift"],function(c){var f=Yh[c],y=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",x=/^(?:pop|shift)$/.test(c);F.prototype[c]=function(){var P=arguments;if(x&&!this.__chain__){var L=this.value();return f.apply(Ke(L)?L:[],P)}return this[y](function(H){return f.apply(Ke(H)?H:[],P)})}}),fo(et.prototype,function(c,f){var y=F[f];if(y){var x=y.name+"";mt.call(Jl,x)||(Jl[x]=[]),Jl[x].push({name:f,func:y})}}),Jl[vf(n,C).name]=[{name:"wrapper",func:n}],et.prototype.clone=o$,et.prototype.reverse=a$,et.prototype.value=s$,F.prototype.at=LF,F.prototype.chain=OF,F.prototype.commit=_F,F.prototype.next=NF,F.prototype.plant=HF,F.prototype.reverse=jF,F.prototype.toJSON=F.prototype.valueOf=F.prototype.value=UF,F.prototype.first=F.prototype.head,$d&&(F.prototype[$d]=zF),F},Kl=_M();Hu?((Hu.exports=Kl)._=Kl,j1._=Kl):Pn._=Kl}).call(fc)})(dm,dm.exports);var VVe=dm.exports;const GVe=vh(VVe);let yo,Un;function JVe(e){const[t,n]=l.useState(),[r,i]=l.useState(!0),o=l.useCallback(u=>{u.loadRoom(e),u.setIsLoading(!0),u.pause(),n(u);const d=UVe({dictionaries:[KVe]});u.updateUsers([{id:u.currentUser.id,point:[0,0],color:HVe(),status:CT.Connected,activeShapes:[],selectedIds:[],metadata:{name:d}}])},[e]),a=JS((u,d,h)=>{if(!u||yo===void 0||Un===void 0)return;const p=(g,m)=>Object.keys(g).filter(v=>!GVe.isEqual(g[v],m[v]));Object.entries(d).forEach(([g,m])=>{Un.update(v=>{m?v.shapes[g]?p(m,v.shapes[g].toJS()).forEach(w=>{const C=m[w];v.shapes[g][w]=C}):v.shapes[g]=m:delete v.shapes[g]})}),Object.entries(h).forEach(([g,m])=>{Un.update(v=>{m?v.bindings[g]?p(m,v.bindings[g].toJS()).forEach(w=>{const C=m[w];v.bindings[g][w]=C}):v.bindings[g]=m:delete v.bindings[g]})}),Object.entries(u.assets).forEach(([,g])=>{Un.update(m=>{g.id?m.assets[g.id]?m.assets[g.id]=g:p(g,m.assets[g.id].toJS()).forEach(E=>{const w=g[E];m.assets[g.id][E]=w}):delete m.assets[g.id]})})},60,!1),s=JS((u,d)=>{!u||yo===void 0||!yo.isActive()||Un.update((h,p)=>{p.set({tdUser:d})})},60,!1);return l.useEffect(()=>{if(!t)return;function u(){yo===void 0||Un===void 0||(yo.detach(Un),yo.deactivate())}window.addEventListener("beforeunload",u);function d(){const g=Un.getRoot(),m=JSON.parse(g.shapes.toJSON()),v=JSON.parse(g.bindings.toJSON()),E=JSON.parse(g.assets.toJSON());t==null||t.replacePageContent(m,v,E)}let h=!0;async function p(){try{const g={apiKey:"cedaovjuioqlk4pjqn6g",syncLoopDuration:0,reconnectStreamDelay:1e3};yo=new e9("https://api.yorkie.dev",g),await yo.activate(),Un=new QC(e,{enableDevtools:!0}),Un.subscribe("my-presence",v=>{if(v.type===bn.Initialized){const E=Un.getPresences().map(w=>w.presence.tdUser);t==null||t.updateUsers(E)}}),Un.subscribe("others",v=>{v.type===bn.Unwatched&&(t==null||t.removeUser(v.value.presence.tdUser.id));const E=Un.getPresences().map(w=>w.presence.tdUser);t==null||t.updateUsers(E)});const m=(t==null?void 0:t.currentUser)&&{initialPresence:{tdUser:t.currentUser}};await yo.attach(Un,m),Un.update(v=>{v.shapes||(v.shapes={}),v.bindings||(v.bindings={}),v.assets||(v.assets={})},"create shapes/bindings/assets object if not exists"),Un.subscribe(v=>{v.type==="remote-change"&&d()}),await yo.sync(),h&&(d(),t&&(t.zoomToFit(),t.zoom>1&&t.resetZoom(),t.setIsLoading(!1)),i(!1))}catch(g){console.error(g)}}return p(),()=>{window.removeEventListener("beforeunload",u),h=!1}},[t]),{onMount:o,onChangePage:a,loading:r,onChangePresence:s}}const WVe=({color:e,metadata:t})=>ce.jsxs("div",{style:{display:"flex",width:"fit-content",alignItems:"center",gap:8},children:[ce.jsx("div",{style:{width:12,height:12,background:e,borderRadius:"100%"}}),ce.jsx("div",{style:{background:"white",padding:"4px 8px",borderRadius:4,whiteSpace:"nowrap"},children:t.name})]});function YVe(){const e=mne(),{...t}=JVe(`tldraw-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`),n={Cursor:WVe};return ce.jsx("div",{className:"tldraw",children:ce.jsx(Bje,{components:n,autofocus:!0,disableAssets:!0,showPages:!1,...e,...t})})}u2.createRoot(document.getElementById("root")).render(ce.jsx(Kt.StrictMode,{children:ce.jsx(YVe,{})})); diff --git a/examples/react-tldraw/index.html b/examples/react-tldraw/index.html index 78adb9b42..e0a8d5531 100644 --- a/examples/react-tldraw/index.html +++ b/examples/react-tldraw/index.html @@ -4,7 +4,7 @@ react-tldraw - + diff --git a/examples/react-todomvc/assets/index-CosHSvo1.js b/examples/react-todomvc/assets/index-4GhU6Gpr.js similarity index 76% rename from examples/react-todomvc/assets/index-CosHSvo1.js rename to examples/react-todomvc/assets/index-4GhU6Gpr.js index d327a63af..a91ed4c10 100644 --- a/examples/react-todomvc/assets/index-CosHSvo1.js +++ b/examples/react-todomvc/assets/index-4GhU6Gpr.js @@ -6,7 +6,7 @@ var Fy=Object.defineProperty;var My=(n,e,t)=>e in n?Fy(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Eo=Symbol.for("react.element"),$y=Symbol.for("react.portal"),zy=Symbol.for("react.fragment"),Uy=Symbol.for("react.strict_mode"),jy=Symbol.for("react.profiler"),Vy=Symbol.for("react.provider"),qy=Symbol.for("react.context"),Ky=Symbol.for("react.forward_ref"),Wy=Symbol.for("react.suspense"),Hy=Symbol.for("react.memo"),_y=Symbol.for("react.lazy"),dd=Symbol.iterator;function Gy(n){return n===null||typeof n!="object"?null:(n=dd&&n[dd]||n["@@iterator"],typeof n=="function"?n:null)}var hg={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},gg=Object.assign,mg={};function vs(n,e,t){this.props=n,this.context=e,this.refs=mg,this.updater=t||hg}vs.prototype.isReactComponent={};vs.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};vs.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function pg(){}pg.prototype=vs.prototype;function Gc(n,e,t){this.props=n,this.context=e,this.refs=mg,this.updater=t||hg}var Yc=Gc.prototype=new pg;Yc.constructor=Gc;gg(Yc,vs.prototype);Yc.isPureReactComponent=!0;var hd=Array.isArray,yg=Object.prototype.hasOwnProperty,Qc={current:null},vg={key:!0,ref:!0,__self:!0,__source:!0};function wg(n,e,t){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)yg.call(e,r)&&!vg.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=t;else if(1e in n?Fy(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var ev=Mr,tv=Symbol.for("react.element"),nv=Symbol.for("react.fragment"),rv=Object.prototype.hasOwnProperty,iv=ev.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sv={key:!0,ref:!0,__self:!0,__source:!0};function Sg(n,e,t){var r,i={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)rv.call(e,r)&&!sv.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:tv,type:n,key:s,ref:o,props:i,_owner:iv.current}}wl.Fragment=nv;wl.jsx=Sg;wl.jsxs=Sg;fg.exports=wl;var Q=fg.exports,Cu={},kg={exports:{}},rt={},Tg={exports:{}},Ag={};/** + */var ev=Mr,tv=Symbol.for("react.element"),nv=Symbol.for("react.fragment"),rv=Object.prototype.hasOwnProperty,iv=ev.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sv={key:!0,ref:!0,__self:!0,__source:!0};function Sg(n,e,t){var r,i={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)rv.call(e,r)&&!sv.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:tv,type:n,key:s,ref:o,props:i,_owner:iv.current}}wl.Fragment=nv;wl.jsx=Sg;wl.jsxs=Sg;fg.exports=wl;var Q=fg.exports,Nu={},kg={exports:{}},rt={},Tg={exports:{}},Ag={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var Fy=Object.defineProperty;var My=(n,e,t)=>e in n?Fy(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(n){function e(B,U){var j=B.length;B.push(U);e:for(;0>>1,ke=B[fe];if(0>>1;fei(Kl,j))iii(Fo,Kl)?(B[fe]=Fo,B[ii]=j,fe=ii):(B[fe]=Kl,B[ri]=j,fe=ri);else if(iii(Fo,j))B[fe]=Fo,B[ii]=j,fe=ii;else break e}}return U}function i(B,U){var j=B.sortIndex-U.sortIndex;return j!==0?j:B.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],d=1,h=null,m=3,y=!1,w=!1,T=!1,P=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(B){for(var U=t(c);U!==null;){if(U.callback===null)r(c);else if(U.startTime<=B)r(c),U.sortIndex=U.expirationTime,e(l,U);else break;U=t(c)}}function I(B){if(T=!1,v(B),!w)if(t(l)!==null)w=!0,Vl(E);else{var U=t(c);U!==null&&ql(I,U.startTime-B)}}function E(B,U){w=!1,T&&(T=!1,p(R),R=-1),y=!0;var j=m;try{for(v(U),h=t(l);h!==null&&(!(h.expirationTime>U)||B&&!Se());){var fe=h.callback;if(typeof fe=="function"){h.callback=null,m=h.priorityLevel;var ke=fe(h.expirationTime<=U);U=n.unstable_now(),typeof ke=="function"?h.callback=ke:h===t(l)&&r(l),v(U)}else r(l);h=t(l)}if(h!==null)var bo=!0;else{var ri=t(c);ri!==null&&ql(I,ri.startTime-U),bo=!1}return bo}finally{h=null,m=j,y=!1}}var N=!1,D=null,R=-1,q=5,$=-1;function Se(){return!(n.unstable_now()-$B||125fe?(B.sortIndex=j,e(c,B),t(l)===null&&B===t(c)&&(T?(p(R),R=-1):T=!0,ql(I,j-fe))):(B.sortIndex=ke,e(l,B),w||y||(w=!0,Vl(E))),B},n.unstable_shouldYield=Se,n.unstable_wrapCallback=function(B){var U=m;return function(){var j=m;m=U;try{return B.apply(this,arguments)}finally{m=j}}}})(Ag);Tg.exports=Ag;var ov=Tg.exports;/** + */(function(n){function e(B,U){var j=B.length;B.push(U);e:for(;0>>1,ke=B[fe];if(0>>1;fei(Wl,j))iii(Fo,Wl)?(B[fe]=Fo,B[ii]=j,fe=ii):(B[fe]=Wl,B[ri]=j,fe=ri);else if(iii(Fo,j))B[fe]=Fo,B[ii]=j,fe=ii;else break e}}return U}function i(B,U){var j=B.sortIndex-U.sortIndex;return j!==0?j:B.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var l=[],c=[],d=1,h=null,m=3,y=!1,w=!1,T=!1,P=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(B){for(var U=t(c);U!==null;){if(U.callback===null)r(c);else if(U.startTime<=B)r(c),U.sortIndex=U.expirationTime,e(l,U);else break;U=t(c)}}function I(B){if(T=!1,v(B),!w)if(t(l)!==null)w=!0,ql(E);else{var U=t(c);U!==null&&Kl(I,U.startTime-B)}}function E(B,U){w=!1,T&&(T=!1,p(R),R=-1),y=!0;var j=m;try{for(v(U),h=t(l);h!==null&&(!(h.expirationTime>U)||B&&!Se());){var fe=h.callback;if(typeof fe=="function"){h.callback=null,m=h.priorityLevel;var ke=fe(h.expirationTime<=U);U=n.unstable_now(),typeof ke=="function"?h.callback=ke:h===t(l)&&r(l),v(U)}else r(l);h=t(l)}if(h!==null)var bo=!0;else{var ri=t(c);ri!==null&&Kl(I,ri.startTime-U),bo=!1}return bo}finally{h=null,m=j,y=!1}}var N=!1,D=null,R=-1,q=5,$=-1;function Se(){return!(n.unstable_now()-$B||125fe?(B.sortIndex=j,e(c,B),t(l)===null&&B===t(c)&&(T?(p(R),R=-1):T=!0,Kl(I,j-fe))):(B.sortIndex=ke,e(l,B),w||y||(w=!0,ql(E))),B},n.unstable_shouldYield=Se,n.unstable_wrapCallback=function(B){var U=m;return function(){var j=m;m=U;try{return B.apply(this,arguments)}finally{m=j}}}})(Ag);Tg.exports=Ag;var ov=Tg.exports;/** * @license React * react-dom.production.min.js * @@ -30,16 +30,16 @@ var Fy=Object.defineProperty;var My=(n,e,t)=>e in n?Fy(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ig=Mr,nt=ov;function x(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nu=Object.prototype.hasOwnProperty,av=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,md={},pd={};function lv(n){return Nu.call(pd,n)?!0:Nu.call(md,n)?!1:av.test(n)?pd[n]=!0:(md[n]=!0,!1)}function uv(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function cv(n,e,t,r){if(e===null||typeof e>"u"||uv(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ze(n,e,t,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Ne[n]=new ze(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Ne[e]=new ze(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Ne[n]=new ze(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Ne[n]=new ze(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){Ne[n]=new ze(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Ne[n]=new ze(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Ne[n]=new ze(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Ne[n]=new ze(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Ne[n]=new ze(n,5,!1,n.toLowerCase(),null,!1,!1)});var Zc=/[\-:]([a-z])/g;function ef(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(Zc,ef);Ne[e]=new ze(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(Zc,ef);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(Zc,ef);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!0,!0)});function tf(n,e,t,r){var i=Ne.hasOwnProperty(e)?Ne[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pu=Object.prototype.hasOwnProperty,av=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,md={},pd={};function lv(n){return Pu.call(pd,n)?!0:Pu.call(md,n)?!1:av.test(n)?pd[n]=!0:(md[n]=!0,!1)}function uv(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function cv(n,e,t,r){if(e===null||typeof e>"u"||uv(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ze(n,e,t,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Ne[n]=new ze(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Ne[e]=new ze(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Ne[n]=new ze(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Ne[n]=new ze(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){Ne[n]=new ze(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Ne[n]=new ze(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Ne[n]=new ze(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Ne[n]=new ze(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Ne[n]=new ze(n,5,!1,n.toLowerCase(),null,!1,!1)});var ef=/[\-:]([a-z])/g;function tf(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(ef,tf);Ne[e]=new ze(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(ef,tf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(ef,tf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!0,!0)});function nf(n,e,t,r){var i=Ne.hasOwnProperty(e)?Ne[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return n.displayName&&l.includes("")&&(l=l.replace("",n.displayName)),l}while(1<=o&&0<=a);break}}}finally{_l=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Rs(n):""}function fv(n){switch(n.tag){case 5:return Rs(n.type);case 16:return Rs("Lazy");case 13:return Rs("Suspense");case 19:return Rs("SuspenseList");case 0:case 2:case 15:return n=Gl(n.type,!1),n;case 11:return n=Gl(n.type.render,!1),n;case 1:return n=Gl(n.type,!0),n;default:return""}}function Ru(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case bi:return"Fragment";case Bi:return"Portal";case Pu:return"Profiler";case nf:return"StrictMode";case Du:return"Suspense";case Ou:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Cg:return(n.displayName||"Context")+".Consumer";case xg:return(n._context.displayName||"Context")+".Provider";case rf:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case sf:return e=n.displayName||null,e!==null?e:Ru(n.type)||"Memo";case Dr:e=n._payload,n=n._init;try{return Ru(n(e))}catch{}}return null}function dv(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ru(e);case 8:return e===nf?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Gr(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Pg(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hv(n){var e=Pg(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function $o(n){n._valueTracker||(n._valueTracker=hv(n))}function Dg(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Pg(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function Ea(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Lu(n,e){var t=e.checked;return ae({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function vd(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Gr(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Og(n,e){e=e.checked,e!=null&&tf(n,"checked",e,!1)}function Bu(n,e){Og(n,e);var t=Gr(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?bu(n,e.type,t):e.hasOwnProperty("defaultValue")&&bu(n,e.type,Gr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function wd(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function bu(n,e,t){(e!=="number"||Ea(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Ls=Array.isArray;function _i(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=zo.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Xs(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var Ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gv=["Webkit","ms","Moz","O"];Object.keys(Ms).forEach(function(n){gv.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),Ms[e]=Ms[n]})});function bg(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||Ms.hasOwnProperty(n)&&Ms[n]?(""+e).trim():e+"px"}function Fg(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=bg(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var mv=ae({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ju(n,e){if(e){if(mv[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(x(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(x(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(x(61))}if(e.style!=null&&typeof e.style!="object")throw Error(x(62))}}function $u(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zu=null;function of(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Uu=null,Gi=null,Yi=null;function Td(n){if(n=No(n)){if(typeof Uu!="function")throw Error(x(280));var e=n.stateNode;e&&(e=Il(e),Uu(n.stateNode,n.type,e))}}function Mg(n){Gi?Yi?Yi.push(n):Yi=[n]:Gi=n}function Jg(){if(Gi){var n=Gi,e=Yi;if(Yi=Gi=null,Td(n),e)for(n=0;n>>=0,n===0?32:31-(xv(n)/Cv|0)|0}var Uo=64,jo=4194304;function Bs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Pa(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~i;a!==0?r=Bs(a):(s&=o,s!==0&&(r=Bs(s)))}else o=t&~i,o!==0?r=Bs(o):s!==0&&(r=Bs(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function xo(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Lt(e),n[e]=t}function Ov(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=$s),Od=" ",Rd=!1;function im(n,e){switch(n){case"keyup":return s0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sm(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Fi=!1;function a0(n,e){switch(n){case"compositionend":return sm(e);case"keypress":return e.which!==32?null:(Rd=!0,Od);case"textInput":return n=e.data,n===Od&&Rd?null:n;default:return null}}function l0(n,e){if(Fi)return n==="compositionend"||!gf&&im(n,e)?(n=nm(),ua=ff=Br=null,Fi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=Fd(t)}}function um(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?um(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function cm(){for(var n=window,e=Ea();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Ea(n.document)}return e}function mf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function y0(n){var e=cm(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&um(t.ownerDocument.documentElement,t)){if(r!==null&&mf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!n.extend&&s>r&&(i=r,r=s,s=i),i=Md(t,s);var o=Md(t,r);i&&o&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),s>r?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Mi=null,Hu=null,Us=null,_u=!1;function Jd(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;_u||Mi==null||Mi!==Ea(r)||(r=Mi,"selectionStart"in r&&mf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Us&&io(Us,r)||(Us=r,r=Ra(Hu,"onSelect"),0zi||(n.current=ec[zi],ec[zi]=null,zi--)}function X(n,e){zi++,ec[zi]=n.current,n.current=e}var Yr={},Le=ti(Yr),qe=ti(!1),vi=Yr;function is(n,e){var t=n.type.contextTypes;if(!t)return Yr;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in t)i[s]=e[s];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function Ke(n){return n=n.childContextTypes,n!=null}function Ba(){ee(qe),ee(Le)}function Kd(n,e,t){if(Le.current!==Yr)throw Error(x(168));X(Le,e),X(qe,t)}function wm(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,dv(n)||"Unknown",i));return ae({},t,r)}function ba(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Yr,vi=Le.current,X(Le,n),X(qe,qe.current),!0}function Wd(n,e,t){var r=n.stateNode;if(!r)throw Error(x(169));t?(n=wm(n,e,vi),r.__reactInternalMemoizedMergedChildContext=n,ee(qe),ee(Le),X(Le,n)):ee(qe),X(qe,t)}var or=null,El=!1,uu=!1;function Sm(n){or===null?or=[n]:or.push(n)}function P0(n){El=!0,Sm(n)}function ni(){if(!uu&&or!==null){uu=!0;var n=0,e=G;try{var t=or;for(G=1;n>=o,i-=o,ur=1<<32-Lt(e)+i|t<R?(q=D,D=null):q=D.sibling;var $=m(p,D,v[R],I);if($===null){D===null&&(D=q);break}n&&D&&$.alternate===null&&e(p,D),g=s($,g,R),N===null?E=$:N.sibling=$,N=$,D=q}if(R===v.length)return t(p,D),te&&si(p,R),E;if(D===null){for(;RR?(q=D,D=null):q=D.sibling;var Se=m(p,D,$.value,I);if(Se===null){D===null&&(D=q);break}n&&D&&Se.alternate===null&&e(p,D),g=s(Se,g,R),N===null?E=Se:N.sibling=Se,N=Se,D=q}if($.done)return t(p,D),te&&si(p,R),E;if(D===null){for(;!$.done;R++,$=v.next())$=h(p,$.value,I),$!==null&&(g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return te&&si(p,R),E}for(D=r(p,D);!$.done;R++,$=v.next())$=y(D,p,R,$.value,I),$!==null&&(n&&$.alternate!==null&&D.delete($.key===null?R:$.key),g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return n&&D.forEach(function(Er){return e(p,Er)}),te&&si(p,R),E}function P(p,g,v,I){if(typeof v=="object"&&v!==null&&v.type===bi&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Jo:e:{for(var E=v.key,N=g;N!==null;){if(N.key===E){if(E=v.type,E===bi){if(N.tag===7){t(p,N.sibling),g=i(N,v.props.children),g.return=p,p=g;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Dr&&Zd(E)===N.type){t(p,N.sibling),g=i(N,v.props),g.ref=Cs(p,N,v),g.return=p,p=g;break e}t(p,N);break}else e(p,N);N=N.sibling}v.type===bi?(g=mi(v.props.children,p.mode,I,v.key),g.return=p,p=g):(I=ya(v.type,v.key,v.props,null,p.mode,I),I.ref=Cs(p,g,v),I.return=p,p=I)}return o(p);case Bi:e:{for(N=v.key;g!==null;){if(g.key===N)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){t(p,g.sibling),g=i(g,v.children||[]),g.return=p,p=g;break e}else{t(p,g);break}else e(p,g);g=g.sibling}g=yu(v,p.mode,I),g.return=p,p=g}return o(p);case Dr:return N=v._init,P(p,g,N(v._payload),I)}if(Ls(v))return w(p,g,v,I);if(Ts(v))return T(p,g,v,I);Go(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(t(p,g.sibling),g=i(g,v),g.return=p,p=g):(t(p,g),g=pu(v,p.mode,I),g.return=p,p=g),o(p)):t(p,g)}return P}var os=Nm(!0),Pm=Nm(!1),Po={},nn=ti(Po),lo=ti(Po),uo=ti(Po);function fi(n){if(n===Po)throw Error(x(174));return n}function If(n,e){switch(X(uo,e),X(lo,n),X(nn,Po),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Mu(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=Mu(e,n)}ee(nn),X(nn,e)}function as(){ee(nn),ee(lo),ee(uo)}function Dm(n){fi(uo.current);var e=fi(nn.current),t=Mu(e,n.type);e!==t&&(X(lo,n),X(nn,t))}function Ef(n){lo.current===n&&(ee(nn),ee(lo))}var ie=ti(0);function Ua(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var cu=[];function xf(){for(var n=0;nt?t:4,n(!0);var r=fu.transition;fu.transition={};try{n(!1),e()}finally{G=t,fu.transition=r}}function Wm(){return At().memoizedState}function L0(n,e,t){var r=qr(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Hm(n))_m(e,t);else if(t=Im(n,e,t,r),t!==null){var i=Je();Bt(t,n,r,i),Gm(t,e,r)}}function B0(n,e,t){var r=qr(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Hm(n))_m(e,i);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(i.hasEagerState=!0,i.eagerState=a,Mt(a,o)){var l=e.interleaved;l===null?(i.next=i,Tf(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}t=Im(n,e,i,r),t!==null&&(i=Je(),Bt(t,n,r,i),Gm(t,e,r))}}function Hm(n){var e=n.alternate;return n===oe||e!==null&&e===oe}function _m(n,e){js=ja=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function Gm(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,lf(n,t)}}var Va={readContext:Tt,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useInsertionEffect:Pe,useLayoutEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useMutableSource:Pe,useSyncExternalStore:Pe,useId:Pe,unstable_isNewReconciler:!1},b0={readContext:Tt,useCallback:function(n,e){return Ut().memoizedState=[n,e===void 0?null:e],n},useContext:Tt,useEffect:th,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ha(4194308,4,Um.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ha(4194308,4,n,e)},useInsertionEffect:function(n,e){return ha(4,2,n,e)},useMemo:function(n,e){var t=Ut();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Ut();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=L0.bind(null,oe,n),[r.memoizedState,n]},useRef:function(n){var e=Ut();return n={current:n},e.memoizedState=n},useState:eh,useDebugValue:Of,useDeferredValue:function(n){return Ut().memoizedState=n},useTransition:function(){var n=eh(!1),e=n[0];return n=R0.bind(null,n[1]),Ut().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=oe,i=Ut();if(te){if(t===void 0)throw Error(x(407));t=t()}else{if(t=e(),Ae===null)throw Error(x(349));Si&30||Lm(r,e,t)}i.memoizedState=t;var s={value:t,getSnapshot:e};return i.queue=s,th(bm.bind(null,r,s,n),[n]),r.flags|=2048,ho(9,Bm.bind(null,r,s,t,e),void 0,null),t},useId:function(){var n=Ut(),e=Ae.identifierPrefix;if(te){var t=cr,r=ur;t=(r&~(1<<32-Lt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=co++,0")&&(l=l.replace("",n.displayName)),l}while(1<=o&&0<=a);break}}}finally{Gl=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Rs(n):""}function fv(n){switch(n.tag){case 5:return Rs(n.type);case 16:return Rs("Lazy");case 13:return Rs("Suspense");case 19:return Rs("SuspenseList");case 0:case 2:case 15:return n=Yl(n.type,!1),n;case 11:return n=Yl(n.type.render,!1),n;case 1:return n=Yl(n.type,!0),n;default:return""}}function Lu(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case bi:return"Fragment";case Bi:return"Portal";case Du:return"Profiler";case rf:return"StrictMode";case Ou:return"Suspense";case Ru:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Cg:return(n.displayName||"Context")+".Consumer";case xg:return(n._context.displayName||"Context")+".Provider";case sf:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case of:return e=n.displayName||null,e!==null?e:Lu(n.type)||"Memo";case Dr:e=n._payload,n=n._init;try{return Lu(n(e))}catch{}}return null}function dv(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Lu(e);case 8:return e===rf?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Gr(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Pg(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hv(n){var e=Pg(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function $o(n){n._valueTracker||(n._valueTracker=hv(n))}function Dg(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Pg(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function Ea(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Bu(n,e){var t=e.checked;return ae({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function vd(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Gr(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Og(n,e){e=e.checked,e!=null&&nf(n,"checked",e,!1)}function bu(n,e){Og(n,e);var t=Gr(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?Fu(n,e.type,t):e.hasOwnProperty("defaultValue")&&Fu(n,e.type,Gr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function wd(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function Fu(n,e,t){(e!=="number"||Ea(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Ls=Array.isArray;function _i(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=zo.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Xs(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var Ms={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gv=["Webkit","ms","Moz","O"];Object.keys(Ms).forEach(function(n){gv.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),Ms[e]=Ms[n]})});function bg(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||Ms.hasOwnProperty(n)&&Ms[n]?(""+e).trim():e+"px"}function Fg(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=bg(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var mv=ae({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $u(n,e){if(e){if(mv[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(x(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(x(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(x(61))}if(e.style!=null&&typeof e.style!="object")throw Error(x(62))}}function zu(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Uu=null;function af(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ju=null,Gi=null,Yi=null;function Td(n){if(n=No(n)){if(typeof ju!="function")throw Error(x(280));var e=n.stateNode;e&&(e=Il(e),ju(n.stateNode,n.type,e))}}function Mg(n){Gi?Yi?Yi.push(n):Yi=[n]:Gi=n}function Jg(){if(Gi){var n=Gi,e=Yi;if(Yi=Gi=null,Td(n),e)for(n=0;n>>=0,n===0?32:31-(xv(n)/Cv|0)|0}var Uo=64,jo=4194304;function Bs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Pa(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~i;a!==0?r=Bs(a):(s&=o,s!==0&&(r=Bs(s)))}else o=t&~i,o!==0?r=Bs(o):s!==0&&(r=Bs(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function xo(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Lt(e),n[e]=t}function Ov(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=$s),Od=" ",Rd=!1;function im(n,e){switch(n){case"keyup":return s0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sm(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Fi=!1;function a0(n,e){switch(n){case"compositionend":return sm(e);case"keypress":return e.which!==32?null:(Rd=!0,Od);case"textInput":return n=e.data,n===Od&&Rd?null:n;default:return null}}function l0(n,e){if(Fi)return n==="compositionend"||!mf&&im(n,e)?(n=nm(),ua=df=Br=null,Fi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=Fd(t)}}function um(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?um(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function cm(){for(var n=window,e=Ea();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=Ea(n.document)}return e}function pf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function y0(n){var e=cm(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&um(t.ownerDocument.documentElement,t)){if(r!==null&&pf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!n.extend&&s>r&&(i=r,r=s,s=i),i=Md(t,s);var o=Md(t,r);i&&o&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),s>r?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Mi=null,_u=null,Us=null,Gu=!1;function Jd(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Gu||Mi==null||Mi!==Ea(r)||(r=Mi,"selectionStart"in r&&pf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Us&&io(Us,r)||(Us=r,r=Ra(_u,"onSelect"),0zi||(n.current=tc[zi],tc[zi]=null,zi--)}function X(n,e){zi++,tc[zi]=n.current,n.current=e}var Yr={},Le=ti(Yr),qe=ti(!1),vi=Yr;function is(n,e){var t=n.type.contextTypes;if(!t)return Yr;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in t)i[s]=e[s];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function Ke(n){return n=n.childContextTypes,n!=null}function Ba(){ee(qe),ee(Le)}function Kd(n,e,t){if(Le.current!==Yr)throw Error(x(168));X(Le,e),X(qe,t)}function wm(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,dv(n)||"Unknown",i));return ae({},t,r)}function ba(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Yr,vi=Le.current,X(Le,n),X(qe,qe.current),!0}function Wd(n,e,t){var r=n.stateNode;if(!r)throw Error(x(169));t?(n=wm(n,e,vi),r.__reactInternalMemoizedMergedChildContext=n,ee(qe),ee(Le),X(Le,n)):ee(qe),X(qe,t)}var or=null,El=!1,cu=!1;function Sm(n){or===null?or=[n]:or.push(n)}function P0(n){El=!0,Sm(n)}function ni(){if(!cu&&or!==null){cu=!0;var n=0,e=G;try{var t=or;for(G=1;n>=o,i-=o,ur=1<<32-Lt(e)+i|t<R?(q=D,D=null):q=D.sibling;var $=m(p,D,v[R],I);if($===null){D===null&&(D=q);break}n&&D&&$.alternate===null&&e(p,D),g=s($,g,R),N===null?E=$:N.sibling=$,N=$,D=q}if(R===v.length)return t(p,D),te&&si(p,R),E;if(D===null){for(;RR?(q=D,D=null):q=D.sibling;var Se=m(p,D,$.value,I);if(Se===null){D===null&&(D=q);break}n&&D&&Se.alternate===null&&e(p,D),g=s(Se,g,R),N===null?E=Se:N.sibling=Se,N=Se,D=q}if($.done)return t(p,D),te&&si(p,R),E;if(D===null){for(;!$.done;R++,$=v.next())$=h(p,$.value,I),$!==null&&(g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return te&&si(p,R),E}for(D=r(p,D);!$.done;R++,$=v.next())$=y(D,p,R,$.value,I),$!==null&&(n&&$.alternate!==null&&D.delete($.key===null?R:$.key),g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return n&&D.forEach(function(Er){return e(p,Er)}),te&&si(p,R),E}function P(p,g,v,I){if(typeof v=="object"&&v!==null&&v.type===bi&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Jo:e:{for(var E=v.key,N=g;N!==null;){if(N.key===E){if(E=v.type,E===bi){if(N.tag===7){t(p,N.sibling),g=i(N,v.props.children),g.return=p,p=g;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Dr&&Zd(E)===N.type){t(p,N.sibling),g=i(N,v.props),g.ref=Cs(p,N,v),g.return=p,p=g;break e}t(p,N);break}else e(p,N);N=N.sibling}v.type===bi?(g=mi(v.props.children,p.mode,I,v.key),g.return=p,p=g):(I=ya(v.type,v.key,v.props,null,p.mode,I),I.ref=Cs(p,g,v),I.return=p,p=I)}return o(p);case Bi:e:{for(N=v.key;g!==null;){if(g.key===N)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){t(p,g.sibling),g=i(g,v.children||[]),g.return=p,p=g;break e}else{t(p,g);break}else e(p,g);g=g.sibling}g=vu(v,p.mode,I),g.return=p,p=g}return o(p);case Dr:return N=v._init,P(p,g,N(v._payload),I)}if(Ls(v))return w(p,g,v,I);if(Ts(v))return T(p,g,v,I);Go(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(t(p,g.sibling),g=i(g,v),g.return=p,p=g):(t(p,g),g=yu(v,p.mode,I),g.return=p,p=g),o(p)):t(p,g)}return P}var os=Nm(!0),Pm=Nm(!1),Po={},nn=ti(Po),lo=ti(Po),uo=ti(Po);function fi(n){if(n===Po)throw Error(x(174));return n}function Ef(n,e){switch(X(uo,e),X(lo,n),X(nn,Po),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Ju(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=Ju(e,n)}ee(nn),X(nn,e)}function as(){ee(nn),ee(lo),ee(uo)}function Dm(n){fi(uo.current);var e=fi(nn.current),t=Ju(e,n.type);e!==t&&(X(lo,n),X(nn,t))}function xf(n){lo.current===n&&(ee(nn),ee(lo))}var ie=ti(0);function Ua(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var fu=[];function Cf(){for(var n=0;nt?t:4,n(!0);var r=du.transition;du.transition={};try{n(!1),e()}finally{G=t,du.transition=r}}function Wm(){return At().memoizedState}function L0(n,e,t){var r=qr(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Hm(n))_m(e,t);else if(t=Im(n,e,t,r),t!==null){var i=Je();Bt(t,n,r,i),Gm(t,e,r)}}function B0(n,e,t){var r=qr(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Hm(n))_m(e,i);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(i.hasEagerState=!0,i.eagerState=a,Mt(a,o)){var l=e.interleaved;l===null?(i.next=i,Af(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}t=Im(n,e,i,r),t!==null&&(i=Je(),Bt(t,n,r,i),Gm(t,e,r))}}function Hm(n){var e=n.alternate;return n===oe||e!==null&&e===oe}function _m(n,e){js=ja=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function Gm(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,uf(n,t)}}var Va={readContext:Tt,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useInsertionEffect:Pe,useLayoutEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useMutableSource:Pe,useSyncExternalStore:Pe,useId:Pe,unstable_isNewReconciler:!1},b0={readContext:Tt,useCallback:function(n,e){return Ut().memoizedState=[n,e===void 0?null:e],n},useContext:Tt,useEffect:th,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ha(4194308,4,Um.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ha(4194308,4,n,e)},useInsertionEffect:function(n,e){return ha(4,2,n,e)},useMemo:function(n,e){var t=Ut();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Ut();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=L0.bind(null,oe,n),[r.memoizedState,n]},useRef:function(n){var e=Ut();return n={current:n},e.memoizedState=n},useState:eh,useDebugValue:Rf,useDeferredValue:function(n){return Ut().memoizedState=n},useTransition:function(){var n=eh(!1),e=n[0];return n=R0.bind(null,n[1]),Ut().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=oe,i=Ut();if(te){if(t===void 0)throw Error(x(407));t=t()}else{if(t=e(),Ae===null)throw Error(x(349));Si&30||Lm(r,e,t)}i.memoizedState=t;var s={value:t,getSnapshot:e};return i.queue=s,th(bm.bind(null,r,s,n),[n]),r.flags|=2048,ho(9,Bm.bind(null,r,s,t,e),void 0,null),t},useId:function(){var n=Ut(),e=Ae.identifierPrefix;if(te){var t=cr,r=ur;t=(r&~(1<<32-Lt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=co++,0<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=o.createElement(t,{is:r.is}):(n=o.createElement(t),t==="select"&&(o=n,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):n=o.createElementNS(n,t),n[qt]=e,n[ao]=r,ip(n,e,!1,!1),e.stateNode=n;e:{switch(o=$u(t,r),t){case"dialog":Z("cancel",n),Z("close",n),i=r;break;case"iframe":case"object":case"embed":Z("load",n),i=r;break;case"video":case"audio":for(i=0;ius&&(e.flags|=128,r=!0,Ns(s,!1),e.lanes=4194304)}else{if(!r)if(n=Ua(o),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ns(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!te)return De(e),null}else 2*he()-s.renderingStartTime>us&&t!==1073741824&&(e.flags|=128,r=!0,Ns(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=he(),e.sibling=null,t=ie.current,X(ie,r?t&1|2:t&1),e):(De(e),null);case 22:case 23:return Mf(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(De(e),e.subtreeFlags&6&&(e.flags|=8192)):De(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function V0(n,e){switch(yf(e),e.tag){case 1:return Ke(e.type)&&Ba(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return as(),ee(qe),ee(Le),xf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Ef(e),null;case 13:if(ee(ie),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(x(340));ss()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return ee(ie),null;case 4:return as(),null;case 10:return kf(e.type._context),null;case 22:case 23:return Mf(),null;case 24:return null;default:return null}}var Qo=!1,Oe=!1,q0=typeof WeakSet=="function"?WeakSet:Set,L=null;function qi(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){ue(n,e,r)}else t.current=null}function dc(n,e,t){try{t()}catch(r){ue(n,e,r)}}var ch=!1;function K0(n,e){if(Gu=Da,n=cm(),mf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,d=0,h=n,m=null;t:for(;;){for(var y;h!==t||i!==0&&h.nodeType!==3||(a=o+i),h!==s||r!==0&&h.nodeType!==3||(l=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(y=h.firstChild)!==null;)m=h,h=y;for(;;){if(h===n)break t;if(m===t&&++c===i&&(a=o),m===s&&++d===r&&(l=o),(y=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=y}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(Yu={focusedElem:n,selectionRange:t},Da=!1,L=e;L!==null;)if(e=L,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,L=n;else for(;L!==null;){e=L;try{var w=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var T=w.memoizedProps,P=w.memoizedState,p=e.stateNode,g=p.getSnapshotBeforeUpdate(e.elementType===e.type?T:Ct(e.type,T),P);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(I){ue(e,e.return,I)}if(n=e.sibling,n!==null){n.return=e.return,L=n;break}L=e.return}return w=ch,ch=!1,w}function Vs(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var s=i.destroy;i.destroy=void 0,s!==void 0&&dc(e,t,s)}i=i.next}while(i!==r)}}function Nl(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function hc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function ap(n){var e=n.alternate;e!==null&&(n.alternate=null,ap(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[qt],delete e[ao],delete e[Zu],delete e[C0],delete e[N0])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function lp(n){return n.tag===5||n.tag===3||n.tag===4}function fh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||lp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function gc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=La));else if(r!==4&&(n=n.child,n!==null))for(gc(n,e,t),n=n.sibling;n!==null;)gc(n,e,t),n=n.sibling}function mc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(mc(n,e,t),n=n.sibling;n!==null;)mc(n,e,t),n=n.sibling}var Ie=null,Pt=!1;function xr(n,e,t){for(t=t.child;t!==null;)up(n,e,t),t=t.sibling}function up(n,e,t){if(tn&&typeof tn.onCommitFiberUnmount=="function")try{tn.onCommitFiberUnmount(Sl,t)}catch{}switch(t.tag){case 5:Oe||qi(t,e);case 6:var r=Ie,i=Pt;Ie=null,xr(n,e,t),Ie=r,Pt=i,Ie!==null&&(Pt?(n=Ie,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Ie.removeChild(t.stateNode));break;case 18:Ie!==null&&(Pt?(n=Ie,t=t.stateNode,n.nodeType===8?lu(n.parentNode,t):n.nodeType===1&&lu(n,t),no(n)):lu(Ie,t.stateNode));break;case 4:r=Ie,i=Pt,Ie=t.stateNode.containerInfo,Pt=!0,xr(n,e,t),Ie=r,Pt=i;break;case 0:case 11:case 14:case 15:if(!Oe&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&dc(t,e,o),i=i.next}while(i!==r)}xr(n,e,t);break;case 1:if(!Oe&&(qi(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(a){ue(t,e,a)}xr(n,e,t);break;case 21:xr(n,e,t);break;case 22:t.mode&1?(Oe=(r=Oe)||t.memoizedState!==null,xr(n,e,t),Oe=r):xr(n,e,t);break;default:xr(n,e,t)}}function dh(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new q0),e.forEach(function(r){var i=ew.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function xt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*H0(r/1960))-r,10n?16:n,br===null)var r=!1;else{if(n=br,br=null,Wa=0,W&6)throw Error(x(331));var i=W;for(W|=4,L=n.current;L!==null;){var s=L,o=s.child;if(L.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lhe()-bf?gi(n,0):Bf|=t),We(n,e)}function yp(n,e){e===0&&(n.mode&1?(e=jo,jo<<=1,!(jo&130023424)&&(jo=4194304)):e=1);var t=Je();n=wr(n,e),n!==null&&(xo(n,e,t),We(n,t))}function Z0(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),yp(n,t)}function ew(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),yp(n,t)}var vp;vp=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||qe.current)je=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return je=!1,U0(n,e,t);je=!!(n.flags&131072)}else je=!1,te&&e.flags&1048576&&km(e,Ma,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ga(n,e),n=e.pendingProps;var i=is(e,Le.current);Xi(e,t),i=Nf(null,e,r,n,i,t);var s=Pf();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ke(r)?(s=!0,ba(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Af(e),i.updater=xl,e.stateNode=i,i._reactInternals=e,sc(e,r,n,t),e=lc(null,e,r,!0,s,t)):(e.tag=0,te&&s&&pf(e),be(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(ga(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=nw(r),n=Ct(r,n),i){case 0:e=ac(null,e,r,n,t);break e;case 1:e=ah(null,e,r,n,t);break e;case 11:e=sh(null,e,r,n,t);break e;case 14:e=oh(null,e,r,Ct(r.type,n),t);break e}throw Error(x(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),ac(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),ah(n,e,r,i,t);case 3:e:{if(tp(e),n===null)throw Error(x(387));r=e.pendingProps,s=e.memoizedState,i=s.element,Em(n,e),za(e,r,null,t);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=ls(Error(x(423)),e),e=lh(n,e,r,t,i);break e}else if(r!==i){i=ls(Error(x(424)),e),e=lh(n,e,r,t,i);break e}else for(Ye=Ur(e.stateNode.containerInfo.firstChild),Ze=e,te=!0,Dt=null,t=Pm(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ss(),r===i){e=Sr(n,e,t);break e}be(n,e,r,t)}e=e.child}return e;case 5:return Dm(e),n===null&&nc(e),r=e.type,i=e.pendingProps,s=n!==null?n.memoizedProps:null,o=i.children,Qu(r,i)?o=null:s!==null&&Qu(r,s)&&(e.flags|=32),ep(n,e),be(n,e,o,t),e.child;case 6:return n===null&&nc(e),null;case 13:return np(n,e,t);case 4:return If(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=os(e,null,r,t):be(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),sh(n,e,r,i,t);case 7:return be(n,e,e.pendingProps,t),e.child;case 8:return be(n,e,e.pendingProps.children,t),e.child;case 12:return be(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,X(Ja,r._currentValue),r._currentValue=o,s!==null)if(Mt(s.value,o)){if(s.children===i.children&&!qe.current){e=Sr(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=gr(-1,t&-t),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?l.next=l:(l.next=d.next,d.next=l),c.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),rc(s.return,t,e),a.lanes|=t;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(x(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),rc(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}be(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Xi(e,t),i=Tt(i),r=r(i),e.flags|=1,be(n,e,r,t),e.child;case 14:return r=e.type,i=Ct(r,e.pendingProps),i=Ct(r.type,i),oh(n,e,r,i,t);case 15:return Xm(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),ga(n,e),e.tag=1,Ke(r)?(n=!0,ba(e)):n=!1,Xi(e,t),Cm(e,r,i),sc(e,r,i,t),lc(null,e,r,!0,n,t);case 19:return rp(n,e,t);case 22:return Zm(n,e,t)}throw Error(x(156,e.tag))};function wp(n,e){return Kg(n,e)}function tw(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function yt(n,e,t,r){return new tw(n,e,t,r)}function $f(n){return n=n.prototype,!(!n||!n.isReactComponent)}function nw(n){if(typeof n=="function")return $f(n)?1:0;if(n!=null){if(n=n.$$typeof,n===rf)return 11;if(n===sf)return 14}return 2}function Kr(n,e){var t=n.alternate;return t===null?(t=yt(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function ya(n,e,t,r,i,s){var o=2;if(r=n,typeof n=="function")$f(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case bi:return mi(t.children,i,s,e);case nf:o=8,i|=8;break;case Pu:return n=yt(12,t,e,i|2),n.elementType=Pu,n.lanes=s,n;case Du:return n=yt(13,t,e,i),n.elementType=Du,n.lanes=s,n;case Ou:return n=yt(19,t,e,i),n.elementType=Ou,n.lanes=s,n;case Ng:return Dl(t,i,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case xg:o=10;break e;case Cg:o=9;break e;case rf:o=11;break e;case sf:o=14;break e;case Dr:o=16,r=null;break e}throw Error(x(130,n==null?n:typeof n,""))}return e=yt(o,t,e,i),e.elementType=n,e.type=r,e.lanes=s,e}function mi(n,e,t,r){return n=yt(7,n,r,e),n.lanes=t,n}function Dl(n,e,t,r){return n=yt(22,n,r,e),n.elementType=Ng,n.lanes=t,n.stateNode={isHidden:!1},n}function pu(n,e,t){return n=yt(6,n,null,e),n.lanes=t,n}function yu(n,e,t){return e=yt(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function rw(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ql(0),this.expirationTimes=Ql(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ql(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function zf(n,e,t,r,i,s,o,a,l){return n=new rw(n,e,t,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=yt(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Af(s),n}function iw(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ap)}catch(n){console.error(n)}}Ap(),kg.exports=rt;var uw=kg.exports,Sh=uw;Cu.createRoot=Sh.createRoot,Cu.hydrateRoot=Sh.hydrateRoot;var _;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(_||(_={}));function kh(n){const e=_[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class ne extends Error{constructor(e,t=_.Unknown,r,i,s){super(cw(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=s}static from(e,t=_.Unknown){return e instanceof ne?e:e instanceof Error?e.name=="AbortError"?new ne(e.message,_.Canceled):new ne(e.message,t,void 0,void 0,e):new ne(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===ne.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:i=>i===e.typeName?e:void 0}:e,r=[];for(const i of this.details){if("getType"in i){t.findMessage(i.getType().typeName)&&r.push(i);continue}const s=t.findMessage(i.type);if(s)try{r.push(s.fromBinary(i.value))}catch{}}return r}}function cw(n,e){return n.length?`[${kh(e)}] ${n}`:`[${kh(e)}]`}function ce(n,e){if(!n)throw new Error(e)}const fw=34028234663852886e22,dw=-34028234663852886e22,hw=4294967295,gw=2147483647,mw=-2147483648;function va(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>gw||nhw||n<0)throw new Error("invalid uint 32: "+n)}function Ip(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>fw||n({no:i.no,name:i.name,localName:n[i.no]})))}function Cp(n,e,t){const r=Object.create(null),i=Object.create(null),s=[];for(const o of e){const a=Np(o);s.push(a),r[o.name]=a,i[o.no]=a}return{typeName:n,values:s,findName(o){return r[o]},findNumber(o){return i[o]}}}function yw(n,e,t){const r={};for(const i of e){const s=Np(i);r[s.localName]=s.no,r[s.no]=s.localName}return xp(r,n,e),r}function Np(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class O{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),i=r.runtime.bin,s=i.makeReadOptions(t);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const r=this.getType(),i=r.runtime.json,s=i.makeReadOptions(t);return i.readMessage(r,e,s,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,i=r.makeWriteOptions(e),s=i.writerFactory();return r.writeMessage(this,s,i),s.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,i=r.makeWriteOptions(e);return r.writeMessage(this,i)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function vw(n,e,t,r){var i;const s=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new O),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,l){return new o().fromBinary(a,l)},fromJson(a,l){return new o().fromJson(a,l)},fromJsonString(a,l){return new o().fromJsonString(a,l)},equals(a,l){return n.util.equals(o,a,l)}}),o}function ww(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const wa=4294967296;function Th(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,i=0;function s(o,a){const l=Number(n.slice(o,a));i*=t,r=r*t+l,r>=wa&&(i=i+(r/wa|0),r=r%wa)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Dp(r,i):qf(r,i)}function Sw(n,e){let t=qf(n,e);const r=t.hi&2147483648;r&&(t=Dp(t.lo,t.hi));const i=Pp(t.lo,t.hi);return r?"-"+i:i}function Pp(n,e){if({lo:n,hi:e}=kw(n,e),e<=2097151)return String(wa*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,i=e>>16&65535;let s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2;const l=1e7;return s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l),a.toString()+Ah(o)+Ah(s)}function kw(n,e){return{lo:n>>>0,hi:e>>>0}}function qf(n,e){return{lo:n|0,hi:e|0}}function Dp(n,e){return e=~e,n?n=~n+1:e+=1,qf(n,e)}const Ah=n=>{const e=String(n);return"0000000".slice(e.length)+e};function Ih(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Tw(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Eh={};function Aw(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof Eh!="object"||Eh.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>s||ca||cce(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>ce(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),t(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),t(i),Th(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),Th(i)},dec(i,s){return Sw(i,s)},uDec(i,s){return Pp(i,s)}}}const re=Aw();var A;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(A||(A={}));var Qr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(Qr||(Qr={}));function Cr(n,e,t){if(e===t)return!0;if(n==A.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Sc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return va(e),Ih(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Ip(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Sc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){va(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return va(e),e=(e<<1^e>>31)>>>0,Ih(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=re.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=re.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=re.enc(e);return vu(t.lo,t.hi,this.buf),this}sint64(e){let t=re.enc(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return vu(i,s,this.buf),this}uint64(e){let t=re.uEnc(e);return vu(t.lo,t.hi,this.buf),this}}class Ew{constructor(e,t){this.varint64=ww,this.uint32=Tw,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ge.Varint:for(;this.buf[this.pos++]&128;);break;case ge.Bit64:this.pos+=4;case ge.Bit32:this.pos+=4;break;case ge.LengthDelimited:let i=this.uint32();this.pos+=i;break;case ge.StartGroup:for(;;){const[s,o]=this.tag();if(o===ge.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return re.dec(...this.varint64())}uint64(){return re.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,re.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return re.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return re.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function xw(n,e,t,r){let i;return{typeName:e,extendee:t,get field(){if(!i){const s=typeof r=="function"?r():r;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,i=n.util.newFieldList([s]).list()[0]}return i},runtime:n}}function Rp(n){const e=n.field.localName,t=Object.create(null);return t[e]=Cw(n),[t,()=>t[e]]}function Cw(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return cs(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Nw(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let lr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),bl=[];for(let n=0;n>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,i=0;for(let s=0;s>2],i=(r&3)<<4,t=1;break;case 1:e+=lr[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=lr[i|r>>6],e+=lr[r&63],t=0;break}return t&&(e+=lr[i],e+="=",t==1&&(e+="=")),e}};function Pw(n,e,t){Bp(e,n);const r=e.runtime.bin.makeReadOptions(t),i=Nw(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Rp(e);for(const a of i)e.runtime.bin.readField(s,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Dw(n,e,t,r){Bp(e,n);const i=e.runtime.bin.makeReadOptions(r),s=e.runtime.bin.makeWriteOptions(r);if(Lp(n,e)){const c=n.getType().runtime.bin.listUnknownFields(n).filter(d=>d.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const d of c)n.getType().runtime.bin.onUnknownField(n,d.no,d.wireType,d.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const l=i.readerFactory(o.finish());for(;l.posr.no==e.field.no)}function Bp(n,e){ce(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function bp(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Op(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function xh(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?cs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function pi(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(O.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Fp(n,e){return pi(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}A.DOUBLE,A.FLOAT,A.INT64,A.UINT64,A.INT32,A.UINT32,A.BOOL,A.STRING,A.BYTES;const Ch={ignoreUnknownFields:!1},Nh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ow(n){return n?Object.assign(Object.assign({},Ch),n):Ch}function Rw(n){return n?Object.assign(Object.assign({},Nh),n):Nh}const Ga=Symbol(),Sa=Symbol();function Lw(){return{makeReadOptions:Ow,makeWriteOptions:Rw,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Vt(e)}`);r=r??new n;const i=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(a===null&&l.kind=="scalar")continue;const c=i.get(l.oneof);if(c!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${c}", "${o}"`);i.set(l.oneof,o)}Ph(r,a,l,t,n)}else{let c=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const d=s.findExtension(o.substring(1,o.length-1));if(d&&d.extendee.typeName==n.typeName){c=!0;const[h,m]=Rp(d);Ph(h,a,d.field,t,d),Dw(r,d,m(),t)}}if(!c&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let i;try{for(i of t.fields.byNumber()){if(!bp(i,n)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!bw(i))continue}const o=i.oneof?n[i.oneof.localName].value:n[i.localName],a=Dh(i,o,e);a!==void 0&&(r[e.useProtoFieldName?i.name:i.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&Lp(n,a)){const l=Pw(n,a,e),c=Dh(a.field,l,e);c!==void 0&&(r[a.field.jsonName]=c)}}}catch(s){const o=i?`cannot encode field ${t.typeName}.${i.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return Ws(n,e,t??Qr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Op(n,e)))return ka(n,e)},debug:Vt}}function Vt(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function Ph(n,e,t,r,i){let s=t.localName;if(t.repeated){if(ce(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const l=wu(t.T,a,r.ignoreUnknownFields,!0);l!==Sa&&o.push(l);break;case"scalar":try{o.push(Ws(t.T,a,t.L,!0))}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(a)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`);const o=n[s];for(const[a,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: map value null`);let c;try{c=Bw(t.K,a)}catch(d){let h=`cannot decode map key for field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}switch(t.V.kind){case"message":o[c]=t.V.T.fromJson(l,r);break;case"enum":const d=wu(t.V.T,l,r.ignoreUnknownFields,!0);d!==Sa&&(o[c]=d);break;case"scalar":try{o[c]=Ws(t.V.T,l,Qr.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];pi(a)?a.fromJson(e,r):(n[s]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const l=wu(t.T,e,r.ignoreUnknownFields,!1);switch(l){case Ga:xh(t,n);break;case Sa:break;default:n[s]=l;break}break;case"scalar":try{const c=Ws(t.T,e,t.L,!1);switch(c){case Ga:xh(t,n);break;default:n[s]=c;break}}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}function Bw(n,e){if(n===A.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ws(n,e,Qr.BIGINT,!0).toString()}function Ws(n,e,t,r){if(e===null)return r?cs(n,t):Ga;switch(n){case A.DOUBLE:case A.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return n==A.FLOAT&&Ip(i),i;case A.INT32:case A.FIXED32:case A.SFIXED32:case A.SINT32:case A.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==A.UINT32||n==A.FIXED32?Sc(s):va(s),s;case A.INT64:case A.SFIXED64:case A.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=re.parse(e);return t?o.toString():o;case A.FIXED64:case A.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=re.uParse(e);return t?a.toString():a;case A.BOOL:if(typeof e!="boolean")break;return e;case A.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case A.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Kf.dec(e)}throw new Error}function wu(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Ga;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=n.findName(e);if(i!==void 0)return i.no;if(t)return Sa;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Vt(e)}`)}function bw(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function Dh(n,e,t){if(n.kind=="map"){ce(typeof e=="object"&&e!=null);const r={},i=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of i)r[o.toString()]=ka(n.V.T,a);break;case"message":for(const[o,a]of i)r[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of i)r[o.toString()]=Su(s,a,t.enumAsInteger);break}return t.emitDefaultValues||i.length>0?r:void 0}if(n.repeated){ce(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let i=0;i0?r:void 0}switch(n.kind){case"scalar":return ka(n.T,e);case"enum":return Su(n.T,e,t.enumAsInteger);case"message":return Fp(n.T,e).toJson(t)}}function Su(n,e,t){var r;if(ce(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const i=n.findNumber(e);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:e}function ka(n,e){switch(n){case A.INT32:case A.SFIXED32:case A.SINT32:case A.FIXED32:case A.UINT32:return ce(typeof e=="number"),e;case A.FLOAT:case A.DOUBLE:return ce(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case A.STRING:return ce(typeof e=="string"),e;case A.BOOL:return ce(typeof e=="boolean"),e;case A.UINT64:case A.FIXED64:case A.INT64:case A.SFIXED64:case A.SINT64:return ce(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case A.BYTES:return ce(e instanceof Uint8Array),Kf.enc(e)}}const Di=Symbol("@bufbuild/protobuf/unknown-fields"),Oh={readUnknownFields:!0,readerFactory:n=>new Ew(n)},Rh={writeUnknownFields:!0,writerFactory:()=>new Iw};function Fw(n){return n?Object.assign(Object.assign({},Oh),n):Oh}function Mw(n){return n?Object.assign(Object.assign({},Rh),n):Rh}function Jw(){return{makeReadOptions:Fw,makeWriteOptions:Mw,listUnknownFields(n){var e;return(e=n[Di])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Di]},writeUnknownFields(n,e){const r=n[Di];if(r)for(const i of r)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(n,e,t,r){const i=n;Array.isArray(i[Di])||(i[Di]=[]),i[Di].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,i){const s=n.getType(),o=i?e.len:e.pos+t;let a,l;for(;e.pos0&&(l=zw),s){let m=n[o];if(r==ge.LengthDelimited&&a!=A.STRING&&a!=A.BYTES){let w=e.uint32()+e.pos;for(;e.pospi(m,h)?m:new h(m));else{const m=o[i];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[i]=Ds(m):s[i]=m:s[i]=pi(m,h)?m:new h(m)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const i=e[r.localName],s=t[r.localName];if(r.repeated){if(i.length!==s.length)return!1;switch(r.kind){case"message":return i.every((o,a)=>r.T.equals(o,s[a]));case"scalar":return i.every((o,a)=>Cr(r.T,o,s[a]));case"enum":return i.every((o,a)=>Cr(A.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,s);case"enum":return Cr(A.INT32,i,s);case"scalar":return Cr(r.T,i,s);case"oneof":if(i.case!==s.case)return!1;const o=r.findField(i.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(i.value,s.value);case"enum":return Cr(A.INT32,i.value,s.value);case"scalar":return Cr(o.T,i.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(i).concat(Object.keys(s));switch(r.V.kind){case"message":const l=r.V.T;return a.every(d=>l.equals(i[d],s[d]));case"enum":return a.every(d=>Cr(A.INT32,i[d],s[d]));case"scalar":const c=r.V.T;return a.every(d=>Cr(c,i[d],s[d]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const i of e.fields.byMember()){const s=n[i.localName];let o;if(i.repeated)o=s.map(ea);else if(i.kind=="map"){o=r[i.localName];for(const[a,l]of Object.entries(s))o[a]=ea(l)}else i.kind=="oneof"?o=i.findField(s.case)?{case:s.case,value:ea(s.value)}:{case:void 0}:o=ea(s);r[i.localName]=o}for(const i of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return t}}}function ea(n){if(n===void 0)return n;if(pi(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Ds(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function qw(n,e,t){return{syntax:n,json:Lw(),bin:Jw(),util:Object.assign(Object.assign({},Vw()),{newFieldList:e,initFields:t}),makeMessageType(r,i,s){return vw(this,r,i,s)},makeEnum:yw,makeEnumType:Cp,getEnumType:pw,makeExtension(r,i,s){return xw(this,r,i,s)}}}class Kw{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function Jp(n,e){const t=$p(n);return e?t:Qw(Yw(t))}function Ww(n){return Jp(n,!1)}const Hw=$p;function $p(n){let e=!1;const t=[];for(let r=0;r`${n}$`,Yw=n=>Gw.has(n)?zp(n):n,Qw=n=>_w.has(n)?zp(n):n;class Xw{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ww(e)}addField(e){ce(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew Kw(n,e=>Zw(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=cs(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Fh;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Fh||(Fh={}));class Re extends O{constructor(e){super(),this.seconds=re.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=re.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Re.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Re({seconds:re.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Re().fromBinary(e,t)}static fromJson(e,t){return new Re().fromJson(e,t)}static fromJsonString(e,t){return new Re().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Re,e,t)}}Re.runtime=f;Re.typeName="google.protobuf.Timestamp";Re.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class fr extends O{constructor(e){super(),this.seconds=re.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=re.parse(i),typeof r[2]=="string"){const s=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(s),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new fr().fromBinary(e,t)}static fromJson(e,t){return new fr().fromJson(e,t)}static fromJsonString(e,t){return new fr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(fr,e,t)}}fr.runtime=f;fr.typeName="google.protobuf.Duration";fr.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Kt extends O{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=i.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const i=e["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(i),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const l=Object.assign({},e);delete l["@type"],a=o.fromJson(l,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Kt;return t.packFrom(e),t}static fromBinary(e,t){return new Kt().fromBinary(e,t)}static fromJson(e,t){return new Kt().fromJson(e,t)}static fromJsonString(e,t){return new Kt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Kt,e,t)}}Kt.runtime=f;Kt.typeName="google.protobuf.Any";Kt.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Wt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.DOUBLE,e)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Wt().fromBinary(e,t)}static fromJson(e,t){return new Wt().fromJson(e,t)}static fromJsonString(e,t){return new Wt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wt,e,t)}}Wt.runtime=f;Wt.typeName="google.protobuf.DoubleValue";Wt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Wt.fieldWrapper={wrapField(n){return new Wt({value:n})},unwrapField(n){return n.value}};class Ht extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.FLOAT,e)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Ht().fromBinary(e,t)}static fromJson(e,t){return new Ht().fromJson(e,t)}static fromJsonString(e,t){return new Ht().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ht,e,t)}}Ht.runtime=f;Ht.typeName="google.protobuf.FloatValue";Ht.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Ht.fieldWrapper={wrapField(n){return new Ht({value:n})},unwrapField(n){return n.value}};class _t extends O{constructor(e){super(),this.value=re.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT64,e)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new _t().fromBinary(e,t)}static fromJson(e,t){return new _t().fromJson(e,t)}static fromJsonString(e,t){return new _t().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_t,e,t)}}_t.runtime=f;_t.typeName="google.protobuf.Int64Value";_t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);_t.fieldWrapper={wrapField(n){return new _t({value:n})},unwrapField(n){return n.value}};class Gt extends O{constructor(e){super(),this.value=re.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT64,e)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Gt().fromBinary(e,t)}static fromJson(e,t){return new Gt().fromJson(e,t)}static fromJsonString(e,t){return new Gt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gt,e,t)}}Gt.runtime=f;Gt.typeName="google.protobuf.UInt64Value";Gt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Gt.fieldWrapper={wrapField(n){return new Gt({value:n})},unwrapField(n){return n.value}};class Yt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT32,e)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Yt().fromBinary(e,t)}static fromJson(e,t){return new Yt().fromJson(e,t)}static fromJsonString(e,t){return new Yt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Yt,e,t)}}Yt.runtime=f;Yt.typeName="google.protobuf.Int32Value";Yt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Yt.fieldWrapper={wrapField(n){return new Yt({value:n})},unwrapField(n){return n.value}};class Qt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT32,e)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qt().fromBinary(e,t)}static fromJson(e,t){return new Qt().fromJson(e,t)}static fromJsonString(e,t){return new Qt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qt,e,t)}}Qt.runtime=f;Qt.typeName="google.protobuf.UInt32Value";Qt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Qt.fieldWrapper={wrapField(n){return new Qt({value:n})},unwrapField(n){return n.value}};class Xt extends O{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BOOL,e)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xt().fromBinary(e,t)}static fromJson(e,t){return new Xt().fromJson(e,t)}static fromJsonString(e,t){return new Xt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xt,e,t)}}Xt.runtime=f;Xt.typeName="google.protobuf.BoolValue";Xt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Xt.fieldWrapper={wrapField(n){return new Xt({value:n})},unwrapField(n){return n.value}};class Qe extends O{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.STRING,e)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qe().fromBinary(e,t)}static fromJson(e,t){return new Qe().fromJson(e,t)}static fromJsonString(e,t){return new Qe().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qe,e,t)}}Qe.runtime=f;Qe.typeName="google.protobuf.StringValue";Qe.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Qe.fieldWrapper={wrapField(n){return new Qe({value:n})},unwrapField(n){return n.value}};class Zt extends O{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BYTES,e)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Zt().fromBinary(e,t)}static fromJson(e,t){return new Zt().fromJson(e,t)}static fromJsonString(e,t){return new Zt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zt,e,t)}}Zt.runtime=f;Zt.typeName="google.protobuf.BytesValue";Zt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Zt.fieldWrapper={wrapField(n){return new Zt({value:n})},unwrapField(n){return n.value}};function e1(n,e,t){try{const r=Kf.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw ne.from(r,_.DataLoss)}}function t1(n,e){const t={};for(const[r,i]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},i),{localName:r,service:n}));s!=null&&(t[r]=s)}return t}function Mh(n){let e,t=new Uint8Array(0);function r(i){const s=new Uint8Array(t.length+i.length);s.set(t),s.set(i,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(i){let s;for(;;){if(s===void 0&&t.byteLength>=5){let l=0;for(let c=1;c<5;c++)l=(l<<8)+t[c];s={flags:t[0],length:l}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(s===void 0){if(t.byteLength==0){i.close();return}i.error(new ne("premature end of stream",_.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),i.enqueue({flags:s.flags,data:o})}})}function Jh(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var n1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(c){s({value:c,done:a})},o)}},mo=function(n){return this instanceof mo?(this.v=n,this):new mo(n)},r1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof mo?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}},i1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:mo(n[i](o)),done:!1}:s?s(o):o}:s}};function s1(n){return r1(this,arguments,function*(){yield mo(yield*i1(n1(n)))})}var Up=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(c){s({value:c,done:a})},o)}},fs=function(n){return this instanceof fs?(this.v=n,this):new fs(n)},o1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:fs(n[i](o)),done:!1}:s?s(o):o}:s}},a1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof fs?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}};function l1(n,e){return t1(n,t=>{switch(t.kind){case Fe.Unary:return u1(e,n,t);case Fe.ServerStreaming:return c1(e,n,t);case Fe.ClientStreaming:return f1(e,n,t);case Fe.BiDiStreaming:return d1(e,n,t);default:return null}})}function u1(n,e,t){return async function(r,i){var s,o;const a=await n.unary(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(s=i==null?void 0:i.onHeader)===null||s===void 0||s.call(i,a.header),(o=i==null?void 0:i.onTrailer)===null||o===void 0||o.call(i,a.trailer),a.message}}function c1(n,e,t){return function(r,i){return jp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,s1([r]),i==null?void 0:i.contextValues),i)}}function f1(n,e,t){return async function(r,i){var s,o,a,l,c,d;const h=await n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(c=i==null?void 0:i.onHeader)===null||c===void 0||c.call(i,h.header);let m;try{for(var y=!0,w=Up(h.message),T;T=await w.next(),s=T.done,!s;y=!0)l=T.value,y=!1,m=l}catch(P){o={error:P}}finally{try{!y&&!s&&(a=w.return)&&await a.call(w)}finally{if(o)throw o.error}}if(!m)throw new ne("protocol error: missing response message",_.Internal);return(d=i==null?void 0:i.onTrailer)===null||d===void 0||d.call(i,h.trailer),m}}function d1(n,e,t){return function(r,i){return jp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function jp(n,e){const t=function(){var r,i;return a1(this,arguments,function*(){const s=yield fs(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,s.header),yield fs(yield*o1(Up(s.message))),(i=e==null?void 0:e.onTrailer)===null||i===void 0||i.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function h1(...n){const e=new AbortController,t=n.filter(i=>i!==void 0).concat(e.signal);for(const i of t){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(Vp(this));for(const i of t)i.removeEventListener("abort",r)}return e}function g1(n){const e=new AbortController,t=()=>{e.abort(new ne("the operation timed out",_.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function Vp(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function $h(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const ku=128;function zh(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r -`);for(const r of t){if(r==="")continue;const i=r.indexOf(":");if(i>0){const s=r.substring(0,i).trim(),o=r.substring(i+1).trim();e.append(s,o)}}return e}const m1="Content-Type",p1="Grpc-Timeout",qp="Grpc-Status",Kp="Grpc-Message",y1="Grpc-Status-Details-Bin",v1="X-User-Agent",w1="X-Grpc-Web",S1="application/grpc-web+proto",k1="application/grpc-web+json";class dr extends O{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new dr().fromBinary(e,t)}static fromJson(e,t){return new dr().fromJson(e,t)}static fromJsonString(e,t){return new dr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(dr,e,t)}}dr.runtime=f;dr.typeName="google.rpc.Status";dr.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Kt,repeated:!0}]);const T1="0";function Wp(n){var e;const t=n.get(y1);if(t!=null){const i=e1(t,dr);if(i.code==0)return;const s=new ne(i.message,i.code,n);return s.details=i.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const r=n.get(qp);if(r!=null){if(r===T1)return;const i=parseInt(r,10);return i in _?new ne(decodeURIComponent((e=n.get(Kp))!==null&&e!==void 0?e:""),i,n):new ne(`invalid grpc-status: ${r}`,_.Internal,n)}}function Uh(n,e,t){const r=typeof e=="string"?e:e.typeName,i=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${i}`)}function Hp(n,e){return e instanceof n?e:new n(e)}function A1(n,e){function t(r){return r.done===!0?r:{done:r.done,value:Hp(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),i={next:()=>r.next().then(t)};return r.throw!==void 0&&(i.throw=s=>r.throw(s).then(t)),r.return!==void 0&&(i.return=s=>r.return(s).then(t)),i}}}function _p(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,i)=>i(r),n))!==null&&t!==void 0?t:n}function I1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function jh(n,e,t,r){const i=e?Vh(n.I,r):qh(n.I,t);return{parse:(e?Vh(n.O,r):qh(n.O,t)).parse,serialize:i.serialize}}function Vh(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new ne(`parse binary: ${i}`,_.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new ne(`serialize binary: ${i}`,_.Internal)}}}}function qh(n,e){var t,r;const i=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=I1(e);return{parse(a){try{const l=s.decode(a);return n.fromJsonString(l,o)}catch(l){throw ne.from(l,_.InvalidArgument)}},serialize(a){try{const l=a.toJsonString(o);return i.encode(l)}catch(l){throw ne.from(l,_.Internal)}}}}function E1(n){const e=_p(n.next,n.interceptors),[t,r,i]=Gp(n),s=Object.assign(Object.assign({},n.req),{message:Hp(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(i(),o),r)}function x1(n){const e=_p(n.next,n.interceptors),[t,r,i]=Gp(n),s=Object.assign(Object.assign({},n.req),{message:A1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,l;const c=n.req.message[Symbol.asyncIterator]();o||(a=c.throw)===null||a===void 0||a.call(c,this.reason).catch(()=>{}),(l=c.return)===null||l===void 0||l.call(c).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const l=a.message[Symbol.asyncIterator]();return{next(){return l.next().then(c=>(c.done==!0&&(o=!0,i()),c),r)}}}}}),r)}function Gp(n){const{signal:e,cleanup:t}=g1(n.timeoutMs),r=h1(n.signal,e);return[r.signal,function(s){const o=ne.from(e.aborted?Vp(e):s);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function C1(){try{new Headers}catch{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.")}}function Kh(n,e){const t=Wp(n);if(t)throw e.forEach((r,i)=>{t.metadata.append(i,r)}),t}function Wh(n,e,t,r){const i=new Headers(t??{});return i.set(m1,n?S1:k1),i.set(w1,"1"),i.set(v1,"connect-es/1.4.0"),e!==void 0&&i.set(p1,`${e}m`),i}function N1(n){switch(n){case 400:return _.Internal;case 401:return _.Unauthenticated;case 403:return _.PermissionDenied;case 404:return _.Unimplemented;case 429:return _.Unavailable;case 502:return _.Unavailable;case 503:return _.Unavailable;case 504:return _.Unavailable;default:return _.Unknown}}function Hh(n,e){var t;if(n>=200&&n<300){const r=Wp(e);if(r)throw r;return{foundStatus:e.has(qp)}}throw new ne(decodeURIComponent((t=e.get(Kp))!==null&&t!==void 0?t:`HTTP ${n}`),N1(n),e)}var di=function(n){return this instanceof di?(this.v=n,this):new di(n)},P1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof di?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}};function D1(n){var e;C1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,i,s,o,a,l,c){var d;const{serialize:h,parse:m}=jh(i,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await E1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:r,method:i,url:Uh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Wh(t,o,a),contextValues:c??$h(),message:l},next:async y=>{var w;const P=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(y.url,Object.assign(Object.assign({},y.init),{headers:y.header,signal:y.signal,body:Jh(0,h(y.message))}));if(Hh(P.status,P.headers),!P.body)throw"missing response body";const p=Mh(P.body).getReader();let g,v;for(;;){const I=await p.read();if(I.done)break;const{flags:E,data:N}=I.value;if(E===ku){if(g!==void 0)throw"extra trailer";g=zh(N);continue}if(v!==void 0)throw"extra message";v=m(N)}if(g===void 0)throw"missing trailer";if(Kh(g,P.headers),v===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:P.headers,message:v,trailer:g}}})},async stream(r,i,s,o,a,l,c){var d;const{serialize:h,parse:m}=jh(i,t,n.jsonOptions,n.binaryOptions);function y(T,P,p,g){return P1(this,arguments,function*(){const I=Mh(T).getReader();if(P){if(!(yield di(I.read())).done)throw"extra data for trailers-only";return yield di(void 0)}let E=!1;for(;;){const N=yield di(I.read());if(N.done)break;const{flags:D,data:R}=N.value;if((D&ku)===ku){if(E)throw"extra trailer";E=!0;const q=zh(R);Kh(q,g),q.forEach(($,Se)=>p.set(Se,$));continue}if(E)throw"extra message";yield yield di(m(R))}if(!E)throw"missing trailer"})}async function w(T){if(i.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const P=await T[Symbol.asyncIterator]().next();if(P.done==!0)throw"missing request message";return Jh(0,h(P.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,x1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:r,method:i,url:Uh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Wh(t,o,a),contextValues:c??$h(),message:l},next:async T=>{var P;const g=await((P=n.fetch)!==null&&P!==void 0?P:globalThis.fetch)(T.url,Object.assign(Object.assign({},T.init),{headers:T.header,signal:T.signal,body:await w(T.message)})),{foundStatus:v}=Hh(g.status,g.headers);if(!g.body)throw"missing response body";const I=new Headers;return Object.assign(Object.assign({},T),{header:g.headers,trailer:I,message:y(g.body,v,I,g.headers)})}})}}}var z=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(z||{});f.util.setEnumType(z,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var yi=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(yi||{});f.util.setEnumType(yi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const an=class an extends O{constructor(t){super();u(this,"root");u(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new an().fromBinary(t,r)}static fromJson(t,r){return new an().fromJson(t,r)}static fromJsonString(t,r){return new an().fromJsonString(t,r)}static equals(t,r){return f.util.equals(an,t,r)}};u(an,"runtime",f),u(an,"typeName","yorkie.v1.Snapshot"),u(an,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:_e},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Hf}}]));let kc=an;var lt;let Ir=(lt=class extends O{constructor(t){super();u(this,"documentKey","");u(this,"checkpoint");u(this,"snapshot",new Uint8Array(0));u(this,"changes",[]);u(this,"minSyncedTicket");u(this,"isRemoved",!1);u(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new lt().fromBinary(t,r)}static fromJson(t,r){return new lt().fromJson(t,r)}static fromJsonString(t,r){return new lt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(lt,t,r)}},u(lt,"runtime",f),u(lt,"typeName","yorkie.v1.ChangePack"),u(lt,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Xp},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Yp,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:b},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Ml}])),lt);var ut;let Yp=(ut=class extends O{constructor(t){super();u(this,"id");u(this,"message","");u(this,"operations",[]);u(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new ut().fromBinary(t,r)}static fromJson(t,r){return new ut().fromJson(t,r)}static fromJsonString(t,r){return new ut().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ut,t,r)}},u(ut,"runtime",f),u(ut,"typeName","yorkie.v1.Change"),u(ut,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Fl},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Wf,repeated:!0},{no:4,name:"presence_change",kind:"message",T:vo}])),ut);var ct;let Fl=(ct=class extends O{constructor(t){super();u(this,"clientSeq",0);u(this,"serverSeq",re.zero);u(this,"lamport",re.zero);u(this,"actorId",new Uint8Array(0));u(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ct().fromBinary(t,r)}static fromJson(t,r){return new ct().fromJson(t,r)}static fromJsonString(t,r){return new ct().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ct,t,r)}},u(ct,"runtime",f),u(ct,"typeName","yorkie.v1.ChangeID"),u(ct,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Ml}])),ct);var ft;let Ml=(ft=class extends O{constructor(t){super();u(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new ft().fromBinary(t,r)}static fromJson(t,r){return new ft().fromJson(t,r)}static fromJsonString(t,r){return new ft().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ft,t,r)}},u(ft,"runtime",f),u(ft,"typeName","yorkie.v1.VersionVector"),u(ft,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),ft);var dt;let Wf=(dt=class extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new dt().fromBinary(t,r)}static fromJson(t,r){return new dt().fromJson(t,r)}static fromJsonString(t,r){return new dt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dt,t,r)}},u(dt,"runtime",f),u(dt,"typeName","yorkie.v1.Operation"),u(dt,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Qa,oneof:"body"},{no:2,name:"add",kind:"message",T:Xa,oneof:"body"},{no:3,name:"move",kind:"message",T:Za,oneof:"body"},{no:4,name:"remove",kind:"message",T:el,oneof:"body"},{no:5,name:"edit",kind:"message",T:tl,oneof:"body"},{no:6,name:"select",kind:"message",T:Tc,oneof:"body"},{no:7,name:"style",kind:"message",T:nl,oneof:"body"},{no:8,name:"increase",kind:"message",T:rl,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:il,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:sl,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Ac,oneof:"body"}])),dt);const ln=class ln extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"key","");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};u(ln,"runtime",f),u(ln,"typeName","yorkie.v1.Operation.Set"),u(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Qa=ln;const un=class un extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"prevCreatedAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};u(un,"runtime",f),u(un,"typeName","yorkie.v1.Operation.Add"),u(un,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Xa=un;const cn=class cn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"prevCreatedAt");u(this,"createdAt");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};u(cn,"runtime",f),u(cn,"typeName","yorkie.v1.Operation.Move"),u(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"executed_at",kind:"message",T:b}]));let Za=cn;const fn=class fn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"createdAt");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};u(fn,"runtime",f),u(fn,"typeName","yorkie.v1.Operation.Remove"),u(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"executed_at",kind:"message",T:b}]));let el=fn;const dn=class dn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"createdAtMapByActor",{});u(this,"content","");u(this,"executedAt");u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};u(dn,"runtime",f),u(dn,"typeName","yorkie.v1.Operation.Edit"),u(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:b},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let tl=dn;const hn=class hn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};u(hn,"runtime",f),u(hn,"typeName","yorkie.v1.Operation.Select"),u(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"executed_at",kind:"message",T:b}]));let Tc=hn;const gn=class gn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"attributes",{});u(this,"executedAt");u(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};u(gn,"runtime",f),u(gn,"typeName","yorkie.v1.Operation.Style"),u(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let nl=gn;const mn=class mn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};u(mn,"runtime",f),u(mn,"typeName","yorkie.v1.Operation.Increase"),u(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"value",kind:"message",T:at},{no:3,name:"executed_at",kind:"message",T:b}]));let rl=mn;const pn=class pn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"createdAtMapByActor",{});u(this,"contents",[]);u(this,"splitLevel",0);u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};u(pn,"runtime",f),u(pn,"typeName","yorkie.v1.Operation.TreeEdit"),u(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ai},{no:3,name:"to",kind:"message",T:Ai},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"contents",kind:"message",T:gl,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:b}]));let il=pn;const yn=class yn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"attributes",{});u(this,"executedAt");u(this,"attributesToRemove",[]);u(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};u(yn,"runtime",f),u(yn,"typeName","yorkie.v1.Operation.TreeStyle"),u(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ai},{no:3,name:"to",kind:"message",T:Ai},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let sl=yn;const vn=class vn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"createdAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};u(vn,"runtime",f),u(vn,"typeName","yorkie.v1.Operation.ArraySet"),u(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Ac=vn;const wn=class wn extends O{constructor(t){super();u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");u(this,"type",0);u(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};u(wn,"runtime",f),u(wn,"typeName","yorkie.v1.JSONElementSimple"),u(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"moved_at",kind:"message",T:b},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"type",kind:"enum",T:f.getEnumType(z)},{no:5,name:"value",kind:"scalar",T:12}]));let at=wn;const Sn=class Sn extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};u(Sn,"runtime",f),u(Sn,"typeName","yorkie.v1.JSONElement"),u(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:ol,oneof:"body"},{no:2,name:"json_array",kind:"message",T:al,oneof:"body"},{no:3,name:"primitive",kind:"message",T:ll,oneof:"body"},{no:5,name:"text",kind:"message",T:ul,oneof:"body"},{no:6,name:"counter",kind:"message",T:cl,oneof:"body"},{no:7,name:"tree",kind:"message",T:fl,oneof:"body"}]));let _e=Sn;const kn=class kn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};u(kn,"runtime",f),u(kn,"typeName","yorkie.v1.JSONElement.JSONObject"),u(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Qp,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ol=kn;const Tn=class Tn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};u(Tn,"runtime",f),u(Tn,"typeName","yorkie.v1.JSONElement.JSONArray"),u(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:dl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let al=Tn;const An=class An extends O{constructor(t){super();u(this,"type",0);u(this,"value",new Uint8Array(0));u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};u(An,"runtime",f),u(An,"typeName","yorkie.v1.JSONElement.Primitive"),u(An,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let ll=An;const In=class In extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};u(In,"runtime",f),u(In,"typeName","yorkie.v1.JSONElement.Text"),u(In,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:hl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ul=In;const En=class En extends O{constructor(t){super();u(this,"type",0);u(this,"value",new Uint8Array(0));u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};u(En,"runtime",f),u(En,"typeName","yorkie.v1.JSONElement.Counter"),u(En,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let cl=En;const xn=class xn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};u(xn,"runtime",f),u(xn,"typeName","yorkie.v1.JSONElement.Tree"),u(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yo,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let fl=xn;var ht;let Qp=(ht=class extends O{constructor(t){super();u(this,"key","");u(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new ht().fromBinary(t,r)}static fromJson(t,r){return new ht().fromJson(t,r)}static fromJsonString(t,r){return new ht().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ht,t,r)}},u(ht,"runtime",f),u(ht,"typeName","yorkie.v1.RHTNode"),u(ht,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:_e}])),ht);const jt=class jt extends O{constructor(t){super();u(this,"next");u(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new jt().fromBinary(t,r)}static fromJson(t,r){return new jt().fromJson(t,r)}static fromJsonString(t,r){return new jt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jt,t,r)}};u(jt,"runtime",f),u(jt,"typeName","yorkie.v1.RGANode"),u(jt,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:jt},{no:2,name:"element",kind:"message",T:_e}]));let dl=jt;const Cn=class Cn extends O{constructor(t){super();u(this,"value","");u(this,"updatedAt");u(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};u(Cn,"runtime",f),u(Cn,"typeName","yorkie.v1.NodeAttr"),u(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:b},{no:3,name:"is_removed",kind:"scalar",T:8}]));let ds=Cn;const Nn=class Nn extends O{constructor(t){super();u(this,"id");u(this,"value","");u(this,"removedAt");u(this,"insPrevId");u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};u(Nn,"runtime",f),u(Nn,"typeName","yorkie.v1.TextNode"),u(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:po},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"ins_prev_id",kind:"message",T:po},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ds}}]));let hl=Nn;const Pn=class Pn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};u(Pn,"runtime",f),u(Pn,"typeName","yorkie.v1.TextNodeID"),u(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let po=Pn;const Dn=class Dn extends O{constructor(t){super();u(this,"id");u(this,"type","");u(this,"value","");u(this,"removedAt");u(this,"insPrevId");u(this,"insNextId");u(this,"depth",0);u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};u(Dn,"runtime",f),u(Dn,"typeName","yorkie.v1.TreeNode"),u(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Wr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:b},{no:5,name:"ins_prev_id",kind:"message",T:Wr},{no:6,name:"ins_next_id",kind:"message",T:Wr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ds}}]));let yo=Dn;const On=class On extends O{constructor(t){super();u(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};u(On,"runtime",f),u(On,"typeName","yorkie.v1.TreeNodes"),u(On,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:yo,repeated:!0}]));let gl=On;const Rn=class Rn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};u(Rn,"runtime",f),u(Rn,"typeName","yorkie.v1.TreeNodeID"),u(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let Wr=Rn;const Ln=class Ln extends O{constructor(t){super();u(this,"parentId");u(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};u(Ln,"runtime",f),u(Ln,"typeName","yorkie.v1.TreePos"),u(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:Wr},{no:2,name:"left_sibling_id",kind:"message",T:Wr}]));let Ai=Ln;const Bn=class Bn extends O{constructor(t){super();u(this,"id","");u(this,"username","");u(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};u(Bn,"runtime",f),u(Bn,"typeName","yorkie.v1.User"),u(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Re}]));let _h=Bn;const bn=class bn extends O{constructor(t){super();u(this,"id","");u(this,"name","");u(this,"publicKey","");u(this,"secretKey","");u(this,"authWebhookUrl","");u(this,"authWebhookMethods",[]);u(this,"clientDeactivateThreshold","");u(this,"createdAt");u(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};u(bn,"runtime",f),u(bn,"typeName","yorkie.v1.Project"),u(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Re},{no:9,name:"updated_at",kind:"message",T:Re}]));let Gh=bn;const Fn=class Fn extends O{constructor(t){super();u(this,"name");u(this,"authWebhookUrl");u(this,"authWebhookMethods");u(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new Fn().fromBinary(t,r)}static fromJson(t,r){return new Fn().fromJson(t,r)}static fromJsonString(t,r){return new Fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Fn,t,r)}};u(Fn,"runtime",f),u(Fn,"typeName","yorkie.v1.UpdatableProjectFields"),u(Fn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Qe},{no:2,name:"auth_webhook_url",kind:"message",T:Qe},{no:3,name:"auth_webhook_methods",kind:"message",T:Ic},{no:4,name:"client_deactivate_threshold",kind:"message",T:Qe}]));let Yh=Fn;const Mn=class Mn extends O{constructor(t){super();u(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};u(Mn,"runtime",f),u(Mn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),u(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Ic=Mn;const Jn=class Jn extends O{constructor(t){super();u(this,"id","");u(this,"key","");u(this,"snapshot","");u(this,"createdAt");u(this,"accessedAt");u(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};u(Jn,"runtime",f),u(Jn,"typeName","yorkie.v1.DocumentSummary"),u(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Re},{no:5,name:"accessed_at",kind:"message",T:Re},{no:6,name:"updated_at",kind:"message",T:Re}]));let Qh=Jn;const $n=class $n extends O{constructor(t){super();u(this,"type",0);u(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};u($n,"runtime",f),u($n,"typeName","yorkie.v1.PresenceChange"),u($n,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(Ii)},{no:2,name:"presence",kind:"message",T:Hf}]));let vo=$n;var Ii=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Ii||{});f.util.setEnumType(Ii,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var gt;let Hf=(gt=class extends O{constructor(t){super();u(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new gt().fromBinary(t,r)}static fromJson(t,r){return new gt().fromJson(t,r)}static fromJsonString(t,r){return new gt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gt,t,r)}},u(gt,"runtime",f),u(gt,"typeName","yorkie.v1.Presence"),u(gt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),gt);var mt;let Xp=(mt=class extends O{constructor(t){super();u(this,"serverSeq",re.zero);u(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new mt().fromBinary(t,r)}static fromJson(t,r){return new mt().fromJson(t,r)}static fromJsonString(t,r){return new mt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mt,t,r)}},u(mt,"runtime",f),u(mt,"typeName","yorkie.v1.Checkpoint"),u(mt,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),mt);const zn=class zn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);u(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};u(zn,"runtime",f),u(zn,"typeName","yorkie.v1.TextNodePos"),u(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let kr=zn;var pt;let b=(pt=class extends O{constructor(t){super();u(this,"lamport",re.zero);u(this,"delimiter",0);u(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new pt().fromBinary(t,r)}static fromJson(t,r){return new pt().fromJson(t,r)}static fromJsonString(t,r){return new pt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pt,t,r)}},u(pt,"runtime",f),u(pt,"typeName","yorkie.v1.TimeTicket"),u(pt,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),pt);const Un=class Un extends O{constructor(t){super();u(this,"topic","");u(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};u(Un,"runtime",f),u(Un,"typeName","yorkie.v1.DocEventBody"),u(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Ec=Un;const jn=class jn extends O{constructor(t){super();u(this,"type",0);u(this,"publisher","");u(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};u(jn,"runtime",f),u(jn,"typeName","yorkie.v1.DocEvent"),u(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(yi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Ec}]));let xc=jn;const Vn=class Vn extends O{constructor(t){super();u(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};u(Vn,"runtime",f),u(Vn,"typeName","yorkie.v1.ActivateClientRequest"),u(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Cc=Vn;const qn=class qn extends O{constructor(t){super();u(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};u(qn,"runtime",f),u(qn,"typeName","yorkie.v1.ActivateClientResponse"),u(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Nc=qn;const Kn=class Kn extends O{constructor(t){super();u(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};u(Kn,"runtime",f),u(Kn,"typeName","yorkie.v1.DeactivateClientRequest"),u(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Pc=Kn;const Wn=class Wn extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Wn().fromBinary(e,t)}static fromJson(e,t){return new Wn().fromJson(e,t)}static fromJsonString(e,t){return new Wn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wn,e,t)}};u(Wn,"runtime",f),u(Wn,"typeName","yorkie.v1.DeactivateClientResponse"),u(Wn,"fields",f.util.newFieldList(()=>[]));let Dc=Wn;const Hn=class Hn extends O{constructor(t){super();u(this,"clientId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};u(Hn,"runtime",f),u(Hn,"typeName","yorkie.v1.AttachDocumentRequest"),u(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Ir}]));let Oc=Hn;const _n=class _n extends O{constructor(t){super();u(this,"documentId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new _n().fromBinary(t,r)}static fromJson(t,r){return new _n().fromJson(t,r)}static fromJsonString(t,r){return new _n().fromJsonString(t,r)}static equals(t,r){return f.util.equals(_n,t,r)}};u(_n,"runtime",f),u(_n,"typeName","yorkie.v1.AttachDocumentResponse"),u(_n,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Ir}]));let Rc=_n;const Gn=class Gn extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");u(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Gn().fromBinary(t,r)}static fromJson(t,r){return new Gn().fromJson(t,r)}static fromJsonString(t,r){return new Gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Gn,t,r)}};u(Gn,"runtime",f),u(Gn,"typeName","yorkie.v1.DetachDocumentRequest"),u(Gn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let Lc=Gn;const Yn=class Yn extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Yn().fromBinary(t,r)}static fromJson(t,r){return new Yn().fromJson(t,r)}static fromJsonString(t,r){return new Yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yn,t,r)}};u(Yn,"runtime",f),u(Yn,"typeName","yorkie.v1.DetachDocumentResponse"),u(Yn,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Ir}]));let Bc=Yn;const Qn=class Qn extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qn().fromBinary(t,r)}static fromJson(t,r){return new Qn().fromJson(t,r)}static fromJsonString(t,r){return new Qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qn,t,r)}};u(Qn,"runtime",f),u(Qn,"typeName","yorkie.v1.WatchDocumentRequest"),u(Qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let bc=Qn;const Xn=class Xn extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Xn().fromBinary(t,r)}static fromJson(t,r){return new Xn().fromJson(t,r)}static fromJsonString(t,r){return new Xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xn,t,r)}};u(Xn,"runtime",f),u(Xn,"typeName","yorkie.v1.WatchDocumentResponse"),u(Xn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Mc,oneof:"body"},{no:2,name:"event",kind:"message",T:xc,oneof:"body"}]));let Fc=Xn;const Zn=class Zn extends O{constructor(t){super();u(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Zn().fromBinary(t,r)}static fromJson(t,r){return new Zn().fromJson(t,r)}static fromJsonString(t,r){return new Zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zn,t,r)}};u(Zn,"runtime",f),u(Zn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),u(Zn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Mc=Zn;const er=class er extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new er().fromBinary(t,r)}static fromJson(t,r){return new er().fromJson(t,r)}static fromJsonString(t,r){return new er().fromJsonString(t,r)}static equals(t,r){return f.util.equals(er,t,r)}};u(er,"runtime",f),u(er,"typeName","yorkie.v1.RemoveDocumentRequest"),u(er,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir}]));let Jc=er;const tr=class tr extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new tr().fromBinary(t,r)}static fromJson(t,r){return new tr().fromJson(t,r)}static fromJsonString(t,r){return new tr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tr,t,r)}};u(tr,"runtime",f),u(tr,"typeName","yorkie.v1.RemoveDocumentResponse"),u(tr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Ir}]));let $c=tr;const nr=class nr extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");u(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new nr().fromBinary(t,r)}static fromJson(t,r){return new nr().fromJson(t,r)}static fromJsonString(t,r){return new nr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nr,t,r)}};u(nr,"runtime",f),u(nr,"typeName","yorkie.v1.PushPullChangesRequest"),u(nr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir},{no:4,name:"push_only",kind:"scalar",T:8}]));let zc=nr;const rr=class rr extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new rr().fromBinary(t,r)}static fromJson(t,r){return new rr().fromJson(t,r)}static fromJsonString(t,r){return new rr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rr,t,r)}};u(rr,"runtime",f),u(rr,"typeName","yorkie.v1.PushPullChangesResponse"),u(rr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Ir}]));let Uc=rr;const ir=class ir extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"topic","");u(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new ir().fromBinary(t,r)}static fromJson(t,r){return new ir().fromJson(t,r)}static fromJsonString(t,r){return new ir().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ir,t,r)}};u(ir,"runtime",f),u(ir,"typeName","yorkie.v1.BroadcastRequest"),u(ir,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let jc=ir;const sr=class sr extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new sr().fromBinary(e,t)}static fromJson(e,t){return new sr().fromJson(e,t)}static fromJsonString(e,t){return new sr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(sr,e,t)}};u(sr,"runtime",f),u(sr,"typeName","yorkie.v1.BroadcastResponse"),u(sr,"fields",f.util.newFieldList(()=>[]));let Vc=sr;const O1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Cc,O:Nc,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:Pc,O:Dc,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:Oc,O:Rc,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:Lc,O:Bc,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:Jc,O:$c,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:zc,O:Uc,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:bc,O:Fc,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:jc,O:Vc,kind:Fe.Unary}}},R1=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:fr}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:L1,repeated:!0}]);const L1=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:B1,repeated:!0}]);const B1=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:b1,repeated:!0}]);const b1=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var S=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(S||{});class k extends Error{constructor(t,r){super(r);u(this,"name","YorkieError");u(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Nt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const Zp=n=>n?Object.entries(n).length===0:!0,hs=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},es=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Xr=(n=>(n.Put="put",n.Clear="clear",n))(Xr||{});class Tu{constructor(e,t){u(this,"context");u(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:Nt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const _f="000000000000000000000000";class kt{constructor(e,t,r){u(this,"lamport");u(this,"delimiter");u(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new kt(e,t,r)}static fromStruct(e){return kt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new kt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const ey=0,_s=9223372036854775807n,bt=new kt(0n,ey,_f);function en(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` +`+s.stack}return{value:n,source:e,stack:i,digest:null}}function mu(n,e,t){return{value:n,source:null,stack:t??null,digest:e??null}}function ac(n,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var J0=typeof WeakMap=="function"?WeakMap:Map;function Ym(n,e,t){t=gr(-1,t),t.tag=3,t.payload={element:null};var r=e.value;return t.callback=function(){Ka||(Ka=!0,yc=r),ac(n,e)},t}function Qm(n,e,t){t=gr(-1,t),t.tag=3;var r=n.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;t.payload=function(){return r(i)},t.callback=function(){ac(n,e)}}var s=n.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(t.callback=function(){ac(n,e),typeof r!="function"&&(Vr===null?Vr=new Set([this]):Vr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),t}function nh(n,e,t){var r=n.pingCache;if(r===null){r=n.pingCache=new J0;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(t)||(i.add(t),n=X0.bind(null,n,e,t),e.then(n,n))}function rh(n){do{var e;if((e=n.tag===13)&&(e=n.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return n;n=n.return}while(n!==null);return null}function ih(n,e,t,r,i){return n.mode&1?(n.flags|=65536,n.lanes=i,n):(n===e?n.flags|=65536:(n.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(e=gr(-1,1),e.tag=2,jr(t,e,1))),t.lanes|=1),n)}var $0=Ar.ReactCurrentOwner,je=!1;function be(n,e,t,r){e.child=n===null?Pm(e,null,t,r):os(e,n.child,t,r)}function sh(n,e,t,r,i){t=t.render;var s=e.ref;return Xi(e,i),r=Pf(n,e,t,r,s,i),t=Df(),n!==null&&!je?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Sr(n,e,i)):(te&&t&&yf(e),e.flags|=1,be(n,e,r,i),e.child)}function oh(n,e,t,r,i){if(n===null){var s=t.type;return typeof s=="function"&&!zf(s)&&s.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=s,Xm(n,e,s,r,i)):(n=ya(t.type,null,r,e,e.mode,i),n.ref=e.ref,n.return=e,e.child=n)}if(s=n.child,!(n.lanes&i)){var o=s.memoizedProps;if(t=t.compare,t=t!==null?t:io,t(o,r)&&n.ref===e.ref)return Sr(n,e,i)}return e.flags|=1,n=Kr(s,r),n.ref=e.ref,n.return=e,e.child=n}function Xm(n,e,t,r,i){if(n!==null){var s=n.memoizedProps;if(io(s,r)&&n.ref===e.ref)if(je=!1,e.pendingProps=r=s,(n.lanes&i)!==0)n.flags&131072&&(je=!0);else return e.lanes=n.lanes,Sr(n,e,i)}return lc(n,e,t,r,i)}function Zm(n,e,t){var r=e.pendingProps,i=r.children,s=n!==null?n.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},X(Ki,Ge),Ge|=t;else{if(!(t&1073741824))return n=s!==null?s.baseLanes|t:t,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:n,cachePool:null,transitions:null},e.updateQueue=null,X(Ki,Ge),Ge|=n,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:t,X(Ki,Ge),Ge|=r}else s!==null?(r=s.baseLanes|t,e.memoizedState=null):r=t,X(Ki,Ge),Ge|=r;return be(n,e,i,t),e.child}function ep(n,e){var t=e.ref;(n===null&&t!==null||n!==null&&n.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function lc(n,e,t,r,i){var s=Ke(t)?vi:Le.current;return s=is(e,s),Xi(e,i),t=Pf(n,e,t,r,s,i),r=Df(),n!==null&&!je?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,Sr(n,e,i)):(te&&r&&yf(e),e.flags|=1,be(n,e,t,i),e.child)}function ah(n,e,t,r,i){if(Ke(t)){var s=!0;ba(e)}else s=!1;if(Xi(e,i),e.stateNode===null)ga(n,e),Cm(e,t,r),oc(e,t,r,i),r=!0;else if(n===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,c=t.contextType;typeof c=="object"&&c!==null?c=Tt(c):(c=Ke(t)?vi:Le.current,c=is(e,c));var d=t.getDerivedStateFromProps,h=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==c)&&Xd(e,o,r,c),Or=!1;var m=e.memoizedState;o.state=m,za(e,r,o,i),l=e.memoizedState,a!==r||m!==l||qe.current||Or?(typeof d=="function"&&(sc(e,t,d,r),l=e.memoizedState),(a=Or||Qd(e,t,a,r,m,l,c))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,Em(n,e),a=e.memoizedProps,c=e.type===e.elementType?a:Ct(e.type,a),o.props=c,h=e.pendingProps,m=o.context,l=t.contextType,typeof l=="object"&&l!==null?l=Tt(l):(l=Ke(t)?vi:Le.current,l=is(e,l));var y=t.getDerivedStateFromProps;(d=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==h||m!==l)&&Xd(e,o,r,l),Or=!1,m=e.memoizedState,o.state=m,za(e,r,o,i);var w=e.memoizedState;a!==h||m!==w||qe.current||Or?(typeof y=="function"&&(sc(e,t,y,r),w=e.memoizedState),(c=Or||Qd(e,t,c,r,m,w,l)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=w),o.props=r,o.state=w,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),r=!1)}return uc(n,e,t,r,s,i)}function uc(n,e,t,r,i,s){ep(n,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&Wd(e,t,!1),Sr(n,e,s);r=e.stateNode,$0.current=e;var a=o&&typeof t.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,n!==null&&o?(e.child=os(e,n.child,null,s),e.child=os(e,null,a,s)):be(n,e,a,s),e.memoizedState=r.state,i&&Wd(e,t,!0),e.child}function tp(n){var e=n.stateNode;e.pendingContext?Kd(n,e.pendingContext,e.pendingContext!==e.context):e.context&&Kd(n,e.context,!1),Ef(n,e.containerInfo)}function lh(n,e,t,r,i){return ss(),wf(i),e.flags|=256,be(n,e,t,r),e.child}var cc={dehydrated:null,treeContext:null,retryLane:0};function fc(n){return{baseLanes:n,cachePool:null,transitions:null}}function np(n,e,t){var r=e.pendingProps,i=ie.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=n!==null&&n.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(n===null||n.memoizedState!==null)&&(i|=1),X(ie,i&1),n===null)return rc(e),n=e.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?(e.mode&1?n.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,n=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Dl(o,r,0,null),n=mi(n,r,t,null),s.return=e,n.return=e,s.sibling=n,e.child=s,e.child.memoizedState=fc(t),e.memoizedState=cc,n):Lf(e,o));if(i=n.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return z0(n,e,o,r,a,i,t);if(s){s=r.fallback,o=e.mode,i=n.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=Kr(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=Kr(a,s):(s=mi(s,o,t,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=n.child.memoizedState,o=o===null?fc(t):{baseLanes:o.baseLanes|t,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=n.childLanes&~t,e.memoizedState=cc,r}return s=n.child,n=s.sibling,r=Kr(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=t),r.return=e,r.sibling=null,n!==null&&(t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)),e.child=r,e.memoizedState=null,r}function Lf(n,e){return e=Dl({mode:"visible",children:e},n.mode,0,null),e.return=n,n.child=e}function Yo(n,e,t,r){return r!==null&&wf(r),os(e,n.child,null,t),n=Lf(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function z0(n,e,t,r,i,s,o){if(t)return e.flags&256?(e.flags&=-257,r=mu(Error(x(422))),Yo(n,e,o,r)):e.memoizedState!==null?(e.child=n.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=Dl({mode:"visible",children:r.children},i,0,null),s=mi(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&os(e,n.child,null,o),e.child.memoizedState=fc(o),e.memoizedState=cc,s);if(!(e.mode&1))return Yo(n,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(x(419)),r=mu(s,r,void 0),Yo(n,e,o,r)}if(a=(o&n.childLanes)!==0,je||a){if(r=Ae,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,wr(n,i),Bt(r,n,i,-1))}return $f(),r=mu(Error(x(421))),Yo(n,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=n.child,e=Z0.bind(null,n),i._reactRetry=e,null):(n=s.treeContext,Ye=Ur(i.nextSibling),Ze=e,te=!0,Dt=null,n!==null&&(st[ot++]=ur,st[ot++]=cr,st[ot++]=wi,ur=n.id,cr=n.overflow,wi=e),e=Lf(e,r.children),e.flags|=4096,e)}function uh(n,e,t){n.lanes|=e;var r=n.alternate;r!==null&&(r.lanes|=e),ic(n.return,e,t)}function pu(n,e,t,r,i){var s=n.memoizedState;s===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=t,s.tailMode=i)}function rp(n,e,t){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(be(n,e,r.children,t),r=ie.current,r&2)r=r&1|2,e.flags|=128;else{if(n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&uh(n,t,e);else if(n.tag===19)uh(n,t,e);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}r&=1}if(X(ie,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(t=e.child,i=null;t!==null;)n=t.alternate,n!==null&&Ua(n)===null&&(i=t),t=t.sibling;t=i,t===null?(i=e.child,e.child=null):(i=t.sibling,t.sibling=null),pu(e,!1,i,t,s);break;case"backwards":for(t=null,i=e.child,e.child=null;i!==null;){if(n=i.alternate,n!==null&&Ua(n)===null){e.child=i;break}n=i.sibling,i.sibling=t,t=i,i=n}pu(e,!0,t,null,s);break;case"together":pu(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ga(n,e){!(e.mode&1)&&n!==null&&(n.alternate=null,e.alternate=null,e.flags|=2)}function Sr(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),ki|=e.lanes,!(t&e.childLanes))return null;if(n!==null&&e.child!==n.child)throw Error(x(153));if(e.child!==null){for(n=e.child,t=Kr(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=Kr(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function U0(n,e,t){switch(e.tag){case 3:tp(e),ss();break;case 5:Dm(e);break;case 1:Ke(e.type)&&ba(e);break;case 4:Ef(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;X(Ja,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(X(ie,ie.current&1),e.flags|=128,null):t&e.child.childLanes?np(n,e,t):(X(ie,ie.current&1),n=Sr(n,e,t),n!==null?n.sibling:null);X(ie,ie.current&1);break;case 19:if(r=(t&e.childLanes)!==0,n.flags&128){if(r)return rp(n,e,t);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),X(ie,ie.current),r)break;return null;case 22:case 23:return e.lanes=0,Zm(n,e,t)}return Sr(n,e,t)}var ip,dc,sp,op;ip=function(n,e){for(var t=e.child;t!==null;){if(t.tag===5||t.tag===6)n.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};dc=function(){};sp=function(n,e,t,r){var i=n.memoizedProps;if(i!==r){n=e.stateNode,fi(nn.current);var s=null;switch(t){case"input":i=Bu(n,i),r=Bu(n,r),s=[];break;case"select":i=ae({},i,{value:void 0}),r=ae({},r,{value:void 0}),s=[];break;case"textarea":i=Mu(n,i),r=Mu(n,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(n.onclick=La)}$u(t,r);var o;t=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(o in a)a.hasOwnProperty(o)&&(t||(t={}),t[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Qs.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(t||(t={}),t[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(t||(t={}),t[o]=l[o])}else t||(s||(s=[]),s.push(c,t)),t=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Qs.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&Z("scroll",n),s||a===l||(s=[])):(s=s||[]).push(c,l))}t&&(s=s||[]).push("style",t);var c=s;(e.updateQueue=c)&&(e.flags|=4)}};op=function(n,e,t,r){t!==r&&(e.flags|=4)};function Ns(n,e){if(!te)switch(n.tailMode){case"hidden":e=n.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?n.tail=null:t.sibling=null;break;case"collapsed":t=n.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e||n.tail===null?n.tail=null:n.tail.sibling=null:r.sibling=null}}function De(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,r=0;if(e)for(var i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=n,i=i.sibling;else for(i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=n,i=i.sibling;return n.subtreeFlags|=r,n.childLanes=t,e}function j0(n,e,t){var r=e.pendingProps;switch(vf(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return De(e),null;case 1:return Ke(e.type)&&Ba(),De(e),null;case 3:return r=e.stateNode,as(),ee(qe),ee(Le),Cf(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(n===null||n.child===null)&&(_o(e)?e.flags|=4:n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Dt!==null&&(Sc(Dt),Dt=null))),dc(n,e),De(e),null;case 5:xf(e);var i=fi(uo.current);if(t=e.type,n!==null&&e.stateNode!=null)sp(n,e,t,r,i),n.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(x(166));return De(e),null}if(n=fi(nn.current),_o(e)){r=e.stateNode,t=e.type;var s=e.memoizedProps;switch(r[qt]=e,r[ao]=s,n=(e.mode&1)!==0,t){case"dialog":Z("cancel",r),Z("close",r);break;case"iframe":case"object":case"embed":Z("load",r);break;case"video":case"audio":for(i=0;i<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=o.createElement(t,{is:r.is}):(n=o.createElement(t),t==="select"&&(o=n,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):n=o.createElementNS(n,t),n[qt]=e,n[ao]=r,ip(n,e,!1,!1),e.stateNode=n;e:{switch(o=zu(t,r),t){case"dialog":Z("cancel",n),Z("close",n),i=r;break;case"iframe":case"object":case"embed":Z("load",n),i=r;break;case"video":case"audio":for(i=0;ius&&(e.flags|=128,r=!0,Ns(s,!1),e.lanes=4194304)}else{if(!r)if(n=Ua(o),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ns(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!te)return De(e),null}else 2*he()-s.renderingStartTime>us&&t!==1073741824&&(e.flags|=128,r=!0,Ns(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=he(),e.sibling=null,t=ie.current,X(ie,r?t&1|2:t&1),e):(De(e),null);case 22:case 23:return Jf(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(De(e),e.subtreeFlags&6&&(e.flags|=8192)):De(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function V0(n,e){switch(vf(e),e.tag){case 1:return Ke(e.type)&&Ba(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return as(),ee(qe),ee(Le),Cf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return xf(e),null;case 13:if(ee(ie),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(x(340));ss()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return ee(ie),null;case 4:return as(),null;case 10:return Tf(e.type._context),null;case 22:case 23:return Jf(),null;case 24:return null;default:return null}}var Qo=!1,Oe=!1,q0=typeof WeakSet=="function"?WeakSet:Set,L=null;function qi(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){ue(n,e,r)}else t.current=null}function hc(n,e,t){try{t()}catch(r){ue(n,e,r)}}var ch=!1;function K0(n,e){if(Yu=Da,n=cm(),pf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,l=-1,c=0,d=0,h=n,m=null;t:for(;;){for(var y;h!==t||i!==0&&h.nodeType!==3||(a=o+i),h!==s||r!==0&&h.nodeType!==3||(l=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(y=h.firstChild)!==null;)m=h,h=y;for(;;){if(h===n)break t;if(m===t&&++c===i&&(a=o),m===s&&++d===r&&(l=o),(y=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=y}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(Qu={focusedElem:n,selectionRange:t},Da=!1,L=e;L!==null;)if(e=L,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,L=n;else for(;L!==null;){e=L;try{var w=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var T=w.memoizedProps,P=w.memoizedState,p=e.stateNode,g=p.getSnapshotBeforeUpdate(e.elementType===e.type?T:Ct(e.type,T),P);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(I){ue(e,e.return,I)}if(n=e.sibling,n!==null){n.return=e.return,L=n;break}L=e.return}return w=ch,ch=!1,w}function Vs(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var s=i.destroy;i.destroy=void 0,s!==void 0&&hc(e,t,s)}i=i.next}while(i!==r)}}function Nl(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function gc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function ap(n){var e=n.alternate;e!==null&&(n.alternate=null,ap(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[qt],delete e[ao],delete e[ec],delete e[C0],delete e[N0])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function lp(n){return n.tag===5||n.tag===3||n.tag===4}function fh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||lp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function mc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=La));else if(r!==4&&(n=n.child,n!==null))for(mc(n,e,t),n=n.sibling;n!==null;)mc(n,e,t),n=n.sibling}function pc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(pc(n,e,t),n=n.sibling;n!==null;)pc(n,e,t),n=n.sibling}var Ie=null,Pt=!1;function xr(n,e,t){for(t=t.child;t!==null;)up(n,e,t),t=t.sibling}function up(n,e,t){if(tn&&typeof tn.onCommitFiberUnmount=="function")try{tn.onCommitFiberUnmount(Sl,t)}catch{}switch(t.tag){case 5:Oe||qi(t,e);case 6:var r=Ie,i=Pt;Ie=null,xr(n,e,t),Ie=r,Pt=i,Ie!==null&&(Pt?(n=Ie,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Ie.removeChild(t.stateNode));break;case 18:Ie!==null&&(Pt?(n=Ie,t=t.stateNode,n.nodeType===8?uu(n.parentNode,t):n.nodeType===1&&uu(n,t),no(n)):uu(Ie,t.stateNode));break;case 4:r=Ie,i=Pt,Ie=t.stateNode.containerInfo,Pt=!0,xr(n,e,t),Ie=r,Pt=i;break;case 0:case 11:case 14:case 15:if(!Oe&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&hc(t,e,o),i=i.next}while(i!==r)}xr(n,e,t);break;case 1:if(!Oe&&(qi(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(a){ue(t,e,a)}xr(n,e,t);break;case 21:xr(n,e,t);break;case 22:t.mode&1?(Oe=(r=Oe)||t.memoizedState!==null,xr(n,e,t),Oe=r):xr(n,e,t);break;default:xr(n,e,t)}}function dh(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new q0),e.forEach(function(r){var i=ew.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function xt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*H0(r/1960))-r,10n?16:n,br===null)var r=!1;else{if(n=br,br=null,Wa=0,W&6)throw Error(x(331));var i=W;for(W|=4,L=n.current;L!==null;){var s=L,o=s.child;if(L.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lhe()-Ff?gi(n,0):bf|=t),We(n,e)}function yp(n,e){e===0&&(n.mode&1?(e=jo,jo<<=1,!(jo&130023424)&&(jo=4194304)):e=1);var t=Je();n=wr(n,e),n!==null&&(xo(n,e,t),We(n,t))}function Z0(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),yp(n,t)}function ew(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),yp(n,t)}var vp;vp=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||qe.current)je=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return je=!1,U0(n,e,t);je=!!(n.flags&131072)}else je=!1,te&&e.flags&1048576&&km(e,Ma,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ga(n,e),n=e.pendingProps;var i=is(e,Le.current);Xi(e,t),i=Pf(null,e,r,n,i,t);var s=Df();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ke(r)?(s=!0,ba(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,If(e),i.updater=xl,e.stateNode=i,i._reactInternals=e,oc(e,r,n,t),e=uc(null,e,r,!0,s,t)):(e.tag=0,te&&s&&yf(e),be(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(ga(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=nw(r),n=Ct(r,n),i){case 0:e=lc(null,e,r,n,t);break e;case 1:e=ah(null,e,r,n,t);break e;case 11:e=sh(null,e,r,n,t);break e;case 14:e=oh(null,e,r,Ct(r.type,n),t);break e}throw Error(x(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),lc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),ah(n,e,r,i,t);case 3:e:{if(tp(e),n===null)throw Error(x(387));r=e.pendingProps,s=e.memoizedState,i=s.element,Em(n,e),za(e,r,null,t);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=ls(Error(x(423)),e),e=lh(n,e,r,t,i);break e}else if(r!==i){i=ls(Error(x(424)),e),e=lh(n,e,r,t,i);break e}else for(Ye=Ur(e.stateNode.containerInfo.firstChild),Ze=e,te=!0,Dt=null,t=Pm(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ss(),r===i){e=Sr(n,e,t);break e}be(n,e,r,t)}e=e.child}return e;case 5:return Dm(e),n===null&&rc(e),r=e.type,i=e.pendingProps,s=n!==null?n.memoizedProps:null,o=i.children,Xu(r,i)?o=null:s!==null&&Xu(r,s)&&(e.flags|=32),ep(n,e),be(n,e,o,t),e.child;case 6:return n===null&&rc(e),null;case 13:return np(n,e,t);case 4:return Ef(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=os(e,null,r,t):be(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),sh(n,e,r,i,t);case 7:return be(n,e,e.pendingProps,t),e.child;case 8:return be(n,e,e.pendingProps.children,t),e.child;case 12:return be(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,X(Ja,r._currentValue),r._currentValue=o,s!==null)if(Mt(s.value,o)){if(s.children===i.children&&!qe.current){e=Sr(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=gr(-1,t&-t),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?l.next=l:(l.next=d.next,d.next=l),c.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),ic(s.return,t,e),a.lanes|=t;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(x(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),ic(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}be(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Xi(e,t),i=Tt(i),r=r(i),e.flags|=1,be(n,e,r,t),e.child;case 14:return r=e.type,i=Ct(r,e.pendingProps),i=Ct(r.type,i),oh(n,e,r,i,t);case 15:return Xm(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ct(r,i),ga(n,e),e.tag=1,Ke(r)?(n=!0,ba(e)):n=!1,Xi(e,t),Cm(e,r,i),oc(e,r,i,t),uc(null,e,r,!0,n,t);case 19:return rp(n,e,t);case 22:return Zm(n,e,t)}throw Error(x(156,e.tag))};function wp(n,e){return Kg(n,e)}function tw(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function yt(n,e,t,r){return new tw(n,e,t,r)}function zf(n){return n=n.prototype,!(!n||!n.isReactComponent)}function nw(n){if(typeof n=="function")return zf(n)?1:0;if(n!=null){if(n=n.$$typeof,n===sf)return 11;if(n===of)return 14}return 2}function Kr(n,e){var t=n.alternate;return t===null?(t=yt(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function ya(n,e,t,r,i,s){var o=2;if(r=n,typeof n=="function")zf(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case bi:return mi(t.children,i,s,e);case rf:o=8,i|=8;break;case Du:return n=yt(12,t,e,i|2),n.elementType=Du,n.lanes=s,n;case Ou:return n=yt(13,t,e,i),n.elementType=Ou,n.lanes=s,n;case Ru:return n=yt(19,t,e,i),n.elementType=Ru,n.lanes=s,n;case Ng:return Dl(t,i,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case xg:o=10;break e;case Cg:o=9;break e;case sf:o=11;break e;case of:o=14;break e;case Dr:o=16,r=null;break e}throw Error(x(130,n==null?n:typeof n,""))}return e=yt(o,t,e,i),e.elementType=n,e.type=r,e.lanes=s,e}function mi(n,e,t,r){return n=yt(7,n,r,e),n.lanes=t,n}function Dl(n,e,t,r){return n=yt(22,n,r,e),n.elementType=Ng,n.lanes=t,n.stateNode={isHidden:!1},n}function yu(n,e,t){return n=yt(6,n,null,e),n.lanes=t,n}function vu(n,e,t){return e=yt(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function rw(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xl(0),this.expirationTimes=Xl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Uf(n,e,t,r,i,s,o,a,l){return n=new rw(n,e,t,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=yt(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},If(s),n}function iw(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ap)}catch(n){console.error(n)}}Ap(),kg.exports=rt;var uw=kg.exports,Sh=uw;Nu.createRoot=Sh.createRoot,Nu.hydrateRoot=Sh.hydrateRoot;var _;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(_||(_={}));function kh(n){const e=_[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class ne extends Error{constructor(e,t=_.Unknown,r,i,s){super(cw(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=s}static from(e,t=_.Unknown){return e instanceof ne?e:e instanceof Error?e.name=="AbortError"?new ne(e.message,_.Canceled):new ne(e.message,t,void 0,void 0,e):new ne(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===ne.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:i=>i===e.typeName?e:void 0}:e,r=[];for(const i of this.details){if("getType"in i){t.findMessage(i.getType().typeName)&&r.push(i);continue}const s=t.findMessage(i.type);if(s)try{r.push(s.fromBinary(i.value))}catch{}}return r}}function cw(n,e){return n.length?`[${kh(e)}] ${n}`:`[${kh(e)}]`}function ce(n,e){if(!n)throw new Error(e)}const fw=34028234663852886e22,dw=-34028234663852886e22,hw=4294967295,gw=2147483647,mw=-2147483648;function va(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>gw||nhw||n<0)throw new Error("invalid uint 32: "+n)}function Ip(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>fw||n({no:i.no,name:i.name,localName:n[i.no]})))}function Cp(n,e,t){const r=Object.create(null),i=Object.create(null),s=[];for(const o of e){const a=Np(o);s.push(a),r[o.name]=a,i[o.no]=a}return{typeName:n,values:s,findName(o){return r[o]},findNumber(o){return i[o]}}}function yw(n,e,t){const r={};for(const i of e){const s=Np(i);r[s.localName]=s.no,r[s.no]=s.localName}return xp(r,n,e),r}function Np(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class O{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),i=r.runtime.bin,s=i.makeReadOptions(t);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const r=this.getType(),i=r.runtime.json,s=i.makeReadOptions(t);return i.readMessage(r,e,s,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,i=r.makeWriteOptions(e),s=i.writerFactory();return r.writeMessage(this,s,i),s.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,i=r.makeWriteOptions(e);return r.writeMessage(this,i)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function vw(n,e,t,r){var i;const s=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new O),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,l){return new o().fromBinary(a,l)},fromJson(a,l){return new o().fromJson(a,l)},fromJsonString(a,l){return new o().fromJsonString(a,l)},equals(a,l){return n.util.equals(o,a,l)}}),o}function ww(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const wa=4294967296;function Th(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,i=0;function s(o,a){const l=Number(n.slice(o,a));i*=t,r=r*t+l,r>=wa&&(i=i+(r/wa|0),r=r%wa)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Dp(r,i):Kf(r,i)}function Sw(n,e){let t=Kf(n,e);const r=t.hi&2147483648;r&&(t=Dp(t.lo,t.hi));const i=Pp(t.lo,t.hi);return r?"-"+i:i}function Pp(n,e){if({lo:n,hi:e}=kw(n,e),e<=2097151)return String(wa*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,i=e>>16&65535;let s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2;const l=1e7;return s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l),a.toString()+Ah(o)+Ah(s)}function kw(n,e){return{lo:n>>>0,hi:e>>>0}}function Kf(n,e){return{lo:n|0,hi:e|0}}function Dp(n,e){return e=~e,n?n=~n+1:e+=1,Kf(n,e)}const Ah=n=>{const e=String(n);return"0000000".slice(e.length)+e};function Ih(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Tw(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Eh={};function Aw(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof Eh!="object"||Eh.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const c=typeof l=="bigint"?l:BigInt(l);if(c>s||ca||cce(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>ce(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),t(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),t(i),Th(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),Th(i)},dec(i,s){return Sw(i,s)},uDec(i,s){return Pp(i,s)}}}const re=Aw();var A;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(A||(A={}));var Qr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(Qr||(Qr={}));function Cr(n,e,t){if(e===t)return!0;if(n==A.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(kc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return va(e),Ih(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Ip(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){kc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){va(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return va(e),e=(e<<1^e>>31)>>>0,Ih(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=re.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=re.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=re.enc(e);return wu(t.lo,t.hi,this.buf),this}sint64(e){let t=re.enc(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return wu(i,s,this.buf),this}uint64(e){let t=re.uEnc(e);return wu(t.lo,t.hi,this.buf),this}}class Ew{constructor(e,t){this.varint64=ww,this.uint32=Tw,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ge.Varint:for(;this.buf[this.pos++]&128;);break;case ge.Bit64:this.pos+=4;case ge.Bit32:this.pos+=4;break;case ge.LengthDelimited:let i=this.uint32();this.pos+=i;break;case ge.StartGroup:for(;;){const[s,o]=this.tag();if(o===ge.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return re.dec(...this.varint64())}uint64(){return re.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,re.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return re.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return re.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function xw(n,e,t,r){let i;return{typeName:e,extendee:t,get field(){if(!i){const s=typeof r=="function"?r():r;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,i=n.util.newFieldList([s]).list()[0]}return i},runtime:n}}function Rp(n){const e=n.field.localName,t=Object.create(null);return t[e]=Cw(n),[t,()=>t[e]]}function Cw(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return cs(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Nw(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let lr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),bl=[];for(let n=0;n>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,i=0;for(let s=0;s>2],i=(r&3)<<4,t=1;break;case 1:e+=lr[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=lr[i|r>>6],e+=lr[r&63],t=0;break}return t&&(e+=lr[i],e+="=",t==1&&(e+="=")),e}};function Pw(n,e,t){Bp(e,n);const r=e.runtime.bin.makeReadOptions(t),i=Nw(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Rp(e);for(const a of i)e.runtime.bin.readField(s,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Dw(n,e,t,r){Bp(e,n);const i=e.runtime.bin.makeReadOptions(r),s=e.runtime.bin.makeWriteOptions(r);if(Lp(n,e)){const c=n.getType().runtime.bin.listUnknownFields(n).filter(d=>d.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const d of c)n.getType().runtime.bin.onUnknownField(n,d.no,d.wireType,d.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const l=i.readerFactory(o.finish());for(;l.posr.no==e.field.no)}function Bp(n,e){ce(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function bp(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Op(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function xh(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?cs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function pi(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(O.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Fp(n,e){return pi(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}A.DOUBLE,A.FLOAT,A.INT64,A.UINT64,A.INT32,A.UINT32,A.BOOL,A.STRING,A.BYTES;const Ch={ignoreUnknownFields:!1},Nh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ow(n){return n?Object.assign(Object.assign({},Ch),n):Ch}function Rw(n){return n?Object.assign(Object.assign({},Nh),n):Nh}const Ga=Symbol(),Sa=Symbol();function Lw(){return{makeReadOptions:Ow,makeWriteOptions:Rw,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Vt(e)}`);r=r??new n;const i=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(a===null&&l.kind=="scalar")continue;const c=i.get(l.oneof);if(c!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${c}", "${o}"`);i.set(l.oneof,o)}Ph(r,a,l,t,n)}else{let c=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const d=s.findExtension(o.substring(1,o.length-1));if(d&&d.extendee.typeName==n.typeName){c=!0;const[h,m]=Rp(d);Ph(h,a,d.field,t,d),Dw(r,d,m(),t)}}if(!c&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let i;try{for(i of t.fields.byNumber()){if(!bp(i,n)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!bw(i))continue}const o=i.oneof?n[i.oneof.localName].value:n[i.localName],a=Dh(i,o,e);a!==void 0&&(r[e.useProtoFieldName?i.name:i.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&Lp(n,a)){const l=Pw(n,a,e),c=Dh(a.field,l,e);c!==void 0&&(r[a.field.jsonName]=c)}}}catch(s){const o=i?`cannot encode field ${t.typeName}.${i.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return Ws(n,e,t??Qr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Op(n,e)))return ka(n,e)},debug:Vt}}function Vt(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function Ph(n,e,t,r,i){let s=t.localName;if(t.repeated){if(ce(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const l=Su(t.T,a,r.ignoreUnknownFields,!0);l!==Sa&&o.push(l);break;case"scalar":try{o.push(Ws(t.T,a,t.L,!0))}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(a)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`);const o=n[s];for(const[a,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: map value null`);let c;try{c=Bw(t.K,a)}catch(d){let h=`cannot decode map key for field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}switch(t.V.kind){case"message":o[c]=t.V.T.fromJson(l,r);break;case"enum":const d=Su(t.V.T,l,r.ignoreUnknownFields,!0);d!==Sa&&(o[c]=d);break;case"scalar":try{o[c]=Ws(t.V.T,l,Qr.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];pi(a)?a.fromJson(e,r):(n[s]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const l=Su(t.T,e,r.ignoreUnknownFields,!1);switch(l){case Ga:xh(t,n);break;case Sa:break;default:n[s]=l;break}break;case"scalar":try{const c=Ws(t.T,e,t.L,!1);switch(c){case Ga:xh(t,n);break;default:n[s]=c;break}}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${Vt(e)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}function Bw(n,e){if(n===A.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ws(n,e,Qr.BIGINT,!0).toString()}function Ws(n,e,t,r){if(e===null)return r?cs(n,t):Ga;switch(n){case A.DOUBLE:case A.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return n==A.FLOAT&&Ip(i),i;case A.INT32:case A.FIXED32:case A.SFIXED32:case A.SINT32:case A.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==A.UINT32||n==A.FIXED32?kc(s):va(s),s;case A.INT64:case A.SFIXED64:case A.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=re.parse(e);return t?o.toString():o;case A.FIXED64:case A.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=re.uParse(e);return t?a.toString():a;case A.BOOL:if(typeof e!="boolean")break;return e;case A.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case A.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Wf.dec(e)}throw new Error}function Su(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Ga;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=n.findName(e);if(i!==void 0)return i.no;if(t)return Sa;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Vt(e)}`)}function bw(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function Dh(n,e,t){if(n.kind=="map"){ce(typeof e=="object"&&e!=null);const r={},i=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of i)r[o.toString()]=ka(n.V.T,a);break;case"message":for(const[o,a]of i)r[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of i)r[o.toString()]=ku(s,a,t.enumAsInteger);break}return t.emitDefaultValues||i.length>0?r:void 0}if(n.repeated){ce(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let i=0;i0?r:void 0}switch(n.kind){case"scalar":return ka(n.T,e);case"enum":return ku(n.T,e,t.enumAsInteger);case"message":return Fp(n.T,e).toJson(t)}}function ku(n,e,t){var r;if(ce(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const i=n.findNumber(e);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:e}function ka(n,e){switch(n){case A.INT32:case A.SFIXED32:case A.SINT32:case A.FIXED32:case A.UINT32:return ce(typeof e=="number"),e;case A.FLOAT:case A.DOUBLE:return ce(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case A.STRING:return ce(typeof e=="string"),e;case A.BOOL:return ce(typeof e=="boolean"),e;case A.UINT64:case A.FIXED64:case A.INT64:case A.SFIXED64:case A.SINT64:return ce(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case A.BYTES:return ce(e instanceof Uint8Array),Wf.enc(e)}}const Di=Symbol("@bufbuild/protobuf/unknown-fields"),Oh={readUnknownFields:!0,readerFactory:n=>new Ew(n)},Rh={writeUnknownFields:!0,writerFactory:()=>new Iw};function Fw(n){return n?Object.assign(Object.assign({},Oh),n):Oh}function Mw(n){return n?Object.assign(Object.assign({},Rh),n):Rh}function Jw(){return{makeReadOptions:Fw,makeWriteOptions:Mw,listUnknownFields(n){var e;return(e=n[Di])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Di]},writeUnknownFields(n,e){const r=n[Di];if(r)for(const i of r)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(n,e,t,r){const i=n;Array.isArray(i[Di])||(i[Di]=[]),i[Di].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,i){const s=n.getType(),o=i?e.len:e.pos+t;let a,l;for(;e.pos0&&(l=zw),s){let m=n[o];if(r==ge.LengthDelimited&&a!=A.STRING&&a!=A.BYTES){let w=e.uint32()+e.pos;for(;e.pospi(m,h)?m:new h(m));else{const m=o[i];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[i]=Ds(m):s[i]=m:s[i]=pi(m,h)?m:new h(m)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const i=e[r.localName],s=t[r.localName];if(r.repeated){if(i.length!==s.length)return!1;switch(r.kind){case"message":return i.every((o,a)=>r.T.equals(o,s[a]));case"scalar":return i.every((o,a)=>Cr(r.T,o,s[a]));case"enum":return i.every((o,a)=>Cr(A.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,s);case"enum":return Cr(A.INT32,i,s);case"scalar":return Cr(r.T,i,s);case"oneof":if(i.case!==s.case)return!1;const o=r.findField(i.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(i.value,s.value);case"enum":return Cr(A.INT32,i.value,s.value);case"scalar":return Cr(o.T,i.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(i).concat(Object.keys(s));switch(r.V.kind){case"message":const l=r.V.T;return a.every(d=>l.equals(i[d],s[d]));case"enum":return a.every(d=>Cr(A.INT32,i[d],s[d]));case"scalar":const c=r.V.T;return a.every(d=>Cr(c,i[d],s[d]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const i of e.fields.byMember()){const s=n[i.localName];let o;if(i.repeated)o=s.map(ea);else if(i.kind=="map"){o=r[i.localName];for(const[a,l]of Object.entries(s))o[a]=ea(l)}else i.kind=="oneof"?o=i.findField(s.case)?{case:s.case,value:ea(s.value)}:{case:void 0}:o=ea(s);r[i.localName]=o}for(const i of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return t}}}function ea(n){if(n===void 0)return n;if(pi(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Ds(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function qw(n,e,t){return{syntax:n,json:Lw(),bin:Jw(),util:Object.assign(Object.assign({},Vw()),{newFieldList:e,initFields:t}),makeMessageType(r,i,s){return vw(this,r,i,s)},makeEnum:yw,makeEnumType:Cp,getEnumType:pw,makeExtension(r,i,s){return xw(this,r,i,s)}}}class Kw{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function Jp(n,e){const t=$p(n);return e?t:Qw(Yw(t))}function Ww(n){return Jp(n,!1)}const Hw=$p;function $p(n){let e=!1;const t=[];for(let r=0;r`${n}$`,Yw=n=>Gw.has(n)?zp(n):n,Qw=n=>_w.has(n)?zp(n):n;class Xw{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ww(e)}addField(e){ce(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew Kw(n,e=>Zw(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=cs(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Fh;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Fh||(Fh={}));class Re extends O{constructor(e){super(),this.seconds=re.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=re.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Re.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Re({seconds:re.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Re().fromBinary(e,t)}static fromJson(e,t){return new Re().fromJson(e,t)}static fromJsonString(e,t){return new Re().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Re,e,t)}}Re.runtime=f;Re.typeName="google.protobuf.Timestamp";Re.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class fr extends O{constructor(e){super(),this.seconds=re.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=re.parse(i),typeof r[2]=="string"){const s=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(s),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new fr().fromBinary(e,t)}static fromJson(e,t){return new fr().fromJson(e,t)}static fromJsonString(e,t){return new fr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(fr,e,t)}}fr.runtime=f;fr.typeName="google.protobuf.Duration";fr.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Kt extends O{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=i.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const i=e["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(i),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const l=Object.assign({},e);delete l["@type"],a=o.fromJson(l,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Kt;return t.packFrom(e),t}static fromBinary(e,t){return new Kt().fromBinary(e,t)}static fromJson(e,t){return new Kt().fromJson(e,t)}static fromJsonString(e,t){return new Kt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Kt,e,t)}}Kt.runtime=f;Kt.typeName="google.protobuf.Any";Kt.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Wt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.DOUBLE,e)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Wt().fromBinary(e,t)}static fromJson(e,t){return new Wt().fromJson(e,t)}static fromJsonString(e,t){return new Wt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wt,e,t)}}Wt.runtime=f;Wt.typeName="google.protobuf.DoubleValue";Wt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Wt.fieldWrapper={wrapField(n){return new Wt({value:n})},unwrapField(n){return n.value}};class Ht extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.FLOAT,e)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Ht().fromBinary(e,t)}static fromJson(e,t){return new Ht().fromJson(e,t)}static fromJsonString(e,t){return new Ht().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ht,e,t)}}Ht.runtime=f;Ht.typeName="google.protobuf.FloatValue";Ht.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Ht.fieldWrapper={wrapField(n){return new Ht({value:n})},unwrapField(n){return n.value}};class _t extends O{constructor(e){super(),this.value=re.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT64,e)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new _t().fromBinary(e,t)}static fromJson(e,t){return new _t().fromJson(e,t)}static fromJsonString(e,t){return new _t().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_t,e,t)}}_t.runtime=f;_t.typeName="google.protobuf.Int64Value";_t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);_t.fieldWrapper={wrapField(n){return new _t({value:n})},unwrapField(n){return n.value}};class Gt extends O{constructor(e){super(),this.value=re.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT64,e)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Gt().fromBinary(e,t)}static fromJson(e,t){return new Gt().fromJson(e,t)}static fromJsonString(e,t){return new Gt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gt,e,t)}}Gt.runtime=f;Gt.typeName="google.protobuf.UInt64Value";Gt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Gt.fieldWrapper={wrapField(n){return new Gt({value:n})},unwrapField(n){return n.value}};class Yt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT32,e)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Yt().fromBinary(e,t)}static fromJson(e,t){return new Yt().fromJson(e,t)}static fromJsonString(e,t){return new Yt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Yt,e,t)}}Yt.runtime=f;Yt.typeName="google.protobuf.Int32Value";Yt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Yt.fieldWrapper={wrapField(n){return new Yt({value:n})},unwrapField(n){return n.value}};class Qt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT32,e)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qt().fromBinary(e,t)}static fromJson(e,t){return new Qt().fromJson(e,t)}static fromJsonString(e,t){return new Qt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qt,e,t)}}Qt.runtime=f;Qt.typeName="google.protobuf.UInt32Value";Qt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Qt.fieldWrapper={wrapField(n){return new Qt({value:n})},unwrapField(n){return n.value}};class Xt extends O{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BOOL,e)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xt().fromBinary(e,t)}static fromJson(e,t){return new Xt().fromJson(e,t)}static fromJsonString(e,t){return new Xt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xt,e,t)}}Xt.runtime=f;Xt.typeName="google.protobuf.BoolValue";Xt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Xt.fieldWrapper={wrapField(n){return new Xt({value:n})},unwrapField(n){return n.value}};class Qe extends O{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.STRING,e)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qe().fromBinary(e,t)}static fromJson(e,t){return new Qe().fromJson(e,t)}static fromJsonString(e,t){return new Qe().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qe,e,t)}}Qe.runtime=f;Qe.typeName="google.protobuf.StringValue";Qe.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Qe.fieldWrapper={wrapField(n){return new Qe({value:n})},unwrapField(n){return n.value}};class Zt extends O{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BYTES,e)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Zt().fromBinary(e,t)}static fromJson(e,t){return new Zt().fromJson(e,t)}static fromJsonString(e,t){return new Zt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zt,e,t)}}Zt.runtime=f;Zt.typeName="google.protobuf.BytesValue";Zt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Zt.fieldWrapper={wrapField(n){return new Zt({value:n})},unwrapField(n){return n.value}};function e1(n,e,t){try{const r=Wf.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw ne.from(r,_.DataLoss)}}function t1(n,e){const t={};for(const[r,i]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},i),{localName:r,service:n}));s!=null&&(t[r]=s)}return t}function Mh(n){let e,t=new Uint8Array(0);function r(i){const s=new Uint8Array(t.length+i.length);s.set(t),s.set(i,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(i){let s;for(;;){if(s===void 0&&t.byteLength>=5){let l=0;for(let c=1;c<5;c++)l=(l<<8)+t[c];s={flags:t[0],length:l}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(s===void 0){if(t.byteLength==0){i.close();return}i.error(new ne("premature end of stream",_.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),i.enqueue({flags:s.flags,data:o})}})}function Jh(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var n1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(c){s({value:c,done:a})},o)}},mo=function(n){return this instanceof mo?(this.v=n,this):new mo(n)},r1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof mo?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}},i1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:mo(n[i](o)),done:!1}:s?s(o):o}:s}};function s1(n){return r1(this,arguments,function*(){yield mo(yield*i1(n1(n)))})}var Up=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(c){s({value:c,done:a})},o)}},fs=function(n){return this instanceof fs?(this.v=n,this):new fs(n)},o1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:fs(n[i](o)),done:!1}:s?s(o):o}:s}},a1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof fs?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}};function l1(n,e){return t1(n,t=>{switch(t.kind){case Fe.Unary:return u1(e,n,t);case Fe.ServerStreaming:return c1(e,n,t);case Fe.ClientStreaming:return f1(e,n,t);case Fe.BiDiStreaming:return d1(e,n,t);default:return null}})}function u1(n,e,t){return async function(r,i){var s,o;const a=await n.unary(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(s=i==null?void 0:i.onHeader)===null||s===void 0||s.call(i,a.header),(o=i==null?void 0:i.onTrailer)===null||o===void 0||o.call(i,a.trailer),a.message}}function c1(n,e,t){return function(r,i){return jp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,s1([r]),i==null?void 0:i.contextValues),i)}}function f1(n,e,t){return async function(r,i){var s,o,a,l,c,d;const h=await n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(c=i==null?void 0:i.onHeader)===null||c===void 0||c.call(i,h.header);let m;try{for(var y=!0,w=Up(h.message),T;T=await w.next(),s=T.done,!s;y=!0)l=T.value,y=!1,m=l}catch(P){o={error:P}}finally{try{!y&&!s&&(a=w.return)&&await a.call(w)}finally{if(o)throw o.error}}if(!m)throw new ne("protocol error: missing response message",_.Internal);return(d=i==null?void 0:i.onTrailer)===null||d===void 0||d.call(i,h.trailer),m}}function d1(n,e,t){return function(r,i){return jp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function jp(n,e){const t=function(){var r,i;return a1(this,arguments,function*(){const s=yield fs(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,s.header),yield fs(yield*o1(Up(s.message))),(i=e==null?void 0:e.onTrailer)===null||i===void 0||i.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function h1(...n){const e=new AbortController,t=n.filter(i=>i!==void 0).concat(e.signal);for(const i of t){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(Vp(this));for(const i of t)i.removeEventListener("abort",r)}return e}function g1(n){const e=new AbortController,t=()=>{e.abort(new ne("the operation timed out",_.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function Vp(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function $h(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Tu=128;function zh(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r +`);for(const r of t){if(r==="")continue;const i=r.indexOf(":");if(i>0){const s=r.substring(0,i).trim(),o=r.substring(i+1).trim();e.append(s,o)}}return e}const m1="Content-Type",p1="Grpc-Timeout",qp="Grpc-Status",Kp="Grpc-Message",y1="Grpc-Status-Details-Bin",v1="X-User-Agent",w1="X-Grpc-Web",S1="application/grpc-web+proto",k1="application/grpc-web+json";class dr extends O{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new dr().fromBinary(e,t)}static fromJson(e,t){return new dr().fromJson(e,t)}static fromJsonString(e,t){return new dr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(dr,e,t)}}dr.runtime=f;dr.typeName="google.rpc.Status";dr.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Kt,repeated:!0}]);const T1="0";function Wp(n){var e;const t=n.get(y1);if(t!=null){const i=e1(t,dr);if(i.code==0)return;const s=new ne(i.message,i.code,n);return s.details=i.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const r=n.get(qp);if(r!=null){if(r===T1)return;const i=parseInt(r,10);return i in _?new ne(decodeURIComponent((e=n.get(Kp))!==null&&e!==void 0?e:""),i,n):new ne(`invalid grpc-status: ${r}`,_.Internal,n)}}function Uh(n,e,t){const r=typeof e=="string"?e:e.typeName,i=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${i}`)}function Hp(n,e){return e instanceof n?e:new n(e)}function A1(n,e){function t(r){return r.done===!0?r:{done:r.done,value:Hp(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),i={next:()=>r.next().then(t)};return r.throw!==void 0&&(i.throw=s=>r.throw(s).then(t)),r.return!==void 0&&(i.return=s=>r.return(s).then(t)),i}}}function _p(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,i)=>i(r),n))!==null&&t!==void 0?t:n}function I1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function jh(n,e,t,r){const i=e?Vh(n.I,r):qh(n.I,t);return{parse:(e?Vh(n.O,r):qh(n.O,t)).parse,serialize:i.serialize}}function Vh(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new ne(`parse binary: ${i}`,_.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new ne(`serialize binary: ${i}`,_.Internal)}}}}function qh(n,e){var t,r;const i=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=I1(e);return{parse(a){try{const l=s.decode(a);return n.fromJsonString(l,o)}catch(l){throw ne.from(l,_.InvalidArgument)}},serialize(a){try{const l=a.toJsonString(o);return i.encode(l)}catch(l){throw ne.from(l,_.Internal)}}}}function E1(n){const e=_p(n.next,n.interceptors),[t,r,i]=Gp(n),s=Object.assign(Object.assign({},n.req),{message:Hp(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(i(),o),r)}function x1(n){const e=_p(n.next,n.interceptors),[t,r,i]=Gp(n),s=Object.assign(Object.assign({},n.req),{message:A1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,l;const c=n.req.message[Symbol.asyncIterator]();o||(a=c.throw)===null||a===void 0||a.call(c,this.reason).catch(()=>{}),(l=c.return)===null||l===void 0||l.call(c).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const l=a.message[Symbol.asyncIterator]();return{next(){return l.next().then(c=>(c.done==!0&&(o=!0,i()),c),r)}}}}}),r)}function Gp(n){const{signal:e,cleanup:t}=g1(n.timeoutMs),r=h1(n.signal,e);return[r.signal,function(s){const o=ne.from(e.aborted?Vp(e):s);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function C1(){try{new Headers}catch{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.")}}function Kh(n,e){const t=Wp(n);if(t)throw e.forEach((r,i)=>{t.metadata.append(i,r)}),t}function Wh(n,e,t,r){const i=new Headers(t??{});return i.set(m1,n?S1:k1),i.set(w1,"1"),i.set(v1,"connect-es/1.4.0"),e!==void 0&&i.set(p1,`${e}m`),i}function N1(n){switch(n){case 400:return _.Internal;case 401:return _.Unauthenticated;case 403:return _.PermissionDenied;case 404:return _.Unimplemented;case 429:return _.Unavailable;case 502:return _.Unavailable;case 503:return _.Unavailable;case 504:return _.Unavailable;default:return _.Unknown}}function Hh(n,e){var t;if(n>=200&&n<300){const r=Wp(e);if(r)throw r;return{foundStatus:e.has(qp)}}throw new ne(decodeURIComponent((t=e.get(Kp))!==null&&t!==void 0?t:`HTTP ${n}`),N1(n),e)}var di=function(n){return this instanceof di?(this.v=n,this):new di(n)},P1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||l(y,T)})},w&&(i[y]=w(i[y])))}function l(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof di?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){l("next",y)}function h(y){l("throw",y)}function m(y,w){y(w),s.shift(),s.length&&l(s[0][0],s[0][1])}};function D1(n){var e;C1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,i,s,o,a,l,c){var d;const{serialize:h,parse:m}=jh(i,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await E1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:r,method:i,url:Uh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Wh(t,o,a),contextValues:c??$h(),message:l},next:async y=>{var w;const P=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(y.url,Object.assign(Object.assign({},y.init),{headers:y.header,signal:y.signal,body:Jh(0,h(y.message))}));if(Hh(P.status,P.headers),!P.body)throw"missing response body";const p=Mh(P.body).getReader();let g,v;for(;;){const I=await p.read();if(I.done)break;const{flags:E,data:N}=I.value;if(E===Tu){if(g!==void 0)throw"extra trailer";g=zh(N);continue}if(v!==void 0)throw"extra message";v=m(N)}if(g===void 0)throw"missing trailer";if(Kh(g,P.headers),v===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:P.headers,message:v,trailer:g}}})},async stream(r,i,s,o,a,l,c){var d;const{serialize:h,parse:m}=jh(i,t,n.jsonOptions,n.binaryOptions);function y(T,P,p,g){return P1(this,arguments,function*(){const I=Mh(T).getReader();if(P){if(!(yield di(I.read())).done)throw"extra data for trailers-only";return yield di(void 0)}let E=!1;for(;;){const N=yield di(I.read());if(N.done)break;const{flags:D,data:R}=N.value;if((D&Tu)===Tu){if(E)throw"extra trailer";E=!0;const q=zh(R);Kh(q,g),q.forEach(($,Se)=>p.set(Se,$));continue}if(E)throw"extra message";yield yield di(m(R))}if(!E)throw"missing trailer"})}async function w(T){if(i.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const P=await T[Symbol.asyncIterator]().next();if(P.done==!0)throw"missing request message";return Jh(0,h(P.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,x1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:r,method:i,url:Uh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Wh(t,o,a),contextValues:c??$h(),message:l},next:async T=>{var P;const g=await((P=n.fetch)!==null&&P!==void 0?P:globalThis.fetch)(T.url,Object.assign(Object.assign({},T.init),{headers:T.header,signal:T.signal,body:await w(T.message)})),{foundStatus:v}=Hh(g.status,g.headers);if(!g.body)throw"missing response body";const I=new Headers;return Object.assign(Object.assign({},T),{header:g.headers,trailer:I,message:y(g.body,v,I,g.headers)})}})}}}var z=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(z||{});f.util.setEnumType(z,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var yi=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(yi||{});f.util.setEnumType(yi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const an=class an extends O{constructor(t){super();u(this,"root");u(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new an().fromBinary(t,r)}static fromJson(t,r){return new an().fromJson(t,r)}static fromJsonString(t,r){return new an().fromJsonString(t,r)}static equals(t,r){return f.util.equals(an,t,r)}};u(an,"runtime",f),u(an,"typeName","yorkie.v1.Snapshot"),u(an,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:_e},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:_f}}]));let Tc=an;var lt;let Ir=(lt=class extends O{constructor(t){super();u(this,"documentKey","");u(this,"checkpoint");u(this,"snapshot",new Uint8Array(0));u(this,"changes",[]);u(this,"minSyncedTicket");u(this,"isRemoved",!1);u(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new lt().fromBinary(t,r)}static fromJson(t,r){return new lt().fromJson(t,r)}static fromJsonString(t,r){return new lt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(lt,t,r)}},u(lt,"runtime",f),u(lt,"typeName","yorkie.v1.ChangePack"),u(lt,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Xp},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Yp,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:b},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Ml}])),lt);var ut;let Yp=(ut=class extends O{constructor(t){super();u(this,"id");u(this,"message","");u(this,"operations",[]);u(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new ut().fromBinary(t,r)}static fromJson(t,r){return new ut().fromJson(t,r)}static fromJsonString(t,r){return new ut().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ut,t,r)}},u(ut,"runtime",f),u(ut,"typeName","yorkie.v1.Change"),u(ut,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Fl},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Hf,repeated:!0},{no:4,name:"presence_change",kind:"message",T:vo}])),ut);var ct;let Fl=(ct=class extends O{constructor(t){super();u(this,"clientSeq",0);u(this,"serverSeq",re.zero);u(this,"lamport",re.zero);u(this,"actorId",new Uint8Array(0));u(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ct().fromBinary(t,r)}static fromJson(t,r){return new ct().fromJson(t,r)}static fromJsonString(t,r){return new ct().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ct,t,r)}},u(ct,"runtime",f),u(ct,"typeName","yorkie.v1.ChangeID"),u(ct,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Ml}])),ct);var ft;let Ml=(ft=class extends O{constructor(t){super();u(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new ft().fromBinary(t,r)}static fromJson(t,r){return new ft().fromJson(t,r)}static fromJsonString(t,r){return new ft().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ft,t,r)}},u(ft,"runtime",f),u(ft,"typeName","yorkie.v1.VersionVector"),u(ft,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),ft);var dt;let Hf=(dt=class extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new dt().fromBinary(t,r)}static fromJson(t,r){return new dt().fromJson(t,r)}static fromJsonString(t,r){return new dt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dt,t,r)}},u(dt,"runtime",f),u(dt,"typeName","yorkie.v1.Operation"),u(dt,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Qa,oneof:"body"},{no:2,name:"add",kind:"message",T:Xa,oneof:"body"},{no:3,name:"move",kind:"message",T:Za,oneof:"body"},{no:4,name:"remove",kind:"message",T:el,oneof:"body"},{no:5,name:"edit",kind:"message",T:tl,oneof:"body"},{no:6,name:"select",kind:"message",T:Ac,oneof:"body"},{no:7,name:"style",kind:"message",T:nl,oneof:"body"},{no:8,name:"increase",kind:"message",T:rl,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:il,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:sl,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Ic,oneof:"body"}])),dt);const ln=class ln extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"key","");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};u(ln,"runtime",f),u(ln,"typeName","yorkie.v1.Operation.Set"),u(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Qa=ln;const un=class un extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"prevCreatedAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};u(un,"runtime",f),u(un,"typeName","yorkie.v1.Operation.Add"),u(un,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Xa=un;const cn=class cn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"prevCreatedAt");u(this,"createdAt");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};u(cn,"runtime",f),u(cn,"typeName","yorkie.v1.Operation.Move"),u(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"executed_at",kind:"message",T:b}]));let Za=cn;const fn=class fn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"createdAt");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};u(fn,"runtime",f),u(fn,"typeName","yorkie.v1.Operation.Remove"),u(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"executed_at",kind:"message",T:b}]));let el=fn;const dn=class dn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"createdAtMapByActor",{});u(this,"content","");u(this,"executedAt");u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};u(dn,"runtime",f),u(dn,"typeName","yorkie.v1.Operation.Edit"),u(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:b},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let tl=dn;const hn=class hn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};u(hn,"runtime",f),u(hn,"typeName","yorkie.v1.Operation.Select"),u(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"executed_at",kind:"message",T:b}]));let Ac=hn;const gn=class gn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"attributes",{});u(this,"executedAt");u(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};u(gn,"runtime",f),u(gn,"typeName","yorkie.v1.Operation.Style"),u(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:kr},{no:3,name:"to",kind:"message",T:kr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let nl=gn;const mn=class mn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};u(mn,"runtime",f),u(mn,"typeName","yorkie.v1.Operation.Increase"),u(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"value",kind:"message",T:at},{no:3,name:"executed_at",kind:"message",T:b}]));let rl=mn;const pn=class pn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"createdAtMapByActor",{});u(this,"contents",[]);u(this,"splitLevel",0);u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};u(pn,"runtime",f),u(pn,"typeName","yorkie.v1.Operation.TreeEdit"),u(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ai},{no:3,name:"to",kind:"message",T:Ai},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"contents",kind:"message",T:gl,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:b}]));let il=pn;const yn=class yn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"from");u(this,"to");u(this,"attributes",{});u(this,"executedAt");u(this,"attributesToRemove",[]);u(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};u(yn,"runtime",f),u(yn,"typeName","yorkie.v1.Operation.TreeStyle"),u(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ai},{no:3,name:"to",kind:"message",T:Ai},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let sl=yn;const vn=class vn extends O{constructor(t){super();u(this,"parentCreatedAt");u(this,"createdAt");u(this,"value");u(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};u(vn,"runtime",f),u(vn,"typeName","yorkie.v1.Operation.ArraySet"),u(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:at},{no:4,name:"executed_at",kind:"message",T:b}]));let Ic=vn;const wn=class wn extends O{constructor(t){super();u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");u(this,"type",0);u(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};u(wn,"runtime",f),u(wn,"typeName","yorkie.v1.JSONElementSimple"),u(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"moved_at",kind:"message",T:b},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"type",kind:"enum",T:f.getEnumType(z)},{no:5,name:"value",kind:"scalar",T:12}]));let at=wn;const Sn=class Sn extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};u(Sn,"runtime",f),u(Sn,"typeName","yorkie.v1.JSONElement"),u(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:ol,oneof:"body"},{no:2,name:"json_array",kind:"message",T:al,oneof:"body"},{no:3,name:"primitive",kind:"message",T:ll,oneof:"body"},{no:5,name:"text",kind:"message",T:ul,oneof:"body"},{no:6,name:"counter",kind:"message",T:cl,oneof:"body"},{no:7,name:"tree",kind:"message",T:fl,oneof:"body"}]));let _e=Sn;const kn=class kn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};u(kn,"runtime",f),u(kn,"typeName","yorkie.v1.JSONElement.JSONObject"),u(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Qp,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ol=kn;const Tn=class Tn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};u(Tn,"runtime",f),u(Tn,"typeName","yorkie.v1.JSONElement.JSONArray"),u(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:dl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let al=Tn;const An=class An extends O{constructor(t){super();u(this,"type",0);u(this,"value",new Uint8Array(0));u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};u(An,"runtime",f),u(An,"typeName","yorkie.v1.JSONElement.Primitive"),u(An,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let ll=An;const In=class In extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};u(In,"runtime",f),u(In,"typeName","yorkie.v1.JSONElement.Text"),u(In,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:hl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ul=In;const En=class En extends O{constructor(t){super();u(this,"type",0);u(this,"value",new Uint8Array(0));u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};u(En,"runtime",f),u(En,"typeName","yorkie.v1.JSONElement.Counter"),u(En,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let cl=En;const xn=class xn extends O{constructor(t){super();u(this,"nodes",[]);u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};u(xn,"runtime",f),u(xn,"typeName","yorkie.v1.JSONElement.Tree"),u(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yo,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let fl=xn;var ht;let Qp=(ht=class extends O{constructor(t){super();u(this,"key","");u(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new ht().fromBinary(t,r)}static fromJson(t,r){return new ht().fromJson(t,r)}static fromJsonString(t,r){return new ht().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ht,t,r)}},u(ht,"runtime",f),u(ht,"typeName","yorkie.v1.RHTNode"),u(ht,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:_e}])),ht);const jt=class jt extends O{constructor(t){super();u(this,"next");u(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new jt().fromBinary(t,r)}static fromJson(t,r){return new jt().fromJson(t,r)}static fromJsonString(t,r){return new jt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jt,t,r)}};u(jt,"runtime",f),u(jt,"typeName","yorkie.v1.RGANode"),u(jt,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:jt},{no:2,name:"element",kind:"message",T:_e}]));let dl=jt;const Cn=class Cn extends O{constructor(t){super();u(this,"value","");u(this,"updatedAt");u(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};u(Cn,"runtime",f),u(Cn,"typeName","yorkie.v1.NodeAttr"),u(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:b},{no:3,name:"is_removed",kind:"scalar",T:8}]));let ds=Cn;const Nn=class Nn extends O{constructor(t){super();u(this,"id");u(this,"value","");u(this,"removedAt");u(this,"insPrevId");u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};u(Nn,"runtime",f),u(Nn,"typeName","yorkie.v1.TextNode"),u(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:po},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"ins_prev_id",kind:"message",T:po},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ds}}]));let hl=Nn;const Pn=class Pn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};u(Pn,"runtime",f),u(Pn,"typeName","yorkie.v1.TextNodeID"),u(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let po=Pn;const Dn=class Dn extends O{constructor(t){super();u(this,"id");u(this,"type","");u(this,"value","");u(this,"removedAt");u(this,"insPrevId");u(this,"insNextId");u(this,"depth",0);u(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};u(Dn,"runtime",f),u(Dn,"typeName","yorkie.v1.TreeNode"),u(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Wr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:b},{no:5,name:"ins_prev_id",kind:"message",T:Wr},{no:6,name:"ins_next_id",kind:"message",T:Wr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:ds}}]));let yo=Dn;const On=class On extends O{constructor(t){super();u(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};u(On,"runtime",f),u(On,"typeName","yorkie.v1.TreeNodes"),u(On,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:yo,repeated:!0}]));let gl=On;const Rn=class Rn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};u(Rn,"runtime",f),u(Rn,"typeName","yorkie.v1.TreeNodeID"),u(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let Wr=Rn;const Ln=class Ln extends O{constructor(t){super();u(this,"parentId");u(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};u(Ln,"runtime",f),u(Ln,"typeName","yorkie.v1.TreePos"),u(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:Wr},{no:2,name:"left_sibling_id",kind:"message",T:Wr}]));let Ai=Ln;const Bn=class Bn extends O{constructor(t){super();u(this,"id","");u(this,"username","");u(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};u(Bn,"runtime",f),u(Bn,"typeName","yorkie.v1.User"),u(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Re}]));let _h=Bn;const bn=class bn extends O{constructor(t){super();u(this,"id","");u(this,"name","");u(this,"publicKey","");u(this,"secretKey","");u(this,"authWebhookUrl","");u(this,"authWebhookMethods",[]);u(this,"clientDeactivateThreshold","");u(this,"createdAt");u(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};u(bn,"runtime",f),u(bn,"typeName","yorkie.v1.Project"),u(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Re},{no:9,name:"updated_at",kind:"message",T:Re}]));let Gh=bn;const Fn=class Fn extends O{constructor(t){super();u(this,"name");u(this,"authWebhookUrl");u(this,"authWebhookMethods");u(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new Fn().fromBinary(t,r)}static fromJson(t,r){return new Fn().fromJson(t,r)}static fromJsonString(t,r){return new Fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Fn,t,r)}};u(Fn,"runtime",f),u(Fn,"typeName","yorkie.v1.UpdatableProjectFields"),u(Fn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Qe},{no:2,name:"auth_webhook_url",kind:"message",T:Qe},{no:3,name:"auth_webhook_methods",kind:"message",T:Ec},{no:4,name:"client_deactivate_threshold",kind:"message",T:Qe}]));let Yh=Fn;const Mn=class Mn extends O{constructor(t){super();u(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};u(Mn,"runtime",f),u(Mn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),u(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Ec=Mn;const Jn=class Jn extends O{constructor(t){super();u(this,"id","");u(this,"key","");u(this,"snapshot","");u(this,"createdAt");u(this,"accessedAt");u(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};u(Jn,"runtime",f),u(Jn,"typeName","yorkie.v1.DocumentSummary"),u(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Re},{no:5,name:"accessed_at",kind:"message",T:Re},{no:6,name:"updated_at",kind:"message",T:Re}]));let Qh=Jn;const $n=class $n extends O{constructor(t){super();u(this,"type",0);u(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};u($n,"runtime",f),u($n,"typeName","yorkie.v1.PresenceChange"),u($n,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(Ii)},{no:2,name:"presence",kind:"message",T:_f}]));let vo=$n;var Ii=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Ii||{});f.util.setEnumType(Ii,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var gt;let _f=(gt=class extends O{constructor(t){super();u(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new gt().fromBinary(t,r)}static fromJson(t,r){return new gt().fromJson(t,r)}static fromJsonString(t,r){return new gt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gt,t,r)}},u(gt,"runtime",f),u(gt,"typeName","yorkie.v1.Presence"),u(gt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),gt);var mt;let Xp=(mt=class extends O{constructor(t){super();u(this,"serverSeq",re.zero);u(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new mt().fromBinary(t,r)}static fromJson(t,r){return new mt().fromJson(t,r)}static fromJsonString(t,r){return new mt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mt,t,r)}},u(mt,"runtime",f),u(mt,"typeName","yorkie.v1.Checkpoint"),u(mt,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),mt);const zn=class zn extends O{constructor(t){super();u(this,"createdAt");u(this,"offset",0);u(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};u(zn,"runtime",f),u(zn,"typeName","yorkie.v1.TextNodePos"),u(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let kr=zn;var pt;let b=(pt=class extends O{constructor(t){super();u(this,"lamport",re.zero);u(this,"delimiter",0);u(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new pt().fromBinary(t,r)}static fromJson(t,r){return new pt().fromJson(t,r)}static fromJsonString(t,r){return new pt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pt,t,r)}},u(pt,"runtime",f),u(pt,"typeName","yorkie.v1.TimeTicket"),u(pt,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),pt);const Un=class Un extends O{constructor(t){super();u(this,"topic","");u(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};u(Un,"runtime",f),u(Un,"typeName","yorkie.v1.DocEventBody"),u(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let xc=Un;const jn=class jn extends O{constructor(t){super();u(this,"type",0);u(this,"publisher","");u(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};u(jn,"runtime",f),u(jn,"typeName","yorkie.v1.DocEvent"),u(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(yi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:xc}]));let Cc=jn;const Vn=class Vn extends O{constructor(t){super();u(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};u(Vn,"runtime",f),u(Vn,"typeName","yorkie.v1.ActivateClientRequest"),u(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Nc=Vn;const qn=class qn extends O{constructor(t){super();u(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};u(qn,"runtime",f),u(qn,"typeName","yorkie.v1.ActivateClientResponse"),u(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Pc=qn;const Kn=class Kn extends O{constructor(t){super();u(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};u(Kn,"runtime",f),u(Kn,"typeName","yorkie.v1.DeactivateClientRequest"),u(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Dc=Kn;const Wn=class Wn extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Wn().fromBinary(e,t)}static fromJson(e,t){return new Wn().fromJson(e,t)}static fromJsonString(e,t){return new Wn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wn,e,t)}};u(Wn,"runtime",f),u(Wn,"typeName","yorkie.v1.DeactivateClientResponse"),u(Wn,"fields",f.util.newFieldList(()=>[]));let Oc=Wn;const Hn=class Hn extends O{constructor(t){super();u(this,"clientId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};u(Hn,"runtime",f),u(Hn,"typeName","yorkie.v1.AttachDocumentRequest"),u(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Ir}]));let Rc=Hn;const _n=class _n extends O{constructor(t){super();u(this,"documentId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new _n().fromBinary(t,r)}static fromJson(t,r){return new _n().fromJson(t,r)}static fromJsonString(t,r){return new _n().fromJsonString(t,r)}static equals(t,r){return f.util.equals(_n,t,r)}};u(_n,"runtime",f),u(_n,"typeName","yorkie.v1.AttachDocumentResponse"),u(_n,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Ir}]));let Lc=_n;const Gn=class Gn extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");u(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Gn().fromBinary(t,r)}static fromJson(t,r){return new Gn().fromJson(t,r)}static fromJsonString(t,r){return new Gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Gn,t,r)}};u(Gn,"runtime",f),u(Gn,"typeName","yorkie.v1.DetachDocumentRequest"),u(Gn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let Bc=Gn;const Yn=class Yn extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Yn().fromBinary(t,r)}static fromJson(t,r){return new Yn().fromJson(t,r)}static fromJsonString(t,r){return new Yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yn,t,r)}};u(Yn,"runtime",f),u(Yn,"typeName","yorkie.v1.DetachDocumentResponse"),u(Yn,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Ir}]));let bc=Yn;const Qn=class Qn extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qn().fromBinary(t,r)}static fromJson(t,r){return new Qn().fromJson(t,r)}static fromJsonString(t,r){return new Qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qn,t,r)}};u(Qn,"runtime",f),u(Qn,"typeName","yorkie.v1.WatchDocumentRequest"),u(Qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Fc=Qn;const Xn=class Xn extends O{constructor(t){super();u(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Xn().fromBinary(t,r)}static fromJson(t,r){return new Xn().fromJson(t,r)}static fromJsonString(t,r){return new Xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xn,t,r)}};u(Xn,"runtime",f),u(Xn,"typeName","yorkie.v1.WatchDocumentResponse"),u(Xn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Jc,oneof:"body"},{no:2,name:"event",kind:"message",T:Cc,oneof:"body"}]));let Mc=Xn;const Zn=class Zn extends O{constructor(t){super();u(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Zn().fromBinary(t,r)}static fromJson(t,r){return new Zn().fromJson(t,r)}static fromJsonString(t,r){return new Zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zn,t,r)}};u(Zn,"runtime",f),u(Zn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),u(Zn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Jc=Zn;const er=class er extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new er().fromBinary(t,r)}static fromJson(t,r){return new er().fromJson(t,r)}static fromJsonString(t,r){return new er().fromJsonString(t,r)}static equals(t,r){return f.util.equals(er,t,r)}};u(er,"runtime",f),u(er,"typeName","yorkie.v1.RemoveDocumentRequest"),u(er,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir}]));let $c=er;const tr=class tr extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new tr().fromBinary(t,r)}static fromJson(t,r){return new tr().fromJson(t,r)}static fromJsonString(t,r){return new tr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tr,t,r)}};u(tr,"runtime",f),u(tr,"typeName","yorkie.v1.RemoveDocumentResponse"),u(tr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Ir}]));let zc=tr;const nr=class nr extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"changePack");u(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new nr().fromBinary(t,r)}static fromJson(t,r){return new nr().fromJson(t,r)}static fromJsonString(t,r){return new nr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nr,t,r)}};u(nr,"runtime",f),u(nr,"typeName","yorkie.v1.PushPullChangesRequest"),u(nr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Ir},{no:4,name:"push_only",kind:"scalar",T:8}]));let Uc=nr;const rr=class rr extends O{constructor(t){super();u(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new rr().fromBinary(t,r)}static fromJson(t,r){return new rr().fromJson(t,r)}static fromJsonString(t,r){return new rr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rr,t,r)}};u(rr,"runtime",f),u(rr,"typeName","yorkie.v1.PushPullChangesResponse"),u(rr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Ir}]));let jc=rr;const ir=class ir extends O{constructor(t){super();u(this,"clientId","");u(this,"documentId","");u(this,"topic","");u(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new ir().fromBinary(t,r)}static fromJson(t,r){return new ir().fromJson(t,r)}static fromJsonString(t,r){return new ir().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ir,t,r)}};u(ir,"runtime",f),u(ir,"typeName","yorkie.v1.BroadcastRequest"),u(ir,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Vc=ir;const sr=class sr extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new sr().fromBinary(e,t)}static fromJson(e,t){return new sr().fromJson(e,t)}static fromJsonString(e,t){return new sr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(sr,e,t)}};u(sr,"runtime",f),u(sr,"typeName","yorkie.v1.BroadcastResponse"),u(sr,"fields",f.util.newFieldList(()=>[]));let qc=sr;const O1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Nc,O:Pc,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:Dc,O:Oc,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:Rc,O:Lc,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:Bc,O:bc,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:$c,O:zc,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:Uc,O:jc,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:Fc,O:Mc,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:Vc,O:qc,kind:Fe.Unary}}},R1=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:fr}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:L1,repeated:!0}]);const L1=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:B1,repeated:!0}]);const B1=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:b1,repeated:!0}]);const b1=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var S=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(S||{});class k extends Error{constructor(t,r){super(r);u(this,"name","YorkieError");u(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Nt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const Zp=n=>n?Object.entries(n).length===0:!0,hs=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},es=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Xr=(n=>(n.Put="put",n.Clear="clear",n))(Xr||{});class Au{constructor(e,t){u(this,"context");u(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:Nt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Jl="000000000000000000000000";class kt{constructor(e,t,r){u(this,"lamport");u(this,"delimiter");u(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new kt(e,t,r)}static fromStruct(e){return kt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new kt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const ey=0,_s=9223372036854775807n,bt=new kt(0n,ey,Jl);function en(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}class Do{constructor(e){u(this,"createdAt");u(this,"movedAt");u(this,"removedAt");this.createdAt=e}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!this.movedAt||e&&e.after(this.movedAt)?(this.movedAt=e,!0):!1}setRemovedAt(e){this.removedAt=e}remove(e){return e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt))?(this.removedAt=e,!0):!1}isRemoved(){return!!this.removedAt}}class Hr extends Do{constructor(e){super(e)}}class Gf{constructor(e,t){u(this,"strKey");u(this,"value");this.strKey=e,this.value=t}static of(e,t){return new Gf(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}}class wo{constructor(){u(this,"nodeMapByKey");u(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new wo}set(e,t,r){let i;const s=this.nodeMapByKey.get(e);s!=null&&!s.isRemoved()&&s.remove(r)&&(i=s.getValue());const o=Gf.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),o),(s==null||r.after(s.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,o),t.setMovedAt(r)),i}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new k(S.ErrInvalidArgument,`fail to find ${e.toIDString()}`);const r=this.nodeMapByCreatedAt.get(e.toIDString());return r.remove(t),r.getValue()}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find ${e.getCreatedAt().toIDString()}`);const r=this.nodeMapByKey.get(t.getStrKey());t===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){const r=this.nodeMapByKey.get(e);if(r!=null&&r.remove(t))return r.getValue()}has(e){const t=this.nodeMapByKey.get(e);return t==null?!1:!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){const t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(const[,e]of this.nodeMapByKey)yield e}}class He extends Hr{constructor(t,r){super(t);u(this,"memberNodes");this.memberNodes=r}static create(t,r){if(!r)return new He(t,wo.create());const i=wo.create();for(const[s,o]of Object.entries(r))i.set(s,o.deepcopy(),o.getCreatedAt());return new He(t,i)}subPathOf(t){return this.memberNodes.subPathOf(t)}purge(t){this.memberNodes.purge(t)}set(t,r,i){return this.memberNodes.set(t,r,i)}delete(t,r){return this.memberNodes.delete(t,r)}deleteByKey(t,r){return this.memberNodes.deleteByKey(t,r)}get(t){const r=this.memberNodes.get(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.memberNodes.getByID(t);return r==null?void 0:r.getValue()}has(t){return this.memberNodes.has(t)}toJSON(){const t=[];for(const[r,i]of this)t.push(`"${en(r)}":${i.toJSON()}`);return`{${t.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(const[r,i]of this){const{createdAt:s,value:o,type:a}=i.toJSForTest();t[r]={key:r,createdAt:s,value:o,type:a}}return{createdAt:this.getCreatedAt().toTestString(),value:t,type:"YORKIE_OBJECT"}}getKeys(){const t=Array();for(const[r]of this)t.push(r);return t}toSortedJSON(){var i;const t=Array();for(const[s]of this)t.push(s);const r=[];for(const s of t.sort()){const o=(i=this.memberNodes.get(s))==null?void 0:i.getValue();r.push(`"${en(s)}":${o.toSortedJSON()}`)}return`{${r.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const t=He.create(this.getCreatedAt());for(const r of this.memberNodes)t.memberNodes.set(r.getStrKey(),r.getValue().deepcopy(),this.getPositionedAt());return t.remove(this.getRemovedAt()),t}getDescendants(t){for(const r of this.memberNodes){const i=r.getValue();if(t(i,this))return;i instanceof Hr&&i.getDescendants(t)}}*[Symbol.iterator](){const t=new Set;for(const r of this.memberNodes)t.has(r.getStrKey())||(t.add(r.getStrKey()),r.isRemoved()||(yield[r.getStrKey(),r.getValue()]))}}var Y=(n=>(n.Local="local",n.Remote="remote",n.UndoRedo="undoredo",n))(Y||{});class Jt{constructor(e,t){u(this,"parentCreatedAt");u(this,"executedAt");this.parentCreatedAt=e,this.executedAt=t}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new k(S.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}}class ty{constructor(e){u(this,"value");u(this,"left");u(this,"right");u(this,"parent");u(this,"weight");this.value=e,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}}class So{constructor(e){u(this,"root");this.root=e}get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new k(S.ErrInvalidArgument,`out of index range: pos: ${e} > node.length: ${t.getLength()}`);return this.splayNode(t),[t,e]}indexOf(e){return!e||e!==this.root&&!e.hasLinks()?-1:(this.splayNode(e),this.root.getLeftWeight())}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t),t):(this.root=t,t)}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);const t=new So(e.getLeft());t.root&&t.root.setParent();const r=new So(e.getRight());if(r.root&&r.root.setParent(),t.root){const i=t.getRightmost();t.splayNode(i),t.root.setRight(r.root),r.root&&r.root.setParent(t.root),this.root=t.root}else this.root=r.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){const t=[];this.traversePostorder(e.getRight(),t);for(const r of t)r.initWeight();this.updateTreeWeight(e)}toTestString(){const e=[];return this.traverseInorder(this.root,e),e.map(t=>`[${t.getWeight()},${t.getLength()}]${t.getValue()||""}`).join("")}checkWeight(){const e=[];this.traverseInorder(this.root,e);for(const t of e)if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return e&&e.hasParent()?e.getParent().getLeft()===e:!1}isRightChild(e){return e&&e.hasParent()?e.getParent().getRight()===e:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -58,9 +58,9 @@ Error generating stack: `+s.message+` * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var vt=null;try{vt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function K(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});function Be(n){return(n&&n.__isLong__)===!0}function Xh(n){var e=Math.clz32(n&-n);return n?31-e:e}K.isLong=Be;var Zh={},eg={};function Ni(n,e){var t,r,i;return e?(n>>>=0,(i=0<=n&&n<256)&&(r=eg[n],r)?r:(t=H(n,0,!0),i&&(eg[n]=t),t)):(n|=0,(i=-128<=n&&n<128)&&(r=Zh[n],r)?r:(t=H(n,n<0?-1:0,!1),i&&(Zh[n]=t),t))}K.fromInt=Ni;function wt(n,e){if(isNaN(n))return e?hr:Ot;if(e){if(n<0)return hr;if(n>=ny)return sy}else{if(n<=-ng)return Ve;if(n+1>=ng)return iy}return n<0?wt(-n,e).neg():H(n%gs|0,n/gs|0,e)}K.fromNumber=wt;function H(n,e,t){return new K(n,e,t)}K.fromBits=H;var ml=Math.pow;function Yf(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?hr:Ot;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return Yf(n.substring(1),e,t).neg();for(var i=wt(ml(t,8)),s=Ot,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*gs+(this.low>>>0):this.high*gs+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,d=c.toString(e);if(o=l,o.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ve)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return Be(e)||(e=$t(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(Be(e)||(e=$t(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(Ve)?Ve:this.not().add(Wi)};C.neg=C.negate;C.add=function(e){Be(e)||(e=$t(e));var t=this.high>>>16,r=this.high&65535,i=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,d=0,h=0,m=0,y=0;return y+=s+c,m+=y>>>16,y&=65535,m+=i+l,h+=m>>>16,m&=65535,h+=r+a,d+=h>>>16,h&=65535,d+=t+o,d&=65535,H(m<<16|y,d<<16|h,this.unsigned)};C.subtract=function(e){return Be(e)||(e=$t(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(Be(e)||(e=$t(e)),vt){var t=vt.mul(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?hr:Ot;if(this.eq(Ve))return e.isOdd()?Ve:Ot;if(e.eq(Ve))return this.isOdd()?Ve:Ot;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(rg)&&e.lt(rg))return wt(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,d=e.low&65535,h=0,m=0,y=0,w=0;return w+=o*d,y+=w>>>16,w&=65535,y+=s*d,m+=y>>>16,y&=65535,y+=o*c,m+=y>>>16,y&=65535,m+=i*d,h+=m>>>16,m&=65535,m+=s*c,h+=m>>>16,m&=65535,m+=o*l,h+=m>>>16,m&=65535,h+=r*d+i*c+s*l+o*a,h&=65535,H(y<<16|w,h<<16|m,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(Be(e)||(e=$t(e)),e.isZero())throw Error("division by zero");if(vt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?vt.div_u:vt.div_s)(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?hr:Ot;var r,i,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return hr;if(e.gt(this.shru(1)))return ry;s=hr}else{if(this.eq(Ve)){if(e.eq(Wi)||e.eq(qc))return Ve;if(e.eq(Ve))return Wi;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Ot)?e.isNegative()?Wi:qc:(i=this.sub(e.mul(r)),s=r.add(i.div(e)),s)}else if(e.eq(Ve))return this.unsigned?hr:Ot;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Ot}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),l=a<=48?1:ml(2,a-48),c=wt(r),d=c.mul(e);d.isNegative()||d.gt(i);)r-=l,c=wt(r,this.unsigned),d=c.mul(e);c.isZero()&&(c=Wi),s=s.add(c),i=i.sub(d)}return s};C.div=C.divide;C.modulo=function(e){if(Be(e)||(e=$t(e)),vt){var t=(this.unsigned?vt.rem_u:vt.rem_s)(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return H(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?Xh(this.low):Xh(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return Be(e)||(e=$t(e)),H(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return Be(e)||(e=$t(e)),H(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return Be(e)||(e=$t(e)),H(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?H(this.low<>>32-e,this.unsigned):H(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):H(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?H(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?H(this.high,0,this.unsigned):H(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?H(this.high,this.low,this.unsigned):e<32?(t=32-e,H(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,H(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?H(this.high,this.low,this.unsigned):e<32?(t=32-e,H(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,H(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?H(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:H(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};K.fromBytes=function(e,t,r){return r?K.fromBytesLE(e,t):K.fromBytesBE(e,t)};K.fromBytesLE=function(e,t){return new K(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};K.fromBytesBE=function(e,t){return new K(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var ve=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(ve||{});class se extends Do{constructor(t,r){super(r);u(this,"valueType");u(this,"value");this.valueType=se.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new se(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(s,o){i.setUint8(o,s)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return K.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(K.fromBytesLE(Array.from(r),!0).toNumber());default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${en(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=se.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof K)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return se.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=K.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class pl extends ty{constructor(t){super(t);u(this,"prev");u(this,"next");this.value=t}static createAfter(t,r){const i=new pl(r),s=t.next;return t.next=i,i.prev=t,i.next=s,s&&(s.prev=i),i}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class ko{constructor(){u(this,"dummyHead");u(this,"last");u(this,"nodeMapByIndex");u(this,"nodeMapByCreatedAt");const e=se.of(0,bt);e.setRemovedAt(bt),this.dummyHead=new pl(e),this.last=this.dummyHead,this.nodeMapByIndex=new So,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new ko}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const i=this.findNextBeforeExecutedAt(e,r),s=pl.createAfter(i,t);i===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(i,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,r){const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new k(S.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);i!==s&&(!s.getValue().getMovedAt()||r.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(i.getCreatedAt(),s.getValue(),r),s.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let i=t;if(e===0&&t===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),i=r.isRemoved();return r.remove(t)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class et extends Hr{constructor(t,r){super(t);u(this,"elements");this.elements=r}static create(t,r){if(!r)return new et(t,ko.create());const i=ko.create();for(const s of r)i.insertAfter(i.getLastCreatedAt(),s.deepcopy());return new et(t,i)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,i){this.elements.moveAfter(t,r,i)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const i=r.getValue();if(t(i,this))return;i instanceof Hr&&i.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...w,value:w.value?{attributes:es(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[d,y,h,[c,c]]}setStyle(t,r,i,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],i),[,l]=this.rgaTreeSplit.findNodeWithSplit(t[0],i),c=[],d=this.rgaTreeSplit.findBetween(l,a),h=new Map,m=[];for(const w of d){const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=_s:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):bt,w.canStyle(i,P,p)){const g=h.get(T),v=w.getCreatedAt();(!g||v.after(g))&&h.set(T,v),m.push(w)}}const y=[];for(const w of m){if(w.isRemoved())continue;const[T,P]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());c.push({type:"style",actor:i.getActorID(),from:T,to:P,value:{attributes:es(r)}});for(const[p,g]of Object.entries(r)){const[v]=w.getValue().setAttr(p,g,i);v!==void 0&&y.push({parent:w.getValue(),child:v})}}return[h,y,c]}indexRangeToPosRange(t,r){const i=this.rgaTreeSplit.indexToPos(t);return t===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();t.push({attributes:es(i.getAttributes()),content:i.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new It(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())t.push(i)}return t}}class Ro extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"content");u(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,r,i,s,o,a,l){return new Ro(t,r,i,s,o,a,l)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof It))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const c of l)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h})=>({type:"edit",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${r},${i},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Lo extends Jt{constructor(t,r,i,s,o,a){super(t,a);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,r,i,s,o,a){return new Lo(t,r,i,s,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof It))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const c of a)t.registerGCPair(c);return{opInfos:l.map(({from:c,to:d,value:h})=>({type:"style",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${r},${i},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const J1=2,$1="root",mr="text";function Os(n,e){let t=0;const r=n.children;for(let i=0;i0)throw new k(S.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===mr}get paddedSize(){return this.size+(this.isText?0:J1)}isAncestorOf(e){return U1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),i=this.value.slice(e);if(!i.length)return;this.value=r;const s=this.cloneText(e+t);return s.value=i,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new k(S.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,e),s=this.children.slice(e);this._children=i,r._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(i=>!i.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function U1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var me=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(me||{});function oy(n,e,t,r){if(e>t)throw new k(S.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new k(S.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new k(S.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let i=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||l)&&r([s,s.isText?"Text":"Start"],c),oy(s,Math.max(0,o),Math.min(a,s.size),r),c&&r([s,"End"],c)}i+=s.paddedSize}}function ay(n,e,t=0){for(const r of n.children)ay(r,e,t+1);e(n,t)}function Jl(n,e,t=0){for(const r of n._children)Jl(r,e,t+1);e(n,t)}function Kc(n,e,t=!0){if(e>n.size)throw new k(S.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,i=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-i)return Kc(s,e-i,t);if(e===i)return{node:n,offset:r};if(!t&&s.paddedSize===e-i)return{node:n,offset:r+1};if(s.paddedSize>e-i)return Kc(s,e-i-1,t);i+=s.paddedSize,r+=1}return{node:n,offset:r}}function ly(n){return n.isText||n.children.length===0?n:ly(n.children[0])}function j1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let i=t.parent,s=t;for(;i&&s===i.left;)s=i,i=i.parent;return i}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new K1(e,t,!0);const i=this.comparator(e,r.key);return i<0?r.left=this.putInternal(e,t,r.left):i>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class Rt{constructor(e,t){u(this,"parentID");u(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new Rt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,i;return r.isText?(r.parent.children[0]===r&&t===0?i=r.parent:i=r,r=r.parent):t===0?i=r:i=r.children[t-1],Rt.of(r.id,Ce.of(i.getCreatedAt(),i.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return Rt.of(Ce.of(kt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ce.of(kt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),i=e.findFloorNode(t);let s=e.findFloorNode(r);if(!i||!s)throw new k(S.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[i,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ce{constructor(e,t){u(this,"createdAt");u(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ce(e,t)}static fromStruct(e){return Ce.of(kt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=i.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new k(S.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new k(S.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new Xe(Ce.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new Xe(Ce.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,i){const s=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new Tr);const i=[];for(const[s,o]of Object.entries(t))i.push(this.attrs.set(s,o,r));return i}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Wc(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Wc)};return n.attrs&&(e.attributes=es((t=n.attrs)==null?void 0:t.toObject())),e}function Qf(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${en(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>Qf(t)).join("")}`}function cy(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(cy),size:n.size,isRemoved:n.isRemoved}}class Et extends Do{constructor(t,r){super(r);u(this,"indexTree");u(this,"nodeMapByID");this.indexTree=new V1(t),this.nodeMapByID=new uy(Ce.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(t,r){return new Et(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[i,s]=t.toTreeNodePair(this);let o=s;const a=i===o,l=o.parent&&!a?o.parent:i;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const c=l.allChildren,d=a?0:c.indexOf(o)+1;for(let h=d;h{const P=T.getCreatedAt().getActorID();let p,g=0n;if(o===void 0&&s===void 0?g=_s:o.size()>0?g=o.get(P)?o.get(P):0n:p=s.has(P)?s.get(P):bt,T.canStyle(i,p,g)&&r){const v=y.get(P),I=T.getCreatedAt();(!v||I.after(v))&&y.set(P,I);const E=T.setAttrs(r,i),N=E.reduce((q,[,$])=>($&&(q[$.getKey()]=m[$.getKey()]),q),{}),D=T.parent,R=T.prevSibling||T.parent;Object.keys(N).length>0&&h.push({type:"style",from:this.toIndex(D,R),to:this.toIndex(T,T),fromPath:this.toPath(D,R),toPath:this.toPath(T,T),actor:i.getActorID(),value:N});for(const[q]of E)q&&w.push({parent:T,child:q})}}),[y,w,h]}removeStyle(t,r,i,s,o){const[a,l]=this.findNodesAndSplitText(t[0],i),[c,d]=this.findNodesAndSplitText(t[1],i),h=[],m=new Map,y=[];return this.traverseInPosRange(a,l,c,d,([w])=>{const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=_s:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):bt,w.canStyle(i,P,p)&&r){const g=m.get(T),v=w.getCreatedAt();(!g||v.after(g))&&m.set(T,v),w.attrs||(w.attrs=new Tr);for(const N of r){const D=w.attrs.remove(N,i);for(const R of D)y.push({parent:w,child:R})}const I=w.parent,E=w.prevSibling||w.parent;h.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(I,E),to:this.toIndex(w,w),fromPath:this.toPath(I,E),toPath:this.toPath(w,w),value:r})}}),[m,y,h]}edit(t,r,i,s,o,a,l){const[c,d]=this.findNodesAndSplitText(t[0],s),[h,m]=this.findNodesAndSplitText(t[1],s),y=this.toIndex(c,d),w=this.toPath(c,d),T=[],P=[],p=[],g=new Map;this.traverseInPosRange(c,d,h,m,([E,N],D)=>{if(N===me.Start&&!D)for(const Se of E.children)p.push(Se);const R=E.getCreatedAt().getActorID();let q,$=0n;if(l===void 0&&a===void 0?$=_s:l.size()>0?$=l.get(R)?l.get(R):0n:q=a.has(R)?a.get(R):bt,E.canDelete(s,q,$)||T.includes(E.parent)){const Se=g.get(R),Er=E.getCreatedAt();(!Se||Er.after(Se))&&g.set(R,Er),(N===me.Text||N===me.Start)&&T.push(E),P.push([E,N])}});const v=this.makeDeletionChanges(P,s),I=[];for(const E of T)E.remove(s),E.isRemoved&&I.push({parent:this,child:E});for(const E of p)E.removedAt||c.append(E);if(i>0){let E=0,N=c,D=d;for(;E{c.isRemoved&&(R.remove(s),I.push({parent:this,child:R})),this.nodeMapByID.put(R.id,R)}),D.isRemoved||E.push(D);if(E.length){const D=E.map(R=>Wc(R));v.length&&v[v.length-1].from===y?v[v.length-1].value=D:v.push({type:"content",from:y,to:y,fromPath:w,toPath:w,actor:s.getActorID(),value:D})}}return[v,I,g]}editT(t,r,i,s,o){const a=this.findPos(t[0]),l=this.findPos(t[1]);this.edit([a,l],r,i,s,o)}move(t,r,i){throw new k(S.ErrUnimplemented,`not implemented: ${t}, ${r}, ${i}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,i=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=i}if(i){const o=this.findFloorNode(i);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const i of r.getGCPairs())t.push(i)}),t}findPos(t,r=!0){const i=this.indexTree.findTreePos(t,r);return Rt.fromTreePos(i)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Qf(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(i,s=void 0,o=void 0,a=0)=>{var y,w,T,P;let l,c,d;const h=i.isText?{node:i,offset:0}:s&&o?this.toTreePos(s,o):null;h&&(l=this.indexTree.indexOf(h),c=this.indexTree.treePosToPath(h),d=Rt.fromTreePos(h).toStruct());const m={type:i.type,parent:s==null?void 0:s.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(y=i.removedAt)==null?void 0:y.toTestString(),insPrev:(w=i.insPrevID)==null?void 0:w.toTestString(),insNext:(T=i.insNextID)==null?void 0:T.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:a,attributes:i.attrs?es((P=i.attrs)==null?void 0:P.toObject()):void 0,index:l,path:c,pos:d};for(let p=0;p0&&p===i[i.length-1].to?(i[i.length-1].to=g,i[i.length-1].toPath=this.toPath(P,y)):i.push({type:"content",from:p,to:g,fromPath:this.toPath(T,h),toPath:this.toPath(P,y),actor:r.getActorID()}))}return i.reverse()}findRightToken([t,r]){if(r===me.Start){const l=t.allChildren;return l.length>0?[l[0],l[0].isText?me.Text:me.Start]:[t,me.End]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===s.length-1)return[i,me.End];const a=s[o+1];return[a,a.isText?me.Text:me.Start]}findLeftToken([t,r]){if(r===me.End){const l=t.allChildren;if(l.length>0){const c=l[l.length-1];return[c,c.isText?me.Text:me.End]}return[t,me.Start]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===0)return[i,me.Start];const a=s[o-1];return[a,a.isText?me.Text:me.End]}}class Bo extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"contents");u(this,"splitLevel");u(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,i,s,o,a,l){return new Bo(t,r,i,s,o,a,l)}execute(t,r,i){var d;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[l,c]=a.edit([this.fromPos,this.toPos],(d=this.contents)==null?void 0:d.map(h=>h.deepcopy()),this.splitLevel,o,(()=>{let h=o.getDelimiter();return this.contents!==void 0&&(h+=this.contents.length),()=>kt.of(o.getLamport(),++h,o.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const h of c)t.registerGCPair(h);return{opInfos:l.map(({from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${r},${i},${s.map(o=>Qf(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ts{constructor(e){u(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,i]of e){const s=this.vector.get(r),o=s&&s>i?s:i;t.set(r,o)}for(const[r,i]of this){const s=e.get(r),o=s&&s>i?s:i;t.set(r,o)}return new ts(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new ts(e)}filter(e){const t=new Map;for(const[r]of e){const i=this.vector.get(r);i!==void 0&&t.set(r,i)}return new ts(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const H1=new ts(new Map);class ar{constructor(e,t,r,i,s){u(this,"clientSeq");u(this,"serverSeq");u(this,"lamport");u(this,"actor");u(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=i,this.actor=r}static of(e,t,r,i,s){return new ar(e,t,r,i,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new ar(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,r=this.versionVector.max(e.versionVector),i=new ar(this.clientSeq,t,this.actor,r);return i.versionVector.set(this.actor,t),i}setClocks(e,t){const r=e>this.lamport?e:this.lamport+1n,i=this.versionVector.max(t);return i.set(this.actor,r),ar.of(this.clientSeq,r,this.actor,i)}createTimeTicket(e){return kt.of(this.lamport,e,this.actor)}setActor(e){return new ar(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new ar(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const _1=new ar(0,0n,_f,H1);class ms{constructor({id:e,operations:t,presenceChange:r,message:i}){u(this,"id");u(this,"operations");u(this,"presenceChange");u(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=i}static create({id:e,operations:t,presenceChange:r,message:i}){return new ms({id:e,operations:t,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const i=[],s=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:l,reverseOp:c}=a;i.push(...l),c&&s.unshift(c)}return this.presenceChange&&(this.presenceChange.type===Xr.Put?t.set(this.id.getActorID(),Nt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:i,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:de.bytesToHex(de.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>de.bytesToHex(de.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:i,message:s}=e;return ms.create({id:de.bytesToChangeID(de.hexToBytes(t)),operations:r==null?void 0:r.map(o=>de.bytesToOperation(de.hexToBytes(o))),presenceChange:i,message:s})}}class $l{constructor(e,t,r,i,s,o,a){u(this,"documentKey");u(this,"checkpoint");u(this,"isRemoved");u(this,"changes");u(this,"snapshot");u(this,"minSyncedTicket");u(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=i,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,r,i,s,o,a){return new $l(e,t,r,i,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class ns{constructor(e,t){u(this,"serverSeq");u(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new ns(e,t)}increaseClientSeq(e){return e===0?this:new ns(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return ns.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const G1=new ns(0n,0);class rn{constructor(e,t){u(this,"createdAt");u(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new rn(e,t)}static fromStruct(e){return rn.of(kt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new rn(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Y1=rn.of(bt,0);class Ft{constructor(e,t){u(this,"id");u(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Ft(e,t)}static fromStruct(e){const t=rn.fromStruct(e.id);return Ft.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return rn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class _r extends ty{constructor(t,r,i){super(r);u(this,"id");u(this,"removedAt");u(this,"prev");u(this,"next");u(this,"insPrev");u(this,"insNext");this.id=t,this.removedAt=i}static create(t,r){return new _r(t,r)}static createComparator(){return(t,r)=>{const i=t.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let i=e;for(;i&&i!==t;)r.push(i),i=i.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new k(S.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const i=e.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,i){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,r,i),a=new Map,l=new Map,c=this.makeChanges(o,t);for(const d of s){const h=d.getCreatedAt().getActorID();(!a.has(h)||d.getID().getCreatedAt().after(a.get(h)))&&a.set(h,d.getID().getCreatedAt()),l.set(d.getID().toIDString(),d),d.remove(t)}return this.deleteIndexNodes(o),[c,a,l]}filterNodes(e,t,r,i){const s=[],o=[],[a,l]=this.findEdgesOfCandidates(e);o.push(a);for(const c of e){const d=c.getCreatedAt().getActorID();let h,m=0n;i===void 0&&r===void 0?m=_s:i.size()>0?m=i.get(d)?i.get(d):0n:h=r.has(d)?r.get(d):bt,c.canDelete(t,h,m)?s.push(c):o.push(c)}return o.push(l),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let i,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var sn=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(sn||{});class tt extends Do{constructor(t,r,i){super(i);u(this,"valueType");u(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=K.fromNumber(r).toInt():this.value=ig(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=K.fromNumber(r):this.value=r;break;default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,i){return new tt(t,r,i)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return K.fromBytesLE(Array.from(r));default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=tt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof K?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!tt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===ve.Long?this.value=this.value+t.getValue().toInt():this.value=K.fromNumber(this.value+ig(t.getValue())).toInt(),this}}class ys extends Jt{constructor(t,r,i){super(t,i);u(this,"value");this.value=r}static create(t,r,i){return new ys(t,r,i)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof tt))throw new k(S.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,s=this.value.deepcopy();return i.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),i=t.getType()===ve.Long?t.getValue().multiply(-1):t.getValue()*-1;return ys.create(this.getParentCreatedAt(),se.of(i,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class pr extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"attributes");u(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,r,i,s,o,a){return new pr(t,r,i,s,o,[],a)}static createTreeRemoveStyleOperation(t,r,i,s,o,a){return new pr(t,r,i,s,new Map,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,l;if(this.attributes.size){const c={};[...this.attributes].forEach(([d,h])=>c[d]=h),[,l,a]=o.style([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const c=this.attributesToRemove;[,l,a]=o.removeStyle([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const c of l)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h,fromPath:m,toPath:y})=>({type:"tree-style",from:c,to:d,value:this.attributes.size?{attributes:h}:{attributesToRemove:h},fromPath:m,toPath:y,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Q1(n){const e=new Hf,t=e.data;for(const[r,i]of Object.entries(n))t[r]=JSON.stringify(i);return e}function X1(n){if(n.type===Xr.Put)return new vo({type:Ii.PUT,presence:Q1(n.presence)});if(n.type===Xr.Clear)return new vo({type:Ii.CLEAR});throw new k(S.ErrUnimplemented,"unimplemented type")}function Z1(n){return new Xp({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function fy(n){return new Fl({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:ld(n.getActorID()),versionVector:Xf(n.getVersionVector())})}function F(n){if(n)return new b({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:ld(n.getActorID())})}function Xf(n){if(!n)return;const e=new Ml;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function dy(n){switch(n){case ve.Null:return z.NULL;case ve.Boolean:return z.BOOLEAN;case ve.Integer:return z.INTEGER;case ve.Long:return z.LONG;case ve.Double:return z.DOUBLE;case ve.String:return z.STRING;case ve.Bytes:return z.BYTES;case ve.Date:return z.DATE;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function hy(n){switch(n){case sn.IntegerCnt:return z.INTEGER_CNT;case sn.LongCnt:return z.LONG_CNT;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function Au(n){if(n instanceof He)return new at({type:z.JSON_OBJECT,createdAt:F(n.getCreatedAt()),value:xy(n)});if(n instanceof et)return new at({type:z.JSON_ARRAY,createdAt:F(n.getCreatedAt()),value:DS(n)});if(n instanceof It)return new at({type:z.TEXT,createdAt:F(n.getCreatedAt())});if(n instanceof se)return new at({type:dy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof tt)return new at({type:hy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Et)return new at({type:z.TREE,createdAt:F(n.getCreatedAt()),value:RS(n)});throw new k(S.ErrUnimplemented,"unimplemented element")}function eS(n){return new po({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function ta(n){return new kr({createdAt:F(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function na(n){return new Ai({parentId:Gs(n.getParentID()),leftSiblingId:Gs(n.getLeftSiblingID())})}function Gs(n){return new Wr({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function gy(n){const e=new Wf;if(n instanceof Ei){const t=n,r=new Qa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Au(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Oo){const t=n,r=new Xa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.value=Au(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof Fr){const t=n,r=new Za;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Zr){const t=n,r=new el;r.parentCreatedAt=F(t.getParentCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Ro){const t=n,r=new tl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ta(t.getFromPos()),r.to=ta(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);r.content=t.getContent();const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof Lo){const t=n,r=new nl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ta(t.getFromPos()),r.to=ta(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof ys){const t=n,r=new rl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.value=Au(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof Bo){const t=n,r=new il,i=r.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())i[s]=F(o);r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos()),r.contents=aS(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=F(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof pr){const t=n,r=new sl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=t.getAttributesToRemove();if(s.length>0)r.attributesToRemove=s;else{const o=r.attributes;for(const[a,l]of t.getAttributes())o[a]=l}r.executedAt=F(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new k(S.ErrUnimplemented,"unimplemented operation");return e}function tS(n){const e=[];for(const t of n)e.push(gy(t));return e}function nS(n){const e=new Yp({id:fy(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=tS(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=X1(n.getPresenceChange())),e}function rS(n){const e=[];for(const t of n)e.push(nS(t));return e}function iS(n){const e=[];for(const t of n)e.push(new Qp({key:t.getStrKey(),element:ed(t.getValue())}));return e}function sS(n){const e=[];for(const t of n)e.push(new dl({element:ed(t.getValue())}));return e}function oS(n){const e=[];for(const t of n){const r=new hl;r.id=eS(t.getID()),r.value=t.getValue().getContent(),r.removedAt=F(t.getRemovedAt());const i=r.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new ds;a.value=o.getValue(),a.updatedAt=F(o.getUpdatedAt()),i[o.getKey()]=a}e.push(r)}return e}function aS(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new gl({content:Zf(t)}));return e}function lS(n){const e={};for(const t of n)e[t.getKey()]=new ds({value:t.getValue(),updatedAt:F(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function Zf(n){if(!n)return[];const e=[];return Jl(n,(t,r)=>{const i=new yo({id:Gs(t.id),type:t.type,removedAt:F(t.removedAt),depth:r});t.isText&&(i.value=t.value),t.insPrevID&&(i.insPrevId=Gs(t.insPrevID)),t.insNextID&&(i.insNextId=Gs(t.insNextID)),t.attrs&&(i.attributes=lS(t.attrs)),e.push(i)}),e}function uS(n){const e=new _e;return e.body.case="jsonObject",e.body.value=new ol({nodes:iS(n.getRHT()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function my(n){const e=new _e;return e.body.case="jsonArray",e.body.value=new al({nodes:sS(n.getElements()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function cS(n){const e=new _e;return e.body.case="primitive",e.body.value=new ll({type:dy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function fS(n){const e=new _e;return e.body.case="text",e.body.value=new ul({nodes:oS(n.getRGATreeSplit()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function dS(n){const e=new _e;return e.body.case="counter",e.body.value=new cl({type:hy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function py(n){const e=new _e;return e.body.case="tree",e.body.value=new fl({nodes:Zf(n.getRoot()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function ed(n){if(n instanceof He)return uS(n);if(n instanceof et)return my(n);if(n instanceof se)return cS(n);if(n instanceof It)return fS(n);if(n instanceof tt)return dS(n);if(n instanceof Et)return py(n);throw new k(S.ErrUnimplemented,"unimplemented element")}function hS(n){return new Ir({documentKey:n.getDocumentKey(),checkpoint:Z1(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:rS(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Xf(n.getVersionVector()),minSyncedTicket:F(n.getMinSyncedTicket())})}function Fs(n){if(!(n instanceof ne))return{};const e=n.findDetails(R1);for(const t of e)return t.metadata;return{}}function Oi(n){return Fs(n).code??""}function yy(n){return ar.of(n.clientSeq,BigInt(n.lamport),od(n.actorId),td(n.versionVector),BigInt(n.serverSeq))}function td(n){if(!n)return;const e=new ts;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return kt.of(BigInt(n.lamport),n.delimiter,od(n.actorId))}function nd(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function gS(n){const e=n.type;if(e===Ii.PUT){const t=nd(n.presence);return{type:Xr.Put,presence:t}}if(e===Ii.CLEAR)return{type:Xr.Clear};throw new k(S.ErrInvalidType,`unsupported type: ${e}`)}function mS(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,nd(r))}),e}function vy(n){switch(n){case z.NULL:return ve.Null;case z.BOOLEAN:return ve.Boolean;case z.INTEGER:return ve.Integer;case z.LONG:return ve.Long;case z.DOUBLE:return ve.Double;case z.STRING:return ve.String;case z.BYTES:return ve.Bytes;case z.DATE:return ve.Date}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function yl(n){switch(n){case z.INTEGER_CNT:return sn.IntegerCnt;case z.LONG_CNT:return sn.LongCnt}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function Iu(n){switch(n.type){case z.JSON_OBJECT:return n.value?Ey(n.value):He.create(M(n.createdAt));case z.JSON_ARRAY:return n.value?PS(n.value):et.create(M(n.createdAt));case z.TEXT:return It.create(ps.create(),M(n.createdAt));case z.TREE:return OS(n.value);case z.NULL:case z.BOOLEAN:case z.INTEGER:case z.LONG:case z.DOUBLE:case z.STRING:case z.BYTES:case z.DATE:return se.of(se.valueFromBytes(vy(n.type),n.value),M(n.createdAt));case z.INTEGER_CNT:case z.LONG_CNT:return tt.create(yl(n.type),tt.valueFromBytes(yl(n.type),n.value),M(n.createdAt))}}function ra(n){return Ft.of(rn.of(M(n.createdAt),n.offset),n.relativeOffset)}function wy(n){return rn.of(M(n.createdAt),n.offset)}function pS(n){const e=To.create(n.value);Object.entries(n.attributes).forEach(([r,i])=>{e.setAttr(r,i.value,M(i.updatedAt))});const t=_r.create(wy(n.id),e);return t.remove(M(n.removedAt)),t}function Ri(n){return Rt.of(Ys(n.parentId),Ys(n.leftSiblingId))}function Ys(n){return Ce.of(M(n.createdAt),n.offset)}function yS(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=rd(t.content);e.push(r)}),e}function rd(n){if(n.length===0)return;const e=[];for(const i of n)e.push(wS(i));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let i=e.length-2;i>=0;i--)r.get(n[i].depth-1).prepend(e[i]),r.set(n[i].depth,e[i]);return t.updateDescendantsSize(),Et.create(t,bt).getRoot()}function vS(n){const e=Tr.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function wS(n){const e=Ys(n.id),t=Xe.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=vS(n.attributes)),n.insPrevId&&(t.insPrevID=Ys(n.insPrevId)),n.insNextId&&(t.insNextID=Ys(n.insNextId)),t.removedAt=M(n.removedAt),t}function Sy(n){if(n.body.case==="set"){const e=n.body.value;return Ei.create(e.key,Iu(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Oo.create(M(e.parentCreatedAt),M(e.prevCreatedAt),Iu(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Fr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Zr.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Ro.create(M(e.parentCreatedAt),ra(e.from),ra(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Lo.create(M(e.parentCreatedAt),ra(e.from),ra(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ys.create(M(e.parentCreatedAt),Iu(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,i])=>{t.set(r,M(i))}),Bo.create(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),yS(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,i=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{i.set(s,M(o))}),(r==null?void 0:r.length)>0?pr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),i,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),pr.create(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),i,t,M(e.executedAt)))}else throw new k(S.ErrUnimplemented,"unimplemented operation")}}function SS(n){const e=[];for(const t of n){const r=Sy(t);r&&e.push(r)}return e}function ky(n){const e=[];for(const t of n)e.push(ms.create({id:yy(t.id),operations:SS(t.operations),presenceChange:t.presenceChange?gS(t.presenceChange):void 0,message:t.message}));return e}function kS(n){return ns.of(BigInt(n.serverSeq),n.clientSeq)}function TS(n){return $l.create(n.documentKey,kS(n.checkpoint),n.isRemoved,ky(n.changes),td(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function Ty(n){const e=new wo;for(const r of n.nodes){const i=id(r.element);e.set(r.key,i,i.getPositionedAt())}const t=new He(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Ay(n){const e=new ko;for(const r of n.nodes)e.insert(id(r.element));const t=new et(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function AS(n){const e=se.of(se.valueFromBytes(vy(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function IS(n){const e=new ps;let t=e.getHead();for(const i of n.nodes){const s=e.insertAfter(t,pS(i));i.insPrevId&&s.setInsPrev(e.findNode(wy(i.insPrevId))),t=s}const r=new It(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function ES(n){const e=tt.create(yl(n.type),tt.valueFromBytes(yl(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function Iy(n){const e=rd(n.nodes);return Et.create(e,M(n.createdAt))}function id(n){if(n.body.case==="jsonObject")return Ty(n.body.value);if(n.body.case==="jsonArray")return Ay(n.body.value);if(n.body.case==="primitive")return AS(n.body.value);if(n.body.case==="text")return IS(n.body.value);if(n.body.case==="counter")return ES(n.body.value);if(n.body.case==="tree")return Iy(n.body.value);throw new k(S.ErrUnimplemented,"unimplemented element")}function xS(n){if(!n)return{root:He.create(bt),presences:new Map};const e=kc.fromBinary(n);return{root:id(e.root),presences:mS(e.presences)}}function CS(n){const e=Xf(n);return sd(e.toBinary())}function NS(n){const e=ad(n),t=Ml.fromBinary(e);return td(t)}function Ey(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Ty(e.body.value)}function xy(n){return ed(n).toBinary()}function PS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Ay(e.body.value)}function DS(n){return my(n).toBinary()}function OS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Iy(e.body.value)}function RS(n){return py(n).toBinary()}function sd(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function od(n){return sd(n)}function ad(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function ld(n){return ad(n)}function LS(n){const e=Fl.fromBinary(n);return yy(e)}function BS(n){const e=Wf.fromBinary(n);return Sy(e)}const de={fromPresence:nd,toChangePack:hS,fromChangePack:TS,fromChanges:ky,toTreeNodes:Zf,fromTreeNodes:rd,objectToBytes:xy,bytesToObject:Ey,bytesToSnapshot:xS,bytesToHex:sd,hexToBytes:ad,toHexString:od,toUint8Array:ld,toOperation:gy,toChangeID:fy,PbChangeID:Fl,bytesToChangeID:LS,bytesToOperation:BS,versionVectorToHex:CS,hexToVersionVector:NS};var Me=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Me||{});let ai=3;function Cy(n){ai=n}const J={trivial:(...n)=>{ai>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{ai>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{ai>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{ai>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{ai>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>ai<=n};function Ny(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class bS{constructor(e,t,r,i,s){u(this,"reconnectStreamDelay");u(this,"doc");u(this,"docID");u(this,"syncMode");u(this,"remoteChangeEventReceived");u(this,"watchStream");u(this,"watchLoopTimerID");u(this,"watchAbortController");u(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ia.RealtimeSyncOff?!1:this.syncMode===Ia.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ia.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Eu=()=>{};class FS{constructor(e){u(this,"finalized",!1);u(this,"observers",[]);u(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(!e)throw new k(S.ErrInvalidArgument,"missing observer");if(this.finalized)throw new k(S.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?i=e:i={next:e,error:t,complete:r},i.next===void 0&&(i.next=Eu),i.error===void 0&&(i.error=Eu),i.complete===void 0&&(i.complete=Eu);const s=Ny(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(a){J.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Hi{constructor(e,t,r,i){u(this,"id");u(this,"delimiter");u(this,"message");u(this,"root");u(this,"operations");u(this,"presenceChange");u(this,"previousPresence");u(this,"reversePresenceKeys");this.id=e,this.delimiter=ey,this.root=t,this.operations=[],this.previousPresence=Nt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(e,t,r,i){return new Hi(e,t,r,i)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ms.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class Ao{constructor(e){u(this,"rootObject");u(this,"elementPairMapByCreatedAt");u(this,"gcElementSetByCreatedAt");u(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof It||t instanceof Et)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new Ao(He.create(bt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const i=t.element.getCreatedAt(),s=t.parent.subPathOf(i);if(s===void 0)throw new k(S.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof Hr&&e.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(e){let t=0;const r=i=>{const s=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return r(e),e instanceof Hr&&e.getDescendants(i=>(r(i),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof Hr&&r.element.getDescendants(i=>(e.add(i.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new Ao(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),s=i.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(i.parent.purge(i.element),t+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Py(n,e){const t=new Io(n);return new Proxy(e,t.getHandlers())}class Io{constructor(e){u(this,"context");u(this,"handlers");this.context=e,this.handlers={set:(t,r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]=${JSON.stringify(i)}`),Io.setInternal(e,t,r,i),!0),get:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():li(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),Io.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,i){if(r.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=vl(e,i,s),a=t.set(r,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(Ei.create(r,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const r={};for(const[i,s]of Object.entries(t)){if(i.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=vl(e,s,o);r[i]=a}return r}static deleteInternal(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByKey(r,i);s&&(e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function JS(n,e){const t=new le(n,e);return new Proxy(e,t.getHandlers())}function $S(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zS(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class le{constructor(e,t){u(this,"context");u(this,"handlers");u(this,"array");this.context=e,this.array=t,this.handlers={get:(r,i,s)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return Nr(e,a)}:i==="getElementByIndex"?o=>{const a=r.get(o);return Nr(e,a)}:i==="getLast"?()=>Nr(e,r.getLast()):i==="deleteByID"?o=>{const a=le.deleteInternalByID(e,r,o);return Nr(e,a)}:i==="insertAfter"?(o,a)=>{const l=le.insertAfterInternal(e,r,o,a);return Nr(e,l)}:i==="insertBefore"?(o,a)=>{const l=le.insertBeforeInternal(e,r,o,a);return Nr(e,l)}:i==="moveBefore"?(o,a)=>{le.moveBeforeInternal(e,r,o,a)}:i==="moveAfter"?(o,a)=>{le.moveAfterInternal(e,r,o,a)}:i==="moveFront"?o=>{le.moveFrontInternal(e,r,o)}:i==="moveLast"?o=>{le.moveLastInternal(e,r,o)}:$S(i)?li(e,r.get(Number(i))):i==="push"?o=>le.pushInternal(e,r,o):i==="splice"?(o,a,...l)=>le.splice(e,r,o,a,...l):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?le.iteratorInternal.bind(this,e,r):i==="includes"?(o,a)=>le.includes(e,r,o,a):i==="indexOf"?(o,a)=>le.indexOf(e,r,o,a):i==="lastIndexOf"?(o,a)=>le.lastIndexOf(e,r,o,a):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>le.toTestString(r):typeof i=="string"&&zS(i)?(...o)=>{const a=Array.from(r).map(l=>li(e,l));return Array.prototype[i].apply(a,o)}:Reflect.get(r,i,s),deleteProperty:(r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`array[${i}]`),le.deleteInternalByIndex(e,r,Number.parseInt(i)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield Nr(e,r)}static buildArrayElements(e,t){const r=[];for(const i of t){const s=e.issueTimeTicket(),o=vl(e,i,s);r.push(o)}return r}static pushInternal(e,t,r){return le.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,i){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,i,s),e.push(Fr.create(t.getCreatedAt(),o,i,s))}static moveAfterInternal(e,t,r,i){const s=e.issueTimeTicket();t.moveAfter(r,i,s),e.push(Fr.create(t.getCreatedAt(),r,i,s))}static moveFrontInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),r,i),e.push(Fr.create(t.getCreatedAt(),s.getCreatedAt(),r,i))}static moveLastInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,r,i),e.push(Fr.create(t.getCreatedAt(),s,r,i))}static insertAfterInternal(e,t,r,i){const s=e.issueTimeTicket(),o=vl(e,i,s);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Oo.create(t.getCreatedAt(),r,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,r,i){return le.insertAfterInternal(e,t,t.getPrevCreatedAt(r),i)}static deleteInternalByIndex(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByIndex(r,i);if(s)return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,r){const i=e.issueTimeTicket(),s=t.delete(r,i);return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static splice(e,t,r,i,...s){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),l=i===void 0?o:i<0?a:Math.min(a+i,o),c=[];for(let d=a;d=s)return!1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).includes(r,o);for(let l=o;l=s)return-1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).indexOf(r,o);for(let l=o;l=s?s-1:i<0?i+s:i;if(o<0)return-1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).lastIndexOf(r,o);for(let l=o;l>0;l--)if(((a=t.get(l))==null?void 0:a.getID())===r.getID())return l;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class zl{constructor(e,t){u(this,"context");u(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,i){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${r}`);const o=i?hs(i):void 0,a=this.context.issueTimeTicket(),[l,,c,d]=this.text.edit(s,r,a,o);for(const h of c)this.context.registerGCPair(h);return this.context.push(new Ro(this.text.getCreatedAt(),s[0],s[1],l,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(d)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`STYL: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const s=hs(r),o=this.context.issueTimeTicket(),[a,l]=this.text.setStyle(i,s,o);for(const c of l)this.context.registerGCPair(c);return this.context.push(new Lo(this.text.getCreatedAt(),i[0],i[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Ft.fromStruct(e[0]),Ft.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class Ul{constructor(e,t){u(this,"valueType");u(this,"value");u(this,"context");u(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=se.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(ys.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function ud(n,e,t){const{type:r}=n,i=t.issueTimeTicket();if(r===mr){Dy(n);const{value:s}=n,o=Xe.create(Ce.of(i,0),r,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!Zp(o)){const c=hs(o);a=new Tr;for(const[d,h]of Object.entries(c))a.set(d,h,i)}const l=Xe.create(Ce.of(i,0),r,void 0,a);e.append(l);for(const c of s)ud(c,l,t)}}function US(n,e){const{type:t}=e,r=n.issueTimeTicket();let i;if(e.type===mr){const{value:s}=e;i=Xe.create(Ce.of(r,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!Zp(o)){const l=hs(o);a=new Tr;for(const[c,d]of Object.entries(l))a.set(c,d,r)}i=Xe.create(Ce.of(n.issueTimeTicket(),0),t,void 0,a);for(const l of s)ud(l,i,n)}return i}function Dy(n){if(!n.value.length)throw new k(S.ErrInvalidArgument,"text node cannot have empty value");return!0}function sg(n){if(!n.length)return!0;if(n[0].type===mr)for(const t of n){const{type:r}=t;if(r!==mr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together");Dy(t)}else for(const t of n){const{type:r}=t;if(r===mr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class jl{constructor(e){u(this,"initialRoot");u(this,"context");u(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return Xe.create(Ce.of(e.issueTimeTicket(),0),$1);const t=Xe.create(Ce.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)ud(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?hs(t):void 0,[a]=this.tree.style([r,i],o,s);this.context.push(pr.create(this.tree.getCreatedAt(),r,i,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?hs(r):void 0,[l,c]=this.tree.style([i,s],a,o);for(const d of c)this.context.registerGCPair(d);this.context.push(pr.create(this.tree.getCreatedAt(),i,s,l,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,l]=this.tree.removeStyle([i,s],r,o);for(const c of l)this.context.registerGCPair(c);this.context.push(pr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,s,a,r,o))}editInternal(e,t,r,i=0){var c;if(r.length!==0&&r[0]&&(sg(r),r[0].type!==mr))for(const d of r){const{children:h=[]}=d;sg(h)}const s=this.context.getLastTimeTicket();let o=new Array;if(((c=r[0])==null?void 0:c.type)===mr){let d="";for(const h of r){const{value:m}=h;d+=m}o.push(Xe.create(Ce.of(this.context.issueTimeTicket(),0),mr,d))}else o=r.map(d=>d&&US(this.context,d)).filter(d=>d);const[,a,l]=this.tree.edit([e,t],o.length?o.map(d=>d==null?void 0:d.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(const d of a)this.context.registerGCPair(d);return this.context.push(Bo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,l,s)),!0}editByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulkByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r,i)}edit(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulk(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r,i)}toXML(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Rt.fromStruct(e[0]),Rt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Rt.fromStruct(e[0]),Rt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function og(n,e){return Py(n,e)}function Nr(n,e){if(e){if(e instanceof se)return e;if(e instanceof He)return Py(n,e);if(e instanceof et)return JS(n,e);if(e instanceof It)return new zl(n,e);if(e instanceof tt){const t=new Ul(sn.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof Et){const t=new jl;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function li(n,e){const t=Nr(n,e);return t instanceof se?t.getValue():t}function vl(n,e,t){let r;if(se.isSupport(e))r=se.of(e,t);else if(Array.isArray(e))r=et.create(t,le.buildArrayElements(n,e));else if(typeof e=="object")e instanceof zl?(r=It.create(ps.create(),t),e.initialize(n,r)):e instanceof Ul?(r=tt.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof jl?(r=Et.create(e.buildRoot(n),t),e.initialize(n,r)):r=He.create(t,Io.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const ag=50;class jS{constructor(){u(this,"undoStack",[]);u(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=ag&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=ag&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const VS="yorkie-devtools-panel",qS="yorkie-devtools-sdk";let Li="disconnected";const lg=new Map,Aa=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Aa);function ia(n,e){(e!=null&&e.force||Li!=="disconnected")&&window.postMessage({source:qS,...n},"*")}function KS(n){if(!n.isEnableDevtools()||typeof window>"u"||lg.has(n.getKey()))return;Aa.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Ee.StatusChanged&&r.type!==Ee.Snapshot&&r.type!==Ee.LocalChange&&r.type!==Ee.RemoteChange&&r.type!==Ee.Initialized&&r.type!==Ee.Watched&&r.type!==Ee.Unwatched&&r.type!==Ee.PresenceChanged)||(Aa.get(n.getKey()).push(t),Li==="synced"&&ia({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});lg.set(n.getKey(),[e]),ia({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var i;if(((i=t.data)==null?void 0:i.source)!==VS)return;switch(t.data.msg){case"devtools::connect":if(Li!=="disconnected")break;Li="connected",ia({msg:"doc::available",docKey:n.getKey()}),J.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Li="disconnected",J.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Li="synced",ia({msg:"doc::sync::full",docKey:n.getKey(),events:Aa.get(n.getKey())}),J.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Pr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Pr||{}),Ee=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Ee||{}),Hc=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Hc||{}),_c=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(_c||{});class Oy{constructor(e,t){u(this,"key");u(this,"status");u(this,"opts");u(this,"changeID");u(this,"checkpoint");u(this,"localChanges");u(this,"root");u(this,"clone");u(this,"eventStream");u(this,"eventStreamObserver");u(this,"onlineClients");u(this,"presences");u(this,"history");u(this,"internalHistory");u(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=Ao.create(),this.changeID=_1,this.checkpoint=G1,this.localChanges=[],this.eventStream=MS(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new jS,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},KS(this)}update(e,t){if(this.getStatus()==="removed")throw new k(S.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const s=og(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(s,new Tu(i,this.clone.presences.get(r)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(i.hasChange()){J.isEnabled(Me.Trivial)&&J.trivial(`trying to update a local change: ${this.toJSON()}`);const s=i.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,Y.Local),l=i.getReversePresence();l&&a.push({type:"presence",value:l}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const c=[];o.length>0&&c.push({type:"local-change",source:Y.Local,value:{message:s.getMessage()||"",operations:o,actor:r,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&c.push({type:"presence-changed",source:Y.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(c),J.isEnabled(Me.Trivial)&&J.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,i){if(typeof e=="string"){if(typeof t!="function")throw new k(S.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="initialized"&&c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||a(c)},r,i)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="initialized"&&c.type!=="presence-changed"||c.type==="presence-changed"&&c.value.clientID!==this.changeID.getActorID()||a(c)},r,i)}if(e==="others"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||c.value.clientID!==this.changeID.getActorID()&&a(c)},r,i)}if(e==="connection"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="connection-changed"&&a(c)},r,i)}if(e==="status"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="status-changed"&&a(c)},r,i)}if(e==="sync"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="sync-status-changed"&&a(c)},r,i)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="local-broadcast"&&a(c)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="broadcast"&&a(c)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="auth-error"&&a(c)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,i)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const l of a){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const c=[];for(const d of l.value.operations)this.isSameElementOrChildOf(d.path,s)&&c.push(d);c.length&&o({...l,value:{...l.value,operations:c}})}},r,i)}if(typeof e=="function"){const s=e,o=t,a=r;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="snapshot"&&c.type!=="local-change"&&c.type!=="remote-change"||s(c)},o,a)}throw new k(S.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((s,o)=>s===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),Y.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),J.isEnabled(Me.Trivial)&&J.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Nt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return $l.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return og(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,i=-1){const{root:s,presences:o}=de.bytesToSnapshot(r);this.root=new Ao(s),this.presences=o,this.changeID=this.changeID.setClocks(e,t),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,Y.Local),this.publish([{type:"snapshot",source:Y.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?de.bytesToHex(r):void 0,snapshotVector:de.versionVectorToHex(t)}}])}applyChanges(e,t){J.isEnabled(Me.Debug)&&J.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),J.isEnabled(Me.Trivial)&&J.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` -`));for(const r of e)this.applyChange(r,t);J.isEnabled(Me.Debug)&&J.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],i=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(i)){const o=e.getPresenceChange();switch(o.type){case Xr.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:t,value:{clientID:i,presence:o.presence}}:{type:"watched",source:Y.Remote,value:{clientID:i,presence:o.presence}});break;case Xr.Clear:r.push({type:"unwatched",source:Y.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===Y.Remote?{type:"remote-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const i of t)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:Y.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,i=[];if(t===yi.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:Y.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===yi.DOCUMENT_UNWATCHED){const s=this.getPresence(r);this.removeOnlineClient(r),s&&i.push({type:"unwatched",source:Y.Remote,value:{clientID:r,presence:s}})}else if(t===yi.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:s,payload:JSON.parse(a.decode(o))}})}i.length>0&&this.publish(i)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(_f),this.publish([{source:e==="removed"?Y.Remote:Y.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:i}=e.value;if(!t)return;this.applySnapshot(BigInt(r),de.hexToVersionVector(i),de.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ms.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:i}of e.value)t.add(r),this.presences.set(r,i);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new k(S.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const i of t)if(r=r[i],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Nt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Nt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Nt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Nt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Nt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new k(S.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof Jt)){new Tu(t,Nt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),l=[];i.length>0&&l.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}redo(){if(this.isUpdating)throw new k(S.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof Jt)){new Tu(t,Nt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),l=[];i.length>0&&l.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const i={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function WS(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const HS="yorkie-js-sdk",_S="0.5.6",GS="Yorkie JS SDK",YS="./src/yorkie.ts",QS={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},XS=["dist"],ZS={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},ek={node:">=18.0.0",npm:">=7.1.0"},tk={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},nk={name:"hackerwins",email:"susukang98@gmail.com"},rk="Apache-2.0",ik={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},sk="https://github.com/yorkie-team/yorkie-js-sdk#readme",ok={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ak={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},ug={name:HS,version:_S,description:GS,main:YS,publishConfig:QS,files:XS,scripts:ZS,engines:ek,repository:tk,author:nk,license:rk,bugs:ik,homepage:sk,devDependencies:ok,dependencies:ak};function lk(){return n=>async e=>(e.header.set("x-yorkie-user-agent",ug.name+"/"+ug.version),await n(e))}const uk=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ia=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ia||{});const sa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},xu={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class Ry{constructor(e,t){u(this,"id");u(this,"key");u(this,"status");u(this,"attachmentMap");u(this,"apiKey");u(this,"authTokenInjector");u(this,"conditions");u(this,"syncLoopDuration");u(this,"reconnectStreamDelay");u(this,"retrySyncLoopDelay");u(this,"rpcClient");u(this,"setAuthToken");u(this,"taskQueue");u(this,"processing",!1);u(this,"keepalive",!1);t=t||sa,this.key=t.key?t.key:Ny(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??sa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??sa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??sa.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=WS(this.apiKey);this.setAuthToken=i,this.rpcClient=l1(O1,D1({baseUrl:e,interceptors:[r,lk()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),J.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw J.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),J.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw J.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Pr.Detached)throw new k(S.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async s=>{var d;const{topic:o,payload:a}=s.value,l=(d=s.options)==null?void 0:d.error,c=s.options;try{await this.broadcast(e.getKey(),o,a,c)}catch(h){h instanceof Error&&(l==null||l(h))}}),i=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:de.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=de.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Pr.Removed)return e;e.applyStatus(Pr.Attached),this.attachmentMap.set(e.getKey(),new bS(this.reconnectStreamDelay,e,s.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(e.getKey()),J.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const l=t.initialRoot;e.update(c=>{for(const[d,h]of Object.entries(l))if(!a.has(d)){const m=d;c[m]=h}})}return e}).catch(async s=>{throw J.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((i,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:de.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);return e.applyChangePack(s),e.getStatus()!==Pr.Removed&&e.applyStatus(Pr.Detached),this.detachInternal(e.getKey()),J.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async i=>{throw J.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(e,t){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const i=r.syncMode;return i===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=de.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),J.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async i=>{throw J.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,i){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);if(!uk(r))throw new k(S.ErrInvalidArgument,"payload is not serializable");const o=(i==null?void 0:i.maxRetries)??xu.maxRetries,a=xu.maxBackoff;let l=0;const c=h=>Math.min(xu.initialRetryInterval*2**h,a),d=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{J.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async h=>{if(J.error(`[BC] c:"${this.getKey()}" err:`,h),await this.handleConnectError(h))if(h instanceof ne&&Oi(h)===S.ErrUnauthenticated&&s.doc.publish([{type:Ee.AuthError,value:{reason:Fs(h).reason,method:"Broadcast"}}]),ld(),c(l-1)),J.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw J.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),h;else throw h}));return d()}runSyncLoop(){const e=()=>{if(!this.isActive()){J.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof ne&&Oi(i)===S.ErrUnauthenticated&&r.doc.publish([{type:Ee.AuthError,value:{reason:Fs(i).reason,method:"PushPull"}}]),i})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{J.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};J.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new k(S.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:i.signal});return t.doc.publish([{type:Ee.ConnectionChanged,value:Hc.Connected}]),J.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const c of s)this.handleWatchDocumentsResponse(t,c),c.body.case==="initialization"&&o([s,i])}catch(c){t.doc.resetOnlineClients(),t.doc.publish([{type:Ee.Initialized,source:Y.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Ee.ConnectionChanged,value:Hc.Disconnected}]),J.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(c)?(c instanceof ne&&Oi(c)===S.ErrUnauthenticated&&t.doc.publish([{type:Ee.AuthError,value:{reason:Fs(c).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(c)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===yi.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Pr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:i}=e,s=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:de.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=de.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Ee.SyncStatusChanged,value:_c.Synced}]),r.getStatus()===Pr.Removed&&this.detachInternal(r.getKey());const l=r.getKey(),c=a.getChangeSize();return J.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${s.getChangeSize()} pull:${c} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Ee.SyncStatusChanged,value:_c.SyncFailed}]),J.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof ne))return!1;if(e.code===_.Canceled||e.code===_.Unknown||e.code===_.ResourceExhausted||e.code===_.Unavailable)return!0;if(Oi(e)===S.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Fs(e).reason);this.setAuthToken(t)}return!0}return(Oi(e)===S.ErrClientNotActivated||Oi(e)===S.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{J.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const cg={Client:Ry,Document:Oy,Primitive:se,Text:zl,Counter:Ul,Tree:jl,LogLevel:Me,setLogLevel:Cy,IntType:sn.IntegerCnt,LongType:sn.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:Ry,Document:Oy,Primitive:se,Text:zl,Counter:Ul,Tree:jl,LogLevel:Me,setLogLevel:Cy,IntType:sn.IntegerCnt,LongType:sn.LongCnt});var Ly={exports:{}};/*! + */var vt=null;try{vt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function K(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});function Be(n){return(n&&n.__isLong__)===!0}function Xh(n){var e=Math.clz32(n&-n);return n?31-e:e}K.isLong=Be;var Zh={},eg={};function Ni(n,e){var t,r,i;return e?(n>>>=0,(i=0<=n&&n<256)&&(r=eg[n],r)?r:(t=H(n,0,!0),i&&(eg[n]=t),t)):(n|=0,(i=-128<=n&&n<128)&&(r=Zh[n],r)?r:(t=H(n,n<0?-1:0,!1),i&&(Zh[n]=t),t))}K.fromInt=Ni;function wt(n,e){if(isNaN(n))return e?hr:Ot;if(e){if(n<0)return hr;if(n>=ny)return sy}else{if(n<=-ng)return Ve;if(n+1>=ng)return iy}return n<0?wt(-n,e).neg():H(n%gs|0,n/gs|0,e)}K.fromNumber=wt;function H(n,e,t){return new K(n,e,t)}K.fromBits=H;var ml=Math.pow;function Yf(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?hr:Ot;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return Yf(n.substring(1),e,t).neg();for(var i=wt(ml(t,8)),s=Ot,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*gs+(this.low>>>0):this.high*gs+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,d=c.toString(e);if(o=l,o.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Ve)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return Be(e)||(e=$t(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(Be(e)||(e=$t(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(Ve)?Ve:this.not().add(Wi)};C.neg=C.negate;C.add=function(e){Be(e)||(e=$t(e));var t=this.high>>>16,r=this.high&65535,i=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,d=0,h=0,m=0,y=0;return y+=s+c,m+=y>>>16,y&=65535,m+=i+l,h+=m>>>16,m&=65535,h+=r+a,d+=h>>>16,h&=65535,d+=t+o,d&=65535,H(m<<16|y,d<<16|h,this.unsigned)};C.subtract=function(e){return Be(e)||(e=$t(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(Be(e)||(e=$t(e)),vt){var t=vt.mul(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?hr:Ot;if(this.eq(Ve))return e.isOdd()?Ve:Ot;if(e.eq(Ve))return this.isOdd()?Ve:Ot;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(rg)&&e.lt(rg))return wt(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,d=e.low&65535,h=0,m=0,y=0,w=0;return w+=o*d,y+=w>>>16,w&=65535,y+=s*d,m+=y>>>16,y&=65535,y+=o*c,m+=y>>>16,y&=65535,m+=i*d,h+=m>>>16,m&=65535,m+=s*c,h+=m>>>16,m&=65535,m+=o*l,h+=m>>>16,m&=65535,h+=r*d+i*c+s*l+o*a,h&=65535,H(y<<16|w,h<<16|m,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(Be(e)||(e=$t(e)),e.isZero())throw Error("division by zero");if(vt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?vt.div_u:vt.div_s)(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?hr:Ot;var r,i,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return hr;if(e.gt(this.shru(1)))return ry;s=hr}else{if(this.eq(Ve)){if(e.eq(Wi)||e.eq(Kc))return Ve;if(e.eq(Ve))return Wi;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Ot)?e.isNegative()?Wi:Kc:(i=this.sub(e.mul(r)),s=r.add(i.div(e)),s)}else if(e.eq(Ve))return this.unsigned?hr:Ot;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Ot}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),l=a<=48?1:ml(2,a-48),c=wt(r),d=c.mul(e);d.isNegative()||d.gt(i);)r-=l,c=wt(r,this.unsigned),d=c.mul(e);c.isZero()&&(c=Wi),s=s.add(c),i=i.sub(d)}return s};C.div=C.divide;C.modulo=function(e){if(Be(e)||(e=$t(e)),vt){var t=(this.unsigned?vt.rem_u:vt.rem_s)(this.low,this.high,e.low,e.high);return H(t,vt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return H(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?Xh(this.low):Xh(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return Be(e)||(e=$t(e)),H(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return Be(e)||(e=$t(e)),H(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return Be(e)||(e=$t(e)),H(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?H(this.low<>>32-e,this.unsigned):H(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):H(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?H(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?H(this.high,0,this.unsigned):H(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?H(this.high,this.low,this.unsigned):e<32?(t=32-e,H(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,H(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?H(this.high,this.low,this.unsigned):e<32?(t=32-e,H(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,H(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?H(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:H(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};K.fromBytes=function(e,t,r){return r?K.fromBytesLE(e,t):K.fromBytesBE(e,t)};K.fromBytesLE=function(e,t){return new K(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};K.fromBytesBE=function(e,t){return new K(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var ve=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(ve||{});class se extends Do{constructor(t,r){super(r);u(this,"valueType");u(this,"value");this.valueType=se.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new se(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(s,o){i.setUint8(o,s)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return K.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(K.fromBytesLE(Array.from(r),!0).toNumber());default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${en(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=se.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof K)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return se.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=K.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class pl extends ty{constructor(t){super(t);u(this,"prev");u(this,"next");this.value=t}static createAfter(t,r){const i=new pl(r),s=t.next;return t.next=i,i.prev=t,i.next=s,s&&(s.prev=i),i}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class ko{constructor(){u(this,"dummyHead");u(this,"last");u(this,"nodeMapByIndex");u(this,"nodeMapByCreatedAt");const e=se.of(0,bt);e.setRemovedAt(bt),this.dummyHead=new pl(e),this.last=this.dummyHead,this.nodeMapByIndex=new So,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new ko}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const i=this.findNextBeforeExecutedAt(e,r),s=pl.createAfter(i,t);i===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(i,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,r){const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new k(S.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);i!==s&&(!s.getValue().getMovedAt()||r.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(i.getCreatedAt(),s.getValue(),r),s.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let i=t;if(e===0&&t===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),i=r.isRemoved();return r.remove(t)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class et extends Hr{constructor(t,r){super(t);u(this,"elements");this.elements=r}static create(t,r){if(!r)return new et(t,ko.create());const i=ko.create();for(const s of r)i.insertAfter(i.getLastCreatedAt(),s.deepcopy());return new et(t,i)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,i){this.elements.moveAfter(t,r,i)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const i=r.getValue();if(t(i,this))return;i instanceof Hr&&i.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...w,value:w.value?{attributes:es(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[d,y,h,[c,c]]}setStyle(t,r,i,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],i),[,l]=this.rgaTreeSplit.findNodeWithSplit(t[0],i),c=[],d=this.rgaTreeSplit.findBetween(l,a),h=new Map,m=[];for(const w of d){const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=_s:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):bt,w.canStyle(i,P,p)){const g=h.get(T),v=w.getCreatedAt();(!g||v.after(g))&&h.set(T,v),m.push(w)}}const y=[];for(const w of m){if(w.isRemoved())continue;const[T,P]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());c.push({type:"style",actor:i.getActorID(),from:T,to:P,value:{attributes:es(r)}});for(const[p,g]of Object.entries(r)){const[v]=w.getValue().setAttr(p,g,i);v!==void 0&&y.push({parent:w.getValue(),child:v})}}return[h,y,c]}indexRangeToPosRange(t,r){const i=this.rgaTreeSplit.indexToPos(t);return t===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();t.push({attributes:es(i.getAttributes()),content:i.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new It(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())t.push(i)}return t}}class Ro extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"content");u(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,r,i,s,o,a,l){return new Ro(t,r,i,s,o,a,l)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof It))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const c of l)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h})=>({type:"edit",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${r},${i},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Lo extends Jt{constructor(t,r,i,s,o,a){super(t,a);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,r,i,s,o,a){return new Lo(t,r,i,s,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof It))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const c of a)t.registerGCPair(c);return{opInfos:l.map(({from:c,to:d,value:h})=>({type:"style",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${r},${i},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const J1=2,$1="root",mr="text";function Os(n,e){let t=0;const r=n.children;for(let i=0;i0)throw new k(S.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===mr}get paddedSize(){return this.size+(this.isText?0:J1)}isAncestorOf(e){return U1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),i=this.value.slice(e);if(!i.length)return;this.value=r;const s=this.cloneText(e+t);return s.value=i,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new k(S.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,e),s=this.children.slice(e);this._children=i,r._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(i=>!i.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function U1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var me=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(me||{});function oy(n,e,t,r){if(e>t)throw new k(S.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new k(S.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new k(S.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let i=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||l)&&r([s,s.isText?"Text":"Start"],c),oy(s,Math.max(0,o),Math.min(a,s.size),r),c&&r([s,"End"],c)}i+=s.paddedSize}}function ay(n,e,t=0){for(const r of n.children)ay(r,e,t+1);e(n,t)}function $l(n,e,t=0){for(const r of n._children)$l(r,e,t+1);e(n,t)}function Wc(n,e,t=!0){if(e>n.size)throw new k(S.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,i=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-i)return Wc(s,e-i,t);if(e===i)return{node:n,offset:r};if(!t&&s.paddedSize===e-i)return{node:n,offset:r+1};if(s.paddedSize>e-i)return Wc(s,e-i-1,t);i+=s.paddedSize,r+=1}return{node:n,offset:r}}function ly(n){return n.isText||n.children.length===0?n:ly(n.children[0])}function j1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let i=t.parent,s=t;for(;i&&s===i.left;)s=i,i=i.parent;return i}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new K1(e,t,!0);const i=this.comparator(e,r.key);return i<0?r.left=this.putInternal(e,t,r.left):i>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class Rt{constructor(e,t){u(this,"parentID");u(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new Rt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,i;return r.isText?(r.parent.children[0]===r&&t===0?i=r.parent:i=r,r=r.parent):t===0?i=r:i=r.children[t-1],Rt.of(r.id,Ce.of(i.getCreatedAt(),i.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return Rt.of(Ce.of(kt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ce.of(kt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),i=e.findFloorNode(t);let s=e.findFloorNode(r);if(!i||!s)throw new k(S.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[i,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ce{constructor(e,t){u(this,"createdAt");u(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ce(e,t)}static fromStruct(e){return Ce.of(kt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=i.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new k(S.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new k(S.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new Xe(Ce.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new Xe(Ce.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,i){const s=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new Tr);const i=[];for(const[s,o]of Object.entries(t))i.push(this.attrs.set(s,o,r));return i}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Hc(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Hc)};return n.attrs&&(e.attributes=es((t=n.attrs)==null?void 0:t.toObject())),e}function Qf(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${en(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>Qf(t)).join("")}`}function cy(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(cy),size:n.size,isRemoved:n.isRemoved}}class Et extends Do{constructor(t,r){super(r);u(this,"indexTree");u(this,"nodeMapByID");this.indexTree=new V1(t),this.nodeMapByID=new uy(Ce.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(t,r){return new Et(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[i,s]=t.toTreeNodePair(this);let o=s;const a=i===o,l=o.parent&&!a?o.parent:i;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const c=l.allChildren,d=a?0:c.indexOf(o)+1;for(let h=d;h{const P=T.getCreatedAt().getActorID();let p,g=0n;if(o===void 0&&s===void 0?g=_s:o.size()>0?g=o.get(P)?o.get(P):0n:p=s.has(P)?s.get(P):bt,T.canStyle(i,p,g)&&r){const v=y.get(P),I=T.getCreatedAt();(!v||I.after(v))&&y.set(P,I);const E=T.setAttrs(r,i),N=E.reduce((q,[,$])=>($&&(q[$.getKey()]=m[$.getKey()]),q),{}),D=T.parent,R=T.prevSibling||T.parent;Object.keys(N).length>0&&h.push({type:"style",from:this.toIndex(D,R),to:this.toIndex(T,T),fromPath:this.toPath(D,R),toPath:this.toPath(T,T),actor:i.getActorID(),value:N});for(const[q]of E)q&&w.push({parent:T,child:q})}}),[y,w,h]}removeStyle(t,r,i,s,o){const[a,l]=this.findNodesAndSplitText(t[0],i),[c,d]=this.findNodesAndSplitText(t[1],i),h=[],m=new Map,y=[];return this.traverseInPosRange(a,l,c,d,([w])=>{const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=_s:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):bt,w.canStyle(i,P,p)&&r){const g=m.get(T),v=w.getCreatedAt();(!g||v.after(g))&&m.set(T,v),w.attrs||(w.attrs=new Tr);for(const N of r){const D=w.attrs.remove(N,i);for(const R of D)y.push({parent:w,child:R})}const I=w.parent,E=w.prevSibling||w.parent;h.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(I,E),to:this.toIndex(w,w),fromPath:this.toPath(I,E),toPath:this.toPath(w,w),value:r})}}),[m,y,h]}edit(t,r,i,s,o,a,l){const[c,d]=this.findNodesAndSplitText(t[0],s),[h,m]=this.findNodesAndSplitText(t[1],s),y=this.toIndex(c,d),w=this.toPath(c,d),T=[],P=[],p=[],g=new Map;this.traverseInPosRange(c,d,h,m,([E,N],D)=>{if(N===me.Start&&!D)for(const Se of E.children)p.push(Se);const R=E.getCreatedAt().getActorID();let q,$=0n;if(l===void 0&&a===void 0?$=_s:l.size()>0?$=l.get(R)?l.get(R):0n:q=a.has(R)?a.get(R):bt,E.canDelete(s,q,$)||T.includes(E.parent)){const Se=g.get(R),Er=E.getCreatedAt();(!Se||Er.after(Se))&&g.set(R,Er),(N===me.Text||N===me.Start)&&T.push(E),P.push([E,N])}});const v=this.makeDeletionChanges(P,s),I=[];for(const E of T)E.remove(s),E.isRemoved&&I.push({parent:this,child:E});for(const E of p)E.removedAt||c.append(E);if(i>0){let E=0,N=c,D=d;for(;E{c.isRemoved&&(R.remove(s),I.push({parent:this,child:R})),this.nodeMapByID.put(R.id,R)}),D.isRemoved||E.push(D);if(E.length){const D=E.map(R=>Hc(R));v.length&&v[v.length-1].from===y?v[v.length-1].value=D:v.push({type:"content",from:y,to:y,fromPath:w,toPath:w,actor:s.getActorID(),value:D})}}return[v,I,g]}editT(t,r,i,s,o){const a=this.findPos(t[0]),l=this.findPos(t[1]);this.edit([a,l],r,i,s,o)}move(t,r,i){throw new k(S.ErrUnimplemented,`not implemented: ${t}, ${r}, ${i}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,i=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=i}if(i){const o=this.findFloorNode(i);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const i of r.getGCPairs())t.push(i)}),t}findPos(t,r=!0){const i=this.indexTree.findTreePos(t,r);return Rt.fromTreePos(i)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Qf(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(i,s=void 0,o=void 0,a=0)=>{var y,w,T,P;let l,c,d;const h=i.isText?{node:i,offset:0}:s&&o?this.toTreePos(s,o):null;h&&(l=this.indexTree.indexOf(h),c=this.indexTree.treePosToPath(h),d=Rt.fromTreePos(h).toStruct());const m={type:i.type,parent:s==null?void 0:s.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(y=i.removedAt)==null?void 0:y.toTestString(),insPrev:(w=i.insPrevID)==null?void 0:w.toTestString(),insNext:(T=i.insNextID)==null?void 0:T.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:a,attributes:i.attrs?es((P=i.attrs)==null?void 0:P.toObject()):void 0,index:l,path:c,pos:d};for(let p=0;p0&&p===i[i.length-1].to?(i[i.length-1].to=g,i[i.length-1].toPath=this.toPath(P,y)):i.push({type:"content",from:p,to:g,fromPath:this.toPath(T,h),toPath:this.toPath(P,y),actor:r.getActorID()}))}return i.reverse()}findRightToken([t,r]){if(r===me.Start){const l=t.allChildren;return l.length>0?[l[0],l[0].isText?me.Text:me.Start]:[t,me.End]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===s.length-1)return[i,me.End];const a=s[o+1];return[a,a.isText?me.Text:me.Start]}findLeftToken([t,r]){if(r===me.End){const l=t.allChildren;if(l.length>0){const c=l[l.length-1];return[c,c.isText?me.Text:me.End]}return[t,me.Start]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===0)return[i,me.Start];const a=s[o-1];return[a,a.isText?me.Text:me.End]}}class Bo extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"contents");u(this,"splitLevel");u(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,i,s,o,a,l){return new Bo(t,r,i,s,o,a,l)}execute(t,r,i){var d;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[l,c]=a.edit([this.fromPos,this.toPos],(d=this.contents)==null?void 0:d.map(h=>h.deepcopy()),this.splitLevel,o,(()=>{let h=o.getDelimiter();return this.contents!==void 0&&(h+=this.contents.length),()=>kt.of(o.getLamport(),++h,o.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const h of c)t.registerGCPair(h);return{opInfos:l.map(({from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${r},${i},${s.map(o=>Qf(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ts{constructor(e){u(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}unset(e){this.vector.delete(e)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,i]of e){const s=this.vector.get(r),o=s&&s>i?s:i;t.set(r,o)}for(const[r,i]of this){const s=e.get(r),o=s&&s>i?s:i;t.set(r,o)}return new ts(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new ts(e)}filter(e){const t=new Map;for(const[r]of e){const i=this.vector.get(r);i!==void 0&&t.set(r,i)}return new ts(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const H1=new ts(new Map);class ar{constructor(e,t,r,i,s){u(this,"clientSeq");u(this,"serverSeq");u(this,"lamport");u(this,"actor");u(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=i,this.actor=r}static of(e,t,r,i,s){return new ar(e,t,r,i,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new ar(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n;let r=e.versionVector;r.size()===0&&(r=r.deepcopy(),r.set(e.actor,e.lamport));const i=this.versionVector.max(r),s=new ar(this.clientSeq,t,this.actor,i);return s.versionVector.set(this.actor,t),s}setClocks(e,t){const r=e>this.lamport?e+1n:this.lamport+1n;t.unset(Jl);const i=this.versionVector.max(t);return i.set(this.actor,r),ar.of(this.clientSeq,r,this.actor,i)}createTimeTicket(e){return kt.of(this.lamport,e,this.actor)}setActor(e){return new ar(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new ar(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const _1=new ar(0,0n,Jl,H1);class ms{constructor({id:e,operations:t,presenceChange:r,message:i}){u(this,"id");u(this,"operations");u(this,"presenceChange");u(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=i}static create({id:e,operations:t,presenceChange:r,message:i}){return new ms({id:e,operations:t,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const i=[],s=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:l,reverseOp:c}=a;i.push(...l),c&&s.unshift(c)}return this.presenceChange&&(this.presenceChange.type===Xr.Put?t.set(this.id.getActorID(),Nt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:i,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:de.bytesToHex(de.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>de.bytesToHex(de.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:i,message:s}=e;return ms.create({id:de.bytesToChangeID(de.hexToBytes(t)),operations:r==null?void 0:r.map(o=>de.bytesToOperation(de.hexToBytes(o))),presenceChange:i,message:s})}}class zl{constructor(e,t,r,i,s,o,a){u(this,"documentKey");u(this,"checkpoint");u(this,"isRemoved");u(this,"changes");u(this,"snapshot");u(this,"minSyncedTicket");u(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=i,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,r,i,s,o,a){return new zl(e,t,r,i,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class ns{constructor(e,t){u(this,"serverSeq");u(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new ns(e,t)}increaseClientSeq(e){return e===0?this:new ns(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return ns.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const G1=new ns(0n,0);class rn{constructor(e,t){u(this,"createdAt");u(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new rn(e,t)}static fromStruct(e){return rn.of(kt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new rn(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Y1=rn.of(bt,0);class Ft{constructor(e,t){u(this,"id");u(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Ft(e,t)}static fromStruct(e){const t=rn.fromStruct(e.id);return Ft.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return rn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class _r extends ty{constructor(t,r,i){super(r);u(this,"id");u(this,"removedAt");u(this,"prev");u(this,"next");u(this,"insPrev");u(this,"insNext");this.id=t,this.removedAt=i}static create(t,r){return new _r(t,r)}static createComparator(){return(t,r)=>{const i=t.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let i=e;for(;i&&i!==t;)r.push(i),i=i.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new k(S.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const i=e.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,i){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,r,i),a=new Map,l=new Map,c=this.makeChanges(o,t);for(const d of s){const h=d.getCreatedAt().getActorID();(!a.has(h)||d.getID().getCreatedAt().after(a.get(h)))&&a.set(h,d.getID().getCreatedAt()),l.set(d.getID().toIDString(),d),d.remove(t)}return this.deleteIndexNodes(o),[c,a,l]}filterNodes(e,t,r,i){const s=[],o=[],[a,l]=this.findEdgesOfCandidates(e);o.push(a);for(const c of e){const d=c.getCreatedAt().getActorID();let h,m=0n;i===void 0&&r===void 0?m=_s:i.size()>0?m=i.get(d)?i.get(d):0n:h=r.has(d)?r.get(d):bt,c.canDelete(t,h,m)?s.push(c):o.push(c)}return o.push(l),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let i,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var sn=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(sn||{});class tt extends Do{constructor(t,r,i){super(i);u(this,"valueType");u(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=K.fromNumber(r).toInt():this.value=ig(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=K.fromNumber(r):this.value=r;break;default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,i){return new tt(t,r,i)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return K.fromBytesLE(Array.from(r));default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=tt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof K?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!tt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===ve.Long?this.value=this.value+t.getValue().toInt():this.value=K.fromNumber(this.value+ig(t.getValue())).toInt(),this}}class ys extends Jt{constructor(t,r,i){super(t,i);u(this,"value");this.value=r}static create(t,r,i){return new ys(t,r,i)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof tt))throw new k(S.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,s=this.value.deepcopy();return i.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),i=t.getType()===ve.Long?t.getValue().multiply(-1):t.getValue()*-1;return ys.create(this.getParentCreatedAt(),se.of(i,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class pr extends Jt{constructor(t,r,i,s,o,a,l){super(t,l);u(this,"fromPos");u(this,"toPos");u(this,"maxCreatedAtMapByActor");u(this,"attributes");u(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,r,i,s,o,a){return new pr(t,r,i,s,o,[],a)}static createTreeRemoveStyleOperation(t,r,i,s,o,a){return new pr(t,r,i,s,new Map,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,l;if(this.attributes.size){const c={};[...this.attributes].forEach(([d,h])=>c[d]=h),[,l,a]=o.style([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const c=this.attributesToRemove;[,l,a]=o.removeStyle([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const c of l)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h,fromPath:m,toPath:y})=>({type:"tree-style",from:c,to:d,value:this.attributes.size?{attributes:h}:{attributesToRemove:h},fromPath:m,toPath:y,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Q1(n){const e=new _f,t=e.data;for(const[r,i]of Object.entries(n))t[r]=JSON.stringify(i);return e}function X1(n){if(n.type===Xr.Put)return new vo({type:Ii.PUT,presence:Q1(n.presence)});if(n.type===Xr.Clear)return new vo({type:Ii.CLEAR});throw new k(S.ErrUnimplemented,"unimplemented type")}function Z1(n){return new Xp({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function fy(n){return new Fl({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:ld(n.getActorID()),versionVector:Xf(n.getVersionVector())})}function F(n){if(n)return new b({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:ld(n.getActorID())})}function Xf(n){if(!n)return;const e=new Ml;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function dy(n){switch(n){case ve.Null:return z.NULL;case ve.Boolean:return z.BOOLEAN;case ve.Integer:return z.INTEGER;case ve.Long:return z.LONG;case ve.Double:return z.DOUBLE;case ve.String:return z.STRING;case ve.Bytes:return z.BYTES;case ve.Date:return z.DATE;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function hy(n){switch(n){case sn.IntegerCnt:return z.INTEGER_CNT;case sn.LongCnt:return z.LONG_CNT;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function Iu(n){if(n instanceof He)return new at({type:z.JSON_OBJECT,createdAt:F(n.getCreatedAt()),value:xy(n)});if(n instanceof et)return new at({type:z.JSON_ARRAY,createdAt:F(n.getCreatedAt()),value:DS(n)});if(n instanceof It)return new at({type:z.TEXT,createdAt:F(n.getCreatedAt())});if(n instanceof se)return new at({type:dy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof tt)return new at({type:hy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Et)return new at({type:z.TREE,createdAt:F(n.getCreatedAt()),value:RS(n)});throw new k(S.ErrUnimplemented,"unimplemented element")}function eS(n){return new po({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function ta(n){return new kr({createdAt:F(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function na(n){return new Ai({parentId:Gs(n.getParentID()),leftSiblingId:Gs(n.getLeftSiblingID())})}function Gs(n){return new Wr({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function gy(n){const e=new Hf;if(n instanceof Ei){const t=n,r=new Qa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Oo){const t=n,r=new Xa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof Fr){const t=n,r=new Za;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Zr){const t=n,r=new el;r.parentCreatedAt=F(t.getParentCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Ro){const t=n,r=new tl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ta(t.getFromPos()),r.to=ta(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);r.content=t.getContent();const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof Lo){const t=n,r=new nl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ta(t.getFromPos()),r.to=ta(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof ys){const t=n,r=new rl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof Bo){const t=n,r=new il,i=r.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())i[s]=F(o);r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos()),r.contents=aS(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=F(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof pr){const t=n,r=new sl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=t.getAttributesToRemove();if(s.length>0)r.attributesToRemove=s;else{const o=r.attributes;for(const[a,l]of t.getAttributes())o[a]=l}r.executedAt=F(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new k(S.ErrUnimplemented,"unimplemented operation");return e}function tS(n){const e=[];for(const t of n)e.push(gy(t));return e}function nS(n){const e=new Yp({id:fy(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=tS(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=X1(n.getPresenceChange())),e}function rS(n){const e=[];for(const t of n)e.push(nS(t));return e}function iS(n){const e=[];for(const t of n)e.push(new Qp({key:t.getStrKey(),element:ed(t.getValue())}));return e}function sS(n){const e=[];for(const t of n)e.push(new dl({element:ed(t.getValue())}));return e}function oS(n){const e=[];for(const t of n){const r=new hl;r.id=eS(t.getID()),r.value=t.getValue().getContent(),r.removedAt=F(t.getRemovedAt());const i=r.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new ds;a.value=o.getValue(),a.updatedAt=F(o.getUpdatedAt()),i[o.getKey()]=a}e.push(r)}return e}function aS(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new gl({content:Zf(t)}));return e}function lS(n){const e={};for(const t of n)e[t.getKey()]=new ds({value:t.getValue(),updatedAt:F(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function Zf(n){if(!n)return[];const e=[];return $l(n,(t,r)=>{const i=new yo({id:Gs(t.id),type:t.type,removedAt:F(t.removedAt),depth:r});t.isText&&(i.value=t.value),t.insPrevID&&(i.insPrevId=Gs(t.insPrevID)),t.insNextID&&(i.insNextId=Gs(t.insNextID)),t.attrs&&(i.attributes=lS(t.attrs)),e.push(i)}),e}function uS(n){const e=new _e;return e.body.case="jsonObject",e.body.value=new ol({nodes:iS(n.getRHT()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function my(n){const e=new _e;return e.body.case="jsonArray",e.body.value=new al({nodes:sS(n.getElements()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function cS(n){const e=new _e;return e.body.case="primitive",e.body.value=new ll({type:dy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function fS(n){const e=new _e;return e.body.case="text",e.body.value=new ul({nodes:oS(n.getRGATreeSplit()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function dS(n){const e=new _e;return e.body.case="counter",e.body.value=new cl({type:hy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function py(n){const e=new _e;return e.body.case="tree",e.body.value=new fl({nodes:Zf(n.getRoot()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function ed(n){if(n instanceof He)return uS(n);if(n instanceof et)return my(n);if(n instanceof se)return cS(n);if(n instanceof It)return fS(n);if(n instanceof tt)return dS(n);if(n instanceof Et)return py(n);throw new k(S.ErrUnimplemented,"unimplemented element")}function hS(n){return new Ir({documentKey:n.getDocumentKey(),checkpoint:Z1(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:rS(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Xf(n.getVersionVector()),minSyncedTicket:F(n.getMinSyncedTicket())})}function Fs(n){if(!(n instanceof ne))return{};const e=n.findDetails(R1);for(const t of e)return t.metadata;return{}}function Oi(n){return Fs(n).code??""}function yy(n){return ar.of(n.clientSeq,BigInt(n.lamport),od(n.actorId),td(n.versionVector),BigInt(n.serverSeq))}function td(n){if(!n)return;const e=new ts;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return kt.of(BigInt(n.lamport),n.delimiter,od(n.actorId))}function nd(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function gS(n){const e=n.type;if(e===Ii.PUT){const t=nd(n.presence);return{type:Xr.Put,presence:t}}if(e===Ii.CLEAR)return{type:Xr.Clear};throw new k(S.ErrInvalidType,`unsupported type: ${e}`)}function mS(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,nd(r))}),e}function vy(n){switch(n){case z.NULL:return ve.Null;case z.BOOLEAN:return ve.Boolean;case z.INTEGER:return ve.Integer;case z.LONG:return ve.Long;case z.DOUBLE:return ve.Double;case z.STRING:return ve.String;case z.BYTES:return ve.Bytes;case z.DATE:return ve.Date}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function yl(n){switch(n){case z.INTEGER_CNT:return sn.IntegerCnt;case z.LONG_CNT:return sn.LongCnt}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function Eu(n){switch(n.type){case z.JSON_OBJECT:return n.value?Ey(n.value):He.create(M(n.createdAt));case z.JSON_ARRAY:return n.value?PS(n.value):et.create(M(n.createdAt));case z.TEXT:return It.create(ps.create(),M(n.createdAt));case z.TREE:return OS(n.value);case z.NULL:case z.BOOLEAN:case z.INTEGER:case z.LONG:case z.DOUBLE:case z.STRING:case z.BYTES:case z.DATE:return se.of(se.valueFromBytes(vy(n.type),n.value),M(n.createdAt));case z.INTEGER_CNT:case z.LONG_CNT:return tt.create(yl(n.type),tt.valueFromBytes(yl(n.type),n.value),M(n.createdAt))}}function ra(n){return Ft.of(rn.of(M(n.createdAt),n.offset),n.relativeOffset)}function wy(n){return rn.of(M(n.createdAt),n.offset)}function pS(n){const e=To.create(n.value);Object.entries(n.attributes).forEach(([r,i])=>{e.setAttr(r,i.value,M(i.updatedAt))});const t=_r.create(wy(n.id),e);return t.remove(M(n.removedAt)),t}function Ri(n){return Rt.of(Ys(n.parentId),Ys(n.leftSiblingId))}function Ys(n){return Ce.of(M(n.createdAt),n.offset)}function yS(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=rd(t.content);e.push(r)}),e}function rd(n){if(n.length===0)return;const e=[];for(const i of n)e.push(wS(i));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let i=e.length-2;i>=0;i--)r.get(n[i].depth-1).prepend(e[i]),r.set(n[i].depth,e[i]);return t.updateDescendantsSize(),Et.create(t,bt).getRoot()}function vS(n){const e=Tr.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function wS(n){const e=Ys(n.id),t=Xe.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=vS(n.attributes)),n.insPrevId&&(t.insPrevID=Ys(n.insPrevId)),n.insNextId&&(t.insNextID=Ys(n.insNextId)),t.removedAt=M(n.removedAt),t}function Sy(n){if(n.body.case==="set"){const e=n.body.value;return Ei.create(e.key,Eu(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Oo.create(M(e.parentCreatedAt),M(e.prevCreatedAt),Eu(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Fr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Zr.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Ro.create(M(e.parentCreatedAt),ra(e.from),ra(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Lo.create(M(e.parentCreatedAt),ra(e.from),ra(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ys.create(M(e.parentCreatedAt),Eu(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,i])=>{t.set(r,M(i))}),Bo.create(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),yS(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,i=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{i.set(s,M(o))}),(r==null?void 0:r.length)>0?pr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),i,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),pr.create(M(e.parentCreatedAt),Ri(e.from),Ri(e.to),i,t,M(e.executedAt)))}else throw new k(S.ErrUnimplemented,"unimplemented operation")}}function SS(n){const e=[];for(const t of n){const r=Sy(t);r&&e.push(r)}return e}function ky(n){const e=[];for(const t of n)e.push(ms.create({id:yy(t.id),operations:SS(t.operations),presenceChange:t.presenceChange?gS(t.presenceChange):void 0,message:t.message}));return e}function kS(n){return ns.of(BigInt(n.serverSeq),n.clientSeq)}function TS(n){return zl.create(n.documentKey,kS(n.checkpoint),n.isRemoved,ky(n.changes),td(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function Ty(n){const e=new wo;for(const r of n.nodes){const i=id(r.element);e.set(r.key,i,i.getPositionedAt())}const t=new He(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Ay(n){const e=new ko;for(const r of n.nodes)e.insert(id(r.element));const t=new et(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function AS(n){const e=se.of(se.valueFromBytes(vy(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function IS(n){const e=new ps;let t=e.getHead();for(const i of n.nodes){const s=e.insertAfter(t,pS(i));i.insPrevId&&s.setInsPrev(e.findNode(wy(i.insPrevId))),t=s}const r=new It(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function ES(n){const e=tt.create(yl(n.type),tt.valueFromBytes(yl(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function Iy(n){const e=rd(n.nodes);return Et.create(e,M(n.createdAt))}function id(n){if(n.body.case==="jsonObject")return Ty(n.body.value);if(n.body.case==="jsonArray")return Ay(n.body.value);if(n.body.case==="primitive")return AS(n.body.value);if(n.body.case==="text")return IS(n.body.value);if(n.body.case==="counter")return ES(n.body.value);if(n.body.case==="tree")return Iy(n.body.value);throw new k(S.ErrUnimplemented,"unimplemented element")}function xS(n){if(!n)return{root:He.create(bt),presences:new Map};const e=Tc.fromBinary(n);return{root:id(e.root),presences:mS(e.presences)}}function CS(n){const e=Xf(n);return sd(e.toBinary())}function NS(n){const e=ad(n),t=Ml.fromBinary(e);return td(t)}function Ey(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Ty(e.body.value)}function xy(n){return ed(n).toBinary()}function PS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Ay(e.body.value)}function DS(n){return my(n).toBinary()}function OS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=_e.fromBinary(n);return Iy(e.body.value)}function RS(n){return py(n).toBinary()}function sd(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function od(n){return sd(n)}function ad(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function ld(n){return ad(n)}function LS(n){const e=Fl.fromBinary(n);return yy(e)}function BS(n){const e=Hf.fromBinary(n);return Sy(e)}const de={fromPresence:nd,toChangePack:hS,fromChangePack:TS,fromChanges:ky,toTreeNodes:Zf,fromTreeNodes:rd,objectToBytes:xy,bytesToObject:Ey,bytesToSnapshot:xS,bytesToHex:sd,hexToBytes:ad,toHexString:od,toUint8Array:ld,toOperation:gy,toChangeID:fy,PbChangeID:Fl,bytesToChangeID:LS,bytesToOperation:BS,versionVectorToHex:CS,hexToVersionVector:NS};var Me=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Me||{});let ai=3;function Cy(n){ai=n}const J={trivial:(...n)=>{ai>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{ai>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{ai>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{ai>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{ai>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>ai<=n};function Ny(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class bS{constructor(e,t,r,i,s){u(this,"reconnectStreamDelay");u(this,"doc");u(this,"docID");u(this,"syncMode");u(this,"remoteChangeEventReceived");u(this,"watchStream");u(this,"watchLoopTimerID");u(this,"watchAbortController");u(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ia.RealtimeSyncOff?!1:this.syncMode===Ia.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ia.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const xu=()=>{};class FS{constructor(e){u(this,"finalized",!1);u(this,"observers",[]);u(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(!e)throw new k(S.ErrInvalidArgument,"missing observer");if(this.finalized)throw new k(S.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?i=e:i={next:e,error:t,complete:r},i.next===void 0&&(i.next=xu),i.error===void 0&&(i.error=xu),i.complete===void 0&&(i.complete=xu);const s=Ny(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(a){J.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Hi{constructor(e,t,r,i){u(this,"id");u(this,"delimiter");u(this,"message");u(this,"root");u(this,"operations");u(this,"presenceChange");u(this,"previousPresence");u(this,"reversePresenceKeys");this.id=e,this.delimiter=ey,this.root=t,this.operations=[],this.previousPresence=Nt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(e,t,r,i){return new Hi(e,t,r,i)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ms.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class Ao{constructor(e){u(this,"rootObject");u(this,"elementPairMapByCreatedAt");u(this,"gcElementSetByCreatedAt");u(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof It||t instanceof Et)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new Ao(He.create(bt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const i=t.element.getCreatedAt(),s=t.parent.subPathOf(i);if(s===void 0)throw new k(S.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof Hr&&e.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(e){let t=0;const r=i=>{const s=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return r(e),e instanceof Hr&&e.getDescendants(i=>(r(i),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof Hr&&r.element.getDescendants(i=>(e.add(i.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new Ao(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),s=i.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(i.parent.purge(i.element),t+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Py(n,e){const t=new Io(n);return new Proxy(e,t.getHandlers())}class Io{constructor(e){u(this,"context");u(this,"handlers");this.context=e,this.handlers={set:(t,r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]=${JSON.stringify(i)}`),Io.setInternal(e,t,r,i),!0),get:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():li(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),Io.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,i){if(r.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=vl(e,i,s),a=t.set(r,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(Ei.create(r,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const r={};for(const[i,s]of Object.entries(t)){if(i.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=vl(e,s,o);r[i]=a}return r}static deleteInternal(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByKey(r,i);s&&(e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function JS(n,e){const t=new le(n,e);return new Proxy(e,t.getHandlers())}function $S(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zS(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class le{constructor(e,t){u(this,"context");u(this,"handlers");u(this,"array");this.context=e,this.array=t,this.handlers={get:(r,i,s)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return Nr(e,a)}:i==="getElementByIndex"?o=>{const a=r.get(o);return Nr(e,a)}:i==="getLast"?()=>Nr(e,r.getLast()):i==="deleteByID"?o=>{const a=le.deleteInternalByID(e,r,o);return Nr(e,a)}:i==="insertAfter"?(o,a)=>{const l=le.insertAfterInternal(e,r,o,a);return Nr(e,l)}:i==="insertBefore"?(o,a)=>{const l=le.insertBeforeInternal(e,r,o,a);return Nr(e,l)}:i==="moveBefore"?(o,a)=>{le.moveBeforeInternal(e,r,o,a)}:i==="moveAfter"?(o,a)=>{le.moveAfterInternal(e,r,o,a)}:i==="moveFront"?o=>{le.moveFrontInternal(e,r,o)}:i==="moveLast"?o=>{le.moveLastInternal(e,r,o)}:$S(i)?li(e,r.get(Number(i))):i==="push"?o=>le.pushInternal(e,r,o):i==="splice"?(o,a,...l)=>le.splice(e,r,o,a,...l):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?le.iteratorInternal.bind(this,e,r):i==="includes"?(o,a)=>le.includes(e,r,o,a):i==="indexOf"?(o,a)=>le.indexOf(e,r,o,a):i==="lastIndexOf"?(o,a)=>le.lastIndexOf(e,r,o,a):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>le.toTestString(r):typeof i=="string"&&zS(i)?(...o)=>{const a=Array.from(r).map(l=>li(e,l));return Array.prototype[i].apply(a,o)}:Reflect.get(r,i,s),deleteProperty:(r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`array[${i}]`),le.deleteInternalByIndex(e,r,Number.parseInt(i)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield Nr(e,r)}static buildArrayElements(e,t){const r=[];for(const i of t){const s=e.issueTimeTicket(),o=vl(e,i,s);r.push(o)}return r}static pushInternal(e,t,r){return le.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,i){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,i,s),e.push(Fr.create(t.getCreatedAt(),o,i,s))}static moveAfterInternal(e,t,r,i){const s=e.issueTimeTicket();t.moveAfter(r,i,s),e.push(Fr.create(t.getCreatedAt(),r,i,s))}static moveFrontInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),r,i),e.push(Fr.create(t.getCreatedAt(),s.getCreatedAt(),r,i))}static moveLastInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,r,i),e.push(Fr.create(t.getCreatedAt(),s,r,i))}static insertAfterInternal(e,t,r,i){const s=e.issueTimeTicket(),o=vl(e,i,s);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Oo.create(t.getCreatedAt(),r,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,r,i){return le.insertAfterInternal(e,t,t.getPrevCreatedAt(r),i)}static deleteInternalByIndex(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByIndex(r,i);if(s)return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,r){const i=e.issueTimeTicket(),s=t.delete(r,i);return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static splice(e,t,r,i,...s){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),l=i===void 0?o:i<0?a:Math.min(a+i,o),c=[];for(let d=a;d=s)return!1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).includes(r,o);for(let l=o;l=s)return-1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).indexOf(r,o);for(let l=o;l=s?s-1:i<0?i+s:i;if(o<0)return-1;if(se.isSupport(r))return Array.from(t).map(c=>li(e,c)).lastIndexOf(r,o);for(let l=o;l>0;l--)if(((a=t.get(l))==null?void 0:a.getID())===r.getID())return l;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class Ul{constructor(e,t){u(this,"context");u(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,i){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${r}`);const o=i?hs(i):void 0,a=this.context.issueTimeTicket(),[l,,c,d]=this.text.edit(s,r,a,o);for(const h of c)this.context.registerGCPair(h);return this.context.push(new Ro(this.text.getCreatedAt(),s[0],s[1],l,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(d)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`STYL: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const s=hs(r),o=this.context.issueTimeTicket(),[a,l]=this.text.setStyle(i,s,o);for(const c of l)this.context.registerGCPair(c);return this.context.push(new Lo(this.text.getCreatedAt(),i[0],i[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Ft.fromStruct(e[0]),Ft.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class jl{constructor(e,t){u(this,"valueType");u(this,"value");u(this,"context");u(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=se.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(ys.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function ud(n,e,t){const{type:r}=n,i=t.issueTimeTicket();if(r===mr){Dy(n);const{value:s}=n,o=Xe.create(Ce.of(i,0),r,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!Zp(o)){const c=hs(o);a=new Tr;for(const[d,h]of Object.entries(c))a.set(d,h,i)}const l=Xe.create(Ce.of(i,0),r,void 0,a);e.append(l);for(const c of s)ud(c,l,t)}}function US(n,e){const{type:t}=e,r=n.issueTimeTicket();let i;if(e.type===mr){const{value:s}=e;i=Xe.create(Ce.of(r,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!Zp(o)){const l=hs(o);a=new Tr;for(const[c,d]of Object.entries(l))a.set(c,d,r)}i=Xe.create(Ce.of(n.issueTimeTicket(),0),t,void 0,a);for(const l of s)ud(l,i,n)}return i}function Dy(n){if(!n.value.length)throw new k(S.ErrInvalidArgument,"text node cannot have empty value");return!0}function sg(n){if(!n.length)return!0;if(n[0].type===mr)for(const t of n){const{type:r}=t;if(r!==mr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together");Dy(t)}else for(const t of n){const{type:r}=t;if(r===mr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class Vl{constructor(e){u(this,"initialRoot");u(this,"context");u(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return Xe.create(Ce.of(e.issueTimeTicket(),0),$1);const t=Xe.create(Ce.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)ud(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?hs(t):void 0,[a]=this.tree.style([r,i],o,s);this.context.push(pr.create(this.tree.getCreatedAt(),r,i,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?hs(r):void 0,[l,c]=this.tree.style([i,s],a,o);for(const d of c)this.context.registerGCPair(d);this.context.push(pr.create(this.tree.getCreatedAt(),i,s,l,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,l]=this.tree.removeStyle([i,s],r,o);for(const c of l)this.context.registerGCPair(c);this.context.push(pr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,s,a,r,o))}editInternal(e,t,r,i=0){var c;if(r.length!==0&&r[0]&&(sg(r),r[0].type!==mr))for(const d of r){const{children:h=[]}=d;sg(h)}const s=this.context.getLastTimeTicket();let o=new Array;if(((c=r[0])==null?void 0:c.type)===mr){let d="";for(const h of r){const{value:m}=h;d+=m}o.push(Xe.create(Ce.of(this.context.issueTimeTicket(),0),mr,d))}else o=r.map(d=>d&&US(this.context,d)).filter(d=>d);const[,a,l]=this.tree.edit([e,t],o.length?o.map(d=>d==null?void 0:d.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(const d of a)this.context.registerGCPair(d);return this.context.push(Bo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,l,s)),!0}editByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulkByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r,i)}edit(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulk(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r,i)}toXML(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Rt.fromStruct(e[0]),Rt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Rt.fromStruct(e[0]),Rt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function og(n,e){return Py(n,e)}function Nr(n,e){if(e){if(e instanceof se)return e;if(e instanceof He)return Py(n,e);if(e instanceof et)return JS(n,e);if(e instanceof It)return new Ul(n,e);if(e instanceof tt){const t=new jl(sn.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof Et){const t=new Vl;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function li(n,e){const t=Nr(n,e);return t instanceof se?t.getValue():t}function vl(n,e,t){let r;if(se.isSupport(e))r=se.of(e,t);else if(Array.isArray(e))r=et.create(t,le.buildArrayElements(n,e));else if(typeof e=="object")e instanceof Ul?(r=It.create(ps.create(),t),e.initialize(n,r)):e instanceof jl?(r=tt.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof Vl?(r=Et.create(e.buildRoot(n),t),e.initialize(n,r)):r=He.create(t,Io.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const ag=50;class jS{constructor(){u(this,"undoStack",[]);u(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=ag&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=ag&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const VS="yorkie-devtools-panel",qS="yorkie-devtools-sdk";let Li="disconnected";const lg=new Map,Aa=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Aa);function ia(n,e){(e!=null&&e.force||Li!=="disconnected")&&window.postMessage({source:qS,...n},"*")}function KS(n){if(!n.isEnableDevtools()||typeof window>"u"||lg.has(n.getKey()))return;Aa.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Ee.StatusChanged&&r.type!==Ee.Snapshot&&r.type!==Ee.LocalChange&&r.type!==Ee.RemoteChange&&r.type!==Ee.Initialized&&r.type!==Ee.Watched&&r.type!==Ee.Unwatched&&r.type!==Ee.PresenceChanged)||(Aa.get(n.getKey()).push(t),Li==="synced"&&ia({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});lg.set(n.getKey(),[e]),ia({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var i;if(((i=t.data)==null?void 0:i.source)!==VS)return;switch(t.data.msg){case"devtools::connect":if(Li!=="disconnected")break;Li="connected",ia({msg:"doc::available",docKey:n.getKey()}),J.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Li="disconnected",J.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Li="synced",ia({msg:"doc::sync::full",docKey:n.getKey(),events:Aa.get(n.getKey())}),J.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Pr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Pr||{}),Ee=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Ee||{}),_c=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(_c||{}),Gc=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Gc||{});class Oy{constructor(e,t){u(this,"key");u(this,"status");u(this,"opts");u(this,"changeID");u(this,"checkpoint");u(this,"localChanges");u(this,"root");u(this,"clone");u(this,"eventStream");u(this,"eventStreamObserver");u(this,"onlineClients");u(this,"presences");u(this,"history");u(this,"internalHistory");u(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=Ao.create(),this.changeID=_1,this.checkpoint=G1,this.localChanges=[],this.eventStream=MS(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new jS,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},KS(this)}update(e,t){if(this.getStatus()==="removed")throw new k(S.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const s=og(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(s,new Au(i,this.clone.presences.get(r)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(i.hasChange()){J.isEnabled(Me.Trivial)&&J.trivial(`trying to update a local change: ${this.toJSON()}`);const s=i.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,Y.Local),l=i.getReversePresence();l&&a.push({type:"presence",value:l}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const c=[];o.length>0&&c.push({type:"local-change",source:Y.Local,value:{message:s.getMessage()||"",operations:o,actor:r,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&c.push({type:"presence-changed",source:Y.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(c),J.isEnabled(Me.Trivial)&&J.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,i){if(typeof e=="string"){if(typeof t!="function")throw new k(S.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="initialized"&&c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||a(c)},r,i)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="initialized"&&c.type!=="presence-changed"||c.type==="presence-changed"&&c.value.clientID!==this.changeID.getActorID()||a(c)},r,i)}if(e==="others"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||c.value.clientID!==this.changeID.getActorID()&&a(c)},r,i)}if(e==="connection"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="connection-changed"&&a(c)},r,i)}if(e==="status"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="status-changed"&&a(c)},r,i)}if(e==="sync"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="sync-status-changed"&&a(c)},r,i)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="local-broadcast"&&a(c)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="broadcast"&&a(c)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(l=>{for(const c of l)c.type==="auth-error"&&a(c)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,i)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const l of a){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const c=[];for(const d of l.value.operations)this.isSameElementOrChildOf(d.path,s)&&c.push(d);c.length&&o({...l,value:{...l.value,operations:c}})}},r,i)}if(typeof e=="function"){const s=e,o=t,a=r;return this.eventStream.subscribe(l=>{for(const c of l)c.type!=="snapshot"&&c.type!=="local-change"&&c.type!=="remote-change"||s(c)},o,a)}throw new k(S.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((s,o)=>s===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),Y.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),J.isEnabled(Me.Trivial)&&J.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Nt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return zl.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return og(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,i=-1){const{root:s,presences:o}=de.bytesToSnapshot(r);this.root=new Ao(s),this.presences=o,this.changeID=this.changeID.setClocks(t.maxLamport(),t),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,Y.Local),this.publish([{type:"snapshot",source:Y.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?de.bytesToHex(r):void 0,snapshotVector:de.versionVectorToHex(t)}}])}applyChanges(e,t){J.isEnabled(Me.Debug)&&J.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),J.isEnabled(Me.Trivial)&&J.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` +`));for(const r of e)this.applyChange(r,t);J.isEnabled(Me.Debug)&&J.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],i=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(i)){const o=e.getPresenceChange();switch(o.type){case Xr.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:t,value:{clientID:i,presence:o.presence}}:{type:"watched",source:Y.Remote,value:{clientID:i,presence:o.presence}});break;case Xr.Clear:r.push({type:"unwatched",source:Y.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===Y.Remote?{type:"remote-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const i of t)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:Y.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,i=[];if(t===yi.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:Y.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===yi.DOCUMENT_UNWATCHED){const s=this.getPresence(r);this.removeOnlineClient(r),s&&i.push({type:"unwatched",source:Y.Remote,value:{clientID:r,presence:s}})}else if(t===yi.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:s,payload:JSON.parse(a.decode(o))}})}i.length>0&&this.publish(i)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(Jl),this.publish([{source:e==="removed"?Y.Remote:Y.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:i}=e.value;if(!t)return;this.applySnapshot(BigInt(r),de.hexToVersionVector(i),de.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ms.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:i}of e.value)t.add(r),this.presences.set(r,i);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new k(S.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const i of t)if(r=r[i],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Nt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Nt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Nt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Nt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Nt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new k(S.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof Jt)){new Au(t,Nt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),l=[];i.length>0&&l.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}redo(){if(this.isUpdating)throw new k(S.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof Jt)){new Au(t,Nt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),l=[];i.length>0&&l.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&l.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const i={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function WS(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const HS="yorkie-js-sdk",_S="0.5.6",GS="Yorkie JS SDK",YS="./src/yorkie.ts",QS={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},XS=["dist"],ZS={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},ek={node:">=18.0.0",npm:">=7.1.0"},tk={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},nk={name:"hackerwins",email:"susukang98@gmail.com"},rk="Apache-2.0",ik={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},sk="https://github.com/yorkie-team/yorkie-js-sdk#readme",ok={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ak={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},ug={name:HS,version:_S,description:GS,main:YS,publishConfig:QS,files:XS,scripts:ZS,engines:ek,repository:tk,author:nk,license:rk,bugs:ik,homepage:sk,devDependencies:ok,dependencies:ak};function lk(){return n=>async e=>(e.header.set("x-yorkie-user-agent",ug.name+"/"+ug.version),await n(e))}const uk=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ia=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ia||{});const sa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Cu={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class Ry{constructor(e,t){u(this,"id");u(this,"key");u(this,"status");u(this,"attachmentMap");u(this,"apiKey");u(this,"authTokenInjector");u(this,"conditions");u(this,"syncLoopDuration");u(this,"reconnectStreamDelay");u(this,"retrySyncLoopDelay");u(this,"rpcClient");u(this,"setAuthToken");u(this,"taskQueue");u(this,"processing",!1);u(this,"keepalive",!1);t=t||sa,this.key=t.key?t.key:Ny(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??sa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??sa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??sa.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=WS(this.apiKey);this.setAuthToken=i,this.rpcClient=l1(O1,D1({baseUrl:e,interceptors:[r,lk()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),J.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw J.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),J.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw J.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Pr.Detached)throw new k(S.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async s=>{var d;const{topic:o,payload:a}=s.value,l=(d=s.options)==null?void 0:d.error,c=s.options;try{await this.broadcast(e.getKey(),o,a,c)}catch(h){h instanceof Error&&(l==null||l(h))}}),i=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:de.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=de.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Pr.Removed)return e;e.applyStatus(Pr.Attached),this.attachmentMap.set(e.getKey(),new bS(this.reconnectStreamDelay,e,s.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(e.getKey()),J.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const l=t.initialRoot;e.update(c=>{for(const[d,h]of Object.entries(l))if(!a.has(d)){const m=d;c[m]=h}})}return e}).catch(async s=>{throw J.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((i,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:de.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);return e.applyChangePack(s),e.getStatus()!==Pr.Removed&&e.applyStatus(Pr.Detached),this.detachInternal(e.getKey()),J.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async i=>{throw J.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(e,t){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const i=r.syncMode;return i===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=de.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),J.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async i=>{throw J.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,i){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);if(!uk(r))throw new k(S.ErrInvalidArgument,"payload is not serializable");const o=(i==null?void 0:i.maxRetries)??Cu.maxRetries,a=Cu.maxBackoff;let l=0;const c=h=>Math.min(Cu.initialRetryInterval*2**h,a),d=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{J.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async h=>{if(J.error(`[BC] c:"${this.getKey()}" err:`,h),await this.handleConnectError(h))if(h instanceof ne&&Oi(h)===S.ErrUnauthenticated&&s.doc.publish([{type:Ee.AuthError,value:{reason:Fs(h).reason,method:"Broadcast"}}]),ld(),c(l-1)),J.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw J.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),h;else throw h}));return d()}runSyncLoop(){const e=()=>{if(!this.isActive()){J.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof ne&&Oi(i)===S.ErrUnauthenticated&&r.doc.publish([{type:Ee.AuthError,value:{reason:Fs(i).reason,method:"PushPull"}}]),i})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{J.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};J.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new k(S.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:i.signal});return t.doc.publish([{type:Ee.ConnectionChanged,value:_c.Connected}]),J.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const c of s)this.handleWatchDocumentsResponse(t,c),c.body.case==="initialization"&&o([s,i])}catch(c){t.doc.resetOnlineClients(),t.doc.publish([{type:Ee.Initialized,source:Y.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Ee.ConnectionChanged,value:_c.Disconnected}]),J.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(c)?(c instanceof ne&&Oi(c)===S.ErrUnauthenticated&&t.doc.publish([{type:Ee.AuthError,value:{reason:Fs(c).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(c)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===yi.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Pr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:i}=e,s=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:de.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=de.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Ee.SyncStatusChanged,value:Gc.Synced}]),r.getStatus()===Pr.Removed&&this.detachInternal(r.getKey());const l=r.getKey(),c=a.getChangeSize();return J.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${s.getChangeSize()} pull:${c} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Ee.SyncStatusChanged,value:Gc.SyncFailed}]),J.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof ne))return!1;if(e.code===_.Canceled||e.code===_.Unknown||e.code===_.ResourceExhausted||e.code===_.Unavailable)return!0;if(Oi(e)===S.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Fs(e).reason);this.setAuthToken(t)}return!0}return(Oi(e)===S.ErrClientNotActivated||Oi(e)===S.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{J.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const cg={Client:Ry,Document:Oy,Primitive:se,Text:Ul,Counter:jl,Tree:Vl,LogLevel:Me,setLogLevel:Cy,IntType:sn.IntegerCnt,LongType:sn.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:Ry,Document:Oy,Primitive:se,Text:Ul,Counter:jl,Tree:Vl,LogLevel:Me,setLogLevel:Cy,IntType:sn.IntegerCnt,LongType:sn.LongCnt});var Ly={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var r=[],i=0;i{n.newTodo||n.onSave(r.target.value)},onChange:r=>{t(r.target.value)},onKeyDown:r=>{const i=r.target;r.which===13&&(n.onSave(i.value.trim()),n.newTodo&&t(""))}})}function fk(n){return Q.jsxs("header",{className:"header",children:[Q.jsx("h1",{children:"todos"}),Q.jsx(By,{newTodo:!0,onSave:e=>{e.length!==0&&n.addTodo(e)},placeholder:"What needs to be done?"})]})}function dk(n){const[e,t]=Mr.useState(!1),{todo:r,completeTodo:i,editTodo:s,deleteTodo:o}=n;return Q.jsx("li",{className:cd({completed:r.completed,editing:e}),children:e?Q.jsx(By,{text:r.text,editing:e,onSave:a=>{a.length===0?o(r.id):s(r.id,a),t(!1)}}):Q.jsxs("div",{className:"view",children:[Q.jsx("input",{id:`item-input-${r.id}`,className:"toggle",type:"checkbox",checked:r.completed,onChange:()=>i(r.id)}),Q.jsx("label",{htmlFor:`item-input-${r.id}`,onDoubleClick:()=>t(!0),children:r.text}),Q.jsx("button",{type:"button","aria-label":"Delete",className:"destroy",onClick:()=>o(r.id)})]})})}const hk={SHOW_ALL:"All",SHOW_ACTIVE:"Active",SHOW_COMPLETED:"Completed"};function gk(n){const{activeCount:e,completedCount:t,filter:r,onClearCompleted:i,onShow:s}=n;return Q.jsxs("footer",{className:"footer",children:[Q.jsxs("span",{className:"todo-count",children:[Q.jsx("strong",{children:e||"No"})," ",e===1?"item":"items"," left"]}),Q.jsx("ul",{className:"filters",children:["SHOW_ALL","SHOW_ACTIVE","SHOW_COMPLETED"].map(o=>Q.jsx("li",{children:Q.jsx("button",{type:"button",className:cd({selected:o===r}),style:{cursor:"pointer"},onClick:()=>s(o),children:hk[o]})},o))}),!!t&&Q.jsx("button",{type:"button",className:"clear-completed",onClick:i,children:"Clear completed"})]})}const mk={SHOW_ALL:n=>!0,SHOW_ACTIVE:n=>!n.completed,SHOW_COMPLETED:n=>n.completed};function pk(n){const[e,t]=Mr.useState("SHOW_ALL"),{todos:r,actions:i}=n,s=r.filter(mk[e]),o=r.reduce((l,c)=>c.completed?l+1:l,0),a=r.length-o;return r.length===0?null:Q.jsxs("section",{className:"main",children:[Q.jsx("input",{className:"toggle-all",type:"checkbox",defaultChecked:o===r.length,onChange:i.completeAll}),Q.jsx("ul",{className:"todo-list",children:s.map(l=>Q.jsx(dk,{todo:l,editTodo:i.editTodo,deleteTodo:i.deleteTodo,completeTodo:i.completeTodo},l.id))}),Q.jsx(gk,{completedCount:o,activeCount:a,filter:e,onClearCompleted:()=>i.clearCompleted(),onShow:t})]})}const yk=[{id:0,text:"Yorkie JS SDK",completed:!1},{id:1,text:"Garbage collection",completed:!1},{id:2,text:"RichText datatype",completed:!1}];function vk(){const[n]=Mr.useState(()=>new cg.Document(`react-todomvc-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`)),[e,t]=Mr.useState([]),r={addTodo:i=>{n==null||n.update(s=>{s.todos.push({id:s.todos.reduce((o,a)=>Math.max(a.id,o),-1)+1,completed:!1,text:i})})},deleteTodo:i=>{n==null||n.update(s=>{let o;for(const a of s.todos)if(a.id===i){o=a;break}o&&s.todos.deleteByID(o.getID())})},editTodo:(i,s)=>{n==null||n.update(o=>{let a;for(const l of o.todos)if(l.id===i){a=l;break}a&&(a.text=s)})},completeTodo:i=>{n==null||n.update(s=>{let o;for(const a of s.todos)if(a.id===i){o=a;break}o&&(o.completed=!o.completed)})},clearCompleted:()=>{n==null||n.update(i=>{for(const s of i.todos)if(s.completed){const o=s;i.todos.deleteByID(o.getID())}},"")}};return Mr.useEffect(()=>{const i=new cg.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});async function s(o,a){await i.activate(),await i.attach(o),o.update(l=>{l.todos||(l.todos=yk)},"create default todos if not exists"),o.subscribe(l=>{a(o.getRoot().todos)}),a(o.getRoot().todos)}s(n,o=>{t(o)})},[]),Q.jsxs("div",{className:"App",children:[Q.jsx(fk,{addTodo:r.addTodo}),Q.jsx(pk,{todos:e,actions:r})]})}Cu.createRoot(document.getElementById("root")).render(Q.jsx(vk,{})); +*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var r=[],i=0;i{n.newTodo||n.onSave(r.target.value)},onChange:r=>{t(r.target.value)},onKeyDown:r=>{const i=r.target;r.which===13&&(n.onSave(i.value.trim()),n.newTodo&&t(""))}})}function fk(n){return Q.jsxs("header",{className:"header",children:[Q.jsx("h1",{children:"todos"}),Q.jsx(By,{newTodo:!0,onSave:e=>{e.length!==0&&n.addTodo(e)},placeholder:"What needs to be done?"})]})}function dk(n){const[e,t]=Mr.useState(!1),{todo:r,completeTodo:i,editTodo:s,deleteTodo:o}=n;return Q.jsx("li",{className:cd({completed:r.completed,editing:e}),children:e?Q.jsx(By,{text:r.text,editing:e,onSave:a=>{a.length===0?o(r.id):s(r.id,a),t(!1)}}):Q.jsxs("div",{className:"view",children:[Q.jsx("input",{id:`item-input-${r.id}`,className:"toggle",type:"checkbox",checked:r.completed,onChange:()=>i(r.id)}),Q.jsx("label",{htmlFor:`item-input-${r.id}`,onDoubleClick:()=>t(!0),children:r.text}),Q.jsx("button",{type:"button","aria-label":"Delete",className:"destroy",onClick:()=>o(r.id)})]})})}const hk={SHOW_ALL:"All",SHOW_ACTIVE:"Active",SHOW_COMPLETED:"Completed"};function gk(n){const{activeCount:e,completedCount:t,filter:r,onClearCompleted:i,onShow:s}=n;return Q.jsxs("footer",{className:"footer",children:[Q.jsxs("span",{className:"todo-count",children:[Q.jsx("strong",{children:e||"No"})," ",e===1?"item":"items"," left"]}),Q.jsx("ul",{className:"filters",children:["SHOW_ALL","SHOW_ACTIVE","SHOW_COMPLETED"].map(o=>Q.jsx("li",{children:Q.jsx("button",{type:"button",className:cd({selected:o===r}),style:{cursor:"pointer"},onClick:()=>s(o),children:hk[o]})},o))}),!!t&&Q.jsx("button",{type:"button",className:"clear-completed",onClick:i,children:"Clear completed"})]})}const mk={SHOW_ALL:n=>!0,SHOW_ACTIVE:n=>!n.completed,SHOW_COMPLETED:n=>n.completed};function pk(n){const[e,t]=Mr.useState("SHOW_ALL"),{todos:r,actions:i}=n,s=r.filter(mk[e]),o=r.reduce((l,c)=>c.completed?l+1:l,0),a=r.length-o;return r.length===0?null:Q.jsxs("section",{className:"main",children:[Q.jsx("input",{className:"toggle-all",type:"checkbox",defaultChecked:o===r.length,onChange:i.completeAll}),Q.jsx("ul",{className:"todo-list",children:s.map(l=>Q.jsx(dk,{todo:l,editTodo:i.editTodo,deleteTodo:i.deleteTodo,completeTodo:i.completeTodo},l.id))}),Q.jsx(gk,{completedCount:o,activeCount:a,filter:e,onClearCompleted:()=>i.clearCompleted(),onShow:t})]})}const yk=[{id:0,text:"Yorkie JS SDK",completed:!1},{id:1,text:"Garbage collection",completed:!1},{id:2,text:"RichText datatype",completed:!1}];function vk(){const[n]=Mr.useState(()=>new cg.Document(`react-todomvc-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`)),[e,t]=Mr.useState([]),r={addTodo:i=>{n==null||n.update(s=>{s.todos.push({id:s.todos.reduce((o,a)=>Math.max(a.id,o),-1)+1,completed:!1,text:i})})},deleteTodo:i=>{n==null||n.update(s=>{let o;for(const a of s.todos)if(a.id===i){o=a;break}o&&s.todos.deleteByID(o.getID())})},editTodo:(i,s)=>{n==null||n.update(o=>{let a;for(const l of o.todos)if(l.id===i){a=l;break}a&&(a.text=s)})},completeTodo:i=>{n==null||n.update(s=>{let o;for(const a of s.todos)if(a.id===i){o=a;break}o&&(o.completed=!o.completed)})},clearCompleted:()=>{n==null||n.update(i=>{for(const s of i.todos)if(s.completed){const o=s;i.todos.deleteByID(o.getID())}},"")}};return Mr.useEffect(()=>{const i=new cg.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});async function s(o,a){await i.activate(),await i.attach(o),o.update(l=>{l.todos||(l.todos=yk)},"create default todos if not exists"),o.subscribe(l=>{a(o.getRoot().todos)}),a(o.getRoot().todos)}s(n,o=>{t(o)})},[]),Q.jsxs("div",{className:"App",children:[Q.jsx(fk,{addTodo:r.addTodo}),Q.jsx(pk,{todos:e,actions:r})]})}Nu.createRoot(document.getElementById("root")).render(Q.jsx(vk,{})); diff --git a/examples/react-todomvc/index.html b/examples/react-todomvc/index.html index 8a751039c..97c89b32f 100644 --- a/examples/react-todomvc/index.html +++ b/examples/react-todomvc/index.html @@ -5,7 +5,7 @@ Vite + React + TS - + diff --git a/examples/simultaneous-cursors/assets/index-BJ1xyFxJ.js b/examples/simultaneous-cursors/assets/index-CUyGqr_M.js similarity index 76% rename from examples/simultaneous-cursors/assets/index-BJ1xyFxJ.js rename to examples/simultaneous-cursors/assets/index-CUyGqr_M.js index 99ce65e7b..d5c50cf2d 100644 --- a/examples/simultaneous-cursors/assets/index-BJ1xyFxJ.js +++ b/examples/simultaneous-cursors/assets/index-CUyGqr_M.js @@ -6,7 +6,7 @@ var My=Object.defineProperty;var Jy=(n,e,t)=>e in n?My(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var xo=Symbol.for("react.element"),$y=Symbol.for("react.portal"),zy=Symbol.for("react.fragment"),Uy=Symbol.for("react.strict_mode"),jy=Symbol.for("react.profiler"),Vy=Symbol.for("react.provider"),qy=Symbol.for("react.context"),Ky=Symbol.for("react.forward_ref"),Wy=Symbol.for("react.suspense"),_y=Symbol.for("react.memo"),Hy=Symbol.for("react.lazy"),gd=Symbol.iterator;function Gy(n){return n===null||typeof n!="object"?null:(n=gd&&n[gd]||n["@@iterator"],typeof n=="function"?n:null)}var mg={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},pg=Object.assign,yg={};function ws(n,e,t){this.props=n,this.context=e,this.refs=yg,this.updater=t||mg}ws.prototype.isReactComponent={};ws.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};ws.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function vg(){}vg.prototype=ws.prototype;function Xc(n,e,t){this.props=n,this.context=e,this.refs=yg,this.updater=t||mg}var Zc=Xc.prototype=new vg;Zc.constructor=Xc;pg(Zc,ws.prototype);Zc.isPureReactComponent=!0;var md=Array.isArray,wg=Object.prototype.hasOwnProperty,ef={current:null},Sg={key:!0,ref:!0,__self:!0,__source:!0};function kg(n,e,t){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)wg.call(e,r)&&!Sg.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=t;else if(1e in n?My(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var ev=je,tv=Symbol.for("react.element"),nv=Symbol.for("react.fragment"),rv=Object.prototype.hasOwnProperty,iv=ev.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sv={key:!0,ref:!0,__self:!0,__source:!0};function Tg(n,e,t){var r,i={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)rv.call(e,r)&&!sv.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:tv,type:n,key:s,ref:o,props:i,_owner:iv.current}}Sl.Fragment=nv;Sl.jsx=Tg;Sl.jsxs=Tg;hg.exports=Sl;var ce=hg.exports,Du={},Ag={exports:{}},it={},Ig={exports:{}},Eg={};/** + */var ev=je,tv=Symbol.for("react.element"),nv=Symbol.for("react.fragment"),rv=Object.prototype.hasOwnProperty,iv=ev.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sv={key:!0,ref:!0,__self:!0,__source:!0};function Tg(n,e,t){var r,i={},s=null,o=null;t!==void 0&&(s=""+t),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)rv.call(e,r)&&!sv.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:tv,type:n,key:s,ref:o,props:i,_owner:iv.current}}Sl.Fragment=nv;Sl.jsx=Tg;Sl.jsxs=Tg;hg.exports=Sl;var ce=hg.exports,Ou={},Ag={exports:{}},it={},Ig={exports:{}},Eg={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var My=Object.defineProperty;var Jy=(n,e,t)=>e in n?My(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(n){function e(B,U){var j=B.length;B.push(U);e:for(;0>>1,ke=B[fe];if(0>>1;fei(Wl,j))iii(Mo,Wl)?(B[fe]=Mo,B[ii]=j,fe=ii):(B[fe]=Wl,B[ri]=j,fe=ri);else if(iii(Mo,j))B[fe]=Mo,B[ii]=j,fe=ii;else break e}}return U}function i(B,U){var j=B.sortIndex-U.sortIndex;return j!==0?j:B.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var u=[],c=[],d=1,h=null,m=3,y=!1,w=!1,T=!1,P=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(B){for(var U=t(c);U!==null;){if(U.callback===null)r(c);else if(U.startTime<=B)r(c),U.sortIndex=U.expirationTime,e(u,U);else break;U=t(c)}}function I(B){if(T=!1,v(B),!w)if(t(u)!==null)w=!0,ql(E);else{var U=t(c);U!==null&&Kl(I,U.startTime-B)}}function E(B,U){w=!1,T&&(T=!1,p(R),R=-1),y=!0;var j=m;try{for(v(U),h=t(u);h!==null&&(!(h.expirationTime>U)||B&&!Se());){var fe=h.callback;if(typeof fe=="function"){h.callback=null,m=h.priorityLevel;var ke=fe(h.expirationTime<=U);U=n.unstable_now(),typeof ke=="function"?h.callback=ke:h===t(u)&&r(u),v(U)}else r(u);h=t(u)}if(h!==null)var Fo=!0;else{var ri=t(c);ri!==null&&Kl(I,ri.startTime-U),Fo=!1}return Fo}finally{h=null,m=j,y=!1}}var N=!1,D=null,R=-1,q=5,$=-1;function Se(){return!(n.unstable_now()-$B||125fe?(B.sortIndex=j,e(c,B),t(u)===null&&B===t(c)&&(T?(p(R),R=-1):T=!0,Kl(I,j-fe))):(B.sortIndex=ke,e(u,B),w||y||(w=!0,ql(E))),B},n.unstable_shouldYield=Se,n.unstable_wrapCallback=function(B){var U=m;return function(){var j=m;m=U;try{return B.apply(this,arguments)}finally{m=j}}}})(Eg);Ig.exports=Eg;var ov=Ig.exports;/** + */(function(n){function e(B,U){var j=B.length;B.push(U);e:for(;0>>1,ke=B[fe];if(0>>1;fei(_l,j))iii(Mo,_l)?(B[fe]=Mo,B[ii]=j,fe=ii):(B[fe]=_l,B[ri]=j,fe=ri);else if(iii(Mo,j))B[fe]=Mo,B[ii]=j,fe=ii;else break e}}return U}function i(B,U){var j=B.sortIndex-U.sortIndex;return j!==0?j:B.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();n.unstable_now=function(){return o.now()-a}}var u=[],c=[],d=1,h=null,m=3,y=!1,w=!1,T=!1,P=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(B){for(var U=t(c);U!==null;){if(U.callback===null)r(c);else if(U.startTime<=B)r(c),U.sortIndex=U.expirationTime,e(u,U);else break;U=t(c)}}function I(B){if(T=!1,v(B),!w)if(t(u)!==null)w=!0,Kl(E);else{var U=t(c);U!==null&&Wl(I,U.startTime-B)}}function E(B,U){w=!1,T&&(T=!1,p(R),R=-1),y=!0;var j=m;try{for(v(U),h=t(u);h!==null&&(!(h.expirationTime>U)||B&&!Se());){var fe=h.callback;if(typeof fe=="function"){h.callback=null,m=h.priorityLevel;var ke=fe(h.expirationTime<=U);U=n.unstable_now(),typeof ke=="function"?h.callback=ke:h===t(u)&&r(u),v(U)}else r(u);h=t(u)}if(h!==null)var Fo=!0;else{var ri=t(c);ri!==null&&Wl(I,ri.startTime-U),Fo=!1}return Fo}finally{h=null,m=j,y=!1}}var N=!1,D=null,R=-1,q=5,$=-1;function Se(){return!(n.unstable_now()-$B||125fe?(B.sortIndex=j,e(c,B),t(u)===null&&B===t(c)&&(T?(p(R),R=-1):T=!0,Wl(I,j-fe))):(B.sortIndex=ke,e(u,B),w||y||(w=!0,Kl(E))),B},n.unstable_shouldYield=Se,n.unstable_wrapCallback=function(B){var U=m;return function(){var j=m;m=U;try{return B.apply(this,arguments)}finally{m=j}}}})(Eg);Ig.exports=Eg;var ov=Ig.exports;/** * @license React * react-dom.production.min.js * @@ -30,16 +30,16 @@ var My=Object.defineProperty;var Jy=(n,e,t)=>e in n?My(n,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var xg=je,rt=ov;function x(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ou=Object.prototype.hasOwnProperty,av=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,yd={},vd={};function lv(n){return Ou.call(vd,n)?!0:Ou.call(yd,n)?!1:av.test(n)?vd[n]=!0:(yd[n]=!0,!1)}function uv(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function cv(n,e,t,r){if(e===null||typeof e>"u"||uv(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ze(n,e,t,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Ne[n]=new ze(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Ne[e]=new ze(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Ne[n]=new ze(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Ne[n]=new ze(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){Ne[n]=new ze(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Ne[n]=new ze(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Ne[n]=new ze(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Ne[n]=new ze(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Ne[n]=new ze(n,5,!1,n.toLowerCase(),null,!1,!1)});var nf=/[\-:]([a-z])/g;function rf(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(nf,rf);Ne[e]=new ze(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(nf,rf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(nf,rf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!0,!0)});function sf(n,e,t,r){var i=Ne.hasOwnProperty(e)?Ne[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ru=Object.prototype.hasOwnProperty,av=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,yd={},vd={};function lv(n){return Ru.call(vd,n)?!0:Ru.call(yd,n)?!1:av.test(n)?vd[n]=!0:(yd[n]=!0,!1)}function uv(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function cv(n,e,t,r){if(e===null||typeof e>"u"||uv(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function ze(n,e,t,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){Ne[n]=new ze(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];Ne[e]=new ze(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){Ne[n]=new ze(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){Ne[n]=new ze(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){Ne[n]=new ze(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){Ne[n]=new ze(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){Ne[n]=new ze(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){Ne[n]=new ze(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){Ne[n]=new ze(n,5,!1,n.toLowerCase(),null,!1,!1)});var rf=/[\-:]([a-z])/g;function sf(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(rf,sf);Ne[e]=new ze(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(rf,sf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(rf,sf);Ne[e]=new ze(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new ze("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){Ne[n]=new ze(n,1,!1,n.toLowerCase(),null,!0,!0)});function of(n,e,t,r){var i=Ne.hasOwnProperty(e)?Ne[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var u=` -`+i[o].replace(" at new "," at ");return n.displayName&&u.includes("")&&(u=u.replace("",n.displayName)),u}while(1<=o&&0<=a);break}}}finally{Gl=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Ls(n):""}function fv(n){switch(n.tag){case 5:return Ls(n.type);case 16:return Ls("Lazy");case 13:return Ls("Suspense");case 19:return Ls("SuspenseList");case 0:case 2:case 15:return n=Yl(n.type,!1),n;case 11:return n=Yl(n.type.render,!1),n;case 1:return n=Yl(n.type,!0),n;default:return""}}function bu(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Fi:return"Fragment";case bi:return"Portal";case Ru:return"Profiler";case of:return"StrictMode";case Lu:return"Suspense";case Bu:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Pg:return(n.displayName||"Context")+".Consumer";case Ng:return(n._context.displayName||"Context")+".Provider";case af:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case lf:return e=n.displayName||null,e!==null?e:bu(n.type)||"Memo";case Or:e=n._payload,n=n._init;try{return bu(n(e))}catch{}}return null}function dv(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return bu(e);case 8:return e===of?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Gr(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Og(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hv(n){var e=Og(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function zo(n){n._valueTracker||(n._valueTracker=hv(n))}function Rg(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Og(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function xa(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Fu(n,e){var t=e.checked;return oe({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function Sd(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Gr(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Lg(n,e){e=e.checked,e!=null&&sf(n,"checked",e,!1)}function Mu(n,e){Lg(n,e);var t=Gr(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?Ju(n,e.type,t):e.hasOwnProperty("defaultValue")&&Ju(n,e.type,Gr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function kd(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function Ju(n,e,t){(e!=="number"||xa(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Bs=Array.isArray;function Gi(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Uo.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Zs(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var Js={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gv=["Webkit","ms","Moz","O"];Object.keys(Js).forEach(function(n){gv.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),Js[e]=Js[n]})});function Mg(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||Js.hasOwnProperty(n)&&Js[n]?(""+e).trim():e+"px"}function Jg(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Mg(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var mv=oe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Uu(n,e){if(e){if(mv[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(x(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(x(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(x(61))}if(e.style!=null&&typeof e.style!="object")throw Error(x(62))}}function ju(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vu=null;function uf(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var qu=null,Yi=null,Qi=null;function Id(n){if(n=Po(n)){if(typeof qu!="function")throw Error(x(280));var e=n.stateNode;e&&(e=El(e),qu(n.stateNode,n.type,e))}}function $g(n){Yi?Qi?Qi.push(n):Qi=[n]:Yi=n}function zg(){if(Yi){var n=Yi,e=Qi;if(Qi=Yi=null,Id(n),e)for(n=0;n>>=0,n===0?32:31-(xv(n)/Cv|0)|0}var jo=64,Vo=4194304;function bs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Da(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~i;a!==0?r=bs(a):(s&=o,s!==0&&(r=bs(s)))}else o=t&~i,o!==0?r=bs(o):s!==0&&(r=bs(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function Co(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Bt(e),n[e]=t}function Ov(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=zs),Ld=" ",Bd=!1;function om(n,e){switch(n){case"keyup":return s0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function am(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mi=!1;function a0(n,e){switch(n){case"compositionend":return am(e);case"keypress":return e.which!==32?null:(Bd=!0,Ld);case"textInput":return n=e.data,n===Ld&&Bd?null:n;default:return null}}function l0(n,e){if(Mi)return n==="compositionend"||!yf&&om(n,e)?(n=im(),ca=gf=br=null,Mi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=Jd(t)}}function fm(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?fm(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function dm(){for(var n=window,e=xa();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=xa(n.document)}return e}function vf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function y0(n){var e=dm(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&fm(t.ownerDocument.documentElement,t)){if(r!==null&&vf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!n.extend&&s>r&&(i=r,r=s,s=i),i=$d(t,s);var o=$d(t,r);i&&o&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),s>r?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Ji=null,Yu=null,js=null,Qu=!1;function zd(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Qu||Ji==null||Ji!==xa(r)||(r=Ji,"selectionStart"in r&&vf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),js&&so(js,r)||(js=r,r=La(Yu,"onSelect"),0Ui||(n.current=rc[Ui],rc[Ui]=null,Ui--)}function Q(n,e){Ui++,rc[Ui]=n.current,n.current=e}var Yr={},Le=ti(Yr),Ke=ti(!1),wi=Yr;function ss(n,e){var t=n.type.contextTypes;if(!t)return Yr;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in t)i[s]=e[s];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function We(n){return n=n.childContextTypes,n!=null}function ba(){Z(Ke),Z(Le)}function _d(n,e,t){if(Le.current!==Yr)throw Error(x(168));Q(Le,e),Q(Ke,t)}function km(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,dv(n)||"Unknown",i));return oe({},t,r)}function Fa(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Yr,wi=Le.current,Q(Le,n),Q(Ke,Ke.current),!0}function Hd(n,e,t){var r=n.stateNode;if(!r)throw Error(x(169));t?(n=km(n,e,wi),r.__reactInternalMemoizedMergedChildContext=n,Z(Ke),Z(Le),Q(Le,n)):Z(Ke),Q(Ke,t)}var ar=null,xl=!1,cu=!1;function Tm(n){ar===null?ar=[n]:ar.push(n)}function P0(n){xl=!0,Tm(n)}function ni(){if(!cu&&ar!==null){cu=!0;var n=0,e=G;try{var t=ar;for(G=1;n>=o,i-=o,cr=1<<32-Bt(e)+i|t<R?(q=D,D=null):q=D.sibling;var $=m(p,D,v[R],I);if($===null){D===null&&(D=q);break}n&&D&&$.alternate===null&&e(p,D),g=s($,g,R),N===null?E=$:N.sibling=$,N=$,D=q}if(R===v.length)return t(p,D),ee&&oi(p,R),E;if(D===null){for(;RR?(q=D,D=null):q=D.sibling;var Se=m(p,D,$.value,I);if(Se===null){D===null&&(D=q);break}n&&D&&Se.alternate===null&&e(p,D),g=s(Se,g,R),N===null?E=Se:N.sibling=Se,N=Se,D=q}if($.done)return t(p,D),ee&&oi(p,R),E;if(D===null){for(;!$.done;R++,$=v.next())$=h(p,$.value,I),$!==null&&(g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return ee&&oi(p,R),E}for(D=r(p,D);!$.done;R++,$=v.next())$=y(D,p,R,$.value,I),$!==null&&(n&&$.alternate!==null&&D.delete($.key===null?R:$.key),g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return n&&D.forEach(function(xr){return e(p,xr)}),ee&&oi(p,R),E}function P(p,g,v,I){if(typeof v=="object"&&v!==null&&v.type===Fi&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case $o:e:{for(var E=v.key,N=g;N!==null;){if(N.key===E){if(E=v.type,E===Fi){if(N.tag===7){t(p,N.sibling),g=i(N,v.props.children),g.return=p,p=g;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Or&&th(E)===N.type){t(p,N.sibling),g=i(N,v.props),g.ref=Ns(p,N,v),g.return=p,p=g;break e}t(p,N);break}else e(p,N);N=N.sibling}v.type===Fi?(g=pi(v.props.children,p.mode,I,v.key),g.return=p,p=g):(I=va(v.type,v.key,v.props,null,p.mode,I),I.ref=Ns(p,g,v),I.return=p,p=I)}return o(p);case bi:e:{for(N=v.key;g!==null;){if(g.key===N)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){t(p,g.sibling),g=i(g,v.children||[]),g.return=p,p=g;break e}else{t(p,g);break}else e(p,g);g=g.sibling}g=vu(v,p.mode,I),g.return=p,p=g}return o(p);case Or:return N=v._init,P(p,g,N(v._payload),I)}if(Bs(v))return w(p,g,v,I);if(As(v))return T(p,g,v,I);Yo(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(t(p,g.sibling),g=i(g,v),g.return=p,p=g):(t(p,g),g=yu(v,p.mode,I),g.return=p,p=g),o(p)):t(p,g)}return P}var as=Dm(!0),Om=Dm(!1),Do={},rn=ti(Do),uo=ti(Do),co=ti(Do);function di(n){if(n===Do)throw Error(x(174));return n}function Cf(n,e){switch(Q(co,e),Q(uo,n),Q(rn,Do),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:zu(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=zu(e,n)}Z(rn),Q(rn,e)}function ls(){Z(rn),Z(uo),Z(co)}function Rm(n){di(co.current);var e=di(rn.current),t=zu(e,n.type);e!==t&&(Q(uo,n),Q(rn,t))}function Nf(n){uo.current===n&&(Z(rn),Z(uo))}var re=ti(0);function ja(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var fu=[];function Pf(){for(var n=0;nt?t:4,n(!0);var r=du.transition;du.transition={};try{n(!1),e()}finally{G=t,du.transition=r}}function Hm(){return It().memoizedState}function L0(n,e,t){var r=qr(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Gm(n))Ym(e,t);else if(t=xm(n,e,t,r),t!==null){var i=Je();bt(t,n,r,i),Qm(t,e,r)}}function B0(n,e,t){var r=qr(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Gm(n))Ym(e,i);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(i.hasEagerState=!0,i.eagerState=a,Jt(a,o)){var u=e.interleaved;u===null?(i.next=i,Ef(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}t=xm(n,e,i,r),t!==null&&(i=Je(),bt(t,n,r,i),Qm(t,e,r))}}function Gm(n){var e=n.alternate;return n===se||e!==null&&e===se}function Ym(n,e){Vs=Va=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function Qm(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,ff(n,t)}}var qa={readContext:At,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useInsertionEffect:Pe,useLayoutEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useMutableSource:Pe,useSyncExternalStore:Pe,useId:Pe,unstable_isNewReconciler:!1},b0={readContext:At,useCallback:function(n,e){return jt().memoizedState=[n,e===void 0?null:e],n},useContext:At,useEffect:rh,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ga(4194308,4,Vm.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ga(4194308,4,n,e)},useInsertionEffect:function(n,e){return ga(4,2,n,e)},useMemo:function(n,e){var t=jt();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=jt();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=L0.bind(null,se,n),[r.memoizedState,n]},useRef:function(n){var e=jt();return n={current:n},e.memoizedState=n},useState:nh,useDebugValue:Bf,useDeferredValue:function(n){return jt().memoizedState=n},useTransition:function(){var n=nh(!1),e=n[0];return n=R0.bind(null,n[1]),jt().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=se,i=jt();if(ee){if(t===void 0)throw Error(x(407));t=t()}else{if(t=e(),Ae===null)throw Error(x(349));ki&30||bm(r,e,t)}i.memoizedState=t;var s={value:t,getSnapshot:e};return i.queue=s,rh(Mm.bind(null,r,s,n),[n]),r.flags|=2048,go(9,Fm.bind(null,r,s,t,e),void 0,null),t},useId:function(){var n=jt(),e=Ae.identifierPrefix;if(ee){var t=fr,r=cr;t=(r&~(1<<32-Bt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=fo++,0")&&(u=u.replace("",n.displayName)),u}while(1<=o&&0<=a);break}}}finally{Yl=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?Ls(n):""}function fv(n){switch(n.tag){case 5:return Ls(n.type);case 16:return Ls("Lazy");case 13:return Ls("Suspense");case 19:return Ls("SuspenseList");case 0:case 2:case 15:return n=Ql(n.type,!1),n;case 11:return n=Ql(n.type.render,!1),n;case 1:return n=Ql(n.type,!0),n;default:return""}}function Fu(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Fi:return"Fragment";case bi:return"Portal";case Lu:return"Profiler";case af:return"StrictMode";case Bu:return"Suspense";case bu:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Pg:return(n.displayName||"Context")+".Consumer";case Ng:return(n._context.displayName||"Context")+".Provider";case lf:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case uf:return e=n.displayName||null,e!==null?e:Fu(n.type)||"Memo";case Or:e=n._payload,n=n._init;try{return Fu(n(e))}catch{}}return null}function dv(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Fu(e);case 8:return e===af?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Gr(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Og(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function hv(n){var e=Og(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function zo(n){n._valueTracker||(n._valueTracker=hv(n))}function Rg(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Og(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function xa(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Mu(n,e){var t=e.checked;return oe({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function Sd(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=Gr(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Lg(n,e){e=e.checked,e!=null&&of(n,"checked",e,!1)}function Ju(n,e){Lg(n,e);var t=Gr(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?$u(n,e.type,t):e.hasOwnProperty("defaultValue")&&$u(n,e.type,Gr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function kd(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function $u(n,e,t){(e!=="number"||xa(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Bs=Array.isArray;function Gi(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Uo.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function Zs(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var Js={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gv=["Webkit","ms","Moz","O"];Object.keys(Js).forEach(function(n){gv.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),Js[e]=Js[n]})});function Mg(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||Js.hasOwnProperty(n)&&Js[n]?(""+e).trim():e+"px"}function Jg(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Mg(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var mv=oe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ju(n,e){if(e){if(mv[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(x(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(x(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(x(61))}if(e.style!=null&&typeof e.style!="object")throw Error(x(62))}}function Vu(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var qu=null;function cf(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Ku=null,Yi=null,Qi=null;function Id(n){if(n=Po(n)){if(typeof Ku!="function")throw Error(x(280));var e=n.stateNode;e&&(e=El(e),Ku(n.stateNode,n.type,e))}}function $g(n){Yi?Qi?Qi.push(n):Qi=[n]:Yi=n}function zg(){if(Yi){var n=Yi,e=Qi;if(Qi=Yi=null,Id(n),e)for(n=0;n>>=0,n===0?32:31-(xv(n)/Cv|0)|0}var jo=64,Vo=4194304;function bs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Da(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,s=n.pingedLanes,o=t&268435455;if(o!==0){var a=o&~i;a!==0?r=bs(a):(s&=o,s!==0&&(r=bs(s)))}else o=t&~i,o!==0?r=bs(o):s!==0&&(r=bs(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function Co(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-Bt(e),n[e]=t}function Ov(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=zs),Ld=" ",Bd=!1;function om(n,e){switch(n){case"keyup":return s0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function am(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Mi=!1;function a0(n,e){switch(n){case"compositionend":return am(e);case"keypress":return e.which!==32?null:(Bd=!0,Ld);case"textInput":return n=e.data,n===Ld&&Bd?null:n;default:return null}}function l0(n,e){if(Mi)return n==="compositionend"||!vf&&om(n,e)?(n=im(),ca=mf=br=null,Mi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=Jd(t)}}function fm(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?fm(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function dm(){for(var n=window,e=xa();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=xa(n.document)}return e}function wf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function y0(n){var e=dm(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&fm(t.ownerDocument.documentElement,t)){if(r!==null&&wf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!n.extend&&s>r&&(i=r,r=s,s=i),i=$d(t,s);var o=$d(t,r);i&&o&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==o.node||n.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),s>r?(n.addRange(e),n.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Ji=null,Qu=null,js=null,Xu=!1;function zd(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;Xu||Ji==null||Ji!==xa(r)||(r=Ji,"selectionStart"in r&&wf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),js&&so(js,r)||(js=r,r=La(Qu,"onSelect"),0Ui||(n.current=ic[Ui],ic[Ui]=null,Ui--)}function Q(n,e){Ui++,ic[Ui]=n.current,n.current=e}var Yr={},Le=ti(Yr),Ke=ti(!1),wi=Yr;function ss(n,e){var t=n.type.contextTypes;if(!t)return Yr;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in t)i[s]=e[s];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function We(n){return n=n.childContextTypes,n!=null}function ba(){Z(Ke),Z(Le)}function _d(n,e,t){if(Le.current!==Yr)throw Error(x(168));Q(Le,e),Q(Ke,t)}function km(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(x(108,dv(n)||"Unknown",i));return oe({},t,r)}function Fa(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Yr,wi=Le.current,Q(Le,n),Q(Ke,Ke.current),!0}function Hd(n,e,t){var r=n.stateNode;if(!r)throw Error(x(169));t?(n=km(n,e,wi),r.__reactInternalMemoizedMergedChildContext=n,Z(Ke),Z(Le),Q(Le,n)):Z(Ke),Q(Ke,t)}var ar=null,xl=!1,fu=!1;function Tm(n){ar===null?ar=[n]:ar.push(n)}function P0(n){xl=!0,Tm(n)}function ni(){if(!fu&&ar!==null){fu=!0;var n=0,e=G;try{var t=ar;for(G=1;n>=o,i-=o,cr=1<<32-Bt(e)+i|t<R?(q=D,D=null):q=D.sibling;var $=m(p,D,v[R],I);if($===null){D===null&&(D=q);break}n&&D&&$.alternate===null&&e(p,D),g=s($,g,R),N===null?E=$:N.sibling=$,N=$,D=q}if(R===v.length)return t(p,D),ee&&oi(p,R),E;if(D===null){for(;RR?(q=D,D=null):q=D.sibling;var Se=m(p,D,$.value,I);if(Se===null){D===null&&(D=q);break}n&&D&&Se.alternate===null&&e(p,D),g=s(Se,g,R),N===null?E=Se:N.sibling=Se,N=Se,D=q}if($.done)return t(p,D),ee&&oi(p,R),E;if(D===null){for(;!$.done;R++,$=v.next())$=h(p,$.value,I),$!==null&&(g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return ee&&oi(p,R),E}for(D=r(p,D);!$.done;R++,$=v.next())$=y(D,p,R,$.value,I),$!==null&&(n&&$.alternate!==null&&D.delete($.key===null?R:$.key),g=s($,g,R),N===null?E=$:N.sibling=$,N=$);return n&&D.forEach(function(xr){return e(p,xr)}),ee&&oi(p,R),E}function P(p,g,v,I){if(typeof v=="object"&&v!==null&&v.type===Fi&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case $o:e:{for(var E=v.key,N=g;N!==null;){if(N.key===E){if(E=v.type,E===Fi){if(N.tag===7){t(p,N.sibling),g=i(N,v.props.children),g.return=p,p=g;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Or&&th(E)===N.type){t(p,N.sibling),g=i(N,v.props),g.ref=Ns(p,N,v),g.return=p,p=g;break e}t(p,N);break}else e(p,N);N=N.sibling}v.type===Fi?(g=pi(v.props.children,p.mode,I,v.key),g.return=p,p=g):(I=va(v.type,v.key,v.props,null,p.mode,I),I.ref=Ns(p,g,v),I.return=p,p=I)}return o(p);case bi:e:{for(N=v.key;g!==null;){if(g.key===N)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){t(p,g.sibling),g=i(g,v.children||[]),g.return=p,p=g;break e}else{t(p,g);break}else e(p,g);g=g.sibling}g=wu(v,p.mode,I),g.return=p,p=g}return o(p);case Or:return N=v._init,P(p,g,N(v._payload),I)}if(Bs(v))return w(p,g,v,I);if(As(v))return T(p,g,v,I);Yo(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(t(p,g.sibling),g=i(g,v),g.return=p,p=g):(t(p,g),g=vu(v,p.mode,I),g.return=p,p=g),o(p)):t(p,g)}return P}var as=Dm(!0),Om=Dm(!1),Do={},rn=ti(Do),uo=ti(Do),co=ti(Do);function di(n){if(n===Do)throw Error(x(174));return n}function Nf(n,e){switch(Q(co,e),Q(uo,n),Q(rn,Do),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Uu(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=Uu(e,n)}Z(rn),Q(rn,e)}function ls(){Z(rn),Z(uo),Z(co)}function Rm(n){di(co.current);var e=di(rn.current),t=Uu(e,n.type);e!==t&&(Q(uo,n),Q(rn,t))}function Pf(n){uo.current===n&&(Z(rn),Z(uo))}var re=ti(0);function ja(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var du=[];function Df(){for(var n=0;nt?t:4,n(!0);var r=hu.transition;hu.transition={};try{n(!1),e()}finally{G=t,hu.transition=r}}function Hm(){return It().memoizedState}function L0(n,e,t){var r=qr(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Gm(n))Ym(e,t);else if(t=xm(n,e,t,r),t!==null){var i=Je();bt(t,n,r,i),Qm(t,e,r)}}function B0(n,e,t){var r=qr(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Gm(n))Ym(e,i);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,t);if(i.hasEagerState=!0,i.eagerState=a,Jt(a,o)){var u=e.interleaved;u===null?(i.next=i,xf(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}t=xm(n,e,i,r),t!==null&&(i=Je(),bt(t,n,r,i),Qm(t,e,r))}}function Gm(n){var e=n.alternate;return n===se||e!==null&&e===se}function Ym(n,e){Vs=Va=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function Qm(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,df(n,t)}}var qa={readContext:At,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useInsertionEffect:Pe,useLayoutEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useMutableSource:Pe,useSyncExternalStore:Pe,useId:Pe,unstable_isNewReconciler:!1},b0={readContext:At,useCallback:function(n,e){return jt().memoizedState=[n,e===void 0?null:e],n},useContext:At,useEffect:rh,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,ga(4194308,4,Vm.bind(null,e,n),t)},useLayoutEffect:function(n,e){return ga(4194308,4,n,e)},useInsertionEffect:function(n,e){return ga(4,2,n,e)},useMemo:function(n,e){var t=jt();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=jt();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=L0.bind(null,se,n),[r.memoizedState,n]},useRef:function(n){var e=jt();return n={current:n},e.memoizedState=n},useState:nh,useDebugValue:bf,useDeferredValue:function(n){return jt().memoizedState=n},useTransition:function(){var n=nh(!1),e=n[0];return n=R0.bind(null,n[1]),jt().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=se,i=jt();if(ee){if(t===void 0)throw Error(x(407));t=t()}else{if(t=e(),Ae===null)throw Error(x(349));ki&30||bm(r,e,t)}i.memoizedState=t;var s={value:t,getSnapshot:e};return i.queue=s,rh(Mm.bind(null,r,s,n),[n]),r.flags|=2048,go(9,Fm.bind(null,r,s,t,e),void 0,null),t},useId:function(){var n=jt(),e=Ae.identifierPrefix;if(ee){var t=fr,r=cr;t=(r&~(1<<32-Bt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=fo++,0<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=o.createElement(t,{is:r.is}):(n=o.createElement(t),t==="select"&&(o=n,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):n=o.createElementNS(n,t),n[Kt]=e,n[lo]=r,op(n,e,!1,!1),e.stateNode=n;e:{switch(o=ju(t,r),t){case"dialog":X("cancel",n),X("close",n),i=r;break;case"iframe":case"object":case"embed":X("load",n),i=r;break;case"video":case"audio":for(i=0;ics&&(e.flags|=128,r=!0,Ps(s,!1),e.lanes=4194304)}else{if(!r)if(n=ja(o),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ps(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!ee)return De(e),null}else 2*he()-s.renderingStartTime>cs&&t!==1073741824&&(e.flags|=128,r=!0,Ps(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=he(),e.sibling=null,t=re.current,Q(re,r?t&1|2:t&1),e):(De(e),null);case 22:case 23:return zf(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ye&1073741824&&(De(e),e.subtreeFlags&6&&(e.flags|=8192)):De(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function V0(n,e){switch(Sf(e),e.tag){case 1:return We(e.type)&&ba(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return ls(),Z(Ke),Z(Le),Pf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Nf(e),null;case 13:if(Z(re),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(x(340));os()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return Z(re),null;case 4:return ls(),null;case 10:return If(e.type._context),null;case 22:case 23:return zf(),null;case 24:return null;default:return null}}var Xo=!1,Oe=!1,q0=typeof WeakSet=="function"?WeakSet:Set,L=null;function Ki(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){le(n,e,r)}else t.current=null}function mc(n,e,t){try{t()}catch(r){le(n,e,r)}}var dh=!1;function K0(n,e){if(Xu=Oa,n=dm(),vf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,u=-1,c=0,d=0,h=n,m=null;t:for(;;){for(var y;h!==t||i!==0&&h.nodeType!==3||(a=o+i),h!==s||r!==0&&h.nodeType!==3||(u=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(y=h.firstChild)!==null;)m=h,h=y;for(;;){if(h===n)break t;if(m===t&&++c===i&&(a=o),m===s&&++d===r&&(u=o),(y=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=y}t=a===-1||u===-1?null:{start:a,end:u}}else t=null}t=t||{start:0,end:0}}else t=null;for(Zu={focusedElem:n,selectionRange:t},Oa=!1,L=e;L!==null;)if(e=L,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,L=n;else for(;L!==null;){e=L;try{var w=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var T=w.memoizedProps,P=w.memoizedState,p=e.stateNode,g=p.getSnapshotBeforeUpdate(e.elementType===e.type?T:Nt(e.type,T),P);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(I){le(e,e.return,I)}if(n=e.sibling,n!==null){n.return=e.return,L=n;break}L=e.return}return w=dh,dh=!1,w}function qs(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var s=i.destroy;i.destroy=void 0,s!==void 0&&mc(e,t,s)}i=i.next}while(i!==r)}}function Pl(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function pc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function up(n){var e=n.alternate;e!==null&&(n.alternate=null,up(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Kt],delete e[lo],delete e[nc],delete e[C0],delete e[N0])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function cp(n){return n.tag===5||n.tag===3||n.tag===4}function hh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||cp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function yc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Ba));else if(r!==4&&(n=n.child,n!==null))for(yc(n,e,t),n=n.sibling;n!==null;)yc(n,e,t),n=n.sibling}function vc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(vc(n,e,t),n=n.sibling;n!==null;)vc(n,e,t),n=n.sibling}var Ie=null,Dt=!1;function Cr(n,e,t){for(t=t.child;t!==null;)fp(n,e,t),t=t.sibling}function fp(n,e,t){if(nn&&typeof nn.onCommitFiberUnmount=="function")try{nn.onCommitFiberUnmount(kl,t)}catch{}switch(t.tag){case 5:Oe||Ki(t,e);case 6:var r=Ie,i=Dt;Ie=null,Cr(n,e,t),Ie=r,Dt=i,Ie!==null&&(Dt?(n=Ie,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Ie.removeChild(t.stateNode));break;case 18:Ie!==null&&(Dt?(n=Ie,t=t.stateNode,n.nodeType===8?uu(n.parentNode,t):n.nodeType===1&&uu(n,t),ro(n)):uu(Ie,t.stateNode));break;case 4:r=Ie,i=Dt,Ie=t.stateNode.containerInfo,Dt=!0,Cr(n,e,t),Ie=r,Dt=i;break;case 0:case 11:case 14:case 15:if(!Oe&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&mc(t,e,o),i=i.next}while(i!==r)}Cr(n,e,t);break;case 1:if(!Oe&&(Ki(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(a){le(t,e,a)}Cr(n,e,t);break;case 21:Cr(n,e,t);break;case 22:t.mode&1?(Oe=(r=Oe)||t.memoizedState!==null,Cr(n,e,t),Oe=r):Cr(n,e,t);break;default:Cr(n,e,t)}}function gh(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new q0),e.forEach(function(r){var i=ew.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function Ct(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_0(r/1960))-r,10n?16:n,Fr===null)var r=!1;else{if(n=Fr,Fr=null,_a=0,W&6)throw Error(x(331));var i=W;for(W|=4,L=n.current;L!==null;){var s=L,o=s.child;if(L.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uhe()-Jf?mi(n,0):Mf|=t),_e(n,e)}function wp(n,e){e===0&&(n.mode&1?(e=Vo,Vo<<=1,!(Vo&130023424)&&(Vo=4194304)):e=1);var t=Je();n=Sr(n,e),n!==null&&(Co(n,e,t),_e(n,t))}function Z0(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),wp(n,t)}function ew(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),wp(n,t)}var Sp;Sp=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ke.current)Ve=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Ve=!1,U0(n,e,t);Ve=!!(n.flags&131072)}else Ve=!1,ee&&e.flags&1048576&&Am(e,Ja,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ma(n,e),n=e.pendingProps;var i=ss(e,Le.current);Zi(e,t),i=Of(null,e,r,n,i,t);var s=Rf();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,We(r)?(s=!0,Fa(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,xf(e),i.updater=Cl,e.stateNode=i,i._reactInternals=e,lc(e,r,n,t),e=fc(null,e,r,!0,s,t)):(e.tag=0,ee&&s&&wf(e),be(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(ma(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=nw(r),n=Nt(r,n),i){case 0:e=cc(null,e,r,n,t);break e;case 1:e=uh(null,e,r,n,t);break e;case 11:e=ah(null,e,r,n,t);break e;case 14:e=lh(null,e,r,Nt(r.type,n),t);break e}throw Error(x(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),cc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),uh(n,e,r,i,t);case 3:e:{if(rp(e),n===null)throw Error(x(387));r=e.pendingProps,s=e.memoizedState,i=s.element,Cm(n,e),Ua(e,r,null,t);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=us(Error(x(423)),e),e=ch(n,e,r,t,i);break e}else if(r!==i){i=us(Error(x(424)),e),e=ch(n,e,r,t,i);break e}else for(Qe=Ur(e.stateNode.containerInfo.firstChild),et=e,ee=!0,Ot=null,t=Om(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(os(),r===i){e=kr(n,e,t);break e}be(n,e,r,t)}e=e.child}return e;case 5:return Rm(e),n===null&&sc(e),r=e.type,i=e.pendingProps,s=n!==null?n.memoizedProps:null,o=i.children,ec(r,i)?o=null:s!==null&&ec(r,s)&&(e.flags|=32),np(n,e),be(n,e,o,t),e.child;case 6:return n===null&&sc(e),null;case 13:return ip(n,e,t);case 4:return Cf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=as(e,null,r,t):be(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),ah(n,e,r,i,t);case 7:return be(n,e,e.pendingProps,t),e.child;case 8:return be(n,e,e.pendingProps.children,t),e.child;case 12:return be(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Q($a,r._currentValue),r._currentValue=o,s!==null)if(Jt(s.value,o)){if(s.children===i.children&&!Ke.current){e=kr(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=mr(-1,t&-t),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?u.next=u:(u.next=d.next,d.next=u),c.pending=u}}s.lanes|=t,u=s.alternate,u!==null&&(u.lanes|=t),oc(s.return,t,e),a.lanes|=t;break}u=u.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(x(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),oc(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}be(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Zi(e,t),i=At(i),r=r(i),e.flags|=1,be(n,e,r,t),e.child;case 14:return r=e.type,i=Nt(r,e.pendingProps),i=Nt(r.type,i),lh(n,e,r,i,t);case 15:return ep(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),ma(n,e),e.tag=1,We(r)?(n=!0,Fa(e)):n=!1,Zi(e,t),Pm(e,r,i),lc(e,r,i,t),fc(null,e,r,!0,n,t);case 19:return sp(n,e,t);case 22:return tp(n,e,t)}throw Error(x(156,e.tag))};function kp(n,e){return _g(n,e)}function tw(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(n,e,t,r){return new tw(n,e,t,r)}function jf(n){return n=n.prototype,!(!n||!n.isReactComponent)}function nw(n){if(typeof n=="function")return jf(n)?1:0;if(n!=null){if(n=n.$$typeof,n===af)return 11;if(n===lf)return 14}return 2}function Kr(n,e){var t=n.alternate;return t===null?(t=vt(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function va(n,e,t,r,i,s){var o=2;if(r=n,typeof n=="function")jf(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case Fi:return pi(t.children,i,s,e);case of:o=8,i|=8;break;case Ru:return n=vt(12,t,e,i|2),n.elementType=Ru,n.lanes=s,n;case Lu:return n=vt(13,t,e,i),n.elementType=Lu,n.lanes=s,n;case Bu:return n=vt(19,t,e,i),n.elementType=Bu,n.lanes=s,n;case Dg:return Ol(t,i,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Ng:o=10;break e;case Pg:o=9;break e;case af:o=11;break e;case lf:o=14;break e;case Or:o=16,r=null;break e}throw Error(x(130,n==null?n:typeof n,""))}return e=vt(o,t,e,i),e.elementType=n,e.type=r,e.lanes=s,e}function pi(n,e,t,r){return n=vt(7,n,r,e),n.lanes=t,n}function Ol(n,e,t,r){return n=vt(22,n,r,e),n.elementType=Dg,n.lanes=t,n.stateNode={isHidden:!1},n}function yu(n,e,t){return n=vt(6,n,null,e),n.lanes=t,n}function vu(n,e,t){return e=vt(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function rw(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xl(0),this.expirationTimes=Xl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Vf(n,e,t,r,i,s,o,a,u){return n=new rw(n,e,t,a,u),e===1?(e=1,s===!0&&(e|=8)):e=0,s=vt(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},xf(s),n}function iw(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ep)}catch(n){console.error(n)}}Ep(),Ag.exports=it;var uw=Ag.exports,Th=uw;Du.createRoot=Th.createRoot,Du.hydrateRoot=Th.hydrateRoot;var H;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(H||(H={}));function Ah(n){const e=H[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class te extends Error{constructor(e,t=H.Unknown,r,i,s){super(cw(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=s}static from(e,t=H.Unknown){return e instanceof te?e:e instanceof Error?e.name=="AbortError"?new te(e.message,H.Canceled):new te(e.message,t,void 0,void 0,e):new te(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===te.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:i=>i===e.typeName?e:void 0}:e,r=[];for(const i of this.details){if("getType"in i){t.findMessage(i.getType().typeName)&&r.push(i);continue}const s=t.findMessage(i.type);if(s)try{r.push(s.fromBinary(i.value))}catch{}}return r}}function cw(n,e){return n.length?`[${Ah(e)}] ${n}`:`[${Ah(e)}]`}function ue(n,e){if(!n)throw new Error(e)}const fw=34028234663852886e22,dw=-34028234663852886e22,hw=4294967295,gw=2147483647,mw=-2147483648;function wa(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>gw||nhw||n<0)throw new Error("invalid uint 32: "+n)}function xp(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>fw||n({no:i.no,name:i.name,localName:n[i.no]})))}function Pp(n,e,t){const r=Object.create(null),i=Object.create(null),s=[];for(const o of e){const a=Dp(o);s.push(a),r[o.name]=a,i[o.no]=a}return{typeName:n,values:s,findName(o){return r[o]},findNumber(o){return i[o]}}}function yw(n,e,t){const r={};for(const i of e){const s=Dp(i);r[s.localName]=s.no,r[s.no]=s.localName}return Np(r,n,e),r}function Dp(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class O{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),i=r.runtime.bin,s=i.makeReadOptions(t);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const r=this.getType(),i=r.runtime.json,s=i.makeReadOptions(t);return i.readMessage(r,e,s,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,i=r.makeWriteOptions(e),s=i.writerFactory();return r.writeMessage(this,s,i),s.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,i=r.makeWriteOptions(e);return r.writeMessage(this,i)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function vw(n,e,t,r){var i;const s=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new O),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,u){return new o().fromBinary(a,u)},fromJson(a,u){return new o().fromJson(a,u)},fromJsonString(a,u){return new o().fromJsonString(a,u)},equals(a,u){return n.util.equals(o,a,u)}}),o}function ww(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>s,a=!(!(o>>>7)&&e==0),u=(a?o|128:o)&255;if(t.push(u),!a)return}const r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),u=(a?o|128:o)&255;if(t.push(u),!a)return}t.push(e>>>31&1)}}const Sa=4294967296;function Ih(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,i=0;function s(o,a){const u=Number(n.slice(o,a));i*=t,r=r*t+u,r>=Sa&&(i=i+(r/Sa|0),r=r%Sa)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Rp(r,i):_f(r,i)}function Sw(n,e){let t=_f(n,e);const r=t.hi&2147483648;r&&(t=Rp(t.lo,t.hi));const i=Op(t.lo,t.hi);return r?"-"+i:i}function Op(n,e){if({lo:n,hi:e}=kw(n,e),e<=2097151)return String(Sa*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,i=e>>16&65535;let s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2;const u=1e7;return s>=u&&(o+=Math.floor(s/u),s%=u),o>=u&&(a+=Math.floor(o/u),o%=u),a.toString()+Eh(o)+Eh(s)}function kw(n,e){return{lo:n>>>0,hi:e>>>0}}function _f(n,e){return{lo:n|0,hi:e|0}}function Rp(n,e){return e=~e,n?n=~n+1:e+=1,_f(n,e)}const Eh=n=>{const e=String(n);return"0000000".slice(e.length)+e};function xh(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Tw(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Ch={};function Aw(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof Ch!="object"||Ch.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const c=typeof u=="bigint"?u:BigInt(u);if(c>s||ca||cue(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>ue(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),t(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),t(i),Ih(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),Ih(i)},dec(i,s){return Sw(i,s)},uDec(i,s){return Op(i,s)}}}const ne=Aw();var A;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(A||(A={}));var Qr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(Qr||(Qr={}));function Nr(n,e,t){if(e===t)return!0;if(n==A.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ac(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return wa(e),xh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){xp(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ac(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){wa(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return wa(e),e=(e<<1^e>>31)>>>0,xh(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=ne.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=ne.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=ne.enc(e);return wu(t.lo,t.hi,this.buf),this}sint64(e){let t=ne.enc(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return wu(i,s,this.buf),this}uint64(e){let t=ne.uEnc(e);return wu(t.lo,t.hi,this.buf),this}}class Ew{constructor(e,t){this.varint64=ww,this.uint32=Tw,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ge.Varint:for(;this.buf[this.pos++]&128;);break;case ge.Bit64:this.pos+=4;case ge.Bit32:this.pos+=4;break;case ge.LengthDelimited:let i=this.uint32();this.pos+=i;break;case ge.StartGroup:for(;;){const[s,o]=this.tag();if(o===ge.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return ne.dec(...this.varint64())}uint64(){return ne.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,ne.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ne.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ne.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function xw(n,e,t,r){let i;return{typeName:e,extendee:t,get field(){if(!i){const s=typeof r=="function"?r():r;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,i=n.util.newFieldList([s]).list()[0]}return i},runtime:n}}function Bp(n){const e=n.field.localName,t=Object.create(null);return t[e]=Cw(n),[t,()=>t[e]]}function Cw(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return fs(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Nw(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let ur="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Fl=[];for(let n=0;n>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,i=0;for(let s=0;s>2],i=(r&3)<<4,t=1;break;case 1:e+=ur[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=ur[i|r>>6],e+=ur[r&63],t=0;break}return t&&(e+=ur[i],e+="=",t==1&&(e+="=")),e}};function Pw(n,e,t){Fp(e,n);const r=e.runtime.bin.makeReadOptions(t),i=Nw(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Bp(e);for(const a of i)e.runtime.bin.readField(s,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Dw(n,e,t,r){Fp(e,n);const i=e.runtime.bin.makeReadOptions(r),s=e.runtime.bin.makeWriteOptions(r);if(bp(n,e)){const c=n.getType().runtime.bin.listUnknownFields(n).filter(d=>d.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const d of c)n.getType().runtime.bin.onUnknownField(n,d.no,d.wireType,d.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const u=i.readerFactory(o.finish());for(;u.posr.no==e.field.no)}function Fp(n,e){ue(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Mp(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Lp(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function Nh(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?fs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function yi(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(O.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Jp(n,e){return yi(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}A.DOUBLE,A.FLOAT,A.INT64,A.UINT64,A.INT32,A.UINT32,A.BOOL,A.STRING,A.BYTES;const Ph={ignoreUnknownFields:!1},Dh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ow(n){return n?Object.assign(Object.assign({},Ph),n):Ph}function Rw(n){return n?Object.assign(Object.assign({},Dh),n):Dh}const Ya=Symbol(),ka=Symbol();function Lw(){return{makeReadOptions:Ow,makeWriteOptions:Rw,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${qt(e)}`);r=r??new n;const i=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const u=n.fields.findJsonName(o);if(u){if(u.oneof){if(a===null&&u.kind=="scalar")continue;const c=i.get(u.oneof);if(c!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${c}", "${o}"`);i.set(u.oneof,o)}Oh(r,a,u,t,n)}else{let c=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const d=s.findExtension(o.substring(1,o.length-1));if(d&&d.extendee.typeName==n.typeName){c=!0;const[h,m]=Bp(d);Oh(h,a,d.field,t,d),Dw(r,d,m(),t)}}if(!c&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let i;try{for(i of t.fields.byNumber()){if(!Mp(i,n)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!bw(i))continue}const o=i.oneof?n[i.oneof.localName].value:n[i.localName],a=Rh(i,o,e);a!==void 0&&(r[e.useProtoFieldName?i.name:i.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&bp(n,a)){const u=Pw(n,a,e),c=Rh(a.field,u,e);c!==void 0&&(r[a.field.jsonName]=c)}}}catch(s){const o=i?`cannot encode field ${t.typeName}.${i.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return _s(n,e,t??Qr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Lp(n,e)))return Ta(n,e)},debug:qt}}function qt(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function Oh(n,e,t,r,i){let s=t.localName;if(t.repeated){if(ue(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const u=Su(t.T,a,r.ignoreUnknownFields,!0);u!==ka&&o.push(u);break;case"scalar":try{o.push(_s(t.T,a,t.L,!0))}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(a)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`);const o=n[s];for(const[a,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: map value null`);let c;try{c=Bw(t.K,a)}catch(d){let h=`cannot decode map key for field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}switch(t.V.kind){case"message":o[c]=t.V.T.fromJson(u,r);break;case"enum":const d=Su(t.V.T,u,r.ignoreUnknownFields,!0);d!==ka&&(o[c]=d);break;case"scalar":try{o[c]=_s(t.V.T,u,Qr.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];yi(a)?a.fromJson(e,r):(n[s]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const u=Su(t.T,e,r.ignoreUnknownFields,!1);switch(u){case Ya:Nh(t,n);break;case ka:break;default:n[s]=u;break}break;case"scalar":try{const c=_s(t.T,e,t.L,!1);switch(c){case Ya:Nh(t,n);break;default:n[s]=c;break}}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}function Bw(n,e){if(n===A.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return _s(n,e,Qr.BIGINT,!0).toString()}function _s(n,e,t,r){if(e===null)return r?fs(n,t):Ya;switch(n){case A.DOUBLE:case A.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return n==A.FLOAT&&xp(i),i;case A.INT32:case A.FIXED32:case A.SFIXED32:case A.SINT32:case A.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==A.UINT32||n==A.FIXED32?Ac(s):wa(s),s;case A.INT64:case A.SFIXED64:case A.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=ne.parse(e);return t?o.toString():o;case A.FIXED64:case A.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=ne.uParse(e);return t?a.toString():a;case A.BOOL:if(typeof e!="boolean")break;return e;case A.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case A.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Hf.dec(e)}throw new Error}function Su(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Ya;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=n.findName(e);if(i!==void 0)return i.no;if(t)return ka;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${qt(e)}`)}function bw(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function Rh(n,e,t){if(n.kind=="map"){ue(typeof e=="object"&&e!=null);const r={},i=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of i)r[o.toString()]=Ta(n.V.T,a);break;case"message":for(const[o,a]of i)r[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of i)r[o.toString()]=ku(s,a,t.enumAsInteger);break}return t.emitDefaultValues||i.length>0?r:void 0}if(n.repeated){ue(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let i=0;i0?r:void 0}switch(n.kind){case"scalar":return Ta(n.T,e);case"enum":return ku(n.T,e,t.enumAsInteger);case"message":return Jp(n.T,e).toJson(t)}}function ku(n,e,t){var r;if(ue(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const i=n.findNumber(e);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:e}function Ta(n,e){switch(n){case A.INT32:case A.SFIXED32:case A.SINT32:case A.FIXED32:case A.UINT32:return ue(typeof e=="number"),e;case A.FLOAT:case A.DOUBLE:return ue(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case A.STRING:return ue(typeof e=="string"),e;case A.BOOL:return ue(typeof e=="boolean"),e;case A.UINT64:case A.FIXED64:case A.INT64:case A.SFIXED64:case A.SINT64:return ue(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case A.BYTES:return ue(e instanceof Uint8Array),Hf.enc(e)}}const Oi=Symbol("@bufbuild/protobuf/unknown-fields"),Lh={readUnknownFields:!0,readerFactory:n=>new Ew(n)},Bh={writeUnknownFields:!0,writerFactory:()=>new Iw};function Fw(n){return n?Object.assign(Object.assign({},Lh),n):Lh}function Mw(n){return n?Object.assign(Object.assign({},Bh),n):Bh}function Jw(){return{makeReadOptions:Fw,makeWriteOptions:Mw,listUnknownFields(n){var e;return(e=n[Oi])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Oi]},writeUnknownFields(n,e){const r=n[Oi];if(r)for(const i of r)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(n,e,t,r){const i=n;Array.isArray(i[Oi])||(i[Oi]=[]),i[Oi].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,i){const s=n.getType(),o=i?e.len:e.pos+t;let a,u;for(;e.pos0&&(u=zw),s){let m=n[o];if(r==ge.LengthDelimited&&a!=A.STRING&&a!=A.BYTES){let w=e.uint32()+e.pos;for(;e.posyi(m,h)?m:new h(m));else{const m=o[i];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[i]=Os(m):s[i]=m:s[i]=yi(m,h)?m:new h(m)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const i=e[r.localName],s=t[r.localName];if(r.repeated){if(i.length!==s.length)return!1;switch(r.kind){case"message":return i.every((o,a)=>r.T.equals(o,s[a]));case"scalar":return i.every((o,a)=>Nr(r.T,o,s[a]));case"enum":return i.every((o,a)=>Nr(A.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,s);case"enum":return Nr(A.INT32,i,s);case"scalar":return Nr(r.T,i,s);case"oneof":if(i.case!==s.case)return!1;const o=r.findField(i.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(i.value,s.value);case"enum":return Nr(A.INT32,i.value,s.value);case"scalar":return Nr(o.T,i.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(i).concat(Object.keys(s));switch(r.V.kind){case"message":const u=r.V.T;return a.every(d=>u.equals(i[d],s[d]));case"enum":return a.every(d=>Nr(A.INT32,i[d],s[d]));case"scalar":const c=r.V.T;return a.every(d=>Nr(c,i[d],s[d]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const i of e.fields.byMember()){const s=n[i.localName];let o;if(i.repeated)o=s.map(ta);else if(i.kind=="map"){o=r[i.localName];for(const[a,u]of Object.entries(s))o[a]=ta(u)}else i.kind=="oneof"?o=i.findField(s.case)?{case:s.case,value:ta(s.value)}:{case:void 0}:o=ta(s);r[i.localName]=o}for(const i of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return t}}}function ta(n){if(n===void 0)return n;if(yi(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Os(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function qw(n,e,t){return{syntax:n,json:Lw(),bin:Jw(),util:Object.assign(Object.assign({},Vw()),{newFieldList:e,initFields:t}),makeMessageType(r,i,s){return vw(this,r,i,s)},makeEnum:yw,makeEnumType:Pp,getEnumType:pw,makeExtension(r,i,s){return xw(this,r,i,s)}}}class Kw{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function zp(n,e){const t=Up(n);return e?t:Qw(Yw(t))}function Ww(n){return zp(n,!1)}const _w=Up;function Up(n){let e=!1;const t=[];for(let r=0;r`${n}$`,Yw=n=>Gw.has(n)?jp(n):n,Qw=n=>Hw.has(n)?jp(n):n;class Xw{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ww(e)}addField(e){ue(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew Kw(n,e=>Zw(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=fs(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Jh;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Jh||(Jh={}));class Re extends O{constructor(e){super(),this.seconds=ne.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=ne.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Re.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Re({seconds:ne.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Re().fromBinary(e,t)}static fromJson(e,t){return new Re().fromJson(e,t)}static fromJsonString(e,t){return new Re().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Re,e,t)}}Re.runtime=f;Re.typeName="google.protobuf.Timestamp";Re.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class dr extends O{constructor(e){super(),this.seconds=ne.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=ne.parse(i),typeof r[2]=="string"){const s=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(s),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new dr().fromBinary(e,t)}static fromJson(e,t){return new dr().fromJson(e,t)}static fromJsonString(e,t){return new dr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(dr,e,t)}}dr.runtime=f;dr.typeName="google.protobuf.Duration";dr.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Wt extends O{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=i.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const i=e["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(i),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const u=Object.assign({},e);delete u["@type"],a=o.fromJson(u,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Wt;return t.packFrom(e),t}static fromBinary(e,t){return new Wt().fromBinary(e,t)}static fromJson(e,t){return new Wt().fromJson(e,t)}static fromJsonString(e,t){return new Wt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wt,e,t)}}Wt.runtime=f;Wt.typeName="google.protobuf.Any";Wt.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class _t extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.DOUBLE,e)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new _t().fromBinary(e,t)}static fromJson(e,t){return new _t().fromJson(e,t)}static fromJsonString(e,t){return new _t().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_t,e,t)}}_t.runtime=f;_t.typeName="google.protobuf.DoubleValue";_t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);_t.fieldWrapper={wrapField(n){return new _t({value:n})},unwrapField(n){return n.value}};class Ht extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.FLOAT,e)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Ht().fromBinary(e,t)}static fromJson(e,t){return new Ht().fromJson(e,t)}static fromJsonString(e,t){return new Ht().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ht,e,t)}}Ht.runtime=f;Ht.typeName="google.protobuf.FloatValue";Ht.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Ht.fieldWrapper={wrapField(n){return new Ht({value:n})},unwrapField(n){return n.value}};class Gt extends O{constructor(e){super(),this.value=ne.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT64,e)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Gt().fromBinary(e,t)}static fromJson(e,t){return new Gt().fromJson(e,t)}static fromJsonString(e,t){return new Gt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gt,e,t)}}Gt.runtime=f;Gt.typeName="google.protobuf.Int64Value";Gt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Gt.fieldWrapper={wrapField(n){return new Gt({value:n})},unwrapField(n){return n.value}};class Yt extends O{constructor(e){super(),this.value=ne.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT64,e)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Yt().fromBinary(e,t)}static fromJson(e,t){return new Yt().fromJson(e,t)}static fromJsonString(e,t){return new Yt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Yt,e,t)}}Yt.runtime=f;Yt.typeName="google.protobuf.UInt64Value";Yt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Yt.fieldWrapper={wrapField(n){return new Yt({value:n})},unwrapField(n){return n.value}};class Qt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT32,e)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qt().fromBinary(e,t)}static fromJson(e,t){return new Qt().fromJson(e,t)}static fromJsonString(e,t){return new Qt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qt,e,t)}}Qt.runtime=f;Qt.typeName="google.protobuf.Int32Value";Qt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Qt.fieldWrapper={wrapField(n){return new Qt({value:n})},unwrapField(n){return n.value}};class Xt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT32,e)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xt().fromBinary(e,t)}static fromJson(e,t){return new Xt().fromJson(e,t)}static fromJsonString(e,t){return new Xt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xt,e,t)}}Xt.runtime=f;Xt.typeName="google.protobuf.UInt32Value";Xt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Xt.fieldWrapper={wrapField(n){return new Xt({value:n})},unwrapField(n){return n.value}};class Zt extends O{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BOOL,e)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Zt().fromBinary(e,t)}static fromJson(e,t){return new Zt().fromJson(e,t)}static fromJsonString(e,t){return new Zt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zt,e,t)}}Zt.runtime=f;Zt.typeName="google.protobuf.BoolValue";Zt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Zt.fieldWrapper={wrapField(n){return new Zt({value:n})},unwrapField(n){return n.value}};class Xe extends O{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.STRING,e)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xe().fromBinary(e,t)}static fromJson(e,t){return new Xe().fromJson(e,t)}static fromJsonString(e,t){return new Xe().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xe,e,t)}}Xe.runtime=f;Xe.typeName="google.protobuf.StringValue";Xe.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Xe.fieldWrapper={wrapField(n){return new Xe({value:n})},unwrapField(n){return n.value}};class en extends O{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BYTES,e)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new en().fromBinary(e,t)}static fromJson(e,t){return new en().fromJson(e,t)}static fromJsonString(e,t){return new en().fromJsonString(e,t)}static equals(e,t){return f.util.equals(en,e,t)}}en.runtime=f;en.typeName="google.protobuf.BytesValue";en.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);en.fieldWrapper={wrapField(n){return new en({value:n})},unwrapField(n){return n.value}};function e1(n,e,t){try{const r=Hf.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw te.from(r,H.DataLoss)}}function t1(n,e){const t={};for(const[r,i]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},i),{localName:r,service:n}));s!=null&&(t[r]=s)}return t}function $h(n){let e,t=new Uint8Array(0);function r(i){const s=new Uint8Array(t.length+i.length);s.set(t),s.set(i,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(i){let s;for(;;){if(s===void 0&&t.byteLength>=5){let u=0;for(let c=1;c<5;c++)u=(u<<8)+t[c];s={flags:t[0],length:u}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(s===void 0){if(t.byteLength==0){i.close();return}i.error(new te("premature end of stream",H.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),i.enqueue({flags:s.flags,data:o})}})}function zh(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var n1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){o=n[s](o),i(a,u,o.done,o.value)})}}function i(s,o,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},o)}},po=function(n){return this instanceof po?(this.v=n,this):new po(n)},r1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof po?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}},i1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:po(n[i](o)),done:!1}:s?s(o):o}:s}};function s1(n){return r1(this,arguments,function*(){yield po(yield*i1(n1(n)))})}var Vp=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){o=n[s](o),i(a,u,o.done,o.value)})}}function i(s,o,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},o)}},ds=function(n){return this instanceof ds?(this.v=n,this):new ds(n)},o1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:ds(n[i](o)),done:!1}:s?s(o):o}:s}},a1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof ds?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}};function l1(n,e){return t1(n,t=>{switch(t.kind){case Fe.Unary:return u1(e,n,t);case Fe.ServerStreaming:return c1(e,n,t);case Fe.ClientStreaming:return f1(e,n,t);case Fe.BiDiStreaming:return d1(e,n,t);default:return null}})}function u1(n,e,t){return async function(r,i){var s,o;const a=await n.unary(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(s=i==null?void 0:i.onHeader)===null||s===void 0||s.call(i,a.header),(o=i==null?void 0:i.onTrailer)===null||o===void 0||o.call(i,a.trailer),a.message}}function c1(n,e,t){return function(r,i){return qp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,s1([r]),i==null?void 0:i.contextValues),i)}}function f1(n,e,t){return async function(r,i){var s,o,a,u,c,d;const h=await n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(c=i==null?void 0:i.onHeader)===null||c===void 0||c.call(i,h.header);let m;try{for(var y=!0,w=Vp(h.message),T;T=await w.next(),s=T.done,!s;y=!0)u=T.value,y=!1,m=u}catch(P){o={error:P}}finally{try{!y&&!s&&(a=w.return)&&await a.call(w)}finally{if(o)throw o.error}}if(!m)throw new te("protocol error: missing response message",H.Internal);return(d=i==null?void 0:i.onTrailer)===null||d===void 0||d.call(i,h.trailer),m}}function d1(n,e,t){return function(r,i){return qp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function qp(n,e){const t=function(){var r,i;return a1(this,arguments,function*(){const s=yield ds(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,s.header),yield ds(yield*o1(Vp(s.message))),(i=e==null?void 0:e.onTrailer)===null||i===void 0||i.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function h1(...n){const e=new AbortController,t=n.filter(i=>i!==void 0).concat(e.signal);for(const i of t){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(Kp(this));for(const i of t)i.removeEventListener("abort",r)}return e}function g1(n){const e=new AbortController,t=()=>{e.abort(new te("the operation timed out",H.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function Kp(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function Uh(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Tu=128;function jh(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r -`);for(const r of t){if(r==="")continue;const i=r.indexOf(":");if(i>0){const s=r.substring(0,i).trim(),o=r.substring(i+1).trim();e.append(s,o)}}return e}const m1="Content-Type",p1="Grpc-Timeout",Wp="Grpc-Status",_p="Grpc-Message",y1="Grpc-Status-Details-Bin",v1="X-User-Agent",w1="X-Grpc-Web",S1="application/grpc-web+proto",k1="application/grpc-web+json";class hr extends O{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new hr().fromBinary(e,t)}static fromJson(e,t){return new hr().fromJson(e,t)}static fromJsonString(e,t){return new hr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(hr,e,t)}}hr.runtime=f;hr.typeName="google.rpc.Status";hr.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Wt,repeated:!0}]);const T1="0";function Hp(n){var e;const t=n.get(y1);if(t!=null){const i=e1(t,hr);if(i.code==0)return;const s=new te(i.message,i.code,n);return s.details=i.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const r=n.get(Wp);if(r!=null){if(r===T1)return;const i=parseInt(r,10);return i in H?new te(decodeURIComponent((e=n.get(_p))!==null&&e!==void 0?e:""),i,n):new te(`invalid grpc-status: ${r}`,H.Internal,n)}}function Vh(n,e,t){const r=typeof e=="string"?e:e.typeName,i=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${i}`)}function Gp(n,e){return e instanceof n?e:new n(e)}function A1(n,e){function t(r){return r.done===!0?r:{done:r.done,value:Gp(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),i={next:()=>r.next().then(t)};return r.throw!==void 0&&(i.throw=s=>r.throw(s).then(t)),r.return!==void 0&&(i.return=s=>r.return(s).then(t)),i}}}function Yp(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,i)=>i(r),n))!==null&&t!==void 0?t:n}function I1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function qh(n,e,t,r){const i=e?Kh(n.I,r):Wh(n.I,t);return{parse:(e?Kh(n.O,r):Wh(n.O,t)).parse,serialize:i.serialize}}function Kh(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new te(`parse binary: ${i}`,H.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new te(`serialize binary: ${i}`,H.Internal)}}}}function Wh(n,e){var t,r;const i=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=I1(e);return{parse(a){try{const u=s.decode(a);return n.fromJsonString(u,o)}catch(u){throw te.from(u,H.InvalidArgument)}},serialize(a){try{const u=a.toJsonString(o);return i.encode(u)}catch(u){throw te.from(u,H.Internal)}}}}function E1(n){const e=Yp(n.next,n.interceptors),[t,r,i]=Qp(n),s=Object.assign(Object.assign({},n.req),{message:Gp(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(i(),o),r)}function x1(n){const e=Yp(n.next,n.interceptors),[t,r,i]=Qp(n),s=Object.assign(Object.assign({},n.req),{message:A1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,u;const c=n.req.message[Symbol.asyncIterator]();o||(a=c.throw)===null||a===void 0||a.call(c,this.reason).catch(()=>{}),(u=c.return)===null||u===void 0||u.call(c).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const u=a.message[Symbol.asyncIterator]();return{next(){return u.next().then(c=>(c.done==!0&&(o=!0,i()),c),r)}}}}}),r)}function Qp(n){const{signal:e,cleanup:t}=g1(n.timeoutMs),r=h1(n.signal,e);return[r.signal,function(s){const o=te.from(e.aborted?Kp(e):s);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function C1(){try{new Headers}catch{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.")}}function _h(n,e){const t=Hp(n);if(t)throw e.forEach((r,i)=>{t.metadata.append(i,r)}),t}function Hh(n,e,t,r){const i=new Headers(t??{});return i.set(m1,n?S1:k1),i.set(w1,"1"),i.set(v1,"connect-es/1.4.0"),e!==void 0&&i.set(p1,`${e}m`),i}function N1(n){switch(n){case 400:return H.Internal;case 401:return H.Unauthenticated;case 403:return H.PermissionDenied;case 404:return H.Unimplemented;case 429:return H.Unavailable;case 502:return H.Unavailable;case 503:return H.Unavailable;case 504:return H.Unavailable;default:return H.Unknown}}function Gh(n,e){var t;if(n>=200&&n<300){const r=Hp(e);if(r)throw r;return{foundStatus:e.has(Wp)}}throw new te(decodeURIComponent((t=e.get(_p))!==null&&t!==void 0?t:`HTTP ${n}`),N1(n),e)}var hi=function(n){return this instanceof hi?(this.v=n,this):new hi(n)},P1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof hi?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}};function D1(n){var e;C1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,i,s,o,a,u,c){var d;const{serialize:h,parse:m}=qh(i,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await E1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:r,method:i,url:Vh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Hh(t,o,a),contextValues:c??Uh(),message:u},next:async y=>{var w;const P=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(y.url,Object.assign(Object.assign({},y.init),{headers:y.header,signal:y.signal,body:zh(0,h(y.message))}));if(Gh(P.status,P.headers),!P.body)throw"missing response body";const p=$h(P.body).getReader();let g,v;for(;;){const I=await p.read();if(I.done)break;const{flags:E,data:N}=I.value;if(E===Tu){if(g!==void 0)throw"extra trailer";g=jh(N);continue}if(v!==void 0)throw"extra message";v=m(N)}if(g===void 0)throw"missing trailer";if(_h(g,P.headers),v===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:P.headers,message:v,trailer:g}}})},async stream(r,i,s,o,a,u,c){var d;const{serialize:h,parse:m}=qh(i,t,n.jsonOptions,n.binaryOptions);function y(T,P,p,g){return P1(this,arguments,function*(){const I=$h(T).getReader();if(P){if(!(yield hi(I.read())).done)throw"extra data for trailers-only";return yield hi(void 0)}let E=!1;for(;;){const N=yield hi(I.read());if(N.done)break;const{flags:D,data:R}=N.value;if((D&Tu)===Tu){if(E)throw"extra trailer";E=!0;const q=jh(R);_h(q,g),q.forEach(($,Se)=>p.set(Se,$));continue}if(E)throw"extra message";yield yield hi(m(R))}if(!E)throw"missing trailer"})}async function w(T){if(i.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const P=await T[Symbol.asyncIterator]().next();if(P.done==!0)throw"missing request message";return zh(0,h(P.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,x1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:r,method:i,url:Vh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Hh(t,o,a),contextValues:c??Uh(),message:u},next:async T=>{var P;const g=await((P=n.fetch)!==null&&P!==void 0?P:globalThis.fetch)(T.url,Object.assign(Object.assign({},T.init),{headers:T.header,signal:T.signal,body:await w(T.message)})),{foundStatus:v}=Gh(g.status,g.headers);if(!g.body)throw"missing response body";const I=new Headers;return Object.assign(Object.assign({},T),{header:g.headers,trailer:I,message:y(g.body,v,I,g.headers)})}})}}}var z=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(z||{});f.util.setEnumType(z,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var vi=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(vi||{});f.util.setEnumType(vi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const ln=class ln extends O{constructor(t){super();l(this,"root");l(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};l(ln,"runtime",f),l(ln,"typeName","yorkie.v1.Snapshot"),l(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:Ge},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Yf}}]));let Ic=ln;var ut;let Er=(ut=class extends O{constructor(t){super();l(this,"documentKey","");l(this,"checkpoint");l(this,"snapshot",new Uint8Array(0));l(this,"changes",[]);l(this,"minSyncedTicket");l(this,"isRemoved",!1);l(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ut().fromBinary(t,r)}static fromJson(t,r){return new ut().fromJson(t,r)}static fromJsonString(t,r){return new ut().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ut,t,r)}},l(ut,"runtime",f),l(ut,"typeName","yorkie.v1.ChangePack"),l(ut,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:ey},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Xp,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:b},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Jl}])),ut);var ct;let Xp=(ct=class extends O{constructor(t){super();l(this,"id");l(this,"message","");l(this,"operations",[]);l(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new ct().fromBinary(t,r)}static fromJson(t,r){return new ct().fromJson(t,r)}static fromJsonString(t,r){return new ct().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ct,t,r)}},l(ct,"runtime",f),l(ct,"typeName","yorkie.v1.Change"),l(ct,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Ml},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Gf,repeated:!0},{no:4,name:"presence_change",kind:"message",T:wo}])),ct);var ft;let Ml=(ft=class extends O{constructor(t){super();l(this,"clientSeq",0);l(this,"serverSeq",ne.zero);l(this,"lamport",ne.zero);l(this,"actorId",new Uint8Array(0));l(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ft().fromBinary(t,r)}static fromJson(t,r){return new ft().fromJson(t,r)}static fromJsonString(t,r){return new ft().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ft,t,r)}},l(ft,"runtime",f),l(ft,"typeName","yorkie.v1.ChangeID"),l(ft,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Jl}])),ft);var dt;let Jl=(dt=class extends O{constructor(t){super();l(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new dt().fromBinary(t,r)}static fromJson(t,r){return new dt().fromJson(t,r)}static fromJsonString(t,r){return new dt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dt,t,r)}},l(dt,"runtime",f),l(dt,"typeName","yorkie.v1.VersionVector"),l(dt,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),dt);var ht;let Gf=(ht=class extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new ht().fromBinary(t,r)}static fromJson(t,r){return new ht().fromJson(t,r)}static fromJsonString(t,r){return new ht().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ht,t,r)}},l(ht,"runtime",f),l(ht,"typeName","yorkie.v1.Operation"),l(ht,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Xa,oneof:"body"},{no:2,name:"add",kind:"message",T:Za,oneof:"body"},{no:3,name:"move",kind:"message",T:el,oneof:"body"},{no:4,name:"remove",kind:"message",T:tl,oneof:"body"},{no:5,name:"edit",kind:"message",T:nl,oneof:"body"},{no:6,name:"select",kind:"message",T:Ec,oneof:"body"},{no:7,name:"style",kind:"message",T:rl,oneof:"body"},{no:8,name:"increase",kind:"message",T:il,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:sl,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ol,oneof:"body"},{no:11,name:"array_set",kind:"message",T:xc,oneof:"body"}])),ht);const un=class un extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"key","");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};l(un,"runtime",f),l(un,"typeName","yorkie.v1.Operation.Set"),l(un,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let Xa=un;const cn=class cn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"prevCreatedAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};l(cn,"runtime",f),l(cn,"typeName","yorkie.v1.Operation.Add"),l(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let Za=cn;const fn=class fn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"prevCreatedAt");l(this,"createdAt");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};l(fn,"runtime",f),l(fn,"typeName","yorkie.v1.Operation.Move"),l(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"executed_at",kind:"message",T:b}]));let el=fn;const dn=class dn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"createdAt");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};l(dn,"runtime",f),l(dn,"typeName","yorkie.v1.Operation.Remove"),l(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"executed_at",kind:"message",T:b}]));let tl=dn;const hn=class hn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"createdAtMapByActor",{});l(this,"content","");l(this,"executedAt");l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};l(hn,"runtime",f),l(hn,"typeName","yorkie.v1.Operation.Edit"),l(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:b},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let nl=hn;const gn=class gn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};l(gn,"runtime",f),l(gn,"typeName","yorkie.v1.Operation.Select"),l(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"executed_at",kind:"message",T:b}]));let Ec=gn;const mn=class mn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"attributes",{});l(this,"executedAt");l(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};l(mn,"runtime",f),l(mn,"typeName","yorkie.v1.Operation.Style"),l(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let rl=mn;const pn=class pn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};l(pn,"runtime",f),l(pn,"typeName","yorkie.v1.Operation.Increase"),l(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"value",kind:"message",T:lt},{no:3,name:"executed_at",kind:"message",T:b}]));let il=pn;const yn=class yn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"createdAtMapByActor",{});l(this,"contents",[]);l(this,"splitLevel",0);l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};l(yn,"runtime",f),l(yn,"typeName","yorkie.v1.Operation.TreeEdit"),l(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"contents",kind:"message",T:ml,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:b}]));let sl=yn;const vn=class vn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"attributes",{});l(this,"executedAt");l(this,"attributesToRemove",[]);l(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};l(vn,"runtime",f),l(vn,"typeName","yorkie.v1.Operation.TreeStyle"),l(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let ol=vn;const wn=class wn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"createdAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};l(wn,"runtime",f),l(wn,"typeName","yorkie.v1.Operation.ArraySet"),l(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let xc=wn;const Sn=class Sn extends O{constructor(t){super();l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");l(this,"type",0);l(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};l(Sn,"runtime",f),l(Sn,"typeName","yorkie.v1.JSONElementSimple"),l(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"moved_at",kind:"message",T:b},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"type",kind:"enum",T:f.getEnumType(z)},{no:5,name:"value",kind:"scalar",T:12}]));let lt=Sn;const kn=class kn extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};l(kn,"runtime",f),l(kn,"typeName","yorkie.v1.JSONElement"),l(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:al,oneof:"body"},{no:2,name:"json_array",kind:"message",T:ll,oneof:"body"},{no:3,name:"primitive",kind:"message",T:ul,oneof:"body"},{no:5,name:"text",kind:"message",T:cl,oneof:"body"},{no:6,name:"counter",kind:"message",T:fl,oneof:"body"},{no:7,name:"tree",kind:"message",T:dl,oneof:"body"}]));let Ge=kn;const Tn=class Tn extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};l(Tn,"runtime",f),l(Tn,"typeName","yorkie.v1.JSONElement.JSONObject"),l(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Zp,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let al=Tn;const An=class An extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};l(An,"runtime",f),l(An,"typeName","yorkie.v1.JSONElement.JSONArray"),l(An,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:hl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ll=An;const In=class In extends O{constructor(t){super();l(this,"type",0);l(this,"value",new Uint8Array(0));l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};l(In,"runtime",f),l(In,"typeName","yorkie.v1.JSONElement.Primitive"),l(In,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let ul=In;const En=class En extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};l(En,"runtime",f),l(En,"typeName","yorkie.v1.JSONElement.Text"),l(En,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:gl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let cl=En;const xn=class xn extends O{constructor(t){super();l(this,"type",0);l(this,"value",new Uint8Array(0));l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};l(xn,"runtime",f),l(xn,"typeName","yorkie.v1.JSONElement.Counter"),l(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let fl=xn;const Cn=class Cn extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};l(Cn,"runtime",f),l(Cn,"typeName","yorkie.v1.JSONElement.Tree"),l(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:vo,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let dl=Cn;var gt;let Zp=(gt=class extends O{constructor(t){super();l(this,"key","");l(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new gt().fromBinary(t,r)}static fromJson(t,r){return new gt().fromJson(t,r)}static fromJsonString(t,r){return new gt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gt,t,r)}},l(gt,"runtime",f),l(gt,"typeName","yorkie.v1.RHTNode"),l(gt,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:Ge}])),gt);const Vt=class Vt extends O{constructor(t){super();l(this,"next");l(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vt().fromBinary(t,r)}static fromJson(t,r){return new Vt().fromJson(t,r)}static fromJsonString(t,r){return new Vt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vt,t,r)}};l(Vt,"runtime",f),l(Vt,"typeName","yorkie.v1.RGANode"),l(Vt,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Vt},{no:2,name:"element",kind:"message",T:Ge}]));let hl=Vt;const Nn=class Nn extends O{constructor(t){super();l(this,"value","");l(this,"updatedAt");l(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};l(Nn,"runtime",f),l(Nn,"typeName","yorkie.v1.NodeAttr"),l(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:b},{no:3,name:"is_removed",kind:"scalar",T:8}]));let hs=Nn;const Pn=class Pn extends O{constructor(t){super();l(this,"id");l(this,"value","");l(this,"removedAt");l(this,"insPrevId");l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};l(Pn,"runtime",f),l(Pn,"typeName","yorkie.v1.TextNode"),l(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:yo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"ins_prev_id",kind:"message",T:yo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let gl=Pn;const Dn=class Dn extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};l(Dn,"runtime",f),l(Dn,"typeName","yorkie.v1.TextNodeID"),l(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let yo=Dn;const On=class On extends O{constructor(t){super();l(this,"id");l(this,"type","");l(this,"value","");l(this,"removedAt");l(this,"insPrevId");l(this,"insNextId");l(this,"depth",0);l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};l(On,"runtime",f),l(On,"typeName","yorkie.v1.TreeNode"),l(On,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Wr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:b},{no:5,name:"ins_prev_id",kind:"message",T:Wr},{no:6,name:"ins_next_id",kind:"message",T:Wr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let vo=On;const Rn=class Rn extends O{constructor(t){super();l(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};l(Rn,"runtime",f),l(Rn,"typeName","yorkie.v1.TreeNodes"),l(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:vo,repeated:!0}]));let ml=Rn;const Ln=class Ln extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};l(Ln,"runtime",f),l(Ln,"typeName","yorkie.v1.TreeNodeID"),l(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let Wr=Ln;const Bn=class Bn extends O{constructor(t){super();l(this,"parentId");l(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};l(Bn,"runtime",f),l(Bn,"typeName","yorkie.v1.TreePos"),l(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:Wr},{no:2,name:"left_sibling_id",kind:"message",T:Wr}]));let Ii=Bn;const bn=class bn extends O{constructor(t){super();l(this,"id","");l(this,"username","");l(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};l(bn,"runtime",f),l(bn,"typeName","yorkie.v1.User"),l(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Re}]));let Yh=bn;const Fn=class Fn extends O{constructor(t){super();l(this,"id","");l(this,"name","");l(this,"publicKey","");l(this,"secretKey","");l(this,"authWebhookUrl","");l(this,"authWebhookMethods",[]);l(this,"clientDeactivateThreshold","");l(this,"createdAt");l(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Fn().fromBinary(t,r)}static fromJson(t,r){return new Fn().fromJson(t,r)}static fromJsonString(t,r){return new Fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Fn,t,r)}};l(Fn,"runtime",f),l(Fn,"typeName","yorkie.v1.Project"),l(Fn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Re},{no:9,name:"updated_at",kind:"message",T:Re}]));let Qh=Fn;const Mn=class Mn extends O{constructor(t){super();l(this,"name");l(this,"authWebhookUrl");l(this,"authWebhookMethods");l(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};l(Mn,"runtime",f),l(Mn,"typeName","yorkie.v1.UpdatableProjectFields"),l(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Xe},{no:2,name:"auth_webhook_url",kind:"message",T:Xe},{no:3,name:"auth_webhook_methods",kind:"message",T:Cc},{no:4,name:"client_deactivate_threshold",kind:"message",T:Xe}]));let Xh=Mn;const Jn=class Jn extends O{constructor(t){super();l(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};l(Jn,"runtime",f),l(Jn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),l(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Cc=Jn;const $n=class $n extends O{constructor(t){super();l(this,"id","");l(this,"key","");l(this,"snapshot","");l(this,"createdAt");l(this,"accessedAt");l(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};l($n,"runtime",f),l($n,"typeName","yorkie.v1.DocumentSummary"),l($n,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Re},{no:5,name:"accessed_at",kind:"message",T:Re},{no:6,name:"updated_at",kind:"message",T:Re}]));let Zh=$n;const zn=class zn extends O{constructor(t){super();l(this,"type",0);l(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};l(zn,"runtime",f),l(zn,"typeName","yorkie.v1.PresenceChange"),l(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(Ei)},{no:2,name:"presence",kind:"message",T:Yf}]));let wo=zn;var Ei=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Ei||{});f.util.setEnumType(Ei,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var mt;let Yf=(mt=class extends O{constructor(t){super();l(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new mt().fromBinary(t,r)}static fromJson(t,r){return new mt().fromJson(t,r)}static fromJsonString(t,r){return new mt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mt,t,r)}},l(mt,"runtime",f),l(mt,"typeName","yorkie.v1.Presence"),l(mt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),mt);var pt;let ey=(pt=class extends O{constructor(t){super();l(this,"serverSeq",ne.zero);l(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new pt().fromBinary(t,r)}static fromJson(t,r){return new pt().fromJson(t,r)}static fromJsonString(t,r){return new pt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pt,t,r)}},l(pt,"runtime",f),l(pt,"typeName","yorkie.v1.Checkpoint"),l(pt,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),pt);const Un=class Un extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);l(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};l(Un,"runtime",f),l(Un,"typeName","yorkie.v1.TextNodePos"),l(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Tr=Un;var yt;let b=(yt=class extends O{constructor(t){super();l(this,"lamport",ne.zero);l(this,"delimiter",0);l(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new yt().fromBinary(t,r)}static fromJson(t,r){return new yt().fromJson(t,r)}static fromJsonString(t,r){return new yt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yt,t,r)}},l(yt,"runtime",f),l(yt,"typeName","yorkie.v1.TimeTicket"),l(yt,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),yt);const jn=class jn extends O{constructor(t){super();l(this,"topic","");l(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};l(jn,"runtime",f),l(jn,"typeName","yorkie.v1.DocEventBody"),l(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Nc=jn;const Vn=class Vn extends O{constructor(t){super();l(this,"type",0);l(this,"publisher","");l(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};l(Vn,"runtime",f),l(Vn,"typeName","yorkie.v1.DocEvent"),l(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(vi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Nc}]));let Pc=Vn;const qn=class qn extends O{constructor(t){super();l(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};l(qn,"runtime",f),l(qn,"typeName","yorkie.v1.ActivateClientRequest"),l(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Dc=qn;const Kn=class Kn extends O{constructor(t){super();l(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};l(Kn,"runtime",f),l(Kn,"typeName","yorkie.v1.ActivateClientResponse"),l(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Oc=Kn;const Wn=class Wn extends O{constructor(t){super();l(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Wn().fromBinary(t,r)}static fromJson(t,r){return new Wn().fromJson(t,r)}static fromJsonString(t,r){return new Wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Wn,t,r)}};l(Wn,"runtime",f),l(Wn,"typeName","yorkie.v1.DeactivateClientRequest"),l(Wn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Rc=Wn;const _n=class _n extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new _n().fromBinary(e,t)}static fromJson(e,t){return new _n().fromJson(e,t)}static fromJsonString(e,t){return new _n().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_n,e,t)}};l(_n,"runtime",f),l(_n,"typeName","yorkie.v1.DeactivateClientResponse"),l(_n,"fields",f.util.newFieldList(()=>[]));let Lc=_n;const Hn=class Hn extends O{constructor(t){super();l(this,"clientId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};l(Hn,"runtime",f),l(Hn,"typeName","yorkie.v1.AttachDocumentRequest"),l(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Er}]));let Bc=Hn;const Gn=class Gn extends O{constructor(t){super();l(this,"documentId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Gn().fromBinary(t,r)}static fromJson(t,r){return new Gn().fromJson(t,r)}static fromJsonString(t,r){return new Gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Gn,t,r)}};l(Gn,"runtime",f),l(Gn,"typeName","yorkie.v1.AttachDocumentResponse"),l(Gn,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Er}]));let bc=Gn;const Yn=class Yn extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");l(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Yn().fromBinary(t,r)}static fromJson(t,r){return new Yn().fromJson(t,r)}static fromJsonString(t,r){return new Yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yn,t,r)}};l(Yn,"runtime",f),l(Yn,"typeName","yorkie.v1.DetachDocumentRequest"),l(Yn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let Fc=Yn;const Qn=class Qn extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qn().fromBinary(t,r)}static fromJson(t,r){return new Qn().fromJson(t,r)}static fromJsonString(t,r){return new Qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qn,t,r)}};l(Qn,"runtime",f),l(Qn,"typeName","yorkie.v1.DetachDocumentResponse"),l(Qn,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Er}]));let Mc=Qn;const Xn=class Xn extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xn().fromBinary(t,r)}static fromJson(t,r){return new Xn().fromJson(t,r)}static fromJsonString(t,r){return new Xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xn,t,r)}};l(Xn,"runtime",f),l(Xn,"typeName","yorkie.v1.WatchDocumentRequest"),l(Xn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Jc=Xn;const Zn=class Zn extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Zn().fromBinary(t,r)}static fromJson(t,r){return new Zn().fromJson(t,r)}static fromJsonString(t,r){return new Zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zn,t,r)}};l(Zn,"runtime",f),l(Zn,"typeName","yorkie.v1.WatchDocumentResponse"),l(Zn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:zc,oneof:"body"},{no:2,name:"event",kind:"message",T:Pc,oneof:"body"}]));let $c=Zn;const er=class er extends O{constructor(t){super();l(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new er().fromBinary(t,r)}static fromJson(t,r){return new er().fromJson(t,r)}static fromJsonString(t,r){return new er().fromJsonString(t,r)}static equals(t,r){return f.util.equals(er,t,r)}};l(er,"runtime",f),l(er,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),l(er,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let zc=er;const tr=class tr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new tr().fromBinary(t,r)}static fromJson(t,r){return new tr().fromJson(t,r)}static fromJsonString(t,r){return new tr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tr,t,r)}};l(tr,"runtime",f),l(tr,"typeName","yorkie.v1.RemoveDocumentRequest"),l(tr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er}]));let Uc=tr;const nr=class nr extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new nr().fromBinary(t,r)}static fromJson(t,r){return new nr().fromJson(t,r)}static fromJsonString(t,r){return new nr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nr,t,r)}};l(nr,"runtime",f),l(nr,"typeName","yorkie.v1.RemoveDocumentResponse"),l(nr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Er}]));let jc=nr;const rr=class rr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");l(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new rr().fromBinary(t,r)}static fromJson(t,r){return new rr().fromJson(t,r)}static fromJsonString(t,r){return new rr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rr,t,r)}};l(rr,"runtime",f),l(rr,"typeName","yorkie.v1.PushPullChangesRequest"),l(rr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er},{no:4,name:"push_only",kind:"scalar",T:8}]));let Vc=rr;const ir=class ir extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new ir().fromBinary(t,r)}static fromJson(t,r){return new ir().fromJson(t,r)}static fromJsonString(t,r){return new ir().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ir,t,r)}};l(ir,"runtime",f),l(ir,"typeName","yorkie.v1.PushPullChangesResponse"),l(ir,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Er}]));let qc=ir;const sr=class sr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"topic","");l(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new sr().fromBinary(t,r)}static fromJson(t,r){return new sr().fromJson(t,r)}static fromJsonString(t,r){return new sr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(sr,t,r)}};l(sr,"runtime",f),l(sr,"typeName","yorkie.v1.BroadcastRequest"),l(sr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Kc=sr;const or=class or extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new or().fromBinary(e,t)}static fromJson(e,t){return new or().fromJson(e,t)}static fromJsonString(e,t){return new or().fromJsonString(e,t)}static equals(e,t){return f.util.equals(or,e,t)}};l(or,"runtime",f),l(or,"typeName","yorkie.v1.BroadcastResponse"),l(or,"fields",f.util.newFieldList(()=>[]));let Wc=or;const O1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Dc,O:Oc,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:Rc,O:Lc,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:Bc,O:bc,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:Fc,O:Mc,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:Uc,O:jc,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:Vc,O:qc,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:Jc,O:$c,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:Kc,O:Wc,kind:Fe.Unary}}},R1=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:dr}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:L1,repeated:!0}]);const L1=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:B1,repeated:!0}]);const B1=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:b1,repeated:!0}]);const b1=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var S=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(S||{});class k extends Error{constructor(t,r){super(r);l(this,"name","YorkieError");l(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Pt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const ty=n=>n?Object.entries(n).length===0:!0,gs=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},ts=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Xr=(n=>(n.Put="put",n.Clear="clear",n))(Xr||{});class Au{constructor(e,t){l(this,"context");l(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:Pt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Qf="000000000000000000000000";class Tt{constructor(e,t,r){l(this,"lamport");l(this,"delimiter");l(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new Tt(e,t,r)}static fromStruct(e){return Tt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new Tt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const ny=0,Gs=9223372036854775807n,Ft=new Tt(0n,ny,Qf);function tn(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` +`+s.stack}return{value:n,source:e,stack:i,digest:null}}function pu(n,e,t){return{value:n,source:null,stack:t??null,digest:e??null}}function cc(n,e){try{console.error(e.value)}catch(t){setTimeout(function(){throw t})}}var J0=typeof WeakMap=="function"?WeakMap:Map;function Xm(n,e,t){t=mr(-1,t),t.tag=3,t.payload={element:null};var r=e.value;return t.callback=function(){Wa||(Wa=!0,Sc=r),cc(n,e)},t}function Zm(n,e,t){t=mr(-1,t),t.tag=3;var r=n.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;t.payload=function(){return r(i)},t.callback=function(){cc(n,e)}}var s=n.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(t.callback=function(){cc(n,e),typeof r!="function"&&(Vr===null?Vr=new Set([this]):Vr.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),t}function ih(n,e,t){var r=n.pingCache;if(r===null){r=n.pingCache=new J0;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(t)||(i.add(t),n=X0.bind(null,n,e,t),e.then(n,n))}function sh(n){do{var e;if((e=n.tag===13)&&(e=n.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return n;n=n.return}while(n!==null);return null}function oh(n,e,t,r,i){return n.mode&1?(n.flags|=65536,n.lanes=i,n):(n===e?n.flags|=65536:(n.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(e=mr(-1,1),e.tag=2,jr(t,e,1))),t.lanes|=1),n)}var $0=Ir.ReactCurrentOwner,Ve=!1;function be(n,e,t,r){e.child=n===null?Om(e,null,t,r):as(e,n.child,t,r)}function ah(n,e,t,r,i){t=t.render;var s=e.ref;return Zi(e,i),r=Rf(n,e,t,r,s,i),t=Lf(),n!==null&&!Ve?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,kr(n,e,i)):(ee&&t&&Sf(e),e.flags|=1,be(n,e,r,i),e.child)}function lh(n,e,t,r,i){if(n===null){var s=t.type;return typeof s=="function"&&!Vf(s)&&s.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(e.tag=15,e.type=s,ep(n,e,s,r,i)):(n=va(t.type,null,r,e,e.mode,i),n.ref=e.ref,n.return=e,e.child=n)}if(s=n.child,!(n.lanes&i)){var o=s.memoizedProps;if(t=t.compare,t=t!==null?t:so,t(o,r)&&n.ref===e.ref)return kr(n,e,i)}return e.flags|=1,n=Kr(s,r),n.ref=e.ref,n.return=e,e.child=n}function ep(n,e,t,r,i){if(n!==null){var s=n.memoizedProps;if(so(s,r)&&n.ref===e.ref)if(Ve=!1,e.pendingProps=r=s,(n.lanes&i)!==0)n.flags&131072&&(Ve=!0);else return e.lanes=n.lanes,kr(n,e,i)}return fc(n,e,t,r,i)}function tp(n,e,t){var r=e.pendingProps,i=r.children,s=n!==null?n.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},Q(Wi,Ye),Ye|=t;else{if(!(t&1073741824))return n=s!==null?s.baseLanes|t:t,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:n,cachePool:null,transitions:null},e.updateQueue=null,Q(Wi,Ye),Ye|=n,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:t,Q(Wi,Ye),Ye|=r}else s!==null?(r=s.baseLanes|t,e.memoizedState=null):r=t,Q(Wi,Ye),Ye|=r;return be(n,e,i,t),e.child}function np(n,e){var t=e.ref;(n===null&&t!==null||n!==null&&n.ref!==t)&&(e.flags|=512,e.flags|=2097152)}function fc(n,e,t,r,i){var s=We(t)?wi:Le.current;return s=ss(e,s),Zi(e,i),t=Rf(n,e,t,r,s,i),r=Lf(),n!==null&&!Ve?(e.updateQueue=n.updateQueue,e.flags&=-2053,n.lanes&=~i,kr(n,e,i)):(ee&&r&&Sf(e),e.flags|=1,be(n,e,t,i),e.child)}function uh(n,e,t,r,i){if(We(t)){var s=!0;Fa(e)}else s=!1;if(Zi(e,i),e.stateNode===null)ma(n,e),Pm(e,t,r),uc(e,t,r,i),r=!0;else if(n===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var u=o.context,c=t.contextType;typeof c=="object"&&c!==null?c=At(c):(c=We(t)?wi:Le.current,c=ss(e,c));var d=t.getDerivedStateFromProps,h=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||u!==c)&&eh(e,o,r,c),Rr=!1;var m=e.memoizedState;o.state=m,Ua(e,r,o,i),u=e.memoizedState,a!==r||m!==u||Ke.current||Rr?(typeof d=="function"&&(lc(e,t,d,r),u=e.memoizedState),(a=Rr||Zd(e,t,a,r,m,u,c))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=u),o.props=r,o.state=u,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,Cm(n,e),a=e.memoizedProps,c=e.type===e.elementType?a:Nt(e.type,a),o.props=c,h=e.pendingProps,m=o.context,u=t.contextType,typeof u=="object"&&u!==null?u=At(u):(u=We(t)?wi:Le.current,u=ss(e,u));var y=t.getDerivedStateFromProps;(d=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==h||m!==u)&&eh(e,o,r,u),Rr=!1,m=e.memoizedState,o.state=m,Ua(e,r,o,i);var w=e.memoizedState;a!==h||m!==w||Ke.current||Rr?(typeof y=="function"&&(lc(e,t,y,r),w=e.memoizedState),(c=Rr||Zd(e,t,c,r,m,w,u)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,u)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=w),o.props=r,o.state=w,o.context=u,r=c):(typeof o.componentDidUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===n.memoizedProps&&m===n.memoizedState||(e.flags|=1024),r=!1)}return dc(n,e,t,r,s,i)}function dc(n,e,t,r,i,s){np(n,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&Hd(e,t,!1),kr(n,e,s);r=e.stateNode,$0.current=e;var a=o&&typeof t.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,n!==null&&o?(e.child=as(e,n.child,null,s),e.child=as(e,null,a,s)):be(n,e,a,s),e.memoizedState=r.state,i&&Hd(e,t,!0),e.child}function rp(n){var e=n.stateNode;e.pendingContext?_d(n,e.pendingContext,e.pendingContext!==e.context):e.context&&_d(n,e.context,!1),Nf(n,e.containerInfo)}function ch(n,e,t,r,i){return os(),Tf(i),e.flags|=256,be(n,e,t,r),e.child}var hc={dehydrated:null,treeContext:null,retryLane:0};function gc(n){return{baseLanes:n,cachePool:null,transitions:null}}function ip(n,e,t){var r=e.pendingProps,i=re.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=n!==null&&n.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(n===null||n.memoizedState!==null)&&(i|=1),Q(re,i&1),n===null)return oc(e),n=e.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?(e.mode&1?n.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,n=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=Ol(o,r,0,null),n=pi(n,r,t,null),s.return=e,n.return=e,s.sibling=n,e.child=s,e.child.memoizedState=gc(t),e.memoizedState=hc,n):Ff(e,o));if(i=n.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return z0(n,e,o,r,a,i,t);if(s){s=r.fallback,o=e.mode,i=n.child,a=i.sibling;var u={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=u,e.deletions=null):(r=Kr(i,u),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=Kr(a,s):(s=pi(s,o,t,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=n.child.memoizedState,o=o===null?gc(t):{baseLanes:o.baseLanes|t,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=n.childLanes&~t,e.memoizedState=hc,r}return s=n.child,n=s.sibling,r=Kr(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=t),r.return=e,r.sibling=null,n!==null&&(t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)),e.child=r,e.memoizedState=null,r}function Ff(n,e){return e=Ol({mode:"visible",children:e},n.mode,0,null),e.return=n,n.child=e}function Qo(n,e,t,r){return r!==null&&Tf(r),as(e,n.child,null,t),n=Ff(e,e.pendingProps.children),n.flags|=2,e.memoizedState=null,n}function z0(n,e,t,r,i,s,o){if(t)return e.flags&256?(e.flags&=-257,r=pu(Error(x(422))),Qo(n,e,o,r)):e.memoizedState!==null?(e.child=n.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=Ol({mode:"visible",children:r.children},i,0,null),s=pi(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&as(e,n.child,null,o),e.child.memoizedState=gc(o),e.memoizedState=hc,s);if(!(e.mode&1))return Qo(n,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(x(419)),r=pu(s,r,void 0),Qo(n,e,o,r)}if(a=(o&n.childLanes)!==0,Ve||a){if(r=Ae,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Sr(n,i),bt(r,n,i,-1))}return jf(),r=pu(Error(x(421))),Qo(n,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=n.child,e=Z0.bind(null,n),i._reactRetry=e,null):(n=s.treeContext,Qe=Ur(i.nextSibling),et=e,ee=!0,Ot=null,n!==null&&(ot[at++]=cr,ot[at++]=fr,ot[at++]=Si,cr=n.id,fr=n.overflow,Si=e),e=Ff(e,r.children),e.flags|=4096,e)}function fh(n,e,t){n.lanes|=e;var r=n.alternate;r!==null&&(r.lanes|=e),ac(n.return,e,t)}function yu(n,e,t,r,i){var s=n.memoizedState;s===null?n.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=t,s.tailMode=i)}function sp(n,e,t){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(be(n,e,r.children,t),r=re.current,r&2)r=r&1|2,e.flags|=128;else{if(n!==null&&n.flags&128)e:for(n=e.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&fh(n,t,e);else if(n.tag===19)fh(n,t,e);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}r&=1}if(Q(re,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(t=e.child,i=null;t!==null;)n=t.alternate,n!==null&&ja(n)===null&&(i=t),t=t.sibling;t=i,t===null?(i=e.child,e.child=null):(i=t.sibling,t.sibling=null),yu(e,!1,i,t,s);break;case"backwards":for(t=null,i=e.child,e.child=null;i!==null;){if(n=i.alternate,n!==null&&ja(n)===null){e.child=i;break}n=i.sibling,i.sibling=t,t=i,i=n}yu(e,!0,t,null,s);break;case"together":yu(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ma(n,e){!(e.mode&1)&&n!==null&&(n.alternate=null,e.alternate=null,e.flags|=2)}function kr(n,e,t){if(n!==null&&(e.dependencies=n.dependencies),Ti|=e.lanes,!(t&e.childLanes))return null;if(n!==null&&e.child!==n.child)throw Error(x(153));if(e.child!==null){for(n=e.child,t=Kr(n,n.pendingProps),e.child=t,t.return=e;n.sibling!==null;)n=n.sibling,t=t.sibling=Kr(n,n.pendingProps),t.return=e;t.sibling=null}return e.child}function U0(n,e,t){switch(e.tag){case 3:rp(e),os();break;case 5:Rm(e);break;case 1:We(e.type)&&Fa(e);break;case 4:Nf(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;Q($a,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(Q(re,re.current&1),e.flags|=128,null):t&e.child.childLanes?ip(n,e,t):(Q(re,re.current&1),n=kr(n,e,t),n!==null?n.sibling:null);Q(re,re.current&1);break;case 19:if(r=(t&e.childLanes)!==0,n.flags&128){if(r)return sp(n,e,t);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Q(re,re.current),r)break;return null;case 22:case 23:return e.lanes=0,tp(n,e,t)}return kr(n,e,t)}var op,mc,ap,lp;op=function(n,e){for(var t=e.child;t!==null;){if(t.tag===5||t.tag===6)n.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};mc=function(){};ap=function(n,e,t,r){var i=n.memoizedProps;if(i!==r){n=e.stateNode,di(rn.current);var s=null;switch(t){case"input":i=Mu(n,i),r=Mu(n,r),s=[];break;case"select":i=oe({},i,{value:void 0}),r=oe({},r,{value:void 0}),s=[];break;case"textarea":i=zu(n,i),r=zu(n,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(n.onclick=Ba)}ju(t,r);var o;t=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(o in a)a.hasOwnProperty(o)&&(t||(t={}),t[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Xs.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var u=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&u!==a&&(u!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||u&&u.hasOwnProperty(o)||(t||(t={}),t[o]="");for(o in u)u.hasOwnProperty(o)&&a[o]!==u[o]&&(t||(t={}),t[o]=u[o])}else t||(s||(s=[]),s.push(c,t)),t=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,a=a?a.__html:void 0,u!=null&&a!==u&&(s=s||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(s=s||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Xs.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&X("scroll",n),s||a===u||(s=[])):(s=s||[]).push(c,u))}t&&(s=s||[]).push("style",t);var c=s;(e.updateQueue=c)&&(e.flags|=4)}};lp=function(n,e,t,r){t!==r&&(e.flags|=4)};function Ps(n,e){if(!ee)switch(n.tailMode){case"hidden":e=n.tail;for(var t=null;e!==null;)e.alternate!==null&&(t=e),e=e.sibling;t===null?n.tail=null:t.sibling=null;break;case"collapsed":t=n.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e||n.tail===null?n.tail=null:n.tail.sibling=null:r.sibling=null}}function De(n){var e=n.alternate!==null&&n.alternate.child===n.child,t=0,r=0;if(e)for(var i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=n,i=i.sibling;else for(i=n.child;i!==null;)t|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=n,i=i.sibling;return n.subtreeFlags|=r,n.childLanes=t,e}function j0(n,e,t){var r=e.pendingProps;switch(kf(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return De(e),null;case 1:return We(e.type)&&ba(),De(e),null;case 3:return r=e.stateNode,ls(),Z(Ke),Z(Le),Df(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(n===null||n.child===null)&&(Go(e)?e.flags|=4:n===null||n.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Ot!==null&&(Ac(Ot),Ot=null))),mc(n,e),De(e),null;case 5:Pf(e);var i=di(co.current);if(t=e.type,n!==null&&e.stateNode!=null)ap(n,e,t,r,i),n.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(x(166));return De(e),null}if(n=di(rn.current),Go(e)){r=e.stateNode,t=e.type;var s=e.memoizedProps;switch(r[Kt]=e,r[lo]=s,n=(e.mode&1)!==0,t){case"dialog":X("cancel",r),X("close",r);break;case"iframe":case"object":case"embed":X("load",r);break;case"video":case"audio":for(i=0;i<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=o.createElement(t,{is:r.is}):(n=o.createElement(t),t==="select"&&(o=n,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):n=o.createElementNS(n,t),n[Kt]=e,n[lo]=r,op(n,e,!1,!1),e.stateNode=n;e:{switch(o=Vu(t,r),t){case"dialog":X("cancel",n),X("close",n),i=r;break;case"iframe":case"object":case"embed":X("load",n),i=r;break;case"video":case"audio":for(i=0;ics&&(e.flags|=128,r=!0,Ps(s,!1),e.lanes=4194304)}else{if(!r)if(n=ja(o),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),Ps(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!ee)return De(e),null}else 2*he()-s.renderingStartTime>cs&&t!==1073741824&&(e.flags|=128,r=!0,Ps(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(t=s.last,t!==null?t.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=he(),e.sibling=null,t=re.current,Q(re,r?t&1|2:t&1),e):(De(e),null);case 22:case 23:return Uf(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ye&1073741824&&(De(e),e.subtreeFlags&6&&(e.flags|=8192)):De(e),null;case 24:return null;case 25:return null}throw Error(x(156,e.tag))}function V0(n,e){switch(kf(e),e.tag){case 1:return We(e.type)&&ba(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return ls(),Z(Ke),Z(Le),Df(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Pf(e),null;case 13:if(Z(re),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(x(340));os()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return Z(re),null;case 4:return ls(),null;case 10:return Ef(e.type._context),null;case 22:case 23:return Uf(),null;case 24:return null;default:return null}}var Xo=!1,Oe=!1,q0=typeof WeakSet=="function"?WeakSet:Set,L=null;function Ki(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){le(n,e,r)}else t.current=null}function pc(n,e,t){try{t()}catch(r){le(n,e,r)}}var dh=!1;function K0(n,e){if(Zu=Oa,n=dm(),wf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var o=0,a=-1,u=-1,c=0,d=0,h=n,m=null;t:for(;;){for(var y;h!==t||i!==0&&h.nodeType!==3||(a=o+i),h!==s||r!==0&&h.nodeType!==3||(u=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(y=h.firstChild)!==null;)m=h,h=y;for(;;){if(h===n)break t;if(m===t&&++c===i&&(a=o),m===s&&++d===r&&(u=o),(y=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=y}t=a===-1||u===-1?null:{start:a,end:u}}else t=null}t=t||{start:0,end:0}}else t=null;for(ec={focusedElem:n,selectionRange:t},Oa=!1,L=e;L!==null;)if(e=L,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,L=n;else for(;L!==null;){e=L;try{var w=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var T=w.memoizedProps,P=w.memoizedState,p=e.stateNode,g=p.getSnapshotBeforeUpdate(e.elementType===e.type?T:Nt(e.type,T),P);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(I){le(e,e.return,I)}if(n=e.sibling,n!==null){n.return=e.return,L=n;break}L=e.return}return w=dh,dh=!1,w}function qs(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var s=i.destroy;i.destroy=void 0,s!==void 0&&pc(e,t,s)}i=i.next}while(i!==r)}}function Pl(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function yc(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function up(n){var e=n.alternate;e!==null&&(n.alternate=null,up(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Kt],delete e[lo],delete e[rc],delete e[C0],delete e[N0])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function cp(n){return n.tag===5||n.tag===3||n.tag===4}function hh(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||cp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function vc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Ba));else if(r!==4&&(n=n.child,n!==null))for(vc(n,e,t),n=n.sibling;n!==null;)vc(n,e,t),n=n.sibling}function wc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(wc(n,e,t),n=n.sibling;n!==null;)wc(n,e,t),n=n.sibling}var Ie=null,Dt=!1;function Cr(n,e,t){for(t=t.child;t!==null;)fp(n,e,t),t=t.sibling}function fp(n,e,t){if(nn&&typeof nn.onCommitFiberUnmount=="function")try{nn.onCommitFiberUnmount(kl,t)}catch{}switch(t.tag){case 5:Oe||Ki(t,e);case 6:var r=Ie,i=Dt;Ie=null,Cr(n,e,t),Ie=r,Dt=i,Ie!==null&&(Dt?(n=Ie,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):Ie.removeChild(t.stateNode));break;case 18:Ie!==null&&(Dt?(n=Ie,t=t.stateNode,n.nodeType===8?cu(n.parentNode,t):n.nodeType===1&&cu(n,t),ro(n)):cu(Ie,t.stateNode));break;case 4:r=Ie,i=Dt,Ie=t.stateNode.containerInfo,Dt=!0,Cr(n,e,t),Ie=r,Dt=i;break;case 0:case 11:case 14:case 15:if(!Oe&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&pc(t,e,o),i=i.next}while(i!==r)}Cr(n,e,t);break;case 1:if(!Oe&&(Ki(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(a){le(t,e,a)}Cr(n,e,t);break;case 21:Cr(n,e,t);break;case 22:t.mode&1?(Oe=(r=Oe)||t.memoizedState!==null,Cr(n,e,t),Oe=r):Cr(n,e,t);break;default:Cr(n,e,t)}}function gh(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new q0),e.forEach(function(r){var i=ew.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function Ct(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=he()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_0(r/1960))-r,10n?16:n,Fr===null)var r=!1;else{if(n=Fr,Fr=null,_a=0,W&6)throw Error(x(331));var i=W;for(W|=4,L=n.current;L!==null;){var s=L,o=s.child;if(L.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uhe()-$f?mi(n,0):Jf|=t),_e(n,e)}function wp(n,e){e===0&&(n.mode&1?(e=Vo,Vo<<=1,!(Vo&130023424)&&(Vo=4194304)):e=1);var t=Je();n=Sr(n,e),n!==null&&(Co(n,e,t),_e(n,t))}function Z0(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),wp(n,t)}function ew(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(e),wp(n,t)}var Sp;Sp=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ke.current)Ve=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return Ve=!1,U0(n,e,t);Ve=!!(n.flags&131072)}else Ve=!1,ee&&e.flags&1048576&&Am(e,Ja,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ma(n,e),n=e.pendingProps;var i=ss(e,Le.current);Zi(e,t),i=Rf(null,e,r,n,i,t);var s=Lf();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,We(r)?(s=!0,Fa(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Cf(e),i.updater=Cl,e.stateNode=i,i._reactInternals=e,uc(e,r,n,t),e=dc(null,e,r,!0,s,t)):(e.tag=0,ee&&s&&Sf(e),be(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(ma(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=nw(r),n=Nt(r,n),i){case 0:e=fc(null,e,r,n,t);break e;case 1:e=uh(null,e,r,n,t);break e;case 11:e=ah(null,e,r,n,t);break e;case 14:e=lh(null,e,r,Nt(r.type,n),t);break e}throw Error(x(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),fc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),uh(n,e,r,i,t);case 3:e:{if(rp(e),n===null)throw Error(x(387));r=e.pendingProps,s=e.memoizedState,i=s.element,Cm(n,e),Ua(e,r,null,t);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=us(Error(x(423)),e),e=ch(n,e,r,t,i);break e}else if(r!==i){i=us(Error(x(424)),e),e=ch(n,e,r,t,i);break e}else for(Qe=Ur(e.stateNode.containerInfo.firstChild),et=e,ee=!0,Ot=null,t=Om(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(os(),r===i){e=kr(n,e,t);break e}be(n,e,r,t)}e=e.child}return e;case 5:return Rm(e),n===null&&oc(e),r=e.type,i=e.pendingProps,s=n!==null?n.memoizedProps:null,o=i.children,tc(r,i)?o=null:s!==null&&tc(r,s)&&(e.flags|=32),np(n,e),be(n,e,o,t),e.child;case 6:return n===null&&oc(e),null;case 13:return ip(n,e,t);case 4:return Nf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=as(e,null,r,t):be(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),ah(n,e,r,i,t);case 7:return be(n,e,e.pendingProps,t),e.child;case 8:return be(n,e,e.pendingProps.children,t),e.child;case 12:return be(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Q($a,r._currentValue),r._currentValue=o,s!==null)if(Jt(s.value,o)){if(s.children===i.children&&!Ke.current){e=kr(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=mr(-1,t&-t),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?u.next=u:(u.next=d.next,d.next=u),c.pending=u}}s.lanes|=t,u=s.alternate,u!==null&&(u.lanes|=t),ac(s.return,t,e),a.lanes|=t;break}u=u.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(x(341));o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),ac(o,t,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}be(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Zi(e,t),i=At(i),r=r(i),e.flags|=1,be(n,e,r,t),e.child;case 14:return r=e.type,i=Nt(r,e.pendingProps),i=Nt(r.type,i),lh(n,e,r,i,t);case 15:return ep(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Nt(r,i),ma(n,e),e.tag=1,We(r)?(n=!0,Fa(e)):n=!1,Zi(e,t),Pm(e,r,i),uc(e,r,i,t),dc(null,e,r,!0,n,t);case 19:return sp(n,e,t);case 22:return tp(n,e,t)}throw Error(x(156,e.tag))};function kp(n,e){return _g(n,e)}function tw(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(n,e,t,r){return new tw(n,e,t,r)}function Vf(n){return n=n.prototype,!(!n||!n.isReactComponent)}function nw(n){if(typeof n=="function")return Vf(n)?1:0;if(n!=null){if(n=n.$$typeof,n===lf)return 11;if(n===uf)return 14}return 2}function Kr(n,e){var t=n.alternate;return t===null?(t=vt(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function va(n,e,t,r,i,s){var o=2;if(r=n,typeof n=="function")Vf(n)&&(o=1);else if(typeof n=="string")o=5;else e:switch(n){case Fi:return pi(t.children,i,s,e);case af:o=8,i|=8;break;case Lu:return n=vt(12,t,e,i|2),n.elementType=Lu,n.lanes=s,n;case Bu:return n=vt(13,t,e,i),n.elementType=Bu,n.lanes=s,n;case bu:return n=vt(19,t,e,i),n.elementType=bu,n.lanes=s,n;case Dg:return Ol(t,i,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case Ng:o=10;break e;case Pg:o=9;break e;case lf:o=11;break e;case uf:o=14;break e;case Or:o=16,r=null;break e}throw Error(x(130,n==null?n:typeof n,""))}return e=vt(o,t,e,i),e.elementType=n,e.type=r,e.lanes=s,e}function pi(n,e,t,r){return n=vt(7,n,r,e),n.lanes=t,n}function Ol(n,e,t,r){return n=vt(22,n,r,e),n.elementType=Dg,n.lanes=t,n.stateNode={isHidden:!1},n}function vu(n,e,t){return n=vt(6,n,null,e),n.lanes=t,n}function wu(n,e,t){return e=vt(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function rw(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zl(0),this.expirationTimes=Zl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function qf(n,e,t,r,i,s,o,a,u){return n=new rw(n,e,t,a,u),e===1?(e=1,s===!0&&(e|=8)):e=0,s=vt(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Cf(s),n}function iw(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ep)}catch(n){console.error(n)}}Ep(),Ag.exports=it;var uw=Ag.exports,Th=uw;Ou.createRoot=Th.createRoot,Ou.hydrateRoot=Th.hydrateRoot;var H;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(H||(H={}));function Ah(n){const e=H[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class te extends Error{constructor(e,t=H.Unknown,r,i,s){super(cw(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=i??[],this.cause=s}static from(e,t=H.Unknown){return e instanceof te?e:e instanceof Error?e.name=="AbortError"?new te(e.message,H.Canceled):new te(e.message,t,void 0,void 0,e):new te(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===te.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:i=>i===e.typeName?e:void 0}:e,r=[];for(const i of this.details){if("getType"in i){t.findMessage(i.getType().typeName)&&r.push(i);continue}const s=t.findMessage(i.type);if(s)try{r.push(s.fromBinary(i.value))}catch{}}return r}}function cw(n,e){return n.length?`[${Ah(e)}] ${n}`:`[${Ah(e)}]`}function ue(n,e){if(!n)throw new Error(e)}const fw=34028234663852886e22,dw=-34028234663852886e22,hw=4294967295,gw=2147483647,mw=-2147483648;function wa(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>gw||nhw||n<0)throw new Error("invalid uint 32: "+n)}function xp(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>fw||n({no:i.no,name:i.name,localName:n[i.no]})))}function Pp(n,e,t){const r=Object.create(null),i=Object.create(null),s=[];for(const o of e){const a=Dp(o);s.push(a),r[o.name]=a,i[o.no]=a}return{typeName:n,values:s,findName(o){return r[o]},findNumber(o){return i[o]}}}function yw(n,e,t){const r={};for(const i of e){const s=Dp(i);r[s.localName]=s.no,r[s.no]=s.localName}return Np(r,n,e),r}function Dp(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class O{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),i=r.runtime.bin,s=i.makeReadOptions(t);return i.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const r=this.getType(),i=r.runtime.json,s=i.makeReadOptions(t);return i.readMessage(r,e,s,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(i){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${i instanceof Error?i.message:String(i)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,i=r.makeWriteOptions(e),s=i.writerFactory();return r.writeMessage(this,s,i),s.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,i=r.makeWriteOptions(e);return r.writeMessage(this,i)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function vw(n,e,t,r){var i;const s=(i=r==null?void 0:r.localName)!==null&&i!==void 0?i:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new O),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,u){return new o().fromBinary(a,u)},fromJson(a,u){return new o().fromJson(a,u)},fromJsonString(a,u){return new o().fromJsonString(a,u)},equals(a,u){return n.util.equals(o,a,u)}}),o}function ww(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>s,a=!(!(o>>>7)&&e==0),u=(a?o|128:o)&255;if(t.push(u),!a)return}const r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),u=(a?o|128:o)&255;if(t.push(u),!a)return}t.push(e>>>31&1)}}const Sa=4294967296;function Ih(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,i=0;function s(o,a){const u=Number(n.slice(o,a));i*=t,r=r*t+u,r>=Sa&&(i=i+(r/Sa|0),r=r%Sa)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Rp(r,i):Hf(r,i)}function Sw(n,e){let t=Hf(n,e);const r=t.hi&2147483648;r&&(t=Rp(t.lo,t.hi));const i=Op(t.lo,t.hi);return r?"-"+i:i}function Op(n,e){if({lo:n,hi:e}=kw(n,e),e<=2097151)return String(Sa*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,i=e>>16&65535;let s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2;const u=1e7;return s>=u&&(o+=Math.floor(s/u),s%=u),o>=u&&(a+=Math.floor(o/u),o%=u),a.toString()+Eh(o)+Eh(s)}function kw(n,e){return{lo:n>>>0,hi:e>>>0}}function Hf(n,e){return{lo:n|0,hi:e|0}}function Rp(n,e){return e=~e,n?n=~n+1:e+=1,Hf(n,e)}const Eh=n=>{const e=String(n);return"0000000".slice(e.length)+e};function xh(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Tw(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Ch={};function Aw(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof Ch!="object"||Ch.BUF_BIGINT_DISABLE!=="1")){const i=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const c=typeof u=="bigint"?u:BigInt(u);if(c>s||ca||cue(/^-?[0-9]+$/.test(i),`int64 invalid: ${i}`),r=i=>ue(/^[0-9]+$/.test(i),`uint64 invalid: ${i}`);return{zero:"0",supported:!1,parse(i){return typeof i!="string"&&(i=i.toString()),t(i),i},uParse(i){return typeof i!="string"&&(i=i.toString()),r(i),i},enc(i){return typeof i!="string"&&(i=i.toString()),t(i),Ih(i)},uEnc(i){return typeof i!="string"&&(i=i.toString()),r(i),Ih(i)},dec(i,s){return Sw(i,s)},uDec(i,s){return Op(i,s)}}}const ne=Aw();var A;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(A||(A={}));var Qr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(Qr||(Qr={}));function Nr(n,e,t){if(e===t)return!0;if(n==A.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ic(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return wa(e),xh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){xp(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ic(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){wa(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return wa(e),e=(e<<1^e>>31)>>>0,xh(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=ne.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=ne.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=ne.enc(e);return Su(t.lo,t.hi,this.buf),this}sint64(e){let t=ne.enc(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return Su(i,s,this.buf),this}uint64(e){let t=ne.uEnc(e);return Su(t.lo,t.hi,this.buf),this}}class Ew{constructor(e,t){this.varint64=ww,this.uint32=Tw,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ge.Varint:for(;this.buf[this.pos++]&128;);break;case ge.Bit64:this.pos+=4;case ge.Bit32:this.pos+=4;break;case ge.LengthDelimited:let i=this.uint32();this.pos+=i;break;case ge.StartGroup:for(;;){const[s,o]=this.tag();if(o===ge.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return ne.dec(...this.varint64())}uint64(){return ne.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,ne.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ne.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ne.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function xw(n,e,t,r){let i;return{typeName:e,extendee:t,get field(){if(!i){const s=typeof r=="function"?r():r;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,i=n.util.newFieldList([s]).list()[0]}return i},runtime:n}}function Bp(n){const e=n.field.localName,t=Object.create(null);return t[e]=Cw(n),[t,()=>t[e]]}function Cw(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return fs(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Nw(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let ur="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Fl=[];for(let n=0;n>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,i=0;for(let s=0;s>2],i=(r&3)<<4,t=1;break;case 1:e+=ur[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=ur[i|r>>6],e+=ur[r&63],t=0;break}return t&&(e+=ur[i],e+="=",t==1&&(e+="=")),e}};function Pw(n,e,t){Fp(e,n);const r=e.runtime.bin.makeReadOptions(t),i=Nw(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Bp(e);for(const a of i)e.runtime.bin.readField(s,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Dw(n,e,t,r){Fp(e,n);const i=e.runtime.bin.makeReadOptions(r),s=e.runtime.bin.makeWriteOptions(r);if(bp(n,e)){const c=n.getType().runtime.bin.listUnknownFields(n).filter(d=>d.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const d of c)n.getType().runtime.bin.onUnknownField(n,d.no,d.wireType,d.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const u=i.readerFactory(o.finish());for(;u.posr.no==e.field.no)}function Fp(n,e){ue(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Mp(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Lp(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function Nh(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?fs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function yi(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(O.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Jp(n,e){return yi(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}A.DOUBLE,A.FLOAT,A.INT64,A.UINT64,A.INT32,A.UINT32,A.BOOL,A.STRING,A.BYTES;const Ph={ignoreUnknownFields:!1},Dh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ow(n){return n?Object.assign(Object.assign({},Ph),n):Ph}function Rw(n){return n?Object.assign(Object.assign({},Dh),n):Dh}const Ya=Symbol(),ka=Symbol();function Lw(){return{makeReadOptions:Ow,makeWriteOptions:Rw,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${qt(e)}`);r=r??new n;const i=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const u=n.fields.findJsonName(o);if(u){if(u.oneof){if(a===null&&u.kind=="scalar")continue;const c=i.get(u.oneof);if(c!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${c}", "${o}"`);i.set(u.oneof,o)}Oh(r,a,u,t,n)}else{let c=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const d=s.findExtension(o.substring(1,o.length-1));if(d&&d.extendee.typeName==n.typeName){c=!0;const[h,m]=Bp(d);Oh(h,a,d.field,t,d),Dw(r,d,m(),t)}}if(!c&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let i;try{for(i of t.fields.byNumber()){if(!Mp(i,n)){if(i.req)throw"required field not set";if(!e.emitDefaultValues||!bw(i))continue}const o=i.oneof?n[i.oneof.localName].value:n[i.localName],a=Rh(i,o,e);a!==void 0&&(r[e.useProtoFieldName?i.name:i.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&bp(n,a)){const u=Pw(n,a,e),c=Rh(a.field,u,e);c!==void 0&&(r[a.field.jsonName]=c)}}}catch(s){const o=i?`cannot encode field ${t.typeName}.${i.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return _s(n,e,t??Qr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Lp(n,e)))return Ta(n,e)},debug:qt}}function qt(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function Oh(n,e,t,r,i){let s=t.localName;if(t.repeated){if(ue(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const u=ku(t.T,a,r.ignoreUnknownFields,!0);u!==ka&&o.push(u);break;case"scalar":try{o.push(_s(t.T,a,t.L,!0))}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(a)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`);const o=n[s];for(const[a,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${i.typeName}.${t.name} from JSON: map value null`);let c;try{c=Bw(t.K,a)}catch(d){let h=`cannot decode map key for field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw d instanceof Error&&d.message.length>0&&(h+=`: ${d.message}`),new Error(h)}switch(t.V.kind){case"message":o[c]=t.V.T.fromJson(u,r);break;case"enum":const d=ku(t.V.T,u,r.ignoreUnknownFields,!0);d!==ka&&(o[c]=d);break;case"scalar":try{o[c]=_s(t.V.T,u,Qr.BIGINT,!0)}catch(h){let m=`cannot decode map value for field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw h instanceof Error&&h.message.length>0&&(m+=`: ${h.message}`),new Error(m)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];yi(a)?a.fromJson(e,r):(n[s]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const u=ku(t.T,e,r.ignoreUnknownFields,!1);switch(u){case Ya:Nh(t,n);break;case ka:break;default:n[s]=u;break}break;case"scalar":try{const c=_s(t.T,e,t.L,!1);switch(c){case Ya:Nh(t,n);break;default:n[s]=c;break}}catch(c){let d=`cannot decode field ${i.typeName}.${t.name} from JSON: ${qt(e)}`;throw c instanceof Error&&c.message.length>0&&(d+=`: ${c.message}`),new Error(d)}break}}function Bw(n,e){if(n===A.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return _s(n,e,Qr.BIGINT,!0).toString()}function _s(n,e,t,r){if(e===null)return r?fs(n,t):Ya;switch(n){case A.DOUBLE:case A.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const i=Number(e);if(Number.isNaN(i)||!Number.isFinite(i))break;return n==A.FLOAT&&xp(i),i;case A.INT32:case A.FIXED32:case A.SFIXED32:case A.SINT32:case A.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==A.UINT32||n==A.FIXED32?Ic(s):wa(s),s;case A.INT64:case A.SFIXED64:case A.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=ne.parse(e);return t?o.toString():o;case A.FIXED64:case A.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=ne.uParse(e);return t?a.toString():a;case A.BOOL:if(typeof e!="boolean")break;return e;case A.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case A.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Gf.dec(e)}throw new Error}function ku(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Ya;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const i=n.findName(e);if(i!==void 0)return i.no;if(t)return ka;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${qt(e)}`)}function bw(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function Rh(n,e,t){if(n.kind=="map"){ue(typeof e=="object"&&e!=null);const r={},i=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of i)r[o.toString()]=Ta(n.V.T,a);break;case"message":for(const[o,a]of i)r[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of i)r[o.toString()]=Tu(s,a,t.enumAsInteger);break}return t.emitDefaultValues||i.length>0?r:void 0}if(n.repeated){ue(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let i=0;i0?r:void 0}switch(n.kind){case"scalar":return Ta(n.T,e);case"enum":return Tu(n.T,e,t.enumAsInteger);case"message":return Jp(n.T,e).toJson(t)}}function Tu(n,e,t){var r;if(ue(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const i=n.findNumber(e);return(r=i==null?void 0:i.name)!==null&&r!==void 0?r:e}function Ta(n,e){switch(n){case A.INT32:case A.SFIXED32:case A.SINT32:case A.FIXED32:case A.UINT32:return ue(typeof e=="number"),e;case A.FLOAT:case A.DOUBLE:return ue(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case A.STRING:return ue(typeof e=="string"),e;case A.BOOL:return ue(typeof e=="boolean"),e;case A.UINT64:case A.FIXED64:case A.INT64:case A.SFIXED64:case A.SINT64:return ue(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case A.BYTES:return ue(e instanceof Uint8Array),Gf.enc(e)}}const Oi=Symbol("@bufbuild/protobuf/unknown-fields"),Lh={readUnknownFields:!0,readerFactory:n=>new Ew(n)},Bh={writeUnknownFields:!0,writerFactory:()=>new Iw};function Fw(n){return n?Object.assign(Object.assign({},Lh),n):Lh}function Mw(n){return n?Object.assign(Object.assign({},Bh),n):Bh}function Jw(){return{makeReadOptions:Fw,makeWriteOptions:Mw,listUnknownFields(n){var e;return(e=n[Oi])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Oi]},writeUnknownFields(n,e){const r=n[Oi];if(r)for(const i of r)e.tag(i.no,i.wireType).raw(i.data)},onUnknownField(n,e,t,r){const i=n;Array.isArray(i[Oi])||(i[Oi]=[]),i[Oi].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,i){const s=n.getType(),o=i?e.len:e.pos+t;let a,u;for(;e.pos0&&(u=zw),s){let m=n[o];if(r==ge.LengthDelimited&&a!=A.STRING&&a!=A.BYTES){let w=e.uint32()+e.pos;for(;e.posyi(m,h)?m:new h(m));else{const m=o[i];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[i]=Os(m):s[i]=m:s[i]=yi(m,h)?m:new h(m)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const i=e[r.localName],s=t[r.localName];if(r.repeated){if(i.length!==s.length)return!1;switch(r.kind){case"message":return i.every((o,a)=>r.T.equals(o,s[a]));case"scalar":return i.every((o,a)=>Nr(r.T,o,s[a]));case"enum":return i.every((o,a)=>Nr(A.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(i,s);case"enum":return Nr(A.INT32,i,s);case"scalar":return Nr(r.T,i,s);case"oneof":if(i.case!==s.case)return!1;const o=r.findField(i.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(i.value,s.value);case"enum":return Nr(A.INT32,i.value,s.value);case"scalar":return Nr(o.T,i.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(i).concat(Object.keys(s));switch(r.V.kind){case"message":const u=r.V.T;return a.every(d=>u.equals(i[d],s[d]));case"enum":return a.every(d=>Nr(A.INT32,i[d],s[d]));case"scalar":const c=r.V.T;return a.every(d=>Nr(c,i[d],s[d]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const i of e.fields.byMember()){const s=n[i.localName];let o;if(i.repeated)o=s.map(ta);else if(i.kind=="map"){o=r[i.localName];for(const[a,u]of Object.entries(s))o[a]=ta(u)}else i.kind=="oneof"?o=i.findField(s.case)?{case:s.case,value:ta(s.value)}:{case:void 0}:o=ta(s);r[i.localName]=o}for(const i of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,i.no,i.wireType,i.data);return t}}}function ta(n){if(n===void 0)return n;if(yi(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Os(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function qw(n,e,t){return{syntax:n,json:Lw(),bin:Jw(),util:Object.assign(Object.assign({},Vw()),{newFieldList:e,initFields:t}),makeMessageType(r,i,s){return vw(this,r,i,s)},makeEnum:yw,makeEnumType:Pp,getEnumType:pw,makeExtension(r,i,s){return xw(this,r,i,s)}}}class Kw{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function zp(n,e){const t=Up(n);return e?t:Qw(Yw(t))}function Ww(n){return zp(n,!1)}const _w=Up;function Up(n){let e=!1;const t=[];for(let r=0;r`${n}$`,Yw=n=>Gw.has(n)?jp(n):n,Qw=n=>Hw.has(n)?jp(n):n;class Xw{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=Ww(e)}addField(e){ue(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew Kw(n,e=>Zw(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=fs(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Jh;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Jh||(Jh={}));class Re extends O{constructor(e){super(),this.seconds=ne.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=ne.parse(i/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const i=(this.nanos+1e9).toString().substring(1);i.substring(3)==="000000"?r="."+i.substring(0,3)+"Z":i.substring(6)==="000"?r="."+i.substring(0,6)+"Z":r="."+i+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Re.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Re({seconds:ne.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Re().fromBinary(e,t)}static fromJson(e,t){return new Re().fromJson(e,t)}static fromJsonString(e,t){return new Re().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Re,e,t)}}Re.runtime=f;Re.typeName="google.protobuf.Timestamp";Re.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class dr extends O{constructor(e){super(),this.seconds=ne.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const i=Number(r[1]);if(i>315576e6||i<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=ne.parse(i),typeof r[2]=="string"){const s=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(s),(i<0||Object.is(i,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new dr().fromBinary(e,t)}static fromJson(e,t){return new dr().fromJson(e,t)}static fromJsonString(e,t){return new dr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(dr,e,t)}}dr.runtime=f;dr.typeName="google.protobuf.Duration";dr.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Wt extends O{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),i=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!i)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=i.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const i=e["@type"];if(typeof i!="string"||i=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(i),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${i} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const u=Object.assign({},e);delete u["@type"],a=o.fromJson(u,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Wt;return t.packFrom(e),t}static fromBinary(e,t){return new Wt().fromBinary(e,t)}static fromJson(e,t){return new Wt().fromJson(e,t)}static fromJsonString(e,t){return new Wt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Wt,e,t)}}Wt.runtime=f;Wt.typeName="google.protobuf.Any";Wt.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class _t extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.DOUBLE,e)}catch(r){let i='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new _t().fromBinary(e,t)}static fromJson(e,t){return new _t().fromJson(e,t)}static fromJsonString(e,t){return new _t().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_t,e,t)}}_t.runtime=f;_t.typeName="google.protobuf.DoubleValue";_t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);_t.fieldWrapper={wrapField(n){return new _t({value:n})},unwrapField(n){return n.value}};class Ht extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.FLOAT,e)}catch(r){let i='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Ht().fromBinary(e,t)}static fromJson(e,t){return new Ht().fromJson(e,t)}static fromJsonString(e,t){return new Ht().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ht,e,t)}}Ht.runtime=f;Ht.typeName="google.protobuf.FloatValue";Ht.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Ht.fieldWrapper={wrapField(n){return new Ht({value:n})},unwrapField(n){return n.value}};class Gt extends O{constructor(e){super(),this.value=ne.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT64,e)}catch(r){let i='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Gt().fromBinary(e,t)}static fromJson(e,t){return new Gt().fromJson(e,t)}static fromJsonString(e,t){return new Gt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gt,e,t)}}Gt.runtime=f;Gt.typeName="google.protobuf.Int64Value";Gt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Gt.fieldWrapper={wrapField(n){return new Gt({value:n})},unwrapField(n){return n.value}};class Yt extends O{constructor(e){super(),this.value=ne.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT64,e)}catch(r){let i='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Yt().fromBinary(e,t)}static fromJson(e,t){return new Yt().fromJson(e,t)}static fromJsonString(e,t){return new Yt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Yt,e,t)}}Yt.runtime=f;Yt.typeName="google.protobuf.UInt64Value";Yt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Yt.fieldWrapper={wrapField(n){return new Yt({value:n})},unwrapField(n){return n.value}};class Qt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.INT32,e)}catch(r){let i='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Qt().fromBinary(e,t)}static fromJson(e,t){return new Qt().fromJson(e,t)}static fromJsonString(e,t){return new Qt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Qt,e,t)}}Qt.runtime=f;Qt.typeName="google.protobuf.Int32Value";Qt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Qt.fieldWrapper={wrapField(n){return new Qt({value:n})},unwrapField(n){return n.value}};class Xt extends O{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.UINT32,e)}catch(r){let i='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xt().fromBinary(e,t)}static fromJson(e,t){return new Xt().fromJson(e,t)}static fromJsonString(e,t){return new Xt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xt,e,t)}}Xt.runtime=f;Xt.typeName="google.protobuf.UInt32Value";Xt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Xt.fieldWrapper={wrapField(n){return new Xt({value:n})},unwrapField(n){return n.value}};class Zt extends O{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BOOL,e)}catch(r){let i='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Zt().fromBinary(e,t)}static fromJson(e,t){return new Zt().fromJson(e,t)}static fromJsonString(e,t){return new Zt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zt,e,t)}}Zt.runtime=f;Zt.typeName="google.protobuf.BoolValue";Zt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Zt.fieldWrapper={wrapField(n){return new Zt({value:n})},unwrapField(n){return n.value}};class Xe extends O{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.STRING,e)}catch(r){let i='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new Xe().fromBinary(e,t)}static fromJson(e,t){return new Xe().fromJson(e,t)}static fromJsonString(e,t){return new Xe().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xe,e,t)}}Xe.runtime=f;Xe.typeName="google.protobuf.StringValue";Xe.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Xe.fieldWrapper={wrapField(n){return new Xe({value:n})},unwrapField(n){return n.value}};class en extends O{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(A.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(A.BYTES,e)}catch(r){let i='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(i+=`: ${r.message}`),new Error(i)}return this}static fromBinary(e,t){return new en().fromBinary(e,t)}static fromJson(e,t){return new en().fromJson(e,t)}static fromJsonString(e,t){return new en().fromJsonString(e,t)}static equals(e,t){return f.util.equals(en,e,t)}}en.runtime=f;en.typeName="google.protobuf.BytesValue";en.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);en.fieldWrapper={wrapField(n){return new en({value:n})},unwrapField(n){return n.value}};function e1(n,e,t){try{const r=Gf.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw te.from(r,H.DataLoss)}}function t1(n,e){const t={};for(const[r,i]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},i),{localName:r,service:n}));s!=null&&(t[r]=s)}return t}function $h(n){let e,t=new Uint8Array(0);function r(i){const s=new Uint8Array(t.length+i.length);s.set(t),s.set(i,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(i){let s;for(;;){if(s===void 0&&t.byteLength>=5){let u=0;for(let c=1;c<5;c++)u=(u<<8)+t[c];s={flags:t[0],length:u}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(s===void 0){if(t.byteLength==0){i.close();return}i.error(new te("premature end of stream",H.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),i.enqueue({flags:s.flags,data:o})}})}function zh(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var n1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){o=n[s](o),i(a,u,o.done,o.value)})}}function i(s,o,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},o)}},po=function(n){return this instanceof po?(this.v=n,this):new po(n)},r1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof po?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}},i1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:po(n[i](o)),done:!1}:s?s(o):o}:s}};function s1(n){return r1(this,arguments,function*(){yield po(yield*i1(n1(n)))})}var Vp=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){o=n[s](o),i(a,u,o.done,o.value)})}}function i(s,o,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},o)}},ds=function(n){return this instanceof ds?(this.v=n,this):new ds(n)},o1=function(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:ds(n[i](o)),done:!1}:s?s(o):o}:s}},a1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof ds?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}};function l1(n,e){return t1(n,t=>{switch(t.kind){case Fe.Unary:return u1(e,n,t);case Fe.ServerStreaming:return c1(e,n,t);case Fe.ClientStreaming:return f1(e,n,t);case Fe.BiDiStreaming:return d1(e,n,t);default:return null}})}function u1(n,e,t){return async function(r,i){var s,o;const a=await n.unary(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);return(s=i==null?void 0:i.onHeader)===null||s===void 0||s.call(i,a.header),(o=i==null?void 0:i.onTrailer)===null||o===void 0||o.call(i,a.trailer),a.message}}function c1(n,e,t){return function(r,i){return qp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,s1([r]),i==null?void 0:i.contextValues),i)}}function f1(n,e,t){return async function(r,i){var s,o,a,u,c,d;const h=await n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues);(c=i==null?void 0:i.onHeader)===null||c===void 0||c.call(i,h.header);let m;try{for(var y=!0,w=Vp(h.message),T;T=await w.next(),s=T.done,!s;y=!0)u=T.value,y=!1,m=u}catch(P){o={error:P}}finally{try{!y&&!s&&(a=w.return)&&await a.call(w)}finally{if(o)throw o.error}}if(!m)throw new te("protocol error: missing response message",H.Internal);return(d=i==null?void 0:i.onTrailer)===null||d===void 0||d.call(i,h.trailer),m}}function d1(n,e,t){return function(r,i){return qp(n.stream(e,t,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,r,i==null?void 0:i.contextValues),i)}}function qp(n,e){const t=function(){var r,i;return a1(this,arguments,function*(){const s=yield ds(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,s.header),yield ds(yield*o1(Vp(s.message))),(i=e==null?void 0:e.onTrailer)===null||i===void 0||i.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function h1(...n){const e=new AbortController,t=n.filter(i=>i!==void 0).concat(e.signal);for(const i of t){if(i.aborted){r.apply(i);break}i.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(Kp(this));for(const i of t)i.removeEventListener("abort",r)}return e}function g1(n){const e=new AbortController,t=()=>{e.abort(new te("the operation timed out",H.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function Kp(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function Uh(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Au=128;function jh(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r +`);for(const r of t){if(r==="")continue;const i=r.indexOf(":");if(i>0){const s=r.substring(0,i).trim(),o=r.substring(i+1).trim();e.append(s,o)}}return e}const m1="Content-Type",p1="Grpc-Timeout",Wp="Grpc-Status",_p="Grpc-Message",y1="Grpc-Status-Details-Bin",v1="X-User-Agent",w1="X-Grpc-Web",S1="application/grpc-web+proto",k1="application/grpc-web+json";class hr extends O{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new hr().fromBinary(e,t)}static fromJson(e,t){return new hr().fromJson(e,t)}static fromJsonString(e,t){return new hr().fromJsonString(e,t)}static equals(e,t){return f.util.equals(hr,e,t)}}hr.runtime=f;hr.typeName="google.rpc.Status";hr.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Wt,repeated:!0}]);const T1="0";function Hp(n){var e;const t=n.get(y1);if(t!=null){const i=e1(t,hr);if(i.code==0)return;const s=new te(i.message,i.code,n);return s.details=i.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const r=n.get(Wp);if(r!=null){if(r===T1)return;const i=parseInt(r,10);return i in H?new te(decodeURIComponent((e=n.get(_p))!==null&&e!==void 0?e:""),i,n):new te(`invalid grpc-status: ${r}`,H.Internal,n)}}function Vh(n,e,t){const r=typeof e=="string"?e:e.typeName,i=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${i}`)}function Gp(n,e){return e instanceof n?e:new n(e)}function A1(n,e){function t(r){return r.done===!0?r:{done:r.done,value:Gp(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),i={next:()=>r.next().then(t)};return r.throw!==void 0&&(i.throw=s=>r.throw(s).then(t)),r.return!==void 0&&(i.return=s=>r.return(s).then(t)),i}}}function Yp(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,i)=>i(r),n))!==null&&t!==void 0?t:n}function I1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function qh(n,e,t,r){const i=e?Kh(n.I,r):Wh(n.I,t);return{parse:(e?Kh(n.O,r):Wh(n.O,t)).parse,serialize:i.serialize}}function Kh(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new te(`parse binary: ${i}`,H.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const i=r instanceof Error?r.message:String(r);throw new te(`serialize binary: ${i}`,H.Internal)}}}}function Wh(n,e){var t,r;const i=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=I1(e);return{parse(a){try{const u=s.decode(a);return n.fromJsonString(u,o)}catch(u){throw te.from(u,H.InvalidArgument)}},serialize(a){try{const u=a.toJsonString(o);return i.encode(u)}catch(u){throw te.from(u,H.Internal)}}}}function E1(n){const e=Yp(n.next,n.interceptors),[t,r,i]=Qp(n),s=Object.assign(Object.assign({},n.req),{message:Gp(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(i(),o),r)}function x1(n){const e=Yp(n.next,n.interceptors),[t,r,i]=Qp(n),s=Object.assign(Object.assign({},n.req),{message:A1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,u;const c=n.req.message[Symbol.asyncIterator]();o||(a=c.throw)===null||a===void 0||a.call(c,this.reason).catch(()=>{}),(u=c.return)===null||u===void 0||u.call(c).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const u=a.message[Symbol.asyncIterator]();return{next(){return u.next().then(c=>(c.done==!0&&(o=!0,i()),c),r)}}}}}),r)}function Qp(n){const{signal:e,cleanup:t}=g1(n.timeoutMs),r=h1(n.signal,e);return[r.signal,function(s){const o=te.from(e.aborted?Kp(e):s);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function C1(){try{new Headers}catch{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.")}}function _h(n,e){const t=Hp(n);if(t)throw e.forEach((r,i)=>{t.metadata.append(i,r)}),t}function Hh(n,e,t,r){const i=new Headers(t??{});return i.set(m1,n?S1:k1),i.set(w1,"1"),i.set(v1,"connect-es/1.4.0"),e!==void 0&&i.set(p1,`${e}m`),i}function N1(n){switch(n){case 400:return H.Internal;case 401:return H.Unauthenticated;case 403:return H.PermissionDenied;case 404:return H.Unimplemented;case 429:return H.Unavailable;case 502:return H.Unavailable;case 503:return H.Unavailable;case 504:return H.Unavailable;default:return H.Unknown}}function Gh(n,e){var t;if(n>=200&&n<300){const r=Hp(e);if(r)throw r;return{foundStatus:e.has(Wp)}}throw new te(decodeURIComponent((t=e.get(_p))!==null&&t!==void 0?t:`HTTP ${n}`),N1(n),e)}var hi=function(n){return this instanceof hi?(this.v=n,this):new hi(n)},P1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(y){return function(w){return Promise.resolve(w).then(y,h)}}function a(y,w){r[y]&&(i[y]=function(T){return new Promise(function(P,p){s.push([y,T,P,p])>1||u(y,T)})},w&&(i[y]=w(i[y])))}function u(y,w){try{c(r[y](w))}catch(T){m(s[0][3],T)}}function c(y){y.value instanceof hi?Promise.resolve(y.value.v).then(d,h):m(s[0][2],y)}function d(y){u("next",y)}function h(y){u("throw",y)}function m(y,w){y(w),s.shift(),s.length&&u(s[0][0],s[0][1])}};function D1(n){var e;C1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,i,s,o,a,u,c){var d;const{serialize:h,parse:m}=qh(i,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await E1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:r,method:i,url:Vh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Hh(t,o,a),contextValues:c??Uh(),message:u},next:async y=>{var w;const P=await((w=n.fetch)!==null&&w!==void 0?w:globalThis.fetch)(y.url,Object.assign(Object.assign({},y.init),{headers:y.header,signal:y.signal,body:zh(0,h(y.message))}));if(Gh(P.status,P.headers),!P.body)throw"missing response body";const p=$h(P.body).getReader();let g,v;for(;;){const I=await p.read();if(I.done)break;const{flags:E,data:N}=I.value;if(E===Au){if(g!==void 0)throw"extra trailer";g=jh(N);continue}if(v!==void 0)throw"extra message";v=m(N)}if(g===void 0)throw"missing trailer";if(_h(g,P.headers),v===void 0)throw"missing message";return{stream:!1,service:r,method:i,header:P.headers,message:v,trailer:g}}})},async stream(r,i,s,o,a,u,c){var d;const{serialize:h,parse:m}=qh(i,t,n.jsonOptions,n.binaryOptions);function y(T,P,p,g){return P1(this,arguments,function*(){const I=$h(T).getReader();if(P){if(!(yield hi(I.read())).done)throw"extra data for trailers-only";return yield hi(void 0)}let E=!1;for(;;){const N=yield hi(I.read());if(N.done)break;const{flags:D,data:R}=N.value;if((D&Au)===Au){if(E)throw"extra trailer";E=!0;const q=jh(R);_h(q,g),q.forEach(($,Se)=>p.set(Se,$));continue}if(E)throw"extra message";yield yield hi(m(R))}if(!E)throw"missing trailer"})}async function w(T){if(i.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const P=await T[Symbol.asyncIterator]().next();if(P.done==!0)throw"missing request message";return zh(0,h(P.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,x1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:r,method:i,url:Vh(n.baseUrl,r,i),init:{method:"POST",credentials:(d=n.credentials)!==null&&d!==void 0?d:"same-origin",redirect:"error",mode:"cors"},header:Hh(t,o,a),contextValues:c??Uh(),message:u},next:async T=>{var P;const g=await((P=n.fetch)!==null&&P!==void 0?P:globalThis.fetch)(T.url,Object.assign(Object.assign({},T.init),{headers:T.header,signal:T.signal,body:await w(T.message)})),{foundStatus:v}=Gh(g.status,g.headers);if(!g.body)throw"missing response body";const I=new Headers;return Object.assign(Object.assign({},T),{header:g.headers,trailer:I,message:y(g.body,v,I,g.headers)})}})}}}var z=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(z||{});f.util.setEnumType(z,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var vi=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(vi||{});f.util.setEnumType(vi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const ln=class ln extends O{constructor(t){super();l(this,"root");l(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};l(ln,"runtime",f),l(ln,"typeName","yorkie.v1.Snapshot"),l(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:Ge},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Qf}}]));let Ec=ln;var ut;let Er=(ut=class extends O{constructor(t){super();l(this,"documentKey","");l(this,"checkpoint");l(this,"snapshot",new Uint8Array(0));l(this,"changes",[]);l(this,"minSyncedTicket");l(this,"isRemoved",!1);l(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ut().fromBinary(t,r)}static fromJson(t,r){return new ut().fromJson(t,r)}static fromJsonString(t,r){return new ut().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ut,t,r)}},l(ut,"runtime",f),l(ut,"typeName","yorkie.v1.ChangePack"),l(ut,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:ey},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:Xp,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:b},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Jl}])),ut);var ct;let Xp=(ct=class extends O{constructor(t){super();l(this,"id");l(this,"message","");l(this,"operations",[]);l(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new ct().fromBinary(t,r)}static fromJson(t,r){return new ct().fromJson(t,r)}static fromJsonString(t,r){return new ct().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ct,t,r)}},l(ct,"runtime",f),l(ct,"typeName","yorkie.v1.Change"),l(ct,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Ml},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Yf,repeated:!0},{no:4,name:"presence_change",kind:"message",T:wo}])),ct);var ft;let Ml=(ft=class extends O{constructor(t){super();l(this,"clientSeq",0);l(this,"serverSeq",ne.zero);l(this,"lamport",ne.zero);l(this,"actorId",new Uint8Array(0));l(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new ft().fromBinary(t,r)}static fromJson(t,r){return new ft().fromJson(t,r)}static fromJsonString(t,r){return new ft().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ft,t,r)}},l(ft,"runtime",f),l(ft,"typeName","yorkie.v1.ChangeID"),l(ft,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Jl}])),ft);var dt;let Jl=(dt=class extends O{constructor(t){super();l(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new dt().fromBinary(t,r)}static fromJson(t,r){return new dt().fromJson(t,r)}static fromJsonString(t,r){return new dt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dt,t,r)}},l(dt,"runtime",f),l(dt,"typeName","yorkie.v1.VersionVector"),l(dt,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),dt);var ht;let Yf=(ht=class extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new ht().fromBinary(t,r)}static fromJson(t,r){return new ht().fromJson(t,r)}static fromJsonString(t,r){return new ht().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ht,t,r)}},l(ht,"runtime",f),l(ht,"typeName","yorkie.v1.Operation"),l(ht,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Xa,oneof:"body"},{no:2,name:"add",kind:"message",T:Za,oneof:"body"},{no:3,name:"move",kind:"message",T:el,oneof:"body"},{no:4,name:"remove",kind:"message",T:tl,oneof:"body"},{no:5,name:"edit",kind:"message",T:nl,oneof:"body"},{no:6,name:"select",kind:"message",T:xc,oneof:"body"},{no:7,name:"style",kind:"message",T:rl,oneof:"body"},{no:8,name:"increase",kind:"message",T:il,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:sl,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ol,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Cc,oneof:"body"}])),ht);const un=class un extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"key","");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};l(un,"runtime",f),l(un,"typeName","yorkie.v1.Operation.Set"),l(un,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let Xa=un;const cn=class cn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"prevCreatedAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};l(cn,"runtime",f),l(cn,"typeName","yorkie.v1.Operation.Add"),l(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let Za=cn;const fn=class fn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"prevCreatedAt");l(this,"createdAt");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};l(fn,"runtime",f),l(fn,"typeName","yorkie.v1.Operation.Move"),l(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"prev_created_at",kind:"message",T:b},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"executed_at",kind:"message",T:b}]));let el=fn;const dn=class dn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"createdAt");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};l(dn,"runtime",f),l(dn,"typeName","yorkie.v1.Operation.Remove"),l(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"executed_at",kind:"message",T:b}]));let tl=dn;const hn=class hn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"createdAtMapByActor",{});l(this,"content","");l(this,"executedAt");l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};l(hn,"runtime",f),l(hn,"typeName","yorkie.v1.Operation.Edit"),l(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:b},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let nl=hn;const gn=class gn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};l(gn,"runtime",f),l(gn,"typeName","yorkie.v1.Operation.Select"),l(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"executed_at",kind:"message",T:b}]));let xc=gn;const mn=class mn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"attributes",{});l(this,"executedAt");l(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};l(mn,"runtime",f),l(mn,"typeName","yorkie.v1.Operation.Style"),l(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Tr},{no:3,name:"to",kind:"message",T:Tr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let rl=mn;const pn=class pn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};l(pn,"runtime",f),l(pn,"typeName","yorkie.v1.Operation.Increase"),l(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"value",kind:"message",T:lt},{no:3,name:"executed_at",kind:"message",T:b}]));let il=pn;const yn=class yn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"createdAtMapByActor",{});l(this,"contents",[]);l(this,"splitLevel",0);l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};l(yn,"runtime",f),l(yn,"typeName","yorkie.v1.Operation.TreeEdit"),l(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}},{no:5,name:"contents",kind:"message",T:ml,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:b}]));let sl=yn;const vn=class vn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"from");l(this,"to");l(this,"attributes",{});l(this,"executedAt");l(this,"attributesToRemove",[]);l(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};l(vn,"runtime",f),l(vn,"typeName","yorkie.v1.Operation.TreeStyle"),l(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:b},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:b}}]));let ol=vn;const wn=class wn extends O{constructor(t){super();l(this,"parentCreatedAt");l(this,"createdAt");l(this,"value");l(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};l(wn,"runtime",f),l(wn,"typeName","yorkie.v1.Operation.ArraySet"),l(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:b},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"value",kind:"message",T:lt},{no:4,name:"executed_at",kind:"message",T:b}]));let Cc=wn;const Sn=class Sn extends O{constructor(t){super();l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");l(this,"type",0);l(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};l(Sn,"runtime",f),l(Sn,"typeName","yorkie.v1.JSONElementSimple"),l(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"moved_at",kind:"message",T:b},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"type",kind:"enum",T:f.getEnumType(z)},{no:5,name:"value",kind:"scalar",T:12}]));let lt=Sn;const kn=class kn extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};l(kn,"runtime",f),l(kn,"typeName","yorkie.v1.JSONElement"),l(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:al,oneof:"body"},{no:2,name:"json_array",kind:"message",T:ll,oneof:"body"},{no:3,name:"primitive",kind:"message",T:ul,oneof:"body"},{no:5,name:"text",kind:"message",T:cl,oneof:"body"},{no:6,name:"counter",kind:"message",T:fl,oneof:"body"},{no:7,name:"tree",kind:"message",T:dl,oneof:"body"}]));let Ge=kn;const Tn=class Tn extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};l(Tn,"runtime",f),l(Tn,"typeName","yorkie.v1.JSONElement.JSONObject"),l(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Zp,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let al=Tn;const An=class An extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};l(An,"runtime",f),l(An,"typeName","yorkie.v1.JSONElement.JSONArray"),l(An,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:hl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let ll=An;const In=class In extends O{constructor(t){super();l(this,"type",0);l(this,"value",new Uint8Array(0));l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};l(In,"runtime",f),l(In,"typeName","yorkie.v1.JSONElement.Primitive"),l(In,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let ul=In;const En=class En extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};l(En,"runtime",f),l(En,"typeName","yorkie.v1.JSONElement.Text"),l(En,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:gl,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let cl=En;const xn=class xn extends O{constructor(t){super();l(this,"type",0);l(this,"value",new Uint8Array(0));l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};l(xn,"runtime",f),l(xn,"typeName","yorkie.v1.JSONElement.Counter"),l(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(z)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:b},{no:4,name:"moved_at",kind:"message",T:b},{no:5,name:"removed_at",kind:"message",T:b}]));let fl=xn;const Cn=class Cn extends O{constructor(t){super();l(this,"nodes",[]);l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};l(Cn,"runtime",f),l(Cn,"typeName","yorkie.v1.JSONElement.Tree"),l(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:vo,repeated:!0},{no:2,name:"created_at",kind:"message",T:b},{no:3,name:"moved_at",kind:"message",T:b},{no:4,name:"removed_at",kind:"message",T:b}]));let dl=Cn;var gt;let Zp=(gt=class extends O{constructor(t){super();l(this,"key","");l(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new gt().fromBinary(t,r)}static fromJson(t,r){return new gt().fromJson(t,r)}static fromJsonString(t,r){return new gt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gt,t,r)}},l(gt,"runtime",f),l(gt,"typeName","yorkie.v1.RHTNode"),l(gt,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:Ge}])),gt);const Vt=class Vt extends O{constructor(t){super();l(this,"next");l(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vt().fromBinary(t,r)}static fromJson(t,r){return new Vt().fromJson(t,r)}static fromJsonString(t,r){return new Vt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vt,t,r)}};l(Vt,"runtime",f),l(Vt,"typeName","yorkie.v1.RGANode"),l(Vt,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Vt},{no:2,name:"element",kind:"message",T:Ge}]));let hl=Vt;const Nn=class Nn extends O{constructor(t){super();l(this,"value","");l(this,"updatedAt");l(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};l(Nn,"runtime",f),l(Nn,"typeName","yorkie.v1.NodeAttr"),l(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:b},{no:3,name:"is_removed",kind:"scalar",T:8}]));let hs=Nn;const Pn=class Pn extends O{constructor(t){super();l(this,"id");l(this,"value","");l(this,"removedAt");l(this,"insPrevId");l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};l(Pn,"runtime",f),l(Pn,"typeName","yorkie.v1.TextNode"),l(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:yo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:b},{no:4,name:"ins_prev_id",kind:"message",T:yo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let gl=Pn;const Dn=class Dn extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};l(Dn,"runtime",f),l(Dn,"typeName","yorkie.v1.TextNodeID"),l(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let yo=Dn;const On=class On extends O{constructor(t){super();l(this,"id");l(this,"type","");l(this,"value","");l(this,"removedAt");l(this,"insPrevId");l(this,"insNextId");l(this,"depth",0);l(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};l(On,"runtime",f),l(On,"typeName","yorkie.v1.TreeNode"),l(On,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:Wr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:b},{no:5,name:"ins_prev_id",kind:"message",T:Wr},{no:6,name:"ins_next_id",kind:"message",T:Wr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let vo=On;const Rn=class Rn extends O{constructor(t){super();l(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};l(Rn,"runtime",f),l(Rn,"typeName","yorkie.v1.TreeNodes"),l(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:vo,repeated:!0}]));let ml=Rn;const Ln=class Ln extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};l(Ln,"runtime",f),l(Ln,"typeName","yorkie.v1.TreeNodeID"),l(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5}]));let Wr=Ln;const Bn=class Bn extends O{constructor(t){super();l(this,"parentId");l(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};l(Bn,"runtime",f),l(Bn,"typeName","yorkie.v1.TreePos"),l(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:Wr},{no:2,name:"left_sibling_id",kind:"message",T:Wr}]));let Ii=Bn;const bn=class bn extends O{constructor(t){super();l(this,"id","");l(this,"username","");l(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};l(bn,"runtime",f),l(bn,"typeName","yorkie.v1.User"),l(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Re}]));let Yh=bn;const Fn=class Fn extends O{constructor(t){super();l(this,"id","");l(this,"name","");l(this,"publicKey","");l(this,"secretKey","");l(this,"authWebhookUrl","");l(this,"authWebhookMethods",[]);l(this,"clientDeactivateThreshold","");l(this,"createdAt");l(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Fn().fromBinary(t,r)}static fromJson(t,r){return new Fn().fromJson(t,r)}static fromJsonString(t,r){return new Fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Fn,t,r)}};l(Fn,"runtime",f),l(Fn,"typeName","yorkie.v1.Project"),l(Fn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Re},{no:9,name:"updated_at",kind:"message",T:Re}]));let Qh=Fn;const Mn=class Mn extends O{constructor(t){super();l(this,"name");l(this,"authWebhookUrl");l(this,"authWebhookMethods");l(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};l(Mn,"runtime",f),l(Mn,"typeName","yorkie.v1.UpdatableProjectFields"),l(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Xe},{no:2,name:"auth_webhook_url",kind:"message",T:Xe},{no:3,name:"auth_webhook_methods",kind:"message",T:Nc},{no:4,name:"client_deactivate_threshold",kind:"message",T:Xe}]));let Xh=Mn;const Jn=class Jn extends O{constructor(t){super();l(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};l(Jn,"runtime",f),l(Jn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),l(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Nc=Jn;const $n=class $n extends O{constructor(t){super();l(this,"id","");l(this,"key","");l(this,"snapshot","");l(this,"createdAt");l(this,"accessedAt");l(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};l($n,"runtime",f),l($n,"typeName","yorkie.v1.DocumentSummary"),l($n,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Re},{no:5,name:"accessed_at",kind:"message",T:Re},{no:6,name:"updated_at",kind:"message",T:Re}]));let Zh=$n;const zn=class zn extends O{constructor(t){super();l(this,"type",0);l(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};l(zn,"runtime",f),l(zn,"typeName","yorkie.v1.PresenceChange"),l(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(Ei)},{no:2,name:"presence",kind:"message",T:Qf}]));let wo=zn;var Ei=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Ei||{});f.util.setEnumType(Ei,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var mt;let Qf=(mt=class extends O{constructor(t){super();l(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new mt().fromBinary(t,r)}static fromJson(t,r){return new mt().fromJson(t,r)}static fromJsonString(t,r){return new mt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mt,t,r)}},l(mt,"runtime",f),l(mt,"typeName","yorkie.v1.Presence"),l(mt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),mt);var pt;let ey=(pt=class extends O{constructor(t){super();l(this,"serverSeq",ne.zero);l(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new pt().fromBinary(t,r)}static fromJson(t,r){return new pt().fromJson(t,r)}static fromJsonString(t,r){return new pt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pt,t,r)}},l(pt,"runtime",f),l(pt,"typeName","yorkie.v1.Checkpoint"),l(pt,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),pt);const Un=class Un extends O{constructor(t){super();l(this,"createdAt");l(this,"offset",0);l(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};l(Un,"runtime",f),l(Un,"typeName","yorkie.v1.TextNodePos"),l(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:b},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Tr=Un;var yt;let b=(yt=class extends O{constructor(t){super();l(this,"lamport",ne.zero);l(this,"delimiter",0);l(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new yt().fromBinary(t,r)}static fromJson(t,r){return new yt().fromJson(t,r)}static fromJsonString(t,r){return new yt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yt,t,r)}},l(yt,"runtime",f),l(yt,"typeName","yorkie.v1.TimeTicket"),l(yt,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),yt);const jn=class jn extends O{constructor(t){super();l(this,"topic","");l(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};l(jn,"runtime",f),l(jn,"typeName","yorkie.v1.DocEventBody"),l(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Pc=jn;const Vn=class Vn extends O{constructor(t){super();l(this,"type",0);l(this,"publisher","");l(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};l(Vn,"runtime",f),l(Vn,"typeName","yorkie.v1.DocEvent"),l(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(vi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Pc}]));let Dc=Vn;const qn=class qn extends O{constructor(t){super();l(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};l(qn,"runtime",f),l(qn,"typeName","yorkie.v1.ActivateClientRequest"),l(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Oc=qn;const Kn=class Kn extends O{constructor(t){super();l(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};l(Kn,"runtime",f),l(Kn,"typeName","yorkie.v1.ActivateClientResponse"),l(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Rc=Kn;const Wn=class Wn extends O{constructor(t){super();l(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Wn().fromBinary(t,r)}static fromJson(t,r){return new Wn().fromJson(t,r)}static fromJsonString(t,r){return new Wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Wn,t,r)}};l(Wn,"runtime",f),l(Wn,"typeName","yorkie.v1.DeactivateClientRequest"),l(Wn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Lc=Wn;const _n=class _n extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new _n().fromBinary(e,t)}static fromJson(e,t){return new _n().fromJson(e,t)}static fromJsonString(e,t){return new _n().fromJsonString(e,t)}static equals(e,t){return f.util.equals(_n,e,t)}};l(_n,"runtime",f),l(_n,"typeName","yorkie.v1.DeactivateClientResponse"),l(_n,"fields",f.util.newFieldList(()=>[]));let Bc=_n;const Hn=class Hn extends O{constructor(t){super();l(this,"clientId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};l(Hn,"runtime",f),l(Hn,"typeName","yorkie.v1.AttachDocumentRequest"),l(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Er}]));let bc=Hn;const Gn=class Gn extends O{constructor(t){super();l(this,"documentId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Gn().fromBinary(t,r)}static fromJson(t,r){return new Gn().fromJson(t,r)}static fromJsonString(t,r){return new Gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Gn,t,r)}};l(Gn,"runtime",f),l(Gn,"typeName","yorkie.v1.AttachDocumentResponse"),l(Gn,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Er}]));let Fc=Gn;const Yn=class Yn extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");l(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Yn().fromBinary(t,r)}static fromJson(t,r){return new Yn().fromJson(t,r)}static fromJsonString(t,r){return new Yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yn,t,r)}};l(Yn,"runtime",f),l(Yn,"typeName","yorkie.v1.DetachDocumentRequest"),l(Yn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let Mc=Yn;const Qn=class Qn extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qn().fromBinary(t,r)}static fromJson(t,r){return new Qn().fromJson(t,r)}static fromJsonString(t,r){return new Qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qn,t,r)}};l(Qn,"runtime",f),l(Qn,"typeName","yorkie.v1.DetachDocumentResponse"),l(Qn,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Er}]));let Jc=Qn;const Xn=class Xn extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xn().fromBinary(t,r)}static fromJson(t,r){return new Xn().fromJson(t,r)}static fromJsonString(t,r){return new Xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xn,t,r)}};l(Xn,"runtime",f),l(Xn,"typeName","yorkie.v1.WatchDocumentRequest"),l(Xn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let $c=Xn;const Zn=class Zn extends O{constructor(t){super();l(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new Zn().fromBinary(t,r)}static fromJson(t,r){return new Zn().fromJson(t,r)}static fromJsonString(t,r){return new Zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zn,t,r)}};l(Zn,"runtime",f),l(Zn,"typeName","yorkie.v1.WatchDocumentResponse"),l(Zn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Uc,oneof:"body"},{no:2,name:"event",kind:"message",T:Dc,oneof:"body"}]));let zc=Zn;const er=class er extends O{constructor(t){super();l(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new er().fromBinary(t,r)}static fromJson(t,r){return new er().fromJson(t,r)}static fromJsonString(t,r){return new er().fromJsonString(t,r)}static equals(t,r){return f.util.equals(er,t,r)}};l(er,"runtime",f),l(er,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),l(er,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Uc=er;const tr=class tr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new tr().fromBinary(t,r)}static fromJson(t,r){return new tr().fromJson(t,r)}static fromJsonString(t,r){return new tr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tr,t,r)}};l(tr,"runtime",f),l(tr,"typeName","yorkie.v1.RemoveDocumentRequest"),l(tr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er}]));let jc=tr;const nr=class nr extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new nr().fromBinary(t,r)}static fromJson(t,r){return new nr().fromJson(t,r)}static fromJsonString(t,r){return new nr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nr,t,r)}};l(nr,"runtime",f),l(nr,"typeName","yorkie.v1.RemoveDocumentResponse"),l(nr,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Er}]));let Vc=nr;const rr=class rr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"changePack");l(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new rr().fromBinary(t,r)}static fromJson(t,r){return new rr().fromJson(t,r)}static fromJsonString(t,r){return new rr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rr,t,r)}};l(rr,"runtime",f),l(rr,"typeName","yorkie.v1.PushPullChangesRequest"),l(rr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Er},{no:4,name:"push_only",kind:"scalar",T:8}]));let qc=rr;const ir=class ir extends O{constructor(t){super();l(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new ir().fromBinary(t,r)}static fromJson(t,r){return new ir().fromJson(t,r)}static fromJsonString(t,r){return new ir().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ir,t,r)}};l(ir,"runtime",f),l(ir,"typeName","yorkie.v1.PushPullChangesResponse"),l(ir,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Er}]));let Kc=ir;const sr=class sr extends O{constructor(t){super();l(this,"clientId","");l(this,"documentId","");l(this,"topic","");l(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new sr().fromBinary(t,r)}static fromJson(t,r){return new sr().fromJson(t,r)}static fromJsonString(t,r){return new sr().fromJsonString(t,r)}static equals(t,r){return f.util.equals(sr,t,r)}};l(sr,"runtime",f),l(sr,"typeName","yorkie.v1.BroadcastRequest"),l(sr,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Wc=sr;const or=class or extends O{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new or().fromBinary(e,t)}static fromJson(e,t){return new or().fromJson(e,t)}static fromJsonString(e,t){return new or().fromJsonString(e,t)}static equals(e,t){return f.util.equals(or,e,t)}};l(or,"runtime",f),l(or,"typeName","yorkie.v1.BroadcastResponse"),l(or,"fields",f.util.newFieldList(()=>[]));let _c=or;const O1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Oc,O:Rc,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:Lc,O:Bc,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:bc,O:Fc,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:Mc,O:Jc,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:jc,O:Vc,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:qc,O:Kc,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:$c,O:zc,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:Wc,O:_c,kind:Fe.Unary}}},R1=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:dr}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:L1,repeated:!0}]);const L1=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:B1,repeated:!0}]);const B1=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:b1,repeated:!0}]);const b1=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var S=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(S||{});class k extends Error{constructor(t,r){super(r);l(this,"name","YorkieError");l(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Pt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const ty=n=>n?Object.entries(n).length===0:!0,gs=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},ts=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Xr=(n=>(n.Put="put",n.Clear="clear",n))(Xr||{});class Iu{constructor(e,t){l(this,"context");l(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:Pt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const $l="000000000000000000000000";class Tt{constructor(e,t,r){l(this,"lamport");l(this,"delimiter");l(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new Tt(e,t,r)}static fromStruct(e){return Tt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new Tt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const ny=0,Gs=9223372036854775807n,Ft=new Tt(0n,ny,$l);function tn(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}class Oo{constructor(e){l(this,"createdAt");l(this,"movedAt");l(this,"removedAt");this.createdAt=e}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!this.movedAt||e&&e.after(this.movedAt)?(this.movedAt=e,!0):!1}setRemovedAt(e){this.removedAt=e}remove(e){return e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt))?(this.removedAt=e,!0):!1}isRemoved(){return!!this.removedAt}}class _r extends Oo{constructor(e){super(e)}}class Xf{constructor(e,t){l(this,"strKey");l(this,"value");this.strKey=e,this.value=t}static of(e,t){return new Xf(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}}class So{constructor(){l(this,"nodeMapByKey");l(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new So}set(e,t,r){let i;const s=this.nodeMapByKey.get(e);s!=null&&!s.isRemoved()&&s.remove(r)&&(i=s.getValue());const o=Xf.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),o),(s==null||r.after(s.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,o),t.setMovedAt(r)),i}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new k(S.ErrInvalidArgument,`fail to find ${e.toIDString()}`);const r=this.nodeMapByCreatedAt.get(e.toIDString());return r.remove(t),r.getValue()}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find ${e.getCreatedAt().toIDString()}`);const r=this.nodeMapByKey.get(t.getStrKey());t===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){const r=this.nodeMapByKey.get(e);if(r!=null&&r.remove(t))return r.getValue()}has(e){const t=this.nodeMapByKey.get(e);return t==null?!1:!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){const t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(const[,e]of this.nodeMapByKey)yield e}}class He extends _r{constructor(t,r){super(t);l(this,"memberNodes");this.memberNodes=r}static create(t,r){if(!r)return new He(t,So.create());const i=So.create();for(const[s,o]of Object.entries(r))i.set(s,o.deepcopy(),o.getCreatedAt());return new He(t,i)}subPathOf(t){return this.memberNodes.subPathOf(t)}purge(t){this.memberNodes.purge(t)}set(t,r,i){return this.memberNodes.set(t,r,i)}delete(t,r){return this.memberNodes.delete(t,r)}deleteByKey(t,r){return this.memberNodes.deleteByKey(t,r)}get(t){const r=this.memberNodes.get(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.memberNodes.getByID(t);return r==null?void 0:r.getValue()}has(t){return this.memberNodes.has(t)}toJSON(){const t=[];for(const[r,i]of this)t.push(`"${tn(r)}":${i.toJSON()}`);return`{${t.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(const[r,i]of this){const{createdAt:s,value:o,type:a}=i.toJSForTest();t[r]={key:r,createdAt:s,value:o,type:a}}return{createdAt:this.getCreatedAt().toTestString(),value:t,type:"YORKIE_OBJECT"}}getKeys(){const t=Array();for(const[r]of this)t.push(r);return t}toSortedJSON(){var i;const t=Array();for(const[s]of this)t.push(s);const r=[];for(const s of t.sort()){const o=(i=this.memberNodes.get(s))==null?void 0:i.getValue();r.push(`"${tn(s)}":${o.toSortedJSON()}`)}return`{${r.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const t=He.create(this.getCreatedAt());for(const r of this.memberNodes)t.memberNodes.set(r.getStrKey(),r.getValue().deepcopy(),this.getPositionedAt());return t.remove(this.getRemovedAt()),t}getDescendants(t){for(const r of this.memberNodes){const i=r.getValue();if(t(i,this))return;i instanceof _r&&i.getDescendants(t)}}*[Symbol.iterator](){const t=new Set;for(const r of this.memberNodes)t.has(r.getStrKey())||(t.add(r.getStrKey()),r.isRemoved()||(yield[r.getStrKey(),r.getValue()]))}}var Y=(n=>(n.Local="local",n.Remote="remote",n.UndoRedo="undoredo",n))(Y||{});class $t{constructor(e,t){l(this,"parentCreatedAt");l(this,"executedAt");this.parentCreatedAt=e,this.executedAt=t}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new k(S.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}}class ry{constructor(e){l(this,"value");l(this,"left");l(this,"right");l(this,"parent");l(this,"weight");this.value=e,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}}class ko{constructor(e){l(this,"root");this.root=e}get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new k(S.ErrInvalidArgument,`out of index range: pos: ${e} > node.length: ${t.getLength()}`);return this.splayNode(t),[t,e]}indexOf(e){return!e||e!==this.root&&!e.hasLinks()?-1:(this.splayNode(e),this.root.getLeftWeight())}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t),t):(this.root=t,t)}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);const t=new ko(e.getLeft());t.root&&t.root.setParent();const r=new ko(e.getRight());if(r.root&&r.root.setParent(),t.root){const i=t.getRightmost();t.splayNode(i),t.root.setRight(r.root),r.root&&r.root.setParent(t.root),this.root=t.root}else this.root=r.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){const t=[];this.traversePostorder(e.getRight(),t);for(const r of t)r.initWeight();this.updateTreeWeight(e)}toTestString(){const e=[];return this.traverseInorder(this.root,e),e.map(t=>`[${t.getWeight()},${t.getLength()}]${t.getValue()||""}`).join("")}checkWeight(){const e=[];this.traverseInorder(this.root,e);for(const t of e)if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return e&&e.hasParent()?e.getParent().getLeft()===e:!1}isRightChild(e){return e&&e.hasParent()?e.getParent().getRight()===e:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -58,5 +58,5 @@ Error generating stack: `+s.message+` * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var wt=null;try{wt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function K(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});function Be(n){return(n&&n.__isLong__)===!0}function eg(n){var e=Math.clz32(n&-n);return n?31-e:e}K.isLong=Be;var tg={},ng={};function Pi(n,e){var t,r,i;return e?(n>>>=0,(i=0<=n&&n<256)&&(r=ng[n],r)?r:(t=_(n,0,!0),i&&(ng[n]=t),t)):(n|=0,(i=-128<=n&&n<128)&&(r=tg[n],r)?r:(t=_(n,n<0?-1:0,!1),i&&(tg[n]=t),t))}K.fromInt=Pi;function St(n,e){if(isNaN(n))return e?gr:Rt;if(e){if(n<0)return gr;if(n>=iy)return ay}else{if(n<=-ig)return qe;if(n+1>=ig)return oy}return n<0?St(-n,e).neg():_(n%ms|0,n/ms|0,e)}K.fromNumber=St;function _(n,e,t){return new K(n,e,t)}K.fromBits=_;var pl=Math.pow;function Zf(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?gr:Rt;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return Zf(n.substring(1),e,t).neg();for(var i=St(pl(t,8)),s=Rt,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*ms+(this.low>>>0):this.high*ms+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,d=c.toString(e);if(o=u,o.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(qe)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return Be(e)||(e=zt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(Be(e)||(e=zt(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(qe)?qe:this.not().add(_i)};C.neg=C.negate;C.add=function(e){Be(e)||(e=zt(e));var t=this.high>>>16,r=this.high&65535,i=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,u=e.low>>>16,c=e.low&65535,d=0,h=0,m=0,y=0;return y+=s+c,m+=y>>>16,y&=65535,m+=i+u,h+=m>>>16,m&=65535,h+=r+a,d+=h>>>16,h&=65535,d+=t+o,d&=65535,_(m<<16|y,d<<16|h,this.unsigned)};C.subtract=function(e){return Be(e)||(e=zt(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(Be(e)||(e=zt(e)),wt){var t=wt.mul(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?gr:Rt;if(this.eq(qe))return e.isOdd()?qe:Rt;if(e.eq(qe))return this.isOdd()?qe:Rt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(sg)&&e.lt(sg))return St(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,u=e.high&65535,c=e.low>>>16,d=e.low&65535,h=0,m=0,y=0,w=0;return w+=o*d,y+=w>>>16,w&=65535,y+=s*d,m+=y>>>16,y&=65535,y+=o*c,m+=y>>>16,y&=65535,m+=i*d,h+=m>>>16,m&=65535,m+=s*c,h+=m>>>16,m&=65535,m+=o*u,h+=m>>>16,m&=65535,h+=r*d+i*c+s*u+o*a,h&=65535,_(y<<16|w,h<<16|m,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(Be(e)||(e=zt(e)),e.isZero())throw Error("division by zero");if(wt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?wt.div_u:wt.div_s)(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?gr:Rt;var r,i,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return gr;if(e.gt(this.shru(1)))return sy;s=gr}else{if(this.eq(qe)){if(e.eq(_i)||e.eq(_c))return qe;if(e.eq(qe))return _i;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Rt)?e.isNegative()?_i:_c:(i=this.sub(e.mul(r)),s=r.add(i.div(e)),s)}else if(e.eq(qe))return this.unsigned?gr:Rt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Rt}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),u=a<=48?1:pl(2,a-48),c=St(r),d=c.mul(e);d.isNegative()||d.gt(i);)r-=u,c=St(r,this.unsigned),d=c.mul(e);c.isZero()&&(c=_i),s=s.add(c),i=i.sub(d)}return s};C.div=C.divide;C.modulo=function(e){if(Be(e)||(e=zt(e)),wt){var t=(this.unsigned?wt.rem_u:wt.rem_s)(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return _(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?eg(this.low):eg(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return Be(e)||(e=zt(e)),_(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return Be(e)||(e=zt(e)),_(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return Be(e)||(e=zt(e)),_(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?_(this.low<>>32-e,this.unsigned):_(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):_(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?_(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?_(this.high,0,this.unsigned):_(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?_(this.high,this.low,this.unsigned):e<32?(t=32-e,_(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,_(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?_(this.high,this.low,this.unsigned):e<32?(t=32-e,_(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,_(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?_(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:_(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};K.fromBytes=function(e,t,r){return r?K.fromBytesLE(e,t):K.fromBytesBE(e,t)};K.fromBytesLE=function(e,t){return new K(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};K.fromBytesBE=function(e,t){return new K(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var ve=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(ve||{});class ie extends Oo{constructor(t,r){super(r);l(this,"valueType");l(this,"value");this.valueType=ie.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new ie(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(s,o){i.setUint8(o,s)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return K.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(K.fromBytesLE(Array.from(r),!0).toNumber());default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${tn(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=ie.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof K)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return ie.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=K.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class yl extends ry{constructor(t){super(t);l(this,"prev");l(this,"next");this.value=t}static createAfter(t,r){const i=new yl(r),s=t.next;return t.next=i,i.prev=t,i.next=s,s&&(s.prev=i),i}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class To{constructor(){l(this,"dummyHead");l(this,"last");l(this,"nodeMapByIndex");l(this,"nodeMapByCreatedAt");const e=ie.of(0,Ft);e.setRemovedAt(Ft),this.dummyHead=new yl(e),this.last=this.dummyHead,this.nodeMapByIndex=new ko,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new To}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const i=this.findNextBeforeExecutedAt(e,r),s=yl.createAfter(i,t);i===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(i,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,r){const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new k(S.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);i!==s&&(!s.getValue().getMovedAt()||r.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(i.getCreatedAt(),s.getValue(),r),s.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let i=t;if(e===0&&t===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),i=r.isRemoved();return r.remove(t)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class tt extends _r{constructor(t,r){super(t);l(this,"elements");this.elements=r}static create(t,r){if(!r)return new tt(t,To.create());const i=To.create();for(const s of r)i.insertAfter(i.getLastCreatedAt(),s.deepcopy());return new tt(t,i)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,i){this.elements.moveAfter(t,r,i)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const i=r.getValue();if(t(i,this))return;i instanceof _r&&i.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...w,value:w.value?{attributes:ts(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[d,y,h,[c,c]]}setStyle(t,r,i,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],i),[,u]=this.rgaTreeSplit.findNodeWithSplit(t[0],i),c=[],d=this.rgaTreeSplit.findBetween(u,a),h=new Map,m=[];for(const w of d){const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=Gs:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):Ft,w.canStyle(i,P,p)){const g=h.get(T),v=w.getCreatedAt();(!g||v.after(g))&&h.set(T,v),m.push(w)}}const y=[];for(const w of m){if(w.isRemoved())continue;const[T,P]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());c.push({type:"style",actor:i.getActorID(),from:T,to:P,value:{attributes:ts(r)}});for(const[p,g]of Object.entries(r)){const[v]=w.getValue().setAttr(p,g,i);v!==void 0&&y.push({parent:w.getValue(),child:v})}}return[h,y,c]}indexRangeToPosRange(t,r){const i=this.rgaTreeSplit.indexToPos(t);return t===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();t.push({attributes:ts(i.getAttributes()),content:i.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new Et(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())t.push(i)}return t}}class Lo extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"content");l(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,r,i,s,o,a,u){return new Lo(t,r,i,s,o,a,u)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,u]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const c of u)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h})=>({type:"edit",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${r},${i},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Bo extends $t{constructor(t,r,i,s,o,a){super(t,a);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,r,i,s,o,a){return new Bo(t,r,i,s,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,u]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const c of a)t.registerGCPair(c);return{opInfos:u.map(({from:c,to:d,value:h})=>({type:"style",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${r},${i},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const J1=2,$1="root",pr="text";function Rs(n,e){let t=0;const r=n.children;for(let i=0;i0)throw new k(S.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===pr}get paddedSize(){return this.size+(this.isText?0:J1)}isAncestorOf(e){return U1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),i=this.value.slice(e);if(!i.length)return;this.value=r;const s=this.cloneText(e+t);return s.value=i,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new k(S.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,e),s=this.children.slice(e);this._children=i,r._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(i=>!i.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function U1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var me=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(me||{});function ly(n,e,t,r){if(e>t)throw new k(S.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new k(S.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new k(S.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let i=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||u)&&r([s,s.isText?"Text":"Start"],c),ly(s,Math.max(0,o),Math.min(a,s.size),r),c&&r([s,"End"],c)}i+=s.paddedSize}}function uy(n,e,t=0){for(const r of n.children)uy(r,e,t+1);e(n,t)}function $l(n,e,t=0){for(const r of n._children)$l(r,e,t+1);e(n,t)}function Hc(n,e,t=!0){if(e>n.size)throw new k(S.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,i=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-i)return Hc(s,e-i,t);if(e===i)return{node:n,offset:r};if(!t&&s.paddedSize===e-i)return{node:n,offset:r+1};if(s.paddedSize>e-i)return Hc(s,e-i-1,t);i+=s.paddedSize,r+=1}return{node:n,offset:r}}function cy(n){return n.isText||n.children.length===0?n:cy(n.children[0])}function j1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let i=t.parent,s=t;for(;i&&s===i.left;)s=i,i=i.parent;return i}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new K1(e,t,!0);const i=this.comparator(e,r.key);return i<0?r.left=this.putInternal(e,t,r.left):i>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class Lt{constructor(e,t){l(this,"parentID");l(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new Lt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,i;return r.isText?(r.parent.children[0]===r&&t===0?i=r.parent:i=r,r=r.parent):t===0?i=r:i=r.children[t-1],Lt.of(r.id,Ce.of(i.getCreatedAt(),i.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return Lt.of(Ce.of(Tt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ce.of(Tt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),i=e.findFloorNode(t);let s=e.findFloorNode(r);if(!i||!s)throw new k(S.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[i,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ce{constructor(e,t){l(this,"createdAt");l(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ce(e,t)}static fromStruct(e){return Ce.of(Tt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=i.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new k(S.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new k(S.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new Ze(Ce.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new Ze(Ce.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,i){const s=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new Ar);const i=[];for(const[s,o]of Object.entries(t))i.push(this.attrs.set(s,o,r));return i}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Gc(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Gc)};return n.attrs&&(e.attributes=ts((t=n.attrs)==null?void 0:t.toObject())),e}function ed(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${tn(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>ed(t)).join("")}`}function dy(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(dy),size:n.size,isRemoved:n.isRemoved}}class xt extends Oo{constructor(t,r){super(r);l(this,"indexTree");l(this,"nodeMapByID");this.indexTree=new V1(t),this.nodeMapByID=new fy(Ce.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(t,r){return new xt(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[i,s]=t.toTreeNodePair(this);let o=s;const a=i===o,u=o.parent&&!a?o.parent:i;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const c=u.allChildren,d=a?0:c.indexOf(o)+1;for(let h=d;h{const P=T.getCreatedAt().getActorID();let p,g=0n;if(o===void 0&&s===void 0?g=Gs:o.size()>0?g=o.get(P)?o.get(P):0n:p=s.has(P)?s.get(P):Ft,T.canStyle(i,p,g)&&r){const v=y.get(P),I=T.getCreatedAt();(!v||I.after(v))&&y.set(P,I);const E=T.setAttrs(r,i),N=E.reduce((q,[,$])=>($&&(q[$.getKey()]=m[$.getKey()]),q),{}),D=T.parent,R=T.prevSibling||T.parent;Object.keys(N).length>0&&h.push({type:"style",from:this.toIndex(D,R),to:this.toIndex(T,T),fromPath:this.toPath(D,R),toPath:this.toPath(T,T),actor:i.getActorID(),value:N});for(const[q]of E)q&&w.push({parent:T,child:q})}}),[y,w,h]}removeStyle(t,r,i,s,o){const[a,u]=this.findNodesAndSplitText(t[0],i),[c,d]=this.findNodesAndSplitText(t[1],i),h=[],m=new Map,y=[];return this.traverseInPosRange(a,u,c,d,([w])=>{const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=Gs:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):Ft,w.canStyle(i,P,p)&&r){const g=m.get(T),v=w.getCreatedAt();(!g||v.after(g))&&m.set(T,v),w.attrs||(w.attrs=new Ar);for(const N of r){const D=w.attrs.remove(N,i);for(const R of D)y.push({parent:w,child:R})}const I=w.parent,E=w.prevSibling||w.parent;h.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(I,E),to:this.toIndex(w,w),fromPath:this.toPath(I,E),toPath:this.toPath(w,w),value:r})}}),[m,y,h]}edit(t,r,i,s,o,a,u){const[c,d]=this.findNodesAndSplitText(t[0],s),[h,m]=this.findNodesAndSplitText(t[1],s),y=this.toIndex(c,d),w=this.toPath(c,d),T=[],P=[],p=[],g=new Map;this.traverseInPosRange(c,d,h,m,([E,N],D)=>{if(N===me.Start&&!D)for(const Se of E.children)p.push(Se);const R=E.getCreatedAt().getActorID();let q,$=0n;if(u===void 0&&a===void 0?$=Gs:u.size()>0?$=u.get(R)?u.get(R):0n:q=a.has(R)?a.get(R):Ft,E.canDelete(s,q,$)||T.includes(E.parent)){const Se=g.get(R),xr=E.getCreatedAt();(!Se||xr.after(Se))&&g.set(R,xr),(N===me.Text||N===me.Start)&&T.push(E),P.push([E,N])}});const v=this.makeDeletionChanges(P,s),I=[];for(const E of T)E.remove(s),E.isRemoved&&I.push({parent:this,child:E});for(const E of p)E.removedAt||c.append(E);if(i>0){let E=0,N=c,D=d;for(;E{c.isRemoved&&(R.remove(s),I.push({parent:this,child:R})),this.nodeMapByID.put(R.id,R)}),D.isRemoved||E.push(D);if(E.length){const D=E.map(R=>Gc(R));v.length&&v[v.length-1].from===y?v[v.length-1].value=D:v.push({type:"content",from:y,to:y,fromPath:w,toPath:w,actor:s.getActorID(),value:D})}}return[v,I,g]}editT(t,r,i,s,o){const a=this.findPos(t[0]),u=this.findPos(t[1]);this.edit([a,u],r,i,s,o)}move(t,r,i){throw new k(S.ErrUnimplemented,`not implemented: ${t}, ${r}, ${i}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,i=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=i}if(i){const o=this.findFloorNode(i);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const i of r.getGCPairs())t.push(i)}),t}findPos(t,r=!0){const i=this.indexTree.findTreePos(t,r);return Lt.fromTreePos(i)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ed(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(i,s=void 0,o=void 0,a=0)=>{var y,w,T,P;let u,c,d;const h=i.isText?{node:i,offset:0}:s&&o?this.toTreePos(s,o):null;h&&(u=this.indexTree.indexOf(h),c=this.indexTree.treePosToPath(h),d=Lt.fromTreePos(h).toStruct());const m={type:i.type,parent:s==null?void 0:s.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(y=i.removedAt)==null?void 0:y.toTestString(),insPrev:(w=i.insPrevID)==null?void 0:w.toTestString(),insNext:(T=i.insNextID)==null?void 0:T.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:a,attributes:i.attrs?ts((P=i.attrs)==null?void 0:P.toObject()):void 0,index:u,path:c,pos:d};for(let p=0;p0&&p===i[i.length-1].to?(i[i.length-1].to=g,i[i.length-1].toPath=this.toPath(P,y)):i.push({type:"content",from:p,to:g,fromPath:this.toPath(T,h),toPath:this.toPath(P,y),actor:r.getActorID()}))}return i.reverse()}findRightToken([t,r]){if(r===me.Start){const u=t.allChildren;return u.length>0?[u[0],u[0].isText?me.Text:me.Start]:[t,me.End]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===s.length-1)return[i,me.End];const a=s[o+1];return[a,a.isText?me.Text:me.Start]}findLeftToken([t,r]){if(r===me.End){const u=t.allChildren;if(u.length>0){const c=u[u.length-1];return[c,c.isText?me.Text:me.End]}return[t,me.Start]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===0)return[i,me.Start];const a=s[o-1];return[a,a.isText?me.Text:me.End]}}class bo extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"contents");l(this,"splitLevel");l(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,i,s,o,a,u){return new bo(t,r,i,s,o,a,u)}execute(t,r,i){var d;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof xt))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[u,c]=a.edit([this.fromPos,this.toPos],(d=this.contents)==null?void 0:d.map(h=>h.deepcopy()),this.splitLevel,o,(()=>{let h=o.getDelimiter();return this.contents!==void 0&&(h+=this.contents.length),()=>Tt.of(o.getLamport(),++h,o.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const h of c)t.registerGCPair(h);return{opInfos:u.map(({from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${r},${i},${s.map(o=>ed(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ns{constructor(e){l(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,i]of e){const s=this.vector.get(r),o=s&&s>i?s:i;t.set(r,o)}for(const[r,i]of this){const s=e.get(r),o=s&&s>i?s:i;t.set(r,o)}return new ns(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new ns(e)}filter(e){const t=new Map;for(const[r]of e){const i=this.vector.get(r);i!==void 0&&t.set(r,i)}return new ns(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const _1=new ns(new Map);class lr{constructor(e,t,r,i,s){l(this,"clientSeq");l(this,"serverSeq");l(this,"lamport");l(this,"actor");l(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=i,this.actor=r}static of(e,t,r,i,s){return new lr(e,t,r,i,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new lr(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,r=this.versionVector.max(e.versionVector),i=new lr(this.clientSeq,t,this.actor,r);return i.versionVector.set(this.actor,t),i}setClocks(e,t){const r=e>this.lamport?e:this.lamport+1n,i=this.versionVector.max(t);return i.set(this.actor,r),lr.of(this.clientSeq,r,this.actor,i)}createTimeTicket(e){return Tt.of(this.lamport,e,this.actor)}setActor(e){return new lr(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new lr(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const H1=new lr(0,0n,Qf,_1);class ps{constructor({id:e,operations:t,presenceChange:r,message:i}){l(this,"id");l(this,"operations");l(this,"presenceChange");l(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=i}static create({id:e,operations:t,presenceChange:r,message:i}){return new ps({id:e,operations:t,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const i=[],s=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:u,reverseOp:c}=a;i.push(...u),c&&s.unshift(c)}return this.presenceChange&&(this.presenceChange.type===Xr.Put?t.set(this.id.getActorID(),Pt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:i,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:de.bytesToHex(de.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>de.bytesToHex(de.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:i,message:s}=e;return ps.create({id:de.bytesToChangeID(de.hexToBytes(t)),operations:r==null?void 0:r.map(o=>de.bytesToOperation(de.hexToBytes(o))),presenceChange:i,message:s})}}class zl{constructor(e,t,r,i,s,o,a){l(this,"documentKey");l(this,"checkpoint");l(this,"isRemoved");l(this,"changes");l(this,"snapshot");l(this,"minSyncedTicket");l(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=i,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,r,i,s,o,a){return new zl(e,t,r,i,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class rs{constructor(e,t){l(this,"serverSeq");l(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new rs(e,t)}increaseClientSeq(e){return e===0?this:new rs(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return rs.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const G1=new rs(0n,0);class sn{constructor(e,t){l(this,"createdAt");l(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new sn(e,t)}static fromStruct(e){return sn.of(Tt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new sn(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Y1=sn.of(Ft,0);class Mt{constructor(e,t){l(this,"id");l(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Mt(e,t)}static fromStruct(e){const t=sn.fromStruct(e.id);return Mt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return sn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class Hr extends ry{constructor(t,r,i){super(r);l(this,"id");l(this,"removedAt");l(this,"prev");l(this,"next");l(this,"insPrev");l(this,"insNext");this.id=t,this.removedAt=i}static create(t,r){return new Hr(t,r)}static createComparator(){return(t,r)=>{const i=t.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let i=e;for(;i&&i!==t;)r.push(i),i=i.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new k(S.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const i=e.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,i){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,r,i),a=new Map,u=new Map,c=this.makeChanges(o,t);for(const d of s){const h=d.getCreatedAt().getActorID();(!a.has(h)||d.getID().getCreatedAt().after(a.get(h)))&&a.set(h,d.getID().getCreatedAt()),u.set(d.getID().toIDString(),d),d.remove(t)}return this.deleteIndexNodes(o),[c,a,u]}filterNodes(e,t,r,i){const s=[],o=[],[a,u]=this.findEdgesOfCandidates(e);o.push(a);for(const c of e){const d=c.getCreatedAt().getActorID();let h,m=0n;i===void 0&&r===void 0?m=Gs:i.size()>0?m=i.get(d)?i.get(d):0n:h=r.has(d)?r.get(d):Ft,c.canDelete(t,h,m)?s.push(c):o.push(c)}return o.push(u),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let i,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var on=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(on||{});class nt extends Oo{constructor(t,r,i){super(i);l(this,"valueType");l(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=K.fromNumber(r).toInt():this.value=og(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=K.fromNumber(r):this.value=r;break;default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,i){return new nt(t,r,i)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return K.fromBytesLE(Array.from(r));default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=nt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof K?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!nt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===ve.Long?this.value=this.value+t.getValue().toInt():this.value=K.fromNumber(this.value+og(t.getValue())).toInt(),this}}class vs extends $t{constructor(t,r,i){super(t,i);l(this,"value");this.value=r}static create(t,r,i){return new vs(t,r,i)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof nt))throw new k(S.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,s=this.value.deepcopy();return i.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),i=t.getType()===ve.Long?t.getValue().multiply(-1):t.getValue()*-1;return vs.create(this.getParentCreatedAt(),ie.of(i,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class yr extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"attributes");l(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,r,i,s,o,a){return new yr(t,r,i,s,o,[],a)}static createTreeRemoveStyleOperation(t,r,i,s,o,a){return new yr(t,r,i,s,new Map,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof xt))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,u;if(this.attributes.size){const c={};[...this.attributes].forEach(([d,h])=>c[d]=h),[,u,a]=o.style([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const c=this.attributesToRemove;[,u,a]=o.removeStyle([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const c of u)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h,fromPath:m,toPath:y})=>({type:"tree-style",from:c,to:d,value:this.attributes.size?{attributes:h}:{attributesToRemove:h},fromPath:m,toPath:y,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Q1(n){const e=new Yf,t=e.data;for(const[r,i]of Object.entries(n))t[r]=JSON.stringify(i);return e}function X1(n){if(n.type===Xr.Put)return new wo({type:Ei.PUT,presence:Q1(n.presence)});if(n.type===Xr.Clear)return new wo({type:Ei.CLEAR});throw new k(S.ErrUnimplemented,"unimplemented type")}function Z1(n){return new ey({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function hy(n){return new Ml({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:fd(n.getActorID()),versionVector:td(n.getVersionVector())})}function F(n){if(n)return new b({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:fd(n.getActorID())})}function td(n){if(!n)return;const e=new Jl;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function gy(n){switch(n){case ve.Null:return z.NULL;case ve.Boolean:return z.BOOLEAN;case ve.Integer:return z.INTEGER;case ve.Long:return z.LONG;case ve.Double:return z.DOUBLE;case ve.String:return z.STRING;case ve.Bytes:return z.BYTES;case ve.Date:return z.DATE;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function my(n){switch(n){case on.IntegerCnt:return z.INTEGER_CNT;case on.LongCnt:return z.LONG_CNT;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function Iu(n){if(n instanceof He)return new lt({type:z.JSON_OBJECT,createdAt:F(n.getCreatedAt()),value:Ny(n)});if(n instanceof tt)return new lt({type:z.JSON_ARRAY,createdAt:F(n.getCreatedAt()),value:DS(n)});if(n instanceof Et)return new lt({type:z.TEXT,createdAt:F(n.getCreatedAt())});if(n instanceof ie)return new lt({type:gy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof nt)return new lt({type:my(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof xt)return new lt({type:z.TREE,createdAt:F(n.getCreatedAt()),value:RS(n)});throw new k(S.ErrUnimplemented,"unimplemented element")}function eS(n){return new yo({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function na(n){return new Tr({createdAt:F(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function ra(n){return new Ii({parentId:Ys(n.getParentID()),leftSiblingId:Ys(n.getLeftSiblingID())})}function Ys(n){return new Wr({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function py(n){const e=new Gf;if(n instanceof xi){const t=n,r=new Xa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Ro){const t=n,r=new Za;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof Mr){const t=n,r=new el;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Zr){const t=n,r=new tl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Lo){const t=n,r=new nl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);r.content=t.getContent();const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof Bo){const t=n,r=new rl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof vs){const t=n,r=new il;r.parentCreatedAt=F(t.getParentCreatedAt()),r.value=Iu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof bo){const t=n,r=new sl,i=r.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())i[s]=F(o);r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ra(t.getFromPos()),r.to=ra(t.getToPos()),r.contents=aS(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=F(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof yr){const t=n,r=new ol;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ra(t.getFromPos()),r.to=ra(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=t.getAttributesToRemove();if(s.length>0)r.attributesToRemove=s;else{const o=r.attributes;for(const[a,u]of t.getAttributes())o[a]=u}r.executedAt=F(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new k(S.ErrUnimplemented,"unimplemented operation");return e}function tS(n){const e=[];for(const t of n)e.push(py(t));return e}function nS(n){const e=new Xp({id:hy(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=tS(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=X1(n.getPresenceChange())),e}function rS(n){const e=[];for(const t of n)e.push(nS(t));return e}function iS(n){const e=[];for(const t of n)e.push(new Zp({key:t.getStrKey(),element:rd(t.getValue())}));return e}function sS(n){const e=[];for(const t of n)e.push(new hl({element:rd(t.getValue())}));return e}function oS(n){const e=[];for(const t of n){const r=new gl;r.id=eS(t.getID()),r.value=t.getValue().getContent(),r.removedAt=F(t.getRemovedAt());const i=r.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new hs;a.value=o.getValue(),a.updatedAt=F(o.getUpdatedAt()),i[o.getKey()]=a}e.push(r)}return e}function aS(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new ml({content:nd(t)}));return e}function lS(n){const e={};for(const t of n)e[t.getKey()]=new hs({value:t.getValue(),updatedAt:F(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function nd(n){if(!n)return[];const e=[];return $l(n,(t,r)=>{const i=new vo({id:Ys(t.id),type:t.type,removedAt:F(t.removedAt),depth:r});t.isText&&(i.value=t.value),t.insPrevID&&(i.insPrevId=Ys(t.insPrevID)),t.insNextID&&(i.insNextId=Ys(t.insNextID)),t.attrs&&(i.attributes=lS(t.attrs)),e.push(i)}),e}function uS(n){const e=new Ge;return e.body.case="jsonObject",e.body.value=new al({nodes:iS(n.getRHT()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function yy(n){const e=new Ge;return e.body.case="jsonArray",e.body.value=new ll({nodes:sS(n.getElements()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function cS(n){const e=new Ge;return e.body.case="primitive",e.body.value=new ul({type:gy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function fS(n){const e=new Ge;return e.body.case="text",e.body.value=new cl({nodes:oS(n.getRGATreeSplit()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function dS(n){const e=new Ge;return e.body.case="counter",e.body.value=new fl({type:my(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function vy(n){const e=new Ge;return e.body.case="tree",e.body.value=new dl({nodes:nd(n.getRoot()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function rd(n){if(n instanceof He)return uS(n);if(n instanceof tt)return yy(n);if(n instanceof ie)return cS(n);if(n instanceof Et)return fS(n);if(n instanceof nt)return dS(n);if(n instanceof xt)return vy(n);throw new k(S.ErrUnimplemented,"unimplemented element")}function hS(n){return new Er({documentKey:n.getDocumentKey(),checkpoint:Z1(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:rS(n.getChanges()),snapshot:n.getSnapshot(),versionVector:td(n.getVersionVector()),minSyncedTicket:F(n.getMinSyncedTicket())})}function Ms(n){if(!(n instanceof te))return{};const e=n.findDetails(R1);for(const t of e)return t.metadata;return{}}function Ri(n){return Ms(n).code??""}function wy(n){return lr.of(n.clientSeq,BigInt(n.lamport),ud(n.actorId),id(n.versionVector),BigInt(n.serverSeq))}function id(n){if(!n)return;const e=new ns;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return Tt.of(BigInt(n.lamport),n.delimiter,ud(n.actorId))}function sd(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function gS(n){const e=n.type;if(e===Ei.PUT){const t=sd(n.presence);return{type:Xr.Put,presence:t}}if(e===Ei.CLEAR)return{type:Xr.Clear};throw new k(S.ErrInvalidType,`unsupported type: ${e}`)}function mS(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,sd(r))}),e}function Sy(n){switch(n){case z.NULL:return ve.Null;case z.BOOLEAN:return ve.Boolean;case z.INTEGER:return ve.Integer;case z.LONG:return ve.Long;case z.DOUBLE:return ve.Double;case z.STRING:return ve.String;case z.BYTES:return ve.Bytes;case z.DATE:return ve.Date}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function vl(n){switch(n){case z.INTEGER_CNT:return on.IntegerCnt;case z.LONG_CNT:return on.LongCnt}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function Eu(n){switch(n.type){case z.JSON_OBJECT:return n.value?Cy(n.value):He.create(M(n.createdAt));case z.JSON_ARRAY:return n.value?PS(n.value):tt.create(M(n.createdAt));case z.TEXT:return Et.create(ys.create(),M(n.createdAt));case z.TREE:return OS(n.value);case z.NULL:case z.BOOLEAN:case z.INTEGER:case z.LONG:case z.DOUBLE:case z.STRING:case z.BYTES:case z.DATE:return ie.of(ie.valueFromBytes(Sy(n.type),n.value),M(n.createdAt));case z.INTEGER_CNT:case z.LONG_CNT:return nt.create(vl(n.type),nt.valueFromBytes(vl(n.type),n.value),M(n.createdAt))}}function ia(n){return Mt.of(sn.of(M(n.createdAt),n.offset),n.relativeOffset)}function ky(n){return sn.of(M(n.createdAt),n.offset)}function pS(n){const e=Ao.create(n.value);Object.entries(n.attributes).forEach(([r,i])=>{e.setAttr(r,i.value,M(i.updatedAt))});const t=Hr.create(ky(n.id),e);return t.remove(M(n.removedAt)),t}function Li(n){return Lt.of(Qs(n.parentId),Qs(n.leftSiblingId))}function Qs(n){return Ce.of(M(n.createdAt),n.offset)}function yS(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=od(t.content);e.push(r)}),e}function od(n){if(n.length===0)return;const e=[];for(const i of n)e.push(wS(i));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let i=e.length-2;i>=0;i--)r.get(n[i].depth-1).prepend(e[i]),r.set(n[i].depth,e[i]);return t.updateDescendantsSize(),xt.create(t,Ft).getRoot()}function vS(n){const e=Ar.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function wS(n){const e=Qs(n.id),t=Ze.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=vS(n.attributes)),n.insPrevId&&(t.insPrevID=Qs(n.insPrevId)),n.insNextId&&(t.insNextID=Qs(n.insNextId)),t.removedAt=M(n.removedAt),t}function Ty(n){if(n.body.case==="set"){const e=n.body.value;return xi.create(e.key,Eu(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Ro.create(M(e.parentCreatedAt),M(e.prevCreatedAt),Eu(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Mr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Zr.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Lo.create(M(e.parentCreatedAt),ia(e.from),ia(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Bo.create(M(e.parentCreatedAt),ia(e.from),ia(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return vs.create(M(e.parentCreatedAt),Eu(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,i])=>{t.set(r,M(i))}),bo.create(M(e.parentCreatedAt),Li(e.from),Li(e.to),yS(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,i=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{i.set(s,M(o))}),(r==null?void 0:r.length)>0?yr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),Li(e.from),Li(e.to),i,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),yr.create(M(e.parentCreatedAt),Li(e.from),Li(e.to),i,t,M(e.executedAt)))}else throw new k(S.ErrUnimplemented,"unimplemented operation")}}function SS(n){const e=[];for(const t of n){const r=Ty(t);r&&e.push(r)}return e}function Ay(n){const e=[];for(const t of n)e.push(ps.create({id:wy(t.id),operations:SS(t.operations),presenceChange:t.presenceChange?gS(t.presenceChange):void 0,message:t.message}));return e}function kS(n){return rs.of(BigInt(n.serverSeq),n.clientSeq)}function TS(n){return zl.create(n.documentKey,kS(n.checkpoint),n.isRemoved,Ay(n.changes),id(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function Iy(n){const e=new So;for(const r of n.nodes){const i=ad(r.element);e.set(r.key,i,i.getPositionedAt())}const t=new He(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Ey(n){const e=new To;for(const r of n.nodes)e.insert(ad(r.element));const t=new tt(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function AS(n){const e=ie.of(ie.valueFromBytes(Sy(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function IS(n){const e=new ys;let t=e.getHead();for(const i of n.nodes){const s=e.insertAfter(t,pS(i));i.insPrevId&&s.setInsPrev(e.findNode(ky(i.insPrevId))),t=s}const r=new Et(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function ES(n){const e=nt.create(vl(n.type),nt.valueFromBytes(vl(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function xy(n){const e=od(n.nodes);return xt.create(e,M(n.createdAt))}function ad(n){if(n.body.case==="jsonObject")return Iy(n.body.value);if(n.body.case==="jsonArray")return Ey(n.body.value);if(n.body.case==="primitive")return AS(n.body.value);if(n.body.case==="text")return IS(n.body.value);if(n.body.case==="counter")return ES(n.body.value);if(n.body.case==="tree")return xy(n.body.value);throw new k(S.ErrUnimplemented,"unimplemented element")}function xS(n){if(!n)return{root:He.create(Ft),presences:new Map};const e=Ic.fromBinary(n);return{root:ad(e.root),presences:mS(e.presences)}}function CS(n){const e=td(n);return ld(e.toBinary())}function NS(n){const e=cd(n),t=Jl.fromBinary(e);return id(t)}function Cy(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return Iy(e.body.value)}function Ny(n){return rd(n).toBinary()}function PS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return Ey(e.body.value)}function DS(n){return yy(n).toBinary()}function OS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return xy(e.body.value)}function RS(n){return vy(n).toBinary()}function ld(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function ud(n){return ld(n)}function cd(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function fd(n){return cd(n)}function LS(n){const e=Ml.fromBinary(n);return wy(e)}function BS(n){const e=Gf.fromBinary(n);return Ty(e)}const de={fromPresence:sd,toChangePack:hS,fromChangePack:TS,fromChanges:Ay,toTreeNodes:nd,fromTreeNodes:od,objectToBytes:Ny,bytesToObject:Cy,bytesToSnapshot:xS,bytesToHex:ld,hexToBytes:cd,toHexString:ud,toUint8Array:fd,toOperation:py,toChangeID:hy,PbChangeID:Ml,bytesToChangeID:LS,bytesToOperation:BS,versionVectorToHex:CS,hexToVersionVector:NS};var Me=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Me||{});let li=3;function Py(n){li=n}const J={trivial:(...n)=>{li>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{li>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{li>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{li>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{li>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>li<=n};function Dy(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class bS{constructor(e,t,r,i,s){l(this,"reconnectStreamDelay");l(this,"doc");l(this,"docID");l(this,"syncMode");l(this,"remoteChangeEventReceived");l(this,"watchStream");l(this,"watchLoopTimerID");l(this,"watchAbortController");l(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ea.RealtimeSyncOff?!1:this.syncMode===Ea.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ea.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const xu=()=>{};class FS{constructor(e){l(this,"finalized",!1);l(this,"observers",[]);l(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(!e)throw new k(S.ErrInvalidArgument,"missing observer");if(this.finalized)throw new k(S.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?i=e:i={next:e,error:t,complete:r},i.next===void 0&&(i.next=xu),i.error===void 0&&(i.error=xu),i.complete===void 0&&(i.complete=xu);const s=Dy(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(a){J.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Hi{constructor(e,t,r,i){l(this,"id");l(this,"delimiter");l(this,"message");l(this,"root");l(this,"operations");l(this,"presenceChange");l(this,"previousPresence");l(this,"reversePresenceKeys");this.id=e,this.delimiter=ny,this.root=t,this.operations=[],this.previousPresence=Pt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(e,t,r,i){return new Hi(e,t,r,i)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ps.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class Io{constructor(e){l(this,"rootObject");l(this,"elementPairMapByCreatedAt");l(this,"gcElementSetByCreatedAt");l(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof Et||t instanceof xt)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new Io(He.create(Ft))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const i=t.element.getCreatedAt(),s=t.parent.subPathOf(i);if(s===void 0)throw new k(S.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof _r&&e.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(e){let t=0;const r=i=>{const s=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return r(e),e instanceof _r&&e.getDescendants(i=>(r(i),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof _r&&r.element.getDescendants(i=>(e.add(i.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new Io(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),s=i.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(i.parent.purge(i.element),t+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Oy(n,e){const t=new Eo(n);return new Proxy(e,t.getHandlers())}class Eo{constructor(e){l(this,"context");l(this,"handlers");this.context=e,this.handlers={set:(t,r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]=${JSON.stringify(i)}`),Eo.setInternal(e,t,r,i),!0),get:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():ui(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),Eo.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,i){if(r.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=wl(e,i,s),a=t.set(r,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(xi.create(r,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const r={};for(const[i,s]of Object.entries(t)){if(i.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=wl(e,s,o);r[i]=a}return r}static deleteInternal(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByKey(r,i);s&&(e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function JS(n,e){const t=new ae(n,e);return new Proxy(e,t.getHandlers())}function $S(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zS(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class ae{constructor(e,t){l(this,"context");l(this,"handlers");l(this,"array");this.context=e,this.array=t,this.handlers={get:(r,i,s)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return Pr(e,a)}:i==="getElementByIndex"?o=>{const a=r.get(o);return Pr(e,a)}:i==="getLast"?()=>Pr(e,r.getLast()):i==="deleteByID"?o=>{const a=ae.deleteInternalByID(e,r,o);return Pr(e,a)}:i==="insertAfter"?(o,a)=>{const u=ae.insertAfterInternal(e,r,o,a);return Pr(e,u)}:i==="insertBefore"?(o,a)=>{const u=ae.insertBeforeInternal(e,r,o,a);return Pr(e,u)}:i==="moveBefore"?(o,a)=>{ae.moveBeforeInternal(e,r,o,a)}:i==="moveAfter"?(o,a)=>{ae.moveAfterInternal(e,r,o,a)}:i==="moveFront"?o=>{ae.moveFrontInternal(e,r,o)}:i==="moveLast"?o=>{ae.moveLastInternal(e,r,o)}:$S(i)?ui(e,r.get(Number(i))):i==="push"?o=>ae.pushInternal(e,r,o):i==="splice"?(o,a,...u)=>ae.splice(e,r,o,a,...u):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?ae.iteratorInternal.bind(this,e,r):i==="includes"?(o,a)=>ae.includes(e,r,o,a):i==="indexOf"?(o,a)=>ae.indexOf(e,r,o,a):i==="lastIndexOf"?(o,a)=>ae.lastIndexOf(e,r,o,a):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>ae.toTestString(r):typeof i=="string"&&zS(i)?(...o)=>{const a=Array.from(r).map(u=>ui(e,u));return Array.prototype[i].apply(a,o)}:Reflect.get(r,i,s),deleteProperty:(r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`array[${i}]`),ae.deleteInternalByIndex(e,r,Number.parseInt(i)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield Pr(e,r)}static buildArrayElements(e,t){const r=[];for(const i of t){const s=e.issueTimeTicket(),o=wl(e,i,s);r.push(o)}return r}static pushInternal(e,t,r){return ae.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,i){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,i,s),e.push(Mr.create(t.getCreatedAt(),o,i,s))}static moveAfterInternal(e,t,r,i){const s=e.issueTimeTicket();t.moveAfter(r,i,s),e.push(Mr.create(t.getCreatedAt(),r,i,s))}static moveFrontInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),r,i),e.push(Mr.create(t.getCreatedAt(),s.getCreatedAt(),r,i))}static moveLastInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,r,i),e.push(Mr.create(t.getCreatedAt(),s,r,i))}static insertAfterInternal(e,t,r,i){const s=e.issueTimeTicket(),o=wl(e,i,s);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Ro.create(t.getCreatedAt(),r,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,r,i){return ae.insertAfterInternal(e,t,t.getPrevCreatedAt(r),i)}static deleteInternalByIndex(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByIndex(r,i);if(s)return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,r){const i=e.issueTimeTicket(),s=t.delete(r,i);return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static splice(e,t,r,i,...s){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),u=i===void 0?o:i<0?a:Math.min(a+i,o),c=[];for(let d=a;d=s)return!1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).includes(r,o);for(let u=o;u=s)return-1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).indexOf(r,o);for(let u=o;u=s?s-1:i<0?i+s:i;if(o<0)return-1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).lastIndexOf(r,o);for(let u=o;u>0;u--)if(((a=t.get(u))==null?void 0:a.getID())===r.getID())return u;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class Ul{constructor(e,t){l(this,"context");l(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,i){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${r}`);const o=i?gs(i):void 0,a=this.context.issueTimeTicket(),[u,,c,d]=this.text.edit(s,r,a,o);for(const h of c)this.context.registerGCPair(h);return this.context.push(new Lo(this.text.getCreatedAt(),s[0],s[1],u,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(d)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`STYL: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const s=gs(r),o=this.context.issueTimeTicket(),[a,u]=this.text.setStyle(i,s,o);for(const c of u)this.context.registerGCPair(c);return this.context.push(new Bo(this.text.getCreatedAt(),i[0],i[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Mt.fromStruct(e[0]),Mt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class jl{constructor(e,t){l(this,"valueType");l(this,"value");l(this,"context");l(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=ie.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(vs.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function dd(n,e,t){const{type:r}=n,i=t.issueTimeTicket();if(r===pr){Ry(n);const{value:s}=n,o=Ze.create(Ce.of(i,0),r,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!ty(o)){const c=gs(o);a=new Ar;for(const[d,h]of Object.entries(c))a.set(d,h,i)}const u=Ze.create(Ce.of(i,0),r,void 0,a);e.append(u);for(const c of s)dd(c,u,t)}}function US(n,e){const{type:t}=e,r=n.issueTimeTicket();let i;if(e.type===pr){const{value:s}=e;i=Ze.create(Ce.of(r,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!ty(o)){const u=gs(o);a=new Ar;for(const[c,d]of Object.entries(u))a.set(c,d,r)}i=Ze.create(Ce.of(n.issueTimeTicket(),0),t,void 0,a);for(const u of s)dd(u,i,n)}return i}function Ry(n){if(!n.value.length)throw new k(S.ErrInvalidArgument,"text node cannot have empty value");return!0}function ag(n){if(!n.length)return!0;if(n[0].type===pr)for(const t of n){const{type:r}=t;if(r!==pr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together");Ry(t)}else for(const t of n){const{type:r}=t;if(r===pr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class Vl{constructor(e){l(this,"initialRoot");l(this,"context");l(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return Ze.create(Ce.of(e.issueTimeTicket(),0),$1);const t=Ze.create(Ce.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)dd(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?gs(t):void 0,[a]=this.tree.style([r,i],o,s);this.context.push(yr.create(this.tree.getCreatedAt(),r,i,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?gs(r):void 0,[u,c]=this.tree.style([i,s],a,o);for(const d of c)this.context.registerGCPair(d);this.context.push(yr.create(this.tree.getCreatedAt(),i,s,u,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,u]=this.tree.removeStyle([i,s],r,o);for(const c of u)this.context.registerGCPair(c);this.context.push(yr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,s,a,r,o))}editInternal(e,t,r,i=0){var c;if(r.length!==0&&r[0]&&(ag(r),r[0].type!==pr))for(const d of r){const{children:h=[]}=d;ag(h)}const s=this.context.getLastTimeTicket();let o=new Array;if(((c=r[0])==null?void 0:c.type)===pr){let d="";for(const h of r){const{value:m}=h;d+=m}o.push(Ze.create(Ce.of(this.context.issueTimeTicket(),0),pr,d))}else o=r.map(d=>d&&US(this.context,d)).filter(d=>d);const[,a,u]=this.tree.edit([e,t],o.length?o.map(d=>d==null?void 0:d.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(const d of a)this.context.registerGCPair(d);return this.context.push(bo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,u,s)),!0}editByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulkByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r,i)}edit(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulk(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r,i)}toXML(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Lt.fromStruct(e[0]),Lt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Lt.fromStruct(e[0]),Lt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function lg(n,e){return Oy(n,e)}function Pr(n,e){if(e){if(e instanceof ie)return e;if(e instanceof He)return Oy(n,e);if(e instanceof tt)return JS(n,e);if(e instanceof Et)return new Ul(n,e);if(e instanceof nt){const t=new jl(on.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof xt){const t=new Vl;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function ui(n,e){const t=Pr(n,e);return t instanceof ie?t.getValue():t}function wl(n,e,t){let r;if(ie.isSupport(e))r=ie.of(e,t);else if(Array.isArray(e))r=tt.create(t,ae.buildArrayElements(n,e));else if(typeof e=="object")e instanceof Ul?(r=Et.create(ys.create(),t),e.initialize(n,r)):e instanceof jl?(r=nt.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof Vl?(r=xt.create(e.buildRoot(n),t),e.initialize(n,r)):r=He.create(t,Eo.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const ug=50;class jS{constructor(){l(this,"undoStack",[]);l(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=ug&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=ug&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const VS="yorkie-devtools-panel",qS="yorkie-devtools-sdk";let Bi="disconnected";const cg=new Map,Ia=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Ia);function sa(n,e){(e!=null&&e.force||Bi!=="disconnected")&&window.postMessage({source:qS,...n},"*")}function KS(n){if(!n.isEnableDevtools()||typeof window>"u"||cg.has(n.getKey()))return;Ia.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Ee.StatusChanged&&r.type!==Ee.Snapshot&&r.type!==Ee.LocalChange&&r.type!==Ee.RemoteChange&&r.type!==Ee.Initialized&&r.type!==Ee.Watched&&r.type!==Ee.Unwatched&&r.type!==Ee.PresenceChanged)||(Ia.get(n.getKey()).push(t),Bi==="synced"&&sa({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});cg.set(n.getKey(),[e]),sa({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var i;if(((i=t.data)==null?void 0:i.source)!==VS)return;switch(t.data.msg){case"devtools::connect":if(Bi!=="disconnected")break;Bi="connected",sa({msg:"doc::available",docKey:n.getKey()}),J.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Bi="disconnected",J.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Bi="synced",sa({msg:"doc::sync::full",docKey:n.getKey(),events:Ia.get(n.getKey())}),J.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Dr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Dr||{}),Ee=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Ee||{}),Yc=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Yc||{}),Qc=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Qc||{});class Ly{constructor(e,t){l(this,"key");l(this,"status");l(this,"opts");l(this,"changeID");l(this,"checkpoint");l(this,"localChanges");l(this,"root");l(this,"clone");l(this,"eventStream");l(this,"eventStreamObserver");l(this,"onlineClients");l(this,"presences");l(this,"history");l(this,"internalHistory");l(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=Io.create(),this.changeID=H1,this.checkpoint=G1,this.localChanges=[],this.eventStream=MS(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new jS,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},KS(this)}update(e,t){if(this.getStatus()==="removed")throw new k(S.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const s=lg(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(s,new Au(i,this.clone.presences.get(r)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(i.hasChange()){J.isEnabled(Me.Trivial)&&J.trivial(`trying to update a local change: ${this.toJSON()}`);const s=i.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,Y.Local),u=i.getReversePresence();u&&a.push({type:"presence",value:u}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const c=[];o.length>0&&c.push({type:"local-change",source:Y.Local,value:{message:s.getMessage()||"",operations:o,actor:r,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&c.push({type:"presence-changed",source:Y.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(c),J.isEnabled(Me.Trivial)&&J.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,i){if(typeof e=="string"){if(typeof t!="function")throw new k(S.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="initialized"&&c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||a(c)},r,i)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="initialized"&&c.type!=="presence-changed"||c.type==="presence-changed"&&c.value.clientID!==this.changeID.getActorID()||a(c)},r,i)}if(e==="others"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||c.value.clientID!==this.changeID.getActorID()&&a(c)},r,i)}if(e==="connection"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="connection-changed"&&a(c)},r,i)}if(e==="status"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="status-changed"&&a(c)},r,i)}if(e==="sync"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="sync-status-changed"&&a(c)},r,i)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="local-broadcast"&&a(c)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="broadcast"&&a(c)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="auth-error"&&a(c)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,i)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const u of a){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const c=[];for(const d of u.value.operations)this.isSameElementOrChildOf(d.path,s)&&c.push(d);c.length&&o({...u,value:{...u.value,operations:c}})}},r,i)}if(typeof e=="function"){const s=e,o=t,a=r;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="snapshot"&&c.type!=="local-change"&&c.type!=="remote-change"||s(c)},o,a)}throw new k(S.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((s,o)=>s===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),Y.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),J.isEnabled(Me.Trivial)&&J.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Pt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return zl.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return lg(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,i=-1){const{root:s,presences:o}=de.bytesToSnapshot(r);this.root=new Io(s),this.presences=o,this.changeID=this.changeID.setClocks(e,t),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,Y.Local),this.publish([{type:"snapshot",source:Y.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?de.bytesToHex(r):void 0,snapshotVector:de.versionVectorToHex(t)}}])}applyChanges(e,t){J.isEnabled(Me.Debug)&&J.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),J.isEnabled(Me.Trivial)&&J.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` -`));for(const r of e)this.applyChange(r,t);J.isEnabled(Me.Debug)&&J.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],i=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(i)){const o=e.getPresenceChange();switch(o.type){case Xr.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:t,value:{clientID:i,presence:o.presence}}:{type:"watched",source:Y.Remote,value:{clientID:i,presence:o.presence}});break;case Xr.Clear:r.push({type:"unwatched",source:Y.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===Y.Remote?{type:"remote-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const i of t)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:Y.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,i=[];if(t===vi.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:Y.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===vi.DOCUMENT_UNWATCHED){const s=this.getPresence(r);this.removeOnlineClient(r),s&&i.push({type:"unwatched",source:Y.Remote,value:{clientID:r,presence:s}})}else if(t===vi.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:s,payload:JSON.parse(a.decode(o))}})}i.length>0&&this.publish(i)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(Qf),this.publish([{source:e==="removed"?Y.Remote:Y.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:i}=e.value;if(!t)return;this.applySnapshot(BigInt(r),de.hexToVersionVector(i),de.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ps.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:i}of e.value)t.add(r),this.presences.set(r,i);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new k(S.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const i of t)if(r=r[i],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Pt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Pt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Pt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Pt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Pt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new k(S.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof $t)){new Au(t,Pt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}redo(){if(this.isUpdating)throw new k(S.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof $t)){new Au(t,Pt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const i={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function WS(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const _S="yorkie-js-sdk",HS="0.5.6",GS="Yorkie JS SDK",YS="./src/yorkie.ts",QS={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},XS=["dist"],ZS={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},ek={node:">=18.0.0",npm:">=7.1.0"},tk={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},nk={name:"hackerwins",email:"susukang98@gmail.com"},rk="Apache-2.0",ik={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},sk="https://github.com/yorkie-team/yorkie-js-sdk#readme",ok={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ak={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},fg={name:_S,version:HS,description:GS,main:YS,publishConfig:QS,files:XS,scripts:ZS,engines:ek,repository:tk,author:nk,license:rk,bugs:ik,homepage:sk,devDependencies:ok,dependencies:ak};function lk(){return n=>async e=>(e.header.set("x-yorkie-user-agent",fg.name+"/"+fg.version),await n(e))}const uk=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ea=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ea||{});const oa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Cu={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class By{constructor(e,t){l(this,"id");l(this,"key");l(this,"status");l(this,"attachmentMap");l(this,"apiKey");l(this,"authTokenInjector");l(this,"conditions");l(this,"syncLoopDuration");l(this,"reconnectStreamDelay");l(this,"retrySyncLoopDelay");l(this,"rpcClient");l(this,"setAuthToken");l(this,"taskQueue");l(this,"processing",!1);l(this,"keepalive",!1);t=t||oa,this.key=t.key?t.key:Dy(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??oa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??oa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??oa.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=WS(this.apiKey);this.setAuthToken=i,this.rpcClient=l1(O1,D1({baseUrl:e,interceptors:[r,lk()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),J.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw J.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),J.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw J.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Dr.Detached)throw new k(S.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async s=>{var d;const{topic:o,payload:a}=s.value,u=(d=s.options)==null?void 0:d.error,c=s.options;try{await this.broadcast(e.getKey(),o,a,c)}catch(h){h instanceof Error&&(u==null||u(h))}}),i=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:de.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=de.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Dr.Removed)return e;e.applyStatus(Dr.Attached),this.attachmentMap.set(e.getKey(),new bS(this.reconnectStreamDelay,e,s.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(e.getKey()),J.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const u=t.initialRoot;e.update(c=>{for(const[d,h]of Object.entries(u))if(!a.has(d)){const m=d;c[m]=h}})}return e}).catch(async s=>{throw J.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((i,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:de.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);return e.applyChangePack(s),e.getStatus()!==Dr.Removed&&e.applyStatus(Dr.Detached),this.detachInternal(e.getKey()),J.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async i=>{throw J.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(e,t){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const i=r.syncMode;return i===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=de.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),J.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async i=>{throw J.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,i){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);if(!uk(r))throw new k(S.ErrInvalidArgument,"payload is not serializable");const o=(i==null?void 0:i.maxRetries)??Cu.maxRetries,a=Cu.maxBackoff;let u=0;const c=h=>Math.min(Cu.initialRetryInterval*2**h,a),d=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{J.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async h=>{if(J.error(`[BC] c:"${this.getKey()}" err:`,h),await this.handleConnectError(h))if(h instanceof te&&Ri(h)===S.ErrUnauthenticated&&s.doc.publish([{type:Ee.AuthError,value:{reason:Ms(h).reason,method:"Broadcast"}}]),ud(),c(u-1)),J.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${o}`);else throw J.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),h;else throw h}));return d()}runSyncLoop(){const e=()=>{if(!this.isActive()){J.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof te&&Ri(i)===S.ErrUnauthenticated&&r.doc.publish([{type:Ee.AuthError,value:{reason:Ms(i).reason,method:"PushPull"}}]),i})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{J.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};J.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new k(S.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:i.signal});return t.doc.publish([{type:Ee.ConnectionChanged,value:Yc.Connected}]),J.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const c of s)this.handleWatchDocumentsResponse(t,c),c.body.case==="initialization"&&o([s,i])}catch(c){t.doc.resetOnlineClients(),t.doc.publish([{type:Ee.Initialized,source:Y.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Ee.ConnectionChanged,value:Yc.Disconnected}]),J.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(c)?(c instanceof te&&Ri(c)===S.ErrUnauthenticated&&t.doc.publish([{type:Ee.AuthError,value:{reason:Ms(c).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(c)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===vi.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Dr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:i}=e,s=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:de.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=de.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Ee.SyncStatusChanged,value:Qc.Synced}]),r.getStatus()===Dr.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),c=a.getChangeSize();return J.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${s.getChangeSize()} pull:${c} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Ee.SyncStatusChanged,value:Qc.SyncFailed}]),J.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof te))return!1;if(e.code===H.Canceled||e.code===H.Unknown||e.code===H.ResourceExhausted||e.code===H.Unavailable)return!0;if(Ri(e)===S.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Ms(e).reason);this.setAuthToken(t)}return!0}return(Ri(e)===S.ErrClientNotActivated||Ri(e)===S.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{J.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const by={Client:By,Document:Ly,Primitive:ie,Text:Ul,Counter:jl,Tree:Vl,LogLevel:Me,setLogLevel:Py,IntType:on.IntegerCnt,LongType:on.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:By,Document:Ly,Primitive:ie,Text:Ul,Counter:jl,Tree:Vl,LogLevel:Me,setLogLevel:Py,IntType:on.IntegerCnt,LongType:on.LongCnt});class ck{constructor(e,t){this.x=e,this.y=t,this.lifetime=0}}const fk=({xPos:n,yPos:e})=>{const[t,r]=je.useState([]),i=je.useRef(null),[s,o]=je.useState([]),a=(u,c)=>{const d=new ck(u,c);s.push(d),o(s),t.push(d),r(t)};return je.useEffect(()=>{const c=i.current.getContext("2d"),d=()=>{c.clearRect(0,0,c.canvas.width,c.canvas.height);const h=.7*(1*4e3)/60;for(let m=0;mh)s.shift();else{c.lineWidth=5,c.lineJoin="round";const T=0,P=0,p=0;c.strokeStyle=`rgb(${T},${P},${p})`,c.beginPath(),c.moveTo(w.x,w.y),c.lineTo(y.x,y.y),c.stroke(),c.closePath()}}requestAnimationFrame(d)};d()},[s]),je.useEffect(()=>{a(n,e)},[n,e]),ce.jsx("canvas",{className:"pen-cursor-canvas",ref:i,width:document.body.clientWidth,height:document.body.clientHeight})},dk="_goUp0_1lnal_1",hk="_goUpAnimation0_1lnal_1",gk="_fadeOut_1lnal_1",mk="_goUp1_1lnal_16",pk="_goUpAnimation1_1lnal_1",yk="_goUp2_1lnal_31",vk="_goUpAnimation2_1lnal_1",wk="_leftRight0_1lnal_46",Sk="_leftRightAnimation0_1lnal_1",kk="_leftRight1_1lnal_60",Tk="_leftRightAnimation1_1lnal_1",Ak="_leftRight2_1lnal_74",Ik="_leftRightAnimation2_1lnal_1",Nu={goUp0:dk,goUpAnimation0:hk,fadeOut:gk,goUp1:mk,goUpAnimation1:pk,goUp2:yk,goUpAnimation2:vk,leftRight0:wk,leftRightAnimation0:Sk,leftRight1:kk,leftRightAnimation1:Tk,leftRight2:Ak,leftRightAnimation2:Ik};function Ek({x:n,y:e,timestamp:t,selectedCursorShape:r}){return ce.jsx("div",{className:"single-animation-container",children:ce.jsx("div",{className:`absolute select-none pointer-events-none ${Nu.disappear} text-${t%5+2}xl ${Nu["goUp"+t%3]}`,style:{left:n,top:e},children:ce.jsx("div",{className:Nu["leftRight"+t%3],children:ce.jsx("div",{className:"transform -translate-x-1/2 -translate-y-1/2",children:ce.jsx("img",{src:`./icons/icon_${r}.svg`})})})})})}function dg(n,e){const t=je.useRef(n);je.useEffect(()=>{t.current=n},[n]),je.useEffect(()=>{function r(){t.current()}if(e!==null){let i=setInterval(r,e);return()=>clearInterval(i)}},[e])}const xk=({pointerDown:n,xPos:e,yPos:t,selectedCursorShape:r})=>{const[i,s]=je.useState([]),o=100;return dg(()=>{s(a=>a.filter(u=>u.timestamp>Date.now()-4e3))},1e3),dg(()=>{n&&s(a=>a.concat([{point:{x:e,y:t},timestamp:Date.now()}]))},o),ce.jsx("div",{style:{transform:`translateX(${e}px) translateY(${t}px)`},children:i.map(a=>ce.jsx(Ek,{x:a.point.x,y:a.point.y,timestamp:a.timestamp,selectedCursorShape:r},a.timestamp.toString()))})},Ck=({selectedCursorShape:n,x:e,y:t,pointerDown:r})=>ce.jsxs(ce.Fragment,{children:[ce.jsx("img",{src:`./icons/icon_${n}.svg`,className:`${n}-cursor`,style:{transform:`translate3d(${e}px, ${t}px, 0)`}}),(n==="heart"||n==="thumbs")&&ce.jsx(xk,{pointerDown:r,xPos:e,yPos:t,selectedCursorShape:n}),n==="pen"&&r&&ce.jsx(fk,{xPos:e,yPos:t})]}),Nk=({handleCursorShapeSelect:n,clientsLength:e})=>{const[t,r]=je.useState("cursor"),i=["heart","thumbs","pen","cursor"];return ce.jsxs("div",{className:"cursor-selector-container",children:[ce.jsx("div",{className:"cursor-selections-container",children:i.map(s=>ce.jsx("img",{onClick:()=>{n(s),r(s)},className:`${t===s?"cursor-shape-selected":"cursor-shape-not-selected"}`,src:`./icons/icon_${s}.svg`},s))}),ce.jsx("div",{className:"num-users-container",children:ce.jsx("p",{children:e!==1?`${e} users are here`:"1 user here"})})]})},Pu=new by.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"}),si=new by.Document("simultaneous-cursors",{enableDevtools:!0}),Pk=()=>{const[n,e]=je.useState([]),t=r=>{si.update((i,s)=>{s.set({cursorShape:r})})};return je.useEffect(()=>{(async()=>{await Pu.activate(),si.subscribe("presence",a=>{e(si.getPresences())}),await Pu.attach(si,{initialPresence:{cursorShape:"cursor",cursor:{xPos:0,yPos:0},pointerDown:!1}}),window.addEventListener("beforeunload",()=>{Pu.deactivate()})})();const i=()=>{si.update((a,u)=>{u.set({pointerDown:!1})})},s=()=>{si.update((a,u)=>{u.set({pointerDown:!0})})},o=a=>{si.update((u,c)=>{c.set({cursor:{xPos:a.clientX,yPos:a.clientY}})})};return window.addEventListener("mousedown",s),window.addEventListener("mouseup",i),window.addEventListener("mousemove",o),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("mouseup",i),window.removeEventListener("mousemove",o)}},[]),ce.jsxs("div",{className:"general-container",children:[n.map(({clientID:r,presence:{cursorShape:i,cursor:s,pointerDown:o}})=>s?ce.jsx(Ck,{selectedCursorShape:i,x:s.xPos,y:s.yPos,pointerDown:o},r):null),ce.jsx(Nk,{handleCursorShapeSelect:t,clientsLength:n.length})]})};Du.createRoot(document.getElementById("root")).render(ce.jsx(Pk,{})); + */var wt=null;try{wt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function K(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});function Be(n){return(n&&n.__isLong__)===!0}function eg(n){var e=Math.clz32(n&-n);return n?31-e:e}K.isLong=Be;var tg={},ng={};function Pi(n,e){var t,r,i;return e?(n>>>=0,(i=0<=n&&n<256)&&(r=ng[n],r)?r:(t=_(n,0,!0),i&&(ng[n]=t),t)):(n|=0,(i=-128<=n&&n<128)&&(r=tg[n],r)?r:(t=_(n,n<0?-1:0,!1),i&&(tg[n]=t),t))}K.fromInt=Pi;function St(n,e){if(isNaN(n))return e?gr:Rt;if(e){if(n<0)return gr;if(n>=iy)return ay}else{if(n<=-ig)return qe;if(n+1>=ig)return oy}return n<0?St(-n,e).neg():_(n%ms|0,n/ms|0,e)}K.fromNumber=St;function _(n,e,t){return new K(n,e,t)}K.fromBits=_;var pl=Math.pow;function Zf(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?gr:Rt;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return Zf(n.substring(1),e,t).neg();for(var i=St(pl(t,8)),s=Rt,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*ms+(this.low>>>0):this.high*ms+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,d=c.toString(e);if(o=u,o.isZero())return d+a;for(;d.length<6;)d="0"+d;a=""+d+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(qe)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return Be(e)||(e=zt(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(Be(e)||(e=zt(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(qe)?qe:this.not().add(_i)};C.neg=C.negate;C.add=function(e){Be(e)||(e=zt(e));var t=this.high>>>16,r=this.high&65535,i=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,u=e.low>>>16,c=e.low&65535,d=0,h=0,m=0,y=0;return y+=s+c,m+=y>>>16,y&=65535,m+=i+u,h+=m>>>16,m&=65535,h+=r+a,d+=h>>>16,h&=65535,d+=t+o,d&=65535,_(m<<16|y,d<<16|h,this.unsigned)};C.subtract=function(e){return Be(e)||(e=zt(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(Be(e)||(e=zt(e)),wt){var t=wt.mul(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?gr:Rt;if(this.eq(qe))return e.isOdd()?qe:Rt;if(e.eq(qe))return this.isOdd()?qe:Rt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(sg)&&e.lt(sg))return St(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,u=e.high&65535,c=e.low>>>16,d=e.low&65535,h=0,m=0,y=0,w=0;return w+=o*d,y+=w>>>16,w&=65535,y+=s*d,m+=y>>>16,y&=65535,y+=o*c,m+=y>>>16,y&=65535,m+=i*d,h+=m>>>16,m&=65535,m+=s*c,h+=m>>>16,m&=65535,m+=o*u,h+=m>>>16,m&=65535,h+=r*d+i*c+s*u+o*a,h&=65535,_(y<<16|w,h<<16|m,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(Be(e)||(e=zt(e)),e.isZero())throw Error("division by zero");if(wt){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?wt.div_u:wt.div_s)(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?gr:Rt;var r,i,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return gr;if(e.gt(this.shru(1)))return sy;s=gr}else{if(this.eq(qe)){if(e.eq(_i)||e.eq(Hc))return qe;if(e.eq(qe))return _i;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(Rt)?e.isNegative()?_i:Hc:(i=this.sub(e.mul(r)),s=r.add(i.div(e)),s)}else if(e.eq(qe))return this.unsigned?gr:Rt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Rt}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),u=a<=48?1:pl(2,a-48),c=St(r),d=c.mul(e);d.isNegative()||d.gt(i);)r-=u,c=St(r,this.unsigned),d=c.mul(e);c.isZero()&&(c=_i),s=s.add(c),i=i.sub(d)}return s};C.div=C.divide;C.modulo=function(e){if(Be(e)||(e=zt(e)),wt){var t=(this.unsigned?wt.rem_u:wt.rem_s)(this.low,this.high,e.low,e.high);return _(t,wt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return _(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?eg(this.low):eg(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return Be(e)||(e=zt(e)),_(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return Be(e)||(e=zt(e)),_(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return Be(e)||(e=zt(e)),_(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?_(this.low<>>32-e,this.unsigned):_(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):_(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?_(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?_(this.high,0,this.unsigned):_(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?_(this.high,this.low,this.unsigned):e<32?(t=32-e,_(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,_(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return Be(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?_(this.high,this.low,this.unsigned):e<32?(t=32-e,_(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,_(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?_(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:_(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};K.fromBytes=function(e,t,r){return r?K.fromBytesLE(e,t):K.fromBytesBE(e,t)};K.fromBytesLE=function(e,t){return new K(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};K.fromBytesBE=function(e,t){return new K(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var ve=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(ve||{});class ie extends Oo{constructor(t,r){super(r);l(this,"valueType");l(this,"value");this.valueType=ie.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new ie(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const i=new DataView(r.buffer);return r.forEach(function(s,o){i.setUint8(o,s)}),i.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return K.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(K.fromBytesLE(Array.from(r),!0).toNumber());default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${tn(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=ie.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof K)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return ie.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=K.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class yl extends ry{constructor(t){super(t);l(this,"prev");l(this,"next");this.value=t}static createAfter(t,r){const i=new yl(r),s=t.next;return t.next=i,i.prev=t,i.next=s,s&&(s.prev=i),i}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class To{constructor(){l(this,"dummyHead");l(this,"last");l(this,"nodeMapByIndex");l(this,"nodeMapByCreatedAt");const e=ie.of(0,Ft);e.setRemovedAt(Ft),this.dummyHead=new yl(e),this.last=this.dummyHead,this.nodeMapByIndex=new ko,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new To}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const i=this.findNextBeforeExecutedAt(e,r),s=yl.createAfter(i,t);i===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(i,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,r){const i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new k(S.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new k(S.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);i!==s&&(!s.getValue().getMovedAt()||r.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(i.getCreatedAt(),s.getValue(),r),s.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new k(S.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let i=t;if(e===0&&t===this.dummyHead||r>0)do i&&(i=i.getNext());while(i&&i.isRemoved());return i}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),i=r.isRemoved();return r.remove(t)&&!i&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class tt extends _r{constructor(t,r){super(t);l(this,"elements");this.elements=r}static create(t,r){if(!r)return new tt(t,To.create());const i=To.create();for(const s of r)i.insertAfter(i.getLastCreatedAt(),s.deepcopy());return new tt(t,i)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,i){this.elements.moveAfter(t,r,i)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const i=r.getValue();if(t(i,this))return;i instanceof _r&&i.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...w,value:w.value?{attributes:ts(w.value.getAttributes()),content:w.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[d,y,h,[c,c]]}setStyle(t,r,i,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],i),[,u]=this.rgaTreeSplit.findNodeWithSplit(t[0],i),c=[],d=this.rgaTreeSplit.findBetween(u,a),h=new Map,m=[];for(const w of d){const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=Gs:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):Ft,w.canStyle(i,P,p)){const g=h.get(T),v=w.getCreatedAt();(!g||v.after(g))&&h.set(T,v),m.push(w)}}const y=[];for(const w of m){if(w.isRemoved())continue;const[T,P]=this.rgaTreeSplit.findIndexesFromRange(w.createPosRange());c.push({type:"style",actor:i.getActorID(),from:T,to:P,value:{attributes:ts(r)}});for(const[p,g]of Object.entries(r)){const[v]=w.getValue().setAttr(p,g,i);v!==void 0&&y.push({parent:w.getValue(),child:v})}}return[h,y,c]}indexRangeToPosRange(t,r){const i=this.rgaTreeSplit.indexToPos(t);return t===r?[i,i]:[i,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const i=r.getValue();t.push({attributes:ts(i.getAttributes()),content:i.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new Et(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const i of r.getValue().getGCPairs())t.push(i)}return t}}class Lo extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"content");l(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,r,i,s,o,a,u){return new Lo(t,r,i,s,o,a,u)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,u]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,i);for(const c of u)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h})=>({type:"edit",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${r},${i},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Bo extends $t{constructor(t,r,i,s,o,a){super(t,a);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"attributes");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,r,i,s,o,a){return new Bo(t,r,i,s,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Et))throw new k(S.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,u]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,i);for(const c of a)t.registerGCPair(c);return{opInfos:u.map(({from:c,to:d,value:h})=>({type:"style",from:c,to:d,value:h,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),i=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${r},${i},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const J1=2,$1="root",pr="text";function Rs(n,e){let t=0;const r=n.children;for(let i=0;i0)throw new k(S.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===pr}get paddedSize(){return this.size+(this.isText?0:J1)}isAncestorOf(e){return U1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),i=this.value.slice(e);if(!i.length)return;this.value=r;const s=this.cloneText(e+t);return s.value=i,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new k(S.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const i=this.children.slice(0,e),s=this.children.slice(e);this._children=i,r._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new k(S.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(i=>!i.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new k(S.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function U1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var me=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(me||{});function ly(n,e,t,r){if(e>t)throw new k(S.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new k(S.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new k(S.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let i=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||u)&&r([s,s.isText?"Text":"Start"],c),ly(s,Math.max(0,o),Math.min(a,s.size),r),c&&r([s,"End"],c)}i+=s.paddedSize}}function uy(n,e,t=0){for(const r of n.children)uy(r,e,t+1);e(n,t)}function zl(n,e,t=0){for(const r of n._children)zl(r,e,t+1);e(n,t)}function Gc(n,e,t=!0){if(e>n.size)throw new k(S.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,i=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-i)return Gc(s,e-i,t);if(e===i)return{node:n,offset:r};if(!t&&s.paddedSize===e-i)return{node:n,offset:r+1};if(s.paddedSize>e-i)return Gc(s,e-i-1,t);i+=s.paddedSize,r+=1}return{node:n,offset:r}}function cy(n){return n.isText||n.children.length===0?n:cy(n.children[0])}function j1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let i=t.parent,s=t;for(;i&&s===i.left;)s=i,i=i.parent;return i}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new K1(e,t,!0);const i=this.comparator(e,r.key);return i<0?r.left=this.putInternal(e,t,r.left):i>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class Lt{constructor(e,t){l(this,"parentID");l(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new Lt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,i;return r.isText?(r.parent.children[0]===r&&t===0?i=r.parent:i=r,r=r.parent):t===0?i=r:i=r.children[t-1],Lt.of(r.id,Ce.of(i.getCreatedAt(),i.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return Lt.of(Ce.of(Tt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ce.of(Tt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),i=e.findFloorNode(t);let s=e.findFloorNode(r);if(!i||!s)throw new k(S.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[i,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ce{constructor(e,t){l(this,"createdAt");l(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ce(e,t)}static fromStruct(e){return Ce.of(Tt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=i.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new k(S.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new k(S.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new Ze(Ce.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new Ze(Ce.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,i){const s=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,i);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,i){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,i){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=i)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new Ar);const i=[];for(const[s,o]of Object.entries(t))i.push(this.attrs.set(s,o,r));return i}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Yc(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Yc)};return n.attrs&&(e.attributes=ts((t=n.attrs)==null?void 0:t.toObject())),e}function ed(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${tn(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>ed(t)).join("")}`}function dy(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(dy),size:n.size,isRemoved:n.isRemoved}}class xt extends Oo{constructor(t,r){super(r);l(this,"indexTree");l(this,"nodeMapByID");this.indexTree=new V1(t),this.nodeMapByID=new fy(Ce.createComparator()),this.indexTree.traverseAll(i=>{this.nodeMapByID.put(i.id,i)})}static create(t,r){return new xt(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[i,s]=t.toTreeNodePair(this);let o=s;const a=i===o,u=o.parent&&!a?o.parent:i;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const c=u.allChildren,d=a?0:c.indexOf(o)+1;for(let h=d;h{const P=T.getCreatedAt().getActorID();let p,g=0n;if(o===void 0&&s===void 0?g=Gs:o.size()>0?g=o.get(P)?o.get(P):0n:p=s.has(P)?s.get(P):Ft,T.canStyle(i,p,g)&&r){const v=y.get(P),I=T.getCreatedAt();(!v||I.after(v))&&y.set(P,I);const E=T.setAttrs(r,i),N=E.reduce((q,[,$])=>($&&(q[$.getKey()]=m[$.getKey()]),q),{}),D=T.parent,R=T.prevSibling||T.parent;Object.keys(N).length>0&&h.push({type:"style",from:this.toIndex(D,R),to:this.toIndex(T,T),fromPath:this.toPath(D,R),toPath:this.toPath(T,T),actor:i.getActorID(),value:N});for(const[q]of E)q&&w.push({parent:T,child:q})}}),[y,w,h]}removeStyle(t,r,i,s,o){const[a,u]=this.findNodesAndSplitText(t[0],i),[c,d]=this.findNodesAndSplitText(t[1],i),h=[],m=new Map,y=[];return this.traverseInPosRange(a,u,c,d,([w])=>{const T=w.getCreatedAt().getActorID();let P,p=0n;if(o===void 0&&s===void 0?p=Gs:o.size()>0?p=o.get(T)?o.get(T):0n:P=s.has(T)?s.get(T):Ft,w.canStyle(i,P,p)&&r){const g=m.get(T),v=w.getCreatedAt();(!g||v.after(g))&&m.set(T,v),w.attrs||(w.attrs=new Ar);for(const N of r){const D=w.attrs.remove(N,i);for(const R of D)y.push({parent:w,child:R})}const I=w.parent,E=w.prevSibling||w.parent;h.push({actor:i.getActorID(),type:"removeStyle",from:this.toIndex(I,E),to:this.toIndex(w,w),fromPath:this.toPath(I,E),toPath:this.toPath(w,w),value:r})}}),[m,y,h]}edit(t,r,i,s,o,a,u){const[c,d]=this.findNodesAndSplitText(t[0],s),[h,m]=this.findNodesAndSplitText(t[1],s),y=this.toIndex(c,d),w=this.toPath(c,d),T=[],P=[],p=[],g=new Map;this.traverseInPosRange(c,d,h,m,([E,N],D)=>{if(N===me.Start&&!D)for(const Se of E.children)p.push(Se);const R=E.getCreatedAt().getActorID();let q,$=0n;if(u===void 0&&a===void 0?$=Gs:u.size()>0?$=u.get(R)?u.get(R):0n:q=a.has(R)?a.get(R):Ft,E.canDelete(s,q,$)||T.includes(E.parent)){const Se=g.get(R),xr=E.getCreatedAt();(!Se||xr.after(Se))&&g.set(R,xr),(N===me.Text||N===me.Start)&&T.push(E),P.push([E,N])}});const v=this.makeDeletionChanges(P,s),I=[];for(const E of T)E.remove(s),E.isRemoved&&I.push({parent:this,child:E});for(const E of p)E.removedAt||c.append(E);if(i>0){let E=0,N=c,D=d;for(;E{c.isRemoved&&(R.remove(s),I.push({parent:this,child:R})),this.nodeMapByID.put(R.id,R)}),D.isRemoved||E.push(D);if(E.length){const D=E.map(R=>Yc(R));v.length&&v[v.length-1].from===y?v[v.length-1].value=D:v.push({type:"content",from:y,to:y,fromPath:w,toPath:w,actor:s.getActorID(),value:D})}}return[v,I,g]}editT(t,r,i,s,o){const a=this.findPos(t[0]),u=this.findPos(t[1]);this.edit([a,u],r,i,s,o)}move(t,r,i){throw new k(S.ErrUnimplemented,`not implemented: ${t}, ${r}, ${i}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,i=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=i}if(i){const o=this.findFloorNode(i);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const i of r.getGCPairs())t.push(i)}),t}findPos(t,r=!0){const i=this.indexTree.findTreePos(t,r);return Lt.fromTreePos(i)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ed(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(i,s=void 0,o=void 0,a=0)=>{var y,w,T,P;let u,c,d;const h=i.isText?{node:i,offset:0}:s&&o?this.toTreePos(s,o):null;h&&(u=this.indexTree.indexOf(h),c=this.indexTree.treePosToPath(h),d=Lt.fromTreePos(h).toStruct());const m={type:i.type,parent:s==null?void 0:s.id.toTestString(),size:i.size,id:i.id.toTestString(),removedAt:(y=i.removedAt)==null?void 0:y.toTestString(),insPrev:(w=i.insPrevID)==null?void 0:w.toTestString(),insNext:(T=i.insNextID)==null?void 0:T.toTestString(),value:i.isText?i.value:void 0,isRemoved:i.isRemoved,children:[],depth:a,attributes:i.attrs?ts((P=i.attrs)==null?void 0:P.toObject()):void 0,index:u,path:c,pos:d};for(let p=0;p0&&p===i[i.length-1].to?(i[i.length-1].to=g,i[i.length-1].toPath=this.toPath(P,y)):i.push({type:"content",from:p,to:g,fromPath:this.toPath(T,h),toPath:this.toPath(P,y),actor:r.getActorID()}))}return i.reverse()}findRightToken([t,r]){if(r===me.Start){const u=t.allChildren;return u.length>0?[u[0],u[0].isText?me.Text:me.Start]:[t,me.End]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===s.length-1)return[i,me.End];const a=s[o+1];return[a,a.isText?me.Text:me.Start]}findLeftToken([t,r]){if(r===me.End){const u=t.allChildren;if(u.length>0){const c=u[u.length-1];return[c,c.isText?me.Text:me.End]}return[t,me.Start]}const i=t.parent,s=i.allChildren,o=s.indexOf(t);if(i&&o===0)return[i,me.Start];const a=s[o-1];return[a,a.isText?me.Text:me.End]}}class bo extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"contents");l(this,"splitLevel");l(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=i,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,i,s,o,a,u){return new bo(t,r,i,s,o,a,u)}execute(t,r,i){var d;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof xt))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[u,c]=a.edit([this.fromPos,this.toPos],(d=this.contents)==null?void 0:d.map(h=>h.deepcopy()),this.splitLevel,o,(()=>{let h=o.getDelimiter();return this.contents!==void 0&&(h+=this.contents.length),()=>Tt.of(o.getLamport(),++h,o.getActorID())})(),this.maxCreatedAtMapByActor,i);for(const h of c)t.registerGCPair(h);return{opInfos:u.map(({from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:h,to:m,value:y,splitLevel:w,fromPath:T,toPath:P}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${r},${i},${s.map(o=>ed(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ns{constructor(e){l(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}unset(e){this.vector.delete(e)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,i]of e){const s=this.vector.get(r),o=s&&s>i?s:i;t.set(r,o)}for(const[r,i]of this){const s=e.get(r),o=s&&s>i?s:i;t.set(r,o)}return new ns(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new ns(e)}filter(e){const t=new Map;for(const[r]of e){const i=this.vector.get(r);i!==void 0&&t.set(r,i)}return new ns(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const _1=new ns(new Map);class lr{constructor(e,t,r,i,s){l(this,"clientSeq");l(this,"serverSeq");l(this,"lamport");l(this,"actor");l(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=i,this.actor=r}static of(e,t,r,i,s){return new lr(e,t,r,i,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new lr(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n;let r=e.versionVector;r.size()===0&&(r=r.deepcopy(),r.set(e.actor,e.lamport));const i=this.versionVector.max(r),s=new lr(this.clientSeq,t,this.actor,i);return s.versionVector.set(this.actor,t),s}setClocks(e,t){const r=e>this.lamport?e+1n:this.lamport+1n;t.unset($l);const i=this.versionVector.max(t);return i.set(this.actor,r),lr.of(this.clientSeq,r,this.actor,i)}createTimeTicket(e){return Tt.of(this.lamport,e,this.actor)}setActor(e){return new lr(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new lr(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const H1=new lr(0,0n,$l,_1);class ps{constructor({id:e,operations:t,presenceChange:r,message:i}){l(this,"id");l(this,"operations");l(this,"presenceChange");l(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=i}static create({id:e,operations:t,presenceChange:r,message:i}){return new ps({id:e,operations:t,presenceChange:r,message:i})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const i=[],s=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:u,reverseOp:c}=a;i.push(...u),c&&s.unshift(c)}return this.presenceChange&&(this.presenceChange.type===Xr.Put?t.set(this.id.getActorID(),Pt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:i,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:de.bytesToHex(de.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>de.bytesToHex(de.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:i,message:s}=e;return ps.create({id:de.bytesToChangeID(de.hexToBytes(t)),operations:r==null?void 0:r.map(o=>de.bytesToOperation(de.hexToBytes(o))),presenceChange:i,message:s})}}class Ul{constructor(e,t,r,i,s,o,a){l(this,"documentKey");l(this,"checkpoint");l(this,"isRemoved");l(this,"changes");l(this,"snapshot");l(this,"minSyncedTicket");l(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=i,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,r,i,s,o,a){return new Ul(e,t,r,i,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class rs{constructor(e,t){l(this,"serverSeq");l(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new rs(e,t)}increaseClientSeq(e){return e===0?this:new rs(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return rs.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const G1=new rs(0n,0);class sn{constructor(e,t){l(this,"createdAt");l(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new sn(e,t)}static fromStruct(e){return sn.of(Tt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new sn(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Y1=sn.of(Ft,0);class Mt{constructor(e,t){l(this,"id");l(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Mt(e,t)}static fromStruct(e){const t=sn.fromStruct(e.id);return Mt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return sn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class Hr extends ry{constructor(t,r,i){super(r);l(this,"id");l(this,"removedAt");l(this,"prev");l(this,"next");l(this,"insPrev");l(this,"insNext");this.id=t,this.removedAt=i}static create(t,r){return new Hr(t,r)}static createComparator(){return(t,r)=>{const i=t.getCreatedAt().compare(r.getCreatedAt());return i!==0?i:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let i=e;for(;i&&i!==t;)r.push(i),i=i.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new k(S.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const i=e.getInsNext();return i&&i.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,i){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,r,i),a=new Map,u=new Map,c=this.makeChanges(o,t);for(const d of s){const h=d.getCreatedAt().getActorID();(!a.has(h)||d.getID().getCreatedAt().after(a.get(h)))&&a.set(h,d.getID().getCreatedAt()),u.set(d.getID().toIDString(),d),d.remove(t)}return this.deleteIndexNodes(o),[c,a,u]}filterNodes(e,t,r,i){const s=[],o=[],[a,u]=this.findEdgesOfCandidates(e);o.push(a);for(const c of e){const d=c.getCreatedAt().getActorID();let h,m=0n;i===void 0&&r===void 0?m=Gs:i.size()>0?m=i.get(d)?i.get(d):0n:h=r.has(d)?r.get(d):Ft,c.canDelete(t,h,m)?s.push(c):o.push(c)}return o.push(u),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let i,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var on=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(on||{});class nt extends Oo{constructor(t,r,i){super(i);l(this,"valueType");l(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=K.fromNumber(r).toInt():this.value=og(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=K.fromNumber(r):this.value=r;break;default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,i){return new nt(t,r,i)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return K.fromBytesLE(Array.from(r));default:throw new k(S.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=nt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof K?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!nt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new k(S.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(i){if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===ve.Long?this.value=this.value+t.getValue().toInt():this.value=K.fromNumber(this.value+og(t.getValue())).toInt(),this}}class vs extends $t{constructor(t,r,i){super(t,i);l(this,"value");this.value=r}static create(t,r,i){return new vs(t,r,i)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof nt))throw new k(S.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const i=r,s=this.value.deepcopy();return i.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),i=t.getType()===ve.Long?t.getValue().multiply(-1):t.getValue()*-1;return vs.create(this.getParentCreatedAt(),ie.of(i,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class yr extends $t{constructor(t,r,i,s,o,a,u){super(t,u);l(this,"fromPos");l(this,"toPos");l(this,"maxCreatedAtMapByActor");l(this,"attributes");l(this,"attributesToRemove");this.fromPos=r,this.toPos=i,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,r,i,s,o,a){return new yr(t,r,i,s,o,[],a)}static createTreeRemoveStyleOperation(t,r,i,s,o,a){return new yr(t,r,i,s,new Map,o,a)}execute(t,r,i){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new k(S.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof xt))throw new k(S.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,u;if(this.attributes.size){const c={};[...this.attributes].forEach(([d,h])=>c[d]=h),[,u,a]=o.style([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}else{const c=this.attributesToRemove;[,u,a]=o.removeStyle([this.fromPos,this.toPos],c,this.getExecutedAt(),this.maxCreatedAtMapByActor,i)}for(const c of u)t.registerGCPair(c);return{opInfos:a.map(({from:c,to:d,value:h,fromPath:m,toPath:y})=>({type:"tree-style",from:c,to:d,value:this.attributes.size?{attributes:h}:{attributesToRemove:h},fromPath:m,toPath:y,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,i=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${i},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Q1(n){const e=new Qf,t=e.data;for(const[r,i]of Object.entries(n))t[r]=JSON.stringify(i);return e}function X1(n){if(n.type===Xr.Put)return new wo({type:Ei.PUT,presence:Q1(n.presence)});if(n.type===Xr.Clear)return new wo({type:Ei.CLEAR});throw new k(S.ErrUnimplemented,"unimplemented type")}function Z1(n){return new ey({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function hy(n){return new Ml({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:fd(n.getActorID()),versionVector:td(n.getVersionVector())})}function F(n){if(n)return new b({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:fd(n.getActorID())})}function td(n){if(!n)return;const e=new Jl;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function gy(n){switch(n){case ve.Null:return z.NULL;case ve.Boolean:return z.BOOLEAN;case ve.Integer:return z.INTEGER;case ve.Long:return z.LONG;case ve.Double:return z.DOUBLE;case ve.String:return z.STRING;case ve.Bytes:return z.BYTES;case ve.Date:return z.DATE;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function my(n){switch(n){case on.IntegerCnt:return z.INTEGER_CNT;case on.LongCnt:return z.LONG_CNT;default:throw new k(S.ErrInvalidType,`unsupported type: ${n}`)}}function Eu(n){if(n instanceof He)return new lt({type:z.JSON_OBJECT,createdAt:F(n.getCreatedAt()),value:Ny(n)});if(n instanceof tt)return new lt({type:z.JSON_ARRAY,createdAt:F(n.getCreatedAt()),value:DS(n)});if(n instanceof Et)return new lt({type:z.TEXT,createdAt:F(n.getCreatedAt())});if(n instanceof ie)return new lt({type:gy(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof nt)return new lt({type:my(n.getType()),createdAt:F(n.getCreatedAt()),value:n.toBytes()});if(n instanceof xt)return new lt({type:z.TREE,createdAt:F(n.getCreatedAt()),value:RS(n)});throw new k(S.ErrUnimplemented,"unimplemented element")}function eS(n){return new yo({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function na(n){return new Tr({createdAt:F(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function ra(n){return new Ii({parentId:Ys(n.getParentID()),leftSiblingId:Ys(n.getLeftSiblingID())})}function Ys(n){return new Wr({createdAt:F(n.getCreatedAt()),offset:n.getOffset()})}function py(n){const e=new Yf;if(n instanceof xi){const t=n,r=new Xa;r.parentCreatedAt=F(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Eu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Ro){const t=n,r=new Za;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.value=Eu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof Mr){const t=n,r=new el;r.parentCreatedAt=F(t.getParentCreatedAt()),r.prevCreatedAt=F(t.getPrevCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Zr){const t=n,r=new tl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.createdAt=F(t.getCreatedAt()),r.executedAt=F(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Lo){const t=n,r=new nl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);r.content=t.getContent();const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof Bo){const t=n,r=new rl;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=na(t.getFromPos()),r.to=na(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=r.attributes;for(const[o,a]of t.getAttributes())s[o]=a;r.executedAt=F(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof vs){const t=n,r=new il;r.parentCreatedAt=F(t.getParentCreatedAt()),r.value=Eu(t.getValue()),r.executedAt=F(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof bo){const t=n,r=new sl,i=r.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())i[s]=F(o);r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ra(t.getFromPos()),r.to=ra(t.getToPos()),r.contents=aS(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=F(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof yr){const t=n,r=new ol;r.parentCreatedAt=F(t.getParentCreatedAt()),r.from=ra(t.getFromPos()),r.to=ra(t.getToPos());const i=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())i[o]=F(a);const s=t.getAttributesToRemove();if(s.length>0)r.attributesToRemove=s;else{const o=r.attributes;for(const[a,u]of t.getAttributes())o[a]=u}r.executedAt=F(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new k(S.ErrUnimplemented,"unimplemented operation");return e}function tS(n){const e=[];for(const t of n)e.push(py(t));return e}function nS(n){const e=new Xp({id:hy(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=tS(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=X1(n.getPresenceChange())),e}function rS(n){const e=[];for(const t of n)e.push(nS(t));return e}function iS(n){const e=[];for(const t of n)e.push(new Zp({key:t.getStrKey(),element:rd(t.getValue())}));return e}function sS(n){const e=[];for(const t of n)e.push(new hl({element:rd(t.getValue())}));return e}function oS(n){const e=[];for(const t of n){const r=new gl;r.id=eS(t.getID()),r.value=t.getValue().getContent(),r.removedAt=F(t.getRemovedAt());const i=r.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new hs;a.value=o.getValue(),a.updatedAt=F(o.getUpdatedAt()),i[o.getKey()]=a}e.push(r)}return e}function aS(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new ml({content:nd(t)}));return e}function lS(n){const e={};for(const t of n)e[t.getKey()]=new hs({value:t.getValue(),updatedAt:F(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function nd(n){if(!n)return[];const e=[];return zl(n,(t,r)=>{const i=new vo({id:Ys(t.id),type:t.type,removedAt:F(t.removedAt),depth:r});t.isText&&(i.value=t.value),t.insPrevID&&(i.insPrevId=Ys(t.insPrevID)),t.insNextID&&(i.insNextId=Ys(t.insNextID)),t.attrs&&(i.attributes=lS(t.attrs)),e.push(i)}),e}function uS(n){const e=new Ge;return e.body.case="jsonObject",e.body.value=new al({nodes:iS(n.getRHT()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function yy(n){const e=new Ge;return e.body.case="jsonArray",e.body.value=new ll({nodes:sS(n.getElements()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function cS(n){const e=new Ge;return e.body.case="primitive",e.body.value=new ul({type:gy(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function fS(n){const e=new Ge;return e.body.case="text",e.body.value=new cl({nodes:oS(n.getRGATreeSplit()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function dS(n){const e=new Ge;return e.body.case="counter",e.body.value=new fl({type:my(n.getType()),value:n.toBytes(),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function vy(n){const e=new Ge;return e.body.case="tree",e.body.value=new dl({nodes:nd(n.getRoot()),createdAt:F(n.getCreatedAt()),movedAt:F(n.getMovedAt()),removedAt:F(n.getRemovedAt())}),e}function rd(n){if(n instanceof He)return uS(n);if(n instanceof tt)return yy(n);if(n instanceof ie)return cS(n);if(n instanceof Et)return fS(n);if(n instanceof nt)return dS(n);if(n instanceof xt)return vy(n);throw new k(S.ErrUnimplemented,"unimplemented element")}function hS(n){return new Er({documentKey:n.getDocumentKey(),checkpoint:Z1(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:rS(n.getChanges()),snapshot:n.getSnapshot(),versionVector:td(n.getVersionVector()),minSyncedTicket:F(n.getMinSyncedTicket())})}function Ms(n){if(!(n instanceof te))return{};const e=n.findDetails(R1);for(const t of e)return t.metadata;return{}}function Ri(n){return Ms(n).code??""}function wy(n){return lr.of(n.clientSeq,BigInt(n.lamport),ud(n.actorId),id(n.versionVector),BigInt(n.serverSeq))}function id(n){if(!n)return;const e=new ns;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return Tt.of(BigInt(n.lamport),n.delimiter,ud(n.actorId))}function sd(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function gS(n){const e=n.type;if(e===Ei.PUT){const t=sd(n.presence);return{type:Xr.Put,presence:t}}if(e===Ei.CLEAR)return{type:Xr.Clear};throw new k(S.ErrInvalidType,`unsupported type: ${e}`)}function mS(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,sd(r))}),e}function Sy(n){switch(n){case z.NULL:return ve.Null;case z.BOOLEAN:return ve.Boolean;case z.INTEGER:return ve.Integer;case z.LONG:return ve.Long;case z.DOUBLE:return ve.Double;case z.STRING:return ve.String;case z.BYTES:return ve.Bytes;case z.DATE:return ve.Date}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function vl(n){switch(n){case z.INTEGER_CNT:return on.IntegerCnt;case z.LONG_CNT:return on.LongCnt}throw new k(S.ErrUnimplemented,`unimplemented value type: ${n}`)}function xu(n){switch(n.type){case z.JSON_OBJECT:return n.value?Cy(n.value):He.create(M(n.createdAt));case z.JSON_ARRAY:return n.value?PS(n.value):tt.create(M(n.createdAt));case z.TEXT:return Et.create(ys.create(),M(n.createdAt));case z.TREE:return OS(n.value);case z.NULL:case z.BOOLEAN:case z.INTEGER:case z.LONG:case z.DOUBLE:case z.STRING:case z.BYTES:case z.DATE:return ie.of(ie.valueFromBytes(Sy(n.type),n.value),M(n.createdAt));case z.INTEGER_CNT:case z.LONG_CNT:return nt.create(vl(n.type),nt.valueFromBytes(vl(n.type),n.value),M(n.createdAt))}}function ia(n){return Mt.of(sn.of(M(n.createdAt),n.offset),n.relativeOffset)}function ky(n){return sn.of(M(n.createdAt),n.offset)}function pS(n){const e=Ao.create(n.value);Object.entries(n.attributes).forEach(([r,i])=>{e.setAttr(r,i.value,M(i.updatedAt))});const t=Hr.create(ky(n.id),e);return t.remove(M(n.removedAt)),t}function Li(n){return Lt.of(Qs(n.parentId),Qs(n.leftSiblingId))}function Qs(n){return Ce.of(M(n.createdAt),n.offset)}function yS(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=od(t.content);e.push(r)}),e}function od(n){if(n.length===0)return;const e=[];for(const i of n)e.push(wS(i));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let i=e.length-2;i>=0;i--)r.get(n[i].depth-1).prepend(e[i]),r.set(n[i].depth,e[i]);return t.updateDescendantsSize(),xt.create(t,Ft).getRoot()}function vS(n){const e=Ar.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function wS(n){const e=Qs(n.id),t=Ze.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=vS(n.attributes)),n.insPrevId&&(t.insPrevID=Qs(n.insPrevId)),n.insNextId&&(t.insNextID=Qs(n.insNextId)),t.removedAt=M(n.removedAt),t}function Ty(n){if(n.body.case==="set"){const e=n.body.value;return xi.create(e.key,xu(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Ro.create(M(e.parentCreatedAt),M(e.prevCreatedAt),xu(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Mr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Zr.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Lo.create(M(e.parentCreatedAt),ia(e.from),ia(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([i,s])=>{t.set(i,M(s))});const r=new Map;return Object.entries(e.attributes).forEach(([i,s])=>{r.set(i,s)}),Bo.create(M(e.parentCreatedAt),ia(e.from),ia(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return vs.create(M(e.parentCreatedAt),xu(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,i])=>{t.set(r,M(i))}),bo.create(M(e.parentCreatedAt),Li(e.from),Li(e.to),yS(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,i=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{i.set(s,M(o))}),(r==null?void 0:r.length)>0?yr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),Li(e.from),Li(e.to),i,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),yr.create(M(e.parentCreatedAt),Li(e.from),Li(e.to),i,t,M(e.executedAt)))}else throw new k(S.ErrUnimplemented,"unimplemented operation")}}function SS(n){const e=[];for(const t of n){const r=Ty(t);r&&e.push(r)}return e}function Ay(n){const e=[];for(const t of n)e.push(ps.create({id:wy(t.id),operations:SS(t.operations),presenceChange:t.presenceChange?gS(t.presenceChange):void 0,message:t.message}));return e}function kS(n){return rs.of(BigInt(n.serverSeq),n.clientSeq)}function TS(n){return Ul.create(n.documentKey,kS(n.checkpoint),n.isRemoved,Ay(n.changes),id(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function Iy(n){const e=new So;for(const r of n.nodes){const i=ad(r.element);e.set(r.key,i,i.getPositionedAt())}const t=new He(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Ey(n){const e=new To;for(const r of n.nodes)e.insert(ad(r.element));const t=new tt(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function AS(n){const e=ie.of(ie.valueFromBytes(Sy(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function IS(n){const e=new ys;let t=e.getHead();for(const i of n.nodes){const s=e.insertAfter(t,pS(i));i.insPrevId&&s.setInsPrev(e.findNode(ky(i.insPrevId))),t=s}const r=new Et(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function ES(n){const e=nt.create(vl(n.type),nt.valueFromBytes(vl(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function xy(n){const e=od(n.nodes);return xt.create(e,M(n.createdAt))}function ad(n){if(n.body.case==="jsonObject")return Iy(n.body.value);if(n.body.case==="jsonArray")return Ey(n.body.value);if(n.body.case==="primitive")return AS(n.body.value);if(n.body.case==="text")return IS(n.body.value);if(n.body.case==="counter")return ES(n.body.value);if(n.body.case==="tree")return xy(n.body.value);throw new k(S.ErrUnimplemented,"unimplemented element")}function xS(n){if(!n)return{root:He.create(Ft),presences:new Map};const e=Ec.fromBinary(n);return{root:ad(e.root),presences:mS(e.presences)}}function CS(n){const e=td(n);return ld(e.toBinary())}function NS(n){const e=cd(n),t=Jl.fromBinary(e);return id(t)}function Cy(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return Iy(e.body.value)}function Ny(n){return rd(n).toBinary()}function PS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return Ey(e.body.value)}function DS(n){return yy(n).toBinary()}function OS(n){if(!n)throw new k(S.ErrInvalidArgument,"bytes is empty");const e=Ge.fromBinary(n);return xy(e.body.value)}function RS(n){return vy(n).toBinary()}function ld(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function ud(n){return ld(n)}function cd(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function fd(n){return cd(n)}function LS(n){const e=Ml.fromBinary(n);return wy(e)}function BS(n){const e=Yf.fromBinary(n);return Ty(e)}const de={fromPresence:sd,toChangePack:hS,fromChangePack:TS,fromChanges:Ay,toTreeNodes:nd,fromTreeNodes:od,objectToBytes:Ny,bytesToObject:Cy,bytesToSnapshot:xS,bytesToHex:ld,hexToBytes:cd,toHexString:ud,toUint8Array:fd,toOperation:py,toChangeID:hy,PbChangeID:Ml,bytesToChangeID:LS,bytesToOperation:BS,versionVectorToHex:CS,hexToVersionVector:NS};var Me=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Me||{});let li=3;function Py(n){li=n}const J={trivial:(...n)=>{li>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{li>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{li>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{li>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{li>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>li<=n};function Dy(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class bS{constructor(e,t,r,i,s){l(this,"reconnectStreamDelay");l(this,"doc");l(this,"docID");l(this,"syncMode");l(this,"remoteChangeEventReceived");l(this,"watchStream");l(this,"watchLoopTimerID");l(this,"watchAbortController");l(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=i,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ea.RealtimeSyncOff?!1:this.syncMode===Ea.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ea.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Cu=()=>{};class FS{constructor(e){l(this,"finalized",!1);l(this,"observers",[]);l(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let i;if(!e)throw new k(S.ErrInvalidArgument,"missing observer");if(this.finalized)throw new k(S.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?i=e:i={next:e,error:t,complete:r},i.next===void 0&&(i.next=Cu),i.error===void 0&&(i.error=Cu),i.complete===void 0&&(i.complete=Cu);const s=Dy(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:i}),this.finalized)try{this.finalError?i.error(this.finalError):i.complete()}catch(a){J.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Hi{constructor(e,t,r,i){l(this,"id");l(this,"delimiter");l(this,"message");l(this,"root");l(this,"operations");l(this,"presenceChange");l(this,"previousPresence");l(this,"reversePresenceKeys");this.id=e,this.delimiter=ny,this.root=t,this.operations=[],this.previousPresence=Pt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=i}static create(e,t,r,i){return new Hi(e,t,r,i)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ps.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class Io{constructor(e){l(this,"rootObject");l(this,"elementPairMapByCreatedAt");l(this,"gcElementSetByCreatedAt");l(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof Et||t instanceof xt)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new Io(He.create(Ft))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const i=t.element.getCreatedAt(),s=t.parent.subPathOf(i);if(s===void 0)throw new k(S.ErrInvalidArgument,`cant find the given element: ${i.toIDString()}`);r.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof _r&&e.getDescendants((r,i)=>(this.registerElement(r,i),!1))}deregisterElement(e){let t=0;const r=i=>{const s=i.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return r(e),e instanceof _r&&e.getDescendants(i=>(r(i),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof _r&&r.element.getDescendants(i=>(e.add(i.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new Io(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const i=this.elementPairMapByCreatedAt.get(r),s=i.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(i.parent.purge(i.element),t+=this.deregisterElement(i.element))}for(const[,r]of this.gcPairMap){const i=r.child.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Oy(n,e){const t=new Eo(n);return new Proxy(e,t.getHandlers())}class Eo{constructor(e){l(this,"context");l(this,"handlers");this.context=e,this.handlers={set:(t,r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]=${JSON.stringify(i)}`),Eo.setInternal(e,t,r,i),!0),get:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():ui(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(J.isEnabled(Me.Trivial)&&J.trivial(`obj[${r}]`),Eo.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,i){if(r.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=wl(e,i,s),a=t.set(r,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(xi.create(r,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const r={};for(const[i,s]of Object.entries(t)){if(i.includes("."))throw new k(S.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=wl(e,s,o);r[i]=a}return r}static deleteInternal(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByKey(r,i);s&&(e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function JS(n,e){const t=new ae(n,e);return new Proxy(e,t.getHandlers())}function $S(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function zS(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class ae{constructor(e,t){l(this,"context");l(this,"handlers");l(this,"array");this.context=e,this.array=t,this.handlers={get:(r,i,s)=>i==="getID"?()=>r.getCreatedAt():i==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return Pr(e,a)}:i==="getElementByIndex"?o=>{const a=r.get(o);return Pr(e,a)}:i==="getLast"?()=>Pr(e,r.getLast()):i==="deleteByID"?o=>{const a=ae.deleteInternalByID(e,r,o);return Pr(e,a)}:i==="insertAfter"?(o,a)=>{const u=ae.insertAfterInternal(e,r,o,a);return Pr(e,u)}:i==="insertBefore"?(o,a)=>{const u=ae.insertBeforeInternal(e,r,o,a);return Pr(e,u)}:i==="moveBefore"?(o,a)=>{ae.moveBeforeInternal(e,r,o,a)}:i==="moveAfter"?(o,a)=>{ae.moveAfterInternal(e,r,o,a)}:i==="moveFront"?o=>{ae.moveFrontInternal(e,r,o)}:i==="moveLast"?o=>{ae.moveLastInternal(e,r,o)}:$S(i)?ui(e,r.get(Number(i))):i==="push"?o=>ae.pushInternal(e,r,o):i==="splice"?(o,a,...u)=>ae.splice(e,r,o,a,...u):i==="length"?r.length:typeof i=="symbol"&&i===Symbol.iterator?ae.iteratorInternal.bind(this,e,r):i==="includes"?(o,a)=>ae.includes(e,r,o,a):i==="indexOf"?(o,a)=>ae.indexOf(e,r,o,a):i==="lastIndexOf"?(o,a)=>ae.lastIndexOf(e,r,o,a):i==="toJSForTest"?()=>r.toJSForTest():i==="toTestString"?()=>ae.toTestString(r):typeof i=="string"&&zS(i)?(...o)=>{const a=Array.from(r).map(u=>ui(e,u));return Array.prototype[i].apply(a,o)}:Reflect.get(r,i,s),deleteProperty:(r,i)=>(J.isEnabled(Me.Trivial)&&J.trivial(`array[${i}]`),ae.deleteInternalByIndex(e,r,Number.parseInt(i)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield Pr(e,r)}static buildArrayElements(e,t){const r=[];for(const i of t){const s=e.issueTimeTicket(),o=wl(e,i,s);r.push(o)}return r}static pushInternal(e,t,r){return ae.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,i){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,i,s),e.push(Mr.create(t.getCreatedAt(),o,i,s))}static moveAfterInternal(e,t,r,i){const s=e.issueTimeTicket();t.moveAfter(r,i,s),e.push(Mr.create(t.getCreatedAt(),r,i,s))}static moveFrontInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),r,i),e.push(Mr.create(t.getCreatedAt(),s.getCreatedAt(),r,i))}static moveLastInternal(e,t,r){const i=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,r,i),e.push(Mr.create(t.getCreatedAt(),s,r,i))}static insertAfterInternal(e,t,r,i){const s=e.issueTimeTicket(),o=wl(e,i,s);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Ro.create(t.getCreatedAt(),r,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,r,i){return ae.insertAfterInternal(e,t,t.getPrevCreatedAt(r),i)}static deleteInternalByIndex(e,t,r){const i=e.issueTimeTicket(),s=t.deleteByIndex(r,i);if(s)return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,r){const i=e.issueTimeTicket(),s=t.delete(r,i);return e.push(Zr.create(t.getCreatedAt(),s.getCreatedAt(),i)),e.registerRemovedElement(s),s}static splice(e,t,r,i,...s){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),u=i===void 0?o:i<0?a:Math.min(a+i,o),c=[];for(let d=a;d=s)return!1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).includes(r,o);for(let u=o;u=s)return-1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).indexOf(r,o);for(let u=o;u=s?s-1:i<0?i+s:i;if(o<0)return-1;if(ie.isSupport(r))return Array.from(t).map(c=>ui(e,c)).lastIndexOf(r,o);for(let u=o;u>0;u--)if(((a=t.get(u))==null?void 0:a.getID())===r.getID())return u;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class jl{constructor(e,t){l(this,"context");l(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,i){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${r}`);const o=i?gs(i):void 0,a=this.context.issueTimeTicket(),[u,,c,d]=this.text.edit(s,r,a,o);for(const h of c)this.context.registerGCPair(h);return this.context.push(new Lo(this.text.getCreatedAt(),s[0],s[1],u,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(d)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);J.isEnabled(Me.Debug)&&J.debug(`STYL: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} a:${JSON.stringify(r)}`);const s=gs(r),o=this.context.issueTimeTicket(),[a,u]=this.text.setStyle(i,s,o);for(const c of u)this.context.registerGCPair(c);return this.context.push(new Bo(this.text.getCreatedAt(),i[0],i[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Mt.fromStruct(e[0]),Mt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new k(S.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class Vl{constructor(e,t){l(this,"valueType");l(this,"value");l(this,"context");l(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=ie.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(vs.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new k(S.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function dd(n,e,t){const{type:r}=n,i=t.issueTimeTicket();if(r===pr){Ry(n);const{value:s}=n,o=Ze.create(Ce.of(i,0),r,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!ty(o)){const c=gs(o);a=new Ar;for(const[d,h]of Object.entries(c))a.set(d,h,i)}const u=Ze.create(Ce.of(i,0),r,void 0,a);e.append(u);for(const c of s)dd(c,u,t)}}function US(n,e){const{type:t}=e,r=n.issueTimeTicket();let i;if(e.type===pr){const{value:s}=e;i=Ze.create(Ce.of(r,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!ty(o)){const u=gs(o);a=new Ar;for(const[c,d]of Object.entries(u))a.set(c,d,r)}i=Ze.create(Ce.of(n.issueTimeTicket(),0),t,void 0,a);for(const u of s)dd(u,i,n)}return i}function Ry(n){if(!n.value.length)throw new k(S.ErrInvalidArgument,"text node cannot have empty value");return!0}function ag(n){if(!n.length)return!0;if(n[0].type===pr)for(const t of n){const{type:r}=t;if(r!==pr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together");Ry(t)}else for(const t of n){const{type:r}=t;if(r===pr)throw new k(S.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class ql{constructor(e){l(this,"initialRoot");l(this,"context");l(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return Ze.create(Ce.of(e.issueTimeTicket(),0),$1);const t=Ze.create(Ce.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)dd(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const[r,i]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?gs(t):void 0,[a]=this.tree.style([r,i],o,s);this.context.push(yr.create(this.tree.getCreatedAt(),r,i,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?gs(r):void 0,[u,c]=this.tree.style([i,s],a,o);for(const d of c)this.context.registerGCPair(d);this.context.push(yr.create(this.tree.getCreatedAt(),i,s,u,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,u]=this.tree.removeStyle([i,s],r,o);for(const c of u)this.context.registerGCPair(c);this.context.push(yr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),i,s,a,r,o))}editInternal(e,t,r,i=0){var c;if(r.length!==0&&r[0]&&(ag(r),r[0].type!==pr))for(const d of r){const{children:h=[]}=d;ag(h)}const s=this.context.getLastTimeTicket();let o=new Array;if(((c=r[0])==null?void 0:c.type)===pr){let d="";for(const h of r){const{value:m}=h;d+=m}o.push(Ze.create(Ce.of(this.context.issueTimeTicket(),0),pr,d))}else o=r.map(d=>d&&US(this.context,d)).filter(d=>d);const[,a,u]=this.tree.edit([e,t],o.length?o.map(d=>d==null?void 0:d.deepcopy()):void 0,i,s,()=>this.context.issueTimeTicket());for(const d of a)this.context.registerGCPair(d);return this.context.push(bo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,i,u,s)),!0}editByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulkByPath(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new k(S.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new k(S.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,r,i)}edit(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r?[r]:[],i)}editBulk(e,t,r,i=0){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new k(S.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,r,i)}toXML(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Lt.fromStruct(e[0]),Lt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new k(S.ErrNotInitialized,"Tree is not initialized yet");const t=[Lt.fromStruct(e[0]),Lt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function lg(n,e){return Oy(n,e)}function Pr(n,e){if(e){if(e instanceof ie)return e;if(e instanceof He)return Oy(n,e);if(e instanceof tt)return JS(n,e);if(e instanceof Et)return new jl(n,e);if(e instanceof nt){const t=new Vl(on.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof xt){const t=new ql;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function ui(n,e){const t=Pr(n,e);return t instanceof ie?t.getValue():t}function wl(n,e,t){let r;if(ie.isSupport(e))r=ie.of(e,t);else if(Array.isArray(e))r=tt.create(t,ae.buildArrayElements(n,e));else if(typeof e=="object")e instanceof jl?(r=Et.create(ys.create(),t),e.initialize(n,r)):e instanceof Vl?(r=nt.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof ql?(r=xt.create(e.buildRoot(n),t),e.initialize(n,r)):r=He.create(t,Eo.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const ug=50;class jS{constructor(){l(this,"undoStack",[]);l(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=ug&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=ug&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const VS="yorkie-devtools-panel",qS="yorkie-devtools-sdk";let Bi="disconnected";const cg=new Map,Ia=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Ia);function sa(n,e){(e!=null&&e.force||Bi!=="disconnected")&&window.postMessage({source:qS,...n},"*")}function KS(n){if(!n.isEnableDevtools()||typeof window>"u"||cg.has(n.getKey()))return;Ia.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Ee.StatusChanged&&r.type!==Ee.Snapshot&&r.type!==Ee.LocalChange&&r.type!==Ee.RemoteChange&&r.type!==Ee.Initialized&&r.type!==Ee.Watched&&r.type!==Ee.Unwatched&&r.type!==Ee.PresenceChanged)||(Ia.get(n.getKey()).push(t),Bi==="synced"&&sa({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});cg.set(n.getKey(),[e]),sa({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var i;if(((i=t.data)==null?void 0:i.source)!==VS)return;switch(t.data.msg){case"devtools::connect":if(Bi!=="disconnected")break;Bi="connected",sa({msg:"doc::available",docKey:n.getKey()}),J.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Bi="disconnected",J.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Bi="synced",sa({msg:"doc::sync::full",docKey:n.getKey(),events:Ia.get(n.getKey())}),J.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Dr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Dr||{}),Ee=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Ee||{}),Qc=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Qc||{}),Xc=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Xc||{});class Ly{constructor(e,t){l(this,"key");l(this,"status");l(this,"opts");l(this,"changeID");l(this,"checkpoint");l(this,"localChanges");l(this,"root");l(this,"clone");l(this,"eventStream");l(this,"eventStreamObserver");l(this,"onlineClients");l(this,"presences");l(this,"history");l(this,"internalHistory");l(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=Io.create(),this.changeID=H1,this.checkpoint=G1,this.localChanges=[],this.eventStream=MS(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new jS,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},KS(this)}update(e,t){if(this.getStatus()==="removed")throw new k(S.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),i=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const s=lg(i,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(s,new Iu(i,this.clone.presences.get(r)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(i.hasChange()){J.isEnabled(Me.Trivial)&&J.trivial(`trying to update a local change: ${this.toJSON()}`);const s=i.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,Y.Local),u=i.getReversePresence();u&&a.push({type:"presence",value:u}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const c=[];o.length>0&&c.push({type:"local-change",source:Y.Local,value:{message:s.getMessage()||"",operations:o,actor:r,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&c.push({type:"presence-changed",source:Y.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(c),J.isEnabled(Me.Trivial)&&J.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,i){if(typeof e=="string"){if(typeof t!="function")throw new k(S.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="initialized"&&c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||a(c)},r,i)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="initialized"&&c.type!=="presence-changed"||c.type==="presence-changed"&&c.value.clientID!==this.changeID.getActorID()||a(c)},r,i)}if(e==="others"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="watched"&&c.type!=="unwatched"&&c.type!=="presence-changed"||c.value.clientID!==this.changeID.getActorID()&&a(c)},r,i)}if(e==="connection"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="connection-changed"&&a(c)},r,i)}if(e==="status"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="status-changed"&&a(c)},r,i)}if(e==="sync"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="sync-status-changed"&&a(c)},r,i)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="local-broadcast"&&a(c)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="broadcast"&&a(c)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(u=>{for(const c of u)c.type==="auth-error"&&a(c)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,i)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const u of a){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const c=[];for(const d of u.value.operations)this.isSameElementOrChildOf(d.path,s)&&c.push(d);c.length&&o({...u,value:{...u.value,operations:c}})}},r,i)}if(typeof e=="function"){const s=e,o=t,a=r;return this.eventStream.subscribe(u=>{for(const c of u)c.type!=="snapshot"&&c.type!=="local-change"&&c.type!=="remote-change"||s(c)},o,a)}throw new k(S.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((s,o)=>s===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),Y.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),J.isEnabled(Me.Trivial)&&J.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Pt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return Ul.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return lg(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,i=-1){const{root:s,presences:o}=de.bytesToSnapshot(r);this.root=new Io(s),this.presences=o,this.changeID=this.changeID.setClocks(t.maxLamport(),t),this.clone=void 0,this.removePushedLocalChanges(i),this.applyChanges(this.localChanges,Y.Local),this.publish([{type:"snapshot",source:Y.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?de.bytesToHex(r):void 0,snapshotVector:de.versionVectorToHex(t)}}])}applyChanges(e,t){J.isEnabled(Me.Debug)&&J.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),J.isEnabled(Me.Trivial)&&J.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` +`));for(const r of e)this.applyChange(r,t);J.isEnabled(Me.Debug)&&J.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],i=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(i)){const o=e.getPresenceChange();switch(o.type){case Xr.Put:r.push(this.presences.has(i)?{type:"presence-changed",source:t,value:{clientID:i,presence:o.presence}}:{type:"watched",source:Y.Remote,value:{clientID:i,presence:o.presence}});break;case Xr.Clear:r.push({type:"unwatched",source:Y.Remote,value:{clientID:i,presence:this.getPresence(i)}}),this.removeOnlineClient(i);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===Y.Remote?{type:"remote-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:i,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const i of t)i!==this.changeID.getActorID()&&r.add(i);this.setOnlineClients(r),this.publish([{type:"initialized",source:Y.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,i=[];if(t===vi.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&i.push({type:"watched",source:Y.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===vi.DOCUMENT_UNWATCHED){const s=this.getPresence(r);this.removeOnlineClient(r),s&&i.push({type:"unwatched",source:Y.Remote,value:{clientID:r,presence:s}})}else if(t===vi.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;i.push({type:"broadcast",value:{clientID:r,topic:s,payload:JSON.parse(a.decode(o))}})}i.length>0&&this.publish(i)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor($l),this.publish([{source:e==="removed"?Y.Remote:Y.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:i}=e.value;if(!t)return;this.applySnapshot(BigInt(r),de.hexToVersionVector(i),de.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ps.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:i}of e.value)t.add(r),this.presences.set(r,i);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new k(S.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const i of t)if(r=r[i],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Pt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Pt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Pt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Pt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Pt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new k(S.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof $t)){new Iu(t,Pt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}redo(){if(this.isUpdating)throw new k(S.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new k(S.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Hi.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const c of e){if(!(c instanceof $t)){new Iu(t,Pt(this.clone.presences.get(this.changeID.getActorID()))).set(c.value,{addToHistory:!0});continue}const d=t.issueTimeTicket();c.setExecutedAt(d),t.push(c)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,Y.UndoRedo);const{opInfos:i,reverseOps:s}=r.execute(this.root,this.presences,Y.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!r.hasPresenceChange()&&i.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];i.length>0&&u.push({type:"local-change",source:Y.UndoRedo,value:{message:r.getMessage()||"",operations:i,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:Y.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const i={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([i])}getVersionVector(){return this.changeID.getVersionVector()}}function WS(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const _S="yorkie-js-sdk",HS="0.5.6",GS="Yorkie JS SDK",YS="./src/yorkie.ts",QS={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},XS=["dist"],ZS={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},ek={node:">=18.0.0",npm:">=7.1.0"},tk={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},nk={name:"hackerwins",email:"susukang98@gmail.com"},rk="Apache-2.0",ik={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},sk="https://github.com/yorkie-team/yorkie-js-sdk#readme",ok={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},ak={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},fg={name:_S,version:HS,description:GS,main:YS,publishConfig:QS,files:XS,scripts:ZS,engines:ek,repository:tk,author:nk,license:rk,bugs:ik,homepage:sk,devDependencies:ok,dependencies:ak};function lk(){return n=>async e=>(e.header.set("x-yorkie-user-agent",fg.name+"/"+fg.version),await n(e))}const uk=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ea=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ea||{});const oa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Nu={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class By{constructor(e,t){l(this,"id");l(this,"key");l(this,"status");l(this,"attachmentMap");l(this,"apiKey");l(this,"authTokenInjector");l(this,"conditions");l(this,"syncLoopDuration");l(this,"reconnectStreamDelay");l(this,"retrySyncLoopDelay");l(this,"rpcClient");l(this,"setAuthToken");l(this,"taskQueue");l(this,"processing",!1);l(this,"keepalive",!1);t=t||oa,this.key=t.key?t.key:Dy(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??oa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??oa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??oa.retrySyncLoopDelay;const{authInterceptor:r,setToken:i}=WS(this.apiKey);this.setAuthToken=i,this.rpcClient=l1(O1,D1({baseUrl:e,interceptors:[r,lk()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),J.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw J.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),J.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw J.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Dr.Detached)throw new k(S.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async s=>{var d;const{topic:o,payload:a}=s.value,u=(d=s.options)==null?void 0:d.error,c=s.options;try{await this.broadcast(e.getKey(),o,a,c)}catch(h){h instanceof Error&&(u==null||u(h))}}),i=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:de.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=de.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Dr.Removed)return e;e.applyStatus(Dr.Attached),this.attachmentMap.set(e.getKey(),new bS(this.reconnectStreamDelay,e,s.documentId,i,r)),i!=="manual"&&await this.runWatchLoop(e.getKey()),J.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const u=t.initialRoot;e.update(c=>{for(const[d,h]of Object.entries(u))if(!a.has(d)){const m=d;c[m]=h}})}return e}).catch(async s=>{throw J.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((i,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:de.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);return e.applyChangePack(s),e.getStatus()!==Dr.Removed&&e.applyStatus(Dr.Detached),this.detachInternal(e.getKey()),J.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async i=>{throw J.error(`[DD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}async changeSyncMode(e,t){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const i=r.syncMode;return i===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),i==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw J.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new k(S.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=de.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(i=>{const s=de.fromChangePack(i.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),J.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async i=>{throw J.error(`[RD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,i){if(!this.isActive())throw new k(S.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);if(!uk(r))throw new k(S.ErrInvalidArgument,"payload is not serializable");const o=(i==null?void 0:i.maxRetries)??Nu.maxRetries,a=Nu.maxBackoff;let u=0;const c=h=>Math.min(Nu.initialRetryInterval*2**h,a),d=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{J.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async h=>{if(J.error(`[BC] c:"${this.getKey()}" err:`,h),await this.handleConnectError(h))if(h instanceof te&&Ri(h)===S.ErrUnauthenticated&&s.doc.publish([{type:Ee.AuthError,value:{reason:Ms(h).reason,method:"Broadcast"}}]),ud(),c(u-1)),J.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${o}`);else throw J.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),h;else throw h}));return d()}runSyncLoop(){const e=()=>{if(!this.isActive()){J.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async i=>{throw i instanceof te&&Ri(i)===S.ErrUnauthenticated&&r.doc.publish([{type:Ee.AuthError,value:{reason:Ms(i).reason,method:"PushPull"}}]),i})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{J.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};J.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new k(S.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new k(S.ErrClientNotActivated,`${this.key} is not active`));const i=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:i.signal});return t.doc.publish([{type:Ee.ConnectionChanged,value:Qc.Connected}]),J.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const c of s)this.handleWatchDocumentsResponse(t,c),c.body.case==="initialization"&&o([s,i])}catch(c){t.doc.resetOnlineClients(),t.doc.publish([{type:Ee.Initialized,source:Y.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Ee.ConnectionChanged,value:Qc.Disconnected}]),J.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(c)?(c instanceof te&&Ri(c)===S.ErrUnauthenticated&&t.doc.publish([{type:Ee.AuthError,value:{reason:Ms(c).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(c)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===vi.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Dr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:i}=e,s=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:i,changePack:de.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=de.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Ee.SyncStatusChanged,value:Xc.Synced}]),r.getStatus()===Dr.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),c=a.getChangeSize();return J.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${s.getChangeSize()} pull:${c} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Ee.SyncStatusChanged,value:Xc.SyncFailed}]),J.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof te))return!1;if(e.code===H.Canceled||e.code===H.Unknown||e.code===H.ResourceExhausted||e.code===H.Unavailable)return!0;if(Ri(e)===S.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Ms(e).reason);this.setAuthToken(t)}return!0}return(Ri(e)===S.ErrClientNotActivated||Ri(e)===S.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{J.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const by={Client:By,Document:Ly,Primitive:ie,Text:jl,Counter:Vl,Tree:ql,LogLevel:Me,setLogLevel:Py,IntType:on.IntegerCnt,LongType:on.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:By,Document:Ly,Primitive:ie,Text:jl,Counter:Vl,Tree:ql,LogLevel:Me,setLogLevel:Py,IntType:on.IntegerCnt,LongType:on.LongCnt});class ck{constructor(e,t){this.x=e,this.y=t,this.lifetime=0}}const fk=({xPos:n,yPos:e})=>{const[t,r]=je.useState([]),i=je.useRef(null),[s,o]=je.useState([]),a=(u,c)=>{const d=new ck(u,c);s.push(d),o(s),t.push(d),r(t)};return je.useEffect(()=>{const c=i.current.getContext("2d"),d=()=>{c.clearRect(0,0,c.canvas.width,c.canvas.height);const h=.7*(1*4e3)/60;for(let m=0;mh)s.shift();else{c.lineWidth=5,c.lineJoin="round";const T=0,P=0,p=0;c.strokeStyle=`rgb(${T},${P},${p})`,c.beginPath(),c.moveTo(w.x,w.y),c.lineTo(y.x,y.y),c.stroke(),c.closePath()}}requestAnimationFrame(d)};d()},[s]),je.useEffect(()=>{a(n,e)},[n,e]),ce.jsx("canvas",{className:"pen-cursor-canvas",ref:i,width:document.body.clientWidth,height:document.body.clientHeight})},dk="_goUp0_1lnal_1",hk="_goUpAnimation0_1lnal_1",gk="_fadeOut_1lnal_1",mk="_goUp1_1lnal_16",pk="_goUpAnimation1_1lnal_1",yk="_goUp2_1lnal_31",vk="_goUpAnimation2_1lnal_1",wk="_leftRight0_1lnal_46",Sk="_leftRightAnimation0_1lnal_1",kk="_leftRight1_1lnal_60",Tk="_leftRightAnimation1_1lnal_1",Ak="_leftRight2_1lnal_74",Ik="_leftRightAnimation2_1lnal_1",Pu={goUp0:dk,goUpAnimation0:hk,fadeOut:gk,goUp1:mk,goUpAnimation1:pk,goUp2:yk,goUpAnimation2:vk,leftRight0:wk,leftRightAnimation0:Sk,leftRight1:kk,leftRightAnimation1:Tk,leftRight2:Ak,leftRightAnimation2:Ik};function Ek({x:n,y:e,timestamp:t,selectedCursorShape:r}){return ce.jsx("div",{className:"single-animation-container",children:ce.jsx("div",{className:`absolute select-none pointer-events-none ${Pu.disappear} text-${t%5+2}xl ${Pu["goUp"+t%3]}`,style:{left:n,top:e},children:ce.jsx("div",{className:Pu["leftRight"+t%3],children:ce.jsx("div",{className:"transform -translate-x-1/2 -translate-y-1/2",children:ce.jsx("img",{src:`./icons/icon_${r}.svg`})})})})})}function dg(n,e){const t=je.useRef(n);je.useEffect(()=>{t.current=n},[n]),je.useEffect(()=>{function r(){t.current()}if(e!==null){let i=setInterval(r,e);return()=>clearInterval(i)}},[e])}const xk=({pointerDown:n,xPos:e,yPos:t,selectedCursorShape:r})=>{const[i,s]=je.useState([]),o=100;return dg(()=>{s(a=>a.filter(u=>u.timestamp>Date.now()-4e3))},1e3),dg(()=>{n&&s(a=>a.concat([{point:{x:e,y:t},timestamp:Date.now()}]))},o),ce.jsx("div",{style:{transform:`translateX(${e}px) translateY(${t}px)`},children:i.map(a=>ce.jsx(Ek,{x:a.point.x,y:a.point.y,timestamp:a.timestamp,selectedCursorShape:r},a.timestamp.toString()))})},Ck=({selectedCursorShape:n,x:e,y:t,pointerDown:r})=>ce.jsxs(ce.Fragment,{children:[ce.jsx("img",{src:`./icons/icon_${n}.svg`,className:`${n}-cursor`,style:{transform:`translate3d(${e}px, ${t}px, 0)`}}),(n==="heart"||n==="thumbs")&&ce.jsx(xk,{pointerDown:r,xPos:e,yPos:t,selectedCursorShape:n}),n==="pen"&&r&&ce.jsx(fk,{xPos:e,yPos:t})]}),Nk=({handleCursorShapeSelect:n,clientsLength:e})=>{const[t,r]=je.useState("cursor"),i=["heart","thumbs","pen","cursor"];return ce.jsxs("div",{className:"cursor-selector-container",children:[ce.jsx("div",{className:"cursor-selections-container",children:i.map(s=>ce.jsx("img",{onClick:()=>{n(s),r(s)},className:`${t===s?"cursor-shape-selected":"cursor-shape-not-selected"}`,src:`./icons/icon_${s}.svg`},s))}),ce.jsx("div",{className:"num-users-container",children:ce.jsx("p",{children:e!==1?`${e} users are here`:"1 user here"})})]})},Du=new by.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"}),si=new by.Document("simultaneous-cursors",{enableDevtools:!0}),Pk=()=>{const[n,e]=je.useState([]),t=r=>{si.update((i,s)=>{s.set({cursorShape:r})})};return je.useEffect(()=>{(async()=>{await Du.activate(),si.subscribe("presence",a=>{e(si.getPresences())}),await Du.attach(si,{initialPresence:{cursorShape:"cursor",cursor:{xPos:0,yPos:0},pointerDown:!1}}),window.addEventListener("beforeunload",()=>{Du.deactivate()})})();const i=()=>{si.update((a,u)=>{u.set({pointerDown:!1})})},s=()=>{si.update((a,u)=>{u.set({pointerDown:!0})})},o=a=>{si.update((u,c)=>{c.set({cursor:{xPos:a.clientX,yPos:a.clientY}})})};return window.addEventListener("mousedown",s),window.addEventListener("mouseup",i),window.addEventListener("mousemove",o),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("mouseup",i),window.removeEventListener("mousemove",o)}},[]),ce.jsxs("div",{className:"general-container",children:[n.map(({clientID:r,presence:{cursorShape:i,cursor:s,pointerDown:o}})=>s?ce.jsx(Ck,{selectedCursorShape:i,x:s.xPos,y:s.yPos,pointerDown:o},r):null),ce.jsx(Nk,{handleCursorShapeSelect:t,clientsLength:n.length})]})};Ou.createRoot(document.getElementById("root")).render(ce.jsx(Pk,{})); diff --git a/examples/simultaneous-cursors/index.html b/examples/simultaneous-cursors/index.html index 9782d58bf..39f3c1c82 100644 --- a/examples/simultaneous-cursors/index.html +++ b/examples/simultaneous-cursors/index.html @@ -5,7 +5,7 @@ Simultaneous Cursors - Yorkie Example - + diff --git a/examples/vanilla-codemirror6/assets/index--0f-Tmnq.js b/examples/vanilla-codemirror6/assets/index-DBSPfpB3.js similarity index 88% rename from examples/vanilla-codemirror6/assets/index--0f-Tmnq.js rename to examples/vanilla-codemirror6/assets/index-DBSPfpB3.js index c1c5e004b..e84252605 100644 --- a/examples/vanilla-codemirror6/assets/index--0f-Tmnq.js +++ b/examples/vanilla-codemirror6/assets/index-DBSPfpB3.js @@ -1,6 +1,6 @@ -var bS=Object.defineProperty;var SS=(n,e,t)=>e in n?bS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>SS(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();var ne;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(ne||(ne={}));function td(n){const e=ne[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class ue extends Error{constructor(e,t=ne.Unknown,i,r,s){super(wS(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(i??{}),this.details=r??[],this.cause=s}static from(e,t=ne.Unknown){return e instanceof ue?e:e instanceof Error?e.name=="AbortError"?new ue(e.message,ne.Canceled):new ue(e.message,t,void 0,void 0,e):new ue(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===ue.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,i=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&i.push(r);continue}const s=t.findMessage(r.type);if(s)try{i.push(s.fromBinary(r.value))}catch{}}return i}}function wS(n,e){return n.length?`[${td(e)}] ${n}`:`[${td(e)}]`}function be(n,e){if(!n)throw new Error(e)}const vS=34028234663852886e22,kS=-34028234663852886e22,xS=4294967295,TS=2147483647,QS=-2147483648;function Da(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>TS||nxS||n<0)throw new Error("invalid uint 32: "+n)}function vm(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>vS||n({no:r.no,name:r.name,localName:n[r.no]})))}function Tm(n,e,t){const i=Object.create(null),r=Object.create(null),s=[];for(const o of e){const a=Qm(o);s.push(a),i[o.name]=a,r[o.no]=a}return{typeName:n,values:s,findName(o){return i[o]},findNumber(o){return r[o]}}}function AS(n,e,t){const i={};for(const r of e){const s=Qm(r);i[s.localName]=s.no,i[s.no]=s.localName}return xm(i,n,e),i}function Qm(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class D{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const i=this.getType(),r=i.runtime.bin,s=r.makeReadOptions(t);return r.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const i=this.getType(),r=i.runtime.json,s=r.makeReadOptions(t);return r.readMessage(i,e,s,this),this}fromJsonString(e,t){let i;try{i=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(i,t)}toBinary(e){const t=this.getType(),i=t.runtime.bin,r=i.makeWriteOptions(e),s=r.writerFactory();return i.writeMessage(this,s,r),s.finish()}toJson(e){const t=this.getType(),i=t.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var t;const i=this.toJson(e);return JSON.stringify(i,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function $S(n,e,t,i){var r;const s=(r=i==null?void 0:i.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new D),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,l){return new o().fromBinary(a,l)},fromJson(a,l){return new o().fromJson(a,l)},fromJsonString(a,l){return new o().fromJsonString(a,l)},equals(a,l){return n.util.equals(o,a,l)}}),o}function CS(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const Na=4294967296;function id(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function s(o,a){const l=Number(n.slice(o,a));r*=t,i=i*t+l,i>=Na&&(r=r+(i/Na|0),i=i%Na)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Am(i,r):Wu(i,r)}function IS(n,e){let t=Wu(n,e);const i=t.hi&2147483648;i&&(t=Am(t.lo,t.hi));const r=Pm(t.lo,t.hi);return i?"-"+r:r}function Pm(n,e){if({lo:n,hi:e}=RS(n,e),e<=2097151)return String(Na*e+n);const t=n&16777215,i=(n>>>24|e<<8)&16777215,r=e>>16&65535;let s=t+i*6777216+r*6710656,o=i+r*8147497,a=r*2;const l=1e7;return s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l),a.toString()+nd(o)+nd(s)}function RS(n,e){return{lo:n>>>0,hi:e>>>0}}function Wu(n,e){return{lo:n|0,hi:e|0}}function Am(n,e){return e=~e,n?n=~n+1:e+=1,Wu(n,e)}const nd=n=>{const e=String(n);return"0000000".slice(e.length)+e};function rd(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function ES(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var sd={};function DS(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof sd!="object"||sd.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const h=typeof l=="bigint"?l:BigInt(l);if(h>s||ha||hbe(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),i=r=>be(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),t(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),t(r),id(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),id(r)},dec(r,s){return IS(r,s)},uDec(r,s){return Pm(r,s)}}}const fe=DS();var T;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(T||(T={}));var hr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(hr||(hr={}));function zn(n,e,t){if(e===t)return!0;if(n==T.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let i=0;i>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(mc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Da(e),rd(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){vm(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){mc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Da(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Da(e),e=(e<<1^e>>31)>>>0,rd(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=fe.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=fe.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=fe.enc(e);return Th(t.lo,t.hi,this.buf),this}sint64(e){let t=fe.enc(e),i=t.hi>>31,r=t.lo<<1^i,s=(t.hi<<1|t.lo>>>31)^i;return Th(r,s,this.buf),this}uint64(e){let t=fe.uEnc(e);return Th(t.lo,t.hi,this.buf),this}}class BS{constructor(e,t){this.varint64=CS,this.uint32=ES,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e,t){let i=this.pos;switch(e){case xe.Varint:for(;this.buf[this.pos++]&128;);break;case xe.Bit64:this.pos+=4;case xe.Bit32:this.pos+=4;break;case xe.LengthDelimited:let r=this.uint32();this.pos+=r;break;case xe.StartGroup:for(;;){const[s,o]=this.tag();if(o===xe.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return fe.dec(...this.varint64())}uint64(){return fe.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,fe.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return fe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return fe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function qS(n,e,t,i){let r;return{typeName:e,extendee:t,get field(){if(!r){const s=typeof i=="function"?i():i;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,r=n.util.newFieldList([s]).list()[0]}return r},runtime:n}}function Cm(n){const e=n.field.localName,t=Object.create(null);return t[e]=MS(n),[t,()=>t[e]]}function MS(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return hs(e.T,e.L);case"message":const t=e.T,i=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function VS(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let Cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),eh=[];for(let n=0;n>4,o=s,r=2;break;case 2:t[i++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[i++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)},enc(n){let e="",t=0,i,r=0;for(let s=0;s>2],r=(i&3)<<4,t=1;break;case 1:e+=Cn[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=Cn[r|i>>6],e+=Cn[i&63],t=0;break}return t&&(e+=Cn[r],e+="=",t==1&&(e+="=")),e}};function LS(n,e,t){Rm(e,n);const i=e.runtime.bin.makeReadOptions(t),r=VS(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Cm(e);for(const a of r)e.runtime.bin.readField(s,i.readerFactory(a.data),e.field,a.wireType,i);return o()}function XS(n,e,t,i){Rm(e,n);const r=e.runtime.bin.makeReadOptions(i),s=e.runtime.bin.makeWriteOptions(i);if(Im(n,e)){const h=n.getType().runtime.bin.listUnknownFields(n).filter(c=>c.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const c of h)n.getType().runtime.bin.onUnknownField(n,c.no,c.wireType,c.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const l=r.readerFactory(o.finish());for(;l.posi.no==e.field.no)}function Rm(n,e){be(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Em(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!$m(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function od(n,e){const t=n.localName,i=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=i?n.T.values[0].no:void 0;break;case"scalar":e[t]=i?hs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function Ir(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(D.prototype).every(i=>i in n&&typeof n[i]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Dm(n,e){return Ir(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}T.DOUBLE,T.FLOAT,T.INT64,T.UINT64,T.INT32,T.UINT32,T.BOOL,T.STRING,T.BYTES;const ad={ignoreUnknownFields:!1},ld={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function US(n){return n?Object.assign(Object.assign({},ad),n):ad}function ZS(n){return n?Object.assign(Object.assign({},ld),n):ld}const tl=Symbol(),Ba=Symbol();function WS(){return{makeReadOptions:US,makeWriteOptions:ZS,readMessage(n,e,t,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${hi(e)}`);i=i??new n;const r=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(a===null&&l.kind=="scalar")continue;const h=r.get(l.oneof);if(h!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${h}", "${o}"`);r.set(l.oneof,o)}hd(i,a,l,t,n)}else{let h=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const c=s.findExtension(o.substring(1,o.length-1));if(c&&c.extendee.typeName==n.typeName){h=!0;const[u,f]=Cm(c);hd(u,a,c.field,t,c),XS(i,c,f(),t)}}if(!h&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return i},writeMessage(n,e){const t=n.getType(),i={};let r;try{for(r of t.fields.byNumber()){if(!Em(r,n)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!zS(r))continue}const o=r.oneof?n[r.oneof.localName].value:n[r.localName],a=cd(r,o,e);a!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&Im(n,a)){const l=LS(n,a,e),h=cd(a.field,l,e);h!==void 0&&(i[a.field.jsonName]=h)}}}catch(s){const o=r?`cannot encode field ${t.typeName}.${r.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return i},readScalar(n,e,t){return Ys(n,e,t??hr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||$m(n,e)))return qa(n,e)},debug:hi}}function hi(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function hd(n,e,t,i,r){let s=t.localName;if(t.repeated){if(be(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,i));break;case"enum":const l=Qh(t.T,a,i.ignoreUnknownFields,!0);l!==Ba&&o.push(l);break;case"scalar":try{o.push(Ys(t.T,a,t.L,!0))}catch(h){let c=`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(a)}`;throw h instanceof Error&&h.message.length>0&&(c+=`: ${h.message}`),new Error(c)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`);const o=n[s];for(const[a,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: map value null`);let h;try{h=jS(t.K,a)}catch(c){let u=`cannot decode map key for field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw c instanceof Error&&c.message.length>0&&(u+=`: ${c.message}`),new Error(u)}switch(t.V.kind){case"message":o[h]=t.V.T.fromJson(l,i);break;case"enum":const c=Qh(t.V.T,l,i.ignoreUnknownFields,!0);c!==Ba&&(o[h]=c);break;case"scalar":try{o[h]=Ys(t.V.T,l,hr.BIGINT,!0)}catch(u){let f=`cannot decode map value for field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw u instanceof Error&&u.message.length>0&&(f+=`: ${u.message}`),new Error(f)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];Ir(a)?a.fromJson(e,i):(n[s]=a=o.fromJson(e,i),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const l=Qh(t.T,e,i.ignoreUnknownFields,!1);switch(l){case tl:od(t,n);break;case Ba:break;default:n[s]=l;break}break;case"scalar":try{const h=Ys(t.T,e,t.L,!1);switch(h){case tl:od(t,n);break;default:n[s]=h;break}}catch(h){let c=`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw h instanceof Error&&h.message.length>0&&(c+=`: ${h.message}`),new Error(c)}break}}function jS(n,e){if(n===T.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ys(n,e,hr.BIGINT,!0).toString()}function Ys(n,e,t,i){if(e===null)return i?hs(n,t):tl;switch(n){case T.DOUBLE:case T.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return n==T.FLOAT&&vm(r),r;case T.INT32:case T.FIXED32:case T.SFIXED32:case T.SINT32:case T.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==T.UINT32||n==T.FIXED32?mc(s):Da(s),s;case T.INT64:case T.SFIXED64:case T.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=fe.parse(e);return t?o.toString():o;case T.FIXED64:case T.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=fe.uParse(e);return t?a.toString():a;case T.BOOL:if(typeof e!="boolean")break;return e;case T.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case T.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return ju.dec(e)}throw new Error}function Qh(n,e,t,i){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:i?n.values[0].no:tl;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=n.findName(e);if(r!==void 0)return r.no;if(t)return Ba;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${hi(e)}`)}function zS(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function cd(n,e,t){if(n.kind=="map"){be(typeof e=="object"&&e!=null);const i={},r=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of r)i[o.toString()]=qa(n.V.T,a);break;case"message":for(const[o,a]of r)i[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of r)i[o.toString()]=Ph(s,a,t.enumAsInteger);break}return t.emitDefaultValues||r.length>0?i:void 0}if(n.repeated){be(Array.isArray(e));const i=[];switch(n.kind){case"scalar":for(let r=0;r0?i:void 0}switch(n.kind){case"scalar":return qa(n.T,e);case"enum":return Ph(n.T,e,t.enumAsInteger);case"message":return Dm(n.T,e).toJson(t)}}function Ph(n,e,t){var i;if(be(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const r=n.findNumber(e);return(i=r==null?void 0:r.name)!==null&&i!==void 0?i:e}function qa(n,e){switch(n){case T.INT32:case T.SFIXED32:case T.SINT32:case T.FIXED32:case T.UINT32:return be(typeof e=="number"),e;case T.FLOAT:case T.DOUBLE:return be(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case T.STRING:return be(typeof e=="string"),e;case T.BOOL:return be(typeof e=="boolean"),e;case T.UINT64:case T.FIXED64:case T.INT64:case T.SFIXED64:case T.SINT64:return be(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case T.BYTES:return be(e instanceof Uint8Array),ju.enc(e)}}const Zr=Symbol("@bufbuild/protobuf/unknown-fields"),ud={readUnknownFields:!0,readerFactory:n=>new BS(n)},fd={writeUnknownFields:!0,writerFactory:()=>new NS};function FS(n){return n?Object.assign(Object.assign({},ud),n):ud}function _S(n){return n?Object.assign(Object.assign({},fd),n):fd}function GS(){return{makeReadOptions:FS,makeWriteOptions:_S,listUnknownFields(n){var e;return(e=n[Zr])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Zr]},writeUnknownFields(n,e){const i=n[Zr];if(i)for(const r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(n,e,t,i){const r=n;Array.isArray(r[Zr])||(r[Zr]=[]),r[Zr].push({no:e,wireType:t,data:i})},readMessage(n,e,t,i,r){const s=n.getType(),o=r?e.len:e.pos+t;let a,l;for(;e.pos0&&(l=YS),s){let f=n[o];if(i==xe.LengthDelimited&&a!=T.STRING&&a!=T.BYTES){let g=e.uint32()+e.pos;for(;e.posIr(f,u)?f:new u(f));else{const f=o[r];u.fieldWrapper?u.typeName==="google.protobuf.BytesValue"?s[r]=Es(f):s[r]=f:s[r]=Ir(f,u)?f:new u(f)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(i=>{const r=e[i.localName],s=t[i.localName];if(i.repeated){if(r.length!==s.length)return!1;switch(i.kind){case"message":return r.every((o,a)=>i.T.equals(o,s[a]));case"scalar":return r.every((o,a)=>zn(i.T,o,s[a]));case"enum":return r.every((o,a)=>zn(T.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${i.kind}`)}switch(i.kind){case"message":return i.T.equals(r,s);case"enum":return zn(T.INT32,r,s);case"scalar":return zn(i.T,r,s);case"oneof":if(r.case!==s.case)return!1;const o=i.findField(r.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(r.value,s.value);case"enum":return zn(T.INT32,r.value,s.value);case"scalar":return zn(o.T,r.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(r).concat(Object.keys(s));switch(i.V.kind){case"message":const l=i.V.T;return a.every(c=>l.equals(r[c],s[c]));case"enum":return a.every(c=>zn(T.INT32,r[c],s[c]));case"scalar":const h=i.V.T;return a.every(c=>zn(h,r[c],s[c]))}break}})},clone(n){const e=n.getType(),t=new e,i=t;for(const r of e.fields.byMember()){const s=n[r.localName];let o;if(r.repeated)o=s.map(ta);else if(r.kind=="map"){o=i[r.localName];for(const[a,l]of Object.entries(s))o[a]=ta(l)}else r.kind=="oneof"?o=r.findField(s.case)?{case:s.case,value:ta(s.value)}:{case:void 0}:o=ta(s);i[r.localName]=o}for(const r of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return t}}}function ta(n){if(n===void 0)return n;if(Ir(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Es(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function t1(n,e,t){return{syntax:n,json:WS(),bin:GS(),util:Object.assign(Object.assign({},e1()),{newFieldList:e,initFields:t}),makeMessageType(i,r,s){return $S(this,i,r,s)},makeEnum:AS,makeEnumType:Tm,getEnumType:PS,makeExtension(i,r,s){return qS(this,i,r,s)}}}class i1{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const i of this.list())t[i.jsonName]=t[i.name]=i;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const i of this.list())t[i.no]=i;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const i of this.list())i.oneof?i.oneof!==t&&(t=i.oneof,e.push(t)):e.push(i)}return this.members}}function Bm(n,e){const t=qm(n);return e?t:l1(a1(t))}function n1(n){return Bm(n,!1)}const r1=qm;function qm(n){let e=!1;const t=[];for(let i=0;i`${n}$`,a1=n=>o1.has(n)?Mm(n):n,l1=n=>s1.has(n)?Mm(n):n;class h1{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=n1(e)}addField(e){be(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew i1(n,e=>c1(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,i=n;if(e.repeated){i[t]=[];continue}switch(e.kind){case"oneof":i[t]={case:void 0};break;case"enum":i[t]=0;break;case"map":i[t]={};break;case"scalar":i[t]=hs(e.T,e.L);break}}});var _e;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(_e||(_e={}));var md;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(md||(md={}));class Ze extends D{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,m.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${m.json.debug(e)}`);const i=e.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]))$/);if(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(rDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=fe.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let i="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(t).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Ze.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ze({seconds:fe.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ze().fromBinary(e,t)}static fromJson(e,t){return new Ze().fromJson(e,t)}static fromJsonString(e,t){return new Ze().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Ze,e,t)}}Ze.runtime=m;Ze.typeName="google.protobuf.Timestamp";Ze.fields=m.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class In extends D{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,m.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);const i=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(i===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);const r=Number(i[1]);if(r>315576e6||r<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);if(this.seconds=fe.parse(r),typeof i[2]=="string"){const s=i[2]+"0".repeat(9-i[2].length);this.nanos=parseInt(s),(r<0||Object.is(r,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let i=Math.abs(this.nanos).toString();i="0".repeat(9-i.length)+i,i.substring(3)==="000000"?i=i.substring(0,3):i.substring(6)==="000"&&(i=i.substring(0,6)),t+="."+i,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new In().fromBinary(e,t)}static fromJson(e,t){return new In().fromJson(e,t)}static fromJsonString(e,t){return new In().fromJsonString(e,t)}static equals(e,t){return m.util.equals(In,e,t)}}In.runtime=m;In.typeName="google.protobuf.Duration";In.fields=m.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class ci extends D{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),m.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const i=this.typeUrlToName(this.typeUrl),r=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(i);if(!r)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=r.fromBinary(this.value).toJson(e);return(i.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var i;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const r=e["@type"];if(typeof r!="string"||r=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(r),o=(i=t==null?void 0:t.typeRegistry)===null||i===void 0?void 0:i.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${r} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const l=Object.assign({},e);delete l["@type"],a=o.fromJson(l,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let i="";return typeof e=="string"?i=e:i=e.typeName,t===i}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),i=t>=0?e.substring(t+1):e;if(!i.length)throw new Error(`invalid type url: ${e}`);return i}static pack(e){const t=new ci;return t.packFrom(e),t}static fromBinary(e,t){return new ci().fromBinary(e,t)}static fromJson(e,t){return new ci().fromJson(e,t)}static fromJsonString(e,t){return new ci().fromJsonString(e,t)}static equals(e,t){return m.util.equals(ci,e,t)}}ci.runtime=m;ci.typeName="google.protobuf.Any";ci.fields=m.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class di extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.DOUBLE,e)}catch(i){let r='cannot decode message google.protobuf.DoubleValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new di().fromBinary(e,t)}static fromJson(e,t){return new di().fromJson(e,t)}static fromJsonString(e,t){return new di().fromJsonString(e,t)}static equals(e,t){return m.util.equals(di,e,t)}}di.runtime=m;di.typeName="google.protobuf.DoubleValue";di.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);di.fieldWrapper={wrapField(n){return new di({value:n})},unwrapField(n){return n.value}};class pi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.FLOAT,e)}catch(i){let r='cannot decode message google.protobuf.FloatValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new pi().fromBinary(e,t)}static fromJson(e,t){return new pi().fromJson(e,t)}static fromJsonString(e,t){return new pi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(pi,e,t)}}pi.runtime=m;pi.typeName="google.protobuf.FloatValue";pi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);pi.fieldWrapper={wrapField(n){return new pi({value:n})},unwrapField(n){return n.value}};class gi extends D{constructor(e){super(),this.value=fe.zero,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.INT64,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.INT64,e)}catch(i){let r='cannot decode message google.protobuf.Int64Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new gi().fromBinary(e,t)}static fromJson(e,t){return new gi().fromJson(e,t)}static fromJsonString(e,t){return new gi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(gi,e,t)}}gi.runtime=m;gi.typeName="google.protobuf.Int64Value";gi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);gi.fieldWrapper={wrapField(n){return new gi({value:n})},unwrapField(n){return n.value}};class mi extends D{constructor(e){super(),this.value=fe.zero,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.UINT64,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.UINT64,e)}catch(i){let r='cannot decode message google.protobuf.UInt64Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new mi().fromBinary(e,t)}static fromJson(e,t){return new mi().fromJson(e,t)}static fromJsonString(e,t){return new mi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(mi,e,t)}}mi.runtime=m;mi.typeName="google.protobuf.UInt64Value";mi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);mi.fieldWrapper={wrapField(n){return new mi({value:n})},unwrapField(n){return n.value}};class Oi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.INT32,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.INT32,e)}catch(i){let r='cannot decode message google.protobuf.Int32Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new Oi().fromBinary(e,t)}static fromJson(e,t){return new Oi().fromJson(e,t)}static fromJsonString(e,t){return new Oi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Oi,e,t)}}Oi.runtime=m;Oi.typeName="google.protobuf.Int32Value";Oi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Oi.fieldWrapper={wrapField(n){return new Oi({value:n})},unwrapField(n){return n.value}};class yi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.UINT32,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.UINT32,e)}catch(i){let r='cannot decode message google.protobuf.UInt32Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new yi().fromBinary(e,t)}static fromJson(e,t){return new yi().fromJson(e,t)}static fromJsonString(e,t){return new yi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(yi,e,t)}}yi.runtime=m;yi.typeName="google.protobuf.UInt32Value";yi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);yi.fieldWrapper={wrapField(n){return new yi({value:n})},unwrapField(n){return n.value}};class bi extends D{constructor(e){super(),this.value=!1,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.BOOL,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.BOOL,e)}catch(i){let r='cannot decode message google.protobuf.BoolValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new bi().fromBinary(e,t)}static fromJson(e,t){return new bi().fromJson(e,t)}static fromJsonString(e,t){return new bi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(bi,e,t)}}bi.runtime=m;bi.typeName="google.protobuf.BoolValue";bi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);bi.fieldWrapper={wrapField(n){return new bi({value:n})},unwrapField(n){return n.value}};class ct extends D{constructor(e){super(),this.value="",m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.STRING,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.STRING,e)}catch(i){let r='cannot decode message google.protobuf.StringValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new ct().fromBinary(e,t)}static fromJson(e,t){return new ct().fromJson(e,t)}static fromJsonString(e,t){return new ct().fromJsonString(e,t)}static equals(e,t){return m.util.equals(ct,e,t)}}ct.runtime=m;ct.typeName="google.protobuf.StringValue";ct.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);ct.fieldWrapper={wrapField(n){return new ct({value:n})},unwrapField(n){return n.value}};class Si extends D{constructor(e){super(),this.value=new Uint8Array(0),m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.BYTES,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.BYTES,e)}catch(i){let r='cannot decode message google.protobuf.BytesValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new Si().fromBinary(e,t)}static fromJson(e,t){return new Si().fromJson(e,t)}static fromJsonString(e,t){return new Si().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Si,e,t)}}Si.runtime=m;Si.typeName="google.protobuf.BytesValue";Si.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Si.fieldWrapper={wrapField(n){return new Si({value:n})},unwrapField(n){return n.value}};function u1(n,e,t){try{const i=ju.dec(n);return e?e.fromBinary(i,t):i}catch(i){throw ue.from(i,ne.DataLoss)}}function f1(n,e){const t={};for(const[i,r]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},r),{localName:i,service:n}));s!=null&&(t[i]=s)}return t}function Od(n){let e,t=new Uint8Array(0);function i(r){const s=new Uint8Array(t.length+r.length);s.set(t),s.set(r,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(r){let s;for(;;){if(s===void 0&&t.byteLength>=5){let l=0;for(let h=1;h<5;h++)l=(l<<8)+t[h];s={flags:t[0],length:l}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;i(a.value)}if(s===void 0){if(t.byteLength==0){r.close();return}r.error(new ue("premature end of stream",ne.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),r.enqueue({flags:s.flags,data:o})}})}function yd(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setUint8(0,n),i.setUint32(1,e.length),t}var d1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),r(a,l,o.done,o.value)})}}function r(s,o,a,l){Promise.resolve(l).then(function(h){s({value:h,done:a})},o)}},co=function(n){return this instanceof co?(this.v=n,this):new co(n)},p1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof co?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}},g1=function(n){var e,t;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=n[r]?function(o){return(t=!t)?{value:co(n[r](o)),done:!1}:s?s(o):o}:s}};function m1(n){return p1(this,arguments,function*(){yield co(yield*g1(d1(n)))})}var Vm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),r(a,l,o.done,o.value)})}}function r(s,o,a,l){Promise.resolve(l).then(function(h){s({value:h,done:a})},o)}},cs=function(n){return this instanceof cs?(this.v=n,this):new cs(n)},O1=function(n){var e,t;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=n[r]?function(o){return(t=!t)?{value:cs(n[r](o)),done:!1}:s?s(o):o}:s}},y1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof cs?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}};function b1(n,e){return f1(n,t=>{switch(t.kind){case _e.Unary:return S1(e,n,t);case _e.ServerStreaming:return w1(e,n,t);case _e.ClientStreaming:return v1(e,n,t);case _e.BiDiStreaming:return k1(e,n,t);default:return null}})}function S1(n,e,t){return async function(i,r){var s,o;const a=await n.unary(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues);return(s=r==null?void 0:r.onHeader)===null||s===void 0||s.call(r,a.header),(o=r==null?void 0:r.onTrailer)===null||o===void 0||o.call(r,a.trailer),a.message}}function w1(n,e,t){return function(i,r){return Lm(n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,m1([i]),r==null?void 0:r.contextValues),r)}}function v1(n,e,t){return async function(i,r){var s,o,a,l,h,c;const u=await n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues);(h=r==null?void 0:r.onHeader)===null||h===void 0||h.call(r,u.header);let f;try{for(var p=!0,g=Vm(u.message),O;O=await g.next(),s=O.done,!s;p=!0)l=O.value,p=!1,f=l}catch(y){o={error:y}}finally{try{!p&&!s&&(a=g.return)&&await a.call(g)}finally{if(o)throw o.error}}if(!f)throw new ue("protocol error: missing response message",ne.Internal);return(c=r==null?void 0:r.onTrailer)===null||c===void 0||c.call(r,u.trailer),f}}function k1(n,e,t){return function(i,r){return Lm(n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues),r)}}function Lm(n,e){const t=function(){var i,r;return y1(this,arguments,function*(){const s=yield cs(n);(i=e==null?void 0:e.onHeader)===null||i===void 0||i.call(e,s.header),yield cs(yield*O1(Vm(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function x1(...n){const e=new AbortController,t=n.filter(r=>r!==void 0).concat(e.signal);for(const r of t){if(r.aborted){i.apply(r);break}r.addEventListener("abort",i)}function i(){e.signal.aborted||e.abort(Xm(this));for(const r of t)r.removeEventListener("abort",i)}return e}function T1(n){const e=new AbortController,t=()=>{e.abort(new ue("the operation timed out",ne.DeadlineExceeded))};let i;return n!==void 0&&(n<=0?t():i=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(i)}}function Xm(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function bd(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Ah=128;function Sd(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r -`);for(const i of t){if(i==="")continue;const r=i.indexOf(":");if(r>0){const s=i.substring(0,r).trim(),o=i.substring(r+1).trim();e.append(s,o)}}return e}const Q1="Content-Type",P1="Grpc-Timeout",Um="Grpc-Status",Zm="Grpc-Message",A1="Grpc-Status-Details-Bin",$1="X-User-Agent",C1="X-Grpc-Web",I1="application/grpc-web+proto",R1="application/grpc-web+json";class Rn extends D{constructor(e){super(),this.code=0,this.message="",this.details=[],m.util.initPartial(e,this)}static fromBinary(e,t){return new Rn().fromBinary(e,t)}static fromJson(e,t){return new Rn().fromJson(e,t)}static fromJsonString(e,t){return new Rn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Rn,e,t)}}Rn.runtime=m;Rn.typeName="google.rpc.Status";Rn.fields=m.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:ci,repeated:!0}]);const E1="0";function Wm(n){var e;const t=n.get(A1);if(t!=null){const r=u1(t,Rn);if(r.code==0)return;const s=new ue(r.message,r.code,n);return s.details=r.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const i=n.get(Um);if(i!=null){if(i===E1)return;const r=parseInt(i,10);return r in ne?new ue(decodeURIComponent((e=n.get(Zm))!==null&&e!==void 0?e:""),r,n):new ue(`invalid grpc-status: ${i}`,ne.Internal,n)}}function wd(n,e,t){const i=typeof e=="string"?e:e.typeName,r=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${i}/${r}`)}function jm(n,e){return e instanceof n?e:new n(e)}function D1(n,e){function t(i){return i.done===!0?i:{done:i.done,value:jm(n,i.value)}}return{[Symbol.asyncIterator](){const i=e[Symbol.asyncIterator](),r={next:()=>i.next().then(t)};return i.throw!==void 0&&(r.throw=s=>i.throw(s).then(t)),i.return!==void 0&&(r.return=s=>i.return(s).then(t)),r}}}function zm(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((i,r)=>r(i),n))!==null&&t!==void 0?t:n}function N1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function vd(n,e,t,i){const r=e?kd(n.I,i):xd(n.I,t);return{parse:(e?kd(n.O,i):xd(n.O,t)).parse,serialize:r.serialize}}function kd(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(i){const r=i instanceof Error?i.message:String(i);throw new ue(`parse binary: ${r}`,ne.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(i){const r=i instanceof Error?i.message:String(i);throw new ue(`serialize binary: ${r}`,ne.Internal)}}}}function xd(n,e){var t,i;const r=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(i=e==null?void 0:e.textDecoder)!==null&&i!==void 0?i:new TextDecoder,o=N1(e);return{parse(a){try{const l=s.decode(a);return n.fromJsonString(l,o)}catch(l){throw ue.from(l,ne.InvalidArgument)}},serialize(a){try{const l=a.toJsonString(o);return r.encode(l)}catch(l){throw ue.from(l,ne.Internal)}}}}function B1(n){const e=zm(n.next,n.interceptors),[t,i,r]=Fm(n),s=Object.assign(Object.assign({},n.req),{message:jm(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(r(),o),i)}function q1(n){const e=zm(n.next,n.interceptors),[t,i,r]=Fm(n),s=Object.assign(Object.assign({},n.req),{message:D1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,l;const h=n.req.message[Symbol.asyncIterator]();o||(a=h.throw)===null||a===void 0||a.call(h,this.reason).catch(()=>{}),(l=h.return)===null||l===void 0||l.call(h).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const l=a.message[Symbol.asyncIterator]();return{next(){return l.next().then(h=>(h.done==!0&&(o=!0,r()),h),i)}}}}}),i)}function Fm(n){const{signal:e,cleanup:t}=T1(n.timeoutMs),i=x1(n.signal,e);return[i.signal,function(s){const o=ue.from(e.aborted?Xm(e):s);return i.abort(o),t(),Promise.reject(o)},function(){t(),i.abort()}]}function M1(){try{new Headers}catch{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.")}}function Td(n,e){const t=Wm(n);if(t)throw e.forEach((i,r)=>{t.metadata.append(r,i)}),t}function Qd(n,e,t,i){const r=new Headers(t??{});return r.set(Q1,n?I1:R1),r.set(C1,"1"),r.set($1,"connect-es/1.4.0"),e!==void 0&&r.set(P1,`${e}m`),r}function V1(n){switch(n){case 400:return ne.Internal;case 401:return ne.Unauthenticated;case 403:return ne.PermissionDenied;case 404:return ne.Unimplemented;case 429:return ne.Unavailable;case 502:return ne.Unavailable;case 503:return ne.Unavailable;case 504:return ne.Unavailable;default:return ne.Unknown}}function Pd(n,e){var t;if(n>=200&&n<300){const i=Wm(e);if(i)throw i;return{foundStatus:e.has(Um)}}throw new ue(decodeURIComponent((t=e.get(Zm))!==null&&t!==void 0?t:`HTTP ${n}`),V1(n),e)}var Pr=function(n){return this instanceof Pr?(this.v=n,this):new Pr(n)},L1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof Pr?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}};function X1(n){var e;M1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(i,r,s,o,a,l,h){var c;const{serialize:u,parse:f}=vd(r,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await B1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:i,method:r,url:wd(n.baseUrl,i,r),init:{method:"POST",credentials:(c=n.credentials)!==null&&c!==void 0?c:"same-origin",redirect:"error",mode:"cors"},header:Qd(t,o,a),contextValues:h??bd(),message:l},next:async p=>{var g;const y=await((g=n.fetch)!==null&&g!==void 0?g:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:yd(0,u(p.message))}));if(Pd(y.status,y.headers),!y.body)throw"missing response body";const S=Od(y.body).getReader();let k,$;for(;;){const A=await S.read();if(A.done)break;const{flags:x,data:P}=A.value;if(x===Ah){if(k!==void 0)throw"extra trailer";k=Sd(P);continue}if($!==void 0)throw"extra message";$=f(P)}if(k===void 0)throw"missing trailer";if(Td(k,y.headers),$===void 0)throw"missing message";return{stream:!1,service:i,method:r,header:y.headers,message:$,trailer:k}}})},async stream(i,r,s,o,a,l,h){var c;const{serialize:u,parse:f}=vd(r,t,n.jsonOptions,n.binaryOptions);function p(O,y,S,k){return L1(this,arguments,function*(){const A=Od(O).getReader();if(y){if(!(yield Pr(A.read())).done)throw"extra data for trailers-only";return yield Pr(void 0)}let x=!1;for(;;){const P=yield Pr(A.read());if(P.done)break;const{flags:R,data:X}=P.value;if((R&Ah)===Ah){if(x)throw"extra trailer";x=!0;const W=Sd(X);Td(W,k),W.forEach((z,H)=>S.set(H,z));continue}if(x)throw"extra message";yield yield Pr(f(X))}if(!x)throw"missing trailer"})}async function g(O){if(r.kind!=_e.ServerStreaming)throw"The fetch API does not support streaming request bodies";const y=await O[Symbol.asyncIterator]().next();if(y.done==!0)throw"missing request message";return yd(0,u(y.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,q1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:i,method:r,url:wd(n.baseUrl,i,r),init:{method:"POST",credentials:(c=n.credentials)!==null&&c!==void 0?c:"same-origin",redirect:"error",mode:"cors"},header:Qd(t,o,a),contextValues:h??bd(),message:l},next:async O=>{var y;const k=await((y=n.fetch)!==null&&y!==void 0?y:globalThis.fetch)(O.url,Object.assign(Object.assign({},O.init),{headers:O.header,signal:O.signal,body:await g(O.message)})),{foundStatus:$}=Pd(k.status,k.headers);if(!k.body)throw"missing response body";const A=new Headers;return Object.assign(Object.assign({},O),{header:k.headers,trailer:A,message:p(k.body,$,A,k.headers)})}})}}}var F=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(F||{});m.util.setEnumType(F,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var Rr=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(Rr||{});m.util.setEnumType(Rr,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const Ci=class Ci extends D{constructor(t){super();d(this,"root");d(this,"presences",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Ci().fromBinary(t,i)}static fromJson(t,i){return new Ci().fromJson(t,i)}static fromJsonString(t,i){return new Ci().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ci,t,i)}};d(Ci,"runtime",m),d(Ci,"typeName","yorkie.v1.Snapshot"),d(Ci,"fields",m.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:rt},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:_u}}]));let Oc=Ci;var yt;let Wn=(yt=class extends D{constructor(t){super();d(this,"documentKey","");d(this,"checkpoint");d(this,"snapshot",new Uint8Array(0));d(this,"changes",[]);d(this,"minSyncedTicket");d(this,"isRemoved",!1);d(this,"versionVector");m.util.initPartial(t,this)}static fromBinary(t,i){return new yt().fromBinary(t,i)}static fromJson(t,i){return new yt().fromJson(t,i)}static fromJsonString(t,i){return new yt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(yt,t,i)}},d(yt,"runtime",m),d(yt,"typeName","yorkie.v1.ChangePack"),d(yt,"fields",m.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Ym},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:_m,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:M},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:ih}])),yt);var bt;let _m=(bt=class extends D{constructor(t){super();d(this,"id");d(this,"message","");d(this,"operations",[]);d(this,"presenceChange");m.util.initPartial(t,this)}static fromBinary(t,i){return new bt().fromBinary(t,i)}static fromJson(t,i){return new bt().fromJson(t,i)}static fromJsonString(t,i){return new bt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(bt,t,i)}},d(bt,"runtime",m),d(bt,"typeName","yorkie.v1.Change"),d(bt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:th},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:zu,repeated:!0},{no:4,name:"presence_change",kind:"message",T:fo}])),bt);var St;let th=(St=class extends D{constructor(t){super();d(this,"clientSeq",0);d(this,"serverSeq",fe.zero);d(this,"lamport",fe.zero);d(this,"actorId",new Uint8Array(0));d(this,"versionVector");m.util.initPartial(t,this)}static fromBinary(t,i){return new St().fromBinary(t,i)}static fromJson(t,i){return new St().fromJson(t,i)}static fromJsonString(t,i){return new St().fromJsonString(t,i)}static equals(t,i){return m.util.equals(St,t,i)}},d(St,"runtime",m),d(St,"typeName","yorkie.v1.ChangeID"),d(St,"fields",m.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:ih}])),St);var wt;let ih=(wt=class extends D{constructor(t){super();d(this,"vector",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new wt().fromBinary(t,i)}static fromJson(t,i){return new wt().fromJson(t,i)}static fromJsonString(t,i){return new wt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(wt,t,i)}},d(wt,"runtime",m),d(wt,"typeName","yorkie.v1.VersionVector"),d(wt,"fields",m.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),wt);var vt;let zu=(vt=class extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new vt().fromBinary(t,i)}static fromJson(t,i){return new vt().fromJson(t,i)}static fromJsonString(t,i){return new vt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(vt,t,i)}},d(vt,"runtime",m),d(vt,"typeName","yorkie.v1.Operation"),d(vt,"fields",m.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:nl,oneof:"body"},{no:2,name:"add",kind:"message",T:rl,oneof:"body"},{no:3,name:"move",kind:"message",T:sl,oneof:"body"},{no:4,name:"remove",kind:"message",T:ol,oneof:"body"},{no:5,name:"edit",kind:"message",T:al,oneof:"body"},{no:6,name:"select",kind:"message",T:yc,oneof:"body"},{no:7,name:"style",kind:"message",T:ll,oneof:"body"},{no:8,name:"increase",kind:"message",T:hl,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:cl,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ul,oneof:"body"},{no:11,name:"array_set",kind:"message",T:bc,oneof:"body"}])),vt);const Ii=class Ii extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"key","");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ii().fromBinary(t,i)}static fromJson(t,i){return new Ii().fromJson(t,i)}static fromJsonString(t,i){return new Ii().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ii,t,i)}};d(Ii,"runtime",m),d(Ii,"typeName","yorkie.v1.Operation.Set"),d(Ii,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let nl=Ii;const Ri=class Ri extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"prevCreatedAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ri().fromBinary(t,i)}static fromJson(t,i){return new Ri().fromJson(t,i)}static fromJsonString(t,i){return new Ri().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ri,t,i)}};d(Ri,"runtime",m),d(Ri,"typeName","yorkie.v1.Operation.Add"),d(Ri,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"prev_created_at",kind:"message",T:M},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let rl=Ri;const Ei=class Ei extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"prevCreatedAt");d(this,"createdAt");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ei().fromBinary(t,i)}static fromJson(t,i){return new Ei().fromJson(t,i)}static fromJsonString(t,i){return new Ei().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ei,t,i)}};d(Ei,"runtime",m),d(Ei,"typeName","yorkie.v1.Operation.Move"),d(Ei,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"prev_created_at",kind:"message",T:M},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"executed_at",kind:"message",T:M}]));let sl=Ei;const Di=class Di extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"createdAt");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Di().fromBinary(t,i)}static fromJson(t,i){return new Di().fromJson(t,i)}static fromJsonString(t,i){return new Di().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Di,t,i)}};d(Di,"runtime",m),d(Di,"typeName","yorkie.v1.Operation.Remove"),d(Di,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"executed_at",kind:"message",T:M}]));let ol=Di;const Ni=class Ni extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"createdAtMapByActor",{});d(this,"content","");d(this,"executedAt");d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Ni().fromBinary(t,i)}static fromJson(t,i){return new Ni().fromJson(t,i)}static fromJsonString(t,i){return new Ni().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ni,t,i)}};d(Ni,"runtime",m),d(Ni,"typeName","yorkie.v1.Operation.Edit"),d(Ni,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:M},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let al=Ni;const Bi=class Bi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Bi().fromBinary(t,i)}static fromJson(t,i){return new Bi().fromJson(t,i)}static fromJsonString(t,i){return new Bi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Bi,t,i)}};d(Bi,"runtime",m),d(Bi,"typeName","yorkie.v1.Operation.Select"),d(Bi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"executed_at",kind:"message",T:M}]));let yc=Bi;const qi=class qi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"attributes",{});d(this,"executedAt");d(this,"createdAtMapByActor",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new qi().fromBinary(t,i)}static fromJson(t,i){return new qi().fromJson(t,i)}static fromJsonString(t,i){return new qi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(qi,t,i)}};d(qi,"runtime",m),d(qi,"typeName","yorkie.v1.Operation.Style"),d(qi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:M},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}}]));let ll=qi;const Mi=class Mi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Mi().fromBinary(t,i)}static fromJson(t,i){return new Mi().fromJson(t,i)}static fromJsonString(t,i){return new Mi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Mi,t,i)}};d(Mi,"runtime",m),d(Mi,"typeName","yorkie.v1.Operation.Increase"),d(Mi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"value",kind:"message",T:mt},{no:3,name:"executed_at",kind:"message",T:M}]));let hl=Mi;const Vi=class Vi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"createdAtMapByActor",{});d(this,"contents",[]);d(this,"splitLevel",0);d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Vi().fromBinary(t,i)}static fromJson(t,i){return new Vi().fromJson(t,i)}static fromJsonString(t,i){return new Vi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Vi,t,i)}};d(Vi,"runtime",m),d(Vi,"typeName","yorkie.v1.Operation.TreeEdit"),d(Vi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Er},{no:3,name:"to",kind:"message",T:Er},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}},{no:5,name:"contents",kind:"message",T:bl,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:M}]));let cl=Vi;const Li=class Li extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"attributes",{});d(this,"executedAt");d(this,"attributesToRemove",[]);d(this,"createdAtMapByActor",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Li().fromBinary(t,i)}static fromJson(t,i){return new Li().fromJson(t,i)}static fromJsonString(t,i){return new Li().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Li,t,i)}};d(Li,"runtime",m),d(Li,"typeName","yorkie.v1.Operation.TreeStyle"),d(Li,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Er},{no:3,name:"to",kind:"message",T:Er},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:M},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}}]));let ul=Li;const Xi=class Xi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"createdAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Xi().fromBinary(t,i)}static fromJson(t,i){return new Xi().fromJson(t,i)}static fromJsonString(t,i){return new Xi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Xi,t,i)}};d(Xi,"runtime",m),d(Xi,"typeName","yorkie.v1.Operation.ArraySet"),d(Xi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let bc=Xi;const Ui=class Ui extends D{constructor(t){super();d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");d(this,"type",0);d(this,"value",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new Ui().fromBinary(t,i)}static fromJson(t,i){return new Ui().fromJson(t,i)}static fromJsonString(t,i){return new Ui().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ui,t,i)}};d(Ui,"runtime",m),d(Ui,"typeName","yorkie.v1.JSONElementSimple"),d(Ui,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"moved_at",kind:"message",T:M},{no:3,name:"removed_at",kind:"message",T:M},{no:4,name:"type",kind:"enum",T:m.getEnumType(F)},{no:5,name:"value",kind:"scalar",T:12}]));let mt=Ui;const Zi=class Zi extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new Zi().fromBinary(t,i)}static fromJson(t,i){return new Zi().fromJson(t,i)}static fromJsonString(t,i){return new Zi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Zi,t,i)}};d(Zi,"runtime",m),d(Zi,"typeName","yorkie.v1.JSONElement"),d(Zi,"fields",m.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:fl,oneof:"body"},{no:2,name:"json_array",kind:"message",T:dl,oneof:"body"},{no:3,name:"primitive",kind:"message",T:pl,oneof:"body"},{no:5,name:"text",kind:"message",T:gl,oneof:"body"},{no:6,name:"counter",kind:"message",T:ml,oneof:"body"},{no:7,name:"tree",kind:"message",T:Ol,oneof:"body"}]));let rt=Zi;const Wi=class Wi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Wi().fromBinary(t,i)}static fromJson(t,i){return new Wi().fromJson(t,i)}static fromJsonString(t,i){return new Wi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Wi,t,i)}};d(Wi,"runtime",m),d(Wi,"typeName","yorkie.v1.JSONElement.JSONObject"),d(Wi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Gm,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let fl=Wi;const ji=class ji extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new ji().fromBinary(t,i)}static fromJson(t,i){return new ji().fromJson(t,i)}static fromJsonString(t,i){return new ji().fromJsonString(t,i)}static equals(t,i){return m.util.equals(ji,t,i)}};d(ji,"runtime",m),d(ji,"typeName","yorkie.v1.JSONElement.JSONArray"),d(ji,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yl,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let dl=ji;const zi=class zi extends D{constructor(t){super();d(this,"type",0);d(this,"value",new Uint8Array(0));d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new zi().fromBinary(t,i)}static fromJson(t,i){return new zi().fromJson(t,i)}static fromJsonString(t,i){return new zi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(zi,t,i)}};d(zi,"runtime",m),d(zi,"typeName","yorkie.v1.JSONElement.Primitive"),d(zi,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(F)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"moved_at",kind:"message",T:M},{no:5,name:"removed_at",kind:"message",T:M}]));let pl=zi;const Fi=class Fi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Fi().fromBinary(t,i)}static fromJson(t,i){return new Fi().fromJson(t,i)}static fromJsonString(t,i){return new Fi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Fi,t,i)}};d(Fi,"runtime",m),d(Fi,"typeName","yorkie.v1.JSONElement.Text"),d(Fi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Jm,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let gl=Fi;const _i=class _i extends D{constructor(t){super();d(this,"type",0);d(this,"value",new Uint8Array(0));d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new _i().fromBinary(t,i)}static fromJson(t,i){return new _i().fromJson(t,i)}static fromJsonString(t,i){return new _i().fromJsonString(t,i)}static equals(t,i){return m.util.equals(_i,t,i)}};d(_i,"runtime",m),d(_i,"typeName","yorkie.v1.JSONElement.Counter"),d(_i,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(F)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"moved_at",kind:"message",T:M},{no:5,name:"removed_at",kind:"message",T:M}]));let ml=_i;const Gi=class Gi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Gi().fromBinary(t,i)}static fromJson(t,i){return new Gi().fromJson(t,i)}static fromJsonString(t,i){return new Gi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Gi,t,i)}};d(Gi,"runtime",m),d(Gi,"typeName","yorkie.v1.JSONElement.Tree"),d(Gi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Fu,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let Ol=Gi;var kt;let Gm=(kt=class extends D{constructor(t){super();d(this,"key","");d(this,"element");m.util.initPartial(t,this)}static fromBinary(t,i){return new kt().fromBinary(t,i)}static fromJson(t,i){return new kt().fromJson(t,i)}static fromJsonString(t,i){return new kt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(kt,t,i)}},d(kt,"runtime",m),d(kt,"typeName","yorkie.v1.RHTNode"),d(kt,"fields",m.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:rt}])),kt);const li=class li extends D{constructor(t){super();d(this,"next");d(this,"element");m.util.initPartial(t,this)}static fromBinary(t,i){return new li().fromBinary(t,i)}static fromJson(t,i){return new li().fromJson(t,i)}static fromJsonString(t,i){return new li().fromJsonString(t,i)}static equals(t,i){return m.util.equals(li,t,i)}};d(li,"runtime",m),d(li,"typeName","yorkie.v1.RGANode"),d(li,"fields",m.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:li},{no:2,name:"element",kind:"message",T:rt}]));let yl=li;const Ji=class Ji extends D{constructor(t){super();d(this,"value","");d(this,"updatedAt");d(this,"isRemoved",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new Ji().fromBinary(t,i)}static fromJson(t,i){return new Ji().fromJson(t,i)}static fromJsonString(t,i){return new Ji().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ji,t,i)}};d(Ji,"runtime",m),d(Ji,"typeName","yorkie.v1.NodeAttr"),d(Ji,"fields",m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:M},{no:3,name:"is_removed",kind:"scalar",T:8}]));let us=Ji;var xt;let Jm=(xt=class extends D{constructor(t){super();d(this,"id");d(this,"value","");d(this,"removedAt");d(this,"insPrevId");d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new xt().fromBinary(t,i)}static fromJson(t,i){return new xt().fromJson(t,i)}static fromJsonString(t,i){return new xt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(xt,t,i)}},d(xt,"runtime",m),d(xt,"typeName","yorkie.v1.TextNode"),d(xt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:uo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:M},{no:4,name:"ins_prev_id",kind:"message",T:uo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:us}}])),xt);const Yi=class Yi extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Yi().fromBinary(t,i)}static fromJson(t,i){return new Yi().fromJson(t,i)}static fromJsonString(t,i){return new Yi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Yi,t,i)}};d(Yi,"runtime",m),d(Yi,"typeName","yorkie.v1.TextNodeID"),d(Yi,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5}]));let uo=Yi;var Tt;let Fu=(Tt=class extends D{constructor(t){super();d(this,"id");d(this,"type","");d(this,"value","");d(this,"removedAt");d(this,"insPrevId");d(this,"insNextId");d(this,"depth",0);d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Tt().fromBinary(t,i)}static fromJson(t,i){return new Tt().fromJson(t,i)}static fromJsonString(t,i){return new Tt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Tt,t,i)}},d(Tt,"runtime",m),d(Tt,"typeName","yorkie.v1.TreeNode"),d(Tt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:nr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:M},{no:5,name:"ins_prev_id",kind:"message",T:nr},{no:6,name:"ins_next_id",kind:"message",T:nr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:us}}])),Tt);const Hi=class Hi extends D{constructor(t){super();d(this,"content",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new Hi().fromBinary(t,i)}static fromJson(t,i){return new Hi().fromJson(t,i)}static fromJsonString(t,i){return new Hi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Hi,t,i)}};d(Hi,"runtime",m),d(Hi,"typeName","yorkie.v1.TreeNodes"),d(Hi,"fields",m.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:Fu,repeated:!0}]));let bl=Hi;const Ki=class Ki extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Ki().fromBinary(t,i)}static fromJson(t,i){return new Ki().fromJson(t,i)}static fromJsonString(t,i){return new Ki().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ki,t,i)}};d(Ki,"runtime",m),d(Ki,"typeName","yorkie.v1.TreeNodeID"),d(Ki,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5}]));let nr=Ki;const en=class en extends D{constructor(t){super();d(this,"parentId");d(this,"leftSiblingId");m.util.initPartial(t,this)}static fromBinary(t,i){return new en().fromBinary(t,i)}static fromJson(t,i){return new en().fromJson(t,i)}static fromJsonString(t,i){return new en().fromJsonString(t,i)}static equals(t,i){return m.util.equals(en,t,i)}};d(en,"runtime",m),d(en,"typeName","yorkie.v1.TreePos"),d(en,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:nr},{no:2,name:"left_sibling_id",kind:"message",T:nr}]));let Er=en;const tn=class tn extends D{constructor(t){super();d(this,"id","");d(this,"username","");d(this,"createdAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new tn().fromBinary(t,i)}static fromJson(t,i){return new tn().fromJson(t,i)}static fromJsonString(t,i){return new tn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(tn,t,i)}};d(tn,"runtime",m),d(tn,"typeName","yorkie.v1.User"),d(tn,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Ze}]));let Ad=tn;const nn=class nn extends D{constructor(t){super();d(this,"id","");d(this,"name","");d(this,"publicKey","");d(this,"secretKey","");d(this,"authWebhookUrl","");d(this,"authWebhookMethods",[]);d(this,"clientDeactivateThreshold","");d(this,"createdAt");d(this,"updatedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new nn().fromBinary(t,i)}static fromJson(t,i){return new nn().fromJson(t,i)}static fromJsonString(t,i){return new nn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(nn,t,i)}};d(nn,"runtime",m),d(nn,"typeName","yorkie.v1.Project"),d(nn,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Ze},{no:9,name:"updated_at",kind:"message",T:Ze}]));let $d=nn;const rn=class rn extends D{constructor(t){super();d(this,"name");d(this,"authWebhookUrl");d(this,"authWebhookMethods");d(this,"clientDeactivateThreshold");m.util.initPartial(t,this)}static fromBinary(t,i){return new rn().fromBinary(t,i)}static fromJson(t,i){return new rn().fromJson(t,i)}static fromJsonString(t,i){return new rn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(rn,t,i)}};d(rn,"runtime",m),d(rn,"typeName","yorkie.v1.UpdatableProjectFields"),d(rn,"fields",m.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:ct},{no:2,name:"auth_webhook_url",kind:"message",T:ct},{no:3,name:"auth_webhook_methods",kind:"message",T:Sc},{no:4,name:"client_deactivate_threshold",kind:"message",T:ct}]));let Cd=rn;const sn=class sn extends D{constructor(t){super();d(this,"methods",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new sn().fromBinary(t,i)}static fromJson(t,i){return new sn().fromJson(t,i)}static fromJsonString(t,i){return new sn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(sn,t,i)}};d(sn,"runtime",m),d(sn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),d(sn,"fields",m.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Sc=sn;const on=class on extends D{constructor(t){super();d(this,"id","");d(this,"key","");d(this,"snapshot","");d(this,"createdAt");d(this,"accessedAt");d(this,"updatedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new on().fromBinary(t,i)}static fromJson(t,i){return new on().fromJson(t,i)}static fromJsonString(t,i){return new on().fromJsonString(t,i)}static equals(t,i){return m.util.equals(on,t,i)}};d(on,"runtime",m),d(on,"typeName","yorkie.v1.DocumentSummary"),d(on,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Ze},{no:5,name:"accessed_at",kind:"message",T:Ze},{no:6,name:"updated_at",kind:"message",T:Ze}]));let Id=on;const an=class an extends D{constructor(t){super();d(this,"type",0);d(this,"presence");m.util.initPartial(t,this)}static fromBinary(t,i){return new an().fromBinary(t,i)}static fromJson(t,i){return new an().fromJson(t,i)}static fromJsonString(t,i){return new an().fromJsonString(t,i)}static equals(t,i){return m.util.equals(an,t,i)}};d(an,"runtime",m),d(an,"typeName","yorkie.v1.PresenceChange"),d(an,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(Dr)},{no:2,name:"presence",kind:"message",T:_u}]));let fo=an;var Dr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Dr||{});m.util.setEnumType(Dr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var Qt;let _u=(Qt=class extends D{constructor(t){super();d(this,"data",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Qt().fromBinary(t,i)}static fromJson(t,i){return new Qt().fromJson(t,i)}static fromJsonString(t,i){return new Qt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Qt,t,i)}},d(Qt,"runtime",m),d(Qt,"typeName","yorkie.v1.Presence"),d(Qt,"fields",m.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),Qt);var Pt;let Ym=(Pt=class extends D{constructor(t){super();d(this,"serverSeq",fe.zero);d(this,"clientSeq",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Pt().fromBinary(t,i)}static fromJson(t,i){return new Pt().fromJson(t,i)}static fromJsonString(t,i){return new Pt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Pt,t,i)}},d(Pt,"runtime",m),d(Pt,"typeName","yorkie.v1.Checkpoint"),d(Pt,"fields",m.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),Pt);const ln=class ln extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);d(this,"relativeOffset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new ln().fromBinary(t,i)}static fromJson(t,i){return new ln().fromJson(t,i)}static fromJsonString(t,i){return new ln().fromJsonString(t,i)}static equals(t,i){return m.util.equals(ln,t,i)}};d(ln,"runtime",m),d(ln,"typeName","yorkie.v1.TextNodePos"),d(ln,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Mn=ln;var At;let M=(At=class extends D{constructor(t){super();d(this,"lamport",fe.zero);d(this,"delimiter",0);d(this,"actorId",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new At().fromBinary(t,i)}static fromJson(t,i){return new At().fromJson(t,i)}static fromJsonString(t,i){return new At().fromJsonString(t,i)}static equals(t,i){return m.util.equals(At,t,i)}},d(At,"runtime",m),d(At,"typeName","yorkie.v1.TimeTicket"),d(At,"fields",m.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),At);const hn=class hn extends D{constructor(t){super();d(this,"topic","");d(this,"payload",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new hn().fromBinary(t,i)}static fromJson(t,i){return new hn().fromJson(t,i)}static fromJsonString(t,i){return new hn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(hn,t,i)}};d(hn,"runtime",m),d(hn,"typeName","yorkie.v1.DocEventBody"),d(hn,"fields",m.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let wc=hn;const cn=class cn extends D{constructor(t){super();d(this,"type",0);d(this,"publisher","");d(this,"body");m.util.initPartial(t,this)}static fromBinary(t,i){return new cn().fromBinary(t,i)}static fromJson(t,i){return new cn().fromJson(t,i)}static fromJsonString(t,i){return new cn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(cn,t,i)}};d(cn,"runtime",m),d(cn,"typeName","yorkie.v1.DocEvent"),d(cn,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(Rr)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:wc}]));let vc=cn;const un=class un extends D{constructor(t){super();d(this,"clientKey","");m.util.initPartial(t,this)}static fromBinary(t,i){return new un().fromBinary(t,i)}static fromJson(t,i){return new un().fromJson(t,i)}static fromJsonString(t,i){return new un().fromJsonString(t,i)}static equals(t,i){return m.util.equals(un,t,i)}};d(un,"runtime",m),d(un,"typeName","yorkie.v1.ActivateClientRequest"),d(un,"fields",m.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let kc=un;const fn=class fn extends D{constructor(t){super();d(this,"clientId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new fn().fromBinary(t,i)}static fromJson(t,i){return new fn().fromJson(t,i)}static fromJsonString(t,i){return new fn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(fn,t,i)}};d(fn,"runtime",m),d(fn,"typeName","yorkie.v1.ActivateClientResponse"),d(fn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let xc=fn;const dn=class dn extends D{constructor(t){super();d(this,"clientId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new dn().fromBinary(t,i)}static fromJson(t,i){return new dn().fromJson(t,i)}static fromJsonString(t,i){return new dn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(dn,t,i)}};d(dn,"runtime",m),d(dn,"typeName","yorkie.v1.DeactivateClientRequest"),d(dn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Tc=dn;const pn=class pn extends D{constructor(e){super(),m.util.initPartial(e,this)}static fromBinary(e,t){return new pn().fromBinary(e,t)}static fromJson(e,t){return new pn().fromJson(e,t)}static fromJsonString(e,t){return new pn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(pn,e,t)}};d(pn,"runtime",m),d(pn,"typeName","yorkie.v1.DeactivateClientResponse"),d(pn,"fields",m.util.newFieldList(()=>[]));let Qc=pn;const gn=class gn extends D{constructor(t){super();d(this,"clientId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new gn().fromBinary(t,i)}static fromJson(t,i){return new gn().fromJson(t,i)}static fromJsonString(t,i){return new gn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(gn,t,i)}};d(gn,"runtime",m),d(gn,"typeName","yorkie.v1.AttachDocumentRequest"),d(gn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Wn}]));let Pc=gn;const mn=class mn extends D{constructor(t){super();d(this,"documentId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new mn().fromBinary(t,i)}static fromJson(t,i){return new mn().fromJson(t,i)}static fromJsonString(t,i){return new mn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(mn,t,i)}};d(mn,"runtime",m),d(mn,"typeName","yorkie.v1.AttachDocumentResponse"),d(mn,"fields",m.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Wn}]));let Ac=mn;const On=class On extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");d(this,"removeIfNotAttached",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new On().fromBinary(t,i)}static fromJson(t,i){return new On().fromJson(t,i)}static fromJsonString(t,i){return new On().fromJsonString(t,i)}static equals(t,i){return m.util.equals(On,t,i)}};d(On,"runtime",m),d(On,"typeName","yorkie.v1.DetachDocumentRequest"),d(On,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let $c=On;const yn=class yn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new yn().fromBinary(t,i)}static fromJson(t,i){return new yn().fromJson(t,i)}static fromJsonString(t,i){return new yn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(yn,t,i)}};d(yn,"runtime",m),d(yn,"typeName","yorkie.v1.DetachDocumentResponse"),d(yn,"fields",m.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Wn}]));let Cc=yn;const bn=class bn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new bn().fromBinary(t,i)}static fromJson(t,i){return new bn().fromJson(t,i)}static fromJsonString(t,i){return new bn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(bn,t,i)}};d(bn,"runtime",m),d(bn,"typeName","yorkie.v1.WatchDocumentRequest"),d(bn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Ic=bn;const Sn=class Sn extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new Sn().fromBinary(t,i)}static fromJson(t,i){return new Sn().fromJson(t,i)}static fromJsonString(t,i){return new Sn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Sn,t,i)}};d(Sn,"runtime",m),d(Sn,"typeName","yorkie.v1.WatchDocumentResponse"),d(Sn,"fields",m.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Ec,oneof:"body"},{no:2,name:"event",kind:"message",T:vc,oneof:"body"}]));let Rc=Sn;const wn=class wn extends D{constructor(t){super();d(this,"clientIds",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new wn().fromBinary(t,i)}static fromJson(t,i){return new wn().fromJson(t,i)}static fromJsonString(t,i){return new wn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(wn,t,i)}};d(wn,"runtime",m),d(wn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),d(wn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Ec=wn;const vn=class vn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new vn().fromBinary(t,i)}static fromJson(t,i){return new vn().fromJson(t,i)}static fromJsonString(t,i){return new vn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(vn,t,i)}};d(vn,"runtime",m),d(vn,"typeName","yorkie.v1.RemoveDocumentRequest"),d(vn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn}]));let Dc=vn;const kn=class kn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new kn().fromBinary(t,i)}static fromJson(t,i){return new kn().fromJson(t,i)}static fromJsonString(t,i){return new kn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(kn,t,i)}};d(kn,"runtime",m),d(kn,"typeName","yorkie.v1.RemoveDocumentResponse"),d(kn,"fields",m.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Wn}]));let Nc=kn;const xn=class xn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");d(this,"pushOnly",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new xn().fromBinary(t,i)}static fromJson(t,i){return new xn().fromJson(t,i)}static fromJsonString(t,i){return new xn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(xn,t,i)}};d(xn,"runtime",m),d(xn,"typeName","yorkie.v1.PushPullChangesRequest"),d(xn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn},{no:4,name:"push_only",kind:"scalar",T:8}]));let Bc=xn;const Tn=class Tn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new Tn().fromBinary(t,i)}static fromJson(t,i){return new Tn().fromJson(t,i)}static fromJsonString(t,i){return new Tn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Tn,t,i)}};d(Tn,"runtime",m),d(Tn,"typeName","yorkie.v1.PushPullChangesResponse"),d(Tn,"fields",m.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Wn}]));let qc=Tn;const Qn=class Qn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"topic","");d(this,"payload",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new Qn().fromBinary(t,i)}static fromJson(t,i){return new Qn().fromJson(t,i)}static fromJsonString(t,i){return new Qn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Qn,t,i)}};d(Qn,"runtime",m),d(Qn,"typeName","yorkie.v1.BroadcastRequest"),d(Qn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Mc=Qn;const Pn=class Pn extends D{constructor(e){super(),m.util.initPartial(e,this)}static fromBinary(e,t){return new Pn().fromBinary(e,t)}static fromJson(e,t){return new Pn().fromJson(e,t)}static fromJsonString(e,t){return new Pn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Pn,e,t)}};d(Pn,"runtime",m),d(Pn,"typeName","yorkie.v1.BroadcastResponse"),d(Pn,"fields",m.util.newFieldList(()=>[]));let Vc=Pn;const U1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:kc,O:xc,kind:_e.Unary},deactivateClient:{name:"DeactivateClient",I:Tc,O:Qc,kind:_e.Unary},attachDocument:{name:"AttachDocument",I:Pc,O:Ac,kind:_e.Unary},detachDocument:{name:"DetachDocument",I:$c,O:Cc,kind:_e.Unary},removeDocument:{name:"RemoveDocument",I:Dc,O:Nc,kind:_e.Unary},pushPullChanges:{name:"PushPullChanges",I:Bc,O:qc,kind:_e.Unary},watchDocument:{name:"WatchDocument",I:Ic,O:Rc,kind:_e.ServerStreaming},broadcast:{name:"Broadcast",I:Mc,O:Vc,kind:_e.Unary}}},Z1=m.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);m.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:In}]);m.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:W1,repeated:!0}]);const W1=m.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});m.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:j1,repeated:!0}]);const j1=m.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});m.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:z1,repeated:!0}]);const z1=m.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});m.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=m.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});m.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var w=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(w||{});class v extends Error{constructor(t,i){super(i);d(this,"name","YorkieError");d(this,"stack");this.code=t,this.message=i,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Wt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const Hm=n=>n?Object.entries(n).length===0:!0,fs=n=>{const e={};for(const[t,i]of Object.entries(n))e[t]=JSON.stringify(i);return e},ts=n=>{const e={};for(const[t,i]of Object.entries(n))e[t]=JSON.parse(i);return e};var cr=(n=>(n.Put="put",n.Clear="clear",n))(cr||{});class $h{constructor(e,t){d(this,"context");d(this,"presence");this.context=e,this.presence=t}set(e,t){for(const i of Object.keys(e))this.presence[i]=e[i];this.context.setPresenceChange({type:"put",presence:Wt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Gu="000000000000000000000000";class Dt{constructor(e,t,i){d(this,"lamport");d(this,"delimiter");d(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=i}static of(e,t,i){return new Dt(e,t,i)}static fromStruct(e){return Dt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new Dt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const Km=0,Ks=9223372036854775807n,Gt=new Dt(0n,Km,Gu);function wi(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` +var bS=Object.defineProperty;var SS=(n,e,t)=>e in n?bS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>SS(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();var ne;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(ne||(ne={}));function td(n){const e=ne[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class ue extends Error{constructor(e,t=ne.Unknown,i,r,s){super(wS(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(i??{}),this.details=r??[],this.cause=s}static from(e,t=ne.Unknown){return e instanceof ue?e:e instanceof Error?e.name=="AbortError"?new ue(e.message,ne.Canceled):new ue(e.message,t,void 0,void 0,e):new ue(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===ue.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,i=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&i.push(r);continue}const s=t.findMessage(r.type);if(s)try{i.push(s.fromBinary(r.value))}catch{}}return i}}function wS(n,e){return n.length?`[${td(e)}] ${n}`:`[${td(e)}]`}function be(n,e){if(!n)throw new Error(e)}const vS=34028234663852886e22,kS=-34028234663852886e22,xS=4294967295,TS=2147483647,QS=-2147483648;function Da(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>TS||nxS||n<0)throw new Error("invalid uint 32: "+n)}function vm(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>vS||n({no:r.no,name:r.name,localName:n[r.no]})))}function Tm(n,e,t){const i=Object.create(null),r=Object.create(null),s=[];for(const o of e){const a=Qm(o);s.push(a),i[o.name]=a,r[o.no]=a}return{typeName:n,values:s,findName(o){return i[o]},findNumber(o){return r[o]}}}function AS(n,e,t){const i={};for(const r of e){const s=Qm(r);i[s.localName]=s.no,i[s.no]=s.localName}return xm(i,n,e),i}function Qm(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class D{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const i=this.getType(),r=i.runtime.bin,s=r.makeReadOptions(t);return r.readMessage(this,s.readerFactory(e),e.byteLength,s),this}fromJson(e,t){const i=this.getType(),r=i.runtime.json,s=r.makeReadOptions(t);return r.readMessage(i,e,s,this),this}fromJsonString(e,t){let i;try{i=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(i,t)}toBinary(e){const t=this.getType(),i=t.runtime.bin,r=i.makeWriteOptions(e),s=r.writerFactory();return i.writeMessage(this,s,r),s.finish()}toJson(e){const t=this.getType(),i=t.runtime.json,r=i.makeWriteOptions(e);return i.writeMessage(this,r)}toJsonString(e){var t;const i=this.toJson(e);return JSON.stringify(i,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function $S(n,e,t,i){var r;const s=(r=i==null?void 0:i.localName)!==null&&r!==void 0?r:e.substring(e.lastIndexOf(".")+1),o={[s]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[s];return Object.setPrototypeOf(o.prototype,new D),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,l){return new o().fromBinary(a,l)},fromJson(a,l){return new o().fromJson(a,l)},fromJsonString(a,l){return new o().fromJsonString(a,l)},equals(a,l){return n.util.equals(o,a,l)}}),o}function CS(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<>>s,a=!(!(o>>>7)&&e==0),l=(a?o|128:o)&255;if(t.push(l),!a)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),l=(a?o|128:o)&255;if(t.push(l),!a)return}t.push(e>>>31&1)}}const Na=4294967296;function id(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function s(o,a){const l=Number(n.slice(o,a));r*=t,i=i*t+l,i>=Na&&(r=r+(i/Na|0),i=i%Na)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Am(i,r):ju(i,r)}function IS(n,e){let t=ju(n,e);const i=t.hi&2147483648;i&&(t=Am(t.lo,t.hi));const r=Pm(t.lo,t.hi);return i?"-"+r:r}function Pm(n,e){if({lo:n,hi:e}=RS(n,e),e<=2097151)return String(Na*e+n);const t=n&16777215,i=(n>>>24|e<<8)&16777215,r=e>>16&65535;let s=t+i*6777216+r*6710656,o=i+r*8147497,a=r*2;const l=1e7;return s>=l&&(o+=Math.floor(s/l),s%=l),o>=l&&(a+=Math.floor(o/l),o%=l),a.toString()+nd(o)+nd(s)}function RS(n,e){return{lo:n>>>0,hi:e>>>0}}function ju(n,e){return{lo:n|0,hi:e|0}}function Am(n,e){return e=~e,n?n=~n+1:e+=1,ju(n,e)}const nd=n=>{const e=String(n);return"0000000".slice(e.length)+e};function rd(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function ES(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var sd={};function DS(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof sd!="object"||sd.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),s=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(l){const h=typeof l=="bigint"?l:BigInt(l);if(h>s||ha||hbe(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),i=r=>be(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),t(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),i(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),t(r),id(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),i(r),id(r)},dec(r,s){return IS(r,s)},uDec(r,s){return Pm(r,s)}}}const fe=DS();var T;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(T||(T={}));var hr;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(hr||(hr={}));function zn(n,e,t){if(e===t)return!0;if(n==T.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let i=0;i>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Oc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Da(e),rd(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){vm(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Oc(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Da(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Da(e),e=(e<<1^e>>31)>>>0,rd(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=fe.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=fe.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=fe.enc(e);return Qh(t.lo,t.hi,this.buf),this}sint64(e){let t=fe.enc(e),i=t.hi>>31,r=t.lo<<1^i,s=(t.hi<<1|t.lo>>>31)^i;return Qh(r,s,this.buf),this}uint64(e){let t=fe.uEnc(e);return Qh(t.lo,t.hi,this.buf),this}}class BS{constructor(e,t){this.varint64=CS,this.uint32=ES,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e,t){let i=this.pos;switch(e){case xe.Varint:for(;this.buf[this.pos++]&128;);break;case xe.Bit64:this.pos+=4;case xe.Bit32:this.pos+=4;break;case xe.LengthDelimited:let r=this.uint32();this.pos+=r;break;case xe.StartGroup:for(;;){const[s,o]=this.tag();if(o===xe.EndGroup){if(t!==void 0&&s!==t)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return fe.dec(...this.varint64())}uint64(){return fe.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,fe.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return fe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return fe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function qS(n,e,t,i){let r;return{typeName:e,extendee:t,get field(){if(!r){const s=typeof i=="function"?i():i;s.name=e.split(".").pop(),s.jsonName=`[${e}]`,r=n.util.newFieldList([s]).list()[0]}return r},runtime:n}}function Cm(n){const e=n.field.localName,t=Object.create(null);return t[e]=MS(n),[t,()=>t[e]]}function MS(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return hs(e.T,e.L);case"message":const t=e.T,i=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(i):i;case"map":throw"map fields are not allowed to be extensions"}}function VS(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let Cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),eh=[];for(let n=0;n>4,o=s,r=2;break;case 2:t[i++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[i++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)},enc(n){let e="",t=0,i,r=0;for(let s=0;s>2],r=(i&3)<<4,t=1;break;case 1:e+=Cn[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=Cn[r|i>>6],e+=Cn[i&63],t=0;break}return t&&(e+=Cn[r],e+="=",t==1&&(e+="=")),e}};function LS(n,e,t){Rm(e,n);const i=e.runtime.bin.makeReadOptions(t),r=VS(n.getType().runtime.bin.listUnknownFields(n),e.field),[s,o]=Cm(e);for(const a of r)e.runtime.bin.readField(s,i.readerFactory(a.data),e.field,a.wireType,i);return o()}function XS(n,e,t,i){Rm(e,n);const r=e.runtime.bin.makeReadOptions(i),s=e.runtime.bin.makeWriteOptions(i);if(Im(n,e)){const h=n.getType().runtime.bin.listUnknownFields(n).filter(c=>c.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const c of h)n.getType().runtime.bin.onUnknownField(n,c.no,c.wireType,c.data)}const o=s.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,s);const l=r.readerFactory(o.finish());for(;l.posi.no==e.field.no)}function Rm(n,e){be(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Em(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!$m(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function od(n,e){const t=n.localName,i=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=i?n.T.values[0].no:void 0;break;case"scalar":e[t]=i?hs(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function Ir(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(D.prototype).every(i=>i in n&&typeof n[i]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Dm(n,e){return Ir(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}T.DOUBLE,T.FLOAT,T.INT64,T.UINT64,T.INT32,T.UINT32,T.BOOL,T.STRING,T.BYTES;const ad={ignoreUnknownFields:!1},ld={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function US(n){return n?Object.assign(Object.assign({},ad),n):ad}function ZS(n){return n?Object.assign(Object.assign({},ld),n):ld}const tl=Symbol(),Ba=Symbol();function WS(){return{makeReadOptions:US,makeWriteOptions:ZS,readMessage(n,e,t,i){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${hi(e)}`);i=i??new n;const r=new Map,s=t.typeRegistry;for(const[o,a]of Object.entries(e)){const l=n.fields.findJsonName(o);if(l){if(l.oneof){if(a===null&&l.kind=="scalar")continue;const h=r.get(l.oneof);if(h!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${h}", "${o}"`);r.set(l.oneof,o)}hd(i,a,l,t,n)}else{let h=!1;if(s!=null&&s.findExtension&&o.startsWith("[")&&o.endsWith("]")){const c=s.findExtension(o.substring(1,o.length-1));if(c&&c.extendee.typeName==n.typeName){h=!0;const[u,f]=Cm(c);hd(u,a,c.field,t,c),XS(i,c,f(),t)}}if(!h&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return i},writeMessage(n,e){const t=n.getType(),i={};let r;try{for(r of t.fields.byNumber()){if(!Em(r,n)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!zS(r))continue}const o=r.oneof?n[r.oneof.localName].value:n[r.localName],a=cd(r,o,e);a!==void 0&&(i[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=s.findExtensionFor(t.typeName,o.no);if(a&&Im(n,a)){const l=LS(n,a,e),h=cd(a.field,l,e);h!==void 0&&(i[a.field.jsonName]=h)}}}catch(s){const o=r?`cannot encode field ${t.typeName}.${r.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=s instanceof Error?s.message:String(s);throw new Error(o+(a.length>0?`: ${a}`:""))}return i},readScalar(n,e,t){return Ys(n,e,t??hr.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||$m(n,e)))return qa(n,e)},debug:hi}}function hi(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function hd(n,e,t,i,r){let s=t.localName;if(t.repeated){if(be(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`);const o=n[s];for(const a of e){if(a===null)throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,i));break;case"enum":const l=Ph(t.T,a,i.ignoreUnknownFields,!0);l!==Ba&&o.push(l);break;case"scalar":try{o.push(Ys(t.T,a,t.L,!0))}catch(h){let c=`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(a)}`;throw h instanceof Error&&h.message.length>0&&(c+=`: ${h.message}`),new Error(c)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`);const o=n[s];for(const[a,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${t.name} from JSON: map value null`);let h;try{h=jS(t.K,a)}catch(c){let u=`cannot decode map key for field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw c instanceof Error&&c.message.length>0&&(u+=`: ${c.message}`),new Error(u)}switch(t.V.kind){case"message":o[h]=t.V.T.fromJson(l,i);break;case"enum":const c=Ph(t.V.T,l,i.ignoreUnknownFields,!0);c!==Ba&&(o[h]=c);break;case"scalar":try{o[h]=Ys(t.V.T,l,hr.BIGINT,!0)}catch(u){let f=`cannot decode map value for field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw u instanceof Error&&u.message.length>0&&(f+=`: ${u.message}`),new Error(f)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:s},s="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[s];Ir(a)?a.fromJson(e,i):(n[s]=a=o.fromJson(e,i),o.fieldWrapper&&!t.oneof&&(n[s]=o.fieldWrapper.unwrapField(a)));break;case"enum":const l=Ph(t.T,e,i.ignoreUnknownFields,!1);switch(l){case tl:od(t,n);break;case Ba:break;default:n[s]=l;break}break;case"scalar":try{const h=Ys(t.T,e,t.L,!1);switch(h){case tl:od(t,n);break;default:n[s]=h;break}}catch(h){let c=`cannot decode field ${r.typeName}.${t.name} from JSON: ${hi(e)}`;throw h instanceof Error&&h.message.length>0&&(c+=`: ${h.message}`),new Error(c)}break}}function jS(n,e){if(n===T.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ys(n,e,hr.BIGINT,!0).toString()}function Ys(n,e,t,i){if(e===null)return i?hs(n,t):tl;switch(n){case T.DOUBLE:case T.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return n==T.FLOAT&&vm(r),r;case T.INT32:case T.FIXED32:case T.SFIXED32:case T.SINT32:case T.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return n==T.UINT32||n==T.FIXED32?Oc(s):Da(s),s;case T.INT64:case T.SFIXED64:case T.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=fe.parse(e);return t?o.toString():o;case T.FIXED64:case T.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=fe.uParse(e);return t?a.toString():a;case T.BOOL:if(typeof e!="boolean")break;return e;case T.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case T.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return zu.dec(e)}throw new Error}function Ph(n,e,t,i){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:i?n.values[0].no:tl;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=n.findName(e);if(r!==void 0)return r.no;if(t)return Ba;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${hi(e)}`)}function zS(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function cd(n,e,t){if(n.kind=="map"){be(typeof e=="object"&&e!=null);const i={},r=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of r)i[o.toString()]=qa(n.V.T,a);break;case"message":for(const[o,a]of r)i[o.toString()]=a.toJson(t);break;case"enum":const s=n.V.T;for(const[o,a]of r)i[o.toString()]=Ah(s,a,t.enumAsInteger);break}return t.emitDefaultValues||r.length>0?i:void 0}if(n.repeated){be(Array.isArray(e));const i=[];switch(n.kind){case"scalar":for(let r=0;r0?i:void 0}switch(n.kind){case"scalar":return qa(n.T,e);case"enum":return Ah(n.T,e,t.enumAsInteger);case"message":return Dm(n.T,e).toJson(t)}}function Ah(n,e,t){var i;if(be(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const r=n.findNumber(e);return(i=r==null?void 0:r.name)!==null&&i!==void 0?i:e}function qa(n,e){switch(n){case T.INT32:case T.SFIXED32:case T.SINT32:case T.FIXED32:case T.UINT32:return be(typeof e=="number"),e;case T.FLOAT:case T.DOUBLE:return be(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case T.STRING:return be(typeof e=="string"),e;case T.BOOL:return be(typeof e=="boolean"),e;case T.UINT64:case T.FIXED64:case T.INT64:case T.SFIXED64:case T.SINT64:return be(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case T.BYTES:return be(e instanceof Uint8Array),zu.enc(e)}}const Zr=Symbol("@bufbuild/protobuf/unknown-fields"),ud={readUnknownFields:!0,readerFactory:n=>new BS(n)},fd={writeUnknownFields:!0,writerFactory:()=>new NS};function FS(n){return n?Object.assign(Object.assign({},ud),n):ud}function _S(n){return n?Object.assign(Object.assign({},fd),n):fd}function GS(){return{makeReadOptions:FS,makeWriteOptions:_S,listUnknownFields(n){var e;return(e=n[Zr])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Zr]},writeUnknownFields(n,e){const i=n[Zr];if(i)for(const r of i)e.tag(r.no,r.wireType).raw(r.data)},onUnknownField(n,e,t,i){const r=n;Array.isArray(r[Zr])||(r[Zr]=[]),r[Zr].push({no:e,wireType:t,data:i})},readMessage(n,e,t,i,r){const s=n.getType(),o=r?e.len:e.pos+t;let a,l;for(;e.pos0&&(l=YS),s){let f=n[o];if(i==xe.LengthDelimited&&a!=T.STRING&&a!=T.BYTES){let g=e.uint32()+e.pos;for(;e.posIr(f,u)?f:new u(f));else{const f=o[r];u.fieldWrapper?u.typeName==="google.protobuf.BytesValue"?s[r]=Es(f):s[r]=f:s[r]=Ir(f,u)?f:new u(f)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(i=>{const r=e[i.localName],s=t[i.localName];if(i.repeated){if(r.length!==s.length)return!1;switch(i.kind){case"message":return r.every((o,a)=>i.T.equals(o,s[a]));case"scalar":return r.every((o,a)=>zn(i.T,o,s[a]));case"enum":return r.every((o,a)=>zn(T.INT32,o,s[a]))}throw new Error(`repeated cannot contain ${i.kind}`)}switch(i.kind){case"message":return i.T.equals(r,s);case"enum":return zn(T.INT32,r,s);case"scalar":return zn(i.T,r,s);case"oneof":if(r.case!==s.case)return!1;const o=i.findField(r.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(r.value,s.value);case"enum":return zn(T.INT32,r.value,s.value);case"scalar":return zn(o.T,r.value,s.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(r).concat(Object.keys(s));switch(i.V.kind){case"message":const l=i.V.T;return a.every(c=>l.equals(r[c],s[c]));case"enum":return a.every(c=>zn(T.INT32,r[c],s[c]));case"scalar":const h=i.V.T;return a.every(c=>zn(h,r[c],s[c]))}break}})},clone(n){const e=n.getType(),t=new e,i=t;for(const r of e.fields.byMember()){const s=n[r.localName];let o;if(r.repeated)o=s.map(ta);else if(r.kind=="map"){o=i[r.localName];for(const[a,l]of Object.entries(s))o[a]=ta(l)}else r.kind=="oneof"?o=r.findField(s.case)?{case:s.case,value:ta(s.value)}:{case:void 0}:o=ta(s);i[r.localName]=o}for(const r of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return t}}}function ta(n){if(n===void 0)return n;if(Ir(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Es(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function t1(n,e,t){return{syntax:n,json:WS(),bin:GS(),util:Object.assign(Object.assign({},e1()),{newFieldList:e,initFields:t}),makeMessageType(i,r,s){return $S(this,i,r,s)},makeEnum:AS,makeEnumType:Tm,getEnumType:PS,makeExtension(i,r,s){return qS(this,i,r,s)}}}class i1{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const i of this.list())t[i.jsonName]=t[i.name]=i;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const i of this.list())t[i.no]=i;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const i of this.list())i.oneof?i.oneof!==t&&(t=i.oneof,e.push(t)):e.push(i)}return this.members}}function Bm(n,e){const t=qm(n);return e?t:l1(a1(t))}function n1(n){return Bm(n,!1)}const r1=qm;function qm(n){let e=!1;const t=[];for(let i=0;i`${n}$`,a1=n=>o1.has(n)?Mm(n):n,l1=n=>s1.has(n)?Mm(n):n;class h1{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=n1(e)}addField(e){be(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew i1(n,e=>c1(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,i=n;if(e.repeated){i[t]=[];continue}switch(e.kind){case"oneof":i[t]={case:void 0};break;case"enum":i[t]=0;break;case"map":i[t]={};break;case"scalar":i[t]=hs(e.T,e.L);break}}});var _e;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(_e||(_e={}));var md;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(md||(md={}));class Ze extends D{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,m.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${m.json.debug(e)}`);const i=e.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]))$/);if(!i)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(i[1]+"-"+i[2]+"-"+i[3]+"T"+i[4]+":"+i[5]+":"+i[6]+(i[8]?i[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(rDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=fe.parse(r/1e3),this.nanos=0,i[7]&&(this.nanos=parseInt("1"+i[7]+"0".repeat(9-i[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let i="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?i="."+r.substring(0,3)+"Z":r.substring(6)==="000"?i="."+r.substring(0,6)+"Z":i="."+r+"Z"}return new Date(t).toISOString().replace(".000Z",i)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Ze.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ze({seconds:fe.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ze().fromBinary(e,t)}static fromJson(e,t){return new Ze().fromJson(e,t)}static fromJsonString(e,t){return new Ze().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Ze,e,t)}}Ze.runtime=m;Ze.typeName="google.protobuf.Timestamp";Ze.fields=m.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class In extends D{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,m.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);const i=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(i===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);const r=Number(i[1]);if(r>315576e6||r<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${m.json.debug(e)}`);if(this.seconds=fe.parse(r),typeof i[2]=="string"){const s=i[2]+"0".repeat(9-i[2].length);this.nanos=parseInt(s),(r<0||Object.is(r,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let i=Math.abs(this.nanos).toString();i="0".repeat(9-i.length)+i,i.substring(3)==="000000"?i=i.substring(0,3):i.substring(6)==="000"&&(i=i.substring(0,6)),t+="."+i,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new In().fromBinary(e,t)}static fromJson(e,t){return new In().fromJson(e,t)}static fromJsonString(e,t){return new In().fromJsonString(e,t)}static equals(e,t){return m.util.equals(In,e,t)}}In.runtime=m;In.typeName="google.protobuf.Duration";In.fields=m.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class ci extends D{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),m.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const i=this.typeUrlToName(this.typeUrl),r=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(i);if(!r)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=r.fromBinary(this.value).toJson(e);return(i.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var i;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const r=e["@type"];if(typeof r!="string"||r=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const s=this.typeUrlToName(r),o=(i=t==null?void 0:t.typeRegistry)===null||i===void 0?void 0:i.findMessage(s);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${r} is not in the type registry`);let a;if(s.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const l=Object.assign({},e);delete l["@type"],a=o.fromJson(l,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let i="";return typeof e=="string"?i=e:i=e.typeName,t===i}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),i=t>=0?e.substring(t+1):e;if(!i.length)throw new Error(`invalid type url: ${e}`);return i}static pack(e){const t=new ci;return t.packFrom(e),t}static fromBinary(e,t){return new ci().fromBinary(e,t)}static fromJson(e,t){return new ci().fromJson(e,t)}static fromJsonString(e,t){return new ci().fromJsonString(e,t)}static equals(e,t){return m.util.equals(ci,e,t)}}ci.runtime=m;ci.typeName="google.protobuf.Any";ci.fields=m.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class di extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.DOUBLE,e)}catch(i){let r='cannot decode message google.protobuf.DoubleValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new di().fromBinary(e,t)}static fromJson(e,t){return new di().fromJson(e,t)}static fromJsonString(e,t){return new di().fromJsonString(e,t)}static equals(e,t){return m.util.equals(di,e,t)}}di.runtime=m;di.typeName="google.protobuf.DoubleValue";di.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);di.fieldWrapper={wrapField(n){return new di({value:n})},unwrapField(n){return n.value}};class pi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.FLOAT,e)}catch(i){let r='cannot decode message google.protobuf.FloatValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new pi().fromBinary(e,t)}static fromJson(e,t){return new pi().fromJson(e,t)}static fromJsonString(e,t){return new pi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(pi,e,t)}}pi.runtime=m;pi.typeName="google.protobuf.FloatValue";pi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);pi.fieldWrapper={wrapField(n){return new pi({value:n})},unwrapField(n){return n.value}};class gi extends D{constructor(e){super(),this.value=fe.zero,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.INT64,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.INT64,e)}catch(i){let r='cannot decode message google.protobuf.Int64Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new gi().fromBinary(e,t)}static fromJson(e,t){return new gi().fromJson(e,t)}static fromJsonString(e,t){return new gi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(gi,e,t)}}gi.runtime=m;gi.typeName="google.protobuf.Int64Value";gi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);gi.fieldWrapper={wrapField(n){return new gi({value:n})},unwrapField(n){return n.value}};class mi extends D{constructor(e){super(),this.value=fe.zero,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.UINT64,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.UINT64,e)}catch(i){let r='cannot decode message google.protobuf.UInt64Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new mi().fromBinary(e,t)}static fromJson(e,t){return new mi().fromJson(e,t)}static fromJsonString(e,t){return new mi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(mi,e,t)}}mi.runtime=m;mi.typeName="google.protobuf.UInt64Value";mi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);mi.fieldWrapper={wrapField(n){return new mi({value:n})},unwrapField(n){return n.value}};class Oi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.INT32,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.INT32,e)}catch(i){let r='cannot decode message google.protobuf.Int32Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new Oi().fromBinary(e,t)}static fromJson(e,t){return new Oi().fromJson(e,t)}static fromJsonString(e,t){return new Oi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Oi,e,t)}}Oi.runtime=m;Oi.typeName="google.protobuf.Int32Value";Oi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Oi.fieldWrapper={wrapField(n){return new Oi({value:n})},unwrapField(n){return n.value}};class yi extends D{constructor(e){super(),this.value=0,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.UINT32,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.UINT32,e)}catch(i){let r='cannot decode message google.protobuf.UInt32Value from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new yi().fromBinary(e,t)}static fromJson(e,t){return new yi().fromJson(e,t)}static fromJsonString(e,t){return new yi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(yi,e,t)}}yi.runtime=m;yi.typeName="google.protobuf.UInt32Value";yi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);yi.fieldWrapper={wrapField(n){return new yi({value:n})},unwrapField(n){return n.value}};class bi extends D{constructor(e){super(),this.value=!1,m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.BOOL,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.BOOL,e)}catch(i){let r='cannot decode message google.protobuf.BoolValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new bi().fromBinary(e,t)}static fromJson(e,t){return new bi().fromJson(e,t)}static fromJsonString(e,t){return new bi().fromJsonString(e,t)}static equals(e,t){return m.util.equals(bi,e,t)}}bi.runtime=m;bi.typeName="google.protobuf.BoolValue";bi.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);bi.fieldWrapper={wrapField(n){return new bi({value:n})},unwrapField(n){return n.value}};class ct extends D{constructor(e){super(),this.value="",m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.STRING,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.STRING,e)}catch(i){let r='cannot decode message google.protobuf.StringValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new ct().fromBinary(e,t)}static fromJson(e,t){return new ct().fromJson(e,t)}static fromJsonString(e,t){return new ct().fromJsonString(e,t)}static equals(e,t){return m.util.equals(ct,e,t)}}ct.runtime=m;ct.typeName="google.protobuf.StringValue";ct.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);ct.fieldWrapper={wrapField(n){return new ct({value:n})},unwrapField(n){return n.value}};class Si extends D{constructor(e){super(),this.value=new Uint8Array(0),m.util.initPartial(e,this)}toJson(e){return m.json.writeScalar(T.BYTES,this.value,!0)}fromJson(e,t){try{this.value=m.json.readScalar(T.BYTES,e)}catch(i){let r='cannot decode message google.protobuf.BytesValue from JSON"';throw i instanceof Error&&i.message.length>0&&(r+=`: ${i.message}`),new Error(r)}return this}static fromBinary(e,t){return new Si().fromBinary(e,t)}static fromJson(e,t){return new Si().fromJson(e,t)}static fromJsonString(e,t){return new Si().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Si,e,t)}}Si.runtime=m;Si.typeName="google.protobuf.BytesValue";Si.fields=m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);Si.fieldWrapper={wrapField(n){return new Si({value:n})},unwrapField(n){return n.value}};function u1(n,e,t){try{const i=zu.dec(n);return e?e.fromBinary(i,t):i}catch(i){throw ue.from(i,ne.DataLoss)}}function f1(n,e){const t={};for(const[i,r]of Object.entries(n.methods)){const s=e(Object.assign(Object.assign({},r),{localName:i,service:n}));s!=null&&(t[i]=s)}return t}function Od(n){let e,t=new Uint8Array(0);function i(r){const s=new Uint8Array(t.length+r.length);s.set(t),s.set(r,t.length),t=s}return new ReadableStream({start(){e=n.getReader()},async pull(r){let s;for(;;){if(s===void 0&&t.byteLength>=5){let l=0;for(let h=1;h<5;h++)l=(l<<8)+t[h];s={flags:t[0],length:l}}if(s!==void 0&&t.byteLength>=s.length+5)break;const a=await e.read();if(a.done)break;i(a.value)}if(s===void 0){if(t.byteLength==0){r.close();return}r.error(new ue("premature end of stream",ne.DataLoss));return}const o=t.subarray(5,5+s.length);t=t.subarray(5+s.length),r.enqueue({flags:s.flags,data:o})}})}function yd(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const i=new DataView(t.buffer,t.byteOffset,t.byteLength);return i.setUint8(0,n),i.setUint32(1,e.length),t}var d1=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),r(a,l,o.done,o.value)})}}function r(s,o,a,l){Promise.resolve(l).then(function(h){s({value:h,done:a})},o)}},co=function(n){return this instanceof co?(this.v=n,this):new co(n)},p1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof co?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}},g1=function(n){var e,t;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=n[r]?function(o){return(t=!t)?{value:co(n[r](o)),done:!1}:s?s(o):o}:s}};function m1(n){return p1(this,arguments,function*(){yield co(yield*g1(d1(n)))})}var Vm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){o=n[s](o),r(a,l,o.done,o.value)})}}function r(s,o,a,l){Promise.resolve(l).then(function(h){s({value:h,done:a})},o)}},cs=function(n){return this instanceof cs?(this.v=n,this):new cs(n)},O1=function(n){var e,t;return e={},i("next"),i("throw",function(r){throw r}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(r,s){e[r]=n[r]?function(o){return(t=!t)?{value:cs(n[r](o)),done:!1}:s?s(o):o}:s}},y1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof cs?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}};function b1(n,e){return f1(n,t=>{switch(t.kind){case _e.Unary:return S1(e,n,t);case _e.ServerStreaming:return w1(e,n,t);case _e.ClientStreaming:return v1(e,n,t);case _e.BiDiStreaming:return k1(e,n,t);default:return null}})}function S1(n,e,t){return async function(i,r){var s,o;const a=await n.unary(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues);return(s=r==null?void 0:r.onHeader)===null||s===void 0||s.call(r,a.header),(o=r==null?void 0:r.onTrailer)===null||o===void 0||o.call(r,a.trailer),a.message}}function w1(n,e,t){return function(i,r){return Lm(n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,m1([i]),r==null?void 0:r.contextValues),r)}}function v1(n,e,t){return async function(i,r){var s,o,a,l,h,c;const u=await n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues);(h=r==null?void 0:r.onHeader)===null||h===void 0||h.call(r,u.header);let f;try{for(var p=!0,g=Vm(u.message),O;O=await g.next(),s=O.done,!s;p=!0)l=O.value,p=!1,f=l}catch(y){o={error:y}}finally{try{!p&&!s&&(a=g.return)&&await a.call(g)}finally{if(o)throw o.error}}if(!f)throw new ue("protocol error: missing response message",ne.Internal);return(c=r==null?void 0:r.onTrailer)===null||c===void 0||c.call(r,u.trailer),f}}function k1(n,e,t){return function(i,r){return Lm(n.stream(e,t,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,i,r==null?void 0:r.contextValues),r)}}function Lm(n,e){const t=function(){var i,r;return y1(this,arguments,function*(){const s=yield cs(n);(i=e==null?void 0:e.onHeader)===null||i===void 0||i.call(e,s.header),yield cs(yield*O1(Vm(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function x1(...n){const e=new AbortController,t=n.filter(r=>r!==void 0).concat(e.signal);for(const r of t){if(r.aborted){i.apply(r);break}r.addEventListener("abort",i)}function i(){e.signal.aborted||e.abort(Xm(this));for(const r of t)r.removeEventListener("abort",i)}return e}function T1(n){const e=new AbortController,t=()=>{e.abort(new ue("the operation timed out",ne.DeadlineExceeded))};let i;return n!==void 0&&(n<=0?t():i=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(i)}}function Xm(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function bd(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const $h=128;function Sd(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r +`);for(const i of t){if(i==="")continue;const r=i.indexOf(":");if(r>0){const s=i.substring(0,r).trim(),o=i.substring(r+1).trim();e.append(s,o)}}return e}const Q1="Content-Type",P1="Grpc-Timeout",Um="Grpc-Status",Zm="Grpc-Message",A1="Grpc-Status-Details-Bin",$1="X-User-Agent",C1="X-Grpc-Web",I1="application/grpc-web+proto",R1="application/grpc-web+json";class Rn extends D{constructor(e){super(),this.code=0,this.message="",this.details=[],m.util.initPartial(e,this)}static fromBinary(e,t){return new Rn().fromBinary(e,t)}static fromJson(e,t){return new Rn().fromJson(e,t)}static fromJsonString(e,t){return new Rn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Rn,e,t)}}Rn.runtime=m;Rn.typeName="google.rpc.Status";Rn.fields=m.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:ci,repeated:!0}]);const E1="0";function Wm(n){var e;const t=n.get(A1);if(t!=null){const r=u1(t,Rn);if(r.code==0)return;const s=new ue(r.message,r.code,n);return s.details=r.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),s}const i=n.get(Um);if(i!=null){if(i===E1)return;const r=parseInt(i,10);return r in ne?new ue(decodeURIComponent((e=n.get(Zm))!==null&&e!==void 0?e:""),r,n):new ue(`invalid grpc-status: ${i}`,ne.Internal,n)}}function wd(n,e,t){const i=typeof e=="string"?e:e.typeName,r=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${i}/${r}`)}function jm(n,e){return e instanceof n?e:new n(e)}function D1(n,e){function t(i){return i.done===!0?i:{done:i.done,value:jm(n,i.value)}}return{[Symbol.asyncIterator](){const i=e[Symbol.asyncIterator](),r={next:()=>i.next().then(t)};return i.throw!==void 0&&(r.throw=s=>i.throw(s).then(t)),i.return!==void 0&&(r.return=s=>i.return(s).then(t)),r}}}function zm(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((i,r)=>r(i),n))!==null&&t!==void 0?t:n}function N1(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function vd(n,e,t,i){const r=e?kd(n.I,i):xd(n.I,t);return{parse:(e?kd(n.O,i):xd(n.O,t)).parse,serialize:r.serialize}}function kd(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(i){const r=i instanceof Error?i.message:String(i);throw new ue(`parse binary: ${r}`,ne.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(i){const r=i instanceof Error?i.message:String(i);throw new ue(`serialize binary: ${r}`,ne.Internal)}}}}function xd(n,e){var t,i;const r=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,s=(i=e==null?void 0:e.textDecoder)!==null&&i!==void 0?i:new TextDecoder,o=N1(e);return{parse(a){try{const l=s.decode(a);return n.fromJsonString(l,o)}catch(l){throw ue.from(l,ne.InvalidArgument)}},serialize(a){try{const l=a.toJsonString(o);return r.encode(l)}catch(l){throw ue.from(l,ne.Internal)}}}}function B1(n){const e=zm(n.next,n.interceptors),[t,i,r]=Fm(n),s=Object.assign(Object.assign({},n.req),{message:jm(n.req.method.I,n.req.message),signal:t});return e(s).then(o=>(r(),o),i)}function q1(n){const e=zm(n.next,n.interceptors),[t,i,r]=Fm(n),s=Object.assign(Object.assign({},n.req),{message:D1(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,l;const h=n.req.message[Symbol.asyncIterator]();o||(a=h.throw)===null||a===void 0||a.call(h,this.reason).catch(()=>{}),(l=h.return)===null||l===void 0||l.call(h).catch(()=>{})}),e(s).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const l=a.message[Symbol.asyncIterator]();return{next(){return l.next().then(h=>(h.done==!0&&(o=!0,r()),h),i)}}}}}),i)}function Fm(n){const{signal:e,cleanup:t}=T1(n.timeoutMs),i=x1(n.signal,e);return[i.signal,function(s){const o=ue.from(e.aborted?Xm(e):s);return i.abort(o),t(),Promise.reject(o)},function(){t(),i.abort()}]}function M1(){try{new Headers}catch{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.")}}function Td(n,e){const t=Wm(n);if(t)throw e.forEach((i,r)=>{t.metadata.append(r,i)}),t}function Qd(n,e,t,i){const r=new Headers(t??{});return r.set(Q1,n?I1:R1),r.set(C1,"1"),r.set($1,"connect-es/1.4.0"),e!==void 0&&r.set(P1,`${e}m`),r}function V1(n){switch(n){case 400:return ne.Internal;case 401:return ne.Unauthenticated;case 403:return ne.PermissionDenied;case 404:return ne.Unimplemented;case 429:return ne.Unavailable;case 502:return ne.Unavailable;case 503:return ne.Unavailable;case 504:return ne.Unavailable;default:return ne.Unknown}}function Pd(n,e){var t;if(n>=200&&n<300){const i=Wm(e);if(i)throw i;return{foundStatus:e.has(Um)}}throw new ue(decodeURIComponent((t=e.get(Zm))!==null&&t!==void 0?t:`HTTP ${n}`),V1(n),e)}var Pr=function(n){return this instanceof Pr?(this.v=n,this):new Pr(n)},L1=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(n,e||[]),r,s=[];return r={},a("next"),a("throw"),a("return",o),r[Symbol.asyncIterator]=function(){return this},r;function o(p){return function(g){return Promise.resolve(g).then(p,u)}}function a(p,g){i[p]&&(r[p]=function(O){return new Promise(function(y,S){s.push([p,O,y,S])>1||l(p,O)})},g&&(r[p]=g(r[p])))}function l(p,g){try{h(i[p](g))}catch(O){f(s[0][3],O)}}function h(p){p.value instanceof Pr?Promise.resolve(p.value.v).then(c,u):f(s[0][2],p)}function c(p){l("next",p)}function u(p){l("throw",p)}function f(p,g){p(g),s.shift(),s.length&&l(s[0][0],s[0][1])}};function X1(n){var e;M1();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(i,r,s,o,a,l,h){var c;const{serialize:u,parse:f}=vd(r,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await B1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!1,service:i,method:r,url:wd(n.baseUrl,i,r),init:{method:"POST",credentials:(c=n.credentials)!==null&&c!==void 0?c:"same-origin",redirect:"error",mode:"cors"},header:Qd(t,o,a),contextValues:h??bd(),message:l},next:async p=>{var g;const y=await((g=n.fetch)!==null&&g!==void 0?g:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:yd(0,u(p.message))}));if(Pd(y.status,y.headers),!y.body)throw"missing response body";const S=Od(y.body).getReader();let k,$;for(;;){const A=await S.read();if(A.done)break;const{flags:x,data:P}=A.value;if(x===$h){if(k!==void 0)throw"extra trailer";k=Sd(P);continue}if($!==void 0)throw"extra message";$=f(P)}if(k===void 0)throw"missing trailer";if(Td(k,y.headers),$===void 0)throw"missing message";return{stream:!1,service:i,method:r,header:y.headers,message:$,trailer:k}}})},async stream(i,r,s,o,a,l,h){var c;const{serialize:u,parse:f}=vd(r,t,n.jsonOptions,n.binaryOptions);function p(O,y,S,k){return L1(this,arguments,function*(){const A=Od(O).getReader();if(y){if(!(yield Pr(A.read())).done)throw"extra data for trailers-only";return yield Pr(void 0)}let x=!1;for(;;){const P=yield Pr(A.read());if(P.done)break;const{flags:R,data:X}=P.value;if((R&$h)===$h){if(x)throw"extra trailer";x=!0;const W=Sd(X);Td(W,k),W.forEach((z,H)=>S.set(H,z));continue}if(x)throw"extra message";yield yield Pr(f(X))}if(!x)throw"missing trailer"})}async function g(O){if(r.kind!=_e.ServerStreaming)throw"The fetch API does not support streaming request bodies";const y=await O[Symbol.asyncIterator]().next();if(y.done==!0)throw"missing request message";return yd(0,u(y.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,q1({interceptors:n.interceptors,signal:s,timeoutMs:o,req:{stream:!0,service:i,method:r,url:wd(n.baseUrl,i,r),init:{method:"POST",credentials:(c=n.credentials)!==null&&c!==void 0?c:"same-origin",redirect:"error",mode:"cors"},header:Qd(t,o,a),contextValues:h??bd(),message:l},next:async O=>{var y;const k=await((y=n.fetch)!==null&&y!==void 0?y:globalThis.fetch)(O.url,Object.assign(Object.assign({},O.init),{headers:O.header,signal:O.signal,body:await g(O.message)})),{foundStatus:$}=Pd(k.status,k.headers);if(!k.body)throw"missing response body";const A=new Headers;return Object.assign(Object.assign({},O),{header:k.headers,trailer:A,message:p(k.body,$,A,k.headers)})}})}}}var F=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(F||{});m.util.setEnumType(F,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var Rr=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))(Rr||{});m.util.setEnumType(Rr,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const Ci=class Ci extends D{constructor(t){super();d(this,"root");d(this,"presences",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Ci().fromBinary(t,i)}static fromJson(t,i){return new Ci().fromJson(t,i)}static fromJsonString(t,i){return new Ci().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ci,t,i)}};d(Ci,"runtime",m),d(Ci,"typeName","yorkie.v1.Snapshot"),d(Ci,"fields",m.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:rt},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Gu}}]));let yc=Ci;var yt;let Wn=(yt=class extends D{constructor(t){super();d(this,"documentKey","");d(this,"checkpoint");d(this,"snapshot",new Uint8Array(0));d(this,"changes",[]);d(this,"minSyncedTicket");d(this,"isRemoved",!1);d(this,"versionVector");m.util.initPartial(t,this)}static fromBinary(t,i){return new yt().fromBinary(t,i)}static fromJson(t,i){return new yt().fromJson(t,i)}static fromJsonString(t,i){return new yt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(yt,t,i)}},d(yt,"runtime",m),d(yt,"typeName","yorkie.v1.ChangePack"),d(yt,"fields",m.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:Ym},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:_m,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:M},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:ih}])),yt);var bt;let _m=(bt=class extends D{constructor(t){super();d(this,"id");d(this,"message","");d(this,"operations",[]);d(this,"presenceChange");m.util.initPartial(t,this)}static fromBinary(t,i){return new bt().fromBinary(t,i)}static fromJson(t,i){return new bt().fromJson(t,i)}static fromJsonString(t,i){return new bt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(bt,t,i)}},d(bt,"runtime",m),d(bt,"typeName","yorkie.v1.Change"),d(bt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:th},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Fu,repeated:!0},{no:4,name:"presence_change",kind:"message",T:fo}])),bt);var St;let th=(St=class extends D{constructor(t){super();d(this,"clientSeq",0);d(this,"serverSeq",fe.zero);d(this,"lamport",fe.zero);d(this,"actorId",new Uint8Array(0));d(this,"versionVector");m.util.initPartial(t,this)}static fromBinary(t,i){return new St().fromBinary(t,i)}static fromJson(t,i){return new St().fromJson(t,i)}static fromJsonString(t,i){return new St().fromJsonString(t,i)}static equals(t,i){return m.util.equals(St,t,i)}},d(St,"runtime",m),d(St,"typeName","yorkie.v1.ChangeID"),d(St,"fields",m.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:ih}])),St);var wt;let ih=(wt=class extends D{constructor(t){super();d(this,"vector",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new wt().fromBinary(t,i)}static fromJson(t,i){return new wt().fromJson(t,i)}static fromJsonString(t,i){return new wt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(wt,t,i)}},d(wt,"runtime",m),d(wt,"typeName","yorkie.v1.VersionVector"),d(wt,"fields",m.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),wt);var vt;let Fu=(vt=class extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new vt().fromBinary(t,i)}static fromJson(t,i){return new vt().fromJson(t,i)}static fromJsonString(t,i){return new vt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(vt,t,i)}},d(vt,"runtime",m),d(vt,"typeName","yorkie.v1.Operation"),d(vt,"fields",m.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:nl,oneof:"body"},{no:2,name:"add",kind:"message",T:rl,oneof:"body"},{no:3,name:"move",kind:"message",T:sl,oneof:"body"},{no:4,name:"remove",kind:"message",T:ol,oneof:"body"},{no:5,name:"edit",kind:"message",T:al,oneof:"body"},{no:6,name:"select",kind:"message",T:bc,oneof:"body"},{no:7,name:"style",kind:"message",T:ll,oneof:"body"},{no:8,name:"increase",kind:"message",T:hl,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:cl,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ul,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Sc,oneof:"body"}])),vt);const Ii=class Ii extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"key","");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ii().fromBinary(t,i)}static fromJson(t,i){return new Ii().fromJson(t,i)}static fromJsonString(t,i){return new Ii().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ii,t,i)}};d(Ii,"runtime",m),d(Ii,"typeName","yorkie.v1.Operation.Set"),d(Ii,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let nl=Ii;const Ri=class Ri extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"prevCreatedAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ri().fromBinary(t,i)}static fromJson(t,i){return new Ri().fromJson(t,i)}static fromJsonString(t,i){return new Ri().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ri,t,i)}};d(Ri,"runtime",m),d(Ri,"typeName","yorkie.v1.Operation.Add"),d(Ri,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"prev_created_at",kind:"message",T:M},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let rl=Ri;const Ei=class Ei extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"prevCreatedAt");d(this,"createdAt");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Ei().fromBinary(t,i)}static fromJson(t,i){return new Ei().fromJson(t,i)}static fromJsonString(t,i){return new Ei().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ei,t,i)}};d(Ei,"runtime",m),d(Ei,"typeName","yorkie.v1.Operation.Move"),d(Ei,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"prev_created_at",kind:"message",T:M},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"executed_at",kind:"message",T:M}]));let sl=Ei;const Di=class Di extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"createdAt");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Di().fromBinary(t,i)}static fromJson(t,i){return new Di().fromJson(t,i)}static fromJsonString(t,i){return new Di().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Di,t,i)}};d(Di,"runtime",m),d(Di,"typeName","yorkie.v1.Operation.Remove"),d(Di,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"executed_at",kind:"message",T:M}]));let ol=Di;const Ni=class Ni extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"createdAtMapByActor",{});d(this,"content","");d(this,"executedAt");d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Ni().fromBinary(t,i)}static fromJson(t,i){return new Ni().fromJson(t,i)}static fromJsonString(t,i){return new Ni().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ni,t,i)}};d(Ni,"runtime",m),d(Ni,"typeName","yorkie.v1.Operation.Edit"),d(Ni,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:M},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let al=Ni;const Bi=class Bi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Bi().fromBinary(t,i)}static fromJson(t,i){return new Bi().fromJson(t,i)}static fromJsonString(t,i){return new Bi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Bi,t,i)}};d(Bi,"runtime",m),d(Bi,"typeName","yorkie.v1.Operation.Select"),d(Bi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"executed_at",kind:"message",T:M}]));let bc=Bi;const qi=class qi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"attributes",{});d(this,"executedAt");d(this,"createdAtMapByActor",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new qi().fromBinary(t,i)}static fromJson(t,i){return new qi().fromJson(t,i)}static fromJsonString(t,i){return new qi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(qi,t,i)}};d(qi,"runtime",m),d(qi,"typeName","yorkie.v1.Operation.Style"),d(qi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Mn},{no:3,name:"to",kind:"message",T:Mn},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:M},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}}]));let ll=qi;const Mi=class Mi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Mi().fromBinary(t,i)}static fromJson(t,i){return new Mi().fromJson(t,i)}static fromJsonString(t,i){return new Mi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Mi,t,i)}};d(Mi,"runtime",m),d(Mi,"typeName","yorkie.v1.Operation.Increase"),d(Mi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"value",kind:"message",T:mt},{no:3,name:"executed_at",kind:"message",T:M}]));let hl=Mi;const Vi=class Vi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"createdAtMapByActor",{});d(this,"contents",[]);d(this,"splitLevel",0);d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Vi().fromBinary(t,i)}static fromJson(t,i){return new Vi().fromJson(t,i)}static fromJsonString(t,i){return new Vi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Vi,t,i)}};d(Vi,"runtime",m),d(Vi,"typeName","yorkie.v1.Operation.TreeEdit"),d(Vi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Er},{no:3,name:"to",kind:"message",T:Er},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}},{no:5,name:"contents",kind:"message",T:bl,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:M}]));let cl=Vi;const Li=class Li extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"from");d(this,"to");d(this,"attributes",{});d(this,"executedAt");d(this,"attributesToRemove",[]);d(this,"createdAtMapByActor",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Li().fromBinary(t,i)}static fromJson(t,i){return new Li().fromJson(t,i)}static fromJsonString(t,i){return new Li().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Li,t,i)}};d(Li,"runtime",m),d(Li,"typeName","yorkie.v1.Operation.TreeStyle"),d(Li,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"from",kind:"message",T:Er},{no:3,name:"to",kind:"message",T:Er},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:M},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:M}}]));let ul=Li;const Xi=class Xi extends D{constructor(t){super();d(this,"parentCreatedAt");d(this,"createdAt");d(this,"value");d(this,"executedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Xi().fromBinary(t,i)}static fromJson(t,i){return new Xi().fromJson(t,i)}static fromJsonString(t,i){return new Xi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Xi,t,i)}};d(Xi,"runtime",m),d(Xi,"typeName","yorkie.v1.Operation.ArraySet"),d(Xi,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:M},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"value",kind:"message",T:mt},{no:4,name:"executed_at",kind:"message",T:M}]));let Sc=Xi;const Ui=class Ui extends D{constructor(t){super();d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");d(this,"type",0);d(this,"value",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new Ui().fromBinary(t,i)}static fromJson(t,i){return new Ui().fromJson(t,i)}static fromJsonString(t,i){return new Ui().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ui,t,i)}};d(Ui,"runtime",m),d(Ui,"typeName","yorkie.v1.JSONElementSimple"),d(Ui,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"moved_at",kind:"message",T:M},{no:3,name:"removed_at",kind:"message",T:M},{no:4,name:"type",kind:"enum",T:m.getEnumType(F)},{no:5,name:"value",kind:"scalar",T:12}]));let mt=Ui;const Zi=class Zi extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new Zi().fromBinary(t,i)}static fromJson(t,i){return new Zi().fromJson(t,i)}static fromJsonString(t,i){return new Zi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Zi,t,i)}};d(Zi,"runtime",m),d(Zi,"typeName","yorkie.v1.JSONElement"),d(Zi,"fields",m.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:fl,oneof:"body"},{no:2,name:"json_array",kind:"message",T:dl,oneof:"body"},{no:3,name:"primitive",kind:"message",T:pl,oneof:"body"},{no:5,name:"text",kind:"message",T:gl,oneof:"body"},{no:6,name:"counter",kind:"message",T:ml,oneof:"body"},{no:7,name:"tree",kind:"message",T:Ol,oneof:"body"}]));let rt=Zi;const Wi=class Wi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Wi().fromBinary(t,i)}static fromJson(t,i){return new Wi().fromJson(t,i)}static fromJsonString(t,i){return new Wi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Wi,t,i)}};d(Wi,"runtime",m),d(Wi,"typeName","yorkie.v1.JSONElement.JSONObject"),d(Wi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Gm,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let fl=Wi;const ji=class ji extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new ji().fromBinary(t,i)}static fromJson(t,i){return new ji().fromJson(t,i)}static fromJsonString(t,i){return new ji().fromJsonString(t,i)}static equals(t,i){return m.util.equals(ji,t,i)}};d(ji,"runtime",m),d(ji,"typeName","yorkie.v1.JSONElement.JSONArray"),d(ji,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yl,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let dl=ji;const zi=class zi extends D{constructor(t){super();d(this,"type",0);d(this,"value",new Uint8Array(0));d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new zi().fromBinary(t,i)}static fromJson(t,i){return new zi().fromJson(t,i)}static fromJsonString(t,i){return new zi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(zi,t,i)}};d(zi,"runtime",m),d(zi,"typeName","yorkie.v1.JSONElement.Primitive"),d(zi,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(F)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"moved_at",kind:"message",T:M},{no:5,name:"removed_at",kind:"message",T:M}]));let pl=zi;const Fi=class Fi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Fi().fromBinary(t,i)}static fromJson(t,i){return new Fi().fromJson(t,i)}static fromJsonString(t,i){return new Fi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Fi,t,i)}};d(Fi,"runtime",m),d(Fi,"typeName","yorkie.v1.JSONElement.Text"),d(Fi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Jm,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let gl=Fi;const _i=class _i extends D{constructor(t){super();d(this,"type",0);d(this,"value",new Uint8Array(0));d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new _i().fromBinary(t,i)}static fromJson(t,i){return new _i().fromJson(t,i)}static fromJsonString(t,i){return new _i().fromJsonString(t,i)}static equals(t,i){return m.util.equals(_i,t,i)}};d(_i,"runtime",m),d(_i,"typeName","yorkie.v1.JSONElement.Counter"),d(_i,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(F)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:M},{no:4,name:"moved_at",kind:"message",T:M},{no:5,name:"removed_at",kind:"message",T:M}]));let ml=_i;const Gi=class Gi extends D{constructor(t){super();d(this,"nodes",[]);d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new Gi().fromBinary(t,i)}static fromJson(t,i){return new Gi().fromJson(t,i)}static fromJsonString(t,i){return new Gi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Gi,t,i)}};d(Gi,"runtime",m),d(Gi,"typeName","yorkie.v1.JSONElement.Tree"),d(Gi,"fields",m.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:_u,repeated:!0},{no:2,name:"created_at",kind:"message",T:M},{no:3,name:"moved_at",kind:"message",T:M},{no:4,name:"removed_at",kind:"message",T:M}]));let Ol=Gi;var kt;let Gm=(kt=class extends D{constructor(t){super();d(this,"key","");d(this,"element");m.util.initPartial(t,this)}static fromBinary(t,i){return new kt().fromBinary(t,i)}static fromJson(t,i){return new kt().fromJson(t,i)}static fromJsonString(t,i){return new kt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(kt,t,i)}},d(kt,"runtime",m),d(kt,"typeName","yorkie.v1.RHTNode"),d(kt,"fields",m.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:rt}])),kt);const li=class li extends D{constructor(t){super();d(this,"next");d(this,"element");m.util.initPartial(t,this)}static fromBinary(t,i){return new li().fromBinary(t,i)}static fromJson(t,i){return new li().fromJson(t,i)}static fromJsonString(t,i){return new li().fromJsonString(t,i)}static equals(t,i){return m.util.equals(li,t,i)}};d(li,"runtime",m),d(li,"typeName","yorkie.v1.RGANode"),d(li,"fields",m.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:li},{no:2,name:"element",kind:"message",T:rt}]));let yl=li;const Ji=class Ji extends D{constructor(t){super();d(this,"value","");d(this,"updatedAt");d(this,"isRemoved",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new Ji().fromBinary(t,i)}static fromJson(t,i){return new Ji().fromJson(t,i)}static fromJsonString(t,i){return new Ji().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ji,t,i)}};d(Ji,"runtime",m),d(Ji,"typeName","yorkie.v1.NodeAttr"),d(Ji,"fields",m.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:M},{no:3,name:"is_removed",kind:"scalar",T:8}]));let us=Ji;var xt;let Jm=(xt=class extends D{constructor(t){super();d(this,"id");d(this,"value","");d(this,"removedAt");d(this,"insPrevId");d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new xt().fromBinary(t,i)}static fromJson(t,i){return new xt().fromJson(t,i)}static fromJsonString(t,i){return new xt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(xt,t,i)}},d(xt,"runtime",m),d(xt,"typeName","yorkie.v1.TextNode"),d(xt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:uo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:M},{no:4,name:"ins_prev_id",kind:"message",T:uo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:us}}])),xt);const Yi=class Yi extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Yi().fromBinary(t,i)}static fromJson(t,i){return new Yi().fromJson(t,i)}static fromJsonString(t,i){return new Yi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Yi,t,i)}};d(Yi,"runtime",m),d(Yi,"typeName","yorkie.v1.TextNodeID"),d(Yi,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5}]));let uo=Yi;var Tt;let _u=(Tt=class extends D{constructor(t){super();d(this,"id");d(this,"type","");d(this,"value","");d(this,"removedAt");d(this,"insPrevId");d(this,"insNextId");d(this,"depth",0);d(this,"attributes",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Tt().fromBinary(t,i)}static fromJson(t,i){return new Tt().fromJson(t,i)}static fromJsonString(t,i){return new Tt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Tt,t,i)}},d(Tt,"runtime",m),d(Tt,"typeName","yorkie.v1.TreeNode"),d(Tt,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:nr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:M},{no:5,name:"ins_prev_id",kind:"message",T:nr},{no:6,name:"ins_next_id",kind:"message",T:nr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:us}}])),Tt);const Hi=class Hi extends D{constructor(t){super();d(this,"content",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new Hi().fromBinary(t,i)}static fromJson(t,i){return new Hi().fromJson(t,i)}static fromJsonString(t,i){return new Hi().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Hi,t,i)}};d(Hi,"runtime",m),d(Hi,"typeName","yorkie.v1.TreeNodes"),d(Hi,"fields",m.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:_u,repeated:!0}]));let bl=Hi;const Ki=class Ki extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Ki().fromBinary(t,i)}static fromJson(t,i){return new Ki().fromJson(t,i)}static fromJsonString(t,i){return new Ki().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Ki,t,i)}};d(Ki,"runtime",m),d(Ki,"typeName","yorkie.v1.TreeNodeID"),d(Ki,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5}]));let nr=Ki;const en=class en extends D{constructor(t){super();d(this,"parentId");d(this,"leftSiblingId");m.util.initPartial(t,this)}static fromBinary(t,i){return new en().fromBinary(t,i)}static fromJson(t,i){return new en().fromJson(t,i)}static fromJsonString(t,i){return new en().fromJsonString(t,i)}static equals(t,i){return m.util.equals(en,t,i)}};d(en,"runtime",m),d(en,"typeName","yorkie.v1.TreePos"),d(en,"fields",m.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:nr},{no:2,name:"left_sibling_id",kind:"message",T:nr}]));let Er=en;const tn=class tn extends D{constructor(t){super();d(this,"id","");d(this,"username","");d(this,"createdAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new tn().fromBinary(t,i)}static fromJson(t,i){return new tn().fromJson(t,i)}static fromJsonString(t,i){return new tn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(tn,t,i)}};d(tn,"runtime",m),d(tn,"typeName","yorkie.v1.User"),d(tn,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Ze}]));let Ad=tn;const nn=class nn extends D{constructor(t){super();d(this,"id","");d(this,"name","");d(this,"publicKey","");d(this,"secretKey","");d(this,"authWebhookUrl","");d(this,"authWebhookMethods",[]);d(this,"clientDeactivateThreshold","");d(this,"createdAt");d(this,"updatedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new nn().fromBinary(t,i)}static fromJson(t,i){return new nn().fromJson(t,i)}static fromJsonString(t,i){return new nn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(nn,t,i)}};d(nn,"runtime",m),d(nn,"typeName","yorkie.v1.Project"),d(nn,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Ze},{no:9,name:"updated_at",kind:"message",T:Ze}]));let $d=nn;const rn=class rn extends D{constructor(t){super();d(this,"name");d(this,"authWebhookUrl");d(this,"authWebhookMethods");d(this,"clientDeactivateThreshold");m.util.initPartial(t,this)}static fromBinary(t,i){return new rn().fromBinary(t,i)}static fromJson(t,i){return new rn().fromJson(t,i)}static fromJsonString(t,i){return new rn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(rn,t,i)}};d(rn,"runtime",m),d(rn,"typeName","yorkie.v1.UpdatableProjectFields"),d(rn,"fields",m.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:ct},{no:2,name:"auth_webhook_url",kind:"message",T:ct},{no:3,name:"auth_webhook_methods",kind:"message",T:wc},{no:4,name:"client_deactivate_threshold",kind:"message",T:ct}]));let Cd=rn;const sn=class sn extends D{constructor(t){super();d(this,"methods",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new sn().fromBinary(t,i)}static fromJson(t,i){return new sn().fromJson(t,i)}static fromJsonString(t,i){return new sn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(sn,t,i)}};d(sn,"runtime",m),d(sn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),d(sn,"fields",m.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let wc=sn;const on=class on extends D{constructor(t){super();d(this,"id","");d(this,"key","");d(this,"snapshot","");d(this,"createdAt");d(this,"accessedAt");d(this,"updatedAt");m.util.initPartial(t,this)}static fromBinary(t,i){return new on().fromBinary(t,i)}static fromJson(t,i){return new on().fromJson(t,i)}static fromJsonString(t,i){return new on().fromJsonString(t,i)}static equals(t,i){return m.util.equals(on,t,i)}};d(on,"runtime",m),d(on,"typeName","yorkie.v1.DocumentSummary"),d(on,"fields",m.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Ze},{no:5,name:"accessed_at",kind:"message",T:Ze},{no:6,name:"updated_at",kind:"message",T:Ze}]));let Id=on;const an=class an extends D{constructor(t){super();d(this,"type",0);d(this,"presence");m.util.initPartial(t,this)}static fromBinary(t,i){return new an().fromBinary(t,i)}static fromJson(t,i){return new an().fromJson(t,i)}static fromJsonString(t,i){return new an().fromJsonString(t,i)}static equals(t,i){return m.util.equals(an,t,i)}};d(an,"runtime",m),d(an,"typeName","yorkie.v1.PresenceChange"),d(an,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(Dr)},{no:2,name:"presence",kind:"message",T:Gu}]));let fo=an;var Dr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(Dr||{});m.util.setEnumType(Dr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var Qt;let Gu=(Qt=class extends D{constructor(t){super();d(this,"data",{});m.util.initPartial(t,this)}static fromBinary(t,i){return new Qt().fromBinary(t,i)}static fromJson(t,i){return new Qt().fromJson(t,i)}static fromJsonString(t,i){return new Qt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Qt,t,i)}},d(Qt,"runtime",m),d(Qt,"typeName","yorkie.v1.Presence"),d(Qt,"fields",m.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),Qt);var Pt;let Ym=(Pt=class extends D{constructor(t){super();d(this,"serverSeq",fe.zero);d(this,"clientSeq",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new Pt().fromBinary(t,i)}static fromJson(t,i){return new Pt().fromJson(t,i)}static fromJsonString(t,i){return new Pt().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Pt,t,i)}},d(Pt,"runtime",m),d(Pt,"typeName","yorkie.v1.Checkpoint"),d(Pt,"fields",m.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),Pt);const ln=class ln extends D{constructor(t){super();d(this,"createdAt");d(this,"offset",0);d(this,"relativeOffset",0);m.util.initPartial(t,this)}static fromBinary(t,i){return new ln().fromBinary(t,i)}static fromJson(t,i){return new ln().fromJson(t,i)}static fromJsonString(t,i){return new ln().fromJsonString(t,i)}static equals(t,i){return m.util.equals(ln,t,i)}};d(ln,"runtime",m),d(ln,"typeName","yorkie.v1.TextNodePos"),d(ln,"fields",m.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:M},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Mn=ln;var At;let M=(At=class extends D{constructor(t){super();d(this,"lamport",fe.zero);d(this,"delimiter",0);d(this,"actorId",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new At().fromBinary(t,i)}static fromJson(t,i){return new At().fromJson(t,i)}static fromJsonString(t,i){return new At().fromJsonString(t,i)}static equals(t,i){return m.util.equals(At,t,i)}},d(At,"runtime",m),d(At,"typeName","yorkie.v1.TimeTicket"),d(At,"fields",m.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),At);const hn=class hn extends D{constructor(t){super();d(this,"topic","");d(this,"payload",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new hn().fromBinary(t,i)}static fromJson(t,i){return new hn().fromJson(t,i)}static fromJsonString(t,i){return new hn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(hn,t,i)}};d(hn,"runtime",m),d(hn,"typeName","yorkie.v1.DocEventBody"),d(hn,"fields",m.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let vc=hn;const cn=class cn extends D{constructor(t){super();d(this,"type",0);d(this,"publisher","");d(this,"body");m.util.initPartial(t,this)}static fromBinary(t,i){return new cn().fromBinary(t,i)}static fromJson(t,i){return new cn().fromJson(t,i)}static fromJsonString(t,i){return new cn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(cn,t,i)}};d(cn,"runtime",m),d(cn,"typeName","yorkie.v1.DocEvent"),d(cn,"fields",m.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:m.getEnumType(Rr)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:vc}]));let kc=cn;const un=class un extends D{constructor(t){super();d(this,"clientKey","");m.util.initPartial(t,this)}static fromBinary(t,i){return new un().fromBinary(t,i)}static fromJson(t,i){return new un().fromJson(t,i)}static fromJsonString(t,i){return new un().fromJsonString(t,i)}static equals(t,i){return m.util.equals(un,t,i)}};d(un,"runtime",m),d(un,"typeName","yorkie.v1.ActivateClientRequest"),d(un,"fields",m.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let xc=un;const fn=class fn extends D{constructor(t){super();d(this,"clientId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new fn().fromBinary(t,i)}static fromJson(t,i){return new fn().fromJson(t,i)}static fromJsonString(t,i){return new fn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(fn,t,i)}};d(fn,"runtime",m),d(fn,"typeName","yorkie.v1.ActivateClientResponse"),d(fn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Tc=fn;const dn=class dn extends D{constructor(t){super();d(this,"clientId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new dn().fromBinary(t,i)}static fromJson(t,i){return new dn().fromJson(t,i)}static fromJsonString(t,i){return new dn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(dn,t,i)}};d(dn,"runtime",m),d(dn,"typeName","yorkie.v1.DeactivateClientRequest"),d(dn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Qc=dn;const pn=class pn extends D{constructor(e){super(),m.util.initPartial(e,this)}static fromBinary(e,t){return new pn().fromBinary(e,t)}static fromJson(e,t){return new pn().fromJson(e,t)}static fromJsonString(e,t){return new pn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(pn,e,t)}};d(pn,"runtime",m),d(pn,"typeName","yorkie.v1.DeactivateClientResponse"),d(pn,"fields",m.util.newFieldList(()=>[]));let Pc=pn;const gn=class gn extends D{constructor(t){super();d(this,"clientId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new gn().fromBinary(t,i)}static fromJson(t,i){return new gn().fromJson(t,i)}static fromJsonString(t,i){return new gn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(gn,t,i)}};d(gn,"runtime",m),d(gn,"typeName","yorkie.v1.AttachDocumentRequest"),d(gn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Wn}]));let Ac=gn;const mn=class mn extends D{constructor(t){super();d(this,"documentId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new mn().fromBinary(t,i)}static fromJson(t,i){return new mn().fromJson(t,i)}static fromJsonString(t,i){return new mn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(mn,t,i)}};d(mn,"runtime",m),d(mn,"typeName","yorkie.v1.AttachDocumentResponse"),d(mn,"fields",m.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Wn}]));let $c=mn;const On=class On extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");d(this,"removeIfNotAttached",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new On().fromBinary(t,i)}static fromJson(t,i){return new On().fromJson(t,i)}static fromJsonString(t,i){return new On().fromJsonString(t,i)}static equals(t,i){return m.util.equals(On,t,i)}};d(On,"runtime",m),d(On,"typeName","yorkie.v1.DetachDocumentRequest"),d(On,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let Cc=On;const yn=class yn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new yn().fromBinary(t,i)}static fromJson(t,i){return new yn().fromJson(t,i)}static fromJsonString(t,i){return new yn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(yn,t,i)}};d(yn,"runtime",m),d(yn,"typeName","yorkie.v1.DetachDocumentResponse"),d(yn,"fields",m.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Wn}]));let Ic=yn;const bn=class bn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");m.util.initPartial(t,this)}static fromBinary(t,i){return new bn().fromBinary(t,i)}static fromJson(t,i){return new bn().fromJson(t,i)}static fromJsonString(t,i){return new bn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(bn,t,i)}};d(bn,"runtime",m),d(bn,"typeName","yorkie.v1.WatchDocumentRequest"),d(bn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let Rc=bn;const Sn=class Sn extends D{constructor(t){super();d(this,"body",{case:void 0});m.util.initPartial(t,this)}static fromBinary(t,i){return new Sn().fromBinary(t,i)}static fromJson(t,i){return new Sn().fromJson(t,i)}static fromJsonString(t,i){return new Sn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Sn,t,i)}};d(Sn,"runtime",m),d(Sn,"typeName","yorkie.v1.WatchDocumentResponse"),d(Sn,"fields",m.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:Dc,oneof:"body"},{no:2,name:"event",kind:"message",T:kc,oneof:"body"}]));let Ec=Sn;const wn=class wn extends D{constructor(t){super();d(this,"clientIds",[]);m.util.initPartial(t,this)}static fromBinary(t,i){return new wn().fromBinary(t,i)}static fromJson(t,i){return new wn().fromJson(t,i)}static fromJsonString(t,i){return new wn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(wn,t,i)}};d(wn,"runtime",m),d(wn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),d(wn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let Dc=wn;const vn=class vn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new vn().fromBinary(t,i)}static fromJson(t,i){return new vn().fromJson(t,i)}static fromJsonString(t,i){return new vn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(vn,t,i)}};d(vn,"runtime",m),d(vn,"typeName","yorkie.v1.RemoveDocumentRequest"),d(vn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn}]));let Nc=vn;const kn=class kn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new kn().fromBinary(t,i)}static fromJson(t,i){return new kn().fromJson(t,i)}static fromJsonString(t,i){return new kn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(kn,t,i)}};d(kn,"runtime",m),d(kn,"typeName","yorkie.v1.RemoveDocumentResponse"),d(kn,"fields",m.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Wn}]));let Bc=kn;const xn=class xn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"changePack");d(this,"pushOnly",!1);m.util.initPartial(t,this)}static fromBinary(t,i){return new xn().fromBinary(t,i)}static fromJson(t,i){return new xn().fromJson(t,i)}static fromJsonString(t,i){return new xn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(xn,t,i)}};d(xn,"runtime",m),d(xn,"typeName","yorkie.v1.PushPullChangesRequest"),d(xn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Wn},{no:4,name:"push_only",kind:"scalar",T:8}]));let qc=xn;const Tn=class Tn extends D{constructor(t){super();d(this,"changePack");m.util.initPartial(t,this)}static fromBinary(t,i){return new Tn().fromBinary(t,i)}static fromJson(t,i){return new Tn().fromJson(t,i)}static fromJsonString(t,i){return new Tn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Tn,t,i)}};d(Tn,"runtime",m),d(Tn,"typeName","yorkie.v1.PushPullChangesResponse"),d(Tn,"fields",m.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Wn}]));let Mc=Tn;const Qn=class Qn extends D{constructor(t){super();d(this,"clientId","");d(this,"documentId","");d(this,"topic","");d(this,"payload",new Uint8Array(0));m.util.initPartial(t,this)}static fromBinary(t,i){return new Qn().fromBinary(t,i)}static fromJson(t,i){return new Qn().fromJson(t,i)}static fromJsonString(t,i){return new Qn().fromJsonString(t,i)}static equals(t,i){return m.util.equals(Qn,t,i)}};d(Qn,"runtime",m),d(Qn,"typeName","yorkie.v1.BroadcastRequest"),d(Qn,"fields",m.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Vc=Qn;const Pn=class Pn extends D{constructor(e){super(),m.util.initPartial(e,this)}static fromBinary(e,t){return new Pn().fromBinary(e,t)}static fromJson(e,t){return new Pn().fromJson(e,t)}static fromJsonString(e,t){return new Pn().fromJsonString(e,t)}static equals(e,t){return m.util.equals(Pn,e,t)}};d(Pn,"runtime",m),d(Pn,"typeName","yorkie.v1.BroadcastResponse"),d(Pn,"fields",m.util.newFieldList(()=>[]));let Lc=Pn;const U1={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:xc,O:Tc,kind:_e.Unary},deactivateClient:{name:"DeactivateClient",I:Qc,O:Pc,kind:_e.Unary},attachDocument:{name:"AttachDocument",I:Ac,O:$c,kind:_e.Unary},detachDocument:{name:"DetachDocument",I:Cc,O:Ic,kind:_e.Unary},removeDocument:{name:"RemoveDocument",I:Nc,O:Bc,kind:_e.Unary},pushPullChanges:{name:"PushPullChanges",I:qc,O:Mc,kind:_e.Unary},watchDocument:{name:"WatchDocument",I:Rc,O:Ec,kind:_e.ServerStreaming},broadcast:{name:"Broadcast",I:Vc,O:Lc,kind:_e.Unary}}},Z1=m.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);m.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:In}]);m.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:W1,repeated:!0}]);const W1=m.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});m.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:j1,repeated:!0}]);const j1=m.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});m.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:z1,repeated:!0}]);const z1=m.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});m.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);m.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:F1,repeated:!0}]);const F1=m.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});m.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var w=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(w||{});class v extends Error{constructor(t,i){super(i);d(this,"name","YorkieError");d(this,"stack");this.code=t,this.message=i,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function Wt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const Hm=n=>n?Object.entries(n).length===0:!0,fs=n=>{const e={};for(const[t,i]of Object.entries(n))e[t]=JSON.stringify(i);return e},ts=n=>{const e={};for(const[t,i]of Object.entries(n))e[t]=JSON.parse(i);return e};var cr=(n=>(n.Put="put",n.Clear="clear",n))(cr||{});class Ch{constructor(e,t){d(this,"context");d(this,"presence");this.context=e,this.presence=t}set(e,t){for(const i of Object.keys(e))this.presence[i]=e[i];this.context.setPresenceChange({type:"put",presence:Wt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const nh="000000000000000000000000";class Dt{constructor(e,t,i){d(this,"lamport");d(this,"delimiter");d(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=i}static of(e,t,i){return new Dt(e,t,i)}static fromStruct(e){return Dt.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new Dt(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const Km=0,Ks=9223372036854775807n,Gt=new Dt(0n,Km,nh);function wi(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}class Vo{constructor(e){d(this,"createdAt");d(this,"movedAt");d(this,"removedAt");this.createdAt=e}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!this.movedAt||e&&e.after(this.movedAt)?(this.movedAt=e,!0):!1}setRemovedAt(e){this.removedAt=e}remove(e){return e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt))?(this.removedAt=e,!0):!1}isRemoved(){return!!this.removedAt}}class rr extends Vo{constructor(e){super(e)}}class Ju{constructor(e,t){d(this,"strKey");d(this,"value");this.strKey=e,this.value=t}static of(e,t){return new Ju(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}}class po{constructor(){d(this,"nodeMapByKey");d(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new po}set(e,t,i){let r;const s=this.nodeMapByKey.get(e);s!=null&&!s.isRemoved()&&s.remove(i)&&(r=s.getValue());const o=Ju.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),o),(s==null||i.after(s.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,o),t.setMovedAt(i)),r}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new v(w.ErrInvalidArgument,`fail to find ${e.toIDString()}`);const i=this.nodeMapByCreatedAt.get(e.toIDString());return i.remove(t),i.getValue()}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new v(w.ErrInvalidArgument,`fail to find ${e.getCreatedAt().toIDString()}`);const i=this.nodeMapByKey.get(t.getStrKey());t===i&&this.nodeMapByKey.delete(i.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){const i=this.nodeMapByKey.get(e);if(i!=null&&i.remove(t))return i.getValue()}has(e){const t=this.nodeMapByKey.get(e);return t==null?!1:!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){const t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(const[,e]of this.nodeMapByKey)yield e}}class nt extends rr{constructor(t,i){super(t);d(this,"memberNodes");this.memberNodes=i}static create(t,i){if(!i)return new nt(t,po.create());const r=po.create();for(const[s,o]of Object.entries(i))r.set(s,o.deepcopy(),o.getCreatedAt());return new nt(t,r)}subPathOf(t){return this.memberNodes.subPathOf(t)}purge(t){this.memberNodes.purge(t)}set(t,i,r){return this.memberNodes.set(t,i,r)}delete(t,i){return this.memberNodes.delete(t,i)}deleteByKey(t,i){return this.memberNodes.deleteByKey(t,i)}get(t){const i=this.memberNodes.get(t);return i==null?void 0:i.getValue()}getByID(t){const i=this.memberNodes.getByID(t);return i==null?void 0:i.getValue()}has(t){return this.memberNodes.has(t)}toJSON(){const t=[];for(const[i,r]of this)t.push(`"${wi(i)}":${r.toJSON()}`);return`{${t.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(const[i,r]of this){const{createdAt:s,value:o,type:a}=r.toJSForTest();t[i]={key:i,createdAt:s,value:o,type:a}}return{createdAt:this.getCreatedAt().toTestString(),value:t,type:"YORKIE_OBJECT"}}getKeys(){const t=Array();for(const[i]of this)t.push(i);return t}toSortedJSON(){var r;const t=Array();for(const[s]of this)t.push(s);const i=[];for(const s of t.sort()){const o=(r=this.memberNodes.get(s))==null?void 0:r.getValue();i.push(`"${wi(s)}":${o.toSortedJSON()}`)}return`{${i.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const t=nt.create(this.getCreatedAt());for(const i of this.memberNodes)t.memberNodes.set(i.getStrKey(),i.getValue().deepcopy(),this.getPositionedAt());return t.remove(this.getRemovedAt()),t}getDescendants(t){for(const i of this.memberNodes){const r=i.getValue();if(t(r,this))return;r instanceof rr&&r.getDescendants(t)}}*[Symbol.iterator](){const t=new Set;for(const i of this.memberNodes)t.has(i.getStrKey())||(t.add(i.getStrKey()),i.isRemoved()||(yield[i.getStrKey(),i.getValue()]))}}var se=(n=>(n.Local="local",n.Remote="remote",n.UndoRedo="undoredo",n))(se||{});class Yt{constructor(e,t){d(this,"parentCreatedAt");d(this,"executedAt");this.parentCreatedAt=e,this.executedAt=t}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new v(w.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}}class eO{constructor(e){d(this,"value");d(this,"left");d(this,"right");d(this,"parent");d(this,"weight");this.value=e,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}}class go{constructor(e){d(this,"root");this.root=e}get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new v(w.ErrInvalidArgument,`out of index range: pos: ${e} > node.length: ${t.getLength()}`);return this.splayNode(t),[t,e]}indexOf(e){return!e||e!==this.root&&!e.hasLinks()?-1:(this.splayNode(e),this.root.getLeftWeight())}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t),t):(this.root=t,t)}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);const t=new go(e.getLeft());t.root&&t.root.setParent();const i=new go(e.getRight());if(i.root&&i.root.setParent(),t.root){const r=t.getRightmost();t.splayNode(r),t.root.setRight(i.root),i.root&&i.root.setParent(t.root),this.root=t.root}else this.root=i.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){const t=[];this.traversePostorder(e.getRight(),t);for(const i of t)i.initWeight();this.updateTreeWeight(e)}toTestString(){const e=[];return this.traverseInorder(this.root,e),e.map(t=>`[${t.getWeight()},${t.getLength()}]${t.getValue()||""}`).join("")}checkWeight(){const e=[];this.traverseInorder(this.root,e);for(const t of e)if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return e&&e.hasParent()?e.getParent().getLeft()===e:!1}isRightChild(e){return e&&e.hasParent()?e.getParent().getRight()===e:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -19,25 +19,25 @@ var bS=Object.defineProperty;var SS=(n,e,t)=>e in n?bS(n,e,{enumerable:!0,config * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var $t=null;try{$t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function Y(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}Y.prototype.__isLong__;Object.defineProperty(Y.prototype,"__isLong__",{value:!0});function ze(n){return(n&&n.__isLong__)===!0}function Rd(n){var e=Math.clz32(n&-n);return n?31-e:e}Y.isLong=ze;var Ed={},Dd={};function Lr(n,e){var t,i,r;return e?(n>>>=0,(r=0<=n&&n<256)&&(i=Dd[n],i)?i:(t=te(n,0,!0),r&&(Dd[n]=t),t)):(n|=0,(r=-128<=n&&n<128)&&(i=Ed[n],i)?i:(t=te(n,n<0?-1:0,!1),r&&(Ed[n]=t),t))}Y.fromInt=Lr;function Ct(n,e){if(isNaN(n))return e?En:Ft;if(e){if(n<0)return En;if(n>=tO)return rO}else{if(n<=-Bd)return tt;if(n+1>=Bd)return nO}return n<0?Ct(-n,e).neg():te(n%ds|0,n/ds|0,e)}Y.fromNumber=Ct;function te(n,e,t){return new Y(n,e,t)}Y.fromBits=te;var Sl=Math.pow;function Yu(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?En:Ft;if(t=t||10,t<2||360)throw Error("interior hyphen");if(i===0)return Yu(n.substring(1),e,t).neg();for(var r=Ct(Sl(t,8)),s=Ft,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*ds+(this.low>>>0):this.high*ds+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,c=h.toString(e);if(o=l,o.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return ze(e)||(e=ei(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(ze(e)||(e=ei(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(tt)?tt:this.not().add(Jr)};C.neg=C.negate;C.add=function(e){ze(e)||(e=ei(e));var t=this.high>>>16,i=this.high&65535,r=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,l=e.low>>>16,h=e.low&65535,c=0,u=0,f=0,p=0;return p+=s+h,f+=p>>>16,p&=65535,f+=r+l,u+=f>>>16,f&=65535,u+=i+a,c+=u>>>16,u&=65535,c+=t+o,c&=65535,te(f<<16|p,c<<16|u,this.unsigned)};C.subtract=function(e){return ze(e)||(e=ei(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(ze(e)||(e=ei(e)),$t){var t=$t.mul(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?En:Ft;if(this.eq(tt))return e.isOdd()?tt:Ft;if(e.eq(tt))return this.isOdd()?tt:Ft;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(qd)&&e.lt(qd))return Ct(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,l=e.high&65535,h=e.low>>>16,c=e.low&65535,u=0,f=0,p=0,g=0;return g+=o*c,p+=g>>>16,g&=65535,p+=s*c,f+=p>>>16,p&=65535,p+=o*h,f+=p>>>16,p&=65535,f+=r*c,u+=f>>>16,f&=65535,f+=s*h,u+=f>>>16,f&=65535,f+=o*l,u+=f>>>16,f&=65535,u+=i*c+r*h+s*l+o*a,u&=65535,te(p<<16|g,u<<16|f,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(ze(e)||(e=ei(e)),e.isZero())throw Error("division by zero");if($t){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?$t.div_u:$t.div_s)(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?En:Ft;var i,r,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return En;if(e.gt(this.shru(1)))return iO;s=En}else{if(this.eq(tt)){if(e.eq(Jr)||e.eq(Lc))return tt;if(e.eq(tt))return Jr;var o=this.shr(1);return i=o.div(e).shl(1),i.eq(Ft)?e.isNegative()?Jr:Lc:(r=this.sub(e.mul(i)),s=i.add(r.div(e)),s)}else if(e.eq(tt))return this.unsigned?En:Ft;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Ft}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(i)/Math.LN2),l=a<=48?1:Sl(2,a-48),h=Ct(i),c=h.mul(e);c.isNegative()||c.gt(r);)i-=l,h=Ct(i,this.unsigned),c=h.mul(e);h.isZero()&&(h=Jr),s=s.add(h),r=r.sub(c)}return s};C.div=C.divide;C.modulo=function(e){if(ze(e)||(e=ei(e)),$t){var t=(this.unsigned?$t.rem_u:$t.rem_s)(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return te(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?Rd(this.low):Rd(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return ze(e)||(e=ei(e)),te(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return ze(e)||(e=ei(e)),te(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return ze(e)||(e=ei(e)),te(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?te(this.low<>>32-e,this.unsigned):te(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):te(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?te(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?te(this.high,0,this.unsigned):te(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?te(this.high,this.low,this.unsigned):e<32?(t=32-e,te(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,te(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?te(this.high,this.low,this.unsigned):e<32?(t=32-e,te(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,te(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?te(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:te(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};Y.fromBytes=function(e,t,i){return i?Y.fromBytesLE(e,t):Y.fromBytesBE(e,t)};Y.fromBytesLE=function(e,t){return new Y(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};Y.fromBytesBE=function(e,t){return new Y(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var $e=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))($e||{});class ge extends Vo{constructor(t,i){super(i);d(this,"valueType");d(this,"value");this.valueType=ge.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,i){return new ge(t,i)}static valueFromBytes(t,i){switch(t){case 0:return null;case 1:return!!i[0];case 2:return i[0]|i[1]<<8|i[2]<<16|i[3]<<24;case 4:{const r=new DataView(i.buffer);return i.forEach(function(s,o){r.setUint8(o,s)}),r.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(i);case 3:return Y.fromBytesLE(Array.from(i));case 6:return i;case 7:return new Date(Y.fromBytesLE(Array.from(i),!0).toNumber());default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${wi(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=ge.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof Y)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return ge.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,i=new Uint8Array(8);return new DataView(i.buffer).setFloat64(0,t,!0),i}case 5:return new TextEncoder().encode(this.value);case 3:{const i=this.value.toBytesLE();return Uint8Array.from(i)}case 6:return this.value;case 7:{const t=this.value,i=Y.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(i)}default:throw new v(w.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class wl extends eO{constructor(t){super(t);d(this,"prev");d(this,"next");this.value=t}static createAfter(t,i){const r=new wl(i),s=t.next;return t.next=r,r.prev=t,r.next=s,s&&(s.prev=r),r}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class mo{constructor(){d(this,"dummyHead");d(this,"last");d(this,"nodeMapByIndex");d(this,"nodeMapByCreatedAt");const e=ge.of(0,Gt);e.setRemovedAt(Gt),this.dummyHead=new wl(e),this.last=this.dummyHead,this.nodeMapByIndex=new go,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new mo}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new v(w.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;i.getNext()&&i.getNext().getPositionedAt().after(t);)i=i.getNext();return i}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,i=t.getCreatedAt()){const r=this.findNextBeforeExecutedAt(e,i),s=wl.createAfter(r,t);r===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(r,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,i){const r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new v(w.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new v(w.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);r!==s&&(!s.getValue().getMovedAt()||i.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(r.getCreatedAt(),s.getValue(),i),s.getValue().setMovedAt(i))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new v(w.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,i]=this.nodeMapByIndex.find(e);let r=t;if(e===0&&t===this.dummyHead||i>0)do r&&(r=r.getNext());while(r&&r.isRemoved());return r}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const i=this.nodeMapByCreatedAt.get(e.toIDString()),r=i.isRemoved();return i.remove(t)&&!r&&this.nodeMapByIndex.splayNode(i),i.getValue()}deleteByIndex(e,t){const i=this.getByIndex(e);if(i)return i.remove(t)&&this.nodeMapByIndex.splayNode(i),i.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const i=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${i}}`):e.push(`[${i}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class dt extends rr{constructor(t,i){super(t);d(this,"elements");this.elements=i}static create(t,i){if(!i)return new dt(t,mo.create());const r=mo.create();for(const s of i)r.insertAfter(r.getLastCreatedAt(),s.deepcopy());return new dt(t,r)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,i){this.elements.insertAfter(t,i)}moveAfter(t,i,r){this.elements.moveAfter(t,i,r)}get(t){const i=this.elements.getByIndex(t);return i==null?void 0:i.getValue()}getByID(t){const i=this.elements.getByID(t);return i==null?void 0:i.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,i){return this.elements.delete(t,i)}deleteByIndex(t,i){return this.elements.deleteByIndex(t,i)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const i of this.elements){const r=i.getValue();if(t(r,this))return;r instanceof rr&&r.getDescendants(t)}}toJSON(){const t=[];for(const i of this)t.push(i.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let i=0;i({...g,value:g.value?{attributes:ts(g.value.getAttributes()),content:g.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[c,p,u,[h,h]]}setStyle(t,i,r,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],r),[,l]=this.rgaTreeSplit.findNodeWithSplit(t[0],r),h=[],c=this.rgaTreeSplit.findBetween(l,a),u=new Map,f=[];for(const g of c){const O=g.getCreatedAt().getActorID();let y,S=0n;if(o===void 0&&s===void 0?S=Ks:o.size()>0?S=o.get(O)?o.get(O):0n:y=s.has(O)?s.get(O):Gt,g.canStyle(r,y,S)){const k=u.get(O),$=g.getCreatedAt();(!k||$.after(k))&&u.set(O,$),f.push(g)}}const p=[];for(const g of f){if(g.isRemoved())continue;const[O,y]=this.rgaTreeSplit.findIndexesFromRange(g.createPosRange());h.push({type:"style",actor:r.getActorID(),from:O,to:y,value:{attributes:ts(i)}});for(const[S,k]of Object.entries(i)){const[$]=g.getValue().setAttr(S,k,r);$!==void 0&&p.push({parent:g.getValue(),child:$})}}return[u,p,h]}indexRangeToPosRange(t,i){const r=this.rgaTreeSplit.indexToPos(t);return t===i?[r,r]:[r,this.rgaTreeSplit.indexToPos(i)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const i of this.rgaTreeSplit)i.isRemoved()||t.push(i.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const i of this.rgaTreeSplit)if(!i.isRemoved()){const r=i.getValue();t.push({attributes:ts(r.getAttributes()),content:r.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new qt(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const i of this.rgaTreeSplit){i.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:i});for(const r of i.getValue().getGCPairs())t.push(r)}return t}}class Xo extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"content");d(this,"attributes");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,i,r,s,o,a,l){return new Xo(t,i,r,s,o,a,l)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof qt))throw new v(w.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(const h of l)t.registerGCPair(h);return{opInfos:a.map(({from:h,to:c,value:u})=>({type:"edit",from:h,to:c,value:u,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=this.fromPos.toTestString(),r=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${i},${r},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Uo extends Yt{constructor(t,i,r,s,o,a){super(t,a);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"attributes");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,i,r,s,o,a){return new Uo(t,i,r,s,o,a)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof qt))throw new v(w.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(const h of a)t.registerGCPair(h);return{opInfos:l.map(({from:h,to:c,value:u})=>({type:"style",from:h,to:c,value:u,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=this.fromPos.toTestString(),r=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${i},${r},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const G1=2,J1="root",Dn="text";function Ds(n,e){let t=0;const i=n.children;for(let r=0;r0)throw new v(w.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const i=t.updateDescendantsSize();t.isRemoved||(e+=i)}return this.size+=e,this.paddedSize}get isText(){return this.type===Dn}get paddedSize(){return this.size+(this.isText?0:G1)}isAncestorOf(e){return H1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const i=this.value.slice(0,e),r=this.value.slice(e);if(!r.length)return;this.value=i;const s=this.cloneText(e+t);return s.value=r,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new v(w.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const i=this.cloneElement(t);this.parent.insertAfterInternal(i,this),i.updateAncestorsSize();const r=this.children.slice(0,e),s=this.children.slice(e);this._children=r,i._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),i.size=i._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of i._children)o.parent=i;return i}insertAfterInternal(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i+1)}insertAtInternal(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(r=>!r.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const i=this._children.indexOf(t);if(i!==-1)return i;t=t.parent}return-1}}function H1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var Qe=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(Qe||{});function sO(n,e,t,i){if(e>t)throw new v(w.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new v(w.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new v(w.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let r=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||l)&&i([s,s.isText?"Text":"Start"],h),sO(s,Math.max(0,o),Math.min(a,s.size),i),h&&i([s,"End"],h)}r+=s.paddedSize}}function oO(n,e,t=0){for(const i of n.children)oO(i,e,t+1);e(n,t)}function nh(n,e,t=0){for(const i of n._children)nh(i,e,t+1);e(n,t)}function Xc(n,e,t=!0){if(e>n.size)throw new v(w.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let i=0,r=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-r)return Xc(s,e-r,t);if(e===r)return{node:n,offset:i};if(!t&&s.paddedSize===e-r)return{node:n,offset:i+1};if(s.paddedSize>e-r)return Xc(s,e-r-1,t);r+=s.paddedSize,i+=1}return{node:n,offset:i}}function aO(n){return n.isText||n.children.length===0?n:aO(n.children[0])}function K1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(i<0)if(t.left)t.left.parent=t,t=t.left;else{let r=t.parent,s=t;for(;r&&s===r.left;)s=r,r=r.parent;return r}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const i=this.comparator(e,t.key);if(i===0)return t;i<0?t=t.left:i>0&&(t=t.right)}}putInternal(e,t,i){if(!i)return this.counter+=1,new iw(e,t,!0);const r=this.comparator(e,i.key);return r<0?i.left=this.putInternal(e,t,i.left):r>0?i.right=this.putInternal(e,t,i.right):i.value=t,this.isRed(i.right)&&!this.isRed(i.left)&&(i=this.rotateLeft(i)),this.isRed(i.left)&&this.isRed(i.left.left)&&(i=this.rotateRight(i)),this.isRed(i.left)&&this.isRed(i.right)&&this.flipColors(i),i}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const i=this.min(e.right);e.value=i.value,e.key=i.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class _t{constructor(e,t){d(this,"parentID");d(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new _t(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:i}=e,r;return i.isText?(i.parent.children[0]===i&&t===0?r=i.parent:r=i,i=i.parent):t===0?r=i:r=i.children[t-1],_t.of(i.id,Ve.of(r.getCreatedAt(),r.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return _t.of(Ve.of(Dt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ve.of(Dt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),i=this.getLeftSiblingID(),r=e.findFloorNode(t);let s=e.findFloorNode(i);if(!r||!s)throw new v(w.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${i.toTestString()})`);return!i.equals(t)&&i.getOffset()>0&&i.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[r,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ve{constructor(e,t){d(this,"createdAt");d(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ve(e,t)}static fromStruct(e){return Ve.of(Dt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const i=e.getCreatedAt().compare(t.getCreatedAt());return i!==0?i:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=r.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new v(w.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new v(w.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const i=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),i&&this.updateAncestorsSize()}cloneText(t){return new ut(Ve.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new ut(Ve.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,i,r){const s=this.isText?this.splitText(i,this.id.getOffset()):this.splitElement(i,r);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,i,r){return(i?!this.getCreatedAt().after(i):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,i,r){return this.isText?!1:(i?!this.getCreatedAt().after(i):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,i){this.attrs||(this.attrs=new Vn);const r=[];for(const[s,o]of Object.entries(t))r.push(this.attrs.set(s,o,i));return r}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const i of this.attrs)i.getRemovedAt()&&t.push({parent:this,child:i});return t}}function Uc(n){var t;if(n.isText){const i=n;return{type:i.type,value:i.value}}const e={type:n.type,children:n.children.map(Uc)};return n.attrs&&(e.attributes=ts((t=n.attrs)==null?void 0:t.toObject())),e}function Hu(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,i)=>t.getKey().localeCompare(i.getKey())).map(t=>{const i=JSON.parse(t.getValue());return typeof i=="string"?`${t.getKey()}="${i}"`:`${t.getKey()}="${wi(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>Hu(t)).join("")}`}function hO(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(hO),size:n.size,isRemoved:n.isRemoved}}class Mt extends Vo{constructor(t,i){super(i);d(this,"indexTree");d(this,"nodeMapByID");this.indexTree=new ew(t),this.nodeMapByID=new lO(Ve.createComparator()),this.indexTree.traverseAll(r=>{this.nodeMapByID.put(r.id,r)})}static create(t,i){return new Mt(t,i)}findFloorNode(t){const i=this.nodeMapByID.floorEntry(t);if(!(!i||!i.key.getCreatedAt().equals(t.getCreatedAt())))return i.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,i){const[r,s]=t.toTreeNodePair(this);let o=s;const a=r===o,l=o.parent&&!a?o.parent:r;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),i){const h=l.allChildren,c=a?0:h.indexOf(o)+1;for(let u=c;u{const y=O.getCreatedAt().getActorID();let S,k=0n;if(o===void 0&&s===void 0?k=Ks:o.size()>0?k=o.get(y)?o.get(y):0n:S=s.has(y)?s.get(y):Gt,O.canStyle(r,S,k)&&i){const $=p.get(y),A=O.getCreatedAt();(!$||A.after($))&&p.set(y,A);const x=O.setAttrs(i,r),P=x.reduce((W,[,z])=>(z&&(W[z.getKey()]=f[z.getKey()]),W),{}),R=O.parent,X=O.prevSibling||O.parent;Object.keys(P).length>0&&u.push({type:"style",from:this.toIndex(R,X),to:this.toIndex(O,O),fromPath:this.toPath(R,X),toPath:this.toPath(O,O),actor:r.getActorID(),value:P});for(const[W]of x)W&&g.push({parent:O,child:W})}}),[p,g,u]}removeStyle(t,i,r,s,o){const[a,l]=this.findNodesAndSplitText(t[0],r),[h,c]=this.findNodesAndSplitText(t[1],r),u=[],f=new Map,p=[];return this.traverseInPosRange(a,l,h,c,([g])=>{const O=g.getCreatedAt().getActorID();let y,S=0n;if(o===void 0&&s===void 0?S=Ks:o.size()>0?S=o.get(O)?o.get(O):0n:y=s.has(O)?s.get(O):Gt,g.canStyle(r,y,S)&&i){const k=f.get(O),$=g.getCreatedAt();(!k||$.after(k))&&f.set(O,$),g.attrs||(g.attrs=new Vn);for(const P of i){const R=g.attrs.remove(P,r);for(const X of R)p.push({parent:g,child:X})}const A=g.parent,x=g.prevSibling||g.parent;u.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(A,x),to:this.toIndex(g,g),fromPath:this.toPath(A,x),toPath:this.toPath(g,g),value:i})}}),[f,p,u]}edit(t,i,r,s,o,a,l){const[h,c]=this.findNodesAndSplitText(t[0],s),[u,f]=this.findNodesAndSplitText(t[1],s),p=this.toIndex(h,c),g=this.toPath(h,c),O=[],y=[],S=[],k=new Map;this.traverseInPosRange(h,c,u,f,([x,P],R)=>{if(P===Qe.Start&&!R)for(const H of x.children)S.push(H);const X=x.getCreatedAt().getActorID();let W,z=0n;if(l===void 0&&a===void 0?z=Ks:l.size()>0?z=l.get(X)?l.get(X):0n:W=a.has(X)?a.get(X):Gt,x.canDelete(s,W,z)||O.includes(x.parent)){const H=k.get(X),Oe=x.getCreatedAt();(!H||Oe.after(H))&&k.set(X,Oe),(P===Qe.Text||P===Qe.Start)&&O.push(x),y.push([x,P])}});const $=this.makeDeletionChanges(y,s),A=[];for(const x of O)x.remove(s),x.isRemoved&&A.push({parent:this,child:x});for(const x of S)x.removedAt||h.append(x);if(r>0){let x=0,P=h,R=c;for(;x{h.isRemoved&&(X.remove(s),A.push({parent:this,child:X})),this.nodeMapByID.put(X.id,X)}),R.isRemoved||x.push(R);if(x.length){const R=x.map(X=>Uc(X));$.length&&$[$.length-1].from===p?$[$.length-1].value=R:$.push({type:"content",from:p,to:p,fromPath:g,toPath:g,actor:s.getActorID(),value:R})}}return[$,A,k]}editT(t,i,r,s,o){const a=this.findPos(t[0]),l=this.findPos(t[1]);this.edit([a,l],i,r,s,o)}move(t,i,r){throw new v(w.ErrUnimplemented,`not implemented: ${t}, ${i}, ${r}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const i=t.insPrevID,r=t.insNextID;if(i){const o=this.findFloorNode(i);o.insNextID=r}if(r){const o=this.findFloorNode(r);o.insPrevID=i}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(i=>{i.getRemovedAt()&&t.push({parent:this,child:i});for(const r of i.getGCPairs())t.push(r)}),t}findPos(t,i=!0){const r=this.indexTree.findTreePos(t,i);return _t.fromTreePos(r)}pathToPosRange(t){const i=this.pathToIndex(t);return[this.findPos(i),this.findPos(i+1)]}pathToPos(t){const i=this.indexTree.pathToIndex(t);return this.findPos(i)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Hu(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),i=(r,s=void 0,o=void 0,a=0)=>{var p,g,O,y;let l,h,c;const u=r.isText?{node:r,offset:0}:s&&o?this.toTreePos(s,o):null;u&&(l=this.indexTree.indexOf(u),h=this.indexTree.treePosToPath(u),c=_t.fromTreePos(u).toStruct());const f={type:r.type,parent:s==null?void 0:s.id.toTestString(),size:r.size,id:r.id.toTestString(),removedAt:(p=r.removedAt)==null?void 0:p.toTestString(),insPrev:(g=r.insPrevID)==null?void 0:g.toTestString(),insNext:(O=r.insNextID)==null?void 0:O.toTestString(),value:r.isText?r.value:void 0,isRemoved:r.isRemoved,children:[],depth:a,attributes:r.attrs?ts((y=r.attrs)==null?void 0:y.toObject()):void 0,index:l,path:h,pos:c};for(let S=0;S0&&S===r[r.length-1].to?(r[r.length-1].to=k,r[r.length-1].toPath=this.toPath(y,p)):r.push({type:"content",from:S,to:k,fromPath:this.toPath(O,u),toPath:this.toPath(y,p),actor:i.getActorID()}))}return r.reverse()}findRightToken([t,i]){if(i===Qe.Start){const l=t.allChildren;return l.length>0?[l[0],l[0].isText?Qe.Text:Qe.Start]:[t,Qe.End]}const r=t.parent,s=r.allChildren,o=s.indexOf(t);if(r&&o===s.length-1)return[r,Qe.End];const a=s[o+1];return[a,a.isText?Qe.Text:Qe.Start]}findLeftToken([t,i]){if(i===Qe.End){const l=t.allChildren;if(l.length>0){const h=l[l.length-1];return[h,h.isText?Qe.Text:Qe.End]}return[t,Qe.Start]}const r=t.parent,s=r.allChildren,o=s.indexOf(t);if(r&&o===0)return[r,Qe.Start];const a=s[o-1];return[a,a.isText?Qe.Text:Qe.End]}}class Zo extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"contents");d(this,"splitLevel");d(this,"maxCreatedAtMapByActor");this.fromPos=i,this.toPos=r,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,i,r,s,o,a,l){return new Zo(t,i,r,s,o,a,l)}execute(t,i,r){var c;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Mt))throw new v(w.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[l,h]=a.edit([this.fromPos,this.toPos],(c=this.contents)==null?void 0:c.map(u=>u.deepcopy()),this.splitLevel,o,(()=>{let u=o.getDelimiter();return this.contents!==void 0&&(u+=this.contents.length),()=>Dt.of(o.getLamport(),++u,o.getActorID())})(),this.maxCreatedAtMapByActor,r);for(const u of h)t.registerGCPair(u);return{opInfos:l.map(({from:u,to:f,value:p,splitLevel:g,fromPath:O,toPath:y})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:u,to:f,value:p,splitLevel:g,fromPath:O,toPath:y}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${i},${r},${s.map(o=>Hu(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class is{constructor(e){d(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[i,r]of e){const s=this.vector.get(i),o=s&&s>r?s:r;t.set(i,o)}for(const[i,r]of this){const s=e.get(i),o=s&&s>r?s:r;t.set(i,o)}return new is(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,i]of this.vector)e.set(t,i);return new is(e)}filter(e){const t=new Map;for(const[i]of e){const r=this.vector.get(i);r!==void 0&&t.set(i,r)}return new is(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const rw=new is(new Map);class An{constructor(e,t,i,r,s){d(this,"clientSeq");d(this,"serverSeq");d(this,"lamport");d(this,"actor");d(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=r,this.actor=i}static of(e,t,i,r,s){return new An(e,t,i,r,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new An(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,i=this.versionVector.max(e.versionVector),r=new An(this.clientSeq,t,this.actor,i);return r.versionVector.set(this.actor,t),r}setClocks(e,t){const i=e>this.lamport?e:this.lamport+1n,r=this.versionVector.max(t);return r.set(this.actor,i),An.of(this.clientSeq,i,this.actor,r)}createTimeTicket(e){return Dt.of(this.lamport,e,this.actor)}setActor(e){return new An(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new An(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const sw=new An(0,0n,Gu,rw);class ps{constructor({id:e,operations:t,presenceChange:i,message:r}){d(this,"id");d(this,"operations");d(this,"presenceChange");d(this,"message");this.id=e,this.operations=t||[],this.presenceChange=i,this.message=r}static create({id:e,operations:t,presenceChange:i,message:r}){return new ps({id:e,operations:t,presenceChange:i,message:r})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,i){const r=[],s=[];for(const o of this.operations){const a=o.execute(e,i,this.id.getVersionVector());if(!a)continue;const{opInfos:l,reverseOp:h}=a;r.push(...l),h&&s.unshift(h)}return this.presenceChange&&(this.presenceChange.type===cr.Put?t.set(this.id.getActorID(),Wt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:r,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:ke.bytesToHex(ke.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>ke.bytesToHex(ke.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:i,presenceChange:r,message:s}=e;return ps.create({id:ke.bytesToChangeID(ke.hexToBytes(t)),operations:i==null?void 0:i.map(o=>ke.bytesToOperation(ke.hexToBytes(o))),presenceChange:r,message:s})}}class rh{constructor(e,t,i,r,s,o,a){d(this,"documentKey");d(this,"checkpoint");d(this,"isRemoved");d(this,"changes");d(this,"snapshot");d(this,"minSyncedTicket");d(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=i,this.changes=r,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,i,r,s,o,a){return new rh(e,t,i,r,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class ns{constructor(e,t){d(this,"serverSeq");d(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new ns(e,t)}increaseClientSeq(e){return e===0?this:new ns(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,i=Math.max(this.clientSeq,e.clientSeq);return ns.of(t,i)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const ow=new ns(0n,0);class Ti{constructor(e,t){d(this,"createdAt");d(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ti(e,t)}static fromStruct(e){return Ti.of(Dt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new Ti(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const aw=Ti.of(Gt,0);class Jt{constructor(e,t){d(this,"id");d(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Jt(e,t)}static fromStruct(e){const t=Ti.fromStruct(e.id);return Jt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return Ti.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class sr extends eO{constructor(t,i,r){super(i);d(this,"id");d(this,"removedAt");d(this,"prev");d(this,"next");d(this,"insPrev");d(this,"insNext");this.id=t,this.removedAt=r}static create(t,i){return new sr(t,i)}static createComparator(){return(t,i)=>{const r=t.getCreatedAt().compare(i.getCreatedAt());return r!==0?r:t.getOffset()>i.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const i=[];let r=e;for(;r&&r!==t;)i.push(r),r=r.getNext();return i}splitNode(e,t){if(t>e.getContentLength())throw new v(w.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const i=e.split(t);this.treeByIndex.updateWeight(i),this.insertAfter(e,i);const r=e.getInsNext();return r&&r.setInsPrev(i),i.setInsPrev(e),i}deleteNodes(e,t,i,r){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,i,r),a=new Map,l=new Map,h=this.makeChanges(o,t);for(const c of s){const u=c.getCreatedAt().getActorID();(!a.has(u)||c.getID().getCreatedAt().after(a.get(u)))&&a.set(u,c.getID().getCreatedAt()),l.set(c.getID().toIDString(),c),c.remove(t)}return this.deleteIndexNodes(o),[h,a,l]}filterNodes(e,t,i,r){const s=[],o=[],[a,l]=this.findEdgesOfCandidates(e);o.push(a);for(const h of e){const c=h.getCreatedAt().getActorID();let u,f=0n;r===void 0&&i===void 0?f=Ks:r.size()>0?f=r.get(c)?r.get(c):0n:u=i.has(c)?i.get(c):Gt,h.canDelete(t,u,f)?s.push(h):o.push(h)}return o.push(l),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const i=[];let r,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var Pi=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(Pi||{});class pt extends Vo{constructor(t,i,r){super(r);d(this,"valueType");d(this,"value");switch(this.valueType=t,t){case 0:typeof i=="number"?i>Math.pow(2,31)-1||i<-Math.pow(2,31)?this.value=Y.fromNumber(i).toInt():this.value=Md(i):this.value=i.toInt();break;case 1:typeof i=="number"?this.value=Y.fromNumber(i):this.value=i;break;default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,i,r){return new pt(t,i,r)}static valueFromBytes(t,i){switch(t){case 0:return i[0]|i[1]<<8|i[2]<<16|i[3]<<24;case 1:return Y.fromBytesLE(Array.from(i));default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=pt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof Y?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!pt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const i=this.value.toBytesLE();return Uint8Array.from(i)}default:throw new v(w.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function i(r){if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`)}return i(this),i(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===$e.Long?this.value=this.value+t.getValue().toInt():this.value=Y.fromNumber(this.value+Md(t.getValue())).toInt(),this}}class ms extends Yt{constructor(t,i,r){super(t,r);d(this,"value");this.value=i}static create(t,i,r){return new ms(t,i,r)}execute(t){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof pt))throw new v(w.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const r=i,s=this.value.deepcopy();return r.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),r=t.getType()===$e.Long?t.getValue().multiply(-1):t.getValue()*-1;return ms.create(this.getParentCreatedAt(),ge.of(r,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Nn extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"attributes");d(this,"attributesToRemove");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,i,r,s,o,a){return new Nn(t,i,r,s,o,[],a)}static createTreeRemoveStyleOperation(t,i,r,s,o,a){return new Nn(t,i,r,s,new Map,o,a)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Mt))throw new v(w.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,l;if(this.attributes.size){const h={};[...this.attributes].forEach(([c,u])=>h[c]=u),[,l,a]=o.style([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{const h=this.attributesToRemove;[,l,a]=o.removeStyle([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(const h of l)t.registerGCPair(h);return{opInfos:a.map(({from:h,to:c,value:u,fromPath:f,toPath:p})=>({type:"tree-style",from:h,to:c,value:this.attributes.size?{attributes:u}:{attributesToRemove:u},fromPath:f,toPath:p,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${i},${r},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function lw(n){const e=new _u,t=e.data;for(const[i,r]of Object.entries(n))t[i]=JSON.stringify(r);return e}function hw(n){if(n.type===cr.Put)return new fo({type:Dr.PUT,presence:lw(n.presence)});if(n.type===cr.Clear)return new fo({type:Dr.CLEAR});throw new v(w.ErrUnimplemented,"unimplemented type")}function cw(n){return new Ym({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function cO(n){return new th({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:cf(n.getActorID()),versionVector:Ku(n.getVersionVector())})}function L(n){if(n)return new M({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:cf(n.getActorID())})}function Ku(n){if(!n)return;const e=new ih;for(const[t,i]of n)e.vector[t]=BigInt(i.toString());return e}function uO(n){switch(n){case $e.Null:return F.NULL;case $e.Boolean:return F.BOOLEAN;case $e.Integer:return F.INTEGER;case $e.Long:return F.LONG;case $e.Double:return F.DOUBLE;case $e.String:return F.STRING;case $e.Bytes:return F.BYTES;case $e.Date:return F.DATE;default:throw new v(w.ErrInvalidType,`unsupported type: ${n}`)}}function fO(n){switch(n){case Pi.IntegerCnt:return F.INTEGER_CNT;case Pi.LongCnt:return F.LONG_CNT;default:throw new v(w.ErrInvalidType,`unsupported type: ${n}`)}}function Ch(n){if(n instanceof nt)return new mt({type:F.JSON_OBJECT,createdAt:L(n.getCreatedAt()),value:TO(n)});if(n instanceof dt)return new mt({type:F.JSON_ARRAY,createdAt:L(n.getCreatedAt()),value:Xw(n)});if(n instanceof qt)return new mt({type:F.TEXT,createdAt:L(n.getCreatedAt())});if(n instanceof ge)return new mt({type:uO(n.getType()),createdAt:L(n.getCreatedAt()),value:n.toBytes()});if(n instanceof pt)return new mt({type:fO(n.getType()),createdAt:L(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Mt)return new mt({type:F.TREE,createdAt:L(n.getCreatedAt()),value:Zw(n)});throw new v(w.ErrUnimplemented,"unimplemented element")}function uw(n){return new uo({createdAt:L(n.getCreatedAt()),offset:n.getOffset()})}function ia(n){return new Mn({createdAt:L(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function na(n){return new Er({parentId:eo(n.getParentID()),leftSiblingId:eo(n.getLeftSiblingID())})}function eo(n){return new nr({createdAt:L(n.getCreatedAt()),offset:n.getOffset()})}function dO(n){const e=new zu;if(n instanceof Nr){const t=n,i=new nl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.key=t.getKey(),i.value=Ch(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="set",e.body.value=i}else if(n instanceof Lo){const t=n,i=new rl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.prevCreatedAt=L(t.getPrevCreatedAt()),i.value=Ch(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="add",e.body.value=i}else if(n instanceof Kn){const t=n,i=new sl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.prevCreatedAt=L(t.getPrevCreatedAt()),i.createdAt=L(t.getCreatedAt()),i.executedAt=L(t.getExecutedAt()),e.body.case="move",e.body.value=i}else if(n instanceof ur){const t=n,i=new ol;i.parentCreatedAt=L(t.getParentCreatedAt()),i.createdAt=L(t.getCreatedAt()),i.executedAt=L(t.getExecutedAt()),e.body.case="remove",e.body.value=i}else if(n instanceof Xo){const t=n,i=new al;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=ia(t.getFromPos()),i.to=ia(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);i.content=t.getContent();const s=i.attributes;for(const[o,a]of t.getAttributes())s[o]=a;i.executedAt=L(t.getExecutedAt()),e.body.case="edit",e.body.value=i}else if(n instanceof Uo){const t=n,i=new ll;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=ia(t.getFromPos()),i.to=ia(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);const s=i.attributes;for(const[o,a]of t.getAttributes())s[o]=a;i.executedAt=L(t.getExecutedAt()),e.body.case="style",e.body.value=i}else if(n instanceof ms){const t=n,i=new hl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.value=Ch(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="increase",e.body.value=i}else if(n instanceof Zo){const t=n,i=new cl,r=i.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())r[s]=L(o);i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=na(t.getFromPos()),i.to=na(t.getToPos()),i.contents=yw(t.getContents()),i.splitLevel=t.getSplitLevel(),i.executedAt=L(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=i}else if(n instanceof Nn){const t=n,i=new ul;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=na(t.getFromPos()),i.to=na(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);const s=t.getAttributesToRemove();if(s.length>0)i.attributesToRemove=s;else{const o=i.attributes;for(const[a,l]of t.getAttributes())o[a]=l}i.executedAt=L(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=i}else throw new v(w.ErrUnimplemented,"unimplemented operation");return e}function fw(n){const e=[];for(const t of n)e.push(dO(t));return e}function dw(n){const e=new _m({id:cO(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=fw(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=hw(n.getPresenceChange())),e}function pw(n){const e=[];for(const t of n)e.push(dw(t));return e}function gw(n){const e=[];for(const t of n)e.push(new Gm({key:t.getStrKey(),element:tf(t.getValue())}));return e}function mw(n){const e=[];for(const t of n)e.push(new yl({element:tf(t.getValue())}));return e}function Ow(n){const e=[];for(const t of n){const i=new Jm;i.id=uw(t.getID()),i.value=t.getValue().getContent(),i.removedAt=L(t.getRemovedAt());const r=i.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new us;a.value=o.getValue(),a.updatedAt=L(o.getUpdatedAt()),r[o.getKey()]=a}e.push(i)}return e}function yw(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new bl({content:ef(t)}));return e}function bw(n){const e={};for(const t of n)e[t.getKey()]=new us({value:t.getValue(),updatedAt:L(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function ef(n){if(!n)return[];const e=[];return nh(n,(t,i)=>{const r=new Fu({id:eo(t.id),type:t.type,removedAt:L(t.removedAt),depth:i});t.isText&&(r.value=t.value),t.insPrevID&&(r.insPrevId=eo(t.insPrevID)),t.insNextID&&(r.insNextId=eo(t.insNextID)),t.attrs&&(r.attributes=bw(t.attrs)),e.push(r)}),e}function Sw(n){const e=new rt;return e.body.case="jsonObject",e.body.value=new fl({nodes:gw(n.getRHT()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function pO(n){const e=new rt;return e.body.case="jsonArray",e.body.value=new dl({nodes:mw(n.getElements()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function ww(n){const e=new rt;return e.body.case="primitive",e.body.value=new pl({type:uO(n.getType()),value:n.toBytes(),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function vw(n){const e=new rt;return e.body.case="text",e.body.value=new gl({nodes:Ow(n.getRGATreeSplit()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function kw(n){const e=new rt;return e.body.case="counter",e.body.value=new ml({type:fO(n.getType()),value:n.toBytes(),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function gO(n){const e=new rt;return e.body.case="tree",e.body.value=new Ol({nodes:ef(n.getRoot()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function tf(n){if(n instanceof nt)return Sw(n);if(n instanceof dt)return pO(n);if(n instanceof ge)return ww(n);if(n instanceof qt)return vw(n);if(n instanceof pt)return kw(n);if(n instanceof Mt)return gO(n);throw new v(w.ErrUnimplemented,"unimplemented element")}function xw(n){return new Wn({documentKey:n.getDocumentKey(),checkpoint:cw(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:pw(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Ku(n.getVersionVector()),minSyncedTicket:L(n.getMinSyncedTicket())})}function js(n){if(!(n instanceof ue))return{};const e=n.findDetails(Z1);for(const t of e)return t.metadata;return{}}function Wr(n){return js(n).code??""}function mO(n){return An.of(n.clientSeq,BigInt(n.lamport),lf(n.actorId),nf(n.versionVector),BigInt(n.serverSeq))}function nf(n){if(!n)return;const e=new is;return Object.entries(n.vector).forEach(([t,i])=>{e.set(t,BigInt(i.toString()))}),e}function U(n){if(n)return Dt.of(BigInt(n.lamport),n.delimiter,lf(n.actorId))}function rf(n){const e={};return Object.entries(n.data).forEach(([t,i])=>{e[t]=JSON.parse(i)}),e}function Tw(n){const e=n.type;if(e===Dr.PUT){const t=rf(n.presence);return{type:cr.Put,presence:t}}if(e===Dr.CLEAR)return{type:cr.Clear};throw new v(w.ErrInvalidType,`unsupported type: ${e}`)}function Qw(n){const e=new Map;return Object.entries(n).forEach(([t,i])=>{e.set(t,rf(i))}),e}function OO(n){switch(n){case F.NULL:return $e.Null;case F.BOOLEAN:return $e.Boolean;case F.INTEGER:return $e.Integer;case F.LONG:return $e.Long;case F.DOUBLE:return $e.Double;case F.STRING:return $e.String;case F.BYTES:return $e.Bytes;case F.DATE:return $e.Date}throw new v(w.ErrUnimplemented,`unimplemented value type: ${n}`)}function vl(n){switch(n){case F.INTEGER_CNT:return Pi.IntegerCnt;case F.LONG_CNT:return Pi.LongCnt}throw new v(w.ErrUnimplemented,`unimplemented value type: ${n}`)}function Ih(n){switch(n.type){case F.JSON_OBJECT:return n.value?xO(n.value):nt.create(U(n.createdAt));case F.JSON_ARRAY:return n.value?Lw(n.value):dt.create(U(n.createdAt));case F.TEXT:return qt.create(gs.create(),U(n.createdAt));case F.TREE:return Uw(n.value);case F.NULL:case F.BOOLEAN:case F.INTEGER:case F.LONG:case F.DOUBLE:case F.STRING:case F.BYTES:case F.DATE:return ge.of(ge.valueFromBytes(OO(n.type),n.value),U(n.createdAt));case F.INTEGER_CNT:case F.LONG_CNT:return pt.create(vl(n.type),pt.valueFromBytes(vl(n.type),n.value),U(n.createdAt))}}function ra(n){return Jt.of(Ti.of(U(n.createdAt),n.offset),n.relativeOffset)}function yO(n){return Ti.of(U(n.createdAt),n.offset)}function Pw(n){const e=Oo.create(n.value);Object.entries(n.attributes).forEach(([i,r])=>{e.setAttr(i,r.value,U(r.updatedAt))});const t=sr.create(yO(n.id),e);return t.remove(U(n.removedAt)),t}function jr(n){return _t.of(to(n.parentId),to(n.leftSiblingId))}function to(n){return Ve.of(U(n.createdAt),n.offset)}function Aw(n){if(!n.length)return;const e=[];return n.forEach(t=>{const i=sf(t.content);e.push(i)}),e}function sf(n){if(n.length===0)return;const e=[];for(const r of n)e.push(Cw(r));const t=e[e.length-1],i=new Map;i.set(n[e.length-1].depth,e[e.length-1]);for(let r=e.length-2;r>=0;r--)i.get(n[r].depth-1).prepend(e[r]),i.set(n[r].depth,e[r]);return t.updateDescendantsSize(),Mt.create(t,Gt).getRoot()}function $w(n){const e=Vn.create();for(const[t,i]of Object.entries(n))e.setInternal(t,i.value,U(i.updatedAt),i.isRemoved);return e}function Cw(n){const e=to(n.id),t=ut.create(e,n.type),i=Object.entries(n.attributes);return t.isText?t.value=n.value:i.length&&(t.attrs=$w(n.attributes)),n.insPrevId&&(t.insPrevID=to(n.insPrevId)),n.insNextId&&(t.insNextID=to(n.insNextId)),t.removedAt=U(n.removedAt),t}function bO(n){if(n.body.case==="set"){const e=n.body.value;return Nr.create(e.key,Ih(e.value),U(e.parentCreatedAt),U(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Lo.create(U(e.parentCreatedAt),U(e.prevCreatedAt),Ih(e.value),U(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Kn.create(U(e.parentCreatedAt),U(e.prevCreatedAt),U(e.createdAt),U(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return ur.create(U(e.parentCreatedAt),U(e.createdAt),U(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,U(s))});const i=new Map;return Object.entries(e.attributes).forEach(([r,s])=>{i.set(r,s)}),Xo.create(U(e.parentCreatedAt),ra(e.from),ra(e.to),t,e.content,i,U(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,U(s))});const i=new Map;return Object.entries(e.attributes).forEach(([r,s])=>{i.set(r,s)}),Uo.create(U(e.parentCreatedAt),ra(e.from),ra(e.to),t,i,U(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ms.create(U(e.parentCreatedAt),Ih(e.value),U(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([i,r])=>{t.set(i,U(r))}),Zo.create(U(e.parentCreatedAt),jr(e.from),jr(e.to),Aw(e.contents),e.splitLevel,t,U(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,i=e.attributesToRemove,r=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{r.set(s,U(o))}),(i==null?void 0:i.length)>0?Nn.createTreeRemoveStyleOperation(U(e.parentCreatedAt),jr(e.from),jr(e.to),r,i,U(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),Nn.create(U(e.parentCreatedAt),jr(e.from),jr(e.to),r,t,U(e.executedAt)))}else throw new v(w.ErrUnimplemented,"unimplemented operation")}}function Iw(n){const e=[];for(const t of n){const i=bO(t);i&&e.push(i)}return e}function SO(n){const e=[];for(const t of n)e.push(ps.create({id:mO(t.id),operations:Iw(t.operations),presenceChange:t.presenceChange?Tw(t.presenceChange):void 0,message:t.message}));return e}function Rw(n){return ns.of(BigInt(n.serverSeq),n.clientSeq)}function Ew(n){return rh.create(n.documentKey,Rw(n.checkpoint),n.isRemoved,SO(n.changes),nf(n.versionVector),n.snapshot,U(n.minSyncedTicket))}function wO(n){const e=new po;for(const i of n.nodes){const r=of(i.element);e.set(i.key,r,r.getPositionedAt())}const t=new nt(U(n.createdAt),e);return t.setMovedAt(U(n.movedAt)),t.setRemovedAt(U(n.removedAt)),t}function vO(n){const e=new mo;for(const i of n.nodes)e.insert(of(i.element));const t=new dt(U(n.createdAt),e);return t.setMovedAt(U(n.movedAt)),t.setRemovedAt(U(n.removedAt)),t}function Dw(n){const e=ge.of(ge.valueFromBytes(OO(n.type),n.value),U(n.createdAt));return e.setMovedAt(U(n.movedAt)),e.setRemovedAt(U(n.removedAt)),e}function Nw(n){const e=new gs;let t=e.getHead();for(const r of n.nodes){const s=e.insertAfter(t,Pw(r));r.insPrevId&&s.setInsPrev(e.findNode(yO(r.insPrevId))),t=s}const i=new qt(e,U(n.createdAt));return i.setMovedAt(U(n.movedAt)),i.setRemovedAt(U(n.removedAt)),i}function Bw(n){const e=pt.create(vl(n.type),pt.valueFromBytes(vl(n.type),n.value),U(n.createdAt));return e.setMovedAt(U(n.movedAt)),e.setRemovedAt(U(n.removedAt)),e}function kO(n){const e=sf(n.nodes);return Mt.create(e,U(n.createdAt))}function of(n){if(n.body.case==="jsonObject")return wO(n.body.value);if(n.body.case==="jsonArray")return vO(n.body.value);if(n.body.case==="primitive")return Dw(n.body.value);if(n.body.case==="text")return Nw(n.body.value);if(n.body.case==="counter")return Bw(n.body.value);if(n.body.case==="tree")return kO(n.body.value);throw new v(w.ErrUnimplemented,"unimplemented element")}function qw(n){if(!n)return{root:nt.create(Gt),presences:new Map};const e=Oc.fromBinary(n);return{root:of(e.root),presences:Qw(e.presences)}}function Mw(n){const e=Ku(n);return af(e.toBinary())}function Vw(n){const e=hf(n),t=ih.fromBinary(e);return nf(t)}function xO(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return wO(e.body.value)}function TO(n){return tf(n).toBinary()}function Lw(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return vO(e.body.value)}function Xw(n){return pO(n).toBinary()}function Uw(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return kO(e.body.value)}function Zw(n){return gO(n).toBinary()}function af(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function lf(n){return af(n)}function hf(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function cf(n){return hf(n)}function Ww(n){const e=th.fromBinary(n);return mO(e)}function jw(n){const e=zu.fromBinary(n);return bO(e)}const ke={fromPresence:rf,toChangePack:xw,fromChangePack:Ew,fromChanges:SO,toTreeNodes:ef,fromTreeNodes:sf,objectToBytes:TO,bytesToObject:xO,bytesToSnapshot:qw,bytesToHex:af,hexToBytes:hf,toHexString:lf,toUint8Array:cf,toOperation:dO,toChangeID:cO,PbChangeID:th,bytesToChangeID:Ww,bytesToOperation:jw,versionVectorToHex:Mw,hexToVersionVector:Vw};var Ge=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Ge||{});let vr=3;function QO(n){vr=n}const Z={trivial:(...n)=>{vr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{vr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{vr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{vr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{vr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>vr<=n};function PO(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class zw{constructor(e,t,i,r,s){d(this,"reconnectStreamDelay");d(this,"doc");d(this,"docID");d(this,"syncMode");d(this,"remoteChangeEventReceived");d(this,"watchStream");d(this,"watchLoopTimerID");d(this,"watchAbortController");d(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=i,this.syncMode=r,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===La.RealtimeSyncOff?!1:this.syncMode===La.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==La.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Rh=()=>{};class Fw{constructor(e){d(this,"finalized",!1);d(this,"observers",[]);d(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,i){let r;if(!e)throw new v(w.ErrInvalidArgument,"missing observer");if(this.finalized)throw new v(w.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?r=e:r={next:e,error:t,complete:i},r.next===void 0&&(r.next=Rh),r.error===void 0&&(r.error=Rh),r.complete===void 0&&(r.complete=Rh);const s=PO(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:r}),this.finalized)try{this.finalError?r.error(this.finalError):r.complete()}catch(a){Z.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(i=>i.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Yr{constructor(e,t,i,r){d(this,"id");d(this,"delimiter");d(this,"message");d(this,"root");d(this,"operations");d(this,"presenceChange");d(this,"previousPresence");d(this,"reversePresenceKeys");this.id=e,this.delimiter=Km,this.root=t,this.operations=[],this.previousPresence=Wt(i),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=r}static create(e,t,i,r){return new Yr(e,t,i,r)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ps.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const i of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(i):this.reversePresenceKeys.delete(i)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class yo{constructor(e){d(this,"rootObject");d(this,"elementPairMapByCreatedAt");d(this,"gcElementSetByCreatedAt");d(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof qt||t instanceof Mt)for(const i of t.getGCPairs())this.registerGCPair(i);return!1})}static create(){return new yo(nt.create(Gt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const i=[];for(;t.parent;){const r=t.element.getCreatedAt(),s=t.parent.subPathOf(r);if(s===void 0)throw new v(w.ErrInvalidArgument,`cant find the given element: ${r.toIDString()}`);i.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return i.unshift("$"),i}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof rr&&e.getDescendants((i,r)=>(this.registerElement(i,r),!1))}deregisterElement(e){let t=0;const i=r=>{const s=r.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return i(e),e instanceof rr&&e.getDescendants(r=>(i(r),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const i=this.elementPairMapByCreatedAt.get(t);i.element instanceof rr&&i.element.getDescendants(r=>(e.add(r.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new yo(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const i of this.gcElementSetByCreatedAt){const r=this.elementPairMapByCreatedAt.get(i),s=r.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(r.parent.purge(r.element),t+=this.deregisterElement(r.element))}for(const[,i]of this.gcPairMap){const r=i.child.getRemovedAt();r&&(e!=null&&e.afterOrEqual(r))&&(i.parent.purge(i.child),this.gcPairMap.delete(i.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function AO(n,e){const t=new bo(n);return new Proxy(e,t.getHandlers())}class bo{constructor(e){d(this,"context");d(this,"handlers");this.context=e,this.handlers={set:(t,i,r)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]=${JSON.stringify(r)}`),bo.setInternal(e,t,i,r),!0),get:(t,i)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]`),i==="getID"?()=>t.getCreatedAt():i==="toJSON"||i==="toString"?()=>t.toJSON():i==="toJS"?()=>t.toJS():i==="toJSForTest"?()=>t.toJSForTest():kr(e,t.get(i))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,i)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]`),bo.deleteInternal(e,t,i),!0)}}static setInternal(e,t,i,r){if(i.includes("."))throw new v(w.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=kl(e,r,s),a=t.set(i,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(Nr.create(i,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const i={};for(const[r,s]of Object.entries(t)){if(r.includes("."))throw new v(w.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=kl(e,s,o);i[r]=a}return i}static deleteInternal(e,t,i){const r=e.issueTimeTicket(),s=t.deleteByKey(i,r);s&&(e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function Gw(n,e){const t=new ye(n,e);return new Proxy(e,t.getHandlers())}function Jw(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function Yw(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class ye{constructor(e,t){d(this,"context");d(this,"handlers");d(this,"array");this.context=e,this.array=t,this.handlers={get:(i,r,s)=>r==="getID"?()=>i.getCreatedAt():r==="getElementByID"?o=>{const a=i.getByID(o);if(!(!a||a.isRemoved()))return _n(e,a)}:r==="getElementByIndex"?o=>{const a=i.get(o);return _n(e,a)}:r==="getLast"?()=>_n(e,i.getLast()):r==="deleteByID"?o=>{const a=ye.deleteInternalByID(e,i,o);return _n(e,a)}:r==="insertAfter"?(o,a)=>{const l=ye.insertAfterInternal(e,i,o,a);return _n(e,l)}:r==="insertBefore"?(o,a)=>{const l=ye.insertBeforeInternal(e,i,o,a);return _n(e,l)}:r==="moveBefore"?(o,a)=>{ye.moveBeforeInternal(e,i,o,a)}:r==="moveAfter"?(o,a)=>{ye.moveAfterInternal(e,i,o,a)}:r==="moveFront"?o=>{ye.moveFrontInternal(e,i,o)}:r==="moveLast"?o=>{ye.moveLastInternal(e,i,o)}:Jw(r)?kr(e,i.get(Number(r))):r==="push"?o=>ye.pushInternal(e,i,o):r==="splice"?(o,a,...l)=>ye.splice(e,i,o,a,...l):r==="length"?i.length:typeof r=="symbol"&&r===Symbol.iterator?ye.iteratorInternal.bind(this,e,i):r==="includes"?(o,a)=>ye.includes(e,i,o,a):r==="indexOf"?(o,a)=>ye.indexOf(e,i,o,a):r==="lastIndexOf"?(o,a)=>ye.lastIndexOf(e,i,o,a):r==="toJSForTest"?()=>i.toJSForTest():r==="toTestString"?()=>ye.toTestString(i):typeof r=="string"&&Yw(r)?(...o)=>{const a=Array.from(i).map(l=>kr(e,l));return Array.prototype[r].apply(a,o)}:Reflect.get(i,r,s),deleteProperty:(i,r)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`array[${r}]`),ye.deleteInternalByIndex(e,i,Number.parseInt(r)),!0)}}static*iteratorInternal(e,t){for(const i of t)yield _n(e,i)}static buildArrayElements(e,t){const i=[];for(const r of t){const s=e.issueTimeTicket(),o=kl(e,r,s);i.push(o)}return i}static pushInternal(e,t,i){return ye.insertAfterInternal(e,t,t.getLastCreatedAt(),i),t.length}static moveBeforeInternal(e,t,i,r){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(i);t.moveAfter(o,r,s),e.push(Kn.create(t.getCreatedAt(),o,r,s))}static moveAfterInternal(e,t,i,r){const s=e.issueTimeTicket();t.moveAfter(i,r,s),e.push(Kn.create(t.getCreatedAt(),i,r,s))}static moveFrontInternal(e,t,i){const r=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),i,r),e.push(Kn.create(t.getCreatedAt(),s.getCreatedAt(),i,r))}static moveLastInternal(e,t,i){const r=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,i,r),e.push(Kn.create(t.getCreatedAt(),s,i,r))}static insertAfterInternal(e,t,i,r){const s=e.issueTimeTicket(),o=kl(e,r,s);return t.insertAfter(i,o),e.registerElement(o,t),e.push(Lo.create(t.getCreatedAt(),i,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,i,r){return ye.insertAfterInternal(e,t,t.getPrevCreatedAt(i),r)}static deleteInternalByIndex(e,t,i){const r=e.issueTimeTicket(),s=t.deleteByIndex(i,r);if(s)return e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,i){const r=e.issueTimeTicket(),s=t.delete(i,r);return e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s),s}static splice(e,t,i,r,...s){const o=t.length,a=i>=0?Math.min(i,o):Math.max(o+i,0),l=r===void 0?o:r<0?a:Math.min(a+r,o),h=[];for(let c=a;c=s)return!1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).includes(i,o);for(let l=o;l=s)return-1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).indexOf(i,o);for(let l=o;l=s?s-1:r<0?r+s:r;if(o<0)return-1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).lastIndexOf(i,o);for(let l=o;l>0;l--)if(((a=t.get(l))==null?void 0:a.getID())===i.getID())return l;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}let sh=class{constructor(e,t){d(this,"context");d(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,i,r){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);Z.isEnabled(Ge.Debug)&&Z.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${i}`);const o=r?fs(r):void 0,a=this.context.issueTimeTicket(),[l,,h,c]=this.text.edit(s,i,a,o);for(const u of h)this.context.registerGCPair(u);return this.context.push(new Xo(this.text.getCreatedAt(),s[0],s[1],l,i,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(c)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,i){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.text.indexRangeToPosRange(e,t);Z.isEnabled(Ge.Debug)&&Z.debug(`STYL: f:${e}->${r[0].toTestString()}, t:${t}->${r[1].toTestString()} a:${JSON.stringify(i)}`);const s=fs(i),o=this.context.issueTimeTicket(),[a,l]=this.text.setStyle(r,s,o);for(const h of l)this.context.registerGCPair(h);return this.context.push(new Uo(this.text.getCreatedAt(),r[0],r[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Jt.fromStruct(e[0]),Jt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}};class oh{constructor(e,t){d(this,"valueType");d(this,"value");d(this,"context");d(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new v(w.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),i=ge.of(e,t);if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`);return this.counter.increase(i),this.context.push(ms.create(this.counter.getCreatedAt(),i,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new v(w.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function uf(n,e,t){const{type:i}=n,r=t.issueTimeTicket();if(i===Dn){$O(n);const{value:s}=n,o=ut.create(Ve.of(r,0),i,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!Hm(o)){const h=fs(o);a=new Vn;for(const[c,u]of Object.entries(h))a.set(c,u,r)}const l=ut.create(Ve.of(r,0),i,void 0,a);e.append(l);for(const h of s)uf(h,l,t)}}function Hw(n,e){const{type:t}=e,i=n.issueTimeTicket();let r;if(e.type===Dn){const{value:s}=e;r=ut.create(Ve.of(i,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!Hm(o)){const l=fs(o);a=new Vn;for(const[h,c]of Object.entries(l))a.set(h,c,i)}r=ut.create(Ve.of(n.issueTimeTicket(),0),t,void 0,a);for(const l of s)uf(l,r,n)}return r}function $O(n){if(!n.value.length)throw new v(w.ErrInvalidArgument,"text node cannot have empty value");return!0}function Vd(n){if(!n.length)return!0;if(n[0].type===Dn)for(const t of n){const{type:i}=t;if(i!==Dn)throw new v(w.ErrInvalidArgument,"element node and text node cannot be passed together");$O(t)}else for(const t of n){const{type:i}=t;if(i===Dn)throw new v(w.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}let ah=class{constructor(e){d(this,"initialRoot");d(this,"context");d(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return ut.create(Ve.of(e.issueTimeTicket(),0),J1);const t=ut.create(Ve.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const i of this.initialRoot.children)uf(i,t,e);return t}getSize(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const[i,r]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?fs(t):void 0,[a]=this.tree.style([i,r],o,s);this.context.push(Nn.create(this.tree.getCreatedAt(),i,r,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,i){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=i?fs(i):void 0,[l,h]=this.tree.style([r,s],a,o);for(const c of h)this.context.registerGCPair(c);this.context.push(Nn.create(this.tree.getCreatedAt(),r,s,l,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,i){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,l]=this.tree.removeStyle([r,s],i,o);for(const h of l)this.context.registerGCPair(h);this.context.push(Nn.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),r,s,a,i,o))}editInternal(e,t,i,r=0){var h;if(i.length!==0&&i[0]&&(Vd(i),i[0].type!==Dn))for(const c of i){const{children:u=[]}=c;Vd(u)}const s=this.context.getLastTimeTicket();let o=new Array;if(((h=i[0])==null?void 0:h.type)===Dn){let c="";for(const u of i){const{value:f}=u;c+=f}o.push(ut.create(Ve.of(this.context.issueTimeTicket(),0),Dn,c))}else o=i.map(c=>c&&Hw(this.context,c)).filter(c=>c);const[,a,l]=this.tree.edit([e,t],o.length?o.map(c=>c==null?void 0:c.deepcopy()):void 0,r,s,()=>this.context.issueTimeTicket());for(const c of a)this.context.registerGCPair(c);return this.context.push(Zo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,r,l,s)),!0}editByPath(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new v(w.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,i?[i]:[],r)}editBulkByPath(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new v(w.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,i,r)}edit(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,i?[i]:[],r)}editBulk(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,i,r)}toXML(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],i=this.tree.indexRangeToPosRange(t);return[i[0].toStruct(),i[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[_t.fromStruct(e[0]),_t.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[_t.fromStruct(e[0]),_t.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}};function Ld(n,e){return AO(n,e)}function _n(n,e){if(e){if(e instanceof ge)return e;if(e instanceof nt)return AO(n,e);if(e instanceof dt)return Gw(n,e);if(e instanceof qt)return new sh(n,e);if(e instanceof pt){const t=new oh(Pi.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof Mt){const t=new ah;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function kr(n,e){const t=_n(n,e);return t instanceof ge?t.getValue():t}function kl(n,e,t){let i;if(ge.isSupport(e))i=ge.of(e,t);else if(Array.isArray(e))i=dt.create(t,ye.buildArrayElements(n,e));else if(typeof e=="object")e instanceof sh?(i=qt.create(gs.create(),t),e.initialize(n,i)):e instanceof oh?(i=pt.create(e.getValueType(),e.getValue(),t),e.initialize(n,i)):e instanceof ah?(i=Mt.create(e.buildRoot(n),t),e.initialize(n,i)):i=nt.create(t,bo.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return i}const Xd=50;class Kw{constructor(){d(this,"undoStack",[]);d(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=Xd&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=Xd&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const ev="yorkie-devtools-panel",tv="yorkie-devtools-sdk";let Fr="disconnected";const Ud=new Map,Va=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Va);function sa(n,e){(e!=null&&e.force||Fr!=="disconnected")&&window.postMessage({source:tv,...n},"*")}function iv(n){if(!n.isEnableDevtools()||typeof window>"u"||Ud.has(n.getKey()))return;Va.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(i=>i.type!==Re.StatusChanged&&i.type!==Re.Snapshot&&i.type!==Re.LocalChange&&i.type!==Re.RemoteChange&&i.type!==Re.Initialized&&i.type!==Re.Watched&&i.type!==Re.Unwatched&&i.type!==Re.PresenceChanged)||(Va.get(n.getKey()).push(t),Fr==="synced"&&sa({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});Ud.set(n.getKey(),[e]),sa({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var r;if(((r=t.data)==null?void 0:r.source)!==ev)return;switch(t.data.msg){case"devtools::connect":if(Fr!=="disconnected")break;Fr="connected",sa({msg:"doc::available",docKey:n.getKey()}),Z.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Fr="disconnected",Z.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Fr="synced",sa({msg:"doc::sync::full",docKey:n.getKey(),events:Va.get(n.getKey())}),Z.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Gn=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Gn||{}),Re=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Re||{}),So=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(So||{}),Zc=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Zc||{});class CO{constructor(e,t){d(this,"key");d(this,"status");d(this,"opts");d(this,"changeID");d(this,"checkpoint");d(this,"localChanges");d(this,"root");d(this,"clone");d(this,"eventStream");d(this,"eventStreamObserver");d(this,"onlineClients");d(this,"presences");d(this,"history");d(this,"internalHistory");d(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=yo.create(),this.changeID=sw,this.checkpoint=ow,this.localChanges=[],this.eventStream=_w(i=>{this.eventStreamObserver=i}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Kw,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},iv(this)}update(e,t){if(this.getStatus()==="removed")throw new v(w.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const i=this.changeID.getActorID(),r=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(i)||{},t);try{const s=Ld(r,this.clone.root.getObject());this.presences.has(i)||this.clone.presences.set(i,{}),this.isUpdating=!0,e(s,new $h(r,this.clone.presences.get(i)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(r.hasChange()){Z.isEnabled(Ge.Trivial)&&Z.trivial(`trying to update a local change: ${this.toJSON()}`);const s=r.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,se.Local),l=r.getReversePresence();l&&a.push({type:"presence",value:l}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const h=[];o.length>0&&h.push({type:"local-change",source:se.Local,value:{message:s.getMessage()||"",operations:o,actor:i,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&h.push({type:"presence-changed",source:se.Local,value:{clientID:i,presence:this.getPresence(i)}}),this.publish(h),Z.isEnabled(Ge.Trivial)&&Z.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,i,r){if(typeof e=="string"){if(typeof t!="function")throw new v(w.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||a(h)},i,r)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="presence-changed"||h.type==="presence-changed"&&h.value.clientID!==this.changeID.getActorID()||a(h)},i,r)}if(e==="others"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||h.value.clientID!==this.changeID.getActorID()&&a(h)},i,r)}if(e==="connection"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="connection-changed"&&a(h)},i,r)}if(e==="status"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="status-changed"&&a(h)},i,r)}if(e==="sync"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="sync-status-changed"&&a(h)},i,r)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="local-broadcast"&&a(h)},i)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="broadcast"&&a(h)},i)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="auth-error"&&a(h)},i)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,i,r)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const l of a){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const h=[];for(const c of l.value.operations)this.isSameElementOrChildOf(c.path,s)&&h.push(c);h.length&&o({...l,value:{...l.value,operations:h}})}},i,r)}if(typeof e=="function"){const s=e,o=t,a=i;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="snapshot"&&h.type!=="local-change"&&h.type!=="remote-change"||s(h)},o,a)}throw new v(w.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const i=e.split(".");return t.split(".").every((s,o)=>s===i[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),se.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),Z.isEnabled(Ge.Trivial)&&Z.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Wt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return rh.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Ld(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,i,r=-1){const{root:s,presences:o}=ke.bytesToSnapshot(i);this.root=new yo(s),this.presences=o,this.changeID=this.changeID.setClocks(e,t),this.clone=void 0,this.removePushedLocalChanges(r),this.applyChanges(this.localChanges,se.Local),this.publish([{type:"snapshot",source:se.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?ke.bytesToHex(i):void 0,snapshotVector:ke.versionVectorToHex(t)}}])}applyChanges(e,t){Z.isEnabled(Ge.Debug)&&Z.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),Z.isEnabled(Ge.Trivial)&&Z.trivial(e.map(i=>`${i.getID().toTestString()} ${i.toTestString()}`).join(` -`));for(const i of e)this.applyChange(i,t);Z.isEnabled(Ge.Debug)&&Z.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const i=[],r=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(r)){const o=e.getPresenceChange();switch(o.type){case cr.Put:i.push(this.presences.has(r)?{type:"presence-changed",source:t,value:{clientID:r,presence:o.presence}}:{type:"watched",source:se.Remote,value:{clientID:r,presence:o.presence}});break;case cr.Clear:i.push({type:"unwatched",source:se.Remote,value:{clientID:r,presence:this.getPresence(r)}}),this.removeOnlineClient(r);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;i.push(t===se.Remote?{type:"remote-change",source:t,value:{actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}i.length>0&&this.publish(i)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,i=new Set;for(const r of t)r!==this.changeID.getActorID()&&i.add(r);this.setOnlineClients(i),this.publish([{type:"initialized",source:se.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:i}=e.body.value,r=[];if(t===Rr.DOCUMENT_WATCHED){if(this.onlineClients.has(i)&&this.hasPresence(i))return;this.addOnlineClient(i),this.hasPresence(i)&&r.push({type:"watched",source:se.Remote,value:{clientID:i,presence:this.getPresence(i)}})}else if(t===Rr.DOCUMENT_UNWATCHED){const s=this.getPresence(i);this.removeOnlineClient(i),s&&r.push({type:"unwatched",source:se.Remote,value:{clientID:i,presence:s}})}else if(t===Rr.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;r.push({type:"broadcast",value:{clientID:i,topic:s,payload:JSON.parse(a.decode(o))}})}r.length>0&&this.publish(r)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(Gu),this.publish([{source:e==="removed"?se.Remote:se.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:i,snapshotVector:r}=e.value;if(!t)return;this.applySnapshot(BigInt(i),ke.hexToVersionVector(r),ke.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ps.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:i,presence:r}of e.value)t.add(i),this.presences.set(i,r);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:i}=e.value;this.addOnlineClient(t),this.presences.set(t,i);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:i}=e.value;this.presences.set(t,i)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new v(w.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let i=this.getRoot();for(const r of t)if(i=i[r],i===void 0)return;return i}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Wt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Wt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Wt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Wt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Wt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,i)=>t.clientID>i.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const i=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(i)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new v(w.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new v(w.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of e){if(!(h instanceof Yt)){new $h(t,Wt(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const c=t.issueTimeTicket();h.setExecutedAt(c),t.push(h)}const i=t.getChange();i.execute(this.clone.root,this.clone.presences,se.UndoRedo);const{opInfos:r,reverseOps:s}=i.execute(this.root,this.presences,se.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!i.hasPresenceChange()&&r.length===0)return;this.localChanges.push(i),this.changeID=i.getID();const a=this.changeID.getActorID(),l=[];r.length>0&&l.push({type:"local-change",source:se.UndoRedo,value:{message:i.getMessage()||"",operations:r,actor:a,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:se.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}redo(){if(this.isUpdating)throw new v(w.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new v(w.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of e){if(!(h instanceof Yt)){new $h(t,Wt(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const c=t.issueTimeTicket();h.setExecutedAt(c),t.push(h)}const i=t.getChange();i.execute(this.clone.root,this.clone.presences,se.UndoRedo);const{opInfos:r,reverseOps:s}=i.execute(this.root,this.presences,se.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!i.hasPresenceChange()&&r.length===0)return;this.localChanges.push(i),this.changeID=i.getID();const a=this.changeID.getActorID(),l=[];r.length>0&&l.push({type:"local-change",source:se.UndoRedo,value:{message:i.getMessage()||"",operations:r,actor:a,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:se.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,i){const r={type:"local-broadcast",value:{topic:e,payload:t},options:i};this.publish([r])}getVersionVector(){return this.changeID.getVersionVector()}}function nv(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const rv="yorkie-js-sdk",sv="0.5.6",ov="Yorkie JS SDK",av="./src/yorkie.ts",lv={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},hv=["dist"],cv={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},uv={node:">=18.0.0",npm:">=7.1.0"},fv={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},dv={name:"hackerwins",email:"susukang98@gmail.com"},pv="Apache-2.0",gv={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},mv="https://github.com/yorkie-team/yorkie-js-sdk#readme",Ov={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},yv={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Zd={name:rv,version:sv,description:ov,main:av,publishConfig:lv,files:hv,scripts:cv,engines:uv,repository:fv,author:dv,license:pv,bugs:gv,homepage:mv,devDependencies:Ov,dependencies:yv};function bv(){return n=>async e=>(e.header.set("x-yorkie-user-agent",Zd.name+"/"+Zd.version),await n(e))}const Sv=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var La=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(La||{});const oa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Eh={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class IO{constructor(e,t){d(this,"id");d(this,"key");d(this,"status");d(this,"attachmentMap");d(this,"apiKey");d(this,"authTokenInjector");d(this,"conditions");d(this,"syncLoopDuration");d(this,"reconnectStreamDelay");d(this,"retrySyncLoopDelay");d(this,"rpcClient");d(this,"setAuthToken");d(this,"taskQueue");d(this,"processing",!1);d(this,"keepalive",!1);t=t||oa,this.key=t.key?t.key:PO(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??oa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??oa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??oa.retrySyncLoopDelay;const{authInterceptor:i,setToken:r}=nv(this.apiKey);this.setAuthToken=r,this.rpcClient=b1(U1,X1({baseUrl:e,interceptors:[i,bv()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),Z.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw Z.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),Z.info(`[DC] c"${this.getKey()}" deactivated`)}catch(i){throw Z.error(`[DC] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}};if(e.keepalive){this.keepalive=!0;const i=t();return this.keepalive=!1,i}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Gn.Detached)throw new v(w.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const i=e.subscribe("local-broadcast",async s=>{var c;const{topic:o,payload:a}=s.value,l=(c=s.options)==null?void 0:c.error,h=s.options;try{await this.broadcast(e.getKey(),o,a,h)}catch(u){u instanceof Error&&(l==null||l(u))}}),r=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:ke.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=ke.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Gn.Removed)return e;e.applyStatus(Gn.Attached),this.attachmentMap.set(e.getKey(),new zw(this.reconnectStreamDelay,e,s.documentId,r,i)),r!=="manual"&&await this.runWatchLoop(e.getKey()),Z.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const l=t.initialRoot;e.update(h=>{for(const[c,u]of Object.entries(l))if(!a.has(c)){const f=c;h[f]=u}})}return e}).catch(async s=>{throw Z.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e.getKey());if(!i)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((r,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:i.docID,changePack:ke.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(r=>{const s=ke.fromChangePack(r.changePack);return e.applyChangePack(s),e.getStatus()!==Gn.Removed&&e.applyStatus(Gn.Detached),this.detachInternal(e.getKey()),Z.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async r=>{throw Z.error(`[DD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}async changeSyncMode(e,t){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e.getKey());if(!i)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const r=i.syncMode;return r===t?e:(i.changeSyncMode(t),t==="manual"?(i.cancelWatchStream(),e):(t==="realtime"&&(i.remoteChangeEventReceived=!0),r==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async i=>{throw Z.error(`[SY] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}return this.enqueueTask(async()=>{const t=[];for(const[,i]of this.attachmentMap)t.push(this.syncInternal(i,i.syncMode));return Promise.all(t).catch(async i=>{throw Z.error(`[SY] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i})})}remove(e){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const i=ke.toChangePack(e.createChangePack());return i.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:i},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(r=>{const s=ke.fromChangePack(r.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),Z.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async r=>{throw Z.error(`[RD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,i,r){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new v(w.ErrDocumentNotAttached,`${e} is not attached`);if(!Sv(i))throw new v(w.ErrInvalidArgument,"payload is not serializable");const o=(r==null?void 0:r.maxRetries)??Eh.maxRetries,a=Eh.maxBackoff;let l=0;const h=u=>Math.min(Eh.initialRetryInterval*2**u,a),c=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(i))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{Z.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async u=>{if(Z.error(`[BC] c:"${this.getKey()}" err:`,u),await this.handleConnectError(u))if(u instanceof ue&&Wr(u)===w.ErrUnauthenticated&&s.doc.publish([{type:Re.AuthError,value:{reason:js(u).reason,method:"Broadcast"}}]),lc(),h(l-1)),Z.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw Z.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),u;else throw u}));return c()}runSyncLoop(){const e=()=>{if(!this.isActive()){Z.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,i]of this.attachmentMap)i.needRealtimeSync()&&(i.remoteChangeEventReceived=!1,t.push(this.syncInternal(i,i.syncMode).catch(async r=>{throw r instanceof ue&&Wr(r)===w.ErrUnauthenticated&&i.doc.publish([{type:Re.AuthError,value:{reason:js(r).reason,method:"PushPull"}}]),r})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async i=>{Z.error(`[SL] c:"${this.getKey()}" sync failed:`,i),await this.handleConnectError(i)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};Z.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new v(w.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(i=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new v(w.ErrClientNotActivated,`${this.key} is not active`));const r=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:r.signal});return t.doc.publish([{type:Re.ConnectionChanged,value:So.Connected}]),Z.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const h of s)this.handleWatchDocumentsResponse(t,h),h.body.case==="initialization"&&o([s,r])}catch(h){t.doc.resetOnlineClients(),t.doc.publish([{type:Re.Initialized,source:se.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Re.ConnectionChanged,value:So.Disconnected}]),Z.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(h)?(h instanceof ue&&Wr(h)===w.ErrUnauthenticated&&t.doc.publish([{type:Re.AuthError,value:{reason:js(h).reason,method:"WatchDocuments"}}]),i()):this.conditions.WatchLoop=!1,a(h)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===Rr.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Gn.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:i,docID:r}=e,s=i.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:r,changePack:ke.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${i.getKey()}`}}).then(o=>{const a=ke.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return i;i.applyChangePack(a),e.doc.publish([{type:Re.SyncStatusChanged,value:Zc.Synced}]),i.getStatus()===Gn.Removed&&this.detachInternal(i.getKey());const l=i.getKey(),h=a.getChangeSize();return Z.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${s.getChangeSize()} pull:${h} cp:${a.getCheckpoint().toTestString()}`),i}).catch(async o=>{throw i.publish([{type:Re.SyncStatusChanged,value:Zc.SyncFailed}]),Z.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof ue))return!1;if(e.code===ne.Canceled||e.code===ne.Unknown||e.code===ne.ResourceExhausted||e.code===ne.Unavailable)return!0;if(Wr(e)===w.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(js(e).reason);this.setAuthToken(t)}return!0}return(Wr(e)===w.ErrClientNotActivated||Wr(e)===w.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,i)=>{this.taskQueue.push(()=>e().then(t).catch(i)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{Z.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Dh={Client:IO,Document:CO,Primitive:ge,Text:sh,Counter:oh,Tree:ah,LogLevel:Ge,setLogLevel:QO,IntType:Pi.IntegerCnt,LongType:Pi.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:IO,Document:CO,Primitive:ge,Text:sh,Counter:oh,Tree:ah,LogLevel:Ge,setLogLevel:QO,IntType:Pi.IntegerCnt,LongType:Pi.LongCnt});class ee{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Os(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),ui.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Os(this,e,t);let i=[];return this.decompose(e,t,i,0),ui.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new io(this),s=new io(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new io(this,e)}iterRange(e,t=this.length){return new RO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new EO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ee.empty:e.length<=32?new ve(e):ui.from(ve.split(e,[]))}}class ve extends ee{constructor(e,t=wv(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?i:a)>=e)return new vv(r,a,i,o);r=a+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new ve(Wd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),a=Xa(s.text,o.text.slice(),0,s.length);if(a.length<=32)i.push(new ve(a,o.length+s.length));else{let l=a.length>>1;i.push(new ve(a.slice(0,l)),new ve(a.slice(l)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ve))return super.replace(e,t,i);[e,t]=Os(this,e,t);let r=Xa(this.text,Xa(i.text,Wd(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new ve(r,s):ui.from(ve.split(r,[]),s)}sliceString(e,t=this.length,i=` + */var $t=null;try{$t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function Y(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}Y.prototype.__isLong__;Object.defineProperty(Y.prototype,"__isLong__",{value:!0});function ze(n){return(n&&n.__isLong__)===!0}function Rd(n){var e=Math.clz32(n&-n);return n?31-e:e}Y.isLong=ze;var Ed={},Dd={};function Lr(n,e){var t,i,r;return e?(n>>>=0,(r=0<=n&&n<256)&&(i=Dd[n],i)?i:(t=te(n,0,!0),r&&(Dd[n]=t),t)):(n|=0,(r=-128<=n&&n<128)&&(i=Ed[n],i)?i:(t=te(n,n<0?-1:0,!1),r&&(Ed[n]=t),t))}Y.fromInt=Lr;function Ct(n,e){if(isNaN(n))return e?En:Ft;if(e){if(n<0)return En;if(n>=tO)return rO}else{if(n<=-Bd)return tt;if(n+1>=Bd)return nO}return n<0?Ct(-n,e).neg():te(n%ds|0,n/ds|0,e)}Y.fromNumber=Ct;function te(n,e,t){return new Y(n,e,t)}Y.fromBits=te;var Sl=Math.pow;function Yu(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?En:Ft;if(t=t||10,t<2||360)throw Error("interior hyphen");if(i===0)return Yu(n.substring(1),e,t).neg();for(var r=Ct(Sl(t,8)),s=Ft,o=0;o>>0:this.low};C.toNumber=function(){return this.unsigned?(this.high>>>0)*ds+(this.low>>>0):this.high*ds+(this.low>>>0)};C.toString=function(e){if(e=e||10,e<2||36>>0,c=h.toString(e);if(o=l,o.isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}};C.getHighBits=function(){return this.high};C.getHighBitsUnsigned=function(){return this.high>>>0};C.getLowBits=function(){return this.low};C.getLowBitsUnsigned=function(){return this.low>>>0};C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};C.isOdd=function(){return(this.low&1)===1};C.isEven=function(){return(this.low&1)===0};C.equals=function(e){return ze(e)||(e=ei(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};C.eq=C.equals;C.notEquals=function(e){return!this.eq(e)};C.neq=C.notEquals;C.ne=C.notEquals;C.lessThan=function(e){return this.comp(e)<0};C.lt=C.lessThan;C.lessThanOrEqual=function(e){return this.comp(e)<=0};C.lte=C.lessThanOrEqual;C.le=C.lessThanOrEqual;C.greaterThan=function(e){return this.comp(e)>0};C.gt=C.greaterThan;C.greaterThanOrEqual=function(e){return this.comp(e)>=0};C.gte=C.greaterThanOrEqual;C.ge=C.greaterThanOrEqual;C.compare=function(e){if(ze(e)||(e=ei(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};C.comp=C.compare;C.negate=function(){return!this.unsigned&&this.eq(tt)?tt:this.not().add(Jr)};C.neg=C.negate;C.add=function(e){ze(e)||(e=ei(e));var t=this.high>>>16,i=this.high&65535,r=this.low>>>16,s=this.low&65535,o=e.high>>>16,a=e.high&65535,l=e.low>>>16,h=e.low&65535,c=0,u=0,f=0,p=0;return p+=s+h,f+=p>>>16,p&=65535,f+=r+l,u+=f>>>16,f&=65535,u+=i+a,c+=u>>>16,u&=65535,c+=t+o,c&=65535,te(f<<16|p,c<<16|u,this.unsigned)};C.subtract=function(e){return ze(e)||(e=ei(e)),this.add(e.neg())};C.sub=C.subtract;C.multiply=function(e){if(this.isZero())return this;if(ze(e)||(e=ei(e)),$t){var t=$t.mul(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?En:Ft;if(this.eq(tt))return e.isOdd()?tt:Ft;if(e.eq(tt))return this.isOdd()?tt:Ft;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(qd)&&e.lt(qd))return Ct(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=this.high&65535,s=this.low>>>16,o=this.low&65535,a=e.high>>>16,l=e.high&65535,h=e.low>>>16,c=e.low&65535,u=0,f=0,p=0,g=0;return g+=o*c,p+=g>>>16,g&=65535,p+=s*c,f+=p>>>16,p&=65535,p+=o*h,f+=p>>>16,p&=65535,f+=r*c,u+=f>>>16,f&=65535,f+=s*h,u+=f>>>16,f&=65535,f+=o*l,u+=f>>>16,f&=65535,u+=i*c+r*h+s*l+o*a,u&=65535,te(p<<16|g,u<<16|f,this.unsigned)};C.mul=C.multiply;C.divide=function(e){if(ze(e)||(e=ei(e)),e.isZero())throw Error("division by zero");if($t){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?$t.div_u:$t.div_s)(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?En:Ft;var i,r,s;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return En;if(e.gt(this.shru(1)))return iO;s=En}else{if(this.eq(tt)){if(e.eq(Jr)||e.eq(Xc))return tt;if(e.eq(tt))return Jr;var o=this.shr(1);return i=o.div(e).shl(1),i.eq(Ft)?e.isNegative()?Jr:Xc:(r=this.sub(e.mul(i)),s=i.add(r.div(e)),s)}else if(e.eq(tt))return this.unsigned?En:Ft;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=Ft}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(i)/Math.LN2),l=a<=48?1:Sl(2,a-48),h=Ct(i),c=h.mul(e);c.isNegative()||c.gt(r);)i-=l,h=Ct(i,this.unsigned),c=h.mul(e);h.isZero()&&(h=Jr),s=s.add(h),r=r.sub(c)}return s};C.div=C.divide;C.modulo=function(e){if(ze(e)||(e=ei(e)),$t){var t=(this.unsigned?$t.rem_u:$t.rem_s)(this.low,this.high,e.low,e.high);return te(t,$t.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};C.mod=C.modulo;C.rem=C.modulo;C.not=function(){return te(~this.low,~this.high,this.unsigned)};C.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};C.clz=C.countLeadingZeros;C.countTrailingZeros=function(){return this.low?Rd(this.low):Rd(this.high)+32};C.ctz=C.countTrailingZeros;C.and=function(e){return ze(e)||(e=ei(e)),te(this.low&e.low,this.high&e.high,this.unsigned)};C.or=function(e){return ze(e)||(e=ei(e)),te(this.low|e.low,this.high|e.high,this.unsigned)};C.xor=function(e){return ze(e)||(e=ei(e)),te(this.low^e.low,this.high^e.high,this.unsigned)};C.shiftLeft=function(e){return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?te(this.low<>>32-e,this.unsigned):te(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):te(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};C.shr=C.shiftRight;C.shiftRightUnsigned=function(e){return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?te(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?te(this.high,0,this.unsigned):te(this.high>>>e-32,0,this.unsigned)};C.shru=C.shiftRightUnsigned;C.shr_u=C.shiftRightUnsigned;C.rotateLeft=function(e){var t;return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?te(this.high,this.low,this.unsigned):e<32?(t=32-e,te(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,te(this.high<>>t,this.low<>>t,this.unsigned))};C.rotl=C.rotateLeft;C.rotateRight=function(e){var t;return ze(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?te(this.high,this.low,this.unsigned):e<32?(t=32-e,te(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,te(this.low<>>e,this.high<>>e,this.unsigned))};C.rotr=C.rotateRight;C.toSigned=function(){return this.unsigned?te(this.low,this.high,!1):this};C.toUnsigned=function(){return this.unsigned?this:te(this.low,this.high,!0)};C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};C.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};Y.fromBytes=function(e,t,i){return i?Y.fromBytesLE(e,t):Y.fromBytesBE(e,t)};Y.fromBytesLE=function(e,t){return new Y(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};Y.fromBytesBE=function(e,t){return new Y(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var $e=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))($e||{});class ge extends Vo{constructor(t,i){super(i);d(this,"valueType");d(this,"value");this.valueType=ge.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,i){return new ge(t,i)}static valueFromBytes(t,i){switch(t){case 0:return null;case 1:return!!i[0];case 2:return i[0]|i[1]<<8|i[2]<<16|i[3]<<24;case 4:{const r=new DataView(i.buffer);return i.forEach(function(s,o){r.setUint8(o,s)}),r.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(i);case 3:return Y.fromBytesLE(Array.from(i));case 6:return i;case 7:return new Date(Y.fromBytesLE(Array.from(i),!0).toNumber());default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${wi(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=ge.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof Y)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return ge.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,i=new Uint8Array(8);return new DataView(i.buffer).setFloat64(0,t,!0),i}case 5:return new TextEncoder().encode(this.value);case 3:{const i=this.value.toBytesLE();return Uint8Array.from(i)}case 6:return this.value;case 7:{const t=this.value,i=Y.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(i)}default:throw new v(w.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class wl extends eO{constructor(t){super(t);d(this,"prev");d(this,"next");this.value=t}static createAfter(t,i){const r=new wl(i),s=t.next;return t.next=r,r.prev=t,r.next=s,s&&(s.prev=r),r}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class mo{constructor(){d(this,"dummyHead");d(this,"last");d(this,"nodeMapByIndex");d(this,"nodeMapByCreatedAt");const e=ge.of(0,Gt);e.setRemovedAt(Gt),this.dummyHead=new wl(e),this.last=this.dummyHead,this.nodeMapByIndex=new go,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new mo}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let i=this.nodeMapByCreatedAt.get(e.toIDString());if(!i)throw new v(w.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;i.getNext()&&i.getNext().getPositionedAt().after(t);)i=i.getNext();return i}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,i=t.getCreatedAt()){const r=this.findNextBeforeExecutedAt(e,i),s=wl.createAfter(r,t);r===this.last&&(this.last=s),this.nodeMapByIndex.insertAfter(r,s),this.nodeMapByCreatedAt.set(s.getCreatedAt().toIDString(),s)}moveAfter(e,t,i){const r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new v(w.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const s=this.nodeMapByCreatedAt.get(t.toIDString());if(!s)throw new v(w.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);r!==s&&(!s.getValue().getMovedAt()||i.after(s.getValue().getMovedAt()))&&(this.release(s),this.insertAfter(r.getCreatedAt(),s.getValue(),i),s.getValue().setMovedAt(i))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new v(w.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,i]=this.nodeMapByIndex.find(e);let r=t;if(e===0&&t===this.dummyHead||i>0)do r&&(r=r.getNext());while(r&&r.isRemoved());return r}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const i=this.nodeMapByCreatedAt.get(e.toIDString()),r=i.isRemoved();return i.remove(t)&&!r&&this.nodeMapByIndex.splayNode(i),i.getValue()}deleteByIndex(e,t){const i=this.getByIndex(e);if(i)return i.remove(t)&&this.nodeMapByIndex.splayNode(i),i.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const i=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${i}}`):e.push(`[${i}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class dt extends rr{constructor(t,i){super(t);d(this,"elements");this.elements=i}static create(t,i){if(!i)return new dt(t,mo.create());const r=mo.create();for(const s of i)r.insertAfter(r.getLastCreatedAt(),s.deepcopy());return new dt(t,r)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,i){this.elements.insertAfter(t,i)}moveAfter(t,i,r){this.elements.moveAfter(t,i,r)}get(t){const i=this.elements.getByIndex(t);return i==null?void 0:i.getValue()}getByID(t){const i=this.elements.getByID(t);return i==null?void 0:i.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,i){return this.elements.delete(t,i)}deleteByIndex(t,i){return this.elements.deleteByIndex(t,i)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const i of this.elements){const r=i.getValue();if(t(r,this))return;r instanceof rr&&r.getDescendants(t)}}toJSON(){const t=[];for(const i of this)t.push(i.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let i=0;i({...g,value:g.value?{attributes:ts(g.value.getAttributes()),content:g.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[c,p,u,[h,h]]}setStyle(t,i,r,s,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],r),[,l]=this.rgaTreeSplit.findNodeWithSplit(t[0],r),h=[],c=this.rgaTreeSplit.findBetween(l,a),u=new Map,f=[];for(const g of c){const O=g.getCreatedAt().getActorID();let y,S=0n;if(o===void 0&&s===void 0?S=Ks:o.size()>0?S=o.get(O)?o.get(O):0n:y=s.has(O)?s.get(O):Gt,g.canStyle(r,y,S)){const k=u.get(O),$=g.getCreatedAt();(!k||$.after(k))&&u.set(O,$),f.push(g)}}const p=[];for(const g of f){if(g.isRemoved())continue;const[O,y]=this.rgaTreeSplit.findIndexesFromRange(g.createPosRange());h.push({type:"style",actor:r.getActorID(),from:O,to:y,value:{attributes:ts(i)}});for(const[S,k]of Object.entries(i)){const[$]=g.getValue().setAttr(S,k,r);$!==void 0&&p.push({parent:g.getValue(),child:$})}}return[u,p,h]}indexRangeToPosRange(t,i){const r=this.rgaTreeSplit.indexToPos(t);return t===i?[r,r]:[r,this.rgaTreeSplit.indexToPos(i)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const i of this.rgaTreeSplit)i.isRemoved()||t.push(i.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const i of this.rgaTreeSplit)if(!i.isRemoved()){const r=i.getValue();t.push({attributes:ts(r.getAttributes()),content:r.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new qt(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const i of this.rgaTreeSplit){i.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:i});for(const r of i.getValue().getGCPairs())t.push(r)}return t}}class Xo extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"content");d(this,"attributes");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.content=o,this.attributes=a}static create(t,i,r,s,o,a,l){return new Xo(t,i,r,s,o,a,l)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof qt))throw new v(w.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(const h of l)t.registerGCPair(h);return{opInfos:a.map(({from:h,to:c,value:u})=>({type:"edit",from:h,to:c,value:u,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=this.fromPos.toTestString(),r=this.toPos.toTestString(),s=this.content;return`${t}.EDIT(${i},${r},${s})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Uo extends Yt{constructor(t,i,r,s,o,a){super(t,a);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"attributes");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.attributes=o}static create(t,i,r,s,o,a){return new Uo(t,i,r,s,o,a)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof qt))throw new v(w.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=s,[,a,l]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(const h of a)t.registerGCPair(h);return{opInfos:l.map(({from:h,to:c,value:u})=>({type:"style",from:h,to:c,value:u,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=this.fromPos.toTestString(),r=this.toPos.toTestString(),s=this.attributes;return`${t}.STYL(${i},${r},${JSON.stringify(s)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const G1=2,J1="root",Dn="text";function Ds(n,e){let t=0;const i=n.children;for(let r=0;r0)throw new v(w.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const i=t.updateDescendantsSize();t.isRemoved||(e+=i)}return this.size+=e,this.paddedSize}get isText(){return this.type===Dn}get paddedSize(){return this.size+(this.isText?0:G1)}isAncestorOf(e){return H1(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const i=this.value.slice(0,e),r=this.value.slice(e);if(!r.length)return;this.value=i;const s=this.cloneText(e+t);return s.value=r,this.parent.insertAfterInternal(s,this),s}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new v(w.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const i=this.cloneElement(t);this.parent.insertAfterInternal(i,this),i.updateAncestorsSize();const r=this.children.slice(0,e),s=this.children.slice(e);this._children=r,i._children=s,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),i.size=i._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of i._children)o.parent=i;return i}insertAfterInternal(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");const i=this._children.indexOf(t);if(i===-1)throw new v(w.ErrInvalidArgument,"child not found");this.insertAtInternal(e,i+1)}insertAtInternal(e,t){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(r=>!r.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new v(w.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const i=this._children.indexOf(t);if(i!==-1)return i;t=t.parent}return-1}}function H1(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var Qe=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(Qe||{});function sO(n,e,t,i){if(e>t)throw new v(w.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new v(w.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new v(w.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let r=0;for(const s of n.children){if(e-s.paddedSizes.size;(s.isText||l)&&i([s,s.isText?"Text":"Start"],h),sO(s,Math.max(0,o),Math.min(a,s.size),i),h&&i([s,"End"],h)}r+=s.paddedSize}}function oO(n,e,t=0){for(const i of n.children)oO(i,e,t+1);e(n,t)}function rh(n,e,t=0){for(const i of n._children)rh(i,e,t+1);e(n,t)}function Uc(n,e,t=!0){if(e>n.size)throw new v(w.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let i=0,r=0;for(const s of n.children){if(t&&s.isText&&s.size>=e-r)return Uc(s,e-r,t);if(e===r)return{node:n,offset:i};if(!t&&s.paddedSize===e-r)return{node:n,offset:i+1};if(s.paddedSize>e-r)return Uc(s,e-r-1,t);r+=s.paddedSize,i+=1}return{node:n,offset:i}}function aO(n){return n.isText||n.children.length===0?n:aO(n.children[0])}function K1(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(i<0)if(t.left)t.left.parent=t,t=t.left;else{let r=t.parent,s=t;for(;r&&s===r.left;)s=r,r=r.parent;return r}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const i=this.comparator(e,t.key);if(i===0)return t;i<0?t=t.left:i>0&&(t=t.right)}}putInternal(e,t,i){if(!i)return this.counter+=1,new iw(e,t,!0);const r=this.comparator(e,i.key);return r<0?i.left=this.putInternal(e,t,i.left):r>0?i.right=this.putInternal(e,t,i.right):i.value=t,this.isRed(i.right)&&!this.isRed(i.left)&&(i=this.rotateLeft(i)),this.isRed(i.left)&&this.isRed(i.left.left)&&(i=this.rotateRight(i)),this.isRed(i.left)&&this.isRed(i.right)&&this.flipColors(i),i}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const i=this.min(e.right);e.value=i.value,e.key=i.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class _t{constructor(e,t){d(this,"parentID");d(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new _t(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:i}=e,r;return i.isText?(i.parent.children[0]===i&&t===0?r=i.parent:r=i,i=i.parent):t===0?r=i:r=i.children[t-1],_t.of(i.id,Ve.of(r.getCreatedAt(),r.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return _t.of(Ve.of(Dt.fromStruct(e.parentID.createdAt),e.parentID.offset),Ve.of(Dt.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),i=this.getLeftSiblingID(),r=e.findFloorNode(t);let s=e.findFloorNode(i);if(!r||!s)throw new v(w.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${i.toTestString()})`);return!i.equals(t)&&i.getOffset()>0&&i.getOffset()===s.id.getOffset()&&s.insPrevID&&(s=e.findFloorNode(s.insPrevID)),[r,s]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class Ve{constructor(e,t){d(this,"createdAt");d(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ve(e,t)}static fromStruct(e){return Ve.of(Dt.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const i=e.getCreatedAt().compare(t.getCreatedAt());return i!==0?i:e.getOffset()>t.getOffset()?1:e.getOffset(){const s=r.deepcopy();return s.parent=t,s}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new v(w.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new v(w.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const i=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),i&&this.updateAncestorsSize()}cloneText(t){return new ut(Ve.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new ut(Ve.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,i,r){const s=this.isText?this.splitText(i,this.id.getOffset()):this.splitElement(i,r);if(s){if(s.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=s.id,s.insNextID=this.insNextID}this.insNextID=s.id,t.registerNode(s)}return s}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,i,r){return(i?!this.getCreatedAt().after(i):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,i,r){return this.isText?!1:(i?!this.getCreatedAt().after(i):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,i){this.attrs||(this.attrs=new Vn);const r=[];for(const[s,o]of Object.entries(t))r.push(this.attrs.set(s,o,i));return r}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const i of this.attrs)i.getRemovedAt()&&t.push({parent:this,child:i});return t}}function Zc(n){var t;if(n.isText){const i=n;return{type:i.type,value:i.value}}const e={type:n.type,children:n.children.map(Zc)};return n.attrs&&(e.attributes=ts((t=n.attrs)==null?void 0:t.toObject())),e}function Hu(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,i)=>t.getKey().localeCompare(i.getKey())).map(t=>{const i=JSON.parse(t.getValue());return typeof i=="string"?`${t.getKey()}="${i}"`:`${t.getKey()}="${wi(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>Hu(t)).join("")}`}function hO(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(hO),size:n.size,isRemoved:n.isRemoved}}class Mt extends Vo{constructor(t,i){super(i);d(this,"indexTree");d(this,"nodeMapByID");this.indexTree=new ew(t),this.nodeMapByID=new lO(Ve.createComparator()),this.indexTree.traverseAll(r=>{this.nodeMapByID.put(r.id,r)})}static create(t,i){return new Mt(t,i)}findFloorNode(t){const i=this.nodeMapByID.floorEntry(t);if(!(!i||!i.key.getCreatedAt().equals(t.getCreatedAt())))return i.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,i){const[r,s]=t.toTreeNodePair(this);let o=s;const a=r===o,l=o.parent&&!a?o.parent:r;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),i){const h=l.allChildren,c=a?0:h.indexOf(o)+1;for(let u=c;u{const y=O.getCreatedAt().getActorID();let S,k=0n;if(o===void 0&&s===void 0?k=Ks:o.size()>0?k=o.get(y)?o.get(y):0n:S=s.has(y)?s.get(y):Gt,O.canStyle(r,S,k)&&i){const $=p.get(y),A=O.getCreatedAt();(!$||A.after($))&&p.set(y,A);const x=O.setAttrs(i,r),P=x.reduce((W,[,z])=>(z&&(W[z.getKey()]=f[z.getKey()]),W),{}),R=O.parent,X=O.prevSibling||O.parent;Object.keys(P).length>0&&u.push({type:"style",from:this.toIndex(R,X),to:this.toIndex(O,O),fromPath:this.toPath(R,X),toPath:this.toPath(O,O),actor:r.getActorID(),value:P});for(const[W]of x)W&&g.push({parent:O,child:W})}}),[p,g,u]}removeStyle(t,i,r,s,o){const[a,l]=this.findNodesAndSplitText(t[0],r),[h,c]=this.findNodesAndSplitText(t[1],r),u=[],f=new Map,p=[];return this.traverseInPosRange(a,l,h,c,([g])=>{const O=g.getCreatedAt().getActorID();let y,S=0n;if(o===void 0&&s===void 0?S=Ks:o.size()>0?S=o.get(O)?o.get(O):0n:y=s.has(O)?s.get(O):Gt,g.canStyle(r,y,S)&&i){const k=f.get(O),$=g.getCreatedAt();(!k||$.after(k))&&f.set(O,$),g.attrs||(g.attrs=new Vn);for(const P of i){const R=g.attrs.remove(P,r);for(const X of R)p.push({parent:g,child:X})}const A=g.parent,x=g.prevSibling||g.parent;u.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(A,x),to:this.toIndex(g,g),fromPath:this.toPath(A,x),toPath:this.toPath(g,g),value:i})}}),[f,p,u]}edit(t,i,r,s,o,a,l){const[h,c]=this.findNodesAndSplitText(t[0],s),[u,f]=this.findNodesAndSplitText(t[1],s),p=this.toIndex(h,c),g=this.toPath(h,c),O=[],y=[],S=[],k=new Map;this.traverseInPosRange(h,c,u,f,([x,P],R)=>{if(P===Qe.Start&&!R)for(const H of x.children)S.push(H);const X=x.getCreatedAt().getActorID();let W,z=0n;if(l===void 0&&a===void 0?z=Ks:l.size()>0?z=l.get(X)?l.get(X):0n:W=a.has(X)?a.get(X):Gt,x.canDelete(s,W,z)||O.includes(x.parent)){const H=k.get(X),Oe=x.getCreatedAt();(!H||Oe.after(H))&&k.set(X,Oe),(P===Qe.Text||P===Qe.Start)&&O.push(x),y.push([x,P])}});const $=this.makeDeletionChanges(y,s),A=[];for(const x of O)x.remove(s),x.isRemoved&&A.push({parent:this,child:x});for(const x of S)x.removedAt||h.append(x);if(r>0){let x=0,P=h,R=c;for(;x{h.isRemoved&&(X.remove(s),A.push({parent:this,child:X})),this.nodeMapByID.put(X.id,X)}),R.isRemoved||x.push(R);if(x.length){const R=x.map(X=>Zc(X));$.length&&$[$.length-1].from===p?$[$.length-1].value=R:$.push({type:"content",from:p,to:p,fromPath:g,toPath:g,actor:s.getActorID(),value:R})}}return[$,A,k]}editT(t,i,r,s,o){const a=this.findPos(t[0]),l=this.findPos(t[1]);this.edit([a,l],i,r,s,o)}move(t,i,r){throw new v(w.ErrUnimplemented,`not implemented: ${t}, ${i}, ${r}`)}purge(t){var s;(s=t.parent)==null||s.removeChild(t),this.nodeMapByID.remove(t.id);const i=t.insPrevID,r=t.insNextID;if(i){const o=this.findFloorNode(i);o.insNextID=r}if(r){const o=this.findFloorNode(r);o.insPrevID=i}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(i=>{i.getRemovedAt()&&t.push({parent:this,child:i});for(const r of i.getGCPairs())t.push(r)}),t}findPos(t,i=!0){const r=this.indexTree.findTreePos(t,i);return _t.fromTreePos(r)}pathToPosRange(t){const i=this.pathToIndex(t);return[this.findPos(i),this.findPos(i+1)]}pathToPos(t){const i=this.indexTree.pathToIndex(t);return this.findPos(i)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return Hu(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),i=(r,s=void 0,o=void 0,a=0)=>{var p,g,O,y;let l,h,c;const u=r.isText?{node:r,offset:0}:s&&o?this.toTreePos(s,o):null;u&&(l=this.indexTree.indexOf(u),h=this.indexTree.treePosToPath(u),c=_t.fromTreePos(u).toStruct());const f={type:r.type,parent:s==null?void 0:s.id.toTestString(),size:r.size,id:r.id.toTestString(),removedAt:(p=r.removedAt)==null?void 0:p.toTestString(),insPrev:(g=r.insPrevID)==null?void 0:g.toTestString(),insNext:(O=r.insNextID)==null?void 0:O.toTestString(),value:r.isText?r.value:void 0,isRemoved:r.isRemoved,children:[],depth:a,attributes:r.attrs?ts((y=r.attrs)==null?void 0:y.toObject()):void 0,index:l,path:h,pos:c};for(let S=0;S0&&S===r[r.length-1].to?(r[r.length-1].to=k,r[r.length-1].toPath=this.toPath(y,p)):r.push({type:"content",from:S,to:k,fromPath:this.toPath(O,u),toPath:this.toPath(y,p),actor:i.getActorID()}))}return r.reverse()}findRightToken([t,i]){if(i===Qe.Start){const l=t.allChildren;return l.length>0?[l[0],l[0].isText?Qe.Text:Qe.Start]:[t,Qe.End]}const r=t.parent,s=r.allChildren,o=s.indexOf(t);if(r&&o===s.length-1)return[r,Qe.End];const a=s[o+1];return[a,a.isText?Qe.Text:Qe.Start]}findLeftToken([t,i]){if(i===Qe.End){const l=t.allChildren;if(l.length>0){const h=l[l.length-1];return[h,h.isText?Qe.Text:Qe.End]}return[t,Qe.Start]}const r=t.parent,s=r.allChildren,o=s.indexOf(t);if(r&&o===0)return[r,Qe.Start];const a=s[o-1];return[a,a.isText?Qe.Text:Qe.End]}}class Zo extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"contents");d(this,"splitLevel");d(this,"maxCreatedAtMapByActor");this.fromPos=i,this.toPos=r,this.contents=s,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,i,r,s,o,a,l){return new Zo(t,i,r,s,o,a,l)}execute(t,i,r){var c;const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Mt))throw new v(w.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=s,[l,h]=a.edit([this.fromPos,this.toPos],(c=this.contents)==null?void 0:c.map(u=>u.deepcopy()),this.splitLevel,o,(()=>{let u=o.getDelimiter();return this.contents!==void 0&&(u+=this.contents.length),()=>Dt.of(o.getLamport(),++u,o.getActorID())})(),this.maxCreatedAtMapByActor,r);for(const u of h)t.registerGCPair(u);return{opInfos:l.map(({from:u,to:f,value:p,splitLevel:g,fromPath:O,toPath:y})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:u,to:f,value:p,splitLevel:g,fromPath:O,toPath:y}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,s=this.contents||[];return`${t}.EDIT(${i},${r},${s.map(o=>Hu(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class is{constructor(e){d(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}unset(e){this.vector.delete(e)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[i,r]of e){const s=this.vector.get(i),o=s&&s>r?s:r;t.set(i,o)}for(const[i,r]of this){const s=e.get(i),o=s&&s>r?s:r;t.set(i,o)}return new is(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,i]of this.vector)e.set(t,i);return new is(e)}filter(e){const t=new Map;for(const[i]of e){const r=this.vector.get(i);r!==void 0&&t.set(i,r)}return new is(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const rw=new is(new Map);class An{constructor(e,t,i,r,s){d(this,"clientSeq");d(this,"serverSeq");d(this,"lamport");d(this,"actor");d(this,"versionVector");this.clientSeq=e,this.serverSeq=s,this.lamport=t,this.versionVector=r,this.actor=i}static of(e,t,i,r,s){return new An(e,t,i,r,s)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new An(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n;let i=e.versionVector;i.size()===0&&(i=i.deepcopy(),i.set(e.actor,e.lamport));const r=this.versionVector.max(i),s=new An(this.clientSeq,t,this.actor,r);return s.versionVector.set(this.actor,t),s}setClocks(e,t){const i=e>this.lamport?e+1n:this.lamport+1n;t.unset(nh);const r=this.versionVector.max(t);return r.set(this.actor,i),An.of(this.clientSeq,i,this.actor,r)}createTimeTicket(e){return Dt.of(this.lamport,e,this.actor)}setActor(e){return new An(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new An(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const sw=new An(0,0n,nh,rw);class ps{constructor({id:e,operations:t,presenceChange:i,message:r}){d(this,"id");d(this,"operations");d(this,"presenceChange");d(this,"message");this.id=e,this.operations=t||[],this.presenceChange=i,this.message=r}static create({id:e,operations:t,presenceChange:i,message:r}){return new ps({id:e,operations:t,presenceChange:i,message:r})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,i){const r=[],s=[];for(const o of this.operations){const a=o.execute(e,i,this.id.getVersionVector());if(!a)continue;const{opInfos:l,reverseOp:h}=a;r.push(...l),h&&s.unshift(h)}return this.presenceChange&&(this.presenceChange.type===cr.Put?t.set(this.id.getActorID(),Wt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:r,reverseOps:s}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:ke.bytesToHex(ke.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>ke.bytesToHex(ke.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:i,presenceChange:r,message:s}=e;return ps.create({id:ke.bytesToChangeID(ke.hexToBytes(t)),operations:i==null?void 0:i.map(o=>ke.bytesToOperation(ke.hexToBytes(o))),presenceChange:r,message:s})}}class sh{constructor(e,t,i,r,s,o,a){d(this,"documentKey");d(this,"checkpoint");d(this,"isRemoved");d(this,"changes");d(this,"snapshot");d(this,"minSyncedTicket");d(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=i,this.changes=r,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=s}static create(e,t,i,r,s,o,a){return new sh(e,t,i,r,s,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class ns{constructor(e,t){d(this,"serverSeq");d(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new ns(e,t)}increaseClientSeq(e){return e===0?this:new ns(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,i=Math.max(this.clientSeq,e.clientSeq);return ns.of(t,i)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const ow=new ns(0n,0);class Ti{constructor(e,t){d(this,"createdAt");d(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new Ti(e,t)}static fromStruct(e){return Ti.of(Dt.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new Ti(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const aw=Ti.of(Gt,0);class Jt{constructor(e,t){d(this,"id");d(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Jt(e,t)}static fromStruct(e){const t=Ti.fromStruct(e.id);return Jt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return Ti.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class sr extends eO{constructor(t,i,r){super(i);d(this,"id");d(this,"removedAt");d(this,"prev");d(this,"next");d(this,"insPrev");d(this,"insNext");this.id=t,this.removedAt=r}static create(t,i){return new sr(t,i)}static createComparator(){return(t,i)=>{const r=t.getCreatedAt().compare(i.getCreatedAt());return r!==0?r:t.getOffset()>i.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const i=[];let r=e;for(;r&&r!==t;)i.push(r),r=r.getNext();return i}splitNode(e,t){if(t>e.getContentLength())throw new v(w.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const i=e.split(t);this.treeByIndex.updateWeight(i),this.insertAfter(e,i);const r=e.getInsNext();return r&&r.setInsPrev(i),i.setInsPrev(e),i}deleteNodes(e,t,i,r){if(!e.length)return[[],new Map,new Map];const[s,o]=this.filterNodes(e,t,i,r),a=new Map,l=new Map,h=this.makeChanges(o,t);for(const c of s){const u=c.getCreatedAt().getActorID();(!a.has(u)||c.getID().getCreatedAt().after(a.get(u)))&&a.set(u,c.getID().getCreatedAt()),l.set(c.getID().toIDString(),c),c.remove(t)}return this.deleteIndexNodes(o),[h,a,l]}filterNodes(e,t,i,r){const s=[],o=[],[a,l]=this.findEdgesOfCandidates(e);o.push(a);for(const h of e){const c=h.getCreatedAt().getActorID();let u,f=0n;r===void 0&&i===void 0?f=Ks:r.size()>0?f=r.get(c)?r.get(c):0n:u=i.has(c)?i.get(c):Gt,h.canDelete(t,u,f)?s.push(h):o.push(h)}return o.push(l),[s,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const i=[];let r,s;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var Pi=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(Pi||{});class pt extends Vo{constructor(t,i,r){super(r);d(this,"valueType");d(this,"value");switch(this.valueType=t,t){case 0:typeof i=="number"?i>Math.pow(2,31)-1||i<-Math.pow(2,31)?this.value=Y.fromNumber(i).toInt():this.value=Md(i):this.value=i.toInt();break;case 1:typeof i=="number"?this.value=Y.fromNumber(i):this.value=i;break;default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,i,r){return new pt(t,i,r)}static valueFromBytes(t,i){switch(t){case 0:return i[0]|i[1]<<8|i[2]<<16|i[3]<<24;case 1:return Y.fromBytesLE(Array.from(i));default:throw new v(w.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=pt.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof Y?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!pt.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const i=this.value.toBytesLE();return Uint8Array.from(i)}default:throw new v(w.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function i(r){if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`)}return i(this),i(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===$e.Long?this.value=this.value+t.getValue().toInt():this.value=Y.fromNumber(this.value+Md(t.getValue())).toInt(),this}}class ms extends Yt{constructor(t,i,r){super(t,r);d(this,"value");this.value=i}static create(t,i,r){return new ms(t,i,r)}execute(t){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof pt))throw new v(w.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const r=i,s=this.value.deepcopy();return r.increase(s),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:s.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),r=t.getType()===$e.Long?t.getValue().multiply(-1):t.getValue()*-1;return ms.create(this.getParentCreatedAt(),ge.of(r,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Nn extends Yt{constructor(t,i,r,s,o,a,l){super(t,l);d(this,"fromPos");d(this,"toPos");d(this,"maxCreatedAtMapByActor");d(this,"attributes");d(this,"attributesToRemove");this.fromPos=i,this.toPos=r,this.maxCreatedAtMapByActor=s,this.attributes=o,this.attributesToRemove=a}static create(t,i,r,s,o,a){return new Nn(t,i,r,s,o,[],a)}static createTreeRemoveStyleOperation(t,i,r,s,o,a){return new Nn(t,i,r,s,new Map,o,a)}execute(t,i,r){const s=t.findByCreatedAt(this.getParentCreatedAt());if(!s)throw new v(w.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(s instanceof Mt))throw new v(w.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=s;let a,l;if(this.attributes.size){const h={};[...this.attributes].forEach(([c,u])=>h[c]=u),[,l,a]=o.style([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{const h=this.attributesToRemove;[,l,a]=o.removeStyle([this.fromPos,this.toPos],h,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(const h of l)t.registerGCPair(h);return{opInfos:a.map(({from:h,to:c,value:u,fromPath:f,toPath:p})=>({type:"tree-style",from:h,to:c,value:this.attributes.size?{attributes:u}:{attributesToRemove:u},fromPath:f,toPath:p,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),i=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${i},${r},${Object.entries(this.attributes||{}).map(([s,o])=>`${s}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function lw(n){const e=new Gu,t=e.data;for(const[i,r]of Object.entries(n))t[i]=JSON.stringify(r);return e}function hw(n){if(n.type===cr.Put)return new fo({type:Dr.PUT,presence:lw(n.presence)});if(n.type===cr.Clear)return new fo({type:Dr.CLEAR});throw new v(w.ErrUnimplemented,"unimplemented type")}function cw(n){return new Ym({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function cO(n){return new th({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:cf(n.getActorID()),versionVector:Ku(n.getVersionVector())})}function L(n){if(n)return new M({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:cf(n.getActorID())})}function Ku(n){if(!n)return;const e=new ih;for(const[t,i]of n)e.vector[t]=BigInt(i.toString());return e}function uO(n){switch(n){case $e.Null:return F.NULL;case $e.Boolean:return F.BOOLEAN;case $e.Integer:return F.INTEGER;case $e.Long:return F.LONG;case $e.Double:return F.DOUBLE;case $e.String:return F.STRING;case $e.Bytes:return F.BYTES;case $e.Date:return F.DATE;default:throw new v(w.ErrInvalidType,`unsupported type: ${n}`)}}function fO(n){switch(n){case Pi.IntegerCnt:return F.INTEGER_CNT;case Pi.LongCnt:return F.LONG_CNT;default:throw new v(w.ErrInvalidType,`unsupported type: ${n}`)}}function Ih(n){if(n instanceof nt)return new mt({type:F.JSON_OBJECT,createdAt:L(n.getCreatedAt()),value:TO(n)});if(n instanceof dt)return new mt({type:F.JSON_ARRAY,createdAt:L(n.getCreatedAt()),value:Xw(n)});if(n instanceof qt)return new mt({type:F.TEXT,createdAt:L(n.getCreatedAt())});if(n instanceof ge)return new mt({type:uO(n.getType()),createdAt:L(n.getCreatedAt()),value:n.toBytes()});if(n instanceof pt)return new mt({type:fO(n.getType()),createdAt:L(n.getCreatedAt()),value:n.toBytes()});if(n instanceof Mt)return new mt({type:F.TREE,createdAt:L(n.getCreatedAt()),value:Zw(n)});throw new v(w.ErrUnimplemented,"unimplemented element")}function uw(n){return new uo({createdAt:L(n.getCreatedAt()),offset:n.getOffset()})}function ia(n){return new Mn({createdAt:L(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function na(n){return new Er({parentId:eo(n.getParentID()),leftSiblingId:eo(n.getLeftSiblingID())})}function eo(n){return new nr({createdAt:L(n.getCreatedAt()),offset:n.getOffset()})}function dO(n){const e=new Fu;if(n instanceof Nr){const t=n,i=new nl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.key=t.getKey(),i.value=Ih(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="set",e.body.value=i}else if(n instanceof Lo){const t=n,i=new rl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.prevCreatedAt=L(t.getPrevCreatedAt()),i.value=Ih(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="add",e.body.value=i}else if(n instanceof Kn){const t=n,i=new sl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.prevCreatedAt=L(t.getPrevCreatedAt()),i.createdAt=L(t.getCreatedAt()),i.executedAt=L(t.getExecutedAt()),e.body.case="move",e.body.value=i}else if(n instanceof ur){const t=n,i=new ol;i.parentCreatedAt=L(t.getParentCreatedAt()),i.createdAt=L(t.getCreatedAt()),i.executedAt=L(t.getExecutedAt()),e.body.case="remove",e.body.value=i}else if(n instanceof Xo){const t=n,i=new al;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=ia(t.getFromPos()),i.to=ia(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);i.content=t.getContent();const s=i.attributes;for(const[o,a]of t.getAttributes())s[o]=a;i.executedAt=L(t.getExecutedAt()),e.body.case="edit",e.body.value=i}else if(n instanceof Uo){const t=n,i=new ll;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=ia(t.getFromPos()),i.to=ia(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);const s=i.attributes;for(const[o,a]of t.getAttributes())s[o]=a;i.executedAt=L(t.getExecutedAt()),e.body.case="style",e.body.value=i}else if(n instanceof ms){const t=n,i=new hl;i.parentCreatedAt=L(t.getParentCreatedAt()),i.value=Ih(t.getValue()),i.executedAt=L(t.getExecutedAt()),e.body.case="increase",e.body.value=i}else if(n instanceof Zo){const t=n,i=new cl,r=i.createdAtMapByActor;for(const[s,o]of t.getMaxCreatedAtMapByActor())r[s]=L(o);i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=na(t.getFromPos()),i.to=na(t.getToPos()),i.contents=yw(t.getContents()),i.splitLevel=t.getSplitLevel(),i.executedAt=L(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=i}else if(n instanceof Nn){const t=n,i=new ul;i.parentCreatedAt=L(t.getParentCreatedAt()),i.from=na(t.getFromPos()),i.to=na(t.getToPos());const r=i.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())r[o]=L(a);const s=t.getAttributesToRemove();if(s.length>0)i.attributesToRemove=s;else{const o=i.attributes;for(const[a,l]of t.getAttributes())o[a]=l}i.executedAt=L(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=i}else throw new v(w.ErrUnimplemented,"unimplemented operation");return e}function fw(n){const e=[];for(const t of n)e.push(dO(t));return e}function dw(n){const e=new _m({id:cO(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=fw(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=hw(n.getPresenceChange())),e}function pw(n){const e=[];for(const t of n)e.push(dw(t));return e}function gw(n){const e=[];for(const t of n)e.push(new Gm({key:t.getStrKey(),element:tf(t.getValue())}));return e}function mw(n){const e=[];for(const t of n)e.push(new yl({element:tf(t.getValue())}));return e}function Ow(n){const e=[];for(const t of n){const i=new Jm;i.id=uw(t.getID()),i.value=t.getValue().getContent(),i.removedAt=L(t.getRemovedAt());const r=i.attributes,s=t.getValue().getAttrs();for(const o of s){const a=new us;a.value=o.getValue(),a.updatedAt=L(o.getUpdatedAt()),r[o.getKey()]=a}e.push(i)}return e}function yw(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new bl({content:ef(t)}));return e}function bw(n){const e={};for(const t of n)e[t.getKey()]=new us({value:t.getValue(),updatedAt:L(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function ef(n){if(!n)return[];const e=[];return rh(n,(t,i)=>{const r=new _u({id:eo(t.id),type:t.type,removedAt:L(t.removedAt),depth:i});t.isText&&(r.value=t.value),t.insPrevID&&(r.insPrevId=eo(t.insPrevID)),t.insNextID&&(r.insNextId=eo(t.insNextID)),t.attrs&&(r.attributes=bw(t.attrs)),e.push(r)}),e}function Sw(n){const e=new rt;return e.body.case="jsonObject",e.body.value=new fl({nodes:gw(n.getRHT()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function pO(n){const e=new rt;return e.body.case="jsonArray",e.body.value=new dl({nodes:mw(n.getElements()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function ww(n){const e=new rt;return e.body.case="primitive",e.body.value=new pl({type:uO(n.getType()),value:n.toBytes(),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function vw(n){const e=new rt;return e.body.case="text",e.body.value=new gl({nodes:Ow(n.getRGATreeSplit()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function kw(n){const e=new rt;return e.body.case="counter",e.body.value=new ml({type:fO(n.getType()),value:n.toBytes(),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function gO(n){const e=new rt;return e.body.case="tree",e.body.value=new Ol({nodes:ef(n.getRoot()),createdAt:L(n.getCreatedAt()),movedAt:L(n.getMovedAt()),removedAt:L(n.getRemovedAt())}),e}function tf(n){if(n instanceof nt)return Sw(n);if(n instanceof dt)return pO(n);if(n instanceof ge)return ww(n);if(n instanceof qt)return vw(n);if(n instanceof pt)return kw(n);if(n instanceof Mt)return gO(n);throw new v(w.ErrUnimplemented,"unimplemented element")}function xw(n){return new Wn({documentKey:n.getDocumentKey(),checkpoint:cw(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:pw(n.getChanges()),snapshot:n.getSnapshot(),versionVector:Ku(n.getVersionVector()),minSyncedTicket:L(n.getMinSyncedTicket())})}function js(n){if(!(n instanceof ue))return{};const e=n.findDetails(Z1);for(const t of e)return t.metadata;return{}}function Wr(n){return js(n).code??""}function mO(n){return An.of(n.clientSeq,BigInt(n.lamport),lf(n.actorId),nf(n.versionVector),BigInt(n.serverSeq))}function nf(n){if(!n)return;const e=new is;return Object.entries(n.vector).forEach(([t,i])=>{e.set(t,BigInt(i.toString()))}),e}function U(n){if(n)return Dt.of(BigInt(n.lamport),n.delimiter,lf(n.actorId))}function rf(n){const e={};return Object.entries(n.data).forEach(([t,i])=>{e[t]=JSON.parse(i)}),e}function Tw(n){const e=n.type;if(e===Dr.PUT){const t=rf(n.presence);return{type:cr.Put,presence:t}}if(e===Dr.CLEAR)return{type:cr.Clear};throw new v(w.ErrInvalidType,`unsupported type: ${e}`)}function Qw(n){const e=new Map;return Object.entries(n).forEach(([t,i])=>{e.set(t,rf(i))}),e}function OO(n){switch(n){case F.NULL:return $e.Null;case F.BOOLEAN:return $e.Boolean;case F.INTEGER:return $e.Integer;case F.LONG:return $e.Long;case F.DOUBLE:return $e.Double;case F.STRING:return $e.String;case F.BYTES:return $e.Bytes;case F.DATE:return $e.Date}throw new v(w.ErrUnimplemented,`unimplemented value type: ${n}`)}function vl(n){switch(n){case F.INTEGER_CNT:return Pi.IntegerCnt;case F.LONG_CNT:return Pi.LongCnt}throw new v(w.ErrUnimplemented,`unimplemented value type: ${n}`)}function Rh(n){switch(n.type){case F.JSON_OBJECT:return n.value?xO(n.value):nt.create(U(n.createdAt));case F.JSON_ARRAY:return n.value?Lw(n.value):dt.create(U(n.createdAt));case F.TEXT:return qt.create(gs.create(),U(n.createdAt));case F.TREE:return Uw(n.value);case F.NULL:case F.BOOLEAN:case F.INTEGER:case F.LONG:case F.DOUBLE:case F.STRING:case F.BYTES:case F.DATE:return ge.of(ge.valueFromBytes(OO(n.type),n.value),U(n.createdAt));case F.INTEGER_CNT:case F.LONG_CNT:return pt.create(vl(n.type),pt.valueFromBytes(vl(n.type),n.value),U(n.createdAt))}}function ra(n){return Jt.of(Ti.of(U(n.createdAt),n.offset),n.relativeOffset)}function yO(n){return Ti.of(U(n.createdAt),n.offset)}function Pw(n){const e=Oo.create(n.value);Object.entries(n.attributes).forEach(([i,r])=>{e.setAttr(i,r.value,U(r.updatedAt))});const t=sr.create(yO(n.id),e);return t.remove(U(n.removedAt)),t}function jr(n){return _t.of(to(n.parentId),to(n.leftSiblingId))}function to(n){return Ve.of(U(n.createdAt),n.offset)}function Aw(n){if(!n.length)return;const e=[];return n.forEach(t=>{const i=sf(t.content);e.push(i)}),e}function sf(n){if(n.length===0)return;const e=[];for(const r of n)e.push(Cw(r));const t=e[e.length-1],i=new Map;i.set(n[e.length-1].depth,e[e.length-1]);for(let r=e.length-2;r>=0;r--)i.get(n[r].depth-1).prepend(e[r]),i.set(n[r].depth,e[r]);return t.updateDescendantsSize(),Mt.create(t,Gt).getRoot()}function $w(n){const e=Vn.create();for(const[t,i]of Object.entries(n))e.setInternal(t,i.value,U(i.updatedAt),i.isRemoved);return e}function Cw(n){const e=to(n.id),t=ut.create(e,n.type),i=Object.entries(n.attributes);return t.isText?t.value=n.value:i.length&&(t.attrs=$w(n.attributes)),n.insPrevId&&(t.insPrevID=to(n.insPrevId)),n.insNextId&&(t.insNextID=to(n.insNextId)),t.removedAt=U(n.removedAt),t}function bO(n){if(n.body.case==="set"){const e=n.body.value;return Nr.create(e.key,Rh(e.value),U(e.parentCreatedAt),U(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Lo.create(U(e.parentCreatedAt),U(e.prevCreatedAt),Rh(e.value),U(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return Kn.create(U(e.parentCreatedAt),U(e.prevCreatedAt),U(e.createdAt),U(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return ur.create(U(e.parentCreatedAt),U(e.createdAt),U(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,U(s))});const i=new Map;return Object.entries(e.attributes).forEach(([r,s])=>{i.set(r,s)}),Xo.create(U(e.parentCreatedAt),ra(e.from),ra(e.to),t,e.content,i,U(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,U(s))});const i=new Map;return Object.entries(e.attributes).forEach(([r,s])=>{i.set(r,s)}),Uo.create(U(e.parentCreatedAt),ra(e.from),ra(e.to),t,i,U(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ms.create(U(e.parentCreatedAt),Rh(e.value),U(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([i,r])=>{t.set(i,U(r))}),Zo.create(U(e.parentCreatedAt),jr(e.from),jr(e.to),Aw(e.contents),e.splitLevel,t,U(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,i=e.attributesToRemove,r=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([s,o])=>{r.set(s,U(o))}),(i==null?void 0:i.length)>0?Nn.createTreeRemoveStyleOperation(U(e.parentCreatedAt),jr(e.from),jr(e.to),r,i,U(e.executedAt)):(Object.entries(e.attributes).forEach(([s,o])=>{t.set(s,o)}),Nn.create(U(e.parentCreatedAt),jr(e.from),jr(e.to),r,t,U(e.executedAt)))}else throw new v(w.ErrUnimplemented,"unimplemented operation")}}function Iw(n){const e=[];for(const t of n){const i=bO(t);i&&e.push(i)}return e}function SO(n){const e=[];for(const t of n)e.push(ps.create({id:mO(t.id),operations:Iw(t.operations),presenceChange:t.presenceChange?Tw(t.presenceChange):void 0,message:t.message}));return e}function Rw(n){return ns.of(BigInt(n.serverSeq),n.clientSeq)}function Ew(n){return sh.create(n.documentKey,Rw(n.checkpoint),n.isRemoved,SO(n.changes),nf(n.versionVector),n.snapshot,U(n.minSyncedTicket))}function wO(n){const e=new po;for(const i of n.nodes){const r=of(i.element);e.set(i.key,r,r.getPositionedAt())}const t=new nt(U(n.createdAt),e);return t.setMovedAt(U(n.movedAt)),t.setRemovedAt(U(n.removedAt)),t}function vO(n){const e=new mo;for(const i of n.nodes)e.insert(of(i.element));const t=new dt(U(n.createdAt),e);return t.setMovedAt(U(n.movedAt)),t.setRemovedAt(U(n.removedAt)),t}function Dw(n){const e=ge.of(ge.valueFromBytes(OO(n.type),n.value),U(n.createdAt));return e.setMovedAt(U(n.movedAt)),e.setRemovedAt(U(n.removedAt)),e}function Nw(n){const e=new gs;let t=e.getHead();for(const r of n.nodes){const s=e.insertAfter(t,Pw(r));r.insPrevId&&s.setInsPrev(e.findNode(yO(r.insPrevId))),t=s}const i=new qt(e,U(n.createdAt));return i.setMovedAt(U(n.movedAt)),i.setRemovedAt(U(n.removedAt)),i}function Bw(n){const e=pt.create(vl(n.type),pt.valueFromBytes(vl(n.type),n.value),U(n.createdAt));return e.setMovedAt(U(n.movedAt)),e.setRemovedAt(U(n.removedAt)),e}function kO(n){const e=sf(n.nodes);return Mt.create(e,U(n.createdAt))}function of(n){if(n.body.case==="jsonObject")return wO(n.body.value);if(n.body.case==="jsonArray")return vO(n.body.value);if(n.body.case==="primitive")return Dw(n.body.value);if(n.body.case==="text")return Nw(n.body.value);if(n.body.case==="counter")return Bw(n.body.value);if(n.body.case==="tree")return kO(n.body.value);throw new v(w.ErrUnimplemented,"unimplemented element")}function qw(n){if(!n)return{root:nt.create(Gt),presences:new Map};const e=yc.fromBinary(n);return{root:of(e.root),presences:Qw(e.presences)}}function Mw(n){const e=Ku(n);return af(e.toBinary())}function Vw(n){const e=hf(n),t=ih.fromBinary(e);return nf(t)}function xO(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return wO(e.body.value)}function TO(n){return tf(n).toBinary()}function Lw(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return vO(e.body.value)}function Xw(n){return pO(n).toBinary()}function Uw(n){if(!n)throw new v(w.ErrInvalidArgument,"bytes is empty");const e=rt.fromBinary(n);return kO(e.body.value)}function Zw(n){return gO(n).toBinary()}function af(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function lf(n){return af(n)}function hf(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function cf(n){return hf(n)}function Ww(n){const e=th.fromBinary(n);return mO(e)}function jw(n){const e=Fu.fromBinary(n);return bO(e)}const ke={fromPresence:rf,toChangePack:xw,fromChangePack:Ew,fromChanges:SO,toTreeNodes:ef,fromTreeNodes:sf,objectToBytes:TO,bytesToObject:xO,bytesToSnapshot:qw,bytesToHex:af,hexToBytes:hf,toHexString:lf,toUint8Array:cf,toOperation:dO,toChangeID:cO,PbChangeID:th,bytesToChangeID:Ww,bytesToOperation:jw,versionVectorToHex:Mw,hexToVersionVector:Vw};var Ge=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Ge||{});let vr=3;function QO(n){vr=n}const Z={trivial:(...n)=>{vr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{vr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{vr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{vr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{vr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>vr<=n};function PO(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class zw{constructor(e,t,i,r,s){d(this,"reconnectStreamDelay");d(this,"doc");d(this,"docID");d(this,"syncMode");d(this,"remoteChangeEventReceived");d(this,"watchStream");d(this,"watchLoopTimerID");d(this,"watchAbortController");d(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=i,this.syncMode=r,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=s}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===La.RealtimeSyncOff?!1:this.syncMode===La.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==La.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Eh=()=>{};class Fw{constructor(e){d(this,"finalized",!1);d(this,"observers",[]);d(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,i){let r;if(!e)throw new v(w.ErrInvalidArgument,"missing observer");if(this.finalized)throw new v(w.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?r=e:r={next:e,error:t,complete:i},r.next===void 0&&(r.next=Eh),r.error===void 0&&(r.error=Eh),r.complete===void 0&&(r.complete=Eh);const s=PO(),o=this.unsubscribeOne.bind(this,s);if(this.observers.push({subscriptionID:s,observer:r}),this.finalized)try{this.finalError?r.error(this.finalError):r.complete()}catch(a){Z.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(i=>i.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Yr{constructor(e,t,i,r){d(this,"id");d(this,"delimiter");d(this,"message");d(this,"root");d(this,"operations");d(this,"presenceChange");d(this,"previousPresence");d(this,"reversePresenceKeys");this.id=e,this.delimiter=Km,this.root=t,this.operations=[],this.previousPresence=Wt(i),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=r}static create(e,t,i,r){return new Yr(e,t,i,r)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ps.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const i of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(i):this.reversePresenceKeys.delete(i)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class yo{constructor(e){d(this,"rootObject");d(this,"elementPairMapByCreatedAt");d(this,"gcElementSetByCreatedAt");d(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof qt||t instanceof Mt)for(const i of t.getGCPairs())this.registerGCPair(i);return!1})}static create(){return new yo(nt.create(Gt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const i=[];for(;t.parent;){const r=t.element.getCreatedAt(),s=t.parent.subPathOf(r);if(s===void 0)throw new v(w.ErrInvalidArgument,`cant find the given element: ${r.toIDString()}`);i.unshift(s),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return i.unshift("$"),i}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof rr&&e.getDescendants((i,r)=>(this.registerElement(i,r),!1))}deregisterElement(e){let t=0;const i=r=>{const s=r.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(s),this.gcElementSetByCreatedAt.delete(s),t++};return i(e),e instanceof rr&&e.getDescendants(r=>(i(r),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const i=this.elementPairMapByCreatedAt.get(t);i.element instanceof rr&&i.element.getDescendants(r=>(e.add(r.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new yo(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const i of this.gcElementSetByCreatedAt){const r=this.elementPairMapByCreatedAt.get(i),s=r.element.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(r.parent.purge(r.element),t+=this.deregisterElement(r.element))}for(const[,i]of this.gcPairMap){const r=i.child.getRemovedAt();r&&(e!=null&&e.afterOrEqual(r))&&(i.parent.purge(i.child),this.gcPairMap.delete(i.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function AO(n,e){const t=new bo(n);return new Proxy(e,t.getHandlers())}class bo{constructor(e){d(this,"context");d(this,"handlers");this.context=e,this.handlers={set:(t,i,r)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]=${JSON.stringify(r)}`),bo.setInternal(e,t,i,r),!0),get:(t,i)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]`),i==="getID"?()=>t.getCreatedAt():i==="toJSON"||i==="toString"?()=>t.toJSON():i==="toJS"?()=>t.toJS():i==="toJSForTest"?()=>t.toJSForTest():kr(e,t.get(i))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,i)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`obj[${i}]`),bo.deleteInternal(e,t,i),!0)}}static setInternal(e,t,i,r){if(i.includes("."))throw new v(w.ErrInvalidObjectKey,"key must not contain the '.'.");const s=e.issueTimeTicket(),o=kl(e,r,s),a=t.set(i,o,s);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(Nr.create(i,o.deepcopy(),t.getCreatedAt(),s))}static buildObjectMembers(e,t){const i={};for(const[r,s]of Object.entries(t)){if(r.includes("."))throw new v(w.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=kl(e,s,o);i[r]=a}return i}static deleteInternal(e,t,i){const r=e.issueTimeTicket(),s=t.deleteByKey(i,r);s&&(e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s))}getHandlers(){return this.handlers}}function Gw(n,e){const t=new ye(n,e);return new Proxy(e,t.getHandlers())}function Jw(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function Yw(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class ye{constructor(e,t){d(this,"context");d(this,"handlers");d(this,"array");this.context=e,this.array=t,this.handlers={get:(i,r,s)=>r==="getID"?()=>i.getCreatedAt():r==="getElementByID"?o=>{const a=i.getByID(o);if(!(!a||a.isRemoved()))return _n(e,a)}:r==="getElementByIndex"?o=>{const a=i.get(o);return _n(e,a)}:r==="getLast"?()=>_n(e,i.getLast()):r==="deleteByID"?o=>{const a=ye.deleteInternalByID(e,i,o);return _n(e,a)}:r==="insertAfter"?(o,a)=>{const l=ye.insertAfterInternal(e,i,o,a);return _n(e,l)}:r==="insertBefore"?(o,a)=>{const l=ye.insertBeforeInternal(e,i,o,a);return _n(e,l)}:r==="moveBefore"?(o,a)=>{ye.moveBeforeInternal(e,i,o,a)}:r==="moveAfter"?(o,a)=>{ye.moveAfterInternal(e,i,o,a)}:r==="moveFront"?o=>{ye.moveFrontInternal(e,i,o)}:r==="moveLast"?o=>{ye.moveLastInternal(e,i,o)}:Jw(r)?kr(e,i.get(Number(r))):r==="push"?o=>ye.pushInternal(e,i,o):r==="splice"?(o,a,...l)=>ye.splice(e,i,o,a,...l):r==="length"?i.length:typeof r=="symbol"&&r===Symbol.iterator?ye.iteratorInternal.bind(this,e,i):r==="includes"?(o,a)=>ye.includes(e,i,o,a):r==="indexOf"?(o,a)=>ye.indexOf(e,i,o,a):r==="lastIndexOf"?(o,a)=>ye.lastIndexOf(e,i,o,a):r==="toJSForTest"?()=>i.toJSForTest():r==="toTestString"?()=>ye.toTestString(i):typeof r=="string"&&Yw(r)?(...o)=>{const a=Array.from(i).map(l=>kr(e,l));return Array.prototype[r].apply(a,o)}:Reflect.get(i,r,s),deleteProperty:(i,r)=>(Z.isEnabled(Ge.Trivial)&&Z.trivial(`array[${r}]`),ye.deleteInternalByIndex(e,i,Number.parseInt(r)),!0)}}static*iteratorInternal(e,t){for(const i of t)yield _n(e,i)}static buildArrayElements(e,t){const i=[];for(const r of t){const s=e.issueTimeTicket(),o=kl(e,r,s);i.push(o)}return i}static pushInternal(e,t,i){return ye.insertAfterInternal(e,t,t.getLastCreatedAt(),i),t.length}static moveBeforeInternal(e,t,i,r){const s=e.issueTimeTicket(),o=t.getPrevCreatedAt(i);t.moveAfter(o,r,s),e.push(Kn.create(t.getCreatedAt(),o,r,s))}static moveAfterInternal(e,t,i,r){const s=e.issueTimeTicket();t.moveAfter(i,r,s),e.push(Kn.create(t.getCreatedAt(),i,r,s))}static moveFrontInternal(e,t,i){const r=e.issueTimeTicket(),s=t.getHead();t.moveAfter(s.getCreatedAt(),i,r),e.push(Kn.create(t.getCreatedAt(),s.getCreatedAt(),i,r))}static moveLastInternal(e,t,i){const r=e.issueTimeTicket(),s=t.getLastCreatedAt();t.moveAfter(s,i,r),e.push(Kn.create(t.getCreatedAt(),s,i,r))}static insertAfterInternal(e,t,i,r){const s=e.issueTimeTicket(),o=kl(e,r,s);return t.insertAfter(i,o),e.registerElement(o,t),e.push(Lo.create(t.getCreatedAt(),i,o.deepcopy(),s)),o}static insertBeforeInternal(e,t,i,r){return ye.insertAfterInternal(e,t,t.getPrevCreatedAt(i),r)}static deleteInternalByIndex(e,t,i){const r=e.issueTimeTicket(),s=t.deleteByIndex(i,r);if(s)return e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s),s}static deleteInternalByID(e,t,i){const r=e.issueTimeTicket(),s=t.delete(i,r);return e.push(ur.create(t.getCreatedAt(),s.getCreatedAt(),r)),e.registerRemovedElement(s),s}static splice(e,t,i,r,...s){const o=t.length,a=i>=0?Math.min(i,o):Math.max(o+i,0),l=r===void 0?o:r<0?a:Math.min(a+r,o),h=[];for(let c=a;c=s)return!1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).includes(i,o);for(let l=o;l=s)return-1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).indexOf(i,o);for(let l=o;l=s?s-1:r<0?r+s:r;if(o<0)return-1;if(ge.isSupport(i))return Array.from(t).map(h=>kr(e,h)).lastIndexOf(i,o);for(let l=o;l>0;l--)if(((a=t.get(l))==null?void 0:a.getID())===i.getID())return l;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}let oh=class{constructor(e,t){d(this,"context");d(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,i,r){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);Z.isEnabled(Ge.Debug)&&Z.debug(`EDIT: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} c:${i}`);const o=r?fs(r):void 0,a=this.context.issueTimeTicket(),[l,,h,c]=this.text.edit(s,i,a,o);for(const u of h)this.context.registerGCPair(u);return this.context.push(new Xo(this.text.getCreatedAt(),s[0],s[1],l,i,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(c)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,i){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.text.indexRangeToPosRange(e,t);Z.isEnabled(Ge.Debug)&&Z.debug(`STYL: f:${e}->${r[0].toTestString()}, t:${t}->${r[1].toTestString()} a:${JSON.stringify(i)}`);const s=fs(i),o=this.context.issueTimeTicket(),[a,l]=this.text.setStyle(r,s,o);for(const h of l)this.context.registerGCPair(h);return this.context.push(new Uo(this.text.getCreatedAt(),r[0],r[1],a,new Map(Object.entries(s)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Jt.fromStruct(e[0]),Jt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new v(w.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}};class ah{constructor(e,t){d(this,"valueType");d(this,"value");d(this,"context");d(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new v(w.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),i=ge.of(e,t);if(!i.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof i.getValue()}`);return this.counter.increase(i),this.context.push(ms.create(this.counter.getCreatedAt(),i,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new v(w.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function uf(n,e,t){const{type:i}=n,r=t.issueTimeTicket();if(i===Dn){$O(n);const{value:s}=n,o=ut.create(Ve.of(r,0),i,s);e.append(o)}else{const{children:s=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!Hm(o)){const h=fs(o);a=new Vn;for(const[c,u]of Object.entries(h))a.set(c,u,r)}const l=ut.create(Ve.of(r,0),i,void 0,a);e.append(l);for(const h of s)uf(h,l,t)}}function Hw(n,e){const{type:t}=e,i=n.issueTimeTicket();let r;if(e.type===Dn){const{value:s}=e;r=ut.create(Ve.of(i,0),t,s)}else if(e){const{children:s=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!Hm(o)){const l=fs(o);a=new Vn;for(const[h,c]of Object.entries(l))a.set(h,c,i)}r=ut.create(Ve.of(n.issueTimeTicket(),0),t,void 0,a);for(const l of s)uf(l,r,n)}return r}function $O(n){if(!n.value.length)throw new v(w.ErrInvalidArgument,"text node cannot have empty value");return!0}function Vd(n){if(!n.length)return!0;if(n[0].type===Dn)for(const t of n){const{type:i}=t;if(i!==Dn)throw new v(w.ErrInvalidArgument,"element node and text node cannot be passed together");$O(t)}else for(const t of n){const{type:i}=t;if(i===Dn)throw new v(w.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}let lh=class{constructor(e){d(this,"initialRoot");d(this,"context");d(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return ut.create(Ve.of(e.issueTimeTicket(),0),J1);const t=ut.create(Ve.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const i of this.initialRoot.children)uf(i,t,e);return t}getSize(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const[i,r]=this.tree.pathToPosRange(e),s=this.context.issueTimeTicket(),o=t?fs(t):void 0,[a]=this.tree.style([i,r],o,s);this.context.push(Nn.create(this.tree.getCreatedAt(),i,r,a,o?new Map(Object.entries(o)):new Map,s))}style(e,t,i){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=i?fs(i):void 0,[l,h]=this.tree.style([r,s],a,o);for(const c of h)this.context.registerGCPair(c);this.context.push(Nn.create(this.tree.getCreatedAt(),r,s,l,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,i){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(e),s=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,l]=this.tree.removeStyle([r,s],i,o);for(const h of l)this.context.registerGCPair(h);this.context.push(Nn.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),r,s,a,i,o))}editInternal(e,t,i,r=0){var h;if(i.length!==0&&i[0]&&(Vd(i),i[0].type!==Dn))for(const c of i){const{children:u=[]}=c;Vd(u)}const s=this.context.getLastTimeTicket();let o=new Array;if(((h=i[0])==null?void 0:h.type)===Dn){let c="";for(const u of i){const{value:f}=u;c+=f}o.push(ut.create(Ve.of(this.context.issueTimeTicket(),0),Dn,c))}else o=i.map(c=>c&&Hw(this.context,c)).filter(c=>c);const[,a,l]=this.tree.edit([e,t],o.length?o.map(c=>c==null?void 0:c.deepcopy()):void 0,r,s,()=>this.context.issueTimeTicket());for(const c of a)this.context.registerGCPair(c);return this.context.push(Zo.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,r,l,s)),!0}editByPath(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new v(w.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,i?[i]:[],r)}editBulkByPath(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new v(w.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new v(w.ErrInvalidArgument,"path should not be empty");const s=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(s,o,i,r)}edit(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,i?[i]:[],r)}editBulk(e,t,i,r=0){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new v(w.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(s,o,i,r)}toXML(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],i=this.tree.indexRangeToPosRange(t);return[i[0].toStruct(),i[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[_t.fromStruct(e[0]),_t.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new v(w.ErrNotInitialized,"Tree is not initialized yet");const t=[_t.fromStruct(e[0]),_t.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}};function Ld(n,e){return AO(n,e)}function _n(n,e){if(e){if(e instanceof ge)return e;if(e instanceof nt)return AO(n,e);if(e instanceof dt)return Gw(n,e);if(e instanceof qt)return new oh(n,e);if(e instanceof pt){const t=new ah(Pi.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof Mt){const t=new lh;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function kr(n,e){const t=_n(n,e);return t instanceof ge?t.getValue():t}function kl(n,e,t){let i;if(ge.isSupport(e))i=ge.of(e,t);else if(Array.isArray(e))i=dt.create(t,ye.buildArrayElements(n,e));else if(typeof e=="object")e instanceof oh?(i=qt.create(gs.create(),t),e.initialize(n,i)):e instanceof ah?(i=pt.create(e.getValueType(),e.getValue(),t),e.initialize(n,i)):e instanceof lh?(i=Mt.create(e.buildRoot(n),t),e.initialize(n,i)):i=nt.create(t,bo.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return i}const Xd=50;class Kw{constructor(){d(this,"undoStack",[]);d(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=Xd&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=Xd&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const ev="yorkie-devtools-panel",tv="yorkie-devtools-sdk";let Fr="disconnected";const Ud=new Map,Va=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Va);function sa(n,e){(e!=null&&e.force||Fr!=="disconnected")&&window.postMessage({source:tv,...n},"*")}function iv(n){if(!n.isEnableDevtools()||typeof window>"u"||Ud.has(n.getKey()))return;Va.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(i=>i.type!==Re.StatusChanged&&i.type!==Re.Snapshot&&i.type!==Re.LocalChange&&i.type!==Re.RemoteChange&&i.type!==Re.Initialized&&i.type!==Re.Watched&&i.type!==Re.Unwatched&&i.type!==Re.PresenceChanged)||(Va.get(n.getKey()).push(t),Fr==="synced"&&sa({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});Ud.set(n.getKey(),[e]),sa({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var r;if(((r=t.data)==null?void 0:r.source)!==ev)return;switch(t.data.msg){case"devtools::connect":if(Fr!=="disconnected")break;Fr="connected",sa({msg:"doc::available",docKey:n.getKey()}),Z.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Fr="disconnected",Z.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Fr="synced",sa({msg:"doc::sync::full",docKey:n.getKey(),events:Va.get(n.getKey())}),Z.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var Gn=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(Gn||{}),Re=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Re||{}),So=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(So||{}),Wc=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Wc||{});class CO{constructor(e,t){d(this,"key");d(this,"status");d(this,"opts");d(this,"changeID");d(this,"checkpoint");d(this,"localChanges");d(this,"root");d(this,"clone");d(this,"eventStream");d(this,"eventStreamObserver");d(this,"onlineClients");d(this,"presences");d(this,"history");d(this,"internalHistory");d(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=yo.create(),this.changeID=sw,this.checkpoint=ow,this.localChanges=[],this.eventStream=_w(i=>{this.eventStreamObserver=i}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Kw,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},iv(this)}update(e,t){if(this.getStatus()==="removed")throw new v(w.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const i=this.changeID.getActorID(),r=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(i)||{},t);try{const s=Ld(r,this.clone.root.getObject());this.presences.has(i)||this.clone.presences.set(i,{}),this.isUpdating=!0,e(s,new Ch(r,this.clone.presences.get(i)))}catch(s){throw this.clone=void 0,s}finally{this.isUpdating=!1}if(r.hasChange()){Z.isEnabled(Ge.Trivial)&&Z.trivial(`trying to update a local change: ${this.toJSON()}`);const s=r.getChange(),{opInfos:o,reverseOps:a}=s.execute(this.root,this.presences,se.Local),l=r.getReversePresence();l&&a.push({type:"presence",value:l}),this.localChanges.push(s),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=s.getID();const h=[];o.length>0&&h.push({type:"local-change",source:se.Local,value:{message:s.getMessage()||"",operations:o,actor:i,clientSeq:s.getID().getClientSeq(),serverSeq:s.getID().getServerSeq()},rawChange:this.isEnableDevtools()?s.toStruct():void 0}),s.hasPresenceChange()&&h.push({type:"presence-changed",source:se.Local,value:{clientID:i,presence:this.getPresence(i)}}),this.publish(h),Z.isEnabled(Ge.Trivial)&&Z.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,i,r){if(typeof e=="string"){if(typeof t!="function")throw new v(w.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||a(h)},i,r)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="initialized"&&h.type!=="presence-changed"||h.type==="presence-changed"&&h.value.clientID!==this.changeID.getActorID()||a(h)},i,r)}if(e==="others"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="watched"&&h.type!=="unwatched"&&h.type!=="presence-changed"||h.value.clientID!==this.changeID.getActorID()&&a(h)},i,r)}if(e==="connection"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="connection-changed"&&a(h)},i,r)}if(e==="status"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="status-changed"&&a(h)},i,r)}if(e==="sync"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="sync-status-changed"&&a(h)},i,r)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="local-broadcast"&&a(h)},i)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="broadcast"&&a(h)},i)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(l=>{for(const h of l)h.type==="auth-error"&&a(h)},i)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,i,r)}const s=e,o=t;return this.eventStream.subscribe(a=>{for(const l of a){if(l.type!=="local-change"&&l.type!=="remote-change")continue;const h=[];for(const c of l.value.operations)this.isSameElementOrChildOf(c.path,s)&&h.push(c);h.length&&o({...l,value:{...l.value,operations:h}})}},i,r)}if(typeof e=="function"){const s=e,o=t,a=i;return this.eventStream.subscribe(l=>{for(const h of l)h.type!=="snapshot"&&h.type!=="local-change"&&h.type!=="remote-change"||s(h)},o,a)}throw new v(w.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const i=e.split(".");return t.split(".").every((s,o)=>s===i[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),se.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),Z.isEnabled(Ge.Trivial)&&Z.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:Wt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return sh.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Ld(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,i,r=-1){const{root:s,presences:o}=ke.bytesToSnapshot(i);this.root=new yo(s),this.presences=o,this.changeID=this.changeID.setClocks(t.maxLamport(),t),this.clone=void 0,this.removePushedLocalChanges(r),this.applyChanges(this.localChanges,se.Local),this.publish([{type:"snapshot",source:se.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?ke.bytesToHex(i):void 0,snapshotVector:ke.versionVectorToHex(t)}}])}applyChanges(e,t){Z.isEnabled(Ge.Debug)&&Z.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),Z.isEnabled(Ge.Trivial)&&Z.trivial(e.map(i=>`${i.getID().toTestString()} ${i.toTestString()}`).join(` +`));for(const i of e)this.applyChange(i,t);Z.isEnabled(Ge.Debug)&&Z.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const i=[],r=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(r)){const o=e.getPresenceChange();switch(o.type){case cr.Put:i.push(this.presences.has(r)?{type:"presence-changed",source:t,value:{clientID:r,presence:o.presence}}:{type:"watched",source:se.Remote,value:{clientID:r,presence:o.presence}});break;case cr.Clear:i.push({type:"unwatched",source:se.Remote,value:{clientID:r,presence:this.getPresence(r)}}),this.removeOnlineClient(r);break}}const{opInfos:s}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),s.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;i.push(t===se.Remote?{type:"remote-change",source:t,value:{actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o}:{type:"local-change",source:t,value:{actor:r,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:s},rawChange:o})}i.length>0&&this.publish(i)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,i=new Set;for(const r of t)r!==this.changeID.getActorID()&&i.add(r);this.setOnlineClients(i),this.publish([{type:"initialized",source:se.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:i}=e.body.value,r=[];if(t===Rr.DOCUMENT_WATCHED){if(this.onlineClients.has(i)&&this.hasPresence(i))return;this.addOnlineClient(i),this.hasPresence(i)&&r.push({type:"watched",source:se.Remote,value:{clientID:i,presence:this.getPresence(i)}})}else if(t===Rr.DOCUMENT_UNWATCHED){const s=this.getPresence(i);this.removeOnlineClient(i),s&&r.push({type:"unwatched",source:se.Remote,value:{clientID:i,presence:s}})}else if(t===Rr.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:s,payload:o}=e.body.value.body,a=new TextDecoder;r.push({type:"broadcast",value:{clientID:i,topic:s,payload:JSON.parse(a.decode(o))}})}r.length>0&&this.publish(r)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(nh),this.publish([{source:e==="removed"?se.Remote:se.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:i,snapshotVector:r}=e.value;if(!t)return;this.applySnapshot(BigInt(i),ke.hexToVersionVector(r),ke.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ps.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:i,presence:r}of e.value)t.add(i),this.presences.set(i,r);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:i}=e.value;this.addOnlineClient(t),this.presences.set(t,i);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:i}=e.value;this.presences.set(t,i)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new v(w.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let i=this.getRoot();for(const r of t)if(i=i[r],i===void 0)return;return i}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?Wt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?Wt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?Wt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:Wt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:Wt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,i)=>t.clientID>i.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const i=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(i)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new v(w.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new v(w.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of e){if(!(h instanceof Yt)){new Ch(t,Wt(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const c=t.issueTimeTicket();h.setExecutedAt(c),t.push(h)}const i=t.getChange();i.execute(this.clone.root,this.clone.presences,se.UndoRedo);const{opInfos:r,reverseOps:s}=i.execute(this.root,this.presences,se.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushRedo(s),!i.hasPresenceChange()&&r.length===0)return;this.localChanges.push(i),this.changeID=i.getID();const a=this.changeID.getActorID(),l=[];r.length>0&&l.push({type:"local-change",source:se.UndoRedo,value:{message:i.getMessage()||"",operations:r,actor:a,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:se.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}redo(){if(this.isUpdating)throw new v(w.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new v(w.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Yr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const h of e){if(!(h instanceof Yt)){new Ch(t,Wt(this.clone.presences.get(this.changeID.getActorID()))).set(h.value,{addToHistory:!0});continue}const c=t.issueTimeTicket();h.setExecutedAt(c),t.push(h)}const i=t.getChange();i.execute(this.clone.root,this.clone.presences,se.UndoRedo);const{opInfos:r,reverseOps:s}=i.execute(this.root,this.presences,se.UndoRedo),o=t.getReversePresence();if(o&&s.push({type:"presence",value:o}),s.length>0&&this.internalHistory.pushUndo(s),!i.hasPresenceChange()&&r.length===0)return;this.localChanges.push(i),this.changeID=i.getID();const a=this.changeID.getActorID(),l=[];r.length>0&&l.push({type:"local-change",source:se.UndoRedo,value:{message:i.getMessage()||"",operations:r,actor:a,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:se.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(l)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,i){const r={type:"local-broadcast",value:{topic:e,payload:t},options:i};this.publish([r])}getVersionVector(){return this.changeID.getVersionVector()}}function nv(n,e){let t=e;return{authInterceptor:s=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await s(o)),setToken:s=>{t=s}}}const rv="yorkie-js-sdk",sv="0.5.6",ov="Yorkie JS SDK",av="./src/yorkie.ts",lv={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},hv=["dist"],cv={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},uv={node:">=18.0.0",npm:">=7.1.0"},fv={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},dv={name:"hackerwins",email:"susukang98@gmail.com"},pv="Apache-2.0",gv={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},mv="https://github.com/yorkie-team/yorkie-js-sdk#readme",Ov={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},yv={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Zd={name:rv,version:sv,description:ov,main:av,publishConfig:lv,files:hv,scripts:cv,engines:uv,repository:fv,author:dv,license:pv,bugs:gv,homepage:mv,devDependencies:Ov,dependencies:yv};function bv(){return n=>async e=>(e.header.set("x-yorkie-user-agent",Zd.name+"/"+Zd.version),await n(e))}const Sv=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var La=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(La||{});const oa={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Dh={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class IO{constructor(e,t){d(this,"id");d(this,"key");d(this,"status");d(this,"attachmentMap");d(this,"apiKey");d(this,"authTokenInjector");d(this,"conditions");d(this,"syncLoopDuration");d(this,"reconnectStreamDelay");d(this,"retrySyncLoopDelay");d(this,"rpcClient");d(this,"setAuthToken");d(this,"taskQueue");d(this,"processing",!1);d(this,"keepalive",!1);t=t||oa,this.key=t.key?t.key:PO(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??oa.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??oa.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??oa.retrySyncLoopDelay;const{authInterceptor:i,setToken:r}=nv(this.apiKey);this.setAuthToken=r,this.rpcClient=b1(U1,X1({baseUrl:e,interceptors:[i,bv()],fetch:(s,o)=>{const a={...o,keepalive:this.keepalive};return fetch(s,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),Z.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw Z.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),Z.info(`[DC] c"${this.getKey()}" deactivated`)}catch(i){throw Z.error(`[DC] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}};if(e.keepalive){this.keepalive=!0;const i=t();return this.keepalive=!1,i}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==Gn.Detached)throw new v(w.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((s,o)=>o.set(t.initialPresence||{}));const i=e.subscribe("local-broadcast",async s=>{var c;const{topic:o,payload:a}=s.value,l=(c=s.options)==null?void 0:c.error,h=s.options;try{await this.broadcast(e.getKey(),o,a,h)}catch(u){u instanceof Error&&(l==null||l(u))}}),r=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:ke.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async s=>{const o=ke.fromChangePack(s.changePack);if(e.applyChangePack(o),e.getStatus()===Gn.Removed)return e;e.applyStatus(Gn.Attached),this.attachmentMap.set(e.getKey(),new zw(this.reconnectStreamDelay,e,s.documentId,r,i)),r!=="manual"&&await this.runWatchLoop(e.getKey()),Z.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const l=t.initialRoot;e.update(h=>{for(const[c,u]of Object.entries(l))if(!a.has(c)){const f=c;h[f]=u}})}return e}).catch(async s=>{throw Z.error(`[AD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}detach(e,t={}){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e.getKey());if(!i)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((r,s)=>s.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:i.docID,changePack:ke.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(r=>{const s=ke.fromChangePack(r.changePack);return e.applyChangePack(s),e.getStatus()!==Gn.Removed&&e.applyStatus(Gn.Detached),this.detachInternal(e.getKey()),Z.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async r=>{throw Z.error(`[DD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}async changeSyncMode(e,t){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e.getKey());if(!i)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const r=i.syncMode;return r===t?e:(i.changeSyncMode(t),t==="manual"?(i.cancelWatchStream(),e):(t==="realtime"&&(i.remoteChangeEventReceived=!0),r==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async i=>{throw Z.error(`[SY] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}return this.enqueueTask(async()=>{const t=[];for(const[,i]of this.attachmentMap)t.push(this.syncInternal(i,i.syncMode));return Promise.all(t).catch(async i=>{throw Z.error(`[SY] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i})})}remove(e){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new v(w.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const i=ke.toChangePack(e.createChangePack());return i.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:i},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(r=>{const s=ke.fromChangePack(r.changePack);e.applyChangePack(s),this.detachInternal(e.getKey()),Z.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async r=>{throw Z.error(`[RD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,i,r){if(!this.isActive())throw new v(w.ErrClientNotActivated,`${this.key} is not active`);const s=this.attachmentMap.get(e);if(!s)throw new v(w.ErrDocumentNotAttached,`${e} is not attached`);if(!Sv(i))throw new v(w.ErrInvalidArgument,"payload is not serializable");const o=(r==null?void 0:r.maxRetries)??Dh.maxRetries,a=Dh.maxBackoff;let l=0;const h=u=>Math.min(Dh.initialRetryInterval*2**u,a),c=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:s.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(i))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{Z.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async u=>{if(Z.error(`[BC] c:"${this.getKey()}" err:`,u),await this.handleConnectError(u))if(u instanceof ue&&Wr(u)===w.ErrUnauthenticated&&s.doc.publish([{type:Re.AuthError,value:{reason:js(u).reason,method:"Broadcast"}}]),lc(),h(l-1)),Z.info(`[BC] c:"${this.getKey()}" retry attempt ${l}/${o}`);else throw Z.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),u;else throw u}));return c()}runSyncLoop(){const e=()=>{if(!this.isActive()){Z.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,i]of this.attachmentMap)i.needRealtimeSync()&&(i.remoteChangeEventReceived=!1,t.push(this.syncInternal(i,i.syncMode).catch(async r=>{throw r instanceof ue&&Wr(r)===w.ErrUnauthenticated&&i.doc.publish([{type:Re.AuthError,value:{reason:js(r).reason,method:"PushPull"}}]),r})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async i=>{Z.error(`[SL] c:"${this.getKey()}" sync failed:`,i),await this.handleConnectError(i)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};Z.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new v(w.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(i=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new v(w.ErrClientNotActivated,`${this.key} is not active`));const r=new AbortController,s=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:r.signal});return t.doc.publish([{type:Re.ConnectionChanged,value:So.Connected}]),Z.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const h of s)this.handleWatchDocumentsResponse(t,h),h.body.case==="initialization"&&o([s,r])}catch(h){t.doc.resetOnlineClients(),t.doc.publish([{type:Re.Initialized,source:se.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Re.ConnectionChanged,value:So.Disconnected}]),Z.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(h)?(h instanceof ue&&Wr(h)===w.ErrUnauthenticated&&t.doc.publish([{type:Re.AuthError,value:{reason:js(h).reason,method:"WatchDocuments"}}]),i()):this.conditions.WatchLoop=!1,a(h)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===Rr.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(Gn.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:i,docID:r}=e,s=i.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:r,changePack:ke.toChangePack(s),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${i.getKey()}`}}).then(o=>{const a=ke.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return i;i.applyChangePack(a),e.doc.publish([{type:Re.SyncStatusChanged,value:Wc.Synced}]),i.getStatus()===Gn.Removed&&this.detachInternal(i.getKey());const l=i.getKey(),h=a.getChangeSize();return Z.info(`[PP] c:"${this.getKey()}" sync d:"${l}", push:${s.getChangeSize()} pull:${h} cp:${a.getCheckpoint().toTestString()}`),i}).catch(async o=>{throw i.publish([{type:Re.SyncStatusChanged,value:Wc.SyncFailed}]),Z.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof ue))return!1;if(e.code===ne.Canceled||e.code===ne.Unknown||e.code===ne.ResourceExhausted||e.code===ne.Unavailable)return!0;if(Wr(e)===w.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(js(e).reason);this.setAuthToken(t)}return!0}return(Wr(e)===w.ErrClientNotActivated||Wr(e)===w.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,i)=>{this.taskQueue.push(()=>e().then(t).catch(i)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{Z.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Nh={Client:IO,Document:CO,Primitive:ge,Text:oh,Counter:ah,Tree:lh,LogLevel:Ge,setLogLevel:QO,IntType:Pi.IntegerCnt,LongType:Pi.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:IO,Document:CO,Primitive:ge,Text:oh,Counter:ah,Tree:lh,LogLevel:Ge,setLogLevel:QO,IntType:Pi.IntegerCnt,LongType:Pi.LongCnt});class ee{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Os(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),ui.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Os(this,e,t);let i=[];return this.decompose(e,t,i,0),ui.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new io(this),s=new io(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new io(this,e)}iterRange(e,t=this.length){return new RO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new EO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ee.empty:e.length<=32?new ve(e):ui.from(ve.split(e,[]))}}class ve extends ee{constructor(e,t=wv(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?i:a)>=e)return new vv(r,a,i,o);r=a+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new ve(Wd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),a=Xa(s.text,o.text.slice(),0,s.length);if(a.length<=32)i.push(new ve(a,o.length+s.length));else{let l=a.length>>1;i.push(new ve(a.slice(0,l)),new ve(a.slice(l)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof ve))return super.replace(e,t,i);[e,t]=Os(this,e,t);let r=Xa(this.text,Xa(i.text,Wd(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new ve(r,s):ui.from(ve.split(r,[]),s)}sliceString(e,t=this.length,i=` `){[e,t]=Os(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=i),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new ve(i,r)),i=[],r=-1);return r>-1&&t.push(new ve(i,r)),t}}class ui extends ee{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=i+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,i,r);r=a+1,i=l+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s=o){let h=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!h?i.push(a):a.decompose(e-o,t-o,i,h)}o=l+1}}replace(e,t,i){if([e,t]=Os(this,e,t),i.lines=s&&t<=a){let l=o.replace(e-s,t-s,i),h=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>h>>6){let c=this.children.slice();return c[r]=l,new ui(c,this.length-(t-e)+i.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=Os(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=a.sliceString(e-o,t-o,i)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof ui))return 0;let i=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return i;let l=this.children[r],h=e.children[s];if(l!=h)return i+l.scanIdentical(h,t);i+=l.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new ve(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,a=[],l=0,h=-1,c=[];function u(p){let g;if(p.lines>s&&p instanceof ui)for(let O of p.children)u(O);else p.lines>o&&(l>o||!l)?(f(),a.push(p)):p instanceof ve&&l&&(g=c[c.length-1])instanceof ve&&p.lines+g.lines<=32?(l+=p.lines,h+=p.length+1,c[c.length-1]=new ve(g.text.concat(p.text),g.length+1+p.length)):(l+p.lines>r&&f(),l+=p.lines,h+=p.length+1,c.push(p))}function f(){l!=0&&(a.push(c.length==1?c[0]:ui.from(c,h)),h=-1,l=c.length=0)}for(let p of e)u(p);return f(),a.length==1?a[0]:new ui(a,t)}}ee.empty=new ve([""],0);function wv(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Xa(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s=t&&(l>i&&(a=a.slice(0,i-r)),r0?1:(e instanceof ve?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,a=r instanceof ve?r.text.length:r.children.length;if(o==(t>0?a:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof ve){let l=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof ve?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class RO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new io(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class EO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ee.prototype[Symbol.iterator]=function(){return this.iter()},io.prototype[Symbol.iterator]=RO.prototype[Symbol.iterator]=EO.prototype[Symbol.iterator]=function(){return this});let vv=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Os(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}let rs="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;nn)return rs[e-1]<=n;return!1}function jd(n){return n>=127462&&n<=127487}const zd=8205;function je(n,e,t=!0,i=!0){return(t?DO:xv)(n,e,i)}function DO(n,e,t){if(e==n.length)return e;e&&NO(n.charCodeAt(e))&&BO(n.charCodeAt(e-1))&&e--;let i=Be(n,e);for(e+=lt(i);e=0&&jd(Be(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function xv(n,e,t){for(;e>0;){let i=DO(n,e-2,t);if(i=56320&&n<57344}function BO(n){return n>=55296&&n<56320}function Be(n,e){let t=n.charCodeAt(e);if(!BO(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return NO(i)?(t-55296<<10)+(i-56320)+65536:t}function ff(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function lt(n){return n<65536?1:2}const Wc=/\r\n?|\n/;var Me=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Me||(Me={}));class Qi{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(i!=Me.Simple&&h>=e&&(i==Me.TrackDel&&re||i==Me.TrackBefore&&re))return null;if(h>e||h==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qi(e)}static create(e){return new Qi(e)}}class Ce extends Qi{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return jc(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return zc(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;i.length0&&er(i,t,s.text),s.forward(c),a+=c}let h=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,a=null;function l(c=!1){if(!c&&!r.length)return;of||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let g=p?typeof p=="string"?ee.of(p.split(i||Wc)):p:ee.empty,O=g.length;if(u==f&&O==0)return;uo&&Ue(r,u-o,-1),Ue(r,f-u,O),er(s,r,g),o=f}}return h(e),l(!a),a}static empty(e){return new Ce(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function er(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)a=n.sections[o++],l=n.sections[o++];e(r,h,s,c,u),r=h,s=c}}}function zc(n,e,t,i=!1){let r=[],s=i?[]:null,o=new wo(n),a=new wo(e);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let h=Math.min(o.len,a.len);Ue(r,h,-1),o.forward(h),a.forward(h)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let h=0,c=o.len;for(;c;)if(a.ins==-1){let u=Math.min(c,a.len);h+=u,c-=u,a.forward(u)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||i.length>h),s.forward2(l),o.forward(l)}}}}class wo{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ee.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ee.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class $r{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new $r(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Q.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Q.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Q.range(e.anchor,e.head)}static create(e,t,i){return new $r(e,t,i)}}class Q{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Q.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Q(e.ranges.map(t=>$r.fromJSON(t)),e.main)}static single(e,t=e){return new Q([Q.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;re?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;rs.head?Q.range(l,a):Q.range(a,l))}}return new Q(e,t)}}function MO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let df=0;class B{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=df++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new B(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:pf),!!e.static,e.enables)}of(e){return new Ua([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ua(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ua(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function pf(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Ua{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=df++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,h=!1,c=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?h=!0:((t=e[u.id])!==null&&t!==void 0?t:1)&1||c.push(e[u.id]);return{create(u){return u.values[o]=i(u),1},update(u,f){if(l&&f.docChanged||h&&(f.docChanged||f.selection)||Fc(u,c)){let p=i(u);if(a?!Fd(p,u.values[o],r):!r(p,u.values[o]))return u.values[o]=p,1}return 0},reconfigure:(u,f)=>{let p,g=f.config.address[s];if(g!=null){let O=Tl(f,g);if(this.dependencies.every(y=>y instanceof B?f.facet(y)===u.facet(y):y instanceof Ee?f.field(y,!1)==u.field(y,!1):!0)||(a?Fd(p=i(u),O,r):r(p=i(u),O)))return u.values[o]=O,0}else p=i(u);return u.values[o]=p,1}}}}function Fd(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[l.id]),r=t.map(l=>l.type),s=i.filter(l=>!(l&1)),o=n[e.id]>>1;function a(l){let h=[];for(let c=0;ci===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(_d).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,_d.of({field:this,create:e})]}get extension(){return this}}const Tr={lowest:4,low:3,default:2,high:1,highest:0};function Ns(n){return e=>new VO(e,n)}const mr={highest:Ns(Tr.highest),high:Ns(Tr.high),default:Ns(Tr.default),low:Ns(Tr.low),lowest:Ns(Tr.lowest)};class VO{constructor(e,t){this.inner=e,this.prec=t}}class lh{of(e){return new _c(this,e)}reconfigure(e){return lh.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class _c{constructor(e,t){this.compartment=e,this.inner=t}}class xl{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let f of Qv(e,t,o))f instanceof Ee?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],h=[];for(let f of r)a[f.id]=h.length<<1,h.push(p=>f.slot(p));let c=i==null?void 0:i.config.facets;for(let f in s){let p=s[f],g=p[0].facet,O=c&&c[f]||[];if(p.every(y=>y.type==0))if(a[g.id]=l.length<<1|1,pf(O,p))l.push(i.facet(g));else{let y=g.combine(p.map(S=>S.value));l.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(a[y.id]=l.length<<1|1,l.push(y.value)):(a[y.id]=h.length<<1,h.push(S=>y.dynamicSlot(S)));a[g.id]=h.length<<1,h.push(y=>Tv(y,g,p))}}let u=h.map(f=>f(a));return new xl(e,o,u,a,l,s)}}function Qv(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let h=i[l].indexOf(o);h>-1&&i[l].splice(h,1),o instanceof _c&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let h of o)s(h,a);else if(o instanceof _c){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,a)}else if(o instanceof VO)s(o.inner,o.prec);else if(o instanceof Ee)i[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Ua)i[a].push(o),o.facet.extensions&&s(o.facet.extensions,Tr.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,a)}}return s(n,Tr.default),i.reduce((o,a)=>o.concat(a))}function no(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Tl(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const LO=B.define(),Gc=B.define({combine:n=>n.some(e=>e),static:!0}),XO=B.define({combine:n=>n.length?n[0]:void 0,static:!0}),UO=B.define(),ZO=B.define(),WO=B.define(),jO=B.define({combine:n=>n.length?n[0]:!1});class jn{constructor(e,t){this.type=e,this.value=t}static define(){return new Pv}}class Pv{of(e){return new jn(this,e)}}class Av{constructor(e){this.map=e}of(e){return new _(this,e)}}class _{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new _(this.type,t)}is(e){return this.type==e}static define(e={}){return new Av(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}_.reconfigure=_.define();_.appendConfig=_.define();class Se{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&MO(i,t.newLength),s.some(a=>a.type==Se.time)||(this.annotations=s.concat(Se.time.of(Date.now())))}static create(e,t,i,r,s,o){return new Se(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Se.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Se.time=jn.define();Se.userEvent=jn.define();Se.addToHistory=jn.define();Se.remote=jn.define();function $v(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i=n[i]))s=n[i++],o=n[i++];else if(r=0;r--){let s=i[r](n);s instanceof Se?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Se?n=s[0]:n=FO(e,ss(s),!1)}return n}function Iv(n){let e=n.startState,t=e.facet(WO),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=zO(i,Jc(e,s,n.changes.newLength),!0))}return i==n?n:Se.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Rv=[];function ss(n){return n==null?Rv:Array.isArray(n)?n:[n]}var de=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(de||(de={}));const Ev=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Yc;try{Yc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Dv(n){if(Yc)return Yc.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Ev.test(t)))return!0}return!1}function Nv(n){return e=>{if(!/\S/.test(e))return de.Space;if(Dv(e))return de.Word;for(let t=0;t-1)return de.Word;return de.Other}}class K{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(h,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(_.reconfigure)?(t=null,i=a.value):a.is(_.appendConfig)&&(t=null,i=ss(i).concat(a.value));let s;t?s=e.startState.values.slice():(t=xl.resolve(i,r,this),s=new K(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values);let o=e.startState.facet(Gc)?e.newSelection:e.newSelection.asSingle();new K(t,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Q.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=ss(i.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return K.create({doc:e.doc,selection:Q.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=xl.resolve(e.extensions||[],new Map),i=e.doc instanceof ee?e.doc:ee.of((e.doc||"").split(t.staticFacet(K.lineSeparator)||Wc)),r=e.selection?e.selection instanceof Q?e.selection:Q.single(e.selection.anchor,e.selection.head):Q.single(0);return MO(r,i.length),t.staticFacet(Gc)||(r=r.asSingle()),new K(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(K.tabSize)}get lineBreak(){return this.facet(K.lineSeparator)||` -`}get readOnly(){return this.facet(jO)}phrase(e,...t){for(let i of this.facet(K.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(LO))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Nv(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,a=e-i;for(;o>0;){let l=je(t,o,!1);if(s(t.slice(l,o))!=de.Word)break;o=l}for(;an.length?n[0]:4});K.lineSeparator=XO;K.readOnly=jO;K.phrases=B.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});K.languageData=LO;K.changeFilter=UO;K.transactionFilter=ZO;K.transactionExtender=WO;lh.reconfigure=_.define();function Ai(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],a=i[s];if(a===void 0)i[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class Br{eq(e){return this==e}range(e,t=e){return Hc.create(e,t,this)}}Br.prototype.startSide=Br.prototype.endSide=0;Br.prototype.point=!1;Br.prototype.mapMode=Me.TrackDel;let Hc=class _O{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new _O(e,t,i)}};function Kc(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class gf{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,h=s[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return h>=0?o:a;h>=0?a=l:o=l+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sp||f==p&&h.startSide>0&&h.endSide<=0)continue;(p-f||h.endSide-h.startSide)<0||(o<0&&(o=f),h.point&&(a=Math.max(a,p-f)),i.push(h),r.push(f-o),s.push(p-o))}return{mapped:i.length?new gf(r,s,i,a):null,pos:o}}}class J{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new J(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Kc)),this.isEmpty)return t.length?J.of(t):this;let a=new GO(this,null,-1).goto(0),l=0,h=[],c=new fr;for(;a.value||l=0){let u=t[l++];c.addInner(u.from,u.to,u.value)||h.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return vo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return vo.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),a=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=s),l=Gd(o,a,i),h=new Bs(o,l,s),c=new Bs(a,l,s);i.iterGaps((u,f,p)=>Jd(h,u,c,f,p,r)),i.empty&&i.length==0&&Jd(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=Gd(s,o),l=new Bs(s,a,0).goto(i),h=new Bs(o,a,0).goto(i);for(;;){if(l.to!=h.to||!eu(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>r)return!0;l.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Bs(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),u=o.pointFroma&&(r.span(a,h,o.active,l),l=o.openEnd(h));if(o.to>i)return l+(o.point&&o.to>i?1:0);a=o.to,o.next()}}static of(e,t=!1){let i=new fr;for(let r of e instanceof Hc?[e]:t?Bv(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return J.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=J.empty;r=r.nextLayer)t=new J(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}J.empty=new J([],[],null,-1);function Bv(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(Kc);e=i}return n}J.empty.nextLayer=J.empty;class fr{finishChunk(e){this.chunks.push(new gf(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new fr)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(J.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=J.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Gd(n,e,t){let i=new Map;for(let s of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new GO(o,t,i,s));return r.length==1?r[0]:new vo(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Nh(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Nh(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Nh(this.heap,0)}}}function Nh(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}class Bs{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=vo.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){aa(this.active,e),aa(this.activeTo,e),aa(this.activeRank,e),this.minActive=Yd(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t0;)t++;la(this.active,t,i),la(this.activeTo,t,r),la(this.activeRank,t,s),e&&la(e,t,this.cursor.from),this.minActive=Yd(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&aa(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Jd(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,a=i,l=i-e;for(;;){let h=n.to+l-t.to||n.endSide-t.endSide,c=h<0?n.to+l:t.to,u=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&eu(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(a,u,n.point,t.point):u>a&&!eu(n.active,t.active)&&s.compareRange(a,u,n.active,t.active),c>o)break;a=c,h<=0&&n.next(),h>=0&&t.next()}}function eu(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function Yd(n,e){let t=-1,i=1e9;for(let r=0;r=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=je(n,r)}return i===!0?-1:n.length}const iu="ͼ",Hd=typeof Symbol>"u"?"__"+iu:Symbol.for(iu),nu=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Kd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};let ys=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,h){let c=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let p in a){let g=a[p];if(/&/.test(p))s(p.split(/,\s*/).map(O=>o.map(y=>O.replace(/&/,y))).reduce((O,y)=>O.concat(y)),g,l);else if(g&&typeof g=="object"){if(!u)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,f)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,O=>"-"+O.toLowerCase())+": "+g+";")}(c.length||f)&&l.push((i&&!u&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Kd[Hd]||1;return Kd[Hd]=e+1,iu+e.toString(36)}static mount(e,t,i){let r=e[nu],s=i&&i.nonce;r?s&&r.setNonce(s):r=new qv(e,s),r.mount(Array.isArray(t)?t:[t],e)}},ep=new Map,qv=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=ep.get(i);if(s)return e[nu]=s;this.sheet=new r.CSSStyleSheet,ep.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[nu]=this}mount(e,t){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,a),i)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tp=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Mv=typeof navigator<"u"&&/Mac/.test(navigator.platform),Vv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Lv=Mv||tp&&+tp[1]<57;for(var qe=0;qe<10;qe++)dr[48+qe]=dr[96+qe]=String(qe);for(var qe=1;qe<=24;qe++)dr[qe+111]="F"+qe;for(var qe=65;qe<=90;qe++)dr[qe]=String.fromCharCode(qe+32),ko[qe]=String.fromCharCode(qe);for(var Bh in dr)ko.hasOwnProperty(Bh)||(ko[Bh]=dr[Bh]);function Xv(n){var e=Lv&&(n.ctrlKey||n.altKey||n.metaKey)||Vv&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ko:dr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Ql(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function ru(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Uv(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Za(n,e){if(!e.anchorNode)return!1;try{return ru(n,e.anchorNode)}catch{return!1}}function xo(n){return n.nodeType==3?qr(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function ro(n,e,t,i){return t?ip(n,e,t,i,-1)||ip(n,e,t,i,1):!1}function To(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function ip(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Ln(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=To(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?Ln(n):0}else return!1}}function Ln(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function mf(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Zv(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function JO(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Wv(n,e,t,i,r,s,o,a){let l=n.ownerDocument,h=l.defaultView||window;for(let c=n,u=!1;c&&!u;)if(c.nodeType==1){let f,p=c==l.body,g=1,O=1;if(p)f=Zv(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let k=c.getBoundingClientRect();({scaleX:g,scaleY:O}=JO(c,k)),f={left:k.left,right:k.left+c.clientWidth*g,top:k.top,bottom:k.top+c.clientHeight*O}}let y=0,S=0;if(r=="nearest")e.top0&&e.bottom>f.bottom+S&&(S=e.bottom-f.bottom+S+o)):e.bottom>f.bottom&&(S=e.bottom-f.bottom+o,t<0&&e.top-S0&&e.right>f.right+y&&(y=e.right-f.right+y+s)):e.right>f.right&&(y=e.right-f.right+s,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class zv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Ln(t):0),i,Math.min(e.focusOffset,i?Ln(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}}let zr=null;function YO(n){if(n.setActive)return n.setActive();if(zr)return n.focus(zr);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(zr==null?{get preventScroll(){return zr={preventScroll:!0},!0}}:void 0),!zr){zr=!1;for(let t=0;tMath.max(1,n.scrollHeight-n.clientHeight-4)}class We{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new We(e.parentNode,To(e),t)}static after(e,t){return new We(e.parentNode,To(e)+1,t)}}const Of=[];class he{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let a=he.get(s);(!a||!a.parent&&a.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=rp(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=rp(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=Ln(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!he.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,a=-1;for(let l=0,h=i,c=i;lt)return u.domBoundsAround(e,t,h);if(f>=e&&r==-1&&(r=l,s=h),h>t&&u.dom.parentNode==this.dom){o=l,a=c;break}c=f,h=f+u.breakAfter}return{from:s,to:a<0?i+this.length:a,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Of){this.markDirty();for(let r=e;rthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function t0(n,e,t,i,r,s,o,a,l){let{children:h}=n,c=h.length?h[e]:null,u=s.length?s[s.length-1]:null,f=u?u.breakAfter:o;if(!(e==i&&c&&!o&&!f&&s.length<2&&c.merge(t,r,s.length?u:null,t==0,a,l))){if(i0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,a,0)?c.breakAfter=s.shift().breakAfter:(t2);var q={mac:ap||/Mac/.test(ht.platform),windows:/Win/.test(ht.platform),linux:/Linux|X11/.test(ht.platform),ie:hh,ie_version:n0?su.documentMode||6:au?+au[1]:ou?+ou[1]:0,gecko:sp,gecko_version:sp?+(/Firefox\/(\d+)/.exec(ht.userAgent)||[0,0])[1]:0,chrome:!!qh,chrome_version:qh?+qh[1]:0,ios:ap,android:/Android\b/.test(ht.userAgent),webkit:op,safari:r0,webkit_version:op?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:su.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Gv=256;class Xn extends he{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof Xn)||this.length-(t-e)+i.length>Gv||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Xn(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new We(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Jv(this.dom,e,t)}}class Un extends he{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(HO(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,r,s,o){return i&&(!(i instanceof Un&&i.mark.eq(this.mark))||e&&s<=0||te&&t.push(i=e&&(r=s),i=l,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new Un(this.mark,t,o)}domAtPos(e){return s0(this,e)}coordsAt(e,t){return a0(this,e,t)}}function Jv(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?q.chrome||q.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return q.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,h=>h.width)||l),o?mf(l,o<0):l||null}class tr extends he{static create(e,t,i){return new tr(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=tr.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof tr)||!this.widget.compare(i.widget)||e>0&&s<=0||t0)?We.before(this.dom):We.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?r.length-1:0;s=r[a],!(e>0?a==0:a==r.length-1||s.top0?We.before(this.dom):We.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ee.empty}get isHidden(){return!0}}Xn.prototype.children=tr.prototype.children=bs.prototype.children=Of;function s0(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;rs&&e0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s0&&e instanceof Un&&r.length&&(i=r[r.length-1])instanceof Un&&i.mark.eq(e.mark)?o0(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function a0(n,e,t){let i=null,r=-1,s=null,o=-1;function a(h,c){for(let u=0,f=0;u=c&&(p.children.length?a(p,c-f):(!s||s.isHidden&&t>0)&&(g>c||f==g&&p.getSide()>0)?(s=p,o=c-f):(f-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function hu(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Hv(n){let e=Object.create(null);for(let t=0;t0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){yf(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){o0(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=lu(t,this.attrs||{})),i&&(this.attrs=lu({class:i},this.attrs||{}))}domAtPos(e){return s0(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(HO(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(hu(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&he.get(r)instanceof Un;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=he.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!q.ios||!this.children.some(s=>s instanceof Xn))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Xn)||/[^ -~]/.test(i.text))return null;let r=xo(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=a0(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight=t){if(s instanceof Ae)return s;if(o>t)break}r=o+s.breakAfter}return null}}class or extends he{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof or)||!this.widget.compare(i.widget)||e>0&&s<=0||t0}}class Or{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Je=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Je||(Je={}));class j extends Br{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new jo(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new pr(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=l0(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new pr(e,i,r,t,e.widget||null,!0)}static line(e){return new zo(e)}static set(e,t=!1){return J.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}j.none=J.empty;class jo extends j{constructor(e){let{start:t,end:i}=l0(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof jo&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&yf(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}jo.prototype.point=!1;class zo extends j{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof zo&&this.spec.class==e.spec.class&&yf(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}zo.prototype.mapMode=Me.TrackBefore;zo.prototype.point=!0;class pr extends j{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Me.TrackBefore:Me.TrackAfter:Me.TrackDel}get type(){return this.startSide!=this.endSide?Je.WidgetRange:this.startSide<=0?Je.WidgetBefore:Je.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof pr&&Kv(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}pr.prototype.point=!0;function l0(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Kv(n,e){return n==e||!!(n&&e&&n.compare(e))}function cu(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}class so{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof or&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ha(new bs(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof or)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ha(new Xn(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof pr){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=t-e;if(i instanceof pr)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new or(i.widget||new hp("div"),a,i));else{let l=tr.create(i.widget||new hp("span"),a,a?0:i.startSide),h=this.atCursorPos&&!l.isEditable&&s<=r.length&&(e0),c=!l.isEditable&&(er.length||i.startSide<=0),u=this.getLine();this.pendingBuffer==2&&!h&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(u.append(ha(new bs(1),r),s),s=r.length+Math.max(0,s-r.length)),u.append(ha(l,r),s),this.atCursorPos=c,this.pendingBuffer=c?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,i,r,s){let o=new so(e,t,i,s);return o.openEnd=J.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function ha(n,e){for(let t of e)n=new Un(t,[n],n.length);return n}class hp extends Or{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var me=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(me||(me={}));const Mr=me.LTR,bf=me.RTL;function h0(n){let e=[];for(let t=0;t=t){if(a.level==i)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function u0(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;O-=3)if(ri[O+1]==-p){let y=ri[O+2],S=y&2?r:y&4?y&1?s:r:0;S&&(oe[u]=oe[ri[O]]=S),a=O;break}}else{if(ri.length==189)break;ri[a++]=u,ri[a++]=f,ri[a++]=l}else if((g=oe[u])==2||g==1){let O=g==r;l=O?0:1;for(let y=a-3;y>=0;y-=3){let S=ri[y+2];if(S&2)break;if(O)ri[y+2]|=2;else{if(S&4)break;ri[y+2]|=4}}}}}function sk(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,a=rl;)g==y&&(g=t[--O].from,y=O?t[O-1].to:n),oe[--g]=p;l=c}else s=h,l++}}}function fu(n,e,t,i,r,s,o){let a=i%2?2:1;if(i%2==r%2)for(let l=e,h=0;ll&&o.push(new ir(l,O.from,p));let y=O.direction==Mr!=!(p%2);du(n,y?i+1:i,r,O.inner,O.from,O.to,o),l=O.to}g=O.to}else{if(g==t||(c?oe[g]!=a:oe[g]==a))break;g++}f?fu(n,l,g,i+1,r,f,o):le;){let c=!0,u=!1;if(!h||l>s[h-1].to){let O=oe[l-1];O!=a&&(c=!1,u=O==16)}let f=!c&&a==1?[]:null,p=c?i:i+1,g=l;e:for(;;)if(h&&g==s[h-1].to){if(u)break e;let O=s[--h];if(!c)for(let y=O.from,S=h;;){if(y==e)break e;if(S&&s[S-1].to==y)y=s[--S].from;else{if(oe[y-1]==a)break e;break}}if(f)f.push(O);else{O.tooe.length;)oe[oe.length]=256;let i=[],r=e==Mr?0:1;return du(n,r,r,t,0,n.length,i),i}function f0(n){return[new ir(0,n,0)]}let d0="";function ak(n,e,t,i,r){var s;let o=i.head-n.from,a=ir.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),l=e[a],h=l.side(r,t);if(o==h){let f=a+=r?1:-1;if(f<0||f>=e.length)return null;l=e[a=f],o=l.side(!r,t),h=l.side(r,t)}let c=je(n.text,o,l.forward(r,t));(cl.to)&&(c=h),d0=n.text.slice(Math.min(o,c),Math.max(o,c));let u=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return u&&c==h&&u.level+(r?0:1)n.some(e=>e)}),w0=B.define({combine:n=>n.some(e=>e)});class as{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new as(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new as(Q.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const ca=_.define({map:(n,e)=>n.map(e)});function gt(n,e,t){let i=n.facet(O0);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const ch=B.define({combine:n=>n.length?n[0]:!0});let hk=0;const zs=B.define();class Te{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){const{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new Te(hk++,e,i,r,a=>{let l=[zs.of(a)];return o&&l.push(Qo.of(h=>{let c=h.plugin(a);return c?o(c):j.none})),s&&l.push(s(a)),l})}static fromClass(e,t){return Te.define(i=>new e(i),t)}}class Mh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(gt(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){gt(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){gt(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const v0=B.define(),Sf=B.define(),Qo=B.define(),k0=B.define(),wf=B.define(),x0=B.define();function cp(n,e){let t=n.state.facet(x0);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return J.spans(i,e.from,e.to,{point(){},span(s,o,a,l){let h=s-e.from,c=o-e.from,u=r;for(let f=a.length-1;f>=0;f--,l--){let p=a[f].spec.bidiIsolate,g;if(p==null&&(p=lk(e.text,h,c)),l>0&&u.length&&(g=u[u.length-1]).to==h&&g.direction==p)g.to=c,u=g.inner;else{let O={from:h,to:c,direction:p,inner:[]};u.push(O),u=O.inner}}}}),r}const T0=B.define();function Q0(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(T0)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}const Fs=B.define();class Nt{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new Nt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toAc)break;s+=2}if(!l)return i;new Nt(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),o=l.toA,a=l.toB}}}class Pl{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Ce.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,a,l)=>r.push(new Nt(s,o,a,l))),this.changedRanges=r}static create(e,t,i){return new Pl(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class up extends he{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Nt(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>cthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!mk(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?uk(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new Nt(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(q.ie||q.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.updateDeco(),l=pk(o,a,e.changes);return i=Nt.extendWithRanges(i,l),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=q.chrome||q.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to=0?r[o]:null;if(!a)break;let{fromA:l,toA:h,fromB:c,toB:u}=a,f,p,g,O;if(i&&i.range.fromBc){let A=so.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),x=so.build(this.view.state.doc,i.range.toB,u,this.decorations,this.dynamicDecorationMap);p=A.breakAtStart,g=A.openStart,O=x.openEnd;let P=this.compositionView(i);x.breakAtStart?P.breakAfter=1:x.content.length&&P.merge(P.length,P.length,x.content[0],!1,x.openStart,0)&&(P.breakAfter=x.content[0].breakAfter,x.content.shift()),A.content.length&&P.merge(0,0,A.content[A.content.length-1],!0,0,A.openEnd)&&A.content.pop(),f=A.content.concat(P).concat(x.content)}else({content:f,breakAtStart:p,openStart:g,openEnd:O}=so.build(this.view.state.doc,c,u,this.decorations,this.dynamicDecorationMap));let{i:y,off:S}=s.findPos(h,1),{i:k,off:$}=s.findPos(l,-1);t0(this,k,$,y,S,f,p,g,O)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Xn(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Un(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(o);let a=he.get(s);a&&a!=o&&(a.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&Za(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(a.anchor)),h=a.empty?l:this.moveToLine(this.domAtPos(a.head));if(q.gecko&&a.empty&&!this.hasComposition&&ck(l)){let u=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(u,l.node.childNodes[l.offset]||null)),l=h=new We(u,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!ro(l.node,l.offset,c.anchorNode,c.anchorOffset)||!ro(h.node,h.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{q.android&&q.chrome&&this.dom.contains(c.focusNode)&&gk(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let u=Ql(this.view.root);if(u)if(a.empty){if(q.gecko){let f=fk(l.node,l.offset);if(f&&f!=3){let p=A0(l.node,l.offset,f==1?1:-1);p&&(l=new We(p.node,p.offset))}}u.collapse(l.node,l.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(l.node,l.offset);try{u.extend(h.node,h.offset)}catch{}}else{let f=document.createRange();a.anchor>a.head&&([l,h]=[h,l]),f.setEnd(h.node,h.offset),f.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(f)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,h)),this.impreciseAnchor=l.precise?null:new We(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new We(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ro(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ql(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.find(this,t.head);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!l||!h||l.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r=0;r--){let s=he.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new We(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=he.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t=0;o--){let a=this.children[o],l=s-a.breakAfter,h=l-a.length;if(le||a.covers(1))&&(!i||a instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=a,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:a,off:l}=r.childPos(i,1);for(;;a++){if(a==r.children.length)return null;if((r=r.children[a]).length)break}i=l}if(!(r instanceof Xn))return null;let s=je(r.text,i);if(s==i)return null;let o=qr(r.dom,i,s).getClientRects();for(let a=0;aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==me.LTR;for(let h=0,c=0;cr)break;if(h>=i){let p=u.dom.getBoundingClientRect();if(t.push(p.height),o){let g=u.dom.lastChild,O=g?xo(g):[];if(O.length){let y=O[O.length-1],S=l?y.right-p.left:p.right-y.left;S>a&&(a=S,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=f)}}}h=f+u.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?me.RTL:me.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=xo(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new e0(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(j.replace({widget:new fp(a),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return j.set(e)}updateDeco(){let e=this.view.state.facet(Qo).map((r,s)=>(this.dynamicDecorationMap[s]=typeof r=="function")?r(this.view):r),t=!1,i=this.view.state.facet(k0).map((r,s)=>{let o=typeof r=="function";return o&&(t=!0),o?r(this.view):r});i.length&&(this.dynamicDecorationMap[e.length]=t,e.push(J.join(i)));for(let r=e.length;rt.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Q0(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;Wv(this.view.scrollDOM,o,t.head0)i=i.childNodes[r-1],r=Ln(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r=0)i=i.childNodes[r],r=0;else break}return null}function fk(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}function Ok(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return Q.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,a=s;t<0?o=je(r.text,s,!1):a=je(r.text,s);let l=i(r.text.slice(o,a));for(;o>0;){let h=je(r.text,o,!1);if(i(r.text.slice(h,o))!=l)break;o=h}for(;an?e.left-n:Math.max(0,n-e.right)}function bk(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function Vh(n,e){return n.tope.top+1}function dp(n,e){return en.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function gu(n,e,t){let i,r,s,o,a=!1,l,h,c,u;for(let g=n.firstChild;g;g=g.nextSibling){let O=xo(g);for(let y=0;y$||o==$&&s>k){i=g,r=S,s=k,o=$;let A=$?t0?y0)}k==0?t>S.bottom&&(!c||c.bottomS.top)&&(h=g,u=S):c&&Vh(c,S)?c=pp(c,S.bottom):u&&Vh(u,S)&&(u=dp(u,S.top))}}if(c&&c.bottom>=t?(i=l,r=c):u&&u.top<=t&&(i=h,r=u),!i)return{node:n,offset:0};let f=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return gp(i,f,t);if(a&&i.contentEditable!="false")return gu(i,f,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function gp(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;at?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&u=(c.left+c.right)/2,p=f;if((q.chrome||q.gecko)&&qr(n,a).getBoundingClientRect().left==c.right&&(p=!f),u<=0)return{node:n,offset:a+(p?1:0)};r=a+(p?1:0),s=u}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function $0(n,e,t,i=-1){var r,s;let o=n.contentDOM.getBoundingClientRect(),a=o.top+n.viewState.paddingTop,l,{docHeight:h}=n.viewState,{x:c,y:u}=e,f=u-a;if(f<0)return 0;if(f>h)return n.state.doc.length;for(let A=n.viewState.heightOracle.textHeight/2,x=!1;l=n.elementAtHeight(f),l.type!=Je.Text;)for(;f=i>0?l.bottom+A:l.top-A,!(f>=0&&f<=h);){if(x)return t?null:0;x=!0,i=-i}u=a+f;let p=l.from;if(pn.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:mp(n,o,l,c,u);let g=n.dom.ownerDocument,O=n.root.elementFromPoint?n.root:g,y=O.elementFromPoint(c,u);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=O.elementFromPoint(c,u),y&&!n.contentDOM.contains(y)&&(y=null));let S,k=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let A=g.caretPositionFromPoint(c,u);A&&({offsetNode:S,offset:k}=A)}else if(g.caretRangeFromPoint){let A=g.caretRangeFromPoint(c,u);A&&({startContainer:S,startOffset:k}=A,(!n.contentDOM.contains(S)||q.safari&&Sk(S,k,c)||q.chrome&&wk(S,k,c))&&(S=void 0))}}if(!S||!n.docView.dom.contains(S)){let A=Ae.find(n.docView,p);if(!A)return f>l.top+l.height/2?l.to:l.from;({node:S,offset:k}=gu(A.dom,c,u))}let $=n.docView.nearest(S);if(!$)return null;if($.isWidget&&((s=$.dom)===null||s===void 0?void 0:s.nodeType)==1){let A=$.dom.getBoundingClientRect();return e.yn.defaultLineHeight*1.5){let a=n.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(n.defaultLineHeight-a)*.5)/a);s+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+tu(o,s,n.state.tabSize)}function Sk(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return qr(n,i-1,i).getBoundingClientRect().left>t}function wk(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():qr(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function mu(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Je.Text))return i}return t}function vk(n,e,t,i){let r=mu(n,e.head),s=!i||r.type!=Je.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),a=n.textDirectionAt(r.from),l=n.posAtCoords({x:t==(a==me.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return Q.cursor(l,t?-1:1)}return Q.cursor(t?r.to:r.from,t?-1:1)}function Op(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let a=e,l=null;;){let h=ak(r,s,o,a,t),c=d0;if(!h){if(r.number==(t?n.state.doc.lines:1))return a;c=` -`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=n.visualLineSide(r,!t)}if(l){if(!l(c))return a}else{if(!i)return h;l=i(c)}a=h}}function kk(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==de.Space&&(r=o),r==o}}function xk(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return Q.cursor(r,e.assoc);let o=e.goalColumn,a,l=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-l.left),a=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-p.from))),a=(s<0?p.top:p.bottom)+c}let u=l.left+o,f=i??n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=a+(f+p)*s,O=$0(n,{x:u,y:g},!1,s);if(gl.bottom||(s<0?Or)){let y=n.docView.coordsForChar(O),S=!y||g{if(e>s&&er(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:Q.cursor(i,inull),q.gecko&&Xk(e.contentDOM.ownerDocument)}handleEvent(e){!Ek(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Qk(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=i[s];a&&o!=!a.handlers.length&&(r.removeEventListener(s,this.handleEvent),a=null),a||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()i.keyCode==e.keyCode))&&!e.ctrlKey||Pk.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,os(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:q.safari&&!q.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function yp(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){gt(t.state,r)}}}function Qk(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(yp(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(yp(i.value,o))}}for(let i in Ht)t(i).handlers.push(Ht[i]);for(let i in Kt)t(i).observers.push(Kt[i]);return e}const C0=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Pk="dthko",I0=[16,17,18,20,91,92,224,225],ua=6;function fa(n){return Math.max(0,n)*.7+8}function Ak(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class $k{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=jv(e.contentDOM),this.atoms=e.state.facet(wf).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(K.allowMultipleSelections)&&Ck(e,t),this.dragging=Rk(e,t)&&N0(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ak(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=Q0(this.view);e.clientX-o.left<=s.left+ua?i=-fa(s.left-e.clientX):e.clientX+o.right>=s.right-ua&&(i=fa(e.clientX-s.right)),e.clientY-o.top<=s.top+ua?r=-fa(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-ua&&(r=fa(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;ithis.select(this.lastEvent),20)}}function Ck(n,e){let t=n.state.facet(p0);return t.length?t[0](e):q.mac?e.metaKey:e.ctrlKey}function Ik(n,e){let t=n.state.facet(g0);return t.length?t[0](e):q.mac?!e.altKey:!e.ctrlKey}function Rk(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Ql(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Ek(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=he.get(t))&&i.ignoreEvent(e))return!1;return!0}const Ht=Object.create(null),Kt=Object.create(null),R0=q.ie&&q.ie_version<15||q.ios&&q.webkit_version<604;function Dk(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),E0(n,t.value)},50)}function E0(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Ou!=null&&t.selection.ranges.every(l=>l.empty)&&Ou==s.toString()){let l=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==l)return{range:h};l=c.from;let u=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:u},range:Q.cursor(h.from+u.length)}})}else o?i=t.changeByRange(l=>{let h=s.line(r++);return{changes:{from:l.from,to:l.to,insert:h.text},range:Q.cursor(l.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Kt.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};Ht.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);Kt.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Kt.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Ht.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(m0))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=qk(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new $k(n,e,t,i)),i&&n.observer.ignore(()=>YO(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function bp(n,e,t,i){if(i==1)return Q.cursor(e,t);if(i==2)return Ok(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return an>=e.top&&n<=e.bottom,Sp=(n,e,t)=>D0(e,t)&&n>=t.left&&n<=t.right;function Nk(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&Sp(t,i,o))return-1;let a=r.coordsAt(s,1);return a&&Sp(t,i,a)?1:o&&D0(i,o)?-1:1}function wp(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Nk(n,t,e.clientX,e.clientY)}}const Bk=q.ie&&q.ie_version<=11;let vp=null,kp=0,xp=0;function N0(n){if(!Bk)return n.detail;let e=vp,t=xp;return vp=n,xp=Date.now(),kp=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(kp+1)%3:1}function qk(n,e){let t=wp(n,e),i=N0(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=wp(n,s),h,c=bp(n,l.pos,l.bias,i);if(t.pos!=l.pos&&!o){let u=bp(n,t.pos,t.bias,i),f=Math.min(u.from,c.from),p=Math.max(u.to,c.to);c=f1&&(h=Mk(r,l.pos))?h:a?r.addRange(c):Q.create([c])}}}function Mk(n,e){for(let t=0;t=e)return Q.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Ht.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=Q.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};Ht.dragend=n=>(n.inputState.draggedContent=null,!1);function Tp(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&Ik(n,e)?{from:s.from,to:s.to}:null,a={from:r,insert:t},l=n.state.changes(o?[o,a]:a);n.focus(),n.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Ht.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&Tp(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(i[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Tp(n,e,i,!0),!0}return!1};Ht.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=R0?null:e.clipboardData;return t?(E0(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(Dk(n),!1)};function Vk(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Lk(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let Ou=null;Ht.copy=Ht.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=Lk(n.state);if(!t&&!r)return!1;Ou=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=R0?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Vk(n,t),!1)};const B0=jn.define();function q0(n,e){let t=[];for(let i of n.facet(b0)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:B0.of(!0)}):null}function M0(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=q0(n.state,e);t?n.dispatch(t):n.update([])}},10)}Kt.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),M0(n)};Kt.blur=n=>{n.observer.clearSelectionRange(),M0(n)};Kt.compositionstart=Kt.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};Kt.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,q.chrome&&q.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};Kt.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Ht.beforeinput=(n,e)=>{var t;let i;if(q.chrome&&q.android&&(i=C0.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};const Qp=new Set;function Xk(n){Qp.has(n)||(Qp.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Pp=["pre-wrap","normal","pre-line","break-spaces"];class Uk{constructor(e){this.lineWrapping=e,this.doc=ee.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Pp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>ja&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return Ye.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:h,fromB:c,toB:u}=r[a],f=s.lineAt(l,le.ByPosNoHeight,i.setDoc(t),0,0),p=f.to>=h?f:s.lineAt(h,le.ByPosNoHeight,i,0,0);for(u+=p.to-h,h=p.to;a>0&&f.from<=r[a-1].toA;)l=r[a-1].fromA,c=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),i+=1+a.break,r-=a.size}else if(s>r*2){let a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class at extends V0{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new fi(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof at||r instanceof Ne&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ne?r=new at(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ye.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ne extends Ye{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),u=a+c.length*l,f=Math.max(i,e-u/2);return new fi(c.from,c.length,f,u,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/a))),{from:c,length:u}=t.doc.line(s+h);return new fi(c,u,i+a*h,a,0)}}lineAt(e,t,i,r,s){if(t==le.ByHeight)return this.blockAt(e,i,r,s);if(t==le.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new fi(p,g-p,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=a+h.length*l,u=h.number-o,f=r+a*u+l*(h.from-s-u);return new fi(h.from,h.length,Math.max(r,Math.min(f,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:l,perChar:h}=this.heightMetrics(i,s);for(let c=e,u=r;c<=t;){let f=i.doc.lineAt(c);if(c==e){let g=f.number-a;u+=l*g+h*(e-s-g)}let p=l+h*f.length;o(new fi(f.from,f.length,u,p,0)),u+=p,c=f.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof Ne?i[i.length-1]=new Ne(s.length+r):i.push(null,new Ne(r-1))}if(e>0){let s=i[0];s instanceof Ne?i[0]=new Ne(e+s.length):i.unshift(new Ne(e-1),null)}return Ye.of(i)}decomposeLeft(e,t){t.push(new Ne(e-1),null)}decomposeRight(e,t){t.push(null,new Ne(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new Ne(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let c=e.doc.lineAt(a).length;o.length&&o.push(null);let u=r.heights[r.index++];l==-1?l=u:Math.abs(u-l)>=ja&&(l=-2);let f=new at(c,u);f.outdated=!1,o.push(f),a+=c+1}a<=s&&o.push(null,new Ne(s-a).updateHeight(e,a));let h=Ye.of(o);return(l<0||Math.abs(h.height-this.height)>=ja||Math.abs(l-this.heightMetrics(e,t).perLine)>=ja)&&(e.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Wk extends Ye{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return ea))return h;let c=t==le.ByPosNoHeight?le.ByPosNoHeight:le.ByPos;return l?h.join(this.right.lineAt(a,c,i,o,a)):this.left.lineAt(a,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,i,a,l,o);else{let h=this.lineAt(l,le.ByPos,i,r,s);e=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,a,l,o)}}replace(e,t,i){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of i)s.push(a);if(e>0&&Ap(s,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Ye.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,i,r):o.updateHeight(e,a,i),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ap(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Ne&&(i=n[e+1])instanceof Ne&&n.splice(e-1,3,new Ne(t.length+1+i.length))}const jk=5;class vf{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof at?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new at(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=jk)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new at(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Ne(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof at)return e;let t=new at(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof at)&&!this.isCovered?this.nodes.push(new at(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&u.overflow!="visible"){let f=c.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),a=Math.max(a,f.top),l=h==n.parentNode?f.bottom:Math.min(l,f.bottom)}h=u.position=="absolute"||u.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function Gk(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Xh{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Uk(t),this.stateDeco=e.facet(Qo).filter(i=>typeof i!="function"),this.heightMap=Ye.empty().applyChanges(this.stateDeco,ee.empty,this.heightOracle.setDoc(e.doc),[new Nt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=j.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new da(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?Cp:new Kk(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:_s(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Qo).filter(c=>typeof c!="function");let r=e.changedRanges,s=Nt.extendWithRanges(r,zk(i,this.stateDeco,e?e.changes:Ce.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let h=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(w0)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?me.RTL:me.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,c=0;if(a.width&&a.height){let{scaleX:A,scaleY:x}=JO(t,a);(this.scaleX!=A||this.scaleY!=x)&&(this.scaleX=A,this.scaleY=x,h|=8,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=KO(e.scrollDOM);let g=(this.printing?Gk:_k)(t,this.paddingTop),O=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let S=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(S!=this.inView&&(this.inView=S,S&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let k=a.width;if((this.contentDOMWidth!=k||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),l){let A=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(A)&&(o=!0),o||r.lineWrapping&&Math.abs(k-this.contentDOMWidth)>r.charWidth){let{lineHeight:x,charWidth:P,textHeight:R}=e.docView.measureTextSize();o=x>0&&r.refresh(s,x,P,R,k/P,A),o&&(e.docView.minWidth=0,h|=8)}O>0&&y>0?c=Math.max(O,y):O<0&&y<0&&(c=Math.min(O,y)),r.heightChanged=!1;for(let x of this.viewports){let P=x.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(x);this.heightMap=(o?Ye.empty().applyChanges(this.stateDeco,ee.empty,this.heightOracle,[new Nt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Zk(x.from,P))}r.heightChanged&&(h|=2)}let $=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return $&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||$)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new da(r.lineAt(o-i*1e3,le.ByHeight,s,0,0).from,r.lineAt(a+(1-i)*1e3,le.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(hl.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(h,le.ByPos,s,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h=a+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=me.LTR&&!i)return[];let a=[],l=(h,c,u,f)=>{if(c-hh&&yy.from>=u.from&&y.to<=u.to&&Math.abs(y.from-h)y.fromS));if(!O){if(cy.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(Q.cursor(c),!1,!0).head;y>h&&(c=y)}O=new Xh(h,c,this.gapSize(u,h,c,f))}a.push(O)};for(let h of this.viewportLines){if(h.lengthh.from&&l(h.from,f,h,c),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];J.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||_s(this.heightMap.lineAt(e,le.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return _s(this.heightMap.lineAt(this.scaler.fromDOM(e),le.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return _s(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class da{constructor(e,t){this.from=e,this.to=t}}function Yk(n,e,t){let i=[],r=n,s=0;return J.spans(t,n,e,{span(){},point(o,a){o>r&&(i.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(i<=a)return s+i;i-=a}}function ga(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Hk(n,e){for(let t of n)if(e(t))return t}const Cp={toDOM(n){return n},fromDOM(n){return n},scale:1};class Kk{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:a,to:l})=>{let h=t.lineAt(a,le.ByPos,e,0,0).top,c=t.lineAt(l,le.ByPos,e,0,0).bottom;return r+=c-h,{from:a,to:l,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t_s(r,e)):n._content)}const ma=B.define({combine:n=>n.join(" ")}),yu=B.define({combine:n=>n.indexOf(!0)>-1}),bu=ys.newName(),L0=ys.newName(),X0=ys.newName(),U0={"&light":"."+L0,"&dark":"."+X0};function Su(n,e,t){return new ys(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}const ex=Su("."+bu,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},U0),Gs="￿";class tx{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(K.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Gs}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let a=he.get(r),l=he.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:Ip(r))||Ip(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=he.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(ix(e,i.node,i.offset)?t:0))}}function ix(n,e,t){for(;;){if(!e||t-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let a=s||o?[]:ox(e),l=new tx(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=ax(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!ru(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),h=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!ru(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),c=e.viewport;if(q.ios&&e.state.selection.main.empty&&l!=h&&(c.from>0||c.toDate.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=r.from,h=null;(s===8||q.android&&e.text.length=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(q.mac||q.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=Q.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:ee.of([" "])}):q.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=Q.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:ee.of([" "])}),t){if(q.ios&&n.inputState.flushIOSKey()||q.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&os(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.lengthr.head)&&os(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&os(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,l=()=>a||(a=rx(n,t,i));return n.state.facet(y0).some(h=>h(n,t.from,t.to,o,l))||n.dispatch(l()),!0}else if(i&&!i.main.eq(r)){let o=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),a=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:a}),!0}else return!1}function rx(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+l))}else{let a=r.changes(e),l=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,u=t&&P0(n,t.main.head);if(u){let g=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-g}}else c=n.state.doc.lineAt(s.head);let f=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:a,range:l||g.map(a)};let O=g.to-f,y=O-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,O)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let S=r.changes({from:y,to:O,insert:e.insert}),k=g.to-s.to;return{changes:S,range:l?Q.range(Math.max(0,l.anchor+k),Math.max(0,l.head+k)):g.map(S)}})}else i={changes:a,selection:l&&r.selection.replaceRange(l)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function sx(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s0&&a>0&&n.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(i=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function ox(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Rp(t,i)),(r!=t||s!=i)&&e.push(new Rp(r,s))),e}function ax(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?Q.single(t+e,i+e):null}const lx={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Uh=q.ie&&q.ie_version<=11;class hx{constructor(e){this.view=e,this.active=!1,this.selectionRange=new zv,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(q.ie&&q.ie_version<=11||q.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Uh&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(ch)?i.root.activeElement!=this.dom:!Za(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(q.ie&&q.ie_version<=11||q.android&&q.chrome)&&!i.state.selection.main.empty&&r.focusNode&&ro(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=q.safari&&e.root.nodeType==11&&Uv(this.dom.ownerDocument)==this.dom&&cx(this.view)||Ql(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=Za(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&os(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Za(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new nx(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=Z0(this.view,t);return this.view.state==i&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=Ep(t,e.previousSibling||e.target.previousSibling,-1),r=Ep(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Ep(n,e,t){for(;e;){let i=he.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function cx(n){let e=null;function t(l){l.preventDefault(),l.stopImmediatePropagation(),e=l.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor);return ro(a.node,a.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}class N{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Fv(e.parent)||document,this.viewState=new $p(e.state||K.create(e)),e.scrollTo&&e.scrollTo.is(ca)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(zs).map(i=>new Mh(i));for(let i of this.plugins)i.update(this);this.observer=new hx(this),this.inputState=new Tk(this),this.inputState.ensureHandlers(this.plugins),this.docView=new up(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof Se?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(f=>f.annotation(B0))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=q0(s,o),l||(a=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(K.phrases)!=this.state.facet(K.phrases))return this.setState(s);r=Pl.create(this,s,e),r.flags|=a;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;u=new as(p.empty?p:Q.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(ca)&&(u=p.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Al.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Fs)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(ma)!=r.state.facet(ma)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let f of this.state.facet(pu))try{f(r)}catch(p){gt(this.state,p,"update listener")}(l||c)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Z0(this,c)&&h.force&&os(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new $p(e),this.plugins=e.facet(zs).map(i=>new Mh(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new up(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(zs),i=e.state.facet(zs);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new Mh(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(KO(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];l&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(p=>{try{return p.read(this)}catch(g){return gt(this.state,g),Dp}}),u=Pl.create(this,this.state,[]),f=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u));for(let p=0;p1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(pu))a(t)}get themeClasses(){return bu+" "+(this.state.facet(yu)?X0:L0)+" "+this.state.facet(ma)}updateAttrs(){let e=Np(this,v0,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ch)?"true":"false",class:"cm-content",style:`${q.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Np(this,Sf,t);let i=this.observer.ignore(()=>{let r=hu(this.contentDOM,this.contentAttrs,t),s=hu(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(N.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Fs);let e=this.state.facet(N.cspNonce);ys.mount(this.root,this.styleModules.concat(ex).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Lh(this,e,Op(this,e,t,i))}moveByGroup(e,t){return Lh(this,e,Op(this,e,t,i=>kk(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return Q.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return vk(this,e,t,i)}moveVertically(e,t,i){return Lh(this,e,xk(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),$0(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ir.find(s,e-r.from,-1,t)];return mf(i,o.dir==me.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(S0)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ux)return f0(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||u0(s.isolates,i=cp(this,e))))return s.order;i||(i=cp(this,e));let r=ok(e.text,t,i);return this.bidiCache.push(new Al(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||q.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{YO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return ca.of(new as(typeof e=="number"?Q.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return ca.of(new as(Q.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return Te.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Te.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ys.newName(),r=[ma.of(i),Fs.of(Su(`.${i}`,e))];return t&&t.dark&&r.push(yu.of(!0)),r}static baseTheme(e){return mr.lowest(Fs.of(Su("."+bu,e,U0)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&he.get(i)||he.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}}N.styleModule=Fs;N.inputHandler=y0;N.focusChangeEffect=b0;N.perLineTextDirection=S0;N.exceptionSink=O0;N.updateListener=pu;N.editable=ch;N.mouseSelectionStyle=m0;N.dragMovesSelection=g0;N.clickAddsSelectionRange=p0;N.decorations=Qo;N.outerDecorations=k0;N.atomicRanges=wf;N.bidiIsolatedRanges=x0;N.scrollMargins=T0;N.darkTheme=yu;N.cspNonce=B.define({combine:n=>n.length?n[0]:""});N.contentAttributes=Sf;N.editorAttributes=v0;N.lineWrapping=N.contentAttributes.of({class:"cm-lineWrapping"});N.announce=_.define();const ux=4096,Dp={};class Al{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:me.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&lu(o,t)}return t}const fx=q.mac?"mac":q.windows?"win":q.linux?"linux":"key";function dx(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,a;for(let l=0;li.concat(r),[]))),t}function gx(n,e,t){return j0(W0(n.state),e,n,t)}let Hn=null;const mx=4e3;function Ox(n,e=fx){let t=Object.create(null),i=Object.create(null),r=(o,a)=>{let l=i[o];if(l==null)i[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,h,c)=>{var u,f;let p=t[o]||(t[o]=Object.create(null)),g=a.split(/ (?!$)/).map(S=>dx(S,e));for(let S=1;S{let A=Hn={view:$,prefix:k,scope:o};return setTimeout(()=>{Hn==A&&(Hn=null)},mx),!0}]})}let O=g.join(" ");r(O,!1);let y=p[O]||(p[O]={preventDefault:!1,stopPropagation:!1,run:((f=(u=p._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});l&&y.run.push(l),h&&(y.preventDefault=!0),c&&(y.stopPropagation=!0)};for(let o of n){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of a){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let u in c)c[u].run.push(o.any)}let l=o[e]||o.key;if(l)for(let h of a)s(h,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}function j0(n,e,t,i){let r=Xv(e),s=Be(r,0),o=lt(s)==r.length&&r!=" ",a="",l=!1,h=!1,c=!1;Hn&&Hn.view==t&&Hn.scope==i&&(a=Hn.prefix+" ",I0.indexOf(e.keyCode)<0&&(h=!0,Hn=null));let u=new Set,f=y=>{if(y){for(let S of y.run)if(!u.has(S)&&(u.add(S),S(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,O;return p&&(f(p[a+Oa(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(q.windows&&e.ctrlKey&&e.altKey)&&(g=dr[e.keyCode])&&g!=r?(f(p[a+Oa(g,e,!0)])||e.shiftKey&&(O=ko[e.keyCode])!=r&&O!=g&&f(p[a+Oa(O,e,!1)]))&&(l=!0):o&&e.shiftKey&&f(p[a+Oa(r,e,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),h&&(l=!0),l&&c&&e.stopPropagation(),l}class Fo{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=z0(e);return[new Fo(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return yx(e,t,i)}}function z0(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==me.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function qp(n,e,t){let i=Q.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Je.Text}}function yx(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==me.LTR,o=n.contentDOM,a=o.getBoundingClientRect(),l=z0(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),u=a.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=a.right-(c?parseInt(c.paddingRight):0),p=mu(n,i),g=mu(n,r),O=p.type==Je.Text?p:null,y=g.type==Je.Text?g:null;if(O&&(n.lineWrapping||p.widgetLineBreaks)&&(O=qp(n,i,O)),y&&(n.lineWrapping||g.widgetLineBreaks)&&(y=qp(n,r,y)),O&&y&&O.from==y.from)return k($(t.from,t.to,O));{let x=O?$(t.from,null,O):A(p,!1),P=y?$(null,t.to,y):A(g,!0),R=[];return(O||p).to<(y||g).from-(O&&y?1:0)||p.widgetLineBreaks>1&&x.bottom+n.defaultLineHeight/2Oe&&He.from=Xe)break;Pe>De&&H(Math.max(we,De),x==null&&we<=Oe,Math.min(Pe,Xe),P==null&&Pe>=Le,Ke.dir)}if(De=ni.to+1,De>=Xe)break}return z.length==0&&H(Oe,x==null,Le,P==null,n.textDirection),{top:X,bottom:W,horizontal:z}}function A(x,P){let R=a.top+(P?x.top:x.bottom);return{top:R,bottom:R,horizontal:[]}}}function bx(n,e){return n.constructor==e.constructor&&n.eq(e)}class Sx{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(za)!=e.state.facet(za)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}setOrder(e){let t=0,i=e.facet(za);for(;t!bx(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const za=B.define();function F0(n){return[Te.define(e=>new Sx(e,n)),za.of(n)]}const _0=!q.ios,Po=B.define({combine(n){return Ai(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function wx(n={}){return[Po.of(n),vx,kx,xx,w0.of(!0)]}function G0(n){return n.startState.facet(Po)!=n.state.facet(Po)}const vx=F0({above:!0,markers(n){let{state:e}=n,t=e.facet(Po),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||_0:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=r.empty?r:Q.cursor(r.head,r.head>r.anchor?-1:1);for(let l of Fo.forRange(n,o,a))i.push(l)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=G0(n);return t&&Mp(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Mp(e.state,n)},class:"cm-cursorLayer"});function Mp(n,e){e.style.animationDuration=n.facet(Po).cursorBlinkRate+"ms"}const kx=F0({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:Fo.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||G0(n)},class:"cm-selectionLayer"}),wu={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};_0&&(wu[".cm-line"].caretColor="transparent !important",wu[".cm-content"]={caretColor:"transparent !important"});const xx=mr.highest(N.theme(wu)),J0=_.define({map(n,e){return n==null?null:e.mapPos(n)}}),Js=Ee.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(J0)?i.value:t,n)}}),Tx=Te.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Js);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Js)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Js),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Js)!=n&&this.view.dispatch({effects:J0.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Qx(){return[Js,Tx]}function Vp(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)r(o+a.index,a)}function Px(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class Ax{constructor(e){const{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(a,l,h,c)=>r(c,h,h+a[0].length,a,l);else if(typeof i=="function")this.addMatch=(a,l,h,c)=>{let u=i(a,l,h);u&&c(h,h+a[0].length,u)};else if(i)this.addMatch=(a,l,h,c)=>c(h,h+a[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new fr,i=t.add.bind(t);for(let{from:r,to:s}of Px(e,this.maxLength))Vp(e.state.doc,this.regexp,r,s,(o,a)=>this.addMatch(a,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,l)=>{l>e.view.viewport.from&&a1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),a=Math.min(s.to,r);if(a>o){let l=e.state.doc.lineAt(o),h=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){c=o;break}for(;af.push(S.range(O,y));if(l==h)for(this.regexp.lastIndex=c-l.from;(p=this.regexp.exec(l.text))&&p.indexthis.addMatch(y,e,O,g));t=t.update({filterFrom:c,filterTo:u,filter:(O,y)=>Ou,add:f})}}return t}}const vu=/x/.unicode!=null?"gu":"g",$x=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,vu),Cx={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Zh=null;function Ix(){var n;if(Zh==null&&typeof document<"u"&&document.body){let e=document.body.style;Zh=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Zh||!1}const Fa=B.define({combine(n){let e=Ai(n,{render:null,specialChars:$x,addSpecialChars:null});return(e.replaceTabs=!Ix())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,vu)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,vu)),e}});function Rx(n={}){return[Fa.of(n),Ex()]}let Lp=null;function Ex(){return Lp||(Lp=Te.fromClass(class{constructor(n){this.view=n,this.decorations=j.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Fa)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Ax({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=Be(e[0],0);if(s==9){let o=r.lineAt(i),a=t.state.tabSize,l=Wo(o.text,a,i-o.from);return j.replace({widget:new qx((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=j.replace({widget:new Bx(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Fa);n.startState.facet(Fa)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const Dx="•";function Nx(n){return n>=32?Dx:n==10?"␤":String.fromCharCode(9216+n)}class Bx extends Or{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Nx(this.code),i=e.state.phrase("Control character")+" "+(Cx[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class qx extends Or{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function Mx(){return Lx}const Vx=j.line({class:"cm-activeLine"}),Lx=Te.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(Vx.range(r.from)),e=r.from)}return j.set(t)}},{decorations:n=>n.decorations}),ku=2e3;function Xx(n,e,t){let i=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>ku||t.off>ku||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=i;l<=r;l++){let h=n.doc.line(l);h.length<=a&&s.push(Q.range(h.from+o,h.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=i;l<=r;l++){let h=n.doc.line(l),c=tu(h.text,o,n.tabSize,!0);if(c<0)s.push(Q.cursor(h.to));else{let u=tu(h.text,a,n.tabSize);s.push(Q.range(h.from+c,h.from+u))}}}return s}function Ux(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Xp(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),r=t-i.from,s=r>ku?-1:r==i.length?Ux(n,e.clientX):Wo(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:s,off:r}}function Zx(n,e){let t=Xp(n,e),i=n.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(r.changes)}},get(r,s,o){let a=Xp(n,r);if(!a)return i;let l=Xx(n.state,t,a);return l.length?o?Q.create(l.concat(i.ranges)):Q.create(l):i}}:null}function Wx(n){let e=t=>t.altKey&&t.button==0;return N.mouseSelectionStyle.of((t,i)=>e(i)?Zx(t,i):null)}const jx={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},zx={style:"cursor: crosshair"};function Fx(n={}){let[e,t]=jx[n.key||"Alt"],i=Te.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[i,N.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?zx:null})]}const qs="-10000px";class Y0{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[h]=l),t.length=a.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function _x(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Wh=B.define({combine:n=>{var e,t,i;return{position:q.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||_x}}}),Up=new WeakMap,kf=Te.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Wh);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Y0(n,xf,t=>this.createTooltip(t),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Wh);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=qs,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(q.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==qs&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Wh).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{editor:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let a=0;a=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1){c.style.top=qs;continue}let p=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,O=f.right-f.left,y=(e=Up.get(h))!==null&&e!==void 0?e:f.bottom-f.top,S=h.offset||Jx,k=this.view.textDirection==me.LTR,$=f.width>i.right-i.left?k?i.left:i.right-f.width:k?Math.min(u.left-(p?14:0)+S.x,i.right-O):Math.max(i.left,u.left-O+(p?14:0)-S.x),A=this.above[a];!l.strictSide&&(A?u.top-(f.bottom-f.top)-S.yi.bottom)&&A==i.bottom-u.bottom>u.top-i.top&&(A=this.above[a]=!A);let x=(A?u.top-i.top:i.bottom-u.bottom)-g;if(x$&&X.topP&&(P=A?X.top-y-2-g:X.bottom+g+2);if(this.position=="absolute"?(c.style.top=(P-n.parent.top)/s+"px",c.style.left=($-n.parent.left)/r+"px"):(c.style.top=P/s+"px",c.style.left=$/r+"px"),p){let X=u.left+(k?S.x:-S.x)-($+14-7);p.style.left=X/r+"px"}h.overlap!==!0&&o.push({left:$,top:P,right:R,bottom:P+y}),c.classList.toggle("cm-tooltip-above",A),c.classList.toggle("cm-tooltip-below",!A),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=qs}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Gx=N.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Jx={x:0,y:0},xf=B.define({enables:[kf,Gx]}),$l=B.define();class uh{static create(e){return new uh(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Y0(e,$l,t=>this.createHostedView(t),t=>t.dom.remove())}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Yx=xf.compute([$l],n=>{let e=n.facet($l).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:uh.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Hx{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=l&&l.dir==me.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&e.dispatch({effects:this.setHover.of(l)}))},l=>gt(e.state,l,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(kf),t=e?e.manager.tooltips.findIndex(i=>i.create==uh.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i&&r&&!Kx(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!eT(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ya=4;function Kx(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-ya&&e.clientX<=t.right+ya&&e.clientY>=t.top-ya&&e.clientY<=t.bottom+ya}function eT(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rightr||Math.min(o.bottom,a)=e&&l<=t}function tT(n,e={}){let t=_.define(),i=Ee.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Me.TrackDel);if(o==null)return null;let a=Object.assign(Object.create(null),r);a.pos=o,r.end!=null&&(a.end=s.changes.mapPos(r.end)),r=a}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(nT)&&(r=null);return r},provide:r=>$l.from(r)});return[i,Te.define(r=>new Hx(r,n,i,t,e.hoverTime||300)),Yx]}function iT(n,e){let t=n.plugin(kf);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const nT=_.define(),Zp=B.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ao(n,e){let t=n.plugin(H0),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const H0=Te.fromClass(class{constructor(n){this.input=n.state.facet($o),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Zp);this.top=new ba(n,!0,e.topContainer),this.bottom=new ba(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Zp);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ba(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ba(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet($o);if(t!=this.input){let i=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of i){let h=this.specs.indexOf(l),c;h<0?(c=l(n.view),a.push(c)):(c=this.panels[h],c.update&&c.update(n)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>N.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class ba{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Wp(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Wp(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Wp(n){let e=n.nextSibling;return n.remove(),e}const $o=B.define({enables:H0});class Zn extends Br{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Zn.prototype.elementClass="";Zn.prototype.toDOM=void 0;Zn.prototype.mapMode=Me.TrackBefore;Zn.prototype.startSide=Zn.prototype.endSide=-1;Zn.prototype.point=!0;const _a=B.define(),rT={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>J.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},oo=B.define();function sT(n){return[K0(),oo.of(Object.assign(Object.assign({},rT),n))]}const jp=B.define({combine:n=>n.some(e=>e)});function K0(n){return[oT]}const oT=Te.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(oo).map(e=>new Fp(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(jp),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(jp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=J.iter(this.view.state.facet(_a),this.view.viewport.from),i=[],r=this.gutters.map(s=>new aT(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Je.Text&&o){xu(t,i,a.from);for(let l of r)l.line(this.view,a,i);o=!1}else if(a.widget)for(let l of r)l.widget(this.view,a)}else if(s.type==Je.Text){xu(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(oo),t=n.state.facet(oo),i=n.docChanged||n.heightChanged||n.viewportChanged||!J.eq(n.startState.facet(_a),n.state.facet(_a),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Fp(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>N.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==me.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function zp(n){return Array.isArray(n)?n:[n]}function xu(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class aT{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=J.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let a=new ey(e,o,s,i);r.elements.push(a),r.dom.appendChild(a.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];xu(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Fp{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=r.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,a,r)&&r.preventDefault()});this.markers=zp(t.markers(e)),t.initialSpacer&&(this.spacer=new ey(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=zp(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!J.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class ey{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),lT(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=ss(a,l,h)||o(a,l,h):o}return i}})}});class jh extends Zn{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function zh(n,e){return n.state.facet(Hr).formatNumber(e,n.state)}const cT=oo.compute([Hr],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(hT)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new jh(zh(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Hr)!=e.state.facet(Hr),initialSpacer(e){return new jh(zh(e,_p(e.state.doc.lines)))},updateSpacer(e,t){let i=zh(t.view,_p(t.view.state.doc.lines));return i==e.number?e:new jh(i)},domEventHandlers:n.facet(Hr).domEventHandlers}));function uT(n={}){return[Hr.of(n),K0(),cT]}function _p(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.head).from;r>t&&(t=r,e.push(fT.range(r)))}return J.of(e)});function pT(){return dT}const ty=1024;let gT=0;class It{constructor(e,t){this.from=e,this.to=t}}class G{constructor(e={}){this.id=gT++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ie.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}G.closedBy=new G({deserialize:n=>n.split(" ")});G.openedBy=new G({deserialize:n=>n.split(" ")});G.group=new G({deserialize:n=>n.split(" ")});G.contextHash=new G({perNode:!0});G.lookAhead=new G({perNode:!0});G.mounted=new G({perNode:!0});class mT{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}}const OT=Object.create(null);class Ie{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):OT,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Ie(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(G.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}}Ie.none=new Ie("",Object.create(null),0,8);class _o{constructor(e){this.types=e;for(let t=0;t=r&&(o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;a=!0}for(;a&&i&&!o.type.isAnonymous&&i(o),!o.nextSibling();){if(!o.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Pf(Ie.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new re(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new re(Ie.none,t,i,r)))}static build(e){return bT(e)}}re.empty=new re(Ie.none,[],[],0);class Tf{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Tf(this.buffer,this.index)}}class Xr{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ie.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ny(n,e){let t=n.childBefore(e);for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}function Ss(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?a.length:-1;e!=h;e+=t){let c=a[e],u=l[e]+o.from;if(iy(r,i,u,u+c.length)){if(c instanceof Xr){if(s&ce.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,t,i-u,r);if(f>-1)return new vi(new yT(o,c,e,u),null,f)}else if(s&ce.IncludeAnonymous||!c.type.isAnonymous||Qf(c)){let f;if(!(s&ce.IgnoreMounts)&&c.props&&(f=c.prop(G.mounted))&&!f.overlay)return new Bt(f.tree,u,e,o);let p=new Bt(c,u,e,o);return s&ce.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ce.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let r;if(!(i&ce.IgnoreOverlays)&&(r=this._tree.prop(G.mounted))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new Bt(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Co(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Ss(this,e,t,!1)}resolveInner(e,t=0){return Ss(this,e,t,!0)}enterUnfinishedNodesBefore(e){return ny(this,e)}getChild(e,t=null,i=null){let r=Cl(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Cl(this,e,t,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Il(this,e)}}function Cl(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Il(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class yT{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}}class vi{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new vi(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ce.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new vi(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new vi(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new vi(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Co(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new re(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Ss(this,e,t,!1)}resolveInner(e,t=0){return Ss(this,e,t,!0)}enterUnfinishedNodesBefore(e){return ny(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let r=Cl(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Cl(this,e,t,i)}get node(){return this}matchContext(e){return Il(this,e)}}class Co{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Bt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof Bt?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ce.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ce.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ce.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let a=i._tree.children[s];if(this.mode&ce.IncludeAnonymous||a instanceof Xr||!a.type.isAnonymous||Qf(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return Il(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Qf(n){return n.children.some(e=>e instanceof Xr||!e.type.isAnonymous||Qf(e))}function bT(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=ty,reused:s=[],minRepeatType:o=i.types.length}=n,a=Array.isArray(t)?new Tf(t,t.length):t,l=i.types,h=0,c=0;function u(A,x,P,R,X){let{id:W,start:z,end:H,size:Oe}=a,Le=c;for(;Oe<0;)if(a.next(),Oe==-1){let Ke=s[W];P.push(Ke),R.push(z-A);return}else if(Oe==-3){h=W;return}else if(Oe==-4){c=W;return}else throw new RangeError(`Unrecognized record size: ${Oe}`);let He=l[W],De,Xe,ni=z-A;if(H-z<=r&&(Xe=O(a.pos-x,X))){let Ke=new Uint16Array(Xe.size-Xe.skip),we=a.pos-Xe.size,Pe=Ke.length;for(;a.pos>we;)Pe=y(Xe.start,Ke,Pe);De=new Xr(Ke,H-Xe.start,i),ni=Xe.start-A}else{let Ke=a.pos-Oe;a.next();let we=[],Pe=[],br=W>=o?W:-1,Ur=0,ea=H;for(;a.pos>Ke;)br>=0&&a.id==br&&a.size>=0?(a.end<=ea-r&&(p(we,Pe,z,Ur,a.end,ea,br,Le),Ur=we.length,ea=a.end),a.next()):u(z,Ke,we,Pe,br);if(br>=0&&Ur>0&&Ur-1&&Ur>0){let ed=f(He);De=Pf(He,we,Pe,0,we.length,0,H-z,ed,ed)}else De=g(He,we,Pe,H-z,Le-H)}P.push(De),R.push(ni)}function f(A){return(x,P,R)=>{let X=0,W=x.length-1,z,H;if(W>=0&&(z=x[W])instanceof re){if(!W&&z.type==A&&z.length==R)return z;(H=z.prop(G.lookAhead))&&(X=P[W]+z.length+H)}return g(A,x,P,R,X)}}function p(A,x,P,R,X,W,z,H){let Oe=[],Le=[];for(;A.length>R;)Oe.push(A.pop()),Le.push(x.pop()+P-X);A.push(g(i.types[z],Oe,Le,W-X,H-W)),x.push(X-P)}function g(A,x,P,R,X=0,W){if(h){let z=[G.contextHash,h];W=W?[z].concat(W):[z]}if(X>25){let z=[G.lookAhead,X];W=W?[z].concat(W):[z]}return new re(A,x,P,R,W)}function O(A,x){let P=a.fork(),R=0,X=0,W=0,z=P.end-r,H={size:0,start:0,skip:0};e:for(let Oe=P.pos-A;P.pos>Oe;){let Le=P.size;if(P.id==x&&Le>=0){H.size=R,H.start=X,H.skip=W,W+=4,R+=4,P.next();continue}let He=P.pos-Le;if(Le<0||He=o?4:0,Xe=P.start;for(P.next();P.pos>He;){if(P.size<0)if(P.size==-3)De+=4;else break e;else P.id>=o&&(De+=4);P.next()}X=Xe,R+=Le,W+=De}return(x<0||R==A)&&(H.size=R,H.start=X,H.skip=W),H.size>4?H:void 0}function y(A,x,P){let{id:R,start:X,end:W,size:z}=a;if(a.next(),z>=0&&R4){let Oe=a.pos-(z-4);for(;a.pos>Oe;)P=y(A,x,P)}x[--P]=H,x[--P]=W-A,x[--P]=X-A,x[--P]=R}else z==-3?h=R:z==-4&&(c=R);return P}let S=[],k=[];for(;a.pos>0;)u(n.start||0,n.bufferStart||0,S,k,-1);let $=(e=n.length)!==null&&e!==void 0?e:S.length?k[0]+S[0].length:0;return new re(l[n.topID],S.reverse(),k.reverse(),$)}const Jp=new WeakMap;function Ga(n,e){if(!n.isAnonymous||e instanceof Xr||e.type!=n)return 1;let t=Jp.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof re)){t=1;break}t+=Ga(n,i)}Jp.set(e,t)}return t}function Pf(n,e,t,i,r,s,o,a,l){let h=0;for(let g=i;g=c)break;P+=R}if($==A+1){if(P>c){let R=g[A];p(R.children,R.positions,0,R.children.length,O[A]+k);continue}u.push(g[A])}else{let R=O[$-1]+g[$-1].length-x;u.push(Pf(n,g,O,A,$,x,R,null,l))}f.push(x+k-s)}}return p(e,t,i,r,0),(a||l)(u,f,o)}class ST{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof vi?this.setBuffer(e.context.buffer,e.index,t):e instanceof Bt&&this.map.set(e.tree,t)}get(e){return e instanceof vi?this.getBuffer(e.context.buffer,e.index):e instanceof Bt?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Bn{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new Bn(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,h=0;;a++){let c=a=i)for(;o&&o.from=f.from||u<=f.to||h){let p=Math.max(f.from,l)-h,g=Math.min(f.to,u)-h;f=p>=g?null:new Bn(p,g,f.tree,f.offset+h,a>0,!!c)}if(f&&r.push(f),o.to>u)break;o=snew It(r.from,r.to)):[new It(0,0)]:[new It(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}}class wT{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function ry(n){return(e,t,i,r)=>new kT(e,n,t,i,r)}class Yp{constructor(e,t,i,r,s){this.parser=e,this.parse=t,this.overlay=i,this.target=r,this.ranges=s}}class vT{constructor(e,t,i,r,s,o,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=r,this.start=s,this.target=o,this.prev=a,this.depth=0,this.ranges=[]}}const Tu=new G({perNode:!0});class kT{constructor(e,t,i,r,s){this.nest=t,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new re(i.type,i.children,i.positions,i.length,i.propValues.concat([[Tu,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[G.mounted.id]=new mT(t,e.overlay,e.parser),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;tc.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let u=c.from+h.pos,f=c.to+h.pos;u>=r.from&&f<=r.to&&!t.ranges.some(p=>p.fromu)&&t.ranges.push({from:u,to:f})}}a=!1}else if(i&&(o=xT(i.ranges,r.from,r.to)))a=o!=2;else if(!r.type.isAnonymous&&r.fromnew It(u.from-r.from,u.to-r.from)):null,r.tree,c)),s.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):a=!1}}else t&&(l=t.predicate(r))&&(l===!0&&(l=new It(r.from,r.to)),l.fromnew It(c.from-t.start,c.to-t.start)),t.target,h)),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function xT(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Hp(n,e,t,i,r,s){if(e=e.to);i++);let o=r.children[i],a=o.buffer;function l(h,c,u,f,p){let g=h;for(;a[g+2]+s<=e.from;)g=a[g+3];let O=[],y=[];Hp(o,h,g,O,y,f);let S=a[g+1],k=a[g+2],$=S+s==e.from&&k+s==e.to&&a[g]==e.type.id;return O.push($?e.toTree():l(g+4,a[g+3],o.set.types[a[g]],S,k-S)),y.push(S-f),Hp(o,a[g+3],c,O,y,f),new re(u,O,y,p)}r.children[i]=l(0,a.length,Ie.none,0,o.length);for(let h=0;h<=t;h++)n.childAfter(e.from)}class Kp{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(ce.IncludeAnonymous|ce.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from=e&&t.enter(i,1,ce.IgnoreOverlays|ce.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof re)t=t.children[0];else break}return!1}}let QT=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(Tu))!==null&&t!==void 0?t:i.to,this.inner=new Kp(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Tu))!==null&&e!==void 0?e:t.to,this.inner=new Kp(t.tree,-t.offset)}}findMounts(e,t){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(G.mounted);if(o&&o.parser==t)for(let a=this.fragI;a=s.to)break;l.tree==this.curFrag.tree&&r.push({frag:l,pos:s.from-l.offset,mount:o})}}}return r}};function eg(n,e){let t=null,i=e;for(let r=1,s=0;r=a)break;l.to<=o||(t||(i=t=e.slice()),l.froma&&t.splice(s+1,0,new It(a,l.to))):l.to>a?t[s--]=new It(a,l.to):t.splice(s--,1))}}return i}function PT(n,e,t,i){let r=0,s=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let c=r==n.length?1e9:o?n[r].to:n[r].from,u=s==e.length?1e9:a?e[s].to:e[s].from;if(o!=a){let f=Math.max(l,t),p=Math.min(c,u,i);fnew It(f.from+i,f.to+i)),u=PT(e,c,l,h);for(let f=0,p=l;;f++){let g=f==u.length,O=g?h:u[f].from;if(O>p&&t.push(new Bn(p,O,r.tree,-o,s.from>=p||s.openStart,s.to<=O||s.openEnd)),g)break;p=u[f].to}}else t.push(new Bn(l,h,r.tree,-o,s.from>=o||s.openStart,s.to<=a||s.openEnd))}return t}let AT=0;class jt{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=AT++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new jt([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Rl;return t=>t.modified.indexOf(e)>-1?t:Rl.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}}let $T=0;class Rl{constructor(){this.instances=[],this.id=$T++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&CT(t,a.modified));if(i)return i;let r=[],s=new jt(r,e,t);for(let a of t)a.instances.push(s);let o=IT(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(Rl.get(a,l));return s}}function CT(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function IT(n){let e=[[]];for(let t=0;ti.length-t.length)}function Cs(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let u=0;;){if(a=="..."&&u>0&&u+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let p=r[u++];if(u==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);a=r.slice(u)}let l=s.length-1,h=s[l];if(!h)throw new RangeError("Invalid path: "+r);let c=new El(i,o,l>0?s.slice(0,l):null);e[h]=c.sort(e[h])}}return sy.add(e)}const sy=new G;class El{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let a of s)for(let l of a.set){let h=t[l.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function RT(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function ET(n,e,t,i=0,r=n.length){let s=new DT(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}class DT{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:a,to:l}=e;if(a>=i||l<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=NT(e)||El.empty,u=RT(s,c.tags);if(u&&(h&&(h+=" "),h+=u,c.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(e.from,h),c.opaque)return;let f=e.tree&&e.tree.prop(G.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+a,1),g=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),O=e.firstChild();for(let y=0,S=a;;y++){let k=y=$||!e.nextSibling())););if(!k||$>i)break;S=k.to+a,S>t&&(this.highlightRange(p.cursor(),Math.max(t,k.from+a),Math.min(i,S),r,g),this.startSpan(S,h))}O&&e.parent()}else if(e.firstChild()){do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function NT(n){let e=n.type.prop(sy);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const E=jt.define,wa=E(),Jn=E(),ig=E(Jn),ng=E(Jn),Yn=E(),va=E(Yn),Fh=E(Yn),ai=E(),Sr=E(ai),si=E(),oi=E(),Qu=E(),Ms=E(Qu),ka=E(),b={comment:wa,lineComment:E(wa),blockComment:E(wa),docComment:E(wa),name:Jn,variableName:E(Jn),typeName:ig,tagName:E(ig),propertyName:ng,attributeName:E(ng),className:E(Jn),labelName:E(Jn),namespace:E(Jn),macroName:E(Jn),literal:Yn,string:va,docString:E(va),character:E(va),attributeValue:E(va),number:Fh,integer:E(Fh),float:E(Fh),bool:E(Yn),regexp:E(Yn),escape:E(Yn),color:E(Yn),url:E(Yn),keyword:si,self:E(si),null:E(si),atom:E(si),unit:E(si),modifier:E(si),operatorKeyword:E(si),controlKeyword:E(si),definitionKeyword:E(si),moduleKeyword:E(si),operator:oi,derefOperator:E(oi),arithmeticOperator:E(oi),logicOperator:E(oi),bitwiseOperator:E(oi),compareOperator:E(oi),updateOperator:E(oi),definitionOperator:E(oi),typeOperator:E(oi),controlOperator:E(oi),punctuation:Qu,separator:E(Qu),bracket:Ms,angleBracket:E(Ms),squareBracket:E(Ms),paren:E(Ms),brace:E(Ms),content:ai,heading:Sr,heading1:E(Sr),heading2:E(Sr),heading3:E(Sr),heading4:E(Sr),heading5:E(Sr),heading6:E(Sr),contentSeparator:E(ai),list:E(ai),quote:E(ai),emphasis:E(ai),strong:E(ai),link:E(ai),monospace:E(ai),strikethrough:E(ai),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:ka,documentMeta:E(ka),annotation:E(ka),processingInstruction:E(ka),definition:jt.defineModifier(),constant:jt.defineModifier(),function:jt.defineModifier(),standard:jt.defineModifier(),local:jt.defineModifier(),special:jt.defineModifier()};oy([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);const Pu="ͼ",rg=typeof Symbol>"u"?"__"+Pu:Symbol.for(Pu),Au=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),sg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class og{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,h){let c=[],u=/^@(\w+)\b/.exec(o[0]),f=u&&u[1]=="keyframes";if(u&&a==null)return l.push(o[0]+";");for(let p in a){let g=a[p];if(/&/.test(p))s(p.split(/,\s*/).map(O=>o.map(y=>O.replace(/&/,y))).reduce((O,y)=>O.concat(y)),g,l);else if(g&&typeof g=="object"){if(!u)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,f)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,O=>"-"+O.toLowerCase())+": "+g+";")}(c.length||f)&&l.push((i&&!u&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=sg[rg]||1;return sg[rg]=e+1,Pu+e.toString(36)}static mount(e,t){(e[Au]||new BT(e)).mount(Array.isArray(t)?t:[t])}}let xa=null;class BT{constructor(e){if(!e.head&&e.adoptedStyleSheets&&typeof CSSStyleSheet<"u"){if(xa)return e.adoptedStyleSheets=[xa.sheet].concat(e.adoptedStyleSheets),e[Au]=xa;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),xa=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[Au]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,o),t)for(let l=0;le.concat(n):void 0})}class Rt{constructor(e,t,i=[],r=""){this.data=e,this.name=r,K.prototype.hasOwnProperty("tree")||Object.defineProperty(K.prototype,"tree",{get(){return pe(this)}}),this.parser=t,this.extension=[gr.of(this),K.languageData.of((s,o,a)=>s.facet(ag(s,o,a)))].concat(i)}isActiveAt(e,t,i=-1){return ag(e,t,i)==this.data}findRegions(e){let t=e.facet(gr);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(ws)==this.data){i.push({from:o,to:o+s.length});return}let a=s.prop(G.mounted);if(a){if(a.tree.prop(ws)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+o,to:l.to+o});else i.push({from:o,to:o+s.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+o),i.length>l)return}}for(let l=0;li.isTop?t:void 0)]}),e.name)}configure(e,t){return new vs(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function pe(n){let e=n.field(Rt.state,!1);return e?e.tree:re.empty}class qT{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Vs=null;class Io{constructor(e,t,i=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Io(e,t,[],re.empty,0,i,[],null)}startParse(){return this.parser.startParse(new qT(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=re.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Bn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Vs;Vs=this;try{return e()}finally{Vs=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=lg(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((h,c,u,f)=>l.push({fromA:h,toA:c,fromB:u,toB:f})),i=Bn.applyChanges(i,l),r=re.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),u=e.mapPos(h.to,-1);ce.from&&(this.fragments=lg(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Af{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=Vs;if(l){for(let h of r)l.tempSkipped.push(h);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new re(Ie.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Vs}}function lg(n,e,t){return Bn.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ks{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ks(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Io.create(e.facet(gr).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ks(i)}}Rt.state=Ee.define({create:ks.init,update(n,e){for(let t of e.effects)if(t.is(Rt.setState))return t.value;return e.startState.facet(gr)!=e.state.facet(gr)?ks.init(e.state):n.apply(e)}});let ly=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ly=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Gh=typeof navigator<"u"&&(!((_h=navigator.scheduling)===null||_h===void 0)&&_h.isInputPending)?()=>navigator.scheduling.isInputPending():null,MT=Te.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Rt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Rt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ly(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>Gh&&Gh()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Rt.setState.of(new ks(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>gt(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),gr=B.define({combine(n){return n.length?n[0]:null},enables:n=>[Rt.state,MT,N.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Ro{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Dl{constructor(e,t,i,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Dl(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let i=/\.([^.]+)$/.exec(t);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(i)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}}const VT=B.define(),fh=B.define({combine:n=>{if(!n.length)return" ";if(!/^(?: +|\t+)$/.test(n[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return n[0]}});function Nl(n){let e=n.facet(fh);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Eo(n,e){let t="",i=n.tabSize;if(n.facet(fh).charCodeAt(0)==9)for(;e>=i;)t+=" ",e-=i;for(let r=0;r=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Wo(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Go=new G;function LT(n,e,t){return hy(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,n)}function XT(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function UT(n){let e=n.type.prop(Go);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(G.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>cy(o,!0,1,void 0,s&&!XT(o)?r.from:void 0)}return n.parent==null?ZT:null}function hy(n,e,t){for(;n;n=n.parent){let i=UT(n);if(i)return i(Cf.create(t,e,n))}return null}function ZT(){return 0}class Cf extends dh{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.node=i}static create(e,t,i){return new Cf(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(WT(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?hy(e,this.pos,this.base):0}}function WT(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function jT(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped)return l.fromcy(i,e,t,n)}function cy(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,a=i&&s.slice(o,o+i.length)==i||r==n.pos+o,l=e?jT(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}const FT=n=>n.baseIndent;function Ja({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const _T=200;function GT(){return K.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+_T)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return n;let{state:o}=n,a=-1,l=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==a)continue;a=c.from;let u=$f(o,c.from);if(u==null)continue;let f=/^\s*/.exec(c.text)[0],p=Eo(o,u);f!=p&&l.push({from:c.from,to:c.from+f.length,insert:p})}return l.length?[n,{changes:l,sequential:!0}]:n})}const JT=B.define(),Jo=new G;function uy(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(s&&o.from=e&&l.to>t&&(s=l)}}return s}function HT(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Bl(n,e,t){for(let i of n.facet(JT)){let r=i(n,e,t);if(r)return r}return YT(n,e,t)}function fy(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const ph=_.define({map:fy}),Yo=_.define({map:fy});function dy(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Vr=Ee.define({create(){return j.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)t.is(ph)&&!KT(n,t.value.from,t.value.to)?n=n.update({add:[hg.range(t.value.from,t.value.to)]}):t.is(Yo)&&(n=n.update({filter:(i,r)=>t.value.from!=i||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(r,s)=>{ri&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(r,s)=>s<=i||r>=i}))}return n},provide:n=>N.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function KT(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}function py(n,e){return n.field(Vr,!1)?e:e.concat(_.appendConfig.of(my()))}const eQ=n=>{for(let e of dy(n)){let t=Bl(n.state,e.from,e.to);if(t)return n.dispatch({effects:py(n.state,[ph.of(t),gy(n,t)])}),!0}return!1},tQ=n=>{if(!n.state.field(Vr,!1))return!1;let e=[];for(let t of dy(n)){let i=ql(n.state,t.from,t.to);i&&e.push(Yo.of(i),gy(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function gy(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,r=n.state.doc.lineAt(e.to).number;return N.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${r}.`)}const iQ=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(Vr,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Yo.of({from:i,to:r}))}),n.dispatch({effects:t}),!0},rQ=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:eQ},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:tQ},{key:"Ctrl-Alt-[",run:iQ},{key:"Ctrl-Alt-]",run:nQ}],sQ={placeholderDOM:null,placeholderText:"…"},oQ=B.define({combine(n){return Ai(n,sQ)}});function my(n){return[Vr,hQ]}const hg=j.replace({widget:new class extends Or{toDOM(n){let{state:e}=n,t=e.facet(oQ),i=s=>{let o=n.lineBlockAt(n.posAtDOM(s.target)),a=ql(n.state,o.from,o.to);a&&n.dispatch({effects:Yo.of(a)}),s.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(n,i);let r=document.createElement("span");return r.textContent=t.placeholderText,r.setAttribute("aria-label",e.phrase("folded code")),r.title=e.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}}}),aQ={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Jh extends Zn{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function lQ(n={}){let e=Object.assign(Object.assign({},aQ),n),t=new Jh(e,!0),i=new Jh(e,!1),r=Te.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(gr)!=o.state.facet(gr)||o.startState.field(Vr,!1)!=o.state.field(Vr,!1)||pe(o.startState)!=pe(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new fr;for(let l of o.viewportLineBlocks){let h=ql(o.state,l.from,l.to)?i:Bl(o.state,l.from,l.to)?t:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:s}=e;return[r,sT({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(r))===null||a===void 0?void 0:a.markers)||J.empty},initialSpacer(){return new Jh(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let h=ql(o.state,a.from,a.to);if(h)return o.dispatch({effects:Yo.of(h)}),!0;let c=Bl(o.state,a.from,a.to);return c?(o.dispatch({effects:ph.of(c)}),!0):!1}})}),my()]}const hQ=N.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class gh{constructor(e,t){this.specs=e;let i;function r(a){let l=og.newName();return(i||(i=Object.create(null)))["."+l]=a,l}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Rt?a=>a.prop(ws)==o.data:o?a=>a==o:void 0,this.style=oy(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=i?new og(i):null,this.themeType=t.themeType}static define(e,t){return new gh(e,t||{})}}const $u=B.define(),Oy=B.define({combine(n){return n.length?[n[0]]:null}});function Yh(n){let e=n.facet($u);return e.length?e:n.facet(Oy)}function cQ(n,e){let t=[fQ],i;return n instanceof gh&&(n.module&&t.push(N.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Oy.of(n)):i?t.push($u.computeN([N.darkTheme],r=>r.facet(N.darkTheme)==(i=="dark")?[n]:[])):t.push($u.of(n)),t}class uQ{constructor(e){this.markCache=Object.create(null),this.tree=pe(e.state),this.decorations=this.buildDeco(e,Yh(e.state))}update(e){let t=pe(e.state),i=Yh(e.state),r=i!=Yh(e.startState);t.length{i.add(o,a,this.markCache[l]||(this.markCache[l]=j.mark({class:l})))},r,s);return i.finish()}}const fQ=mr.high(Te.fromClass(uQ,{decorations:n=>n.decorations})),dQ=gh.define([{tag:b.meta,color:"#7a757a"},{tag:b.link,textDecoration:"underline"},{tag:b.heading,textDecoration:"underline",fontWeight:"bold"},{tag:b.emphasis,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold"},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.keyword,color:"#708"},{tag:[b.atom,b.bool,b.url,b.contentSeparator,b.labelName],color:"#219"},{tag:[b.literal,b.inserted],color:"#164"},{tag:[b.string,b.deleted],color:"#a11"},{tag:[b.regexp,b.escape,b.special(b.string)],color:"#e40"},{tag:b.definition(b.variableName),color:"#00f"},{tag:b.local(b.variableName),color:"#30a"},{tag:[b.typeName,b.namespace],color:"#085"},{tag:b.className,color:"#167"},{tag:[b.special(b.variableName),b.macroName],color:"#256"},{tag:b.definition(b.propertyName),color:"#00c"},{tag:b.comment,color:"#940"},{tag:b.invalid,color:"#f00"}]),pQ=N.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yy=1e4,by="()[]{}",Sy=B.define({combine(n){return Ai(n,{afterCursor:!0,brackets:by,maxScanDistance:yy,renderMatch:OQ})}}),gQ=j.mark({class:"cm-matchingBracket"}),mQ=j.mark({class:"cm-nonmatchingBracket"});function OQ(n){let e=[],t=n.matched?gQ:mQ;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const yQ=Ee.define({create(){return j.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Sy);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=ki(e.state,r.head,-1,i)||r.head>0&&ki(e.state,r.head-1,1,i)||i.afterCursor&&(ki(e.state,r.head,1,i)||r.headN.decorations.from(n)}),bQ=[yQ,pQ];function SQ(n={}){return[Sy.of(n),bQ]}function Cu(n,e,t){let i=n.prop(e<0?G.openedBy:G.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function ki(n,e,t,i={}){let r=i.maxScanDistance||yy,s=i.brackets||by,o=pe(n),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let h=Cu(l.type,t,s);if(h&&l.from=i.to){if(l==0&&r.indexOf(h.type.name)>-1&&h.from0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),u=0;for(let f=0;!c.next().done&&f<=s;){let p=c.value;t<0&&(f+=p.length);let g=e+f*t;for(let O=t>0?0:p.length-1,y=t>0?p.length:-1;O!=y;O+=t){let S=o.indexOf(p[O]);if(!(S<0||i.resolveInner(g+O,1).type!=r))if(S%2==0==t>0)u++;else{if(u==1)return{start:h,end:{from:g+O,to:g+O+1},matched:S>>1==l>>1};u--}}t>0&&(f+=p.length)}return c.done?{start:h,matched:!1}:null}const kQ=Object.create(null),cg=[Ie.none],ug=[],xQ=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])xQ[n]=TQ(kQ,e);function Hh(n,e){ug.indexOf(n)>-1||(ug.push(n),console.warn(e))}function TQ(n,e){let t=null;for(let s of e.split(".")){let o=n[s]||b[s];o?typeof o=="function"?t?t=o(t):Hh(s,`Modifier ${s} used at start of tag`):t?Hh(s,`Tag ${s} used as modifier`):t=o:Hh(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let i=e.replace(/ /g,"_"),r=Ie.define({id:cg.length,name:i,props:[Cs({[i]:t})]});return cg.push(r),r.id}const QQ=n=>{let e=Rf(n.state);return e.line?PQ(n):e.block?$Q(n):!1};function If(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}const PQ=If(RQ,0),AQ=If(wy,0),$Q=If((n,e)=>wy(n,e,IQ(e)),0);function Rf(n,e=n.selection.main.head){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const Ls=50;function CQ(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Ls,i),o=n.sliceDoc(r,r+Ls),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,h=s.length-a;if(s.slice(h-e.length,h)==e&&o.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let c,u;r-i<=2*Ls?c=u=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+Ls),u=n.sliceDoc(r-Ls,r));let f=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(u)[0].length,g=u.length-p-t.length;return c.slice(f,f+e.length)==e&&u.slice(g,g+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(c.charAt(f+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(u.charAt(g-1))?1:0}}:null}function IQ(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from,to:r.to})}return e}function wy(n,e,t=e.selection.ranges){let i=t.map(s=>Rf(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>CQ(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,a;or&&(s==o||o>c.from)){r=c.from;let u=Rf(e,h).line;if(!u)continue;let f=/^\s*/.exec(c.text)[0].length,p=f==c.length,g=c.text.slice(f,f+u.length)==u?f:-1;fs.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:h,empty:c,single:u}of i)(u||!c)&&s.push({from:a.from+h,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of i)if(a>=0){let h=o.from+a,c=h+l.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}const Iu=jn.define(),EQ=jn.define(),DQ=B.define(),vy=B.define({combine(n){return Ai(n,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function NQ(n){let e=0;return n.iterChangedRanges((t,i)=>e=i),e}const ky=Ee.define({create(){return xi.empty},update(n,e){let t=e.state.facet(vy),i=e.annotation(Iu);if(i){let l=e.docChanged?Q.single(NQ(e.changes)):void 0,h=it.fromTransaction(e,l),c=i.side,u=c==0?n.undone:n.done;return h?u=Ml(u,u.length,t.minDepth,h):u=Qy(u,e.startState.selection),new xi(c==0?i.rest:u,c==0?u:i.rest)}let r=e.annotation(EQ);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(Se.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=it.fromTransaction(e),o=e.annotation(Se.time),a=e.annotation(Se.userEvent);return s?n=n.addChanges(s,o,a,t.newGroupDelay,t.minDepth):e.selection&&(n=n.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new xi(n.done.map(it.fromJSON),n.undone.map(it.fromJSON))}});function BQ(n={}){return[ky,vy.of(n),N.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?xy:e.inputType=="historyRedo"?Ru:null;return i?(e.preventDefault(),i(t)):!1}})]}function mh(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(ky,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}const xy=mh(0,!1),Ru=mh(1,!1),qQ=mh(0,!0),MQ=mh(1,!0);class it{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new it(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new it(e.changes&&Ce.fromJSON(e.changes),[],e.mapped&&Qi.fromJSON(e.mapped),e.startSelection&&Q.fromJSON(e.startSelection),e.selectionsAfter.map(Q.fromJSON))}static fromTransaction(e,t){let i=Et;for(let r of e.startState.facet(DQ)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new it(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Et)}static selection(e){return new it(void 0,Et,void 0,void 0,e)}}function Ml(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function VQ(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,a)=>{for(let l=0;l=h&&o<=c&&(i=!0)}}),i}function LQ(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Ty(n,e){return n.length?e.length?n.concat(e):n:e}const Et=[],XQ=200;function Qy(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-XQ));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Ml(n,n.length-1,1e9,t.setSelAfter(i)))}else return[it.selection([e])]}function UQ(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Kh(n,e){if(!n.length)return n;let t=n.length,i=Et;for(;t;){let r=ZQ(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[it.selection(i)]:Et}function ZQ(n,e,t){let i=Ty(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):Et,t);if(!n.changes)return it.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new it(r,_.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}const WQ=/^(input\.type|delete)($|\.)/;class xi{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new xi(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||WQ.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Oh(t,e))}function Fe(n){return n.textDirectionAt(n.state.selection.main.head)==me.LTR}const Ay=n=>Py(n,!Fe(n)),$y=n=>Py(n,Fe(n));function Cy(n,e){return ti(n,t=>t.empty?n.moveByGroup(t,e):Oh(t,e))}const zQ=n=>Cy(n,!Fe(n)),FQ=n=>Cy(n,Fe(n));function _Q(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function yh(n,e,t){let i=pe(n).resolveInner(e.head),r=t?G.closedBy:G.openedBy;for(let l=e.head;;){let h=t?i.childAfter(l):i.childBefore(l);if(!h)break;_Q(n,h,r)?i=h:l=t?h.to:h.from}let s=i.type.prop(r),o,a;return s&&(o=t?ki(n,i.from,1):ki(n,i.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?i.to:i.from,Q.cursor(a,t?-1:1)}const GQ=n=>ti(n,e=>yh(n.state,e,!Fe(n))),JQ=n=>ti(n,e=>yh(n.state,e,Fe(n)));function Iy(n,e){return ti(n,t=>{if(!t.empty)return Oh(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const Ry=n=>Iy(n,!1),Ey=n=>Iy(n,!0);function Dy(n){return Math.max(n.defaultLineHeight,Math.min(n.dom.clientHeight,innerHeight)-5)}function Ny(n,e){let{state:t}=n,i=Is(t.selection,a=>a.empty?n.moveVertically(a,e,Dy(n)):Oh(a,e));if(i.eq(t.selection))return!1;let r=n.coordsAtPos(t.selection.main.head),s=n.scrollDOM.getBoundingClientRect(),o;return r&&r.top>s.top&&r.bottomNy(n,!1),Eu=n=>Ny(n,!0);function yr(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=Q.cursor(i.from+s))}return r}const YQ=n=>ti(n,e=>yr(n,e,!0)),HQ=n=>ti(n,e=>yr(n,e,!1)),KQ=n=>ti(n,e=>yr(n,e,!Fe(n))),eP=n=>ti(n,e=>yr(n,e,Fe(n))),tP=n=>ti(n,e=>Q.cursor(n.lineBlockAt(e.head).from,1)),iP=n=>ti(n,e=>Q.cursor(n.lineBlockAt(e.head).to,-1));function nP(n,e,t){let i=!1,r=Is(n.selection,s=>{let o=ki(n,s.head,-1)||ki(n,s.head,1)||s.head>0&&ki(n,s.head-1,1)||s.headnP(n,e);function Lt(n,e){let t=Is(n.state.selection,i=>{let r=e(i);return Q.range(i.anchor,r.head,r.goalColumn)});return t.eq(n.state.selection)?!1:(n.dispatch($i(n.state,t)),!0)}function By(n,e){return Lt(n,t=>n.moveByChar(t,e))}const qy=n=>By(n,!Fe(n)),My=n=>By(n,Fe(n));function Vy(n,e){return Lt(n,t=>n.moveByGroup(t,e))}const sP=n=>Vy(n,!Fe(n)),oP=n=>Vy(n,Fe(n)),aP=n=>Lt(n,e=>yh(n.state,e,!Fe(n))),lP=n=>Lt(n,e=>yh(n.state,e,Fe(n)));function Ly(n,e){return Lt(n,t=>n.moveVertically(t,e))}const Xy=n=>Ly(n,!1),Uy=n=>Ly(n,!0);function Zy(n,e){return Lt(n,t=>n.moveVertically(t,e,Dy(n)))}const dg=n=>Zy(n,!1),pg=n=>Zy(n,!0),hP=n=>Lt(n,e=>yr(n,e,!0)),cP=n=>Lt(n,e=>yr(n,e,!1)),uP=n=>Lt(n,e=>yr(n,e,!Fe(n))),fP=n=>Lt(n,e=>yr(n,e,Fe(n))),dP=n=>Lt(n,e=>Q.cursor(n.lineBlockAt(e.head).from)),pP=n=>Lt(n,e=>Q.cursor(n.lineBlockAt(e.head).to)),gg=({state:n,dispatch:e})=>(e($i(n,{anchor:0})),!0),mg=({state:n,dispatch:e})=>(e($i(n,{anchor:n.doc.length})),!0),Og=({state:n,dispatch:e})=>(e($i(n,{anchor:n.selection.main.anchor,head:0})),!0),yg=({state:n,dispatch:e})=>(e($i(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),gP=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),mP=({state:n,dispatch:e})=>{let t=Sh(n).map(({from:i,to:r})=>Q.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:Q.create(t),userEvent:"select"})),!0},OP=({state:n,dispatch:e})=>{let t=Is(n.selection,i=>{var r;let s=pe(n).resolveInner(i.head,1);for(;!(s.from=i.to||s.to>i.to&&s.from<=i.from||!(!((r=s.parent)===null||r===void 0)&&r.parent));)s=s.parent;return Q.range(s.to,s.from)});return e($i(n,t)),!0},yP=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=Q.create([t.main]):t.main.empty||(i=Q.create([Q.cursor(t.main.head)])),i?(e($i(n,i)),!0):!1};function bh(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(o);lo&&(t="delete.forward",l=Ta(n,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Ta(n,o,!1),a=Ta(n,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:Q.cursor(o)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?N.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ta(n,e,t){if(n instanceof N)for(let i of n.state.facet(N.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}const Wy=(n,e)=>bh(n,t=>{let{state:i}=n,r=i.doc.lineAt(t),s,o;if(!e&&t>r.from&&tWy(n,!1),jy=n=>Wy(n,!0),zy=(n,e)=>bh(n,t=>{let i=t,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let a=null;;){if(i==(e?s.to:s.from)){i==t&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=je(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),c=o(h);if(a!=null&&c!=a)break;(h!=" "||i!=t)&&(a=c),i=l}return i}),Fy=n=>zy(n,!1),bP=n=>zy(n,!0),_y=n=>bh(n,e=>{let t=n.lineBlockAt(e).to;return ebh(n,e=>{let t=n.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)}),wP=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ee.of(["",""])},range:Q.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},vP=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:je(s.text,r-s.from,!1)+s.from,a=r==s.to?r+1:je(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(o,r))},range:Q.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sh(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Gy(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Sh(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let l of s.ranges)r.push(Q.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let l of s.ranges)r.push(Q.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:Q.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kP=({state:n,dispatch:e})=>Gy(n,e,!1),xP=({state:n,dispatch:e})=>Gy(n,e,!0);function Jy(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Sh(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const TP=({state:n,dispatch:e})=>Jy(n,e,!1),QP=({state:n,dispatch:e})=>Jy(n,e,!0),PP=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Sh(e).map(({from:r,to:s})=>(r>0?r--:sn.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function AP(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=pe(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(G.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from?{from:i.to,to:r.from}:null}const $P=Yy(!1),CP=Yy(!0);function Yy(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,a=e.doc.lineAt(s),l=!n&&s==o&&AP(e,s);n&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let h=new dh(e,{simulateBreak:s,simulateDoubleBreak:!!l}),c=$f(h,s);for(c==null&&(c=/^\s*/.exec(e.doc.lineAt(s).text)[0].length);oa.from&&s{let r=[];for(let o=i.from;o<=i.to;){let a=n.doc.lineAt(o);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),o=a.to+1}let s=n.changes(r);return{changes:r,range:Q.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const IP=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new dh(n,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=Ef(n,(s,o,a)=>{let l=$f(i,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let h=/^\s*/.exec(s.text)[0],c=Eo(n,l);(h!=c||a.fromn.readOnly?!1:(e(n.update(Ef(n,(t,i)=>{i.push({from:t.from,insert:n.facet(fh)})}),{userEvent:"input.indent"})),!0),EP=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ef(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Wo(r,n.tabSize),o=0,a=Eo(n,Math.max(0,s-Nl(n)));for(;o({mac:n.key,run:n.run,shift:n.shift}))),BP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:GQ,shift:aP},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:JQ,shift:lP},{key:"Alt-ArrowUp",run:kP},{key:"Shift-Alt-ArrowUp",run:TP},{key:"Alt-ArrowDown",run:xP},{key:"Shift-Alt-ArrowDown",run:QP},{key:"Escape",run:yP},{key:"Mod-Enter",run:CP},{key:"Alt-l",mac:"Ctrl-l",run:mP},{key:"Mod-i",run:OP,preventDefault:!0},{key:"Mod-[",run:EP},{key:"Mod-]",run:RP},{key:"Mod-Alt-\\",run:IP},{key:"Shift-Mod-k",run:PP},{key:"Shift-Mod-\\",run:rP},{key:"Mod-/",run:QQ},{key:"Alt-A",run:AQ}].concat(NP);function ae(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;en.normalize("NFKD"):n=>n;class xs{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?a=>s(bg(a)):bg,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Be(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=ff(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=lt(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let a=r.charCodeAt(s),l=this.match(a,o);if(l)return this.value=l,this;if(s==r.length-1)break;o==i&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=Vl(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||r.to<=t){let a=new ls(t,e.sliceString(t,i));return ec.set(e,a),a}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=Vl(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ls.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(eb.prototype[Symbol.iterator]=tb.prototype[Symbol.iterator]=function(){return this});function qP(n){try{return new RegExp(n,Df),!0}catch{return!1}}function Vl(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}function Nu(n){let e=ae("input",{class:"cm-textfield",name:"line"}),t=ae("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:Ll.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),i())},onsubmit:r=>{r.preventDefault(),i()}},ae("label",n.state.phrase("Go to line"),": ",e)," ",ae("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function i(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!r)return;let{state:s}=n,o=s.doc.lineAt(s.selection.main.head),[,a,l,h,c]=r,u=h?+h.slice(1):0,f=l?+l:o.number;if(l&&c){let g=f/100;a&&(g=g*(a=="-"?-1:1)+o.number/s.doc.lines),f=Math.round(s.doc.lines*g)}else l&&a&&(f=f*(a=="-"?-1:1)+o.number);let p=s.doc.line(Math.max(1,Math.min(s.doc.lines,f)));n.dispatch({effects:Ll.of(!1),selection:Q.cursor(p.from+Math.max(0,Math.min(u,p.length))),scrollIntoView:!0}),n.focus()}return{dom:t}}const Ll=_.define(),Sg=Ee.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Ll)&&(n=t.value);return n},provide:n=>$o.from(n,e=>e?Nu:null)}),MP=n=>{let e=Ao(n,Nu);if(!e){let t=[Ll.of(!0)];n.state.field(Sg,!1)==null&&t.push(_.appendConfig.of([Sg,VP])),n.dispatch({effects:t}),e=Ao(n,Nu)}return e&&e.dom.querySelector("input").focus(),!0},VP=N.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),LP={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},XP=B.define({combine(n){return Ai(n,LP,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function UP(n){return[FP,zP]}const ZP=j.mark({class:"cm-selectionMatch"}),WP=j.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function wg(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=de.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=de.Word)}function jP(n,e,t,i){return n(e.sliceDoc(t,t+1))==de.Word&&n(e.sliceDoc(i-1,i))==de.Word}const zP=Te.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(XP),{state:t}=n,i=t.selection;if(i.ranges.length>1)return j.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return j.none;let l=t.wordAt(r.head);if(!l)return j.none;o=t.charCategorizer(r.head),s=t.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l200)return j.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(wg(o,t,r.from,r.to)&&jP(o,t,r.from,r.to)))return j.none}else if(s=t.sliceDoc(r.from,r.to).trim(),!s)return j.none}let a=[];for(let l of n.visibleRanges){let h=new xs(t.doc,s,l.from,l.to);for(;!h.next().done;){let{from:c,to:u}=h.value;if((!o||wg(o,t,c,u))&&(r.empty&&c<=r.from&&u>=r.to?a.push(WP.range(c,u)):(c>=r.to||u<=r.from)&&a.push(ZP.range(c,u)),a.length>e.maxMatches))return j.none}}return j.set(a)}},{decorations:n=>n.decorations}),FP=N.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),_P=({state:n,dispatch:e})=>{let{selection:t}=n,i=Q.create(t.ranges.map(r=>n.wordAt(r.head)||Q.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function GP(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,a=new xs(n.doc,e,i[i.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new xs(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(l=>l.from==a.value.from))continue;if(s){let l=n.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const JP=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return _P({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=GP(n,i);return r?(e(n.update({selection:n.selection.addRange(Q.range(r.from,r.to),!1),effects:N.scrollIntoView(r.to)})),!0):!1},Nf=B.define({combine(n){return Ai(n,{top:!1,caseSensitive:!1,literal:!1,wholeWord:!1,createPanel:e=>new lA(e)})}});class ib{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||qP(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` -`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new eA(this):new HP(this)}getCursor(e,t=0,i){let r=e.doc?e:K.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Gr(this,r,t,i):_r(this,r,t,i)}}class nb{constructor(e){this.spec=e}}function _r(n,e,t,i){return new xs(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?YP(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function YP(n,e){return(t,i,r,s)=>((s>t||s+r.length=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=_r(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Gr(n,e,t,i){return new eb(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?KP(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function Xl(n,e){return n.slice(je(n,e,!1),e)}function Ul(n,e){return n.slice(e,je(n,e))}function KP(n){return(e,t,i)=>!i[0].length||(n(Xl(i.input,i.index))!=de.Word||n(Ul(i.input,i.index))!=de.Word)&&(n(Ul(i.input,i.index+i[0].length))!=de.Word||n(Xl(i.input,i.index+i[0].length))!=de.Word)}class eA extends nb{nextMatch(e,t,i){let r=Gr(this.spec,e,i,e.doc.length).next();return r.done&&(r=Gr(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Gr(this.spec,e,s,i),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Gr(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Do=_.define(),Bf=_.define(),ar=Ee.define({create(n){return new tc(Bu(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Do)?n=new tc(t.value.create(),n.panel):t.is(Bf)&&(n=new tc(n.query,t.value?qf:null));return n},provide:n=>$o.from(n,e=>e.panel)});class tc{constructor(e,t){this.query=e,this.panel=t}}const tA=j.mark({class:"cm-searchMatch"}),iA=j.mark({class:"cm-searchMatch cm-searchMatch-selected"}),nA=Te.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ar))}update(n){let e=n.state.field(ar);(e!=n.startState.field(ar)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return j.none;let{view:t}=this,i=new fr;for(let r=0,s=t.visibleRanges,o=s.length;rs[r+1].from-2*250;)l=s[++r].to;n.highlight(t.state,a,l,(h,c)=>{let u=t.state.selection.ranges.some(f=>f.from==h&&f.to==c);i.add(h,c,u?iA:tA)})}return i.finish()}},{decorations:n=>n.decorations});function Ho(n){return e=>{let t=e.state.field(ar,!1);return t&&t.query.spec.valid?n(e,t):rb(e)}}const Zl=Ho((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);return i?(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Mf(n,i),userEvent:"select.search"}),!0):!1}),Wl=Ho((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);return r?(n.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Mf(n,r),userEvent:"select.search"}),!0):!1}),rA=Ho((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:Q.create(t.map(i=>Q.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),sA=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let a=new xs(n.doc,n.sliceDoc(i,r));!a.next().done;){if(s.length>1e3)return!1;a.value.from==i&&(o=s.length),s.push(Q.range(a.value.from,a.value.to))}return e(n.update({selection:Q.create(s,o),userEvent:"select.search.matches"})),!0},vg=Ho((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],a,l,h=[];if(s.from==i&&s.to==r&&(l=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(t,s.from,s.to),h.push(N.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-l.length;a={anchor:s.from-c,head:s.to-c},h.push(Mf(n,s))}return n.dispatch({changes:o,selection:a,scrollIntoView:!!a,effects:h,userEvent:"input.replace"}),!0}),oA=Ho((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:N.announce.of(i),userEvent:"input.replace.all"}),!0});function qf(n){return n.state.facet(Nf).createPanel(n)}function Bu(n,e){var t,i,r,s;let o=n.selection.main,a=o.empty||o.to>o.from+100?"":n.sliceDoc(o.from,o.to);if(e&&!a)return e;let l=n.facet(Nf);return new ib({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:l.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:l.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:l.literal,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:l.wholeWord})}const rb=n=>{let e=n.state.field(ar,!1);if(e&&e.panel){let t=Ao(n,qf);if(!t)return!1;let i=t.dom.querySelector("[main-field]");if(i&&i!=n.root.activeElement){let r=Bu(n.state,e.query.spec);r.valid&&n.dispatch({effects:Do.of(r)}),i.focus(),i.select()}}else n.dispatch({effects:[Bf.of(!0),e?Do.of(Bu(n.state,e.query.spec)):_.appendConfig.of(cA)]});return!0},sb=n=>{let e=n.state.field(ar,!1);if(!e||!e.panel)return!1;let t=Ao(n,qf);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Bf.of(!1)}),!0},aA=[{key:"Mod-f",run:rb,scope:"editor search-panel"},{key:"F3",run:Zl,shift:Wl,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Zl,shift:Wl,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:sb,scope:"editor search-panel"},{key:"Mod-Shift-l",run:sA},{key:"Alt-g",run:MP},{key:"Mod-d",run:JP,preventDefault:!0}];class lA{constructor(e){this.view=e;let t=this.query=e.state.field(ar).query.spec;this.commit=this.commit.bind(this),this.searchField=ae("input",{value:t.search,placeholder:st(e,"Find"),"aria-label":st(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ae("input",{value:t.replace,placeholder:st(e,"Replace"),"aria-label":st(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ae("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ae("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ae("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ae("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ae("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>Zl(e),[st(e,"next")]),i("prev",()=>Wl(e),[st(e,"previous")]),i("select",()=>rA(e),[st(e,"all")]),ae("label",null,[this.caseField,st(e,"match case")]),ae("label",null,[this.reField,st(e,"regexp")]),ae("label",null,[this.wordField,st(e,"by word")]),...e.state.readOnly?[]:[ae("br"),this.replaceField,i("replace",()=>vg(e),[st(e,"replace")]),i("replaceAll",()=>oA(e),[st(e,"replace all")])],ae("button",{name:"close",onclick:()=>sb(e),"aria-label":st(e,"close"),type:"button"},["×"])])}commit(){let e=new ib({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Do.of(e)}))}keydown(e){gx(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Wl:Zl)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),vg(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Do)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Nf).top}}function st(n,e){return n.state.phrase(e)}const Qa=30,Pa=/[\s\.,:;?!]/;function Mf(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-Qa),o=Math.min(r,t+Qa),a=n.state.sliceDoc(s,o);if(s!=i.from){for(let l=0;la.length-Qa;l--)if(!Pa.test(a[l-1])&&Pa.test(a[l])){a=a.slice(0,l);break}}return N.announce.of(`${n.state.phrase("current match")}. ${a} ${n.state.phrase("on line")} ${i.number}.`)}const hA=N.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),cA=[ar,mr.lowest(nA),hA];class ob{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=pe(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(lb(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function kg(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function uA(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:uA(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}function fA(n,e){return t=>{for(let i=pe(t.state).resolveInner(t.pos,-1);i;i=i.parent)if(n.indexOf(i.name)>-1)return null;return e(t)}}class xg{constructor(e,t,i){this.completion=e,this.source=t,this.match=i}}function lr(n){return n.selection.main.head}function lb(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const dA=jn.define();function pA(n,e,t,i){return Object.assign(Object.assign({},n.changeByRange(r=>{if(r==n.selection.main)return{changes:{from:t,to:i,insert:e},range:Q.cursor(t+e.length)};let s=i-t;return!r.empty||s&&n.sliceDoc(r.from-s,r.from)!=n.sliceDoc(t,i)?{range:r}:{changes:{from:r.from-s,to:r.from,insert:e},range:Q.cursor(r.from-s+e.length)}})),{userEvent:"input.complete"})}function hb(n,e){const t=e.completion.apply||e.completion.label;let i=e.source;typeof t=="string"?n.dispatch(Object.assign(Object.assign({},pA(n.state,t,i.from,i.to)),{annotations:dA.of(e.completion)})):t(n,e.completion,i.from,i.to)}const Tg=new WeakMap;function gA(n){if(!Array.isArray(n))return n;let e=Tg.get(n);return e||Tg.set(n,e=ab(n)),e}class mA{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(P=ff(x))!=P.toLowerCase()?1:P!=P.toUpperCase()?2:0;(!k||R==1&&y||A==0&&R!=0)&&(t[u]==x||i[u]==x&&(f=!0)?o[u++]=k:o.length&&(S=!1)),A=R,k+=lt(x)}return u==l&&o[0]==0&&S?this.result(-100+(f?-200:0),o,e):p==l&&g==0?[-200-e.length,0,O]:a>-1?[-700-e.length,a,a+this.pattern.length]:p==l?[-900-e.length,g,O]:u==l?this.result(-100+(f?-200:0)+-700+(S?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[e-i.length],s=1;for(let o of t){let a=o+(this.astral?lt(Be(i,o)):1);s>1&&r[s-1]==o?r[s-1]=a:(r[s++]=o,r[s++]=a)}return r}}const Vt=B.define({combine(n){return Ai(n,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>i=>OA(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function OA(n,e){return n?e?n+" "+e:n:e}function yA(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r){let s=document.createElement("span");s.className="cm-completionLabel";let{label:o}=t,a=0;for(let l=1;la&&s.appendChild(document.createTextNode(o.slice(a,h)));let u=s.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(o.slice(h,c))),u.className="cm-completionMatchedText",a=c}return at.position-i.position).map(t=>t.render)}function Qg(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class bA{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:a=>this.positionInfo(a),key:this},this.space=null;let i=e.state.field(t),{options:r,selected:s}=i.open,o=e.state.facet(Vt);this.optionContent=yA(o),this.optionClass=o.optionClass,this.range=Qg(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",a=>{for(let l=a.target,h;l&&l!=this.dom;l=l.parentNode)if(l.nodeName=="LI"&&(h=/-(\d+)$/.exec(l.id))&&+h[1]{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){var t,i,r;let s=e.state.field(this.stateField),o=e.startState.field(this.stateField);s!=o&&(this.updateSel(),((t=s.open)===null||t===void 0?void 0:t.disabled)!=((i=o.open)===null||i===void 0?void 0:i.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(!((r=s.open)===null||r===void 0)&&r.disabled)))}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=Qg(t.options.length,t.selected,this.view.state.facet(Vt).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:i}=t.options[t.selected],{info:r}=i;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(i);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o)}).catch(o=>gt(this.view.state,o,"completion info")):this.addInfoPane(s)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&wA(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let g=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:g.innerWidth,bottom:g.innerHeight}}if(r.top>Math.min(s.bottom,t.bottom)-10||r.bottom=i.height||g>t.top?c=r.bottom-t.top+"px":u=t.bottom-r.top+"px"}return{top:c,bottom:u,maxWidth:h,class:l?o?"left-narrow":"right-narrow":a?"left":"right"}}positionInfo(e){this.info&&(e?(this.info.style.top=e.top,this.info.style.bottom=e.bottom,this.info.style.maxWidth=e.maxWidth,this.info.className="cm-tooltip cm-completionInfo cm-completionInfo-"+e.class):this.info.style.top="-1e6px")}createListBox(e,t,i){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let s=i.from;snew bA(e,n)}function wA(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect();i.topt.bottom&&(n.scrollTop+=i.bottom-t.bottom)}function Pg(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function vA(n,e){let t=[],i=0;for(let a of n)if(a.hasResult())if(a.result.filter===!1){let l=a.result.getMatch;for(let h of a.result.options){let c=[1e9-i++];if(l)for(let u of l(h))c.push(u);t.push(new xg(h,a,c))}}else{let l=new mA(e.sliceDoc(a.from,a.to)),h;for(let c of a.result.options)(h=l.match(c.label))&&(c.boost!=null&&(h[0]+=c.boost),t.push(new xg(c,a,h)))}let r=[],s=null,o=e.facet(Vt).compareCompletions;for(let a of t.sort((l,h)=>h.match[0]-l.match[0]||o(l.completion,h.completion)))!s||s.label!=a.completion.label||s.detail!=a.completion.detail||s.type!=null&&a.completion.type!=null&&s.type!=a.completion.type||s.apply!=a.completion.apply?r.push(a):Pg(a.completion)>Pg(s)&&(r[r.length-1]=a),s=a.completion;return r}class Kr{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Kr(this.options,Ag(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s){let o=vA(e,t);if(!o.length)return r&&e.some(l=>l.state==1)?new Kr(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let a=t.facet(Vt).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let l=r.options[r.selected].completion;for(let h=0;hh.hasResult()?Math.min(l,h.from):l,1e8),create:SA(Ot),above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new Kr(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class jl{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new jl(TA,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Vt),s=(i.override||t.languageDataAt("autocomplete",lr(t)).map(gA)).map(a=>(this.active.find(h=>h.source==a)||new et(a,this.active.some(h=>h.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((a,l)=>a==this.active[l])&&(s=this.active);let o=this.open;e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!kA(s,this.active)?o=Kr.build(s,t,this.id,this.open,i):o&&o.disabled&&!s.some(a=>a.state==1)?o=null:o&&e.docChanged&&(o=o.map(e.changes)),!o&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new et(a.source,0):a));for(let a of e.effects)a.is(ub)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new jl(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:xA}}function kA(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const TA=[];function qu(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class et{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=qu(e),r=this;i?r=r.handleUserEvent(e,i,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new et(r.source,0));for(let s of e.effects)if(s.is(Vf))r=new et(r.source,1,s.value?lr(e.state):-1);else if(s.is(zl))r=new et(r.source,0);else if(s.is(cb))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new et(this.source,1)}handleChange(e){return e.changes.touchesRange(lr(e.startState))?new et(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new et(this.source,this.state,e.mapPos(this.explicitPos))}}class ao extends et{constructor(e,t,i,r,s){super(e,2,t),this.result=i,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,i){var r;let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=lr(e.state);if((this.explicitPos<0?a<=s:ao||t=="delete"&&lr(e.startState)==this.from)return new et(this.source,t=="input"&&i.activateOnTyping?1:0);let l=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),h;return QA(this.result.validFor,e.state,s,o)?new ao(this.source,l,this.result,s,o):this.result.update&&(h=this.result.update(this.result,s,o,new ob(e.state,a,l>=0)))?new ao(this.source,l,h,h.from,(r=h.to)!==null&&r!==void 0?r:lr(e.state)):new et(this.source,1,l)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new et(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new ao(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function QA(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):lb(n,!0).test(r)}const Vf=_.define(),zl=_.define(),cb=_.define({map(n,e){return n.map(t=>t.map(e))}}),ub=_.define(),Ot=Ee.define({create(){return jl.start()},update(n,e){return n.update(e)},provide:n=>[xf.from(n,e=>e.tooltip),N.contentAttributes.from(n,e=>e.attrs)]});function Aa(n,e="option"){return t=>{let i=t.state.field(Ot,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+r*(n?1:-1):n?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:ub.of(a)}),!0}}const PA=n=>{let e=n.state.field(Ot,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||Date.now()-e.open.timestampn.state.field(Ot,!1)?(n.dispatch({effects:Vf.of(!0)}),!0):!1,$A=n=>{let e=n.state.field(Ot,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:zl.of(null)}),!0)};class CA{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const $g=50,IA=50,RA=1e3,EA=Te.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of n.state.field(Ot).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Ot);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Ot)==e)return;let t=n.transactions.some(i=>(i.selection||i.docChanged)&&!qu(i));for(let i=0;iIA&&Date.now()-r.time>RA){for(let s of r.context.abortListeners)try{s()}catch(o){gt(this.view.state,o)}r.context.abortListeners=null,this.running.splice(i--,1)}else r.updates.push(...n.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(r=>r.active.source==i.source))?setTimeout(()=>this.startUpdate(),$g):-1,this.composing!=0)for(let i of n.transactions)qu(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:n}=this.view,e=n.field(Ot);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=lr(e),i=new ob(e,t,n.explicitPos==t),r=new CA(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:zl.of(null)}),gt(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),$g))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Vt);for(let i=0;io.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new et(r.active.source,0);for(let a of r.updates)o=o.update(a,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:cb.of(e)})}},{eventHandlers:{blur(){let n=this.view.state.field(Ot,!1);n&&n.tooltip&&this.view.state.facet(Vt).closeOnBlur&&this.view.dispatch({effects:zl.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vf.of(!1)}),20),this.composing=0}}}),fb=N.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class DA{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}}class Lf{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Me.TrackDel),i=e.mapPos(this.to,1,Me.TrackDel);return t==null||i==null?null:new Lf(this.field,t,i)}}class Xf{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(i.length){let h=o,c=/^\t*/.exec(l)[0].length;for(let u=0;unew Lf(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",h=-1;for(let c=0;c=h&&u.field++}r.push(new DA(h,i.length,s.index,s.index+l.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}for(let a;a=/\\([{}])/.exec(o);){o=o.slice(0,a.index)+a[1]+o.slice(a.index+a[0].length);for(let l of r)l.line==i.length&&l.from>a.index&&(l.from--,l.to--)}i.push(o)}return new Xf(i,r)}}let NA=j.widget({widget:new class extends Or{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),BA=j.mark({class:"cm-snippetField"});class Rs{constructor(e,t){this.ranges=e,this.active=t,this.deco=j.set(e.map(i=>(i.from==i.to?NA:BA).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new Rs(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const Ko=_.define({map(n,e){return n&&n.map(e)}}),qA=_.define(),No=Ee.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Ko))return t.value;if(t.is(qA)&&n)return new Rs(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>N.decorations.from(n,e=>e?e.deco:j.none)});function Uf(n,e){return Q.create(n.filter(t=>t.field==e).map(t=>Q.range(t.from,t.to)))}function MA(n){let e=Xf.parse(n);return(t,i,r,s)=>{let{text:o,ranges:a}=e.instantiate(t.state,r),l={changes:{from:r,to:s,insert:ee.of(o)},scrollIntoView:!0};if(a.length&&(l.selection=Uf(a,0)),a.length>1){let h=new Rs(a,0),c=l.effects=[Ko.of(h)];t.state.field(No,!1)===void 0&&c.push(_.appendConfig.of([No,ZA,WA,fb]))}t.dispatch(t.state.update(l))}}function db(n){return({state:e,dispatch:t})=>{let i=e.field(No,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,s=n>0&&!i.ranges.some(o=>o.field==r+n);return t(e.update({selection:Uf(i.ranges,r),effects:Ko.of(s?null:new Rs(i.ranges,r))})),!0}}const VA=({state:n,dispatch:e})=>n.field(No,!1)?(e(n.update({effects:Ko.of(null)})),!0):!1,LA=db(1),XA=db(-1),UA=[{key:"Tab",run:LA,shift:XA},{key:"Escape",run:VA}],Cg=B.define({combine(n){return n.length?n[0]:UA}}),ZA=mr.highest($s.compute([Cg],n=>n.facet(Cg)));function Ut(n,e){return Object.assign(Object.assign({},e),{apply:MA(n)})}const WA=N.domEventHandlers({mousedown(n,e){let t=e.state.field(No,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:Uf(t.ranges,r.field),effects:Ko.of(t.ranges.some(s=>s.field>r.field)?new Rs(t.ranges,r.field):null)}),!0)}}),Bo={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Cr=_.define({map(n,e){let t=e.mapPos(n,-1,Me.TrackAfter);return t??void 0}}),Zf=_.define({map(n,e){return e.mapPos(n)}}),Wf=new class extends Br{};Wf.startSide=1;Wf.endSide=-1;const pb=Ee.define({create(){return J.empty},update(n,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(i,-1)&&(n=J.empty)}n=n.map(e.changes);for(let t of e.effects)t.is(Cr)?n=n.update({add:[Wf.range(t.value,t.value+1)]}):t.is(Zf)&&(n=n.update({filter:i=>i!=t.value}));return n}});function jA(){return[FA,pb]}const ic="()[]{}<>";function gb(n){for(let e=0;e{if((zA?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&<(Be(i,0))==1||e!=r.from||t!=r.to)return!1;let s=JA(n.state,i);return s?(n.dispatch(s),!0):!1}),_A=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=mb(n,n.selection.main.head).brackets||Bo.brackets,r=null,s=n.changeByRange(o=>{if(o.empty){let a=YA(n.doc,o.head);for(let l of i)if(l==a&&wh(n.doc,o.head)==gb(Be(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Q.cursor(o.head-l.length)}}return{range:r=o}});return r||e(n.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},GA=[{key:"Backspace",run:_A}];function JA(n,e){let t=mb(n,n.selection.main.head),i=t.brackets||Bo.brackets;for(let r of i){let s=gb(Be(r,0));if(e==r)return s==r?e$(n,r,i.indexOf(r+r+r)>-1,t):HA(n,r,s,t.before||Bo.before);if(e==s&&Ob(n,n.selection.main.from))return KA(n,r,s)}return null}function Ob(n,e){let t=!1;return n.field(pb).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function wh(n,e){let t=n.sliceString(e,e+2);return t.slice(0,lt(Be(t,0)))}function YA(n,e){let t=n.sliceString(e-2,e);return lt(Be(t,0))==t.length?t:t.slice(1)}function HA(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Cr.of(o.to+e.length),range:Q.range(o.anchor+e.length,o.head+e.length)};let a=wh(n.doc,o.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:Cr.of(o.head+e.length),range:Q.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function KA(n,e,t){let i=null,r=n.selection.ranges.map(s=>s.empty&&wh(n.doc,s.head)==t?Q.cursor(s.head+t.length):i=s);return i?null:n.update({selection:Q.create(r,n.selection.mainIndex),scrollIntoView:!0,effects:n.selection.ranges.map(({from:s})=>Zf.of(s))})}function e$(n,e,t,i){let r=i.stringPrefixes||Bo.stringPrefixes,s=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Cr.of(a.to+e.length),range:Q.range(a.anchor+e.length,a.head+e.length)};let l=a.head,h=wh(n.doc,l),c;if(h==e){if(Ig(n,l))return{changes:{insert:e+e,from:l},effects:Cr.of(l+e.length),range:Q.cursor(l+e.length)};if(Ob(n,l)){let u=t&&n.sliceDoc(l,l+e.length*3)==e+e+e;return{range:Q.cursor(l+e.length*(u?3:1)),effects:Zf.of(l)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(c=Rg(n,l-2*e.length,r))>-1&&Ig(n,c))return{changes:{insert:e+e+e+e,from:l},effects:Cr.of(l+e.length),range:Q.cursor(l+e.length)};if(n.charCategorizer(l)(h)!=de.Word&&Rg(n,l,r)>-1&&!t$(n,l,e,r))return{changes:{insert:e+e,from:l},effects:Cr.of(l+e.length),range:Q.cursor(l+e.length)}}return{range:s=a}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Ig(n,e){let t=pe(n).resolveInner(e+1);return t.parent&&t.from==e}function t$(n,e,t,i){let r=pe(n).resolveInner(e,-1),s=i.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+l;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function Rg(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=de.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=de.Word)return s}return-1}function i$(n={}){return[Ot,Vt.of(n),EA,n$,fb]}const yb=[{key:"Ctrl-Space",run:AA},{key:"Escape",run:$A},{key:"ArrowDown",run:Aa(!0)},{key:"ArrowUp",run:Aa(!1)},{key:"PageDown",run:Aa(!0,"page")},{key:"PageUp",run:Aa(!1,"page")},{key:"Enter",run:PA}],n$=mr.highest($s.computeN([Vt],n=>n.facet(Vt).defaultKeymap?[yb]:[]));class r${constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Qr{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(es).markerFilter;s&&(r=s(r));let o=j.set(r.map(a=>a.from==a.to||a.from==a.to-1&&i.doc.lineAt(a.from).to==a.from?j.widget({widget:new p$(a),diagnostic:a}).range(a.from):j.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity},diagnostic:a}).range(a.from,a.to)),!0);return new Qr(o,t,Ts(o))}}function Ts(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new r$(r,s,o.diagnostic),!1}),i}function s$(n,e){return!!(n.effects.some(t=>t.is(jf))||n.changes.touchesRange(e.pos))}function bb(n,e){return n.field(ft,!1)?e:e.concat(_.appendConfig.of([ft,N.decorations.compute([ft],t=>{let{selected:i,panel:r}=t.field(ft);return!i||!r||i.from==i.to?j.none:j.set([a$.range(i.from,i.to)])}),tT(l$,{hideOn:s$}),m$]))}function o$(n,e){return{effects:bb(n,[jf.of(e)])}}const jf=_.define(),zf=_.define(),Sb=_.define(),ft=Ee.define({create(){return new Qr(j.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Ts(t,n.selected.diagnostic,r)||Ts(t,null,r)}n=new Qr(t,n.panel,i)}for(let t of e.effects)t.is(jf)?n=Qr.init(t.value,n.panel,e.state):t.is(zf)?n=new Qr(n.diagnostics,t.value?vh.open:null,n.selected):t.is(Sb)&&(n=new Qr(n.diagnostics,n.panel,t.value));return n},provide:n=>[$o.from(n,e=>e.panel),N.decorations.from(n,e=>e.diagnostics)]}),a$=j.mark({class:"cm-lintRange cm-lintRange-active"});function l$(n,e,t){let{diagnostics:i}=n.state.field(ft),r=[],s=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,h,{spec:c})=>{e>=l&&e<=h&&(l==h||(e>l||t>0)&&(evb(n,t,!1)))}const c$=n=>{let e=n.state.field(ft,!1);(!e||!e.panel)&&n.dispatch({effects:bb(n.state,[zf.of(!0)])});let t=Ao(n,vh.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Eg=n=>{let e=n.state.field(ft,!1);return!e||!e.panel?!1:(n.dispatch({effects:zf.of(!1)}),!0)},u$=n=>{let e=n.state.field(ft,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},f$=[{key:"Mod-Shift-m",run:c$,preventDefault:!0},{key:"F8",run:u$}],d$=Te.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(es);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(nPromise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(o$(this.view.state,r))},i=>{gt(this.view.state,i)})}}update(n){let e=n.state.facet(es);(n.docChanged||e!=n.startState.facet(es))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),es=B.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},Ai(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:d$});function wb(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;is.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function vb(n,e,t){var i;let r=t?wb(e.actions):[];return ae("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ae("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let a=u=>{u.preventDefault();let f=Ts(n.state.field(ft).diagnostics,e);f&&s.apply(n,f.from,f.to)},{name:l}=s,h=r[o]?l.indexOf(r[o]):-1,c=h<0?l:[l.slice(0,h),ae("u",l.slice(h,h+1)),l.slice(h+1)];return ae("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${l}${h<0?"":` (access key "${r[o]})"`}.`},c)}),e.source&&ae("div",{class:"cm-diagnosticSource"},e.source))}class p$ extends Or{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ae("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Dg{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=vb(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class vh{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)Eg(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=wb(s.actions);for(let a=0;a{for(let s=0;sEg(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ft).selected;if(!e)return-1;for(let t=0;t{let h=-1,c;for(let u=i;ui&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{o.topa.bottom&&(this.list.scrollTop+=o.bottom-a.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ft),i=Ts(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Sb.of(i)})}static open(e){return new vh(e)}}function g$(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function nc(n){return g$(``,'width="6" height="3"')}const m$=N.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:nc("#d11")},".cm-lintRange-warning":{backgroundImage:nc("orange")},".cm-lintRange-info":{backgroundImage:nc("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),O$=[uT(),pT(),Rx(),BQ(),lQ(),wx(),Qx(),K.allowMultipleSelections.of(!0),GT(),cQ(dQ,{fallback:!0}),SQ(),jA(),i$(),Wx(),Fx(),Mx(),UP(),$s.of([...GA,...BP,...aA,...jQ,...rQ,...yb,...f$])];class Fl{constructor(e,t,i,r,s,o,a){this.type=e,this.value=t,this.from=i,this.hash=r,this.end=s,this.children=o,this.positions=a,this.hashProp=[[G.contextHash,r]]}static create(e,t,i,r,s){let o=r+(r<<8)+e+(t<<4)|0;return new Fl(e,t,i,o,s,[],[])}addChild(e,t){e.prop(G.contextHash)!=this.hash&&(e=new re(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let i=this.children.length-1;return i>=0&&(t=Math.max(t,this.positions[i]+this.children[i].length+this.from)),new re(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(s,o,a)=>new re(Ie.none,s,o,a,this.hashProp)})}}var I;(function(n){n[n.Document=1]="Document",n[n.CodeBlock=2]="CodeBlock",n[n.FencedCode=3]="FencedCode",n[n.Blockquote=4]="Blockquote",n[n.HorizontalRule=5]="HorizontalRule",n[n.BulletList=6]="BulletList",n[n.OrderedList=7]="OrderedList",n[n.ListItem=8]="ListItem",n[n.ATXHeading1=9]="ATXHeading1",n[n.ATXHeading2=10]="ATXHeading2",n[n.ATXHeading3=11]="ATXHeading3",n[n.ATXHeading4=12]="ATXHeading4",n[n.ATXHeading5=13]="ATXHeading5",n[n.ATXHeading6=14]="ATXHeading6",n[n.SetextHeading1=15]="SetextHeading1",n[n.SetextHeading2=16]="SetextHeading2",n[n.HTMLBlock=17]="HTMLBlock",n[n.LinkReference=18]="LinkReference",n[n.Paragraph=19]="Paragraph",n[n.CommentBlock=20]="CommentBlock",n[n.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",n[n.Escape=22]="Escape",n[n.Entity=23]="Entity",n[n.HardBreak=24]="HardBreak",n[n.Emphasis=25]="Emphasis",n[n.StrongEmphasis=26]="StrongEmphasis",n[n.Link=27]="Link",n[n.Image=28]="Image",n[n.InlineCode=29]="InlineCode",n[n.HTMLTag=30]="HTMLTag",n[n.Comment=31]="Comment",n[n.ProcessingInstruction=32]="ProcessingInstruction",n[n.URL=33]="URL",n[n.HeaderMark=34]="HeaderMark",n[n.QuoteMark=35]="QuoteMark",n[n.ListMark=36]="ListMark",n[n.LinkMark=37]="LinkMark",n[n.EmphasisMark=38]="EmphasisMark",n[n.CodeMark=39]="CodeMark",n[n.CodeText=40]="CodeText",n[n.CodeInfo=41]="CodeInfo",n[n.LinkTitle=42]="LinkTitle",n[n.LinkLabel=43]="LinkLabel"})(I||(I={}));class y${constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class b${constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return lo(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,i=0){for(let r=t;r=e.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let i=(n.type==I.OrderedList?Gf:_f)(t,e,!1);return i>0&&(n.type!=I.BulletList||Ff(t,e,!1)<0)&&t.text.charCodeAt(t.pos+i-1)==n.value}const kb={[I.Blockquote](n,e,t){return t.next!=62?!1:(t.markers.push(ie(I.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1)),t.moveBase(t.pos+(Xt(t.text.charCodeAt(t.pos+1))?2:1)),n.end=e.lineStart+t.text.length,!0)},[I.ListItem](n,e,t){return t.indent-1?!1:(t.moveBaseColumn(t.baseIndent+n.value),!0)},[I.OrderedList]:Ng,[I.BulletList]:Ng,[I.Document](){return!0}};function Xt(n){return n==32||n==9||n==10||n==13}function lo(n,e=0){for(;et&&Xt(n.charCodeAt(e-1));)e--;return e}function xb(n){if(n.next!=96&&n.next!=126)return-1;let e=n.pos+1;for(;e-1&&n.depth==e.stack.length||i<3?-1:1}function Qb(n,e){for(let t=n.stack.length-1;t>=0;t--)if(n.stack[t].type==e)return!0;return!1}function _f(n,e,t){return(n.next==45||n.next==43||n.next==42)&&(n.pos==n.text.length-1||Xt(n.text.charCodeAt(n.pos+1)))&&(!t||Qb(e,I.BulletList)||n.skipSpace(n.pos+2)=48&&r<=57;){i++;if(i==n.text.length)return-1;r=n.text.charCodeAt(i)}return i==n.pos||i>n.pos+9||r!=46&&r!=41||in.pos+1||n.next!=49)?-1:i+1-n.pos}function Pb(n){if(n.next!=35)return-1;let e=n.pos+1;for(;e6?-1:t}function Ab(n){if(n.next!=45&&n.next!=61||n.indent>=n.baseIndent+4)return-1;let e=n.pos+1;for(;e/,Cb=/\?>/,Vu=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/,Cb=/\?>/,Lu=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(i);if(s)return n.append(ie(I.Comment,t,t+1+s[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return n.append(ie(I.ProcessingInstruction,t,t+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?n.append(ie(I.HTMLTag,t,t+1+a[0].length)):-1},Emphasis(n,e,t){if(e!=95&&e!=42)return-1;let i=t+1;for(;n.char(i)==e;)i++;let r=n.slice(t-1,t),s=n.slice(i,i+1),o=Mo.test(r),a=Mo.test(s),l=/\s|^$/.test(r),h=/\s|^$/.test(s),c=!h&&(!a||l||o),u=!l&&(!o||h||a),f=c&&(e==42||!u||o),p=u&&(e==42||!c||a);return n.append(new zt(e==95?Bb:qb,t,i,(f?1:0)|(p?2:0)))},HardBreak(n,e,t){if(e==92&&n.char(t+1)==10)return n.append(ie(I.HardBreak,t,t+2));if(e==32){let i=t+1;for(;n.char(i)==32;)i++;if(n.char(i)==10&&i>=t+2)return n.append(ie(I.HardBreak,t,i+1))}return-1},Link(n,e,t){return e==91?n.append(new zt(Us,t,t+1,1)):-1},Image(n,e,t){return e==33&&n.char(t+1)==91?n.append(new zt(Mg,t,t+2,1)):-1},LinkEnd(n,e,t){if(e!=93)return-1;for(let i=n.parts.length-1;i>=0;i--){let r=n.parts[i];if(r instanceof zt&&(r.type==Us||r.type==Mg)){if(!r.side||n.skipSpace(r.to)==t&&!/[(\[]/.test(n.slice(t+1,t+2)))return n.parts[i]=null,-1;let s=n.takeContent(i),o=n.parts[i]=Q$(n,s,r.type==Us?I.Link:I.Image,r.from,t+1);if(r.type==Us)for(let a=0;ae?ie(I.URL,e+t,s+t):s==n.length?null:!1}}function Vb(n,e,t){let i=n.charCodeAt(e);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=e+1,o=!1;s=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,i,r,s){return this.append(new zt(e,t,i,(r?1:0)|(s?2:0)))}addElement(e){return this.append(e)}resolveMarkers(e){for(let i=e;i=e;l--){let O=this.parts[l];if(O instanceof zt&&O.side&1&&O.type==r.type&&!(s&&(r.side&1||O.side&2)&&(O.to-O.from+o)%3==0&&((O.to-O.from)%3||o%3))){a=O;break}}if(!a)continue;let h=r.type.resolve,c=[],u=a.from,f=r.to;if(s){let O=Math.min(2,a.to-a.from,o);u=a.to-O,f=r.from+O,h=O==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,u,a.to));for(let O=l+1;O=0;t--){let i=this.parts[t];if(i instanceof zt&&i.type==e)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}skipSpace(e){return lo(this.text,e-this.offset)+this.offset}elt(e,t,i,r){return typeof e=="string"?ie(this.parser.getNodeType(e),t,i,r):new Nb(e,t)}}function Xu(n,e){if(!e.length)return n;if(!n.length)return e;let t=n.slice(),i=0;for(let r of e){for(;i(e?e-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` -`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=t;if(!i.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(G.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,a=e.block.children.length,l=o,h=a;for(;;){if(t.to-i>r){if(t.type.isAnonymous&&t.firstChild())continue;break}if(e.dontInject.add(t.tree),e.addNode(t.tree,t.from-i),t.type.is("Block")&&(A$.indexOf(t.type.id)<0?(o=t.to-i,a=e.block.children.length):(o=l,a=h,l=t.to-i,h=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return o-s}};const C$=Cs({"Blockquote/...":b.quote,HorizontalRule:b.contentSeparator,"ATXHeading1/... SetextHeading1/...":b.heading1,"ATXHeading2/... SetextHeading2/...":b.heading2,"ATXHeading3/...":b.heading3,"ATXHeading4/...":b.heading4,"ATXHeading5/...":b.heading5,"ATXHeading6/...":b.heading6,"Comment CommentBlock":b.comment,Escape:b.escape,Entity:b.character,"Emphasis/...":b.emphasis,"StrongEmphasis/...":b.strong,"Link/... Image/...":b.link,"OrderedList/... BulletList/...":b.list,"BlockQuote/...":b.quote,"InlineCode CodeText":b.monospace,URL:b.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":b.processingInstruction,"CodeInfo LinkLabel":b.labelName,LinkTitle:b.string,Paragraph:b.content}),I$=new kh(new _o(Eb).extend(C$),Object.keys($a).map(n=>$a[n]),Object.keys($a).map(n=>v$[n]),Object.keys($a),k$,kb,Object.keys(sc).map(n=>sc[n]),Object.keys(sc),[]);function R$(n,e,t){let i=[];for(let r=n.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:t;if(o>s&&i.push({from:s,to:o}),!r)break;s=r.to}return i}function E$(n){let{codeParser:e,htmlParser:t}=n;return{wrap:ry((r,s)=>{let o=r.type.id;if(e&&(o==I.CodeBlock||o==I.FencedCode)){let a="";if(o==I.FencedCode){let h=r.node.getChild(I.CodeInfo);h&&(a=s.read(h.from,h.to))}let l=e(a);if(l)return{parser:l,overlay:h=>h.type.id==I.CodeText}}else if(t&&(o==I.HTMLBlock||o==I.HTMLTag))return{parser:t,overlay:R$(r.node,r.from,r.to)};return null})}}const D$={resolve:"Strikethrough",mark:"StrikethroughMark"},N$={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":b.strikethrough}},{name:"StrikethroughMark",style:b.processingInstruction}],parseInline:[{name:"Strikethrough",parse(n,e,t){if(e!=126||n.char(t+1)!=126||n.char(t+2)==126)return-1;let i=n.slice(t-1,t),r=n.slice(t+2,t+3),s=/\s|^$/.test(i),o=/\s|^$/.test(r),a=Mo.test(i),l=Mo.test(r);return n.addDelimiter(D$,t,t+2,!o&&(!l||s||a),!s&&(!a||o||l))},after:"Emphasis"}]};function ho(n,e,t=0,i,r=0){let s=0,o=!0,a=-1,l=-1,h=!1,c=()=>{i.push(n.elt("TableCell",r+a,r+l,n.parser.parseInline(e.slice(a,l),r+a)))};for(let u=t;u-1)&&s++,o=!1,i&&(a>-1&&c(),i.push(n.elt("TableDelimiter",u+r,u+r+1))),a=l=-1):(h||f!=32&&f!=9)&&(a<0&&(a=u),l=u+1),h=!h&&f==92}return a>-1&&(s++,i&&c()),s}function Lg(n,e){for(let t=e;tr instanceof Xg)||!Lg(e.text,e.basePos))return!1;let i=n.scanLine(n.absoluteLineEnd+1).text;return Xb.test(i)&&ho(n,e.text,e.basePos)==ho(n,i,e.basePos)},before:"SetextHeading"}]};class q${nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const M$={defineNodes:[{name:"Task",block:!0,style:b.list},{name:"TaskMarker",style:b.atom}],parseBlock:[{name:"TaskList",leaf(n,e){return/^\[[ xX]\]/.test(e.content)&&n.parentType().name=="ListItem"?new q$:null},after:"SetextHeading"}]},V$=[B$,M$,N$];function Ub(n,e,t){return(i,r,s)=>{if(r!=n||i.char(s+1)==n)return-1;let o=[i.elt(t,s,s+1)];for(let a=s+1;at%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new _l(e,[],t,i,i,0,[],0,r?new Zg(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,i=e&65535,{parser:r}=this.p,s=r.dynamicPrecedence(i);if(s&&(this.score+=s),t==0){this.pushState(r.getGoto(this.state,i,!0),this.reducePos),io;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==i)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(t,r),t<=o.maxNode&&this.buffer.push(t,r,i,4)}}apply(e,t,i){e&65536?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new _l(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Z$(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if(!(i&65536))return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sl&1&&a==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r>19,r=e&65535,s=this.stack.length-i*3;if(s<0||t.getGoto(this.stack[s],r,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Zg{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var Wg;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth"})(Wg||(Wg={}));class Z${constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Gl{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Gl(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gl(this.stack,this.pos,this.index)}}class Ya{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const jg=new Ya;class W${constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=jg,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=jg,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class Ha{constructor(e,t){this.data=e,this.id=t}token(e,t){j$(this.data,e,t,this.id)}}Ha.prototype.contextual=Ha.prototype.fallback=Ha.prototype.extend=!1;class ii{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function j$(n,e,t,i){let r=0,s=1<0){let p=n[f];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||o.overrides(p,e.token.value))){e.acceptToken(p);break}}let h=e.next,c=0,u=n[r+2];if(e.next<0&&u>c&&n[l+u*3-3]==65535&&n[l+u*3-3]==65535){r=n[l+u*3-1];continue e}for(;c>1,p=l+f+(f<<1),g=n[p],O=n[p+1]||65536;if(h=O)c=f+1;else{r=n[p+2],e.advance();continue e}}break}}function Ia(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}const Zt=typeof process<"u"&&Ug&&/\bparse\b/.test(Ug.LOG);let oc=null;var zg;(function(n){n[n.Margin=25]="Margin"})(zg||(zg={}));function Fg(n,e,t){let i=n.cursor(ce.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.toe)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class z${constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Fg(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Fg(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof re){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class F${constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Ya)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let h=0;hu.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!c.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new Ya,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ya,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;se.bufferLength*4?new z$(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;for(let o=0;ot)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!i.length){let o=r&&J$(r);if(o)return this.stackToTree(o);if(this.parser.strict)throw Zt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1)e:for(let o=0;o500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?s.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!h||(u.prop(G.contextHash)||0)==c))return e.useNode(u,f),Zt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(u.type.id)})`),!0;if(!(u instanceof re)||u.children.length==0||u.positions[0]>0)break;let p=u.children[0];if(p instanceof re&&u.positions[0]==0)u=p;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Zt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let h=0;hr?t.push(g):i.push(g)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Gg(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Zt&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),f=c;for(let p=0;u.forceReduce()&&p<10&&(Zt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));p++)Zt&&(f=this.stackID(u)+" -> ");for(let p of a.recoverByInsert(l))Zt&&console.log(c+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,i);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),Zt&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Gg(a,i)):(!r||r.scoren;class Zb{constructor(e){this.start=e.start,this.shift=e.shift||ac,this.reduce=e.reduce||ac,this.reuse=e.reuse||ac,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Ps extends Af{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)s(c,l,a[h++]);else{let u=a[h+-c];for(let f=-c;f>0;f--)s(a[h++],l,u);h++}}}this.nodeSet=new _o(t.map((a,l)=>Ie.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=ty;let o=Ia(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Ha(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new _$(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&i)return l;for(let h=s+(o>>1);s0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$n(this.data,i+2);else return!1;if(t==$n(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$n(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}overrides(e,t){let i=Jg(this.data,this.tokenPrecTable,t);return i<0||Jg(this.data,this.tokenPrecTable,e){let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(a=>a.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Yg(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const Y$=54,H$=1,K$=55,eC=2,tC=56,iC=3,Jl=4,Wb=5,jb=6,zb=7,Fb=8,nC=9,rC=10,sC=11,lc=57,oC=12,Hg=58,aC=18,lC=20,_b=21,hC=22,Uu=24,Gb=25,cC=27,uC=30,fC=33,dC=35,pC=0,gC={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},mC={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},Kg={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function OC(n){return n==45||n==46||n==58||n>=65&&n<=90||n==95||n>=97&&n<=122||n>=161}function Jb(n){return n==9||n==10||n==13||n==32}let em=null,tm=null,im=0;function Zu(n,e){let t=n.pos+e;if(im==t&&tm==n)return em;let i=n.peek(e);for(;Jb(i);)i=n.peek(++e);let r="";for(;OC(i);)r+=String.fromCharCode(i),i=n.peek(++e);return tm=n,im=t,em=r?r.toLowerCase():i==yC||i==bC?void 0:null}const Yb=60,Hb=62,Kb=47,yC=63,bC=33,SC=45;function nm(n,e){this.name=n,this.parent=e,this.hash=e?e.hash:0;for(let t=0;t-1?new nm(Zu(i,1)||"",n):n},reduce(n,e){return e==aC&&n?n.parent:n},reuse(n,e,t,i){let r=e.type.id;return r==Jl||r==dC?new nm(Zu(i,1)||"",n):n},hash(n){return n?n.hash:0},strict:!1}),kC=new ii((n,e)=>{if(n.next!=Yb){n.next<0&&e.context&&n.acceptToken(lc);return}n.advance();let t=n.next==Kb;t&&n.advance();let i=Zu(n,0);if(i===void 0)return;if(!i)return n.acceptToken(t?oC:Jl);let r=e.context?e.context.name:null;if(t){if(i==r)return n.acceptToken(nC);if(r&&mC[r])return n.acceptToken(lc,-2);if(e.dialectEnabled(pC))return n.acceptToken(rC);for(let s=e.context;s;s=s.parent)if(s.name==i)return;n.acceptToken(sC)}else{if(i=="script")return n.acceptToken(Wb);if(i=="style")return n.acceptToken(jb);if(i=="textarea")return n.acceptToken(zb);if(gC.hasOwnProperty(i))return n.acceptToken(Fb);r&&Kg[r]&&Kg[r][i]?n.acceptToken(lc,-1):n.acceptToken(Jl)}},{contextual:!0}),xC=new ii(n=>{for(let e=0,t=0;;t++){if(n.next<0){t&&n.acceptToken(Hg);break}if(n.next==SC)e++;else if(n.next==Hb&&e>=2){t>3&&n.acceptToken(Hg,-2);break}else e=0;n.advance()}});function Jf(n,e,t){let i=2+n.length;return new ii(r=>{for(let s=0,o=0,a=0;;a++){if(r.next<0){a&&r.acceptToken(e);break}if(s==0&&r.next==Yb||s==1&&r.next==Kb||s>=2&&so?r.acceptToken(e,-o):r.acceptToken(t,-(o-2));break}else if((r.next==10||r.next==13)&&a){r.acceptToken(e,1);break}else s=o=0;r.advance()}})}const TC=Jf("script",Y$,H$),QC=Jf("style",K$,eC),PC=Jf("textarea",tC,iC),AC=Cs({"Text RawText":b.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":b.angleBracket,TagName:b.tagName,"MismatchedCloseTag/TagName":[b.tagName,b.invalid],AttributeName:b.attributeName,"AttributeValue UnquotedAttributeValue":b.attributeValue,Is:b.definitionOperator,"EntityReference CharacterReference":b.character,Comment:b.blockComment,ProcessingInst:b.processingInstruction,DoctypeDecl:b.documentMeta}),$C=Ps.deserialize({version:14,states:",xOVOxOOO!WQ!bO'#CoO!]Q!bO'#CyO!bQ!bO'#C|O!gQ!bO'#DPO!lQ!bO'#DRO!qOXO'#CnO!|OYO'#CnO#XO[O'#CnO$eOxO'#CnOOOW'#Cn'#CnO$lO!rO'#DTO$tQ!bO'#DVO$yQ!bO'#DWOOOW'#Dk'#DkOOOW'#DY'#DYQVOxOOO%OQ#tO,59ZO%WQ#tO,59eO%`Q#tO,59hO%hQ#tO,59kO%sQ#tO,59mOOOX'#D^'#D^O%{OXO'#CwO&WOXO,59YOOOY'#D_'#D_O&`OYO'#CzO&kOYO,59YOOO['#D`'#D`O&sO[O'#C}O'OO[O,59YOOOW'#Da'#DaO'WOxO,59YO'_Q!bO'#DQOOOW,59Y,59YOOO`'#Db'#DbO'dO!rO,59oOOOW,59o,59oO'lQ!bO,59qO'qQ!bO,59rOOOW-E7W-E7WO'vQ#tO'#CqOOQO'#DZ'#DZO(UQ#tO1G.uOOOX1G.u1G.uO(^Q#tO1G/POOOY1G/P1G/PO(fQ#tO1G/SOOO[1G/S1G/SO(nQ#tO1G/VOOOW1G/V1G/VOOOW1G/X1G/XO(yQ#tO1G/XOOOX-E7[-E7[O)RQ!bO'#CxOOOW1G.t1G.tOOOY-E7]-E7]O)WQ!bO'#C{OOO[-E7^-E7^O)]Q!bO'#DOOOOW-E7_-E7_O)bQ!bO,59lOOO`-E7`-E7`OOOW1G/Z1G/ZOOOW1G/]1G/]OOOW1G/^1G/^O)gQ&jO,59]OOQO-E7X-E7XOOOX7+$a7+$aOOOY7+$k7+$kOOO[7+$n7+$nOOOW7+$q7+$qOOOW7+$s7+$sO)rQ!bO,59dO)wQ!bO,59gO)|Q!bO,59jOOOW1G/W1G/WO*RO,UO'#CtO*dO7[O'#CtOOQO1G.w1G.wOOOW1G/O1G/OOOOW1G/R1G/ROOOW1G/U1G/UOOOO'#D['#D[O*uO,UO,59`OOQO,59`,59`OOOO'#D]'#D]O+WO7[O,59`OOOO-E7Y-E7YOOQO1G.z1G.zOOOO-E7Z-E7Z",stateData:"+u~O!^OS~OSSOTPOUQOVROWTOY]OZ[O[^O^^O_^O`^Oa^Ox^O{_O!dZO~OdaO~OdbO~OdcO~OddO~OdeO~O!WfOPkP!ZkP~O!XiOQnP!ZnP~O!YlORqP!ZqP~OSSOTPOUQOVROWTOXqOY]OZ[O[^O^^O_^O`^Oa^Ox^O!dZO~O!ZrO~P#dO![sO!euO~OdvO~OdwO~OfyOj|O~OfyOj!OO~OfyOj!QO~OfyOj!SOv!TO~OfyOj!TO~O!WfOPkX!ZkX~OP!WO!Z!XO~O!XiOQnX!ZnX~OQ!ZO!Z!XO~O!YlORqX!ZqX~OR!]O!Z!XO~O!Z!XO~P#dOd!_O~O![sO!e!aO~Oj!bO~Oj!cO~Og!dOfeXjeXveX~OfyOj!fO~OfyOj!gO~OfyOj!hO~OfyOj!iOv!jO~OfyOj!jO~Od!kO~Od!lO~Od!mO~Oj!nO~Oi!qO!`!oO!b!pO~Oj!rO~Oj!sO~Oj!tO~O_!uO`!uOa!uO!`!wO!a!uO~O_!xO`!xOa!xO!b!wO!c!xO~O_!uO`!uOa!uO!`!{O!a!uO~O_!xO`!xOa!xO!b!{O!c!xO~Ov~vj`!dx{_a_~",goto:"%p!`PPPPPPPPPPPPPPPPPP!a!gP!mPP!yPP!|#P#S#Y#]#`#f#i#l#r#xP!aP!a!aP$O$U$l$r$x%O%U%[%bPPPPPPPP%hX^OX`pXUOX`pezabcde{}!P!R!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ}bQ!PcQ!RdQ!UeZ!e{}!P!R!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue EndTag ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag SelfClosingEndTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:67,context:vC,nodeProps:[["closedBy",-10,1,2,3,5,6,7,8,9,10,11,"EndTag",4,"EndTag SelfClosingEndTag",-4,19,29,32,35,"CloseTag"],["group",-9,12,15,16,17,18,39,40,41,42,"Entity",14,"Entity TextContent",-3,27,30,33,"TextContent Entity"],["openedBy",26,"StartTag StartCloseTag",-4,28,31,34,36,"OpenTag",38,"StartTag"]],propSources:[AC],skippedNodes:[0],repeatNodeCount:9,tokenData:"#(r!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs4ysv-_vw5iwxJ^x}-_}!OKP!O!P-_!P!Q!!O!Q![-_![!]!$c!]!^-_!^!_!(k!_!`#'S!`!a#'z!a!c-_!c!}!$c!}#R-_#R#S!$c#S#T3V#T#o!$c#o#s-_#s$f$q$f%W-_%W%o!$c%o%p-_%p&a!$c&a&b-_&b1p!$c1p4U-_4U4d!$c4d4e-_4e$IS!$c$IS$I`-_$I`$Ib!$c$Ib$Kh-_$Kh%#t!$c%#t&/x-_&/x&Et!$c&Et&FV-_&FV;'S!$c;'S;:j!(e;:j;=`4s<%l?&r-_?&r?Ah!$c?Ah?BY$q?BY?Mn!$c?MnO$q!Z$|c^PiW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr$qrs&}sv$qvw+Pwx(tx!^$q!^!_*V!_!a&X!a#S$q#S#T&X#T;'S$q;'S;=`+z<%lO$q!R&bX^P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&Xq'UV^P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}P'pT^POv'kw!^'k!_;'S'k;'S;=`(P<%lO'kP(SP;=`<%l'kp([S!cpOv(Vx;'S(V;'S;=`(h<%lO(Vp(kP;=`<%l(Vq(qP;=`<%l&}a({W^P!a`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t`)jT!a`Or)esv)ew;'S)e;'S;=`)y<%lO)e`)|P;=`<%l)ea*SP;=`<%l(t!Q*^V!a`!cpOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!Q*vP;=`<%l*V!R*|P;=`<%l&XW+UYiWOX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+PW+wP;=`<%l+P!Z+}P;=`<%l$q!a,]`^P!a`!cp!^^OX&XXY,QYZ,QZ]&X]^,Q^p&Xpq,Qqr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!_-ljfS^PiW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_1n!_!a&X!a#S-_#S#T3V#T#s-_#s$f$q$f;'S-_;'S;=`4s<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q[/ecfSiWOX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!^!_0p!a#S/^#S#T0p#T#s/^#s$f+P$f;'S/^;'S;=`1h<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+PS0uXfSqr0psw0px!P0p!Q!_0p!a#s0p$f;'S0p;'S;=`1b<%l?Ah0p?BY?Mn0pS1eP;=`<%l0p[1kP;=`<%l/^!U1wbfS!a`!cpOq*Vqr1nrs(Vsv1nvw0pwx)ex!P1n!P!Q*V!Q!_1n!_!a*V!a#s1n#s$f*V$f;'S1n;'S;=`3P<%l?Ah1n?Ah?BY*V?BY?Mn1n?MnO*V!U3SP;=`<%l1n!V3bcfS^P!a`!cpOq&Xqr3Vrs&}sv3Vvw0pwx(tx!P3V!P!Q&X!Q!^3V!^!_1n!_!a&X!a#s3V#s$f&X$f;'S3V;'S;=`4m<%l?Ah3V?Ah?BY&X?BY?Mn3V?MnO&X!V4pP;=`<%l3V!_4vP;=`<%l-_!Z5SV!`h^P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}!_5rjfSiWa!ROX7dXZ8qZ[7d[^8q^p7dqr:crs8qst@Ttw:cwx8qx!P:c!P!Q7d!Q!]:c!]!^/^!^!_=p!_!a8q!a#S:c#S#T=p#T#s:c#s$f7d$f;'S:c;'S;=`?}<%l?Ah:c?Ah?BY7d?BY?Mn:c?MnO7d!Z7ibiWOX7dXZ8qZ[7d[^8q^p7dqr7drs8qst+Ptw7dwx8qx!]7d!]!^9f!^!a8q!a#S7d#S#T8q#T;'S7d;'S;=`:]<%lO7d!R8tVOp8qqs8qt!]8q!]!^9Z!^;'S8q;'S;=`9`<%lO8q!R9`O_!R!R9cP;=`<%l8q!Z9mYiW_!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z:`P;=`<%l7d!_:jjfSiWOX7dXZ8qZ[7d[^8q^p7dqr:crs8qst/^tw:cwx8qx!P:c!P!Q7d!Q!]:c!]!^<[!^!_=p!_!a8q!a#S:c#S#T=p#T#s:c#s$f7d$f;'S:c;'S;=`?}<%l?Ah:c?Ah?BY7d?BY?Mn:c?MnO7d!_{let l=o.type.id;if(l==cC)return hc(o,a,t);if(l==uC)return hc(o,a,i);if(l==fC)return hc(o,a,r);if(s&&l==_b){let h=o.node,c;if(c=h.firstChild){let u=s[a.read(c.from,c.to)];if(u)for(let f of u){if(f.tagName){if(!tagName){let g=h.parent.getChild(lC);tagName=g?a.read(g.from,g.to):" "}if(attrTagName!=tagName)continue}let p=h.lastChild;if(p.type.id==Uu)return{parser:f.parser,overlay:[{from:p.from+1,to:p.to-1}]};if(p.type.id==Gb)return{parser:f.parser,overlay:[{from:p.from,to:p.to}]}}}}return null})}const IC=94,rm=1,RC=95,EC=96,sm=2,tS=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],DC=58,NC=40,iS=95,BC=91,Ka=45,qC=46,MC=35,VC=37;function Yl(n){return n>=65&&n<=90||n>=97&&n<=122||n>=161}function LC(n){return n>=48&&n<=57}const XC=new ii((n,e)=>{for(let t=!1,i=0,r=0;;r++){let{next:s}=n;if(Yl(s)||s==Ka||s==iS||t&&LC(s))!t&&(s!=Ka||r>0)&&(t=!0),i===r&&s==Ka&&i++,n.advance();else{t&&n.acceptToken(s==NC?RC:i==2&&e.canShift(sm)?sm:EC);break}}}),UC=new ii(n=>{if(tS.includes(n.peek(-1))){let{next:e}=n;(Yl(e)||e==iS||e==MC||e==qC||e==BC||e==DC||e==Ka)&&n.acceptToken(IC)}}),ZC=new ii(n=>{if(!tS.includes(n.peek(-1))){let{next:e}=n;if(e==VC&&(n.advance(),n.acceptToken(rm)),Yl(e)){do n.advance();while(Yl(n.next));n.acceptToken(rm)}}}),WC=Cs({"AtKeyword import charset namespace keyframes media supports":b.definitionKeyword,"from to selector":b.keyword,NamespaceName:b.namespace,KeyframeName:b.labelName,TagName:b.tagName,ClassName:b.className,PseudoClassName:b.constant(b.className),IdName:b.labelName,"FeatureName PropertyName":b.propertyName,AttributeName:b.attributeName,NumberLiteral:b.number,KeywordQuery:b.keyword,UnaryQueryOp:b.operatorKeyword,"CallTag ValueName":b.atom,VariableName:b.variableName,Callee:b.operatorKeyword,Unit:b.unit,"UniversalSelector NestingSelector":b.definitionOperator,MatchOp:b.compareOperator,"ChildOp SiblingOp, LogicOp":b.logicOperator,BinOp:b.arithmeticOperator,Important:b.modifier,Comment:b.blockComment,ParenthesizedContent:b.special(b.name),ColorLiteral:b.color,StringLiteral:b.string,":":b.punctuation,"PseudoOp #":b.derefOperator,"; ,":b.separator,"( )":b.paren,"[ ]":b.squareBracket,"{ }":b.brace}),jC={__proto__:null,lang:32,"nth-child":32,"nth-last-child":32,"nth-of-type":32,"nth-last-of-type":32,dir:32,"host-context":32,url:60,"url-prefix":60,domain:60,regexp:60,selector:134},zC={__proto__:null,"@import":114,"@media":138,"@charset":142,"@namespace":146,"@keyframes":152,"@supports":164},FC={__proto__:null,not:128,only:128,from:158,to:160},_C=Ps.deserialize({version:14,states:"7WQYQ[OOO#_Q[OOOOQP'#Cd'#CdOOQP'#Cc'#CcO#fQ[O'#CfO$YQXO'#CaO$aQ[O'#ChO$lQ[O'#DPO$qQ[O'#DTOOQP'#Ed'#EdO$vQdO'#DeO%bQ[O'#DrO$vQdO'#DtO%sQ[O'#DvO&OQ[O'#DyO&TQ[O'#EPO&cQ[O'#EROOQS'#Ec'#EcOOQS'#ET'#ETQYQ[OOO&jQXO'#CdO'_QWO'#DaO'dQWO'#EjO'oQ[O'#EjQOQWOOOOQP'#Cg'#CgOOQP,59Q,59QO#fQ[O,59QO'yQ[O'#EWO(eQWO,58{O(mQ[O,59SO$lQ[O,59kO$qQ[O,59oO'yQ[O,59sO'yQ[O,59uO'yQ[O,59vO(xQ[O'#D`OOQS,58{,58{OOQP'#Ck'#CkOOQO'#C}'#C}OOQP,59S,59SO)PQWO,59SO)UQWO,59SOOQP'#DR'#DROOQP,59k,59kOOQO'#DV'#DVO)ZQ`O,59oOOQS'#Cp'#CpO$vQdO'#CqO)cQvO'#CsO*pQtO,5:POOQO'#Cx'#CxO)UQWO'#CwO+UQWO'#CyOOQS'#Eg'#EgOOQO'#Dh'#DhO+ZQ[O'#DoO+iQWO'#EkO&TQ[O'#DmO+wQWO'#DpOOQO'#El'#ElO(hQWO,5:^O+|QpO,5:`OOQS'#Dx'#DxO,UQWO,5:bO,ZQ[O,5:bOOQO'#D{'#D{O,cQWO,5:eO,hQWO,5:kO,pQWO,5:mOOQS-E8R-E8RO$vQdO,59{O,xQ[O'#EYO-VQWO,5;UO-VQWO,5;UOOQP1G.l1G.lO-|QXO,5:rOOQO-E8U-E8UOOQS1G.g1G.gOOQP1G.n1G.nO)PQWO1G.nO)UQWO1G.nOOQP1G/V1G/VO.ZQ`O1G/ZO.tQXO1G/_O/[QXO1G/aO/rQXO1G/bO0YQWO,59zO0_Q[O'#DOO0fQdO'#CoOOQP1G/Z1G/ZO$vQdO1G/ZO0mQpO,59]OOQS,59_,59_O$vQdO,59aO0uQWO1G/kOOQS,59c,59cO0zQ!bO,59eO1SQWO'#DhO1_QWO,5:TO1dQWO,5:ZO&TQ[O,5:VO&TQ[O'#EZO1lQWO,5;VO1wQWO,5:XO'yQ[O,5:[OOQS1G/x1G/xOOQS1G/z1G/zOOQS1G/|1G/|O2YQWO1G/|O2_QdO'#D|OOQS1G0P1G0POOQS1G0V1G0VOOQS1G0X1G0XO2mQtO1G/gOOQO,5:t,5:tO3TQ[O,5:tOOQO-E8W-E8WO3bQWO1G0pOOQP7+$Y7+$YOOQP7+$u7+$uO$vQdO7+$uOOQS1G/f1G/fO3mQXO'#EiO3tQWO,59jO3yQtO'#EUO4nQdO'#EfO4xQWO,59ZO4}QpO7+$uOOQS1G.w1G.wOOQS1G.{1G.{OOQS7+%V7+%VO5VQWO1G/PO$vQdO1G/oOOQO1G/u1G/uOOQO1G/q1G/qO5[QWO,5:uOOQO-E8X-E8XO5jQXO1G/vOOQS7+%h7+%hO5qQYO'#CsO(hQWO'#E[O5yQdO,5:hOOQS,5:h,5:hO6XQtO'#EXO$vQdO'#EXO7VQdO7+%ROOQO7+%R7+%ROOQO1G0`1G0`O7jQpO<T![;'S%^;'S;=`%o<%lO%^^;TUoWOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^^;nYoW#[UOy%^z!Q%^!Q![;g![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^^[[oW#[UOy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^_?VSpVOy%^z;'S%^;'S;=`%o<%lO%^^?hWjSOy%^z!O%^!O!P;O!P!Q%^!Q![>T![;'S%^;'S;=`%o<%lO%^_@VU#XPOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^~@nTjSOy%^z{@}{;'S%^;'S;=`%o<%lO%^~ASUoWOy@}yzAfz{Bm{;'S@};'S;=`Co<%lO@}~AiTOzAfz{Ax{;'SAf;'S;=`Bg<%lOAf~A{VOzAfz{Ax{!PAf!P!QBb!Q;'SAf;'S;=`Bg<%lOAf~BgOR~~BjP;=`<%lAf~BrWoWOy@}yzAfz{Bm{!P@}!P!QC[!Q;'S@};'S;=`Co<%lO@}~CcSoWR~Oy%^z;'S%^;'S;=`%o<%lO%^~CrP;=`<%l@}^Cz[#[UOy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^XDuU]POy%^z![%^![!]EX!];'S%^;'S;=`%o<%lO%^XE`S^PoWOy%^z;'S%^;'S;=`%o<%lO%^_EqS!WVOy%^z;'S%^;'S;=`%o<%lO%^YFSSzQOy%^z;'S%^;'S;=`%o<%lO%^XFeU|POy%^z!`%^!`!aFw!a;'S%^;'S;=`%o<%lO%^XGOS|PoWOy%^z;'S%^;'S;=`%o<%lO%^XG_WOy%^z!c%^!c!}Gw!}#T%^#T#oGw#o;'S%^;'S;=`%o<%lO%^XHO[!YPoWOy%^z}%^}!OGw!O!Q%^!Q![Gw![!c%^!c!}Gw!}#T%^#T#oGw#o;'S%^;'S;=`%o<%lO%^XHySxPOy%^z;'S%^;'S;=`%o<%lO%^^I[SvUOy%^z;'S%^;'S;=`%o<%lO%^XIkUOy%^z#b%^#b#cI}#c;'S%^;'S;=`%o<%lO%^XJSUoWOy%^z#W%^#W#XJf#X;'S%^;'S;=`%o<%lO%^XJmS!`PoWOy%^z;'S%^;'S;=`%o<%lO%^XJ|UOy%^z#f%^#f#gJf#g;'S%^;'S;=`%o<%lO%^XKeS!RPOy%^z;'S%^;'S;=`%o<%lO%^_KvS!QVOy%^z;'S%^;'S;=`%o<%lO%^ZLXU!PPOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^WLnP;=`<%l$}",tokenizers:[UC,ZC,XC,0,1,2,3],topRules:{StyleSheet:[0,4],Styles:[1,84]},specialized:[{term:95,get:n=>jC[n]||-1},{term:56,get:n=>zC[n]||-1},{term:96,get:n=>FC[n]||-1}],tokenPrec:1123});let cc=null;function uc(){if(!cc&&typeof document=="object"&&document.body){let n=[];for(let e in document.body.style)/[A-Z]|^-|^(item|length)$/.test(e)||n.push(e);cc=n.sort().map(e=>({type:"property",label:e}))}return cc||[]}const om=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(n=>({type:"class",label:n})),am=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(n=>({type:"keyword",label:n})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(n=>({type:"constant",label:n}))),GC=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(n=>({type:"type",label:n})),Fn=/^[\w-]*/,JC=n=>{let{state:e,pos:t}=n,i=pe(e).resolveInner(t,-1);if(i.name=="PropertyName")return{from:i.from,options:uc(),validFor:Fn};if(i.name=="ValueName")return{from:i.from,options:am,validFor:Fn};if(i.name=="PseudoClassName")return{from:i.from,options:om,validFor:Fn};if(i.name=="TagName"){for(let{parent:o}=i;o;o=o.parent)if(o.name=="Block")return{from:i.from,options:uc(),validFor:Fn};return{from:i.from,options:GC,validFor:Fn}}if(!n.explicit)return null;let r=i.resolve(t),s=r.childBefore(t);return s&&s.name==":"&&r.name=="PseudoClassSelector"?{from:t,options:om,validFor:Fn}:s&&s.name==":"&&r.name=="Declaration"||r.name=="ArgList"?{from:t,options:am,validFor:Fn}:r.name=="Block"?{from:t,options:uc(),validFor:Fn}:null},Hl=vs.define({name:"css",parser:_C.configure({props:[Go.add({Declaration:Ja()}),Jo.add({Block:uy})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function YC(){return new Ro(Hl,Hl.data.of({autocomplete:JC}))}const HC=1,lm=294,hm=2,KC=3,Ra=295,eI=4,tI=296,cm=297,iI=299,nI=300,rI=5,sI=6,oI=1,aI=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],nS=125,lI=123,hI=59,um=47,cI=42,uI=43,fI=45,dI=36,pI=96,gI=92,mI=new Zb({start:!1,shift(n,e){return e==rI||e==sI||e==iI?n:e==nI},strict:!1}),OI=new ii((n,e)=>{let{next:t}=n;(t==nS||t==-1||e.context)&&e.canShift(cm)&&n.acceptToken(cm)},{contextual:!0,fallback:!0}),yI=new ii((n,e)=>{let{next:t}=n,i;aI.indexOf(t)>-1||t==um&&((i=n.peek(1))==um||i==cI)||t!=nS&&t!=hI&&t!=-1&&!e.context&&e.canShift(lm)&&n.acceptToken(lm)},{contextual:!0}),bI=new ii((n,e)=>{let{next:t}=n;if((t==uI||t==fI)&&(n.advance(),t==n.next)){n.advance();let i=!e.context&&e.canShift(hm);n.acceptToken(i?hm:KC)}},{contextual:!0}),SI=new ii(n=>{for(let e=!1,t=0;;t++){let{next:i}=n;if(i<0){t&&n.acceptToken(Ra);break}else if(i==pI){t?n.acceptToken(Ra):n.acceptToken(tI,1);break}else if(i==lI&&e){t==1?n.acceptToken(eI,1):n.acceptToken(Ra,-1);break}else if(i==10&&t){n.advance(),n.acceptToken(Ra);break}else i==gI&&n.advance();e=i==dI,n.advance()}}),wI=new ii((n,e)=>{if(!(n.next!=101||!e.dialectEnabled(oI))){n.advance();for(let t=0;t<6;t++){if(n.next!="xtends".charCodeAt(t))return;n.advance()}n.next>=57&&n.next<=65||n.next>=48&&n.next<=90||n.next==95||n.next>=97&&n.next<=122||n.next>160||n.acceptToken(HC)}}),vI=Cs({"get set async static":b.modifier,"for while do if else switch try catch finally return throw break continue default case":b.controlKeyword,"in of await yield void typeof delete instanceof":b.operatorKeyword,"let var const function class extends":b.definitionKeyword,"import export from":b.moduleKeyword,"with debugger as new":b.keyword,TemplateString:b.special(b.string),super:b.atom,BooleanLiteral:b.bool,this:b.self,null:b.null,Star:b.modifier,VariableName:b.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":b.function(b.variableName),VariableDefinition:b.definition(b.variableName),Label:b.labelName,PropertyName:b.propertyName,PrivatePropertyName:b.special(b.propertyName),"CallExpression/MemberExpression/PropertyName":b.function(b.propertyName),"FunctionDeclaration/VariableDefinition":b.function(b.definition(b.variableName)),"ClassDeclaration/VariableDefinition":b.definition(b.className),PropertyDefinition:b.definition(b.propertyName),PrivatePropertyDefinition:b.definition(b.special(b.propertyName)),UpdateOp:b.updateOperator,LineComment:b.lineComment,BlockComment:b.blockComment,Number:b.number,String:b.string,ArithOp:b.arithmeticOperator,LogicOp:b.logicOperator,BitOp:b.bitwiseOperator,CompareOp:b.compareOperator,RegExp:b.regexp,Equals:b.definitionOperator,Arrow:b.function(b.punctuation),": Spread":b.punctuation,"( )":b.paren,"[ ]":b.squareBracket,"{ }":b.brace,"InterpolationStart InterpolationEnd":b.special(b.brace),".":b.derefOperator,", ;":b.separator,"@":b.meta,TypeName:b.typeName,TypeDefinition:b.definition(b.typeName),"type enum interface implements namespace module declare":b.definitionKeyword,"abstract global Privacy readonly override":b.modifier,"is keyof unique infer":b.operatorKeyword,JSXAttributeValue:b.attributeValue,JSXText:b.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":b.angleBracket,"JSXIdentifier JSXNameSpacedName":b.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":b.attributeName,"JSXBuiltin/JSXIdentifier":b.standard(b.tagName)}),kI={__proto__:null,export:18,as:23,from:29,default:32,async:37,function:38,this:50,true:58,false:58,null:68,void:72,typeof:76,super:92,new:126,await:143,yield:145,delete:146,class:156,extends:158,public:213,private:213,protected:213,readonly:215,instanceof:234,satisfies:237,in:238,const:240,import:272,keyof:327,unique:331,infer:337,is:373,abstract:393,implements:395,type:397,let:400,var:402,interface:409,enum:413,namespace:419,module:421,declare:425,global:429,for:450,of:459,while:462,with:466,do:470,if:474,else:476,switch:480,case:486,try:492,catch:496,finally:500,return:504,throw:508,break:512,continue:516,debugger:520},xI={__proto__:null,async:113,get:115,set:117,public:175,private:175,protected:175,static:177,abstract:179,override:181,readonly:187,accessor:189,new:377},TI={__proto__:null,"<":133},QI=Ps.deserialize({version:14,states:"$CWO`QdOOO$}QdOOO)WQ(C|O'#ChO)_OWO'#DYO+jQdO'#D_O+zQdO'#DjO$}QdO'#DtO.OQdO'#DzOOQ(C['#ET'#ETO.fQ`O'#EQOOQO'#IW'#IWO.nQ`O'#GgOOQO'#Ee'#EeO.yQ`O'#EdO/OQ`O'#EdO1QQ(C|O'#JQO3nQ(C|O'#JRO4_Q`O'#FSO4dQ!bO'#FkOOQ(C['#F['#F[O4oO#tO'#F[O4}Q&jO'#FrO6bQ`O'#FqOOQ(C['#JR'#JROOQ(CW'#JQ'#JQOOQS'#Jk'#JkO6gQ`O'#H{O6lQ(ChO'#H|OOQS'#Iu'#IuOOQS'#IO'#IOQ`QdOOO$}QdO'#DlO6tQ`O'#GgO6yQ&jO'#CmO7XQ`O'#EcO7dQ`O'#EnO7iQ&jO'#FZO8TQ`O'#GgO8YQ`O'#GkO8eQ`O'#GkO8sQ`O'#GnO8sQ`O'#GoO8sQ`O'#GqO6tQ`O'#GtO9dQ`O'#GwO:uQ`O'#CdO;VQ`O'#HUO;_Q`O'#H[O;_Q`O'#H^O`QdO'#H`O;_Q`O'#HbO;_Q`O'#HeO;dQ`O'#HkO;iQ(CjO'#HqO$}QdO'#HsO;tQ(CjO'#HuOWQpO'#FZO$}QdO'#DZOOOW'#IQ'#IQO>`OWO,59tOOQ(C[,59t,59tO>kQdO'#IRO?OQ`O'#JSOAQQtO'#JSO)jQdO'#JSOAXQ`O,59yOAoQ`O'#EeOA|Q`O'#J`OBXQ`O'#J_OBXQ`O'#J_OBaQ`O,5;ROBfQ`O'#J^OOQ(C[,5:U,5:UOBmQdO,5:UODnQ(C|O,5:`OE_Q`O,5:fOEdQ`O'#J[OF^Q(ChO'#J]O8YQ`O'#J[OFeQ`O'#J[OFmQ`O,5;QOFrQ`O'#J[OOQ(C]'#Ch'#ChO$}QdO'#DzOGfQpO,5:lOOQO'#JX'#JXOOQO-EgOOQS'#Ix'#IxOOQS,5>h,5>hOOQS-E;|-E;|O!.xQ(C|O,5:WOOQ(CX'#Cp'#CpO!/lQ&kO,5=ROOQO'#Cf'#CfO!/}Q(ChO'#IyO6bQ`O'#IyO;dQ`O,59XO!0`Q!bO,59XO!0hQ&jO,59XO6yQ&jO,59XO!0sQ`O,5;OO!0{Q`O'#HTO!1ZQ`O'#JoO$}QdO,5;sO!1cQ,UO,5;uO!1hQ`O,5=nO!1mQ`O,5=nO!1rQ`O,5=nO6lQ(ChO,5=nO!2QQ`O'#EgO!2wQ,UO'#EhOOQ(CW'#J^'#J^O!3OQ(ChO'#JlO6lQ(ChO,5=VO8sQ`O,5=]OOQP'#Cs'#CsO!3ZQ!bO,5=YO!3cQ!cO,5=ZO!3nQ`O,5=]O!3sQpO,5=`O;dQ`O'#GyO6tQ`O'#G{O!3{Q`O'#G{O6yQ&jO'#HOO!4QQ`O'#HOOOQS,5=c,5=cO!4VQ`O'#HPO!4_Q`O'#CmO!4dQ`O,59OO!4nQ`O,59OO!6sQdO,59OOOQS,59O,59OO!7QQ(ChO,59OO$}QdO,59OO!7]QdO'#HWOOQS'#HX'#HXOOQS'#HY'#HYO`QdO,5=pO!7mQ`O,5=pO`QdO,5=vO`QdO,5=xO!7rQ`O,5=zO`QdO,5=|O!7wQ`O,5>PO!7|QdO,5>VOOQS,5>],5>]O$}QdO,5>]O6lQ(ChO,5>_OOQS,5>a,5>aO!aOOQS,5>c,5>cO!cOOQS,5>e,5>eO!mO)jQdO,5>mOOQO,5>s,5>sO!CUQdO'#IROOQO-ExOOQ(CW-E<[-E<[O#5]Q(C}O1G0tOOQ(C[1G0t1G0tO#7hQ(C|O1G1YO#8[Q!bO,5;}O#8dQ!bO,5OQ,UO'#GXOOQ(C],5=Q,5=QOKhQ&jO,5?hOKhQ&jO,5?hO#>TQ`O'#IcO#>`Q`O,5?gO#>hQ`O,59^O#?XQ&kO,59mOOQ(C],59m,59mO#?zQ&kO,5<`O#@mQ&kO,5mO$)XQ`O1G5YO$)aQ`O1G5eO$)iQtO1G5fO8YQ`O,5>sO$)sQ`O1G5bO$)sQ`O1G5bO8YQ`O1G5bO$){Q(C|O1G5cO$}QdO1G5cO$*]Q(ChO1G5cO$*nQ`O,5>uO8YQ`O,5>uOOQO,5>u,5>uO$+SQ`O,5>uOOQO-Ez,5>zO$8rQ`O,5>zOOQ(C]1G2Z1G2ZP$8wQ`O'#I`POQ(C]-E<^-E<^O$9hQ&kO1G2gO$:ZQ&kO1G2iO$:eQqO1G2kOOQ(C]1G2S1G2SO$:lQ`O'#I_O$:zQ`O,5@SO$:zQ`O,5@SO$;SQ`O,5@SO$;_Q`O,5@SOOQO1G2U1G2UO$;mQ&kO1G2TOKhQ&jO1G2TO$;}QMhO'#IaO$<_Q`O,5@TOJRQ&jO,5@TO$|,5>|OOQO-E<`-E<`OOQ(C]1G2]1G2]O!)dQ,UO,5},5>}OOQO-EkQqO'#JjO$(iQ`O7+(XO$>uQ`O7+(XO$>}QqO7+(XO$?XQ(CyO'#ChO$?lQ(CyO,5ROOQS,5>R,5>RO$}QdO'#HhO$EoQ`O'#HjOOQS,5>X,5>XO8YQ`O,5>XOOQS,5>Z,5>ZOOQS7+)]7+)]OOQS7+)c7+)cOOQS7+)g7+)gOOQS7+)i7+)iO$EtQ!bO1G5[O$FYQ!LUO1G0oO$FdQ`O1G0oOOQO1G/k1G/kO$FoQ!LUO1G/kO$FyQ`O,5?pO;dQ`O1G/kOMqQdO'#DeOOQO,5>n,5>nOOQO-Et,5>tOOQO-EoOOQO-EpO$}QdO,5>pOOQO-ExOOOO7+'_7+'_OOOW1G/S1G/SOOQ(C]1G4f1G4fOKhQ&jO7+(VO%7}Q`O,5>yO6tQ`O,5>yOOQO-E<]-E<]O%8]Q`O1G5nO%8]Q`O1G5nO%8eQ`O1G5nO%8pQ&kO7+'oO%9QQqO,5>{O%9[Q`O,5>{OJRQ&jO,5>{OOQO-E<_-E<_O%9aQqO1G5oO%9kQ`O1G5oOOQ(CW1G2_1G2_O$VQdO'#JUO%>^Q,UO'#E[O%>tQ(ChO'#E[O$$sQ(DjO'#E[O$%hQ,UO'#G}OOQO'#Ih'#IhO%?YQ,UO,5=hOOQS,5=h,5=hO%?aQ,UO'#E[O%?rQ,UO'#E[O%@YQ,UO'#E[O%@vQ,UO'#G}O%AXQ`O7+(mO%A^Q`O7+(mO%AfQqO7+(mOOQS7+(m7+(mOJRQ&jO7+(mO$}QdO7+(mOJRQ&jO7+(mO%ApQaO7+(mOOQS7+(p7+(pO6lQ(ChO7+(pO#=PQ`O7+(pO6bQ`O7+(pO!0`Q!bO7+(pO%BOQ`O,5?TOOQO-ESOOQS,5>U,5>UO%CYQ`O1G3sO8YQ`O7+&ZOMqQdO7+&ZOOQ(CW1G5[1G5[OOQO7+%V7+%VO%C_Q!LUO1G5fO;dQ`O7+%VO;dQ`O1G0VOOQO1G0b1G0bO$}QdO1G0bO%CiQ(ChO1G0bO%CtQ(ChO1G0bO!0`Q!bO1G0VO$%_Q,UO1G0VO%DSQ,UO1G0VO%DaQ(DjO1G0bO%D{Q,UO1G0VO$%_Q,UO1G0bO%E]Q,UO1G0bO%EvQ(ChO1G0bOOQO1G0V1G0VO%F[Q(C|O1G0bOOQ(C[<VQdO,5iQ!LVO7+'qO&@_Q&kOG26wOOQO<wAN>wO;dQ`OAN>wO$}QdOAN?SO!0`Q!bOAN>wO&ATQ(ChOAN?SO$%_Q,UOAN>wO&A`Q(ChOAN?SOOQS!$(!P!$(!PO$(iQ`O!$(!PO&AnQ(C}OG26wOOQ(CWG26lG26lOOQO<SO!T+rO!U'wX~O!U+tO~O!_+kO#T+jO!T#]X!U#]X~O!T+uO!U(TX~O!U+wO~O]&VOl&VO{+nO'k$vO's)TO~O!Z+xO![+xO~P!AQO_+}O!U,PO!Y,QO!Z+|O![+|O!u;WO!y,UO!z,SO!{,TO!|,RO#P,VO#Q,VO'|+zO~P!AQOP,[O!V&cO!q,ZO~Oo,aO~O!Q&ua!T&ua~P!-RO!S,eO!Q&uX!T&uX~P$}O!T&rO!Q'va~O!Q'va~P?WO!T&yO!Q(Ra~O{%WO!S,iO!V%XO'j$tO!Q&{X!T&{X~O!T'WO!e(Oa~O{%WO!V%XO#_,lO'j$tO~O#T,nO!T(Pa!e(Pa_(Pa'e(Pa~O!_#UO~P!DvO{%WO!S,qO!V%XO!uXO#^,sO#_,qO'j$tO!T&}X!e&}X~Oy,wO!f#XO~OP,{O!V&cO!q,zO%],yO'n$bO~O_#Wi!T#Wi'e#Wi'a#Wi!Q#Wi!e#Wio#Wi!V#Wi%]#Wi!_#Wi~P!-ROP=mOx(mO{(nO(U(pO(V(rO~O#`#Sa!T#Sa!e#Sa#T#Sa!V#Sa_#Sa'e#Sa!Q#Sa~P!G[O!d#WOP'qXx'qX{'qX(U'qX(V'qXQ'qXZ'qXk'qXy'qX!T'qX!c'qX!f'qX!l'qX#c'qX#d'qX#e'qX#f'qX#g'qX#h'qX#i'qX#j'qX#k'qX#m'qX#o'qX#q'qX#r'qX'r'qX'}'qX~O#`'qX_'qX'e'qX!e'qX!Q'qX'a'qX!V'qX#T'qXo'qX%]'qX!_'qX~P!HZO!T-UOe'yX~P!&VOe-WO~O!T-XO!e'zX~P!-RO!e-[O~O!Q-^O~OQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO'rROZ#bi_#bik#bi!T#bi!c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O#c#bi~P!KrO#c#_O~P!KrOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O'rROZ#bi_#bi!T#bi!c#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~Ok#bi~P!NdOk#aO~P!NdOQ#lOk#aOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO'rRO_#bi!T#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~OZ#bi!c#bi#h#bi#i#bi#j#bi#k#bi~P##UOZ#sO!c#cO#h#cO#i#cO#j#rO#k#cO~P##UOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO'rRO_#bi!T#bi#o#bi#q#bi#r#bi'e#bi'}#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O(U#bi~P#&VO(U#]O~P#&VOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO#o#fO'rRO(U#]O_#bi!T#bi#q#bi#r#bi'e#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O(V#bi~P#(wO(V#^O~P#(wOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO#o#fO#q#hO'rRO(U#]O(V#^O~O_#bi!T#bi#r#bi'e#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~P#+iOQ[XZ[Xk[Xx[Xy[X{[X!c[X!d[X!f[X!l[X#T[X#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X!T[X!U[X~O#u[X~P#.SOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO#q;hO#r;iO'rRO'}#jO(U#]O(V#^O~O#u-`O~P#0aOQ'uXZ'uXk'uXx'uXy'uX{'uX!c'uX!d'uX!f'uX!l'uX#c'uX#d'uX#e'uX#f'uX#g'uX#h'uX#i'uX#j'uX#m'uX#o'uX#q'uX#r'uX'r'uX'}'uX(U'uX(V'uX!T'uX~O#T;nO#w;nO#k'uX#u'uX!U'uX~P#2_O_'Qa!T'Qa'e'Qa'a'Qa!e'Qao'Qa!Q'Qa!V'Qa%]'Qa!_'Qa~P!-ROQ#biZ#bi_#bik#biy#bi!T#bi!c#bi!d#bi!f#bi!l#bi#c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'r#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~P!G[O_#vi!T#vi'e#vi'a#vi!Q#vi!e#vio#vi!V#vi%]#vi!_#vi~P!-RO$S-cO$U-cO~O$S-dO$U-dO~O!_(VO#T-eO!V$YX$P$YX$S$YX$U$YX$]$YX~O!S-fO~O!V(YO$P-hO$S(XO$U(XO$]-iO~O!T;jO!U'tX~P#0aO!U-jO~O$]-lO~OS(hO'c(iO'd-oO~O]-rOl-rO!Q-sO~O!TdX!_dX!edX!e$oX'}dX~P!$|O!e-yO~P!G[O!T-zO!_#UO'}'SO!e([X~O!e.PO~O!S(yO'j$tO!e([P~O#`.RO~O!Q$oX!T$oX!_$vX~P!$|O!T.SO!Q(]X~P!G[O!_.UO~O!Q.WO~Ok.[O!_#UO!f$mO'n$bO'}'SO~O'j.^O~O!_)yO~O_$pO!T.bO'e$pO~O!U.dO~P!(wO!Z.eO![.eO'k$vO's)TO~O{.gO's)TO~O#P.hO~O'j%^Oe'VX!T'VX~O!T)dOe'oa~Oe.mO~Ox.nOy.nO{.oOPua(Uua(Vua!Tua#Tua~Oeua#uua~P#>mOx(mO{(nOP$ha(U$ha(V$ha!T$ha#T$ha~Oe$ha#u$ha~P#?cOx(mO{(nOP$ja(U$ja(V$ja!T$ja#T$ja~Oe$ja#u$ja~P#@UO].pO~O#`.qO~Oe$xa!T$xa#T$xa#u$xa~P!&VO#`.tO~OP,{O!V&cO!q,zO%],yO~O]$SOk$TOl$SOm$SOr$dOt$eOv;oO{$[O!V$]O!a=`O!f$XO#_;xO#|$iO$i;rO$k;uO$n$jO'n$bO'r$UO~Oi.{O'j.zO~P#AvO!_)yO!V'ma_'ma!T'ma'e'ma~O#`/RO~OZ[X!TdX!UdX~O!T/SO!U(dX~O!U/UO~OZ/VO~O]/XO'j*RO~O!V%OO'j$tO^'_X!T'_X~O!T*WO^(ca~O!e/[O~P!-RO]/^O~OZ/_O~O^/`O~O!T*dO_(`a'e(`a~O#T/fO~OP/iO!V$]O~O's'lO!U(aP~OP/sO!V/oO!q/rO%]/qO'n$bO~OZ/}O!T/{O!U(bX~O!U0OO~O^0QO_$pO'e$pO~O]0RO~O]0SO'j!|O~O#k0TO%}0UO~P1nO#T#tO#k0TO%}0UO~O_0VO~P$}O_0XO~O&W0]OQ&UiR&UiX&Ui]&Ui_&Uib&Uic&Uii&Uik&Uil&Uim&Uir&Uit&Uiv&Ui{&Ui!O&Ui!P&Ui!V&Ui!a&Ui!f&Ui!i&Ui!j&Ui!k&Ui!l&Ui!m&Ui!p&Ui!u&Ui#l&Ui#|&Ui$Q&Ui%[&Ui%^&Ui%`&Ui%a&Ui%d&Ui%f&Ui%i&Ui%j&Ui%l&Ui%y&Ui&P&Ui&R&Ui&T&Ui&V&Ui&Y&Ui&`&Ui&f&Ui&h&Ui&j&Ui&l&Ui&n&Ui'a&Ui'j&Ui'r&Ui'|&Ui(Z&Ui!U&Ui`&Ui&]&Ui~O`0cO!U0aO&]0bO~P`O!VTO!f0eO~O&d+aOQ&_iR&_iX&_i]&_i_&_ib&_ic&_ii&_ik&_il&_im&_ir&_it&_iv&_i{&_i!O&_i!P&_i!V&_i!a&_i!f&_i!i&_i!j&_i!k&_i!l&_i!m&_i!p&_i!u&_i#l&_i#|&_i$Q&_i%[&_i%^&_i%`&_i%a&_i%d&_i%f&_i%i&_i%j&_i%l&_i%y&_i&P&_i&R&_i&T&_i&V&_i&Y&_i&`&_i&f&_i&h&_i&j&_i&l&_i&n&_i'a&_i'j&_i'r&_i'|&_i(Z&_i!U&_i&W&_i`&_i&]&_i~O!Q0kO~O!T!Xa!U!Xa~P#0aO!S0rO!Y&bO!Z&ZO![&ZO!T&vX!U&vX~P!AQO!T+rO!U'wa~O!T&|X!U&|X~P!2fO!T+uO!U(Ta~O!Y0{O!Z0zO![0zO!u;WO!y1OO!z0}O!{0}O!|0|O#P1PO#Q1PO'|+zO~P!AQO_$pO!_#UO!f$mO!l1UO#T1SO'e$pO'n$bO'}'SO~O]&VOl&VO{+nO's)TO'|+zO~O_+}O!U1XO!Y,QO!Z+|O![+|O!u;WO!y,UO!z,SO!{,TO!|,RO#P,VO#Q,VO'|+zO~P!AQO!Z0zO![0zO'|+zO~P!AQO!Y0{O!Z0zO![0zO'|+zO~P!AQO!VTO!Y0{O!Z0zO![0zO!|0|O#P1PO#Q1PO'|+zO~P!AQO!Y0{O!Z0zO![0zO!z0}O!{0}O!|0|O#P1PO#Q1PO'|+zO~P!AQO!V&cO~O!V&cO~P!G[O!T#pOo$ga~O!Q&ui!T&ui~P!-RO!T&rO!Q'vi~O!T&yO!Q(Ri~O!Q(Si!T(Si~P!-RO!T'WO!e(Oi~O!T(Pi!e(Pi_(Pi'e(Pi~P!-RO#T1eO!T(Pi!e(Pi_(Pi'e(Pi~O{%WO!V%XO!uXO#^1hO#_1gO'j$tO~O{%WO!V%XO#_1gO'j$tO~OP1pO!V&cO!q1oO%]1nO~OP1pO!V&cO!q1oO%]1nO'n$bO~O#`uaQuaZua_uakua!cua!dua!fua!lua#cua#dua#eua#fua#gua#hua#iua#jua#kua#mua#oua#qua#rua'eua'rua'}ua!eua!Qua'aua!Vuaoua%]ua!_ua~P#>mO#`$haQ$haZ$ha_$hak$hay$ha!c$ha!d$ha!f$ha!l$ha#c$ha#d$ha#e$ha#f$ha#g$ha#h$ha#i$ha#j$ha#k$ha#m$ha#o$ha#q$ha#r$ha'e$ha'r$ha'}$ha!e$ha!Q$ha'a$ha!V$hao$ha%]$ha!_$ha~P#?cO#`$jaQ$jaZ$ja_$jak$jay$ja!c$ja!d$ja!f$ja!l$ja#c$ja#d$ja#e$ja#f$ja#g$ja#h$ja#i$ja#j$ja#k$ja#m$ja#o$ja#q$ja#r$ja'e$ja'r$ja'}$ja!e$ja!Q$ja'a$ja!V$jao$ja%]$ja!_$ja~P#@UO#`$xaQ$xaZ$xa_$xak$xay$xa!T$xa!c$xa!d$xa!f$xa!l$xa#c$xa#d$xa#e$xa#f$xa#g$xa#h$xa#i$xa#j$xa#k$xa#m$xa#o$xa#q$xa#r$xa'e$xa'r$xa'}$xa!e$xa!Q$xa'a$xa!V$xa#T$xao$xa%]$xa!_$xa~P!G[O_#Wq!T#Wq'e#Wq'a#Wq!Q#Wq!e#Wqo#Wq!V#Wq%]#Wq!_#Wq~P!-ROe&wX!T&wX~PKhO!T-UOe'ya~O!S1xO!T&xX!e&xX~P$}O!T-XO!e'za~O!T-XO!e'za~P!-RO!Q1{O~O#u!ha!U!ha~PBtO#u!`a!T!`a!U!`a~P#0aO!V2^O$QbO$Z2_O~O!U2cO~Oo2dO~P!G[O_$dq!T$dq'e$dq'a$dq!Q$dq!e$dqo$dq!V$dq%]$dq!_$dq~P!-RO!Q2eO~O]-rOl-rO~Ox(mO{(nO(V(rOP%Ti(U%Ti!T%Ti#T%Ti~Oe%Ti#u%Ti~P$9POx(mO{(nOP%Vi(U%Vi(V%Vi!T%Vi#T%Vi~Oe%Vi#u%Vi~P$9rO'}#jO~P!G[O!S2hO'j$tO!T'RX!e'RX~O!T-zO!e([a~O!T-zO!_#UO!e([a~O!T-zO!_#UO'}'SO!e([a~Oe$qi!T$qi#T$qi#u$qi~P!&VO!S2pO'j)OO!Q'TX!T'TX~P!&tO!T.SO!Q(]a~O!T.SO!Q(]a~P!G[O!_#UO~O!_#UO#k2xO~Ok2{O!_#UO'}'SO~Oe'pi!T'pi~P!&VO#T3OOe'pi!T'pi~P!&VO!e3RO~O_$eq!T$eq'e$eq'a$eq!Q$eq!e$eqo$eq!V$eq%]$eq!_$eq~P!-RO!T3VO!V(^X~P!G[O!V&cO%]1nO~O!V&cO%]1nO~P!G[O!V$oX%Q[X_$oX!T$oX'e$oX~P!$|O%Q3XOPhXxhX{hX!VhX(UhX(VhX_hX!ThX'ehX~O%Q3XO~O]3_O%^3`O'j*RO!T'^X!U'^X~O!T/SO!U(da~OZ3dO~O^3eO~O]3hO~O!Q3iO~O_$pO'e$pO~P!G[O!V$]O~P!G[O!T3nO#T3pO!U(aX~O!U3qO~O]&VOl&VO{3sO!Y4OO!Z3wO![3wO!u;WO!y3}O!z3|O!{3|O#P3{O#Q,VO'k$vO's)TO'|+zO~O!U3zO~P$BTOP4VO!V/oO!q4UO%]4TO~OP4VO!V/oO!q4UO%]4TO'n$bO~O'j!|O!T']X!U']X~O!T/{O!U(ba~O]4aO's4`O~O]4bO~O^4dO~O!e4gO~P$}O_4iO~O_4iO~P$}O#k4kO%}4lO~PExO`0cO!U4pO&]0bO~P`O!_4rO~O!_4tO!T'xi!U'xi!_'xi!f'xi'n'xi~O!T#]i!U#]i~P#0aO#T4uO!T#]i!U#]i~O!T!Xi!U!Xi~P#0aO!Q4vO~O]!tal!ta!Y!ta!Z!ta![!ta!y!ta!z!ta!{!ta!|!ta#P!ta#Q!ta'k!ta's!ta'|!ta~PGQO_$pO!_#UO!f$mO!l5OO#T4|O'e$pO'n$bO'}'SO~O!Z5QO![5QO'|+zO~P!AQO!Y5RO!Z5QO![5QO'|+zO~P!AQO!Y5RO!Z5QO![5QO!|5TO#P5UO#Q5UO'|+zO~P!AQO!Y5RO!Z5QO![5QO!z5VO!{5VO!|5TO#P5UO#Q5UO'|+zO~P!AQO_$pO#T4|O'e$pO~O_$pO!_#UO#T4|O'e$pO~O_$pO!_#UO!l5OO#T4|O'e$pO'}'SO~O!T'WO!e(Oq~O!T(Pq!e(Pq_(Pq'e(Pq~P!-RO{%WO!V%XO#_5aO'j$tO~O!V&cO%]5cO~O!V&cO%]5cO~P!G[OP5hO!V&cO!q5gO%]5cO~O#`%TiQ%TiZ%Ti_%Tik%Tiy%Ti!c%Ti!d%Ti!f%Ti!l%Ti#c%Ti#d%Ti#e%Ti#f%Ti#g%Ti#h%Ti#i%Ti#j%Ti#k%Ti#m%Ti#o%Ti#q%Ti#r%Ti'e%Ti'r%Ti'}%Ti!e%Ti!Q%Ti'a%Ti!V%Tio%Ti%]%Ti!_%Ti~P$9PO#`%ViQ%ViZ%Vi_%Vik%Viy%Vi!c%Vi!d%Vi!f%Vi!l%Vi#c%Vi#d%Vi#e%Vi#f%Vi#g%Vi#h%Vi#i%Vi#j%Vi#k%Vi#m%Vi#o%Vi#q%Vi#r%Vi'e%Vi'r%Vi'}%Vi!e%Vi!Q%Vi'a%Vi!V%Vio%Vi%]%Vi!_%Vi~P$9rO#`$qiQ$qiZ$qi_$qik$qiy$qi!T$qi!c$qi!d$qi!f$qi!l$qi#c$qi#d$qi#e$qi#f$qi#g$qi#h$qi#i$qi#j$qi#k$qi#m$qi#o$qi#q$qi#r$qi'e$qi'r$qi'}$qi!e$qi!Q$qi'a$qi!V$qi#T$qio$qi%]$qi!_$qi~P!G[Oe&wa!T&wa~P!&VO!T&xa!e&xa~P!-RO!T-XO!e'zi~O#u#Wi!T#Wi!U#Wi~P#0aOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO'rROZ#bik#bi!c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~O#c#bi~P%&nO#c;_O~P%&nOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O'rROZ#bi!c#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~Ok#bi~P%(yOk;aO~P%(yOQ#lOk;aOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO'rRO#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~OZ#bi!c#bi#h#bi#i#bi#j#bi#k#bi~P%+UOZ;mO!c;cO#h;cO#i;cO#j;lO#k;cO~P%+UOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO'rRO#o#bi#q#bi#r#bi#u#bi'}#bi(V#bi!T#bi!U#bi~O(U#bi~P%-pO(U#]O~P%-pOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO'rRO(U#]O#q#bi#r#bi#u#bi'}#bi!T#bi!U#bi~O(V#bi~P%/{O(V#^O~P%/{OQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO#q;hO'rRO(U#]O(V#^O~O#r#bi#u#bi'}#bi!T#bi!U#bi~P%2WO_#sy!T#sy'e#sy'a#sy!Q#sy!e#syo#sy!V#sy%]#sy!_#sy~P!-ROP=oOx(mO{(nO(U(pO(V(rO~OQ#biZ#bik#biy#bi!c#bi!d#bi!f#bi!l#bi#c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'r#bi'}#bi!T#bi!U#bi~P%5OO#u'qX!U'qX~P!HZO#u#vi!T#vi!U#vi~P#0aO!U5tO~O!T'Qa!U'Qa~P#0aO!_#UO'}'SO!T'Ra!e'Ra~O!T-zO!e([i~O!T-zO!_#UO!e([i~Oe$qq!T$qq#T$qq#u$qq~P!&VO!Q'Ta!T'Ta~P!G[O!_5{O~O!T.SO!Q(]i~P!G[O!T.SO!Q(]i~O!Q6PO~O!_#UO#k6UO~Ok6VO!_#UO'}'SO~O!Q6XO~Oe$sq!T$sq#T$sq#u$sq~P!&VO_$ey!T$ey'e$ey'a$ey!Q$ey!e$eyo$ey!V$ey%]$ey!_$ey~P!-RO!T3VO!V(^a~O_#Wy!T#Wy'e#Wy'a#Wy!Q#Wy!e#Wyo#Wy!V#Wy%]#Wy!_#Wy~P!-ROZ6^O~O]6`O'j*RO~O!T/SO!U(di~O]6cO~O^6dO~O!_4tO~O's'lO!T'YX!U'YX~O!T3nO!U(aa~O!f$mO'n$bO_'xX!_'xX!l'xX#T'xX'e'xX'}'xX~O'j6mO~P,RO!u;WO!y6oO!z6nO!{6nO#P1PO#Q1PO~P$%_O_$pO!_#UO!l1UO#T1SO'e$pO'}'SO~O!U6rO~P$BTO]&VOl&VO{6sO's)TO'|+zO~O!Y6wO!Z6vO![6vO#P1PO#Q1PO'|+zO~P!AQO!Y6wO!Z6vO![6vO!z6xO!{6xO#P1PO#Q1PO'|+zO~P!AQO!Z6vO![6vO'k$vO's)TO'|+zO~O!V/oO~O!V/oO%]6zO~O!V/oO%]6zO~P!G[OP7PO!V/oO!q7OO%]6zO~OZ7UO!T']a!U']a~O!T/{O!U(bi~O]7XO~O!e7YO~O!e7ZO~O!e7[O~O!e7[O~P$}O_7^O~O!_7aO~O!e7bO~O!T(Si!U(Si~P#0aO_$pO#T7iO'e$pO~O_$pO!_#UO#T7iO'e$pO~O!Z7mO![7mO'|+zO~P!AQO_$pO!_#UO!f$mO!l7nO#T7iO'e$pO'n$bO'}'SO~O!Y7oO!Z7mO![7mO'|+zO~P!AQO!Y7oO!Z7mO![7mO!|7rO#P7sO#Q7sO'|+zO~P!AQO_$pO!_#UO!l7nO#T7iO'e$pO'}'SO~O_$pO'e$pO~P!-RO!T'WO!e(Oy~O!T(Py!e(Py_(Py'e(Py~P!-RO!V&cO%]7xO~O!V&cO%]7xO~P!G[O#`$qqQ$qqZ$qq_$qqk$qqy$qq!T$qq!c$qq!d$qq!f$qq!l$qq#c$qq#d$qq#e$qq#f$qq#g$qq#h$qq#i$qq#j$qq#k$qq#m$qq#o$qq#q$qq#r$qq'e$qq'r$qq'}$qq!e$qq!Q$qq'a$qq!V$qq#T$qqo$qq%]$qq!_$qq~P!G[O#`$sqQ$sqZ$sq_$sqk$sqy$sq!T$sq!c$sq!d$sq!f$sq!l$sq#c$sq#d$sq#e$sq#f$sq#g$sq#h$sq#i$sq#j$sq#k$sq#m$sq#o$sq#q$sq#r$sq'e$sq'r$sq'}$sq!e$sq!Q$sq'a$sq!V$sq#T$sqo$sq%]$sq!_$sq~P!G[O!T&xi!e&xi~P!-RO#u#Wq!T#Wq!U#Wq~P#0aOx.nOy.nO{.oOPua(Uua(Vua!Uua~OQuaZuakua!cua!dua!fua!lua#cua#dua#eua#fua#gua#hua#iua#jua#kua#mua#oua#qua#rua#uua'rua'}ua!Tua~P%LmOx(mO{(nOP$ha(U$ha(V$ha!U$ha~OQ$haZ$hak$hay$ha!c$ha!d$ha!f$ha!l$ha#c$ha#d$ha#e$ha#f$ha#g$ha#h$ha#i$ha#j$ha#k$ha#m$ha#o$ha#q$ha#r$ha#u$ha'r$ha'}$ha!T$ha~P%NtOx(mO{(nOP$ja(U$ja(V$ja!U$ja~OQ$jaZ$jak$jay$ja!c$ja!d$ja!f$ja!l$ja#c$ja#d$ja#e$ja#f$ja#g$ja#h$ja#i$ja#j$ja#k$ja#m$ja#o$ja#q$ja#r$ja#u$ja'r$ja'}$ja!T$ja~P&!{OQ$xaZ$xak$xay$xa!c$xa!d$xa!f$xa!l$xa#c$xa#d$xa#e$xa#f$xa#g$xa#h$xa#i$xa#j$xa#k$xa#m$xa#o$xa#q$xa#r$xa#u$xa'r$xa'}$xa!T$xa!U$xa~P%5OO#u$dq!T$dq!U$dq~P#0aO#u$eq!T$eq!U$eq~P#0aO!U8RO~O#u8SO~P!&VO!_#UO!T'Ri!e'Ri~O!_#UO'}'SO!T'Ri!e'Ri~O!T-zO!e([q~O!Q'Ti!T'Ti~P!G[O!T.SO!Q(]q~O!Q8YO~P!G[O!Q8YO~Oe'py!T'py~P!&VO!T'Wa!V'Wa~P!G[O!V%Pq_%Pq!T%Pq'e%Pq~P!G[OZ8_O~O!T/SO!U(dq~O]8bO~O#T8cO!T'Ya!U'Ya~O!T3nO!U(ai~P#0aOQ[XZ[Xk[Xx[Xy[X{[X!Q[X!T[X!c[X!d[X!f[X!l[X#T[X#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X~O!_$}X#k$}X~P&*pO#P5UO#Q5UO~P$%_O!z8gO!{8gO#P5UO#Q5UO~P$%_O!Z8jO![8jO'k$vO's)TO'|+zO~O!Y8mO!Z8jO![8jO#P5UO#Q5UO'|+zO~P!AQO!V/oO%]8pO~O!V/oO%]8pO~P!G[O]8wO's8vO~O!T/{O!U(bq~O!e8yO~O!e8yO~P$}O!e8{O~O!e8|O~O#T9OO!T#]y!U#]y~O!T#]y!U#]y~P#0aO_$pO#T9RO'e$pO~O_$pO!_#UO#T9RO'e$pO~O!Z9WO![9WO'|+zO~P!AQO_$pO!_#UO!l9XO#T9RO'e$pO'}'SO~O!f$mO'n$bO~P&0|O!Y9YO!Z9WO![9WO'|+zO~P!AQO!V&cO%]9^O~O!V&cO%]9^O~P!G[O#u#sy!T#sy!U#sy~P#0aOQ$qiZ$qik$qiy$qi!c$qi!d$qi!f$qi!l$qi#c$qi#d$qi#e$qi#f$qi#g$qi#h$qi#i$qi#j$qi#k$qi#m$qi#o$qi#q$qi#r$qi#u$qi'r$qi'}$qi!T$qi!U$qi~P%5OOx(mO{(nO(V(rOP%Ti(U%Ti!U%Ti~OQ%TiZ%Tik%Tiy%Ti!c%Ti!d%Ti!f%Ti!l%Ti#c%Ti#d%Ti#e%Ti#f%Ti#g%Ti#h%Ti#i%Ti#j%Ti#k%Ti#m%Ti#o%Ti#q%Ti#r%Ti#u%Ti'r%Ti'}%Ti!T%Ti~P&4cOx(mO{(nOP%Vi(U%Vi(V%Vi!U%Vi~OQ%ViZ%Vik%Viy%Vi!c%Vi!d%Vi!f%Vi!l%Vi#c%Vi#d%Vi#e%Vi#f%Vi#g%Vi#h%Vi#i%Vi#j%Vi#k%Vi#m%Vi#o%Vi#q%Vi#r%Vi#u%Vi'r%Vi'}%Vi!T%Vi~P&6jO#u$ey!T$ey!U$ey~P#0aO#u#Wy!T#Wy!U#Wy~P#0aO!_#UO!T'Rq!e'Rq~O!T-zO!e([y~O!Q'Tq!T'Tq~P!G[O!Q9dO~P!G[O!T/SO!U(dy~O!T3nO!U(aq~O#P7sO#Q7sO~P$%_O!Z9nO![9nO'k$vO's)TO'|+zO~O!V/oO%]9qO~O!V/oO%]9qO~P!G[O!e9tO~O_$pO#T9zO'e$pO~O_$pO!_#UO#T9zO'e$pO~O!Z9}O![9}O'|+zO~P!AQO_$pO!_#UO!l:OO#T9zO'e$pO'}'SO~OQ$qqZ$qqk$qqy$qq!c$qq!d$qq!f$qq!l$qq#c$qq#d$qq#e$qq#f$qq#g$qq#h$qq#i$qq#j$qq#k$qq#m$qq#o$qq#q$qq#r$qq#u$qq'r$qq'}$qq!T$qq!U$qq~P%5OOQ$sqZ$sqk$sqy$sq!c$sq!d$sq!f$sq!l$sq#c$sq#d$sq#e$sq#f$sq#g$sq#h$sq#i$sq#j$sq#k$sq#m$sq#o$sq#q$sq#r$sq#u$sq'r$sq'}$sq!T$sq!U$sq~P%5OOe%X!Z!T%X!Z#T%X!Z#u%X!Z~P!&VO!T'Yq!U'Yq~P#0aO!T#]!Z!U#]!Z~P#0aO_$pO#T:aO'e$pO~O_$pO!_#UO#T:aO'e$pO~O#`%X!ZQ%X!ZZ%X!Z_%X!Zk%X!Zy%X!Z!T%X!Z!c%X!Z!d%X!Z!f%X!Z!l%X!Z#c%X!Z#d%X!Z#e%X!Z#f%X!Z#g%X!Z#h%X!Z#i%X!Z#j%X!Z#k%X!Z#m%X!Z#o%X!Z#q%X!Z#r%X!Z'e%X!Z'r%X!Z'}%X!Z!e%X!Z!Q%X!Z'a%X!Z!V%X!Z#T%X!Zo%X!Z%]%X!Z!_%X!Z~P!G[O_$pO#T:oO'e$pO~OP=nOx(mO{(nO(U(pO(V(rO~O]#Sal#Sa!U#Sa!Y#Sa!Z#Sa![#Sa!u#Sa!y#Sa!z#Sa!{#Sa#P#Sa#Q#Sa'k#Sa's#Sa'|#Sa~P&D[OQ%X!ZZ%X!Zk%X!Zy%X!Z!c%X!Z!d%X!Z!f%X!Z!l%X!Z#c%X!Z#d%X!Z#e%X!Z#f%X!Z#g%X!Z#h%X!Z#i%X!Z#j%X!Z#k%X!Z#m%X!Z#o%X!Z#q%X!Z#r%X!Z#u%X!Z'r%X!Z'}%X!Z!T%X!Z!U%X!Z~P%5OO]ualua!Yua!Zua![ua!uua!yua!zua!{ua#Pua#Qua'kua'sua'|ua~P%LmO]$hal$ha!Y$ha!Z$ha![$ha!u$ha!y$ha!z$ha!{$ha#P$ha#Q$ha'k$ha's$ha'|$ha~P%NtO]$jal$ja!Y$ja!Z$ja![$ja!u$ja!y$ja!z$ja!{$ja#P$ja#Q$ja'k$ja's$ja'|$ja~P&!{O]$xal$xa!U$xa!Y$xa!Z$xa![$xa!u$xa!y$xa!z$xa!{$xa#P$xa#Q$xa'k$xa's$xa'|$xa~P&D[O]%Til%Ti!Y%Ti!Z%Ti![%Ti!u%Ti!y%Ti!z%Ti!{%Ti#P%Ti#Q%Ti'k%Ti's%Ti'|%Ti~P&4cO]%Vil%Vi!Y%Vi!Z%Vi![%Vi!u%Vi!y%Vi!z%Vi!{%Vi#P%Vi#Q%Vi'k%Vi's%Vi'|%Vi~P&6jO]$qil$qi!U$qi!Y$qi!Z$qi![$qi!u$qi!y$qi!z$qi!{$qi#P$qi#Q$qi'k$qi's$qi'|$qi~P&D[O]$qql$qq!U$qq!Y$qq!Z$qq![$qq!u$qq!y$qq!z$qq!{$qq#P$qq#Q$qq'k$qq's$qq'|$qq~P&D[O]$sql$sq!U$sq!Y$sq!Z$sq![$sq!u$sq!y$sq!z$sq!{$sq#P$sq#Q$sq'k$sq's$sq'|$sq~P&D[O]%X!Zl%X!Z!U%X!Z!Y%X!Z!Z%X!Z![%X!Z!u%X!Z!y%X!Z!z%X!Z!{%X!Z#P%X!Z#Q%X!Z'k%X!Z's%X!Z'|%X!Z~P&D[Oo'tX~P/WO!QdX!TdX#TdX~P&*pOQ[XZ[Xk[Xx[Xy[X{[X!T[X!TdX!c[X!d[X!f[X!l[X#T[X#TdX#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X~O!_dX!e[X!edX'}dX~P'$ZOQ;VOR;VO]gOb=ZOc!`OigOk;VOlgOmgOrgOt;VOv;VO{SO!OgO!PgO!VTO!a;YO!fVO!i;VO!j;VO!k;VO!l;VO!m;VO!p!_O#|!bO$QbO'j'|O'rRO'|WO(Z=XO~O]$SOi$cOk$TOl$SOm$SOr$dOt$eOv;pO{$[O!V$]O!a=aO!f$XO#_;yO#|$iO$i;sO$k;vO$n$jO'j'dO'n$bO'r$UO~O!T;jO!U$ga~O]$SOi$cOk$TOl$SOm$SOr$dOt$eOv;qO{$[O!V$]O!a=bO!f$XO#_;zO#|$iO$i;tO$k;wO$n$jO'j'dO'n$bO'r$UO~O#l(TO~P'*^O!U[X!UdX~P'$ZO!_;^O~O#`;]O~O!_#UO#`;]O~O#T;nO~O#k;cO~O#T;{O!T(SX!U(SX~O#T;nO!T(QX!U(QX~O#`;|O~Oe TypeParamList TypeDefinition ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewExpression new TypeArgList CompareOp < ) ( ArgList UnaryExpression await yield delete LogicOp BitOp ParenthesizedExpression ClassExpression class extends ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXStartTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody MethodDeclaration AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression",maxTerm:345,context:mI,nodeProps:[["closedBy",4,"InterpolationEnd",43,"]",53,"}",68,")",140,"JSXSelfCloseEndTag JSXEndTag",156,"JSXEndTag"],["group",-26,8,15,17,60,195,199,202,203,205,208,211,222,224,230,232,234,236,239,245,251,253,255,257,259,261,262,"Statement",-30,12,13,25,28,29,34,44,46,47,49,54,62,70,76,77,99,100,109,110,127,130,132,133,134,135,137,138,158,159,161,"Expression",-23,24,26,30,33,35,37,162,164,166,167,169,170,171,173,174,175,177,178,179,189,191,193,194,"Type",-3,81,92,98,"ClassItem"],["openedBy",31,"InterpolationStart",48,"[",52,"{",67,"(",139,"JSXStartTag",151,"JSXStartTag JSXStartCloseTag"]],propSources:[vI],skippedNodes:[0,5,6],repeatNodeCount:29,tokenData:"#2k~R!bOX%ZXY%uYZ'kZ[%u[]%Z]^'k^p%Zpq%uqr(Rrs)mst7]tu9guvlxyJcyzJyz{Ka{|Lm|}MW}!OLm!O!PMn!P!Q!$v!Q!R!Er!R![!G_![!]!Nc!]!^!N{!^!_# c!_!`#!`!`!a##d!a!b#%s!b!c#'h!c!}9g!}#O#(O#O#P%Z#P#Q#(f#Q#R#(|#R#S9g#S#T#)g#T#o#)}#o#p#,w#p#q#,|#q#r#-j#r#s#.S#s$f%Z$f$g%u$g#BY9g#BY#BZ#.j#BZ$IS9g$IS$I_#.j$I_$I|9g$I|$I}#1X$I}$JO#1X$JO$JT9g$JT$JU#.j$JU$KV9g$KV$KW#.j$KW&FU9g&FU&FV#.j&FV;'S9g;'S;=`Rw!^%Z!_!`YU$`W#q&lO!^%Z!_!`s]$`W]&ZOY>lYZ?lZw>lwx,jx!^>l!^!_@|!_#O>l#O#PE_#P#o>l#o#p@|#p;'S>l;'S;=`J]<%lO>l,^?qX$`WOw?lwx+_x!^?l!^!_@^!_#o?l#o#p@^#p;'S?l;'S;=`@v<%lO?l,U@aTOw@^wx,Xx;'S@^;'S;=`@p<%lO@^,U@sP;=`<%l@^,^@yP;=`<%l?l1aARX]&ZOY@|YZ@^Zw@|wx-tx#O@|#O#PAn#P;'S@|;'S;=`EX<%lO@|1aAqUOw@|wxBTx;'S@|;'S;=`Dg;=`<%lBt<%lO@|1aB[W$Z,U]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da<%lOBt&ZByW]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da<%lOBt&ZCfRO;'SBt;'S;=`Co;=`OBt&ZCtX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%lBt<%lOBt&ZDdP;=`<%lBt1aDlX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%l@|<%lOBt1aE[P;=`<%l@|1iEdY$`WOw>lwxFSx!^>l!^!_@|!_#o>l#o#p@|#p;'S>l;'S;=`Ik;=`<%lBt<%lO>l1iF]]$Z,U$`W]&ZOYGUYZ%ZZwGUwx4hx!^GU!^!_Bt!_#OGU#O#PHU#P#oGU#o#pBt#p;'SGU;'S;=`Ie<%lOGU&cG]]$`W]&ZOYGUYZ%ZZwGUwx4hx!^GU!^!_Bt!_#OGU#O#PHU#P#oGU#o#pBt#p;'SGU;'S;=`Ie<%lOGU&cHZW$`WO!^GU!^!_Bt!_#oGU#o#pBt#p;'SGU;'S;=`Hs;=`<%lBt<%lOGU&cHxX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%lGU<%lOBt&cIhP;=`<%lGU1iIpX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%l>l<%lOBt1iJ`P;=`<%l>l,TJjT!f+{$`WO!^%Z!_#o%Z#p;'S%Z;'S;=`%o<%lO%Z$PKQT!e#w$`WO!^%Z!_#o%Z#p;'S%Z;'S;=`%o<%lO%Z)ZKjW$`W'k#e#f&lOz%Zz{LS{!^%Z!_!`q#P#Q!-n#Q#o!;l#o#p!6|#p;'S!;l;'S;=`!?i<%lO!;l7Z!q#P#Q!-n#Q#o!;l#o#p!6|#p;'S!;l;'S;=`!?i<%lO!;l7Z!={[$`WU7ROY!+TYZ%ZZ!^!+T!^!_!)o!_#O!+T#O#P!,O#P#Q!&V#Q#o!+T#o#p!)o#p;'S!+T;'S;=`!,p<%lO!+T7Z!>vZ$`WOY!;lYZ!.wZz!;lz{!kI[n]||-1},{term:311,get:n=>xI[n]||-1},{term:65,get:n=>TI[n]||-1}],tokenPrec:13429}),PI=[Ut("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ut("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ut("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ut("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ut("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ut(`try { +`);i=r<0?t:t.slice(0,r)}return e+i.length>this.to?i.slice(0,this.to-e):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,i=0){this.block=Fl.create(e,i,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,i=0){this.startContext(this.parser.getNodeType(e),t,i)}addNode(e,t,i){typeof e=="number"&&(e=new re(this.parser.nodeSet.types[e],Qs,Qs,(i??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(Uu(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?Rb(this.ranges,0,e.topNode,this.ranges[0].from,this.dontInject):e}finishLeaf(e){for(let i of e.parsers)if(i.finish(this,e))return;let t=Uu(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(I.Paragraph,e.content.length),e.start)}elt(e,t,i,r){return typeof e=="string"?ie(this.parser.getNodeType(e),t,i,r):new Nb(e,t)}get buffer(){return new Db(this.parser.nodeSet)}}function Rb(n,e,t,i,r){if(r.has(t.tree))return t.tree;let s=n[e].to,o=[],a=[],l=t.from+i;function h(c,u){for(;u?c>=s:c>s;){let f=n[e+1].from-s;i+=f,c+=f,e++,s=n[e].to}}for(let c=t.firstChild;c;c=c.nextSibling){h(c.from+i,!0);let u=c.from+i,f;c.to+i>s?(f=Rb(n,e,c,i,r),h(c.to+i,!1)):f=c.toTree(),o.push(f),a.push(u-l)}return h(t.to+i,!1),new re(t.type,o,a,t.to+i-l,t.tree?t.tree.propValues:void 0)}class xh extends Af{constructor(e,t,i,r,s,o,a,l,h){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=o,this.inlineParsers=a,this.inlineNames=l,this.wrappers=h,this.nodeTypes=Object.create(null);for(let c of e.types)this.nodeTypes[c.name]=c.id}createParse(e,t,i){let r=new T$(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}configure(e){let t=Xu(e);if(!t)return this;let{nodeSet:i,skipContextMarkup:r}=this,s=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),a=this.blockNames.slice(),l=this.inlineParsers.slice(),h=this.inlineNames.slice(),c=this.endLeafBlock.slice(),u=this.wrappers;if(Xs(t.defineNodes)){r=Object.assign({},r);let f=i.types.slice(),p;for(let g of t.defineNodes){let{name:O,block:y,composite:S,style:k}=typeof g=="string"?{name:g}:g;if(f.some(x=>x.name==O))continue;S&&(r[f.length]=(x,P,R)=>S(P,R,x.value));let $=f.length,A=S?["Block","BlockContext"]:y?$>=I.ATXHeading1&&$<=I.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(Ie.define({id:$,name:O,props:A&&[[G.group,A]]})),k&&(p||(p={}),Array.isArray(k)||k instanceof jt?p[O]=k:Object.assign(p,k))}i=new _o(f),p&&(i=i.extend(Cs(p)))}if(Xs(t.props)&&(i=i.extend(...t.props)),Xs(t.remove))for(let f of t.remove){let p=this.blockNames.indexOf(f),g=this.inlineNames.indexOf(f);p>-1&&(s[p]=o[p]=void 0),g>-1&&(l[g]=void 0)}if(Xs(t.parseBlock))for(let f of t.parseBlock){let p=a.indexOf(f.name);if(p>-1)s[p]=f.parse,o[p]=f.leaf;else{let g=f.before?Ca(a,f.before):f.after?Ca(a,f.after)+1:a.length-1;s.splice(g,0,f.parse),o.splice(g,0,f.leaf),a.splice(g,0,f.name)}f.endLeaf&&c.push(f.endLeaf)}if(Xs(t.parseInline))for(let f of t.parseInline){let p=h.indexOf(f.name);if(p>-1)l[p]=f.parse;else{let g=f.before?Ca(h,f.before):f.after?Ca(h,f.after)+1:h.length-1;l.splice(g,0,f.parse),h.splice(g,0,f.name)}}return t.wrap&&(u=u.concat(t.wrap)),new xh(i,s,o,a,c,r,l,h,u)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let i=new P$(this,e,t);e:for(let r=t;r=0){r=a;continue e}}r++}return i.resolveMarkers(0)}}function Xs(n){return n!=null&&n.length>0}function Xu(n){if(!Array.isArray(n))return n;if(n.length==0)return null;let e=Xu(n[0]);if(n.length==1)return e;let t=Xu(n.slice(1));if(!t||!e)return e||t;let i=(o,a)=>(o||Qs).concat(a||Qs),r=e.wrap,s=t.wrap;return{props:i(e.props,t.props),defineNodes:i(e.defineNodes,t.defineNodes),parseBlock:i(e.parseBlock,t.parseBlock),parseInline:i(e.parseInline,t.parseInline),remove:i(e.remove,t.remove),wrap:r?s?(o,a,l,h)=>r(s(o,a,l,h),a,l,h):r:s}}function Ca(n,e){let t=n.indexOf(e);if(t<0)throw new RangeError(`Position specified relative to unknown parser ${e}`);return t}let Eb=[Ie.none];for(let n=1,e;e=I[n];n++)Eb[n]=Ie.define({id:n,name:e,props:n>=I.Escape?[]:[[G.group,n in kb?["Block","BlockContext"]:["Block","LeafBlock"]]]});const Qs=[];class Db{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,i,r=0){return this.content.push(e,t,i,4+r*4),this}writeElements(e,t=0){for(let i of e)i.writeTo(this,t);return this}finish(e,t){return re.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}let qo=class{constructor(e,t,i,r=Qs){this.type=e,this.from=t,this.to=i,this.children=r}writeTo(e,t){let i=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-i)}toTree(e){return new Db(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}};class Nb{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return Qs}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function ie(n,e,t,i){return new qo(n,e,t,i)}const Bb={resolve:"Emphasis",mark:"EmphasisMark"},qb={resolve:"Emphasis",mark:"EmphasisMark"},Us={},Mg={};class zt{constructor(e,t,i,r){this.type=e,this.from=t,this.to=i,this.side=r}}const Vg="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let Mo=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Mo=new RegExp("[\\p{Pc}|\\p{Pd}|\\p{Pe}|\\p{Pf}|\\p{Pi}|\\p{Po}|\\p{Ps}]","u")}catch{}const oc={Escape(n,e,t){if(e!=92||t==n.end-1)return-1;let i=n.char(t+1);for(let r=0;r]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);if(r)return n.append(ie(I.URL,t,t+1+r[0].length));let s=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(s)return n.append(ie(I.Comment,t,t+1+s[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return n.append(ie(I.ProcessingInstruction,t,t+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return a?n.append(ie(I.HTMLTag,t,t+1+a[0].length)):-1},Emphasis(n,e,t){if(e!=95&&e!=42)return-1;let i=t+1;for(;n.char(i)==e;)i++;let r=n.slice(t-1,t),s=n.slice(i,i+1),o=Mo.test(r),a=Mo.test(s),l=/\s|^$/.test(r),h=/\s|^$/.test(s),c=!h&&(!a||l||o),u=!l&&(!o||h||a),f=c&&(e==42||!u||o),p=u&&(e==42||!c||a);return n.append(new zt(e==95?Bb:qb,t,i,(f?1:0)|(p?2:0)))},HardBreak(n,e,t){if(e==92&&n.char(t+1)==10)return n.append(ie(I.HardBreak,t,t+2));if(e==32){let i=t+1;for(;n.char(i)==32;)i++;if(n.char(i)==10&&i>=t+2)return n.append(ie(I.HardBreak,t,i+1))}return-1},Link(n,e,t){return e==91?n.append(new zt(Us,t,t+1,1)):-1},Image(n,e,t){return e==33&&n.char(t+1)==91?n.append(new zt(Mg,t,t+2,1)):-1},LinkEnd(n,e,t){if(e!=93)return-1;for(let i=n.parts.length-1;i>=0;i--){let r=n.parts[i];if(r instanceof zt&&(r.type==Us||r.type==Mg)){if(!r.side||n.skipSpace(r.to)==t&&!/[(\[]/.test(n.slice(t+1,t+2)))return n.parts[i]=null,-1;let s=n.takeContent(i),o=n.parts[i]=Q$(n,s,r.type==Us?I.Link:I.Image,r.from,t+1);if(r.type==Us)for(let a=0;ae?ie(I.URL,e+t,s+t):s==n.length?null:!1}}function Vb(n,e,t){let i=n.charCodeAt(e);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=e+1,o=!1;s=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,i,r,s){return this.append(new zt(e,t,i,(r?1:0)|(s?2:0)))}addElement(e){return this.append(e)}resolveMarkers(e){for(let i=e;i=e;l--){let O=this.parts[l];if(O instanceof zt&&O.side&1&&O.type==r.type&&!(s&&(r.side&1||O.side&2)&&(O.to-O.from+o)%3==0&&((O.to-O.from)%3||o%3))){a=O;break}}if(!a)continue;let h=r.type.resolve,c=[],u=a.from,f=r.to;if(s){let O=Math.min(2,a.to-a.from,o);u=a.to-O,f=r.from+O,h=O==1?"Emphasis":"StrongEmphasis"}a.type.mark&&c.push(this.elt(a.type.mark,u,a.to));for(let O=l+1;O=0;t--){let i=this.parts[t];if(i instanceof zt&&i.type==e)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}skipSpace(e){return lo(this.text,e-this.offset)+this.offset}elt(e,t,i,r){return typeof e=="string"?ie(this.parser.getNodeType(e),t,i,r):new Nb(e,t)}}function Uu(n,e){if(!e.length)return n;if(!n.length)return e;let t=n.slice(),i=0;for(let r of e){for(;i(e?e-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` +`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=t;if(!i.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(G.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,a=e.block.children.length,l=o,h=a;for(;;){if(t.to-i>r){if(t.type.isAnonymous&&t.firstChild())continue;break}if(e.dontInject.add(t.tree),e.addNode(t.tree,t.from-i),t.type.is("Block")&&(A$.indexOf(t.type.id)<0?(o=t.to-i,a=e.block.children.length):(o=l,a=h,l=t.to-i,h=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return o-s}};const C$=Cs({"Blockquote/...":b.quote,HorizontalRule:b.contentSeparator,"ATXHeading1/... SetextHeading1/...":b.heading1,"ATXHeading2/... SetextHeading2/...":b.heading2,"ATXHeading3/...":b.heading3,"ATXHeading4/...":b.heading4,"ATXHeading5/...":b.heading5,"ATXHeading6/...":b.heading6,"Comment CommentBlock":b.comment,Escape:b.escape,Entity:b.character,"Emphasis/...":b.emphasis,"StrongEmphasis/...":b.strong,"Link/... Image/...":b.link,"OrderedList/... BulletList/...":b.list,"BlockQuote/...":b.quote,"InlineCode CodeText":b.monospace,URL:b.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":b.processingInstruction,"CodeInfo LinkLabel":b.labelName,LinkTitle:b.string,Paragraph:b.content}),I$=new xh(new _o(Eb).extend(C$),Object.keys($a).map(n=>$a[n]),Object.keys($a).map(n=>v$[n]),Object.keys($a),k$,kb,Object.keys(oc).map(n=>oc[n]),Object.keys(oc),[]);function R$(n,e,t){let i=[];for(let r=n.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:t;if(o>s&&i.push({from:s,to:o}),!r)break;s=r.to}return i}function E$(n){let{codeParser:e,htmlParser:t}=n;return{wrap:ry((r,s)=>{let o=r.type.id;if(e&&(o==I.CodeBlock||o==I.FencedCode)){let a="";if(o==I.FencedCode){let h=r.node.getChild(I.CodeInfo);h&&(a=s.read(h.from,h.to))}let l=e(a);if(l)return{parser:l,overlay:h=>h.type.id==I.CodeText}}else if(t&&(o==I.HTMLBlock||o==I.HTMLTag))return{parser:t,overlay:R$(r.node,r.from,r.to)};return null})}}const D$={resolve:"Strikethrough",mark:"StrikethroughMark"},N$={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":b.strikethrough}},{name:"StrikethroughMark",style:b.processingInstruction}],parseInline:[{name:"Strikethrough",parse(n,e,t){if(e!=126||n.char(t+1)!=126||n.char(t+2)==126)return-1;let i=n.slice(t-1,t),r=n.slice(t+2,t+3),s=/\s|^$/.test(i),o=/\s|^$/.test(r),a=Mo.test(i),l=Mo.test(r);return n.addDelimiter(D$,t,t+2,!o&&(!l||s||a),!s&&(!a||o||l))},after:"Emphasis"}]};function ho(n,e,t=0,i,r=0){let s=0,o=!0,a=-1,l=-1,h=!1,c=()=>{i.push(n.elt("TableCell",r+a,r+l,n.parser.parseInline(e.slice(a,l),r+a)))};for(let u=t;u-1)&&s++,o=!1,i&&(a>-1&&c(),i.push(n.elt("TableDelimiter",u+r,u+r+1))),a=l=-1):(h||f!=32&&f!=9)&&(a<0&&(a=u),l=u+1),h=!h&&f==92}return a>-1&&(s++,i&&c()),s}function Lg(n,e){for(let t=e;tr instanceof Xg)||!Lg(e.text,e.basePos))return!1;let i=n.scanLine(n.absoluteLineEnd+1).text;return Xb.test(i)&&ho(n,e.text,e.basePos)==ho(n,i,e.basePos)},before:"SetextHeading"}]};class q${nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const M$={defineNodes:[{name:"Task",block:!0,style:b.list},{name:"TaskMarker",style:b.atom}],parseBlock:[{name:"TaskList",leaf(n,e){return/^\[[ xX]\]/.test(e.content)&&n.parentType().name=="ListItem"?new q$:null},after:"SetextHeading"}]},V$=[B$,M$,N$];function Ub(n,e,t){return(i,r,s)=>{if(r!=n||i.char(s+1)==n)return-1;let o=[i.elt(t,s,s+1)];for(let a=s+1;at%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new _l(e,[],t,i,i,0,[],0,r?new Zg(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,i=e&65535,{parser:r}=this.p,s=r.dynamicPrecedence(i);if(s&&(this.score+=s),t==0){this.pushState(r.getGoto(this.state,i,!0),this.reducePos),io;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==i)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,r);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,t,i){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(t,r),t<=o.maxNode&&this.buffer.push(t,r,i,4)}}apply(e,t,i){e&65536?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new _l(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Z$(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if(!(i&65536))return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sl&1&&a==o)||r.push(t[s],o)}t=r}let i=[];for(let r=0;r>19,r=e&65535,s=this.stack.length-i*3;if(s<0||t.getGoto(this.stack[s],r,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Zg{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var Wg;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth"})(Wg||(Wg={}));class Z${constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class Gl{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Gl(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gl(this.stack,this.pos,this.index)}}class Ya{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const jg=new Ya;class W${constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=jg,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t=this.chunk2Pos&&ia.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=jg,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class Ha{constructor(e,t){this.data=e,this.id=t}token(e,t){j$(this.data,e,t,this.id)}}Ha.prototype.contextual=Ha.prototype.fallback=Ha.prototype.extend=!1;class ii{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function j$(n,e,t,i){let r=0,s=1<0){let p=n[f];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||o.overrides(p,e.token.value))){e.acceptToken(p);break}}let h=e.next,c=0,u=n[r+2];if(e.next<0&&u>c&&n[l+u*3-3]==65535&&n[l+u*3-3]==65535){r=n[l+u*3-1];continue e}for(;c>1,p=l+f+(f<<1),g=n[p],O=n[p+1]||65536;if(h=O)c=f+1;else{r=n[p+2],e.advance();continue e}}break}}function Ia(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}const Zt=typeof process<"u"&&Ug&&/\bparse\b/.test(Ug.LOG);let ac=null;var zg;(function(n){n[n.Margin=25]="Margin"})(zg||(zg={}));function Fg(n,e,t){let i=n.cursor(ce.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.toe)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class z${constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Fg(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Fg(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof re){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class F${constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Ya)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let h=0;hu.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!c.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new Ya,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ya,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let s=0;se.bufferLength*4?new z$(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,s;for(let o=0;ot)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!i.length){let o=r&&J$(r);if(o)return this.stackToTree(o);if(this.parser.strict)throw Zt&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((a,l)=>l.score-a.score);i.length>o;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1)e:for(let o=0;o500&&h.buffer.length>500)if((a.score-h.score||a.buffer.length-h.buffer.length)>0)i.splice(l--,1);else{i.splice(o--,1);continue e}}}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?s.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!h||(u.prop(G.contextHash)||0)==c))return e.useNode(u,f),Zt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(u.type.id)})`),!0;if(!(u instanceof re)||u.children.length==0||u.positions[0]>0)break;let p=u.children[0];if(p instanceof re&&u.positions[0]==0)u=p;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Zt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let h=0;hr?t.push(g):i.push(g)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Gg(e,t),!0}}runRecovery(e,t,i){let r=null,s=!1;for(let o=0;o ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Zt&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let u=a.split(),f=c;for(let p=0;u.forceReduce()&&p<10&&(Zt&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));p++)Zt&&(f=this.stackID(u)+" -> ");for(let p of a.recoverByInsert(l))Zt&&console.log(c+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,i);this.stream.end>a.pos?(h==a.pos&&(h++,l=0),a.recoverByDelete(l,h),Zt&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),Gg(a,i)):(!r||r.scoren;class Zb{constructor(e){this.start=e.start,this.shift=e.shift||lc,this.reduce=e.reduce||lc,this.reuse=e.reuse||lc,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Ps extends Af{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)s(c,l,a[h++]);else{let u=a[h+-c];for(let f=-c;f>0;f--)s(a[h++],l,u);h++}}}this.nodeSet=new _o(t.map((a,l)=>Ie.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=ty;let o=Ia(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Ha(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new _$(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&i)return l;for(let h=s+(o>>1);s0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$n(this.data,i+2);else return!1;if(t==$n(this.data,i+1))return!0}}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=$n(this.data,i+2);else break;if(!(this.data[i+2]&1)){let r=this.data[i+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[i],r)}}return t}overrides(e,t){let i=Jg(this.data,this.tokenPrecTable,t);return i<0||Jg(this.data,this.tokenPrecTable,e){let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(a=>a.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[r]=Yg(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const Y$=54,H$=1,K$=55,eC=2,tC=56,iC=3,Jl=4,Wb=5,jb=6,zb=7,Fb=8,nC=9,rC=10,sC=11,hc=57,oC=12,Hg=58,aC=18,lC=20,_b=21,hC=22,Zu=24,Gb=25,cC=27,uC=30,fC=33,dC=35,pC=0,gC={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},mC={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},Kg={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function OC(n){return n==45||n==46||n==58||n>=65&&n<=90||n==95||n>=97&&n<=122||n>=161}function Jb(n){return n==9||n==10||n==13||n==32}let em=null,tm=null,im=0;function Wu(n,e){let t=n.pos+e;if(im==t&&tm==n)return em;let i=n.peek(e);for(;Jb(i);)i=n.peek(++e);let r="";for(;OC(i);)r+=String.fromCharCode(i),i=n.peek(++e);return tm=n,im=t,em=r?r.toLowerCase():i==yC||i==bC?void 0:null}const Yb=60,Hb=62,Kb=47,yC=63,bC=33,SC=45;function nm(n,e){this.name=n,this.parent=e,this.hash=e?e.hash:0;for(let t=0;t-1?new nm(Wu(i,1)||"",n):n},reduce(n,e){return e==aC&&n?n.parent:n},reuse(n,e,t,i){let r=e.type.id;return r==Jl||r==dC?new nm(Wu(i,1)||"",n):n},hash(n){return n?n.hash:0},strict:!1}),kC=new ii((n,e)=>{if(n.next!=Yb){n.next<0&&e.context&&n.acceptToken(hc);return}n.advance();let t=n.next==Kb;t&&n.advance();let i=Wu(n,0);if(i===void 0)return;if(!i)return n.acceptToken(t?oC:Jl);let r=e.context?e.context.name:null;if(t){if(i==r)return n.acceptToken(nC);if(r&&mC[r])return n.acceptToken(hc,-2);if(e.dialectEnabled(pC))return n.acceptToken(rC);for(let s=e.context;s;s=s.parent)if(s.name==i)return;n.acceptToken(sC)}else{if(i=="script")return n.acceptToken(Wb);if(i=="style")return n.acceptToken(jb);if(i=="textarea")return n.acceptToken(zb);if(gC.hasOwnProperty(i))return n.acceptToken(Fb);r&&Kg[r]&&Kg[r][i]?n.acceptToken(hc,-1):n.acceptToken(Jl)}},{contextual:!0}),xC=new ii(n=>{for(let e=0,t=0;;t++){if(n.next<0){t&&n.acceptToken(Hg);break}if(n.next==SC)e++;else if(n.next==Hb&&e>=2){t>3&&n.acceptToken(Hg,-2);break}else e=0;n.advance()}});function Jf(n,e,t){let i=2+n.length;return new ii(r=>{for(let s=0,o=0,a=0;;a++){if(r.next<0){a&&r.acceptToken(e);break}if(s==0&&r.next==Yb||s==1&&r.next==Kb||s>=2&&so?r.acceptToken(e,-o):r.acceptToken(t,-(o-2));break}else if((r.next==10||r.next==13)&&a){r.acceptToken(e,1);break}else s=o=0;r.advance()}})}const TC=Jf("script",Y$,H$),QC=Jf("style",K$,eC),PC=Jf("textarea",tC,iC),AC=Cs({"Text RawText":b.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":b.angleBracket,TagName:b.tagName,"MismatchedCloseTag/TagName":[b.tagName,b.invalid],AttributeName:b.attributeName,"AttributeValue UnquotedAttributeValue":b.attributeValue,Is:b.definitionOperator,"EntityReference CharacterReference":b.character,Comment:b.blockComment,ProcessingInst:b.processingInstruction,DoctypeDecl:b.documentMeta}),$C=Ps.deserialize({version:14,states:",xOVOxOOO!WQ!bO'#CoO!]Q!bO'#CyO!bQ!bO'#C|O!gQ!bO'#DPO!lQ!bO'#DRO!qOXO'#CnO!|OYO'#CnO#XO[O'#CnO$eOxO'#CnOOOW'#Cn'#CnO$lO!rO'#DTO$tQ!bO'#DVO$yQ!bO'#DWOOOW'#Dk'#DkOOOW'#DY'#DYQVOxOOO%OQ#tO,59ZO%WQ#tO,59eO%`Q#tO,59hO%hQ#tO,59kO%sQ#tO,59mOOOX'#D^'#D^O%{OXO'#CwO&WOXO,59YOOOY'#D_'#D_O&`OYO'#CzO&kOYO,59YOOO['#D`'#D`O&sO[O'#C}O'OO[O,59YOOOW'#Da'#DaO'WOxO,59YO'_Q!bO'#DQOOOW,59Y,59YOOO`'#Db'#DbO'dO!rO,59oOOOW,59o,59oO'lQ!bO,59qO'qQ!bO,59rOOOW-E7W-E7WO'vQ#tO'#CqOOQO'#DZ'#DZO(UQ#tO1G.uOOOX1G.u1G.uO(^Q#tO1G/POOOY1G/P1G/PO(fQ#tO1G/SOOO[1G/S1G/SO(nQ#tO1G/VOOOW1G/V1G/VOOOW1G/X1G/XO(yQ#tO1G/XOOOX-E7[-E7[O)RQ!bO'#CxOOOW1G.t1G.tOOOY-E7]-E7]O)WQ!bO'#C{OOO[-E7^-E7^O)]Q!bO'#DOOOOW-E7_-E7_O)bQ!bO,59lOOO`-E7`-E7`OOOW1G/Z1G/ZOOOW1G/]1G/]OOOW1G/^1G/^O)gQ&jO,59]OOQO-E7X-E7XOOOX7+$a7+$aOOOY7+$k7+$kOOO[7+$n7+$nOOOW7+$q7+$qOOOW7+$s7+$sO)rQ!bO,59dO)wQ!bO,59gO)|Q!bO,59jOOOW1G/W1G/WO*RO,UO'#CtO*dO7[O'#CtOOQO1G.w1G.wOOOW1G/O1G/OOOOW1G/R1G/ROOOW1G/U1G/UOOOO'#D['#D[O*uO,UO,59`OOQO,59`,59`OOOO'#D]'#D]O+WO7[O,59`OOOO-E7Y-E7YOOQO1G.z1G.zOOOO-E7Z-E7Z",stateData:"+u~O!^OS~OSSOTPOUQOVROWTOY]OZ[O[^O^^O_^O`^Oa^Ox^O{_O!dZO~OdaO~OdbO~OdcO~OddO~OdeO~O!WfOPkP!ZkP~O!XiOQnP!ZnP~O!YlORqP!ZqP~OSSOTPOUQOVROWTOXqOY]OZ[O[^O^^O_^O`^Oa^Ox^O!dZO~O!ZrO~P#dO![sO!euO~OdvO~OdwO~OfyOj|O~OfyOj!OO~OfyOj!QO~OfyOj!SOv!TO~OfyOj!TO~O!WfOPkX!ZkX~OP!WO!Z!XO~O!XiOQnX!ZnX~OQ!ZO!Z!XO~O!YlORqX!ZqX~OR!]O!Z!XO~O!Z!XO~P#dOd!_O~O![sO!e!aO~Oj!bO~Oj!cO~Og!dOfeXjeXveX~OfyOj!fO~OfyOj!gO~OfyOj!hO~OfyOj!iOv!jO~OfyOj!jO~Od!kO~Od!lO~Od!mO~Oj!nO~Oi!qO!`!oO!b!pO~Oj!rO~Oj!sO~Oj!tO~O_!uO`!uOa!uO!`!wO!a!uO~O_!xO`!xOa!xO!b!wO!c!xO~O_!uO`!uOa!uO!`!{O!a!uO~O_!xO`!xOa!xO!b!{O!c!xO~Ov~vj`!dx{_a_~",goto:"%p!`PPPPPPPPPPPPPPPPPP!a!gP!mPP!yPP!|#P#S#Y#]#`#f#i#l#r#xP!aP!a!aP$O$U$l$r$x%O%U%[%bPPPPPPPP%hX^OX`pXUOX`pezabcde{}!P!R!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ}bQ!PcQ!RdQ!UeZ!e{}!P!R!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue EndTag ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag SelfClosingEndTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:67,context:vC,nodeProps:[["closedBy",-10,1,2,3,5,6,7,8,9,10,11,"EndTag",4,"EndTag SelfClosingEndTag",-4,19,29,32,35,"CloseTag"],["group",-9,12,15,16,17,18,39,40,41,42,"Entity",14,"Entity TextContent",-3,27,30,33,"TextContent Entity"],["openedBy",26,"StartTag StartCloseTag",-4,28,31,34,36,"OpenTag",38,"StartTag"]],propSources:[AC],skippedNodes:[0],repeatNodeCount:9,tokenData:"#(r!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs4ysv-_vw5iwxJ^x}-_}!OKP!O!P-_!P!Q!!O!Q![-_![!]!$c!]!^-_!^!_!(k!_!`#'S!`!a#'z!a!c-_!c!}!$c!}#R-_#R#S!$c#S#T3V#T#o!$c#o#s-_#s$f$q$f%W-_%W%o!$c%o%p-_%p&a!$c&a&b-_&b1p!$c1p4U-_4U4d!$c4d4e-_4e$IS!$c$IS$I`-_$I`$Ib!$c$Ib$Kh-_$Kh%#t!$c%#t&/x-_&/x&Et!$c&Et&FV-_&FV;'S!$c;'S;:j!(e;:j;=`4s<%l?&r-_?&r?Ah!$c?Ah?BY$q?BY?Mn!$c?MnO$q!Z$|c^PiW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr$qrs&}sv$qvw+Pwx(tx!^$q!^!_*V!_!a&X!a#S$q#S#T&X#T;'S$q;'S;=`+z<%lO$q!R&bX^P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&Xq'UV^P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}P'pT^POv'kw!^'k!_;'S'k;'S;=`(P<%lO'kP(SP;=`<%l'kp([S!cpOv(Vx;'S(V;'S;=`(h<%lO(Vp(kP;=`<%l(Vq(qP;=`<%l&}a({W^P!a`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t`)jT!a`Or)esv)ew;'S)e;'S;=`)y<%lO)e`)|P;=`<%l)ea*SP;=`<%l(t!Q*^V!a`!cpOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!Q*vP;=`<%l*V!R*|P;=`<%l&XW+UYiWOX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+PW+wP;=`<%l+P!Z+}P;=`<%l$q!a,]`^P!a`!cp!^^OX&XXY,QYZ,QZ]&X]^,Q^p&Xpq,Qqr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!_-ljfS^PiW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_1n!_!a&X!a#S-_#S#T3V#T#s-_#s$f$q$f;'S-_;'S;=`4s<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q[/ecfSiWOX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!^!_0p!a#S/^#S#T0p#T#s/^#s$f+P$f;'S/^;'S;=`1h<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+PS0uXfSqr0psw0px!P0p!Q!_0p!a#s0p$f;'S0p;'S;=`1b<%l?Ah0p?BY?Mn0pS1eP;=`<%l0p[1kP;=`<%l/^!U1wbfS!a`!cpOq*Vqr1nrs(Vsv1nvw0pwx)ex!P1n!P!Q*V!Q!_1n!_!a*V!a#s1n#s$f*V$f;'S1n;'S;=`3P<%l?Ah1n?Ah?BY*V?BY?Mn1n?MnO*V!U3SP;=`<%l1n!V3bcfS^P!a`!cpOq&Xqr3Vrs&}sv3Vvw0pwx(tx!P3V!P!Q&X!Q!^3V!^!_1n!_!a&X!a#s3V#s$f&X$f;'S3V;'S;=`4m<%l?Ah3V?Ah?BY&X?BY?Mn3V?MnO&X!V4pP;=`<%l3V!_4vP;=`<%l-_!Z5SV!`h^P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}!_5rjfSiWa!ROX7dXZ8qZ[7d[^8q^p7dqr:crs8qst@Ttw:cwx8qx!P:c!P!Q7d!Q!]:c!]!^/^!^!_=p!_!a8q!a#S:c#S#T=p#T#s:c#s$f7d$f;'S:c;'S;=`?}<%l?Ah:c?Ah?BY7d?BY?Mn:c?MnO7d!Z7ibiWOX7dXZ8qZ[7d[^8q^p7dqr7drs8qst+Ptw7dwx8qx!]7d!]!^9f!^!a8q!a#S7d#S#T8q#T;'S7d;'S;=`:]<%lO7d!R8tVOp8qqs8qt!]8q!]!^9Z!^;'S8q;'S;=`9`<%lO8q!R9`O_!R!R9cP;=`<%l8q!Z9mYiW_!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z:`P;=`<%l7d!_:jjfSiWOX7dXZ8qZ[7d[^8q^p7dqr:crs8qst/^tw:cwx8qx!P:c!P!Q7d!Q!]:c!]!^<[!^!_=p!_!a8q!a#S:c#S#T=p#T#s:c#s$f7d$f;'S:c;'S;=`?}<%l?Ah:c?Ah?BY7d?BY?Mn:c?MnO7d!_{let l=o.type.id;if(l==cC)return cc(o,a,t);if(l==uC)return cc(o,a,i);if(l==fC)return cc(o,a,r);if(s&&l==_b){let h=o.node,c;if(c=h.firstChild){let u=s[a.read(c.from,c.to)];if(u)for(let f of u){if(f.tagName){if(!tagName){let g=h.parent.getChild(lC);tagName=g?a.read(g.from,g.to):" "}if(attrTagName!=tagName)continue}let p=h.lastChild;if(p.type.id==Zu)return{parser:f.parser,overlay:[{from:p.from+1,to:p.to-1}]};if(p.type.id==Gb)return{parser:f.parser,overlay:[{from:p.from,to:p.to}]}}}}return null})}const IC=94,rm=1,RC=95,EC=96,sm=2,tS=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],DC=58,NC=40,iS=95,BC=91,Ka=45,qC=46,MC=35,VC=37;function Yl(n){return n>=65&&n<=90||n>=97&&n<=122||n>=161}function LC(n){return n>=48&&n<=57}const XC=new ii((n,e)=>{for(let t=!1,i=0,r=0;;r++){let{next:s}=n;if(Yl(s)||s==Ka||s==iS||t&&LC(s))!t&&(s!=Ka||r>0)&&(t=!0),i===r&&s==Ka&&i++,n.advance();else{t&&n.acceptToken(s==NC?RC:i==2&&e.canShift(sm)?sm:EC);break}}}),UC=new ii(n=>{if(tS.includes(n.peek(-1))){let{next:e}=n;(Yl(e)||e==iS||e==MC||e==qC||e==BC||e==DC||e==Ka)&&n.acceptToken(IC)}}),ZC=new ii(n=>{if(!tS.includes(n.peek(-1))){let{next:e}=n;if(e==VC&&(n.advance(),n.acceptToken(rm)),Yl(e)){do n.advance();while(Yl(n.next));n.acceptToken(rm)}}}),WC=Cs({"AtKeyword import charset namespace keyframes media supports":b.definitionKeyword,"from to selector":b.keyword,NamespaceName:b.namespace,KeyframeName:b.labelName,TagName:b.tagName,ClassName:b.className,PseudoClassName:b.constant(b.className),IdName:b.labelName,"FeatureName PropertyName":b.propertyName,AttributeName:b.attributeName,NumberLiteral:b.number,KeywordQuery:b.keyword,UnaryQueryOp:b.operatorKeyword,"CallTag ValueName":b.atom,VariableName:b.variableName,Callee:b.operatorKeyword,Unit:b.unit,"UniversalSelector NestingSelector":b.definitionOperator,MatchOp:b.compareOperator,"ChildOp SiblingOp, LogicOp":b.logicOperator,BinOp:b.arithmeticOperator,Important:b.modifier,Comment:b.blockComment,ParenthesizedContent:b.special(b.name),ColorLiteral:b.color,StringLiteral:b.string,":":b.punctuation,"PseudoOp #":b.derefOperator,"; ,":b.separator,"( )":b.paren,"[ ]":b.squareBracket,"{ }":b.brace}),jC={__proto__:null,lang:32,"nth-child":32,"nth-last-child":32,"nth-of-type":32,"nth-last-of-type":32,dir:32,"host-context":32,url:60,"url-prefix":60,domain:60,regexp:60,selector:134},zC={__proto__:null,"@import":114,"@media":138,"@charset":142,"@namespace":146,"@keyframes":152,"@supports":164},FC={__proto__:null,not:128,only:128,from:158,to:160},_C=Ps.deserialize({version:14,states:"7WQYQ[OOO#_Q[OOOOQP'#Cd'#CdOOQP'#Cc'#CcO#fQ[O'#CfO$YQXO'#CaO$aQ[O'#ChO$lQ[O'#DPO$qQ[O'#DTOOQP'#Ed'#EdO$vQdO'#DeO%bQ[O'#DrO$vQdO'#DtO%sQ[O'#DvO&OQ[O'#DyO&TQ[O'#EPO&cQ[O'#EROOQS'#Ec'#EcOOQS'#ET'#ETQYQ[OOO&jQXO'#CdO'_QWO'#DaO'dQWO'#EjO'oQ[O'#EjQOQWOOOOQP'#Cg'#CgOOQP,59Q,59QO#fQ[O,59QO'yQ[O'#EWO(eQWO,58{O(mQ[O,59SO$lQ[O,59kO$qQ[O,59oO'yQ[O,59sO'yQ[O,59uO'yQ[O,59vO(xQ[O'#D`OOQS,58{,58{OOQP'#Ck'#CkOOQO'#C}'#C}OOQP,59S,59SO)PQWO,59SO)UQWO,59SOOQP'#DR'#DROOQP,59k,59kOOQO'#DV'#DVO)ZQ`O,59oOOQS'#Cp'#CpO$vQdO'#CqO)cQvO'#CsO*pQtO,5:POOQO'#Cx'#CxO)UQWO'#CwO+UQWO'#CyOOQS'#Eg'#EgOOQO'#Dh'#DhO+ZQ[O'#DoO+iQWO'#EkO&TQ[O'#DmO+wQWO'#DpOOQO'#El'#ElO(hQWO,5:^O+|QpO,5:`OOQS'#Dx'#DxO,UQWO,5:bO,ZQ[O,5:bOOQO'#D{'#D{O,cQWO,5:eO,hQWO,5:kO,pQWO,5:mOOQS-E8R-E8RO$vQdO,59{O,xQ[O'#EYO-VQWO,5;UO-VQWO,5;UOOQP1G.l1G.lO-|QXO,5:rOOQO-E8U-E8UOOQS1G.g1G.gOOQP1G.n1G.nO)PQWO1G.nO)UQWO1G.nOOQP1G/V1G/VO.ZQ`O1G/ZO.tQXO1G/_O/[QXO1G/aO/rQXO1G/bO0YQWO,59zO0_Q[O'#DOO0fQdO'#CoOOQP1G/Z1G/ZO$vQdO1G/ZO0mQpO,59]OOQS,59_,59_O$vQdO,59aO0uQWO1G/kOOQS,59c,59cO0zQ!bO,59eO1SQWO'#DhO1_QWO,5:TO1dQWO,5:ZO&TQ[O,5:VO&TQ[O'#EZO1lQWO,5;VO1wQWO,5:XO'yQ[O,5:[OOQS1G/x1G/xOOQS1G/z1G/zOOQS1G/|1G/|O2YQWO1G/|O2_QdO'#D|OOQS1G0P1G0POOQS1G0V1G0VOOQS1G0X1G0XO2mQtO1G/gOOQO,5:t,5:tO3TQ[O,5:tOOQO-E8W-E8WO3bQWO1G0pOOQP7+$Y7+$YOOQP7+$u7+$uO$vQdO7+$uOOQS1G/f1G/fO3mQXO'#EiO3tQWO,59jO3yQtO'#EUO4nQdO'#EfO4xQWO,59ZO4}QpO7+$uOOQS1G.w1G.wOOQS1G.{1G.{OOQS7+%V7+%VO5VQWO1G/PO$vQdO1G/oOOQO1G/u1G/uOOQO1G/q1G/qO5[QWO,5:uOOQO-E8X-E8XO5jQXO1G/vOOQS7+%h7+%hO5qQYO'#CsO(hQWO'#E[O5yQdO,5:hOOQS,5:h,5:hO6XQtO'#EXO$vQdO'#EXO7VQdO7+%ROOQO7+%R7+%ROOQO1G0`1G0`O7jQpO<T![;'S%^;'S;=`%o<%lO%^^;TUoWOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^^;nYoW#[UOy%^z!Q%^!Q![;g![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^^[[oW#[UOy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^_?VSpVOy%^z;'S%^;'S;=`%o<%lO%^^?hWjSOy%^z!O%^!O!P;O!P!Q%^!Q![>T![;'S%^;'S;=`%o<%lO%^_@VU#XPOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^~@nTjSOy%^z{@}{;'S%^;'S;=`%o<%lO%^~ASUoWOy@}yzAfz{Bm{;'S@};'S;=`Co<%lO@}~AiTOzAfz{Ax{;'SAf;'S;=`Bg<%lOAf~A{VOzAfz{Ax{!PAf!P!QBb!Q;'SAf;'S;=`Bg<%lOAf~BgOR~~BjP;=`<%lAf~BrWoWOy@}yzAfz{Bm{!P@}!P!QC[!Q;'S@};'S;=`Co<%lO@}~CcSoWR~Oy%^z;'S%^;'S;=`%o<%lO%^~CrP;=`<%l@}^Cz[#[UOy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^XDuU]POy%^z![%^![!]EX!];'S%^;'S;=`%o<%lO%^XE`S^PoWOy%^z;'S%^;'S;=`%o<%lO%^_EqS!WVOy%^z;'S%^;'S;=`%o<%lO%^YFSSzQOy%^z;'S%^;'S;=`%o<%lO%^XFeU|POy%^z!`%^!`!aFw!a;'S%^;'S;=`%o<%lO%^XGOS|PoWOy%^z;'S%^;'S;=`%o<%lO%^XG_WOy%^z!c%^!c!}Gw!}#T%^#T#oGw#o;'S%^;'S;=`%o<%lO%^XHO[!YPoWOy%^z}%^}!OGw!O!Q%^!Q![Gw![!c%^!c!}Gw!}#T%^#T#oGw#o;'S%^;'S;=`%o<%lO%^XHySxPOy%^z;'S%^;'S;=`%o<%lO%^^I[SvUOy%^z;'S%^;'S;=`%o<%lO%^XIkUOy%^z#b%^#b#cI}#c;'S%^;'S;=`%o<%lO%^XJSUoWOy%^z#W%^#W#XJf#X;'S%^;'S;=`%o<%lO%^XJmS!`PoWOy%^z;'S%^;'S;=`%o<%lO%^XJ|UOy%^z#f%^#f#gJf#g;'S%^;'S;=`%o<%lO%^XKeS!RPOy%^z;'S%^;'S;=`%o<%lO%^_KvS!QVOy%^z;'S%^;'S;=`%o<%lO%^ZLXU!PPOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^WLnP;=`<%l$}",tokenizers:[UC,ZC,XC,0,1,2,3],topRules:{StyleSheet:[0,4],Styles:[1,84]},specialized:[{term:95,get:n=>jC[n]||-1},{term:56,get:n=>zC[n]||-1},{term:96,get:n=>FC[n]||-1}],tokenPrec:1123});let uc=null;function fc(){if(!uc&&typeof document=="object"&&document.body){let n=[];for(let e in document.body.style)/[A-Z]|^-|^(item|length)$/.test(e)||n.push(e);uc=n.sort().map(e=>({type:"property",label:e}))}return uc||[]}const om=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(n=>({type:"class",label:n})),am=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(n=>({type:"keyword",label:n})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(n=>({type:"constant",label:n}))),GC=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(n=>({type:"type",label:n})),Fn=/^[\w-]*/,JC=n=>{let{state:e,pos:t}=n,i=pe(e).resolveInner(t,-1);if(i.name=="PropertyName")return{from:i.from,options:fc(),validFor:Fn};if(i.name=="ValueName")return{from:i.from,options:am,validFor:Fn};if(i.name=="PseudoClassName")return{from:i.from,options:om,validFor:Fn};if(i.name=="TagName"){for(let{parent:o}=i;o;o=o.parent)if(o.name=="Block")return{from:i.from,options:fc(),validFor:Fn};return{from:i.from,options:GC,validFor:Fn}}if(!n.explicit)return null;let r=i.resolve(t),s=r.childBefore(t);return s&&s.name==":"&&r.name=="PseudoClassSelector"?{from:t,options:om,validFor:Fn}:s&&s.name==":"&&r.name=="Declaration"||r.name=="ArgList"?{from:t,options:am,validFor:Fn}:r.name=="Block"?{from:t,options:fc(),validFor:Fn}:null},Hl=vs.define({name:"css",parser:_C.configure({props:[Go.add({Declaration:Ja()}),Jo.add({Block:uy})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function YC(){return new Ro(Hl,Hl.data.of({autocomplete:JC}))}const HC=1,lm=294,hm=2,KC=3,Ra=295,eI=4,tI=296,cm=297,iI=299,nI=300,rI=5,sI=6,oI=1,aI=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],nS=125,lI=123,hI=59,um=47,cI=42,uI=43,fI=45,dI=36,pI=96,gI=92,mI=new Zb({start:!1,shift(n,e){return e==rI||e==sI||e==iI?n:e==nI},strict:!1}),OI=new ii((n,e)=>{let{next:t}=n;(t==nS||t==-1||e.context)&&e.canShift(cm)&&n.acceptToken(cm)},{contextual:!0,fallback:!0}),yI=new ii((n,e)=>{let{next:t}=n,i;aI.indexOf(t)>-1||t==um&&((i=n.peek(1))==um||i==cI)||t!=nS&&t!=hI&&t!=-1&&!e.context&&e.canShift(lm)&&n.acceptToken(lm)},{contextual:!0}),bI=new ii((n,e)=>{let{next:t}=n;if((t==uI||t==fI)&&(n.advance(),t==n.next)){n.advance();let i=!e.context&&e.canShift(hm);n.acceptToken(i?hm:KC)}},{contextual:!0}),SI=new ii(n=>{for(let e=!1,t=0;;t++){let{next:i}=n;if(i<0){t&&n.acceptToken(Ra);break}else if(i==pI){t?n.acceptToken(Ra):n.acceptToken(tI,1);break}else if(i==lI&&e){t==1?n.acceptToken(eI,1):n.acceptToken(Ra,-1);break}else if(i==10&&t){n.advance(),n.acceptToken(Ra);break}else i==gI&&n.advance();e=i==dI,n.advance()}}),wI=new ii((n,e)=>{if(!(n.next!=101||!e.dialectEnabled(oI))){n.advance();for(let t=0;t<6;t++){if(n.next!="xtends".charCodeAt(t))return;n.advance()}n.next>=57&&n.next<=65||n.next>=48&&n.next<=90||n.next==95||n.next>=97&&n.next<=122||n.next>160||n.acceptToken(HC)}}),vI=Cs({"get set async static":b.modifier,"for while do if else switch try catch finally return throw break continue default case":b.controlKeyword,"in of await yield void typeof delete instanceof":b.operatorKeyword,"let var const function class extends":b.definitionKeyword,"import export from":b.moduleKeyword,"with debugger as new":b.keyword,TemplateString:b.special(b.string),super:b.atom,BooleanLiteral:b.bool,this:b.self,null:b.null,Star:b.modifier,VariableName:b.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":b.function(b.variableName),VariableDefinition:b.definition(b.variableName),Label:b.labelName,PropertyName:b.propertyName,PrivatePropertyName:b.special(b.propertyName),"CallExpression/MemberExpression/PropertyName":b.function(b.propertyName),"FunctionDeclaration/VariableDefinition":b.function(b.definition(b.variableName)),"ClassDeclaration/VariableDefinition":b.definition(b.className),PropertyDefinition:b.definition(b.propertyName),PrivatePropertyDefinition:b.definition(b.special(b.propertyName)),UpdateOp:b.updateOperator,LineComment:b.lineComment,BlockComment:b.blockComment,Number:b.number,String:b.string,ArithOp:b.arithmeticOperator,LogicOp:b.logicOperator,BitOp:b.bitwiseOperator,CompareOp:b.compareOperator,RegExp:b.regexp,Equals:b.definitionOperator,Arrow:b.function(b.punctuation),": Spread":b.punctuation,"( )":b.paren,"[ ]":b.squareBracket,"{ }":b.brace,"InterpolationStart InterpolationEnd":b.special(b.brace),".":b.derefOperator,", ;":b.separator,"@":b.meta,TypeName:b.typeName,TypeDefinition:b.definition(b.typeName),"type enum interface implements namespace module declare":b.definitionKeyword,"abstract global Privacy readonly override":b.modifier,"is keyof unique infer":b.operatorKeyword,JSXAttributeValue:b.attributeValue,JSXText:b.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":b.angleBracket,"JSXIdentifier JSXNameSpacedName":b.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":b.attributeName,"JSXBuiltin/JSXIdentifier":b.standard(b.tagName)}),kI={__proto__:null,export:18,as:23,from:29,default:32,async:37,function:38,this:50,true:58,false:58,null:68,void:72,typeof:76,super:92,new:126,await:143,yield:145,delete:146,class:156,extends:158,public:213,private:213,protected:213,readonly:215,instanceof:234,satisfies:237,in:238,const:240,import:272,keyof:327,unique:331,infer:337,is:373,abstract:393,implements:395,type:397,let:400,var:402,interface:409,enum:413,namespace:419,module:421,declare:425,global:429,for:450,of:459,while:462,with:466,do:470,if:474,else:476,switch:480,case:486,try:492,catch:496,finally:500,return:504,throw:508,break:512,continue:516,debugger:520},xI={__proto__:null,async:113,get:115,set:117,public:175,private:175,protected:175,static:177,abstract:179,override:181,readonly:187,accessor:189,new:377},TI={__proto__:null,"<":133},QI=Ps.deserialize({version:14,states:"$CWO`QdOOO$}QdOOO)WQ(C|O'#ChO)_OWO'#DYO+jQdO'#D_O+zQdO'#DjO$}QdO'#DtO.OQdO'#DzOOQ(C['#ET'#ETO.fQ`O'#EQOOQO'#IW'#IWO.nQ`O'#GgOOQO'#Ee'#EeO.yQ`O'#EdO/OQ`O'#EdO1QQ(C|O'#JQO3nQ(C|O'#JRO4_Q`O'#FSO4dQ!bO'#FkOOQ(C['#F['#F[O4oO#tO'#F[O4}Q&jO'#FrO6bQ`O'#FqOOQ(C['#JR'#JROOQ(CW'#JQ'#JQOOQS'#Jk'#JkO6gQ`O'#H{O6lQ(ChO'#H|OOQS'#Iu'#IuOOQS'#IO'#IOQ`QdOOO$}QdO'#DlO6tQ`O'#GgO6yQ&jO'#CmO7XQ`O'#EcO7dQ`O'#EnO7iQ&jO'#FZO8TQ`O'#GgO8YQ`O'#GkO8eQ`O'#GkO8sQ`O'#GnO8sQ`O'#GoO8sQ`O'#GqO6tQ`O'#GtO9dQ`O'#GwO:uQ`O'#CdO;VQ`O'#HUO;_Q`O'#H[O;_Q`O'#H^O`QdO'#H`O;_Q`O'#HbO;_Q`O'#HeO;dQ`O'#HkO;iQ(CjO'#HqO$}QdO'#HsO;tQ(CjO'#HuOWQpO'#FZO$}QdO'#DZOOOW'#IQ'#IQO>`OWO,59tOOQ(C[,59t,59tO>kQdO'#IRO?OQ`O'#JSOAQQtO'#JSO)jQdO'#JSOAXQ`O,59yOAoQ`O'#EeOA|Q`O'#J`OBXQ`O'#J_OBXQ`O'#J_OBaQ`O,5;ROBfQ`O'#J^OOQ(C[,5:U,5:UOBmQdO,5:UODnQ(C|O,5:`OE_Q`O,5:fOEdQ`O'#J[OF^Q(ChO'#J]O8YQ`O'#J[OFeQ`O'#J[OFmQ`O,5;QOFrQ`O'#J[OOQ(C]'#Ch'#ChO$}QdO'#DzOGfQpO,5:lOOQO'#JX'#JXOOQO-EgOOQS'#Ix'#IxOOQS,5>h,5>hOOQS-E;|-E;|O!.xQ(C|O,5:WOOQ(CX'#Cp'#CpO!/lQ&kO,5=ROOQO'#Cf'#CfO!/}Q(ChO'#IyO6bQ`O'#IyO;dQ`O,59XO!0`Q!bO,59XO!0hQ&jO,59XO6yQ&jO,59XO!0sQ`O,5;OO!0{Q`O'#HTO!1ZQ`O'#JoO$}QdO,5;sO!1cQ,UO,5;uO!1hQ`O,5=nO!1mQ`O,5=nO!1rQ`O,5=nO6lQ(ChO,5=nO!2QQ`O'#EgO!2wQ,UO'#EhOOQ(CW'#J^'#J^O!3OQ(ChO'#JlO6lQ(ChO,5=VO8sQ`O,5=]OOQP'#Cs'#CsO!3ZQ!bO,5=YO!3cQ!cO,5=ZO!3nQ`O,5=]O!3sQpO,5=`O;dQ`O'#GyO6tQ`O'#G{O!3{Q`O'#G{O6yQ&jO'#HOO!4QQ`O'#HOOOQS,5=c,5=cO!4VQ`O'#HPO!4_Q`O'#CmO!4dQ`O,59OO!4nQ`O,59OO!6sQdO,59OOOQS,59O,59OO!7QQ(ChO,59OO$}QdO,59OO!7]QdO'#HWOOQS'#HX'#HXOOQS'#HY'#HYO`QdO,5=pO!7mQ`O,5=pO`QdO,5=vO`QdO,5=xO!7rQ`O,5=zO`QdO,5=|O!7wQ`O,5>PO!7|QdO,5>VOOQS,5>],5>]O$}QdO,5>]O6lQ(ChO,5>_OOQS,5>a,5>aO!aOOQS,5>c,5>cO!cOOQS,5>e,5>eO!mO)jQdO,5>mOOQO,5>s,5>sO!CUQdO'#IROOQO-ExOOQ(CW-E<[-E<[O#5]Q(C}O1G0tOOQ(C[1G0t1G0tO#7hQ(C|O1G1YO#8[Q!bO,5;}O#8dQ!bO,5OQ,UO'#GXOOQ(C],5=Q,5=QOKhQ&jO,5?hOKhQ&jO,5?hO#>TQ`O'#IcO#>`Q`O,5?gO#>hQ`O,59^O#?XQ&kO,59mOOQ(C],59m,59mO#?zQ&kO,5<`O#@mQ&kO,5mO$)XQ`O1G5YO$)aQ`O1G5eO$)iQtO1G5fO8YQ`O,5>sO$)sQ`O1G5bO$)sQ`O1G5bO8YQ`O1G5bO$){Q(C|O1G5cO$}QdO1G5cO$*]Q(ChO1G5cO$*nQ`O,5>uO8YQ`O,5>uOOQO,5>u,5>uO$+SQ`O,5>uOOQO-Ez,5>zO$8rQ`O,5>zOOQ(C]1G2Z1G2ZP$8wQ`O'#I`POQ(C]-E<^-E<^O$9hQ&kO1G2gO$:ZQ&kO1G2iO$:eQqO1G2kOOQ(C]1G2S1G2SO$:lQ`O'#I_O$:zQ`O,5@SO$:zQ`O,5@SO$;SQ`O,5@SO$;_Q`O,5@SOOQO1G2U1G2UO$;mQ&kO1G2TOKhQ&jO1G2TO$;}QMhO'#IaO$<_Q`O,5@TOJRQ&jO,5@TO$|,5>|OOQO-E<`-E<`OOQ(C]1G2]1G2]O!)dQ,UO,5},5>}OOQO-EkQqO'#JjO$(iQ`O7+(XO$>uQ`O7+(XO$>}QqO7+(XO$?XQ(CyO'#ChO$?lQ(CyO,5ROOQS,5>R,5>RO$}QdO'#HhO$EoQ`O'#HjOOQS,5>X,5>XO8YQ`O,5>XOOQS,5>Z,5>ZOOQS7+)]7+)]OOQS7+)c7+)cOOQS7+)g7+)gOOQS7+)i7+)iO$EtQ!bO1G5[O$FYQ!LUO1G0oO$FdQ`O1G0oOOQO1G/k1G/kO$FoQ!LUO1G/kO$FyQ`O,5?pO;dQ`O1G/kOMqQdO'#DeOOQO,5>n,5>nOOQO-Et,5>tOOQO-EoOOQO-EpO$}QdO,5>pOOQO-ExOOOO7+'_7+'_OOOW1G/S1G/SOOQ(C]1G4f1G4fOKhQ&jO7+(VO%7}Q`O,5>yO6tQ`O,5>yOOQO-E<]-E<]O%8]Q`O1G5nO%8]Q`O1G5nO%8eQ`O1G5nO%8pQ&kO7+'oO%9QQqO,5>{O%9[Q`O,5>{OJRQ&jO,5>{OOQO-E<_-E<_O%9aQqO1G5oO%9kQ`O1G5oOOQ(CW1G2_1G2_O$VQdO'#JUO%>^Q,UO'#E[O%>tQ(ChO'#E[O$$sQ(DjO'#E[O$%hQ,UO'#G}OOQO'#Ih'#IhO%?YQ,UO,5=hOOQS,5=h,5=hO%?aQ,UO'#E[O%?rQ,UO'#E[O%@YQ,UO'#E[O%@vQ,UO'#G}O%AXQ`O7+(mO%A^Q`O7+(mO%AfQqO7+(mOOQS7+(m7+(mOJRQ&jO7+(mO$}QdO7+(mOJRQ&jO7+(mO%ApQaO7+(mOOQS7+(p7+(pO6lQ(ChO7+(pO#=PQ`O7+(pO6bQ`O7+(pO!0`Q!bO7+(pO%BOQ`O,5?TOOQO-ESOOQS,5>U,5>UO%CYQ`O1G3sO8YQ`O7+&ZOMqQdO7+&ZOOQ(CW1G5[1G5[OOQO7+%V7+%VO%C_Q!LUO1G5fO;dQ`O7+%VO;dQ`O1G0VOOQO1G0b1G0bO$}QdO1G0bO%CiQ(ChO1G0bO%CtQ(ChO1G0bO!0`Q!bO1G0VO$%_Q,UO1G0VO%DSQ,UO1G0VO%DaQ(DjO1G0bO%D{Q,UO1G0VO$%_Q,UO1G0bO%E]Q,UO1G0bO%EvQ(ChO1G0bOOQO1G0V1G0VO%F[Q(C|O1G0bOOQ(C[<VQdO,5iQ!LVO7+'qO&@_Q&kOG26wOOQO<wAN>wO;dQ`OAN>wO$}QdOAN?SO!0`Q!bOAN>wO&ATQ(ChOAN?SO$%_Q,UOAN>wO&A`Q(ChOAN?SOOQS!$(!P!$(!PO$(iQ`O!$(!PO&AnQ(C}OG26wOOQ(CWG26lG26lOOQO<SO!T+rO!U'wX~O!U+tO~O!_+kO#T+jO!T#]X!U#]X~O!T+uO!U(TX~O!U+wO~O]&VOl&VO{+nO'k$vO's)TO~O!Z+xO![+xO~P!AQO_+}O!U,PO!Y,QO!Z+|O![+|O!u;WO!y,UO!z,SO!{,TO!|,RO#P,VO#Q,VO'|+zO~P!AQOP,[O!V&cO!q,ZO~Oo,aO~O!Q&ua!T&ua~P!-RO!S,eO!Q&uX!T&uX~P$}O!T&rO!Q'va~O!Q'va~P?WO!T&yO!Q(Ra~O{%WO!S,iO!V%XO'j$tO!Q&{X!T&{X~O!T'WO!e(Oa~O{%WO!V%XO#_,lO'j$tO~O#T,nO!T(Pa!e(Pa_(Pa'e(Pa~O!_#UO~P!DvO{%WO!S,qO!V%XO!uXO#^,sO#_,qO'j$tO!T&}X!e&}X~Oy,wO!f#XO~OP,{O!V&cO!q,zO%],yO'n$bO~O_#Wi!T#Wi'e#Wi'a#Wi!Q#Wi!e#Wio#Wi!V#Wi%]#Wi!_#Wi~P!-ROP=mOx(mO{(nO(U(pO(V(rO~O#`#Sa!T#Sa!e#Sa#T#Sa!V#Sa_#Sa'e#Sa!Q#Sa~P!G[O!d#WOP'qXx'qX{'qX(U'qX(V'qXQ'qXZ'qXk'qXy'qX!T'qX!c'qX!f'qX!l'qX#c'qX#d'qX#e'qX#f'qX#g'qX#h'qX#i'qX#j'qX#k'qX#m'qX#o'qX#q'qX#r'qX'r'qX'}'qX~O#`'qX_'qX'e'qX!e'qX!Q'qX'a'qX!V'qX#T'qXo'qX%]'qX!_'qX~P!HZO!T-UOe'yX~P!&VOe-WO~O!T-XO!e'zX~P!-RO!e-[O~O!Q-^O~OQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO'rROZ#bi_#bik#bi!T#bi!c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O#c#bi~P!KrO#c#_O~P!KrOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O'rROZ#bi_#bi!T#bi!c#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~Ok#bi~P!NdOk#aO~P!NdOQ#lOk#aOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO'rRO_#bi!T#bi#m#bi#o#bi#q#bi#r#bi'e#bi'}#bi(U#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~OZ#bi!c#bi#h#bi#i#bi#j#bi#k#bi~P##UOZ#sO!c#cO#h#cO#i#cO#j#rO#k#cO~P##UOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO'rRO_#bi!T#bi#o#bi#q#bi#r#bi'e#bi'}#bi(V#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O(U#bi~P#&VO(U#]O~P#&VOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO#o#fO'rRO(U#]O_#bi!T#bi#q#bi#r#bi'e#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~O(V#bi~P#(wO(V#^O~P#(wOQ#lOZ#sOk#aOx#YOy#ZO{#[O!c#cO!d#WO!f#XO!l#lO#c#_O#d#`O#e#`O#f#`O#g#bO#h#cO#i#cO#j#rO#k#cO#m#dO#o#fO#q#hO'rRO(U#]O(V#^O~O_#bi!T#bi#r#bi'e#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~P#+iOQ[XZ[Xk[Xx[Xy[X{[X!c[X!d[X!f[X!l[X#T[X#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X!T[X!U[X~O#u[X~P#.SOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO#q;hO#r;iO'rRO'}#jO(U#]O(V#^O~O#u-`O~P#0aOQ'uXZ'uXk'uXx'uXy'uX{'uX!c'uX!d'uX!f'uX!l'uX#c'uX#d'uX#e'uX#f'uX#g'uX#h'uX#i'uX#j'uX#m'uX#o'uX#q'uX#r'uX'r'uX'}'uX(U'uX(V'uX!T'uX~O#T;nO#w;nO#k'uX#u'uX!U'uX~P#2_O_'Qa!T'Qa'e'Qa'a'Qa!e'Qao'Qa!Q'Qa!V'Qa%]'Qa!_'Qa~P!-ROQ#biZ#bi_#bik#biy#bi!T#bi!c#bi!d#bi!f#bi!l#bi#c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi'e#bi'r#bi'}#bi'a#bi!Q#bi!e#bio#bi!V#bi%]#bi!_#bi~P!G[O_#vi!T#vi'e#vi'a#vi!Q#vi!e#vio#vi!V#vi%]#vi!_#vi~P!-RO$S-cO$U-cO~O$S-dO$U-dO~O!_(VO#T-eO!V$YX$P$YX$S$YX$U$YX$]$YX~O!S-fO~O!V(YO$P-hO$S(XO$U(XO$]-iO~O!T;jO!U'tX~P#0aO!U-jO~O$]-lO~OS(hO'c(iO'd-oO~O]-rOl-rO!Q-sO~O!TdX!_dX!edX!e$oX'}dX~P!$|O!e-yO~P!G[O!T-zO!_#UO'}'SO!e([X~O!e.PO~O!S(yO'j$tO!e([P~O#`.RO~O!Q$oX!T$oX!_$vX~P!$|O!T.SO!Q(]X~P!G[O!_.UO~O!Q.WO~Ok.[O!_#UO!f$mO'n$bO'}'SO~O'j.^O~O!_)yO~O_$pO!T.bO'e$pO~O!U.dO~P!(wO!Z.eO![.eO'k$vO's)TO~O{.gO's)TO~O#P.hO~O'j%^Oe'VX!T'VX~O!T)dOe'oa~Oe.mO~Ox.nOy.nO{.oOPua(Uua(Vua!Tua#Tua~Oeua#uua~P#>mOx(mO{(nOP$ha(U$ha(V$ha!T$ha#T$ha~Oe$ha#u$ha~P#?cOx(mO{(nOP$ja(U$ja(V$ja!T$ja#T$ja~Oe$ja#u$ja~P#@UO].pO~O#`.qO~Oe$xa!T$xa#T$xa#u$xa~P!&VO#`.tO~OP,{O!V&cO!q,zO%],yO~O]$SOk$TOl$SOm$SOr$dOt$eOv;oO{$[O!V$]O!a=`O!f$XO#_;xO#|$iO$i;rO$k;uO$n$jO'n$bO'r$UO~Oi.{O'j.zO~P#AvO!_)yO!V'ma_'ma!T'ma'e'ma~O#`/RO~OZ[X!TdX!UdX~O!T/SO!U(dX~O!U/UO~OZ/VO~O]/XO'j*RO~O!V%OO'j$tO^'_X!T'_X~O!T*WO^(ca~O!e/[O~P!-RO]/^O~OZ/_O~O^/`O~O!T*dO_(`a'e(`a~O#T/fO~OP/iO!V$]O~O's'lO!U(aP~OP/sO!V/oO!q/rO%]/qO'n$bO~OZ/}O!T/{O!U(bX~O!U0OO~O^0QO_$pO'e$pO~O]0RO~O]0SO'j!|O~O#k0TO%}0UO~P1nO#T#tO#k0TO%}0UO~O_0VO~P$}O_0XO~O&W0]OQ&UiR&UiX&Ui]&Ui_&Uib&Uic&Uii&Uik&Uil&Uim&Uir&Uit&Uiv&Ui{&Ui!O&Ui!P&Ui!V&Ui!a&Ui!f&Ui!i&Ui!j&Ui!k&Ui!l&Ui!m&Ui!p&Ui!u&Ui#l&Ui#|&Ui$Q&Ui%[&Ui%^&Ui%`&Ui%a&Ui%d&Ui%f&Ui%i&Ui%j&Ui%l&Ui%y&Ui&P&Ui&R&Ui&T&Ui&V&Ui&Y&Ui&`&Ui&f&Ui&h&Ui&j&Ui&l&Ui&n&Ui'a&Ui'j&Ui'r&Ui'|&Ui(Z&Ui!U&Ui`&Ui&]&Ui~O`0cO!U0aO&]0bO~P`O!VTO!f0eO~O&d+aOQ&_iR&_iX&_i]&_i_&_ib&_ic&_ii&_ik&_il&_im&_ir&_it&_iv&_i{&_i!O&_i!P&_i!V&_i!a&_i!f&_i!i&_i!j&_i!k&_i!l&_i!m&_i!p&_i!u&_i#l&_i#|&_i$Q&_i%[&_i%^&_i%`&_i%a&_i%d&_i%f&_i%i&_i%j&_i%l&_i%y&_i&P&_i&R&_i&T&_i&V&_i&Y&_i&`&_i&f&_i&h&_i&j&_i&l&_i&n&_i'a&_i'j&_i'r&_i'|&_i(Z&_i!U&_i&W&_i`&_i&]&_i~O!Q0kO~O!T!Xa!U!Xa~P#0aO!S0rO!Y&bO!Z&ZO![&ZO!T&vX!U&vX~P!AQO!T+rO!U'wa~O!T&|X!U&|X~P!2fO!T+uO!U(Ta~O!Y0{O!Z0zO![0zO!u;WO!y1OO!z0}O!{0}O!|0|O#P1PO#Q1PO'|+zO~P!AQO_$pO!_#UO!f$mO!l1UO#T1SO'e$pO'n$bO'}'SO~O]&VOl&VO{+nO's)TO'|+zO~O_+}O!U1XO!Y,QO!Z+|O![+|O!u;WO!y,UO!z,SO!{,TO!|,RO#P,VO#Q,VO'|+zO~P!AQO!Z0zO![0zO'|+zO~P!AQO!Y0{O!Z0zO![0zO'|+zO~P!AQO!VTO!Y0{O!Z0zO![0zO!|0|O#P1PO#Q1PO'|+zO~P!AQO!Y0{O!Z0zO![0zO!z0}O!{0}O!|0|O#P1PO#Q1PO'|+zO~P!AQO!V&cO~O!V&cO~P!G[O!T#pOo$ga~O!Q&ui!T&ui~P!-RO!T&rO!Q'vi~O!T&yO!Q(Ri~O!Q(Si!T(Si~P!-RO!T'WO!e(Oi~O!T(Pi!e(Pi_(Pi'e(Pi~P!-RO#T1eO!T(Pi!e(Pi_(Pi'e(Pi~O{%WO!V%XO!uXO#^1hO#_1gO'j$tO~O{%WO!V%XO#_1gO'j$tO~OP1pO!V&cO!q1oO%]1nO~OP1pO!V&cO!q1oO%]1nO'n$bO~O#`uaQuaZua_uakua!cua!dua!fua!lua#cua#dua#eua#fua#gua#hua#iua#jua#kua#mua#oua#qua#rua'eua'rua'}ua!eua!Qua'aua!Vuaoua%]ua!_ua~P#>mO#`$haQ$haZ$ha_$hak$hay$ha!c$ha!d$ha!f$ha!l$ha#c$ha#d$ha#e$ha#f$ha#g$ha#h$ha#i$ha#j$ha#k$ha#m$ha#o$ha#q$ha#r$ha'e$ha'r$ha'}$ha!e$ha!Q$ha'a$ha!V$hao$ha%]$ha!_$ha~P#?cO#`$jaQ$jaZ$ja_$jak$jay$ja!c$ja!d$ja!f$ja!l$ja#c$ja#d$ja#e$ja#f$ja#g$ja#h$ja#i$ja#j$ja#k$ja#m$ja#o$ja#q$ja#r$ja'e$ja'r$ja'}$ja!e$ja!Q$ja'a$ja!V$jao$ja%]$ja!_$ja~P#@UO#`$xaQ$xaZ$xa_$xak$xay$xa!T$xa!c$xa!d$xa!f$xa!l$xa#c$xa#d$xa#e$xa#f$xa#g$xa#h$xa#i$xa#j$xa#k$xa#m$xa#o$xa#q$xa#r$xa'e$xa'r$xa'}$xa!e$xa!Q$xa'a$xa!V$xa#T$xao$xa%]$xa!_$xa~P!G[O_#Wq!T#Wq'e#Wq'a#Wq!Q#Wq!e#Wqo#Wq!V#Wq%]#Wq!_#Wq~P!-ROe&wX!T&wX~PKhO!T-UOe'ya~O!S1xO!T&xX!e&xX~P$}O!T-XO!e'za~O!T-XO!e'za~P!-RO!Q1{O~O#u!ha!U!ha~PBtO#u!`a!T!`a!U!`a~P#0aO!V2^O$QbO$Z2_O~O!U2cO~Oo2dO~P!G[O_$dq!T$dq'e$dq'a$dq!Q$dq!e$dqo$dq!V$dq%]$dq!_$dq~P!-RO!Q2eO~O]-rOl-rO~Ox(mO{(nO(V(rOP%Ti(U%Ti!T%Ti#T%Ti~Oe%Ti#u%Ti~P$9POx(mO{(nOP%Vi(U%Vi(V%Vi!T%Vi#T%Vi~Oe%Vi#u%Vi~P$9rO'}#jO~P!G[O!S2hO'j$tO!T'RX!e'RX~O!T-zO!e([a~O!T-zO!_#UO!e([a~O!T-zO!_#UO'}'SO!e([a~Oe$qi!T$qi#T$qi#u$qi~P!&VO!S2pO'j)OO!Q'TX!T'TX~P!&tO!T.SO!Q(]a~O!T.SO!Q(]a~P!G[O!_#UO~O!_#UO#k2xO~Ok2{O!_#UO'}'SO~Oe'pi!T'pi~P!&VO#T3OOe'pi!T'pi~P!&VO!e3RO~O_$eq!T$eq'e$eq'a$eq!Q$eq!e$eqo$eq!V$eq%]$eq!_$eq~P!-RO!T3VO!V(^X~P!G[O!V&cO%]1nO~O!V&cO%]1nO~P!G[O!V$oX%Q[X_$oX!T$oX'e$oX~P!$|O%Q3XOPhXxhX{hX!VhX(UhX(VhX_hX!ThX'ehX~O%Q3XO~O]3_O%^3`O'j*RO!T'^X!U'^X~O!T/SO!U(da~OZ3dO~O^3eO~O]3hO~O!Q3iO~O_$pO'e$pO~P!G[O!V$]O~P!G[O!T3nO#T3pO!U(aX~O!U3qO~O]&VOl&VO{3sO!Y4OO!Z3wO![3wO!u;WO!y3}O!z3|O!{3|O#P3{O#Q,VO'k$vO's)TO'|+zO~O!U3zO~P$BTOP4VO!V/oO!q4UO%]4TO~OP4VO!V/oO!q4UO%]4TO'n$bO~O'j!|O!T']X!U']X~O!T/{O!U(ba~O]4aO's4`O~O]4bO~O^4dO~O!e4gO~P$}O_4iO~O_4iO~P$}O#k4kO%}4lO~PExO`0cO!U4pO&]0bO~P`O!_4rO~O!_4tO!T'xi!U'xi!_'xi!f'xi'n'xi~O!T#]i!U#]i~P#0aO#T4uO!T#]i!U#]i~O!T!Xi!U!Xi~P#0aO!Q4vO~O]!tal!ta!Y!ta!Z!ta![!ta!y!ta!z!ta!{!ta!|!ta#P!ta#Q!ta'k!ta's!ta'|!ta~PGQO_$pO!_#UO!f$mO!l5OO#T4|O'e$pO'n$bO'}'SO~O!Z5QO![5QO'|+zO~P!AQO!Y5RO!Z5QO![5QO'|+zO~P!AQO!Y5RO!Z5QO![5QO!|5TO#P5UO#Q5UO'|+zO~P!AQO!Y5RO!Z5QO![5QO!z5VO!{5VO!|5TO#P5UO#Q5UO'|+zO~P!AQO_$pO#T4|O'e$pO~O_$pO!_#UO#T4|O'e$pO~O_$pO!_#UO!l5OO#T4|O'e$pO'}'SO~O!T'WO!e(Oq~O!T(Pq!e(Pq_(Pq'e(Pq~P!-RO{%WO!V%XO#_5aO'j$tO~O!V&cO%]5cO~O!V&cO%]5cO~P!G[OP5hO!V&cO!q5gO%]5cO~O#`%TiQ%TiZ%Ti_%Tik%Tiy%Ti!c%Ti!d%Ti!f%Ti!l%Ti#c%Ti#d%Ti#e%Ti#f%Ti#g%Ti#h%Ti#i%Ti#j%Ti#k%Ti#m%Ti#o%Ti#q%Ti#r%Ti'e%Ti'r%Ti'}%Ti!e%Ti!Q%Ti'a%Ti!V%Tio%Ti%]%Ti!_%Ti~P$9PO#`%ViQ%ViZ%Vi_%Vik%Viy%Vi!c%Vi!d%Vi!f%Vi!l%Vi#c%Vi#d%Vi#e%Vi#f%Vi#g%Vi#h%Vi#i%Vi#j%Vi#k%Vi#m%Vi#o%Vi#q%Vi#r%Vi'e%Vi'r%Vi'}%Vi!e%Vi!Q%Vi'a%Vi!V%Vio%Vi%]%Vi!_%Vi~P$9rO#`$qiQ$qiZ$qi_$qik$qiy$qi!T$qi!c$qi!d$qi!f$qi!l$qi#c$qi#d$qi#e$qi#f$qi#g$qi#h$qi#i$qi#j$qi#k$qi#m$qi#o$qi#q$qi#r$qi'e$qi'r$qi'}$qi!e$qi!Q$qi'a$qi!V$qi#T$qio$qi%]$qi!_$qi~P!G[Oe&wa!T&wa~P!&VO!T&xa!e&xa~P!-RO!T-XO!e'zi~O#u#Wi!T#Wi!U#Wi~P#0aOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO'rROZ#bik#bi!c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~O#c#bi~P%&nO#c;_O~P%&nOQ#lOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O'rROZ#bi!c#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~Ok#bi~P%(yOk;aO~P%(yOQ#lOk;aOx#YOy#ZO{#[O!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO'rRO#m#bi#o#bi#q#bi#r#bi#u#bi'}#bi(U#bi(V#bi!T#bi!U#bi~OZ#bi!c#bi#h#bi#i#bi#j#bi#k#bi~P%+UOZ;mO!c;cO#h;cO#i;cO#j;lO#k;cO~P%+UOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO'rRO#o#bi#q#bi#r#bi#u#bi'}#bi(V#bi!T#bi!U#bi~O(U#bi~P%-pO(U#]O~P%-pOQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO'rRO(U#]O#q#bi#r#bi#u#bi'}#bi!T#bi!U#bi~O(V#bi~P%/{O(V#^O~P%/{OQ#lOZ;mOk;aOx#YOy#ZO{#[O!c;cO!d#WO!f#XO!l#lO#c;_O#d;`O#e;`O#f;`O#g;bO#h;cO#i;cO#j;lO#k;cO#m;dO#o;fO#q;hO'rRO(U#]O(V#^O~O#r#bi#u#bi'}#bi!T#bi!U#bi~P%2WO_#sy!T#sy'e#sy'a#sy!Q#sy!e#syo#sy!V#sy%]#sy!_#sy~P!-ROP=oOx(mO{(nO(U(pO(V(rO~OQ#biZ#bik#biy#bi!c#bi!d#bi!f#bi!l#bi#c#bi#d#bi#e#bi#f#bi#g#bi#h#bi#i#bi#j#bi#k#bi#m#bi#o#bi#q#bi#r#bi#u#bi'r#bi'}#bi!T#bi!U#bi~P%5OO#u'qX!U'qX~P!HZO#u#vi!T#vi!U#vi~P#0aO!U5tO~O!T'Qa!U'Qa~P#0aO!_#UO'}'SO!T'Ra!e'Ra~O!T-zO!e([i~O!T-zO!_#UO!e([i~Oe$qq!T$qq#T$qq#u$qq~P!&VO!Q'Ta!T'Ta~P!G[O!_5{O~O!T.SO!Q(]i~P!G[O!T.SO!Q(]i~O!Q6PO~O!_#UO#k6UO~Ok6VO!_#UO'}'SO~O!Q6XO~Oe$sq!T$sq#T$sq#u$sq~P!&VO_$ey!T$ey'e$ey'a$ey!Q$ey!e$eyo$ey!V$ey%]$ey!_$ey~P!-RO!T3VO!V(^a~O_#Wy!T#Wy'e#Wy'a#Wy!Q#Wy!e#Wyo#Wy!V#Wy%]#Wy!_#Wy~P!-ROZ6^O~O]6`O'j*RO~O!T/SO!U(di~O]6cO~O^6dO~O!_4tO~O's'lO!T'YX!U'YX~O!T3nO!U(aa~O!f$mO'n$bO_'xX!_'xX!l'xX#T'xX'e'xX'}'xX~O'j6mO~P,RO!u;WO!y6oO!z6nO!{6nO#P1PO#Q1PO~P$%_O_$pO!_#UO!l1UO#T1SO'e$pO'}'SO~O!U6rO~P$BTO]&VOl&VO{6sO's)TO'|+zO~O!Y6wO!Z6vO![6vO#P1PO#Q1PO'|+zO~P!AQO!Y6wO!Z6vO![6vO!z6xO!{6xO#P1PO#Q1PO'|+zO~P!AQO!Z6vO![6vO'k$vO's)TO'|+zO~O!V/oO~O!V/oO%]6zO~O!V/oO%]6zO~P!G[OP7PO!V/oO!q7OO%]6zO~OZ7UO!T']a!U']a~O!T/{O!U(bi~O]7XO~O!e7YO~O!e7ZO~O!e7[O~O!e7[O~P$}O_7^O~O!_7aO~O!e7bO~O!T(Si!U(Si~P#0aO_$pO#T7iO'e$pO~O_$pO!_#UO#T7iO'e$pO~O!Z7mO![7mO'|+zO~P!AQO_$pO!_#UO!f$mO!l7nO#T7iO'e$pO'n$bO'}'SO~O!Y7oO!Z7mO![7mO'|+zO~P!AQO!Y7oO!Z7mO![7mO!|7rO#P7sO#Q7sO'|+zO~P!AQO_$pO!_#UO!l7nO#T7iO'e$pO'}'SO~O_$pO'e$pO~P!-RO!T'WO!e(Oy~O!T(Py!e(Py_(Py'e(Py~P!-RO!V&cO%]7xO~O!V&cO%]7xO~P!G[O#`$qqQ$qqZ$qq_$qqk$qqy$qq!T$qq!c$qq!d$qq!f$qq!l$qq#c$qq#d$qq#e$qq#f$qq#g$qq#h$qq#i$qq#j$qq#k$qq#m$qq#o$qq#q$qq#r$qq'e$qq'r$qq'}$qq!e$qq!Q$qq'a$qq!V$qq#T$qqo$qq%]$qq!_$qq~P!G[O#`$sqQ$sqZ$sq_$sqk$sqy$sq!T$sq!c$sq!d$sq!f$sq!l$sq#c$sq#d$sq#e$sq#f$sq#g$sq#h$sq#i$sq#j$sq#k$sq#m$sq#o$sq#q$sq#r$sq'e$sq'r$sq'}$sq!e$sq!Q$sq'a$sq!V$sq#T$sqo$sq%]$sq!_$sq~P!G[O!T&xi!e&xi~P!-RO#u#Wq!T#Wq!U#Wq~P#0aOx.nOy.nO{.oOPua(Uua(Vua!Uua~OQuaZuakua!cua!dua!fua!lua#cua#dua#eua#fua#gua#hua#iua#jua#kua#mua#oua#qua#rua#uua'rua'}ua!Tua~P%LmOx(mO{(nOP$ha(U$ha(V$ha!U$ha~OQ$haZ$hak$hay$ha!c$ha!d$ha!f$ha!l$ha#c$ha#d$ha#e$ha#f$ha#g$ha#h$ha#i$ha#j$ha#k$ha#m$ha#o$ha#q$ha#r$ha#u$ha'r$ha'}$ha!T$ha~P%NtOx(mO{(nOP$ja(U$ja(V$ja!U$ja~OQ$jaZ$jak$jay$ja!c$ja!d$ja!f$ja!l$ja#c$ja#d$ja#e$ja#f$ja#g$ja#h$ja#i$ja#j$ja#k$ja#m$ja#o$ja#q$ja#r$ja#u$ja'r$ja'}$ja!T$ja~P&!{OQ$xaZ$xak$xay$xa!c$xa!d$xa!f$xa!l$xa#c$xa#d$xa#e$xa#f$xa#g$xa#h$xa#i$xa#j$xa#k$xa#m$xa#o$xa#q$xa#r$xa#u$xa'r$xa'}$xa!T$xa!U$xa~P%5OO#u$dq!T$dq!U$dq~P#0aO#u$eq!T$eq!U$eq~P#0aO!U8RO~O#u8SO~P!&VO!_#UO!T'Ri!e'Ri~O!_#UO'}'SO!T'Ri!e'Ri~O!T-zO!e([q~O!Q'Ti!T'Ti~P!G[O!T.SO!Q(]q~O!Q8YO~P!G[O!Q8YO~Oe'py!T'py~P!&VO!T'Wa!V'Wa~P!G[O!V%Pq_%Pq!T%Pq'e%Pq~P!G[OZ8_O~O!T/SO!U(dq~O]8bO~O#T8cO!T'Ya!U'Ya~O!T3nO!U(ai~P#0aOQ[XZ[Xk[Xx[Xy[X{[X!Q[X!T[X!c[X!d[X!f[X!l[X#T[X#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X~O!_$}X#k$}X~P&*pO#P5UO#Q5UO~P$%_O!z8gO!{8gO#P5UO#Q5UO~P$%_O!Z8jO![8jO'k$vO's)TO'|+zO~O!Y8mO!Z8jO![8jO#P5UO#Q5UO'|+zO~P!AQO!V/oO%]8pO~O!V/oO%]8pO~P!G[O]8wO's8vO~O!T/{O!U(bq~O!e8yO~O!e8yO~P$}O!e8{O~O!e8|O~O#T9OO!T#]y!U#]y~O!T#]y!U#]y~P#0aO_$pO#T9RO'e$pO~O_$pO!_#UO#T9RO'e$pO~O!Z9WO![9WO'|+zO~P!AQO_$pO!_#UO!l9XO#T9RO'e$pO'}'SO~O!f$mO'n$bO~P&0|O!Y9YO!Z9WO![9WO'|+zO~P!AQO!V&cO%]9^O~O!V&cO%]9^O~P!G[O#u#sy!T#sy!U#sy~P#0aOQ$qiZ$qik$qiy$qi!c$qi!d$qi!f$qi!l$qi#c$qi#d$qi#e$qi#f$qi#g$qi#h$qi#i$qi#j$qi#k$qi#m$qi#o$qi#q$qi#r$qi#u$qi'r$qi'}$qi!T$qi!U$qi~P%5OOx(mO{(nO(V(rOP%Ti(U%Ti!U%Ti~OQ%TiZ%Tik%Tiy%Ti!c%Ti!d%Ti!f%Ti!l%Ti#c%Ti#d%Ti#e%Ti#f%Ti#g%Ti#h%Ti#i%Ti#j%Ti#k%Ti#m%Ti#o%Ti#q%Ti#r%Ti#u%Ti'r%Ti'}%Ti!T%Ti~P&4cOx(mO{(nOP%Vi(U%Vi(V%Vi!U%Vi~OQ%ViZ%Vik%Viy%Vi!c%Vi!d%Vi!f%Vi!l%Vi#c%Vi#d%Vi#e%Vi#f%Vi#g%Vi#h%Vi#i%Vi#j%Vi#k%Vi#m%Vi#o%Vi#q%Vi#r%Vi#u%Vi'r%Vi'}%Vi!T%Vi~P&6jO#u$ey!T$ey!U$ey~P#0aO#u#Wy!T#Wy!U#Wy~P#0aO!_#UO!T'Rq!e'Rq~O!T-zO!e([y~O!Q'Tq!T'Tq~P!G[O!Q9dO~P!G[O!T/SO!U(dy~O!T3nO!U(aq~O#P7sO#Q7sO~P$%_O!Z9nO![9nO'k$vO's)TO'|+zO~O!V/oO%]9qO~O!V/oO%]9qO~P!G[O!e9tO~O_$pO#T9zO'e$pO~O_$pO!_#UO#T9zO'e$pO~O!Z9}O![9}O'|+zO~P!AQO_$pO!_#UO!l:OO#T9zO'e$pO'}'SO~OQ$qqZ$qqk$qqy$qq!c$qq!d$qq!f$qq!l$qq#c$qq#d$qq#e$qq#f$qq#g$qq#h$qq#i$qq#j$qq#k$qq#m$qq#o$qq#q$qq#r$qq#u$qq'r$qq'}$qq!T$qq!U$qq~P%5OOQ$sqZ$sqk$sqy$sq!c$sq!d$sq!f$sq!l$sq#c$sq#d$sq#e$sq#f$sq#g$sq#h$sq#i$sq#j$sq#k$sq#m$sq#o$sq#q$sq#r$sq#u$sq'r$sq'}$sq!T$sq!U$sq~P%5OOe%X!Z!T%X!Z#T%X!Z#u%X!Z~P!&VO!T'Yq!U'Yq~P#0aO!T#]!Z!U#]!Z~P#0aO_$pO#T:aO'e$pO~O_$pO!_#UO#T:aO'e$pO~O#`%X!ZQ%X!ZZ%X!Z_%X!Zk%X!Zy%X!Z!T%X!Z!c%X!Z!d%X!Z!f%X!Z!l%X!Z#c%X!Z#d%X!Z#e%X!Z#f%X!Z#g%X!Z#h%X!Z#i%X!Z#j%X!Z#k%X!Z#m%X!Z#o%X!Z#q%X!Z#r%X!Z'e%X!Z'r%X!Z'}%X!Z!e%X!Z!Q%X!Z'a%X!Z!V%X!Z#T%X!Zo%X!Z%]%X!Z!_%X!Z~P!G[O_$pO#T:oO'e$pO~OP=nOx(mO{(nO(U(pO(V(rO~O]#Sal#Sa!U#Sa!Y#Sa!Z#Sa![#Sa!u#Sa!y#Sa!z#Sa!{#Sa#P#Sa#Q#Sa'k#Sa's#Sa'|#Sa~P&D[OQ%X!ZZ%X!Zk%X!Zy%X!Z!c%X!Z!d%X!Z!f%X!Z!l%X!Z#c%X!Z#d%X!Z#e%X!Z#f%X!Z#g%X!Z#h%X!Z#i%X!Z#j%X!Z#k%X!Z#m%X!Z#o%X!Z#q%X!Z#r%X!Z#u%X!Z'r%X!Z'}%X!Z!T%X!Z!U%X!Z~P%5OO]ualua!Yua!Zua![ua!uua!yua!zua!{ua#Pua#Qua'kua'sua'|ua~P%LmO]$hal$ha!Y$ha!Z$ha![$ha!u$ha!y$ha!z$ha!{$ha#P$ha#Q$ha'k$ha's$ha'|$ha~P%NtO]$jal$ja!Y$ja!Z$ja![$ja!u$ja!y$ja!z$ja!{$ja#P$ja#Q$ja'k$ja's$ja'|$ja~P&!{O]$xal$xa!U$xa!Y$xa!Z$xa![$xa!u$xa!y$xa!z$xa!{$xa#P$xa#Q$xa'k$xa's$xa'|$xa~P&D[O]%Til%Ti!Y%Ti!Z%Ti![%Ti!u%Ti!y%Ti!z%Ti!{%Ti#P%Ti#Q%Ti'k%Ti's%Ti'|%Ti~P&4cO]%Vil%Vi!Y%Vi!Z%Vi![%Vi!u%Vi!y%Vi!z%Vi!{%Vi#P%Vi#Q%Vi'k%Vi's%Vi'|%Vi~P&6jO]$qil$qi!U$qi!Y$qi!Z$qi![$qi!u$qi!y$qi!z$qi!{$qi#P$qi#Q$qi'k$qi's$qi'|$qi~P&D[O]$qql$qq!U$qq!Y$qq!Z$qq![$qq!u$qq!y$qq!z$qq!{$qq#P$qq#Q$qq'k$qq's$qq'|$qq~P&D[O]$sql$sq!U$sq!Y$sq!Z$sq![$sq!u$sq!y$sq!z$sq!{$sq#P$sq#Q$sq'k$sq's$sq'|$sq~P&D[O]%X!Zl%X!Z!U%X!Z!Y%X!Z!Z%X!Z![%X!Z!u%X!Z!y%X!Z!z%X!Z!{%X!Z#P%X!Z#Q%X!Z'k%X!Z's%X!Z'|%X!Z~P&D[Oo'tX~P/WO!QdX!TdX#TdX~P&*pOQ[XZ[Xk[Xx[Xy[X{[X!T[X!TdX!c[X!d[X!f[X!l[X#T[X#TdX#`dX#c[X#d[X#e[X#f[X#g[X#h[X#i[X#j[X#k[X#m[X#o[X#q[X#r[X#w[X'r[X'}[X(U[X(V[X~O!_dX!e[X!edX'}dX~P'$ZOQ;VOR;VO]gOb=ZOc!`OigOk;VOlgOmgOrgOt;VOv;VO{SO!OgO!PgO!VTO!a;YO!fVO!i;VO!j;VO!k;VO!l;VO!m;VO!p!_O#|!bO$QbO'j'|O'rRO'|WO(Z=XO~O]$SOi$cOk$TOl$SOm$SOr$dOt$eOv;pO{$[O!V$]O!a=aO!f$XO#_;yO#|$iO$i;sO$k;vO$n$jO'j'dO'n$bO'r$UO~O!T;jO!U$ga~O]$SOi$cOk$TOl$SOm$SOr$dOt$eOv;qO{$[O!V$]O!a=bO!f$XO#_;zO#|$iO$i;tO$k;wO$n$jO'j'dO'n$bO'r$UO~O#l(TO~P'*^O!U[X!UdX~P'$ZO!_;^O~O#`;]O~O!_#UO#`;]O~O#T;nO~O#k;cO~O#T;{O!T(SX!U(SX~O#T;nO!T(QX!U(QX~O#`;|O~Oe TypeParamList TypeDefinition ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewExpression new TypeArgList CompareOp < ) ( ArgList UnaryExpression await yield delete LogicOp BitOp ParenthesizedExpression ClassExpression class extends ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXStartTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody MethodDeclaration AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression",maxTerm:345,context:mI,nodeProps:[["closedBy",4,"InterpolationEnd",43,"]",53,"}",68,")",140,"JSXSelfCloseEndTag JSXEndTag",156,"JSXEndTag"],["group",-26,8,15,17,60,195,199,202,203,205,208,211,222,224,230,232,234,236,239,245,251,253,255,257,259,261,262,"Statement",-30,12,13,25,28,29,34,44,46,47,49,54,62,70,76,77,99,100,109,110,127,130,132,133,134,135,137,138,158,159,161,"Expression",-23,24,26,30,33,35,37,162,164,166,167,169,170,171,173,174,175,177,178,179,189,191,193,194,"Type",-3,81,92,98,"ClassItem"],["openedBy",31,"InterpolationStart",48,"[",52,"{",67,"(",139,"JSXStartTag",151,"JSXStartTag JSXStartCloseTag"]],propSources:[vI],skippedNodes:[0,5,6],repeatNodeCount:29,tokenData:"#2k~R!bOX%ZXY%uYZ'kZ[%u[]%Z]^'k^p%Zpq%uqr(Rrs)mst7]tu9guvlxyJcyzJyz{Ka{|Lm|}MW}!OLm!O!PMn!P!Q!$v!Q!R!Er!R![!G_![!]!Nc!]!^!N{!^!_# c!_!`#!`!`!a##d!a!b#%s!b!c#'h!c!}9g!}#O#(O#O#P%Z#P#Q#(f#Q#R#(|#R#S9g#S#T#)g#T#o#)}#o#p#,w#p#q#,|#q#r#-j#r#s#.S#s$f%Z$f$g%u$g#BY9g#BY#BZ#.j#BZ$IS9g$IS$I_#.j$I_$I|9g$I|$I}#1X$I}$JO#1X$JO$JT9g$JT$JU#.j$JU$KV9g$KV$KW#.j$KW&FU9g&FU&FV#.j&FV;'S9g;'S;=`Rw!^%Z!_!`YU$`W#q&lO!^%Z!_!`s]$`W]&ZOY>lYZ?lZw>lwx,jx!^>l!^!_@|!_#O>l#O#PE_#P#o>l#o#p@|#p;'S>l;'S;=`J]<%lO>l,^?qX$`WOw?lwx+_x!^?l!^!_@^!_#o?l#o#p@^#p;'S?l;'S;=`@v<%lO?l,U@aTOw@^wx,Xx;'S@^;'S;=`@p<%lO@^,U@sP;=`<%l@^,^@yP;=`<%l?l1aARX]&ZOY@|YZ@^Zw@|wx-tx#O@|#O#PAn#P;'S@|;'S;=`EX<%lO@|1aAqUOw@|wxBTx;'S@|;'S;=`Dg;=`<%lBt<%lO@|1aB[W$Z,U]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da<%lOBt&ZByW]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da<%lOBt&ZCfRO;'SBt;'S;=`Co;=`OBt&ZCtX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%lBt<%lOBt&ZDdP;=`<%lBt1aDlX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%l@|<%lOBt1aE[P;=`<%l@|1iEdY$`WOw>lwxFSx!^>l!^!_@|!_#o>l#o#p@|#p;'S>l;'S;=`Ik;=`<%lBt<%lO>l1iF]]$Z,U$`W]&ZOYGUYZ%ZZwGUwx4hx!^GU!^!_Bt!_#OGU#O#PHU#P#oGU#o#pBt#p;'SGU;'S;=`Ie<%lOGU&cG]]$`W]&ZOYGUYZ%ZZwGUwx4hx!^GU!^!_Bt!_#OGU#O#PHU#P#oGU#o#pBt#p;'SGU;'S;=`Ie<%lOGU&cHZW$`WO!^GU!^!_Bt!_#oGU#o#pBt#p;'SGU;'S;=`Hs;=`<%lBt<%lOGU&cHxX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%lGU<%lOBt&cIhP;=`<%lGU1iIpX]&ZOYBtZwBtwx/px#OBt#O#PCc#P;'SBt;'S;=`Da;=`<%l>l<%lOBt1iJ`P;=`<%l>l,TJjT!f+{$`WO!^%Z!_#o%Z#p;'S%Z;'S;=`%o<%lO%Z$PKQT!e#w$`WO!^%Z!_#o%Z#p;'S%Z;'S;=`%o<%lO%Z)ZKjW$`W'k#e#f&lOz%Zz{LS{!^%Z!_!`q#P#Q!-n#Q#o!;l#o#p!6|#p;'S!;l;'S;=`!?i<%lO!;l7Z!q#P#Q!-n#Q#o!;l#o#p!6|#p;'S!;l;'S;=`!?i<%lO!;l7Z!={[$`WU7ROY!+TYZ%ZZ!^!+T!^!_!)o!_#O!+T#O#P!,O#P#Q!&V#Q#o!+T#o#p!)o#p;'S!+T;'S;=`!,p<%lO!+T7Z!>vZ$`WOY!;lYZ!.wZz!;lz{!kI[n]||-1},{term:311,get:n=>xI[n]||-1},{term:65,get:n=>TI[n]||-1}],tokenPrec:13429}),PI=[Ut("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Ut("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Ut("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Ut("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Ut("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Ut(`try { \${} } catch (\${error}) { \${} @@ -49,5 +49,5 @@ var bS=Object.defineProperty;var SS=(n,e,t)=>e in n?bS(n,e,{enumerable:!0,config constructor(\${params}) { \${} } -}`,{label:"class",detail:"definition",type:"keyword"}),Ut('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ut('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],fm=new ST,rS=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Zs(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const AI=["FunctionDeclaration"],$I={FunctionDeclaration:Zs("function"),ClassDeclaration:Zs("class"),ClassExpression:()=>!0,EnumDeclaration:Zs("constant"),TypeAliasDeclaration:Zs("type"),NamespaceDeclaration:Zs("namespace"),VariableDefinition(n,e){n.matchContext(AI)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function sS(n,e){let t=fm.get(e);if(t)return t;let i=[],r=!0;function s(o,a){let l=n.sliceString(o.from,o.to);i.push({label:l,type:a})}return e.cursor(ce.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let a=$I[o.name];if(a&&a(o,s)||rS.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of sS(n,o.node))i.push(a);return!1}}),fm.set(e,i),i}const dm=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,oS=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function CI(n){let e=pe(n.state).resolveInner(n.pos,-1);if(oS.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&dm.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)rS.has(r.name)&&(i=i.concat(sS(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:dm}}const qn=vs.define({name:"javascript",parser:QI.configure({props:[Go.add({IfStatement:Ja({except:/^\s*({|else\b)/}),TryStatement:Ja({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:FT,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:zT({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ja({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Jo.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":uy,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),aS=qn.configure({dialect:"ts"},"typescript"),lS=qn.configure({dialect:"jsx"}),hS=qn.configure({dialect:"jsx ts"},"typescript"),II="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(n=>({label:n,type:"keyword"}));function RI(n={}){let e=n.jsx?n.typescript?hS:lS:n.typescript?aS:qn;return new Ro(e,[qn.data.of({autocomplete:fA(oS,ab(PI.concat(II)))}),qn.data.of({autocomplete:CI}),n.jsx?NI:[]])}function EI(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(!n.parent)return null;n=n.parent}}function pm(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const DI=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),NI=N.inputHandler.of((n,e,t,i)=>{if((DI?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!qn.isActiveAt(n.state,e,-1))return!1;let{state:r}=n,s=r.changeByRange(o=>{var a,l;let{head:h}=o,c=pe(r).resolveInner(h,-1),u;if(c.name=="JSXStartTag"&&(c=c.parent),i==">"&&c.name=="JSXFragmentTag")return{range:Q.cursor(h+1),changes:{from:h,insert:"><>"}};if(i=="/"&&c.name=="JSXFragmentTag"){let f=c.parent,p=f==null?void 0:f.parent;if(f.from==h-1&&((a=p.lastChild)===null||a===void 0?void 0:a.name)!="JSXEndTag"&&(u=pm(r.doc,p==null?void 0:p.firstChild,h))){let g=`/${u}>`;return{range:Q.cursor(h+g.length),changes:{from:h,insert:g}}}}else if(i==">"){let f=EI(c);if(f&&((l=f.lastChild)===null||l===void 0?void 0:l.name)!="JSXEndTag"&&r.sliceDoc(h,h+2)!="`}}}return{range:o}});return s.changes.empty?!1:(n.dispatch(s,{userEvent:"input.type",scrollIntoView:!0}),!0)}),Ws=["_blank","_self","_top","_parent"],fc=["ascii","utf-8","utf-16","latin1","latin1"],dc=["get","post","put","delete"],pc=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ot=["true","false"],V={},BI={a:{attrs:{href:null,ping:null,type:null,media:null,target:Ws,hreflang:null}},abbr:V,address:V,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:V,aside:V,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:V,base:{attrs:{href:null,target:Ws}},bdi:V,bdo:V,blockquote:{attrs:{cite:null}},body:V,br:V,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:pc,formmethod:dc,formnovalidate:["novalidate"],formtarget:Ws,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:V,center:V,cite:V,code:V,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:V,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:V,div:V,dl:V,dt:V,em:V,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:V,figure:V,footer:V,form:{attrs:{action:null,name:null,"accept-charset":fc,autocomplete:["on","off"],enctype:pc,method:dc,novalidate:["novalidate"],target:Ws}},h1:V,h2:V,h3:V,h4:V,h5:V,h6:V,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:V,hgroup:V,hr:V,html:{attrs:{manifest:null}},i:V,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:pc,formmethod:dc,formnovalidate:["novalidate"],formtarget:Ws,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:V,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:V,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:V,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:fc,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:V,noscript:V,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:V,param:{attrs:{name:null,value:null}},pre:V,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:V,rt:V,ruby:V,samp:V,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:fc}},section:V,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:V,source:{attrs:{src:null,type:null,media:null}},span:V,strong:V,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:V,summary:V,sup:V,table:V,tbody:V,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:V,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:V,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:V,time:{attrs:{datetime:null}},title:V,tr:V,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:V,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:V},qI={accesskey:null,class:null,contenteditable:ot,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:ot,autocorrect:ot,autocapitalize:ot,style:null,tabindex:null,title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":ot,"aria-autocomplete":["inline","list","both","none"],"aria-busy":ot,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":ot,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":ot,"aria-hidden":ot,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":ot,"aria-multiselectable":ot,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":ot,"aria-relevant":null,"aria-required":ot,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null};class Kl{constructor(e,t){this.tags=Object.assign(Object.assign({},BI),e),this.globalAttrs=Object.assign(Object.assign({},qI),t),this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Kl.default=new Kl;function As(n,e,t=n.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?n.sliceString(r.from,Math.min(r.to,t)):""}function xh(n,e=!1){for(let t=n.parent;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function cS(n,e,t){let i=t.tags[As(n,xh(e,!0))];return(i==null?void 0:i.children)||t.allTags}function Yf(n,e){let t=[];for(let i=e;i=xh(i);){let r=As(n,i);if(r&&i.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&t.push(r)}return t}const uS=/^[:\-\.\w\u00b7-\uffff]*$/;function gm(n,e,t,i,r){let s=/\s*>/.test(n.sliceDoc(r,r+5))?"":">";return{from:i,to:r,options:cS(n.doc,t,e).map(o=>({label:o,type:"type"})).concat(Yf(n.doc,t).map((o,a)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function mm(n,e,t,i){let r=/\s*>/.test(n.sliceDoc(i,i+5))?"":">";return{from:t,to:i,options:Yf(n.doc,e).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:uS}}function MI(n,e,t,i){let r=[],s=0;for(let o of cS(n.doc,t,e))r.push({label:"<"+o,type:"type"});for(let o of Yf(n.doc,t))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function VI(n,e,t,i,r){let s=xh(t),o=s?e.tags[As(n.doc,s)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:l.map(h=>({label:h,type:"property"})),validFor:uS}}function LI(n,e,t,i,r){var s;let o=(s=t.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),a=[],l;if(o){let h=n.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let u=xh(t),f=u?e.tags[As(n.doc,u)]:null;c=(f==null?void 0:f.attrs)&&f.attrs[h]}if(c){let u=n.sliceDoc(i,r).toLowerCase(),f='"',p='"';/^['"]/.test(u)?(l=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",p=n.sliceDoc(r,r+1)==u[0]?"":u[0],u=u.slice(1),i++):l=/^[^\s<>='"]*$/;for(let g of c)a.push({label:g,apply:f+g+p,type:"constant"})}}return{from:i,to:r,options:a,validFor:l}}function XI(n,e){let{state:t,pos:i}=e,r=pe(t).resolveInner(i),s=r.resolve(i,-1);for(let o=i,a;r==s&&(a=s.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.fromXI(i,r)}const fS=[{tag:"script",attrs:n=>n.type=="text/typescript"||n.lang=="ts",parser:aS.parser},{tag:"script",attrs:n=>n.type=="text/babel"||n.type=="text/jsx",parser:lS.parser},{tag:"script",attrs:n=>n.type=="text/typescript-jsx",parser:hS.parser},{tag:"script",attrs(n){return!n.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(n.type)},parser:qn.parser},{tag:"style",attrs(n){return(!n.lang||n.lang=="css")&&(!n.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(n.type))},parser:Hl.parser}],dS=[{name:"style",parser:Hl.parser.configure({top:"Styles"})}].concat("beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(n=>({name:"on"+n,parser:qn.parser}))),el=vs.define({name:"html",parser:$C.configure({props:[Go.add({Element(n){let e=/^(\s*)(<\/)?/.exec(n.textAfter);return n.node.to<=n.pos+e[0].length?n.continue():n.lineIndent(n.node.from)+(e[2]?0:n.unit)},"OpenTag CloseTag SelfClosingTag"(n){return n.column(n.node.from)+n.unit},Document(n){if(n.pos+/\s*/.exec(n.textAfter)[0].length"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-._"}});function ZI(n={}){let e="",t;n.matchClosingTags===!1&&(e="noMatch"),n.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(n.nestedLanguages&&n.nestedLanguages.length||n.nestedAttributes&&n.nestedAttributes.length)&&(t=eS((n.nestedLanguages||[]).concat(fS),(n.nestedAttributes||[]).concat(dS)));let i=t||e?el.configure({dialect:e,wrap:t}):el;return new Ro(i,[el.data.of({autocomplete:UI(n)}),n.autoCloseTags!==!1?WI:[],RI().support,YC().support])}const WI=N.inputHandler.of((n,e,t,i)=>{if(n.composing||n.state.readOnly||e!=t||i!=">"&&i!="/"||!el.isActiveAt(n.state,e,-1))return!1;let{state:r}=n,s=r.changeByRange(o=>{var a,l,h;let{head:c}=o,u=pe(r).resolveInner(c,-1),f;if((u.name=="TagName"||u.name=="StartTag")&&(u=u.parent),i==">"&&u.name=="OpenTag"){if(((l=(a=u.parent)===null||a===void 0?void 0:a.lastChild)===null||l===void 0?void 0:l.name)!="CloseTag"&&(f=As(r.doc,u.parent,c))){let p=n.state.doc.sliceString(c,c+1)===">",g=`${p?"":">"}`;return{range:Q.cursor(c+1),changes:{from:c+(p?1:0),insert:g}}}}else if(i=="/"&&u.name=="OpenTag"){let p=u.parent,g=p==null?void 0:p.parent;if(p.from==c-1&&((h=g.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(f=As(r.doc,g,c))){let O=n.state.doc.sliceString(c,c+1)===">",y=`/${f}${O?"":">"}`,S=c+y.length+(O?1:0);return{range:Q.cursor(S),changes:{from:c,insert:y}}}}return{range:o}});return s.changes.empty?!1:(n.dispatch(s,{userEvent:"input.type",scrollIntoView:!0}),!0)}),pS=ay({block:{open:""}}),gS=I$.configure({props:[Jo.add(n=>{if(!(!n.is("Block")||n.is("Document")))return(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})}),Go.add({Document:()=>null}),ws.add({Document:pS})]});function Hf(n){return new Rt(pS,n,[],"markdown")}const jI=Hf(gS),zI=gS.configure([V$,X$,L$,U$]),Kf=Hf(zI);function FI(n,e){return t=>{if(t&&n){let i=null;if(t=/\S*/.exec(t)[0],typeof n=="function"?i=n(t):i=Dl.matchLanguageName(n,t,!0),i instanceof Dl)return i.support?i.support.language.parser:Io.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class Ea{constructor(e,t,i,r,s,o,a){this.node=e,this.from=t,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=a}blank(e,t=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length0;r--)i+=" ";return i+(t?this.spaceAfter:"")}}marker(e,t){let i=this.node.name=="OrderedList"?String(+OS(this.item,e)[2]+t):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function mS(n,e){let t=[];for(let r=n;r&&r.name!="Document";r=r.parent)(r.name=="ListItem"||r.name=="Blockquote"||r.name=="FencedCode")&&t.push(r);let i=[];for(let r=t.length-1;r>=0;r--){let s=t[r],o,a=e.lineAt(s.from),l=s.from-a.from;if(s.name=="FencedCode")i.push(new Ea(s,l,l,"","","",null));else if(s.name=="Blockquote"&&(o=/^[ \t]*>( ?)/.exec(a.text.slice(l))))i.push(new Ea(s,l,l+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^([ \t]*)\d+([.)])([ \t]*)/.exec(a.text.slice(l)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new Ea(s.parent,l,l+c,o[1],h,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^([ \t]*)([-+*])([ \t]{1,4}\[[ xX]\])?([ \t]+)/.exec(a.text.slice(l)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),i.push(new Ea(s.parent,l,l+c,o[1],h,u,s))}}return i}function OS(n,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(n.from,n.from+10))}function gc(n,e,t,i=0){for(let r=-1,s=n;;){if(s.name=="ListItem"){let a=OS(s,e),l=+a[2];if(r>=0){if(l!=r+1)return;t.push({from:s.from+a[1].length,to:s.from+a[0].length,insert:String(r+2+i)})}r=l}let o=s.nextSibling;if(!o)break;s=o}}const _I=({state:n,dispatch:e})=>{let t=pe(n),{doc:i}=n,r=null,s=n.changeByRange(o=>{if(!o.empty||!Kf.isActiveAt(n,o.from))return r={range:o};let a=o.from,l=i.lineAt(a),h=mS(t.resolveInner(a,-1),i);for(;h.length&&h[h.length-1].from>a-l.from;)h.pop();if(!h.length)return r={range:o};let c=h[h.length-1];if(c.to-c.spaceAfter.length>a-l.from)return r={range:o};let u=a>=c.to-c.spaceAfter.length&&!/\S/.test(l.text.slice(c.to));if(c.item&&u)if(c.node.firstChild.to>=a||l.from>0&&!/[^\s>]/.test(i.lineAt(l.from-1).text)){let y=h.length>1?h[h.length-2]:null,S,k="";y&&y.item?(S=l.from+y.from,k=y.marker(i,1)):S=l.from+(y?y.to:0);let $=[{from:S,to:a,insert:k}];return c.node.name=="OrderedList"&&gc(c.item,i,$,-2),y&&y.node.name=="OrderedList"&&gc(y.item,i,$),{range:Q.cursor(S+k.length),changes:$}}else{let y="";for(let S=0,k=h.length-2;S<=k;S++)y+=h[S].blank(S\s*$/.exec(y.text);if(S&&S.index==c.from){let k=n.changes([{from:y.from+S.index,to:y.to},{from:l.from+c.from,to:l.to}]);return{range:o.map(k),changes:k}}}let f=[];c.node.name=="OrderedList"&&gc(c.item,i,f);let p=c.item&&c.item.from]*/.exec(l.text)[0].length>=c.to)for(let y=0,S=h.length-1;y<=S;y++)g+=y==S&&!p?h[y].marker(i,1):h[y].blank(yl.from&&/\s/.test(l.text.charAt(O-l.from-1));)O--;return g=n.lineBreak+g,f.push({from:O,to:a,insert:g}),{range:Q.cursor(O+g.length),changes:f}});return r?!1:(e(n.update(s,{scrollIntoView:!0,userEvent:"input"})),!0)};function Om(n){return n.name=="QuoteMark"||n.name=="ListMark"}function GI(n,e){let t=n.resolveInner(e,-1),i=e;Om(t)&&(i=t.from,t=t.parent);for(let r;r=t.childBefore(i);)if(Om(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,i=t.to;else break;return t}const JI=({state:n,dispatch:e})=>{let t=pe(n),i=null,r=n.changeByRange(s=>{let o=s.from,{doc:a}=n;if(s.empty&&Kf.isActiveAt(n,s.from)){let l=a.lineAt(o),h=mS(GI(t,o),a);if(h.length){let c=h[h.length-1],u=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-l.from>u&&!/\S/.test(l.text.slice(u,o-l.from)))return{range:Q.cursor(l.from+u),changes:{from:l.from+u,to:o}};if(o-l.from==u){let f=l.from+c.from;if(c.item&&c.node.from{xr.isOnline=!1,n.innerHTML=' '},showOnline:n=>{xr.isOnline=!0,n.innerHTML=' '},statusListener:n=>e=>{xr.isOnline&&e.value==So.Disconnected?xr.showOffline(n):!xr.isOnline&&e.value==So.Connected&&xr.showOnline(n)}};function HI(n,e,t){const i=[];for(const{clientID:r}of e)i.push(t===r?`${r}`:r);n.innerHTML=JSON.stringify(i)}function bm(n,e,t){n.innerText=t.toJSON(),e.innerText=t.getRoot().content.toTestString()}const KI=document.getElementById("editor"),eR=document.getElementById("peers"),Sm=document.getElementById("document"),wm=document.getElementById("document-text"),tR=document.getElementById("network-status");async function iR(){const n=new Dh.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await n.activate();const e=new Dh.Document(`codemirror6-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`,{enableDevtools:!0});e.subscribe("connection",a=>{xr.statusListener(tR)(a)}),e.subscribe("presence",a=>{a.type!==Re.PresenceChanged&&HI(eR,e.getPresences(),n.getID())}),await n.attach(e),e.update(a=>{a.content||(a.content=new Dh.Text)},"create content if not exists");const t=()=>{const a=e.getRoot().content,l=e.getMyPresence().selection,h={changes:{from:0,to:r.state.doc.length,insert:a.toString()},annotations:[Se.remote.of(!0)]};if(l){const c=a.posRangeToIndexRange(l);h.selection={anchor:c[0],head:c[1]}}r.dispatch(h)};e.subscribe(a=>{a.type==="snapshot"&&t(),bm(Sm,wm,e)}),e.subscribe("$.content",a=>{if(a.type==="remote-change"){const{operations:l}=a.value;s(l)}}),await n.sync();const i=N.updateListener.of(a=>{if(a.docChanged)for(const c of a.transactions){if(!["select","input","delete","move","undo","redo"].map(p=>c.isUserEvent(p)).some(Boolean)||c.annotation(Se.remote))continue;let f=0;c.changes.iterChanges((p,g,O,y,S)=>{const k=S.toJSON().join(` +}`,{label:"class",detail:"definition",type:"keyword"}),Ut('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Ut('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],fm=new ST,rS=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Zs(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const AI=["FunctionDeclaration"],$I={FunctionDeclaration:Zs("function"),ClassDeclaration:Zs("class"),ClassExpression:()=>!0,EnumDeclaration:Zs("constant"),TypeAliasDeclaration:Zs("type"),NamespaceDeclaration:Zs("namespace"),VariableDefinition(n,e){n.matchContext(AI)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function sS(n,e){let t=fm.get(e);if(t)return t;let i=[],r=!0;function s(o,a){let l=n.sliceString(o.from,o.to);i.push({label:l,type:a})}return e.cursor(ce.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let a=$I[o.name];if(a&&a(o,s)||rS.has(o.name))return!1}else if(o.to-o.from>8192){for(let a of sS(n,o.node))i.push(a);return!1}}),fm.set(e,i),i}const dm=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,oS=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function CI(n){let e=pe(n.state).resolveInner(n.pos,-1);if(oS.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&dm.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)rS.has(r.name)&&(i=i.concat(sS(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:dm}}const qn=vs.define({name:"javascript",parser:QI.configure({props:[Go.add({IfStatement:Ja({except:/^\s*({|else\b)/}),TryStatement:Ja({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:FT,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:zT({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ja({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Jo.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression":uy,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),aS=qn.configure({dialect:"ts"},"typescript"),lS=qn.configure({dialect:"jsx"}),hS=qn.configure({dialect:"jsx ts"},"typescript"),II="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(n=>({label:n,type:"keyword"}));function RI(n={}){let e=n.jsx?n.typescript?hS:lS:n.typescript?aS:qn;return new Ro(e,[qn.data.of({autocomplete:fA(oS,ab(PI.concat(II)))}),qn.data.of({autocomplete:CI}),n.jsx?NI:[]])}function EI(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(!n.parent)return null;n=n.parent}}function pm(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const DI=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),NI=N.inputHandler.of((n,e,t,i)=>{if((DI?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!qn.isActiveAt(n.state,e,-1))return!1;let{state:r}=n,s=r.changeByRange(o=>{var a,l;let{head:h}=o,c=pe(r).resolveInner(h,-1),u;if(c.name=="JSXStartTag"&&(c=c.parent),i==">"&&c.name=="JSXFragmentTag")return{range:Q.cursor(h+1),changes:{from:h,insert:"><>"}};if(i=="/"&&c.name=="JSXFragmentTag"){let f=c.parent,p=f==null?void 0:f.parent;if(f.from==h-1&&((a=p.lastChild)===null||a===void 0?void 0:a.name)!="JSXEndTag"&&(u=pm(r.doc,p==null?void 0:p.firstChild,h))){let g=`/${u}>`;return{range:Q.cursor(h+g.length),changes:{from:h,insert:g}}}}else if(i==">"){let f=EI(c);if(f&&((l=f.lastChild)===null||l===void 0?void 0:l.name)!="JSXEndTag"&&r.sliceDoc(h,h+2)!="`}}}return{range:o}});return s.changes.empty?!1:(n.dispatch(s,{userEvent:"input.type",scrollIntoView:!0}),!0)}),Ws=["_blank","_self","_top","_parent"],dc=["ascii","utf-8","utf-16","latin1","latin1"],pc=["get","post","put","delete"],gc=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ot=["true","false"],V={},BI={a:{attrs:{href:null,ping:null,type:null,media:null,target:Ws,hreflang:null}},abbr:V,address:V,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:V,aside:V,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:V,base:{attrs:{href:null,target:Ws}},bdi:V,bdo:V,blockquote:{attrs:{cite:null}},body:V,br:V,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:Ws,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:V,center:V,cite:V,code:V,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:V,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:V,div:V,dl:V,dt:V,em:V,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:V,figure:V,footer:V,form:{attrs:{action:null,name:null,"accept-charset":dc,autocomplete:["on","off"],enctype:gc,method:pc,novalidate:["novalidate"],target:Ws}},h1:V,h2:V,h3:V,h4:V,h5:V,h6:V,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:V,hgroup:V,hr:V,html:{attrs:{manifest:null}},i:V,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:gc,formmethod:pc,formnovalidate:["novalidate"],formtarget:Ws,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:V,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:V,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:V,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:dc,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:V,noscript:V,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:V,param:{attrs:{name:null,value:null}},pre:V,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:V,rt:V,ruby:V,samp:V,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:dc}},section:V,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:V,source:{attrs:{src:null,type:null,media:null}},span:V,strong:V,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:V,summary:V,sup:V,table:V,tbody:V,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:V,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:V,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:V,time:{attrs:{datetime:null}},title:V,tr:V,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:V,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:V},qI={accesskey:null,class:null,contenteditable:ot,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:ot,autocorrect:ot,autocapitalize:ot,style:null,tabindex:null,title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":ot,"aria-autocomplete":["inline","list","both","none"],"aria-busy":ot,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":ot,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":ot,"aria-hidden":ot,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":ot,"aria-multiselectable":ot,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":ot,"aria-relevant":null,"aria-required":ot,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null};class Kl{constructor(e,t){this.tags=Object.assign(Object.assign({},BI),e),this.globalAttrs=Object.assign(Object.assign({},qI),t),this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Kl.default=new Kl;function As(n,e,t=n.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?n.sliceString(r.from,Math.min(r.to,t)):""}function Th(n,e=!1){for(let t=n.parent;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function cS(n,e,t){let i=t.tags[As(n,Th(e,!0))];return(i==null?void 0:i.children)||t.allTags}function Yf(n,e){let t=[];for(let i=e;i=Th(i);){let r=As(n,i);if(r&&i.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&t.push(r)}return t}const uS=/^[:\-\.\w\u00b7-\uffff]*$/;function gm(n,e,t,i,r){let s=/\s*>/.test(n.sliceDoc(r,r+5))?"":">";return{from:i,to:r,options:cS(n.doc,t,e).map(o=>({label:o,type:"type"})).concat(Yf(n.doc,t).map((o,a)=>({label:"/"+o,apply:"/"+o+s,type:"type",boost:99-a}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function mm(n,e,t,i){let r=/\s*>/.test(n.sliceDoc(i,i+5))?"":">";return{from:t,to:i,options:Yf(n.doc,e).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:uS}}function MI(n,e,t,i){let r=[],s=0;for(let o of cS(n.doc,t,e))r.push({label:"<"+o,type:"type"});for(let o of Yf(n.doc,t))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function VI(n,e,t,i,r){let s=Th(t),o=s?e.tags[As(n.doc,s)]:null,a=o&&o.attrs?Object.keys(o.attrs):[],l=o&&o.globalAttrs===!1?a:a.length?a.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:l.map(h=>({label:h,type:"property"})),validFor:uS}}function LI(n,e,t,i,r){var s;let o=(s=t.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),a=[],l;if(o){let h=n.sliceDoc(o.from,o.to),c=e.globalAttrs[h];if(!c){let u=Th(t),f=u?e.tags[As(n.doc,u)]:null;c=(f==null?void 0:f.attrs)&&f.attrs[h]}if(c){let u=n.sliceDoc(i,r).toLowerCase(),f='"',p='"';/^['"]/.test(u)?(l=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",p=n.sliceDoc(r,r+1)==u[0]?"":u[0],u=u.slice(1),i++):l=/^[^\s<>='"]*$/;for(let g of c)a.push({label:g,apply:f+g+p,type:"constant"})}}return{from:i,to:r,options:a,validFor:l}}function XI(n,e){let{state:t,pos:i}=e,r=pe(t).resolveInner(i),s=r.resolve(i,-1);for(let o=i,a;r==s&&(a=s.childBefore(o));){let l=a.lastChild;if(!l||!l.type.isError||l.fromXI(i,r)}const fS=[{tag:"script",attrs:n=>n.type=="text/typescript"||n.lang=="ts",parser:aS.parser},{tag:"script",attrs:n=>n.type=="text/babel"||n.type=="text/jsx",parser:lS.parser},{tag:"script",attrs:n=>n.type=="text/typescript-jsx",parser:hS.parser},{tag:"script",attrs(n){return!n.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(n.type)},parser:qn.parser},{tag:"style",attrs(n){return(!n.lang||n.lang=="css")&&(!n.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(n.type))},parser:Hl.parser}],dS=[{name:"style",parser:Hl.parser.configure({top:"Styles"})}].concat("beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(n=>({name:"on"+n,parser:qn.parser}))),el=vs.define({name:"html",parser:$C.configure({props:[Go.add({Element(n){let e=/^(\s*)(<\/)?/.exec(n.textAfter);return n.node.to<=n.pos+e[0].length?n.continue():n.lineIndent(n.node.from)+(e[2]?0:n.unit)},"OpenTag CloseTag SelfClosingTag"(n){return n.column(n.node.from)+n.unit},Document(n){if(n.pos+/\s*/.exec(n.textAfter)[0].length"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-._"}});function ZI(n={}){let e="",t;n.matchClosingTags===!1&&(e="noMatch"),n.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(n.nestedLanguages&&n.nestedLanguages.length||n.nestedAttributes&&n.nestedAttributes.length)&&(t=eS((n.nestedLanguages||[]).concat(fS),(n.nestedAttributes||[]).concat(dS)));let i=t||e?el.configure({dialect:e,wrap:t}):el;return new Ro(i,[el.data.of({autocomplete:UI(n)}),n.autoCloseTags!==!1?WI:[],RI().support,YC().support])}const WI=N.inputHandler.of((n,e,t,i)=>{if(n.composing||n.state.readOnly||e!=t||i!=">"&&i!="/"||!el.isActiveAt(n.state,e,-1))return!1;let{state:r}=n,s=r.changeByRange(o=>{var a,l,h;let{head:c}=o,u=pe(r).resolveInner(c,-1),f;if((u.name=="TagName"||u.name=="StartTag")&&(u=u.parent),i==">"&&u.name=="OpenTag"){if(((l=(a=u.parent)===null||a===void 0?void 0:a.lastChild)===null||l===void 0?void 0:l.name)!="CloseTag"&&(f=As(r.doc,u.parent,c))){let p=n.state.doc.sliceString(c,c+1)===">",g=`${p?"":">"}`;return{range:Q.cursor(c+1),changes:{from:c+(p?1:0),insert:g}}}}else if(i=="/"&&u.name=="OpenTag"){let p=u.parent,g=p==null?void 0:p.parent;if(p.from==c-1&&((h=g.lastChild)===null||h===void 0?void 0:h.name)!="CloseTag"&&(f=As(r.doc,g,c))){let O=n.state.doc.sliceString(c,c+1)===">",y=`/${f}${O?"":">"}`,S=c+y.length+(O?1:0);return{range:Q.cursor(S),changes:{from:c,insert:y}}}}return{range:o}});return s.changes.empty?!1:(n.dispatch(s,{userEvent:"input.type",scrollIntoView:!0}),!0)}),pS=ay({block:{open:""}}),gS=I$.configure({props:[Jo.add(n=>{if(!(!n.is("Block")||n.is("Document")))return(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})}),Go.add({Document:()=>null}),ws.add({Document:pS})]});function Hf(n){return new Rt(pS,n,[],"markdown")}const jI=Hf(gS),zI=gS.configure([V$,X$,L$,U$]),Kf=Hf(zI);function FI(n,e){return t=>{if(t&&n){let i=null;if(t=/\S*/.exec(t)[0],typeof n=="function"?i=n(t):i=Dl.matchLanguageName(n,t,!0),i instanceof Dl)return i.support?i.support.language.parser:Io.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class Ea{constructor(e,t,i,r,s,o,a){this.node=e,this.from=t,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=a}blank(e,t=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length0;r--)i+=" ";return i+(t?this.spaceAfter:"")}}marker(e,t){let i=this.node.name=="OrderedList"?String(+OS(this.item,e)[2]+t):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function mS(n,e){let t=[];for(let r=n;r&&r.name!="Document";r=r.parent)(r.name=="ListItem"||r.name=="Blockquote"||r.name=="FencedCode")&&t.push(r);let i=[];for(let r=t.length-1;r>=0;r--){let s=t[r],o,a=e.lineAt(s.from),l=s.from-a.from;if(s.name=="FencedCode")i.push(new Ea(s,l,l,"","","",null));else if(s.name=="Blockquote"&&(o=/^[ \t]*>( ?)/.exec(a.text.slice(l))))i.push(new Ea(s,l,l+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^([ \t]*)\d+([.)])([ \t]*)/.exec(a.text.slice(l)))){let h=o[3],c=o[0].length;h.length>=4&&(h=h.slice(0,h.length-4),c-=4),i.push(new Ea(s.parent,l,l+c,o[1],h,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^([ \t]*)([-+*])([ \t]{1,4}\[[ xX]\])?([ \t]+)/.exec(a.text.slice(l)))){let h=o[4],c=o[0].length;h.length>4&&(h=h.slice(0,h.length-4),c-=4);let u=o[2];o[3]&&(u+=o[3].replace(/[xX]/," ")),i.push(new Ea(s.parent,l,l+c,o[1],h,u,s))}}return i}function OS(n,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(n.from,n.from+10))}function mc(n,e,t,i=0){for(let r=-1,s=n;;){if(s.name=="ListItem"){let a=OS(s,e),l=+a[2];if(r>=0){if(l!=r+1)return;t.push({from:s.from+a[1].length,to:s.from+a[0].length,insert:String(r+2+i)})}r=l}let o=s.nextSibling;if(!o)break;s=o}}const _I=({state:n,dispatch:e})=>{let t=pe(n),{doc:i}=n,r=null,s=n.changeByRange(o=>{if(!o.empty||!Kf.isActiveAt(n,o.from))return r={range:o};let a=o.from,l=i.lineAt(a),h=mS(t.resolveInner(a,-1),i);for(;h.length&&h[h.length-1].from>a-l.from;)h.pop();if(!h.length)return r={range:o};let c=h[h.length-1];if(c.to-c.spaceAfter.length>a-l.from)return r={range:o};let u=a>=c.to-c.spaceAfter.length&&!/\S/.test(l.text.slice(c.to));if(c.item&&u)if(c.node.firstChild.to>=a||l.from>0&&!/[^\s>]/.test(i.lineAt(l.from-1).text)){let y=h.length>1?h[h.length-2]:null,S,k="";y&&y.item?(S=l.from+y.from,k=y.marker(i,1)):S=l.from+(y?y.to:0);let $=[{from:S,to:a,insert:k}];return c.node.name=="OrderedList"&&mc(c.item,i,$,-2),y&&y.node.name=="OrderedList"&&mc(y.item,i,$),{range:Q.cursor(S+k.length),changes:$}}else{let y="";for(let S=0,k=h.length-2;S<=k;S++)y+=h[S].blank(S\s*$/.exec(y.text);if(S&&S.index==c.from){let k=n.changes([{from:y.from+S.index,to:y.to},{from:l.from+c.from,to:l.to}]);return{range:o.map(k),changes:k}}}let f=[];c.node.name=="OrderedList"&&mc(c.item,i,f);let p=c.item&&c.item.from]*/.exec(l.text)[0].length>=c.to)for(let y=0,S=h.length-1;y<=S;y++)g+=y==S&&!p?h[y].marker(i,1):h[y].blank(yl.from&&/\s/.test(l.text.charAt(O-l.from-1));)O--;return g=n.lineBreak+g,f.push({from:O,to:a,insert:g}),{range:Q.cursor(O+g.length),changes:f}});return r?!1:(e(n.update(s,{scrollIntoView:!0,userEvent:"input"})),!0)};function Om(n){return n.name=="QuoteMark"||n.name=="ListMark"}function GI(n,e){let t=n.resolveInner(e,-1),i=e;Om(t)&&(i=t.from,t=t.parent);for(let r;r=t.childBefore(i);)if(Om(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,i=t.to;else break;return t}const JI=({state:n,dispatch:e})=>{let t=pe(n),i=null,r=n.changeByRange(s=>{let o=s.from,{doc:a}=n;if(s.empty&&Kf.isActiveAt(n,s.from)){let l=a.lineAt(o),h=mS(GI(t,o),a);if(h.length){let c=h[h.length-1],u=c.to-c.spaceAfter.length+(c.spaceAfter?1:0);if(o-l.from>u&&!/\S/.test(l.text.slice(u,o-l.from)))return{range:Q.cursor(l.from+u),changes:{from:l.from+u,to:o}};if(o-l.from==u){let f=l.from+c.from;if(c.item&&c.node.from{xr.isOnline=!1,n.innerHTML=' '},showOnline:n=>{xr.isOnline=!0,n.innerHTML=' '},statusListener:n=>e=>{xr.isOnline&&e.value==So.Disconnected?xr.showOffline(n):!xr.isOnline&&e.value==So.Connected&&xr.showOnline(n)}};function HI(n,e,t){const i=[];for(const{clientID:r}of e)i.push(t===r?`${r}`:r);n.innerHTML=JSON.stringify(i)}function bm(n,e,t){n.innerText=t.toJSON(),e.innerText=t.getRoot().content.toTestString()}const KI=document.getElementById("editor"),eR=document.getElementById("peers"),Sm=document.getElementById("document"),wm=document.getElementById("document-text"),tR=document.getElementById("network-status");async function iR(){const n=new Nh.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await n.activate();const e=new Nh.Document(`codemirror6-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`,{enableDevtools:!0});e.subscribe("connection",a=>{xr.statusListener(tR)(a)}),e.subscribe("presence",a=>{a.type!==Re.PresenceChanged&&HI(eR,e.getPresences(),n.getID())}),await n.attach(e),e.update(a=>{a.content||(a.content=new Nh.Text)},"create content if not exists");const t=()=>{const a=e.getRoot().content,l=e.getMyPresence().selection,h={changes:{from:0,to:r.state.doc.length,insert:a.toString()},annotations:[Se.remote.of(!0)]};if(l){const c=a.posRangeToIndexRange(l);h.selection={anchor:c[0],head:c[1]}}r.dispatch(h)};e.subscribe(a=>{a.type==="snapshot"&&t(),bm(Sm,wm,e)}),e.subscribe("$.content",a=>{if(a.type==="remote-change"){const{operations:l}=a.value;s(l)}}),await n.sync();const i=N.updateListener.of(a=>{if(a.docChanged)for(const c of a.transactions){if(!["select","input","delete","move","undo","redo"].map(p=>c.isUserEvent(p)).some(Boolean)||c.annotation(Se.remote))continue;let f=0;c.changes.iterChanges((p,g,O,y,S)=>{const k=S.toJSON().join(` `);e.update($=>{$.content.edit(p+f,g+f,k)},`update content byA ${n.getID()}`),f+=k.length-(g-p)})}const h=a.view.hasFocus&&a.view.dom.ownerDocument.hasFocus()?a.state.selection.main:null;e.update((c,u)=>{if(h&&c.content){const f=c.content.indexRangeToPosRange([h.anchor,h.head]);JSON.stringify(f)!==JSON.stringify(u.get("selection"))&&u.set({selection:f})}else u.get("selection")&&u.set({selection:void 0})})}),r=new N({doc:"",extensions:[O$,YI({base:Kf}),$s.of(yS),i],parent:KI});function s(a){for(const l of a)l.type==="edit"&&o(l)}function o(a){const l=[{from:Math.max(0,a.from),to:Math.max(0,a.to),insert:a.value.content}];r.dispatch({changes:l,annotations:[Se.remote.of(!0)]})}t(),bm(Sm,wm,e)}iR(); diff --git a/examples/vanilla-codemirror6/index.html b/examples/vanilla-codemirror6/index.html index 7ef74ca59..68549d60d 100644 --- a/examples/vanilla-codemirror6/index.html +++ b/examples/vanilla-codemirror6/index.html @@ -4,7 +4,7 @@ Yorkie + CodeMirror 6 Example - + diff --git a/examples/vanilla-quill/assets/index-DK_gU96d.js b/examples/vanilla-quill/assets/index-ZU4bONgA.js similarity index 86% rename from examples/vanilla-quill/assets/index-DK_gU96d.js rename to examples/vanilla-quill/assets/index-ZU4bONgA.js index 39e675833..6b57d552d 100644 --- a/examples/vanilla-quill/assets/index-DK_gU96d.js +++ b/examples/vanilla-quill/assets/index-ZU4bONgA.js @@ -1,6 +1,6 @@ -var Ku=Object.defineProperty;var Hu=(i,t,e)=>t in i?Ku(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var T=(i,t,e)=>Hu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function e(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(r){if(r.ep)return;r.ep=!0;const o=e(r);fetch(r.href,o)}})();var Ge;(function(i){i[i.Canceled=1]="Canceled",i[i.Unknown=2]="Unknown",i[i.InvalidArgument=3]="InvalidArgument",i[i.DeadlineExceeded=4]="DeadlineExceeded",i[i.NotFound=5]="NotFound",i[i.AlreadyExists=6]="AlreadyExists",i[i.PermissionDenied=7]="PermissionDenied",i[i.ResourceExhausted=8]="ResourceExhausted",i[i.FailedPrecondition=9]="FailedPrecondition",i[i.Aborted=10]="Aborted",i[i.OutOfRange=11]="OutOfRange",i[i.Unimplemented=12]="Unimplemented",i[i.Internal=13]="Internal",i[i.Unavailable=14]="Unavailable",i[i.DataLoss=15]="DataLoss",i[i.Unauthenticated=16]="Unauthenticated"})(Ge||(Ge={}));function Ua(i){const t=Ge[i];return typeof t!="string"?i.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>"_"+e.toLowerCase())}class Ze extends Error{constructor(t,e=Ge.Unknown,n,r,o){super(Wu(t,e)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=e,this.metadata=new Headers(n??{}),this.details=r??[],this.cause=o}static from(t,e=Ge.Unknown){return t instanceof Ze?t:t instanceof Error?t.name=="AbortError"?new Ze(t.message,Ge.Canceled):new Ze(t.message,e,void 0,void 0,t):new Ze(String(t),e,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===Ze.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const e="typeName"in t?{findMessage:r=>r===t.typeName?t:void 0}:t,n=[];for(const r of this.details){if("getType"in r){e.findMessage(r.getType().typeName)&&n.push(r);continue}const o=e.findMessage(r.type);if(o)try{n.push(o.fromBinary(r.value))}catch{}}return n}}function Wu(i,t){return i.length?`[${Ua(t)}] ${i}`:`[${Ua(t)}]`}function it(i,t){if(!i)throw new Error(t)}const Gu=34028234663852886e22,Yu=-34028234663852886e22,Zu=4294967295,Xu=2147483647,Qu=-2147483648;function Ho(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Xu||iZu||i<0)throw new Error("invalid uint 32: "+i)}function Rl(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Gu||i({no:r.no,name:r.name,localName:i[r.no]})))}function Ml(i,t,e){const n=Object.create(null),r=Object.create(null),o=[];for(const s of t){const u=ql(s);o.push(u),n[s.name]=u,r[s.no]=u}return{typeName:i,values:o,findName(s){return n[s]},findNumber(s){return r[s]}}}function tc(i,t,e){const n={};for(const r of t){const o=ql(r);n[o.localName]=o.no,n[o.no]=o.localName}return Bl(n,i,t),n}function ql(i){return"localName"in i?i:Object.assign(Object.assign({},i),{localName:i.name})}class me{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,e){const n=this.getType(),r=n.runtime.bin,o=r.makeReadOptions(e);return r.readMessage(this,o.readerFactory(t),t.byteLength,o),this}fromJson(t,e){const n=this.getType(),r=n.runtime.json,o=r.makeReadOptions(e);return r.readMessage(n,t,o,this),this}fromJsonString(t,e){let n;try{n=JSON.parse(t)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(n,e)}toBinary(t){const e=this.getType(),n=e.runtime.bin,r=n.makeWriteOptions(t),o=r.writerFactory();return n.writeMessage(this,o,r),o.finish()}toJson(t){const e=this.getType(),n=e.runtime.json,r=n.makeWriteOptions(t);return n.writeMessage(this,r)}toJsonString(t){var e;const n=this.toJson(t);return JSON.stringify(n,null,(e=t==null?void 0:t.prettySpaces)!==null&&e!==void 0?e:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function nc(i,t,e,n){var r;const o=(r=n==null?void 0:n.localName)!==null&&r!==void 0?r:t.substring(t.lastIndexOf(".")+1),s={[o]:function(u){i.util.initFields(this),i.util.initPartial(u,this)}}[o];return Object.setPrototypeOf(s.prototype,new me),Object.assign(s,{runtime:i,typeName:t,fields:i.util.newFieldList(e),fromBinary(u,c){return new s().fromBinary(u,c)},fromJson(u,c){return new s().fromJson(u,c)},fromJsonString(u,c){return new s().fromJsonString(u,c)},equals(u,c){return i.util.equals(s,u,c)}}),s}function rc(){let i=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<>4,!(e&128))return this.assertBounds(),[i,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>>o,u=!(!(s>>>7)&&t==0),c=(u?s|128:s)&255;if(e.push(c),!u)return}const n=i>>>28&15|(t&7)<<4,r=!!(t>>3);if(e.push((r?n|128:n)&255),!!r){for(let o=3;o<31;o=o+7){const s=t>>>o,u=!!(s>>>7),c=(u?s|128:s)&255;if(e.push(c),!u)return}e.push(t>>>31&1)}}const Wo=4294967296;function Ja(i){const t=i[0]==="-";t&&(i=i.slice(1));const e=1e6;let n=0,r=0;function o(s,u){const c=Number(i.slice(s,u));r*=e,n=n*e+c,n>=Wo&&(r=r+(n/Wo|0),n=n%Wo)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?jl(n,r):ba(n,r)}function ic(i,t){let e=ba(i,t);const n=e.hi&2147483648;n&&(e=jl(e.lo,e.hi));const r=Fl(e.lo,e.hi);return n?"-"+r:r}function Fl(i,t){if({lo:i,hi:t}=oc(i,t),t<=2097151)return String(Wo*t+i);const e=i&16777215,n=(i>>>24|t<<8)&16777215,r=t>>16&65535;let o=e+n*6777216+r*6710656,s=n+r*8147497,u=r*2;const c=1e7;return o>=c&&(s+=Math.floor(o/c),o%=c),s>=c&&(u+=Math.floor(s/c),s%=c),u.toString()+$a(s)+$a(o)}function oc(i,t){return{lo:i>>>0,hi:t>>>0}}function ba(i,t){return{lo:i|0,hi:t|0}}function jl(i,t){return t=~t,i?i=~i+1:t+=1,ba(i,t)}const $a=i=>{const t=String(i);return"0000000".slice(t.length)+t};function za(i,t){if(i>=0){for(;i>127;)t.push(i&127|128),i=i>>>7;t.push(i)}else{for(let e=0;e<9;e++)t.push(i&127|128),i=i>>7;t.push(1)}}function sc(){let i=this.buf[this.pos++],t=i&127;if(!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<7,!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<14,!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<21,!(i&128))return this.assertBounds(),t;i=this.buf[this.pos++],t|=(i&15)<<28;for(let e=5;i&128&&e<10;e++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Va={};function ac(){const i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(typeof process!="object"||typeof Va!="object"||Va.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),s=BigInt("0"),u=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){const m=typeof c=="bigint"?c:BigInt(c);if(m>o||mu||mit(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),n=r=>it(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),e(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),e(r),Ja(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),n(r),Ja(r)},dec(r,o){return ic(r,o)},uDec(r,o){return Fl(r,o)}}}const Xe=ac();var le;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(le||(le={}));var gi;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING"})(gi||(gi={}));function ii(i,t,e){if(t===e)return!0;if(i==le.BYTES){if(!(t instanceof Uint8Array)||!(e instanceof Uint8Array)||t.length!==e.length)return!1;for(let n=0;n>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Vs(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Ho(t),za(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){Rl(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){Vs(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Ho(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Ho(t),t=(t<<1^t>>31)>>>0,za(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),n=new DataView(e.buffer),r=Xe.enc(t);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),n=new DataView(e.buffer),r=Xe.uEnc(t);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(e)}int64(t){let e=Xe.enc(t);return Rs(e.lo,e.hi,this.buf),this}sint64(t){let e=Xe.enc(t),n=e.hi>>31,r=e.lo<<1^n,o=(e.hi<<1|e.lo>>>31)^n;return Rs(r,o,this.buf),this}uint64(t){let e=Xe.uEnc(t);return Rs(e.lo,e.hi,this.buf),this}}class uc{constructor(t,e){this.varint64=rc,this.uint32=sc,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e??new TextDecoder}tag(){let t=this.uint32(),e=t>>>3,n=t&7;if(e<=0||n<0||n>5)throw new Error("illegal tag: field no "+e+" wire type "+n);return[e,n]}skip(t,e){let n=this.pos;switch(t){case ut.Varint:for(;this.buf[this.pos++]&128;);break;case ut.Bit64:this.pos+=4;case ut.Bit32:this.pos+=4;break;case ut.LengthDelimited:let r=this.uint32();this.pos+=r;break;case ut.StartGroup:for(;;){const[o,s]=this.tag();if(s===ut.EndGroup){if(e!==void 0&&o!==e)throw new Error("invalid end group tag");break}this.skip(s,o)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return Xe.dec(...this.varint64())}uint64(){return Xe.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),n=-(t&1);return t=(t>>>1|(e&1)<<31)^n,e=e>>>1^n,Xe.dec(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Xe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Xe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}}function cc(i,t,e,n){let r;return{typeName:t,extendee:e,get field(){if(!r){const o=typeof n=="function"?n():n;o.name=t.split(".").pop(),o.jsonName=`[${t}]`,r=i.util.newFieldList([o]).list()[0]}return r},runtime:i}}function Jl(i){const t=i.field.localName,e=Object.create(null);return e[t]=fc(i),[e,()=>e[t]]}function fc(i){const t=i.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Hi(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function hc(i,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let e=i.length-1;e>=0;--e)if(i[e].no==t.no)return[i[e]];return[]}return i.filter(e=>e.no===t.no)}let Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),xs=[];for(let i=0;i>4,s=o,r=2;break;case 2:e[n++]=(s&15)<<4|(o&60)>>2,s=o,r=3;break;case 3:e[n++]=(s&3)<<6|o,r=0;break}}if(r==1)throw Error("invalid base64 string.");return e.subarray(0,n)},enc(i){let t="",e=0,n,r=0;for(let o=0;o>2],r=(n&3)<<4,e=1;break;case 1:t+=Vr[r|n>>4],r=(n&15)<<2,e=2;break;case 2:t+=Vr[r|n>>6],t+=Vr[n&63],e=0;break}return e&&(t+=Vr[r],t+="=",e==1&&(t+="=")),t}};function dc(i,t,e){zl(t,i);const n=t.runtime.bin.makeReadOptions(e),r=hc(i.getType().runtime.bin.listUnknownFields(i),t.field),[o,s]=Jl(t);for(const u of r)t.runtime.bin.readField(o,n.readerFactory(u.data),t.field,u.wireType,n);return s()}function gc(i,t,e,n){zl(t,i);const r=t.runtime.bin.makeReadOptions(n),o=t.runtime.bin.makeWriteOptions(n);if($l(i,t)){const m=i.getType().runtime.bin.listUnknownFields(i).filter(y=>y.no!=t.field.no);i.getType().runtime.bin.discardUnknownFields(i);for(const y of m)i.getType().runtime.bin.onUnknownField(i,y.no,y.wireType,y.data)}const s=o.writerFactory();let u=t.field;!u.opt&&!u.repeated&&(u.kind=="enum"||u.kind=="scalar")&&(u=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(u,e,s,o);const c=r.readerFactory(s.finish());for(;c.posn.no==t.field.no)}function zl(i,t){it(i.extendee.typeName==t.getType().typeName,`extension ${i.typeName} can only be applied to message ${i.extendee.typeName}`)}function Vl(i,t){const e=i.localName;if(i.repeated)return t[e].length>0;if(i.oneof)return t[i.oneof.localName].case===e;switch(i.kind){case"enum":case"scalar":return i.opt||i.req?t[e]!==void 0:i.kind=="enum"?t[e]!==i.T.values[0].no:!Ul(i.T,t[e]);case"message":return t[e]!==void 0;case"map":return Object.keys(t[e]).length>0}}function Ka(i,t){const e=i.localName,n=!i.opt&&!i.req;if(i.repeated)t[e]=[];else if(i.oneof)t[i.oneof.localName]={case:void 0};else switch(i.kind){case"map":t[e]={};break;case"enum":t[e]=n?i.T.values[0].no:void 0;break;case"scalar":t[e]=n?Hi(i.T,i.L):void 0;break;case"message":t[e]=void 0;break}}function ki(i,t){if(i===null||typeof i!="object"||!Object.getOwnPropertyNames(me.prototype).every(n=>n in i&&typeof i[n]=="function"))return!1;const e=i.getType();return e===null||typeof e!="function"||!("typeName"in e)||typeof e.typeName!="string"?!1:t===void 0?!0:e.typeName==t.typeName}function Kl(i,t){return ki(t)||!i.fieldWrapper?t:i.fieldWrapper.wrapField(t)}le.DOUBLE,le.FLOAT,le.INT64,le.UINT64,le.INT32,le.UINT32,le.BOOL,le.STRING,le.BYTES;const Ha={ignoreUnknownFields:!1},Wa={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function pc(i){return i?Object.assign(Object.assign({},Ha),i):Ha}function mc(i){return i?Object.assign(Object.assign({},Wa),i):Wa}const ts=Symbol(),Go=Symbol();function yc(){return{makeReadOptions:pc,makeWriteOptions:mc,readMessage(i,t,e,n){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${i.typeName} from JSON: ${Nn(t)}`);n=n??new i;const r=new Map,o=e.typeRegistry;for(const[s,u]of Object.entries(t)){const c=i.fields.findJsonName(s);if(c){if(c.oneof){if(u===null&&c.kind=="scalar")continue;const m=r.get(c.oneof);if(m!==void 0)throw new Error(`cannot decode message ${i.typeName} from JSON: multiple keys for oneof "${c.oneof.name}" present: "${m}", "${s}"`);r.set(c.oneof,s)}Ga(n,u,c,e,i)}else{let m=!1;if(o!=null&&o.findExtension&&s.startsWith("[")&&s.endsWith("]")){const y=o.findExtension(s.substring(1,s.length-1));if(y&&y.extendee.typeName==i.typeName){m=!0;const[f,l]=Jl(y);Ga(f,u,y.field,e,y),gc(n,y,l(),e)}}if(!m&&!e.ignoreUnknownFields)throw new Error(`cannot decode message ${i.typeName} from JSON: key "${s}" is unknown`)}}return n},writeMessage(i,t){const e=i.getType(),n={};let r;try{for(r of e.fields.byNumber()){if(!Vl(r,i)){if(r.req)throw"required field not set";if(!t.emitDefaultValues||!bc(r))continue}const s=r.oneof?i[r.oneof.localName].value:i[r.localName],u=Ya(r,s,t);u!==void 0&&(n[t.useProtoFieldName?r.name:r.jsonName]=u)}const o=t.typeRegistry;if(o!=null&&o.findExtensionFor)for(const s of e.runtime.bin.listUnknownFields(i)){const u=o.findExtensionFor(e.typeName,s.no);if(u&&$l(i,u)){const c=dc(i,u,t),m=Ya(u.field,c,t);m!==void 0&&(n[u.field.jsonName]=m)}}}catch(o){const s=r?`cannot encode field ${e.typeName}.${r.name} to JSON`:`cannot encode message ${e.typeName} to JSON`,u=o instanceof Error?o.message:String(o);throw new Error(s+(u.length>0?`: ${u}`:""))}return n},readScalar(i,t,e){return uo(i,t,e??gi.BIGINT,!0)},writeScalar(i,t,e){if(t!==void 0&&(e||Ul(i,t)))return Yo(i,t)},debug:Nn}}function Nn(i){if(i===null)return"null";switch(typeof i){case"object":return Array.isArray(i)?"array":"object";case"string":return i.length>100?"string":`"${i.split('"').join('\\"')}"`;default:return String(i)}}function Ga(i,t,e,n,r){let o=e.localName;if(e.repeated){if(it(e.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`);const s=i[o];for(const u of t){if(u===null)throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(u)}`);switch(e.kind){case"message":s.push(e.T.fromJson(u,n));break;case"enum":const c=Ds(e.T,u,n.ignoreUnknownFields,!0);c!==Go&&s.push(c);break;case"scalar":try{s.push(uo(e.T,u,e.L,!0))}catch(m){let y=`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(u)}`;throw m instanceof Error&&m.message.length>0&&(y+=`: ${m.message}`),new Error(y)}break}}}else if(e.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`);const s=i[o];for(const[u,c]of Object.entries(t)){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: map value null`);let m;try{m=vc(e.K,u)}catch(y){let f=`cannot decode map key for field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw y instanceof Error&&y.message.length>0&&(f+=`: ${y.message}`),new Error(f)}switch(e.V.kind){case"message":s[m]=e.V.T.fromJson(c,n);break;case"enum":const y=Ds(e.V.T,c,n.ignoreUnknownFields,!0);y!==Go&&(s[m]=y);break;case"scalar":try{s[m]=uo(e.V.T,c,gi.BIGINT,!0)}catch(f){let l=`cannot decode map value for field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw f instanceof Error&&f.message.length>0&&(l+=`: ${f.message}`),new Error(l)}break}}}else switch(e.oneof&&(i=i[e.oneof.localName]={case:o},o="value"),e.kind){case"message":const s=e.T;if(t===null&&s.typeName!="google.protobuf.Value")return;let u=i[o];ki(u)?u.fromJson(t,n):(i[o]=u=s.fromJson(t,n),s.fieldWrapper&&!e.oneof&&(i[o]=s.fieldWrapper.unwrapField(u)));break;case"enum":const c=Ds(e.T,t,n.ignoreUnknownFields,!1);switch(c){case ts:Ka(e,i);break;case Go:break;default:i[o]=c;break}break;case"scalar":try{const m=uo(e.T,t,e.L,!1);switch(m){case ts:Ka(e,i);break;default:i[o]=m;break}}catch(m){let y=`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw m instanceof Error&&m.message.length>0&&(y+=`: ${m.message}`),new Error(y)}break}}function vc(i,t){if(i===le.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return uo(i,t,gi.BIGINT,!0).toString()}function uo(i,t,e,n){if(t===null)return n?Hi(i,e):ts;switch(i){case le.DOUBLE:case le.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const r=Number(t);if(Number.isNaN(r)||!Number.isFinite(r))break;return i==le.FLOAT&&Rl(r),r;case le.INT32:case le.FIXED32:case le.SFIXED32:case le.SINT32:case le.UINT32:let o;if(typeof t=="number"?o=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),o===void 0)break;return i==le.UINT32||i==le.FIXED32?Vs(o):Ho(o),o;case le.INT64:case le.SFIXED64:case le.SINT64:if(typeof t!="number"&&typeof t!="string")break;const s=Xe.parse(t);return e?s.toString():s;case le.FIXED64:case le.UINT64:if(typeof t!="number"&&typeof t!="string")break;const u=Xe.uParse(t);return e?u.toString():u;case le.BOOL:if(typeof t!="boolean")break;return t;case le.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case le.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return wa.dec(t)}throw new Error}function Ds(i,t,e,n){if(t===null)return i.typeName=="google.protobuf.NullValue"?0:n?i.values[0].no:ts;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const r=i.findName(t);if(r!==void 0)return r.no;if(e)return Go;break}throw new Error(`cannot decode enum ${i.typeName} from JSON: ${Nn(t)}`)}function bc(i){return i.repeated||i.kind=="map"?!0:!(i.oneof||i.kind=="message"||i.opt||i.req)}function Ya(i,t,e){if(i.kind=="map"){it(typeof t=="object"&&t!=null);const n={},r=Object.entries(t);switch(i.V.kind){case"scalar":for(const[s,u]of r)n[s.toString()]=Yo(i.V.T,u);break;case"message":for(const[s,u]of r)n[s.toString()]=u.toJson(e);break;case"enum":const o=i.V.T;for(const[s,u]of r)n[s.toString()]=Bs(o,u,e.enumAsInteger);break}return e.emitDefaultValues||r.length>0?n:void 0}if(i.repeated){it(Array.isArray(t));const n=[];switch(i.kind){case"scalar":for(let r=0;r0?n:void 0}switch(i.kind){case"scalar":return Yo(i.T,t);case"enum":return Bs(i.T,t,e.enumAsInteger);case"message":return Kl(i.T,t).toJson(e)}}function Bs(i,t,e){var n;if(it(typeof t=="number"),i.typeName=="google.protobuf.NullValue")return null;if(e)return t;const r=i.findNumber(t);return(n=r==null?void 0:r.name)!==null&&n!==void 0?n:t}function Yo(i,t){switch(i){case le.INT32:case le.SFIXED32:case le.SINT32:case le.FIXED32:case le.UINT32:return it(typeof t=="number"),t;case le.FLOAT:case le.DOUBLE:return it(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case le.STRING:return it(typeof t=="string"),t;case le.BOOL:return it(typeof t=="boolean"),t;case le.UINT64:case le.FIXED64:case le.INT64:case le.SFIXED64:case le.SINT64:return it(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case le.BYTES:return it(t instanceof Uint8Array),wa.enc(t)}}const Bi=Symbol("@bufbuild/protobuf/unknown-fields"),Za={readUnknownFields:!0,readerFactory:i=>new uc(i)},Xa={writeUnknownFields:!0,writerFactory:()=>new lc};function wc(i){return i?Object.assign(Object.assign({},Za),i):Za}function Ac(i){return i?Object.assign(Object.assign({},Xa),i):Xa}function Tc(){return{makeReadOptions:wc,makeWriteOptions:Ac,listUnknownFields(i){var t;return(t=i[Bi])!==null&&t!==void 0?t:[]},discardUnknownFields(i){delete i[Bi]},writeUnknownFields(i,t){const n=i[Bi];if(n)for(const r of n)t.tag(r.no,r.wireType).raw(r.data)},onUnknownField(i,t,e,n){const r=i;Array.isArray(r[Bi])||(r[Bi]=[]),r[Bi].push({no:t,wireType:e,data:n})},readMessage(i,t,e,n,r){const o=i.getType(),s=r?t.len:t.pos+e;let u,c;for(;t.pos0&&(c=Ec),o){let l=i[s];if(n==ut.LengthDelimited&&u!=le.STRING&&u!=le.BYTES){let p=t.uint32()+t.pos;for(;t.poski(l,f)?l:new f(l));else{const l=s[r];f.fieldWrapper?f.typeName==="google.protobuf.BytesValue"?o[r]=oo(l):o[r]=l:o[r]=ki(l,f)?l:new f(l)}break}}},equals(i,t,e){return t===e?!0:!t||!e?!1:i.fields.byMember().every(n=>{const r=t[n.localName],o=e[n.localName];if(n.repeated){if(r.length!==o.length)return!1;switch(n.kind){case"message":return r.every((s,u)=>n.T.equals(s,o[u]));case"scalar":return r.every((s,u)=>ii(n.T,s,o[u]));case"enum":return r.every((s,u)=>ii(le.INT32,s,o[u]))}throw new Error(`repeated cannot contain ${n.kind}`)}switch(n.kind){case"message":return n.T.equals(r,o);case"enum":return ii(le.INT32,r,o);case"scalar":return ii(n.T,r,o);case"oneof":if(r.case!==o.case)return!1;const s=n.findField(r.case);if(s===void 0)return!0;switch(s.kind){case"message":return s.T.equals(r.value,o.value);case"enum":return ii(le.INT32,r.value,o.value);case"scalar":return ii(s.T,r.value,o.value)}throw new Error(`oneof cannot contain ${s.kind}`);case"map":const u=Object.keys(r).concat(Object.keys(o));switch(n.V.kind){case"message":const c=n.V.T;return u.every(y=>c.equals(r[y],o[y]));case"enum":return u.every(y=>ii(le.INT32,r[y],o[y]));case"scalar":const m=n.V.T;return u.every(y=>ii(m,r[y],o[y]))}break}})},clone(i){const t=i.getType(),e=new t,n=e;for(const r of t.fields.byMember()){const o=i[r.localName];let s;if(r.repeated)s=o.map(jo);else if(r.kind=="map"){s=n[r.localName];for(const[u,c]of Object.entries(o))s[u]=jo(c)}else r.kind=="oneof"?s=r.findField(o.case)?{case:o.case,value:jo(o.value)}:{case:void 0}:s=jo(o);n[r.localName]=s}for(const r of t.runtime.bin.listUnknownFields(i))t.runtime.bin.onUnknownField(n,r.no,r.wireType,r.data);return e}}}function jo(i){if(i===void 0)return i;if(ki(i))return i.clone();if(i instanceof Uint8Array){const t=new Uint8Array(i.byteLength);return t.set(i),t}return i}function oo(i){return i instanceof Uint8Array?i:new Uint8Array(i)}function Ic(i,t,e){return{syntax:i,json:yc(),bin:Tc(),util:Object.assign(Object.assign({},Oc()),{newFieldList:t,initFields:e}),makeMessageType(n,r,o){return nc(this,n,r,o)},makeEnum:tc,makeEnumType:Ml,getEnumType:ec,makeExtension(n,r,o){return cc(this,n,r,o)}}}class Nc{constructor(t,e){this._fields=t,this._normalizer=e}findJsonName(t){if(!this.jsonNames){const e={};for(const n of this.list())e[n.jsonName]=e[n.name]=n;this.jsonNames=e}return this.jsonNames[t]}find(t){if(!this.numbers){const e={};for(const n of this.list())e[n.no]=n;this.numbers=e}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,e)=>t.no-e.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let e;for(const n of this.list())n.oneof?n.oneof!==e&&(e=n.oneof,t.push(e)):t.push(n)}return this.members}}function Wl(i,t){const e=Gl(i);return t?e:Dc(Rc(e))}function _c(i){return Wl(i,!1)}const Pc=Gl;function Gl(i){let t=!1;const e=[];for(let n=0;n`${i}$`,Rc=i=>Lc.has(i)?Yl(i):i,Dc=i=>Cc.has(i)?Yl(i):i;class Bc{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=_c(t)}addField(t){it(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;enew Nc(i,t=>Mc(t)),i=>{for(const t of i.getType().fields.byMember()){if(t.opt)continue;const e=t.localName,n=i;if(t.repeated){n[e]=[];continue}switch(t.kind){case"oneof":n[e]={case:void 0};break;case"enum":n[e]=0;break;case"map":n[e]={};break;case"scalar":n[e]=Hi(t.T,t.L);break}}});var bt;(function(i){i[i.Unary=0]="Unary",i[i.ServerStreaming=1]="ServerStreaming",i[i.ClientStreaming=2]="ClientStreaming",i[i.BiDiStreaming=3]="BiDiStreaming"})(bt||(bt={}));var nl;(function(i){i[i.NoSideEffects=1]="NoSideEffects",i[i.Idempotent=2]="Idempotent"})(nl||(nl={}));class mt extends me{constructor(t){super(),this.seconds=Xe.zero,this.nanos=0,L.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${L.json.debug(t)}`);const n=t.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]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(rDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=Xe.parse(r/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(t){const e=Number(this.seconds)*1e3;if(eDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?n="."+r.substring(0,3)+"Z":r.substring(6)==="000"?n="."+r.substring(0,6)+"Z":n="."+r+"Z"}return new Date(e).toISOString().replace(".000Z",n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return mt.fromDate(new Date)}static fromDate(t){const e=t.getTime();return new mt({seconds:Xe.parse(Math.floor(e/1e3)),nanos:e%1e3*1e6})}static fromBinary(t,e){return new mt().fromBinary(t,e)}static fromJson(t,e){return new mt().fromJson(t,e)}static fromJsonString(t,e){return new mt().fromJsonString(t,e)}static equals(t,e){return L.util.equals(mt,t,e)}}mt.runtime=L;mt.typeName="google.protobuf.Timestamp";mt.fields=L.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Kr extends me{constructor(t){super(),this.seconds=Xe.zero,this.nanos=0,L.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);const n=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(n===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);const r=Number(n[1]);if(r>315576e6||r<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);if(this.seconds=Xe.parse(r),typeof n[2]=="string"){const o=n[2]+"0".repeat(9-n[2].length);this.nanos=parseInt(o),(r<0||Object.is(r,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let e=this.seconds.toString();if(this.nanos!==0){let n=Math.abs(this.nanos).toString();n="0".repeat(9-n.length)+n,n.substring(3)==="000000"?n=n.substring(0,3):n.substring(6)==="000"&&(n=n.substring(0,6)),e+="."+n,this.nanos<0&&Number(this.seconds)==0&&(e="-"+e)}return e+"s"}static fromBinary(t,e){return new Kr().fromBinary(t,e)}static fromJson(t,e){return new Kr().fromJson(t,e)}static fromJsonString(t,e){return new Kr().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Kr,t,e)}}Kr.runtime=L;Kr.typeName="google.protobuf.Duration";Kr.fields=L.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class _n extends me{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),L.util.initPartial(t,this)}toJson(t){var e;if(this.typeUrl==="")return{};const n=this.typeUrlToName(this.typeUrl),r=(e=t==null?void 0:t.typeRegistry)===null||e===void 0?void 0:e.findMessage(n);if(!r)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let s=r.fromBinary(this.value).toJson(t);return(n.startsWith("google.protobuf.")||s===null||Array.isArray(s)||typeof s!="object")&&(s={value:s}),s["@type"]=this.typeUrl,s}fromJson(t,e){var n;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const r=t["@type"];if(typeof r!="string"||r=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const o=this.typeUrlToName(r),s=(n=e==null?void 0:e.typeRegistry)===null||n===void 0?void 0:n.findMessage(o);if(!s)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${r} is not in the type registry`);let u;if(o.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))u=s.fromJson(t.value,e);else{const c=Object.assign({},t);delete c["@type"],u=s.fromJson(c,e)}return this.packFrom(u),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const e=t.findMessage(this.typeUrlToName(this.typeUrl));if(e)return e.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const e=this.typeUrlToName(this.typeUrl);let n="";return typeof t=="string"?n=t:n=t.typeName,e===n}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const e=t.lastIndexOf("/"),n=e>=0?t.substring(e+1):t;if(!n.length)throw new Error(`invalid type url: ${t}`);return n}static pack(t){const e=new _n;return e.packFrom(t),e}static fromBinary(t,e){return new _n().fromBinary(t,e)}static fromJson(t,e){return new _n().fromJson(t,e)}static fromJsonString(t,e){return new _n().fromJsonString(t,e)}static equals(t,e){return L.util.equals(_n,t,e)}}_n.runtime=L;_n.typeName="google.protobuf.Any";_n.fields=L.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Pn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.DOUBLE,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.DOUBLE,t)}catch(n){let r='cannot decode message google.protobuf.DoubleValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Pn().fromBinary(t,e)}static fromJson(t,e){return new Pn().fromJson(t,e)}static fromJsonString(t,e){return new Pn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Pn,t,e)}}Pn.runtime=L;Pn.typeName="google.protobuf.DoubleValue";Pn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Pn.fieldWrapper={wrapField(i){return new Pn({value:i})},unwrapField(i){return i.value}};class Cn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.FLOAT,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.FLOAT,t)}catch(n){let r='cannot decode message google.protobuf.FloatValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Cn().fromBinary(t,e)}static fromJson(t,e){return new Cn().fromJson(t,e)}static fromJsonString(t,e){return new Cn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Cn,t,e)}}Cn.runtime=L;Cn.typeName="google.protobuf.FloatValue";Cn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Cn.fieldWrapper={wrapField(i){return new Cn({value:i})},unwrapField(i){return i.value}};class Ln extends me{constructor(t){super(),this.value=Xe.zero,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.INT64,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.INT64,t)}catch(n){let r='cannot decode message google.protobuf.Int64Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Ln().fromBinary(t,e)}static fromJson(t,e){return new Ln().fromJson(t,e)}static fromJsonString(t,e){return new Ln().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Ln,t,e)}}Ln.runtime=L;Ln.typeName="google.protobuf.Int64Value";Ln.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Ln.fieldWrapper={wrapField(i){return new Ln({value:i})},unwrapField(i){return i.value}};class Rn extends me{constructor(t){super(),this.value=Xe.zero,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.UINT64,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.UINT64,t)}catch(n){let r='cannot decode message google.protobuf.UInt64Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Rn().fromBinary(t,e)}static fromJson(t,e){return new Rn().fromJson(t,e)}static fromJsonString(t,e){return new Rn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Rn,t,e)}}Rn.runtime=L;Rn.typeName="google.protobuf.UInt64Value";Rn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Rn.fieldWrapper={wrapField(i){return new Rn({value:i})},unwrapField(i){return i.value}};class Dn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.INT32,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.INT32,t)}catch(n){let r='cannot decode message google.protobuf.Int32Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Dn().fromBinary(t,e)}static fromJson(t,e){return new Dn().fromJson(t,e)}static fromJsonString(t,e){return new Dn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Dn,t,e)}}Dn.runtime=L;Dn.typeName="google.protobuf.Int32Value";Dn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Dn.fieldWrapper={wrapField(i){return new Dn({value:i})},unwrapField(i){return i.value}};class Bn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.UINT32,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.UINT32,t)}catch(n){let r='cannot decode message google.protobuf.UInt32Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Bn().fromBinary(t,e)}static fromJson(t,e){return new Bn().fromJson(t,e)}static fromJsonString(t,e){return new Bn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Bn,t,e)}}Bn.runtime=L;Bn.typeName="google.protobuf.UInt32Value";Bn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Bn.fieldWrapper={wrapField(i){return new Bn({value:i})},unwrapField(i){return i.value}};class Mn extends me{constructor(t){super(),this.value=!1,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.BOOL,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.BOOL,t)}catch(n){let r='cannot decode message google.protobuf.BoolValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Mn().fromBinary(t,e)}static fromJson(t,e){return new Mn().fromJson(t,e)}static fromJsonString(t,e){return new Mn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Mn,t,e)}}Mn.runtime=L;Mn.typeName="google.protobuf.BoolValue";Mn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Mn.fieldWrapper={wrapField(i){return new Mn({value:i})},unwrapField(i){return i.value}};class Pt extends me{constructor(t){super(),this.value="",L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.STRING,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.STRING,t)}catch(n){let r='cannot decode message google.protobuf.StringValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Pt().fromBinary(t,e)}static fromJson(t,e){return new Pt().fromJson(t,e)}static fromJsonString(t,e){return new Pt().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Pt,t,e)}}Pt.runtime=L;Pt.typeName="google.protobuf.StringValue";Pt.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Pt.fieldWrapper={wrapField(i){return new Pt({value:i})},unwrapField(i){return i.value}};class qn extends me{constructor(t){super(),this.value=new Uint8Array(0),L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.BYTES,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.BYTES,t)}catch(n){let r='cannot decode message google.protobuf.BytesValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new qn().fromBinary(t,e)}static fromJson(t,e){return new qn().fromJson(t,e)}static fromJsonString(t,e){return new qn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(qn,t,e)}}qn.runtime=L;qn.typeName="google.protobuf.BytesValue";qn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);qn.fieldWrapper={wrapField(i){return new qn({value:i})},unwrapField(i){return i.value}};function qc(i,t,e){try{const n=wa.dec(i);return t?t.fromBinary(n,e):n}catch(n){throw Ze.from(n,Ge.DataLoss)}}function Fc(i,t){const e={};for(const[n,r]of Object.entries(i.methods)){const o=t(Object.assign(Object.assign({},r),{localName:n,service:i}));o!=null&&(e[n]=o)}return e}function rl(i){let t,e=new Uint8Array(0);function n(r){const o=new Uint8Array(e.length+r.length);o.set(e),o.set(r,e.length),e=o}return new ReadableStream({start(){t=i.getReader()},async pull(r){let o;for(;;){if(o===void 0&&e.byteLength>=5){let c=0;for(let m=1;m<5;m++)c=(c<<8)+e[m];o={flags:e[0],length:c}}if(o!==void 0&&e.byteLength>=o.length+5)break;const u=await t.read();if(u.done)break;n(u.value)}if(o===void 0){if(e.byteLength==0){r.close();return}r.error(new Ze("premature end of stream",Ge.DataLoss));return}const s=e.subarray(5,5+o.length);e=e.subarray(5+o.length),r.enqueue({flags:o.flags,data:s})}})}function il(i,t){const e=new Uint8Array(t.length+5);e.set(t,5);const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setUint8(0,i),n.setUint32(1,t.length),e}var jc=function(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof __values=="function"?__values(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(u,c){s=i[o](s),r(u,c,s.done,s.value)})}}function r(o,s,u,c){Promise.resolve(c).then(function(m){o({value:m,done:u})},s)}},po=function(i){return this instanceof po?(this.v=i,this):new po(i)},Uc=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof po?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}},Jc=function(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:po(i[r](s)),done:!1}:o?o(s):s}:o}};function $c(i){return Uc(this,arguments,function*(){yield po(yield*Jc(jc(i)))})}var Zl=function(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof __values=="function"?__values(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(u,c){s=i[o](s),r(u,c,s.done,s.value)})}}function r(o,s,u,c){Promise.resolve(c).then(function(m){o({value:m,done:u})},s)}},Wi=function(i){return this instanceof Wi?(this.v=i,this):new Wi(i)},zc=function(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:Wi(i[r](s)),done:!1}:o?o(s):s}:o}},Vc=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof Wi?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}};function Kc(i,t){return Fc(i,e=>{switch(e.kind){case bt.Unary:return Hc(t,i,e);case bt.ServerStreaming:return Wc(t,i,e);case bt.ClientStreaming:return Gc(t,i,e);case bt.BiDiStreaming:return Yc(t,i,e);default:return null}})}function Hc(i,t,e){return async function(n,r){var o,s;const u=await i.unary(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues);return(o=r==null?void 0:r.onHeader)===null||o===void 0||o.call(r,u.header),(s=r==null?void 0:r.onTrailer)===null||s===void 0||s.call(r,u.trailer),u.message}}function Wc(i,t,e){return function(n,r){return Xl(i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,$c([n]),r==null?void 0:r.contextValues),r)}}function Gc(i,t,e){return async function(n,r){var o,s,u,c,m,y;const f=await i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues);(m=r==null?void 0:r.onHeader)===null||m===void 0||m.call(r,f.header);let l;try{for(var a=!0,p=Zl(f.message),b;b=await p.next(),o=b.done,!o;a=!0)c=b.value,a=!1,l=c}catch(w){s={error:w}}finally{try{!a&&!o&&(u=p.return)&&await u.call(p)}finally{if(s)throw s.error}}if(!l)throw new Ze("protocol error: missing response message",Ge.Internal);return(y=r==null?void 0:r.onTrailer)===null||y===void 0||y.call(r,f.trailer),l}}function Yc(i,t,e){return function(n,r){return Xl(i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues),r)}}function Xl(i,t){const e=function(){var n,r;return Vc(this,arguments,function*(){const o=yield Wi(i);(n=t==null?void 0:t.onHeader)===null||n===void 0||n.call(t,o.header),yield Wi(yield*zc(Zl(o.message))),(r=t==null?void 0:t.onTrailer)===null||r===void 0||r.call(t,o.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>e.next()})}}function Zc(...i){const t=new AbortController,e=i.filter(r=>r!==void 0).concat(t.signal);for(const r of e){if(r.aborted){n.apply(r);break}r.addEventListener("abort",n)}function n(){t.signal.aborted||t.abort(Ql(this));for(const r of e)r.removeEventListener("abort",n)}return t}function Xc(i){const t=new AbortController,e=()=>{t.abort(new Ze("the operation timed out",Ge.DeadlineExceeded))};let n;return i!==void 0&&(i<=0?e():n=setTimeout(e,i)),{signal:t.signal,cleanup:()=>clearTimeout(n)}}function Ql(i){if(!i.aborted)return;if(i.reason!==void 0)return i.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function ol(){return{get(i){return i.id in this?this[i.id]:i.defaultValue},set(i,t){return this[i.id]=t,this},delete(i){return delete this[i.id],this}}}const Ms=128;function sl(i){const t=new Headers,e=new TextDecoder().decode(i).split(`\r -`);for(const n of e){if(n==="")continue;const r=n.indexOf(":");if(r>0){const o=n.substring(0,r).trim(),s=n.substring(r+1).trim();t.append(o,s)}}return t}const Qc="Content-Type",ef="Grpc-Timeout",eu="Grpc-Status",tu="Grpc-Message",tf="Grpc-Status-Details-Bin",nf="X-User-Agent",rf="X-Grpc-Web",of="application/grpc-web+proto",sf="application/grpc-web+json";class Hr extends me{constructor(t){super(),this.code=0,this.message="",this.details=[],L.util.initPartial(t,this)}static fromBinary(t,e){return new Hr().fromBinary(t,e)}static fromJson(t,e){return new Hr().fromJson(t,e)}static fromJsonString(t,e){return new Hr().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Hr,t,e)}}Hr.runtime=L;Hr.typeName="google.rpc.Status";Hr.fields=L.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:_n,repeated:!0}]);const af="0";function nu(i){var t;const e=i.get(tf);if(e!=null){const r=qc(e,Hr);if(r.code==0)return;const o=new Ze(r.message,r.code,i);return o.details=r.details.map(s=>({type:s.typeUrl.substring(s.typeUrl.lastIndexOf("/")+1),value:s.value})),o}const n=i.get(eu);if(n!=null){if(n===af)return;const r=parseInt(n,10);return r in Ge?new Ze(decodeURIComponent((t=i.get(tu))!==null&&t!==void 0?t:""),r,i):new Ze(`invalid grpc-status: ${n}`,Ge.Internal,i)}}function al(i,t,e){const n=typeof t=="string"?t:t.typeName,r=typeof e=="string"?e:e.name;return i.toString().replace(/\/?$/,`/${n}/${r}`)}function ru(i,t){return t instanceof i?t:new i(t)}function lf(i,t){function e(n){return n.done===!0?n:{done:n.done,value:ru(i,n.value)}}return{[Symbol.asyncIterator](){const n=t[Symbol.asyncIterator](),r={next:()=>n.next().then(e)};return n.throw!==void 0&&(r.throw=o=>n.throw(o).then(e)),n.return!==void 0&&(r.return=o=>n.return(o).then(e)),r}}}function iu(i,t){var e;return(e=t==null?void 0:t.concat().reverse().reduce((n,r)=>r(n),i))!==null&&e!==void 0?e:i}function uf(i){var t;const e=Object.assign({},i);return(t=e.ignoreUnknownFields)!==null&&t!==void 0||(e.ignoreUnknownFields=!0),e}function ll(i,t,e,n){const r=t?ul(i.I,n):cl(i.I,e);return{parse:(t?ul(i.O,n):cl(i.O,e)).parse,serialize:r.serialize}}function ul(i,t){return{parse(e){try{return i.fromBinary(e,t)}catch(n){const r=n instanceof Error?n.message:String(n);throw new Ze(`parse binary: ${r}`,Ge.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const r=n instanceof Error?n.message:String(n);throw new Ze(`serialize binary: ${r}`,Ge.Internal)}}}}function cl(i,t){var e,n;const r=(e=t==null?void 0:t.textEncoder)!==null&&e!==void 0?e:new TextEncoder,o=(n=t==null?void 0:t.textDecoder)!==null&&n!==void 0?n:new TextDecoder,s=uf(t);return{parse(u){try{const c=o.decode(u);return i.fromJsonString(c,s)}catch(c){throw Ze.from(c,Ge.InvalidArgument)}},serialize(u){try{const c=u.toJsonString(s);return r.encode(c)}catch(c){throw Ze.from(c,Ge.Internal)}}}}function cf(i){const t=iu(i.next,i.interceptors),[e,n,r]=ou(i),o=Object.assign(Object.assign({},i.req),{message:ru(i.req.method.I,i.req.message),signal:e});return t(o).then(s=>(r(),s),n)}function ff(i){const t=iu(i.next,i.interceptors),[e,n,r]=ou(i),o=Object.assign(Object.assign({},i.req),{message:lf(i.req.method.I,i.req.message),signal:e});let s=!1;return e.addEventListener("abort",function(){var u,c;const m=i.req.message[Symbol.asyncIterator]();s||(u=m.throw)===null||u===void 0||u.call(m,this.reason).catch(()=>{}),(c=m.return)===null||c===void 0||c.call(m).catch(()=>{})}),t(o).then(u=>Object.assign(Object.assign({},u),{message:{[Symbol.asyncIterator](){const c=u.message[Symbol.asyncIterator]();return{next(){return c.next().then(m=>(m.done==!0&&(s=!0,r()),m),n)}}}}}),n)}function ou(i){const{signal:t,cleanup:e}=Xc(i.timeoutMs),n=Zc(i.signal,t);return[n.signal,function(o){const s=Ze.from(t.aborted?Ql(t):o);return n.abort(s),e(),Promise.reject(s)},function(){e(),n.abort()}]}function hf(){try{new Headers}catch{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.")}}function fl(i,t){const e=nu(i);if(e)throw t.forEach((n,r)=>{e.metadata.append(r,n)}),e}function hl(i,t,e,n){const r=new Headers(e??{});return r.set(Qc,i?of:sf),r.set(rf,"1"),r.set(nf,"connect-es/1.4.0"),t!==void 0&&r.set(ef,`${t}m`),r}function df(i){switch(i){case 400:return Ge.Internal;case 401:return Ge.Unauthenticated;case 403:return Ge.PermissionDenied;case 404:return Ge.Unimplemented;case 429:return Ge.Unavailable;case 502:return Ge.Unavailable;case 503:return Ge.Unavailable;case 504:return Ge.Unavailable;default:return Ge.Unknown}}function dl(i,t){var e;if(i>=200&&i<300){const n=nu(t);if(n)throw n;return{foundStatus:t.has(eu)}}throw new Ze(decodeURIComponent((e=t.get(tu))!==null&&e!==void 0?e:`HTTP ${i}`),df(i),t)}var Ei=function(i){return this instanceof Ei?(this.v=i,this):new Ei(i)},gf=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof Ei?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}};function pf(i){var t;hf();const e=(t=i.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(n,r,o,s,u,c,m){var y;const{serialize:f,parse:l}=ll(r,e,i.jsonOptions,i.binaryOptions);return s=s===void 0?i.defaultTimeoutMs:s<=0?void 0:s,await cf({interceptors:i.interceptors,signal:o,timeoutMs:s,req:{stream:!1,service:n,method:r,url:al(i.baseUrl,n,r),init:{method:"POST",credentials:(y=i.credentials)!==null&&y!==void 0?y:"same-origin",redirect:"error",mode:"cors"},header:hl(e,s,u),contextValues:m??ol(),message:c},next:async a=>{var p;const w=await((p=i.fetch)!==null&&p!==void 0?p:globalThis.fetch)(a.url,Object.assign(Object.assign({},a.init),{headers:a.header,signal:a.signal,body:il(0,f(a.message))}));if(dl(w.status,w.headers),!w.body)throw"missing response body";const v=rl(w.body).getReader();let h,g;for(;;){const d=await v.read();if(d.done)break;const{flags:A,data:S}=d.value;if(A===Ms){if(h!==void 0)throw"extra trailer";h=sl(S);continue}if(g!==void 0)throw"extra message";g=l(S)}if(h===void 0)throw"missing trailer";if(fl(h,w.headers),g===void 0)throw"missing message";return{stream:!1,service:n,method:r,header:w.headers,message:g,trailer:h}}})},async stream(n,r,o,s,u,c,m){var y;const{serialize:f,parse:l}=ll(r,e,i.jsonOptions,i.binaryOptions);function a(b,w,v,h){return gf(this,arguments,function*(){const d=rl(b).getReader();if(w){if(!(yield Ei(d.read())).done)throw"extra data for trailers-only";return yield Ei(void 0)}let A=!1;for(;;){const S=yield Ei(d.read());if(S.done)break;const{flags:E,data:O}=S.value;if((E&Ms)===Ms){if(A)throw"extra trailer";A=!0;const _=sl(O);fl(_,h),_.forEach((k,x)=>v.set(x,k));continue}if(A)throw"extra message";yield yield Ei(l(O))}if(!A)throw"missing trailer"})}async function p(b){if(r.kind!=bt.ServerStreaming)throw"The fetch API does not support streaming request bodies";const w=await b[Symbol.asyncIterator]().next();if(w.done==!0)throw"missing request message";return il(0,f(w.value))}return s=s===void 0?i.defaultTimeoutMs:s<=0?void 0:s,ff({interceptors:i.interceptors,signal:o,timeoutMs:s,req:{stream:!0,service:n,method:r,url:al(i.baseUrl,n,r),init:{method:"POST",credentials:(y=i.credentials)!==null&&y!==void 0?y:"same-origin",redirect:"error",mode:"cors"},header:hl(e,s,u),contextValues:m??ol(),message:c},next:async b=>{var w;const h=await((w=i.fetch)!==null&&w!==void 0?w:globalThis.fetch)(b.url,Object.assign(Object.assign({},b.init),{headers:b.header,signal:b.signal,body:await p(b.message)})),{foundStatus:g}=dl(h.status,h.headers);if(!h.body)throw"missing response body";const d=new Headers;return Object.assign(Object.assign({},b),{header:h.headers,trailer:d,message:a(h.body,g,d,h.headers)})}})}}}var Re=(i=>(i[i.NULL=0]="NULL",i[i.BOOLEAN=1]="BOOLEAN",i[i.INTEGER=2]="INTEGER",i[i.LONG=3]="LONG",i[i.DOUBLE=4]="DOUBLE",i[i.STRING=5]="STRING",i[i.BYTES=6]="BYTES",i[i.DATE=7]="DATE",i[i.JSON_OBJECT=8]="JSON_OBJECT",i[i.JSON_ARRAY=9]="JSON_ARRAY",i[i.TEXT=10]="TEXT",i[i.INTEGER_CNT=11]="INTEGER_CNT",i[i.LONG_CNT=12]="LONG_CNT",i[i.TREE=13]="TREE",i))(Re||{});L.util.setEnumType(Re,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var Oi=(i=>(i[i.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",i[i.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",i[i.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",i[i.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",i))(Oi||{});L.util.setEnumType(Oi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const Vn=class Vn extends me{constructor(e){super();T(this,"root");T(this,"presences",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Vn().fromBinary(e,n)}static fromJson(e,n){return new Vn().fromJson(e,n)}static fromJsonString(e,n){return new Vn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Vn,e,n)}};T(Vn,"runtime",L),T(Vn,"typeName","yorkie.v1.Snapshot"),T(Vn,"fields",L.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:kt},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Ta}}]));let Ks=Vn;var Mt;let Qr=(Mt=class extends me{constructor(e){super();T(this,"documentKey","");T(this,"checkpoint");T(this,"snapshot",new Uint8Array(0));T(this,"changes",[]);T(this,"minSyncedTicket");T(this,"isRemoved",!1);T(this,"versionVector");L.util.initPartial(e,this)}static fromBinary(e,n){return new Mt().fromBinary(e,n)}static fromJson(e,n){return new Mt().fromJson(e,n)}static fromJsonString(e,n){return new Mt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Mt,e,n)}},T(Mt,"runtime",L),T(Mt,"typeName","yorkie.v1.ChangePack"),T(Mt,"fields",L.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:lu},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:su,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:xe},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Os}])),Mt);var qt;let su=(qt=class extends me{constructor(e){super();T(this,"id");T(this,"message","");T(this,"operations",[]);T(this,"presenceChange");L.util.initPartial(e,this)}static fromBinary(e,n){return new qt().fromBinary(e,n)}static fromJson(e,n){return new qt().fromJson(e,n)}static fromJsonString(e,n){return new qt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(qt,e,n)}},T(qt,"runtime",L),T(qt,"typeName","yorkie.v1.Change"),T(qt,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:ks},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Aa,repeated:!0},{no:4,name:"presence_change",kind:"message",T:vo}])),qt);var Ft;let ks=(Ft=class extends me{constructor(e){super();T(this,"clientSeq",0);T(this,"serverSeq",Xe.zero);T(this,"lamport",Xe.zero);T(this,"actorId",new Uint8Array(0));T(this,"versionVector");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ft().fromBinary(e,n)}static fromJson(e,n){return new Ft().fromJson(e,n)}static fromJsonString(e,n){return new Ft().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ft,e,n)}},T(Ft,"runtime",L),T(Ft,"typeName","yorkie.v1.ChangeID"),T(Ft,"fields",L.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Os}])),Ft);var jt;let Os=(jt=class extends me{constructor(e){super();T(this,"vector",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new jt().fromBinary(e,n)}static fromJson(e,n){return new jt().fromJson(e,n)}static fromJsonString(e,n){return new jt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(jt,e,n)}},T(jt,"runtime",L),T(jt,"typeName","yorkie.v1.VersionVector"),T(jt,"fields",L.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),jt);var Ut;let Aa=(Ut=class extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new Ut().fromBinary(e,n)}static fromJson(e,n){return new Ut().fromJson(e,n)}static fromJsonString(e,n){return new Ut().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ut,e,n)}},T(Ut,"runtime",L),T(Ut,"typeName","yorkie.v1.Operation"),T(Ut,"fields",L.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:rs,oneof:"body"},{no:2,name:"add",kind:"message",T:is,oneof:"body"},{no:3,name:"move",kind:"message",T:os,oneof:"body"},{no:4,name:"remove",kind:"message",T:ss,oneof:"body"},{no:5,name:"edit",kind:"message",T:as,oneof:"body"},{no:6,name:"select",kind:"message",T:Hs,oneof:"body"},{no:7,name:"style",kind:"message",T:ls,oneof:"body"},{no:8,name:"increase",kind:"message",T:us,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:cs,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:fs,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Ws,oneof:"body"}])),Ut);const Kn=class Kn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"key","");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Kn().fromBinary(e,n)}static fromJson(e,n){return new Kn().fromJson(e,n)}static fromJsonString(e,n){return new Kn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Kn,e,n)}};T(Kn,"runtime",L),T(Kn,"typeName","yorkie.v1.Operation.Set"),T(Kn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let rs=Kn;const Hn=class Hn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"prevCreatedAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Hn().fromBinary(e,n)}static fromJson(e,n){return new Hn().fromJson(e,n)}static fromJsonString(e,n){return new Hn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Hn,e,n)}};T(Hn,"runtime",L),T(Hn,"typeName","yorkie.v1.Operation.Add"),T(Hn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"prev_created_at",kind:"message",T:xe},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let is=Hn;const Wn=class Wn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"prevCreatedAt");T(this,"createdAt");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Wn().fromBinary(e,n)}static fromJson(e,n){return new Wn().fromJson(e,n)}static fromJsonString(e,n){return new Wn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Wn,e,n)}};T(Wn,"runtime",L),T(Wn,"typeName","yorkie.v1.Operation.Move"),T(Wn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"prev_created_at",kind:"message",T:xe},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"executed_at",kind:"message",T:xe}]));let os=Wn;const Gn=class Gn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"createdAt");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Gn().fromBinary(e,n)}static fromJson(e,n){return new Gn().fromJson(e,n)}static fromJsonString(e,n){return new Gn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Gn,e,n)}};T(Gn,"runtime",L),T(Gn,"typeName","yorkie.v1.Operation.Remove"),T(Gn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"executed_at",kind:"message",T:xe}]));let ss=Gn;const Yn=class Yn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"createdAtMapByActor",{});T(this,"content","");T(this,"executedAt");T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Yn().fromBinary(e,n)}static fromJson(e,n){return new Yn().fromJson(e,n)}static fromJsonString(e,n){return new Yn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Yn,e,n)}};T(Yn,"runtime",L),T(Yn,"typeName","yorkie.v1.Operation.Edit"),T(Yn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:xe},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let as=Yn;const Zn=class Zn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Zn().fromBinary(e,n)}static fromJson(e,n){return new Zn().fromJson(e,n)}static fromJsonString(e,n){return new Zn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Zn,e,n)}};T(Zn,"runtime",L),T(Zn,"typeName","yorkie.v1.Operation.Select"),T(Zn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"executed_at",kind:"message",T:xe}]));let Hs=Zn;const Xn=class Xn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"attributes",{});T(this,"executedAt");T(this,"createdAtMapByActor",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Xn().fromBinary(e,n)}static fromJson(e,n){return new Xn().fromJson(e,n)}static fromJsonString(e,n){return new Xn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Xn,e,n)}};T(Xn,"runtime",L),T(Xn,"typeName","yorkie.v1.Operation.Style"),T(Xn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:xe},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}}]));let ls=Xn;const Qn=class Qn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Qn().fromBinary(e,n)}static fromJson(e,n){return new Qn().fromJson(e,n)}static fromJsonString(e,n){return new Qn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Qn,e,n)}};T(Qn,"runtime",L),T(Qn,"typeName","yorkie.v1.Operation.Increase"),T(Qn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"value",kind:"message",T:Bt},{no:3,name:"executed_at",kind:"message",T:xe}]));let us=Qn;const er=class er extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"createdAtMapByActor",{});T(this,"contents",[]);T(this,"splitLevel",0);T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new er().fromBinary(e,n)}static fromJson(e,n){return new er().fromJson(e,n)}static fromJsonString(e,n){return new er().fromJsonString(e,n)}static equals(e,n){return L.util.equals(er,e,n)}};T(er,"runtime",L),T(er,"typeName","yorkie.v1.Operation.TreeEdit"),T(er,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}},{no:5,name:"contents",kind:"message",T:ws,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:xe}]));let cs=er;const tr=class tr extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"attributes",{});T(this,"executedAt");T(this,"attributesToRemove",[]);T(this,"createdAtMapByActor",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new tr().fromBinary(e,n)}static fromJson(e,n){return new tr().fromJson(e,n)}static fromJsonString(e,n){return new tr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(tr,e,n)}};T(tr,"runtime",L),T(tr,"typeName","yorkie.v1.Operation.TreeStyle"),T(tr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:xe},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}}]));let fs=tr;const nr=class nr extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"createdAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new nr().fromBinary(e,n)}static fromJson(e,n){return new nr().fromJson(e,n)}static fromJsonString(e,n){return new nr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(nr,e,n)}};T(nr,"runtime",L),T(nr,"typeName","yorkie.v1.Operation.ArraySet"),T(nr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let Ws=nr;const rr=class rr extends me{constructor(e){super();T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");T(this,"type",0);T(this,"value",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new rr().fromBinary(e,n)}static fromJson(e,n){return new rr().fromJson(e,n)}static fromJsonString(e,n){return new rr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(rr,e,n)}};T(rr,"runtime",L),T(rr,"typeName","yorkie.v1.JSONElementSimple"),T(rr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"moved_at",kind:"message",T:xe},{no:3,name:"removed_at",kind:"message",T:xe},{no:4,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:5,name:"value",kind:"scalar",T:12}]));let Bt=rr;const ir=class ir extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new ir().fromBinary(e,n)}static fromJson(e,n){return new ir().fromJson(e,n)}static fromJsonString(e,n){return new ir().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ir,e,n)}};T(ir,"runtime",L),T(ir,"typeName","yorkie.v1.JSONElement"),T(ir,"fields",L.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:hs,oneof:"body"},{no:2,name:"json_array",kind:"message",T:ds,oneof:"body"},{no:3,name:"primitive",kind:"message",T:gs,oneof:"body"},{no:5,name:"text",kind:"message",T:ps,oneof:"body"},{no:6,name:"counter",kind:"message",T:ms,oneof:"body"},{no:7,name:"tree",kind:"message",T:ys,oneof:"body"}]));let kt=ir;const or=class or extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new or().fromBinary(e,n)}static fromJson(e,n){return new or().fromJson(e,n)}static fromJsonString(e,n){return new or().fromJsonString(e,n)}static equals(e,n){return L.util.equals(or,e,n)}};T(or,"runtime",L),T(or,"typeName","yorkie.v1.JSONElement.JSONObject"),T(or,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:au,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let hs=or;const sr=class sr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new sr().fromBinary(e,n)}static fromJson(e,n){return new sr().fromJson(e,n)}static fromJsonString(e,n){return new sr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(sr,e,n)}};T(sr,"runtime",L),T(sr,"typeName","yorkie.v1.JSONElement.JSONArray"),T(sr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:vs,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ds=sr;const ar=class ar extends me{constructor(e){super();T(this,"type",0);T(this,"value",new Uint8Array(0));T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new ar().fromBinary(e,n)}static fromJson(e,n){return new ar().fromJson(e,n)}static fromJsonString(e,n){return new ar().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ar,e,n)}};T(ar,"runtime",L),T(ar,"typeName","yorkie.v1.JSONElement.Primitive"),T(ar,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"moved_at",kind:"message",T:xe},{no:5,name:"removed_at",kind:"message",T:xe}]));let gs=ar;const lr=class lr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new lr().fromBinary(e,n)}static fromJson(e,n){return new lr().fromJson(e,n)}static fromJsonString(e,n){return new lr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(lr,e,n)}};T(lr,"runtime",L),T(lr,"typeName","yorkie.v1.JSONElement.Text"),T(lr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:bs,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ps=lr;const ur=class ur extends me{constructor(e){super();T(this,"type",0);T(this,"value",new Uint8Array(0));T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new ur().fromBinary(e,n)}static fromJson(e,n){return new ur().fromJson(e,n)}static fromJsonString(e,n){return new ur().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ur,e,n)}};T(ur,"runtime",L),T(ur,"typeName","yorkie.v1.JSONElement.Counter"),T(ur,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"moved_at",kind:"message",T:xe},{no:5,name:"removed_at",kind:"message",T:xe}]));let ms=ur;const cr=class cr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new cr().fromBinary(e,n)}static fromJson(e,n){return new cr().fromJson(e,n)}static fromJsonString(e,n){return new cr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(cr,e,n)}};T(cr,"runtime",L),T(cr,"typeName","yorkie.v1.JSONElement.Tree"),T(cr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yo,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ys=cr;var Jt;let au=(Jt=class extends me{constructor(e){super();T(this,"key","");T(this,"element");L.util.initPartial(e,this)}static fromBinary(e,n){return new Jt().fromBinary(e,n)}static fromJson(e,n){return new Jt().fromJson(e,n)}static fromJsonString(e,n){return new Jt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Jt,e,n)}},T(Jt,"runtime",L),T(Jt,"typeName","yorkie.v1.RHTNode"),T(Jt,"fields",L.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:kt}])),Jt);const In=class In extends me{constructor(e){super();T(this,"next");T(this,"element");L.util.initPartial(e,this)}static fromBinary(e,n){return new In().fromBinary(e,n)}static fromJson(e,n){return new In().fromJson(e,n)}static fromJsonString(e,n){return new In().fromJsonString(e,n)}static equals(e,n){return L.util.equals(In,e,n)}};T(In,"runtime",L),T(In,"typeName","yorkie.v1.RGANode"),T(In,"fields",L.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:In},{no:2,name:"element",kind:"message",T:kt}]));let vs=In;const fr=class fr extends me{constructor(e){super();T(this,"value","");T(this,"updatedAt");T(this,"isRemoved",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new fr().fromBinary(e,n)}static fromJson(e,n){return new fr().fromJson(e,n)}static fromJsonString(e,n){return new fr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(fr,e,n)}};T(fr,"runtime",L),T(fr,"typeName","yorkie.v1.NodeAttr"),T(fr,"fields",L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:xe},{no:3,name:"is_removed",kind:"scalar",T:8}]));let Gi=fr;const hr=class hr extends me{constructor(e){super();T(this,"id");T(this,"value","");T(this,"removedAt");T(this,"insPrevId");T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new hr().fromBinary(e,n)}static fromJson(e,n){return new hr().fromJson(e,n)}static fromJsonString(e,n){return new hr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(hr,e,n)}};T(hr,"runtime",L),T(hr,"typeName","yorkie.v1.TextNode"),T(hr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:mo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:xe},{no:4,name:"ins_prev_id",kind:"message",T:mo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Gi}}]));let bs=hr;const dr=class dr extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new dr().fromBinary(e,n)}static fromJson(e,n){return new dr().fromJson(e,n)}static fromJsonString(e,n){return new dr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(dr,e,n)}};T(dr,"runtime",L),T(dr,"typeName","yorkie.v1.TextNodeID"),T(dr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5}]));let mo=dr;const gr=class gr extends me{constructor(e){super();T(this,"id");T(this,"type","");T(this,"value","");T(this,"removedAt");T(this,"insPrevId");T(this,"insNextId");T(this,"depth",0);T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new gr().fromBinary(e,n)}static fromJson(e,n){return new gr().fromJson(e,n)}static fromJsonString(e,n){return new gr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(gr,e,n)}};T(gr,"runtime",L),T(gr,"typeName","yorkie.v1.TreeNode"),T(gr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:fi},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:xe},{no:5,name:"ins_prev_id",kind:"message",T:fi},{no:6,name:"ins_next_id",kind:"message",T:fi},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Gi}}]));let yo=gr;const pr=class pr extends me{constructor(e){super();T(this,"content",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new pr().fromBinary(e,n)}static fromJson(e,n){return new pr().fromJson(e,n)}static fromJsonString(e,n){return new pr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(pr,e,n)}};T(pr,"runtime",L),T(pr,"typeName","yorkie.v1.TreeNodes"),T(pr,"fields",L.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:yo,repeated:!0}]));let ws=pr;const mr=class mr extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new mr().fromBinary(e,n)}static fromJson(e,n){return new mr().fromJson(e,n)}static fromJsonString(e,n){return new mr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(mr,e,n)}};T(mr,"runtime",L),T(mr,"typeName","yorkie.v1.TreeNodeID"),T(mr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5}]));let fi=mr;const yr=class yr extends me{constructor(e){super();T(this,"parentId");T(this,"leftSiblingId");L.util.initPartial(e,this)}static fromBinary(e,n){return new yr().fromBinary(e,n)}static fromJson(e,n){return new yr().fromJson(e,n)}static fromJsonString(e,n){return new yr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(yr,e,n)}};T(yr,"runtime",L),T(yr,"typeName","yorkie.v1.TreePos"),T(yr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:fi},{no:2,name:"left_sibling_id",kind:"message",T:fi}]));let Ii=yr;const vr=class vr extends me{constructor(e){super();T(this,"id","");T(this,"username","");T(this,"createdAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new vr().fromBinary(e,n)}static fromJson(e,n){return new vr().fromJson(e,n)}static fromJsonString(e,n){return new vr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(vr,e,n)}};T(vr,"runtime",L),T(vr,"typeName","yorkie.v1.User"),T(vr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:mt}]));let gl=vr;const br=class br extends me{constructor(e){super();T(this,"id","");T(this,"name","");T(this,"publicKey","");T(this,"secretKey","");T(this,"authWebhookUrl","");T(this,"authWebhookMethods",[]);T(this,"clientDeactivateThreshold","");T(this,"createdAt");T(this,"updatedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new br().fromBinary(e,n)}static fromJson(e,n){return new br().fromJson(e,n)}static fromJsonString(e,n){return new br().fromJsonString(e,n)}static equals(e,n){return L.util.equals(br,e,n)}};T(br,"runtime",L),T(br,"typeName","yorkie.v1.Project"),T(br,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:mt},{no:9,name:"updated_at",kind:"message",T:mt}]));let pl=br;const wr=class wr extends me{constructor(e){super();T(this,"name");T(this,"authWebhookUrl");T(this,"authWebhookMethods");T(this,"clientDeactivateThreshold");L.util.initPartial(e,this)}static fromBinary(e,n){return new wr().fromBinary(e,n)}static fromJson(e,n){return new wr().fromJson(e,n)}static fromJsonString(e,n){return new wr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(wr,e,n)}};T(wr,"runtime",L),T(wr,"typeName","yorkie.v1.UpdatableProjectFields"),T(wr,"fields",L.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Pt},{no:2,name:"auth_webhook_url",kind:"message",T:Pt},{no:3,name:"auth_webhook_methods",kind:"message",T:Gs},{no:4,name:"client_deactivate_threshold",kind:"message",T:Pt}]));let ml=wr;const Ar=class Ar extends me{constructor(e){super();T(this,"methods",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new Ar().fromBinary(e,n)}static fromJson(e,n){return new Ar().fromJson(e,n)}static fromJsonString(e,n){return new Ar().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ar,e,n)}};T(Ar,"runtime",L),T(Ar,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),T(Ar,"fields",L.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Gs=Ar;const Tr=class Tr extends me{constructor(e){super();T(this,"id","");T(this,"key","");T(this,"snapshot","");T(this,"createdAt");T(this,"accessedAt");T(this,"updatedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Tr().fromBinary(e,n)}static fromJson(e,n){return new Tr().fromJson(e,n)}static fromJsonString(e,n){return new Tr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Tr,e,n)}};T(Tr,"runtime",L),T(Tr,"typeName","yorkie.v1.DocumentSummary"),T(Tr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:mt},{no:5,name:"accessed_at",kind:"message",T:mt},{no:6,name:"updated_at",kind:"message",T:mt}]));let yl=Tr;const Sr=class Sr extends me{constructor(e){super();T(this,"type",0);T(this,"presence");L.util.initPartial(e,this)}static fromBinary(e,n){return new Sr().fromBinary(e,n)}static fromJson(e,n){return new Sr().fromJson(e,n)}static fromJsonString(e,n){return new Sr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Sr,e,n)}};T(Sr,"runtime",L),T(Sr,"typeName","yorkie.v1.PresenceChange"),T(Sr,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Ni)},{no:2,name:"presence",kind:"message",T:Ta}]));let vo=Sr;var Ni=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.PUT=1]="PUT",i[i.DELETE=2]="DELETE",i[i.CLEAR=3]="CLEAR",i))(Ni||{});L.util.setEnumType(Ni,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var $t;let Ta=($t=class extends me{constructor(e){super();T(this,"data",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new $t().fromBinary(e,n)}static fromJson(e,n){return new $t().fromJson(e,n)}static fromJsonString(e,n){return new $t().fromJsonString(e,n)}static equals(e,n){return L.util.equals($t,e,n)}},T($t,"runtime",L),T($t,"typeName","yorkie.v1.Presence"),T($t,"fields",L.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),$t);var zt;let lu=(zt=class extends me{constructor(e){super();T(this,"serverSeq",Xe.zero);T(this,"clientSeq",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new zt().fromBinary(e,n)}static fromJson(e,n){return new zt().fromJson(e,n)}static fromJsonString(e,n){return new zt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(zt,e,n)}},T(zt,"runtime",L),T(zt,"typeName","yorkie.v1.Checkpoint"),T(zt,"fields",L.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),zt);const Er=class Er extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);T(this,"relativeOffset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new Er().fromBinary(e,n)}static fromJson(e,n){return new Er().fromJson(e,n)}static fromJsonString(e,n){return new Er().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Er,e,n)}};T(Er,"runtime",L),T(Er,"typeName","yorkie.v1.TextNodePos"),T(Er,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Zr=Er;var Vt;let xe=(Vt=class extends me{constructor(e){super();T(this,"lamport",Xe.zero);T(this,"delimiter",0);T(this,"actorId",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new Vt().fromBinary(e,n)}static fromJson(e,n){return new Vt().fromJson(e,n)}static fromJsonString(e,n){return new Vt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Vt,e,n)}},T(Vt,"runtime",L),T(Vt,"typeName","yorkie.v1.TimeTicket"),T(Vt,"fields",L.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),Vt);const xr=class xr extends me{constructor(e){super();T(this,"topic","");T(this,"payload",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new xr().fromBinary(e,n)}static fromJson(e,n){return new xr().fromJson(e,n)}static fromJsonString(e,n){return new xr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(xr,e,n)}};T(xr,"runtime",L),T(xr,"typeName","yorkie.v1.DocEventBody"),T(xr,"fields",L.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Ys=xr;const kr=class kr extends me{constructor(e){super();T(this,"type",0);T(this,"publisher","");T(this,"body");L.util.initPartial(e,this)}static fromBinary(e,n){return new kr().fromBinary(e,n)}static fromJson(e,n){return new kr().fromJson(e,n)}static fromJsonString(e,n){return new kr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(kr,e,n)}};T(kr,"runtime",L),T(kr,"typeName","yorkie.v1.DocEvent"),T(kr,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Oi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Ys}]));let Zs=kr;const Or=class Or extends me{constructor(e){super();T(this,"clientKey","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Or().fromBinary(e,n)}static fromJson(e,n){return new Or().fromJson(e,n)}static fromJsonString(e,n){return new Or().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Or,e,n)}};T(Or,"runtime",L),T(Or,"typeName","yorkie.v1.ActivateClientRequest"),T(Or,"fields",L.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Xs=Or;const Ir=class Ir extends me{constructor(e){super();T(this,"clientId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ir().fromBinary(e,n)}static fromJson(e,n){return new Ir().fromJson(e,n)}static fromJsonString(e,n){return new Ir().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ir,e,n)}};T(Ir,"runtime",L),T(Ir,"typeName","yorkie.v1.ActivateClientResponse"),T(Ir,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let Qs=Ir;const Nr=class Nr extends me{constructor(e){super();T(this,"clientId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Nr().fromBinary(e,n)}static fromJson(e,n){return new Nr().fromJson(e,n)}static fromJsonString(e,n){return new Nr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Nr,e,n)}};T(Nr,"runtime",L),T(Nr,"typeName","yorkie.v1.DeactivateClientRequest"),T(Nr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let ea=Nr;const _r=class _r extends me{constructor(t){super(),L.util.initPartial(t,this)}static fromBinary(t,e){return new _r().fromBinary(t,e)}static fromJson(t,e){return new _r().fromJson(t,e)}static fromJsonString(t,e){return new _r().fromJsonString(t,e)}static equals(t,e){return L.util.equals(_r,t,e)}};T(_r,"runtime",L),T(_r,"typeName","yorkie.v1.DeactivateClientResponse"),T(_r,"fields",L.util.newFieldList(()=>[]));let ta=_r;const Pr=class Pr extends me{constructor(e){super();T(this,"clientId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Pr().fromBinary(e,n)}static fromJson(e,n){return new Pr().fromJson(e,n)}static fromJsonString(e,n){return new Pr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Pr,e,n)}};T(Pr,"runtime",L),T(Pr,"typeName","yorkie.v1.AttachDocumentRequest"),T(Pr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Qr}]));let na=Pr;const Cr=class Cr extends me{constructor(e){super();T(this,"documentId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Cr().fromBinary(e,n)}static fromJson(e,n){return new Cr().fromJson(e,n)}static fromJsonString(e,n){return new Cr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Cr,e,n)}};T(Cr,"runtime",L),T(Cr,"typeName","yorkie.v1.AttachDocumentResponse"),T(Cr,"fields",L.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Qr}]));let ra=Cr;const Lr=class Lr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");T(this,"removeIfNotAttached",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new Lr().fromBinary(e,n)}static fromJson(e,n){return new Lr().fromJson(e,n)}static fromJsonString(e,n){return new Lr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Lr,e,n)}};T(Lr,"runtime",L),T(Lr,"typeName","yorkie.v1.DetachDocumentRequest"),T(Lr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let ia=Lr;const Rr=class Rr extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Rr().fromBinary(e,n)}static fromJson(e,n){return new Rr().fromJson(e,n)}static fromJsonString(e,n){return new Rr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Rr,e,n)}};T(Rr,"runtime",L),T(Rr,"typeName","yorkie.v1.DetachDocumentResponse"),T(Rr,"fields",L.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Qr}]));let oa=Rr;const Dr=class Dr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Dr().fromBinary(e,n)}static fromJson(e,n){return new Dr().fromJson(e,n)}static fromJsonString(e,n){return new Dr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Dr,e,n)}};T(Dr,"runtime",L),T(Dr,"typeName","yorkie.v1.WatchDocumentRequest"),T(Dr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let sa=Dr;const Br=class Br extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new Br().fromBinary(e,n)}static fromJson(e,n){return new Br().fromJson(e,n)}static fromJsonString(e,n){return new Br().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Br,e,n)}};T(Br,"runtime",L),T(Br,"typeName","yorkie.v1.WatchDocumentResponse"),T(Br,"fields",L.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:la,oneof:"body"},{no:2,name:"event",kind:"message",T:Zs,oneof:"body"}]));let aa=Br;const Mr=class Mr extends me{constructor(e){super();T(this,"clientIds",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new Mr().fromBinary(e,n)}static fromJson(e,n){return new Mr().fromJson(e,n)}static fromJsonString(e,n){return new Mr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Mr,e,n)}};T(Mr,"runtime",L),T(Mr,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),T(Mr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let la=Mr;const qr=class qr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new qr().fromBinary(e,n)}static fromJson(e,n){return new qr().fromJson(e,n)}static fromJsonString(e,n){return new qr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(qr,e,n)}};T(qr,"runtime",L),T(qr,"typeName","yorkie.v1.RemoveDocumentRequest"),T(qr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr}]));let ua=qr;const Fr=class Fr extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Fr().fromBinary(e,n)}static fromJson(e,n){return new Fr().fromJson(e,n)}static fromJsonString(e,n){return new Fr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Fr,e,n)}};T(Fr,"runtime",L),T(Fr,"typeName","yorkie.v1.RemoveDocumentResponse"),T(Fr,"fields",L.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Qr}]));let ca=Fr;const jr=class jr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");T(this,"pushOnly",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new jr().fromBinary(e,n)}static fromJson(e,n){return new jr().fromJson(e,n)}static fromJsonString(e,n){return new jr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(jr,e,n)}};T(jr,"runtime",L),T(jr,"typeName","yorkie.v1.PushPullChangesRequest"),T(jr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr},{no:4,name:"push_only",kind:"scalar",T:8}]));let fa=jr;const Ur=class Ur extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ur().fromBinary(e,n)}static fromJson(e,n){return new Ur().fromJson(e,n)}static fromJsonString(e,n){return new Ur().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ur,e,n)}};T(Ur,"runtime",L),T(Ur,"typeName","yorkie.v1.PushPullChangesResponse"),T(Ur,"fields",L.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Qr}]));let ha=Ur;const Jr=class Jr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"topic","");T(this,"payload",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new Jr().fromBinary(e,n)}static fromJson(e,n){return new Jr().fromJson(e,n)}static fromJsonString(e,n){return new Jr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Jr,e,n)}};T(Jr,"runtime",L),T(Jr,"typeName","yorkie.v1.BroadcastRequest"),T(Jr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let da=Jr;const $r=class $r extends me{constructor(t){super(),L.util.initPartial(t,this)}static fromBinary(t,e){return new $r().fromBinary(t,e)}static fromJson(t,e){return new $r().fromJson(t,e)}static fromJsonString(t,e){return new $r().fromJsonString(t,e)}static equals(t,e){return L.util.equals($r,t,e)}};T($r,"runtime",L),T($r,"typeName","yorkie.v1.BroadcastResponse"),T($r,"fields",L.util.newFieldList(()=>[]));let ga=$r;const mf={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Xs,O:Qs,kind:bt.Unary},deactivateClient:{name:"DeactivateClient",I:ea,O:ta,kind:bt.Unary},attachDocument:{name:"AttachDocument",I:na,O:ra,kind:bt.Unary},detachDocument:{name:"DetachDocument",I:ia,O:oa,kind:bt.Unary},removeDocument:{name:"RemoveDocument",I:ua,O:ca,kind:bt.Unary},pushPullChanges:{name:"PushPullChanges",I:fa,O:ha,kind:bt.Unary},watchDocument:{name:"WatchDocument",I:sa,O:aa,kind:bt.ServerStreaming},broadcast:{name:"Broadcast",I:da,O:ga,kind:bt.Unary}}},yf=L.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);L.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Kr}]);L.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:vf,repeated:!0}]);const vf=L.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});L.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:bf,repeated:!0}]);const bf=L.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});L.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:wf,repeated:!0}]);const wf=L.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});L.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Af,repeated:!0}]);const Af=L.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});L.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var te=(i=>(i.Ok="ok",i.ErrClientNotActivated="ErrClientNotActivated",i.ErrClientNotFound="ErrClientNotFound",i.ErrUnimplemented="ErrUnimplemented",i.ErrInvalidType="ErrInvalidType",i.ErrDummy="ErrDummy",i.ErrDocumentNotAttached="ErrDocumentNotAttached",i.ErrDocumentNotDetached="ErrDocumentNotDetached",i.ErrDocumentRemoved="ErrDocumentRemoved",i.ErrInvalidObjectKey="ErrInvalidObjectKey",i.ErrInvalidArgument="ErrInvalidArgument",i.ErrNotInitialized="ErrNotInitialized",i.ErrNotReady="ErrNotReady",i.ErrRefused="ErrRefused",i.ErrContextNotProvided="ErrContextNotProvided",i.ErrPermissionDenied="ErrPermissionDenied",i.ErrUnauthenticated="ErrUnauthenticated",i))(te||{});class ne extends Error{constructor(e,n){super(n);T(this,"name","YorkieError");T(this,"stack");this.code=e,this.message=n,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function sn(i){if(i instanceof Map){const t=Array.from(i);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(i))}const uu=i=>i?Object.entries(i).length===0:!0,Yi=i=>{const t={};for(const[e,n]of Object.entries(i))t[e]=JSON.stringify(n);return t},zi=i=>{const t={};for(const[e,n]of Object.entries(i))t[e]=JSON.parse(n);return t};var pi=(i=>(i.Put="put",i.Clear="clear",i))(pi||{});class qs{constructor(t,e){T(this,"context");T(this,"presence");this.context=t,this.presence=e}set(t,e){for(const n of Object.keys(t))this.presence[n]=t[n];this.context.setPresenceChange({type:"put",presence:sn(this.presence)}),this.context.setReversePresence(t,e)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Sa="000000000000000000000000";class Wt{constructor(t,e,n){T(this,"lamport");T(this,"delimiter");T(this,"actorID");this.lamport=t,this.delimiter=e,this.actorID=n}static of(t,e,n){return new Wt(t,e,n)}static fromStruct(t){return Wt.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new Wt(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const e=this.actorID.localeCompare(t.actorID);return e!==0?e:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const cu=0,fo=9223372036854775807n,un=new Wt(0n,cu,Sa);function Fn(i){return i.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` +var Ku=Object.defineProperty;var Hu=(i,t,e)=>t in i?Ku(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var T=(i,t,e)=>Hu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function e(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(r){if(r.ep)return;r.ep=!0;const o=e(r);fetch(r.href,o)}})();var Ge;(function(i){i[i.Canceled=1]="Canceled",i[i.Unknown=2]="Unknown",i[i.InvalidArgument=3]="InvalidArgument",i[i.DeadlineExceeded=4]="DeadlineExceeded",i[i.NotFound=5]="NotFound",i[i.AlreadyExists=6]="AlreadyExists",i[i.PermissionDenied=7]="PermissionDenied",i[i.ResourceExhausted=8]="ResourceExhausted",i[i.FailedPrecondition=9]="FailedPrecondition",i[i.Aborted=10]="Aborted",i[i.OutOfRange=11]="OutOfRange",i[i.Unimplemented=12]="Unimplemented",i[i.Internal=13]="Internal",i[i.Unavailable=14]="Unavailable",i[i.DataLoss=15]="DataLoss",i[i.Unauthenticated=16]="Unauthenticated"})(Ge||(Ge={}));function Ua(i){const t=Ge[i];return typeof t!="string"?i.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>"_"+e.toLowerCase())}class Ze extends Error{constructor(t,e=Ge.Unknown,n,r,o){super(Wu(t,e)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=t,this.code=e,this.metadata=new Headers(n??{}),this.details=r??[],this.cause=o}static from(t,e=Ge.Unknown){return t instanceof Ze?t:t instanceof Error?t.name=="AbortError"?new Ze(t.message,Ge.Canceled):new Ze(t.message,e,void 0,void 0,t):new Ze(String(t),e,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===Ze.prototype?!0:t.name==="ConnectError"&&"code"in t&&typeof t.code=="number"&&"metadata"in t&&"details"in t&&Array.isArray(t.details)&&"rawMessage"in t&&typeof t.rawMessage=="string"&&"cause"in t:!1}findDetails(t){const e="typeName"in t?{findMessage:r=>r===t.typeName?t:void 0}:t,n=[];for(const r of this.details){if("getType"in r){e.findMessage(r.getType().typeName)&&n.push(r);continue}const o=e.findMessage(r.type);if(o)try{n.push(o.fromBinary(r.value))}catch{}}return n}}function Wu(i,t){return i.length?`[${Ua(t)}] ${i}`:`[${Ua(t)}]`}function it(i,t){if(!i)throw new Error(t)}const Gu=34028234663852886e22,Yu=-34028234663852886e22,Zu=4294967295,Xu=2147483647,Qu=-2147483648;function Ho(i){if(typeof i!="number")throw new Error("invalid int 32: "+typeof i);if(!Number.isInteger(i)||i>Xu||iZu||i<0)throw new Error("invalid uint 32: "+i)}function Rl(i){if(typeof i!="number")throw new Error("invalid float 32: "+typeof i);if(Number.isFinite(i)&&(i>Gu||i({no:r.no,name:r.name,localName:i[r.no]})))}function Ml(i,t,e){const n=Object.create(null),r=Object.create(null),o=[];for(const s of t){const u=ql(s);o.push(u),n[s.name]=u,r[s.no]=u}return{typeName:i,values:o,findName(s){return n[s]},findNumber(s){return r[s]}}}function tc(i,t,e){const n={};for(const r of t){const o=ql(r);n[o.localName]=o.no,n[o.no]=o.localName}return Bl(n,i,t),n}function ql(i){return"localName"in i?i:Object.assign(Object.assign({},i),{localName:i.name})}class me{equals(t){return this.getType().runtime.util.equals(this.getType(),this,t)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(t,e){const n=this.getType(),r=n.runtime.bin,o=r.makeReadOptions(e);return r.readMessage(this,o.readerFactory(t),t.byteLength,o),this}fromJson(t,e){const n=this.getType(),r=n.runtime.json,o=r.makeReadOptions(e);return r.readMessage(n,t,o,this),this}fromJsonString(t,e){let n;try{n=JSON.parse(t)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(n,e)}toBinary(t){const e=this.getType(),n=e.runtime.bin,r=n.makeWriteOptions(t),o=r.writerFactory();return n.writeMessage(this,o,r),o.finish()}toJson(t){const e=this.getType(),n=e.runtime.json,r=n.makeWriteOptions(t);return n.writeMessage(this,r)}toJsonString(t){var e;const n=this.toJson(t);return JSON.stringify(n,null,(e=t==null?void 0:t.prettySpaces)!==null&&e!==void 0?e:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function nc(i,t,e,n){var r;const o=(r=n==null?void 0:n.localName)!==null&&r!==void 0?r:t.substring(t.lastIndexOf(".")+1),s={[o]:function(u){i.util.initFields(this),i.util.initPartial(u,this)}}[o];return Object.setPrototypeOf(s.prototype,new me),Object.assign(s,{runtime:i,typeName:t,fields:i.util.newFieldList(e),fromBinary(u,c){return new s().fromBinary(u,c)},fromJson(u,c){return new s().fromJson(u,c)},fromJsonString(u,c){return new s().fromJsonString(u,c)},equals(u,c){return i.util.equals(s,u,c)}}),s}function rc(){let i=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<>4,!(e&128))return this.assertBounds(),[i,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<>>o,u=!(!(s>>>7)&&t==0),c=(u?s|128:s)&255;if(e.push(c),!u)return}const n=i>>>28&15|(t&7)<<4,r=!!(t>>3);if(e.push((r?n|128:n)&255),!!r){for(let o=3;o<31;o=o+7){const s=t>>>o,u=!!(s>>>7),c=(u?s|128:s)&255;if(e.push(c),!u)return}e.push(t>>>31&1)}}const Wo=4294967296;function Ja(i){const t=i[0]==="-";t&&(i=i.slice(1));const e=1e6;let n=0,r=0;function o(s,u){const c=Number(i.slice(s,u));r*=e,n=n*e+c,n>=Wo&&(r=r+(n/Wo|0),n=n%Wo)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?jl(n,r):wa(n,r)}function ic(i,t){let e=wa(i,t);const n=e.hi&2147483648;n&&(e=jl(e.lo,e.hi));const r=Fl(e.lo,e.hi);return n?"-"+r:r}function Fl(i,t){if({lo:i,hi:t}=oc(i,t),t<=2097151)return String(Wo*t+i);const e=i&16777215,n=(i>>>24|t<<8)&16777215,r=t>>16&65535;let o=e+n*6777216+r*6710656,s=n+r*8147497,u=r*2;const c=1e7;return o>=c&&(s+=Math.floor(o/c),o%=c),s>=c&&(u+=Math.floor(s/c),s%=c),u.toString()+$a(s)+$a(o)}function oc(i,t){return{lo:i>>>0,hi:t>>>0}}function wa(i,t){return{lo:i|0,hi:t|0}}function jl(i,t){return t=~t,i?i=~i+1:t+=1,wa(i,t)}const $a=i=>{const t=String(i);return"0000000".slice(t.length)+t};function za(i,t){if(i>=0){for(;i>127;)t.push(i&127|128),i=i>>>7;t.push(i)}else{for(let e=0;e<9;e++)t.push(i&127|128),i=i>>7;t.push(1)}}function sc(){let i=this.buf[this.pos++],t=i&127;if(!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<7,!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<14,!(i&128))return this.assertBounds(),t;if(i=this.buf[this.pos++],t|=(i&127)<<21,!(i&128))return this.assertBounds(),t;i=this.buf[this.pos++],t|=(i&15)<<28;for(let e=5;i&128&&e<10;e++)i=this.buf[this.pos++];if(i&128)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Va={};function ac(){const i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(typeof process!="object"||typeof Va!="object"||Va.BUF_BIGINT_DISABLE!=="1")){const r=BigInt("-9223372036854775808"),o=BigInt("9223372036854775807"),s=BigInt("0"),u=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(c){const m=typeof c=="bigint"?c:BigInt(c);if(m>o||mu||mit(/^-?[0-9]+$/.test(r),`int64 invalid: ${r}`),n=r=>it(/^[0-9]+$/.test(r),`uint64 invalid: ${r}`);return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),e(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),n(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),e(r),Ja(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),n(r),Ja(r)},dec(r,o){return ic(r,o)},uDec(r,o){return Fl(r,o)}}}const Xe=ac();var le;(function(i){i[i.DOUBLE=1]="DOUBLE",i[i.FLOAT=2]="FLOAT",i[i.INT64=3]="INT64",i[i.UINT64=4]="UINT64",i[i.INT32=5]="INT32",i[i.FIXED64=6]="FIXED64",i[i.FIXED32=7]="FIXED32",i[i.BOOL=8]="BOOL",i[i.STRING=9]="STRING",i[i.BYTES=12]="BYTES",i[i.UINT32=13]="UINT32",i[i.SFIXED32=15]="SFIXED32",i[i.SFIXED64=16]="SFIXED64",i[i.SINT32=17]="SINT32",i[i.SINT64=18]="SINT64"})(le||(le={}));var gi;(function(i){i[i.BIGINT=0]="BIGINT",i[i.STRING=1]="STRING"})(gi||(gi={}));function ii(i,t,e){if(t===e)return!0;if(i==le.BYTES){if(!(t instanceof Uint8Array)||!(e instanceof Uint8Array)||t.length!==e.length)return!1;for(let n=0;n>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Ks(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Ho(t),za(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.textEncoder.encode(t);return this.uint32(e.byteLength),this.raw(e)}float(t){Rl(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){Ks(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Ho(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Ho(t),t=(t<<1^t>>31)>>>0,za(t,this.buf),this}sfixed64(t){let e=new Uint8Array(8),n=new DataView(e.buffer),r=Xe.enc(t);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),n=new DataView(e.buffer),r=Xe.uEnc(t);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(e)}int64(t){let e=Xe.enc(t);return Ds(e.lo,e.hi,this.buf),this}sint64(t){let e=Xe.enc(t),n=e.hi>>31,r=e.lo<<1^n,o=(e.hi<<1|e.lo>>>31)^n;return Ds(r,o,this.buf),this}uint64(t){let e=Xe.uEnc(t);return Ds(e.lo,e.hi,this.buf),this}}class uc{constructor(t,e){this.varint64=rc,this.uint32=sc,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.textDecoder=e??new TextDecoder}tag(){let t=this.uint32(),e=t>>>3,n=t&7;if(e<=0||n<0||n>5)throw new Error("illegal tag: field no "+e+" wire type "+n);return[e,n]}skip(t,e){let n=this.pos;switch(t){case ut.Varint:for(;this.buf[this.pos++]&128;);break;case ut.Bit64:this.pos+=4;case ut.Bit32:this.pos+=4;break;case ut.LengthDelimited:let r=this.uint32();this.pos+=r;break;case ut.StartGroup:for(;;){const[o,s]=this.tag();if(s===ut.EndGroup){if(e!==void 0&&o!==e)throw new Error("invalid end group tag");break}this.skip(s,o)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return Xe.dec(...this.varint64())}uint64(){return Xe.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),n=-(t&1);return t=(t>>>1|(e&1)<<31)^n,e=e>>>1^n,Xe.dec(t,e)}bool(){let[t,e]=this.varint64();return t!==0||e!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Xe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Xe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.textDecoder.decode(this.bytes())}}function cc(i,t,e,n){let r;return{typeName:t,extendee:e,get field(){if(!r){const o=typeof n=="function"?n():n;o.name=t.split(".").pop(),o.jsonName=`[${t}]`,r=i.util.newFieldList([o]).list()[0]}return r},runtime:i}}function Jl(i){const t=i.field.localName,e=Object.create(null);return e[t]=fc(i),[e,()=>e[t]]}function fc(i){const t=i.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Hi(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}function hc(i,t){if(!t.repeated&&(t.kind=="enum"||t.kind=="scalar")){for(let e=i.length-1;e>=0;--e)if(i[e].no==t.no)return[i[e]];return[]}return i.filter(e=>e.no===t.no)}let Vr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),xs=[];for(let i=0;i>4,s=o,r=2;break;case 2:e[n++]=(s&15)<<4|(o&60)>>2,s=o,r=3;break;case 3:e[n++]=(s&3)<<6|o,r=0;break}}if(r==1)throw Error("invalid base64 string.");return e.subarray(0,n)},enc(i){let t="",e=0,n,r=0;for(let o=0;o>2],r=(n&3)<<4,e=1;break;case 1:t+=Vr[r|n>>4],r=(n&15)<<2,e=2;break;case 2:t+=Vr[r|n>>6],t+=Vr[n&63],e=0;break}return e&&(t+=Vr[r],t+="=",e==1&&(t+="=")),t}};function dc(i,t,e){zl(t,i);const n=t.runtime.bin.makeReadOptions(e),r=hc(i.getType().runtime.bin.listUnknownFields(i),t.field),[o,s]=Jl(t);for(const u of r)t.runtime.bin.readField(o,n.readerFactory(u.data),t.field,u.wireType,n);return s()}function gc(i,t,e,n){zl(t,i);const r=t.runtime.bin.makeReadOptions(n),o=t.runtime.bin.makeWriteOptions(n);if($l(i,t)){const m=i.getType().runtime.bin.listUnknownFields(i).filter(y=>y.no!=t.field.no);i.getType().runtime.bin.discardUnknownFields(i);for(const y of m)i.getType().runtime.bin.onUnknownField(i,y.no,y.wireType,y.data)}const s=o.writerFactory();let u=t.field;!u.opt&&!u.repeated&&(u.kind=="enum"||u.kind=="scalar")&&(u=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(u,e,s,o);const c=r.readerFactory(s.finish());for(;c.posn.no==t.field.no)}function zl(i,t){it(i.extendee.typeName==t.getType().typeName,`extension ${i.typeName} can only be applied to message ${i.extendee.typeName}`)}function Vl(i,t){const e=i.localName;if(i.repeated)return t[e].length>0;if(i.oneof)return t[i.oneof.localName].case===e;switch(i.kind){case"enum":case"scalar":return i.opt||i.req?t[e]!==void 0:i.kind=="enum"?t[e]!==i.T.values[0].no:!Ul(i.T,t[e]);case"message":return t[e]!==void 0;case"map":return Object.keys(t[e]).length>0}}function Ka(i,t){const e=i.localName,n=!i.opt&&!i.req;if(i.repeated)t[e]=[];else if(i.oneof)t[i.oneof.localName]={case:void 0};else switch(i.kind){case"map":t[e]={};break;case"enum":t[e]=n?i.T.values[0].no:void 0;break;case"scalar":t[e]=n?Hi(i.T,i.L):void 0;break;case"message":t[e]=void 0;break}}function ki(i,t){if(i===null||typeof i!="object"||!Object.getOwnPropertyNames(me.prototype).every(n=>n in i&&typeof i[n]=="function"))return!1;const e=i.getType();return e===null||typeof e!="function"||!("typeName"in e)||typeof e.typeName!="string"?!1:t===void 0?!0:e.typeName==t.typeName}function Kl(i,t){return ki(t)||!i.fieldWrapper?t:i.fieldWrapper.wrapField(t)}le.DOUBLE,le.FLOAT,le.INT64,le.UINT64,le.INT32,le.UINT32,le.BOOL,le.STRING,le.BYTES;const Ha={ignoreUnknownFields:!1},Wa={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function pc(i){return i?Object.assign(Object.assign({},Ha),i):Ha}function mc(i){return i?Object.assign(Object.assign({},Wa),i):Wa}const ts=Symbol(),Go=Symbol();function yc(){return{makeReadOptions:pc,makeWriteOptions:mc,readMessage(i,t,e,n){if(t==null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message ${i.typeName} from JSON: ${Nn(t)}`);n=n??new i;const r=new Map,o=e.typeRegistry;for(const[s,u]of Object.entries(t)){const c=i.fields.findJsonName(s);if(c){if(c.oneof){if(u===null&&c.kind=="scalar")continue;const m=r.get(c.oneof);if(m!==void 0)throw new Error(`cannot decode message ${i.typeName} from JSON: multiple keys for oneof "${c.oneof.name}" present: "${m}", "${s}"`);r.set(c.oneof,s)}Ga(n,u,c,e,i)}else{let m=!1;if(o!=null&&o.findExtension&&s.startsWith("[")&&s.endsWith("]")){const y=o.findExtension(s.substring(1,s.length-1));if(y&&y.extendee.typeName==i.typeName){m=!0;const[f,l]=Jl(y);Ga(f,u,y.field,e,y),gc(n,y,l(),e)}}if(!m&&!e.ignoreUnknownFields)throw new Error(`cannot decode message ${i.typeName} from JSON: key "${s}" is unknown`)}}return n},writeMessage(i,t){const e=i.getType(),n={};let r;try{for(r of e.fields.byNumber()){if(!Vl(r,i)){if(r.req)throw"required field not set";if(!t.emitDefaultValues||!bc(r))continue}const s=r.oneof?i[r.oneof.localName].value:i[r.localName],u=Ya(r,s,t);u!==void 0&&(n[t.useProtoFieldName?r.name:r.jsonName]=u)}const o=t.typeRegistry;if(o!=null&&o.findExtensionFor)for(const s of e.runtime.bin.listUnknownFields(i)){const u=o.findExtensionFor(e.typeName,s.no);if(u&&$l(i,u)){const c=dc(i,u,t),m=Ya(u.field,c,t);m!==void 0&&(n[u.field.jsonName]=m)}}}catch(o){const s=r?`cannot encode field ${e.typeName}.${r.name} to JSON`:`cannot encode message ${e.typeName} to JSON`,u=o instanceof Error?o.message:String(o);throw new Error(s+(u.length>0?`: ${u}`:""))}return n},readScalar(i,t,e){return uo(i,t,e??gi.BIGINT,!0)},writeScalar(i,t,e){if(t!==void 0&&(e||Ul(i,t)))return Yo(i,t)},debug:Nn}}function Nn(i){if(i===null)return"null";switch(typeof i){case"object":return Array.isArray(i)?"array":"object";case"string":return i.length>100?"string":`"${i.split('"').join('\\"')}"`;default:return String(i)}}function Ga(i,t,e,n,r){let o=e.localName;if(e.repeated){if(it(e.kind!="map"),t===null)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`);const s=i[o];for(const u of t){if(u===null)throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(u)}`);switch(e.kind){case"message":s.push(e.T.fromJson(u,n));break;case"enum":const c=Bs(e.T,u,n.ignoreUnknownFields,!0);c!==Go&&s.push(c);break;case"scalar":try{s.push(uo(e.T,u,e.L,!0))}catch(m){let y=`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(u)}`;throw m instanceof Error&&m.message.length>0&&(y+=`: ${m.message}`),new Error(y)}break}}}else if(e.kind=="map"){if(t===null)return;if(typeof t!="object"||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`);const s=i[o];for(const[u,c]of Object.entries(t)){if(c===null)throw new Error(`cannot decode field ${r.typeName}.${e.name} from JSON: map value null`);let m;try{m=vc(e.K,u)}catch(y){let f=`cannot decode map key for field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw y instanceof Error&&y.message.length>0&&(f+=`: ${y.message}`),new Error(f)}switch(e.V.kind){case"message":s[m]=e.V.T.fromJson(c,n);break;case"enum":const y=Bs(e.V.T,c,n.ignoreUnknownFields,!0);y!==Go&&(s[m]=y);break;case"scalar":try{s[m]=uo(e.V.T,c,gi.BIGINT,!0)}catch(f){let l=`cannot decode map value for field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw f instanceof Error&&f.message.length>0&&(l+=`: ${f.message}`),new Error(l)}break}}}else switch(e.oneof&&(i=i[e.oneof.localName]={case:o},o="value"),e.kind){case"message":const s=e.T;if(t===null&&s.typeName!="google.protobuf.Value")return;let u=i[o];ki(u)?u.fromJson(t,n):(i[o]=u=s.fromJson(t,n),s.fieldWrapper&&!e.oneof&&(i[o]=s.fieldWrapper.unwrapField(u)));break;case"enum":const c=Bs(e.T,t,n.ignoreUnknownFields,!1);switch(c){case ts:Ka(e,i);break;case Go:break;default:i[o]=c;break}break;case"scalar":try{const m=uo(e.T,t,e.L,!1);switch(m){case ts:Ka(e,i);break;default:i[o]=m;break}}catch(m){let y=`cannot decode field ${r.typeName}.${e.name} from JSON: ${Nn(t)}`;throw m instanceof Error&&m.message.length>0&&(y+=`: ${m.message}`),new Error(y)}break}}function vc(i,t){if(i===le.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1;break}return uo(i,t,gi.BIGINT,!0).toString()}function uo(i,t,e,n){if(t===null)return n?Hi(i,e):ts;switch(i){case le.DOUBLE:case le.FLOAT:if(t==="NaN")return Number.NaN;if(t==="Infinity")return Number.POSITIVE_INFINITY;if(t==="-Infinity")return Number.NEGATIVE_INFINITY;if(t===""||typeof t=="string"&&t.trim().length!==t.length||typeof t!="string"&&typeof t!="number")break;const r=Number(t);if(Number.isNaN(r)||!Number.isFinite(r))break;return i==le.FLOAT&&Rl(r),r;case le.INT32:case le.FIXED32:case le.SFIXED32:case le.SINT32:case le.UINT32:let o;if(typeof t=="number"?o=t:typeof t=="string"&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),o===void 0)break;return i==le.UINT32||i==le.FIXED32?Ks(o):Ho(o),o;case le.INT64:case le.SFIXED64:case le.SINT64:if(typeof t!="number"&&typeof t!="string")break;const s=Xe.parse(t);return e?s.toString():s;case le.FIXED64:case le.UINT64:if(typeof t!="number"&&typeof t!="string")break;const u=Xe.uParse(t);return e?u.toString():u;case le.BOOL:if(typeof t!="boolean")break;return t;case le.STRING:if(typeof t!="string")break;try{encodeURIComponent(t)}catch{throw new Error("invalid UTF8")}return t;case le.BYTES:if(t==="")return new Uint8Array(0);if(typeof t!="string")break;return Aa.dec(t)}throw new Error}function Bs(i,t,e,n){if(t===null)return i.typeName=="google.protobuf.NullValue"?0:n?i.values[0].no:ts;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const r=i.findName(t);if(r!==void 0)return r.no;if(e)return Go;break}throw new Error(`cannot decode enum ${i.typeName} from JSON: ${Nn(t)}`)}function bc(i){return i.repeated||i.kind=="map"?!0:!(i.oneof||i.kind=="message"||i.opt||i.req)}function Ya(i,t,e){if(i.kind=="map"){it(typeof t=="object"&&t!=null);const n={},r=Object.entries(t);switch(i.V.kind){case"scalar":for(const[s,u]of r)n[s.toString()]=Yo(i.V.T,u);break;case"message":for(const[s,u]of r)n[s.toString()]=u.toJson(e);break;case"enum":const o=i.V.T;for(const[s,u]of r)n[s.toString()]=Ms(o,u,e.enumAsInteger);break}return e.emitDefaultValues||r.length>0?n:void 0}if(i.repeated){it(Array.isArray(t));const n=[];switch(i.kind){case"scalar":for(let r=0;r0?n:void 0}switch(i.kind){case"scalar":return Yo(i.T,t);case"enum":return Ms(i.T,t,e.enumAsInteger);case"message":return Kl(i.T,t).toJson(e)}}function Ms(i,t,e){var n;if(it(typeof t=="number"),i.typeName=="google.protobuf.NullValue")return null;if(e)return t;const r=i.findNumber(t);return(n=r==null?void 0:r.name)!==null&&n!==void 0?n:t}function Yo(i,t){switch(i){case le.INT32:case le.SFIXED32:case le.SINT32:case le.FIXED32:case le.UINT32:return it(typeof t=="number"),t;case le.FLOAT:case le.DOUBLE:return it(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case le.STRING:return it(typeof t=="string"),t;case le.BOOL:return it(typeof t=="boolean"),t;case le.UINT64:case le.FIXED64:case le.INT64:case le.SFIXED64:case le.SINT64:return it(typeof t=="bigint"||typeof t=="string"||typeof t=="number"),t.toString();case le.BYTES:return it(t instanceof Uint8Array),Aa.enc(t)}}const Bi=Symbol("@bufbuild/protobuf/unknown-fields"),Za={readUnknownFields:!0,readerFactory:i=>new uc(i)},Xa={writeUnknownFields:!0,writerFactory:()=>new lc};function wc(i){return i?Object.assign(Object.assign({},Za),i):Za}function Ac(i){return i?Object.assign(Object.assign({},Xa),i):Xa}function Tc(){return{makeReadOptions:wc,makeWriteOptions:Ac,listUnknownFields(i){var t;return(t=i[Bi])!==null&&t!==void 0?t:[]},discardUnknownFields(i){delete i[Bi]},writeUnknownFields(i,t){const n=i[Bi];if(n)for(const r of n)t.tag(r.no,r.wireType).raw(r.data)},onUnknownField(i,t,e,n){const r=i;Array.isArray(r[Bi])||(r[Bi]=[]),r[Bi].push({no:t,wireType:e,data:n})},readMessage(i,t,e,n,r){const o=i.getType(),s=r?t.len:t.pos+e;let u,c;for(;t.pos0&&(c=Ec),o){let l=i[s];if(n==ut.LengthDelimited&&u!=le.STRING&&u!=le.BYTES){let p=t.uint32()+t.pos;for(;t.poski(l,f)?l:new f(l));else{const l=s[r];f.fieldWrapper?f.typeName==="google.protobuf.BytesValue"?o[r]=oo(l):o[r]=l:o[r]=ki(l,f)?l:new f(l)}break}}},equals(i,t,e){return t===e?!0:!t||!e?!1:i.fields.byMember().every(n=>{const r=t[n.localName],o=e[n.localName];if(n.repeated){if(r.length!==o.length)return!1;switch(n.kind){case"message":return r.every((s,u)=>n.T.equals(s,o[u]));case"scalar":return r.every((s,u)=>ii(n.T,s,o[u]));case"enum":return r.every((s,u)=>ii(le.INT32,s,o[u]))}throw new Error(`repeated cannot contain ${n.kind}`)}switch(n.kind){case"message":return n.T.equals(r,o);case"enum":return ii(le.INT32,r,o);case"scalar":return ii(n.T,r,o);case"oneof":if(r.case!==o.case)return!1;const s=n.findField(r.case);if(s===void 0)return!0;switch(s.kind){case"message":return s.T.equals(r.value,o.value);case"enum":return ii(le.INT32,r.value,o.value);case"scalar":return ii(s.T,r.value,o.value)}throw new Error(`oneof cannot contain ${s.kind}`);case"map":const u=Object.keys(r).concat(Object.keys(o));switch(n.V.kind){case"message":const c=n.V.T;return u.every(y=>c.equals(r[y],o[y]));case"enum":return u.every(y=>ii(le.INT32,r[y],o[y]));case"scalar":const m=n.V.T;return u.every(y=>ii(m,r[y],o[y]))}break}})},clone(i){const t=i.getType(),e=new t,n=e;for(const r of t.fields.byMember()){const o=i[r.localName];let s;if(r.repeated)s=o.map(jo);else if(r.kind=="map"){s=n[r.localName];for(const[u,c]of Object.entries(o))s[u]=jo(c)}else r.kind=="oneof"?s=r.findField(o.case)?{case:o.case,value:jo(o.value)}:{case:void 0}:s=jo(o);n[r.localName]=s}for(const r of t.runtime.bin.listUnknownFields(i))t.runtime.bin.onUnknownField(n,r.no,r.wireType,r.data);return e}}}function jo(i){if(i===void 0)return i;if(ki(i))return i.clone();if(i instanceof Uint8Array){const t=new Uint8Array(i.byteLength);return t.set(i),t}return i}function oo(i){return i instanceof Uint8Array?i:new Uint8Array(i)}function Ic(i,t,e){return{syntax:i,json:yc(),bin:Tc(),util:Object.assign(Object.assign({},Oc()),{newFieldList:t,initFields:e}),makeMessageType(n,r,o){return nc(this,n,r,o)},makeEnum:tc,makeEnumType:Ml,getEnumType:ec,makeExtension(n,r,o){return cc(this,n,r,o)}}}class Nc{constructor(t,e){this._fields=t,this._normalizer=e}findJsonName(t){if(!this.jsonNames){const e={};for(const n of this.list())e[n.jsonName]=e[n.name]=n;this.jsonNames=e}return this.jsonNames[t]}find(t){if(!this.numbers){const e={};for(const n of this.list())e[n.no]=n;this.numbers=e}return this.numbers[t]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((t,e)=>t.no-e.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const t=this.members;let e;for(const n of this.list())n.oneof?n.oneof!==e&&(e=n.oneof,t.push(e)):t.push(n)}return this.members}}function Wl(i,t){const e=Gl(i);return t?e:Dc(Rc(e))}function _c(i){return Wl(i,!1)}const Pc=Gl;function Gl(i){let t=!1;const e=[];for(let n=0;n`${i}$`,Rc=i=>Lc.has(i)?Yl(i):i,Dc=i=>Cc.has(i)?Yl(i):i;class Bc{constructor(t){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=t,this.localName=_c(t)}addField(t){it(t.oneof===this,`field ${t.name} not one of ${this.name}`),this.fields.push(t)}findField(t){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;enew Nc(i,t=>Mc(t)),i=>{for(const t of i.getType().fields.byMember()){if(t.opt)continue;const e=t.localName,n=i;if(t.repeated){n[e]=[];continue}switch(t.kind){case"oneof":n[e]={case:void 0};break;case"enum":n[e]=0;break;case"map":n[e]={};break;case"scalar":n[e]=Hi(t.T,t.L);break}}});var bt;(function(i){i[i.Unary=0]="Unary",i[i.ServerStreaming=1]="ServerStreaming",i[i.ClientStreaming=2]="ClientStreaming",i[i.BiDiStreaming=3]="BiDiStreaming"})(bt||(bt={}));var nl;(function(i){i[i.NoSideEffects=1]="NoSideEffects",i[i.Idempotent=2]="Idempotent"})(nl||(nl={}));class mt extends me{constructor(t){super(),this.seconds=Xe.zero,this.nanos=0,L.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${L.json.debug(t)}`);const n=t.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]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const r=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(r))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(rDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=Xe.parse(r/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(t){const e=Number(this.seconds)*1e3;if(eDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const r=(this.nanos+1e9).toString().substring(1);r.substring(3)==="000000"?n="."+r.substring(0,3)+"Z":r.substring(6)==="000"?n="."+r.substring(0,6)+"Z":n="."+r+"Z"}return new Date(e).toISOString().replace(".000Z",n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return mt.fromDate(new Date)}static fromDate(t){const e=t.getTime();return new mt({seconds:Xe.parse(Math.floor(e/1e3)),nanos:e%1e3*1e6})}static fromBinary(t,e){return new mt().fromBinary(t,e)}static fromJson(t,e){return new mt().fromJson(t,e)}static fromJsonString(t,e){return new mt().fromJsonString(t,e)}static equals(t,e){return L.util.equals(mt,t,e)}}mt.runtime=L;mt.typeName="google.protobuf.Timestamp";mt.fields=L.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Kr extends me{constructor(t){super(),this.seconds=Xe.zero,this.nanos=0,L.util.initPartial(t,this)}fromJson(t,e){if(typeof t!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);const n=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(n===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);const r=Number(n[1]);if(r>315576e6||r<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${L.json.debug(t)}`);if(this.seconds=Xe.parse(r),typeof n[2]=="string"){const o=n[2]+"0".repeat(9-n[2].length);this.nanos=parseInt(o),(r<0||Object.is(r,-0))&&(this.nanos=-this.nanos)}return this}toJson(t){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let e=this.seconds.toString();if(this.nanos!==0){let n=Math.abs(this.nanos).toString();n="0".repeat(9-n.length)+n,n.substring(3)==="000000"?n=n.substring(0,3):n.substring(6)==="000"&&(n=n.substring(0,6)),e+="."+n,this.nanos<0&&Number(this.seconds)==0&&(e="-"+e)}return e+"s"}static fromBinary(t,e){return new Kr().fromBinary(t,e)}static fromJson(t,e){return new Kr().fromJson(t,e)}static fromJsonString(t,e){return new Kr().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Kr,t,e)}}Kr.runtime=L;Kr.typeName="google.protobuf.Duration";Kr.fields=L.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class _n extends me{constructor(t){super(),this.typeUrl="",this.value=new Uint8Array(0),L.util.initPartial(t,this)}toJson(t){var e;if(this.typeUrl==="")return{};const n=this.typeUrlToName(this.typeUrl),r=(e=t==null?void 0:t.typeRegistry)===null||e===void 0?void 0:e.findMessage(n);if(!r)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let s=r.fromBinary(this.value).toJson(t);return(n.startsWith("google.protobuf.")||s===null||Array.isArray(s)||typeof s!="object")&&(s={value:s}),s["@type"]=this.typeUrl,s}fromJson(t,e){var n;if(t===null||Array.isArray(t)||typeof t!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${t===null?"null":Array.isArray(t)?"array":typeof t}`);if(Object.keys(t).length==0)return this;const r=t["@type"];if(typeof r!="string"||r=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const o=this.typeUrlToName(r),s=(n=e==null?void 0:e.typeRegistry)===null||n===void 0?void 0:n.findMessage(o);if(!s)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${r} is not in the type registry`);let u;if(o.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(t,"value"))u=s.fromJson(t.value,e);else{const c=Object.assign({},t);delete c["@type"],u=s.fromJson(c,e)}return this.packFrom(u),this}packFrom(t){this.value=t.toBinary(),this.typeUrl=this.typeNameToUrl(t.getType().typeName)}unpackTo(t){return this.is(t.getType())?(t.fromBinary(this.value),!0):!1}unpack(t){if(this.typeUrl==="")return;const e=t.findMessage(this.typeUrlToName(this.typeUrl));if(e)return e.fromBinary(this.value)}is(t){if(this.typeUrl==="")return!1;const e=this.typeUrlToName(this.typeUrl);let n="";return typeof t=="string"?n=t:n=t.typeName,e===n}typeNameToUrl(t){return`type.googleapis.com/${t}`}typeUrlToName(t){if(!t.length)throw new Error(`invalid type url: ${t}`);const e=t.lastIndexOf("/"),n=e>=0?t.substring(e+1):t;if(!n.length)throw new Error(`invalid type url: ${t}`);return n}static pack(t){const e=new _n;return e.packFrom(t),e}static fromBinary(t,e){return new _n().fromBinary(t,e)}static fromJson(t,e){return new _n().fromJson(t,e)}static fromJsonString(t,e){return new _n().fromJsonString(t,e)}static equals(t,e){return L.util.equals(_n,t,e)}}_n.runtime=L;_n.typeName="google.protobuf.Any";_n.fields=L.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Pn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.DOUBLE,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.DOUBLE,t)}catch(n){let r='cannot decode message google.protobuf.DoubleValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Pn().fromBinary(t,e)}static fromJson(t,e){return new Pn().fromJson(t,e)}static fromJsonString(t,e){return new Pn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Pn,t,e)}}Pn.runtime=L;Pn.typeName="google.protobuf.DoubleValue";Pn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Pn.fieldWrapper={wrapField(i){return new Pn({value:i})},unwrapField(i){return i.value}};class Cn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.FLOAT,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.FLOAT,t)}catch(n){let r='cannot decode message google.protobuf.FloatValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Cn().fromBinary(t,e)}static fromJson(t,e){return new Cn().fromJson(t,e)}static fromJsonString(t,e){return new Cn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Cn,t,e)}}Cn.runtime=L;Cn.typeName="google.protobuf.FloatValue";Cn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Cn.fieldWrapper={wrapField(i){return new Cn({value:i})},unwrapField(i){return i.value}};class Ln extends me{constructor(t){super(),this.value=Xe.zero,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.INT64,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.INT64,t)}catch(n){let r='cannot decode message google.protobuf.Int64Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Ln().fromBinary(t,e)}static fromJson(t,e){return new Ln().fromJson(t,e)}static fromJsonString(t,e){return new Ln().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Ln,t,e)}}Ln.runtime=L;Ln.typeName="google.protobuf.Int64Value";Ln.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Ln.fieldWrapper={wrapField(i){return new Ln({value:i})},unwrapField(i){return i.value}};class Rn extends me{constructor(t){super(),this.value=Xe.zero,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.UINT64,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.UINT64,t)}catch(n){let r='cannot decode message google.protobuf.UInt64Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Rn().fromBinary(t,e)}static fromJson(t,e){return new Rn().fromJson(t,e)}static fromJsonString(t,e){return new Rn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Rn,t,e)}}Rn.runtime=L;Rn.typeName="google.protobuf.UInt64Value";Rn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Rn.fieldWrapper={wrapField(i){return new Rn({value:i})},unwrapField(i){return i.value}};class Dn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.INT32,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.INT32,t)}catch(n){let r='cannot decode message google.protobuf.Int32Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Dn().fromBinary(t,e)}static fromJson(t,e){return new Dn().fromJson(t,e)}static fromJsonString(t,e){return new Dn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Dn,t,e)}}Dn.runtime=L;Dn.typeName="google.protobuf.Int32Value";Dn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Dn.fieldWrapper={wrapField(i){return new Dn({value:i})},unwrapField(i){return i.value}};class Bn extends me{constructor(t){super(),this.value=0,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.UINT32,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.UINT32,t)}catch(n){let r='cannot decode message google.protobuf.UInt32Value from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Bn().fromBinary(t,e)}static fromJson(t,e){return new Bn().fromJson(t,e)}static fromJsonString(t,e){return new Bn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Bn,t,e)}}Bn.runtime=L;Bn.typeName="google.protobuf.UInt32Value";Bn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Bn.fieldWrapper={wrapField(i){return new Bn({value:i})},unwrapField(i){return i.value}};class Mn extends me{constructor(t){super(),this.value=!1,L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.BOOL,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.BOOL,t)}catch(n){let r='cannot decode message google.protobuf.BoolValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Mn().fromBinary(t,e)}static fromJson(t,e){return new Mn().fromJson(t,e)}static fromJsonString(t,e){return new Mn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Mn,t,e)}}Mn.runtime=L;Mn.typeName="google.protobuf.BoolValue";Mn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Mn.fieldWrapper={wrapField(i){return new Mn({value:i})},unwrapField(i){return i.value}};class Pt extends me{constructor(t){super(),this.value="",L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.STRING,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.STRING,t)}catch(n){let r='cannot decode message google.protobuf.StringValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new Pt().fromBinary(t,e)}static fromJson(t,e){return new Pt().fromJson(t,e)}static fromJsonString(t,e){return new Pt().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Pt,t,e)}}Pt.runtime=L;Pt.typeName="google.protobuf.StringValue";Pt.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Pt.fieldWrapper={wrapField(i){return new Pt({value:i})},unwrapField(i){return i.value}};class qn extends me{constructor(t){super(),this.value=new Uint8Array(0),L.util.initPartial(t,this)}toJson(t){return L.json.writeScalar(le.BYTES,this.value,!0)}fromJson(t,e){try{this.value=L.json.readScalar(le.BYTES,t)}catch(n){let r='cannot decode message google.protobuf.BytesValue from JSON"';throw n instanceof Error&&n.message.length>0&&(r+=`: ${n.message}`),new Error(r)}return this}static fromBinary(t,e){return new qn().fromBinary(t,e)}static fromJson(t,e){return new qn().fromJson(t,e)}static fromJsonString(t,e){return new qn().fromJsonString(t,e)}static equals(t,e){return L.util.equals(qn,t,e)}}qn.runtime=L;qn.typeName="google.protobuf.BytesValue";qn.fields=L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);qn.fieldWrapper={wrapField(i){return new qn({value:i})},unwrapField(i){return i.value}};function qc(i,t,e){try{const n=Aa.dec(i);return t?t.fromBinary(n,e):n}catch(n){throw Ze.from(n,Ge.DataLoss)}}function Fc(i,t){const e={};for(const[n,r]of Object.entries(i.methods)){const o=t(Object.assign(Object.assign({},r),{localName:n,service:i}));o!=null&&(e[n]=o)}return e}function rl(i){let t,e=new Uint8Array(0);function n(r){const o=new Uint8Array(e.length+r.length);o.set(e),o.set(r,e.length),e=o}return new ReadableStream({start(){t=i.getReader()},async pull(r){let o;for(;;){if(o===void 0&&e.byteLength>=5){let c=0;for(let m=1;m<5;m++)c=(c<<8)+e[m];o={flags:e[0],length:c}}if(o!==void 0&&e.byteLength>=o.length+5)break;const u=await t.read();if(u.done)break;n(u.value)}if(o===void 0){if(e.byteLength==0){r.close();return}r.error(new Ze("premature end of stream",Ge.DataLoss));return}const s=e.subarray(5,5+o.length);e=e.subarray(5+o.length),r.enqueue({flags:o.flags,data:s})}})}function il(i,t){const e=new Uint8Array(t.length+5);e.set(t,5);const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setUint8(0,i),n.setUint32(1,t.length),e}var jc=function(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof __values=="function"?__values(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(u,c){s=i[o](s),r(u,c,s.done,s.value)})}}function r(o,s,u,c){Promise.resolve(c).then(function(m){o({value:m,done:u})},s)}},po=function(i){return this instanceof po?(this.v=i,this):new po(i)},Uc=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof po?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}},Jc=function(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:po(i[r](s)),done:!1}:o?o(s):s}:o}};function $c(i){return Uc(this,arguments,function*(){yield po(yield*Jc(jc(i)))})}var Zl=function(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof __values=="function"?__values(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(u,c){s=i[o](s),r(u,c,s.done,s.value)})}}function r(o,s,u,c){Promise.resolve(c).then(function(m){o({value:m,done:u})},s)}},Wi=function(i){return this instanceof Wi?(this.v=i,this):new Wi(i)},zc=function(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:Wi(i[r](s)),done:!1}:o?o(s):s}:o}},Vc=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof Wi?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}};function Kc(i,t){return Fc(i,e=>{switch(e.kind){case bt.Unary:return Hc(t,i,e);case bt.ServerStreaming:return Wc(t,i,e);case bt.ClientStreaming:return Gc(t,i,e);case bt.BiDiStreaming:return Yc(t,i,e);default:return null}})}function Hc(i,t,e){return async function(n,r){var o,s;const u=await i.unary(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues);return(o=r==null?void 0:r.onHeader)===null||o===void 0||o.call(r,u.header),(s=r==null?void 0:r.onTrailer)===null||s===void 0||s.call(r,u.trailer),u.message}}function Wc(i,t,e){return function(n,r){return Xl(i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,$c([n]),r==null?void 0:r.contextValues),r)}}function Gc(i,t,e){return async function(n,r){var o,s,u,c,m,y;const f=await i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues);(m=r==null?void 0:r.onHeader)===null||m===void 0||m.call(r,f.header);let l;try{for(var a=!0,p=Zl(f.message),b;b=await p.next(),o=b.done,!o;a=!0)c=b.value,a=!1,l=c}catch(w){s={error:w}}finally{try{!a&&!o&&(u=p.return)&&await u.call(p)}finally{if(s)throw s.error}}if(!l)throw new Ze("protocol error: missing response message",Ge.Internal);return(y=r==null?void 0:r.onTrailer)===null||y===void 0||y.call(r,f.trailer),l}}function Yc(i,t,e){return function(n,r){return Xl(i.stream(t,e,r==null?void 0:r.signal,r==null?void 0:r.timeoutMs,r==null?void 0:r.headers,n,r==null?void 0:r.contextValues),r)}}function Xl(i,t){const e=function(){var n,r;return Vc(this,arguments,function*(){const o=yield Wi(i);(n=t==null?void 0:t.onHeader)===null||n===void 0||n.call(t,o.header),yield Wi(yield*zc(Zl(o.message))),(r=t==null?void 0:t.onTrailer)===null||r===void 0||r.call(t,o.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>e.next()})}}function Zc(...i){const t=new AbortController,e=i.filter(r=>r!==void 0).concat(t.signal);for(const r of e){if(r.aborted){n.apply(r);break}r.addEventListener("abort",n)}function n(){t.signal.aborted||t.abort(Ql(this));for(const r of e)r.removeEventListener("abort",n)}return t}function Xc(i){const t=new AbortController,e=()=>{t.abort(new Ze("the operation timed out",Ge.DeadlineExceeded))};let n;return i!==void 0&&(i<=0?e():n=setTimeout(e,i)),{signal:t.signal,cleanup:()=>clearTimeout(n)}}function Ql(i){if(!i.aborted)return;if(i.reason!==void 0)return i.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function ol(){return{get(i){return i.id in this?this[i.id]:i.defaultValue},set(i,t){return this[i.id]=t,this},delete(i){return delete this[i.id],this}}}const qs=128;function sl(i){const t=new Headers,e=new TextDecoder().decode(i).split(`\r +`);for(const n of e){if(n==="")continue;const r=n.indexOf(":");if(r>0){const o=n.substring(0,r).trim(),s=n.substring(r+1).trim();t.append(o,s)}}return t}const Qc="Content-Type",ef="Grpc-Timeout",eu="Grpc-Status",tu="Grpc-Message",tf="Grpc-Status-Details-Bin",nf="X-User-Agent",rf="X-Grpc-Web",of="application/grpc-web+proto",sf="application/grpc-web+json";class Hr extends me{constructor(t){super(),this.code=0,this.message="",this.details=[],L.util.initPartial(t,this)}static fromBinary(t,e){return new Hr().fromBinary(t,e)}static fromJson(t,e){return new Hr().fromJson(t,e)}static fromJsonString(t,e){return new Hr().fromJsonString(t,e)}static equals(t,e){return L.util.equals(Hr,t,e)}}Hr.runtime=L;Hr.typeName="google.rpc.Status";Hr.fields=L.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:_n,repeated:!0}]);const af="0";function nu(i){var t;const e=i.get(tf);if(e!=null){const r=qc(e,Hr);if(r.code==0)return;const o=new Ze(r.message,r.code,i);return o.details=r.details.map(s=>({type:s.typeUrl.substring(s.typeUrl.lastIndexOf("/")+1),value:s.value})),o}const n=i.get(eu);if(n!=null){if(n===af)return;const r=parseInt(n,10);return r in Ge?new Ze(decodeURIComponent((t=i.get(tu))!==null&&t!==void 0?t:""),r,i):new Ze(`invalid grpc-status: ${n}`,Ge.Internal,i)}}function al(i,t,e){const n=typeof t=="string"?t:t.typeName,r=typeof e=="string"?e:e.name;return i.toString().replace(/\/?$/,`/${n}/${r}`)}function ru(i,t){return t instanceof i?t:new i(t)}function lf(i,t){function e(n){return n.done===!0?n:{done:n.done,value:ru(i,n.value)}}return{[Symbol.asyncIterator](){const n=t[Symbol.asyncIterator](),r={next:()=>n.next().then(e)};return n.throw!==void 0&&(r.throw=o=>n.throw(o).then(e)),n.return!==void 0&&(r.return=o=>n.return(o).then(e)),r}}}function iu(i,t){var e;return(e=t==null?void 0:t.concat().reverse().reduce((n,r)=>r(n),i))!==null&&e!==void 0?e:i}function uf(i){var t;const e=Object.assign({},i);return(t=e.ignoreUnknownFields)!==null&&t!==void 0||(e.ignoreUnknownFields=!0),e}function ll(i,t,e,n){const r=t?ul(i.I,n):cl(i.I,e);return{parse:(t?ul(i.O,n):cl(i.O,e)).parse,serialize:r.serialize}}function ul(i,t){return{parse(e){try{return i.fromBinary(e,t)}catch(n){const r=n instanceof Error?n.message:String(n);throw new Ze(`parse binary: ${r}`,Ge.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const r=n instanceof Error?n.message:String(n);throw new Ze(`serialize binary: ${r}`,Ge.Internal)}}}}function cl(i,t){var e,n;const r=(e=t==null?void 0:t.textEncoder)!==null&&e!==void 0?e:new TextEncoder,o=(n=t==null?void 0:t.textDecoder)!==null&&n!==void 0?n:new TextDecoder,s=uf(t);return{parse(u){try{const c=o.decode(u);return i.fromJsonString(c,s)}catch(c){throw Ze.from(c,Ge.InvalidArgument)}},serialize(u){try{const c=u.toJsonString(s);return r.encode(c)}catch(c){throw Ze.from(c,Ge.Internal)}}}}function cf(i){const t=iu(i.next,i.interceptors),[e,n,r]=ou(i),o=Object.assign(Object.assign({},i.req),{message:ru(i.req.method.I,i.req.message),signal:e});return t(o).then(s=>(r(),s),n)}function ff(i){const t=iu(i.next,i.interceptors),[e,n,r]=ou(i),o=Object.assign(Object.assign({},i.req),{message:lf(i.req.method.I,i.req.message),signal:e});let s=!1;return e.addEventListener("abort",function(){var u,c;const m=i.req.message[Symbol.asyncIterator]();s||(u=m.throw)===null||u===void 0||u.call(m,this.reason).catch(()=>{}),(c=m.return)===null||c===void 0||c.call(m).catch(()=>{})}),t(o).then(u=>Object.assign(Object.assign({},u),{message:{[Symbol.asyncIterator](){const c=u.message[Symbol.asyncIterator]();return{next(){return c.next().then(m=>(m.done==!0&&(s=!0,r()),m),n)}}}}}),n)}function ou(i){const{signal:t,cleanup:e}=Xc(i.timeoutMs),n=Zc(i.signal,t);return[n.signal,function(o){const s=Ze.from(t.aborted?Ql(t):o);return n.abort(s),e(),Promise.reject(s)},function(){e(),n.abort()}]}function hf(){try{new Headers}catch{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.")}}function fl(i,t){const e=nu(i);if(e)throw t.forEach((n,r)=>{e.metadata.append(r,n)}),e}function hl(i,t,e,n){const r=new Headers(e??{});return r.set(Qc,i?of:sf),r.set(rf,"1"),r.set(nf,"connect-es/1.4.0"),t!==void 0&&r.set(ef,`${t}m`),r}function df(i){switch(i){case 400:return Ge.Internal;case 401:return Ge.Unauthenticated;case 403:return Ge.PermissionDenied;case 404:return Ge.Unimplemented;case 429:return Ge.Unavailable;case 502:return Ge.Unavailable;case 503:return Ge.Unavailable;case 504:return Ge.Unavailable;default:return Ge.Unknown}}function dl(i,t){var e;if(i>=200&&i<300){const n=nu(t);if(n)throw n;return{foundStatus:t.has(eu)}}throw new Ze(decodeURIComponent((e=t.get(tu))!==null&&e!==void 0?e:`HTTP ${i}`),df(i),t)}var Ei=function(i){return this instanceof Ei?(this.v=i,this):new Ei(i)},gf=function(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},u("next"),u("throw"),u("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(a){return function(p){return Promise.resolve(p).then(a,f)}}function u(a,p){n[a]&&(r[a]=function(b){return new Promise(function(w,v){o.push([a,b,w,v])>1||c(a,b)})},p&&(r[a]=p(r[a])))}function c(a,p){try{m(n[a](p))}catch(b){l(o[0][3],b)}}function m(a){a.value instanceof Ei?Promise.resolve(a.value.v).then(y,f):l(o[0][2],a)}function y(a){c("next",a)}function f(a){c("throw",a)}function l(a,p){a(p),o.shift(),o.length&&c(o[0][0],o[0][1])}};function pf(i){var t;hf();const e=(t=i.useBinaryFormat)!==null&&t!==void 0?t:!0;return{async unary(n,r,o,s,u,c,m){var y;const{serialize:f,parse:l}=ll(r,e,i.jsonOptions,i.binaryOptions);return s=s===void 0?i.defaultTimeoutMs:s<=0?void 0:s,await cf({interceptors:i.interceptors,signal:o,timeoutMs:s,req:{stream:!1,service:n,method:r,url:al(i.baseUrl,n,r),init:{method:"POST",credentials:(y=i.credentials)!==null&&y!==void 0?y:"same-origin",redirect:"error",mode:"cors"},header:hl(e,s,u),contextValues:m??ol(),message:c},next:async a=>{var p;const w=await((p=i.fetch)!==null&&p!==void 0?p:globalThis.fetch)(a.url,Object.assign(Object.assign({},a.init),{headers:a.header,signal:a.signal,body:il(0,f(a.message))}));if(dl(w.status,w.headers),!w.body)throw"missing response body";const v=rl(w.body).getReader();let h,g;for(;;){const d=await v.read();if(d.done)break;const{flags:A,data:S}=d.value;if(A===qs){if(h!==void 0)throw"extra trailer";h=sl(S);continue}if(g!==void 0)throw"extra message";g=l(S)}if(h===void 0)throw"missing trailer";if(fl(h,w.headers),g===void 0)throw"missing message";return{stream:!1,service:n,method:r,header:w.headers,message:g,trailer:h}}})},async stream(n,r,o,s,u,c,m){var y;const{serialize:f,parse:l}=ll(r,e,i.jsonOptions,i.binaryOptions);function a(b,w,v,h){return gf(this,arguments,function*(){const d=rl(b).getReader();if(w){if(!(yield Ei(d.read())).done)throw"extra data for trailers-only";return yield Ei(void 0)}let A=!1;for(;;){const S=yield Ei(d.read());if(S.done)break;const{flags:E,data:O}=S.value;if((E&qs)===qs){if(A)throw"extra trailer";A=!0;const _=sl(O);fl(_,h),_.forEach((k,x)=>v.set(x,k));continue}if(A)throw"extra message";yield yield Ei(l(O))}if(!A)throw"missing trailer"})}async function p(b){if(r.kind!=bt.ServerStreaming)throw"The fetch API does not support streaming request bodies";const w=await b[Symbol.asyncIterator]().next();if(w.done==!0)throw"missing request message";return il(0,f(w.value))}return s=s===void 0?i.defaultTimeoutMs:s<=0?void 0:s,ff({interceptors:i.interceptors,signal:o,timeoutMs:s,req:{stream:!0,service:n,method:r,url:al(i.baseUrl,n,r),init:{method:"POST",credentials:(y=i.credentials)!==null&&y!==void 0?y:"same-origin",redirect:"error",mode:"cors"},header:hl(e,s,u),contextValues:m??ol(),message:c},next:async b=>{var w;const h=await((w=i.fetch)!==null&&w!==void 0?w:globalThis.fetch)(b.url,Object.assign(Object.assign({},b.init),{headers:b.header,signal:b.signal,body:await p(b.message)})),{foundStatus:g}=dl(h.status,h.headers);if(!h.body)throw"missing response body";const d=new Headers;return Object.assign(Object.assign({},b),{header:h.headers,trailer:d,message:a(h.body,g,d,h.headers)})}})}}}var Re=(i=>(i[i.NULL=0]="NULL",i[i.BOOLEAN=1]="BOOLEAN",i[i.INTEGER=2]="INTEGER",i[i.LONG=3]="LONG",i[i.DOUBLE=4]="DOUBLE",i[i.STRING=5]="STRING",i[i.BYTES=6]="BYTES",i[i.DATE=7]="DATE",i[i.JSON_OBJECT=8]="JSON_OBJECT",i[i.JSON_ARRAY=9]="JSON_ARRAY",i[i.TEXT=10]="TEXT",i[i.INTEGER_CNT=11]="INTEGER_CNT",i[i.LONG_CNT=12]="LONG_CNT",i[i.TREE=13]="TREE",i))(Re||{});L.util.setEnumType(Re,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var Oi=(i=>(i[i.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",i[i.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",i[i.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",i[i.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",i))(Oi||{});L.util.setEnumType(Oi,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const Vn=class Vn extends me{constructor(e){super();T(this,"root");T(this,"presences",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Vn().fromBinary(e,n)}static fromJson(e,n){return new Vn().fromJson(e,n)}static fromJsonString(e,n){return new Vn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Vn,e,n)}};T(Vn,"runtime",L),T(Vn,"typeName","yorkie.v1.Snapshot"),T(Vn,"fields",L.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:kt},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:Sa}}]));let Hs=Vn;var Mt;let Qr=(Mt=class extends me{constructor(e){super();T(this,"documentKey","");T(this,"checkpoint");T(this,"snapshot",new Uint8Array(0));T(this,"changes",[]);T(this,"minSyncedTicket");T(this,"isRemoved",!1);T(this,"versionVector");L.util.initPartial(e,this)}static fromBinary(e,n){return new Mt().fromBinary(e,n)}static fromJson(e,n){return new Mt().fromJson(e,n)}static fromJsonString(e,n){return new Mt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Mt,e,n)}},T(Mt,"runtime",L),T(Mt,"typeName","yorkie.v1.ChangePack"),T(Mt,"fields",L.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:lu},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:su,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:xe},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:Os}])),Mt);var qt;let su=(qt=class extends me{constructor(e){super();T(this,"id");T(this,"message","");T(this,"operations",[]);T(this,"presenceChange");L.util.initPartial(e,this)}static fromBinary(e,n){return new qt().fromBinary(e,n)}static fromJson(e,n){return new qt().fromJson(e,n)}static fromJsonString(e,n){return new qt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(qt,e,n)}},T(qt,"runtime",L),T(qt,"typeName","yorkie.v1.Change"),T(qt,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:ks},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:Ta,repeated:!0},{no:4,name:"presence_change",kind:"message",T:vo}])),qt);var Ft;let ks=(Ft=class extends me{constructor(e){super();T(this,"clientSeq",0);T(this,"serverSeq",Xe.zero);T(this,"lamport",Xe.zero);T(this,"actorId",new Uint8Array(0));T(this,"versionVector");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ft().fromBinary(e,n)}static fromJson(e,n){return new Ft().fromJson(e,n)}static fromJsonString(e,n){return new Ft().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ft,e,n)}},T(Ft,"runtime",L),T(Ft,"typeName","yorkie.v1.ChangeID"),T(Ft,"fields",L.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:Os}])),Ft);var jt;let Os=(jt=class extends me{constructor(e){super();T(this,"vector",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new jt().fromBinary(e,n)}static fromJson(e,n){return new jt().fromJson(e,n)}static fromJsonString(e,n){return new jt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(jt,e,n)}},T(jt,"runtime",L),T(jt,"typeName","yorkie.v1.VersionVector"),T(jt,"fields",L.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),jt);var Ut;let Ta=(Ut=class extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new Ut().fromBinary(e,n)}static fromJson(e,n){return new Ut().fromJson(e,n)}static fromJsonString(e,n){return new Ut().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ut,e,n)}},T(Ut,"runtime",L),T(Ut,"typeName","yorkie.v1.Operation"),T(Ut,"fields",L.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:rs,oneof:"body"},{no:2,name:"add",kind:"message",T:is,oneof:"body"},{no:3,name:"move",kind:"message",T:os,oneof:"body"},{no:4,name:"remove",kind:"message",T:ss,oneof:"body"},{no:5,name:"edit",kind:"message",T:as,oneof:"body"},{no:6,name:"select",kind:"message",T:Ws,oneof:"body"},{no:7,name:"style",kind:"message",T:ls,oneof:"body"},{no:8,name:"increase",kind:"message",T:us,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:cs,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:fs,oneof:"body"},{no:11,name:"array_set",kind:"message",T:Gs,oneof:"body"}])),Ut);const Kn=class Kn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"key","");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Kn().fromBinary(e,n)}static fromJson(e,n){return new Kn().fromJson(e,n)}static fromJsonString(e,n){return new Kn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Kn,e,n)}};T(Kn,"runtime",L),T(Kn,"typeName","yorkie.v1.Operation.Set"),T(Kn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let rs=Kn;const Hn=class Hn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"prevCreatedAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Hn().fromBinary(e,n)}static fromJson(e,n){return new Hn().fromJson(e,n)}static fromJsonString(e,n){return new Hn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Hn,e,n)}};T(Hn,"runtime",L),T(Hn,"typeName","yorkie.v1.Operation.Add"),T(Hn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"prev_created_at",kind:"message",T:xe},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let is=Hn;const Wn=class Wn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"prevCreatedAt");T(this,"createdAt");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Wn().fromBinary(e,n)}static fromJson(e,n){return new Wn().fromJson(e,n)}static fromJsonString(e,n){return new Wn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Wn,e,n)}};T(Wn,"runtime",L),T(Wn,"typeName","yorkie.v1.Operation.Move"),T(Wn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"prev_created_at",kind:"message",T:xe},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"executed_at",kind:"message",T:xe}]));let os=Wn;const Gn=class Gn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"createdAt");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Gn().fromBinary(e,n)}static fromJson(e,n){return new Gn().fromJson(e,n)}static fromJsonString(e,n){return new Gn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Gn,e,n)}};T(Gn,"runtime",L),T(Gn,"typeName","yorkie.v1.Operation.Remove"),T(Gn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"executed_at",kind:"message",T:xe}]));let ss=Gn;const Yn=class Yn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"createdAtMapByActor",{});T(this,"content","");T(this,"executedAt");T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Yn().fromBinary(e,n)}static fromJson(e,n){return new Yn().fromJson(e,n)}static fromJsonString(e,n){return new Yn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Yn,e,n)}};T(Yn,"runtime",L),T(Yn,"typeName","yorkie.v1.Operation.Edit"),T(Yn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:xe},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let as=Yn;const Zn=class Zn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Zn().fromBinary(e,n)}static fromJson(e,n){return new Zn().fromJson(e,n)}static fromJsonString(e,n){return new Zn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Zn,e,n)}};T(Zn,"runtime",L),T(Zn,"typeName","yorkie.v1.Operation.Select"),T(Zn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"executed_at",kind:"message",T:xe}]));let Ws=Zn;const Xn=class Xn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"attributes",{});T(this,"executedAt");T(this,"createdAtMapByActor",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new Xn().fromBinary(e,n)}static fromJson(e,n){return new Xn().fromJson(e,n)}static fromJsonString(e,n){return new Xn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Xn,e,n)}};T(Xn,"runtime",L),T(Xn,"typeName","yorkie.v1.Operation.Style"),T(Xn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Zr},{no:3,name:"to",kind:"message",T:Zr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:xe},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}}]));let ls=Xn;const Qn=class Qn extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Qn().fromBinary(e,n)}static fromJson(e,n){return new Qn().fromJson(e,n)}static fromJsonString(e,n){return new Qn().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Qn,e,n)}};T(Qn,"runtime",L),T(Qn,"typeName","yorkie.v1.Operation.Increase"),T(Qn,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"value",kind:"message",T:Bt},{no:3,name:"executed_at",kind:"message",T:xe}]));let us=Qn;const er=class er extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"createdAtMapByActor",{});T(this,"contents",[]);T(this,"splitLevel",0);T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new er().fromBinary(e,n)}static fromJson(e,n){return new er().fromJson(e,n)}static fromJsonString(e,n){return new er().fromJsonString(e,n)}static equals(e,n){return L.util.equals(er,e,n)}};T(er,"runtime",L),T(er,"typeName","yorkie.v1.Operation.TreeEdit"),T(er,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}},{no:5,name:"contents",kind:"message",T:ws,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:xe}]));let cs=er;const tr=class tr extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"from");T(this,"to");T(this,"attributes",{});T(this,"executedAt");T(this,"attributesToRemove",[]);T(this,"createdAtMapByActor",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new tr().fromBinary(e,n)}static fromJson(e,n){return new tr().fromJson(e,n)}static fromJsonString(e,n){return new tr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(tr,e,n)}};T(tr,"runtime",L),T(tr,"typeName","yorkie.v1.Operation.TreeStyle"),T(tr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"from",kind:"message",T:Ii},{no:3,name:"to",kind:"message",T:Ii},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:xe},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:xe}}]));let fs=tr;const nr=class nr extends me{constructor(e){super();T(this,"parentCreatedAt");T(this,"createdAt");T(this,"value");T(this,"executedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new nr().fromBinary(e,n)}static fromJson(e,n){return new nr().fromJson(e,n)}static fromJsonString(e,n){return new nr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(nr,e,n)}};T(nr,"runtime",L),T(nr,"typeName","yorkie.v1.Operation.ArraySet"),T(nr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:xe},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"value",kind:"message",T:Bt},{no:4,name:"executed_at",kind:"message",T:xe}]));let Gs=nr;const rr=class rr extends me{constructor(e){super();T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");T(this,"type",0);T(this,"value",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new rr().fromBinary(e,n)}static fromJson(e,n){return new rr().fromJson(e,n)}static fromJsonString(e,n){return new rr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(rr,e,n)}};T(rr,"runtime",L),T(rr,"typeName","yorkie.v1.JSONElementSimple"),T(rr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"moved_at",kind:"message",T:xe},{no:3,name:"removed_at",kind:"message",T:xe},{no:4,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:5,name:"value",kind:"scalar",T:12}]));let Bt=rr;const ir=class ir extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new ir().fromBinary(e,n)}static fromJson(e,n){return new ir().fromJson(e,n)}static fromJsonString(e,n){return new ir().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ir,e,n)}};T(ir,"runtime",L),T(ir,"typeName","yorkie.v1.JSONElement"),T(ir,"fields",L.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:hs,oneof:"body"},{no:2,name:"json_array",kind:"message",T:ds,oneof:"body"},{no:3,name:"primitive",kind:"message",T:gs,oneof:"body"},{no:5,name:"text",kind:"message",T:ps,oneof:"body"},{no:6,name:"counter",kind:"message",T:ms,oneof:"body"},{no:7,name:"tree",kind:"message",T:ys,oneof:"body"}]));let kt=ir;const or=class or extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new or().fromBinary(e,n)}static fromJson(e,n){return new or().fromJson(e,n)}static fromJsonString(e,n){return new or().fromJsonString(e,n)}static equals(e,n){return L.util.equals(or,e,n)}};T(or,"runtime",L),T(or,"typeName","yorkie.v1.JSONElement.JSONObject"),T(or,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:au,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let hs=or;const sr=class sr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new sr().fromBinary(e,n)}static fromJson(e,n){return new sr().fromJson(e,n)}static fromJsonString(e,n){return new sr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(sr,e,n)}};T(sr,"runtime",L),T(sr,"typeName","yorkie.v1.JSONElement.JSONArray"),T(sr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:vs,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ds=sr;const ar=class ar extends me{constructor(e){super();T(this,"type",0);T(this,"value",new Uint8Array(0));T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new ar().fromBinary(e,n)}static fromJson(e,n){return new ar().fromJson(e,n)}static fromJsonString(e,n){return new ar().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ar,e,n)}};T(ar,"runtime",L),T(ar,"typeName","yorkie.v1.JSONElement.Primitive"),T(ar,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"moved_at",kind:"message",T:xe},{no:5,name:"removed_at",kind:"message",T:xe}]));let gs=ar;const lr=class lr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new lr().fromBinary(e,n)}static fromJson(e,n){return new lr().fromJson(e,n)}static fromJsonString(e,n){return new lr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(lr,e,n)}};T(lr,"runtime",L),T(lr,"typeName","yorkie.v1.JSONElement.Text"),T(lr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:bs,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ps=lr;const ur=class ur extends me{constructor(e){super();T(this,"type",0);T(this,"value",new Uint8Array(0));T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new ur().fromBinary(e,n)}static fromJson(e,n){return new ur().fromJson(e,n)}static fromJsonString(e,n){return new ur().fromJsonString(e,n)}static equals(e,n){return L.util.equals(ur,e,n)}};T(ur,"runtime",L),T(ur,"typeName","yorkie.v1.JSONElement.Counter"),T(ur,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Re)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:xe},{no:4,name:"moved_at",kind:"message",T:xe},{no:5,name:"removed_at",kind:"message",T:xe}]));let ms=ur;const cr=class cr extends me{constructor(e){super();T(this,"nodes",[]);T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new cr().fromBinary(e,n)}static fromJson(e,n){return new cr().fromJson(e,n)}static fromJsonString(e,n){return new cr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(cr,e,n)}};T(cr,"runtime",L),T(cr,"typeName","yorkie.v1.JSONElement.Tree"),T(cr,"fields",L.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:yo,repeated:!0},{no:2,name:"created_at",kind:"message",T:xe},{no:3,name:"moved_at",kind:"message",T:xe},{no:4,name:"removed_at",kind:"message",T:xe}]));let ys=cr;var Jt;let au=(Jt=class extends me{constructor(e){super();T(this,"key","");T(this,"element");L.util.initPartial(e,this)}static fromBinary(e,n){return new Jt().fromBinary(e,n)}static fromJson(e,n){return new Jt().fromJson(e,n)}static fromJsonString(e,n){return new Jt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Jt,e,n)}},T(Jt,"runtime",L),T(Jt,"typeName","yorkie.v1.RHTNode"),T(Jt,"fields",L.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:kt}])),Jt);const In=class In extends me{constructor(e){super();T(this,"next");T(this,"element");L.util.initPartial(e,this)}static fromBinary(e,n){return new In().fromBinary(e,n)}static fromJson(e,n){return new In().fromJson(e,n)}static fromJsonString(e,n){return new In().fromJsonString(e,n)}static equals(e,n){return L.util.equals(In,e,n)}};T(In,"runtime",L),T(In,"typeName","yorkie.v1.RGANode"),T(In,"fields",L.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:In},{no:2,name:"element",kind:"message",T:kt}]));let vs=In;const fr=class fr extends me{constructor(e){super();T(this,"value","");T(this,"updatedAt");T(this,"isRemoved",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new fr().fromBinary(e,n)}static fromJson(e,n){return new fr().fromJson(e,n)}static fromJsonString(e,n){return new fr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(fr,e,n)}};T(fr,"runtime",L),T(fr,"typeName","yorkie.v1.NodeAttr"),T(fr,"fields",L.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:xe},{no:3,name:"is_removed",kind:"scalar",T:8}]));let Gi=fr;const hr=class hr extends me{constructor(e){super();T(this,"id");T(this,"value","");T(this,"removedAt");T(this,"insPrevId");T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new hr().fromBinary(e,n)}static fromJson(e,n){return new hr().fromJson(e,n)}static fromJsonString(e,n){return new hr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(hr,e,n)}};T(hr,"runtime",L),T(hr,"typeName","yorkie.v1.TextNode"),T(hr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:mo},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:xe},{no:4,name:"ins_prev_id",kind:"message",T:mo},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Gi}}]));let bs=hr;const dr=class dr extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new dr().fromBinary(e,n)}static fromJson(e,n){return new dr().fromJson(e,n)}static fromJsonString(e,n){return new dr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(dr,e,n)}};T(dr,"runtime",L),T(dr,"typeName","yorkie.v1.TextNodeID"),T(dr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5}]));let mo=dr;const gr=class gr extends me{constructor(e){super();T(this,"id");T(this,"type","");T(this,"value","");T(this,"removedAt");T(this,"insPrevId");T(this,"insNextId");T(this,"depth",0);T(this,"attributes",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new gr().fromBinary(e,n)}static fromJson(e,n){return new gr().fromJson(e,n)}static fromJsonString(e,n){return new gr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(gr,e,n)}};T(gr,"runtime",L),T(gr,"typeName","yorkie.v1.TreeNode"),T(gr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:fi},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:xe},{no:5,name:"ins_prev_id",kind:"message",T:fi},{no:6,name:"ins_next_id",kind:"message",T:fi},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:Gi}}]));let yo=gr;const pr=class pr extends me{constructor(e){super();T(this,"content",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new pr().fromBinary(e,n)}static fromJson(e,n){return new pr().fromJson(e,n)}static fromJsonString(e,n){return new pr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(pr,e,n)}};T(pr,"runtime",L),T(pr,"typeName","yorkie.v1.TreeNodes"),T(pr,"fields",L.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:yo,repeated:!0}]));let ws=pr;const mr=class mr extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new mr().fromBinary(e,n)}static fromJson(e,n){return new mr().fromJson(e,n)}static fromJsonString(e,n){return new mr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(mr,e,n)}};T(mr,"runtime",L),T(mr,"typeName","yorkie.v1.TreeNodeID"),T(mr,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5}]));let fi=mr;const yr=class yr extends me{constructor(e){super();T(this,"parentId");T(this,"leftSiblingId");L.util.initPartial(e,this)}static fromBinary(e,n){return new yr().fromBinary(e,n)}static fromJson(e,n){return new yr().fromJson(e,n)}static fromJsonString(e,n){return new yr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(yr,e,n)}};T(yr,"runtime",L),T(yr,"typeName","yorkie.v1.TreePos"),T(yr,"fields",L.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:fi},{no:2,name:"left_sibling_id",kind:"message",T:fi}]));let Ii=yr;const vr=class vr extends me{constructor(e){super();T(this,"id","");T(this,"username","");T(this,"createdAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new vr().fromBinary(e,n)}static fromJson(e,n){return new vr().fromJson(e,n)}static fromJsonString(e,n){return new vr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(vr,e,n)}};T(vr,"runtime",L),T(vr,"typeName","yorkie.v1.User"),T(vr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:mt}]));let gl=vr;const br=class br extends me{constructor(e){super();T(this,"id","");T(this,"name","");T(this,"publicKey","");T(this,"secretKey","");T(this,"authWebhookUrl","");T(this,"authWebhookMethods",[]);T(this,"clientDeactivateThreshold","");T(this,"createdAt");T(this,"updatedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new br().fromBinary(e,n)}static fromJson(e,n){return new br().fromJson(e,n)}static fromJsonString(e,n){return new br().fromJsonString(e,n)}static equals(e,n){return L.util.equals(br,e,n)}};T(br,"runtime",L),T(br,"typeName","yorkie.v1.Project"),T(br,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:mt},{no:9,name:"updated_at",kind:"message",T:mt}]));let pl=br;const wr=class wr extends me{constructor(e){super();T(this,"name");T(this,"authWebhookUrl");T(this,"authWebhookMethods");T(this,"clientDeactivateThreshold");L.util.initPartial(e,this)}static fromBinary(e,n){return new wr().fromBinary(e,n)}static fromJson(e,n){return new wr().fromJson(e,n)}static fromJsonString(e,n){return new wr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(wr,e,n)}};T(wr,"runtime",L),T(wr,"typeName","yorkie.v1.UpdatableProjectFields"),T(wr,"fields",L.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Pt},{no:2,name:"auth_webhook_url",kind:"message",T:Pt},{no:3,name:"auth_webhook_methods",kind:"message",T:Ys},{no:4,name:"client_deactivate_threshold",kind:"message",T:Pt}]));let ml=wr;const Ar=class Ar extends me{constructor(e){super();T(this,"methods",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new Ar().fromBinary(e,n)}static fromJson(e,n){return new Ar().fromJson(e,n)}static fromJsonString(e,n){return new Ar().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ar,e,n)}};T(Ar,"runtime",L),T(Ar,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),T(Ar,"fields",L.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let Ys=Ar;const Tr=class Tr extends me{constructor(e){super();T(this,"id","");T(this,"key","");T(this,"snapshot","");T(this,"createdAt");T(this,"accessedAt");T(this,"updatedAt");L.util.initPartial(e,this)}static fromBinary(e,n){return new Tr().fromBinary(e,n)}static fromJson(e,n){return new Tr().fromJson(e,n)}static fromJsonString(e,n){return new Tr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Tr,e,n)}};T(Tr,"runtime",L),T(Tr,"typeName","yorkie.v1.DocumentSummary"),T(Tr,"fields",L.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:mt},{no:5,name:"accessed_at",kind:"message",T:mt},{no:6,name:"updated_at",kind:"message",T:mt}]));let yl=Tr;const Sr=class Sr extends me{constructor(e){super();T(this,"type",0);T(this,"presence");L.util.initPartial(e,this)}static fromBinary(e,n){return new Sr().fromBinary(e,n)}static fromJson(e,n){return new Sr().fromJson(e,n)}static fromJsonString(e,n){return new Sr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Sr,e,n)}};T(Sr,"runtime",L),T(Sr,"typeName","yorkie.v1.PresenceChange"),T(Sr,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Ni)},{no:2,name:"presence",kind:"message",T:Sa}]));let vo=Sr;var Ni=(i=>(i[i.UNSPECIFIED=0]="UNSPECIFIED",i[i.PUT=1]="PUT",i[i.DELETE=2]="DELETE",i[i.CLEAR=3]="CLEAR",i))(Ni||{});L.util.setEnumType(Ni,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var $t;let Sa=($t=class extends me{constructor(e){super();T(this,"data",{});L.util.initPartial(e,this)}static fromBinary(e,n){return new $t().fromBinary(e,n)}static fromJson(e,n){return new $t().fromJson(e,n)}static fromJsonString(e,n){return new $t().fromJsonString(e,n)}static equals(e,n){return L.util.equals($t,e,n)}},T($t,"runtime",L),T($t,"typeName","yorkie.v1.Presence"),T($t,"fields",L.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),$t);var zt;let lu=(zt=class extends me{constructor(e){super();T(this,"serverSeq",Xe.zero);T(this,"clientSeq",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new zt().fromBinary(e,n)}static fromJson(e,n){return new zt().fromJson(e,n)}static fromJsonString(e,n){return new zt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(zt,e,n)}},T(zt,"runtime",L),T(zt,"typeName","yorkie.v1.Checkpoint"),T(zt,"fields",L.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),zt);const Er=class Er extends me{constructor(e){super();T(this,"createdAt");T(this,"offset",0);T(this,"relativeOffset",0);L.util.initPartial(e,this)}static fromBinary(e,n){return new Er().fromBinary(e,n)}static fromJson(e,n){return new Er().fromJson(e,n)}static fromJsonString(e,n){return new Er().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Er,e,n)}};T(Er,"runtime",L),T(Er,"typeName","yorkie.v1.TextNodePos"),T(Er,"fields",L.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:xe},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let Zr=Er;var Vt;let xe=(Vt=class extends me{constructor(e){super();T(this,"lamport",Xe.zero);T(this,"delimiter",0);T(this,"actorId",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new Vt().fromBinary(e,n)}static fromJson(e,n){return new Vt().fromJson(e,n)}static fromJsonString(e,n){return new Vt().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Vt,e,n)}},T(Vt,"runtime",L),T(Vt,"typeName","yorkie.v1.TimeTicket"),T(Vt,"fields",L.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),Vt);const xr=class xr extends me{constructor(e){super();T(this,"topic","");T(this,"payload",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new xr().fromBinary(e,n)}static fromJson(e,n){return new xr().fromJson(e,n)}static fromJsonString(e,n){return new xr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(xr,e,n)}};T(xr,"runtime",L),T(xr,"typeName","yorkie.v1.DocEventBody"),T(xr,"fields",L.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let Zs=xr;const kr=class kr extends me{constructor(e){super();T(this,"type",0);T(this,"publisher","");T(this,"body");L.util.initPartial(e,this)}static fromBinary(e,n){return new kr().fromBinary(e,n)}static fromJson(e,n){return new kr().fromJson(e,n)}static fromJsonString(e,n){return new kr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(kr,e,n)}};T(kr,"runtime",L),T(kr,"typeName","yorkie.v1.DocEvent"),T(kr,"fields",L.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:L.getEnumType(Oi)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:Zs}]));let Xs=kr;const Or=class Or extends me{constructor(e){super();T(this,"clientKey","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Or().fromBinary(e,n)}static fromJson(e,n){return new Or().fromJson(e,n)}static fromJsonString(e,n){return new Or().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Or,e,n)}};T(Or,"runtime",L),T(Or,"typeName","yorkie.v1.ActivateClientRequest"),T(Or,"fields",L.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let Qs=Or;const Ir=class Ir extends me{constructor(e){super();T(this,"clientId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ir().fromBinary(e,n)}static fromJson(e,n){return new Ir().fromJson(e,n)}static fromJsonString(e,n){return new Ir().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ir,e,n)}};T(Ir,"runtime",L),T(Ir,"typeName","yorkie.v1.ActivateClientResponse"),T(Ir,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let ea=Ir;const Nr=class Nr extends me{constructor(e){super();T(this,"clientId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Nr().fromBinary(e,n)}static fromJson(e,n){return new Nr().fromJson(e,n)}static fromJsonString(e,n){return new Nr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Nr,e,n)}};T(Nr,"runtime",L),T(Nr,"typeName","yorkie.v1.DeactivateClientRequest"),T(Nr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let ta=Nr;const _r=class _r extends me{constructor(t){super(),L.util.initPartial(t,this)}static fromBinary(t,e){return new _r().fromBinary(t,e)}static fromJson(t,e){return new _r().fromJson(t,e)}static fromJsonString(t,e){return new _r().fromJsonString(t,e)}static equals(t,e){return L.util.equals(_r,t,e)}};T(_r,"runtime",L),T(_r,"typeName","yorkie.v1.DeactivateClientResponse"),T(_r,"fields",L.util.newFieldList(()=>[]));let na=_r;const Pr=class Pr extends me{constructor(e){super();T(this,"clientId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Pr().fromBinary(e,n)}static fromJson(e,n){return new Pr().fromJson(e,n)}static fromJsonString(e,n){return new Pr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Pr,e,n)}};T(Pr,"runtime",L),T(Pr,"typeName","yorkie.v1.AttachDocumentRequest"),T(Pr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Qr}]));let ra=Pr;const Cr=class Cr extends me{constructor(e){super();T(this,"documentId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Cr().fromBinary(e,n)}static fromJson(e,n){return new Cr().fromJson(e,n)}static fromJsonString(e,n){return new Cr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Cr,e,n)}};T(Cr,"runtime",L),T(Cr,"typeName","yorkie.v1.AttachDocumentResponse"),T(Cr,"fields",L.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:Qr}]));let ia=Cr;const Lr=class Lr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");T(this,"removeIfNotAttached",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new Lr().fromBinary(e,n)}static fromJson(e,n){return new Lr().fromJson(e,n)}static fromJsonString(e,n){return new Lr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Lr,e,n)}};T(Lr,"runtime",L),T(Lr,"typeName","yorkie.v1.DetachDocumentRequest"),T(Lr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let oa=Lr;const Rr=class Rr extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Rr().fromBinary(e,n)}static fromJson(e,n){return new Rr().fromJson(e,n)}static fromJsonString(e,n){return new Rr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Rr,e,n)}};T(Rr,"runtime",L),T(Rr,"typeName","yorkie.v1.DetachDocumentResponse"),T(Rr,"fields",L.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:Qr}]));let sa=Rr;const Dr=class Dr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");L.util.initPartial(e,this)}static fromBinary(e,n){return new Dr().fromBinary(e,n)}static fromJson(e,n){return new Dr().fromJson(e,n)}static fromJsonString(e,n){return new Dr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Dr,e,n)}};T(Dr,"runtime",L),T(Dr,"typeName","yorkie.v1.WatchDocumentRequest"),T(Dr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let aa=Dr;const Br=class Br extends me{constructor(e){super();T(this,"body",{case:void 0});L.util.initPartial(e,this)}static fromBinary(e,n){return new Br().fromBinary(e,n)}static fromJson(e,n){return new Br().fromJson(e,n)}static fromJsonString(e,n){return new Br().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Br,e,n)}};T(Br,"runtime",L),T(Br,"typeName","yorkie.v1.WatchDocumentResponse"),T(Br,"fields",L.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:ua,oneof:"body"},{no:2,name:"event",kind:"message",T:Xs,oneof:"body"}]));let la=Br;const Mr=class Mr extends me{constructor(e){super();T(this,"clientIds",[]);L.util.initPartial(e,this)}static fromBinary(e,n){return new Mr().fromBinary(e,n)}static fromJson(e,n){return new Mr().fromJson(e,n)}static fromJsonString(e,n){return new Mr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Mr,e,n)}};T(Mr,"runtime",L),T(Mr,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),T(Mr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let ua=Mr;const qr=class qr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new qr().fromBinary(e,n)}static fromJson(e,n){return new qr().fromJson(e,n)}static fromJsonString(e,n){return new qr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(qr,e,n)}};T(qr,"runtime",L),T(qr,"typeName","yorkie.v1.RemoveDocumentRequest"),T(qr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr}]));let ca=qr;const Fr=class Fr extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Fr().fromBinary(e,n)}static fromJson(e,n){return new Fr().fromJson(e,n)}static fromJsonString(e,n){return new Fr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Fr,e,n)}};T(Fr,"runtime",L),T(Fr,"typeName","yorkie.v1.RemoveDocumentResponse"),T(Fr,"fields",L.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Qr}]));let fa=Fr;const jr=class jr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"changePack");T(this,"pushOnly",!1);L.util.initPartial(e,this)}static fromBinary(e,n){return new jr().fromBinary(e,n)}static fromJson(e,n){return new jr().fromJson(e,n)}static fromJsonString(e,n){return new jr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(jr,e,n)}};T(jr,"runtime",L),T(jr,"typeName","yorkie.v1.PushPullChangesRequest"),T(jr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:Qr},{no:4,name:"push_only",kind:"scalar",T:8}]));let ha=jr;const Ur=class Ur extends me{constructor(e){super();T(this,"changePack");L.util.initPartial(e,this)}static fromBinary(e,n){return new Ur().fromBinary(e,n)}static fromJson(e,n){return new Ur().fromJson(e,n)}static fromJsonString(e,n){return new Ur().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Ur,e,n)}};T(Ur,"runtime",L),T(Ur,"typeName","yorkie.v1.PushPullChangesResponse"),T(Ur,"fields",L.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:Qr}]));let da=Ur;const Jr=class Jr extends me{constructor(e){super();T(this,"clientId","");T(this,"documentId","");T(this,"topic","");T(this,"payload",new Uint8Array(0));L.util.initPartial(e,this)}static fromBinary(e,n){return new Jr().fromBinary(e,n)}static fromJson(e,n){return new Jr().fromJson(e,n)}static fromJsonString(e,n){return new Jr().fromJsonString(e,n)}static equals(e,n){return L.util.equals(Jr,e,n)}};T(Jr,"runtime",L),T(Jr,"typeName","yorkie.v1.BroadcastRequest"),T(Jr,"fields",L.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let ga=Jr;const $r=class $r extends me{constructor(t){super(),L.util.initPartial(t,this)}static fromBinary(t,e){return new $r().fromBinary(t,e)}static fromJson(t,e){return new $r().fromJson(t,e)}static fromJsonString(t,e){return new $r().fromJsonString(t,e)}static equals(t,e){return L.util.equals($r,t,e)}};T($r,"runtime",L),T($r,"typeName","yorkie.v1.BroadcastResponse"),T($r,"fields",L.util.newFieldList(()=>[]));let pa=$r;const mf={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:Qs,O:ea,kind:bt.Unary},deactivateClient:{name:"DeactivateClient",I:ta,O:na,kind:bt.Unary},attachDocument:{name:"AttachDocument",I:ra,O:ia,kind:bt.Unary},detachDocument:{name:"DetachDocument",I:oa,O:sa,kind:bt.Unary},removeDocument:{name:"RemoveDocument",I:ca,O:fa,kind:bt.Unary},pushPullChanges:{name:"PushPullChanges",I:ha,O:da,kind:bt.Unary},watchDocument:{name:"WatchDocument",I:aa,O:la,kind:bt.ServerStreaming},broadcast:{name:"Broadcast",I:ga,O:pa,kind:bt.Unary}}},yf=L.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);L.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Kr}]);L.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:vf,repeated:!0}]);const vf=L.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});L.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:bf,repeated:!0}]);const bf=L.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});L.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:wf,repeated:!0}]);const wf=L.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});L.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);L.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Af,repeated:!0}]);const Af=L.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});L.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var te=(i=>(i.Ok="ok",i.ErrClientNotActivated="ErrClientNotActivated",i.ErrClientNotFound="ErrClientNotFound",i.ErrUnimplemented="ErrUnimplemented",i.ErrInvalidType="ErrInvalidType",i.ErrDummy="ErrDummy",i.ErrDocumentNotAttached="ErrDocumentNotAttached",i.ErrDocumentNotDetached="ErrDocumentNotDetached",i.ErrDocumentRemoved="ErrDocumentRemoved",i.ErrInvalidObjectKey="ErrInvalidObjectKey",i.ErrInvalidArgument="ErrInvalidArgument",i.ErrNotInitialized="ErrNotInitialized",i.ErrNotReady="ErrNotReady",i.ErrRefused="ErrRefused",i.ErrContextNotProvided="ErrContextNotProvided",i.ErrPermissionDenied="ErrPermissionDenied",i.ErrUnauthenticated="ErrUnauthenticated",i))(te||{});class ne extends Error{constructor(e,n){super(n);T(this,"name","YorkieError");T(this,"stack");this.code=e,this.message=n,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function sn(i){if(i instanceof Map){const t=Array.from(i);return new Map(JSON.parse(JSON.stringify(t)))}return JSON.parse(JSON.stringify(i))}const uu=i=>i?Object.entries(i).length===0:!0,Yi=i=>{const t={};for(const[e,n]of Object.entries(i))t[e]=JSON.stringify(n);return t},zi=i=>{const t={};for(const[e,n]of Object.entries(i))t[e]=JSON.parse(n);return t};var pi=(i=>(i.Put="put",i.Clear="clear",i))(pi||{});class Fs{constructor(t,e){T(this,"context");T(this,"presence");this.context=t,this.presence=e}set(t,e){for(const n of Object.keys(t))this.presence[n]=t[n];this.context.setPresenceChange({type:"put",presence:sn(this.presence)}),this.context.setReversePresence(t,e)}get(t){return this.presence[t]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const Is="000000000000000000000000";class Wt{constructor(t,e,n){T(this,"lamport");T(this,"delimiter");T(this,"actorID");this.lamport=t,this.delimiter=e,this.actorID=n}static of(t,e,n){return new Wt(t,e,n)}static fromStruct(t){return Wt.of(BigInt(t.lamport),t.delimiter,t.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(t){return new Wt(this.lamport,this.delimiter,t)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(t){return this.compare(t)>0}equals(t){return this.compare(t)===0}compare(t){if(this.lamport>t.lamport)return 1;if(t.lamport>this.lamport)return-1;const e=this.actorID.localeCompare(t.actorID);return e!==0?e:this.delimiter>t.delimiter?1:t.delimiter>this.delimiter?-1:0}}const cu=0,fo=9223372036854775807n,un=new Wt(0n,cu,Is);function Fn(i){return i.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(t){switch(t){case'"':case"\\":return"\\"+t;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return t}})}class ko{constructor(t){T(this,"createdAt");T(this,"movedAt");T(this,"removedAt");this.createdAt=t}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(t){return!this.movedAt||t&&t.after(this.movedAt)?(this.movedAt=t,!0):!1}setRemovedAt(t){this.removedAt=t}remove(t){return t&&t.after(this.getPositionedAt())&&(!this.removedAt||t.after(this.removedAt))?(this.removedAt=t,!0):!1}isRemoved(){return!!this.removedAt}}class hi extends ko{constructor(t){super(t)}}class Ea{constructor(t,e){T(this,"strKey");T(this,"value");this.strKey=t,this.value=e}static of(t,e){return new Ea(t,e)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(t){return this.value.remove(t)}}class bo{constructor(){T(this,"nodeMapByKey");T(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new bo}set(t,e,n){let r;const o=this.nodeMapByKey.get(t);o!=null&&!o.isRemoved()&&o.remove(n)&&(r=o.getValue());const s=Ea.of(t,e);return this.nodeMapByCreatedAt.set(e.getCreatedAt().toIDString(),s),(o==null||n.after(o.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(t,s),e.setMovedAt(n)),r}delete(t,e){if(!this.nodeMapByCreatedAt.has(t.toIDString()))throw new ne(te.ErrInvalidArgument,`fail to find ${t.toIDString()}`);const n=this.nodeMapByCreatedAt.get(t.toIDString());return n.remove(e),n.getValue()}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return e.getStrKey()}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new ne(te.ErrInvalidArgument,`fail to find ${t.getCreatedAt().toIDString()}`);const n=this.nodeMapByKey.get(e.getStrKey());e===n&&this.nodeMapByKey.delete(n.getStrKey()),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}deleteByKey(t,e){const n=this.nodeMapByKey.get(t);if(n!=null&&n.remove(e))return n.getValue()}has(t){const e=this.nodeMapByKey.get(t);return e==null?!1:!e.isRemoved()}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}get(t){const e=this.nodeMapByKey.get(t);if(!(!e||e.isRemoved()))return e}*[Symbol.iterator](){for(const[,t]of this.nodeMapByKey)yield t}}class xt extends hi{constructor(e,n){super(e);T(this,"memberNodes");this.memberNodes=n}static create(e,n){if(!n)return new xt(e,bo.create());const r=bo.create();for(const[o,s]of Object.entries(n))r.set(o,s.deepcopy(),s.getCreatedAt());return new xt(e,r)}subPathOf(e){return this.memberNodes.subPathOf(e)}purge(e){this.memberNodes.purge(e)}set(e,n,r){return this.memberNodes.set(e,n,r)}delete(e,n){return this.memberNodes.delete(e,n)}deleteByKey(e,n){return this.memberNodes.deleteByKey(e,n)}get(e){const n=this.memberNodes.get(e);return n==null?void 0:n.getValue()}getByID(e){const n=this.memberNodes.getByID(e);return n==null?void 0:n.getValue()}has(e){return this.memberNodes.has(e)}toJSON(){const e=[];for(const[n,r]of this)e.push(`"${Fn(n)}":${r.toJSON()}`);return`{${e.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(const[n,r]of this){const{createdAt:o,value:s,type:u}=r.toJSForTest();e[n]={key:n,createdAt:o,value:s,type:u}}return{createdAt:this.getCreatedAt().toTestString(),value:e,type:"YORKIE_OBJECT"}}getKeys(){const e=Array();for(const[n]of this)e.push(n);return e}toSortedJSON(){var r;const e=Array();for(const[o]of this)e.push(o);const n=[];for(const o of e.sort()){const s=(r=this.memberNodes.get(o))==null?void 0:r.getValue();n.push(`"${Fn(o)}":${s.toSortedJSON()}`)}return`{${n.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const e=xt.create(this.getCreatedAt());for(const n of this.memberNodes)e.memberNodes.set(n.getStrKey(),n.getValue().deepcopy(),this.getPositionedAt());return e.remove(this.getRemovedAt()),e}getDescendants(e){for(const n of this.memberNodes){const r=n.getValue();if(e(r,this))return;r instanceof hi&&r.getDescendants(e)}}*[Symbol.iterator](){const e=new Set;for(const n of this.memberNodes)e.has(n.getStrKey())||(e.add(n.getStrKey()),n.isRemoved()||(yield[n.getStrKey(),n.getValue()]))}}var Ye=(i=>(i.Local="local",i.Remote="remote",i.UndoRedo="undoredo",i))(Ye||{});class fn{constructor(t,e){T(this,"parentCreatedAt");T(this,"executedAt");this.parentCreatedAt=t,this.executedAt=e}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new ne(te.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(t){this.executedAt&&(this.executedAt=this.executedAt.setActor(t))}setExecutedAt(t){this.executedAt=t}}class fu{constructor(t){T(this,"value");T(this,"left");T(this,"right");T(this,"parent");T(this,"weight");this.value=t,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(t){this.left=t}setRight(t){this.right=t}setParent(t){this.parent=t}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(t){this.weight+=t}initWeight(){this.weight=this.getLength()}}class wo{constructor(t){T(this,"root");this.root=t}get length(){return this.root?this.root.getWeight():0}find(t){if(!this.root||t<0)return[void 0,0];let e=this.root;for(;;)if(e.hasLeft()&&t<=e.getLeftWeight())e=e.getLeft();else if(e.hasRight()&&e.getLeftWeight()+e.getLength()e.getLength())throw new ne(te.ErrInvalidArgument,`out of index range: pos: ${t} > node.length: ${e.getLength()}`);return this.splayNode(e),[e,t]}indexOf(t){return!t||t!==this.root&&!t.hasLinks()?-1:(this.splayNode(t),this.root.getLeftWeight())}getRoot(){return this.root}insert(t){return this.insertAfter(this.root,t)}insertAfter(t,e){return t?(this.splayNode(t),this.root=e,e.setRight(t.getRight()),t.hasRight()&&t.getRight().setParent(e),e.setLeft(t),t.setParent(e),t.setRight(),this.updateWeight(t),this.updateWeight(e),e):(this.root=e,e)}updateWeight(t){t.initWeight(),t.hasLeft()&&t.increaseWeight(t.getLeftWeight()),t.hasRight()&&t.increaseWeight(t.getRightWeight())}updateTreeWeight(t){for(;t;)this.updateWeight(t),t=t.getParent()}splayNode(t){if(t)for(;;)if(this.isLeftChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t),this.rotateLeft(t);else if(this.isLeftChild(t.getParent())&&this.isLeftChild(t))this.rotateRight(t.getParent()),this.rotateRight(t);else if(this.isRightChild(t.getParent())&&this.isRightChild(t))this.rotateLeft(t.getParent()),this.rotateLeft(t);else{this.isLeftChild(t)?this.rotateRight(t):this.isRightChild(t)&&this.rotateLeft(t),this.updateWeight(t);return}}delete(t){this.splayNode(t);const e=new wo(t.getLeft());e.root&&e.root.setParent();const n=new wo(t.getRight());if(n.root&&n.root.setParent(),e.root){const r=e.getRightmost();e.splayNode(r),e.root.setRight(n.root),n.root&&n.root.setParent(e.root),this.root=e.root}else this.root=n.root;t.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(t,e){if(!e){this.splayNode(t),this.cutOffRight(t);return}this.splayNode(t),this.splayNode(e),e.getLeft()!=t&&this.rotateRight(t),this.cutOffRight(t)}cutOffRight(t){const e=[];this.traversePostorder(t.getRight(),e);for(const n of e)n.initWeight();this.updateTreeWeight(t)}toTestString(){const t=[];return this.traverseInorder(this.root,t),t.map(e=>`[${e.getWeight()},${e.getLength()}]${e.getValue()||""}`).join("")}checkWeight(){const t=[];this.traverseInorder(this.root,t);for(const e of t)if(e.getWeight()!=e.getLength()+e.getLeftWeight()+e.getRightWeight())return!1;return!0}getRightmost(){let t=this.root;for(;t.hasRight();)t=t.getRight();return t}traverseInorder(t,e){t&&(this.traverseInorder(t.getLeft(),e),e.push(t),this.traverseInorder(t.getRight(),e))}traversePostorder(t,e){t&&(this.traversePostorder(t.getLeft(),e),this.traversePostorder(t.getRight(),e),e.push(t))}rotateLeft(t){const e=t.getParent();e.hasParent()?e===e.getParent().getLeft()?e.getParent().setLeft(t):e.getParent().setRight(t):this.root=t,t.setParent(e.getParent()),e.setRight(t.getLeft()),e.hasRight()&&e.getRight().setParent(e),t.setLeft(e),t.getLeft().setParent(t),this.updateWeight(e),this.updateWeight(t)}rotateRight(t){const e=t.getParent();e.hasParent()?e===e.getParent().getLeft()?e.getParent().setLeft(t):e.getParent().setRight(t):this.root=t,t.setParent(e.getParent()),e.setLeft(t.getRight()),e.hasLeft()&&e.getLeft().setParent(e),t.setRight(e),t.getRight().setParent(t),this.updateWeight(e),this.updateWeight(t)}isLeftChild(t){return t&&t.hasParent()?t.getParent().getLeft()===t:!1}isRightChild(t){return t&&t.hasParent()?t.getParent().getRight()===t:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -19,8 +19,8 @@ var Ku=Object.defineProperty;var Hu=(i,t,e)=>t in i?Ku(i,t,{enumerable:!0,config * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var Kt=null;try{Kt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function Ve(i,t,e){this.low=i|0,this.high=t|0,this.unsigned=!!e}Ve.prototype.__isLong__;Object.defineProperty(Ve.prototype,"__isLong__",{value:!0});function yt(i){return(i&&i.__isLong__)===!0}function vl(i){var t=Math.clz32(i&-i);return i?31-t:t}Ve.isLong=yt;var bl={},wl={};function Pi(i,t){var e,n,r;return t?(i>>>=0,(r=0<=i&&i<256)&&(n=wl[i],n)?n:(e=Ke(i,0,!0),r&&(wl[i]=e),e)):(i|=0,(r=-128<=i&&i<128)&&(n=bl[i],n)?n:(e=Ke(i,i<0?-1:0,!1),r&&(bl[i]=e),e))}Ve.fromInt=Pi;function Ht(i,t){if(isNaN(i))return t?Wr:an;if(t){if(i<0)return Wr;if(i>=hu)return pu}else{if(i<=-Tl)return Et;if(i+1>=Tl)return gu}return i<0?Ht(-i,t).neg():Ke(i%Zi|0,i/Zi|0,t)}Ve.fromNumber=Ht;function Ke(i,t,e){return new Ve(i,t,e)}Ve.fromBits=Ke;var As=Math.pow;function xa(i,t,e){if(i.length===0)throw Error("empty string");if(typeof t=="number"?(e=t,t=!1):t=!!t,i==="NaN"||i==="Infinity"||i==="+Infinity"||i==="-Infinity")return t?Wr:an;if(e=e||10,e<2||360)throw Error("interior hyphen");if(n===0)return xa(i.substring(1),t,e).neg();for(var r=Ht(As(e,8)),o=an,s=0;s>>0:this.low};he.toNumber=function(){return this.unsigned?(this.high>>>0)*Zi+(this.low>>>0):this.high*Zi+(this.low>>>0)};he.toString=function(t){if(t=t||10,t<2||36>>0,y=m.toString(t);if(s=c,s.isZero())return y+u;for(;y.length<6;)y="0"+y;u=""+y+u}};he.getHighBits=function(){return this.high};he.getHighBitsUnsigned=function(){return this.high>>>0};he.getLowBits=function(){return this.low};he.getLowBitsUnsigned=function(){return this.low>>>0};he.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Et)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&!(t&1<=0};he.isOdd=function(){return(this.low&1)===1};he.isEven=function(){return(this.low&1)===0};he.equals=function(t){return yt(t)||(t=hn(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};he.eq=he.equals;he.notEquals=function(t){return!this.eq(t)};he.neq=he.notEquals;he.ne=he.notEquals;he.lessThan=function(t){return this.comp(t)<0};he.lt=he.lessThan;he.lessThanOrEqual=function(t){return this.comp(t)<=0};he.lte=he.lessThanOrEqual;he.le=he.lessThanOrEqual;he.greaterThan=function(t){return this.comp(t)>0};he.gt=he.greaterThan;he.greaterThanOrEqual=function(t){return this.comp(t)>=0};he.gte=he.greaterThanOrEqual;he.ge=he.greaterThanOrEqual;he.compare=function(t){if(yt(t)||(t=hn(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};he.comp=he.compare;he.negate=function(){return!this.unsigned&&this.eq(Et)?Et:this.not().add(Ji)};he.neg=he.negate;he.add=function(t){yt(t)||(t=hn(t));var e=this.high>>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,s=t.high>>>16,u=t.high&65535,c=t.low>>>16,m=t.low&65535,y=0,f=0,l=0,a=0;return a+=o+m,l+=a>>>16,a&=65535,l+=r+c,f+=l>>>16,l&=65535,f+=n+u,y+=f>>>16,f&=65535,y+=e+s,y&=65535,Ke(l<<16|a,y<<16|f,this.unsigned)};he.subtract=function(t){return yt(t)||(t=hn(t)),this.add(t.neg())};he.sub=he.subtract;he.multiply=function(t){if(this.isZero())return this;if(yt(t)||(t=hn(t)),Kt){var e=Kt.mul(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Wr:an;if(this.eq(Et))return t.isOdd()?Et:an;if(t.eq(Et))return this.isOdd()?Et:an;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Sl)&&t.lt(Sl))return Ht(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,s=this.low&65535,u=t.high>>>16,c=t.high&65535,m=t.low>>>16,y=t.low&65535,f=0,l=0,a=0,p=0;return p+=s*y,a+=p>>>16,p&=65535,a+=o*y,l+=a>>>16,a&=65535,a+=s*m,l+=a>>>16,a&=65535,l+=r*y,f+=l>>>16,l&=65535,l+=o*m,f+=l>>>16,l&=65535,l+=s*c,f+=l>>>16,l&=65535,f+=n*y+r*m+o*c+s*u,f&=65535,Ke(a<<16|p,f<<16|l,this.unsigned)};he.mul=he.multiply;he.divide=function(t){if(yt(t)||(t=hn(t)),t.isZero())throw Error("division by zero");if(Kt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?Kt.div_u:Kt.div_s)(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Wr:an;var n,r,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Wr;if(t.gt(this.shru(1)))return du;o=Wr}else{if(this.eq(Et)){if(t.eq(Ji)||t.eq(pa))return Et;if(t.eq(Et))return Ji;var s=this.shr(1);return n=s.div(t).shl(1),n.eq(an)?t.isNegative()?Ji:pa:(r=this.sub(t.mul(n)),o=n.add(r.div(t)),o)}else if(t.eq(Et))return this.unsigned?Wr:an;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=an}for(r=this;r.gte(t);){n=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var u=Math.ceil(Math.log(n)/Math.LN2),c=u<=48?1:As(2,u-48),m=Ht(n),y=m.mul(t);y.isNegative()||y.gt(r);)n-=c,m=Ht(n,this.unsigned),y=m.mul(t);m.isZero()&&(m=Ji),o=o.add(m),r=r.sub(y)}return o};he.div=he.divide;he.modulo=function(t){if(yt(t)||(t=hn(t)),Kt){var e=(this.unsigned?Kt.rem_u:Kt.rem_s)(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};he.mod=he.modulo;he.rem=he.modulo;he.not=function(){return Ke(~this.low,~this.high,this.unsigned)};he.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};he.clz=he.countLeadingZeros;he.countTrailingZeros=function(){return this.low?vl(this.low):vl(this.high)+32};he.ctz=he.countTrailingZeros;he.and=function(t){return yt(t)||(t=hn(t)),Ke(this.low&t.low,this.high&t.high,this.unsigned)};he.or=function(t){return yt(t)||(t=hn(t)),Ke(this.low|t.low,this.high|t.high,this.unsigned)};he.xor=function(t){return yt(t)||(t=hn(t)),Ke(this.low^t.low,this.high^t.high,this.unsigned)};he.shiftLeft=function(t){return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low<>>32-t,this.unsigned):Ke(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):Ke(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};he.shr=he.shiftRight;he.shiftRightUnsigned=function(t){return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?Ke(this.high,0,this.unsigned):Ke(this.high>>>t-32,0,this.unsigned)};he.shru=he.shiftRightUnsigned;he.shr_u=he.shiftRightUnsigned;he.rotateLeft=function(t){var e;return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(e=32-t,Ke(this.low<>>e,this.high<>>e,this.unsigned)):(t-=32,e=32-t,Ke(this.high<>>e,this.low<>>e,this.unsigned))};he.rotl=he.rotateLeft;he.rotateRight=function(t){var e;return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(e=32-t,Ke(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,e=32-t,Ke(this.low<>>t,this.high<>>t,this.unsigned))};he.rotr=he.rotateRight;he.toSigned=function(){return this.unsigned?Ke(this.low,this.high,!1):this};he.toUnsigned=function(){return this.unsigned?this:Ke(this.low,this.high,!0)};he.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};he.toBytesLE=function(){var t=this.high,e=this.low;return[e&255,e>>>8&255,e>>>16&255,e>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};he.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,e>>>24,e>>>16&255,e>>>8&255,e&255]};Ve.fromBytes=function(t,e,n){return n?Ve.fromBytesLE(t,e):Ve.fromBytesBE(t,e)};Ve.fromBytesLE=function(t,e){return new Ve(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};Ve.fromBytesBE=function(t,e){return new Ve(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)};var ht=(i=>(i[i.Null=0]="Null",i[i.Boolean=1]="Boolean",i[i.Integer=2]="Integer",i[i.Long=3]="Long",i[i.Double=4]="Double",i[i.String=5]="String",i[i.Bytes=6]="Bytes",i[i.Date=7]="Date",i))(ht||{});class tt extends ko{constructor(e,n){super(n);T(this,"valueType");T(this,"value");this.valueType=tt.getPrimitiveType(e),this.value=e===void 0?null:e}static of(e,n){return new tt(e,n)}static valueFromBytes(e,n){switch(e){case 0:return null;case 1:return!!n[0];case 2:return n[0]|n[1]<<8|n[2]<<16|n[3]<<24;case 4:{const r=new DataView(n.buffer);return n.forEach(function(o,s){r.setUint8(s,o)}),r.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(n);case 3:return Ve.fromBytesLE(Array.from(n));case 6:return n;case 7:return new Date(Ve.fromBytesLE(Array.from(n),!0).toNumber());default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return this.valueType===5?`"${Fn(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const e=tt.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(e)?2:4;case"string":return 5;case"object":if(e===null)return 0;if(e instanceof Ve)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return tt.getPrimitiveType(e)!==void 0}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===2||e===3||e===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 4:{const e=this.value,n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),n}case 5:return new TextEncoder().encode(this.value);case 3:{const n=this.value.toBytesLE();return Uint8Array.from(n)}case 6:return this.value;case 7:{const e=this.value,n=Ve.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(n)}default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class Ts extends fu{constructor(e){super(e);T(this,"prev");T(this,"next");this.value=e}static createAfter(e,n){const r=new Ts(n),o=e.next;return e.next=r,r.prev=e,r.next=o,o&&(o.prev=r),r}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class Ao{constructor(){T(this,"dummyHead");T(this,"last");T(this,"nodeMapByIndex");T(this,"nodeMapByCreatedAt");const t=tt.of(0,un);t.setRemovedAt(un),this.dummyHead=new Ts(t),this.last=this.dummyHead,this.nodeMapByIndex=new wo,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new Ao}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,e){let n=this.nodeMapByCreatedAt.get(t.toIDString());if(!n)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;n.getNext()&&n.getNext().getPositionedAt().after(e);)n=n.getNext();return n}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,e,n=e.getCreatedAt()){const r=this.findNextBeforeExecutedAt(t,n),o=Ts.createAfter(r,e);r===this.last&&(this.last=o),this.nodeMapByIndex.insertAfter(r,o),this.nodeMapByCreatedAt.set(o.getCreatedAt().toIDString(),o)}moveAfter(t,e,n){const r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const o=this.nodeMapByCreatedAt.get(e.toIDString());if(!o)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);r!==o&&(!o.getValue().getMovedAt()||n.after(o.getValue().getMovedAt()))&&(this.release(o),this.insertAfter(r.getCreatedAt(),o.getValue(),n),o.getValue().setMovedAt(n))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return String(this.nodeMapByIndex.indexOf(e))}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new ne(te.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(e)}getByIndex(t){if(t>=this.length)return;const[e,n]=this.nodeMapByIndex.find(t);let r=e;if(t===0&&e===this.dummyHead||n>0)do r&&(r=r.getNext());while(r&&r.isRemoved());return r}getPrevCreatedAt(t){let e=this.nodeMapByCreatedAt.get(t.toIDString());do e=e.getPrev();while(this.dummyHead!==e&&e.isRemoved());return e.getValue().getCreatedAt()}delete(t,e){const n=this.nodeMapByCreatedAt.get(t.toIDString()),r=n.isRemoved();return n.remove(e)&&!r&&this.nodeMapByIndex.splayNode(n),n.getValue()}deleteByIndex(t,e){const n=this.getByIndex(t);if(n)return n.remove(e)&&this.nodeMapByIndex.splayNode(n),n.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const e of this){const n=`${e.getCreatedAt().toIDString()}:${e.getValue().toJSON()}`;e.isRemoved()?t.push(`{${n}}`):t.push(`[${n}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class Lt extends hi{constructor(e,n){super(e);T(this,"elements");this.elements=n}static create(e,n){if(!n)return new Lt(e,Ao.create());const r=Ao.create();for(const o of n)r.insertAfter(r.getLastCreatedAt(),o.deepcopy());return new Lt(e,r)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,n){this.elements.insertAfter(e,n)}moveAfter(e,n,r){this.elements.moveAfter(e,n,r)}get(e){const n=this.elements.getByIndex(e);return n==null?void 0:n.getValue()}getByID(e){const n=this.elements.getByID(e);return n==null?void 0:n.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,n){return this.elements.delete(e,n)}deleteByIndex(e,n){return this.elements.deleteByIndex(e,n)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(const n of this.elements){const r=n.getValue();if(e(r,this))return;r instanceof hi&&r.getDescendants(e)}}toJSON(){const e=[];for(const n of this)e.push(n.toJSON());return`[${e.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(let n=0;n({...p,value:p.value?{attributes:zi(p.value.getAttributes()),content:p.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[y,a,f,[m,m]]}setStyle(e,n,r,o,s){const[,u]=this.rgaTreeSplit.findNodeWithSplit(e[1],r),[,c]=this.rgaTreeSplit.findNodeWithSplit(e[0],r),m=[],y=this.rgaTreeSplit.findBetween(c,u),f=new Map,l=[];for(const p of y){const b=p.getCreatedAt().getActorID();let w,v=0n;if(s===void 0&&o===void 0?v=fo:s.size()>0?v=s.get(b)?s.get(b):0n:w=o.has(b)?o.get(b):un,p.canStyle(r,w,v)){const h=f.get(b),g=p.getCreatedAt();(!h||g.after(h))&&f.set(b,g),l.push(p)}}const a=[];for(const p of l){if(p.isRemoved())continue;const[b,w]=this.rgaTreeSplit.findIndexesFromRange(p.createPosRange());m.push({type:"style",actor:r.getActorID(),from:b,to:w,value:{attributes:zi(n)}});for(const[v,h]of Object.entries(n)){const[g]=p.getValue().setAttr(v,h,r);g!==void 0&&a.push({parent:p.getValue(),child:g})}}return[f,a,m]}indexRangeToPosRange(e,n){const r=this.rgaTreeSplit.indexToPos(e);return e===n?[r,r]:[r,this.rgaTreeSplit.indexToPos(n)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const e=[];for(const n of this.rgaTreeSplit)n.isRemoved()||e.push(n.getValue().toJSON());return`[${e.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const e=[];for(const n of this.rgaTreeSplit)if(!n.isRemoved()){const r=n.getValue();e.push({attributes:zi(r.getAttributes()),content:r.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const e=new Gt(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){const e=[];for(const n of this.rgaTreeSplit){n.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:n});for(const r of n.getValue().getGCPairs())e.push(r)}return e}}class Io extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"content");T(this,"attributes");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.content=s,this.attributes=u}static create(e,n,r,o,s,u,c){return new Io(e,n,r,o,s,u,c)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Gt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Text can execute edit");const s=o,[,u,c]=s.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(const m of c)e.registerGCPair(m);return{opInfos:u.map(({from:m,to:y,value:f})=>({type:"edit",from:m,to:y,value:f,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=this.fromPos.toTestString(),r=this.toPos.toTestString(),o=this.content;return`${e}.EDIT(${n},${r},${o})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class No extends fn{constructor(e,n,r,o,s,u){super(e,u);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"attributes");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.attributes=s}static create(e,n,r,o,s,u){return new No(e,n,r,o,s,u)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Gt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Text can execute edit");const s=o,[,u,c]=s.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(const m of u)e.registerGCPair(m);return{opInfos:c.map(({from:m,to:y,value:f})=>({type:"style",from:m,to:y,value:f,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=this.fromPos.toTestString(),r=this.toPos.toTestString(),o=this.attributes;return`${e}.STYL(${n},${r},${JSON.stringify(o)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const Sf=2,Ef="root",Gr="text";function so(i,t){let e=0;const n=i.children;for(let r=0;r0)throw new ne(te.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const e=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*e,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const e of this._children){const n=e.updateDescendantsSize();e.isRemoved||(t+=n)}return this.size+=t,this.paddedSize}get isText(){return this.type===Gr}get paddedSize(){return this.size+(this.isText?0:Sf)}isAncestorOf(t){return kf(this,t)}get nextSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t+1];if(e)return e}get prevSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t-1];if(e)return e}splitText(t,e){if(t===0||t===this.size)return;const n=this.value.slice(0,t),r=this.value.slice(t);if(!r.length)return;this.value=n;const o=this.cloneText(t+e);return o.value=r,this.parent.insertAfterInternal(o,this),o}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const e of t)e.parent=this,e.updateAncestorsSize()}prepend(...t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const e of t)e.parent=this}insertBefore(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n),t.updateAncestorsSize()}insertAfter(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n+1),t.updateAncestorsSize()}insertAt(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,e),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const e=this._children.indexOf(t);if(e===-1)throw new ne(te.ErrInvalidArgument,"child not found");this._children.splice(e,1),t.parent=void 0}splitElement(t,e){const n=this.cloneElement(e);this.parent.insertAfterInternal(n,this),n.updateAncestorsSize();const r=this.children.slice(0,t),o=this.children.slice(t);this._children=r,n._children=o,this.size=this._children.reduce((s,u)=>s+u.paddedSize,0),n.size=n._children.reduce((s,u)=>s+u.paddedSize,0);for(const s of n._children)s.parent=n;return n}insertAfterInternal(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n+1)}insertAtInternal(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.splice(e,0,t),t.parent=this}findOffset(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");if(t.isRemoved){const e=this._children.indexOf(t);return this.allChildren.splice(0,e).filter(r=>!r.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");let e=t;for(;e;){const n=this._children.indexOf(e);if(n!==-1)return n;e=e.parent}return-1}}function kf(i,t){if(i===t)return!1;for(;t.parent;){if(t.parent===i)return!0;t=t.parent}return!1}var ct=(i=>(i.Start="Start",i.End="End",i.Text="Text",i))(ct||{});function mu(i,t,e,n){if(t>e)throw new ne(te.ErrInvalidArgument,`from is greater than to: ${t} > ${e}`);if(t>i.size)throw new ne(te.ErrInvalidArgument,`from is out of range: ${t} > ${i.size}`);if(e>i.size)throw new ne(te.ErrInvalidArgument,`to is out of range: ${e} > ${i.size}`);if(t===e)return;let r=0;for(const o of i.children){if(t-o.paddedSizeo.size;(o.isText||c)&&n([o,o.isText?"Text":"Start"],m),mu(o,Math.max(0,s),Math.min(u,o.size),n),m&&n([o,"End"],m)}r+=o.paddedSize}}function yu(i,t,e=0){for(const n of i.children)yu(n,t,e+1);t(i,e)}function Is(i,t,e=0){for(const n of i._children)Is(n,t,e+1);t(i,e)}function ma(i,t,e=!0){if(t>i.size)throw new ne(te.ErrInvalidArgument,`index is out of range: ${t} > ${i.size}`);if(i.isText)return{node:i,offset:t};let n=0,r=0;for(const o of i.children){if(e&&o.isText&&o.size>=t-r)return ma(o,t-r,e);if(t===r)return{node:i,offset:n};if(!e&&o.paddedSize===t-r)return{node:i,offset:n+1};if(o.paddedSize>t-r)return ma(o,t-r-1,e);r+=o.paddedSize,n+=1}return{node:i,offset:n}}function vu(i){return i.isText||i.children.length===0?i:vu(i.children[0])}function Of(i,t){if(i.sizei===t?0:i0)if(e.right)e.right.parent=e,e=e.right;else return e;else if(n<0)if(e.left)e.left.parent=e,e=e.left;else{let r=e.parent,o=e;for(;r&&o===r.left;)o=r,r=r.parent;return r}else return e}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,e){for(;e;){const n=this.comparator(t,e.key);if(n===0)return e;n<0?e=e.left:n>0&&(e=e.right)}}putInternal(t,e,n){if(!n)return this.counter+=1,new _f(t,e,!0);const r=this.comparator(t,n.key);return r<0?n.left=this.putInternal(t,e,n.left):r>0?n.right=this.putInternal(t,e,n.right):n.value=e,this.isRed(n.right)&&!this.isRed(n.left)&&(n=this.rotateLeft(n)),this.isRed(n.left)&&this.isRed(n.left.left)&&(n=this.rotateRight(n)),this.isRed(n.left)&&this.isRed(n.right)&&this.flipColors(n),n}removeInternal(t,e){if(this.comparator(e,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,e);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(e,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(e,t.key)===0){this.counter-=1;const n=this.min(t.right);t.value=n.value,t.key=n.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,e)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const e=t.right;return t.right=e.left,e.left=t,e.isRed=e.left.isRed,e.left.isRed=!0,e}rotateRight(t){const e=t.left;return t.left=e.right,e.right=t,e.isRed=e.right.isRed,e.right.isRed=!0,e}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class ln{constructor(t,e){T(this,"parentID");T(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=e}static of(t,e){return new ln(t,e)}static fromTreePos(t){const{offset:e}=t;let{node:n}=t,r;return n.isText?(n.parent.children[0]===n&&e===0?r=n.parent:r=n,n=n.parent):e===0?r=n:r=n.children[e-1],ln.of(n.id,pt.of(r.getCreatedAt(),r.getOffset()+e))}getParentID(){return this.parentID}static fromStruct(t){return ln.of(pt.of(Wt.fromStruct(t.parentID.createdAt),t.parentID.offset),pt.of(Wt.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const e=this.getParentID(),n=this.getLeftSiblingID(),r=t.findFloorNode(e);let o=t.findFloorNode(n);if(!r||!o)throw new ne(te.ErrRefused,`cannot find node of CRDTTreePos(${e.toTestString()}, ${n.toTestString()})`);return!n.equals(e)&&n.getOffset()>0&&n.getOffset()===o.id.getOffset()&&o.insPrevID&&(o=t.findFloorNode(o.insPrevID)),[r,o]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class pt{constructor(t,e){T(this,"createdAt");T(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new pt(t,e)}static fromStruct(t){return pt.of(Wt.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,e)=>{const n=t.getCreatedAt().compare(e.getCreatedAt());return n!==0?n:t.getOffset()>e.getOffset()?1:t.getOffset(){const o=r.deepcopy();return o.parent=e,o}),e.insPrevID=this.insPrevID,e.insNextID=this.insNextID,e}get value(){if(!this.isText)throw new ne(te.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(e){if(!this.isText)throw new ne(te.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){const n=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),n&&this.updateAncestorsSize()}cloneText(e){return new Ct(pt.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new Ct(pt.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,n,r){const o=this.isText?this.splitText(n,this.id.getOffset()):this.splitElement(n,r);if(o){if(o.insPrevID=this.id,this.insNextID){const s=e.findFloorNode(this.insNextID);s.insPrevID=o.id,o.insNextID=this.insNextID}this.insNextID=o.id,e.registerNode(o)}return o}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,n,r){return(n?!this.getCreatedAt().after(n):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,n,r){return this.isText?!1:(n?!this.getCreatedAt().after(n):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,n){this.attrs||(this.attrs=new Xr);const r=[];for(const[o,s]of Object.entries(e))r.push(this.attrs.set(o,s,n));return r}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){const e=[];if(!this.attrs)return e;for(const n of this.attrs)n.getRemovedAt()&&e.push({parent:this,child:n});return e}}function ya(i){var e;if(i.isText){const n=i;return{type:n.type,value:n.value}}const t={type:i.type,children:i.children.map(ya)};return i.attrs&&(t.attributes=zi((e=i.attrs)==null?void 0:e.toObject())),t}function ka(i){if(i.isText)return i.value;let t="";return i.attrs&&i.attrs.size()&&(t=" "+Array.from(i.attrs).filter(e=>!e.isRemoved()).sort((e,n)=>e.getKey().localeCompare(n.getKey())).map(e=>{const n=JSON.parse(e.getValue());return typeof n=="string"?`${e.getKey()}="${n}"`:`${e.getKey()}="${Fn(e.getValue())}"`}).join(" ")),`<${i.type}${t}>${i.children.map(e=>ka(e)).join("")}`}function wu(i){if(i.isText){const t=i;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:i.type,children:i.children.map(wu),size:i.size,isRemoved:i.isRemoved}}class Yt extends ko{constructor(e,n){super(n);T(this,"indexTree");T(this,"nodeMapByID");this.indexTree=new If(e),this.nodeMapByID=new bu(pt.createComparator()),this.indexTree.traverseAll(r=>{this.nodeMapByID.put(r.id,r)})}static create(e,n){return new Yt(e,n)}findFloorNode(e){const n=this.nodeMapByID.floorEntry(e);if(!(!n||!n.key.getCreatedAt().equals(e.getCreatedAt())))return n.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,n){const[r,o]=e.toTreeNodePair(this);let s=o;const u=r===s,c=s.parent&&!u?s.parent:r;if(s.isText&&s.split(this,e.getLeftSiblingID().getOffset()-s.id.getOffset()),n){const m=c.allChildren,y=u?0:m.indexOf(s)+1;for(let f=y;f{const w=b.getCreatedAt().getActorID();let v,h=0n;if(s===void 0&&o===void 0?h=fo:s.size()>0?h=s.get(w)?s.get(w):0n:v=o.has(w)?o.get(w):un,b.canStyle(r,v,h)&&n){const g=a.get(w),d=b.getCreatedAt();(!g||d.after(g))&&a.set(w,d);const A=b.setAttrs(n,r),S=A.reduce((_,[,k])=>(k&&(_[k.getKey()]=l[k.getKey()]),_),{}),E=b.parent,O=b.prevSibling||b.parent;Object.keys(S).length>0&&f.push({type:"style",from:this.toIndex(E,O),to:this.toIndex(b,b),fromPath:this.toPath(E,O),toPath:this.toPath(b,b),actor:r.getActorID(),value:S});for(const[_]of A)_&&p.push({parent:b,child:_})}}),[a,p,f]}removeStyle(e,n,r,o,s){const[u,c]=this.findNodesAndSplitText(e[0],r),[m,y]=this.findNodesAndSplitText(e[1],r),f=[],l=new Map,a=[];return this.traverseInPosRange(u,c,m,y,([p])=>{const b=p.getCreatedAt().getActorID();let w,v=0n;if(s===void 0&&o===void 0?v=fo:s.size()>0?v=s.get(b)?s.get(b):0n:w=o.has(b)?o.get(b):un,p.canStyle(r,w,v)&&n){const h=l.get(b),g=p.getCreatedAt();(!h||g.after(h))&&l.set(b,g),p.attrs||(p.attrs=new Xr);for(const S of n){const E=p.attrs.remove(S,r);for(const O of E)a.push({parent:p,child:O})}const d=p.parent,A=p.prevSibling||p.parent;f.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(d,A),to:this.toIndex(p,p),fromPath:this.toPath(d,A),toPath:this.toPath(p,p),value:n})}}),[l,a,f]}edit(e,n,r,o,s,u,c){const[m,y]=this.findNodesAndSplitText(e[0],o),[f,l]=this.findNodesAndSplitText(e[1],o),a=this.toIndex(m,y),p=this.toPath(m,y),b=[],w=[],v=[],h=new Map;this.traverseInPosRange(m,y,f,l,([A,S],E)=>{if(S===ct.Start&&!E)for(const x of A.children)v.push(x);const O=A.getCreatedAt().getActorID();let _,k=0n;if(c===void 0&&u===void 0?k=fo:c.size()>0?k=c.get(O)?c.get(O):0n:_=u.has(O)?u.get(O):un,A.canDelete(o,_,k)||b.includes(A.parent)){const x=h.get(O),I=A.getCreatedAt();(!x||I.after(x))&&h.set(O,I),(S===ct.Text||S===ct.Start)&&b.push(A),w.push([A,S])}});const g=this.makeDeletionChanges(w,o),d=[];for(const A of b)A.remove(o),A.isRemoved&&d.push({parent:this,child:A});for(const A of v)A.removedAt||m.append(A);if(r>0){let A=0,S=m,E=y;for(;A{m.isRemoved&&(O.remove(o),d.push({parent:this,child:O})),this.nodeMapByID.put(O.id,O)}),E.isRemoved||A.push(E);if(A.length){const E=A.map(O=>ya(O));g.length&&g[g.length-1].from===a?g[g.length-1].value=E:g.push({type:"content",from:a,to:a,fromPath:p,toPath:p,actor:o.getActorID(),value:E})}}return[g,d,h]}editT(e,n,r,o,s){const u=this.findPos(e[0]),c=this.findPos(e[1]);this.edit([u,c],n,r,o,s)}move(e,n,r){throw new ne(te.ErrUnimplemented,`not implemented: ${e}, ${n}, ${r}`)}purge(e){var o;(o=e.parent)==null||o.removeChild(e),this.nodeMapByID.remove(e.id);const n=e.insPrevID,r=e.insNextID;if(n){const s=this.findFloorNode(n);s.insNextID=r}if(r){const s=this.findFloorNode(r);s.insPrevID=n}e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){const e=[];return this.indexTree.traverse(n=>{n.getRemovedAt()&&e.push({parent:this,child:n});for(const r of n.getGCPairs())e.push(r)}),e}findPos(e,n=!0){const r=this.indexTree.findTreePos(e,n);return ln.fromTreePos(r)}pathToPosRange(e){const n=this.pathToIndex(e);return[this.findPos(n),this.findPos(n+1)]}pathToPos(e){const n=this.indexTree.pathToIndex(e);return this.findPos(n)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ka(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const e=this.indexTree.getRoot(),n=(r,o=void 0,s=void 0,u=0)=>{var a,p,b,w;let c,m,y;const f=r.isText?{node:r,offset:0}:o&&s?this.toTreePos(o,s):null;f&&(c=this.indexTree.indexOf(f),m=this.indexTree.treePosToPath(f),y=ln.fromTreePos(f).toStruct());const l={type:r.type,parent:o==null?void 0:o.id.toTestString(),size:r.size,id:r.id.toTestString(),removedAt:(a=r.removedAt)==null?void 0:a.toTestString(),insPrev:(p=r.insPrevID)==null?void 0:p.toTestString(),insNext:(b=r.insNextID)==null?void 0:b.toTestString(),value:r.isText?r.value:void 0,isRemoved:r.isRemoved,children:[],depth:u,attributes:r.attrs?zi((w=r.attrs)==null?void 0:w.toObject()):void 0,index:c,path:m,pos:y};for(let v=0;v0&&v===r[r.length-1].to?(r[r.length-1].to=h,r[r.length-1].toPath=this.toPath(w,a)):r.push({type:"content",from:v,to:h,fromPath:this.toPath(b,f),toPath:this.toPath(w,a),actor:n.getActorID()}))}return r.reverse()}findRightToken([e,n]){if(n===ct.Start){const c=e.allChildren;return c.length>0?[c[0],c[0].isText?ct.Text:ct.Start]:[e,ct.End]}const r=e.parent,o=r.allChildren,s=o.indexOf(e);if(r&&s===o.length-1)return[r,ct.End];const u=o[s+1];return[u,u.isText?ct.Text:ct.Start]}findLeftToken([e,n]){if(n===ct.End){const c=e.allChildren;if(c.length>0){const m=c[c.length-1];return[m,m.isText?ct.Text:ct.End]}return[e,ct.Start]}const r=e.parent,o=r.allChildren,s=o.indexOf(e);if(r&&s===0)return[r,ct.Start];const u=o[s-1];return[u,u.isText?ct.Text:ct.End]}}class _o extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"contents");T(this,"splitLevel");T(this,"maxCreatedAtMapByActor");this.fromPos=n,this.toPos=r,this.contents=o,this.splitLevel=s,this.maxCreatedAtMapByActor=u}static create(e,n,r,o,s,u,c){return new _o(e,n,r,o,s,u,c)}execute(e,n,r){var y;const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Yt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const s=this.getExecutedAt(),u=o,[c,m]=u.edit([this.fromPos,this.toPos],(y=this.contents)==null?void 0:y.map(f=>f.deepcopy()),this.splitLevel,s,(()=>{let f=s.getDelimiter();return this.contents!==void 0&&(f+=this.contents.length),()=>Wt.of(s.getLamport(),++f,s.getActorID())})(),this.maxCreatedAtMapByActor,r);for(const f of m)e.registerGCPair(f);return{opInfos:c.map(({from:f,to:l,value:a,splitLevel:p,fromPath:b,toPath:w})=>({type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:f,to:l,value:a,splitLevel:p,fromPath:b,toPath:w}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,o=this.contents||[];return`${e}.EDIT(${n},${r},${o.map(s=>ka(s)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Vi{constructor(t){T(this,"vector");this.vector=t||new Map}set(t,e){this.vector.set(t,e)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,e]of this)e>t&&(t=e);return t}max(t){const e=new Map;for(const[n,r]of t){const o=this.vector.get(n),s=o&&o>r?o:r;e.set(n,s)}for(const[n,r]of this){const o=t.get(n),s=o&&o>r?o:r;e.set(n,s)}return new Vi(e)}afterOrEqual(t){const e=this.vector.get(t.getActorID());return e===void 0?!1:e>=t.getLamport()}deepcopy(){const t=new Map;for(const[e,n]of this.vector)t.set(e,n);return new Vi(t)}filter(t){const e=new Map;for(const[n]of t){const r=this.vector.get(n);r!==void 0&&e.set(n,r)}return new Vi(e)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,e]of this.vector)yield[t,e]}}const Cf=new Vi(new Map);class zr{constructor(t,e,n,r,o){T(this,"clientSeq");T(this,"serverSeq");T(this,"lamport");T(this,"actor");T(this,"versionVector");this.clientSeq=t,this.serverSeq=o,this.lamport=e,this.versionVector=r,this.actor=n}static of(t,e,n,r,o){return new zr(t,e,n,r,o)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new zr(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const e=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n,n=this.versionVector.max(t.versionVector),r=new zr(this.clientSeq,e,this.actor,n);return r.versionVector.set(this.actor,e),r}setClocks(t,e){const n=t>this.lamport?t:this.lamport+1n,r=this.versionVector.max(e);return r.set(this.actor,n),zr.of(this.clientSeq,n,this.actor,r)}createTimeTicket(t){return Wt.of(this.lamport,t,this.actor)}setActor(t){return new zr(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new zr(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const Lf=new zr(0,0n,Sa,Cf);class Xi{constructor({id:t,operations:e,presenceChange:n,message:r}){T(this,"id");T(this,"operations");T(this,"presenceChange");T(this,"message");this.id=t,this.operations=e||[],this.presenceChange=n,this.message=r}static create({id:t,operations:e,presenceChange:n,message:r}){return new Xi({id:t,operations:e,presenceChange:n,message:r})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const e of this.operations)e.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,e,n){const r=[],o=[];for(const s of this.operations){const u=s.execute(t,n,this.id.getVersionVector());if(!u)continue;const{opInfos:c,reverseOp:m}=u;r.push(...c),m&&o.unshift(m)}return this.presenceChange&&(this.presenceChange.type===pi.Put?e.set(this.id.getActorID(),sn(this.presenceChange.presence)):e.delete(this.id.getActorID())),{opInfos:r,reverseOps:o}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:lt.bytesToHex(lt.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>lt.bytesToHex(lt.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:e,operations:n,presenceChange:r,message:o}=t;return Xi.create({id:lt.bytesToChangeID(lt.hexToBytes(e)),operations:n==null?void 0:n.map(s=>lt.bytesToOperation(lt.hexToBytes(s))),presenceChange:r,message:o})}}class Ns{constructor(t,e,n,r,o,s,u){T(this,"documentKey");T(this,"checkpoint");T(this,"isRemoved");T(this,"changes");T(this,"snapshot");T(this,"minSyncedTicket");T(this,"versionVector");this.documentKey=t,this.checkpoint=e,this.isRemoved=n,this.changes=r,this.snapshot=s,this.minSyncedTicket=u,this.versionVector=o}static create(t,e,n,r,o,s,u){return new Ns(t,e,n,r,o,s,u)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Ki{constructor(t,e){T(this,"serverSeq");T(this,"clientSeq");this.serverSeq=t,this.clientSeq=e}static of(t,e){return new Ki(t,e)}increaseClientSeq(t){return t===0?this:new Ki(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const e=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,n=Math.max(this.clientSeq,t.clientSeq);return Ki.of(e,n)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const Rf=new Ki(0n,0);class jn{constructor(t,e){T(this,"createdAt");T(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new jn(t,e)}static fromStruct(t){return jn.of(Wt.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new jn(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Df=jn.of(un,0);class cn{constructor(t,e){T(this,"id");T(this,"relativeOffset");this.id=t,this.relativeOffset=e}static of(t,e){return new cn(t,e)}static fromStruct(t){const e=jn.fromStruct(t.id);return cn.of(e,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return jn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class di extends fu{constructor(e,n,r){super(n);T(this,"id");T(this,"removedAt");T(this,"prev");T(this,"next");T(this,"insPrev");T(this,"insNext");this.id=e,this.removedAt=r}static create(e,n){return new di(e,n)}static createComparator(){return(e,n)=>{const r=e.getCreatedAt().compare(n.getCreatedAt());return r!==0?r:e.getOffset()>n.getOffset()?1:e.getOffset()0&&e.getID().getOffset()==t.getOffset()){if(!e.hasInsPrev())return e;e=e.getInsPrev()}return e}findFloorNode(t){const e=this.treeByID.floorEntry(t);if(e&&!(!e.key.equals(t)&&!e.key.hasSameCreatedAt(t)))return e.value}findBetween(t,e){const n=[];let r=t;for(;r&&r!==e;)n.push(r),r=r.getNext();return n}splitNode(t,e){if(e>t.getContentLength())throw new ne(te.ErrInvalidArgument,"offset should be less than or equal to length");if(e===0)return t;if(e===t.getContentLength())return t.getNext();const n=t.split(e);this.treeByIndex.updateWeight(n),this.insertAfter(t,n);const r=t.getInsNext();return r&&r.setInsPrev(n),n.setInsPrev(t),n}deleteNodes(t,e,n,r){if(!t.length)return[[],new Map,new Map];const[o,s]=this.filterNodes(t,e,n,r),u=new Map,c=new Map,m=this.makeChanges(s,e);for(const y of o){const f=y.getCreatedAt().getActorID();(!u.has(f)||y.getID().getCreatedAt().after(u.get(f)))&&u.set(f,y.getID().getCreatedAt()),c.set(y.getID().toIDString(),y),y.remove(e)}return this.deleteIndexNodes(s),[m,u,c]}filterNodes(t,e,n,r){const o=[],s=[],[u,c]=this.findEdgesOfCandidates(t);s.push(u);for(const m of t){const y=m.getCreatedAt().getActorID();let f,l=0n;r===void 0&&n===void 0?l=fo:r.size()>0?l=r.get(y)?r.get(y):0n:f=n.has(y)?n.get(y):un,m.canDelete(e,f,l)?o.push(m):s.push(m)}return s.push(c),[o,s]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,e){const n=[];let r,o;for(let s=0;si<0?Math.ceil(i):Math.floor(i);var Un=(i=>(i[i.IntegerCnt=0]="IntegerCnt",i[i.LongCnt=1]="LongCnt",i))(Un||{});class Rt extends ko{constructor(e,n,r){super(r);T(this,"valueType");T(this,"value");switch(this.valueType=e,e){case 0:typeof n=="number"?n>Math.pow(2,31)-1||n<-Math.pow(2,31)?this.value=Ve.fromNumber(n).toInt():this.value=El(n):this.value=n.toInt();break;case 1:typeof n=="number"?this.value=Ve.fromNumber(n):this.value=n;break;default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}static create(e,n,r){return new Rt(e,n,r)}static valueFromBytes(e,n){switch(e){case 0:return n[0]|n[1]<<8|n[2]<<16|n[3]<<24;case 1:return Ve.fromBytesLE(Array.from(n));default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const e=Rt.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":return e instanceof Ve?1:void 0;case"number":return e>Math.pow(2,31)-1||e<-Math.pow(2,31)?1:0;default:return}}static isSupport(e){return!!Rt.getCounterType(e)}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===0||e===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 1:{const n=this.value.toBytesLE();return Uint8Array.from(n)}default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(e){function n(r){if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`)}return n(this),n(e),this.valueType===1?this.value=this.value.add(e.getValue()):e.getType()===ht.Long?this.value=this.value+e.getValue().toInt():this.value=Ve.fromNumber(this.value+El(e.getValue())).toInt(),this}}class eo extends fn{constructor(e,n,r){super(e,r);T(this,"value");this.value=n}static create(e,n,r){return new eo(e,n,r)}execute(e){const n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(n instanceof Rt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const r=n,o=this.value.deepcopy();return r.increase(o),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:o.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const e=this.value.deepcopy(),r=e.getType()===ht.Long?e.getValue().multiply(-1):e.getValue()*-1;return eo.create(this.getParentCreatedAt(),tt.of(r,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Yr extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"attributes");T(this,"attributesToRemove");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.attributes=s,this.attributesToRemove=u}static create(e,n,r,o,s,u){return new Yr(e,n,r,o,s,[],u)}static createTreeRemoveStyleOperation(e,n,r,o,s,u){return new Yr(e,n,r,o,new Map,s,u)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Yt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const s=o;let u,c;if(this.attributes.size){const m={};[...this.attributes].forEach(([y,f])=>m[y]=f),[,c,u]=s.style([this.fromPos,this.toPos],m,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{const m=this.attributesToRemove;[,c,u]=s.removeStyle([this.fromPos,this.toPos],m,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(const m of c)e.registerGCPair(m);return{opInfos:u.map(({from:m,to:y,value:f,fromPath:l,toPath:a})=>({type:"tree-style",from:m,to:y,value:this.attributes.size?{attributes:f}:{attributesToRemove:f},fromPath:l,toPath:a,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${e}.STYLE(${n},${r},${Object.entries(this.attributes||{}).map(([o,s])=>`${o}:"${s}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Bf(i){const t=new Ta,e=t.data;for(const[n,r]of Object.entries(i))e[n]=JSON.stringify(r);return t}function Mf(i){if(i.type===pi.Put)return new vo({type:Ni.PUT,presence:Bf(i.presence)});if(i.type===pi.Clear)return new vo({type:Ni.CLEAR});throw new ne(te.ErrUnimplemented,"unimplemented type")}function qf(i){return new lu({serverSeq:i.getServerSeq(),clientSeq:i.getClientSeq()})}function Au(i){return new ks({clientSeq:i.getClientSeq(),lamport:i.getLamport(),actorId:Ma(i.getActorID()),versionVector:Oa(i.getVersionVector())})}function ke(i){if(i)return new xe({lamport:i.getLamport(),delimiter:i.getDelimiter(),actorId:Ma(i.getActorID())})}function Oa(i){if(!i)return;const t=new Os;for(const[e,n]of i)t.vector[e]=BigInt(n.toString());return t}function Tu(i){switch(i){case ht.Null:return Re.NULL;case ht.Boolean:return Re.BOOLEAN;case ht.Integer:return Re.INTEGER;case ht.Long:return Re.LONG;case ht.Double:return Re.DOUBLE;case ht.String:return Re.STRING;case ht.Bytes:return Re.BYTES;case ht.Date:return Re.DATE;default:throw new ne(te.ErrInvalidType,`unsupported type: ${i}`)}}function Su(i){switch(i){case Un.IntegerCnt:return Re.INTEGER_CNT;case Un.LongCnt:return Re.LONG_CNT;default:throw new ne(te.ErrInvalidType,`unsupported type: ${i}`)}}function Fs(i){if(i instanceof xt)return new Bt({type:Re.JSON_OBJECT,createdAt:ke(i.getCreatedAt()),value:Bu(i)});if(i instanceof Lt)return new Bt({type:Re.JSON_ARRAY,createdAt:ke(i.getCreatedAt()),value:ph(i)});if(i instanceof Gt)return new Bt({type:Re.TEXT,createdAt:ke(i.getCreatedAt())});if(i instanceof tt)return new Bt({type:Tu(i.getType()),createdAt:ke(i.getCreatedAt()),value:i.toBytes()});if(i instanceof Rt)return new Bt({type:Su(i.getType()),createdAt:ke(i.getCreatedAt()),value:i.toBytes()});if(i instanceof Yt)return new Bt({type:Re.TREE,createdAt:ke(i.getCreatedAt()),value:yh(i)});throw new ne(te.ErrUnimplemented,"unimplemented element")}function Ff(i){return new mo({createdAt:ke(i.getCreatedAt()),offset:i.getOffset()})}function Uo(i){return new Zr({createdAt:ke(i.getID().getCreatedAt()),offset:i.getID().getOffset(),relativeOffset:i.getRelativeOffset()})}function Jo(i){return new Ii({parentId:ho(i.getParentID()),leftSiblingId:ho(i.getLeftSiblingID())})}function ho(i){return new fi({createdAt:ke(i.getCreatedAt()),offset:i.getOffset()})}function Eu(i){const t=new Aa;if(i instanceof _i){const e=i,n=new rs;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.key=e.getKey(),n.value=Fs(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="set",t.body.value=n}else if(i instanceof Oo){const e=i,n=new is;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.prevCreatedAt=ke(e.getPrevCreatedAt()),n.value=Fs(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="add",t.body.value=n}else if(i instanceof ci){const e=i,n=new os;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.prevCreatedAt=ke(e.getPrevCreatedAt()),n.createdAt=ke(e.getCreatedAt()),n.executedAt=ke(e.getExecutedAt()),t.body.case="move",t.body.value=n}else if(i instanceof mi){const e=i,n=new ss;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.createdAt=ke(e.getCreatedAt()),n.executedAt=ke(e.getExecutedAt()),t.body.case="remove",t.body.value=n}else if(i instanceof Io){const e=i,n=new as;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Uo(e.getFromPos()),n.to=Uo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);n.content=e.getContent();const o=n.attributes;for(const[s,u]of e.getAttributes())o[s]=u;n.executedAt=ke(e.getExecutedAt()),t.body.case="edit",t.body.value=n}else if(i instanceof No){const e=i,n=new ls;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Uo(e.getFromPos()),n.to=Uo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);const o=n.attributes;for(const[s,u]of e.getAttributes())o[s]=u;n.executedAt=ke(e.getExecutedAt()),t.body.case="style",t.body.value=n}else if(i instanceof eo){const e=i,n=new us;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.value=Fs(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="increase",t.body.value=n}else if(i instanceof _o){const e=i,n=new cs,r=n.createdAtMapByActor;for(const[o,s]of e.getMaxCreatedAtMapByActor())r[o]=ke(s);n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Jo(e.getFromPos()),n.to=Jo(e.getToPos()),n.contents=Kf(e.getContents()),n.splitLevel=e.getSplitLevel(),n.executedAt=ke(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=n}else if(i instanceof Yr){const e=i,n=new fs;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Jo(e.getFromPos()),n.to=Jo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);const o=e.getAttributesToRemove();if(o.length>0)n.attributesToRemove=o;else{const s=n.attributes;for(const[u,c]of e.getAttributes())s[u]=c}n.executedAt=ke(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=n}else throw new ne(te.ErrUnimplemented,"unimplemented operation");return t}function jf(i){const t=[];for(const e of i)t.push(Eu(e));return t}function Uf(i){const t=new su({id:Au(i.getID()),message:i.getMessage()});return i.hasOperations()&&(t.operations=jf(i.getOperations())),i.hasPresenceChange()&&(t.presenceChange=Mf(i.getPresenceChange())),t}function Jf(i){const t=[];for(const e of i)t.push(Uf(e));return t}function $f(i){const t=[];for(const e of i)t.push(new au({key:e.getStrKey(),element:Na(e.getValue())}));return t}function zf(i){const t=[];for(const e of i)t.push(new vs({element:Na(e.getValue())}));return t}function Vf(i){const t=[];for(const e of i){const n=new bs;n.id=Ff(e.getID()),n.value=e.getValue().getContent(),n.removedAt=ke(e.getRemovedAt());const r=n.attributes,o=e.getValue().getAttrs();for(const s of o){const u=new Gi;u.value=s.getValue(),u.updatedAt=ke(s.getUpdatedAt()),r[s.getKey()]=u}t.push(n)}return t}function Kf(i){const t=[];if(!i||!i.length)return t;for(const e of i)t.push(new ws({content:Ia(e)}));return t}function Hf(i){const t={};for(const e of i)t[e.getKey()]=new Gi({value:e.getValue(),updatedAt:ke(e.getUpdatedAt()),isRemoved:e.isRemoved()});return t}function Ia(i){if(!i)return[];const t=[];return Is(i,(e,n)=>{const r=new yo({id:ho(e.id),type:e.type,removedAt:ke(e.removedAt),depth:n});e.isText&&(r.value=e.value),e.insPrevID&&(r.insPrevId=ho(e.insPrevID)),e.insNextID&&(r.insNextId=ho(e.insNextID)),e.attrs&&(r.attributes=Hf(e.attrs)),t.push(r)}),t}function Wf(i){const t=new kt;return t.body.case="jsonObject",t.body.value=new hs({nodes:$f(i.getRHT()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function xu(i){const t=new kt;return t.body.case="jsonArray",t.body.value=new ds({nodes:zf(i.getElements()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Gf(i){const t=new kt;return t.body.case="primitive",t.body.value=new gs({type:Tu(i.getType()),value:i.toBytes(),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Yf(i){const t=new kt;return t.body.case="text",t.body.value=new ps({nodes:Vf(i.getRGATreeSplit()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Zf(i){const t=new kt;return t.body.case="counter",t.body.value=new ms({type:Su(i.getType()),value:i.toBytes(),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function ku(i){const t=new kt;return t.body.case="tree",t.body.value=new ys({nodes:Ia(i.getRoot()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Na(i){if(i instanceof xt)return Wf(i);if(i instanceof Lt)return xu(i);if(i instanceof tt)return Gf(i);if(i instanceof Gt)return Yf(i);if(i instanceof Rt)return Zf(i);if(i instanceof Yt)return ku(i);throw new ne(te.ErrUnimplemented,"unimplemented element")}function Xf(i){return new Qr({documentKey:i.getDocumentKey(),checkpoint:qf(i.getCheckpoint()),isRemoved:i.getIsRemoved(),changes:Jf(i.getChanges()),snapshot:i.getSnapshot(),versionVector:Oa(i.getVersionVector()),minSyncedTicket:ke(i.getMinSyncedTicket())})}function ao(i){if(!(i instanceof Ze))return{};const t=i.findDetails(yf);for(const e of t)return e.metadata;return{}}function Mi(i){return ao(i).code??""}function Ou(i){return zr.of(i.clientSeq,BigInt(i.lamport),Da(i.actorId),_a(i.versionVector),BigInt(i.serverSeq))}function _a(i){if(!i)return;const t=new Vi;return Object.entries(i.vector).forEach(([e,n])=>{t.set(e,BigInt(n.toString()))}),t}function Ie(i){if(i)return Wt.of(BigInt(i.lamport),i.delimiter,Da(i.actorId))}function Pa(i){const t={};return Object.entries(i.data).forEach(([e,n])=>{t[e]=JSON.parse(n)}),t}function Qf(i){const t=i.type;if(t===Ni.PUT){const e=Pa(i.presence);return{type:pi.Put,presence:e}}if(t===Ni.CLEAR)return{type:pi.Clear};throw new ne(te.ErrInvalidType,`unsupported type: ${t}`)}function eh(i){const t=new Map;return Object.entries(i).forEach(([e,n])=>{t.set(e,Pa(n))}),t}function Iu(i){switch(i){case Re.NULL:return ht.Null;case Re.BOOLEAN:return ht.Boolean;case Re.INTEGER:return ht.Integer;case Re.LONG:return ht.Long;case Re.DOUBLE:return ht.Double;case Re.STRING:return ht.String;case Re.BYTES:return ht.Bytes;case Re.DATE:return ht.Date}throw new ne(te.ErrUnimplemented,`unimplemented value type: ${i}`)}function Ss(i){switch(i){case Re.INTEGER_CNT:return Un.IntegerCnt;case Re.LONG_CNT:return Un.LongCnt}throw new ne(te.ErrUnimplemented,`unimplemented value type: ${i}`)}function js(i){switch(i.type){case Re.JSON_OBJECT:return i.value?Du(i.value):xt.create(Ie(i.createdAt));case Re.JSON_ARRAY:return i.value?gh(i.value):Lt.create(Ie(i.createdAt));case Re.TEXT:return Gt.create(Qi.create(),Ie(i.createdAt));case Re.TREE:return mh(i.value);case Re.NULL:case Re.BOOLEAN:case Re.INTEGER:case Re.LONG:case Re.DOUBLE:case Re.STRING:case Re.BYTES:case Re.DATE:return tt.of(tt.valueFromBytes(Iu(i.type),i.value),Ie(i.createdAt));case Re.INTEGER_CNT:case Re.LONG_CNT:return Rt.create(Ss(i.type),Rt.valueFromBytes(Ss(i.type),i.value),Ie(i.createdAt))}}function $o(i){return cn.of(jn.of(Ie(i.createdAt),i.offset),i.relativeOffset)}function Nu(i){return jn.of(Ie(i.createdAt),i.offset)}function th(i){const t=To.create(i.value);Object.entries(i.attributes).forEach(([n,r])=>{t.setAttr(n,r.value,Ie(r.updatedAt))});const e=di.create(Nu(i.id),t);return e.remove(Ie(i.removedAt)),e}function qi(i){return ln.of(go(i.parentId),go(i.leftSiblingId))}function go(i){return pt.of(Ie(i.createdAt),i.offset)}function nh(i){if(!i.length)return;const t=[];return i.forEach(e=>{const n=Ca(e.content);t.push(n)}),t}function Ca(i){if(i.length===0)return;const t=[];for(const r of i)t.push(ih(r));const e=t[t.length-1],n=new Map;n.set(i[t.length-1].depth,t[t.length-1]);for(let r=t.length-2;r>=0;r--)n.get(i[r].depth-1).prepend(t[r]),n.set(i[r].depth,t[r]);return e.updateDescendantsSize(),Yt.create(e,un).getRoot()}function rh(i){const t=Xr.create();for(const[e,n]of Object.entries(i))t.setInternal(e,n.value,Ie(n.updatedAt),n.isRemoved);return t}function ih(i){const t=go(i.id),e=Ct.create(t,i.type),n=Object.entries(i.attributes);return e.isText?e.value=i.value:n.length&&(e.attrs=rh(i.attributes)),i.insPrevId&&(e.insPrevID=go(i.insPrevId)),i.insNextId&&(e.insNextID=go(i.insNextId)),e.removedAt=Ie(i.removedAt),e}function _u(i){if(i.body.case==="set"){const t=i.body.value;return _i.create(t.key,js(t.value),Ie(t.parentCreatedAt),Ie(t.executedAt))}else if(i.body.case==="add"){const t=i.body.value;return Oo.create(Ie(t.parentCreatedAt),Ie(t.prevCreatedAt),js(t.value),Ie(t.executedAt))}else if(i.body.case==="move"){const t=i.body.value;return ci.create(Ie(t.parentCreatedAt),Ie(t.prevCreatedAt),Ie(t.createdAt),Ie(t.executedAt))}else if(i.body.case==="remove"){const t=i.body.value;return mi.create(Ie(t.parentCreatedAt),Ie(t.createdAt),Ie(t.executedAt))}else if(i.body.case==="edit"){const t=i.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([r,o])=>{e.set(r,Ie(o))});const n=new Map;return Object.entries(t.attributes).forEach(([r,o])=>{n.set(r,o)}),Io.create(Ie(t.parentCreatedAt),$o(t.from),$o(t.to),e,t.content,n,Ie(t.executedAt))}else if(i.body.case==="style"){const t=i.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([r,o])=>{e.set(r,Ie(o))});const n=new Map;return Object.entries(t.attributes).forEach(([r,o])=>{n.set(r,o)}),No.create(Ie(t.parentCreatedAt),$o(t.from),$o(t.to),e,n,Ie(t.executedAt))}else{if(i.body.case==="select")return;if(i.body.case==="increase"){const t=i.body.value;return eo.create(Ie(t.parentCreatedAt),js(t.value),Ie(t.executedAt))}else if(i.body.case==="treeEdit"){const t=i.body.value,e=new Map;return Object.entries(t.createdAtMapByActor).forEach(([n,r])=>{e.set(n,Ie(r))}),_o.create(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),nh(t.contents),t.splitLevel,e,Ie(t.executedAt))}else if(i.body.case==="treeStyle"){const t=i.body.value,e=new Map,n=t.attributesToRemove,r=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([o,s])=>{r.set(o,Ie(s))}),(n==null?void 0:n.length)>0?Yr.createTreeRemoveStyleOperation(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),r,n,Ie(t.executedAt)):(Object.entries(t.attributes).forEach(([o,s])=>{e.set(o,s)}),Yr.create(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),r,e,Ie(t.executedAt)))}else throw new ne(te.ErrUnimplemented,"unimplemented operation")}}function oh(i){const t=[];for(const e of i){const n=_u(e);n&&t.push(n)}return t}function Pu(i){const t=[];for(const e of i)t.push(Xi.create({id:Ou(e.id),operations:oh(e.operations),presenceChange:e.presenceChange?Qf(e.presenceChange):void 0,message:e.message}));return t}function sh(i){return Ki.of(BigInt(i.serverSeq),i.clientSeq)}function ah(i){return Ns.create(i.documentKey,sh(i.checkpoint),i.isRemoved,Pu(i.changes),_a(i.versionVector),i.snapshot,Ie(i.minSyncedTicket))}function Cu(i){const t=new bo;for(const n of i.nodes){const r=La(n.element);t.set(n.key,r,r.getPositionedAt())}const e=new xt(Ie(i.createdAt),t);return e.setMovedAt(Ie(i.movedAt)),e.setRemovedAt(Ie(i.removedAt)),e}function Lu(i){const t=new Ao;for(const n of i.nodes)t.insert(La(n.element));const e=new Lt(Ie(i.createdAt),t);return e.setMovedAt(Ie(i.movedAt)),e.setRemovedAt(Ie(i.removedAt)),e}function lh(i){const t=tt.of(tt.valueFromBytes(Iu(i.type),i.value),Ie(i.createdAt));return t.setMovedAt(Ie(i.movedAt)),t.setRemovedAt(Ie(i.removedAt)),t}function uh(i){const t=new Qi;let e=t.getHead();for(const r of i.nodes){const o=t.insertAfter(e,th(r));r.insPrevId&&o.setInsPrev(t.findNode(Nu(r.insPrevId))),e=o}const n=new Gt(t,Ie(i.createdAt));return n.setMovedAt(Ie(i.movedAt)),n.setRemovedAt(Ie(i.removedAt)),n}function ch(i){const t=Rt.create(Ss(i.type),Rt.valueFromBytes(Ss(i.type),i.value),Ie(i.createdAt));return t.setMovedAt(Ie(i.movedAt)),t.setRemovedAt(Ie(i.removedAt)),t}function Ru(i){const t=Ca(i.nodes);return Yt.create(t,Ie(i.createdAt))}function La(i){if(i.body.case==="jsonObject")return Cu(i.body.value);if(i.body.case==="jsonArray")return Lu(i.body.value);if(i.body.case==="primitive")return lh(i.body.value);if(i.body.case==="text")return uh(i.body.value);if(i.body.case==="counter")return ch(i.body.value);if(i.body.case==="tree")return Ru(i.body.value);throw new ne(te.ErrUnimplemented,"unimplemented element")}function fh(i){if(!i)return{root:xt.create(un),presences:new Map};const t=Ks.fromBinary(i);return{root:La(t.root),presences:eh(t.presences)}}function hh(i){const t=Oa(i);return Ra(t.toBinary())}function dh(i){const t=Ba(i),e=Os.fromBinary(t);return _a(e)}function Du(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Cu(t.body.value)}function Bu(i){return Na(i).toBinary()}function gh(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Lu(t.body.value)}function ph(i){return xu(i).toBinary()}function mh(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Ru(t.body.value)}function yh(i){return ku(i).toBinary()}function Ra(i){return i?Array.from(i).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function Da(i){return Ra(i)}function Ba(i){return new Uint8Array(i.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function Ma(i){return Ba(i)}function vh(i){const t=ks.fromBinary(i);return Ou(t)}function bh(i){const t=Aa.fromBinary(i);return _u(t)}const lt={fromPresence:Pa,toChangePack:Xf,fromChangePack:ah,fromChanges:Pu,toTreeNodes:Ia,fromTreeNodes:Ca,objectToBytes:Bu,bytesToObject:Du,bytesToSnapshot:fh,bytesToHex:Ra,hexToBytes:Ba,toHexString:Da,toUint8Array:Ma,toOperation:Eu,toChangeID:Au,PbChangeID:ks,bytesToChangeID:vh,bytesToOperation:bh,versionVectorToHex:hh,hexToVersionVector:dh};var wt=(i=>(i[i.Trivial=0]="Trivial",i[i.Debug=1]="Debug",i[i.Info=2]="Info",i[i.Warn=3]="Warn",i[i.Error=4]="Error",i[i.Fatal=5]="Fatal",i))(wt||{});let bi=3;function Mu(i){bi=i}const Ne={trivial:(...i)=>{bi>0||typeof console<"u"&&console.log("YORKIE T:",...i)},debug:(...i)=>{bi>1||typeof console<"u"&&console.log("YORKIE D:",...i)},info:(...i)=>{bi>2||typeof console<"u"&&console.log("YORKIE I:",...i)},warn:(...i)=>{bi>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...i):console.log("YORKIE W:",...i))},error:(...i)=>{bi>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...i):console.log("YORKIE E:",...i))},fatal:(...i)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...i):console.log("YORKIE F:",...i))},isEnabled:i=>bi<=i};function qu(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}class wh{constructor(t,e,n,r,o){T(this,"reconnectStreamDelay");T(this,"doc");T(this,"docID");T(this,"syncMode");T(this,"remoteChangeEventReceived");T(this,"watchStream");T(this,"watchLoopTimerID");T(this,"watchAbortController");T(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=e,this.docID=n,this.syncMode=r,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=o}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===Qo.RealtimeSyncOff?!1:this.syncMode===Qo.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Qo.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const e=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(e,this.reconnectStreamDelay)})}catch{}};await e()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Us=()=>{};class Ah{constructor(t){T(this,"finalized",!1);T(this,"observers",[]);T(this,"finalError");try{t(this)}catch(e){this.error(e)}}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,n){let r;if(!t)throw new ne(te.ErrInvalidArgument,"missing observer");if(this.finalized)throw new ne(te.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?r=t:r={next:t,error:e,complete:n},r.next===void 0&&(r.next=Us),r.error===void 0&&(r.error=Us),r.complete===void 0&&(r.complete=Us);const o=qu(),s=this.unsubscribeOne.bind(this,o);if(this.observers.push({subscriptionID:o,observer:r}),this.finalized)try{this.finalError?r.error(this.finalError):r.complete()}catch(u){Ne.warn(u)}return s}unsubscribeOne(t){var e;this.observers=(e=this.observers)==null?void 0:e.filter(n=>n.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let e=0;et}}class $i{constructor(t,e,n,r){T(this,"id");T(this,"delimiter");T(this,"message");T(this,"root");T(this,"operations");T(this,"presenceChange");T(this,"previousPresence");T(this,"reversePresenceKeys");this.id=t,this.delimiter=cu,this.root=e,this.operations=[],this.previousPresence=sn(n),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=r}static create(t,e,n,r){return new $i(t,e,n,r)}push(t){this.operations.push(t)}registerElement(t,e){this.root.registerElement(t,e)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return Xi.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,e){for(const n of Object.keys(t))e!=null&&e.addToHistory?this.reversePresenceKeys.add(n):this.reversePresenceKeys.delete(n)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const e of this.reversePresenceKeys)t[e]=this.previousPresence[e];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class So{constructor(t){T(this,"rootObject");T(this,"elementPairMapByCreatedAt");T(this,"gcElementSetByCreatedAt");T(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof Gt||e instanceof Yt)for(const n of e.getGCPairs())this.registerGCPair(n);return!1})}static create(){return new So(xt.create(un))}findByCreatedAt(t){const e=this.elementPairMapByCreatedAt.get(t.toIDString());if(e)return e.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let e=this.elementPairMapByCreatedAt.get(t.toIDString());if(!e)return[];const n=[];for(;e.parent;){const r=e.element.getCreatedAt(),o=e.parent.subPathOf(r);if(o===void 0)throw new ne(te.ErrInvalidArgument,`cant find the given element: ${r.toIDString()}`);n.unshift(o),e=this.elementPairMapByCreatedAt.get(e.parent.getCreatedAt().toIDString())}return n.unshift("$"),n}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,e){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:e,element:t}),t instanceof hi&&t.getDescendants((n,r)=>(this.registerElement(n,r),!1))}deregisterElement(t){let e=0;const n=r=>{const o=r.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(o),this.gcElementSetByCreatedAt.delete(o),e++};return n(t),t instanceof hi&&t.getDescendants(r=>(n(r),!1)),e}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const e of this.gcElementSetByCreatedAt){t.add(e);const n=this.elementPairMapByCreatedAt.get(e);n.element instanceof hi&&n.element.getDescendants(r=>(t.add(r.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new So(this.rootObject.deepcopy())}garbageCollect(t){let e=0;for(const n of this.gcElementSetByCreatedAt){const r=this.elementPairMapByCreatedAt.get(n),o=r.element.getRemovedAt();o&&(t!=null&&t.afterOrEqual(o))&&(r.parent.purge(r.element),e+=this.deregisterElement(r.element))}for(const[,n]of this.gcPairMap){const r=n.child.getRemovedAt();r&&(t!=null&&t.afterOrEqual(r))&&(n.parent.purge(n.child),this.gcPairMap.delete(n.child.toIDString()),e+=1)}return e}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Fu(i,t){const e=new Eo(i);return new Proxy(t,e.getHandlers())}class Eo{constructor(t){T(this,"context");T(this,"handlers");this.context=t,this.handlers={set:(e,n,r)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]=${JSON.stringify(r)}`),Eo.setInternal(t,e,n,r),!0),get:(e,n)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]`),n==="getID"?()=>e.getCreatedAt():n==="toJSON"||n==="toString"?()=>e.toJSON():n==="toJS"?()=>e.toJS():n==="toJSForTest"?()=>e.toJSForTest():wi(t,e.get(n))),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(e,n)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]`),Eo.deleteInternal(t,e,n),!0)}}static setInternal(t,e,n,r){if(n.includes("."))throw new ne(te.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),s=Es(t,r,o),u=e.set(n,s,o);t.registerElement(s,e),u&&t.registerRemovedElement(u),t.push(_i.create(n,s.deepcopy(),e.getCreatedAt(),o))}static buildObjectMembers(t,e){const n={};for(const[r,o]of Object.entries(e)){if(r.includes("."))throw new ne(te.ErrInvalidObjectKey,"key must not contain the '.'.");const s=t.issueTimeTicket(),u=Es(t,o,s);n[r]=u}return n}static deleteInternal(t,e,n){const r=t.issueTimeTicket(),o=e.deleteByKey(n,r);o&&(t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o))}getHandlers(){return this.handlers}}function Sh(i,t){const e=new rt(i,t);return new Proxy(t,e.getHandlers())}function Eh(i){return typeof i=="string"||i instanceof String?!isNaN(i):!1}function xh(i){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(i)}class rt{constructor(t,e){T(this,"context");T(this,"handlers");T(this,"array");this.context=t,this.array=e,this.handlers={get:(n,r,o)=>r==="getID"?()=>n.getCreatedAt():r==="getElementByID"?s=>{const u=n.getByID(s);if(!(!u||u.isRemoved()))return oi(t,u)}:r==="getElementByIndex"?s=>{const u=n.get(s);return oi(t,u)}:r==="getLast"?()=>oi(t,n.getLast()):r==="deleteByID"?s=>{const u=rt.deleteInternalByID(t,n,s);return oi(t,u)}:r==="insertAfter"?(s,u)=>{const c=rt.insertAfterInternal(t,n,s,u);return oi(t,c)}:r==="insertBefore"?(s,u)=>{const c=rt.insertBeforeInternal(t,n,s,u);return oi(t,c)}:r==="moveBefore"?(s,u)=>{rt.moveBeforeInternal(t,n,s,u)}:r==="moveAfter"?(s,u)=>{rt.moveAfterInternal(t,n,s,u)}:r==="moveFront"?s=>{rt.moveFrontInternal(t,n,s)}:r==="moveLast"?s=>{rt.moveLastInternal(t,n,s)}:Eh(r)?wi(t,n.get(Number(r))):r==="push"?s=>rt.pushInternal(t,n,s):r==="splice"?(s,u,...c)=>rt.splice(t,n,s,u,...c):r==="length"?n.length:typeof r=="symbol"&&r===Symbol.iterator?rt.iteratorInternal.bind(this,t,n):r==="includes"?(s,u)=>rt.includes(t,n,s,u):r==="indexOf"?(s,u)=>rt.indexOf(t,n,s,u):r==="lastIndexOf"?(s,u)=>rt.lastIndexOf(t,n,s,u):r==="toJSForTest"?()=>n.toJSForTest():r==="toTestString"?()=>rt.toTestString(n):typeof r=="string"&&xh(r)?(...s)=>{const u=Array.from(n).map(c=>wi(t,c));return Array.prototype[r].apply(u,s)}:Reflect.get(n,r,o),deleteProperty:(n,r)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`array[${r}]`),rt.deleteInternalByIndex(t,n,Number.parseInt(r)),!0)}}static*iteratorInternal(t,e){for(const n of e)yield oi(t,n)}static buildArrayElements(t,e){const n=[];for(const r of e){const o=t.issueTimeTicket(),s=Es(t,r,o);n.push(s)}return n}static pushInternal(t,e,n){return rt.insertAfterInternal(t,e,e.getLastCreatedAt(),n),e.length}static moveBeforeInternal(t,e,n,r){const o=t.issueTimeTicket(),s=e.getPrevCreatedAt(n);e.moveAfter(s,r,o),t.push(ci.create(e.getCreatedAt(),s,r,o))}static moveAfterInternal(t,e,n,r){const o=t.issueTimeTicket();e.moveAfter(n,r,o),t.push(ci.create(e.getCreatedAt(),n,r,o))}static moveFrontInternal(t,e,n){const r=t.issueTimeTicket(),o=e.getHead();e.moveAfter(o.getCreatedAt(),n,r),t.push(ci.create(e.getCreatedAt(),o.getCreatedAt(),n,r))}static moveLastInternal(t,e,n){const r=t.issueTimeTicket(),o=e.getLastCreatedAt();e.moveAfter(o,n,r),t.push(ci.create(e.getCreatedAt(),o,n,r))}static insertAfterInternal(t,e,n,r){const o=t.issueTimeTicket(),s=Es(t,r,o);return e.insertAfter(n,s),t.registerElement(s,e),t.push(Oo.create(e.getCreatedAt(),n,s.deepcopy(),o)),s}static insertBeforeInternal(t,e,n,r){return rt.insertAfterInternal(t,e,e.getPrevCreatedAt(n),r)}static deleteInternalByIndex(t,e,n){const r=t.issueTimeTicket(),o=e.deleteByIndex(n,r);if(o)return t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o),o}static deleteInternalByID(t,e,n){const r=t.issueTimeTicket(),o=e.delete(n,r);return t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o),o}static splice(t,e,n,r,...o){const s=e.length,u=n>=0?Math.min(n,s):Math.max(s+n,0),c=r===void 0?s:r<0?u:Math.min(u+r,s),m=[];for(let y=u;y=o)return!1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).includes(n,s);for(let c=s;c=o)return-1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).indexOf(n,s);for(let c=s;c=o?o-1:r<0?r+o:r;if(s<0)return-1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).lastIndexOf(n,s);for(let c=s;c>0;c--)if(((u=e.get(c))==null?void 0:u.getID())===n.getID())return c;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}let _s=class{constructor(t,e){T(this,"context");T(this,"text");this.context=t,this.text=e}initialize(t,e){this.context=t,this.text=e}getID(){return this.text.getID()}edit(t,e,n,r){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.text.indexRangeToPosRange(t,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`EDIT: f:${t}->${o[0].toTestString()}, t:${e}->${o[1].toTestString()} c:${n}`);const s=r?Yi(r):void 0,u=this.context.issueTimeTicket(),[c,,m,y]=this.text.edit(o,n,u,s);for(const f of m)this.context.registerGCPair(f);return this.context.push(new Io(this.text.getCreatedAt(),o[0],o[1],c,n,s?new Map(Object.entries(s)):new Map,u)),this.text.findIndexesFromRange(y)}delete(t,e){return this.edit(t,e,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,e,n){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.text.indexRangeToPosRange(t,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`STYL: f:${t}->${r[0].toTestString()}, t:${e}->${r[1].toTestString()} a:${JSON.stringify(n)}`);const o=Yi(n),s=this.context.issueTimeTicket(),[u,c]=this.text.setStyle(r,o,s);for(const m of c)this.context.registerGCPair(m);return this.context.push(new No(this.text.getCreatedAt(),r[0],r[1],u,new Map(Object.entries(o)),s)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");const e=this.text.indexRangeToPosRange(t[0],t[1]);return[e[0].toStruct(),e[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");const e=this.text.findIndexesFromRange([cn.fromStruct(t[0]),cn.fromStruct(t[1])]);return[e[0],e[1]]}toTestString(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,e){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,e)}};class Ps{constructor(t,e){T(this,"valueType");T(this,"value");T(this,"context");T(this,"counter");this.valueType=t,this.value=e}initialize(t,e){this.valueType=e.getValueType(),this.context=t,this.counter=e,this.value=e.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new ne(te.ErrNotInitialized,"Counter is not initialized yet");const e=this.context.issueTimeTicket(),n=tt.of(t,e);if(!n.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof n.getValue()}`);return this.counter.increase(n),this.context.push(eo.create(this.counter.getCreatedAt(),n,e)),this}toJSForTest(){if(!this.context||!this.counter)throw new ne(te.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function qa(i,t,e){const{type:n}=i,r=e.issueTimeTicket();if(n===Gr){ju(i);const{value:o}=i,s=Ct.create(pt.of(r,0),n,o);t.append(s)}else{const{children:o=[]}=i,{attributes:s}=i;let u;if(typeof s=="object"&&!uu(s)){const m=Yi(s);u=new Xr;for(const[y,f]of Object.entries(m))u.set(y,f,r)}const c=Ct.create(pt.of(r,0),n,void 0,u);t.append(c);for(const m of o)qa(m,c,e)}}function kh(i,t){const{type:e}=t,n=i.issueTimeTicket();let r;if(t.type===Gr){const{value:o}=t;r=Ct.create(pt.of(n,0),e,o)}else if(t){const{children:o=[]}=t,{attributes:s}=t;let u;if(typeof s=="object"&&!uu(s)){const c=Yi(s);u=new Xr;for(const[m,y]of Object.entries(c))u.set(m,y,n)}r=Ct.create(pt.of(i.issueTimeTicket(),0),e,void 0,u);for(const c of o)qa(c,r,i)}return r}function ju(i){if(!i.value.length)throw new ne(te.ErrInvalidArgument,"text node cannot have empty value");return!0}function xl(i){if(!i.length)return!0;if(i[0].type===Gr)for(const e of i){const{type:n}=e;if(n!==Gr)throw new ne(te.ErrInvalidArgument,"element node and text node cannot be passed together");ju(e)}else for(const e of i){const{type:n}=e;if(n===Gr)throw new ne(te.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class Cs{constructor(t){T(this,"initialRoot");T(this,"context");T(this,"tree");this.initialRoot=t}initialize(t,e){this.context=t,this.tree=e}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return Ct.create(pt.of(t.issueTimeTicket(),0),Ef);const e=Ct.create(pt.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const n of this.initialRoot.children)qa(n,e,t);return e}getSize(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,e){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const[n,r]=this.tree.pathToPosRange(t),o=this.context.issueTimeTicket(),s=e?Yi(e):void 0,[u]=this.tree.style([n,r],s,o);this.context.push(Yr.create(this.tree.getCreatedAt(),n,r,u,s?new Map(Object.entries(s)):new Map,o))}style(t,e,n){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(t),o=this.tree.findPos(e),s=this.context.issueTimeTicket(),u=n?Yi(n):void 0,[c,m]=this.tree.style([r,o],u,s);for(const y of m)this.context.registerGCPair(y);this.context.push(Yr.create(this.tree.getCreatedAt(),r,o,c,u?new Map(Object.entries(u)):new Map,s))}removeStyle(t,e,n){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(t),o=this.tree.findPos(e),s=this.context.issueTimeTicket(),[u,c]=this.tree.removeStyle([r,o],n,s);for(const m of c)this.context.registerGCPair(m);this.context.push(Yr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),r,o,u,n,s))}editInternal(t,e,n,r=0){var m;if(n.length!==0&&n[0]&&(xl(n),n[0].type!==Gr))for(const y of n){const{children:f=[]}=y;xl(f)}const o=this.context.getLastTimeTicket();let s=new Array;if(((m=n[0])==null?void 0:m.type)===Gr){let y="";for(const f of n){const{value:l}=f;y+=l}s.push(Ct.create(pt.of(this.context.issueTimeTicket(),0),Gr,y))}else s=n.map(y=>y&&kh(this.context,y)).filter(y=>y);const[,u,c]=this.tree.edit([t,e],s.length?s.map(y=>y==null?void 0:y.deepcopy()):void 0,r,o,()=>this.context.issueTimeTicket());for(const y of u)this.context.registerGCPair(y);return this.context.push(_o.create(this.tree.getCreatedAt(),t,e,s.length?s:void 0,r,c,o)),!0}editByPath(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new ne(te.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),s=this.tree.pathToPos(e);return this.editInternal(o,s,n?[n]:[],r)}editBulkByPath(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new ne(te.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),s=this.tree.pathToPos(e);return this.editInternal(o,s,n,r)}edit(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),s=this.tree.findPos(e);return this.editInternal(o,s,n?[n]:[],r)}editBulk(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),s=this.tree.findPos(e);return this.editInternal(o,s,n,r)}toXML(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],n=this.tree.indexRangeToPosRange(e);return[n[0].toStruct(),n[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[ln.fromStruct(t[0]),ln.fromStruct(t[1])];return this.tree.posRangeToIndexRange(e)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[ln.fromStruct(t[0]),ln.fromStruct(t[1])];return this.tree.posRangeToPathRange(e)}}function kl(i,t){return Fu(i,t)}function oi(i,t){if(t){if(t instanceof tt)return t;if(t instanceof xt)return Fu(i,t);if(t instanceof Lt)return Sh(i,t);if(t instanceof Gt)return new _s(i,t);if(t instanceof Rt){const e=new Ps(Un.IntegerCnt,0);return e.initialize(i,t),e}else if(t instanceof Yt){const e=new Cs;return e.initialize(i,t),e}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function wi(i,t){const e=oi(i,t);return e instanceof tt?e.getValue():e}function Es(i,t,e){let n;if(tt.isSupport(t))n=tt.of(t,e);else if(Array.isArray(t))n=Lt.create(e,rt.buildArrayElements(i,t));else if(typeof t=="object")t instanceof _s?(n=Gt.create(Qi.create(),e),t.initialize(i,n)):t instanceof Ps?(n=Rt.create(t.getValueType(),t.getValue(),e),t.initialize(i,n)):t instanceof Cs?(n=Yt.create(t.buildRoot(i),e),t.initialize(i,n)):n=xt.create(e,Eo.buildObjectMembers(i,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return n}const Ol=50;class Oh{constructor(){T(this,"undoStack",[]);T(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Ol&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Ol&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const Ih="yorkie-devtools-panel",Nh="yorkie-devtools-sdk";let Fi="disconnected";const Il=new Map,Xo=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Xo);function zo(i,t){(t!=null&&t.force||Fi!=="disconnected")&&window.postMessage({source:Nh,...i},"*")}function _h(i){if(!i.isEnableDevtools()||typeof window>"u"||Il.has(i.getKey()))return;Xo.set(i.getKey(),[]);const t=i.subscribe("all",e=>{e.some(n=>n.type!==ft.StatusChanged&&n.type!==ft.Snapshot&&n.type!==ft.LocalChange&&n.type!==ft.RemoteChange&&n.type!==ft.Initialized&&n.type!==ft.Watched&&n.type!==ft.Unwatched&&n.type!==ft.PresenceChanged)||(Xo.get(i.getKey()).push(e),Fi==="synced"&&zo({msg:"doc::sync::partial",docKey:i.getKey(),event:e}))});Il.set(i.getKey(),[t]),zo({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",e=>{var r;if(((r=e.data)==null?void 0:r.source)!==Ih)return;switch(e.data.msg){case"devtools::connect":if(Fi!=="disconnected")break;Fi="connected",zo({msg:"doc::available",docKey:i.getKey()}),Ne.info(`[YD] Devtools connected. Doc: ${i.getKey()}`);break;case"devtools::disconnect":Fi="disconnected",Ne.info(`[YD] Devtools disconnected. Doc: ${i.getKey()}`);break;case"devtools::subscribe":Fi="synced",zo({msg:"doc::sync::full",docKey:i.getKey(),events:Xo.get(i.getKey())}),Ne.info(`[YD] Devtools subscribed. Doc: ${i.getKey()}`);break}})}var si=(i=>(i.Detached="detached",i.Attached="attached",i.Removed="removed",i))(si||{}),ft=(i=>(i.StatusChanged="status-changed",i.ConnectionChanged="connection-changed",i.SyncStatusChanged="sync-status-changed",i.Snapshot="snapshot",i.LocalChange="local-change",i.RemoteChange="remote-change",i.Initialized="initialized",i.Watched="watched",i.Unwatched="unwatched",i.PresenceChanged="presence-changed",i.Broadcast="broadcast",i.LocalBroadcast="local-broadcast",i.AuthError="auth-error",i))(ft||{}),xo=(i=>(i.Connected="connected",i.Disconnected="disconnected",i))(xo||{}),va=(i=>(i.Synced="synced",i.SyncFailed="sync-failed",i))(va||{});class Uu{constructor(t,e){T(this,"key");T(this,"status");T(this,"opts");T(this,"changeID");T(this,"checkpoint");T(this,"localChanges");T(this,"root");T(this,"clone");T(this,"eventStream");T(this,"eventStreamObserver");T(this,"onlineClients");T(this,"presences");T(this,"history");T(this,"internalHistory");T(this,"isUpdating");this.opts=e||{},this.key=t,this.status="detached",this.root=So.create(),this.changeID=Lf,this.checkpoint=Rf,this.localChanges=[],this.eventStream=Th(n=>{this.eventStreamObserver=n}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Oh,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},_h(this)}update(t,e){if(this.getStatus()==="removed")throw new ne(te.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const n=this.changeID.getActorID(),r=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(n)||{},e);try{const o=kl(r,this.clone.root.getObject());this.presences.has(n)||this.clone.presences.set(n,{}),this.isUpdating=!0,t(o,new qs(r,this.clone.presences.get(n)))}catch(o){throw this.clone=void 0,o}finally{this.isUpdating=!1}if(r.hasChange()){Ne.isEnabled(wt.Trivial)&&Ne.trivial(`trying to update a local change: ${this.toJSON()}`);const o=r.getChange(),{opInfos:s,reverseOps:u}=o.execute(this.root,this.presences,Ye.Local),c=r.getReversePresence();c&&u.push({type:"presence",value:c}),this.localChanges.push(o),u.length>0&&this.internalHistory.pushUndo(u),s.length>0&&this.internalHistory.clearRedo(),this.changeID=o.getID();const m=[];s.length>0&&m.push({type:"local-change",source:Ye.Local,value:{message:o.getMessage()||"",operations:s,actor:n,clientSeq:o.getID().getClientSeq(),serverSeq:o.getID().getServerSeq()},rawChange:this.isEnableDevtools()?o.toStruct():void 0}),o.hasPresenceChange()&&m.push({type:"presence-changed",source:Ye.Local,value:{clientID:n,presence:this.getPresence(n)}}),this.publish(m),Ne.isEnabled(wt.Trivial)&&Ne.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,e,n,r){if(typeof t=="string"){if(typeof e!="function")throw new ne(te.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="initialized"&&m.type!=="watched"&&m.type!=="unwatched"&&m.type!=="presence-changed"||u(m)},n,r)}if(t==="my-presence"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="initialized"&&m.type!=="presence-changed"||m.type==="presence-changed"&&m.value.clientID!==this.changeID.getActorID()||u(m)},n,r)}if(t==="others"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="watched"&&m.type!=="unwatched"&&m.type!=="presence-changed"||m.value.clientID!==this.changeID.getActorID()&&u(m)},n,r)}if(t==="connection"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="connection-changed"&&u(m)},n,r)}if(t==="status"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="status-changed"&&u(m)},n,r)}if(t==="sync"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="sync-status-changed"&&u(m)},n,r)}if(t==="local-broadcast"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="local-broadcast"&&u(m)},n)}if(t==="broadcast"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="broadcast"&&u(m)},n)}if(t==="auth-error"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="auth-error"&&u(m)},n)}if(t==="all"){const u=e;return this.eventStream.subscribe(u,n,r)}const o=t,s=e;return this.eventStream.subscribe(u=>{for(const c of u){if(c.type!=="local-change"&&c.type!=="remote-change")continue;const m=[];for(const y of c.value.operations)this.isSameElementOrChildOf(y.path,o)&&m.push(y);m.length&&s({...c,value:{...c.value,operations:m}})}},n,r)}if(typeof t=="function"){const o=t,s=e,u=n;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="snapshot"&&m.type!=="local-change"&&m.type!=="remote-change"||o(m)},s,u)}throw new ne(te.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,e){if(e===t)return!0;const n=t.split(".");return e.split(".").every((o,s)=>o===n[s])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const e=t.hasSnapshot();e?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),Ye.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),e||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),Ne.isEnabled(wt.Trivial)&&Ne.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:sn(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),e=this.checkpoint.increaseClientSeq(t.length);return Ns.create(this.key,e,!1,t,this.getVersionVector())}setActor(t){for(const e of this.localChanges)e.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return kl(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,e,n,r=-1){const{root:o,presences:s}=lt.bytesToSnapshot(n);this.root=new So(o),this.presences=s,this.changeID=this.changeID.setClocks(t,e),this.clone=void 0,this.removePushedLocalChanges(r),this.applyChanges(this.localChanges,Ye.Local),this.publish([{type:"snapshot",source:Ye.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?lt.bytesToHex(n):void 0,snapshotVector:lt.versionVectorToHex(e)}}])}applyChanges(t,e){Ne.isEnabled(wt.Debug)&&Ne.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),Ne.isEnabled(wt.Trivial)&&Ne.trivial(t.map(n=>`${n.getID().toTestString()} ${n.toTestString()}`).join(` -`));for(const n of t)this.applyChange(n,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,e){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,e);const n=[],r=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(r)){const s=t.getPresenceChange();switch(s.type){case pi.Put:n.push(this.presences.has(r)?{type:"presence-changed",source:e,value:{clientID:r,presence:s.presence}}:{type:"watched",source:Ye.Remote,value:{clientID:r,presence:s.presence}});break;case pi.Clear:n.push({type:"unwatched",source:Ye.Remote,value:{clientID:r,presence:this.getPresence(r)}}),this.removeOnlineClient(r);break}}const{opInfos:o}=t.execute(this.root,this.presences,e);if(this.changeID=this.changeID.syncClocks(t.getID()),o.length>0){const s=this.isEnableDevtools()?t.toStruct():void 0;n.push(e===Ye.Remote?{type:"remote-change",source:e,value:{actor:r,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:s}:{type:"local-change",source:e,value:{actor:r,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:s})}n.length>0&&this.publish(n)}applyWatchStream(t){if(t.body.case==="initialization"){const e=t.body.value.clientIds,n=new Set;for(const r of e)r!==this.changeID.getActorID()&&n.add(r);this.setOnlineClients(n),this.publish([{type:"initialized",source:Ye.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:e,publisher:n}=t.body.value,r=[];if(e===Oi.DOCUMENT_WATCHED){if(this.onlineClients.has(n)&&this.hasPresence(n))return;this.addOnlineClient(n),this.hasPresence(n)&&r.push({type:"watched",source:Ye.Remote,value:{clientID:n,presence:this.getPresence(n)}})}else if(e===Oi.DOCUMENT_UNWATCHED){const o=this.getPresence(n);this.removeOnlineClient(n),o&&r.push({type:"unwatched",source:Ye.Remote,value:{clientID:n,presence:o}})}else if(e===Oi.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:o,payload:s}=t.body.value.body,u=new TextDecoder;r.push({type:"broadcast",value:{clientID:n,topic:o,payload:JSON.parse(u.decode(s))}})}r.length>0&&this.publish(r)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(Sa),this.publish([{source:t==="removed"?Ye.Remote:Ye.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:e,serverSeq:n,snapshotVector:r}=t.value;if(!e)return;this.applySnapshot(BigInt(n),lt.hexToVersionVector(r),lt.hexToBytes(e));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const e=Xi.fromStruct(t.rawChange);this.applyChange(e,t.source)}if(t.type==="initialized"){const e=new Set;for(const{clientID:n,presence:r}of t.value)e.add(n),this.presences.set(n,r);this.setOnlineClients(e);return}if(t.type==="watched"){const{clientID:e,presence:n}=t.value;this.addOnlineClient(e),this.presences.set(e,n);return}if(t.type==="unwatched"){const{clientID:e}=t.value;this.removeOnlineClient(e),this.presences.delete(e)}if(t.type==="presence-changed"){const{clientID:e,presence:n}=t.value;this.presences.set(e,n)}}applyTransactionEvent(t){for(const e of t)this.applyDocEvent(e)}getValueByPath(t){if(!t.startsWith("$"))throw new ne(te.ErrInvalidArgument,'path must start with "$"');const e=t.split(".");e.shift();let n=this.getRoot();for(const r of e)if(n=n[r],n===void 0)return;return n}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?sn(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const e=this.presences.get(t);return e?sn(e):void 0}getPresenceForTest(t){const e=this.presences.get(t);return e?sn(e):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:sn(this.getMyPresence())});for(const e of this.onlineClients)this.presences.has(e)&&t.push({clientID:e,presence:sn(this.presences.get(e))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(e=>e.clientID!==t).sort((e,n)=>e.clientID>n.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const n=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(n)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new ne(te.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new ne(te.ErrRefused,"There is no operation to be undone");this.ensureClone();const e=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const m of t){if(!(m instanceof fn)){new qs(e,sn(this.clone.presences.get(this.changeID.getActorID()))).set(m.value,{addToHistory:!0});continue}const y=e.issueTimeTicket();m.setExecutedAt(y),e.push(m)}const n=e.getChange();n.execute(this.clone.root,this.clone.presences,Ye.UndoRedo);const{opInfos:r,reverseOps:o}=n.execute(this.root,this.presences,Ye.UndoRedo),s=e.getReversePresence();if(s&&o.push({type:"presence",value:s}),o.length>0&&this.internalHistory.pushRedo(o),!n.hasPresenceChange()&&r.length===0)return;this.localChanges.push(n),this.changeID=n.getID();const u=this.changeID.getActorID(),c=[];r.length>0&&c.push({type:"local-change",source:Ye.UndoRedo,value:{message:n.getMessage()||"",operations:r,actor:u,clientSeq:n.getID().getClientSeq(),serverSeq:n.getID().getServerSeq()},rawChange:this.isEnableDevtools()?n.toStruct():void 0}),n.hasPresenceChange()&&c.push({type:"presence-changed",source:Ye.UndoRedo,value:{clientID:u,presence:this.getPresence(u)}}),this.publish(c)}redo(){if(this.isUpdating)throw new ne(te.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new ne(te.ErrRefused,"There is no operation to be redone");this.ensureClone();const e=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const m of t){if(!(m instanceof fn)){new qs(e,sn(this.clone.presences.get(this.changeID.getActorID()))).set(m.value,{addToHistory:!0});continue}const y=e.issueTimeTicket();m.setExecutedAt(y),e.push(m)}const n=e.getChange();n.execute(this.clone.root,this.clone.presences,Ye.UndoRedo);const{opInfos:r,reverseOps:o}=n.execute(this.root,this.presences,Ye.UndoRedo),s=e.getReversePresence();if(s&&o.push({type:"presence",value:s}),o.length>0&&this.internalHistory.pushUndo(o),!n.hasPresenceChange()&&r.length===0)return;this.localChanges.push(n),this.changeID=n.getID();const u=this.changeID.getActorID(),c=[];r.length>0&&c.push({type:"local-change",source:Ye.UndoRedo,value:{message:n.getMessage()||"",operations:r,actor:u,clientSeq:n.getID().getClientSeq(),serverSeq:n.getID().getServerSeq()},rawChange:this.isEnableDevtools()?n.toStruct():void 0}),n.hasPresenceChange()&&c.push({type:"presence-changed",source:Ye.UndoRedo,value:{clientID:u,presence:this.getPresence(u)}}),this.publish(c)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,e,n){const r={type:"local-broadcast",value:{topic:t,payload:e},options:n};this.publish([r])}getVersionVector(){return this.changeID.getVersionVector()}}function Ph(i,t){let e=t;return{authInterceptor:o=>async s=>(i&&s.header.set("x-api-key",i),e&&s.header.set("authorization",e),await o(s)),setToken:o=>{e=o}}}const Ch="yorkie-js-sdk",Lh="0.5.6",Rh="Yorkie JS SDK",Dh="./src/yorkie.ts",Bh={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},Mh=["dist"],qh={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},Fh={node:">=18.0.0",npm:">=7.1.0"},jh={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},Uh={name:"hackerwins",email:"susukang98@gmail.com"},Jh="Apache-2.0",$h={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},zh="https://github.com/yorkie-team/yorkie-js-sdk#readme",Vh={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},Kh={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Nl={name:Ch,version:Lh,description:Rh,main:Dh,publishConfig:Bh,files:Mh,scripts:qh,engines:Fh,repository:jh,author:Uh,license:Jh,bugs:$h,homepage:zh,devDependencies:Vh,dependencies:Kh};function Hh(){return i=>async t=>(t.header.set("x-yorkie-user-agent",Nl.name+"/"+Nl.version),await i(t))}const Wh=i=>{try{if(JSON.stringify(i)===void 0)return!1}catch{return!1}return!0};var Qo=(i=>(i.Manual="manual",i.Realtime="realtime",i.RealtimePushOnly="realtime-pushonly",i.RealtimeSyncOff="realtime-syncoff",i))(Qo||{});const Vo={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Js={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class Ju{constructor(t,e){T(this,"id");T(this,"key");T(this,"status");T(this,"attachmentMap");T(this,"apiKey");T(this,"authTokenInjector");T(this,"conditions");T(this,"syncLoopDuration");T(this,"reconnectStreamDelay");T(this,"retrySyncLoopDelay");T(this,"rpcClient");T(this,"setAuthToken");T(this,"taskQueue");T(this,"processing",!1);T(this,"keepalive",!1);e=e||Vo,this.key=e.key?e.key:qu(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=e.apiKey||"",this.authTokenInjector=e.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=e.syncLoopDuration??Vo.syncLoopDuration,this.reconnectStreamDelay=e.reconnectStreamDelay??Vo.reconnectStreamDelay,this.retrySyncLoopDelay=e.retrySyncLoopDelay??Vo.retrySyncLoopDelay;const{authInterceptor:n,setToken:r}=Ph(this.apiKey);this.setAuthToken=r,this.rpcClient=Kc(mf,pf({baseUrl:t,interceptors:[n,Hh()],fetch:(o,s)=>{const u={...s,keepalive:this.keepalive};return fetch(o,u)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),Ne.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw Ne.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const e=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),Ne.info(`[DC] c"${this.getKey()}" deactivated`)}catch(n){throw Ne.error(`[DC] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n}};if(t.keepalive){this.keepalive=!0;const n=e();return this.keepalive=!1,n}return this.enqueueTask(e)}attach(t,e={}){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==si.Detached)throw new ne(te.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((o,s)=>s.set(e.initialPresence||{}));const n=t.subscribe("local-broadcast",async o=>{var y;const{topic:s,payload:u}=o.value,c=(y=o.options)==null?void 0:y.error,m=o.options;try{await this.broadcast(t.getKey(),s,u,m)}catch(f){f instanceof Error&&(c==null||c(f))}}),r=e.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:lt.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async o=>{const s=lt.fromChangePack(o.changePack);if(t.applyChangePack(s),t.getStatus()===si.Removed)return t;t.applyStatus(si.Attached),this.attachmentMap.set(t.getKey(),new wh(this.reconnectStreamDelay,t,o.documentId,r,n)),r!=="manual"&&await this.runWatchLoop(t.getKey()),Ne.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const u=t.getRootObject();if(e.initialRoot){const c=e.initialRoot;t.update(m=>{for(const[y,f]of Object.entries(c))if(!u.has(y)){const l=y;m[l]=f}})}return t}).catch(async o=>{throw Ne.error(`[AD] c:"${this.getKey()}" err :`,o),await this.handleConnectError(o),o}))}detach(t,e={}){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((r,o)=>o.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:n.docID,changePack:lt.toChangePack(t.createChangePack()),removeIfNotAttached:e.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(r=>{const o=lt.fromChangePack(r.changePack);return t.applyChangePack(o),t.getStatus()!==si.Removed&&t.applyStatus(si.Detached),this.detachInternal(t.getKey()),Ne.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async r=>{throw Ne.error(`[DD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}async changeSyncMode(t,e){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const r=n.syncMode;return r===e?t:(n.changeSyncMode(e),e==="manual"?(n.cancelWatchStream(),t):(e==="realtime"&&(n.remoteChangeEventReceived=!0),r==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);if(t){const e=this.attachmentMap.get(t.getKey());if(!e)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(e,"realtime").catch(async n=>{throw Ne.error(`[SY] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n}))}return this.enqueueTask(async()=>{const e=[];for(const[,n]of this.attachmentMap)e.push(this.syncInternal(n,n.syncMode));return Promise.all(e).catch(async n=>{throw Ne.error(`[SY] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n})})}remove(t){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const e=this.attachmentMap.get(t.getKey());if(!e)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const n=lt.toChangePack(t.createChangePack());return n.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:e.docID,changePack:n},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(r=>{const o=lt.fromChangePack(r.changePack);t.applyChangePack(o),this.detachInternal(t.getKey()),Ne.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async r=>{throw Ne.error(`[RD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,e,n,r){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const o=this.attachmentMap.get(t);if(!o)throw new ne(te.ErrDocumentNotAttached,`${t} is not attached`);if(!Wh(n))throw new ne(te.ErrInvalidArgument,"payload is not serializable");const s=(r==null?void 0:r.maxRetries)??Js.maxRetries,u=Js.maxBackoff;let c=0;const m=f=>Math.min(Js.initialRetryInterval*2**f,u),y=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:o.docID,topic:e,payload:new TextEncoder().encode(JSON.stringify(n))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{Ne.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${e}"`)}).catch(async f=>{if(Ne.error(`[BC] c:"${this.getKey()}" err:`,f),await this.handleConnectError(f))if(f instanceof Ze&&Mi(f)===te.ErrUnauthenticated&&o.doc.publish([{type:ft.AuthError,value:{reason:ao(f).reason,method:"Broadcast"}}]),cy(),m(c-1)),Ne.info(`[BC] c:"${this.getKey()}" retry attempt ${c}/${s}`);else throw Ne.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),f;else throw f}));return y()}runSyncLoop(){const t=()=>{if(!this.isActive()){Ne.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const e=[];for(const[,n]of this.attachmentMap)n.needRealtimeSync()&&(n.remoteChangeEventReceived=!1,e.push(this.syncInternal(n,n.syncMode).catch(async r=>{throw r instanceof Ze&&Mi(r)===te.ErrUnauthenticated&&n.doc.publish([{type:ft.AuthError,value:{reason:ao(r).reason,method:"PushPull"}}]),r})));Promise.all(e).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async n=>{Ne.error(`[SL] c:"${this.getKey()}" sync failed:`,n),await this.handleConnectError(n)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};Ne.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const e=this.attachmentMap.get(t);if(!e)throw new ne(te.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,e.runWatchLoop(n=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new ne(te.ErrClientNotActivated,`${this.key} is not active`));const r=new AbortController,o=this.rpcClient.watchDocument({clientId:this.id,documentId:e.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:r.signal});return e.doc.publish([{type:ft.ConnectionChanged,value:xo.Connected}]),Ne.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((s,u)=>{(async()=>{try{for await(const m of o)this.handleWatchDocumentsResponse(e,m),m.body.case==="initialization"&&s([o,r])}catch(m){e.doc.resetOnlineClients(),e.doc.publish([{type:ft.Initialized,source:Ye.Local,value:e.doc.getPresences()}]),e.doc.publish([{type:ft.ConnectionChanged,value:xo.Disconnected}]),Ne.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(m)?(m instanceof Ze&&Mi(m)===te.ErrUnauthenticated&&e.doc.publish([{type:ft.AuthError,value:{reason:ao(m).reason,method:"WatchDocuments"}}]),n()):this.conditions.WatchLoop=!1,u(m)}})()})})}handleWatchDocumentsResponse(t,e){if(e.body.case==="event"&&e.body.value.type===Oi.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(e)}deactivateInternal(){this.status="deactivated";for(const[t,e]of this.attachmentMap)this.detachInternal(t),e.doc.applyStatus(si.Detached)}detachInternal(t){const e=this.attachmentMap.get(t);e&&(e.cancelWatchStream(),e.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,e){const{doc:n,docID:r}=t,o=n.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:r,changePack:lt.toChangePack(o),pushOnly:e==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${n.getKey()}`}}).then(s=>{const u=lt.fromChangePack(s.changePack);if(u.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return n;n.applyChangePack(u),t.doc.publish([{type:ft.SyncStatusChanged,value:va.Synced}]),n.getStatus()===si.Removed&&this.detachInternal(n.getKey());const c=n.getKey(),m=u.getChangeSize();return Ne.info(`[PP] c:"${this.getKey()}" sync d:"${c}", push:${o.getChangeSize()} pull:${m} cp:${u.getCheckpoint().toTestString()}`),n}).catch(async s=>{throw n.publish([{type:ft.SyncStatusChanged,value:va.SyncFailed}]),Ne.error(`[PP] c:"${this.getKey()}" err :`,s),s})}async handleConnectError(t){if(!(t instanceof Ze))return!1;if(t.code===Ge.Canceled||t.code===Ge.Unknown||t.code===Ge.ResourceExhausted||t.code===Ge.Unavailable)return!0;if(Mi(t)===te.ErrUnauthenticated){if(this.authTokenInjector){const e=await this.authTokenInjector(ao(t).reason);this.setAuthToken(e)}return!0}return(Mi(t)===te.ErrClientNotActivated||Mi(t)===te.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((e,n)=>{this.taskQueue.push(()=>t().then(e).catch(n)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{Ne.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const $s={Client:Ju,Document:Uu,Primitive:tt,Text:_s,Counter:Ps,Tree:Cs,LogLevel:wt,setLogLevel:Mu,IntType:Un.IntegerCnt,LongType:Un.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:Ju,Document:Uu,Primitive:tt,Text:_s,Counter:Ps,Tree:Cs,LogLevel:wt,setLogLevel:Mu,IntType:Un.IntegerCnt,LongType:Un.LongCnt});var Gh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $u(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var zu={exports:{}};/*! + */var Kt=null;try{Kt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function Ve(i,t,e){this.low=i|0,this.high=t|0,this.unsigned=!!e}Ve.prototype.__isLong__;Object.defineProperty(Ve.prototype,"__isLong__",{value:!0});function yt(i){return(i&&i.__isLong__)===!0}function vl(i){var t=Math.clz32(i&-i);return i?31-t:t}Ve.isLong=yt;var bl={},wl={};function Pi(i,t){var e,n,r;return t?(i>>>=0,(r=0<=i&&i<256)&&(n=wl[i],n)?n:(e=Ke(i,0,!0),r&&(wl[i]=e),e)):(i|=0,(r=-128<=i&&i<128)&&(n=bl[i],n)?n:(e=Ke(i,i<0?-1:0,!1),r&&(bl[i]=e),e))}Ve.fromInt=Pi;function Ht(i,t){if(isNaN(i))return t?Wr:an;if(t){if(i<0)return Wr;if(i>=hu)return pu}else{if(i<=-Tl)return Et;if(i+1>=Tl)return gu}return i<0?Ht(-i,t).neg():Ke(i%Zi|0,i/Zi|0,t)}Ve.fromNumber=Ht;function Ke(i,t,e){return new Ve(i,t,e)}Ve.fromBits=Ke;var As=Math.pow;function xa(i,t,e){if(i.length===0)throw Error("empty string");if(typeof t=="number"?(e=t,t=!1):t=!!t,i==="NaN"||i==="Infinity"||i==="+Infinity"||i==="-Infinity")return t?Wr:an;if(e=e||10,e<2||360)throw Error("interior hyphen");if(n===0)return xa(i.substring(1),t,e).neg();for(var r=Ht(As(e,8)),o=an,s=0;s>>0:this.low};he.toNumber=function(){return this.unsigned?(this.high>>>0)*Zi+(this.low>>>0):this.high*Zi+(this.low>>>0)};he.toString=function(t){if(t=t||10,t<2||36>>0,y=m.toString(t);if(s=c,s.isZero())return y+u;for(;y.length<6;)y="0"+y;u=""+y+u}};he.getHighBits=function(){return this.high};he.getHighBitsUnsigned=function(){return this.high>>>0};he.getLowBits=function(){return this.low};he.getLowBitsUnsigned=function(){return this.low>>>0};he.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Et)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,e=31;e>0&&!(t&1<=0};he.isOdd=function(){return(this.low&1)===1};he.isEven=function(){return(this.low&1)===0};he.equals=function(t){return yt(t)||(t=hn(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};he.eq=he.equals;he.notEquals=function(t){return!this.eq(t)};he.neq=he.notEquals;he.ne=he.notEquals;he.lessThan=function(t){return this.comp(t)<0};he.lt=he.lessThan;he.lessThanOrEqual=function(t){return this.comp(t)<=0};he.lte=he.lessThanOrEqual;he.le=he.lessThanOrEqual;he.greaterThan=function(t){return this.comp(t)>0};he.gt=he.greaterThan;he.greaterThanOrEqual=function(t){return this.comp(t)>=0};he.gte=he.greaterThanOrEqual;he.ge=he.greaterThanOrEqual;he.compare=function(t){if(yt(t)||(t=hn(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};he.comp=he.compare;he.negate=function(){return!this.unsigned&&this.eq(Et)?Et:this.not().add(Ji)};he.neg=he.negate;he.add=function(t){yt(t)||(t=hn(t));var e=this.high>>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,s=t.high>>>16,u=t.high&65535,c=t.low>>>16,m=t.low&65535,y=0,f=0,l=0,a=0;return a+=o+m,l+=a>>>16,a&=65535,l+=r+c,f+=l>>>16,l&=65535,f+=n+u,y+=f>>>16,f&=65535,y+=e+s,y&=65535,Ke(l<<16|a,y<<16|f,this.unsigned)};he.subtract=function(t){return yt(t)||(t=hn(t)),this.add(t.neg())};he.sub=he.subtract;he.multiply=function(t){if(this.isZero())return this;if(yt(t)||(t=hn(t)),Kt){var e=Kt.mul(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?Wr:an;if(this.eq(Et))return t.isOdd()?Et:an;if(t.eq(Et))return this.isOdd()?Et:an;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Sl)&&t.lt(Sl))return Ht(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,r=this.high&65535,o=this.low>>>16,s=this.low&65535,u=t.high>>>16,c=t.high&65535,m=t.low>>>16,y=t.low&65535,f=0,l=0,a=0,p=0;return p+=s*y,a+=p>>>16,p&=65535,a+=o*y,l+=a>>>16,a&=65535,a+=s*m,l+=a>>>16,a&=65535,l+=r*y,f+=l>>>16,l&=65535,l+=o*m,f+=l>>>16,l&=65535,l+=s*c,f+=l>>>16,l&=65535,f+=n*y+r*m+o*c+s*u,f&=65535,Ke(a<<16|p,f<<16|l,this.unsigned)};he.mul=he.multiply;he.divide=function(t){if(yt(t)||(t=hn(t)),t.isZero())throw Error("division by zero");if(Kt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var e=(this.unsigned?Kt.div_u:Kt.div_s)(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Wr:an;var n,r,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return Wr;if(t.gt(this.shru(1)))return du;o=Wr}else{if(this.eq(Et)){if(t.eq(Ji)||t.eq(ma))return Et;if(t.eq(Et))return Ji;var s=this.shr(1);return n=s.div(t).shl(1),n.eq(an)?t.isNegative()?Ji:ma:(r=this.sub(t.mul(n)),o=n.add(r.div(t)),o)}else if(t.eq(Et))return this.unsigned?Wr:an;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=an}for(r=this;r.gte(t);){n=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var u=Math.ceil(Math.log(n)/Math.LN2),c=u<=48?1:As(2,u-48),m=Ht(n),y=m.mul(t);y.isNegative()||y.gt(r);)n-=c,m=Ht(n,this.unsigned),y=m.mul(t);m.isZero()&&(m=Ji),o=o.add(m),r=r.sub(y)}return o};he.div=he.divide;he.modulo=function(t){if(yt(t)||(t=hn(t)),Kt){var e=(this.unsigned?Kt.rem_u:Kt.rem_s)(this.low,this.high,t.low,t.high);return Ke(e,Kt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};he.mod=he.modulo;he.rem=he.modulo;he.not=function(){return Ke(~this.low,~this.high,this.unsigned)};he.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};he.clz=he.countLeadingZeros;he.countTrailingZeros=function(){return this.low?vl(this.low):vl(this.high)+32};he.ctz=he.countTrailingZeros;he.and=function(t){return yt(t)||(t=hn(t)),Ke(this.low&t.low,this.high&t.high,this.unsigned)};he.or=function(t){return yt(t)||(t=hn(t)),Ke(this.low|t.low,this.high|t.high,this.unsigned)};he.xor=function(t){return yt(t)||(t=hn(t)),Ke(this.low^t.low,this.high^t.high,this.unsigned)};he.shiftLeft=function(t){return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low<>>32-t,this.unsigned):Ke(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):Ke(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};he.shr=he.shiftRight;he.shiftRightUnsigned=function(t){return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?Ke(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?Ke(this.high,0,this.unsigned):Ke(this.high>>>t-32,0,this.unsigned)};he.shru=he.shiftRightUnsigned;he.shr_u=he.shiftRightUnsigned;he.rotateLeft=function(t){var e;return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(e=32-t,Ke(this.low<>>e,this.high<>>e,this.unsigned)):(t-=32,e=32-t,Ke(this.high<>>e,this.low<>>e,this.unsigned))};he.rotl=he.rotateLeft;he.rotateRight=function(t){var e;return yt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?Ke(this.high,this.low,this.unsigned):t<32?(e=32-t,Ke(this.high<>>t,this.low<>>t,this.unsigned)):(t-=32,e=32-t,Ke(this.low<>>t,this.high<>>t,this.unsigned))};he.rotr=he.rotateRight;he.toSigned=function(){return this.unsigned?Ke(this.low,this.high,!1):this};he.toUnsigned=function(){return this.unsigned?this:Ke(this.low,this.high,!0)};he.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};he.toBytesLE=function(){var t=this.high,e=this.low;return[e&255,e>>>8&255,e>>>16&255,e>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};he.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,e>>>24,e>>>16&255,e>>>8&255,e&255]};Ve.fromBytes=function(t,e,n){return n?Ve.fromBytesLE(t,e):Ve.fromBytesBE(t,e)};Ve.fromBytesLE=function(t,e){return new Ve(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)};Ve.fromBytesBE=function(t,e){return new Ve(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)};var ht=(i=>(i[i.Null=0]="Null",i[i.Boolean=1]="Boolean",i[i.Integer=2]="Integer",i[i.Long=3]="Long",i[i.Double=4]="Double",i[i.String=5]="String",i[i.Bytes=6]="Bytes",i[i.Date=7]="Date",i))(ht||{});class tt extends ko{constructor(e,n){super(n);T(this,"valueType");T(this,"value");this.valueType=tt.getPrimitiveType(e),this.value=e===void 0?null:e}static of(e,n){return new tt(e,n)}static valueFromBytes(e,n){switch(e){case 0:return null;case 1:return!!n[0];case 2:return n[0]|n[1]<<8|n[2]<<16|n[3]<<24;case 4:{const r=new DataView(n.buffer);return n.forEach(function(o,s){r.setUint8(s,o)}),r.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(n);case 3:return Ve.fromBytesLE(Array.from(n));case 6:return n;case 7:return new Date(Ve.fromBytesLE(Array.from(n),!0).toNumber());default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return this.valueType===5?`"${Fn(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const e=tt.of(this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e.setRemovedAt(this.getRemovedAt()),e}getType(){return this.valueType}static getPrimitiveType(e){switch(typeof e){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(e)?2:4;case"string":return 5;case"object":if(e===null)return 0;if(e instanceof Ve)return 3;if(e instanceof Uint8Array)return 6;if(e instanceof Date)return 7}}static isSupport(e){return tt.getPrimitiveType(e)!==void 0}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===2||e===3||e===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 4:{const e=this.value,n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),n}case 5:return new TextEncoder().encode(this.value);case 3:{const n=this.value.toBytesLE();return Uint8Array.from(n)}case 6:return this.value;case 7:{const e=this.value,n=Ve.fromNumber(e.getTime(),!0).toBytesLE();return Uint8Array.from(n)}default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class Ts extends fu{constructor(e){super(e);T(this,"prev");T(this,"next");this.value=e}static createAfter(e,n){const r=new Ts(n),o=e.next;return e.next=r,r.prev=e,r.next=o,o&&(o.prev=r),r}remove(e){return this.value.remove(e)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class Ao{constructor(){T(this,"dummyHead");T(this,"last");T(this,"nodeMapByIndex");T(this,"nodeMapByCreatedAt");const t=tt.of(0,un);t.setRemovedAt(un),this.dummyHead=new Ts(t),this.last=this.dummyHead,this.nodeMapByIndex=new wo,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new Ao}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(t,e){let n=this.nodeMapByCreatedAt.get(t.toIDString());if(!n)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);for(;n.getNext()&&n.getNext().getPositionedAt().after(e);)n=n.getNext();return n}release(t){this.last===t&&(this.last=t.getPrev()),t.release(),this.nodeMapByIndex.delete(t),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}insertAfter(t,e,n=e.getCreatedAt()){const r=this.findNextBeforeExecutedAt(t,n),o=Ts.createAfter(r,e);r===this.last&&(this.last=o),this.nodeMapByIndex.insertAfter(r,o),this.nodeMapByCreatedAt.set(o.getCreatedAt().toIDString(),o)}moveAfter(t,e,n){const r=this.nodeMapByCreatedAt.get(t.toIDString());if(!r)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);const o=this.nodeMapByCreatedAt.get(e.toIDString());if(!o)throw new ne(te.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);r!==o&&(!o.getValue().getMovedAt()||n.after(o.getValue().getMovedAt()))&&(this.release(o),this.insertAfter(r.getCreatedAt(),o.getValue(),n),o.getValue().setMovedAt(n))}insert(t){this.insertAfter(this.last.getCreatedAt(),t)}getByID(t){return this.nodeMapByCreatedAt.get(t.toIDString())}subPathOf(t){const e=this.nodeMapByCreatedAt.get(t.toIDString());if(e)return String(this.nodeMapByIndex.indexOf(e))}purge(t){const e=this.nodeMapByCreatedAt.get(t.getCreatedAt().toIDString());if(!e)throw new ne(te.ErrInvalidArgument,`fail to find the given createdAt: ${t.getCreatedAt().toIDString()}`);this.release(e)}getByIndex(t){if(t>=this.length)return;const[e,n]=this.nodeMapByIndex.find(t);let r=e;if(t===0&&e===this.dummyHead||n>0)do r&&(r=r.getNext());while(r&&r.isRemoved());return r}getPrevCreatedAt(t){let e=this.nodeMapByCreatedAt.get(t.toIDString());do e=e.getPrev();while(this.dummyHead!==e&&e.isRemoved());return e.getValue().getCreatedAt()}delete(t,e){const n=this.nodeMapByCreatedAt.get(t.toIDString()),r=n.isRemoved();return n.remove(e)&&!r&&this.nodeMapByIndex.splayNode(n),n.getValue()}deleteByIndex(t,e){const n=this.getByIndex(t);if(n)return n.remove(e)&&this.nodeMapByIndex.splayNode(n),n.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const t=[];for(const e of this){const n=`${e.getCreatedAt().toIDString()}:${e.getValue().toJSON()}`;e.isRemoved()?t.push(`{${n}}`):t.push(`[${n}]`)}return t.join("")}*[Symbol.iterator](){let t=this.dummyHead.getNext();for(;t;)yield t,t=t.getNext()}}class Lt extends hi{constructor(e,n){super(e);T(this,"elements");this.elements=n}static create(e,n){if(!n)return new Lt(e,Ao.create());const r=Ao.create();for(const o of n)r.insertAfter(r.getLastCreatedAt(),o.deepcopy());return new Lt(e,r)}subPathOf(e){return this.elements.subPathOf(e)}purge(e){this.elements.purge(e)}insertAfter(e,n){this.elements.insertAfter(e,n)}moveAfter(e,n,r){this.elements.moveAfter(e,n,r)}get(e){const n=this.elements.getByIndex(e);return n==null?void 0:n.getValue()}getByID(e){const n=this.elements.getByID(e);return n==null?void 0:n.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(e){return this.elements.getPrevCreatedAt(e)}delete(e,n){return this.elements.delete(e,n)}deleteByIndex(e,n){return this.elements.deleteByIndex(e,n)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const e of this.elements)e.isRemoved()||(yield e.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(e){for(const n of this.elements){const r=n.getValue();if(e(r,this))return;r instanceof hi&&r.getDescendants(e)}}toJSON(){const e=[];for(const n of this)e.push(n.toJSON());return`[${e.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const e={};for(let n=0;n({...p,value:p.value?{attributes:zi(p.value.getAttributes()),content:p.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[y,a,f,[m,m]]}setStyle(e,n,r,o,s){const[,u]=this.rgaTreeSplit.findNodeWithSplit(e[1],r),[,c]=this.rgaTreeSplit.findNodeWithSplit(e[0],r),m=[],y=this.rgaTreeSplit.findBetween(c,u),f=new Map,l=[];for(const p of y){const b=p.getCreatedAt().getActorID();let w,v=0n;if(s===void 0&&o===void 0?v=fo:s.size()>0?v=s.get(b)?s.get(b):0n:w=o.has(b)?o.get(b):un,p.canStyle(r,w,v)){const h=f.get(b),g=p.getCreatedAt();(!h||g.after(h))&&f.set(b,g),l.push(p)}}const a=[];for(const p of l){if(p.isRemoved())continue;const[b,w]=this.rgaTreeSplit.findIndexesFromRange(p.createPosRange());m.push({type:"style",actor:r.getActorID(),from:b,to:w,value:{attributes:zi(n)}});for(const[v,h]of Object.entries(n)){const[g]=p.getValue().setAttr(v,h,r);g!==void 0&&a.push({parent:p.getValue(),child:g})}}return[f,a,m]}indexRangeToPosRange(e,n){const r=this.rgaTreeSplit.indexToPos(e);return e===n?[r,r]:[r,this.rgaTreeSplit.indexToPos(n)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const e=[];for(const n of this.rgaTreeSplit)n.isRemoved()||e.push(n.getValue().toJSON());return`[${e.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const e=[];for(const n of this.rgaTreeSplit)if(!n.isRemoved()){const r=n.getValue();e.push({attributes:zi(r.getAttributes()),content:r.getContent()})}return e}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const e=new Gt(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return e.remove(this.getRemovedAt()),e}findIndexesFromRange(e){return this.rgaTreeSplit.findIndexesFromRange(e)}getGCPairs(){const e=[];for(const n of this.rgaTreeSplit){n.getRemovedAt()&&e.push({parent:this.rgaTreeSplit,child:n});for(const r of n.getValue().getGCPairs())e.push(r)}return e}}class Io extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"content");T(this,"attributes");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.content=s,this.attributes=u}static create(e,n,r,o,s,u,c){return new Io(e,n,r,o,s,u,c)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Gt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Text can execute edit");const s=o,[,u,c]=s.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,r);for(const m of c)e.registerGCPair(m);return{opInfos:u.map(({from:m,to:y,value:f})=>({type:"edit",from:m,to:y,value:f,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=this.fromPos.toTestString(),r=this.toPos.toTestString(),o=this.content;return`${e}.EDIT(${n},${r},${o})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class No extends fn{constructor(e,n,r,o,s,u){super(e,u);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"attributes");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.attributes=s}static create(e,n,r,o,s,u){return new No(e,n,r,o,s,u)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Gt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Text can execute edit");const s=o,[,u,c]=s.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,r);for(const m of u)e.registerGCPair(m);return{opInfos:c.map(({from:m,to:y,value:f})=>({type:"style",from:m,to:y,value:f,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=this.fromPos.toTestString(),r=this.toPos.toTestString(),o=this.attributes;return`${e}.STYL(${n},${r},${JSON.stringify(o)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const Sf=2,Ef="root",Gr="text";function so(i,t){let e=0;const n=i.children;for(let r=0;r0)throw new ne(te.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let t=this.parent;const e=this.isRemoved?-1:1;for(;t&&(t.size+=this.paddedSize*e,!t.isRemoved);)t=t.parent}updateDescendantsSize(){let t=0;for(const e of this._children){const n=e.updateDescendantsSize();e.isRemoved||(t+=n)}return this.size+=t,this.paddedSize}get isText(){return this.type===Gr}get paddedSize(){return this.size+(this.isText?0:Sf)}isAncestorOf(t){return kf(this,t)}get nextSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t+1];if(e)return e}get prevSibling(){const t=this.parent.findOffset(this),e=this.parent.children[t-1];if(e)return e}splitText(t,e){if(t===0||t===this.size)return;const n=this.value.slice(0,t),r=this.value.slice(t);if(!r.length)return;this.value=n;const o=this.cloneText(t+e);return o.value=r,this.parent.insertAfterInternal(o,this),o}get children(){return this._children.filter(t=>!t.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(t=>t.isText)}append(...t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.push(...t);for(const e of t)e.parent=this,e.updateAncestorsSize()}prepend(...t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.unshift(...t);for(const e of t)e.parent=this}insertBefore(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n),t.updateAncestorsSize()}insertAfter(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n+1),t.updateAncestorsSize()}insertAt(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this.insertAtInternal(t,e),t.updateAncestorsSize()}removeChild(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const e=this._children.indexOf(t);if(e===-1)throw new ne(te.ErrInvalidArgument,"child not found");this._children.splice(e,1),t.parent=void 0}splitElement(t,e){const n=this.cloneElement(e);this.parent.insertAfterInternal(n,this),n.updateAncestorsSize();const r=this.children.slice(0,t),o=this.children.slice(t);this._children=r,n._children=o,this.size=this._children.reduce((s,u)=>s+u.paddedSize,0),n.size=n._children.reduce((s,u)=>s+u.paddedSize,0);for(const s of n._children)s.parent=n;return n}insertAfterInternal(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");const n=this._children.indexOf(e);if(n===-1)throw new ne(te.ErrInvalidArgument,"child not found");this.insertAtInternal(t,n+1)}insertAtInternal(t,e){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");this._children.splice(e,0,t),t.parent=this}findOffset(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");if(t.isRemoved){const e=this._children.indexOf(t);return this.allChildren.splice(0,e).filter(r=>!r.isRemoved).length}return this.children.indexOf(t)}findBranchOffset(t){if(this.isText)throw new ne(te.ErrRefused,"Text node cannot have children");let e=t;for(;e;){const n=this._children.indexOf(e);if(n!==-1)return n;e=e.parent}return-1}}function kf(i,t){if(i===t)return!1;for(;t.parent;){if(t.parent===i)return!0;t=t.parent}return!1}var ct=(i=>(i.Start="Start",i.End="End",i.Text="Text",i))(ct||{});function mu(i,t,e,n){if(t>e)throw new ne(te.ErrInvalidArgument,`from is greater than to: ${t} > ${e}`);if(t>i.size)throw new ne(te.ErrInvalidArgument,`from is out of range: ${t} > ${i.size}`);if(e>i.size)throw new ne(te.ErrInvalidArgument,`to is out of range: ${e} > ${i.size}`);if(t===e)return;let r=0;for(const o of i.children){if(t-o.paddedSizeo.size;(o.isText||c)&&n([o,o.isText?"Text":"Start"],m),mu(o,Math.max(0,s),Math.min(u,o.size),n),m&&n([o,"End"],m)}r+=o.paddedSize}}function yu(i,t,e=0){for(const n of i.children)yu(n,t,e+1);t(i,e)}function Ns(i,t,e=0){for(const n of i._children)Ns(n,t,e+1);t(i,e)}function ya(i,t,e=!0){if(t>i.size)throw new ne(te.ErrInvalidArgument,`index is out of range: ${t} > ${i.size}`);if(i.isText)return{node:i,offset:t};let n=0,r=0;for(const o of i.children){if(e&&o.isText&&o.size>=t-r)return ya(o,t-r,e);if(t===r)return{node:i,offset:n};if(!e&&o.paddedSize===t-r)return{node:i,offset:n+1};if(o.paddedSize>t-r)return ya(o,t-r-1,e);r+=o.paddedSize,n+=1}return{node:i,offset:n}}function vu(i){return i.isText||i.children.length===0?i:vu(i.children[0])}function Of(i,t){if(i.sizei===t?0:i0)if(e.right)e.right.parent=e,e=e.right;else return e;else if(n<0)if(e.left)e.left.parent=e,e=e.left;else{let r=e.parent,o=e;for(;r&&o===r.left;)o=r,r=r.parent;return r}else return e}}lastEntry(){if(!this.root)return this.root;let t=this.root;for(;t.right;)t=t.right;return t}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(t,e){for(;e;){const n=this.comparator(t,e.key);if(n===0)return e;n<0?e=e.left:n>0&&(e=e.right)}}putInternal(t,e,n){if(!n)return this.counter+=1,new _f(t,e,!0);const r=this.comparator(t,n.key);return r<0?n.left=this.putInternal(t,e,n.left):r>0?n.right=this.putInternal(t,e,n.right):n.value=e,this.isRed(n.right)&&!this.isRed(n.left)&&(n=this.rotateLeft(n)),this.isRed(n.left)&&this.isRed(n.left.left)&&(n=this.rotateRight(n)),this.isRed(n.left)&&this.isRed(n.right)&&this.flipColors(n),n}removeInternal(t,e){if(this.comparator(e,t.key)<0)!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeInternal(t.left,e);else{if(this.isRed(t.left)&&(t=this.rotateRight(t)),this.comparator(e,t.key)===0&&!t.right){this.counter-=1;return}if(!this.isRed(t.right)&&!this.isRed(t.right.left)&&(t=this.moveRedRight(t)),this.comparator(e,t.key)===0){this.counter-=1;const n=this.min(t.right);t.value=n.value,t.key=n.key,t.right=this.removeMin(t.right)}else t.right=this.removeInternal(t.right,e)}return this.fixUp(t)}min(t){return t.left?this.min(t.left):t}removeMin(t){if(t.left)return!this.isRed(t.left)&&!this.isRed(t.left.left)&&(t=this.moveRedLeft(t)),t.left=this.removeMin(t.left),this.fixUp(t)}fixUp(t){return this.isRed(t.right)&&(t=this.rotateLeft(t)),this.isRed(t.left)&&this.isRed(t.left.left)&&(t=this.rotateRight(t)),this.isRed(t.left)&&this.isRed(t.right)&&this.flipColors(t),t}moveRedLeft(t){return this.flipColors(t),this.isRed(t.right.left)&&(t.right=this.rotateRight(t.right),t=this.rotateLeft(t),this.flipColors(t)),t}moveRedRight(t){return this.flipColors(t),this.isRed(t.left.left)&&(t=this.rotateRight(t),this.flipColors(t)),t}isRed(t){return t&&t.isRed}rotateLeft(t){const e=t.right;return t.right=e.left,e.left=t,e.isRed=e.left.isRed,e.left.isRed=!0,e}rotateRight(t){const e=t.left;return t.left=e.right,e.right=t,e.isRed=e.right.isRed,e.right.isRed=!0,e}flipColors(t){t.isRed=!t.isRed,t.left.isRed=!t.left.isRed,t.right.isRed=!t.right.isRed}}class ln{constructor(t,e){T(this,"parentID");T(this,"leftSiblingID");this.parentID=t,this.leftSiblingID=e}static of(t,e){return new ln(t,e)}static fromTreePos(t){const{offset:e}=t;let{node:n}=t,r;return n.isText?(n.parent.children[0]===n&&e===0?r=n.parent:r=n,n=n.parent):e===0?r=n:r=n.children[e-1],ln.of(n.id,pt.of(r.getCreatedAt(),r.getOffset()+e))}getParentID(){return this.parentID}static fromStruct(t){return ln.of(pt.of(Wt.fromStruct(t.parentID.createdAt),t.parentID.offset),pt.of(Wt.fromStruct(t.leftSiblingID.createdAt),t.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(t){const e=this.getParentID(),n=this.getLeftSiblingID(),r=t.findFloorNode(e);let o=t.findFloorNode(n);if(!r||!o)throw new ne(te.ErrRefused,`cannot find node of CRDTTreePos(${e.toTestString()}, ${n.toTestString()})`);return!n.equals(e)&&n.getOffset()>0&&n.getOffset()===o.id.getOffset()&&o.insPrevID&&(o=t.findFloorNode(o.insPrevID)),[r,o]}getLeftSiblingID(){return this.leftSiblingID}equals(t){return this.getParentID().getCreatedAt().equals(t.getParentID().getCreatedAt())&&this.getParentID().getOffset()===t.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(t.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===t.getLeftSiblingID().getOffset()}}class pt{constructor(t,e){T(this,"createdAt");T(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new pt(t,e)}static fromStruct(t){return pt.of(Wt.fromStruct(t.createdAt),t.offset)}static createComparator(){return(t,e)=>{const n=t.getCreatedAt().compare(e.getCreatedAt());return n!==0?n:t.getOffset()>e.getOffset()?1:t.getOffset(){const o=r.deepcopy();return o.parent=e,o}),e.insPrevID=this.insPrevID,e.insNextID=this.insNextID,e}get value(){if(!this.isText)throw new ne(te.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(e){if(!this.isText)throw new ne(te.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=e,this.size=e.length}get isRemoved(){return!!this.removedAt}remove(e){const n=!this.removedAt;(!this.removedAt||this.removedAt.compare(e)>0)&&(this.removedAt=e),n&&this.updateAncestorsSize()}cloneText(e){return new Ct(pt.of(this.id.getCreatedAt(),e),this.type,void 0,void 0,this.removedAt)}cloneElement(e){return new Ct(pt.of(e(),0),this.type,void 0,void 0,this.removedAt)}split(e,n,r){const o=this.isText?this.splitText(n,this.id.getOffset()):this.splitElement(n,r);if(o){if(o.insPrevID=this.id,this.insNextID){const s=e.findFloorNode(this.insNextID);s.insPrevID=o.id,o.insNextID=this.insNextID}this.insNextID=o.id,e.registerNode(o)}return o}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(e,n,r){return(n?!this.getCreatedAt().after(n):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}canStyle(e,n,r){return this.isText?!1:(n?!this.getCreatedAt().after(n):this.getCreatedAt().getLamport()<=r)&&(!this.removedAt||e.after(this.removedAt))}setAttrs(e,n){this.attrs||(this.attrs=new Xr);const r=[];for(const[o,s]of Object.entries(e))r.push(this.attrs.set(o,s,n));return r}purge(e){this.attrs&&this.attrs.purge(e)}getGCPairs(){const e=[];if(!this.attrs)return e;for(const n of this.attrs)n.getRemovedAt()&&e.push({parent:this,child:n});return e}}function va(i){var e;if(i.isText){const n=i;return{type:n.type,value:n.value}}const t={type:i.type,children:i.children.map(va)};return i.attrs&&(t.attributes=zi((e=i.attrs)==null?void 0:e.toObject())),t}function ka(i){if(i.isText)return i.value;let t="";return i.attrs&&i.attrs.size()&&(t=" "+Array.from(i.attrs).filter(e=>!e.isRemoved()).sort((e,n)=>e.getKey().localeCompare(n.getKey())).map(e=>{const n=JSON.parse(e.getValue());return typeof n=="string"?`${e.getKey()}="${n}"`:`${e.getKey()}="${Fn(e.getValue())}"`}).join(" ")),`<${i.type}${t}>${i.children.map(e=>ka(e)).join("")}`}function wu(i){if(i.isText){const t=i;return{type:t.type,value:t.value,size:t.size,isRemoved:t.isRemoved}}return{type:i.type,children:i.children.map(wu),size:i.size,isRemoved:i.isRemoved}}class Yt extends ko{constructor(e,n){super(n);T(this,"indexTree");T(this,"nodeMapByID");this.indexTree=new If(e),this.nodeMapByID=new bu(pt.createComparator()),this.indexTree.traverseAll(r=>{this.nodeMapByID.put(r.id,r)})}static create(e,n){return new Yt(e,n)}findFloorNode(e){const n=this.nodeMapByID.floorEntry(e);if(!(!n||!n.key.getCreatedAt().equals(e.getCreatedAt())))return n.value}registerNode(e){this.nodeMapByID.put(e.id,e)}findNodesAndSplitText(e,n){const[r,o]=e.toTreeNodePair(this);let s=o;const u=r===s,c=s.parent&&!u?s.parent:r;if(s.isText&&s.split(this,e.getLeftSiblingID().getOffset()-s.id.getOffset()),n){const m=c.allChildren,y=u?0:m.indexOf(s)+1;for(let f=y;f{const w=b.getCreatedAt().getActorID();let v,h=0n;if(s===void 0&&o===void 0?h=fo:s.size()>0?h=s.get(w)?s.get(w):0n:v=o.has(w)?o.get(w):un,b.canStyle(r,v,h)&&n){const g=a.get(w),d=b.getCreatedAt();(!g||d.after(g))&&a.set(w,d);const A=b.setAttrs(n,r),S=A.reduce((_,[,k])=>(k&&(_[k.getKey()]=l[k.getKey()]),_),{}),E=b.parent,O=b.prevSibling||b.parent;Object.keys(S).length>0&&f.push({type:"style",from:this.toIndex(E,O),to:this.toIndex(b,b),fromPath:this.toPath(E,O),toPath:this.toPath(b,b),actor:r.getActorID(),value:S});for(const[_]of A)_&&p.push({parent:b,child:_})}}),[a,p,f]}removeStyle(e,n,r,o,s){const[u,c]=this.findNodesAndSplitText(e[0],r),[m,y]=this.findNodesAndSplitText(e[1],r),f=[],l=new Map,a=[];return this.traverseInPosRange(u,c,m,y,([p])=>{const b=p.getCreatedAt().getActorID();let w,v=0n;if(s===void 0&&o===void 0?v=fo:s.size()>0?v=s.get(b)?s.get(b):0n:w=o.has(b)?o.get(b):un,p.canStyle(r,w,v)&&n){const h=l.get(b),g=p.getCreatedAt();(!h||g.after(h))&&l.set(b,g),p.attrs||(p.attrs=new Xr);for(const S of n){const E=p.attrs.remove(S,r);for(const O of E)a.push({parent:p,child:O})}const d=p.parent,A=p.prevSibling||p.parent;f.push({actor:r.getActorID(),type:"removeStyle",from:this.toIndex(d,A),to:this.toIndex(p,p),fromPath:this.toPath(d,A),toPath:this.toPath(p,p),value:n})}}),[l,a,f]}edit(e,n,r,o,s,u,c){const[m,y]=this.findNodesAndSplitText(e[0],o),[f,l]=this.findNodesAndSplitText(e[1],o),a=this.toIndex(m,y),p=this.toPath(m,y),b=[],w=[],v=[],h=new Map;this.traverseInPosRange(m,y,f,l,([A,S],E)=>{if(S===ct.Start&&!E)for(const x of A.children)v.push(x);const O=A.getCreatedAt().getActorID();let _,k=0n;if(c===void 0&&u===void 0?k=fo:c.size()>0?k=c.get(O)?c.get(O):0n:_=u.has(O)?u.get(O):un,A.canDelete(o,_,k)||b.includes(A.parent)){const x=h.get(O),I=A.getCreatedAt();(!x||I.after(x))&&h.set(O,I),(S===ct.Text||S===ct.Start)&&b.push(A),w.push([A,S])}});const g=this.makeDeletionChanges(w,o),d=[];for(const A of b)A.remove(o),A.isRemoved&&d.push({parent:this,child:A});for(const A of v)A.removedAt||m.append(A);if(r>0){let A=0,S=m,E=y;for(;A{m.isRemoved&&(O.remove(o),d.push({parent:this,child:O})),this.nodeMapByID.put(O.id,O)}),E.isRemoved||A.push(E);if(A.length){const E=A.map(O=>va(O));g.length&&g[g.length-1].from===a?g[g.length-1].value=E:g.push({type:"content",from:a,to:a,fromPath:p,toPath:p,actor:o.getActorID(),value:E})}}return[g,d,h]}editT(e,n,r,o,s){const u=this.findPos(e[0]),c=this.findPos(e[1]);this.edit([u,c],n,r,o,s)}move(e,n,r){throw new ne(te.ErrUnimplemented,`not implemented: ${e}, ${n}, ${r}`)}purge(e){var o;(o=e.parent)==null||o.removeChild(e),this.nodeMapByID.remove(e.id);const n=e.insPrevID,r=e.insNextID;if(n){const s=this.findFloorNode(n);s.insNextID=r}if(r){const s=this.findFloorNode(r);s.insPrevID=n}e.insPrevID=void 0,e.insNextID=void 0}getGCPairs(){const e=[];return this.indexTree.traverse(n=>{n.getRemovedAt()&&e.push({parent:this,child:n});for(const r of n.getGCPairs())e.push(r)}),e}findPos(e,n=!0){const r=this.indexTree.findTreePos(e,n);return ln.fromTreePos(r)}pathToPosRange(e){const n=this.pathToIndex(e);return[this.findPos(n),this.findPos(n+1)]}pathToPos(e){const n=this.indexTree.pathToIndex(e);return this.findPos(n)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ka(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const e=this.indexTree.getRoot(),n=(r,o=void 0,s=void 0,u=0)=>{var a,p,b,w;let c,m,y;const f=r.isText?{node:r,offset:0}:o&&s?this.toTreePos(o,s):null;f&&(c=this.indexTree.indexOf(f),m=this.indexTree.treePosToPath(f),y=ln.fromTreePos(f).toStruct());const l={type:r.type,parent:o==null?void 0:o.id.toTestString(),size:r.size,id:r.id.toTestString(),removedAt:(a=r.removedAt)==null?void 0:a.toTestString(),insPrev:(p=r.insPrevID)==null?void 0:p.toTestString(),insNext:(b=r.insNextID)==null?void 0:b.toTestString(),value:r.isText?r.value:void 0,isRemoved:r.isRemoved,children:[],depth:u,attributes:r.attrs?zi((w=r.attrs)==null?void 0:w.toObject()):void 0,index:c,path:m,pos:y};for(let v=0;v0&&v===r[r.length-1].to?(r[r.length-1].to=h,r[r.length-1].toPath=this.toPath(w,a)):r.push({type:"content",from:v,to:h,fromPath:this.toPath(b,f),toPath:this.toPath(w,a),actor:n.getActorID()}))}return r.reverse()}findRightToken([e,n]){if(n===ct.Start){const c=e.allChildren;return c.length>0?[c[0],c[0].isText?ct.Text:ct.Start]:[e,ct.End]}const r=e.parent,o=r.allChildren,s=o.indexOf(e);if(r&&s===o.length-1)return[r,ct.End];const u=o[s+1];return[u,u.isText?ct.Text:ct.Start]}findLeftToken([e,n]){if(n===ct.End){const c=e.allChildren;if(c.length>0){const m=c[c.length-1];return[m,m.isText?ct.Text:ct.End]}return[e,ct.Start]}const r=e.parent,o=r.allChildren,s=o.indexOf(e);if(r&&s===0)return[r,ct.Start];const u=o[s-1];return[u,u.isText?ct.Text:ct.End]}}class _o extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"contents");T(this,"splitLevel");T(this,"maxCreatedAtMapByActor");this.fromPos=n,this.toPos=r,this.contents=o,this.splitLevel=s,this.maxCreatedAtMapByActor=u}static create(e,n,r,o,s,u,c){return new _o(e,n,r,o,s,u,c)}execute(e,n,r){var y;const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Yt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const s=this.getExecutedAt(),u=o,[c,m]=u.edit([this.fromPos,this.toPos],(y=this.contents)==null?void 0:y.map(f=>f.deepcopy()),this.splitLevel,s,(()=>{let f=s.getDelimiter();return this.contents!==void 0&&(f+=this.contents.length),()=>Wt.of(s.getLamport(),++f,s.getActorID())})(),this.maxCreatedAtMapByActor,r);for(const f of m)e.registerGCPair(f);return{opInfos:c.map(({from:f,to:l,value:a,splitLevel:p,fromPath:b,toPath:w})=>({type:"tree-edit",path:e.createPath(this.getParentCreatedAt()),from:f,to:l,value:a,splitLevel:p,fromPath:b,toPath:w}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,o=this.contents||[];return`${e}.EDIT(${n},${r},${o.map(s=>ka(s)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class Vi{constructor(t){T(this,"vector");this.vector=t||new Map}set(t,e){this.vector.set(t,e)}unset(t){this.vector.delete(t)}get(t){return this.vector.get(t)}maxLamport(){let t=BigInt(0);for(const[,e]of this)e>t&&(t=e);return t}max(t){const e=new Map;for(const[n,r]of t){const o=this.vector.get(n),s=o&&o>r?o:r;e.set(n,s)}for(const[n,r]of this){const o=t.get(n),s=o&&o>r?o:r;e.set(n,s)}return new Vi(e)}afterOrEqual(t){const e=this.vector.get(t.getActorID());return e===void 0?!1:e>=t.getLamport()}deepcopy(){const t=new Map;for(const[e,n]of this.vector)t.set(e,n);return new Vi(t)}filter(t){const e=new Map;for(const[n]of t){const r=this.vector.get(n);r!==void 0&&e.set(n,r)}return new Vi(e)}size(){return this.vector.size}*[Symbol.iterator](){for(const[t,e]of this.vector)yield[t,e]}}const Cf=new Vi(new Map);class zr{constructor(t,e,n,r,o){T(this,"clientSeq");T(this,"serverSeq");T(this,"lamport");T(this,"actor");T(this,"versionVector");this.clientSeq=t,this.serverSeq=o,this.lamport=e,this.versionVector=r,this.actor=n}static of(t,e,n,r,o){return new zr(t,e,n,r,o)}next(){const t=this.versionVector.deepcopy();return t.set(this.actor,this.lamport+1n),new zr(this.clientSeq+1,this.lamport+1n,this.actor,t)}syncClocks(t){const e=t.lamport>this.lamport?t.lamport+1n:this.lamport+1n;let n=t.versionVector;n.size()===0&&(n=n.deepcopy(),n.set(t.actor,t.lamport));const r=this.versionVector.max(n),o=new zr(this.clientSeq,e,this.actor,r);return o.versionVector.set(this.actor,e),o}setClocks(t,e){const n=t>this.lamport?t+1n:this.lamport+1n;e.unset(Is);const r=this.versionVector.max(e);return r.set(this.actor,n),zr.of(this.clientSeq,n,this.actor,r)}createTimeTicket(t){return Wt.of(this.lamport,t,this.actor)}setActor(t){return new zr(this.clientSeq,this.lamport,t,this.versionVector,this.serverSeq)}setVersionVector(t){return new zr(this.clientSeq,this.lamport,this.actor,t,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const Lf=new zr(0,0n,Is,Cf);class Xi{constructor({id:t,operations:e,presenceChange:n,message:r}){T(this,"id");T(this,"operations");T(this,"presenceChange");T(this,"message");this.id=t,this.operations=e||[],this.presenceChange=n,this.message=r}static create({id:t,operations:e,presenceChange:n,message:r}){return new Xi({id:t,operations:e,presenceChange:n,message:r})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(t){for(const e of this.operations)e.setActor(t);this.id=this.id.setActor(t)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(t,e,n){const r=[],o=[];for(const s of this.operations){const u=s.execute(t,n,this.id.getVersionVector());if(!u)continue;const{opInfos:c,reverseOp:m}=u;r.push(...c),m&&o.unshift(m)}return this.presenceChange&&(this.presenceChange.type===pi.Put?e.set(this.id.getActorID(),sn(this.presenceChange.presence)):e.delete(this.id.getActorID())),{opInfos:r,reverseOps:o}}toTestString(){return`${this.operations.map(t=>t.toTestString()).join(",")}`}toStruct(){return{changeID:lt.bytesToHex(lt.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(t=>lt.bytesToHex(lt.toOperation(t).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(t){const{changeID:e,operations:n,presenceChange:r,message:o}=t;return Xi.create({id:lt.bytesToChangeID(lt.hexToBytes(e)),operations:n==null?void 0:n.map(s=>lt.bytesToOperation(lt.hexToBytes(s))),presenceChange:r,message:o})}}class _s{constructor(t,e,n,r,o,s,u){T(this,"documentKey");T(this,"checkpoint");T(this,"isRemoved");T(this,"changes");T(this,"snapshot");T(this,"minSyncedTicket");T(this,"versionVector");this.documentKey=t,this.checkpoint=e,this.isRemoved=n,this.changes=r,this.snapshot=s,this.minSyncedTicket=u,this.versionVector=o}static create(t,e,n,r,o,s,u){return new _s(t,e,n,r,o,s,u)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class Ki{constructor(t,e){T(this,"serverSeq");T(this,"clientSeq");this.serverSeq=t,this.clientSeq=e}static of(t,e){return new Ki(t,e)}increaseClientSeq(t){return t===0?this:new Ki(this.serverSeq,this.clientSeq+t)}forward(t){if(this.equals(t))return this;const e=this.serverSeq>t.serverSeq?this.serverSeq:t.serverSeq,n=Math.max(this.clientSeq,t.clientSeq);return Ki.of(e,n)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(t){return this.clientSeq===t.clientSeq&&this.serverSeq==t.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const Rf=new Ki(0n,0);class jn{constructor(t,e){T(this,"createdAt");T(this,"offset");this.createdAt=t,this.offset=e}static of(t,e){return new jn(t,e)}static fromStruct(t){return jn.of(Wt.fromStruct(t.createdAt),t.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(t){return this.createdAt.compare(t.createdAt)===0&&this.offset===t.offset}hasSameCreatedAt(t){return this.createdAt.compare(t.createdAt)===0}split(t){return new jn(this.createdAt,this.offset+t)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const Df=jn.of(un,0);class cn{constructor(t,e){T(this,"id");T(this,"relativeOffset");this.id=t,this.relativeOffset=e}static of(t,e){return new cn(t,e)}static fromStruct(t){const e=jn.fromStruct(t.id);return cn.of(e,t.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return jn.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(t){return this.id.equals(t.id)?this.relativeOffset===t.relativeOffset:!1}}class di extends fu{constructor(e,n,r){super(n);T(this,"id");T(this,"removedAt");T(this,"prev");T(this,"next");T(this,"insPrev");T(this,"insNext");this.id=e,this.removedAt=r}static create(e,n){return new di(e,n)}static createComparator(){return(e,n)=>{const r=e.getCreatedAt().compare(n.getCreatedAt());return r!==0?r:e.getOffset()>n.getOffset()?1:e.getOffset()0&&e.getID().getOffset()==t.getOffset()){if(!e.hasInsPrev())return e;e=e.getInsPrev()}return e}findFloorNode(t){const e=this.treeByID.floorEntry(t);if(e&&!(!e.key.equals(t)&&!e.key.hasSameCreatedAt(t)))return e.value}findBetween(t,e){const n=[];let r=t;for(;r&&r!==e;)n.push(r),r=r.getNext();return n}splitNode(t,e){if(e>t.getContentLength())throw new ne(te.ErrInvalidArgument,"offset should be less than or equal to length");if(e===0)return t;if(e===t.getContentLength())return t.getNext();const n=t.split(e);this.treeByIndex.updateWeight(n),this.insertAfter(t,n);const r=t.getInsNext();return r&&r.setInsPrev(n),n.setInsPrev(t),n}deleteNodes(t,e,n,r){if(!t.length)return[[],new Map,new Map];const[o,s]=this.filterNodes(t,e,n,r),u=new Map,c=new Map,m=this.makeChanges(s,e);for(const y of o){const f=y.getCreatedAt().getActorID();(!u.has(f)||y.getID().getCreatedAt().after(u.get(f)))&&u.set(f,y.getID().getCreatedAt()),c.set(y.getID().toIDString(),y),y.remove(e)}return this.deleteIndexNodes(s),[m,u,c]}filterNodes(t,e,n,r){const o=[],s=[],[u,c]=this.findEdgesOfCandidates(t);s.push(u);for(const m of t){const y=m.getCreatedAt().getActorID();let f,l=0n;r===void 0&&n===void 0?l=fo:r.size()>0?l=r.get(y)?r.get(y):0n:f=n.has(y)?n.get(y):un,m.canDelete(e,f,l)?o.push(m):s.push(m)}return s.push(c),[o,s]}findEdgesOfCandidates(t){return[t[0].getPrev(),t[t.length-1].getNext()]}makeChanges(t,e){const n=[];let r,o;for(let s=0;si<0?Math.ceil(i):Math.floor(i);var Un=(i=>(i[i.IntegerCnt=0]="IntegerCnt",i[i.LongCnt=1]="LongCnt",i))(Un||{});class Rt extends ko{constructor(e,n,r){super(r);T(this,"valueType");T(this,"value");switch(this.valueType=e,e){case 0:typeof n=="number"?n>Math.pow(2,31)-1||n<-Math.pow(2,31)?this.value=Ve.fromNumber(n).toInt():this.value=El(n):this.value=n.toInt();break;case 1:typeof n=="number"?this.value=Ve.fromNumber(n):this.value=n;break;default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}static create(e,n,r){return new Rt(e,n,r)}static valueFromBytes(e,n){switch(e){case 0:return n[0]|n[1]<<8|n[2]<<16|n[3]<<24;case 1:return Ve.fromBytesLE(Array.from(n));default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${e}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const e=Rt.create(this.valueType,this.value,this.getCreatedAt());return e.setMovedAt(this.getMovedAt()),e}getType(){return this.valueType}static getCounterType(e){switch(typeof e){case"object":return e instanceof Ve?1:void 0;case"number":return e>Math.pow(2,31)-1||e<-Math.pow(2,31)?1:0;default:return}}static isSupport(e){return!!Rt.getCounterType(e)}static isInteger(e){return e%1===0}isNumericType(){const e=this.valueType;return e===0||e===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const e=this.value;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}case 1:{const n=this.value.toBytesLE();return Uint8Array.from(n)}default:throw new ne(te.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(e){function n(r){if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`)}return n(this),n(e),this.valueType===1?this.value=this.value.add(e.getValue()):e.getType()===ht.Long?this.value=this.value+e.getValue().toInt():this.value=Ve.fromNumber(this.value+El(e.getValue())).toInt(),this}}class eo extends fn{constructor(e,n,r){super(e,r);T(this,"value");this.value=n}static create(e,n,r){return new eo(e,n,r)}execute(e){const n=e.findByCreatedAt(this.getParentCreatedAt());if(!n)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(n instanceof Rt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const r=n,o=this.value.deepcopy();return r.increase(o),{opInfos:[{type:"increase",path:e.createPath(this.getParentCreatedAt()),value:o.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const e=this.value.deepcopy(),r=e.getType()===ht.Long?e.getValue().multiply(-1):e.getValue()*-1;return eo.create(this.getParentCreatedAt(),tt.of(r,e.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class Yr extends fn{constructor(e,n,r,o,s,u,c){super(e,c);T(this,"fromPos");T(this,"toPos");T(this,"maxCreatedAtMapByActor");T(this,"attributes");T(this,"attributesToRemove");this.fromPos=n,this.toPos=r,this.maxCreatedAtMapByActor=o,this.attributes=s,this.attributesToRemove=u}static create(e,n,r,o,s,u){return new Yr(e,n,r,o,s,[],u)}static createTreeRemoveStyleOperation(e,n,r,o,s,u){return new Yr(e,n,r,o,new Map,s,u)}execute(e,n,r){const o=e.findByCreatedAt(this.getParentCreatedAt());if(!o)throw new ne(te.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(o instanceof Yt))throw new ne(te.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const s=o;let u,c;if(this.attributes.size){const m={};[...this.attributes].forEach(([y,f])=>m[y]=f),[,c,u]=s.style([this.fromPos,this.toPos],m,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}else{const m=this.attributesToRemove;[,c,u]=s.removeStyle([this.fromPos,this.toPos],m,this.getExecutedAt(),this.maxCreatedAtMapByActor,r)}for(const m of c)e.registerGCPair(m);return{opInfos:u.map(({from:m,to:y,value:f,fromPath:l,toPath:a})=>({type:"tree-style",from:m,to:y,value:this.attributes.size?{attributes:f}:{attributesToRemove:f},fromPath:l,toPath:a,path:e.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const e=this.getParentCreatedAt().toTestString(),n=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,r=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${e}.STYLE(${n},${r},${Object.entries(this.attributes||{}).map(([o,s])=>`${o}:"${s}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function Bf(i){const t=new Sa,e=t.data;for(const[n,r]of Object.entries(i))e[n]=JSON.stringify(r);return t}function Mf(i){if(i.type===pi.Put)return new vo({type:Ni.PUT,presence:Bf(i.presence)});if(i.type===pi.Clear)return new vo({type:Ni.CLEAR});throw new ne(te.ErrUnimplemented,"unimplemented type")}function qf(i){return new lu({serverSeq:i.getServerSeq(),clientSeq:i.getClientSeq()})}function Au(i){return new ks({clientSeq:i.getClientSeq(),lamport:i.getLamport(),actorId:Ma(i.getActorID()),versionVector:Oa(i.getVersionVector())})}function ke(i){if(i)return new xe({lamport:i.getLamport(),delimiter:i.getDelimiter(),actorId:Ma(i.getActorID())})}function Oa(i){if(!i)return;const t=new Os;for(const[e,n]of i)t.vector[e]=BigInt(n.toString());return t}function Tu(i){switch(i){case ht.Null:return Re.NULL;case ht.Boolean:return Re.BOOLEAN;case ht.Integer:return Re.INTEGER;case ht.Long:return Re.LONG;case ht.Double:return Re.DOUBLE;case ht.String:return Re.STRING;case ht.Bytes:return Re.BYTES;case ht.Date:return Re.DATE;default:throw new ne(te.ErrInvalidType,`unsupported type: ${i}`)}}function Su(i){switch(i){case Un.IntegerCnt:return Re.INTEGER_CNT;case Un.LongCnt:return Re.LONG_CNT;default:throw new ne(te.ErrInvalidType,`unsupported type: ${i}`)}}function js(i){if(i instanceof xt)return new Bt({type:Re.JSON_OBJECT,createdAt:ke(i.getCreatedAt()),value:Bu(i)});if(i instanceof Lt)return new Bt({type:Re.JSON_ARRAY,createdAt:ke(i.getCreatedAt()),value:ph(i)});if(i instanceof Gt)return new Bt({type:Re.TEXT,createdAt:ke(i.getCreatedAt())});if(i instanceof tt)return new Bt({type:Tu(i.getType()),createdAt:ke(i.getCreatedAt()),value:i.toBytes()});if(i instanceof Rt)return new Bt({type:Su(i.getType()),createdAt:ke(i.getCreatedAt()),value:i.toBytes()});if(i instanceof Yt)return new Bt({type:Re.TREE,createdAt:ke(i.getCreatedAt()),value:yh(i)});throw new ne(te.ErrUnimplemented,"unimplemented element")}function Ff(i){return new mo({createdAt:ke(i.getCreatedAt()),offset:i.getOffset()})}function Uo(i){return new Zr({createdAt:ke(i.getID().getCreatedAt()),offset:i.getID().getOffset(),relativeOffset:i.getRelativeOffset()})}function Jo(i){return new Ii({parentId:ho(i.getParentID()),leftSiblingId:ho(i.getLeftSiblingID())})}function ho(i){return new fi({createdAt:ke(i.getCreatedAt()),offset:i.getOffset()})}function Eu(i){const t=new Ta;if(i instanceof _i){const e=i,n=new rs;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.key=e.getKey(),n.value=js(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="set",t.body.value=n}else if(i instanceof Oo){const e=i,n=new is;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.prevCreatedAt=ke(e.getPrevCreatedAt()),n.value=js(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="add",t.body.value=n}else if(i instanceof ci){const e=i,n=new os;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.prevCreatedAt=ke(e.getPrevCreatedAt()),n.createdAt=ke(e.getCreatedAt()),n.executedAt=ke(e.getExecutedAt()),t.body.case="move",t.body.value=n}else if(i instanceof mi){const e=i,n=new ss;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.createdAt=ke(e.getCreatedAt()),n.executedAt=ke(e.getExecutedAt()),t.body.case="remove",t.body.value=n}else if(i instanceof Io){const e=i,n=new as;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Uo(e.getFromPos()),n.to=Uo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);n.content=e.getContent();const o=n.attributes;for(const[s,u]of e.getAttributes())o[s]=u;n.executedAt=ke(e.getExecutedAt()),t.body.case="edit",t.body.value=n}else if(i instanceof No){const e=i,n=new ls;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Uo(e.getFromPos()),n.to=Uo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);const o=n.attributes;for(const[s,u]of e.getAttributes())o[s]=u;n.executedAt=ke(e.getExecutedAt()),t.body.case="style",t.body.value=n}else if(i instanceof eo){const e=i,n=new us;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.value=js(e.getValue()),n.executedAt=ke(e.getExecutedAt()),t.body.case="increase",t.body.value=n}else if(i instanceof _o){const e=i,n=new cs,r=n.createdAtMapByActor;for(const[o,s]of e.getMaxCreatedAtMapByActor())r[o]=ke(s);n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Jo(e.getFromPos()),n.to=Jo(e.getToPos()),n.contents=Kf(e.getContents()),n.splitLevel=e.getSplitLevel(),n.executedAt=ke(e.getExecutedAt()),t.body.case="treeEdit",t.body.value=n}else if(i instanceof Yr){const e=i,n=new fs;n.parentCreatedAt=ke(e.getParentCreatedAt()),n.from=Jo(e.getFromPos()),n.to=Jo(e.getToPos());const r=n.createdAtMapByActor;for(const[s,u]of e.getMaxCreatedAtMapByActor())r[s]=ke(u);const o=e.getAttributesToRemove();if(o.length>0)n.attributesToRemove=o;else{const s=n.attributes;for(const[u,c]of e.getAttributes())s[u]=c}n.executedAt=ke(e.getExecutedAt()),t.body.case="treeStyle",t.body.value=n}else throw new ne(te.ErrUnimplemented,"unimplemented operation");return t}function jf(i){const t=[];for(const e of i)t.push(Eu(e));return t}function Uf(i){const t=new su({id:Au(i.getID()),message:i.getMessage()});return i.hasOperations()&&(t.operations=jf(i.getOperations())),i.hasPresenceChange()&&(t.presenceChange=Mf(i.getPresenceChange())),t}function Jf(i){const t=[];for(const e of i)t.push(Uf(e));return t}function $f(i){const t=[];for(const e of i)t.push(new au({key:e.getStrKey(),element:Na(e.getValue())}));return t}function zf(i){const t=[];for(const e of i)t.push(new vs({element:Na(e.getValue())}));return t}function Vf(i){const t=[];for(const e of i){const n=new bs;n.id=Ff(e.getID()),n.value=e.getValue().getContent(),n.removedAt=ke(e.getRemovedAt());const r=n.attributes,o=e.getValue().getAttrs();for(const s of o){const u=new Gi;u.value=s.getValue(),u.updatedAt=ke(s.getUpdatedAt()),r[s.getKey()]=u}t.push(n)}return t}function Kf(i){const t=[];if(!i||!i.length)return t;for(const e of i)t.push(new ws({content:Ia(e)}));return t}function Hf(i){const t={};for(const e of i)t[e.getKey()]=new Gi({value:e.getValue(),updatedAt:ke(e.getUpdatedAt()),isRemoved:e.isRemoved()});return t}function Ia(i){if(!i)return[];const t=[];return Ns(i,(e,n)=>{const r=new yo({id:ho(e.id),type:e.type,removedAt:ke(e.removedAt),depth:n});e.isText&&(r.value=e.value),e.insPrevID&&(r.insPrevId=ho(e.insPrevID)),e.insNextID&&(r.insNextId=ho(e.insNextID)),e.attrs&&(r.attributes=Hf(e.attrs)),t.push(r)}),t}function Wf(i){const t=new kt;return t.body.case="jsonObject",t.body.value=new hs({nodes:$f(i.getRHT()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function xu(i){const t=new kt;return t.body.case="jsonArray",t.body.value=new ds({nodes:zf(i.getElements()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Gf(i){const t=new kt;return t.body.case="primitive",t.body.value=new gs({type:Tu(i.getType()),value:i.toBytes(),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Yf(i){const t=new kt;return t.body.case="text",t.body.value=new ps({nodes:Vf(i.getRGATreeSplit()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Zf(i){const t=new kt;return t.body.case="counter",t.body.value=new ms({type:Su(i.getType()),value:i.toBytes(),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function ku(i){const t=new kt;return t.body.case="tree",t.body.value=new ys({nodes:Ia(i.getRoot()),createdAt:ke(i.getCreatedAt()),movedAt:ke(i.getMovedAt()),removedAt:ke(i.getRemovedAt())}),t}function Na(i){if(i instanceof xt)return Wf(i);if(i instanceof Lt)return xu(i);if(i instanceof tt)return Gf(i);if(i instanceof Gt)return Yf(i);if(i instanceof Rt)return Zf(i);if(i instanceof Yt)return ku(i);throw new ne(te.ErrUnimplemented,"unimplemented element")}function Xf(i){return new Qr({documentKey:i.getDocumentKey(),checkpoint:qf(i.getCheckpoint()),isRemoved:i.getIsRemoved(),changes:Jf(i.getChanges()),snapshot:i.getSnapshot(),versionVector:Oa(i.getVersionVector()),minSyncedTicket:ke(i.getMinSyncedTicket())})}function ao(i){if(!(i instanceof Ze))return{};const t=i.findDetails(yf);for(const e of t)return e.metadata;return{}}function Mi(i){return ao(i).code??""}function Ou(i){return zr.of(i.clientSeq,BigInt(i.lamport),Da(i.actorId),_a(i.versionVector),BigInt(i.serverSeq))}function _a(i){if(!i)return;const t=new Vi;return Object.entries(i.vector).forEach(([e,n])=>{t.set(e,BigInt(n.toString()))}),t}function Ie(i){if(i)return Wt.of(BigInt(i.lamport),i.delimiter,Da(i.actorId))}function Pa(i){const t={};return Object.entries(i.data).forEach(([e,n])=>{t[e]=JSON.parse(n)}),t}function Qf(i){const t=i.type;if(t===Ni.PUT){const e=Pa(i.presence);return{type:pi.Put,presence:e}}if(t===Ni.CLEAR)return{type:pi.Clear};throw new ne(te.ErrInvalidType,`unsupported type: ${t}`)}function eh(i){const t=new Map;return Object.entries(i).forEach(([e,n])=>{t.set(e,Pa(n))}),t}function Iu(i){switch(i){case Re.NULL:return ht.Null;case Re.BOOLEAN:return ht.Boolean;case Re.INTEGER:return ht.Integer;case Re.LONG:return ht.Long;case Re.DOUBLE:return ht.Double;case Re.STRING:return ht.String;case Re.BYTES:return ht.Bytes;case Re.DATE:return ht.Date}throw new ne(te.ErrUnimplemented,`unimplemented value type: ${i}`)}function Ss(i){switch(i){case Re.INTEGER_CNT:return Un.IntegerCnt;case Re.LONG_CNT:return Un.LongCnt}throw new ne(te.ErrUnimplemented,`unimplemented value type: ${i}`)}function Us(i){switch(i.type){case Re.JSON_OBJECT:return i.value?Du(i.value):xt.create(Ie(i.createdAt));case Re.JSON_ARRAY:return i.value?gh(i.value):Lt.create(Ie(i.createdAt));case Re.TEXT:return Gt.create(Qi.create(),Ie(i.createdAt));case Re.TREE:return mh(i.value);case Re.NULL:case Re.BOOLEAN:case Re.INTEGER:case Re.LONG:case Re.DOUBLE:case Re.STRING:case Re.BYTES:case Re.DATE:return tt.of(tt.valueFromBytes(Iu(i.type),i.value),Ie(i.createdAt));case Re.INTEGER_CNT:case Re.LONG_CNT:return Rt.create(Ss(i.type),Rt.valueFromBytes(Ss(i.type),i.value),Ie(i.createdAt))}}function $o(i){return cn.of(jn.of(Ie(i.createdAt),i.offset),i.relativeOffset)}function Nu(i){return jn.of(Ie(i.createdAt),i.offset)}function th(i){const t=To.create(i.value);Object.entries(i.attributes).forEach(([n,r])=>{t.setAttr(n,r.value,Ie(r.updatedAt))});const e=di.create(Nu(i.id),t);return e.remove(Ie(i.removedAt)),e}function qi(i){return ln.of(go(i.parentId),go(i.leftSiblingId))}function go(i){return pt.of(Ie(i.createdAt),i.offset)}function nh(i){if(!i.length)return;const t=[];return i.forEach(e=>{const n=Ca(e.content);t.push(n)}),t}function Ca(i){if(i.length===0)return;const t=[];for(const r of i)t.push(ih(r));const e=t[t.length-1],n=new Map;n.set(i[t.length-1].depth,t[t.length-1]);for(let r=t.length-2;r>=0;r--)n.get(i[r].depth-1).prepend(t[r]),n.set(i[r].depth,t[r]);return e.updateDescendantsSize(),Yt.create(e,un).getRoot()}function rh(i){const t=Xr.create();for(const[e,n]of Object.entries(i))t.setInternal(e,n.value,Ie(n.updatedAt),n.isRemoved);return t}function ih(i){const t=go(i.id),e=Ct.create(t,i.type),n=Object.entries(i.attributes);return e.isText?e.value=i.value:n.length&&(e.attrs=rh(i.attributes)),i.insPrevId&&(e.insPrevID=go(i.insPrevId)),i.insNextId&&(e.insNextID=go(i.insNextId)),e.removedAt=Ie(i.removedAt),e}function _u(i){if(i.body.case==="set"){const t=i.body.value;return _i.create(t.key,Us(t.value),Ie(t.parentCreatedAt),Ie(t.executedAt))}else if(i.body.case==="add"){const t=i.body.value;return Oo.create(Ie(t.parentCreatedAt),Ie(t.prevCreatedAt),Us(t.value),Ie(t.executedAt))}else if(i.body.case==="move"){const t=i.body.value;return ci.create(Ie(t.parentCreatedAt),Ie(t.prevCreatedAt),Ie(t.createdAt),Ie(t.executedAt))}else if(i.body.case==="remove"){const t=i.body.value;return mi.create(Ie(t.parentCreatedAt),Ie(t.createdAt),Ie(t.executedAt))}else if(i.body.case==="edit"){const t=i.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([r,o])=>{e.set(r,Ie(o))});const n=new Map;return Object.entries(t.attributes).forEach(([r,o])=>{n.set(r,o)}),Io.create(Ie(t.parentCreatedAt),$o(t.from),$o(t.to),e,t.content,n,Ie(t.executedAt))}else if(i.body.case==="style"){const t=i.body.value,e=new Map;Object.entries(t.createdAtMapByActor).forEach(([r,o])=>{e.set(r,Ie(o))});const n=new Map;return Object.entries(t.attributes).forEach(([r,o])=>{n.set(r,o)}),No.create(Ie(t.parentCreatedAt),$o(t.from),$o(t.to),e,n,Ie(t.executedAt))}else{if(i.body.case==="select")return;if(i.body.case==="increase"){const t=i.body.value;return eo.create(Ie(t.parentCreatedAt),Us(t.value),Ie(t.executedAt))}else if(i.body.case==="treeEdit"){const t=i.body.value,e=new Map;return Object.entries(t.createdAtMapByActor).forEach(([n,r])=>{e.set(n,Ie(r))}),_o.create(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),nh(t.contents),t.splitLevel,e,Ie(t.executedAt))}else if(i.body.case==="treeStyle"){const t=i.body.value,e=new Map,n=t.attributesToRemove,r=new Map;return t!=null&&t.createdAtMapByActor&&Object.entries(t.createdAtMapByActor).forEach(([o,s])=>{r.set(o,Ie(s))}),(n==null?void 0:n.length)>0?Yr.createTreeRemoveStyleOperation(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),r,n,Ie(t.executedAt)):(Object.entries(t.attributes).forEach(([o,s])=>{e.set(o,s)}),Yr.create(Ie(t.parentCreatedAt),qi(t.from),qi(t.to),r,e,Ie(t.executedAt)))}else throw new ne(te.ErrUnimplemented,"unimplemented operation")}}function oh(i){const t=[];for(const e of i){const n=_u(e);n&&t.push(n)}return t}function Pu(i){const t=[];for(const e of i)t.push(Xi.create({id:Ou(e.id),operations:oh(e.operations),presenceChange:e.presenceChange?Qf(e.presenceChange):void 0,message:e.message}));return t}function sh(i){return Ki.of(BigInt(i.serverSeq),i.clientSeq)}function ah(i){return _s.create(i.documentKey,sh(i.checkpoint),i.isRemoved,Pu(i.changes),_a(i.versionVector),i.snapshot,Ie(i.minSyncedTicket))}function Cu(i){const t=new bo;for(const n of i.nodes){const r=La(n.element);t.set(n.key,r,r.getPositionedAt())}const e=new xt(Ie(i.createdAt),t);return e.setMovedAt(Ie(i.movedAt)),e.setRemovedAt(Ie(i.removedAt)),e}function Lu(i){const t=new Ao;for(const n of i.nodes)t.insert(La(n.element));const e=new Lt(Ie(i.createdAt),t);return e.setMovedAt(Ie(i.movedAt)),e.setRemovedAt(Ie(i.removedAt)),e}function lh(i){const t=tt.of(tt.valueFromBytes(Iu(i.type),i.value),Ie(i.createdAt));return t.setMovedAt(Ie(i.movedAt)),t.setRemovedAt(Ie(i.removedAt)),t}function uh(i){const t=new Qi;let e=t.getHead();for(const r of i.nodes){const o=t.insertAfter(e,th(r));r.insPrevId&&o.setInsPrev(t.findNode(Nu(r.insPrevId))),e=o}const n=new Gt(t,Ie(i.createdAt));return n.setMovedAt(Ie(i.movedAt)),n.setRemovedAt(Ie(i.removedAt)),n}function ch(i){const t=Rt.create(Ss(i.type),Rt.valueFromBytes(Ss(i.type),i.value),Ie(i.createdAt));return t.setMovedAt(Ie(i.movedAt)),t.setRemovedAt(Ie(i.removedAt)),t}function Ru(i){const t=Ca(i.nodes);return Yt.create(t,Ie(i.createdAt))}function La(i){if(i.body.case==="jsonObject")return Cu(i.body.value);if(i.body.case==="jsonArray")return Lu(i.body.value);if(i.body.case==="primitive")return lh(i.body.value);if(i.body.case==="text")return uh(i.body.value);if(i.body.case==="counter")return ch(i.body.value);if(i.body.case==="tree")return Ru(i.body.value);throw new ne(te.ErrUnimplemented,"unimplemented element")}function fh(i){if(!i)return{root:xt.create(un),presences:new Map};const t=Hs.fromBinary(i);return{root:La(t.root),presences:eh(t.presences)}}function hh(i){const t=Oa(i);return Ra(t.toBinary())}function dh(i){const t=Ba(i),e=Os.fromBinary(t);return _a(e)}function Du(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Cu(t.body.value)}function Bu(i){return Na(i).toBinary()}function gh(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Lu(t.body.value)}function ph(i){return xu(i).toBinary()}function mh(i){if(!i)throw new ne(te.ErrInvalidArgument,"bytes is empty");const t=kt.fromBinary(i);return Ru(t.body.value)}function yh(i){return ku(i).toBinary()}function Ra(i){return i?Array.from(i).map(t=>t.toString(16).padStart(2,"0")).join(""):""}function Da(i){return Ra(i)}function Ba(i){return new Uint8Array(i.match(/.{1,2}/g).map(t=>parseInt(t,16)))}function Ma(i){return Ba(i)}function vh(i){const t=ks.fromBinary(i);return Ou(t)}function bh(i){const t=Ta.fromBinary(i);return _u(t)}const lt={fromPresence:Pa,toChangePack:Xf,fromChangePack:ah,fromChanges:Pu,toTreeNodes:Ia,fromTreeNodes:Ca,objectToBytes:Bu,bytesToObject:Du,bytesToSnapshot:fh,bytesToHex:Ra,hexToBytes:Ba,toHexString:Da,toUint8Array:Ma,toOperation:Eu,toChangeID:Au,PbChangeID:ks,bytesToChangeID:vh,bytesToOperation:bh,versionVectorToHex:hh,hexToVersionVector:dh};var wt=(i=>(i[i.Trivial=0]="Trivial",i[i.Debug=1]="Debug",i[i.Info=2]="Info",i[i.Warn=3]="Warn",i[i.Error=4]="Error",i[i.Fatal=5]="Fatal",i))(wt||{});let bi=3;function Mu(i){bi=i}const Ne={trivial:(...i)=>{bi>0||typeof console<"u"&&console.log("YORKIE T:",...i)},debug:(...i)=>{bi>1||typeof console<"u"&&console.log("YORKIE D:",...i)},info:(...i)=>{bi>2||typeof console<"u"&&console.log("YORKIE I:",...i)},warn:(...i)=>{bi>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...i):console.log("YORKIE W:",...i))},error:(...i)=>{bi>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...i):console.log("YORKIE E:",...i))},fatal:(...i)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...i):console.log("YORKIE F:",...i))},isEnabled:i=>bi<=i};function qu(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}class wh{constructor(t,e,n,r,o){T(this,"reconnectStreamDelay");T(this,"doc");T(this,"docID");T(this,"syncMode");T(this,"remoteChangeEventReceived");T(this,"watchStream");T(this,"watchLoopTimerID");T(this,"watchAbortController");T(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=t,this.doc=e,this.docID=n,this.syncMode=r,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=o}changeSyncMode(t){this.syncMode=t}needRealtimeSync(){return this.syncMode===Qo.RealtimeSyncOff?!1:this.syncMode===Qo.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Qo.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(t){const e=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await t(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(e,this.reconnectStreamDelay)})}catch{}};await e()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Js=()=>{};class Ah{constructor(t){T(this,"finalized",!1);T(this,"observers",[]);T(this,"finalError");try{t(this)}catch(e){this.error(e)}}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,n){let r;if(!t)throw new ne(te.ErrInvalidArgument,"missing observer");if(this.finalized)throw new ne(te.ErrRefused,"observable is finalized due to previous error");typeof t=="object"?r=t:r={next:t,error:e,complete:n},r.next===void 0&&(r.next=Js),r.error===void 0&&(r.error=Js),r.complete===void 0&&(r.complete=Js);const o=qu(),s=this.unsubscribeOne.bind(this,o);if(this.observers.push({subscriptionID:o,observer:r}),this.finalized)try{this.finalError?r.error(this.finalError):r.complete()}catch(u){Ne.warn(u)}return s}unsubscribeOne(t){var e;this.observers=(e=this.observers)==null?void 0:e.filter(n=>n.subscriptionID!==t)}forEachObserver(t){if(!this.finalized)for(let e=0;et}}class $i{constructor(t,e,n,r){T(this,"id");T(this,"delimiter");T(this,"message");T(this,"root");T(this,"operations");T(this,"presenceChange");T(this,"previousPresence");T(this,"reversePresenceKeys");this.id=t,this.delimiter=cu,this.root=e,this.operations=[],this.previousPresence=sn(n),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=r}static create(t,e,n,r){return new $i(t,e,n,r)}push(t){this.operations.push(t)}registerElement(t,e){this.root.registerElement(t,e)}registerRemovedElement(t){this.root.registerRemovedElement(t)}registerGCPair(t){this.root.registerGCPair(t)}getChange(){return Xi.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(t){this.presenceChange=t}setReversePresence(t,e){for(const n of Object.keys(t))e!=null&&e.addToHistory?this.reversePresenceKeys.add(n):this.reversePresenceKeys.delete(n)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const t={};for(const e of this.reversePresenceKeys)t[e]=this.previousPresence[e];return t}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class So{constructor(t){T(this,"rootObject");T(this,"elementPairMapByCreatedAt");T(this,"gcElementSetByCreatedAt");T(this,"gcPairMap");this.rootObject=t,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(t,void 0),t.getDescendants(e=>{if(e.getRemovedAt()&&this.registerRemovedElement(e),e instanceof Gt||e instanceof Yt)for(const n of e.getGCPairs())this.registerGCPair(n);return!1})}static create(){return new So(xt.create(un))}findByCreatedAt(t){const e=this.elementPairMapByCreatedAt.get(t.toIDString());if(e)return e.element}findElementPairByCreatedAt(t){return this.elementPairMapByCreatedAt.get(t.toIDString())}createSubPaths(t){let e=this.elementPairMapByCreatedAt.get(t.toIDString());if(!e)return[];const n=[];for(;e.parent;){const r=e.element.getCreatedAt(),o=e.parent.subPathOf(r);if(o===void 0)throw new ne(te.ErrInvalidArgument,`cant find the given element: ${r.toIDString()}`);n.unshift(o),e=this.elementPairMapByCreatedAt.get(e.parent.getCreatedAt().toIDString())}return n.unshift("$"),n}createPath(t){return this.createSubPaths(t).join(".")}registerElement(t,e){this.elementPairMapByCreatedAt.set(t.getCreatedAt().toIDString(),{parent:e,element:t}),t instanceof hi&&t.getDescendants((n,r)=>(this.registerElement(n,r),!1))}deregisterElement(t){let e=0;const n=r=>{const o=r.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(o),this.gcElementSetByCreatedAt.delete(o),e++};return n(t),t instanceof hi&&t.getDescendants(r=>(n(r),!1)),e}registerRemovedElement(t){this.gcElementSetByCreatedAt.add(t.getCreatedAt().toIDString())}registerGCPair(t){if(this.gcPairMap.get(t.child.toIDString())){this.gcPairMap.delete(t.child.toIDString());return}this.gcPairMap.set(t.child.toIDString(),t)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const t=new Set;for(const e of this.gcElementSetByCreatedAt){t.add(e);const n=this.elementPairMapByCreatedAt.get(e);n.element instanceof hi&&n.element.getDescendants(r=>(t.add(r.getCreatedAt().toIDString()),!1))}return t.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new So(this.rootObject.deepcopy())}garbageCollect(t){let e=0;for(const n of this.gcElementSetByCreatedAt){const r=this.elementPairMapByCreatedAt.get(n),o=r.element.getRemovedAt();o&&(t!=null&&t.afterOrEqual(o))&&(r.parent.purge(r.element),e+=this.deregisterElement(r.element))}for(const[,n]of this.gcPairMap){const r=n.child.getRemovedAt();r&&(t!=null&&t.afterOrEqual(r))&&(n.parent.purge(n.child),this.gcPairMap.delete(n.child.toIDString()),e+=1)}return e}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Fu(i,t){const e=new Eo(i);return new Proxy(t,e.getHandlers())}class Eo{constructor(t){T(this,"context");T(this,"handlers");this.context=t,this.handlers={set:(e,n,r)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]=${JSON.stringify(r)}`),Eo.setInternal(t,e,n,r),!0),get:(e,n)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]`),n==="getID"?()=>e.getCreatedAt():n==="toJSON"||n==="toString"?()=>e.toJSON():n==="toJS"?()=>e.toJS():n==="toJSForTest"?()=>e.toJSForTest():wi(t,e.get(n))),ownKeys:e=>e.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(e,n)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`obj[${n}]`),Eo.deleteInternal(t,e,n),!0)}}static setInternal(t,e,n,r){if(n.includes("."))throw new ne(te.ErrInvalidObjectKey,"key must not contain the '.'.");const o=t.issueTimeTicket(),s=Es(t,r,o),u=e.set(n,s,o);t.registerElement(s,e),u&&t.registerRemovedElement(u),t.push(_i.create(n,s.deepcopy(),e.getCreatedAt(),o))}static buildObjectMembers(t,e){const n={};for(const[r,o]of Object.entries(e)){if(r.includes("."))throw new ne(te.ErrInvalidObjectKey,"key must not contain the '.'.");const s=t.issueTimeTicket(),u=Es(t,o,s);n[r]=u}return n}static deleteInternal(t,e,n){const r=t.issueTimeTicket(),o=e.deleteByKey(n,r);o&&(t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o))}getHandlers(){return this.handlers}}function Sh(i,t){const e=new rt(i,t);return new Proxy(t,e.getHandlers())}function Eh(i){return typeof i=="string"||i instanceof String?!isNaN(i):!1}function xh(i){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(i)}class rt{constructor(t,e){T(this,"context");T(this,"handlers");T(this,"array");this.context=t,this.array=e,this.handlers={get:(n,r,o)=>r==="getID"?()=>n.getCreatedAt():r==="getElementByID"?s=>{const u=n.getByID(s);if(!(!u||u.isRemoved()))return oi(t,u)}:r==="getElementByIndex"?s=>{const u=n.get(s);return oi(t,u)}:r==="getLast"?()=>oi(t,n.getLast()):r==="deleteByID"?s=>{const u=rt.deleteInternalByID(t,n,s);return oi(t,u)}:r==="insertAfter"?(s,u)=>{const c=rt.insertAfterInternal(t,n,s,u);return oi(t,c)}:r==="insertBefore"?(s,u)=>{const c=rt.insertBeforeInternal(t,n,s,u);return oi(t,c)}:r==="moveBefore"?(s,u)=>{rt.moveBeforeInternal(t,n,s,u)}:r==="moveAfter"?(s,u)=>{rt.moveAfterInternal(t,n,s,u)}:r==="moveFront"?s=>{rt.moveFrontInternal(t,n,s)}:r==="moveLast"?s=>{rt.moveLastInternal(t,n,s)}:Eh(r)?wi(t,n.get(Number(r))):r==="push"?s=>rt.pushInternal(t,n,s):r==="splice"?(s,u,...c)=>rt.splice(t,n,s,u,...c):r==="length"?n.length:typeof r=="symbol"&&r===Symbol.iterator?rt.iteratorInternal.bind(this,t,n):r==="includes"?(s,u)=>rt.includes(t,n,s,u):r==="indexOf"?(s,u)=>rt.indexOf(t,n,s,u):r==="lastIndexOf"?(s,u)=>rt.lastIndexOf(t,n,s,u):r==="toJSForTest"?()=>n.toJSForTest():r==="toTestString"?()=>rt.toTestString(n):typeof r=="string"&&xh(r)?(...s)=>{const u=Array.from(n).map(c=>wi(t,c));return Array.prototype[r].apply(u,s)}:Reflect.get(n,r,o),deleteProperty:(n,r)=>(Ne.isEnabled(wt.Trivial)&&Ne.trivial(`array[${r}]`),rt.deleteInternalByIndex(t,n,Number.parseInt(r)),!0)}}static*iteratorInternal(t,e){for(const n of e)yield oi(t,n)}static buildArrayElements(t,e){const n=[];for(const r of e){const o=t.issueTimeTicket(),s=Es(t,r,o);n.push(s)}return n}static pushInternal(t,e,n){return rt.insertAfterInternal(t,e,e.getLastCreatedAt(),n),e.length}static moveBeforeInternal(t,e,n,r){const o=t.issueTimeTicket(),s=e.getPrevCreatedAt(n);e.moveAfter(s,r,o),t.push(ci.create(e.getCreatedAt(),s,r,o))}static moveAfterInternal(t,e,n,r){const o=t.issueTimeTicket();e.moveAfter(n,r,o),t.push(ci.create(e.getCreatedAt(),n,r,o))}static moveFrontInternal(t,e,n){const r=t.issueTimeTicket(),o=e.getHead();e.moveAfter(o.getCreatedAt(),n,r),t.push(ci.create(e.getCreatedAt(),o.getCreatedAt(),n,r))}static moveLastInternal(t,e,n){const r=t.issueTimeTicket(),o=e.getLastCreatedAt();e.moveAfter(o,n,r),t.push(ci.create(e.getCreatedAt(),o,n,r))}static insertAfterInternal(t,e,n,r){const o=t.issueTimeTicket(),s=Es(t,r,o);return e.insertAfter(n,s),t.registerElement(s,e),t.push(Oo.create(e.getCreatedAt(),n,s.deepcopy(),o)),s}static insertBeforeInternal(t,e,n,r){return rt.insertAfterInternal(t,e,e.getPrevCreatedAt(n),r)}static deleteInternalByIndex(t,e,n){const r=t.issueTimeTicket(),o=e.deleteByIndex(n,r);if(o)return t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o),o}static deleteInternalByID(t,e,n){const r=t.issueTimeTicket(),o=e.delete(n,r);return t.push(mi.create(e.getCreatedAt(),o.getCreatedAt(),r)),t.registerRemovedElement(o),o}static splice(t,e,n,r,...o){const s=e.length,u=n>=0?Math.min(n,s):Math.max(s+n,0),c=r===void 0?s:r<0?u:Math.min(u+r,s),m=[];for(let y=u;y=o)return!1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).includes(n,s);for(let c=s;c=o)return-1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).indexOf(n,s);for(let c=s;c=o?o-1:r<0?r+o:r;if(s<0)return-1;if(tt.isSupport(n))return Array.from(e).map(m=>wi(t,m)).lastIndexOf(n,s);for(let c=s;c>0;c--)if(((u=e.get(c))==null?void 0:u.getID())===n.getID())return c;return-1}static toTestString(t){return t.toTestString()}getHandlers(){return this.handlers}}let Ps=class{constructor(t,e){T(this,"context");T(this,"text");this.context=t,this.text=e}initialize(t,e){this.context=t,this.text=e}getID(){return this.text.getID()}edit(t,e,n,r){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.text.indexRangeToPosRange(t,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`EDIT: f:${t}->${o[0].toTestString()}, t:${e}->${o[1].toTestString()} c:${n}`);const s=r?Yi(r):void 0,u=this.context.issueTimeTicket(),[c,,m,y]=this.text.edit(o,n,u,s);for(const f of m)this.context.registerGCPair(f);return this.context.push(new Io(this.text.getCreatedAt(),o[0],o[1],c,n,s?new Map(Object.entries(s)):new Map,u)),this.text.findIndexesFromRange(y)}delete(t,e){return this.edit(t,e,"")}empty(){return this.edit(0,this.length,"")}setStyle(t,e,n){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.text.indexRangeToPosRange(t,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`STYL: f:${t}->${r[0].toTestString()}, t:${e}->${r[1].toTestString()} a:${JSON.stringify(n)}`);const o=Yi(n),s=this.context.issueTimeTicket(),[u,c]=this.text.setStyle(r,o,s);for(const m of c)this.context.registerGCPair(m);return this.context.push(new No(this.text.getCreatedAt(),r[0],r[1],u,new Map(Object.entries(o)),s)),!0}indexRangeToPosRange(t){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");const e=this.text.indexRangeToPosRange(t[0],t[1]);return[e[0].toStruct(),e[1].toStruct()]}posRangeToIndexRange(t){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");const e=this.text.findIndexesFromRange([cn.fromStruct(t[0]),cn.fromStruct(t[1])]);return[e[0],e[1]]}toTestString(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(t,e){if(!this.context||!this.text)throw new ne(te.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(t,e)}};class Cs{constructor(t,e){T(this,"valueType");T(this,"value");T(this,"context");T(this,"counter");this.valueType=t,this.value=e}initialize(t,e){this.valueType=e.getValueType(),this.context=t,this.counter=e,this.value=e.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(t){if(!this.context||!this.counter)throw new ne(te.ErrNotInitialized,"Counter is not initialized yet");const e=this.context.issueTimeTicket(),n=tt.of(t,e);if(!n.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof n.getValue()}`);return this.counter.increase(n),this.context.push(eo.create(this.counter.getCreatedAt(),n,e)),this}toJSForTest(){if(!this.context||!this.counter)throw new ne(te.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function qa(i,t,e){const{type:n}=i,r=e.issueTimeTicket();if(n===Gr){ju(i);const{value:o}=i,s=Ct.create(pt.of(r,0),n,o);t.append(s)}else{const{children:o=[]}=i,{attributes:s}=i;let u;if(typeof s=="object"&&!uu(s)){const m=Yi(s);u=new Xr;for(const[y,f]of Object.entries(m))u.set(y,f,r)}const c=Ct.create(pt.of(r,0),n,void 0,u);t.append(c);for(const m of o)qa(m,c,e)}}function kh(i,t){const{type:e}=t,n=i.issueTimeTicket();let r;if(t.type===Gr){const{value:o}=t;r=Ct.create(pt.of(n,0),e,o)}else if(t){const{children:o=[]}=t,{attributes:s}=t;let u;if(typeof s=="object"&&!uu(s)){const c=Yi(s);u=new Xr;for(const[m,y]of Object.entries(c))u.set(m,y,n)}r=Ct.create(pt.of(i.issueTimeTicket(),0),e,void 0,u);for(const c of o)qa(c,r,i)}return r}function ju(i){if(!i.value.length)throw new ne(te.ErrInvalidArgument,"text node cannot have empty value");return!0}function xl(i){if(!i.length)return!0;if(i[0].type===Gr)for(const e of i){const{type:n}=e;if(n!==Gr)throw new ne(te.ErrInvalidArgument,"element node and text node cannot be passed together");ju(e)}else for(const e of i){const{type:n}=e;if(n===Gr)throw new ne(te.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class Ls{constructor(t){T(this,"initialRoot");T(this,"context");T(this,"tree");this.initialRoot=t}initialize(t,e){this.context=t,this.tree=e}getID(){return this.tree.getID()}buildRoot(t){if(!this.initialRoot)return Ct.create(pt.of(t.issueTimeTicket(),0),Ef);const e=Ct.create(pt.of(t.issueTimeTicket(),0),this.initialRoot.type);for(const n of this.initialRoot.children)qa(n,e,t);return e}getSize(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(t,e){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(!t.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const[n,r]=this.tree.pathToPosRange(t),o=this.context.issueTimeTicket(),s=e?Yi(e):void 0,[u]=this.tree.style([n,r],s,o);this.context.push(Yr.create(this.tree.getCreatedAt(),n,r,u,s?new Map(Object.entries(s)):new Map,o))}style(t,e,n){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(t),o=this.tree.findPos(e),s=this.context.issueTimeTicket(),u=n?Yi(n):void 0,[c,m]=this.tree.style([r,o],u,s);for(const y of m)this.context.registerGCPair(y);this.context.push(Yr.create(this.tree.getCreatedAt(),r,o,c,u?new Map(Object.entries(u)):new Map,s))}removeStyle(t,e,n){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const r=this.tree.findPos(t),o=this.tree.findPos(e),s=this.context.issueTimeTicket(),[u,c]=this.tree.removeStyle([r,o],n,s);for(const m of c)this.context.registerGCPair(m);this.context.push(Yr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),r,o,u,n,s))}editInternal(t,e,n,r=0){var m;if(n.length!==0&&n[0]&&(xl(n),n[0].type!==Gr))for(const y of n){const{children:f=[]}=y;xl(f)}const o=this.context.getLastTimeTicket();let s=new Array;if(((m=n[0])==null?void 0:m.type)===Gr){let y="";for(const f of n){const{value:l}=f;y+=l}s.push(Ct.create(pt.of(this.context.issueTimeTicket(),0),Gr,y))}else s=n.map(y=>y&&kh(this.context,y)).filter(y=>y);const[,u,c]=this.tree.edit([t,e],s.length?s.map(y=>y==null?void 0:y.deepcopy()):void 0,r,o,()=>this.context.issueTimeTicket());for(const y of u)this.context.registerGCPair(y);return this.context.push(_o.create(this.tree.getCreatedAt(),t,e,s.length?s:void 0,r,c,o)),!0}editByPath(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new ne(te.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),s=this.tree.pathToPos(e);return this.editInternal(o,s,n?[n]:[],r)}editBulkByPath(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t.length!==e.length)throw new ne(te.ErrInvalidArgument,"path length should be equal");if(!t.length||!e.length)throw new ne(te.ErrInvalidArgument,"path should not be empty");const o=this.tree.pathToPos(t),s=this.tree.pathToPos(e);return this.editInternal(o,s,n,r)}edit(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),s=this.tree.findPos(e);return this.editInternal(o,s,n?[n]:[],r)}editBulk(t,e,n,r=0){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");if(t>e)throw new ne(te.ErrInvalidArgument,"from should be less than or equal to to");const o=this.tree.findPos(t),s=this.tree.findPos(e);return this.editInternal(o,s,n,r)}toXML(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(t)}pathToIndex(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(t)}pathRangeToPosRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[this.tree.pathToIndex(t[0]),this.tree.pathToIndex(t[1])],n=this.tree.indexRangeToPosRange(e);return[n[0].toStruct(),n[1].toStruct()]}indexRangeToPosRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(t)}posRangeToIndexRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[ln.fromStruct(t[0]),ln.fromStruct(t[1])];return this.tree.posRangeToIndexRange(e)}posRangeToPathRange(t){if(!this.context||!this.tree)throw new ne(te.ErrNotInitialized,"Tree is not initialized yet");const e=[ln.fromStruct(t[0]),ln.fromStruct(t[1])];return this.tree.posRangeToPathRange(e)}}function kl(i,t){return Fu(i,t)}function oi(i,t){if(t){if(t instanceof tt)return t;if(t instanceof xt)return Fu(i,t);if(t instanceof Lt)return Sh(i,t);if(t instanceof Gt)return new Ps(i,t);if(t instanceof Rt){const e=new Cs(Un.IntegerCnt,0);return e.initialize(i,t),e}else if(t instanceof Yt){const e=new Ls;return e.initialize(i,t),e}}else return;throw new TypeError(`Unsupported type of element: ${typeof t}`)}function wi(i,t){const e=oi(i,t);return e instanceof tt?e.getValue():e}function Es(i,t,e){let n;if(tt.isSupport(t))n=tt.of(t,e);else if(Array.isArray(t))n=Lt.create(e,rt.buildArrayElements(i,t));else if(typeof t=="object")t instanceof Ps?(n=Gt.create(Qi.create(),e),t.initialize(i,n)):t instanceof Cs?(n=Rt.create(t.getValueType(),t.getValue(),e),t.initialize(i,n)):t instanceof Ls?(n=Yt.create(t.buildRoot(i),e),t.initialize(i,n)):n=xt.create(e,Eo.buildObjectMembers(i,t));else throw new TypeError(`Unsupported type of value: ${typeof t}`);return n}const Ol=50;class Oh{constructor(){T(this,"undoStack",[]);T(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(t){this.undoStack.length>=Ol&&this.undoStack.shift(),this.undoStack.push(t)}popUndo(){return this.undoStack.pop()}pushRedo(t){this.redoStack.length>=Ol&&this.redoStack.shift(),this.redoStack.push(t)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const Ih="yorkie-devtools-panel",Nh="yorkie-devtools-sdk";let Fi="disconnected";const Il=new Map,Xo=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Xo);function zo(i,t){(t!=null&&t.force||Fi!=="disconnected")&&window.postMessage({source:Nh,...i},"*")}function _h(i){if(!i.isEnableDevtools()||typeof window>"u"||Il.has(i.getKey()))return;Xo.set(i.getKey(),[]);const t=i.subscribe("all",e=>{e.some(n=>n.type!==ft.StatusChanged&&n.type!==ft.Snapshot&&n.type!==ft.LocalChange&&n.type!==ft.RemoteChange&&n.type!==ft.Initialized&&n.type!==ft.Watched&&n.type!==ft.Unwatched&&n.type!==ft.PresenceChanged)||(Xo.get(i.getKey()).push(e),Fi==="synced"&&zo({msg:"doc::sync::partial",docKey:i.getKey(),event:e}))});Il.set(i.getKey(),[t]),zo({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",e=>{var r;if(((r=e.data)==null?void 0:r.source)!==Ih)return;switch(e.data.msg){case"devtools::connect":if(Fi!=="disconnected")break;Fi="connected",zo({msg:"doc::available",docKey:i.getKey()}),Ne.info(`[YD] Devtools connected. Doc: ${i.getKey()}`);break;case"devtools::disconnect":Fi="disconnected",Ne.info(`[YD] Devtools disconnected. Doc: ${i.getKey()}`);break;case"devtools::subscribe":Fi="synced",zo({msg:"doc::sync::full",docKey:i.getKey(),events:Xo.get(i.getKey())}),Ne.info(`[YD] Devtools subscribed. Doc: ${i.getKey()}`);break}})}var si=(i=>(i.Detached="detached",i.Attached="attached",i.Removed="removed",i))(si||{}),ft=(i=>(i.StatusChanged="status-changed",i.ConnectionChanged="connection-changed",i.SyncStatusChanged="sync-status-changed",i.Snapshot="snapshot",i.LocalChange="local-change",i.RemoteChange="remote-change",i.Initialized="initialized",i.Watched="watched",i.Unwatched="unwatched",i.PresenceChanged="presence-changed",i.Broadcast="broadcast",i.LocalBroadcast="local-broadcast",i.AuthError="auth-error",i))(ft||{}),xo=(i=>(i.Connected="connected",i.Disconnected="disconnected",i))(xo||{}),ba=(i=>(i.Synced="synced",i.SyncFailed="sync-failed",i))(ba||{});class Uu{constructor(t,e){T(this,"key");T(this,"status");T(this,"opts");T(this,"changeID");T(this,"checkpoint");T(this,"localChanges");T(this,"root");T(this,"clone");T(this,"eventStream");T(this,"eventStreamObserver");T(this,"onlineClients");T(this,"presences");T(this,"history");T(this,"internalHistory");T(this,"isUpdating");this.opts=e||{},this.key=t,this.status="detached",this.root=So.create(),this.changeID=Lf,this.checkpoint=Rf,this.localChanges=[],this.eventStream=Th(n=>{this.eventStreamObserver=n}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new Oh,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},_h(this)}update(t,e){if(this.getStatus()==="removed")throw new ne(te.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const n=this.changeID.getActorID(),r=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(n)||{},e);try{const o=kl(r,this.clone.root.getObject());this.presences.has(n)||this.clone.presences.set(n,{}),this.isUpdating=!0,t(o,new Fs(r,this.clone.presences.get(n)))}catch(o){throw this.clone=void 0,o}finally{this.isUpdating=!1}if(r.hasChange()){Ne.isEnabled(wt.Trivial)&&Ne.trivial(`trying to update a local change: ${this.toJSON()}`);const o=r.getChange(),{opInfos:s,reverseOps:u}=o.execute(this.root,this.presences,Ye.Local),c=r.getReversePresence();c&&u.push({type:"presence",value:c}),this.localChanges.push(o),u.length>0&&this.internalHistory.pushUndo(u),s.length>0&&this.internalHistory.clearRedo(),this.changeID=o.getID();const m=[];s.length>0&&m.push({type:"local-change",source:Ye.Local,value:{message:o.getMessage()||"",operations:s,actor:n,clientSeq:o.getID().getClientSeq(),serverSeq:o.getID().getServerSeq()},rawChange:this.isEnableDevtools()?o.toStruct():void 0}),o.hasPresenceChange()&&m.push({type:"presence-changed",source:Ye.Local,value:{clientID:n,presence:this.getPresence(n)}}),this.publish(m),Ne.isEnabled(wt.Trivial)&&Ne.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(t,e,n,r){if(typeof t=="string"){if(typeof e!="function")throw new ne(te.ErrInvalidArgument,"Second argument must be a callback function");if(t==="presence"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="initialized"&&m.type!=="watched"&&m.type!=="unwatched"&&m.type!=="presence-changed"||u(m)},n,r)}if(t==="my-presence"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="initialized"&&m.type!=="presence-changed"||m.type==="presence-changed"&&m.value.clientID!==this.changeID.getActorID()||u(m)},n,r)}if(t==="others"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="watched"&&m.type!=="unwatched"&&m.type!=="presence-changed"||m.value.clientID!==this.changeID.getActorID()&&u(m)},n,r)}if(t==="connection"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="connection-changed"&&u(m)},n,r)}if(t==="status"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="status-changed"&&u(m)},n,r)}if(t==="sync"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="sync-status-changed"&&u(m)},n,r)}if(t==="local-broadcast"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="local-broadcast"&&u(m)},n)}if(t==="broadcast"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="broadcast"&&u(m)},n)}if(t==="auth-error"){const u=e;return this.eventStream.subscribe(c=>{for(const m of c)m.type==="auth-error"&&u(m)},n)}if(t==="all"){const u=e;return this.eventStream.subscribe(u,n,r)}const o=t,s=e;return this.eventStream.subscribe(u=>{for(const c of u){if(c.type!=="local-change"&&c.type!=="remote-change")continue;const m=[];for(const y of c.value.operations)this.isSameElementOrChildOf(y.path,o)&&m.push(y);m.length&&s({...c,value:{...c.value,operations:m}})}},n,r)}if(typeof t=="function"){const o=t,s=e,u=n;return this.eventStream.subscribe(c=>{for(const m of c)m.type!=="snapshot"&&m.type!=="local-change"&&m.type!=="remote-change"||o(m)},s,u)}throw new ne(te.ErrInvalidArgument,`"${t}" is not a valid`)}publish(t){this.eventStreamObserver&&this.eventStreamObserver.next(t)}isSameElementOrChildOf(t,e){if(e===t)return!0;const n=t.split(".");return e.split(".").every((o,s)=>o===n[s])}removePushedLocalChanges(t){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>t);)this.localChanges.shift()}applyChangePack(t){const e=t.hasSnapshot();e?this.applySnapshot(t.getCheckpoint().getServerSeq(),t.getVersionVector(),t.getSnapshot(),t.getCheckpoint().getClientSeq()):(this.applyChanges(t.getChanges(),Ye.Remote),this.removePushedLocalChanges(t.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(t.getCheckpoint()),e||this.garbageCollect(t.getVersionVector()),t.getIsRemoved()&&this.applyStatus("removed"),Ne.isEnabled(wt.Trivial)&&Ne.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:sn(this.presences)})}createChangePack(){const t=Array.from(this.localChanges),e=this.checkpoint.increaseClientSeq(t.length);return _s.create(this.key,e,!1,t,this.getVersionVector())}setActor(t){for(const e of this.localChanges)e.setActor(t);this.changeID=this.changeID.setActor(t)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const t=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return kl(t,this.clone.root.getObject())}garbageCollect(t){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(t),this.root.garbageCollect(t))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(t,e,n,r=-1){const{root:o,presences:s}=lt.bytesToSnapshot(n);this.root=new So(o),this.presences=s,this.changeID=this.changeID.setClocks(e.maxLamport(),e),this.clone=void 0,this.removePushedLocalChanges(r),this.applyChanges(this.localChanges,Ye.Local),this.publish([{type:"snapshot",source:Ye.Remote,value:{serverSeq:t.toString(),snapshot:this.isEnableDevtools()?lt.bytesToHex(n):void 0,snapshotVector:lt.versionVectorToHex(e)}}])}applyChanges(t,e){Ne.isEnabled(wt.Debug)&&Ne.debug(`trying to apply ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),Ne.isEnabled(wt.Trivial)&&Ne.trivial(t.map(n=>`${n.getID().toTestString()} ${n.toTestString()}`).join(` +`));for(const n of t)this.applyChange(n,e);Ne.isEnabled(wt.Debug)&&Ne.debug(`after appling ${t.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(t,e){this.ensureClone(),t.execute(this.clone.root,this.clone.presences,e);const n=[],r=t.getID().getActorID();if(t.hasPresenceChange()&&this.onlineClients.has(r)){const s=t.getPresenceChange();switch(s.type){case pi.Put:n.push(this.presences.has(r)?{type:"presence-changed",source:e,value:{clientID:r,presence:s.presence}}:{type:"watched",source:Ye.Remote,value:{clientID:r,presence:s.presence}});break;case pi.Clear:n.push({type:"unwatched",source:Ye.Remote,value:{clientID:r,presence:this.getPresence(r)}}),this.removeOnlineClient(r);break}}const{opInfos:o}=t.execute(this.root,this.presences,e);if(this.changeID=this.changeID.syncClocks(t.getID()),o.length>0){const s=this.isEnableDevtools()?t.toStruct():void 0;n.push(e===Ye.Remote?{type:"remote-change",source:e,value:{actor:r,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:s}:{type:"local-change",source:e,value:{actor:r,clientSeq:t.getID().getClientSeq(),serverSeq:t.getID().getServerSeq(),message:t.getMessage()||"",operations:o},rawChange:s})}n.length>0&&this.publish(n)}applyWatchStream(t){if(t.body.case==="initialization"){const e=t.body.value.clientIds,n=new Set;for(const r of e)r!==this.changeID.getActorID()&&n.add(r);this.setOnlineClients(n),this.publish([{type:"initialized",source:Ye.Local,value:this.getPresences()}]);return}if(t.body.case==="event"){const{type:e,publisher:n}=t.body.value,r=[];if(e===Oi.DOCUMENT_WATCHED){if(this.onlineClients.has(n)&&this.hasPresence(n))return;this.addOnlineClient(n),this.hasPresence(n)&&r.push({type:"watched",source:Ye.Remote,value:{clientID:n,presence:this.getPresence(n)}})}else if(e===Oi.DOCUMENT_UNWATCHED){const o=this.getPresence(n);this.removeOnlineClient(n),o&&r.push({type:"unwatched",source:Ye.Remote,value:{clientID:n,presence:o}})}else if(e===Oi.DOCUMENT_BROADCAST&&t.body.value.body){const{topic:o,payload:s}=t.body.value.body,u=new TextDecoder;r.push({type:"broadcast",value:{clientID:n,topic:o,payload:JSON.parse(u.decode(s))}})}r.length>0&&this.publish(r)}}applyStatus(t){this.status=t,t==="detached"&&this.setActor(Is),this.publish([{source:t==="removed"?Ye.Remote:Ye.Local,type:"status-changed",value:t==="attached"?{status:t,actorID:this.changeID.getActorID()}:{status:t}}])}applyDocEvent(t){if(t.type==="status-changed"){this.applyStatus(t.value.status),t.value.status==="attached"&&this.setActor(t.value.actorID);return}if(t.type==="snapshot"){const{snapshot:e,serverSeq:n,snapshotVector:r}=t.value;if(!e)return;this.applySnapshot(BigInt(n),lt.hexToVersionVector(r),lt.hexToBytes(e));return}if(t.type==="local-change"||t.type==="remote-change"){if(!t.rawChange)return;const e=Xi.fromStruct(t.rawChange);this.applyChange(e,t.source)}if(t.type==="initialized"){const e=new Set;for(const{clientID:n,presence:r}of t.value)e.add(n),this.presences.set(n,r);this.setOnlineClients(e);return}if(t.type==="watched"){const{clientID:e,presence:n}=t.value;this.addOnlineClient(e),this.presences.set(e,n);return}if(t.type==="unwatched"){const{clientID:e}=t.value;this.removeOnlineClient(e),this.presences.delete(e)}if(t.type==="presence-changed"){const{clientID:e,presence:n}=t.value;this.presences.set(e,n)}}applyTransactionEvent(t){for(const e of t)this.applyDocEvent(e)}getValueByPath(t){if(!t.startsWith("$"))throw new ne(te.ErrInvalidArgument,'path must start with "$"');const e=t.split(".");e.shift();let n=this.getRoot();for(const r of e)if(n=n[r],n===void 0)return;return n}setOnlineClients(t){this.onlineClients=t}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(t){this.onlineClients.add(t)}removeOnlineClient(t){this.onlineClients.delete(t)}hasPresence(t){return this.presences.has(t)}getMyPresence(){if(this.status!=="attached")return{};const t=this.presences.get(this.changeID.getActorID());return t?sn(t):{}}getPresence(t){if(t===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(t))return;const e=this.presences.get(t);return e?sn(e):void 0}getPresenceForTest(t){const e=this.presences.get(t);return e?sn(e):void 0}getPresences(){const t=[];t.push({clientID:this.changeID.getActorID(),presence:sn(this.getMyPresence())});for(const e of this.onlineClients)this.presences.has(e)&&t.push({clientID:e,presence:sn(this.presences.get(e))});return t}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const t=this.getChangeID().getActorID();return this.getPresences().filter(e=>e.clientID!==t).sort((e,n)=>e.clientID>n.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(t){const n=this.changeID.getVersionVector().filter(t);this.changeID=this.changeID.setVersionVector(n)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new ne(te.ErrRefused,"Undo is not allowed during an update");const t=this.internalHistory.popUndo();if(t===void 0)throw new ne(te.ErrRefused,"There is no operation to be undone");this.ensureClone();const e=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const m of t){if(!(m instanceof fn)){new Fs(e,sn(this.clone.presences.get(this.changeID.getActorID()))).set(m.value,{addToHistory:!0});continue}const y=e.issueTimeTicket();m.setExecutedAt(y),e.push(m)}const n=e.getChange();n.execute(this.clone.root,this.clone.presences,Ye.UndoRedo);const{opInfos:r,reverseOps:o}=n.execute(this.root,this.presences,Ye.UndoRedo),s=e.getReversePresence();if(s&&o.push({type:"presence",value:s}),o.length>0&&this.internalHistory.pushRedo(o),!n.hasPresenceChange()&&r.length===0)return;this.localChanges.push(n),this.changeID=n.getID();const u=this.changeID.getActorID(),c=[];r.length>0&&c.push({type:"local-change",source:Ye.UndoRedo,value:{message:n.getMessage()||"",operations:r,actor:u,clientSeq:n.getID().getClientSeq(),serverSeq:n.getID().getServerSeq()},rawChange:this.isEnableDevtools()?n.toStruct():void 0}),n.hasPresenceChange()&&c.push({type:"presence-changed",source:Ye.UndoRedo,value:{clientID:u,presence:this.getPresence(u)}}),this.publish(c)}redo(){if(this.isUpdating)throw new ne(te.ErrRefused,"Redo is not allowed during an update");const t=this.internalHistory.popRedo();if(t===void 0)throw new ne(te.ErrRefused,"There is no operation to be redone");this.ensureClone();const e=$i.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const m of t){if(!(m instanceof fn)){new Fs(e,sn(this.clone.presences.get(this.changeID.getActorID()))).set(m.value,{addToHistory:!0});continue}const y=e.issueTimeTicket();m.setExecutedAt(y),e.push(m)}const n=e.getChange();n.execute(this.clone.root,this.clone.presences,Ye.UndoRedo);const{opInfos:r,reverseOps:o}=n.execute(this.root,this.presences,Ye.UndoRedo),s=e.getReversePresence();if(s&&o.push({type:"presence",value:s}),o.length>0&&this.internalHistory.pushUndo(o),!n.hasPresenceChange()&&r.length===0)return;this.localChanges.push(n),this.changeID=n.getID();const u=this.changeID.getActorID(),c=[];r.length>0&&c.push({type:"local-change",source:Ye.UndoRedo,value:{message:n.getMessage()||"",operations:r,actor:u,clientSeq:n.getID().getClientSeq(),serverSeq:n.getID().getServerSeq()},rawChange:this.isEnableDevtools()?n.toStruct():void 0}),n.hasPresenceChange()&&c.push({type:"presence-changed",source:Ye.UndoRedo,value:{clientID:u,presence:this.getPresence(u)}}),this.publish(c)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(t,e,n){const r={type:"local-broadcast",value:{topic:t,payload:e},options:n};this.publish([r])}getVersionVector(){return this.changeID.getVersionVector()}}function Ph(i,t){let e=t;return{authInterceptor:o=>async s=>(i&&s.header.set("x-api-key",i),e&&s.header.set("authorization",e),await o(s)),setToken:o=>{e=o}}}const Ch="yorkie-js-sdk",Lh="0.5.6",Rh="Yorkie JS SDK",Dh="./src/yorkie.ts",Bh={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},Mh=["dist"],qh={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},Fh={node:">=18.0.0",npm:">=7.1.0"},jh={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},Uh={name:"hackerwins",email:"susukang98@gmail.com"},Jh="Apache-2.0",$h={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},zh="https://github.com/yorkie-team/yorkie-js-sdk#readme",Vh={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},Kh={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},Nl={name:Ch,version:Lh,description:Rh,main:Dh,publishConfig:Bh,files:Mh,scripts:qh,engines:Fh,repository:jh,author:Uh,license:Jh,bugs:$h,homepage:zh,devDependencies:Vh,dependencies:Kh};function Hh(){return i=>async t=>(t.header.set("x-yorkie-user-agent",Nl.name+"/"+Nl.version),await i(t))}const Wh=i=>{try{if(JSON.stringify(i)===void 0)return!1}catch{return!1}return!0};var Qo=(i=>(i.Manual="manual",i.Realtime="realtime",i.RealtimePushOnly="realtime-pushonly",i.RealtimeSyncOff="realtime-syncoff",i))(Qo||{});const Vo={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},$s={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class Ju{constructor(t,e){T(this,"id");T(this,"key");T(this,"status");T(this,"attachmentMap");T(this,"apiKey");T(this,"authTokenInjector");T(this,"conditions");T(this,"syncLoopDuration");T(this,"reconnectStreamDelay");T(this,"retrySyncLoopDelay");T(this,"rpcClient");T(this,"setAuthToken");T(this,"taskQueue");T(this,"processing",!1);T(this,"keepalive",!1);e=e||Vo,this.key=e.key?e.key:qu(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=e.apiKey||"",this.authTokenInjector=e.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=e.syncLoopDuration??Vo.syncLoopDuration,this.reconnectStreamDelay=e.reconnectStreamDelay??Vo.reconnectStreamDelay,this.retrySyncLoopDelay=e.retrySyncLoopDelay??Vo.retrySyncLoopDelay;const{authInterceptor:n,setToken:r}=Ph(this.apiKey);this.setAuthToken=r,this.rpcClient=Kc(mf,pf({baseUrl:t,interceptors:[n,Hh()],fetch:(o,s)=>{const u={...s,keepalive:this.keepalive};return fetch(o,u)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const t=await this.authTokenInjector();this.setAuthToken(t)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(t=>{this.id=t.clientId,this.status="activated",this.runSyncLoop(),Ne.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async t=>{throw Ne.error(`[AC] c:"${this.getKey()}" err :`,t),await this.handleConnectError(t),t}))}deactivate(t={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const e=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),Ne.info(`[DC] c"${this.getKey()}" deactivated`)}catch(n){throw Ne.error(`[DC] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n}};if(t.keepalive){this.keepalive=!0;const n=e();return this.keepalive=!1,n}return this.enqueueTask(e)}attach(t,e={}){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);if(t.getStatus()!==si.Detached)throw new ne(te.ErrDocumentNotDetached,`${t.getKey()} is not detached`);t.setActor(this.id),t.update((o,s)=>s.set(e.initialPresence||{}));const n=t.subscribe("local-broadcast",async o=>{var y;const{topic:s,payload:u}=o.value,c=(y=o.options)==null?void 0:y.error,m=o.options;try{await this.broadcast(t.getKey(),s,u,m)}catch(f){f instanceof Error&&(c==null||c(f))}}),r=e.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:lt.toChangePack(t.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(async o=>{const s=lt.fromChangePack(o.changePack);if(t.applyChangePack(s),t.getStatus()===si.Removed)return t;t.applyStatus(si.Attached),this.attachmentMap.set(t.getKey(),new wh(this.reconnectStreamDelay,t,o.documentId,r,n)),r!=="manual"&&await this.runWatchLoop(t.getKey()),Ne.info(`[AD] c:"${this.getKey()}" attaches d:"${t.getKey()}"`);const u=t.getRootObject();if(e.initialRoot){const c=e.initialRoot;t.update(m=>{for(const[y,f]of Object.entries(c))if(!u.has(y)){const l=y;m[l]=f}})}return t}).catch(async o=>{throw Ne.error(`[AD] c:"${this.getKey()}" err :`,o),await this.handleConnectError(o),o}))}detach(t,e={}){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return t.update((r,o)=>o.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:n.docID,changePack:lt.toChangePack(t.createChangePack()),removeIfNotAttached:e.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(r=>{const o=lt.fromChangePack(r.changePack);return t.applyChangePack(o),t.getStatus()!==si.Removed&&t.applyStatus(si.Detached),this.detachInternal(t.getKey()),Ne.info(`[DD] c:"${this.getKey()}" detaches d:"${t.getKey()}"`),t}).catch(async r=>{throw Ne.error(`[DD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}async changeSyncMode(t,e){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const n=this.attachmentMap.get(t.getKey());if(!n)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);const r=n.syncMode;return r===e?t:(n.changeSyncMode(e),e==="manual"?(n.cancelWatchStream(),t):(e==="realtime"&&(n.remoteChangeEventReceived=!0),r==="manual"&&await this.runWatchLoop(t.getKey()),t))}sync(t){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);if(t){const e=this.attachmentMap.get(t.getKey());if(!e)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(e,"realtime").catch(async n=>{throw Ne.error(`[SY] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n}))}return this.enqueueTask(async()=>{const e=[];for(const[,n]of this.attachmentMap)e.push(this.syncInternal(n,n.syncMode));return Promise.all(e).catch(async n=>{throw Ne.error(`[SY] c:"${this.getKey()}" err :`,n),await this.handleConnectError(n),n})})}remove(t){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const e=this.attachmentMap.get(t.getKey());if(!e)throw new ne(te.ErrDocumentNotAttached,`${t.getKey()} is not attached`);t.setActor(this.id);const n=lt.toChangePack(t.createChangePack());return n.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:e.docID,changePack:n},{headers:{"x-shard-key":`${this.apiKey}/${t.getKey()}`}}).then(r=>{const o=lt.fromChangePack(r.changePack);t.applyChangePack(o),this.detachInternal(t.getKey()),Ne.info(`[RD] c:"${this.getKey()}" removes d:"${t.getKey()}"`)}).catch(async r=>{throw Ne.error(`[RD] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(t){return this.conditions[t]}broadcast(t,e,n,r){if(!this.isActive())throw new ne(te.ErrClientNotActivated,`${this.key} is not active`);const o=this.attachmentMap.get(t);if(!o)throw new ne(te.ErrDocumentNotAttached,`${t} is not attached`);if(!Wh(n))throw new ne(te.ErrInvalidArgument,"payload is not serializable");const s=(r==null?void 0:r.maxRetries)??$s.maxRetries,u=$s.maxBackoff;let c=0;const m=f=>Math.min($s.initialRetryInterval*2**f,u),y=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:o.docID,topic:e,payload:new TextEncoder().encode(JSON.stringify(n))},{headers:{"x-shard-key":`${this.apiKey}/${t}`}}).then(()=>{Ne.info(`[BC] c:"${this.getKey()}" broadcasts d:"${t}" t:"${e}"`)}).catch(async f=>{if(Ne.error(`[BC] c:"${this.getKey()}" err:`,f),await this.handleConnectError(f))if(f instanceof Ze&&Mi(f)===te.ErrUnauthenticated&&o.doc.publish([{type:ft.AuthError,value:{reason:ao(f).reason,method:"Broadcast"}}]),cy(),m(c-1)),Ne.info(`[BC] c:"${this.getKey()}" retry attempt ${c}/${s}`);else throw Ne.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),f;else throw f}));return y()}runSyncLoop(){const t=()=>{if(!this.isActive()){Ne.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const e=[];for(const[,n]of this.attachmentMap)n.needRealtimeSync()&&(n.remoteChangeEventReceived=!1,e.push(this.syncInternal(n,n.syncMode).catch(async r=>{throw r instanceof Ze&&Mi(r)===te.ErrUnauthenticated&&n.doc.publish([{type:ft.AuthError,value:{reason:ao(r).reason,method:"PushPull"}}]),r})));Promise.all(e).then(()=>setTimeout(t,this.syncLoopDuration)).catch(async n=>{Ne.error(`[SL] c:"${this.getKey()}" sync failed:`,n),await this.handleConnectError(n)?setTimeout(t,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};Ne.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,t()}async runWatchLoop(t){const e=this.attachmentMap.get(t);if(!e)throw new ne(te.ErrDocumentNotAttached,`${t} is not attached`);return this.conditions.WatchLoop=!0,e.runWatchLoop(n=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new ne(te.ErrClientNotActivated,`${this.key} is not active`));const r=new AbortController,o=this.rpcClient.watchDocument({clientId:this.id,documentId:e.docID},{headers:{"x-shard-key":`${this.apiKey}/${t}`},signal:r.signal});return e.doc.publish([{type:ft.ConnectionChanged,value:xo.Connected}]),Ne.info(`[WD] c:"${this.getKey()}" watches d:"${t}"`),new Promise((s,u)=>{(async()=>{try{for await(const m of o)this.handleWatchDocumentsResponse(e,m),m.body.case==="initialization"&&s([o,r])}catch(m){e.doc.resetOnlineClients(),e.doc.publish([{type:ft.Initialized,source:Ye.Local,value:e.doc.getPresences()}]),e.doc.publish([{type:ft.ConnectionChanged,value:xo.Disconnected}]),Ne.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(m)?(m instanceof Ze&&Mi(m)===te.ErrUnauthenticated&&e.doc.publish([{type:ft.AuthError,value:{reason:ao(m).reason,method:"WatchDocuments"}}]),n()):this.conditions.WatchLoop=!1,u(m)}})()})})}handleWatchDocumentsResponse(t,e){if(e.body.case==="event"&&e.body.value.type===Oi.DOCUMENT_CHANGED){t.remoteChangeEventReceived=!0;return}t.doc.applyWatchStream(e)}deactivateInternal(){this.status="deactivated";for(const[t,e]of this.attachmentMap)this.detachInternal(t),e.doc.applyStatus(si.Detached)}detachInternal(t){const e=this.attachmentMap.get(t);e&&(e.cancelWatchStream(),e.unsubscribeBroadcastEvent(),this.attachmentMap.delete(t))}syncInternal(t,e){const{doc:n,docID:r}=t,o=n.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:r,changePack:lt.toChangePack(o),pushOnly:e==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${n.getKey()}`}}).then(s=>{const u=lt.fromChangePack(s.changePack);if(u.hasChanges()&&(t.syncMode==="realtime-pushonly"||t.syncMode==="realtime-syncoff"))return n;n.applyChangePack(u),t.doc.publish([{type:ft.SyncStatusChanged,value:ba.Synced}]),n.getStatus()===si.Removed&&this.detachInternal(n.getKey());const c=n.getKey(),m=u.getChangeSize();return Ne.info(`[PP] c:"${this.getKey()}" sync d:"${c}", push:${o.getChangeSize()} pull:${m} cp:${u.getCheckpoint().toTestString()}`),n}).catch(async s=>{throw n.publish([{type:ft.SyncStatusChanged,value:ba.SyncFailed}]),Ne.error(`[PP] c:"${this.getKey()}" err :`,s),s})}async handleConnectError(t){if(!(t instanceof Ze))return!1;if(t.code===Ge.Canceled||t.code===Ge.Unknown||t.code===Ge.ResourceExhausted||t.code===Ge.Unavailable)return!0;if(Mi(t)===te.ErrUnauthenticated){if(this.authTokenInjector){const e=await this.authTokenInjector(ao(t).reason);this.setAuthToken(e)}return!0}return(Mi(t)===te.ErrClientNotActivated||Mi(t)===te.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(t){return new Promise((e,n)=>{this.taskQueue.push(()=>t().then(e).catch(n)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{Ne.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const zs={Client:Ju,Document:Uu,Primitive:tt,Text:Ps,Counter:Cs,Tree:Ls,LogLevel:wt,setLogLevel:Mu,IntType:Un.IntegerCnt,LongType:Un.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:Ju,Document:Uu,Primitive:tt,Text:Ps,Counter:Cs,Tree:Ls,LogLevel:wt,setLogLevel:Mu,IntType:Un.IntegerCnt,LongType:Un.LongCnt});var Gh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $u(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var zu={exports:{}};/*! * Quill Editor v1.3.7 * https://quilljs.com/ * Copyright (c) 2014, Jason Chen @@ -60,7 +60,7 @@ var Ku=Object.defineProperty;var Hu=(i,t,e)=>t in i?Ku(i,t,{enumerable:!0,config `),G}function U(j,G){if(D(j)&&j.nextElementSibling!=null&&!V(G,` `)){var se=j.offsetHeight+parseFloat(H(j).marginTop)+parseFloat(H(j).marginBottom);j.nextElementSibling.offsetTop>j.offsetTop+se*1.5&&G.insert(` -`)}return G}function Q(j,G){var se={},ue=j.style||{};return ue.fontStyle&&H(j).fontStyle==="italic"&&(se.italic=!0),ue.fontWeight&&(H(j).fontWeight.startsWith("bold")||parseInt(H(j).fontWeight)>=700)&&(se.bold=!0),Object.keys(se).length>0&&(G=B(G,se)),parseFloat(ue.textIndent||0)>0&&(G=new f.default().insert(" ").concat(G)),G}function Y(j,G){var se=j.data;if(j.parentNode.tagName==="O:P")return G.insert(se.trim());if(se.trim().length===0&&j.parentNode.classList.contains("ql-clipboard"))return G;if(!H(j.parentNode).whiteSpace.startsWith("pre")){var ue=function(ge,ve){return ve=ve.replace(/[^\u00a0]/g,""),ve.length<1&&ge?" ":ve};se=se.replace(/\r\n/g," ").replace(/\n/g," "),se=se.replace(/\s\s+/g,ue.bind(ue,!0)),(j.previousSibling==null&&D(j.parentNode)||j.previousSibling!=null&&D(j.previousSibling))&&(se=se.replace(/^\s+/,ue.bind(ue,!1))),(j.nextSibling==null&&D(j.parentNode)||j.nextSibling!=null&&D(j.nextSibling))&&(se=se.replace(/\s+$/,ue.bind(ue,!1)))}return G.insert(se)}n.default=M,n.matchAttributor=X,n.matchBlot=ie,n.matchNewline=be,n.matchSpacing=U,n.matchText=Y},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;v '},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;va.right&&(b=a.right-p.right,this.root.style.left=f+b+"px"),p.lefta.bottom){var w=p.bottom-p.top,v=y.bottom-y.top+w;this.root.style.top=l-v+"px",this.root.classList.add("ql-flip")}return b}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),c}();n.default=u},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function k(x,I){var N=[],P=!0,R=!1,q=void 0;try{for(var J=x[Symbol.iterator](),ee;!(P=(ee=J.next()).done)&&(N.push(ee.value),!(I&&N.length===I));P=!0);}catch(z){R=!0,q=z}finally{try{!P&&J.return&&J.return()}finally{if(R)throw q}}return N}return function(x,I){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return k(x,I);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=function k(x,I,N){x===null&&(x=Function.prototype);var P=Object.getOwnPropertyDescriptor(x,I);if(P===void 0){var R=Object.getPrototypeOf(x);return R===null?void 0:k(R,I,N)}else{if("value"in P)return P.value;var q=P.get;return q===void 0?void 0:q.call(N)}},u=function(){function k(x,I){for(var N=0;N','','',''].join(""),n.default=O},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=r(29),s=re(o),u=r(36),c=r(38),m=r(64),y=r(65),f=re(y),l=r(66),a=re(l),p=r(67),b=re(p),w=r(37),v=r(26),h=r(39),g=r(40),d=r(56),A=re(d),S=r(68),E=re(S),O=r(27),_=re(O),k=r(69),x=re(k),I=r(70),N=re(I),P=r(71),R=re(P),q=r(72),J=re(q),ee=r(73),z=re(ee),F=r(13),C=re(F),M=r(74),B=re(M),H=r(75),V=re(H),D=r(57),$=re(D),W=r(41),X=re(W),ie=r(28),fe=re(ie),we=r(59),ye=re(we),be=r(60),U=re(be),Q=r(61),Y=re(Q),j=r(108),G=re(j),se=r(62),ue=re(se);function re(ge){return ge&&ge.__esModule?ge:{default:ge}}s.default.register({"attributors/attribute/direction":c.DirectionAttribute,"attributors/class/align":u.AlignClass,"attributors/class/background":w.BackgroundClass,"attributors/class/color":v.ColorClass,"attributors/class/direction":c.DirectionClass,"attributors/class/font":h.FontClass,"attributors/class/size":g.SizeClass,"attributors/style/align":u.AlignStyle,"attributors/style/background":w.BackgroundStyle,"attributors/style/color":v.ColorStyle,"attributors/style/direction":c.DirectionStyle,"attributors/style/font":h.FontStyle,"attributors/style/size":g.SizeStyle},!0),s.default.register({"formats/align":u.AlignClass,"formats/direction":c.DirectionClass,"formats/indent":m.IndentClass,"formats/background":w.BackgroundStyle,"formats/color":v.ColorStyle,"formats/font":h.FontClass,"formats/size":g.SizeClass,"formats/blockquote":f.default,"formats/code-block":C.default,"formats/header":a.default,"formats/list":b.default,"formats/bold":A.default,"formats/code":F.Code,"formats/italic":E.default,"formats/link":_.default,"formats/script":x.default,"formats/strike":N.default,"formats/underline":R.default,"formats/image":J.default,"formats/video":z.default,"formats/list/item":p.ListItem,"modules/formula":B.default,"modules/syntax":V.default,"modules/toolbar":$.default,"themes/bubble":G.default,"themes/snow":ue.default,"ui/icons":X.default,"ui/picker":fe.default,"ui/icon-picker":U.default,"ui/color-picker":ye.default,"ui/tooltip":Y.default},!0),n.default=s.default},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.IndentClass=void 0;var o=function(){function b(w,v){for(var h=0;h0&&this.children.tail.format(E,O)}},{key:"formats",value:function(){return p({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(E,O){if(E instanceof h)s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"insertBefore",this).call(this,E,O);else{var _=O==null?this.length():O.offset(this),k=this.split(_);k.parent.insertBefore(E,k)}}},{key:"optimize",value:function(E){s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"optimize",this).call(this,E);var O=this.next;O!=null&&O.prev===this&&O.statics.blotName===this.statics.blotName&&O.domNode.tagName===this.domNode.tagName&&O.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(O.moveChildren(this),O.remove())}},{key:"replace",value:function(E){if(E.statics.blotName!==this.statics.blotName){var O=c.default.create(this.statics.defaultChild);E.moveChildren(O),this.appendChild(O)}s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replace",this).call(this,E)}}]),A}(l.default);g.blotName="list",g.scope=c.default.Scope.BLOCK_BLOT,g.tagName=["OL","UL"],g.defaultChild="list-item",g.allowedChildren=[h],n.ListItem=h,n.default=g},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=r(56),s=u(o);function u(l){return l&&l.__esModule?l:{default:l}}function c(l,a){if(!(l instanceof a))throw new TypeError("Cannot call a class as a function")}function m(l,a){if(!l)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:l}function y(l,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);l.prototype=Object.create(a&&a.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(l,a):l.__proto__=a)}var f=function(l){y(a,l);function a(){return c(this,a),m(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments))}return a}(s.default);f.blotName="italic",f.tagName=["EM","I"],n.default=f},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;v-1?d?this.domNode.setAttribute(g,d):this.domNode.removeAttribute(g):s(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"format",this).call(this,g,d)}}],[{key:"create",value:function(g){var d=s(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,g);return typeof g=="string"&&d.setAttribute("src",this.sanitize(g)),d}},{key:"formats",value:function(g){return p.reduce(function(d,A){return g.hasAttribute(A)&&(d[A]=g.getAttribute(A)),d},{})}},{key:"match",value:function(g){return/\.(jpe?g|gif|png)$/.test(g)||/^data:image\/.+;base64/.test(g)}},{key:"sanitize",value:function(g){return(0,m.sanitize)(g,["http","https","data"])?g:"//:0"}},{key:"value",value:function(g){return g.getAttribute("src")}}]),v}(c.default.Embed);b.blotName="image",b.tagName="IMG",n.default=b},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function w(v,h){for(var g=0;g-1?d?this.domNode.setAttribute(g,d):this.domNode.removeAttribute(g):s(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"format",this).call(this,g,d)}}],[{key:"create",value:function(g){var d=s(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,g);return d.setAttribute("frameborder","0"),d.setAttribute("allowfullscreen",!0),d.setAttribute("src",this.sanitize(g)),d}},{key:"formats",value:function(g){return p.reduce(function(d,A){return g.hasAttribute(A)&&(d[A]=g.getAttribute(A)),d},{})}},{key:"sanitize",value:function(g){return m.default.sanitize(g)}},{key:"value",value:function(g){return g.getAttribute("src")}}]),v}(u.BlockEmbed);b.blotName="video",b.className="ql-video",b.tagName="IFRAME",n.default=b},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.default=n.FormulaBlot=void 0;var o=function(){function g(d,A){for(var S=0;S0||this.cachedText==null)&&(this.domNode.innerHTML=_(k),this.domNode.normalize(),this.attach()),this.cachedText=k)}}]),E}(p.default);g.className="ql-syntax";var d=new c.default.Attributor.Class("token","hljs",{scope:c.default.Scope.INLINE}),A=function(S){h(E,S),o(E,null,[{key:"register",value:function(){y.default.register(d,!0),y.default.register(g,!0)}}]);function E(O,_){w(this,E);var k=v(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,O,_));if(typeof k.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var x=null;return k.quill.on(y.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(x),x=setTimeout(function(){k.highlight(),x=null},k.options.interval)}),k.highlight(),k}return o(E,[{key:"highlight",value:function(){var _=this;if(!this.quill.selection.composing){this.quill.update(y.default.sources.USER);var k=this.quill.getSelection();this.quill.scroll.descendants(g).forEach(function(x){x.highlight(_.options.highlight)}),this.quill.update(y.default.sources.SILENT),k!=null&&this.quill.setSelection(k,y.default.sources.SILENT)}}}]),E}(l.default);A.DEFAULTS={highlight:function(){return window.hljs==null?null:function(S){var E=window.hljs.highlightAuto(S);return E.value}}(),interval:1e3},n.CodeBlock=g,n.CodeToken=d,n.default=A},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.default=n.BubbleTooltip=void 0;var o=function E(O,_,k){O===null&&(O=Function.prototype);var x=Object.getOwnPropertyDescriptor(O,_);if(x===void 0){var I=Object.getPrototypeOf(O);return I===null?void 0:E(I,_,k)}else{if("value"in x)return x.value;var N=x.get;return N===void 0?void 0:N.call(k)}},s=function(){function E(O,_){for(var k=0;k<_.length;k++){var x=_[k];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}return function(O,_,k){return _&&E(O.prototype,_),k&&E(O,k),O}}(),u=r(3),c=w(u),m=r(8),y=w(m),f=r(43),l=w(f),a=r(15),p=r(41),b=w(p);function w(E){return E&&E.__esModule?E:{default:E}}function v(E,O){if(!(E instanceof O))throw new TypeError("Cannot call a class as a function")}function h(E,O){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:E}function g(E,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);E.prototype=Object.create(O&&O.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(E,O):E.__proto__=O)}var d=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],A=function(E){g(O,E);function O(_,k){v(this,O),k.modules.toolbar!=null&&k.modules.toolbar.container==null&&(k.modules.toolbar.container=d);var x=h(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,_,k));return x.quill.container.classList.add("ql-bubble"),x}return s(O,[{key:"extendToolbar",value:function(k){this.tooltip=new S(this.quill,this.options.bounds),this.tooltip.root.appendChild(k.container),this.buildButtons([].slice.call(k.container.querySelectorAll("button")),b.default),this.buildPickers([].slice.call(k.container.querySelectorAll("select")),b.default)}}]),O}(l.default);A.DEFAULTS=(0,c.default)(!0,{},l.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(O){O?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var S=function(E){g(O,E);function O(_,k){v(this,O);var x=h(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,_,k));return x.quill.on(y.default.events.EDITOR_CHANGE,function(I,N,P,R){if(I===y.default.events.SELECTION_CHANGE)if(N!=null&&N.length>0&&R===y.default.sources.USER){x.show(),x.root.style.left="0px",x.root.style.width="",x.root.style.width=x.root.offsetWidth+"px";var q=x.quill.getLines(N.index,N.length);if(q.length===1)x.position(x.quill.getBounds(N));else{var J=q[q.length-1],ee=x.quill.getIndex(J),z=Math.min(J.length()-1,N.index+N.length-ee),F=x.quill.getBounds(new a.Range(ee,z));x.position(F)}}else document.activeElement!==x.textbox&&x.quill.hasFocus()&&x.hide()}),x}return s(O,[{key:"listen",value:function(){var k=this;o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){k.root.classList.remove("ql-editing")}),this.quill.on(y.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!k.root.classList.contains("ql-hidden")){var x=k.quill.getSelection();x!=null&&k.position(k.quill.getBounds(x))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(k){var x=o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"position",this).call(this,k),I=this.root.querySelector(".ql-tooltip-arrow");if(I.style.marginLeft="",x===0)return x;I.style.marginLeft=-1*x-I.offsetWidth/2+"px"}}]),O}(f.BaseTooltip);S.TEMPLATE=['','
    ','','',"
    "].join(""),n.BubbleTooltip=S,n.default=A},function(e,n,r){e.exports=r(63)}]).default})})(zu);var Yh=zu.exports;const _l=$u(Yh);var Vu={exports:{}};/*! For license information please see quill-cursors.js.LICENSE.txt */(function(i,t){(function(e,n){i.exports=n()})(self,()=>(()=>{var e={582:(s,u,c)=>{c.d(u,{Z:()=>a});var m=c(81),y=c.n(m),f=c(645),l=c.n(f)()(y());l.push([s.id,".ql-container{position:relative;overflow:hidden}@media(pointer: coarse){.ql-cursor-caret-container{z-index:-1}}.ql-cursor.hidden{display:none}.ql-cursor .ql-cursor-caret-container,.ql-cursor .ql-cursor-flag{position:absolute}.ql-cursor .ql-cursor-flag{z-index:1;transform:translate3d(-1px, -100%, 0);opacity:0;visibility:hidden;color:#fff;padding-bottom:2px;border-radius:0 3px 3px 0}.ql-cursor .ql-cursor-flag.flag-flipped{border-radius:3px 0 0 3px;transform:translate3d(calc(-100% + 1px ), -100%, 0)}@media screen{.ql-cursor .ql-cursor-flag{transition:opacity 0ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 0ms,visibility 0ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 0ms}}.ql-cursor .ql-cursor-flag .ql-cursor-name{margin-left:5px;margin-right:5px;display:inline-block;margin-top:-2px;white-space:nowrap}.ql-cursor .ql-cursor-flag.no-delay[style]{transition-delay:unset !important}.ql-cursor .ql-cursor-caret-container{cursor:text;margin-left:-9px;padding:0 9px}.ql-cursor .ql-cursor-caret-container.hover+.ql-cursor-flag{opacity:1;visibility:visible;transition:none}.ql-cursor .ql-cursor-caret-container.no-pointer{pointer-events:none}.ql-cursor .ql-cursor-caret-container .ql-cursor-caret{position:absolute;top:0;bottom:0;width:2px;margin-left:-1px;background-color:attr(data-color)}.ql-cursor .ql-cursor-selection-block{position:absolute;pointer-events:none}",""]);const a=l},645:s=>{s.exports=function(u){var c=[];return c.toString=function(){return this.map(function(m){var y="",f=m[5]!==void 0;return m[4]&&(y+="@supports (".concat(m[4],") {")),m[2]&&(y+="@media ".concat(m[2]," {")),f&&(y+="@layer".concat(m[5].length>0?" ".concat(m[5]):""," {")),y+=u(m),f&&(y+="}"),m[2]&&(y+="}"),m[4]&&(y+="}"),y}).join("")},c.i=function(m,y,f,l,a){typeof m=="string"&&(m=[[null,m,void 0]]);var p={};if(f)for(var b=0;b0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=a),y&&(h[2]&&(h[1]="@media ".concat(h[2]," {").concat(h[1],"}")),h[2]=y),l&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=l):h[4]="".concat(l)),c.push(h))}},c}},81:s=>{s.exports=function(u){return u[1]}},465:(s,u,c)=>{s=c.nmd(s);var m="__lodash_hash_undefined__",y=9007199254740991,f="[object Arguments]",l="[object Boolean]",a="[object Date]",p="[object Function]",b="[object GeneratorFunction]",w="[object Map]",v="[object Number]",h="[object Object]",g="[object Promise]",d="[object RegExp]",A="[object Set]",S="[object String]",E="[object Symbol]",O="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",x="[object Float32Array]",I="[object Float64Array]",N="[object Int8Array]",P="[object Int16Array]",R="[object Int32Array]",q="[object Uint8Array]",J="[object Uint8ClampedArray]",ee="[object Uint16Array]",z="[object Uint32Array]",F=/\w*$/,C=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,B={};B[f]=B["[object Array]"]=B[_]=B[k]=B[l]=B[a]=B[x]=B[I]=B[N]=B[P]=B[R]=B[w]=B[v]=B[h]=B[d]=B[A]=B[S]=B[E]=B[q]=B[J]=B[ee]=B[z]=!0,B["[object Error]"]=B[p]=B[O]=!1;var H=typeof c.g=="object"&&c.g&&c.g.Object===Object&&c.g,V=typeof self=="object"&&self&&self.Object===Object&&self,D=H||V||Function("return this")(),$=u&&!u.nodeType&&u,W=$&&s&&!s.nodeType&&s,X=W&&W.exports===$;function ie(K,oe){return K.set(oe[0],oe[1]),K}function fe(K,oe){return K.add(oe),K}function we(K,oe,pe,Ae){var Me=-1,We=K?K.length:0;for(Ae;++Me-1},St.prototype.set=function(K,oe){var pe=this.__data__,Ae=Ri(pe,K);return Ae<0?pe.push([K,oe]):pe[Ae][1]=oe,this},_t.prototype.clear=function(){this.__data__={hash:new pn,map:new(Tt||St),string:new pn}},_t.prototype.delete=function(K){return Jn(this,K).delete(K)},_t.prototype.get=function(K){return Jn(this,K).get(K)},_t.prototype.has=function(K){return Jn(this,K).has(K)},_t.prototype.set=function(K,oe){return Jn(this,K).set(K,oe),this},ei.prototype.clear=function(){this.__data__=new St},ei.prototype.delete=function(K){return this.__data__.delete(K)},ei.prototype.get=function(K){return this.__data__.get(K)},ei.prototype.has=function(K){return this.__data__.has(K)},ei.prototype.set=function(K,oe){var pe=this.__data__;if(pe instanceof St){var Ae=pe.__data__;if(!Tt||Ae.length<199)return Ae.push([K,oe]),this;pe=this.__data__=new _t(Ae)}return pe.set(K,oe),this};var ro=vt?U(vt,Object):function(){return[]},yn=function(K){return Oe.call(K)};function Lo(K,oe){return!!(oe=oe??y)&&(typeof K=="number"||M.test(K))&&K>-1&&K%1==0&&K-1&&oe%1==0&&oe<=y}(K.length)&&!Ee(K)}var de=Zt||function(){return!1};function Ee(K){var oe=ze(K)?Oe.call(K):"";return oe==p||oe==b}function ze(K){var oe=typeof K;return!!K&&(oe=="object"||oe=="function")}function Be(K){return ae(K)?function(oe,pe){var Ae=Z(oe)||function(je){return function(st){return function(et){return!!et&&typeof et=="object"}(st)&&ae(st)}(je)&&ve.call(je,"callee")&&(!At.call(je,"callee")||Oe.call(je)==f)}(oe)?function(je,st){for(var et=-1,bn=Array(je);++et{s=c.nmd(s);var m="__lodash_hash_undefined__",y=9007199254740991,f="[object Arguments]",l="[object Array]",a="[object Boolean]",p="[object Date]",b="[object Error]",w="[object Function]",v="[object Map]",h="[object Number]",g="[object Object]",d="[object Promise]",A="[object RegExp]",S="[object Set]",E="[object String]",O="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",x=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,N={};N["[object Float32Array]"]=N["[object Float64Array]"]=N["[object Int8Array]"]=N["[object Int16Array]"]=N["[object Int32Array]"]=N["[object Uint8Array]"]=N["[object Uint8ClampedArray]"]=N["[object Uint16Array]"]=N["[object Uint32Array]"]=!0,N[f]=N[l]=N[_]=N[a]=N[k]=N[p]=N[b]=N[w]=N[v]=N[h]=N[g]=N[A]=N[S]=N[E]=N[O]=!1;var P=typeof c.g=="object"&&c.g&&c.g.Object===Object&&c.g,R=typeof self=="object"&&self&&self.Object===Object&&self,q=P||R||Function("return this")(),J=u&&!u.nodeType&&u,ee=J&&s&&!s.nodeType&&s,z=ee&&ee.exports===J,F=z&&P.process,C=function(){try{return F&&F.binding&&F.binding("util")}catch{}}(),M=C&&C.isTypedArray;function B(Z,ae){for(var de=-1,Ee=Z==null?0:Z.length;++deoe))return!1;var Ae=Be.get(Z);if(Ae&&Be.get(ae))return Ae==ae;var Me=-1,We=!0,Qe=2&de?new Ci:void 0;for(Be.set(Z,ae),Be.set(ae,Z);++Me-1},It.prototype.set=function(Z,ae){var de=this.__data__,Ee=Li(de,Z);return Ee<0?(++this.size,de.push([Z,ae])):de[Ee][1]=ae,this},Nt.prototype.clear=function(){this.size=0,this.__data__={hash:new ot,map:new(_e||It),string:new ot}},Nt.prototype.delete=function(Z){var ae=St(this,Z).delete(Z);return this.size-=ae?1:0,ae},Nt.prototype.get=function(Z){return St(this,Z).get(Z)},Nt.prototype.has=function(Z){return St(this,Z).has(Z)},Nt.prototype.set=function(Z,ae){var de=St(this,Z),Ee=de.size;return de.set(Z,ae),this.size+=de.size==Ee?0:1,this},Ci.prototype.add=Ci.prototype.push=function(Z){return this.__data__.set(Z,m),this},Ci.prototype.has=function(Z){return this.__data__.has(Z)},gn.prototype.clear=function(){this.__data__=new It,this.size=0},gn.prototype.delete=function(Z){var ae=this.__data__,de=ae.delete(Z);return this.size=ae.size,de},gn.prototype.get=function(Z){return this.__data__.get(Z)},gn.prototype.has=function(Z){return this.__data__.has(Z)},gn.prototype.set=function(Z,ae){var de=this.__data__;if(de instanceof It){var Ee=de.__data__;if(!_e||Ee.length<199)return Ee.push([Z,ae]),this.size=++de.size,this;de=this.__data__=new Nt(Ee)}return de.set(Z,ae),this.size=de.size,this};var ei=ve?function(Z){return Z==null?[]:(Z=Object(Z),function(ae,de){for(var Ee=-1,ze=ae==null?0:ae.length,Be=0,K=[];++Ee-1&&Z%1==0&&Z-1&&Z%1==0&&Z<=y}function Lo(Z){var ae=typeof Z;return Z!=null&&(ae=="object"||ae=="function")}function ti(Z){return Z!=null&&typeof Z=="object"}var vn=M?function(Z){return function(ae){return Z(ae)}}(M):function(Z){return ti(Z)&&yn(Z.length)&&!!N[yi(Z)]};function Ro(Z){return(ae=Z)!=null&&yn(ae.length)&&!ro(ae)?function(de,Ee){var ze=Jn(de),Be=!ze&&Co(de),K=!ze&&!Be&&mn(de),oe=!ze&&!Be&&!K&&vn(de),pe=ze||Be||K||oe,Ae=pe?function(Qe,je){for(var st=-1,et=Array(Qe);++st0?v:void 0},a.diff=function(p,b){p===void 0&&(p={}),b===void 0&&(b={}),typeof p!="object"&&(p={}),typeof b!="object"&&(b={});var w=Object.keys(p).concat(Object.keys(b)).reduce(function(v,h){return l.default(p[h],b[h])||(v[h]=b[h]===void 0?null:b[h]),v},{});return Object.keys(w).length>0?w:void 0},a.invert=function(p,b){p===void 0&&(p={}),b===void 0&&(b={}),p=p||{};var w=Object.keys(b).reduce(function(v,h){return b[h]!==p[h]&&p[h]!==void 0&&(v[h]=b[h]),v},{});return Object.keys(p).reduce(function(v,h){return p[h]!==b[h]&&b[h]===void 0&&(v[h]=null),v},w)},a.transform=function(p,b,w){if(w===void 0&&(w=!1),typeof p!="object")return b;if(typeof b=="object"){if(!w)return b;var v=Object.keys(b).reduce(function(h,g){return p[g]===void 0&&(h[g]=b[g]),h},{});return Object.keys(v).length>0?v:void 0}}})(y||(y={})),u.default=y},895:function(s,u,c){var m=this&&this.__importDefault||function(v){return v&&v.__esModule?v:{default:v}},y=m(c(103)),f=m(c(465)),l=m(c(307)),a=m(c(210)),p=m(c(430)),b="\0",w=function(){function v(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]}return v.prototype.insert=function(h,g){var d={};return typeof h=="string"&&h.length===0?this:(d.insert=h,g!=null&&typeof g=="object"&&Object.keys(g).length>0&&(d.attributes=g),this.push(d))},v.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},v.prototype.retain=function(h,g){if(h<=0)return this;var d={retain:h};return g!=null&&typeof g=="object"&&Object.keys(g).length>0&&(d.attributes=g),this.push(d)},v.prototype.push=function(h){var g=this.ops.length,d=this.ops[g-1];if(h=f.default(h),typeof d=="object"){if(typeof h.delete=="number"&&typeof d.delete=="number")return this.ops[g-1]={delete:d.delete+h.delete},this;if(typeof d.delete=="number"&&h.insert!=null&&(g-=1,typeof(d=this.ops[g-1])!="object"))return this.ops.unshift(h),this;if(l.default(h.attributes,d.attributes)){if(typeof h.insert=="string"&&typeof d.insert=="string")return this.ops[g-1]={insert:d.insert+h.insert},typeof h.attributes=="object"&&(this.ops[g-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof d.retain=="number")return this.ops[g-1]={retain:d.retain+h.retain},typeof h.attributes=="object"&&(this.ops[g-1].attributes=h.attributes),this}}return g===this.ops.length?this.ops.push(h):this.ops.splice(g,0,h),this},v.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},v.prototype.filter=function(h){return this.ops.filter(h)},v.prototype.forEach=function(h){this.ops.forEach(h)},v.prototype.map=function(h){return this.ops.map(h)},v.prototype.partition=function(h){var g=[],d=[];return this.forEach(function(A){(h(A)?g:d).push(A)}),[g,d]},v.prototype.reduce=function(h,g){return this.ops.reduce(h,g)},v.prototype.changeLength=function(){return this.reduce(function(h,g){return g.insert?h+p.default.length(g):g.delete?h-g.delete:h},0)},v.prototype.length=function(){return this.reduce(function(h,g){return h+p.default.length(g)},0)},v.prototype.slice=function(h,g){h===void 0&&(h=0),g===void 0&&(g=1/0);for(var d=[],A=p.default.iterator(this.ops),S=0;S0&&d.next(S.retain-E)}for(var O=new v(A);g.hasNext()||d.hasNext();)if(d.peekType()==="insert")O.push(d.next());else if(g.peekType()==="delete")O.push(g.next());else{var _=Math.min(g.peekLength(),d.peekLength()),k=g.next(_),x=d.next(_);if(typeof x.retain=="number"){var I={};typeof k.retain=="number"?I.retain=_:I.insert=k.insert;var N=a.default.compose(k.attributes,x.attributes,typeof k.retain=="number");if(N&&(I.attributes=N),O.push(I),!d.hasNext()&&l.default(O.ops[O.ops.length-1],I)){var P=new v(g.rest());return O.concat(P).chop()}}else typeof x.delete=="number"&&typeof k.retain=="number"&&O.push(x)}return O.chop()},v.prototype.concat=function(h){var g=new v(this.ops.slice());return h.ops.length>0&&(g.push(h.ops[0]),g.ops=g.ops.concat(h.ops.slice(1))),g},v.prototype.diff=function(h,g){if(this.ops===h.ops)return new v;var d=[this,h].map(function(_){return _.map(function(k){if(k.insert!=null)return typeof k.insert=="string"?k.insert:b;throw new Error("diff() called "+(_===h?"on":"with")+" non-document")}).join("")}),A=new v,S=y.default(d[0],d[1],g),E=p.default.iterator(this.ops),O=p.default.iterator(h.ops);return S.forEach(function(_){for(var k=_[1].length;k>0;){var x=0;switch(_[0]){case y.default.INSERT:x=Math.min(O.peekLength(),k),A.push(O.next(x));break;case y.default.DELETE:x=Math.min(k,E.peekLength()),E.next(x),A.delete(x);break;case y.default.EQUAL:x=Math.min(E.peekLength(),O.peekLength(),k);var I=E.next(x),N=O.next(x);l.default(I.insert,N.insert)?A.retain(x,a.default.diff(I.attributes,N.attributes)):A.push(N).delete(x)}k-=x}}),A.chop()},v.prototype.eachLine=function(h,g){g===void 0&&(g=` +`)}return G}function Q(j,G){var se={},ue=j.style||{};return ue.fontStyle&&H(j).fontStyle==="italic"&&(se.italic=!0),ue.fontWeight&&(H(j).fontWeight.startsWith("bold")||parseInt(H(j).fontWeight)>=700)&&(se.bold=!0),Object.keys(se).length>0&&(G=B(G,se)),parseFloat(ue.textIndent||0)>0&&(G=new f.default().insert(" ").concat(G)),G}function Y(j,G){var se=j.data;if(j.parentNode.tagName==="O:P")return G.insert(se.trim());if(se.trim().length===0&&j.parentNode.classList.contains("ql-clipboard"))return G;if(!H(j.parentNode).whiteSpace.startsWith("pre")){var ue=function(ge,ve){return ve=ve.replace(/[^\u00a0]/g,""),ve.length<1&&ge?" ":ve};se=se.replace(/\r\n/g," ").replace(/\n/g," "),se=se.replace(/\s\s+/g,ue.bind(ue,!0)),(j.previousSibling==null&&D(j.parentNode)||j.previousSibling!=null&&D(j.previousSibling))&&(se=se.replace(/^\s+/,ue.bind(ue,!1))),(j.nextSibling==null&&D(j.parentNode)||j.nextSibling!=null&&D(j.nextSibling))&&(se=se.replace(/\s+$/,ue.bind(ue,!1)))}return G.insert(se)}n.default=M,n.matchAttributor=X,n.matchBlot=ie,n.matchNewline=be,n.matchSpacing=U,n.matchText=Y},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;v '},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;va.right&&(b=a.right-p.right,this.root.style.left=f+b+"px"),p.lefta.bottom){var w=p.bottom-p.top,v=y.bottom-y.top+w;this.root.style.top=l-v+"px",this.root.classList.add("ql-flip")}return b}},{key:"show",value:function(){this.root.classList.remove("ql-editing"),this.root.classList.remove("ql-hidden")}}]),c}();n.default=u},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function k(x,I){var N=[],P=!0,R=!1,q=void 0;try{for(var J=x[Symbol.iterator](),ee;!(P=(ee=J.next()).done)&&(N.push(ee.value),!(I&&N.length===I));P=!0);}catch(z){R=!0,q=z}finally{try{!P&&J.return&&J.return()}finally{if(R)throw q}}return N}return function(x,I){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return k(x,I);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s=function k(x,I,N){x===null&&(x=Function.prototype);var P=Object.getOwnPropertyDescriptor(x,I);if(P===void 0){var R=Object.getPrototypeOf(x);return R===null?void 0:k(R,I,N)}else{if("value"in P)return P.value;var q=P.get;return q===void 0?void 0:q.call(N)}},u=function(){function k(x,I){for(var N=0;N','','',''].join(""),n.default=O},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=r(29),s=re(o),u=r(36),c=r(38),m=r(64),y=r(65),f=re(y),l=r(66),a=re(l),p=r(67),b=re(p),w=r(37),v=r(26),h=r(39),g=r(40),d=r(56),A=re(d),S=r(68),E=re(S),O=r(27),_=re(O),k=r(69),x=re(k),I=r(70),N=re(I),P=r(71),R=re(P),q=r(72),J=re(q),ee=r(73),z=re(ee),F=r(13),C=re(F),M=r(74),B=re(M),H=r(75),V=re(H),D=r(57),$=re(D),W=r(41),X=re(W),ie=r(28),fe=re(ie),we=r(59),ye=re(we),be=r(60),U=re(be),Q=r(61),Y=re(Q),j=r(108),G=re(j),se=r(62),ue=re(se);function re(ge){return ge&&ge.__esModule?ge:{default:ge}}s.default.register({"attributors/attribute/direction":c.DirectionAttribute,"attributors/class/align":u.AlignClass,"attributors/class/background":w.BackgroundClass,"attributors/class/color":v.ColorClass,"attributors/class/direction":c.DirectionClass,"attributors/class/font":h.FontClass,"attributors/class/size":g.SizeClass,"attributors/style/align":u.AlignStyle,"attributors/style/background":w.BackgroundStyle,"attributors/style/color":v.ColorStyle,"attributors/style/direction":c.DirectionStyle,"attributors/style/font":h.FontStyle,"attributors/style/size":g.SizeStyle},!0),s.default.register({"formats/align":u.AlignClass,"formats/direction":c.DirectionClass,"formats/indent":m.IndentClass,"formats/background":w.BackgroundStyle,"formats/color":v.ColorStyle,"formats/font":h.FontClass,"formats/size":g.SizeClass,"formats/blockquote":f.default,"formats/code-block":C.default,"formats/header":a.default,"formats/list":b.default,"formats/bold":A.default,"formats/code":F.Code,"formats/italic":E.default,"formats/link":_.default,"formats/script":x.default,"formats/strike":N.default,"formats/underline":R.default,"formats/image":J.default,"formats/video":z.default,"formats/list/item":p.ListItem,"modules/formula":B.default,"modules/syntax":V.default,"modules/toolbar":$.default,"themes/bubble":G.default,"themes/snow":ue.default,"ui/icons":X.default,"ui/picker":fe.default,"ui/icon-picker":U.default,"ui/color-picker":ye.default,"ui/tooltip":Y.default},!0),n.default=s.default},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.IndentClass=void 0;var o=function(){function b(w,v){for(var h=0;h0&&this.children.tail.format(E,O)}},{key:"formats",value:function(){return p({},this.statics.blotName,this.statics.formats(this.domNode))}},{key:"insertBefore",value:function(E,O){if(E instanceof h)s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"insertBefore",this).call(this,E,O);else{var _=O==null?this.length():O.offset(this),k=this.split(_);k.parent.insertBefore(E,k)}}},{key:"optimize",value:function(E){s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"optimize",this).call(this,E);var O=this.next;O!=null&&O.prev===this&&O.statics.blotName===this.statics.blotName&&O.domNode.tagName===this.domNode.tagName&&O.domNode.getAttribute("data-checked")===this.domNode.getAttribute("data-checked")&&(O.moveChildren(this),O.remove())}},{key:"replace",value:function(E){if(E.statics.blotName!==this.statics.blotName){var O=c.default.create(this.statics.defaultChild);E.moveChildren(O),this.appendChild(O)}s(A.prototype.__proto__||Object.getPrototypeOf(A.prototype),"replace",this).call(this,E)}}]),A}(l.default);g.blotName="list",g.scope=c.default.Scope.BLOCK_BLOT,g.tagName=["OL","UL"],g.defaultChild="list-item",g.allowedChildren=[h],n.ListItem=h,n.default=g},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=r(56),s=u(o);function u(l){return l&&l.__esModule?l:{default:l}}function c(l,a){if(!(l instanceof a))throw new TypeError("Cannot call a class as a function")}function m(l,a){if(!l)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a&&(typeof a=="object"||typeof a=="function")?a:l}function y(l,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof a);l.prototype=Object.create(a&&a.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(l,a):l.__proto__=a)}var f=function(l){y(a,l);function a(){return c(this,a),m(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments))}return a}(s.default);f.blotName="italic",f.tagName=["EM","I"],n.default=f},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function p(b,w){for(var v=0;v-1?d?this.domNode.setAttribute(g,d):this.domNode.removeAttribute(g):s(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"format",this).call(this,g,d)}}],[{key:"create",value:function(g){var d=s(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,g);return typeof g=="string"&&d.setAttribute("src",this.sanitize(g)),d}},{key:"formats",value:function(g){return p.reduce(function(d,A){return g.hasAttribute(A)&&(d[A]=g.getAttribute(A)),d},{})}},{key:"match",value:function(g){return/\.(jpe?g|gif|png)$/.test(g)||/^data:image\/.+;base64/.test(g)}},{key:"sanitize",value:function(g){return(0,m.sanitize)(g,["http","https","data"])?g:"//:0"}},{key:"value",value:function(g){return g.getAttribute("src")}}]),v}(c.default.Embed);b.blotName="image",b.tagName="IMG",n.default=b},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function w(v,h){for(var g=0;g-1?d?this.domNode.setAttribute(g,d):this.domNode.removeAttribute(g):s(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"format",this).call(this,g,d)}}],[{key:"create",value:function(g){var d=s(v.__proto__||Object.getPrototypeOf(v),"create",this).call(this,g);return d.setAttribute("frameborder","0"),d.setAttribute("allowfullscreen",!0),d.setAttribute("src",this.sanitize(g)),d}},{key:"formats",value:function(g){return p.reduce(function(d,A){return g.hasAttribute(A)&&(d[A]=g.getAttribute(A)),d},{})}},{key:"sanitize",value:function(g){return m.default.sanitize(g)}},{key:"value",value:function(g){return g.getAttribute("src")}}]),v}(u.BlockEmbed);b.blotName="video",b.className="ql-video",b.tagName="IFRAME",n.default=b},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.default=n.FormulaBlot=void 0;var o=function(){function g(d,A){for(var S=0;S0||this.cachedText==null)&&(this.domNode.innerHTML=_(k),this.domNode.normalize(),this.attach()),this.cachedText=k)}}]),E}(p.default);g.className="ql-syntax";var d=new c.default.Attributor.Class("token","hljs",{scope:c.default.Scope.INLINE}),A=function(S){h(E,S),o(E,null,[{key:"register",value:function(){y.default.register(d,!0),y.default.register(g,!0)}}]);function E(O,_){w(this,E);var k=v(this,(E.__proto__||Object.getPrototypeOf(E)).call(this,O,_));if(typeof k.options.highlight!="function")throw new Error("Syntax module requires highlight.js. Please include the library on the page before Quill.");var x=null;return k.quill.on(y.default.events.SCROLL_OPTIMIZE,function(){clearTimeout(x),x=setTimeout(function(){k.highlight(),x=null},k.options.interval)}),k.highlight(),k}return o(E,[{key:"highlight",value:function(){var _=this;if(!this.quill.selection.composing){this.quill.update(y.default.sources.USER);var k=this.quill.getSelection();this.quill.scroll.descendants(g).forEach(function(x){x.highlight(_.options.highlight)}),this.quill.update(y.default.sources.SILENT),k!=null&&this.quill.setSelection(k,y.default.sources.SILENT)}}}]),E}(l.default);A.DEFAULTS={highlight:function(){return window.hljs==null?null:function(S){var E=window.hljs.highlightAuto(S);return E.value}}(),interval:1e3},n.CodeBlock=g,n.CodeToken=d,n.default=A},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n){e.exports=' '},function(e,n,r){Object.defineProperty(n,"__esModule",{value:!0}),n.default=n.BubbleTooltip=void 0;var o=function E(O,_,k){O===null&&(O=Function.prototype);var x=Object.getOwnPropertyDescriptor(O,_);if(x===void 0){var I=Object.getPrototypeOf(O);return I===null?void 0:E(I,_,k)}else{if("value"in x)return x.value;var N=x.get;return N===void 0?void 0:N.call(k)}},s=function(){function E(O,_){for(var k=0;k<_.length;k++){var x=_[k];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(O,x.key,x)}}return function(O,_,k){return _&&E(O.prototype,_),k&&E(O,k),O}}(),u=r(3),c=w(u),m=r(8),y=w(m),f=r(43),l=w(f),a=r(15),p=r(41),b=w(p);function w(E){return E&&E.__esModule?E:{default:E}}function v(E,O){if(!(E instanceof O))throw new TypeError("Cannot call a class as a function")}function h(E,O){if(!E)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O&&(typeof O=="object"||typeof O=="function")?O:E}function g(E,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof O);E.prototype=Object.create(O&&O.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),O&&(Object.setPrototypeOf?Object.setPrototypeOf(E,O):E.__proto__=O)}var d=[["bold","italic","link"],[{header:1},{header:2},"blockquote"]],A=function(E){g(O,E);function O(_,k){v(this,O),k.modules.toolbar!=null&&k.modules.toolbar.container==null&&(k.modules.toolbar.container=d);var x=h(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,_,k));return x.quill.container.classList.add("ql-bubble"),x}return s(O,[{key:"extendToolbar",value:function(k){this.tooltip=new S(this.quill,this.options.bounds),this.tooltip.root.appendChild(k.container),this.buildButtons([].slice.call(k.container.querySelectorAll("button")),b.default),this.buildPickers([].slice.call(k.container.querySelectorAll("select")),b.default)}}]),O}(l.default);A.DEFAULTS=(0,c.default)(!0,{},l.default.DEFAULTS,{modules:{toolbar:{handlers:{link:function(O){O?this.quill.theme.tooltip.edit():this.quill.format("link",!1)}}}}});var S=function(E){g(O,E);function O(_,k){v(this,O);var x=h(this,(O.__proto__||Object.getPrototypeOf(O)).call(this,_,k));return x.quill.on(y.default.events.EDITOR_CHANGE,function(I,N,P,R){if(I===y.default.events.SELECTION_CHANGE)if(N!=null&&N.length>0&&R===y.default.sources.USER){x.show(),x.root.style.left="0px",x.root.style.width="",x.root.style.width=x.root.offsetWidth+"px";var q=x.quill.getLines(N.index,N.length);if(q.length===1)x.position(x.quill.getBounds(N));else{var J=q[q.length-1],ee=x.quill.getIndex(J),z=Math.min(J.length()-1,N.index+N.length-ee),F=x.quill.getBounds(new a.Range(ee,z));x.position(F)}}else document.activeElement!==x.textbox&&x.quill.hasFocus()&&x.hide()}),x}return s(O,[{key:"listen",value:function(){var k=this;o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"listen",this).call(this),this.root.querySelector(".ql-close").addEventListener("click",function(){k.root.classList.remove("ql-editing")}),this.quill.on(y.default.events.SCROLL_OPTIMIZE,function(){setTimeout(function(){if(!k.root.classList.contains("ql-hidden")){var x=k.quill.getSelection();x!=null&&k.position(k.quill.getBounds(x))}},1)})}},{key:"cancel",value:function(){this.show()}},{key:"position",value:function(k){var x=o(O.prototype.__proto__||Object.getPrototypeOf(O.prototype),"position",this).call(this,k),I=this.root.querySelector(".ql-tooltip-arrow");if(I.style.marginLeft="",x===0)return x;I.style.marginLeft=-1*x-I.offsetWidth/2+"px"}}]),O}(f.BaseTooltip);S.TEMPLATE=['','
    ','','',"
    "].join(""),n.BubbleTooltip=S,n.default=A},function(e,n,r){e.exports=r(63)}]).default})})(zu);var Yh=zu.exports;const _l=$u(Yh);var Vu={exports:{}};/*! For license information please see quill-cursors.js.LICENSE.txt */(function(i,t){(function(e,n){i.exports=n()})(self,()=>(()=>{var e={582:(s,u,c)=>{c.d(u,{Z:()=>a});var m=c(81),y=c.n(m),f=c(645),l=c.n(f)()(y());l.push([s.id,".ql-container{position:relative;overflow:hidden}@media(pointer: coarse){.ql-cursor-caret-container{z-index:-1}}.ql-cursor.hidden{display:none}.ql-cursor .ql-cursor-caret-container,.ql-cursor .ql-cursor-flag{position:absolute}.ql-cursor .ql-cursor-flag{z-index:1;transform:translate3d(-1px, -100%, 0);opacity:0;visibility:hidden;color:#fff;padding-bottom:2px;border-radius:0 3px 3px 0}.ql-cursor .ql-cursor-flag.flag-flipped{border-radius:3px 0 0 3px;transform:translate3d(calc(-100% + 1px ), -100%, 0)}@media screen{.ql-cursor .ql-cursor-flag{transition:opacity 0ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 0ms,visibility 0ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 0ms}}.ql-cursor .ql-cursor-flag .ql-cursor-name{margin-left:5px;margin-right:5px;display:inline-block;margin-top:-2px;white-space:nowrap}.ql-cursor .ql-cursor-flag.no-delay[style]{transition-delay:unset !important}.ql-cursor .ql-cursor-caret-container{cursor:text;margin-left:-9px;padding:0 9px}.ql-cursor .ql-cursor-caret-container.hover+.ql-cursor-flag{opacity:1;visibility:visible;transition:none}.ql-cursor .ql-cursor-caret-container.no-pointer{pointer-events:none}.ql-cursor .ql-cursor-caret-container .ql-cursor-caret{position:absolute;top:0;bottom:0;width:2px;margin-left:-1px;background-color:attr(data-color)}.ql-cursor .ql-cursor-selection-block{position:absolute;pointer-events:none}",""]);const a=l},645:s=>{s.exports=function(u){var c=[];return c.toString=function(){return this.map(function(m){var y="",f=m[5]!==void 0;return m[4]&&(y+="@supports (".concat(m[4],") {")),m[2]&&(y+="@media ".concat(m[2]," {")),f&&(y+="@layer".concat(m[5].length>0?" ".concat(m[5]):""," {")),y+=u(m),f&&(y+="}"),m[2]&&(y+="}"),m[4]&&(y+="}"),y}).join("")},c.i=function(m,y,f,l,a){typeof m=="string"&&(m=[[null,m,void 0]]);var p={};if(f)for(var b=0;b0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=a),y&&(h[2]&&(h[1]="@media ".concat(h[2]," {").concat(h[1],"}")),h[2]=y),l&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=l):h[4]="".concat(l)),c.push(h))}},c}},81:s=>{s.exports=function(u){return u[1]}},465:(s,u,c)=>{s=c.nmd(s);var m="__lodash_hash_undefined__",y=9007199254740991,f="[object Arguments]",l="[object Boolean]",a="[object Date]",p="[object Function]",b="[object GeneratorFunction]",w="[object Map]",v="[object Number]",h="[object Object]",g="[object Promise]",d="[object RegExp]",A="[object Set]",S="[object String]",E="[object Symbol]",O="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",x="[object Float32Array]",I="[object Float64Array]",N="[object Int8Array]",P="[object Int16Array]",R="[object Int32Array]",q="[object Uint8Array]",J="[object Uint8ClampedArray]",ee="[object Uint16Array]",z="[object Uint32Array]",F=/\w*$/,C=/^\[object .+?Constructor\]$/,M=/^(?:0|[1-9]\d*)$/,B={};B[f]=B["[object Array]"]=B[_]=B[k]=B[l]=B[a]=B[x]=B[I]=B[N]=B[P]=B[R]=B[w]=B[v]=B[h]=B[d]=B[A]=B[S]=B[E]=B[q]=B[J]=B[ee]=B[z]=!0,B["[object Error]"]=B[p]=B[O]=!1;var H=typeof c.g=="object"&&c.g&&c.g.Object===Object&&c.g,V=typeof self=="object"&&self&&self.Object===Object&&self,D=H||V||Function("return this")(),$=u&&!u.nodeType&&u,W=$&&s&&!s.nodeType&&s,X=W&&W.exports===$;function ie(K,oe){return K.set(oe[0],oe[1]),K}function fe(K,oe){return K.add(oe),K}function we(K,oe,pe,Ae){var Me=-1,We=K?K.length:0;for(Ae;++Me-1},St.prototype.set=function(K,oe){var pe=this.__data__,Ae=Ri(pe,K);return Ae<0?pe.push([K,oe]):pe[Ae][1]=oe,this},_t.prototype.clear=function(){this.__data__={hash:new pn,map:new(Tt||St),string:new pn}},_t.prototype.delete=function(K){return Jn(this,K).delete(K)},_t.prototype.get=function(K){return Jn(this,K).get(K)},_t.prototype.has=function(K){return Jn(this,K).has(K)},_t.prototype.set=function(K,oe){return Jn(this,K).set(K,oe),this},ei.prototype.clear=function(){this.__data__=new St},ei.prototype.delete=function(K){return this.__data__.delete(K)},ei.prototype.get=function(K){return this.__data__.get(K)},ei.prototype.has=function(K){return this.__data__.has(K)},ei.prototype.set=function(K,oe){var pe=this.__data__;if(pe instanceof St){var Ae=pe.__data__;if(!Tt||Ae.length<199)return Ae.push([K,oe]),this;pe=this.__data__=new _t(Ae)}return pe.set(K,oe),this};var ro=vt?U(vt,Object):function(){return[]},yn=function(K){return Oe.call(K)};function Lo(K,oe){return!!(oe=oe??y)&&(typeof K=="number"||M.test(K))&&K>-1&&K%1==0&&K-1&&oe%1==0&&oe<=y}(K.length)&&!Ee(K)}var de=Zt||function(){return!1};function Ee(K){var oe=ze(K)?Oe.call(K):"";return oe==p||oe==b}function ze(K){var oe=typeof K;return!!K&&(oe=="object"||oe=="function")}function Be(K){return ae(K)?function(oe,pe){var Ae=Z(oe)||function(je){return function(st){return function(et){return!!et&&typeof et=="object"}(st)&&ae(st)}(je)&&ve.call(je,"callee")&&(!At.call(je,"callee")||Oe.call(je)==f)}(oe)?function(je,st){for(var et=-1,bn=Array(je);++et{s=c.nmd(s);var m="__lodash_hash_undefined__",y=9007199254740991,f="[object Arguments]",l="[object Array]",a="[object Boolean]",p="[object Date]",b="[object Error]",w="[object Function]",v="[object Map]",h="[object Number]",g="[object Object]",d="[object Promise]",A="[object RegExp]",S="[object Set]",E="[object String]",O="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",x=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,N={};N["[object Float32Array]"]=N["[object Float64Array]"]=N["[object Int8Array]"]=N["[object Int16Array]"]=N["[object Int32Array]"]=N["[object Uint8Array]"]=N["[object Uint8ClampedArray]"]=N["[object Uint16Array]"]=N["[object Uint32Array]"]=!0,N[f]=N[l]=N[_]=N[a]=N[k]=N[p]=N[b]=N[w]=N[v]=N[h]=N[g]=N[A]=N[S]=N[E]=N[O]=!1;var P=typeof c.g=="object"&&c.g&&c.g.Object===Object&&c.g,R=typeof self=="object"&&self&&self.Object===Object&&self,q=P||R||Function("return this")(),J=u&&!u.nodeType&&u,ee=J&&s&&!s.nodeType&&s,z=ee&&ee.exports===J,F=z&&P.process,C=function(){try{return F&&F.binding&&F.binding("util")}catch{}}(),M=C&&C.isTypedArray;function B(Z,ae){for(var de=-1,Ee=Z==null?0:Z.length;++deoe))return!1;var Ae=Be.get(Z);if(Ae&&Be.get(ae))return Ae==ae;var Me=-1,We=!0,Qe=2&de?new Ci:void 0;for(Be.set(Z,ae),Be.set(ae,Z);++Me-1},It.prototype.set=function(Z,ae){var de=this.__data__,Ee=Li(de,Z);return Ee<0?(++this.size,de.push([Z,ae])):de[Ee][1]=ae,this},Nt.prototype.clear=function(){this.size=0,this.__data__={hash:new ot,map:new(_e||It),string:new ot}},Nt.prototype.delete=function(Z){var ae=St(this,Z).delete(Z);return this.size-=ae?1:0,ae},Nt.prototype.get=function(Z){return St(this,Z).get(Z)},Nt.prototype.has=function(Z){return St(this,Z).has(Z)},Nt.prototype.set=function(Z,ae){var de=St(this,Z),Ee=de.size;return de.set(Z,ae),this.size+=de.size==Ee?0:1,this},Ci.prototype.add=Ci.prototype.push=function(Z){return this.__data__.set(Z,m),this},Ci.prototype.has=function(Z){return this.__data__.has(Z)},gn.prototype.clear=function(){this.__data__=new It,this.size=0},gn.prototype.delete=function(Z){var ae=this.__data__,de=ae.delete(Z);return this.size=ae.size,de},gn.prototype.get=function(Z){return this.__data__.get(Z)},gn.prototype.has=function(Z){return this.__data__.has(Z)},gn.prototype.set=function(Z,ae){var de=this.__data__;if(de instanceof It){var Ee=de.__data__;if(!_e||Ee.length<199)return Ee.push([Z,ae]),this.size=++de.size,this;de=this.__data__=new Nt(Ee)}return de.set(Z,ae),this.size=de.size,this};var ei=ve?function(Z){return Z==null?[]:(Z=Object(Z),function(ae,de){for(var Ee=-1,ze=ae==null?0:ae.length,Be=0,K=[];++Ee-1&&Z%1==0&&Z-1&&Z%1==0&&Z<=y}function Lo(Z){var ae=typeof Z;return Z!=null&&(ae=="object"||ae=="function")}function ti(Z){return Z!=null&&typeof Z=="object"}var vn=M?function(Z){return function(ae){return Z(ae)}}(M):function(Z){return ti(Z)&&yn(Z.length)&&!!N[yi(Z)]};function Ro(Z){return(ae=Z)!=null&&yn(ae.length)&&!ro(ae)?function(de,Ee){var ze=Jn(de),Be=!ze&&Co(de),K=!ze&&!Be&&mn(de),oe=!ze&&!Be&&!K&&vn(de),pe=ze||Be||K||oe,Ae=pe?function(Qe,je){for(var st=-1,et=Array(Qe);++st0?v:void 0},a.diff=function(p,b){p===void 0&&(p={}),b===void 0&&(b={}),typeof p!="object"&&(p={}),typeof b!="object"&&(b={});var w=Object.keys(p).concat(Object.keys(b)).reduce(function(v,h){return l.default(p[h],b[h])||(v[h]=b[h]===void 0?null:b[h]),v},{});return Object.keys(w).length>0?w:void 0},a.invert=function(p,b){p===void 0&&(p={}),b===void 0&&(b={}),p=p||{};var w=Object.keys(b).reduce(function(v,h){return b[h]!==p[h]&&p[h]!==void 0&&(v[h]=b[h]),v},{});return Object.keys(p).reduce(function(v,h){return p[h]!==b[h]&&b[h]===void 0&&(v[h]=null),v},w)},a.transform=function(p,b,w){if(w===void 0&&(w=!1),typeof p!="object")return b;if(typeof b=="object"){if(!w)return b;var v=Object.keys(b).reduce(function(h,g){return p[g]===void 0&&(h[g]=b[g]),h},{});return Object.keys(v).length>0?v:void 0}}})(y||(y={})),u.default=y},895:function(s,u,c){var m=this&&this.__importDefault||function(v){return v&&v.__esModule?v:{default:v}},y=m(c(103)),f=m(c(465)),l=m(c(307)),a=m(c(210)),p=m(c(430)),b="\0",w=function(){function v(h){Array.isArray(h)?this.ops=h:h!=null&&Array.isArray(h.ops)?this.ops=h.ops:this.ops=[]}return v.prototype.insert=function(h,g){var d={};return typeof h=="string"&&h.length===0?this:(d.insert=h,g!=null&&typeof g=="object"&&Object.keys(g).length>0&&(d.attributes=g),this.push(d))},v.prototype.delete=function(h){return h<=0?this:this.push({delete:h})},v.prototype.retain=function(h,g){if(h<=0)return this;var d={retain:h};return g!=null&&typeof g=="object"&&Object.keys(g).length>0&&(d.attributes=g),this.push(d)},v.prototype.push=function(h){var g=this.ops.length,d=this.ops[g-1];if(h=f.default(h),typeof d=="object"){if(typeof h.delete=="number"&&typeof d.delete=="number")return this.ops[g-1]={delete:d.delete+h.delete},this;if(typeof d.delete=="number"&&h.insert!=null&&(g-=1,typeof(d=this.ops[g-1])!="object"))return this.ops.unshift(h),this;if(l.default(h.attributes,d.attributes)){if(typeof h.insert=="string"&&typeof d.insert=="string")return this.ops[g-1]={insert:d.insert+h.insert},typeof h.attributes=="object"&&(this.ops[g-1].attributes=h.attributes),this;if(typeof h.retain=="number"&&typeof d.retain=="number")return this.ops[g-1]={retain:d.retain+h.retain},typeof h.attributes=="object"&&(this.ops[g-1].attributes=h.attributes),this}}return g===this.ops.length?this.ops.push(h):this.ops.splice(g,0,h),this},v.prototype.chop=function(){var h=this.ops[this.ops.length-1];return h&&h.retain&&!h.attributes&&this.ops.pop(),this},v.prototype.filter=function(h){return this.ops.filter(h)},v.prototype.forEach=function(h){this.ops.forEach(h)},v.prototype.map=function(h){return this.ops.map(h)},v.prototype.partition=function(h){var g=[],d=[];return this.forEach(function(A){(h(A)?g:d).push(A)}),[g,d]},v.prototype.reduce=function(h,g){return this.ops.reduce(h,g)},v.prototype.changeLength=function(){return this.reduce(function(h,g){return g.insert?h+p.default.length(g):g.delete?h-g.delete:h},0)},v.prototype.length=function(){return this.reduce(function(h,g){return h+p.default.length(g)},0)},v.prototype.slice=function(h,g){h===void 0&&(h=0),g===void 0&&(g=1/0);for(var d=[],A=p.default.iterator(this.ops),S=0;S0&&d.next(S.retain-E)}for(var O=new v(A);g.hasNext()||d.hasNext();)if(d.peekType()==="insert")O.push(d.next());else if(g.peekType()==="delete")O.push(g.next());else{var _=Math.min(g.peekLength(),d.peekLength()),k=g.next(_),x=d.next(_);if(typeof x.retain=="number"){var I={};typeof k.retain=="number"?I.retain=_:I.insert=k.insert;var N=a.default.compose(k.attributes,x.attributes,typeof k.retain=="number");if(N&&(I.attributes=N),O.push(I),!d.hasNext()&&l.default(O.ops[O.ops.length-1],I)){var P=new v(g.rest());return O.concat(P).chop()}}else typeof x.delete=="number"&&typeof k.retain=="number"&&O.push(x)}return O.chop()},v.prototype.concat=function(h){var g=new v(this.ops.slice());return h.ops.length>0&&(g.push(h.ops[0]),g.ops=g.ops.concat(h.ops.slice(1))),g},v.prototype.diff=function(h,g){if(this.ops===h.ops)return new v;var d=[this,h].map(function(_){return _.map(function(k){if(k.insert!=null)return typeof k.insert=="string"?k.insert:b;throw new Error("diff() called "+(_===h?"on":"with")+" non-document")}).join("")}),A=new v,S=y.default(d[0],d[1],g),E=p.default.iterator(this.ops),O=p.default.iterator(h.ops);return S.forEach(function(_){for(var k=_[1].length;k>0;){var x=0;switch(_[0]){case y.default.INSERT:x=Math.min(O.peekLength(),k),A.push(O.next(x));break;case y.default.DELETE:x=Math.min(k,E.peekLength()),E.next(x),A.delete(x);break;case y.default.EQUAL:x=Math.min(E.peekLength(),O.peekLength(),k);var I=E.next(x),N=O.next(x);l.default(I.insert,N.insert)?A.retain(x,a.default.diff(I.attributes,N.attributes)):A.push(N).delete(x)}k-=x}}),A.chop()},v.prototype.eachLine=function(h,g){g===void 0&&(g=` `);for(var d=p.default.iterator(this.ops),A=new v,S=0;d.hasNext();){if(d.peekType()!=="insert")return;var E=d.peek(),O=p.default.length(E)-d.peekLength(),_=typeof E.insert=="string"?E.insert.indexOf(g,O)-O:-1;if(_<0)A.push(d.next());else if(_>0)A.push(d.next(_));else{if(h(A,d.next(1).attributes||{},S)===!1)return;S+=1,A=new v}}A.length()>0&&h(A,{},S)},v.prototype.invert=function(h){var g=new v;return this.reduce(function(d,A){if(A.insert)g.delete(p.default.length(A));else{if(A.retain&&A.attributes==null)return g.retain(A.retain),d+A.retain;if(A.delete||A.retain&&A.attributes){var S=A.delete||A.retain;return h.slice(d,d+S).forEach(function(E){A.delete?g.push(E):A.retain&&A.attributes&&g.retain(p.default.length(E),a.default.invert(A.attributes,E.attributes))}),d+S}}return d},0),g.chop()},v.prototype.transform=function(h,g){if(g===void 0&&(g=!1),g=!!g,typeof h=="number")return this.transformPosition(h,g);for(var d=h,A=p.default.iterator(this.ops),S=p.default.iterator(d.ops),E=new v;A.hasNext()||S.hasNext();)if(A.peekType()!=="insert"||!g&&S.peekType()==="insert")if(S.peekType()==="insert")E.push(S.next());else{var O=Math.min(A.peekLength(),S.peekLength()),_=A.next(O),k=S.next(O);if(_.delete)continue;k.delete?E.push(k):E.retain(O,a.default.transform(_.attributes,k.attributes,g))}else E.retain(p.default.length(A.next()));return E.chop()},v.prototype.transformPosition=function(h,g){g===void 0&&(g=!1),g=!!g;for(var d=p.default.iterator(this.ops),A=0;d.hasNext()&&A<=h;){var S=d.peekLength(),E=d.peekType();d.next(),E!=="delete"?(E==="insert"&&(A=w-b?(a=w-b,this.index+=1,this.offset=0):this.offset+=a,typeof p.delete=="number")return{delete:a};var v={};return p.attributes&&(v.attributes=p.attributes),typeof p.retain=="number"?v.retain=a:typeof p.insert=="string"?v.insert=p.insert.substr(b,a):v.insert=p.insert,v}return{retain:1/0}},l.prototype.peek=function(){return this.ops[this.index]},l.prototype.peekLength=function(){return this.ops[this.index]?y.default.length(this.ops[this.index])-this.offset:1/0},l.prototype.peekType=function(){return this.ops[this.index]?typeof this.ops[this.index].delete=="number"?"delete":typeof this.ops[this.index].retain=="number"?"retain":"insert":"retain"},l.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var a=this.offset,p=this.index,b=this.next(),w=this.ops.slice(this.index);return this.offset=a,this.index=p,[b].concat(w)}return[]},l}();u.default=f},430:function(s,u,c){var m=this&&this.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(u,"__esModule",{value:!0});var y,f=m(c(977));(function(l){l.iterator=function(a){return new f.default(a)},l.length=function(a){return typeof a.delete=="number"?a.delete:typeof a.retain=="number"?a.retain:typeof a.insert=="string"?a.insert.length:1}})(y||(y={})),u.default=y},103:s=>{var u=-1;function c(g,d,A,S){if(g===d)return g?[[0,g]]:[];if(A!=null){var E=function(I,N,P){var R=typeof P=="number"?{index:P,length:0}:P.oldRange,q=typeof P=="number"?null:P.newRange,J=I.length,ee=N.length;if(R.length===0&&(q===null||q.length===0)){var z=R.index,F=I.slice(0,z),C=I.slice(z),M=q?q.index:null,B=z+ee-J;if((M===null||M===B)&&!(B<0||B>ee)){var H=N.slice(0,B);if(($=N.slice(B))===C){var V=Math.min(z,B);if((X=F.slice(0,V))===(fe=H.slice(0,V)))return v(X,F.slice(V),H.slice(V),C)}}if(M===null||M===z){var D=z,$=(H=N.slice(0,D),N.slice(D));if(H===F){var W=Math.min(J-D,ee-D);if((ie=C.slice(C.length-W))===(we=$.slice($.length-W)))return v(F,C.slice(0,C.length-W),$.slice(0,$.length-W),ie)}}}if(R.length>0&&q&&q.length===0){var X=I.slice(0,R.index),ie=I.slice(R.index+R.length);if(!(ee<(V=X.length)+(W=ie.length))){var fe=N.slice(0,V),we=N.slice(ee-W);if(X===fe&&ie===we)return v(X,I.slice(V,J-W),N.slice(V,ee-W),ie)}}return null}(g,d,A);if(E)return E}var O=y(g,d),_=g.substring(0,O);O=f(g=g.substring(O),d=d.substring(O));var k=g.substring(g.length-O),x=function(I,N){var P;if(!I)return[[1,N]];if(!N)return[[u,I]];var R=I.length>N.length?I:N,q=I.length>N.length?N:I,J=R.indexOf(q);if(J!==-1)return P=[[1,R.substring(0,J)],[0,q],[1,R.substring(J+q.length)]],I.length>N.length&&(P[0][0]=P[2][0]=u),P;if(q.length===1)return[[u,I],[1,N]];var ee=function(D,$){var W=D.length>$.length?D:$,X=D.length>$.length?$:D;if(W.length<4||2*X.length=j.length?[ue,re,ge,ve,Ue]:null}var fe,we,ye,be,U,Q=ie(W,X,Math.ceil(W.length/4)),Y=ie(W,X,Math.ceil(W.length/2));return Q||Y?(fe=Y?Q&&Q[4].length>Y[4].length?Q:Y:Q,D.length>$.length?(we=fe[0],ye=fe[1],be=fe[2],U=fe[3]):(be=fe[0],U=fe[1],we=fe[2],ye=fe[3]),[we,ye,be,U,fe[4]]):null}(I,N);if(ee){var z=ee[0],F=ee[1],C=ee[2],M=ee[3],B=ee[4],H=c(z,C),V=c(F,M);return H.concat([[0,B]],V)}return function(D,$){for(var W=D.length,X=$.length,ie=Math.ceil((W+X)/2),fe=ie,we=2*ie,ye=new Array(we),be=new Array(we),U=0;UW)G+=2;else if(Oe>X)j+=2;else if(Y&&(_e=fe+Q-ge)>=0&&_e=(Ue=W-be[_e]))return m(D,$,ce,Oe)}for(var Fe=-re+se;Fe<=re-ue;Fe+=2){for(var Ue,_e=fe+Fe,Ce=(Ue=Fe===-re||Fe!==re&&be[_e-1]W)ue+=2;else if(Ce>X)se+=2;else if(!Y){var ce;if((ve=fe+Q-Fe)>=0&&ve=(Ue=W-Ue)))return m(D,$,ce,Oe)}}}return[[u,D],[1,$]]}(I,N)}(g=g.substring(0,g.length-O),d=d.substring(0,d.length-O));return _&&x.unshift([0,_]),k&&x.push([0,k]),l(x,S),x}function m(g,d,A,S){var E=g.substring(0,A),O=d.substring(0,S),_=g.substring(A),k=d.substring(S),x=c(E,O),I=c(_,k);return x.concat(I)}function y(g,d){if(!g||!d||g.charAt(0)!==d.charAt(0))return 0;for(var A=0,S=Math.min(g.length,d.length),E=S,O=0;A=0&&w(g[x][1])){var I=g[x][1].slice(-1);if(g[x][1]=g[x][1].slice(0,-1),_=I+_,k=I+k,!g[x][1]){g.splice(x,1),S--;var N=x-1;g[N]&&g[N][0]===1&&(O++,k=g[N][1]+k,N--),g[N]&&g[N][0]===u&&(E++,_=g[N][1]+_,N--),x=N}}b(g[S][1])&&(I=g[S][1].charAt(0),g[S][1]=g[S][1].slice(1),_+=I,k+=I)}if(S0||k.length>0){_.length>0&&k.length>0&&((A=y(k,_))!==0&&(x>=0?g[x][1]+=k.substring(0,A):(g.splice(0,0,[0,k.substring(0,A)]),S++),k=k.substring(A),_=_.substring(A)),(A=f(k,_))!==0&&(g[S][1]=k.substring(k.length-A)+g[S][1],k=k.substring(0,k.length-A),_=_.substring(0,_.length-A)));var P=O+E;_.length===0&&k.length===0?(g.splice(S-P,P),S-=P):_.length===0?(g.splice(S-P,P,[1,k]),S=S-P+1):k.length===0?(g.splice(S-P,P,[u,_]),S=S-P+1):(g.splice(S-P,P,[u,_],[1,k]),S=S-P+2)}S!==0&&g[S-1][0]===0?(g[S-1][1]+=g[S][1],g.splice(S,1)):S++,O=0,E=0,_="",k=""}g[g.length-1][1]===""&&g.pop();var R=!1;for(S=1;S=55296&&g<=56319}function p(g){return g>=56320&&g<=57343}function b(g){return p(g.charCodeAt(0))}function w(g){return a(g.charCodeAt(g.length-1))}function v(g,d,A,S){return w(g)||b(S)?null:function(E){for(var O=[],_=0;_0&&O.push(E[_]);return O}([[0,g],[u,d],[1,A],[0,S]])}function h(g,d,A){return c(g,d,A,!0)}h.INSERT=1,h.DELETE=u,h.EQUAL=0,s.exports=h},165:function(s,u,c){var m,y;(y=typeof(m=function(){var f,l={};function a(w,v,h){var g=w.getClientRects();if(g.length===2){var d=w.getBoundingClientRect();return g[v][h]=v.length)return Array.prototype.push.apply(w,v);for(;g1,f.getClientRects||(A.setEnd(g,1),f.getClientRects=f.getBoundingClientRect=A.getClientRects().length===2),!f.getBoundingClientRect){A.setEnd(A.startContainer,A.startOffset);var S=A.getBoundingClientRect();f.getBoundingClientRect=S.top===0&&S.left===0}if(document.body.removeChild(w),!f.getBoundingClientRect){var E=document.createElement("p");E.style.width="0px",E.style.fontSize="20px",E.style.whiteSpace="normal",E.style.wordBreak="normal";var O=document.createTextNode("m mm");E.appendChild(O),document.body.appendChild(E),A.setStart(O,1),A.setEnd(O,2),a(A,1,"left")?f.getBoundingClientRect=!0:(A.setStart(O,1),A.setEnd(O,3),a(A,0,"top")&&(f.getBoundingClientRect=!0)),document.body.removeChild(E)}var _=window.ActiveXObject&&new Function("/*@cc_on return @_jscript_version; @*/")();f.ieZoom=!!_&&_<=10}return f},l.getClientRects=function(w){var v=this.isBroken();if(v.ieZoom)return p(w.getClientRects());if(!v.getClientRects)return w.getClientRects();var h=[],g=[],d=w.endContainer,A=w.endOffset,S=document.createRange();function E(O){for(var _=0;O=O.previousSibling;)_++;return _}for(;d!==w.commonAncestorContainer;)S.setStart(d,0),S.setEnd(d,A),b(g,S.getClientRects()),A=E(d),d=d.parentNode;return(S=w.cloneRange()).setEnd(d,A),b(h,S.getClientRects()),b(h,g),h},l.getBoundingClientRect=function(w){var v=this.getClientRects(w);if(v.length===0)return null;var h,g=w.getBoundingClientRect(),d=this.isBroken();if(d.ieZoom)return p(g);if(!d.getBoundingClientRect)return g;if(g.width===0&&g.height===0)return v[0];for(var A=0,S=v.length;A{c.r(u),c.d(u,{default:()=>N});var m=function(){if(typeof Map<"u")return Map;function P(R,q){var J=-1;return R.some(function(ee,z){return ee[0]===q&&(J=z,!0)}),J}return function(){function R(){this.__entries__=[]}return Object.defineProperty(R.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),R.prototype.get=function(q){var J=P(this.__entries__,q),ee=this.__entries__[J];return ee&&ee[1]},R.prototype.set=function(q,J){var ee=P(this.__entries__,q);~ee?this.__entries__[ee][1]=J:this.__entries__.push([q,J])},R.prototype.delete=function(q){var J=this.__entries__,ee=P(J,q);~ee&&J.splice(ee,1)},R.prototype.has=function(q){return!!~P(this.__entries__,q)},R.prototype.clear=function(){this.__entries__.splice(0)},R.prototype.forEach=function(q,J){J===void 0&&(J=null);for(var ee=0,z=this.__entries__;ee0},P.prototype.connect_=function(){y&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),p?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},P.prototype.disconnect_=function(){y&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},P.prototype.onTransitionEnd_=function(R){var q=R.propertyName,J=q===void 0?"":q;a.some(function(ee){return!!~J.indexOf(ee)})&&this.refresh()},P.getInstance=function(){return this.instance_||(this.instance_=new P),this.instance_},P.instance_=null,P}(),w=function(P,R){for(var q=0,J=Object.keys(R);q0},P}(),x=typeof WeakMap<"u"?new WeakMap:new m,I=function P(R){if(!(this instanceof P))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var q=b.getInstance(),J=new k(R,q,this);x.set(this,J)};["observe","unobserve","disconnect"].forEach(function(P){I.prototype[P]=function(){var R;return(R=x.get(this))[P].apply(R,arguments)}});const N=f.ResizeObserver!==void 0?f.ResizeObserver:I},413:(s,u,c)=>{c.r(u),c.d(u,{default:()=>E});var m=c(379),y=c.n(m),f=c(795),l=c.n(f),a=c(569),p=c.n(a),b=c(565),w=c.n(b),v=c(216),h=c.n(v),g=c(589),d=c.n(g),A=c(582),S={};S.styleTagTransform=d(),S.setAttributes=w(),S.insert=p().bind(null,"head"),S.domAPI=l(),S.insertStyleElement=h(),y()(A.Z,S);const E=A.Z&&A.Z.locals?A.Z.locals:void 0},379:s=>{var u=[];function c(f){for(var l=-1,a=0;a{var u={};s.exports=function(c,m){var y=function(f){if(u[f]===void 0){var l=document.querySelector(f);if(window.HTMLIFrameElement&&l instanceof window.HTMLIFrameElement)try{l=l.contentDocument.head}catch{l=null}u[f]=l}return u[f]}(c);if(!y)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");y.appendChild(m)}},216:s=>{s.exports=function(u){var c=document.createElement("style");return u.setAttributes(c,u.attributes),u.insert(c,u.options),c}},565:(s,u,c)=>{s.exports=function(m){var y=c.nc;y&&m.setAttribute("nonce",y)}},795:s=>{s.exports=function(u){var c=u.insertStyleElement(u);return{update:function(m){(function(y,f,l){var a="";l.supports&&(a+="@supports (".concat(l.supports,") {")),l.media&&(a+="@media ".concat(l.media," {"));var p=l.layer!==void 0;p&&(a+="@layer".concat(l.layer.length>0?" ".concat(l.layer):""," {")),a+=l.css,p&&(a+="}"),l.media&&(a+="}"),l.supports&&(a+="}");var b=l.sourceMap;b&&typeof btoa<"u"&&(a+=` /*# sourceMappingURL=data:application/json;base64,`.concat(btoa(unescape(encodeURIComponent(JSON.stringify(b))))," */")),f.styleTagTransform(a,y,f.options)})(c,u,m)},remove:function(){(function(m){if(m.parentNode===null)return!1;m.parentNode.removeChild(m)})(c)}}}},589:s=>{s.exports=function(u,c){if(c.styleSheet)c.styleSheet.cssText=u;else{for(;c.firstChild;)c.removeChild(c.firstChild);c.appendChild(document.createTextNode(u))}}},621:(s,u,c)=>{var m;(function(y){var f=/^\s+/,l=/\s+$/,a=0,p=y.round,b=y.min,w=y.max,v=y.random;function h(U,Q){if(Q=Q||{},(U=U||"")instanceof h)return U;if(!(this instanceof h))return new h(U,Q);var Y=function(j){var G,se,ue,re={r:0,g:0,b:0},ge=1,ve=null,Oe=null,Fe=null,Ue=!1,_e=!1;return typeof j=="string"&&(j=function(Ce){Ce=Ce.replace(f,"").replace(l,"").toLowerCase();var ce,De=!1;if(F[Ce])Ce=F[Ce],De=!0;else if(Ce=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};return(ce=ye.rgb.exec(Ce))?{r:ce[1],g:ce[2],b:ce[3]}:(ce=ye.rgba.exec(Ce))?{r:ce[1],g:ce[2],b:ce[3],a:ce[4]}:(ce=ye.hsl.exec(Ce))?{h:ce[1],s:ce[2],l:ce[3]}:(ce=ye.hsla.exec(Ce))?{h:ce[1],s:ce[2],l:ce[3],a:ce[4]}:(ce=ye.hsv.exec(Ce))?{h:ce[1],s:ce[2],v:ce[3]}:(ce=ye.hsva.exec(Ce))?{h:ce[1],s:ce[2],v:ce[3],a:ce[4]}:(ce=ye.hex8.exec(Ce))?{r:V(ce[1]),g:V(ce[2]),b:V(ce[3]),a:X(ce[4]),format:De?"name":"hex8"}:(ce=ye.hex6.exec(Ce))?{r:V(ce[1]),g:V(ce[2]),b:V(ce[3]),format:De?"name":"hex"}:(ce=ye.hex4.exec(Ce))?{r:V(ce[1]+""+ce[1]),g:V(ce[2]+""+ce[2]),b:V(ce[3]+""+ce[3]),a:X(ce[4]+""+ce[4]),format:De?"name":"hex8"}:!!(ce=ye.hex3.exec(Ce))&&{r:V(ce[1]+""+ce[1]),g:V(ce[2]+""+ce[2]),b:V(ce[3]+""+ce[3]),format:De?"name":"hex"}}(j)),typeof j=="object"&&(be(j.r)&&be(j.g)&&be(j.b)?(G=j.r,se=j.g,ue=j.b,re={r:255*B(G,255),g:255*B(se,255),b:255*B(ue,255)},Ue=!0,_e=String(j.r).substr(-1)==="%"?"prgb":"rgb"):be(j.h)&&be(j.s)&&be(j.v)?(ve=$(j.s),Oe=$(j.v),re=function(Ce,ce,De){Ce=6*B(Ce,360),ce=B(ce,100),De=B(De,100);var At=y.floor(Ce),dn=Ce-At,vt=De*(1-ce),Zt=De*(1-dn*ce),Dt=De*(1-(1-dn)*ce),Ot=At%6;return{r:255*[De,Zt,vt,vt,Dt,De][Ot],g:255*[Dt,De,De,Zt,vt,vt][Ot],b:255*[vt,vt,Dt,De,De,Zt][Ot]}}(j.h,ve,Oe),Ue=!0,_e="hsv"):be(j.h)&&be(j.s)&&be(j.l)&&(ve=$(j.s),Fe=$(j.l),re=function(Ce,ce,De){var At,dn,vt;function Zt(Tt,Xt,ot){return ot<0&&(ot+=1),ot>1&&(ot-=1),ot<1/6?Tt+6*(Xt-Tt)*ot:ot<.5?Xt:ot<2/3?Tt+(Xt-Tt)*(2/3-ot)*6:Tt}if(Ce=B(Ce,360),ce=B(ce,100),De=B(De,100),ce===0)At=dn=vt=De;else{var Dt=De<.5?De*(1+ce):De+ce-De*ce,Ot=2*De-Dt;At=Zt(Ot,Dt,Ce+1/3),dn=Zt(Ot,Dt,Ce),vt=Zt(Ot,Dt,Ce-1/3)}return{r:255*At,g:255*dn,b:255*vt}}(j.h,ve,Fe),Ue=!0,_e="hsl"),j.hasOwnProperty("a")&&(ge=j.a)),ge=M(ge),{ok:Ue,format:j.format||_e,r:b(255,w(re.r,0)),g:b(255,w(re.g,0)),b:b(255,w(re.b,0)),a:ge}}(U);this._originalInput=U,this._r=Y.r,this._g=Y.g,this._b=Y.b,this._a=Y.a,this._roundA=p(100*this._a)/100,this._format=Q.format||Y.format,this._gradientType=Q.gradientType,this._r<1&&(this._r=p(this._r)),this._g<1&&(this._g=p(this._g)),this._b<1&&(this._b=p(this._b)),this._ok=Y.ok,this._tc_id=a++}function g(U,Q,Y){U=B(U,255),Q=B(Q,255),Y=B(Y,255);var j,G,se=w(U,Q,Y),ue=b(U,Q,Y),re=(se+ue)/2;if(se==ue)j=G=0;else{var ge=se-ue;switch(G=re>.5?ge/(2-se-ue):ge/(se+ue),se){case U:j=(Q-Y)/ge+(Q>1)+720)%360;--Q;)j.h=(j.h+G)%360,se.push(h(j));return se}function z(U,Q){Q=Q||6;for(var Y=h(U).toHsv(),j=Y.h,G=Y.s,se=Y.v,ue=[],re=1/Q;Q--;)ue.push(h({h:j,s:G,v:se})),se=(se+re)%1;return ue}h.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var U=this.toRgb();return(299*U.r+587*U.g+114*U.b)/1e3},getLuminance:function(){var U,Q,Y,j=this.toRgb();return U=j.r/255,Q=j.g/255,Y=j.b/255,.2126*(U<=.03928?U/12.92:y.pow((U+.055)/1.055,2.4))+.7152*(Q<=.03928?Q/12.92:y.pow((Q+.055)/1.055,2.4))+.0722*(Y<=.03928?Y/12.92:y.pow((Y+.055)/1.055,2.4))},setAlpha:function(U){return this._a=M(U),this._roundA=p(100*this._a)/100,this},toHsv:function(){var U=d(this._r,this._g,this._b);return{h:360*U.h,s:U.s,v:U.v,a:this._a}},toHsvString:function(){var U=d(this._r,this._g,this._b),Q=p(360*U.h),Y=p(100*U.s),j=p(100*U.v);return this._a==1?"hsv("+Q+", "+Y+"%, "+j+"%)":"hsva("+Q+", "+Y+"%, "+j+"%, "+this._roundA+")"},toHsl:function(){var U=g(this._r,this._g,this._b);return{h:360*U.h,s:U.s,l:U.l,a:this._a}},toHslString:function(){var U=g(this._r,this._g,this._b),Q=p(360*U.h),Y=p(100*U.s),j=p(100*U.l);return this._a==1?"hsl("+Q+", "+Y+"%, "+j+"%)":"hsla("+Q+", "+Y+"%, "+j+"%, "+this._roundA+")"},toHex:function(U){return A(this._r,this._g,this._b,U)},toHexString:function(U){return"#"+this.toHex(U)},toHex8:function(U){return function(Q,Y,j,G,se){var ue=[D(p(Q).toString(16)),D(p(Y).toString(16)),D(p(j).toString(16)),D(W(G))];return se&&ue[0].charAt(0)==ue[0].charAt(1)&&ue[1].charAt(0)==ue[1].charAt(1)&&ue[2].charAt(0)==ue[2].charAt(1)&&ue[3].charAt(0)==ue[3].charAt(1)?ue[0].charAt(0)+ue[1].charAt(0)+ue[2].charAt(0)+ue[3].charAt(0):ue.join("")}(this._r,this._g,this._b,this._a,U)},toHex8String:function(U){return"#"+this.toHex8(U)},toRgb:function(){return{r:p(this._r),g:p(this._g),b:p(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+p(this._r)+", "+p(this._g)+", "+p(this._b)+")":"rgba("+p(this._r)+", "+p(this._g)+", "+p(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:p(100*B(this._r,255))+"%",g:p(100*B(this._g,255))+"%",b:p(100*B(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+p(100*B(this._r,255))+"%, "+p(100*B(this._g,255))+"%, "+p(100*B(this._b,255))+"%)":"rgba("+p(100*B(this._r,255))+"%, "+p(100*B(this._g,255))+"%, "+p(100*B(this._b,255))+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":!(this._a<1)&&(C[A(this._r,this._g,this._b,!0)]||!1)},toFilter:function(U){var Q="#"+S(this._r,this._g,this._b,this._a),Y=Q,j=this._gradientType?"GradientType = 1, ":"";if(U){var G=h(U);Y="#"+S(G._r,G._g,G._b,G._a)}return"progid:DXImageTransform.Microsoft.gradient("+j+"startColorstr="+Q+",endColorstr="+Y+")"},toString:function(U){var Q=!!U;U=U||this._format;var Y=!1,j=this._a<1&&this._a>=0;return Q||!j||U!=="hex"&&U!=="hex6"&&U!=="hex3"&&U!=="hex4"&&U!=="hex8"&&U!=="name"?(U==="rgb"&&(Y=this.toRgbString()),U==="prgb"&&(Y=this.toPercentageRgbString()),U!=="hex"&&U!=="hex6"||(Y=this.toHexString()),U==="hex3"&&(Y=this.toHexString(!0)),U==="hex4"&&(Y=this.toHex8String(!0)),U==="hex8"&&(Y=this.toHex8String()),U==="name"&&(Y=this.toName()),U==="hsl"&&(Y=this.toHslString()),U==="hsv"&&(Y=this.toHsvString()),Y||this.toHexString()):U==="name"&&this._a===0?this.toName():this.toRgbString()},clone:function(){return h(this.toString())},_applyModification:function(U,Q){var Y=U.apply(null,[this].concat([].slice.call(Q)));return this._r=Y._r,this._g=Y._g,this._b=Y._b,this.setAlpha(Y._a),this},lighten:function(){return this._applyModification(k,arguments)},brighten:function(){return this._applyModification(x,arguments)},darken:function(){return this._applyModification(I,arguments)},desaturate:function(){return this._applyModification(E,arguments)},saturate:function(){return this._applyModification(O,arguments)},greyscale:function(){return this._applyModification(_,arguments)},spin:function(){return this._applyModification(N,arguments)},_applyCombination:function(U,Q){return U.apply(null,[this].concat([].slice.call(Q)))},analogous:function(){return this._applyCombination(ee,arguments)},complement:function(){return this._applyCombination(P,arguments)},monochromatic:function(){return this._applyCombination(z,arguments)},splitcomplement:function(){return this._applyCombination(J,arguments)},triad:function(){return this._applyCombination(R,arguments)},tetrad:function(){return this._applyCombination(q,arguments)}},h.fromRatio=function(U,Q){if(typeof U=="object"){var Y={};for(var j in U)U.hasOwnProperty(j)&&(Y[j]=j==="a"?U[j]:$(U[j]));U=Y}return h(U,Q)},h.equals=function(U,Q){return!(!U||!Q)&&h(U).toRgbString()==h(Q).toRgbString()},h.random=function(){return h.fromRatio({r:v(),g:v(),b:v()})},h.mix=function(U,Q,Y){Y=Y===0?0:Y||50;var j=h(U).toRgb(),G=h(Q).toRgb(),se=Y/100;return h({r:(G.r-j.r)*se+j.r,g:(G.g-j.g)*se+j.g,b:(G.b-j.b)*se+j.b,a:(G.a-j.a)*se+j.a})},h.readability=function(U,Q){var Y=h(U),j=h(Q);return(y.max(Y.getLuminance(),j.getLuminance())+.05)/(y.min(Y.getLuminance(),j.getLuminance())+.05)},h.isReadable=function(U,Q,Y){var j,G,se,ue,re,ge=h.readability(U,Q);switch(G=!1,(se=Y,(ue=((se=se||{level:"AA",size:"small"}).level||"AA").toUpperCase())!=="AA"&&ue!=="AAA"&&(ue="AA"),(re=(se.size||"small").toLowerCase())!=="small"&&re!=="large"&&(re="small"),j={level:ue,size:re}).level+j.size){case"AAsmall":case"AAAlarge":G=ge>=4.5;break;case"AAlarge":G=ge>=3;break;case"AAAsmall":G=ge>=7}return G},h.mostReadable=function(U,Q,Y){var j,G,se,ue,re=null,ge=0;G=(Y=Y||{}).includeFallbackColors,se=Y.level,ue=Y.size;for(var ve=0;vege&&(ge=j,re=h(Q[ve]));return h.isReadable(U,re,{level:se,size:ue})||!G?re:(Y.includeFallbackColors=!1,h.mostReadable(U,["#fff","#000"],Y))};var F=h.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=h.hexNames=function(U){var Q={};for(var Y in U)U.hasOwnProperty(Y)&&(Q[U[Y]]=Y);return Q}(F);function M(U){return U=parseFloat(U),(isNaN(U)||U<0||U>1)&&(U=1),U}function B(U,Q){(function(j){return typeof j=="string"&&j.indexOf(".")!=-1&&parseFloat(j)===1})(U)&&(U="100%");var Y=function(j){return typeof j=="string"&&j.indexOf("%")!=-1}(U);return U=b(Q,w(0,parseFloat(U))),Y&&(U=parseInt(U*Q,10)/100),y.abs(U-Q)<1e-6?1:U%Q/parseFloat(Q)}function H(U){return b(1,w(0,U))}function V(U){return parseInt(U,16)}function D(U){return U.length==1?"0"+U:""+U}function $(U){return U<=1&&(U=100*U+"%"),U}function W(U){return y.round(255*parseFloat(U)).toString(16)}function X(U){return V(U)/255}var ie,fe,we,ye=(fe="[\\s|\\(]+("+(ie="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+ie+")[,|\\s]+("+ie+")\\s*\\)?",we="[\\s|\\(]+("+ie+")[,|\\s]+("+ie+")[,|\\s]+("+ie+")[,|\\s]+("+ie+")\\s*\\)?",{CSS_UNIT:new RegExp(ie),rgb:new RegExp("rgb"+fe),rgba:new RegExp("rgba"+we),hsl:new RegExp("hsl"+fe),hsla:new RegExp("hsla"+we),hsv:new RegExp("hsv"+fe),hsva:new RegExp("hsva"+we),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function be(U){return!!ye.CSS_UNIT.exec(U)}s.exports?s.exports=h:(m=(function(){return h}).call(u,c,u,s))===void 0||(s.exports=m)})(Math)},607:function(s,u,c){var m=this&&this.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(u,"__esModule",{value:!0}),u.Cursor=u.default=void 0;var y=m(c(678));u.default=y.default;var f=m(c(353));u.Cursor=f.default,c(413)},353:(s,u,c)=>{Object.defineProperty(u,"__esModule",{value:!0});var m=c(621),y=function(){function f(l,a,p){this.id=l,this.name=a,this.color=p,this.toggleNearCursor=this.toggleNearCursor.bind(this),this._toggleOpenedCursor=this._toggleOpenedCursor.bind(this),this._setHoverState=this._setHoverState.bind(this)}return f.prototype.build=function(l){var a=document.createElement(f.CONTAINER_ELEMENT_TAG);a.classList.add(f.CURSOR_CLASS),a.id="ql-cursor-".concat(this.id),a.innerHTML=l.template;var p=a.getElementsByClassName(f.SELECTION_CLASS)[0],b=a.getElementsByClassName(f.CARET_CONTAINER_CLASS)[0],w=b.getElementsByClassName(f.CARET_CLASS)[0],v=a.getElementsByClassName(f.FLAG_CLASS)[0];return v.style.backgroundColor=this.color,w.style.backgroundColor=this.color,a.getElementsByClassName(f.NAME_CLASS)[0].textContent=this.name,this._hideDelay="".concat(l.hideDelayMs,"ms"),this._hideSpeedMs=l.hideSpeedMs,this._positionFlag=l.positionFlag,v.style.transitionDelay=this._hideDelay,v.style.transitionDuration="".concat(this._hideSpeedMs,"ms"),this._el=a,this._selectionEl=p,this._caretEl=b,this._flagEl=v,b.addEventListener("mouseover",this._setHoverState),this._el},f.prototype.show=function(){this._el.classList.remove(f.HIDDEN_CLASS)},f.prototype.hide=function(){this._el.classList.add(f.HIDDEN_CLASS)},f.prototype.remove=function(){this._el.parentNode.removeChild(this._el)},f.prototype.toggleNearCursor=function(l,a){var p=this._getCoordinates(),b=p.left,w=p.right,v=p.top,h=p.bottom,g=l>=b&&l<=w&&a>=v&&a<=h;return this._caretEl.classList.toggle(f.CONTAINER_HOVER_CLASS,g),g},f.prototype.toggleFlag=function(l){var a=this;this._caretEl.classList.toggle(f.CONTAINER_HOVER_CLASS,l)||(this._flagEl.classList.add(f.NO_DELAY_CLASS),setTimeout(function(){return a._flagEl.classList.remove(f.NO_DELAY_CLASS)},this._hideSpeedMs))},f.prototype.updateCaret=function(l,a){this._caretEl.style.top="".concat(l.top,"px"),this._caretEl.style.left="".concat(l.left,"px"),this._caretEl.style.height="".concat(l.height,"px"),this._positionFlag?this._positionFlag(this._flagEl,l,a):this._updateCaretFlag(l,a)},f.prototype.updateSelection=function(l,a){var p=this;this._clearSelection(),l=l||[],l=Array.from(l),l=this._sanitize(l),(l=this._sortByDomPosition(l)).forEach(function(b){return p._addSelection(b,a)})},f.prototype._setHoverState=function(){document.addEventListener("mousemove",this._toggleOpenedCursor)},f.prototype._toggleOpenedCursor=function(l){var a=this.toggleNearCursor(l.clientX,l.clientY);this._caretEl.classList.toggle(f.CONTAINER_NO_POINTER_CLASS,a),a||document.removeEventListener("mousemove",this._toggleOpenedCursor)},f.prototype._getCoordinates=function(){return this._caretEl.getBoundingClientRect()},f.prototype._updateCaretFlag=function(l,a){this._flagEl.style.width="";var p=this._flagEl.getBoundingClientRect();this._flagEl.classList.remove(f.FLAG_FLIPPED_CLASS),l.left>a.width-p.width&&this._flagEl.classList.add(f.FLAG_FLIPPED_CLASS),this._flagEl.style.left="".concat(l.left,"px"),this._flagEl.style.top="".concat(l.top,"px"),this._flagEl.style.width="".concat(Math.ceil(p.width),"px")},f.prototype._clearSelection=function(){this._selectionEl.innerHTML=""},f.prototype._addSelection=function(l,a){var p=this._selectionBlock(l,a);this._selectionEl.appendChild(p)},f.prototype._selectionBlock=function(l,a){var p=document.createElement(f.SELECTION_ELEMENT_TAG);return p.classList.add(f.SELECTION_BLOCK_CLASS),p.style.top="".concat(l.top-a.top,"px"),p.style.left="".concat(l.left-a.left,"px"),p.style.width="".concat(l.width,"px"),p.style.height="".concat(l.height,"px"),p.style.backgroundColor=m(this.color).setAlpha(.3).toString(),p},f.prototype._sortByDomPosition=function(l){return l.sort(function(a,p){return a.top===p.top?a.left-p.left:a.top-p.top})},f.prototype._sanitize=function(l){var a=this,p=new Set;return l.filter(function(b){if(!b.width||!b.height)return!1;var w=a._serialize(b);return!p.has(w)&&(p.add(w),!0)})},f.prototype._serialize=function(l){return["top:".concat(l.top),"right:".concat(l.right),"bottom:".concat(l.bottom),"left:".concat(l.left)].join(";")},f.CONTAINER_ELEMENT_TAG="SPAN",f.SELECTION_ELEMENT_TAG="SPAN",f.CURSOR_CLASS="ql-cursor",f.SELECTION_CLASS="ql-cursor-selections",f.SELECTION_BLOCK_CLASS="ql-cursor-selection-block",f.CARET_CLASS="ql-cursor-caret",f.CARET_CONTAINER_CLASS="ql-cursor-caret-container",f.CONTAINER_HOVER_CLASS="hover",f.CONTAINER_NO_POINTER_CLASS="no-pointer",f.FLAG_CLASS="ql-cursor-flag",f.FLAG_FLIPPED_CLASS="flag-flipped",f.NAME_CLASS="ql-cursor-name",f.HIDDEN_CLASS="hidden",f.NO_DELAY_CLASS="no-delay",f}();u.default=y},678:function(s,u,c){var m=this&&this.__createBinding||(Object.create?function(g,d,A,S){S===void 0&&(S=A),Object.defineProperty(g,S,{enumerable:!0,get:function(){return d[A]}})}:function(g,d,A,S){S===void 0&&(S=A),g[S]=d[A]}),y=this&&this.__setModuleDefault||(Object.create?function(g,d){Object.defineProperty(g,"default",{enumerable:!0,value:d})}:function(g,d){g.default=d}),f=this&&this.__importStar||function(g){if(g&&g.__esModule)return g;var d={};if(g!=null)for(var A in g)A!=="default"&&Object.prototype.hasOwnProperty.call(g,A)&&m(d,g,A);return y(d,g),d},l=this&&this.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(u,"__esModule",{value:!0});var a=l(c(353)),p=f(c(165)),b=l(c(338)),w=l(c(33)),v=c(895),h=function(){function g(d,A){A===void 0&&(A={}),this._cursors={},this._isObserving=!1,this._handleCursorTouch=this._handleCursorTouch.bind(this),this.quill=d,this.options=this._setDefaults(A),this._container=this.quill.addContainer(this.options.containerClass),this._boundsContainer=this.options.boundsContainer||this.quill.container,this._currentSelection=this.quill.getSelection(),this._registerSelectionChangeListeners(),this._registerTextChangeListener(),this._registerDomListeners()}return g.prototype.createCursor=function(d,A,S){var E=this._cursors[d];if(!E){E=new a.default(d,A,S),this._cursors[d]=E;var O=E.build(this.options);this._container.appendChild(O)}return E},g.prototype.moveCursor=function(d,A){var S=this._cursors[d];S&&(S.range=A,this._updateCursor(S))},g.prototype.removeCursor=function(d){var A=this._cursors[d];A&&(A.remove(),delete this._cursors[d])},g.prototype.update=function(){var d=this;this.cursors().forEach(function(A){return d._updateCursor(A)})},g.prototype.clearCursors=function(){var d=this;this.cursors().forEach(function(A){return d.removeCursor(A.id)})},g.prototype.toggleFlag=function(d,A){var S=this._cursors[d];S&&S.toggleFlag(A)},g.prototype.cursors=function(){var d=this;return Object.keys(this._cursors).map(function(A){return d._cursors[A]})},g.prototype._registerSelectionChangeListeners=function(){var d=this;this.quill.on(this.quill.constructor.events.SELECTION_CHANGE,function(A){d._currentSelection=A})},g.prototype._registerTextChangeListener=function(){var d=this;this.quill.on(this.quill.constructor.events.TEXT_CHANGE,function(A){return d._handleTextChange(A)})},g.prototype._registerDomListeners=function(){var d=this,A=this.quill.container.getElementsByClassName("ql-editor")[0];A.addEventListener("scroll",function(){return d.update()}),A.addEventListener("touchstart",this._handleCursorTouch)},g.prototype._handleCursorTouch=function(d){var A=this;this.cursors().forEach(function(S){S.toggleNearCursor(d.pageX,d.pageY),setTimeout(function(){return S.toggleFlag(!1)},A.options.hideDelayMs)})},g.prototype._registerResizeObserver=function(){var d=this;if(!this._isObserving){var A=this.quill.container.getElementsByClassName("ql-editor")[0],S=new w.default(function(E){E[0].target.isConnected||(S.disconnect(),d._isObserving=!1),d.update()});S.observe(A),this._isObserving=!0}},g.prototype._updateCursor=function(d){if(this._registerResizeObserver(),!d.range)return d.hide();var A=this._indexWithinQuillBounds(d.range.index),S=this._indexWithinQuillBounds(d.range.index+d.range.length),E=this.quill.getLeaf(A),O=this.quill.getLeaf(S);if(!this._leafIsValid(E)||!this._leafIsValid(O))return d.hide();d.show();var _=this._boundsContainer.getBoundingClientRect(),k=this.quill.getBounds(S);d.updateCaret(k,_);var x=this._lineRanges(d,E,O).reduce(function(I,N){return I.concat(Array.from(p.getClientRects(N)))},[]);d.updateSelection(x,_)},g.prototype._indexWithinQuillBounds=function(d){var A=this.quill.getLength(),S=A?A-1:0;return d=Math.max(d,0),Math.min(d,S)},g.prototype._leafIsValid=function(d){return d&&d[0]&&d[0].domNode&&d[1]>=0},g.prototype._handleTextChange=function(d){var A=this;window.setTimeout(function(){A.options.transformOnTextChange&&A._transformCursors(d),A.options.selectionChangeSource&&(A._emitSelection(),A.update())})},g.prototype._emitSelection=function(){this.quill.emitter.emit(this.quill.constructor.events.SELECTION_CHANGE,this.quill.getSelection(),this._currentSelection,this.options.selectionChangeSource)},g.prototype._setDefaults=function(d){return(d=Object.assign({},d)).template||(d.template=g.DEFAULTS.template),d.containerClass||(d.containerClass=g.DEFAULTS.containerClass),d.selectionChangeSource!==null&&(d.selectionChangeSource||(d.selectionChangeSource=g.DEFAULTS.selectionChangeSource)),d.hideDelayMs=Number.isInteger(d.hideDelayMs)?d.hideDelayMs:g.DEFAULTS.hideDelayMs,d.hideSpeedMs=Number.isInteger(d.hideSpeedMs)?d.hideSpeedMs:g.DEFAULTS.hideSpeedMs,d.transformOnTextChange=!!d.transformOnTextChange,d},g.prototype._lineRanges=function(d,A,S){var E=this.quill.getLines(d.range);return E.reduce(function(O,_,k){if(!_.children){var x=document.createRange();return x.selectNode(_.domNode),O.concat(x)}var I=k===0?A:_.path(0).pop(),N=I[0],P=I[1],R=k===E.length-1?S:_.path(_.length()-1).pop(),q=R[0],J=R[1],ee=document.createRange();return N.domNode.nodeType===Node.TEXT_NODE?ee.setStart(N.domNode,P):ee.setStartBefore(N.domNode),q.domNode.nodeType===Node.TEXT_NODE?ee.setEnd(q.domNode,J):ee.setEndAfter(q.domNode),O.concat(ee)},[])},g.prototype._transformCursors=function(d){var A=this;d=new v(d),this.cursors().filter(function(S){return S.range}).forEach(function(S){S.range.index=d.transformPosition(S.range.index),A._updateCursor(S)})},g.DEFAULTS={template:b.default,containerClass:"ql-cursors",selectionChangeSource:"api",hideDelayMs:3e3,hideSpeedMs:400},g}();u.default=h},338:function(s,u,c){var m=this&&this.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(u,"__esModule",{value:!0});var y=m(c(353)),f=` @@ -70,5 +70,5 @@ var Ku=Object.defineProperty;var Hu=(i,t,e)=>t in i?Ku(i,t,{enumerable:!0,config
    -`);u.default=f}},n={};function r(s){var u=n[s];if(u!==void 0)return u.exports;var c=n[s]={id:s,loaded:!1,exports:{}};return e[s].call(c.exports,c,c.exports,r),c.loaded=!0,c.exports}r.n=s=>{var u=s&&s.__esModule?()=>s.default:()=>s;return r.d(u,{a:u}),u},r.d=(s,u)=>{for(var c in u)r.o(u,c)&&!r.o(s,c)&&Object.defineProperty(s,c,{enumerable:!0,get:u[c]})},r.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),r.o=(s,u)=>Object.prototype.hasOwnProperty.call(s,u),r.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},r.nmd=s=>(s.paths=[],s.children||(s.children=[]),s),r.nc=void 0;var o=r(607);return o.default})())})(Vu);var Zh=Vu.exports;const Xh=$u(Zh);var Le=function(i,t,e){if(!t.has(i))throw new TypeError("attempted to set private field on non-instance");return t.set(i,e),e},Te=function(i,t){if(!t.has(i))throw new TypeError("attempted to get private field on non-instance");return t.get(i)},ai,Ai,on,ji,lo,wn,An,Tn,Sn,En,xn,kn,On,Ti,Ui,li,es,ui;const Qh=function(i){var t=131,e=137,n=0;i+="x";var r=Math.floor(9007199254740991/e);for(let o=0;or&&(n=Math.floor(n/e)),n=n*t+i.charCodeAt(o);return n},Se="0123456789abcdef".split(""),ed=[-2147483648,8388608,32768,128],rn=[24,16,8,0],Ko=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],gt=[];class td{constructor(t=!1,e=!1){ai.set(this,void 0),Ai.set(this,void 0),on.set(this,void 0),ji.set(this,void 0),lo.set(this,void 0),wn.set(this,void 0),An.set(this,void 0),Tn.set(this,void 0),Sn.set(this,void 0),En.set(this,void 0),xn.set(this,void 0),kn.set(this,void 0),On.set(this,void 0),Ti.set(this,void 0),Ui.set(this,void 0),li.set(this,void 0),es.set(this,0),ui.set(this,void 0),this.init(t,e)}init(t,e){e?(gt[0]=gt[16]=gt[1]=gt[2]=gt[3]=gt[4]=gt[5]=gt[6]=gt[7]=gt[8]=gt[9]=gt[10]=gt[11]=gt[12]=gt[13]=gt[14]=gt[15]=0,Le(this,Ai,gt)):Le(this,Ai,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t?(Le(this,wn,3238371032),Le(this,An,914150663),Le(this,Tn,812702999),Le(this,Sn,4144912697),Le(this,En,4290775857),Le(this,xn,1750603025),Le(this,kn,1694076839),Le(this,On,3204075428)):(Le(this,wn,1779033703),Le(this,An,3144134277),Le(this,Tn,1013904242),Le(this,Sn,2773480762),Le(this,En,1359893119),Le(this,xn,2600822924),Le(this,kn,528734635),Le(this,On,1541459225)),Le(this,ai,Le(this,ui,Le(this,on,Le(this,Ui,0)))),Le(this,ji,Le(this,Ti,!1)),Le(this,lo,!0),Le(this,li,t)}update(t){if(Te(this,ji))return this;let e;t instanceof ArrayBuffer?e=new Uint8Array(t):e=t;let n=0;const r=e.length,o=Te(this,Ai);for(;n>2]|=e[n]<>2]|=u<>2]|=(192|u>>6)<>2]|=(128|u&63)<=57344?(o[s>>2]|=(224|u>>12)<>2]|=(128|u>>6&63)<>2]|=(128|u&63)<>2]|=(240|u>>18)<>2]|=(128|u>>12&63)<>2]|=(128|u>>6&63)<>2]|=(128|u&63)<=64?(Le(this,ai,o[16]),Le(this,ui,s-64),this.hash(),Le(this,Ti,!0)):Le(this,ui,s)}return Te(this,on)>4294967295&&(Le(this,Ui,Te(this,Ui)+(Te(this,on)/4294967296<<0)),Le(this,on,Te(this,on)%4294967296)),this}finalize(){if(Te(this,ji))return;Le(this,ji,!0);const t=Te(this,Ai),e=Te(this,es);t[16]=Te(this,ai),t[e>>2]|=ed[e&3],Le(this,ai,t[16]),e>=56&&(Te(this,Ti)||this.hash(),t[0]=Te(this,ai),t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=Te(this,Ui)<<3|Te(this,on)>>>29,t[15]=Te(this,on)<<3,this.hash()}hash(){let t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On);const m=Te(this,Ai);let y,f,l,a,p,b,w,v,h,g;for(let d=16;d<64;++d)a=m[d-15],y=(a>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,a=m[d-2],f=(a>>>17|a<<15)^(a>>>19|a<<13)^a>>>10,m[d]=m[d-16]+y+m[d-7]+f<<0;g=e&n;for(let d=0;d<64;d+=4)Te(this,lo)?(Te(this,li)?(w=300032,a=m[0]-1413257819,c=a-150054599<<0,r=a+24177077<<0):(w=704751109,a=m[0]-210244248,c=a-1521486534<<0,r=a+143694565<<0),Le(this,lo,!1)):(y=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),f=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=t&e,l=w^t&n^g,b=o&s^~o&u,a=c+f+b+Ko[d]+m[d],p=y+l,c=r+a<<0,r=a+p<<0),y=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),f=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),v=r&t,l=v^r&e^w,b=c&o^~c&s,a=u+f+b+Ko[d+1]+m[d+1],p=y+l,u=n+a<<0,n=a+p<<0,y=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),f=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),h=n&r,l=h^n&t^v,b=u&c^~u&o,a=s+f+b+Ko[d+2]+m[d+2],p=y+l,s=e+a<<0,e=a+p<<0,y=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),f=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,l=g^e&r^h,b=s&u^~s&c,a=o+f+b+Ko[d+3]+m[d+3],p=y+l,o=t+a<<0,t=a+p<<0;Le(this,wn,Te(this,wn)+t<<0),Le(this,An,Te(this,An)+e<<0),Le(this,Tn,Te(this,Tn)+n<<0),Le(this,Sn,Te(this,Sn)+r<<0),Le(this,En,Te(this,En)+o<<0),Le(this,xn,Te(this,xn)+s<<0),Le(this,kn,Te(this,kn)+u<<0),Le(this,On,Te(this,On)+c<<0)}hex(){this.finalize();const t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On);let m=Se[t>>28&15]+Se[t>>24&15]+Se[t>>20&15]+Se[t>>16&15]+Se[t>>12&15]+Se[t>>8&15]+Se[t>>4&15]+Se[t&15]+Se[e>>28&15]+Se[e>>24&15]+Se[e>>20&15]+Se[e>>16&15]+Se[e>>12&15]+Se[e>>8&15]+Se[e>>4&15]+Se[e&15]+Se[n>>28&15]+Se[n>>24&15]+Se[n>>20&15]+Se[n>>16&15]+Se[n>>12&15]+Se[n>>8&15]+Se[n>>4&15]+Se[n&15]+Se[r>>28&15]+Se[r>>24&15]+Se[r>>20&15]+Se[r>>16&15]+Se[r>>12&15]+Se[r>>8&15]+Se[r>>4&15]+Se[r&15]+Se[o>>28&15]+Se[o>>24&15]+Se[o>>20&15]+Se[o>>16&15]+Se[o>>12&15]+Se[o>>8&15]+Se[o>>4&15]+Se[o&15]+Se[s>>28&15]+Se[s>>24&15]+Se[s>>20&15]+Se[s>>16&15]+Se[s>>12&15]+Se[s>>8&15]+Se[s>>4&15]+Se[s&15]+Se[u>>28&15]+Se[u>>24&15]+Se[u>>20&15]+Se[u>>16&15]+Se[u>>12&15]+Se[u>>8&15]+Se[u>>4&15]+Se[u&15];return Te(this,li)||(m+=Se[c>>28&15]+Se[c>>24&15]+Se[c>>20&15]+Se[c>>16&15]+Se[c>>12&15]+Se[c>>8&15]+Se[c>>4&15]+Se[c&15]),m}toString(){return this.hex()}digest(){this.finalize();const t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On),m=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,o>>24&255,o>>16&255,o>>8&255,o&255,s>>24&255,s>>16&255,s>>8&255,s&255,u>>24&255,u>>16&255,u>>8&255,u&255];return Te(this,li)||m.push(c>>24&255,c>>16&255,c>>8&255,c&255),m}array(){return this.digest()}arrayBuffer(){this.finalize();const t=new ArrayBuffer(Te(this,li)?28:32),e=new DataView(t);return e.setUint32(0,Te(this,wn)),e.setUint32(4,Te(this,An)),e.setUint32(8,Te(this,Tn)),e.setUint32(12,Te(this,Sn)),e.setUint32(16,Te(this,En)),e.setUint32(20,Te(this,xn)),e.setUint32(24,Te(this,kn)),Te(this,li)||e.setUint32(28,Te(this,On)),t}}ai=new WeakMap,Ai=new WeakMap,on=new WeakMap,ji=new WeakMap,lo=new WeakMap,wn=new WeakMap,An=new WeakMap,Tn=new WeakMap,Sn=new WeakMap,En=new WeakMap,xn=new WeakMap,kn=new WeakMap,On=new WeakMap,Ti=new WeakMap,Ui=new WeakMap,li=new WeakMap,es=new WeakMap,ui=new WeakMap;function nd(i){const t=new td;return t.update(i),parseInt(t.hex().substring(0,8),16)}const rd=function(i){var t="#";return i.forEach(function(e){e<16&&(t+=0),t+=e.toString(16)}),t},id=function(i,t,e){i/=360;var n=e<.5?e*(1+t):e+t-e*t,r=2*e-n;return[i+1/3,i,i-1/3].map(function(o){return o<0&&o++,o>1&&o--,o<1/6?o=r+(n-r)*6*o:o<.5?o=n:o<2/3?o=r+(n-r)*6*(2/3-o):o=r,Math.round(o*255)})};class od{constructor(t={}){const[e,n]=[t.lightness,t.saturation].map(function(r){return r=r!==void 0?r:[.35,.5,.65],Array.isArray(r)?r.concat():[r]});this.L=e,this.S=n,typeof t.hue=="number"&&(t.hue={min:t.hue,max:t.hue}),typeof t.hue=="object"&&!Array.isArray(t.hue)&&(t.hue=[t.hue]),typeof t.hue>"u"&&(t.hue=[]),this.hueRanges=t.hue.map(function(r){return{min:typeof r.min>"u"?0:r.min,max:typeof r.max>"u"?360:r.max}}),this.hash=nd,typeof t.hash=="function"&&(this.hash=t.hash),t.hash==="bkdr"&&(this.hash=Qh)}hsl(t){var e,n,r,o=this.hash(t),s=727;if(this.hueRanges.length){const u=this.hueRanges[o%this.hueRanges.length];e=o/this.hueRanges.length%s*(u.max-u.min)/s+u.min}else e=o%359;return o=Math.ceil(o/360),n=this.S[o%this.S.length],o=Math.ceil(o/this.S.length),r=this.L[o%this.L.length],[e,n,r]}rgb(t){var e=this.hsl(t);return id.apply(this,e)}hex(t){var e=this.rgb(t);return rd(e)}}const Si={isOnline:!1,showOffline:i=>{Si.isOnline=!1,i.innerHTML=' '},showOnline:i=>{Si.isOnline=!0,i.innerHTML=' '},statusListener:i=>t=>{Si.isOnline&&t.value==xo.Disconnected?Si.showOffline(i):!Si.isOnline&&t.value==xo.Connected&&Si.showOnline(i)}};function sd(i,t,e){const n=[];for(const{clientID:r,presence:o}of t)n.push(e===r?`${o.username}`:o.username);i.innerHTML=JSON.stringify(n)}function Pl(i,t,e){i.innerText=e.toJSON(),t.innerText=e.getRoot().content.toTestString()}const ad=document.getElementById("peers"),Cl=document.getElementById("document"),Ll=document.getElementById("document-text"),ld=document.getElementById("network-status"),ud=new od,cd=`vanilla-quill-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`;function zs(i){const{embed:t,...e}=i.attributes??{};return t?{insert:t,attributes:e}:{insert:i.content||"",attributes:i.attributes}}async function fd(){const i=new $s.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await i.activate();const t=new $s.Document(cd,{enableDevtools:!0});t.subscribe("connection",c=>{Si.statusListener(ld)(c)}),t.subscribe("presence",c=>{c.type!==ft.PresenceChanged&&sd(ad,t.getPresences(),i.getID())}),await i.attach(t,{initialPresence:{username:i.getID().slice(-2),color:ud.hex(i.getID().slice(-2)),selection:void 0}}),t.update(c=>{c.content||(c.content=new $s.Text,c.content.edit(0,0,` -`))},"create content if not exists"),t.subscribe(c=>{c.type==="snapshot"&&u(),Pl(Cl,Ll,t)}),t.subscribe("$.content",c=>{c.type==="remote-change"&&s(c.value.operations),n()}),t.subscribe("others",c=>{c.type===ft.Unwatched?o.removeCursor(c.value.clientID):c.type===ft.PresenceChanged&&e(c.value)});function e(c){const{clientID:m,presence:y}=c;if(m===i.getID()||!y)return;const{username:f,color:l,selection:a}=y;if(!a)return;const p=t.getRoot().content.posRangeToIndexRange(a);o.createCursor(m,f,l),o.moveCursor(m,{index:p[0],length:p[1]-p[0]})}function n(){for(const c of t.getPresences())e(c)}await i.sync(),_l.register("modules/cursors",Xh);const r=new _l("#editor",{modules:{toolbar:[["bold","italic","underline","strike"],["blockquote","code-block"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["image","video"],["clean"]],cursors:!0},theme:"snow"}),o=r.getModule("cursors");r.on("text-change",(c,m,y)=>{if(y==="api"||!c.ops)return;let f=0,l=0;console.log(`%c quill: ${JSON.stringify(c.ops)}`,"color: green");for(const a of c.ops)a.attributes!==void 0||a.insert!==void 0?(a.retain!==void 0&&(l=f+a.retain),console.log(`%c local: ${f}-${l}: ${a.insert} ${a.attributes?JSON.stringify(a.attributes):"{}"}`,"color: green"),t.update((p,b)=>{let w;a.attributes!==void 0&&a.insert===void 0?p.content.setStyle(f,l,a.attributes):a.insert!==void 0&&(l{const w=p.content.edit(f,l,"");w&&b.set({selection:p.content.indexRangeToPosRange(w)})},`update content by ${i.getID()}`)):a.retain!==void 0&&(f=l+a.retain,l=f)}).on("selection-change",(c,m,y)=>{if(c){if(y==="api"){const{selection:f}=t.getMyPresence();if(f){const[l,a]=t.getRoot().content.posRangeToIndexRange(f),{index:p,length:b}=c;if(l===p&&a===p+b)return}}t.update((f,l)=>{l.set({selection:f.content.indexRangeToPosRange([c.index,c.index+c.length])})},`update selection by ${i.getID()}`)}});function s(c){const m=[];let y=0;for(const f of c)if(f.type==="edit"){const l=f.from,a=f.to,p=l-y,b=a-l,{insert:w,attributes:v}=zs(f.value);if(console.log(`%c remote: ${l}-${a}: ${w}`,"color: skyblue"),p&&m.push({retain:p}),b&&m.push({delete:b}),w){const h={insert:w};v&&(h.attributes=v),m.push(h)}y=a}else if(f.type==="style"){const l=f.from,a=f.to,p=l-y,b=a-l,{attributes:w}=zs(f.value);if(console.log(`%c remote: ${l}-${a}: ${JSON.stringify(w)}`,"color: skyblue"),p&&m.push({retain:p}),w){const v={attributes:w};b&&(v.retain=b),m.push(v)}y=a}if(m.length){console.log(`%c to quill: ${JSON.stringify(m)}`,"color: green");const f={ops:m};r.updateContents(f,"api")}}function u(){const m={ops:t.getRoot().content.values().map(y=>zs(y))};r.setContents(m,"api")}u(),n(),Pl(Cl,Ll,t)}fd(); +`);u.default=f}},n={};function r(s){var u=n[s];if(u!==void 0)return u.exports;var c=n[s]={id:s,loaded:!1,exports:{}};return e[s].call(c.exports,c,c.exports,r),c.loaded=!0,c.exports}r.n=s=>{var u=s&&s.__esModule?()=>s.default:()=>s;return r.d(u,{a:u}),u},r.d=(s,u)=>{for(var c in u)r.o(u,c)&&!r.o(s,c)&&Object.defineProperty(s,c,{enumerable:!0,get:u[c]})},r.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),r.o=(s,u)=>Object.prototype.hasOwnProperty.call(s,u),r.r=s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},r.nmd=s=>(s.paths=[],s.children||(s.children=[]),s),r.nc=void 0;var o=r(607);return o.default})())})(Vu);var Zh=Vu.exports;const Xh=$u(Zh);var Le=function(i,t,e){if(!t.has(i))throw new TypeError("attempted to set private field on non-instance");return t.set(i,e),e},Te=function(i,t){if(!t.has(i))throw new TypeError("attempted to get private field on non-instance");return t.get(i)},ai,Ai,on,ji,lo,wn,An,Tn,Sn,En,xn,kn,On,Ti,Ui,li,es,ui;const Qh=function(i){var t=131,e=137,n=0;i+="x";var r=Math.floor(9007199254740991/e);for(let o=0;or&&(n=Math.floor(n/e)),n=n*t+i.charCodeAt(o);return n},Se="0123456789abcdef".split(""),ed=[-2147483648,8388608,32768,128],rn=[24,16,8,0],Ko=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],gt=[];class td{constructor(t=!1,e=!1){ai.set(this,void 0),Ai.set(this,void 0),on.set(this,void 0),ji.set(this,void 0),lo.set(this,void 0),wn.set(this,void 0),An.set(this,void 0),Tn.set(this,void 0),Sn.set(this,void 0),En.set(this,void 0),xn.set(this,void 0),kn.set(this,void 0),On.set(this,void 0),Ti.set(this,void 0),Ui.set(this,void 0),li.set(this,void 0),es.set(this,0),ui.set(this,void 0),this.init(t,e)}init(t,e){e?(gt[0]=gt[16]=gt[1]=gt[2]=gt[3]=gt[4]=gt[5]=gt[6]=gt[7]=gt[8]=gt[9]=gt[10]=gt[11]=gt[12]=gt[13]=gt[14]=gt[15]=0,Le(this,Ai,gt)):Le(this,Ai,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t?(Le(this,wn,3238371032),Le(this,An,914150663),Le(this,Tn,812702999),Le(this,Sn,4144912697),Le(this,En,4290775857),Le(this,xn,1750603025),Le(this,kn,1694076839),Le(this,On,3204075428)):(Le(this,wn,1779033703),Le(this,An,3144134277),Le(this,Tn,1013904242),Le(this,Sn,2773480762),Le(this,En,1359893119),Le(this,xn,2600822924),Le(this,kn,528734635),Le(this,On,1541459225)),Le(this,ai,Le(this,ui,Le(this,on,Le(this,Ui,0)))),Le(this,ji,Le(this,Ti,!1)),Le(this,lo,!0),Le(this,li,t)}update(t){if(Te(this,ji))return this;let e;t instanceof ArrayBuffer?e=new Uint8Array(t):e=t;let n=0;const r=e.length,o=Te(this,Ai);for(;n>2]|=e[n]<>2]|=u<>2]|=(192|u>>6)<>2]|=(128|u&63)<=57344?(o[s>>2]|=(224|u>>12)<>2]|=(128|u>>6&63)<>2]|=(128|u&63)<>2]|=(240|u>>18)<>2]|=(128|u>>12&63)<>2]|=(128|u>>6&63)<>2]|=(128|u&63)<=64?(Le(this,ai,o[16]),Le(this,ui,s-64),this.hash(),Le(this,Ti,!0)):Le(this,ui,s)}return Te(this,on)>4294967295&&(Le(this,Ui,Te(this,Ui)+(Te(this,on)/4294967296<<0)),Le(this,on,Te(this,on)%4294967296)),this}finalize(){if(Te(this,ji))return;Le(this,ji,!0);const t=Te(this,Ai),e=Te(this,es);t[16]=Te(this,ai),t[e>>2]|=ed[e&3],Le(this,ai,t[16]),e>=56&&(Te(this,Ti)||this.hash(),t[0]=Te(this,ai),t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=Te(this,Ui)<<3|Te(this,on)>>>29,t[15]=Te(this,on)<<3,this.hash()}hash(){let t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On);const m=Te(this,Ai);let y,f,l,a,p,b,w,v,h,g;for(let d=16;d<64;++d)a=m[d-15],y=(a>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,a=m[d-2],f=(a>>>17|a<<15)^(a>>>19|a<<13)^a>>>10,m[d]=m[d-16]+y+m[d-7]+f<<0;g=e&n;for(let d=0;d<64;d+=4)Te(this,lo)?(Te(this,li)?(w=300032,a=m[0]-1413257819,c=a-150054599<<0,r=a+24177077<<0):(w=704751109,a=m[0]-210244248,c=a-1521486534<<0,r=a+143694565<<0),Le(this,lo,!1)):(y=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),f=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),w=t&e,l=w^t&n^g,b=o&s^~o&u,a=c+f+b+Ko[d]+m[d],p=y+l,c=r+a<<0,r=a+p<<0),y=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),f=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),v=r&t,l=v^r&e^w,b=c&o^~c&s,a=u+f+b+Ko[d+1]+m[d+1],p=y+l,u=n+a<<0,n=a+p<<0,y=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),f=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7),h=n&r,l=h^n&t^v,b=u&c^~u&o,a=s+f+b+Ko[d+2]+m[d+2],p=y+l,s=e+a<<0,e=a+p<<0,y=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),f=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),g=e&n,l=g^e&r^h,b=s&u^~s&c,a=o+f+b+Ko[d+3]+m[d+3],p=y+l,o=t+a<<0,t=a+p<<0;Le(this,wn,Te(this,wn)+t<<0),Le(this,An,Te(this,An)+e<<0),Le(this,Tn,Te(this,Tn)+n<<0),Le(this,Sn,Te(this,Sn)+r<<0),Le(this,En,Te(this,En)+o<<0),Le(this,xn,Te(this,xn)+s<<0),Le(this,kn,Te(this,kn)+u<<0),Le(this,On,Te(this,On)+c<<0)}hex(){this.finalize();const t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On);let m=Se[t>>28&15]+Se[t>>24&15]+Se[t>>20&15]+Se[t>>16&15]+Se[t>>12&15]+Se[t>>8&15]+Se[t>>4&15]+Se[t&15]+Se[e>>28&15]+Se[e>>24&15]+Se[e>>20&15]+Se[e>>16&15]+Se[e>>12&15]+Se[e>>8&15]+Se[e>>4&15]+Se[e&15]+Se[n>>28&15]+Se[n>>24&15]+Se[n>>20&15]+Se[n>>16&15]+Se[n>>12&15]+Se[n>>8&15]+Se[n>>4&15]+Se[n&15]+Se[r>>28&15]+Se[r>>24&15]+Se[r>>20&15]+Se[r>>16&15]+Se[r>>12&15]+Se[r>>8&15]+Se[r>>4&15]+Se[r&15]+Se[o>>28&15]+Se[o>>24&15]+Se[o>>20&15]+Se[o>>16&15]+Se[o>>12&15]+Se[o>>8&15]+Se[o>>4&15]+Se[o&15]+Se[s>>28&15]+Se[s>>24&15]+Se[s>>20&15]+Se[s>>16&15]+Se[s>>12&15]+Se[s>>8&15]+Se[s>>4&15]+Se[s&15]+Se[u>>28&15]+Se[u>>24&15]+Se[u>>20&15]+Se[u>>16&15]+Se[u>>12&15]+Se[u>>8&15]+Se[u>>4&15]+Se[u&15];return Te(this,li)||(m+=Se[c>>28&15]+Se[c>>24&15]+Se[c>>20&15]+Se[c>>16&15]+Se[c>>12&15]+Se[c>>8&15]+Se[c>>4&15]+Se[c&15]),m}toString(){return this.hex()}digest(){this.finalize();const t=Te(this,wn),e=Te(this,An),n=Te(this,Tn),r=Te(this,Sn),o=Te(this,En),s=Te(this,xn),u=Te(this,kn),c=Te(this,On),m=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,o>>24&255,o>>16&255,o>>8&255,o&255,s>>24&255,s>>16&255,s>>8&255,s&255,u>>24&255,u>>16&255,u>>8&255,u&255];return Te(this,li)||m.push(c>>24&255,c>>16&255,c>>8&255,c&255),m}array(){return this.digest()}arrayBuffer(){this.finalize();const t=new ArrayBuffer(Te(this,li)?28:32),e=new DataView(t);return e.setUint32(0,Te(this,wn)),e.setUint32(4,Te(this,An)),e.setUint32(8,Te(this,Tn)),e.setUint32(12,Te(this,Sn)),e.setUint32(16,Te(this,En)),e.setUint32(20,Te(this,xn)),e.setUint32(24,Te(this,kn)),Te(this,li)||e.setUint32(28,Te(this,On)),t}}ai=new WeakMap,Ai=new WeakMap,on=new WeakMap,ji=new WeakMap,lo=new WeakMap,wn=new WeakMap,An=new WeakMap,Tn=new WeakMap,Sn=new WeakMap,En=new WeakMap,xn=new WeakMap,kn=new WeakMap,On=new WeakMap,Ti=new WeakMap,Ui=new WeakMap,li=new WeakMap,es=new WeakMap,ui=new WeakMap;function nd(i){const t=new td;return t.update(i),parseInt(t.hex().substring(0,8),16)}const rd=function(i){var t="#";return i.forEach(function(e){e<16&&(t+=0),t+=e.toString(16)}),t},id=function(i,t,e){i/=360;var n=e<.5?e*(1+t):e+t-e*t,r=2*e-n;return[i+1/3,i,i-1/3].map(function(o){return o<0&&o++,o>1&&o--,o<1/6?o=r+(n-r)*6*o:o<.5?o=n:o<2/3?o=r+(n-r)*6*(2/3-o):o=r,Math.round(o*255)})};class od{constructor(t={}){const[e,n]=[t.lightness,t.saturation].map(function(r){return r=r!==void 0?r:[.35,.5,.65],Array.isArray(r)?r.concat():[r]});this.L=e,this.S=n,typeof t.hue=="number"&&(t.hue={min:t.hue,max:t.hue}),typeof t.hue=="object"&&!Array.isArray(t.hue)&&(t.hue=[t.hue]),typeof t.hue>"u"&&(t.hue=[]),this.hueRanges=t.hue.map(function(r){return{min:typeof r.min>"u"?0:r.min,max:typeof r.max>"u"?360:r.max}}),this.hash=nd,typeof t.hash=="function"&&(this.hash=t.hash),t.hash==="bkdr"&&(this.hash=Qh)}hsl(t){var e,n,r,o=this.hash(t),s=727;if(this.hueRanges.length){const u=this.hueRanges[o%this.hueRanges.length];e=o/this.hueRanges.length%s*(u.max-u.min)/s+u.min}else e=o%359;return o=Math.ceil(o/360),n=this.S[o%this.S.length],o=Math.ceil(o/this.S.length),r=this.L[o%this.L.length],[e,n,r]}rgb(t){var e=this.hsl(t);return id.apply(this,e)}hex(t){var e=this.rgb(t);return rd(e)}}const Si={isOnline:!1,showOffline:i=>{Si.isOnline=!1,i.innerHTML=' '},showOnline:i=>{Si.isOnline=!0,i.innerHTML=' '},statusListener:i=>t=>{Si.isOnline&&t.value==xo.Disconnected?Si.showOffline(i):!Si.isOnline&&t.value==xo.Connected&&Si.showOnline(i)}};function sd(i,t,e){const n=[];for(const{clientID:r,presence:o}of t)n.push(e===r?`${o.username}`:o.username);i.innerHTML=JSON.stringify(n)}function Pl(i,t,e){i.innerText=e.toJSON(),t.innerText=e.getRoot().content.toTestString()}const ad=document.getElementById("peers"),Cl=document.getElementById("document"),Ll=document.getElementById("document-text"),ld=document.getElementById("network-status"),ud=new od,cd=`vanilla-quill-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`;function Vs(i){const{embed:t,...e}=i.attributes??{};return t?{insert:t,attributes:e}:{insert:i.content||"",attributes:i.attributes}}async function fd(){const i=new zs.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"});await i.activate();const t=new zs.Document(cd,{enableDevtools:!0});t.subscribe("connection",c=>{Si.statusListener(ld)(c)}),t.subscribe("presence",c=>{c.type!==ft.PresenceChanged&&sd(ad,t.getPresences(),i.getID())}),await i.attach(t,{initialPresence:{username:i.getID().slice(-2),color:ud.hex(i.getID().slice(-2)),selection:void 0}}),t.update(c=>{c.content||(c.content=new zs.Text,c.content.edit(0,0,` +`))},"create content if not exists"),t.subscribe(c=>{c.type==="snapshot"&&u(),Pl(Cl,Ll,t)}),t.subscribe("$.content",c=>{c.type==="remote-change"&&s(c.value.operations),n()}),t.subscribe("others",c=>{c.type===ft.Unwatched?o.removeCursor(c.value.clientID):c.type===ft.PresenceChanged&&e(c.value)});function e(c){const{clientID:m,presence:y}=c;if(m===i.getID()||!y)return;const{username:f,color:l,selection:a}=y;if(!a)return;const p=t.getRoot().content.posRangeToIndexRange(a);o.createCursor(m,f,l),o.moveCursor(m,{index:p[0],length:p[1]-p[0]})}function n(){for(const c of t.getPresences())e(c)}await i.sync(),_l.register("modules/cursors",Xh);const r=new _l("#editor",{modules:{toolbar:[["bold","italic","underline","strike"],["blockquote","code-block"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["image","video"],["clean"]],cursors:!0},theme:"snow"}),o=r.getModule("cursors");r.on("text-change",(c,m,y)=>{if(y==="api"||!c.ops)return;let f=0,l=0;console.log(`%c quill: ${JSON.stringify(c.ops)}`,"color: green");for(const a of c.ops)a.attributes!==void 0||a.insert!==void 0?(a.retain!==void 0&&(l=f+a.retain),console.log(`%c local: ${f}-${l}: ${a.insert} ${a.attributes?JSON.stringify(a.attributes):"{}"}`,"color: green"),t.update((p,b)=>{let w;a.attributes!==void 0&&a.insert===void 0?p.content.setStyle(f,l,a.attributes):a.insert!==void 0&&(l{const w=p.content.edit(f,l,"");w&&b.set({selection:p.content.indexRangeToPosRange(w)})},`update content by ${i.getID()}`)):a.retain!==void 0&&(f=l+a.retain,l=f)}).on("selection-change",(c,m,y)=>{if(c){if(y==="api"){const{selection:f}=t.getMyPresence();if(f){const[l,a]=t.getRoot().content.posRangeToIndexRange(f),{index:p,length:b}=c;if(l===p&&a===p+b)return}}t.update((f,l)=>{l.set({selection:f.content.indexRangeToPosRange([c.index,c.index+c.length])})},`update selection by ${i.getID()}`)}});function s(c){const m=[];let y=0;for(const f of c)if(f.type==="edit"){const l=f.from,a=f.to,p=l-y,b=a-l,{insert:w,attributes:v}=Vs(f.value);if(console.log(`%c remote: ${l}-${a}: ${w}`,"color: skyblue"),p&&m.push({retain:p}),b&&m.push({delete:b}),w){const h={insert:w};v&&(h.attributes=v),m.push(h)}y=a}else if(f.type==="style"){const l=f.from,a=f.to,p=l-y,b=a-l,{attributes:w}=Vs(f.value);if(console.log(`%c remote: ${l}-${a}: ${JSON.stringify(w)}`,"color: skyblue"),p&&m.push({retain:p}),w){const v={attributes:w};b&&(v.retain=b),m.push(v)}y=a}if(m.length){console.log(`%c to quill: ${JSON.stringify(m)}`,"color: green");const f={ops:m};r.updateContents(f,"api")}}function u(){const m={ops:t.getRoot().content.values().map(y=>Vs(y))};r.setContents(m,"api")}u(),n(),Pl(Cl,Ll,t)}fd(); diff --git a/examples/vanilla-quill/index.html b/examples/vanilla-quill/index.html index 1a90097a1..726213481 100644 --- a/examples/vanilla-quill/index.html +++ b/examples/vanilla-quill/index.html @@ -4,7 +4,7 @@ Yorkie + Quill Example - + diff --git a/examples/vuejs-kanban/assets/index-CvxEjgCh.js b/examples/vuejs-kanban/assets/index-C3LyZcN6.js similarity index 74% rename from examples/vuejs-kanban/assets/index-CvxEjgCh.js rename to examples/vuejs-kanban/assets/index-C3LyZcN6.js index 75664e44f..cb1af13f1 100644 --- a/examples/vuejs-kanban/assets/index-CvxEjgCh.js +++ b/examples/vuejs-kanban/assets/index-C3LyZcN6.js @@ -1,6 +1,6 @@ -var Qf=Object.defineProperty;var eh=(n,e,t)=>e in n?Qf(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>eh(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function Pa(n,e){const t=Object.create(null),r=n.split(",");for(let s=0;s!!t[s]}const ue={},es=[],qt=()=>{},th=()=>!1,nh=/^on[^a-z]/,io=n=>nh.test(n),Oa=n=>n.startsWith("onUpdate:"),ke=Object.assign,Da=(n,e)=>{const t=n.indexOf(e);t>-1&&n.splice(t,1)},rh=Object.prototype.hasOwnProperty,Z=(n,e)=>rh.call(n,e),j=Array.isArray,ts=n=>oo(n)==="[object Map]",Yu=n=>oo(n)==="[object Set]",_=n=>typeof n=="function",Ae=n=>typeof n=="string",Ba=n=>typeof n=="symbol",de=n=>n!==null&&typeof n=="object",Xu=n=>de(n)&&_(n.then)&&_(n.catch),Zu=Object.prototype.toString,oo=n=>Zu.call(n),sh=n=>oo(n).slice(8,-1),Qu=n=>oo(n)==="[object Object]",Ra=n=>Ae(n)&&n!=="NaN"&&n[0]!=="-"&&""+parseInt(n,10)===n,vi=Pa(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),ao=n=>{const e=Object.create(null);return t=>e[t]||(e[t]=n(t))},ih=/-(\w)/g,as=ao(n=>n.replace(ih,(e,t)=>t?t.toUpperCase():"")),oh=/\B([A-Z])/g,Kr=ao(n=>n.replace(oh,"-$1").toLowerCase()),el=ao(n=>n.charAt(0).toUpperCase()+n.slice(1)),xo=ao(n=>n?`on${el(n)}`:""),Pi=(n,e)=>!Object.is(n,e),wi=(n,e)=>{for(let t=0;t{Object.defineProperty(n,e,{configurable:!0,enumerable:!1,value:t})},qo=n=>{const e=parseFloat(n);return isNaN(e)?n:e};let kc;const zo=()=>kc||(kc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Fa(n){if(j(n)){const e={};for(let t=0;t{if(t){const r=t.split(ch);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function La(n){let e="";if(Ae(n))e=n;else if(j(n))for(let t=0;tAe(n)?n:n==null?"":j(n)||de(n)&&(n.toString===Zu||!_(n.toString))?JSON.stringify(n,nl,2):String(n),nl=(n,e)=>e&&e.__v_isRef?nl(n,e.value):ts(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((t,[r,s])=>(t[`${r} =>`]=s,t),{})}:Yu(e)?{[`Set(${e.size})`]:[...e.values()]}:de(e)&&!j(e)&&!Qu(e)?String(e):e;let ht;class dh{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=ht,!e&&ht&&(this.index=(ht.scopes||(ht.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const t=ht;try{return ht=this,e()}finally{ht=t}}}on(){ht=this}off(){ht=this.parent}stop(e){if(this._active){let t,r;for(t=0,r=this.effects.length;t{const e=new Set(n);return e.w=0,e.n=0,e},rl=n=>(n.w&wr)>0,sl=n=>(n.n&wr)>0,ph=({deps:n})=>{if(n.length)for(let e=0;e{const{deps:e}=n;if(e.length){let t=0;for(let r=0;r{(h==="length"||h>=u)&&a.push(l)})}else switch(t!==void 0&&a.push(o.get(t)),e){case"add":j(n)?Ra(t)&&a.push(o.get("length")):(a.push(o.get(Fr)),ts(n)&&a.push(o.get(jo)));break;case"delete":j(n)||(a.push(o.get(Fr)),ts(n)&&a.push(o.get(jo)));break;case"set":ts(n)&&a.push(o.get(Fr));break}if(a.length===1)a[0]&&Wo(a[0]);else{const u=[];for(const l of a)l&&u.push(...l);Wo(Ja(u))}}function Wo(n,e){const t=j(n)?n:[...n];for(const r of t)r.computed&&Nc(r);for(const r of t)r.computed||Nc(r)}function Nc(n,e){(n!==gt||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const vh=Pa("__proto__,__v_isRef,__isVue"),al=new Set(Object.getOwnPropertyNames(Symbol).filter(n=>n!=="arguments"&&n!=="caller").map(n=>Symbol[n]).filter(Ba)),wh=$a(),bh=$a(!1,!0),Th=$a(!0),Pc=Ah();function Ah(){const n={};return["includes","indexOf","lastIndexOf"].forEach(e=>{n[e]=function(...t){const r=re(this);for(let i=0,o=this.length;i{n[e]=function(...t){vs();const r=re(this)[e].apply(this,t);return ws(),r}}),n}function Ih(n){const e=re(this);return qe(e,"has",n),e.hasOwnProperty(n)}function $a(n=!1,e=!1){return function(r,s,i){if(s==="__v_isReactive")return!n;if(s==="__v_isReadonly")return n;if(s==="__v_isShallow")return e;if(s==="__v_raw"&&i===(n?e?$h:hl:e?fl:ll).get(r))return r;const o=j(r);if(!n){if(o&&Z(Pc,s))return Reflect.get(Pc,s,i);if(s==="hasOwnProperty")return Ih}const a=Reflect.get(r,s,i);return(Ba(s)?al.has(s):vh(s))||(n||qe(r,"get",s),e)?a:Je(a)?o&&Ra(s)?a:a.value:de(a)?n?dl(a):za(a):a}}const Sh=cl(),xh=cl(!0);function cl(n=!1){return function(t,r,s,i){let o=t[r];if(Fs(o)&&Je(o)&&!Je(s))return!1;if(!n&&(!Ho(s)&&!Fs(s)&&(o=re(o),s=re(s)),!j(t)&&Je(o)&&!Je(s)))return o.value=s,!0;const a=j(t)&&Ra(r)?Number(r)n,co=n=>Reflect.getPrototypeOf(n);function ii(n,e,t=!1,r=!1){n=n.__v_raw;const s=re(n),i=re(e);t||(e!==i&&qe(s,"get",e),qe(s,"get",i));const{has:o}=co(s),a=r?Ua:t?ja:Va;if(o.call(s,e))return a(n.get(e));if(o.call(s,i))return a(n.get(i));n!==s&&n.get(e)}function oi(n,e=!1){const t=this.__v_raw,r=re(t),s=re(n);return e||(n!==s&&qe(r,"has",n),qe(r,"has",s)),n===s?t.has(n):t.has(n)||t.has(s)}function ai(n,e=!1){return n=n.__v_raw,!e&&qe(re(n),"iterate",Fr),Reflect.get(n,"size",n)}function Oc(n){n=re(n);const e=re(this);return co(e).has.call(e,n)||(e.add(n),nr(e,"add",n,n)),this}function Dc(n,e){e=re(e);const t=re(this),{has:r,get:s}=co(t);let i=r.call(t,n);i||(n=re(n),i=r.call(t,n));const o=s.call(t,n);return t.set(n,e),i?Pi(e,o)&&nr(t,"set",n,e):nr(t,"add",n,e),this}function Bc(n){const e=re(this),{has:t,get:r}=co(e);let s=t.call(e,n);s||(n=re(n),s=t.call(e,n)),r&&r.call(e,n);const i=e.delete(n);return s&&nr(e,"delete",n,void 0),i}function Rc(){const n=re(this),e=n.size!==0,t=n.clear();return e&&nr(n,"clear",void 0,void 0),t}function ci(n,e){return function(r,s){const i=this,o=i.__v_raw,a=re(o),u=e?Ua:n?ja:Va;return!n&&qe(a,"iterate",Fr),o.forEach((l,h)=>r.call(s,u(l),u(h),i))}}function ui(n,e,t){return function(...r){const s=this.__v_raw,i=re(s),o=ts(i),a=n==="entries"||n===Symbol.iterator&&o,u=n==="keys"&&o,l=s[n](...r),h=t?Ua:e?ja:Va;return!e&&qe(i,"iterate",u?jo:Fr),{next(){const{value:d,done:v}=l.next();return v?{value:d,done:v}:{value:a?[h(d[0]),h(d[1])]:h(d),done:v}},[Symbol.iterator](){return this}}}}function ar(n){return function(...e){return n==="delete"?!1:this}}function Oh(){const n={get(i){return ii(this,i)},get size(){return ai(this)},has:oi,add:Oc,set:Dc,delete:Bc,clear:Rc,forEach:ci(!1,!1)},e={get(i){return ii(this,i,!1,!0)},get size(){return ai(this)},has:oi,add:Oc,set:Dc,delete:Bc,clear:Rc,forEach:ci(!1,!0)},t={get(i){return ii(this,i,!0)},get size(){return ai(this,!0)},has(i){return oi.call(this,i,!0)},add:ar("add"),set:ar("set"),delete:ar("delete"),clear:ar("clear"),forEach:ci(!0,!1)},r={get(i){return ii(this,i,!0,!0)},get size(){return ai(this,!0)},has(i){return oi.call(this,i,!0)},add:ar("add"),set:ar("set"),delete:ar("delete"),clear:ar("clear"),forEach:ci(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(i=>{n[i]=ui(i,!1,!1),t[i]=ui(i,!0,!1),e[i]=ui(i,!1,!0),r[i]=ui(i,!0,!0)}),[n,t,e,r]}const[Dh,Bh,Rh,Fh]=Oh();function qa(n,e){const t=e?n?Fh:Rh:n?Bh:Dh;return(r,s,i)=>s==="__v_isReactive"?!n:s==="__v_isReadonly"?n:s==="__v_raw"?r:Reflect.get(Z(t,s)&&s in r?t:r,s,i)}const Lh={get:qa(!1,!1)},Jh={get:qa(!1,!0)},Mh={get:qa(!0,!1)},ll=new WeakMap,fl=new WeakMap,hl=new WeakMap,$h=new WeakMap;function Uh(n){switch(n){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function qh(n){return n.__v_skip||!Object.isExtensible(n)?0:Uh(sh(n))}function za(n){return Fs(n)?n:Ka(n,!1,ul,Lh,ll)}function zh(n){return Ka(n,!1,Ph,Jh,fl)}function dl(n){return Ka(n,!0,Nh,Mh,hl)}function Ka(n,e,t,r,s){if(!de(n)||n.__v_raw&&!(e&&n.__v_isReactive))return n;const i=s.get(n);if(i)return i;const o=qh(n);if(o===0)return n;const a=new Proxy(n,o===2?r:t);return s.set(n,a),a}function ns(n){return Fs(n)?ns(n.__v_raw):!!(n&&n.__v_isReactive)}function Fs(n){return!!(n&&n.__v_isReadonly)}function Ho(n){return!!(n&&n.__v_isShallow)}function gl(n){return ns(n)||Fs(n)}function re(n){const e=n&&n.__v_raw;return e?re(e):n}function ml(n){return Oi(n,"__v_skip",!0),n}const Va=n=>de(n)?za(n):n,ja=n=>de(n)?dl(n):n;function Kh(n){gr&>&&(n=re(n),ol(n.dep||(n.dep=Ja())))}function Vh(n,e){n=re(n);const t=n.dep;t&&Wo(t)}function Je(n){return!!(n&&n.__v_isRef===!0)}function jh(n){return Je(n)?n.value:n}const Wh={get:(n,e,t)=>jh(Reflect.get(n,e,t)),set:(n,e,t,r)=>{const s=n[e];return Je(s)&&!Je(t)?(s.value=t,!0):Reflect.set(n,e,t,r)}};function pl(n){return ns(n)?n:new Proxy(n,Wh)}class Hh{constructor(e,t,r,s){this._setter=t,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new Ma(e,()=>{this._dirty||(this._dirty=!0,Vh(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=r}get value(){const e=re(this);return Kh(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}function Gh(n,e,t=!1){let r,s;const i=_(n);return i?(r=n,s=qt):(r=n.get,s=n.set),new Hh(r,s,i||!s,t)}function mr(n,e,t,r){let s;try{s=r?n(...r):n()}catch(i){uo(i,e,t)}return s}function wt(n,e,t,r){if(_(n)){const i=mr(n,e,t,r);return i&&Xu(i)&&i.catch(o=>{uo(o,e,t)}),i}const s=[];for(let i=0;i>>1;Js(Ne[r])Pt&&Ne.splice(e,1)}function Qh(n){j(n)?rs.push(...n):(!Gt||!Gt.includes(n,n.allowRecurse?Pr+1:Pr))&&rs.push(n),vl()}function Fc(n,e=Ls?Pt+1:0){for(;eJs(t)-Js(r)),Pr=0;Prn.id==null?1/0:n.id,ed=(n,e)=>{const t=Js(n)-Js(e);if(t===0){if(n.pre&&!e.pre)return-1;if(e.pre&&!n.pre)return 1}return t};function bl(n){Go=!1,Ls=!0,Ne.sort(ed);try{for(Pt=0;PtAe(p)?p.trim():p)),d&&(s=t.map(qo))}let a,u=r[a=xo(e)]||r[a=xo(as(e))];!u&&i&&(u=r[a=xo(Kr(e))]),u&&wt(u,n,6,s);const l=r[a+"Once"];if(l){if(!n.emitted)n.emitted={};else if(n.emitted[a])return;n.emitted[a]=!0,wt(l,n,6,s)}}function Tl(n,e,t=!1){const r=e.emitsCache,s=r.get(n);if(s!==void 0)return s;const i=n.emits;let o={},a=!1;if(!_(n)){const u=l=>{const h=Tl(l,e,!0);h&&(a=!0,ke(o,h))};!t&&e.mixins.length&&e.mixins.forEach(u),n.extends&&u(n.extends),n.mixins&&n.mixins.forEach(u)}return!i&&!a?(de(n)&&r.set(n,null),null):(j(i)?i.forEach(u=>o[u]=null):ke(o,i),de(n)&&r.set(n,o),o)}function lo(n,e){return!n||!io(e)?!1:(e=e.slice(2).replace(/Once$/,""),Z(n,e[0].toLowerCase()+e.slice(1))||Z(n,Kr(e))||Z(n,e))}let mt=null,Al=null;function Di(n){const e=mt;return mt=n,Al=n&&n.type.__scopeId||null,e}function nd(n,e=mt,t){if(!e||n._n)return n;const r=(...s)=>{r._d&&Hc(-1);const i=Di(e);let o;try{o=n(...s)}finally{Di(i),r._d&&Hc(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function ko(n){const{type:e,vnode:t,proxy:r,withProxy:s,props:i,propsOptions:[o],slots:a,attrs:u,emit:l,render:h,renderCache:d,data:v,setupState:p,ctx:A,inheritAttrs:I}=n;let D,L;const $=Di(n);try{if(t.shapeFlag&4){const U=s||r;D=Nt(h.call(U,U,d,i,p,v,A)),L=u}else{const U=e;D=Nt(U.length>1?U(i,{attrs:u,slots:a,emit:l}):U(i,null)),L=e.props?u:rd(u)}}catch(U){Ns.length=0,uo(U,n,1),D=Lr(Ms)}let V=D;if(L&&I!==!1){const U=Object.keys(L),{shapeFlag:W}=V;U.length&&W&7&&(o&&U.some(Oa)&&(L=sd(L,o)),V=cs(V,L))}return t.dirs&&(V=cs(V),V.dirs=V.dirs?V.dirs.concat(t.dirs):t.dirs),t.transition&&(V.transition=t.transition),D=V,Di($),D}const rd=n=>{let e;for(const t in n)(t==="class"||t==="style"||io(t))&&((e||(e={}))[t]=n[t]);return e},sd=(n,e)=>{const t={};for(const r in n)(!Oa(r)||!(r.slice(9)in e))&&(t[r]=n[r]);return t};function id(n,e,t){const{props:r,children:s,component:i}=n,{props:o,children:a,patchFlag:u}=e,l=i.emitsOptions;if(e.dirs||e.transition)return!0;if(t&&u>=0){if(u&1024)return!0;if(u&16)return r?Lc(r,o,l):!!o;if(u&8){const h=e.dynamicProps;for(let d=0;dn.__isSuspense;function cd(n,e){e&&e.pendingBranch?j(n)?e.effects.push(...n):e.effects.push(n):Qh(n)}const li={};function Eo(n,e,t){return Il(n,e,t)}function Il(n,e,{immediate:t,deep:r,flush:s,onTrack:i,onTrigger:o}=ue){var a;const u=mh()===((a=Pe)==null?void 0:a.scope)?Pe:null;let l,h=!1,d=!1;if(Je(n)?(l=()=>n.value,h=Ho(n)):ns(n)?(l=()=>n,r=!0):j(n)?(d=!0,h=n.some(U=>ns(U)||Ho(U)),l=()=>n.map(U=>{if(Je(U))return U.value;if(ns(U))return Dr(U);if(_(U))return mr(U,u,2)})):_(n)?e?l=()=>mr(n,u,2):l=()=>{if(!(u&&u.isUnmounted))return v&&v(),wt(n,u,3,[p])}:l=qt,e&&r){const U=l;l=()=>Dr(U())}let v,p=U=>{v=$.onStop=()=>{mr(U,u,4)}},A;if(Us)if(p=qt,e?t&&wt(e,u,3,[l(),d?[]:void 0,p]):l(),s==="sync"){const U=rg();A=U.__watcherHandles||(U.__watcherHandles=[])}else return qt;let I=d?new Array(n.length).fill(li):li;const D=()=>{if($.active)if(e){const U=$.run();(r||h||(d?U.some((W,ee)=>Pi(W,I[ee])):Pi(U,I)))&&(v&&v(),wt(e,u,3,[U,I===li?void 0:d&&I[0]===li?[]:I,p]),I=U)}else $.run()};D.allowRecurse=!!e;let L;s==="sync"?L=D:s==="post"?L=()=>Me(D,u&&u.suspense):(D.pre=!0,u&&(D.id=u.uid),L=()=>Ha(D));const $=new Ma(l,L);e?t?D():I=$.run():s==="post"?Me($.run.bind($),u&&u.suspense):$.run();const V=()=>{$.stop(),u&&u.scope&&Da(u.scope.effects,$)};return A&&A.push(V),V}function ud(n,e,t){const r=this.proxy,s=Ae(n)?n.includes(".")?Sl(r,n):()=>r[n]:n.bind(r,r);let i;_(e)?i=e:(i=e.handler,t=e);const o=Pe;us(this);const a=Il(s,i.bind(r),t);return o?us(o):Jr(),a}function Sl(n,e){const t=e.split(".");return()=>{let r=n;for(let s=0;s{Dr(t,e)});else if(Qu(n))for(const t in n)Dr(n[t],e);return n}function Jc(n,e){const t=mt;if(t===null)return n;const r=mo(t)||t.proxy,s=n.dirs||(n.dirs=[]);for(let i=0;i!!n.type.__asyncLoader,xl=n=>n.type.__isKeepAlive;function ld(n,e){kl(n,"a",e)}function fd(n,e){kl(n,"da",e)}function kl(n,e,t=Pe){const r=n.__wdc||(n.__wdc=()=>{let s=t;for(;s;){if(s.isDeactivated)return;s=s.parent}return n()});if(fo(e,r,t),t){let s=t.parent;for(;s&&s.parent;)xl(s.parent.vnode)&&hd(r,e,t,s),s=s.parent}}function hd(n,e,t,r){const s=fo(e,n,r,!0);El(()=>{Da(r[e],s)},t)}function fo(n,e,t=Pe,r=!1){if(t){const s=t[n]||(t[n]=[]),i=e.__weh||(e.__weh=(...o)=>{if(t.isUnmounted)return;vs(),us(t);const a=wt(e,t,n,o);return Jr(),ws(),a});return r?s.unshift(i):s.push(i),i}}const ir=n=>(e,t=Pe)=>(!Us||n==="sp")&&fo(n,(...r)=>e(...r),t),dd=ir("bm"),gd=ir("m"),md=ir("bu"),pd=ir("u"),yd=ir("bum"),El=ir("um"),vd=ir("sp"),wd=ir("rtg"),bd=ir("rtc");function Td(n,e=Pe){fo("ec",n,e)}const Ad=Symbol.for("v-ndc");function Mc(n,e,t,r){let s;const i=t;if(j(n)||Ae(n)){s=new Array(n.length);for(let o=0,a=n.length;oe(o,a,void 0,i));else{const o=Object.keys(n);s=new Array(o.length);for(let a=0,u=o.length;an?Ml(n)?mo(n)||n.proxy:_o(n.parent):null,Cs=ke(Object.create(null),{$:n=>n,$el:n=>n.vnode.el,$data:n=>n.data,$props:n=>n.props,$attrs:n=>n.attrs,$slots:n=>n.slots,$refs:n=>n.refs,$parent:n=>_o(n.parent),$root:n=>_o(n.root),$emit:n=>n.emit,$options:n=>Ga(n),$forceUpdate:n=>n.f||(n.f=()=>Ha(n.update)),$nextTick:n=>n.n||(n.n=Yh.bind(n.proxy)),$watch:n=>ud.bind(n)}),Co=(n,e)=>n!==ue&&!n.__isScriptSetup&&Z(n,e),Id={get({_:n},e){const{ctx:t,setupState:r,data:s,props:i,accessCache:o,type:a,appContext:u}=n;let l;if(e[0]!=="$"){const p=o[e];if(p!==void 0)switch(p){case 1:return r[e];case 2:return s[e];case 4:return t[e];case 3:return i[e]}else{if(Co(r,e))return o[e]=1,r[e];if(s!==ue&&Z(s,e))return o[e]=2,s[e];if((l=n.propsOptions[0])&&Z(l,e))return o[e]=3,i[e];if(t!==ue&&Z(t,e))return o[e]=4,t[e];Yo&&(o[e]=0)}}const h=Cs[e];let d,v;if(h)return e==="$attrs"&&qe(n,"get",e),h(n);if((d=a.__cssModules)&&(d=d[e]))return d;if(t!==ue&&Z(t,e))return o[e]=4,t[e];if(v=u.config.globalProperties,Z(v,e))return v[e]},set({_:n},e,t){const{data:r,setupState:s,ctx:i}=n;return Co(s,e)?(s[e]=t,!0):r!==ue&&Z(r,e)?(r[e]=t,!0):Z(n.props,e)||e[0]==="$"&&e.slice(1)in n?!1:(i[e]=t,!0)},has({_:{data:n,setupState:e,accessCache:t,ctx:r,appContext:s,propsOptions:i}},o){let a;return!!t[o]||n!==ue&&Z(n,o)||Co(e,o)||(a=i[0])&&Z(a,o)||Z(r,o)||Z(Cs,o)||Z(s.config.globalProperties,o)},defineProperty(n,e,t){return t.get!=null?n._.accessCache[e]=0:Z(t,"value")&&this.set(n,e,t.value,null),Reflect.defineProperty(n,e,t)}};function $c(n){return j(n)?n.reduce((e,t)=>(e[t]=null,e),{}):n}let Yo=!0;function Sd(n){const e=Ga(n),t=n.proxy,r=n.ctx;Yo=!1,e.beforeCreate&&Uc(e.beforeCreate,n,"bc");const{data:s,computed:i,methods:o,watch:a,provide:u,inject:l,created:h,beforeMount:d,mounted:v,beforeUpdate:p,updated:A,activated:I,deactivated:D,beforeDestroy:L,beforeUnmount:$,destroyed:V,unmounted:U,render:W,renderTracked:ee,renderTriggered:oe,errorCaptured:te,serverPrefetch:Ee,expose:Ie,inheritAttrs:Ge,components:Ir,directives:ni,filters:So}=e;if(l&&xd(l,r,null),o)for(const ge in o){const ae=o[ge];_(ae)&&(r[ge]=ae.bind(t))}if(s){const ge=s.call(t,t);de(ge)&&(n.data=za(ge))}if(Yo=!0,i)for(const ge in i){const ae=i[ge],Sr=_(ae)?ae.bind(t,t):_(ae.get)?ae.get.bind(t,t):qt,ri=!_(ae)&&_(ae.set)?ae.set.bind(t):qt,xr=tg({get:Sr,set:ri});Object.defineProperty(r,ge,{enumerable:!0,configurable:!0,get:()=>xr.value,set:St=>xr.value=St})}if(a)for(const ge in a)Cl(a[ge],r,t,ge);if(u){const ge=_(u)?u.call(t):u;Reflect.ownKeys(ge).forEach(ae=>{Od(ae,ge[ae])})}h&&Uc(h,n,"c");function De(ge,ae){j(ae)?ae.forEach(Sr=>ge(Sr.bind(t))):ae&&ge(ae.bind(t))}if(De(dd,d),De(gd,v),De(md,p),De(pd,A),De(ld,I),De(fd,D),De(Td,te),De(bd,ee),De(wd,oe),De(yd,$),De(El,U),De(vd,Ee),j(Ie))if(Ie.length){const ge=n.exposed||(n.exposed={});Ie.forEach(ae=>{Object.defineProperty(ge,ae,{get:()=>t[ae],set:Sr=>t[ae]=Sr})})}else n.exposed||(n.exposed={});W&&n.render===qt&&(n.render=W),Ge!=null&&(n.inheritAttrs=Ge),Ir&&(n.components=Ir),ni&&(n.directives=ni)}function xd(n,e,t=qt){j(n)&&(n=Xo(n));for(const r in n){const s=n[r];let i;de(s)?"default"in s?i=Ti(s.from||r,s.default,!0):i=Ti(s.from||r):i=Ti(s),Je(i)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[r]=i}}function Uc(n,e,t){wt(j(n)?n.map(r=>r.bind(e.proxy)):n.bind(e.proxy),e,t)}function Cl(n,e,t,r){const s=r.includes(".")?Sl(t,r):()=>t[r];if(Ae(n)){const i=e[n];_(i)&&Eo(s,i)}else if(_(n))Eo(s,n.bind(t));else if(de(n))if(j(n))n.forEach(i=>Cl(i,e,t,r));else{const i=_(n.handler)?n.handler.bind(t):e[n.handler];_(i)&&Eo(s,i,n)}}function Ga(n){const e=n.type,{mixins:t,extends:r}=e,{mixins:s,optionsCache:i,config:{optionMergeStrategies:o}}=n.appContext,a=i.get(e);let u;return a?u=a:!s.length&&!t&&!r?u=e:(u={},s.length&&s.forEach(l=>Bi(u,l,o,!0)),Bi(u,e,o)),de(e)&&i.set(e,u),u}function Bi(n,e,t,r=!1){const{mixins:s,extends:i}=e;i&&Bi(n,i,t,!0),s&&s.forEach(o=>Bi(n,o,t,!0));for(const o in e)if(!(r&&o==="expose")){const a=kd[o]||t&&t[o];n[o]=a?a(n[o],e[o]):e[o]}return n}const kd={data:qc,props:zc,emits:zc,methods:ks,computed:ks,beforeCreate:Be,created:Be,beforeMount:Be,mounted:Be,beforeUpdate:Be,updated:Be,beforeDestroy:Be,beforeUnmount:Be,destroyed:Be,unmounted:Be,activated:Be,deactivated:Be,errorCaptured:Be,serverPrefetch:Be,components:ks,directives:ks,watch:Cd,provide:qc,inject:Ed};function qc(n,e){return e?n?function(){return ke(_(n)?n.call(this,this):n,_(e)?e.call(this,this):e)}:e:n}function Ed(n,e){return ks(Xo(n),Xo(e))}function Xo(n){if(j(n)){const e={};for(let t=0;t1)return t&&_(e)?e.call(r&&r.proxy):e}}function Dd(n,e,t,r=!1){const s={},i={};Oi(i,go,1),n.propsDefaults=Object.create(null),Pl(n,e,s,i);for(const o in n.propsOptions[0])o in s||(s[o]=void 0);t?n.props=r?s:zh(s):n.type.props?n.props=s:n.props=i,n.attrs=i}function Bd(n,e,t,r){const{props:s,attrs:i,vnode:{patchFlag:o}}=n,a=re(s),[u]=n.propsOptions;let l=!1;if((r||o>0)&&!(o&16)){if(o&8){const h=n.vnode.dynamicProps;for(let d=0;d{u=!0;const[v,p]=Ol(d,e,!0);ke(o,v),p&&a.push(...p)};!t&&e.mixins.length&&e.mixins.forEach(h),n.extends&&h(n.extends),n.mixins&&n.mixins.forEach(h)}if(!i&&!u)return de(n)&&r.set(n,es),es;if(j(i))for(let h=0;h-1,p[1]=I<0||A-1||Z(p,"default"))&&a.push(d)}}}const l=[o,a];return de(n)&&r.set(n,l),l}function Kc(n){return n[0]!=="$"}function Vc(n){const e=n&&n.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:n===null?"null":""}function jc(n,e){return Vc(n)===Vc(e)}function Wc(n,e){return j(e)?e.findIndex(t=>jc(t,n)):_(e)&&jc(e,n)?0:-1}const Dl=n=>n[0]==="_"||n==="$stable",_a=n=>j(n)?n.map(Nt):[Nt(n)],Rd=(n,e,t)=>{if(e._n)return e;const r=nd((...s)=>_a(e(...s)),t);return r._c=!1,r},Bl=(n,e,t)=>{const r=n._ctx;for(const s in n){if(Dl(s))continue;const i=n[s];if(_(i))e[s]=Rd(s,i,r);else if(i!=null){const o=_a(i);e[s]=()=>o}}},Rl=(n,e)=>{const t=_a(e);n.slots.default=()=>t},Fd=(n,e)=>{if(n.vnode.shapeFlag&32){const t=e._;t?(n.slots=re(e),Oi(e,"_",t)):Bl(e,n.slots={})}else n.slots={},e&&Rl(n,e);Oi(n.slots,go,1)},Ld=(n,e,t)=>{const{vnode:r,slots:s}=n;let i=!0,o=ue;if(r.shapeFlag&32){const a=e._;a?t&&a===1?i=!1:(ke(s,e),!t&&a===1&&delete s._):(i=!e.$stable,Bl(e,s)),o=e}else e&&(Rl(n,e),o={default:1});if(i)for(const a in s)!Dl(a)&&!(a in o)&&delete s[a]};function Qo(n,e,t,r,s=!1){if(j(n)){n.forEach((v,p)=>Qo(v,e&&(j(e)?e[p]:e),t,r,s));return}if(bi(r)&&!s)return;const i=r.shapeFlag&4?mo(r.component)||r.component.proxy:r.el,o=s?null:i,{i:a,r:u}=n,l=e&&e.r,h=a.refs===ue?a.refs={}:a.refs,d=a.setupState;if(l!=null&&l!==u&&(Ae(l)?(h[l]=null,Z(d,l)&&(d[l]=null)):Je(l)&&(l.value=null)),_(u))mr(u,a,12,[o,h]);else{const v=Ae(u),p=Je(u);if(v||p){const A=()=>{if(n.f){const I=v?Z(d,u)?d[u]:h[u]:u.value;s?j(I)&&Da(I,i):j(I)?I.includes(i)||I.push(i):v?(h[u]=[i],Z(d,u)&&(d[u]=h[u])):(u.value=[i],n.k&&(h[n.k]=u.value))}else v?(h[u]=o,Z(d,u)&&(d[u]=o)):p&&(u.value=o,n.k&&(h[n.k]=o))};o?(A.id=-1,Me(A,t)):A()}}}const Me=cd;function Jd(n){return Md(n)}function Md(n,e){const t=zo();t.__VUE__=!0;const{insert:r,remove:s,patchProp:i,createElement:o,createText:a,createComment:u,setText:l,setElementText:h,parentNode:d,nextSibling:v,setScopeId:p=qt,insertStaticContent:A}=n,I=(g,m,T,x=null,S=null,N=null,B=!1,C=null,O=!!m.dynamicChildren)=>{if(g===m)return;g&&!As(g,m)&&(x=si(g),St(g,S,N,!0),g=null),m.patchFlag===-2&&(O=!1,m.dynamicChildren=null);const{type:k,ref:q,shapeFlag:R}=m;switch(k){case ho:D(g,m,T,x);break;case Ms:L(g,m,T,x);break;case No:g==null&&$(m,T,x,B);break;case _e:Ir(g,m,T,x,S,N,B,C,O);break;default:R&1?W(g,m,T,x,S,N,B,C,O):R&6?ni(g,m,T,x,S,N,B,C,O):(R&64||R&128)&&k.process(g,m,T,x,S,N,B,C,O,bs)}q!=null&&S&&Qo(q,g&&g.ref,N,m||g,!m)},D=(g,m,T,x)=>{if(g==null)r(m.el=a(m.children),T,x);else{const S=m.el=g.el;m.children!==g.children&&l(S,m.children)}},L=(g,m,T,x)=>{g==null?r(m.el=u(m.children||""),T,x):m.el=g.el},$=(g,m,T,x)=>{[g.el,g.anchor]=A(g.children,m,T,x,g.el,g.anchor)},V=({el:g,anchor:m},T,x)=>{let S;for(;g&&g!==m;)S=v(g),r(g,T,x),g=S;r(m,T,x)},U=({el:g,anchor:m})=>{let T;for(;g&&g!==m;)T=v(g),s(g),g=T;s(m)},W=(g,m,T,x,S,N,B,C,O)=>{B=B||m.type==="svg",g==null?ee(m,T,x,S,N,B,C,O):Ee(g,m,S,N,B,C,O)},ee=(g,m,T,x,S,N,B,C)=>{let O,k;const{type:q,props:R,shapeFlag:z,transition:H,dirs:Y}=g;if(O=g.el=o(g.type,N,R&&R.is,R),z&8?h(O,g.children):z&16&&te(g.children,O,null,x,S,N&&q!=="foreignObject",B,C),Y&&kr(g,null,x,"created"),oe(O,g,g.scopeId,B,x),R){for(const se in R)se!=="value"&&!vi(se)&&i(O,se,null,R[se],N,g.children,x,S,Vt);"value"in R&&i(O,"value",null,R.value),(k=R.onVnodeBeforeMount)&&kt(k,x,g)}Y&&kr(g,null,x,"beforeMount");const ce=(!S||S&&!S.pendingBranch)&&H&&!H.persisted;ce&&H.beforeEnter(O),r(O,m,T),((k=R&&R.onVnodeMounted)||ce||Y)&&Me(()=>{k&&kt(k,x,g),ce&&H.enter(O),Y&&kr(g,null,x,"mounted")},S)},oe=(g,m,T,x,S)=>{if(T&&p(g,T),x)for(let N=0;N{for(let k=O;k{const C=m.el=g.el;let{patchFlag:O,dynamicChildren:k,dirs:q}=m;O|=g.patchFlag&16;const R=g.props||ue,z=m.props||ue;let H;T&&Er(T,!1),(H=z.onVnodeBeforeUpdate)&&kt(H,T,m,g),q&&kr(m,g,T,"beforeUpdate"),T&&Er(T,!0);const Y=S&&m.type!=="foreignObject";if(k?Ie(g.dynamicChildren,k,C,T,x,Y,N):B||ae(g,m,C,null,T,x,Y,N,!1),O>0){if(O&16)Ge(C,m,R,z,T,x,S);else if(O&2&&R.class!==z.class&&i(C,"class",null,z.class,S),O&4&&i(C,"style",R.style,z.style,S),O&8){const ce=m.dynamicProps;for(let se=0;se{H&&kt(H,T,m,g),q&&kr(m,g,T,"updated")},x)},Ie=(g,m,T,x,S,N,B)=>{for(let C=0;C{if(T!==x){if(T!==ue)for(const C in T)!vi(C)&&!(C in x)&&i(g,C,T[C],null,B,m.children,S,N,Vt);for(const C in x){if(vi(C))continue;const O=x[C],k=T[C];O!==k&&C!=="value"&&i(g,C,k,O,B,m.children,S,N,Vt)}"value"in x&&i(g,"value",T.value,x.value)}},Ir=(g,m,T,x,S,N,B,C,O)=>{const k=m.el=g?g.el:a(""),q=m.anchor=g?g.anchor:a("");let{patchFlag:R,dynamicChildren:z,slotScopeIds:H}=m;H&&(C=C?C.concat(H):H),g==null?(r(k,T,x),r(q,T,x),te(m.children,T,q,S,N,B,C,O)):R>0&&R&64&&z&&g.dynamicChildren?(Ie(g.dynamicChildren,z,T,S,N,B,C),(m.key!=null||S&&m===S.subTree)&&Fl(g,m,!0)):ae(g,m,T,q,S,N,B,C,O)},ni=(g,m,T,x,S,N,B,C,O)=>{m.slotScopeIds=C,g==null?m.shapeFlag&512?S.ctx.activate(m,T,x,B,O):So(m,T,x,S,N,B,O):vc(g,m,O)},So=(g,m,T,x,S,N,B)=>{const C=g.component=_d(g,x,S);if(xl(g)&&(C.ctx.renderer=bs),Yd(C),C.asyncDep){if(S&&S.registerDep(C,De),!g.el){const O=C.subTree=Lr(Ms);L(null,O,m,T)}return}De(C,g,m,T,S,N,B)},vc=(g,m,T)=>{const x=m.component=g.component;if(id(g,m,T))if(x.asyncDep&&!x.asyncResolved){ge(x,m,T);return}else x.next=m,Zh(x.update),x.update();else m.el=g.el,x.vnode=m},De=(g,m,T,x,S,N,B)=>{const C=()=>{if(g.isMounted){let{next:q,bu:R,u:z,parent:H,vnode:Y}=g,ce=q,se;Er(g,!1),q?(q.el=Y.el,ge(g,q,B)):q=Y,R&&wi(R),(se=q.props&&q.props.onVnodeBeforeUpdate)&&kt(se,H,q,Y),Er(g,!0);const we=ko(g),ft=g.subTree;g.subTree=we,I(ft,we,d(ft.el),si(ft),g,S,N),q.el=we.el,ce===null&&od(g,we.el),z&&Me(z,S),(se=q.props&&q.props.onVnodeUpdated)&&Me(()=>kt(se,H,q,Y),S)}else{let q;const{el:R,props:z}=m,{bm:H,m:Y,parent:ce}=g,se=bi(m);if(Er(g,!1),H&&wi(H),!se&&(q=z&&z.onVnodeBeforeMount)&&kt(q,ce,m),Er(g,!0),R&&Ac){const we=()=>{g.subTree=ko(g),Ac(R,g.subTree,g,S,null)};se?m.type.__asyncLoader().then(()=>!g.isUnmounted&&we()):we()}else{const we=g.subTree=ko(g);I(null,we,T,x,g,S,N),m.el=we.el}if(Y&&Me(Y,S),!se&&(q=z&&z.onVnodeMounted)){const we=m;Me(()=>kt(q,ce,we),S)}(m.shapeFlag&256||ce&&bi(ce.vnode)&&ce.vnode.shapeFlag&256)&&g.a&&Me(g.a,S),g.isMounted=!0,m=T=x=null}},O=g.effect=new Ma(C,()=>Ha(k),g.scope),k=g.update=()=>O.run();k.id=g.uid,Er(g,!0),k()},ge=(g,m,T)=>{m.component=g;const x=g.vnode.props;g.vnode=m,g.next=null,Bd(g,m.props,x,T),Ld(g,m.children,T),vs(),Fc(),ws()},ae=(g,m,T,x,S,N,B,C,O=!1)=>{const k=g&&g.children,q=g?g.shapeFlag:0,R=m.children,{patchFlag:z,shapeFlag:H}=m;if(z>0){if(z&128){ri(k,R,T,x,S,N,B,C,O);return}else if(z&256){Sr(k,R,T,x,S,N,B,C,O);return}}H&8?(q&16&&Vt(k,S,N),R!==k&&h(T,R)):q&16?H&16?ri(k,R,T,x,S,N,B,C,O):Vt(k,S,N,!0):(q&8&&h(T,""),H&16&&te(R,T,x,S,N,B,C,O))},Sr=(g,m,T,x,S,N,B,C,O)=>{g=g||es,m=m||es;const k=g.length,q=m.length,R=Math.min(k,q);let z;for(z=0;zq?Vt(g,S,N,!0,!1,R):te(m,T,x,S,N,B,C,O,R)},ri=(g,m,T,x,S,N,B,C,O)=>{let k=0;const q=m.length;let R=g.length-1,z=q-1;for(;k<=R&&k<=z;){const H=g[k],Y=m[k]=O?hr(m[k]):Nt(m[k]);if(As(H,Y))I(H,Y,T,null,S,N,B,C,O);else break;k++}for(;k<=R&&k<=z;){const H=g[R],Y=m[z]=O?hr(m[z]):Nt(m[z]);if(As(H,Y))I(H,Y,T,null,S,N,B,C,O);else break;R--,z--}if(k>R){if(k<=z){const H=z+1,Y=Hz)for(;k<=R;)St(g[k],S,N,!0),k++;else{const H=k,Y=k,ce=new Map;for(k=Y;k<=z;k++){const Ke=m[k]=O?hr(m[k]):Nt(m[k]);Ke.key!=null&&ce.set(Ke.key,k)}let se,we=0;const ft=z-Y+1;let jr=!1,Ic=0;const Ts=new Array(ft);for(k=0;k=ft){St(Ke,S,N,!0);continue}let xt;if(Ke.key!=null)xt=ce.get(Ke.key);else for(se=Y;se<=z;se++)if(Ts[se-Y]===0&&As(Ke,m[se])){xt=se;break}xt===void 0?St(Ke,S,N,!0):(Ts[xt-Y]=k+1,xt>=Ic?Ic=xt:jr=!0,I(Ke,m[xt],T,null,S,N,B,C,O),we++)}const Sc=jr?$d(Ts):es;for(se=Sc.length-1,k=ft-1;k>=0;k--){const Ke=Y+k,xt=m[Ke],xc=Ke+1{const{el:N,type:B,transition:C,children:O,shapeFlag:k}=g;if(k&6){xr(g.component.subTree,m,T,x);return}if(k&128){g.suspense.move(m,T,x);return}if(k&64){B.move(g,m,T,bs);return}if(B===_e){r(N,m,T);for(let R=0;RC.enter(N),S);else{const{leave:R,delayLeave:z,afterLeave:H}=C,Y=()=>r(N,m,T),ce=()=>{R(N,()=>{Y(),H&&H()})};z?z(N,Y,ce):ce()}else r(N,m,T)},St=(g,m,T,x=!1,S=!1)=>{const{type:N,props:B,ref:C,children:O,dynamicChildren:k,shapeFlag:q,patchFlag:R,dirs:z}=g;if(C!=null&&Qo(C,null,T,g,!0),q&256){m.ctx.deactivate(g);return}const H=q&1&&z,Y=!bi(g);let ce;if(Y&&(ce=B&&B.onVnodeBeforeUnmount)&&kt(ce,m,g),q&6)Zf(g.component,T,x);else{if(q&128){g.suspense.unmount(T,x);return}H&&kr(g,null,m,"beforeUnmount"),q&64?g.type.remove(g,m,T,S,bs,x):k&&(N!==_e||R>0&&R&64)?Vt(k,m,T,!1,!0):(N===_e&&R&384||!S&&q&16)&&Vt(O,m,T),x&&wc(g)}(Y&&(ce=B&&B.onVnodeUnmounted)||H)&&Me(()=>{ce&&kt(ce,m,g),H&&kr(g,null,m,"unmounted")},T)},wc=g=>{const{type:m,el:T,anchor:x,transition:S}=g;if(m===_e){Xf(T,x);return}if(m===No){U(g);return}const N=()=>{s(T),S&&!S.persisted&&S.afterLeave&&S.afterLeave()};if(g.shapeFlag&1&&S&&!S.persisted){const{leave:B,delayLeave:C}=S,O=()=>B(T,N);C?C(g.el,N,O):O()}else N()},Xf=(g,m)=>{let T;for(;g!==m;)T=v(g),s(g),g=T;s(m)},Zf=(g,m,T)=>{const{bum:x,scope:S,update:N,subTree:B,um:C}=g;x&&wi(x),S.stop(),N&&(N.active=!1,St(B,g,m,T)),C&&Me(C,m),Me(()=>{g.isUnmounted=!0},m),m&&m.pendingBranch&&!m.isUnmounted&&g.asyncDep&&!g.asyncResolved&&g.suspenseId===m.pendingId&&(m.deps--,m.deps===0&&m.resolve())},Vt=(g,m,T,x=!1,S=!1,N=0)=>{for(let B=N;Bg.shapeFlag&6?si(g.component.subTree):g.shapeFlag&128?g.suspense.next():v(g.anchor||g.el),bc=(g,m,T)=>{g==null?m._vnode&&St(m._vnode,null,null,!0):I(m._vnode||null,g,m,null,null,null,T),Fc(),wl(),m._vnode=g},bs={p:I,um:St,m:xr,r:wc,mt:So,mc:te,pc:ae,pbc:Ie,n:si,o:n};let Tc,Ac;return{render:bc,hydrate:Tc,createApp:Pd(bc,Tc)}}function Er({effect:n,update:e},t){n.allowRecurse=e.allowRecurse=t}function Fl(n,e,t=!1){const r=n.children,s=e.children;if(j(r)&&j(s))for(let i=0;i>1,n[t[a]]0&&(e[r]=t[i-1]),t[i]=r)}}for(i=t.length,o=t[i-1];i-- >0;)t[i]=o,o=e[o];return t}const Ud=n=>n.__isTeleport,_e=Symbol.for("v-fgt"),ho=Symbol.for("v-txt"),Ms=Symbol.for("v-cmt"),No=Symbol.for("v-stc"),Ns=[];let pt=null;function jt(n=!1){Ns.push(pt=n?null:[])}function qd(){Ns.pop(),pt=Ns[Ns.length-1]||null}let $s=1;function Hc(n){$s+=n}function zd(n){return n.dynamicChildren=$s>0?pt||es:null,qd(),$s>0&&pt&&pt.push(n),n}function Wt(n,e,t,r,s,i){return zd(Re(n,e,t,r,s,i,!0))}function Kd(n){return n?n.__v_isVNode===!0:!1}function As(n,e){return n.type===e.type&&n.key===e.key}const go="__vInternal",Ll=({key:n})=>n??null,Ai=({ref:n,ref_key:e,ref_for:t})=>(typeof n=="number"&&(n=""+n),n!=null?Ae(n)||Je(n)||_(n)?{i:mt,r:n,k:e,f:!!t}:n:null);function Re(n,e=null,t=null,r=0,s=null,i=n===_e?0:1,o=!1,a=!1){const u={__v_isVNode:!0,__v_skip:!0,type:n,props:e,key:e&&Ll(e),ref:e&&Ai(e),scopeId:Al,slotScopeIds:null,children:t,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:mt};return a?(Ya(u,t),i&128&&n.normalize(u)):t&&(u.shapeFlag|=Ae(t)?8:16),$s>0&&!o&&pt&&(u.patchFlag>0||i&6)&&u.patchFlag!==32&&pt.push(u),u}const Lr=Vd;function Vd(n,e=null,t=null,r=0,s=null,i=!1){if((!n||n===Ad)&&(n=Ms),Kd(n)){const a=cs(n,e,!0);return t&&Ya(a,t),$s>0&&!i&&pt&&(a.shapeFlag&6?pt[pt.indexOf(n)]=a:pt.push(a)),a.patchFlag|=-2,a}if(eg(n)&&(n=n.__vccOpts),e){e=jd(e);let{class:a,style:u}=e;a&&!Ae(a)&&(e.class=La(a)),de(u)&&(gl(u)&&!j(u)&&(u=ke({},u)),e.style=Fa(u))}const o=Ae(n)?1:ad(n)?128:Ud(n)?64:de(n)?4:_(n)?2:0;return Re(n,e,t,r,s,o,i,!0)}function jd(n){return n?gl(n)||go in n?ke({},n):n:null}function cs(n,e,t=!1){const{props:r,ref:s,patchFlag:i,children:o}=n,a=e?Wd(r||{},e):r;return{__v_isVNode:!0,__v_skip:!0,type:n.type,props:a,key:a&&Ll(a),ref:e&&e.ref?t&&s?j(s)?s.concat(Ai(e)):[s,Ai(e)]:Ai(e):s,scopeId:n.scopeId,slotScopeIds:n.slotScopeIds,children:o,target:n.target,targetAnchor:n.targetAnchor,staticCount:n.staticCount,shapeFlag:n.shapeFlag,patchFlag:e&&n.type!==_e?i===-1?16:i|16:i,dynamicProps:n.dynamicProps,dynamicChildren:n.dynamicChildren,appContext:n.appContext,dirs:n.dirs,transition:n.transition,component:n.component,suspense:n.suspense,ssContent:n.ssContent&&cs(n.ssContent),ssFallback:n.ssFallback&&cs(n.ssFallback),el:n.el,anchor:n.anchor,ctx:n.ctx,ce:n.ce}}function Jl(n=" ",e=0){return Lr(ho,null,n,e)}function Nt(n){return n==null||typeof n=="boolean"?Lr(Ms):j(n)?Lr(_e,null,n.slice()):typeof n=="object"?hr(n):Lr(ho,null,String(n))}function hr(n){return n.el===null&&n.patchFlag!==-1||n.memo?n:cs(n)}function Ya(n,e){let t=0;const{shapeFlag:r}=n;if(e==null)e=null;else if(j(e))t=16;else if(typeof e=="object")if(r&65){const s=e.default;s&&(s._c&&(s._d=!1),Ya(n,s()),s._c&&(s._d=!0));return}else{t=32;const s=e._;!s&&!(go in e)?e._ctx=mt:s===3&&mt&&(mt.slots._===1?e._=1:(e._=2,n.patchFlag|=1024))}else _(e)?(e={default:e,_ctx:mt},t=32):(e=String(e),r&64?(t=16,e=[Jl(e)]):t=8);n.children=e,n.shapeFlag|=t}function Wd(...n){const e={};for(let t=0;tPe=n),Xa=n=>{Wr.length>1?Wr.forEach(e=>e(n)):Wr[0](n)};const us=n=>{Xa(n),n.scope.on()},Jr=()=>{Pe&&Pe.scope.off(),Xa(null)};function Ml(n){return n.vnode.shapeFlag&4}let Us=!1;function Yd(n,e=!1){Us=e;const{props:t,children:r}=n.vnode,s=Ml(n);Dd(n,t,s,e),Fd(n,r);const i=s?Xd(n,e):void 0;return Us=!1,i}function Xd(n,e){const t=n.type;n.accessCache=Object.create(null),n.proxy=ml(new Proxy(n.ctx,Id));const{setup:r}=t;if(r){const s=n.setupContext=r.length>1?Qd(n):null;us(n),vs();const i=mr(r,n,0,[n.props,s]);if(ws(),Jr(),Xu(i)){if(i.then(Jr,Jr),e)return i.then(o=>{_c(n,o,e)}).catch(o=>{uo(o,n,0)});n.asyncDep=i}else _c(n,i,e)}else $l(n,e)}function _c(n,e,t){_(e)?n.type.__ssrInlineRender?n.ssrRender=e:n.render=e:de(e)&&(n.setupState=pl(e)),$l(n,t)}let Yc;function $l(n,e,t){const r=n.type;if(!n.render){if(!e&&Yc&&!r.render){const s=r.template||Ga(n).template;if(s){const{isCustomElement:i,compilerOptions:o}=n.appContext.config,{delimiters:a,compilerOptions:u}=r,l=ke(ke({isCustomElement:i,delimiters:a},o),u);r.render=Yc(s,l)}}n.render=r.render||qt}us(n),vs(),Sd(n),ws(),Jr()}function Zd(n){return n.attrsProxy||(n.attrsProxy=new Proxy(n.attrs,{get(e,t){return qe(n,"get","$attrs"),e[t]}}))}function Qd(n){const e=t=>{n.exposed=t||{}};return{get attrs(){return Zd(n)},slots:n.slots,emit:n.emit,expose:e}}function mo(n){if(n.exposed)return n.exposeProxy||(n.exposeProxy=new Proxy(pl(ml(n.exposed)),{get(e,t){if(t in e)return e[t];if(t in Cs)return Cs[t](n)},has(e,t){return t in e||t in Cs}}))}function eg(n){return _(n)&&"__vccOpts"in n}const tg=(n,e)=>Gh(n,e,Us),ng=Symbol.for("v-scx"),rg=()=>Ti(ng),sg="3.3.4",ig="http://www.w3.org/2000/svg",Or=typeof document<"u"?document:null,Xc=Or&&Or.createElement("template"),og={insert:(n,e,t)=>{e.insertBefore(n,t||null)},remove:n=>{const e=n.parentNode;e&&e.removeChild(n)},createElement:(n,e,t,r)=>{const s=e?Or.createElementNS(ig,n):Or.createElement(n,t?{is:t}:void 0);return n==="select"&&r&&r.multiple!=null&&s.setAttribute("multiple",r.multiple),s},createText:n=>Or.createTextNode(n),createComment:n=>Or.createComment(n),setText:(n,e)=>{n.nodeValue=e},setElementText:(n,e)=>{n.textContent=e},parentNode:n=>n.parentNode,nextSibling:n=>n.nextSibling,querySelector:n=>Or.querySelector(n),setScopeId(n,e){n.setAttribute(e,"")},insertStaticContent(n,e,t,r,s,i){const o=t?t.previousSibling:e.lastChild;if(s&&(s===i||s.nextSibling))for(;e.insertBefore(s.cloneNode(!0),t),!(s===i||!(s=s.nextSibling)););else{Xc.innerHTML=r?`${n}`:n;const a=Xc.content;if(r){const u=a.firstChild;for(;u.firstChild;)a.appendChild(u.firstChild);a.removeChild(u)}e.insertBefore(a,t)}return[o?o.nextSibling:e.firstChild,t?t.previousSibling:e.lastChild]}};function ag(n,e,t){const r=n._vtc;r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?n.removeAttribute("class"):t?n.setAttribute("class",e):n.className=e}function cg(n,e,t){const r=n.style,s=Ae(t);if(t&&!s){if(e&&!Ae(e))for(const i in e)t[i]==null&&ea(r,i,"");for(const i in t)ea(r,i,t[i])}else{const i=r.display;s?e!==t&&(r.cssText=t):e&&n.removeAttribute("style"),"_vod"in n&&(r.display=i)}}const Zc=/\s*!important$/;function ea(n,e,t){if(j(t))t.forEach(r=>ea(n,e,r));else if(t==null&&(t=""),e.startsWith("--"))n.setProperty(e,t);else{const r=ug(n,e);Zc.test(t)?n.setProperty(Kr(r),t.replace(Zc,""),"important"):n[r]=t}}const Qc=["Webkit","Moz","ms"],Po={};function ug(n,e){const t=Po[e];if(t)return t;let r=as(e);if(r!=="filter"&&r in n)return Po[e]=r;r=el(r);for(let s=0;sOo||(mg.then(()=>Oo=0),Oo=Date.now());function yg(n,e){const t=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=t.attached)return;wt(vg(r,t.value),e,5,[r])};return t.value=n,t.attached=pg(),t}function vg(n,e){if(j(e)){const t=n.stopImmediatePropagation;return n.stopImmediatePropagation=()=>{t.call(n),n._stopped=!0},e.map(r=>s=>!s._stopped&&r&&r(s))}else return e}const nu=/^on[a-z]/,wg=(n,e,t,r,s=!1,i,o,a,u)=>{e==="class"?ag(n,r,s):e==="style"?cg(n,t,r):io(e)?Oa(e)||dg(n,e,t,r,o):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):bg(n,e,r,s))?fg(n,e,r,i,o,a,u):(e==="true-value"?n._trueValue=r:e==="false-value"&&(n._falseValue=r),lg(n,e,r,s))};function bg(n,e,t,r){return r?!!(e==="innerHTML"||e==="textContent"||e in n&&nu.test(e)&&_(t)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&n.tagName==="INPUT"||e==="type"&&n.tagName==="TEXTAREA"||nu.test(e)&&Ae(t)?!1:e in n}const ru=n=>{const e=n.props["onUpdate:modelValue"]||!1;return j(e)?t=>wi(e,t):e};function Tg(n){n.target.composing=!0}function su(n){const e=n.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const iu={created(n,{modifiers:{lazy:e,trim:t,number:r}},s){n._assign=ru(s);const i=r||s.props&&s.props.type==="number";Yr(n,e?"change":"input",o=>{if(o.target.composing)return;let a=n.value;t&&(a=a.trim()),i&&(a=qo(a)),n._assign(a)}),t&&Yr(n,"change",()=>{n.value=n.value.trim()}),e||(Yr(n,"compositionstart",Tg),Yr(n,"compositionend",su),Yr(n,"change",su))},mounted(n,{value:e}){n.value=e??""},beforeUpdate(n,{value:e,modifiers:{lazy:t,trim:r,number:s}},i){if(n._assign=ru(i),n.composing||document.activeElement===n&&n.type!=="range"&&(t||r&&n.value.trim()===e||(s||n.type==="number")&&qo(n.value)===e))return;const o=e??"";n.value!==o&&(n.value=o)}},Ag={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},fi=(n,e)=>t=>{if(!("key"in t))return;const r=Kr(t.key);if(e.some(s=>s===r||Ag[s]===r))return n(t)},Ig=ke({patchProp:wg},og);let ou;function Sg(){return ou||(ou=Jd(Ig))}const xg=(...n)=>{const e=Sg().createApp(...n),{mount:t}=e;return e.mount=r=>{const s=kg(r);if(!s)return;const i=e._component;!_(i)&&!i.render&&!i.template&&(i.template=s.innerHTML),s.innerHTML="";const o=t(s,!1,s instanceof SVGElement);return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},e};function kg(n){return Ae(n)?document.querySelector(n):n}var ne;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(ne||(ne={}));function au(n){const e=ne[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class le extends Error{constructor(e,t=ne.Unknown,r,s,i){super(Eg(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=s??[],this.cause=i}static from(e,t=ne.Unknown){return e instanceof le?e:e instanceof Error?e.name=="AbortError"?new le(e.message,ne.Canceled):new le(e.message,t,void 0,void 0,e):new le(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===le.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:s=>s===e.typeName?e:void 0}:e,r=[];for(const s of this.details){if("getType"in s){t.findMessage(s.getType().typeName)&&r.push(s);continue}const i=t.findMessage(s.type);if(i)try{r.push(i.fromBinary(s.value))}catch{}}return r}}function Eg(n,e){return n.length?`[${au(e)}] ${n}`:`[${au(e)}]`}function pe(n,e){if(!n)throw new Error(e)}const Cg=34028234663852886e22,Ng=-34028234663852886e22,Pg=4294967295,Og=2147483647,Dg=-2147483648;function Ii(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>Og||nPg||n<0)throw new Error("invalid uint 32: "+n)}function Ul(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Cg||n({no:s.no,name:s.name,localName:n[s.no]})))}function Kl(n,e,t){const r=Object.create(null),s=Object.create(null),i=[];for(const o of e){const a=Vl(o);i.push(a),r[o.name]=a,s[o.no]=a}return{typeName:n,values:i,findName(o){return r[o]},findNumber(o){return s[o]}}}function Rg(n,e,t){const r={};for(const s of e){const i=Vl(s);r[i.localName]=i.no,r[i.no]=i.localName}return zl(r,n,e),r}function Vl(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class P{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),s=r.runtime.bin,i=s.makeReadOptions(t);return s.readMessage(this,i.readerFactory(e),e.byteLength,i),this}fromJson(e,t){const r=this.getType(),s=r.runtime.json,i=s.makeReadOptions(t);return s.readMessage(r,e,i,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(s){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${s instanceof Error?s.message:String(s)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,s=r.makeWriteOptions(e),i=s.writerFactory();return r.writeMessage(this,i,s),i.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,s=r.makeWriteOptions(e);return r.writeMessage(this,s)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Fg(n,e,t,r){var s;const i=(s=r==null?void 0:r.localName)!==null&&s!==void 0?s:e.substring(e.lastIndexOf(".")+1),o={[i]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[i];return Object.setPrototypeOf(o.prototype,new P),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,u){return new o().fromBinary(a,u)},fromJson(a,u){return new o().fromJson(a,u)},fromJsonString(a,u){return new o().fromJsonString(a,u)},equals(a,u){return n.util.equals(o,a,u)}}),o}function Lg(){let n=0,e=0;for(let r=0;r<28;r+=7){let s=this.buf[this.pos++];if(n|=(s&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let s=this.buf[this.pos++];if(e|=(s&127)<>>i,a=!(!(o>>>7)&&e==0),u=(a?o|128:o)&255;if(t.push(u),!a)return}const r=n>>>28&15|(e&7)<<4,s=!!(e>>3);if(t.push((s?r|128:r)&255),!!s){for(let i=3;i<31;i=i+7){const o=e>>>i,a=!!(o>>>7),u=(a?o|128:o)&255;if(t.push(u),!a)return}t.push(e>>>31&1)}}const Si=4294967296;function cu(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,s=0;function i(o,a){const u=Number(n.slice(o,a));s*=t,r=r*t+u,r>=Si&&(s=s+(r/Si|0),r=r%Si)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?Wl(r,s):Za(r,s)}function Jg(n,e){let t=Za(n,e);const r=t.hi&2147483648;r&&(t=Wl(t.lo,t.hi));const s=jl(t.lo,t.hi);return r?"-"+s:s}function jl(n,e){if({lo:n,hi:e}=Mg(n,e),e<=2097151)return String(Si*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,s=e>>16&65535;let i=t+r*6777216+s*6710656,o=r+s*8147497,a=s*2;const u=1e7;return i>=u&&(o+=Math.floor(i/u),i%=u),o>=u&&(a+=Math.floor(o/u),o%=u),a.toString()+uu(o)+uu(i)}function Mg(n,e){return{lo:n>>>0,hi:e>>>0}}function Za(n,e){return{lo:n|0,hi:e|0}}function Wl(n,e){return e=~e,n?n=~n+1:e+=1,Za(n,e)}const uu=n=>{const e=String(n);return"0000000".slice(e.length)+e};function lu(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function $g(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var fu={};function Ug(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof fu!="object"||fu.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const l=typeof u=="bigint"?u:BigInt(u);if(l>i||la||lpe(/^-?[0-9]+$/.test(s),`int64 invalid: ${s}`),r=s=>pe(/^[0-9]+$/.test(s),`uint64 invalid: ${s}`);return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),t(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),r(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),t(s),cu(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),r(s),cu(s)},dec(s,i){return Jg(s,i)},uDec(s,i){return jl(s,i)}}}const fe=Ug();var b;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(b||(b={}));var br;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(br||(br={}));function cr(n,e,t){if(e===t)return!0;if(n==b.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ta(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Ii(e),lu(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Ul(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ta(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Ii(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Ii(e),e=(e<<1^e>>31)>>>0,lu(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),s=fe.enc(e);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),s=fe.uEnc(e);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(t)}int64(e){let t=fe.enc(e);return Do(t.lo,t.hi,this.buf),this}sint64(e){let t=fe.enc(e),r=t.hi>>31,s=t.lo<<1^r,i=(t.hi<<1|t.lo>>>31)^r;return Do(s,i,this.buf),this}uint64(e){let t=fe.uEnc(e);return Do(t.lo,t.hi,this.buf),this}}class zg{constructor(e,t){this.varint64=Lg,this.uint32=$g,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ve.Varint:for(;this.buf[this.pos++]&128;);break;case ve.Bit64:this.pos+=4;case ve.Bit32:this.pos+=4;break;case ve.LengthDelimited:let s=this.uint32();this.pos+=s;break;case ve.StartGroup:for(;;){const[i,o]=this.tag();if(o===ve.EndGroup){if(t!==void 0&&i!==t)throw new Error("invalid end group tag");break}this.skip(o,i)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return fe.dec(...this.varint64())}uint64(){return fe.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,fe.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return fe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return fe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Kg(n,e,t,r){let s;return{typeName:e,extendee:t,get field(){if(!s){const i=typeof r=="function"?r():r;i.name=e.split(".").pop(),i.jsonName=`[${e}]`,s=n.util.newFieldList([i]).list()[0]}return s},runtime:n}}function Gl(n){const e=n.field.localName,t=Object.create(null);return t[e]=Vg(n),[t,()=>t[e]]}function Vg(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return ls(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function jg(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),po=[];for(let n=0;n>4,o=i,s=2;break;case 2:t[r++]=(o&15)<<4|(i&60)>>2,o=i,s=3;break;case 3:t[r++]=(o&3)<<6|i,s=0;break}}if(s==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,s=0;for(let i=0;i>2],s=(r&3)<<4,t=1;break;case 1:e+=Yn[s|r>>4],s=(r&15)<<2,t=2;break;case 2:e+=Yn[s|r>>6],e+=Yn[r&63],t=0;break}return t&&(e+=Yn[s],e+="=",t==1&&(e+="=")),e}};function Wg(n,e,t){Yl(e,n);const r=e.runtime.bin.makeReadOptions(t),s=jg(n.getType().runtime.bin.listUnknownFields(n),e.field),[i,o]=Gl(e);for(const a of s)e.runtime.bin.readField(i,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Hg(n,e,t,r){Yl(e,n);const s=e.runtime.bin.makeReadOptions(r),i=e.runtime.bin.makeWriteOptions(r);if(_l(n,e)){const l=n.getType().runtime.bin.listUnknownFields(n).filter(h=>h.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const h of l)n.getType().runtime.bin.onUnknownField(n,h.no,h.wireType,h.data)}const o=i.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,i);const u=s.readerFactory(o.finish());for(;u.posr.no==e.field.no)}function Yl(n,e){pe(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Xl(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Hl(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function hu(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?ls(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function Mr(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(P.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Zl(n,e){return Mr(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}b.DOUBLE,b.FLOAT,b.INT64,b.UINT64,b.INT32,b.UINT32,b.BOOL,b.STRING,b.BYTES;const du={ignoreUnknownFields:!1},gu={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Gg(n){return n?Object.assign(Object.assign({},du),n):du}function _g(n){return n?Object.assign(Object.assign({},gu),n):gu}const Fi=Symbol(),xi=Symbol();function Yg(){return{makeReadOptions:Gg,makeWriteOptions:_g,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Ct(e)}`);r=r??new n;const s=new Map,i=t.typeRegistry;for(const[o,a]of Object.entries(e)){const u=n.fields.findJsonName(o);if(u){if(u.oneof){if(a===null&&u.kind=="scalar")continue;const l=s.get(u.oneof);if(l!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${l}", "${o}"`);s.set(u.oneof,o)}mu(r,a,u,t,n)}else{let l=!1;if(i!=null&&i.findExtension&&o.startsWith("[")&&o.endsWith("]")){const h=i.findExtension(o.substring(1,o.length-1));if(h&&h.extendee.typeName==n.typeName){l=!0;const[d,v]=Gl(h);mu(d,a,h.field,t,h),Hg(r,h,v(),t)}}if(!l&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let s;try{for(s of t.fields.byNumber()){if(!Xl(s,n)){if(s.req)throw"required field not set";if(!e.emitDefaultValues||!Zg(s))continue}const o=s.oneof?n[s.oneof.localName].value:n[s.localName],a=pu(s,o,e);a!==void 0&&(r[e.useProtoFieldName?s.name:s.jsonName]=a)}const i=e.typeRegistry;if(i!=null&&i.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=i.findExtensionFor(t.typeName,o.no);if(a&&_l(n,a)){const u=Wg(n,a,e),l=pu(a.field,u,e);l!==void 0&&(r[a.field.jsonName]=l)}}}catch(i){const o=s?`cannot encode field ${t.typeName}.${s.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=i instanceof Error?i.message:String(i);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return Ps(n,e,t??br.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Hl(n,e)))return ki(n,e)},debug:Ct}}function Ct(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function mu(n,e,t,r,s){let i=t.localName;if(t.repeated){if(pe(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`);const o=n[i];for(const a of e){if(a===null)throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const u=Bo(t.T,a,r.ignoreUnknownFields,!0);u!==xi&&o.push(u);break;case"scalar":try{o.push(Ps(t.T,a,t.L,!0))}catch(l){let h=`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(a)}`;throw l instanceof Error&&l.message.length>0&&(h+=`: ${l.message}`),new Error(h)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`);const o=n[i];for(const[a,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: map value null`);let l;try{l=Xg(t.K,a)}catch(h){let d=`cannot decode map key for field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw h instanceof Error&&h.message.length>0&&(d+=`: ${h.message}`),new Error(d)}switch(t.V.kind){case"message":o[l]=t.V.T.fromJson(u,r);break;case"enum":const h=Bo(t.V.T,u,r.ignoreUnknownFields,!0);h!==xi&&(o[l]=h);break;case"scalar":try{o[l]=Ps(t.V.T,u,br.BIGINT,!0)}catch(d){let v=`cannot decode map value for field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw d instanceof Error&&d.message.length>0&&(v+=`: ${d.message}`),new Error(v)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:i},i="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[i];Mr(a)?a.fromJson(e,r):(n[i]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[i]=o.fieldWrapper.unwrapField(a)));break;case"enum":const u=Bo(t.T,e,r.ignoreUnknownFields,!1);switch(u){case Fi:hu(t,n);break;case xi:break;default:n[i]=u;break}break;case"scalar":try{const l=Ps(t.T,e,t.L,!1);switch(l){case Fi:hu(t,n);break;default:n[i]=l;break}}catch(l){let h=`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw l instanceof Error&&l.message.length>0&&(h+=`: ${l.message}`),new Error(h)}break}}function Xg(n,e){if(n===b.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ps(n,e,br.BIGINT,!0).toString()}function Ps(n,e,t,r){if(e===null)return r?ls(n,t):Fi;switch(n){case b.DOUBLE:case b.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const s=Number(e);if(Number.isNaN(s)||!Number.isFinite(s))break;return n==b.FLOAT&&Ul(s),s;case b.INT32:case b.FIXED32:case b.SFIXED32:case b.SINT32:case b.UINT32:let i;if(typeof e=="number"?i=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(i=Number(e)),i===void 0)break;return n==b.UINT32||n==b.FIXED32?ta(i):Ii(i),i;case b.INT64:case b.SFIXED64:case b.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=fe.parse(e);return t?o.toString():o;case b.FIXED64:case b.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=fe.uParse(e);return t?a.toString():a;case b.BOOL:if(typeof e!="boolean")break;return e;case b.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case b.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Qa.dec(e)}throw new Error}function Bo(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Fi;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const s=n.findName(e);if(s!==void 0)return s.no;if(t)return xi;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Ct(e)}`)}function Zg(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function pu(n,e,t){if(n.kind=="map"){pe(typeof e=="object"&&e!=null);const r={},s=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of s)r[o.toString()]=ki(n.V.T,a);break;case"message":for(const[o,a]of s)r[o.toString()]=a.toJson(t);break;case"enum":const i=n.V.T;for(const[o,a]of s)r[o.toString()]=Ro(i,a,t.enumAsInteger);break}return t.emitDefaultValues||s.length>0?r:void 0}if(n.repeated){pe(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let s=0;s0?r:void 0}switch(n.kind){case"scalar":return ki(n.T,e);case"enum":return Ro(n.T,e,t.enumAsInteger);case"message":return Zl(n.T,e).toJson(t)}}function Ro(n,e,t){var r;if(pe(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const s=n.findNumber(e);return(r=s==null?void 0:s.name)!==null&&r!==void 0?r:e}function ki(n,e){switch(n){case b.INT32:case b.SFIXED32:case b.SINT32:case b.FIXED32:case b.UINT32:return pe(typeof e=="number"),e;case b.FLOAT:case b.DOUBLE:return pe(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case b.STRING:return pe(typeof e=="string"),e;case b.BOOL:return pe(typeof e=="boolean"),e;case b.UINT64:case b.FIXED64:case b.INT64:case b.SFIXED64:case b.SINT64:return pe(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case b.BYTES:return pe(e instanceof Uint8Array),Qa.enc(e)}}const Hr=Symbol("@bufbuild/protobuf/unknown-fields"),yu={readUnknownFields:!0,readerFactory:n=>new zg(n)},vu={writeUnknownFields:!0,writerFactory:()=>new qg};function Qg(n){return n?Object.assign(Object.assign({},yu),n):yu}function em(n){return n?Object.assign(Object.assign({},vu),n):vu}function tm(){return{makeReadOptions:Qg,makeWriteOptions:em,listUnknownFields(n){var e;return(e=n[Hr])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Hr]},writeUnknownFields(n,e){const r=n[Hr];if(r)for(const s of r)e.tag(s.no,s.wireType).raw(s.data)},onUnknownField(n,e,t,r){const s=n;Array.isArray(s[Hr])||(s[Hr]=[]),s[Hr].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,s){const i=n.getType(),o=s?e.len:e.pos+t;let a,u;for(;e.pos0&&(u=rm),i){let v=n[o];if(r==ve.LengthDelimited&&a!=b.STRING&&a!=b.BYTES){let A=e.uint32()+e.pos;for(;e.posMr(v,d)?v:new d(v));else{const v=o[s];d.fieldWrapper?d.typeName==="google.protobuf.BytesValue"?i[s]=Is(v):i[s]=v:i[s]=Mr(v,d)?v:new d(v)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const s=e[r.localName],i=t[r.localName];if(r.repeated){if(s.length!==i.length)return!1;switch(r.kind){case"message":return s.every((o,a)=>r.T.equals(o,i[a]));case"scalar":return s.every((o,a)=>cr(r.T,o,i[a]));case"enum":return s.every((o,a)=>cr(b.INT32,o,i[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(s,i);case"enum":return cr(b.INT32,s,i);case"scalar":return cr(r.T,s,i);case"oneof":if(s.case!==i.case)return!1;const o=r.findField(s.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(s.value,i.value);case"enum":return cr(b.INT32,s.value,i.value);case"scalar":return cr(o.T,s.value,i.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(s).concat(Object.keys(i));switch(r.V.kind){case"message":const u=r.V.T;return a.every(h=>u.equals(s[h],i[h]));case"enum":return a.every(h=>cr(b.INT32,s[h],i[h]));case"scalar":const l=r.V.T;return a.every(h=>cr(l,s[h],i[h]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const s of e.fields.byMember()){const i=n[s.localName];let o;if(s.repeated)o=i.map(hi);else if(s.kind=="map"){o=r[s.localName];for(const[a,u]of Object.entries(i))o[a]=hi(u)}else s.kind=="oneof"?o=s.findField(i.case)?{case:i.case,value:hi(i.value)}:{case:void 0}:o=hi(i);r[s.localName]=o}for(const s of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,s.no,s.wireType,s.data);return t}}}function hi(n){if(n===void 0)return n;if(Mr(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Is(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function am(n,e,t){return{syntax:n,json:Yg(),bin:tm(),util:Object.assign(Object.assign({},om()),{newFieldList:e,initFields:t}),makeMessageType(r,s,i){return Fg(this,r,s,i)},makeEnum:Rg,makeEnumType:Kl,getEnumType:Bg,makeExtension(r,s,i){return Kg(this,r,s,i)}}}class cm{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function ef(n,e){const t=tf(n);return e?t:gm(dm(t))}function um(n){return ef(n,!1)}const lm=tf;function tf(n){let e=!1;const t=[];for(let r=0;r`${n}$`,dm=n=>hm.has(n)?nf(n):n,gm=n=>fm.has(n)?nf(n):n;class mm{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=um(e)}addField(e){pe(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew cm(n,e=>pm(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=ls(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Au;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Au||(Au={}));class Ce extends P{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(sDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=fe.parse(s/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const s=(this.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Ce.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ce({seconds:fe.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ce().fromBinary(e,t)}static fromJson(e,t){return new Ce().fromJson(e,t)}static fromJsonString(e,t){return new Ce().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ce,e,t)}}Ce.runtime=f;Ce.typeName="google.protobuf.Timestamp";Ce.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Xn extends P{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const s=Number(r[1]);if(s>315576e6||s<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=fe.parse(s),typeof r[2]=="string"){const i=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(i),(s<0||Object.is(s,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new Xn().fromBinary(e,t)}static fromJson(e,t){return new Xn().fromJson(e,t)}static fromJsonString(e,t){return new Xn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xn,e,t)}}Xn.runtime=f;Xn.typeName="google.protobuf.Duration";Xn.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Ot extends P{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),s=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!s)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=s.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const s=e["@type"];if(typeof s!="string"||s=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const i=this.typeUrlToName(s),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(i);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${s} is not in the type registry`);let a;if(i.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const u=Object.assign({},e);delete u["@type"],a=o.fromJson(u,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Ot;return t.packFrom(e),t}static fromBinary(e,t){return new Ot().fromBinary(e,t)}static fromJson(e,t){return new Ot().fromJson(e,t)}static fromJsonString(e,t){return new Ot().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ot,e,t)}}Ot.runtime=f;Ot.typeName="google.protobuf.Any";Ot.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Dt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.DOUBLE,e)}catch(r){let s='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Dt().fromBinary(e,t)}static fromJson(e,t){return new Dt().fromJson(e,t)}static fromJsonString(e,t){return new Dt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Dt,e,t)}}Dt.runtime=f;Dt.typeName="google.protobuf.DoubleValue";Dt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Dt.fieldWrapper={wrapField(n){return new Dt({value:n})},unwrapField(n){return n.value}};class Bt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.FLOAT,e)}catch(r){let s='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Bt().fromBinary(e,t)}static fromJson(e,t){return new Bt().fromJson(e,t)}static fromJsonString(e,t){return new Bt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Bt,e,t)}}Bt.runtime=f;Bt.typeName="google.protobuf.FloatValue";Bt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Bt.fieldWrapper={wrapField(n){return new Bt({value:n})},unwrapField(n){return n.value}};class Rt extends P{constructor(e){super(),this.value=fe.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.INT64,e)}catch(r){let s='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Rt().fromBinary(e,t)}static fromJson(e,t){return new Rt().fromJson(e,t)}static fromJsonString(e,t){return new Rt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Rt,e,t)}}Rt.runtime=f;Rt.typeName="google.protobuf.Int64Value";Rt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Rt.fieldWrapper={wrapField(n){return new Rt({value:n})},unwrapField(n){return n.value}};class Ft extends P{constructor(e){super(),this.value=fe.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.UINT64,e)}catch(r){let s='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Ft().fromBinary(e,t)}static fromJson(e,t){return new Ft().fromJson(e,t)}static fromJsonString(e,t){return new Ft().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ft,e,t)}}Ft.runtime=f;Ft.typeName="google.protobuf.UInt64Value";Ft.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Ft.fieldWrapper={wrapField(n){return new Ft({value:n})},unwrapField(n){return n.value}};class Lt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.INT32,e)}catch(r){let s='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Lt().fromBinary(e,t)}static fromJson(e,t){return new Lt().fromJson(e,t)}static fromJsonString(e,t){return new Lt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Lt,e,t)}}Lt.runtime=f;Lt.typeName="google.protobuf.Int32Value";Lt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Lt.fieldWrapper={wrapField(n){return new Lt({value:n})},unwrapField(n){return n.value}};class Jt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.UINT32,e)}catch(r){let s='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Jt().fromBinary(e,t)}static fromJson(e,t){return new Jt().fromJson(e,t)}static fromJsonString(e,t){return new Jt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Jt,e,t)}}Jt.runtime=f;Jt.typeName="google.protobuf.UInt32Value";Jt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Jt.fieldWrapper={wrapField(n){return new Jt({value:n})},unwrapField(n){return n.value}};class Mt extends P{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.BOOL,e)}catch(r){let s='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Mt().fromBinary(e,t)}static fromJson(e,t){return new Mt().fromJson(e,t)}static fromJsonString(e,t){return new Mt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Mt,e,t)}}Mt.runtime=f;Mt.typeName="google.protobuf.BoolValue";Mt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Mt.fieldWrapper={wrapField(n){return new Mt({value:n})},unwrapField(n){return n.value}};class Ve extends P{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.STRING,e)}catch(r){let s='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Ve().fromBinary(e,t)}static fromJson(e,t){return new Ve().fromJson(e,t)}static fromJsonString(e,t){return new Ve().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ve,e,t)}}Ve.runtime=f;Ve.typeName="google.protobuf.StringValue";Ve.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Ve.fieldWrapper={wrapField(n){return new Ve({value:n})},unwrapField(n){return n.value}};class $t extends P{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.BYTES,e)}catch(r){let s='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new $t().fromBinary(e,t)}static fromJson(e,t){return new $t().fromJson(e,t)}static fromJsonString(e,t){return new $t().fromJsonString(e,t)}static equals(e,t){return f.util.equals($t,e,t)}}$t.runtime=f;$t.typeName="google.protobuf.BytesValue";$t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);$t.fieldWrapper={wrapField(n){return new $t({value:n})},unwrapField(n){return n.value}};function ym(n,e,t){try{const r=Qa.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw le.from(r,ne.DataLoss)}}function vm(n,e){const t={};for(const[r,s]of Object.entries(n.methods)){const i=e(Object.assign(Object.assign({},s),{localName:r,service:n}));i!=null&&(t[r]=i)}return t}function Iu(n){let e,t=new Uint8Array(0);function r(s){const i=new Uint8Array(t.length+s.length);i.set(t),i.set(s,t.length),t=i}return new ReadableStream({start(){e=n.getReader()},async pull(s){let i;for(;;){if(i===void 0&&t.byteLength>=5){let u=0;for(let l=1;l<5;l++)u=(u<<8)+t[l];i={flags:t[0],length:u}}if(i!==void 0&&t.byteLength>=i.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(i===void 0){if(t.byteLength==0){s.close();return}s.error(new le("premature end of stream",ne.DataLoss));return}const o=t.subarray(5,5+i.length);t=t.subarray(5+i.length),s.enqueue({flags:i.flags,data:o})}})}function Su(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var wm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,u){o=n[i](o),s(a,u,o.done,o.value)})}}function s(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}},qs=function(n){return this instanceof qs?(this.v=n,this):new qs(n)},bm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof qs?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}},Tm=function(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:qs(n[s](o)),done:!1}:i?i(o):o}:i}};function Am(n){return bm(this,arguments,function*(){yield qs(yield*Tm(wm(n)))})}var rf=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,u){o=n[i](o),s(a,u,o.done,o.value)})}}function s(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}},fs=function(n){return this instanceof fs?(this.v=n,this):new fs(n)},Im=function(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:fs(n[s](o)),done:!1}:i?i(o):o}:i}},Sm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof fs?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}};function xm(n,e){return vm(n,t=>{switch(t.kind){case Fe.Unary:return km(e,n,t);case Fe.ServerStreaming:return Em(e,n,t);case Fe.ClientStreaming:return Cm(e,n,t);case Fe.BiDiStreaming:return Nm(e,n,t);default:return null}})}function km(n,e,t){return async function(r,s){var i,o;const a=await n.unary(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);return(i=s==null?void 0:s.onHeader)===null||i===void 0||i.call(s,a.header),(o=s==null?void 0:s.onTrailer)===null||o===void 0||o.call(s,a.trailer),a.message}}function Em(n,e,t){return function(r,s){return sf(n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,Am([r]),s==null?void 0:s.contextValues),s)}}function Cm(n,e,t){return async function(r,s){var i,o,a,u,l,h;const d=await n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);(l=s==null?void 0:s.onHeader)===null||l===void 0||l.call(s,d.header);let v;try{for(var p=!0,A=rf(d.message),I;I=await A.next(),i=I.done,!i;p=!0)u=I.value,p=!1,v=u}catch(D){o={error:D}}finally{try{!p&&!i&&(a=A.return)&&await a.call(A)}finally{if(o)throw o.error}}if(!v)throw new le("protocol error: missing response message",ne.Internal);return(h=s==null?void 0:s.onTrailer)===null||h===void 0||h.call(s,d.trailer),v}}function Nm(n,e,t){return function(r,s){return sf(n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues),s)}}function sf(n,e){const t=function(){var r,s;return Sm(this,arguments,function*(){const i=yield fs(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,i.header),yield fs(yield*Im(rf(i.message))),(s=e==null?void 0:e.onTrailer)===null||s===void 0||s.call(e,i.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function Pm(...n){const e=new AbortController,t=n.filter(s=>s!==void 0).concat(e.signal);for(const s of t){if(s.aborted){r.apply(s);break}s.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(of(this));for(const s of t)s.removeEventListener("abort",r)}return e}function Om(n){const e=new AbortController,t=()=>{e.abort(new le("the operation timed out",ne.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function of(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function xu(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Fo=128;function ku(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r -`);for(const r of t){if(r==="")continue;const s=r.indexOf(":");if(s>0){const i=r.substring(0,s).trim(),o=r.substring(s+1).trim();e.append(i,o)}}return e}const Dm="Content-Type",Bm="Grpc-Timeout",af="Grpc-Status",cf="Grpc-Message",Rm="Grpc-Status-Details-Bin",Fm="X-User-Agent",Lm="X-Grpc-Web",Jm="application/grpc-web+proto",Mm="application/grpc-web+json";class Zn extends P{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new Zn().fromBinary(e,t)}static fromJson(e,t){return new Zn().fromJson(e,t)}static fromJsonString(e,t){return new Zn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zn,e,t)}}Zn.runtime=f;Zn.typeName="google.rpc.Status";Zn.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Ot,repeated:!0}]);const $m="0";function uf(n){var e;const t=n.get(Rm);if(t!=null){const s=ym(t,Zn);if(s.code==0)return;const i=new le(s.message,s.code,n);return i.details=s.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),i}const r=n.get(af);if(r!=null){if(r===$m)return;const s=parseInt(r,10);return s in ne?new le(decodeURIComponent((e=n.get(cf))!==null&&e!==void 0?e:""),s,n):new le(`invalid grpc-status: ${r}`,ne.Internal,n)}}function Eu(n,e,t){const r=typeof e=="string"?e:e.typeName,s=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${s}`)}function lf(n,e){return e instanceof n?e:new n(e)}function Um(n,e){function t(r){return r.done===!0?r:{done:r.done,value:lf(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),s={next:()=>r.next().then(t)};return r.throw!==void 0&&(s.throw=i=>r.throw(i).then(t)),r.return!==void 0&&(s.return=i=>r.return(i).then(t)),s}}}function ff(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,s)=>s(r),n))!==null&&t!==void 0?t:n}function qm(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function Cu(n,e,t,r){const s=e?Nu(n.I,r):Pu(n.I,t);return{parse:(e?Nu(n.O,r):Pu(n.O,t)).parse,serialize:s.serialize}}function Nu(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const s=r instanceof Error?r.message:String(r);throw new le(`parse binary: ${s}`,ne.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const s=r instanceof Error?r.message:String(r);throw new le(`serialize binary: ${s}`,ne.Internal)}}}}function Pu(n,e){var t,r;const s=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,i=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=qm(e);return{parse(a){try{const u=i.decode(a);return n.fromJsonString(u,o)}catch(u){throw le.from(u,ne.InvalidArgument)}},serialize(a){try{const u=a.toJsonString(o);return s.encode(u)}catch(u){throw le.from(u,ne.Internal)}}}}function zm(n){const e=ff(n.next,n.interceptors),[t,r,s]=hf(n),i=Object.assign(Object.assign({},n.req),{message:lf(n.req.method.I,n.req.message),signal:t});return e(i).then(o=>(s(),o),r)}function Km(n){const e=ff(n.next,n.interceptors),[t,r,s]=hf(n),i=Object.assign(Object.assign({},n.req),{message:Um(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,u;const l=n.req.message[Symbol.asyncIterator]();o||(a=l.throw)===null||a===void 0||a.call(l,this.reason).catch(()=>{}),(u=l.return)===null||u===void 0||u.call(l).catch(()=>{})}),e(i).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const u=a.message[Symbol.asyncIterator]();return{next(){return u.next().then(l=>(l.done==!0&&(o=!0,s()),l),r)}}}}}),r)}function hf(n){const{signal:e,cleanup:t}=Om(n.timeoutMs),r=Pm(n.signal,e);return[r.signal,function(i){const o=le.from(e.aborted?of(e):i);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function Vm(){try{new Headers}catch{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.")}}function Ou(n,e){const t=uf(n);if(t)throw e.forEach((r,s)=>{t.metadata.append(s,r)}),t}function Du(n,e,t,r){const s=new Headers(t??{});return s.set(Dm,n?Jm:Mm),s.set(Lm,"1"),s.set(Fm,"connect-es/1.4.0"),e!==void 0&&s.set(Bm,`${e}m`),s}function jm(n){switch(n){case 400:return ne.Internal;case 401:return ne.Unauthenticated;case 403:return ne.PermissionDenied;case 404:return ne.Unimplemented;case 429:return ne.Unavailable;case 502:return ne.Unavailable;case 503:return ne.Unavailable;case 504:return ne.Unavailable;default:return ne.Unknown}}function Bu(n,e){var t;if(n>=200&&n<300){const r=uf(e);if(r)throw r;return{foundStatus:e.has(af)}}throw new le(decodeURIComponent((t=e.get(cf))!==null&&t!==void 0?t:`HTTP ${n}`),jm(n),e)}var Br=function(n){return this instanceof Br?(this.v=n,this):new Br(n)},Wm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof Br?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}};function Hm(n){var e;Vm();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,s,i,o,a,u,l){var h;const{serialize:d,parse:v}=Cu(s,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await zm({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!1,service:r,method:s,url:Eu(n.baseUrl,r,s),init:{method:"POST",credentials:(h=n.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Du(t,o,a),contextValues:l??xu(),message:u},next:async p=>{var A;const D=await((A=n.fetch)!==null&&A!==void 0?A:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:Su(0,d(p.message))}));if(Bu(D.status,D.headers),!D.body)throw"missing response body";const L=Iu(D.body).getReader();let $,V;for(;;){const U=await L.read();if(U.done)break;const{flags:W,data:ee}=U.value;if(W===Fo){if($!==void 0)throw"extra trailer";$=ku(ee);continue}if(V!==void 0)throw"extra message";V=v(ee)}if($===void 0)throw"missing trailer";if(Ou($,D.headers),V===void 0)throw"missing message";return{stream:!1,service:r,method:s,header:D.headers,message:V,trailer:$}}})},async stream(r,s,i,o,a,u,l){var h;const{serialize:d,parse:v}=Cu(s,t,n.jsonOptions,n.binaryOptions);function p(I,D,L,$){return Wm(this,arguments,function*(){const U=Iu(I).getReader();if(D){if(!(yield Br(U.read())).done)throw"extra data for trailers-only";return yield Br(void 0)}let W=!1;for(;;){const ee=yield Br(U.read());if(ee.done)break;const{flags:oe,data:te}=ee.value;if((oe&Fo)===Fo){if(W)throw"extra trailer";W=!0;const Ee=ku(te);Ou(Ee,$),Ee.forEach((Ie,Ge)=>L.set(Ge,Ie));continue}if(W)throw"extra message";yield yield Br(v(te))}if(!W)throw"missing trailer"})}async function A(I){if(s.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const D=await I[Symbol.asyncIterator]().next();if(D.done==!0)throw"missing request message";return Su(0,d(D.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,Km({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!0,service:r,method:s,url:Eu(n.baseUrl,r,s),init:{method:"POST",credentials:(h=n.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Du(t,o,a),contextValues:l??xu(),message:u},next:async I=>{var D;const $=await((D=n.fetch)!==null&&D!==void 0?D:globalThis.fetch)(I.url,Object.assign(Object.assign({},I.init),{headers:I.header,signal:I.signal,body:await A(I.message)})),{foundStatus:V}=Bu($.status,$.headers);if(!$.body)throw"missing response body";const U=new Headers;return Object.assign(Object.assign({},I),{header:$.headers,trailer:U,message:p($.body,V,U,$.headers)})}})}}}var G=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(G||{});f.util.setEnumType(G,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var $r=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))($r||{});f.util.setEnumType($r,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const _t=class _t extends P{constructor(t){super();c(this,"root");c(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new _t().fromBinary(t,r)}static fromJson(t,r){return new _t().fromJson(t,r)}static fromJsonString(t,r){return new _t().fromJsonString(t,r)}static equals(t,r){return f.util.equals(_t,t,r)}};c(_t,"runtime",f),c(_t,"typeName","yorkie.v1.Snapshot"),c(_t,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:ze},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:tc}}]));let na=_t;var Xe;let or=(Xe=class extends P{constructor(t){super();c(this,"documentKey","");c(this,"checkpoint");c(this,"snapshot",new Uint8Array(0));c(this,"changes",[]);c(this,"minSyncedTicket");c(this,"isRemoved",!1);c(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xe().fromBinary(t,r)}static fromJson(t,r){return new Xe().fromJson(t,r)}static fromJsonString(t,r){return new Xe().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xe,t,r)}},c(Xe,"runtime",f),c(Xe,"typeName","yorkie.v1.ChangePack"),c(Xe,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:mf},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:df,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:F},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:vo}])),Xe);var Ze;let df=(Ze=class extends P{constructor(t){super();c(this,"id");c(this,"message","");c(this,"operations",[]);c(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ze().fromBinary(t,r)}static fromJson(t,r){return new Ze().fromJson(t,r)}static fromJsonString(t,r){return new Ze().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ze,t,r)}},c(Ze,"runtime",f),c(Ze,"typeName","yorkie.v1.Change"),c(Ze,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:yo},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:ec,repeated:!0},{no:4,name:"presence_change",kind:"message",T:Vs}])),Ze);var Qe;let yo=(Qe=class extends P{constructor(t){super();c(this,"clientSeq",0);c(this,"serverSeq",fe.zero);c(this,"lamport",fe.zero);c(this,"actorId",new Uint8Array(0));c(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qe().fromBinary(t,r)}static fromJson(t,r){return new Qe().fromJson(t,r)}static fromJsonString(t,r){return new Qe().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qe,t,r)}},c(Qe,"runtime",f),c(Qe,"typeName","yorkie.v1.ChangeID"),c(Qe,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:vo}])),Qe);var et;let vo=(et=class extends P{constructor(t){super();c(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new et().fromBinary(t,r)}static fromJson(t,r){return new et().fromJson(t,r)}static fromJsonString(t,r){return new et().fromJsonString(t,r)}static equals(t,r){return f.util.equals(et,t,r)}},c(et,"runtime",f),c(et,"typeName","yorkie.v1.VersionVector"),c(et,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),et);var tt;let ec=(tt=class extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new tt().fromBinary(t,r)}static fromJson(t,r){return new tt().fromJson(t,r)}static fromJsonString(t,r){return new tt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tt,t,r)}},c(tt,"runtime",f),c(tt,"typeName","yorkie.v1.Operation"),c(tt,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Ji,oneof:"body"},{no:2,name:"add",kind:"message",T:Mi,oneof:"body"},{no:3,name:"move",kind:"message",T:$i,oneof:"body"},{no:4,name:"remove",kind:"message",T:Ui,oneof:"body"},{no:5,name:"edit",kind:"message",T:qi,oneof:"body"},{no:6,name:"select",kind:"message",T:ra,oneof:"body"},{no:7,name:"style",kind:"message",T:zi,oneof:"body"},{no:8,name:"increase",kind:"message",T:Ki,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:Vi,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ji,oneof:"body"},{no:11,name:"array_set",kind:"message",T:sa,oneof:"body"}])),tt);const Yt=class Yt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"key","");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Yt().fromBinary(t,r)}static fromJson(t,r){return new Yt().fromJson(t,r)}static fromJsonString(t,r){return new Yt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yt,t,r)}};c(Yt,"runtime",f),c(Yt,"typeName","yorkie.v1.Operation.Set"),c(Yt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let Ji=Yt;const Xt=class Xt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"prevCreatedAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xt().fromBinary(t,r)}static fromJson(t,r){return new Xt().fromJson(t,r)}static fromJsonString(t,r){return new Xt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xt,t,r)}};c(Xt,"runtime",f),c(Xt,"typeName","yorkie.v1.Operation.Add"),c(Xt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"prev_created_at",kind:"message",T:F},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let Mi=Xt;const Zt=class Zt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"prevCreatedAt");c(this,"createdAt");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Zt().fromBinary(t,r)}static fromJson(t,r){return new Zt().fromJson(t,r)}static fromJsonString(t,r){return new Zt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zt,t,r)}};c(Zt,"runtime",f),c(Zt,"typeName","yorkie.v1.Operation.Move"),c(Zt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"prev_created_at",kind:"message",T:F},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"executed_at",kind:"message",T:F}]));let $i=Zt;const Qt=class Qt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"createdAt");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qt().fromBinary(t,r)}static fromJson(t,r){return new Qt().fromJson(t,r)}static fromJsonString(t,r){return new Qt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qt,t,r)}};c(Qt,"runtime",f),c(Qt,"typeName","yorkie.v1.Operation.Remove"),c(Qt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"executed_at",kind:"message",T:F}]));let Ui=Qt;const en=class en extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"createdAtMapByActor",{});c(this,"content","");c(this,"executedAt");c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new en().fromBinary(t,r)}static fromJson(t,r){return new en().fromJson(t,r)}static fromJsonString(t,r){return new en().fromJsonString(t,r)}static equals(t,r){return f.util.equals(en,t,r)}};c(en,"runtime",f),c(en,"typeName","yorkie.v1.Operation.Edit"),c(en,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:F},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let qi=en;const tn=class tn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new tn().fromBinary(t,r)}static fromJson(t,r){return new tn().fromJson(t,r)}static fromJsonString(t,r){return new tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tn,t,r)}};c(tn,"runtime",f),c(tn,"typeName","yorkie.v1.Operation.Select"),c(tn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"executed_at",kind:"message",T:F}]));let ra=tn;const nn=class nn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"attributes",{});c(this,"executedAt");c(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new nn().fromBinary(t,r)}static fromJson(t,r){return new nn().fromJson(t,r)}static fromJsonString(t,r){return new nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nn,t,r)}};c(nn,"runtime",f),c(nn,"typeName","yorkie.v1.Operation.Style"),c(nn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:F},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}}]));let zi=nn;const rn=class rn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new rn().fromBinary(t,r)}static fromJson(t,r){return new rn().fromJson(t,r)}static fromJsonString(t,r){return new rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rn,t,r)}};c(rn,"runtime",f),c(rn,"typeName","yorkie.v1.Operation.Increase"),c(rn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"value",kind:"message",T:Ye},{no:3,name:"executed_at",kind:"message",T:F}]));let Ki=rn;const sn=class sn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"createdAtMapByActor",{});c(this,"contents",[]);c(this,"splitLevel",0);c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new sn().fromBinary(t,r)}static fromJson(t,r){return new sn().fromJson(t,r)}static fromJsonString(t,r){return new sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(sn,t,r)}};c(sn,"runtime",f),c(sn,"typeName","yorkie.v1.Operation.TreeEdit"),c(sn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:Ur},{no:3,name:"to",kind:"message",T:Ur},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}},{no:5,name:"contents",kind:"message",T:eo,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:F}]));let Vi=sn;const on=class on extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"attributes",{});c(this,"executedAt");c(this,"attributesToRemove",[]);c(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new on().fromBinary(t,r)}static fromJson(t,r){return new on().fromJson(t,r)}static fromJsonString(t,r){return new on().fromJsonString(t,r)}static equals(t,r){return f.util.equals(on,t,r)}};c(on,"runtime",f),c(on,"typeName","yorkie.v1.Operation.TreeStyle"),c(on,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:Ur},{no:3,name:"to",kind:"message",T:Ur},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:F},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}}]));let ji=on;const an=class an extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"createdAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new an().fromBinary(t,r)}static fromJson(t,r){return new an().fromJson(t,r)}static fromJsonString(t,r){return new an().fromJsonString(t,r)}static equals(t,r){return f.util.equals(an,t,r)}};c(an,"runtime",f),c(an,"typeName","yorkie.v1.Operation.ArraySet"),c(an,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let sa=an;const cn=class cn extends P{constructor(t){super();c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");c(this,"type",0);c(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};c(cn,"runtime",f),c(cn,"typeName","yorkie.v1.JSONElementSimple"),c(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"moved_at",kind:"message",T:F},{no:3,name:"removed_at",kind:"message",T:F},{no:4,name:"type",kind:"enum",T:f.getEnumType(G)},{no:5,name:"value",kind:"scalar",T:12}]));let Ye=cn;const un=class un extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};c(un,"runtime",f),c(un,"typeName","yorkie.v1.JSONElement"),c(un,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Wi,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Hi,oneof:"body"},{no:3,name:"primitive",kind:"message",T:Gi,oneof:"body"},{no:5,name:"text",kind:"message",T:_i,oneof:"body"},{no:6,name:"counter",kind:"message",T:Yi,oneof:"body"},{no:7,name:"tree",kind:"message",T:Xi,oneof:"body"}]));let ze=un;const ln=class ln extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};c(ln,"runtime",f),c(ln,"typeName","yorkie.v1.JSONElement.JSONObject"),c(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:gf,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Wi=ln;const fn=class fn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};c(fn,"runtime",f),c(fn,"typeName","yorkie.v1.JSONElement.JSONArray"),c(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Zi,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Hi=fn;const hn=class hn extends P{constructor(t){super();c(this,"type",0);c(this,"value",new Uint8Array(0));c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};c(hn,"runtime",f),c(hn,"typeName","yorkie.v1.JSONElement.Primitive"),c(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(G)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"moved_at",kind:"message",T:F},{no:5,name:"removed_at",kind:"message",T:F}]));let Gi=hn;const dn=class dn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};c(dn,"runtime",f),c(dn,"typeName","yorkie.v1.JSONElement.Text"),c(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Qi,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let _i=dn;const gn=class gn extends P{constructor(t){super();c(this,"type",0);c(this,"value",new Uint8Array(0));c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};c(gn,"runtime",f),c(gn,"typeName","yorkie.v1.JSONElement.Counter"),c(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(G)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"moved_at",kind:"message",T:F},{no:5,name:"removed_at",kind:"message",T:F}]));let Yi=gn;const mn=class mn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};c(mn,"runtime",f),c(mn,"typeName","yorkie.v1.JSONElement.Tree"),c(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Ks,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Xi=mn;var nt;let gf=(nt=class extends P{constructor(t){super();c(this,"key","");c(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new nt().fromBinary(t,r)}static fromJson(t,r){return new nt().fromJson(t,r)}static fromJsonString(t,r){return new nt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nt,t,r)}},c(nt,"runtime",f),c(nt,"typeName","yorkie.v1.RHTNode"),c(nt,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:ze}])),nt);const Et=class Et extends P{constructor(t){super();c(this,"next");c(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new Et().fromBinary(t,r)}static fromJson(t,r){return new Et().fromJson(t,r)}static fromJsonString(t,r){return new Et().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Et,t,r)}};c(Et,"runtime",f),c(Et,"typeName","yorkie.v1.RGANode"),c(Et,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Et},{no:2,name:"element",kind:"message",T:ze}]));let Zi=Et;const pn=class pn extends P{constructor(t){super();c(this,"value","");c(this,"updatedAt");c(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};c(pn,"runtime",f),c(pn,"typeName","yorkie.v1.NodeAttr"),c(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:F},{no:3,name:"is_removed",kind:"scalar",T:8}]));let hs=pn;const yn=class yn extends P{constructor(t){super();c(this,"id");c(this,"value","");c(this,"removedAt");c(this,"insPrevId");c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};c(yn,"runtime",f),c(yn,"typeName","yorkie.v1.TextNode"),c(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:zs},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:F},{no:4,name:"ins_prev_id",kind:"message",T:zs},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let Qi=yn;const vn=class vn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};c(vn,"runtime",f),c(vn,"typeName","yorkie.v1.TextNodeID"),c(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5}]));let zs=vn;const wn=class wn extends P{constructor(t){super();c(this,"id");c(this,"type","");c(this,"value","");c(this,"removedAt");c(this,"insPrevId");c(this,"insNextId");c(this,"depth",0);c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};c(wn,"runtime",f),c(wn,"typeName","yorkie.v1.TreeNode"),c(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:pr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:F},{no:5,name:"ins_prev_id",kind:"message",T:pr},{no:6,name:"ins_next_id",kind:"message",T:pr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let Ks=wn;const bn=class bn extends P{constructor(t){super();c(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};c(bn,"runtime",f),c(bn,"typeName","yorkie.v1.TreeNodes"),c(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:Ks,repeated:!0}]));let eo=bn;const Tn=class Tn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};c(Tn,"runtime",f),c(Tn,"typeName","yorkie.v1.TreeNodeID"),c(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5}]));let pr=Tn;const An=class An extends P{constructor(t){super();c(this,"parentId");c(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};c(An,"runtime",f),c(An,"typeName","yorkie.v1.TreePos"),c(An,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:pr},{no:2,name:"left_sibling_id",kind:"message",T:pr}]));let Ur=An;const In=class In extends P{constructor(t){super();c(this,"id","");c(this,"username","");c(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};c(In,"runtime",f),c(In,"typeName","yorkie.v1.User"),c(In,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Ce}]));let Ru=In;const Sn=class Sn extends P{constructor(t){super();c(this,"id","");c(this,"name","");c(this,"publicKey","");c(this,"secretKey","");c(this,"authWebhookUrl","");c(this,"authWebhookMethods",[]);c(this,"clientDeactivateThreshold","");c(this,"createdAt");c(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};c(Sn,"runtime",f),c(Sn,"typeName","yorkie.v1.Project"),c(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Ce},{no:9,name:"updated_at",kind:"message",T:Ce}]));let Fu=Sn;const xn=class xn extends P{constructor(t){super();c(this,"name");c(this,"authWebhookUrl");c(this,"authWebhookMethods");c(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};c(xn,"runtime",f),c(xn,"typeName","yorkie.v1.UpdatableProjectFields"),c(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Ve},{no:2,name:"auth_webhook_url",kind:"message",T:Ve},{no:3,name:"auth_webhook_methods",kind:"message",T:ia},{no:4,name:"client_deactivate_threshold",kind:"message",T:Ve}]));let Lu=xn;const kn=class kn extends P{constructor(t){super();c(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};c(kn,"runtime",f),c(kn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),c(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let ia=kn;const En=class En extends P{constructor(t){super();c(this,"id","");c(this,"key","");c(this,"snapshot","");c(this,"createdAt");c(this,"accessedAt");c(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};c(En,"runtime",f),c(En,"typeName","yorkie.v1.DocumentSummary"),c(En,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Ce},{no:5,name:"accessed_at",kind:"message",T:Ce},{no:6,name:"updated_at",kind:"message",T:Ce}]));let Ju=En;const Cn=class Cn extends P{constructor(t){super();c(this,"type",0);c(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};c(Cn,"runtime",f),c(Cn,"typeName","yorkie.v1.PresenceChange"),c(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(qr)},{no:2,name:"presence",kind:"message",T:tc}]));let Vs=Cn;var qr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(qr||{});f.util.setEnumType(qr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var rt;let tc=(rt=class extends P{constructor(t){super();c(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new rt().fromBinary(t,r)}static fromJson(t,r){return new rt().fromJson(t,r)}static fromJsonString(t,r){return new rt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rt,t,r)}},c(rt,"runtime",f),c(rt,"typeName","yorkie.v1.Presence"),c(rt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),rt);var st;let mf=(st=class extends P{constructor(t){super();c(this,"serverSeq",fe.zero);c(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new st().fromBinary(t,r)}static fromJson(t,r){return new st().fromJson(t,r)}static fromJsonString(t,r){return new st().fromJsonString(t,r)}static equals(t,r){return f.util.equals(st,t,r)}},c(st,"runtime",f),c(st,"typeName","yorkie.v1.Checkpoint"),c(st,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),st);const Nn=class Nn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);c(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};c(Nn,"runtime",f),c(Nn,"typeName","yorkie.v1.TextNodePos"),c(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let rr=Nn;var it;let F=(it=class extends P{constructor(t){super();c(this,"lamport",fe.zero);c(this,"delimiter",0);c(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new it().fromBinary(t,r)}static fromJson(t,r){return new it().fromJson(t,r)}static fromJsonString(t,r){return new it().fromJsonString(t,r)}static equals(t,r){return f.util.equals(it,t,r)}},c(it,"runtime",f),c(it,"typeName","yorkie.v1.TimeTicket"),c(it,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),it);const Pn=class Pn extends P{constructor(t){super();c(this,"topic","");c(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};c(Pn,"runtime",f),c(Pn,"typeName","yorkie.v1.DocEventBody"),c(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let oa=Pn;const On=class On extends P{constructor(t){super();c(this,"type",0);c(this,"publisher","");c(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};c(On,"runtime",f),c(On,"typeName","yorkie.v1.DocEvent"),c(On,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType($r)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:oa}]));let aa=On;const Dn=class Dn extends P{constructor(t){super();c(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};c(Dn,"runtime",f),c(Dn,"typeName","yorkie.v1.ActivateClientRequest"),c(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let ca=Dn;const Bn=class Bn extends P{constructor(t){super();c(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};c(Bn,"runtime",f),c(Bn,"typeName","yorkie.v1.ActivateClientResponse"),c(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let ua=Bn;const Rn=class Rn extends P{constructor(t){super();c(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};c(Rn,"runtime",f),c(Rn,"typeName","yorkie.v1.DeactivateClientRequest"),c(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let la=Rn;const Fn=class Fn extends P{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Fn().fromBinary(e,t)}static fromJson(e,t){return new Fn().fromJson(e,t)}static fromJsonString(e,t){return new Fn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Fn,e,t)}};c(Fn,"runtime",f),c(Fn,"typeName","yorkie.v1.DeactivateClientResponse"),c(Fn,"fields",f.util.newFieldList(()=>[]));let fa=Fn;const Ln=class Ln extends P{constructor(t){super();c(this,"clientId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};c(Ln,"runtime",f),c(Ln,"typeName","yorkie.v1.AttachDocumentRequest"),c(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:or}]));let ha=Ln;const Jn=class Jn extends P{constructor(t){super();c(this,"documentId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};c(Jn,"runtime",f),c(Jn,"typeName","yorkie.v1.AttachDocumentResponse"),c(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:or}]));let da=Jn;const Mn=class Mn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");c(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};c(Mn,"runtime",f),c(Mn,"typeName","yorkie.v1.DetachDocumentRequest"),c(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let ga=Mn;const $n=class $n extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};c($n,"runtime",f),c($n,"typeName","yorkie.v1.DetachDocumentResponse"),c($n,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:or}]));let ma=$n;const Un=class Un extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};c(Un,"runtime",f),c(Un,"typeName","yorkie.v1.WatchDocumentRequest"),c(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let pa=Un;const qn=class qn extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};c(qn,"runtime",f),c(qn,"typeName","yorkie.v1.WatchDocumentResponse"),c(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:va,oneof:"body"},{no:2,name:"event",kind:"message",T:aa,oneof:"body"}]));let ya=qn;const zn=class zn extends P{constructor(t){super();c(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};c(zn,"runtime",f),c(zn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),c(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let va=zn;const Kn=class Kn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};c(Kn,"runtime",f),c(Kn,"typeName","yorkie.v1.RemoveDocumentRequest"),c(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or}]));let wa=Kn;const Vn=class Vn extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};c(Vn,"runtime",f),c(Vn,"typeName","yorkie.v1.RemoveDocumentResponse"),c(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:or}]));let ba=Vn;const jn=class jn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");c(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};c(jn,"runtime",f),c(jn,"typeName","yorkie.v1.PushPullChangesRequest"),c(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or},{no:4,name:"push_only",kind:"scalar",T:8}]));let Ta=jn;const Wn=class Wn extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Wn().fromBinary(t,r)}static fromJson(t,r){return new Wn().fromJson(t,r)}static fromJsonString(t,r){return new Wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Wn,t,r)}};c(Wn,"runtime",f),c(Wn,"typeName","yorkie.v1.PushPullChangesResponse"),c(Wn,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:or}]));let Aa=Wn;const Hn=class Hn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"topic","");c(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};c(Hn,"runtime",f),c(Hn,"typeName","yorkie.v1.BroadcastRequest"),c(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Ia=Hn;const Gn=class Gn extends P{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Gn().fromBinary(e,t)}static fromJson(e,t){return new Gn().fromJson(e,t)}static fromJsonString(e,t){return new Gn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gn,e,t)}};c(Gn,"runtime",f),c(Gn,"typeName","yorkie.v1.BroadcastResponse"),c(Gn,"fields",f.util.newFieldList(()=>[]));let Sa=Gn;const Gm={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:ca,O:ua,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:la,O:fa,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:ha,O:da,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:ga,O:ma,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:wa,O:ba,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:Ta,O:Aa,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:pa,O:ya,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:Ia,O:Sa,kind:Fe.Unary}}},_m=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Xn}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:Ym,repeated:!0}]);const Ym=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:Xm,repeated:!0}]);const Xm=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:Zm,repeated:!0}]);const Zm=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Qm,repeated:!0}]);const Qm=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var y=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(y||{});class w extends Error{constructor(t,r){super(r);c(this,"name","YorkieError");c(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function dt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const pf=n=>n?Object.entries(n).length===0:!0,ds=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},ss=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Tr=(n=>(n.Put="put",n.Clear="clear",n))(Tr||{});class Lo{constructor(e,t){c(this,"context");c(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:dt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const nc="000000000000000000000000";class ct{constructor(e,t,r){c(this,"lamport");c(this,"delimiter");c(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new ct(e,t,r)}static fromStruct(e){return ct.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new ct(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const yf=0,Ds=9223372036854775807n,bt=new ct(0n,yf,nc);function Ut(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` +var Qf=Object.defineProperty;var eh=(n,e,t)=>e in n?Qf(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>eh(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();function Oa(n,e){const t=Object.create(null),r=n.split(",");for(let s=0;s!!t[s]}const ue={},es=[],qt=()=>{},th=()=>!1,nh=/^on[^a-z]/,io=n=>nh.test(n),Da=n=>n.startsWith("onUpdate:"),ke=Object.assign,Ba=(n,e)=>{const t=n.indexOf(e);t>-1&&n.splice(t,1)},rh=Object.prototype.hasOwnProperty,Z=(n,e)=>rh.call(n,e),j=Array.isArray,ts=n=>oo(n)==="[object Map]",Yu=n=>oo(n)==="[object Set]",_=n=>typeof n=="function",Ae=n=>typeof n=="string",Ra=n=>typeof n=="symbol",de=n=>n!==null&&typeof n=="object",Xu=n=>de(n)&&_(n.then)&&_(n.catch),Zu=Object.prototype.toString,oo=n=>Zu.call(n),sh=n=>oo(n).slice(8,-1),Qu=n=>oo(n)==="[object Object]",Fa=n=>Ae(n)&&n!=="NaN"&&n[0]!=="-"&&""+parseInt(n,10)===n,vi=Oa(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),ao=n=>{const e=Object.create(null);return t=>e[t]||(e[t]=n(t))},ih=/-(\w)/g,as=ao(n=>n.replace(ih,(e,t)=>t?t.toUpperCase():"")),oh=/\B([A-Z])/g,Kr=ao(n=>n.replace(oh,"-$1").toLowerCase()),el=ao(n=>n.charAt(0).toUpperCase()+n.slice(1)),ko=ao(n=>n?`on${el(n)}`:""),Pi=(n,e)=>!Object.is(n,e),wi=(n,e)=>{for(let t=0;t{Object.defineProperty(n,e,{configurable:!0,enumerable:!1,value:t})},zo=n=>{const e=parseFloat(n);return isNaN(e)?n:e};let kc;const Ko=()=>kc||(kc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function La(n){if(j(n)){const e={};for(let t=0;t{if(t){const r=t.split(ch);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function Ja(n){let e="";if(Ae(n))e=n;else if(j(n))for(let t=0;tAe(n)?n:n==null?"":j(n)||de(n)&&(n.toString===Zu||!_(n.toString))?JSON.stringify(n,nl,2):String(n),nl=(n,e)=>e&&e.__v_isRef?nl(n,e.value):ts(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((t,[r,s])=>(t[`${r} =>`]=s,t),{})}:Yu(e)?{[`Set(${e.size})`]:[...e.values()]}:de(e)&&!j(e)&&!Qu(e)?String(e):e;let ht;class dh{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=ht,!e&&ht&&(this.index=(ht.scopes||(ht.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const t=ht;try{return ht=this,e()}finally{ht=t}}}on(){ht=this}off(){ht=this.parent}stop(e){if(this._active){let t,r;for(t=0,r=this.effects.length;t{const e=new Set(n);return e.w=0,e.n=0,e},rl=n=>(n.w&wr)>0,sl=n=>(n.n&wr)>0,ph=({deps:n})=>{if(n.length)for(let e=0;e{const{deps:e}=n;if(e.length){let t=0;for(let r=0;r{(h==="length"||h>=u)&&a.push(l)})}else switch(t!==void 0&&a.push(o.get(t)),e){case"add":j(n)?Fa(t)&&a.push(o.get("length")):(a.push(o.get(Fr)),ts(n)&&a.push(o.get(Wo)));break;case"delete":j(n)||(a.push(o.get(Fr)),ts(n)&&a.push(o.get(Wo)));break;case"set":ts(n)&&a.push(o.get(Fr));break}if(a.length===1)a[0]&&Ho(a[0]);else{const u=[];for(const l of a)l&&u.push(...l);Ho(Ma(u))}}function Ho(n,e){const t=j(n)?n:[...n];for(const r of t)r.computed&&Nc(r);for(const r of t)r.computed||Nc(r)}function Nc(n,e){(n!==gt||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const vh=Oa("__proto__,__v_isRef,__isVue"),al=new Set(Object.getOwnPropertyNames(Symbol).filter(n=>n!=="arguments"&&n!=="caller").map(n=>Symbol[n]).filter(Ra)),wh=Ua(),bh=Ua(!1,!0),Th=Ua(!0),Pc=Ah();function Ah(){const n={};return["includes","indexOf","lastIndexOf"].forEach(e=>{n[e]=function(...t){const r=re(this);for(let i=0,o=this.length;i{n[e]=function(...t){vs();const r=re(this)[e].apply(this,t);return ws(),r}}),n}function Ih(n){const e=re(this);return qe(e,"has",n),e.hasOwnProperty(n)}function Ua(n=!1,e=!1){return function(r,s,i){if(s==="__v_isReactive")return!n;if(s==="__v_isReadonly")return n;if(s==="__v_isShallow")return e;if(s==="__v_raw"&&i===(n?e?$h:hl:e?fl:ll).get(r))return r;const o=j(r);if(!n){if(o&&Z(Pc,s))return Reflect.get(Pc,s,i);if(s==="hasOwnProperty")return Ih}const a=Reflect.get(r,s,i);return(Ra(s)?al.has(s):vh(s))||(n||qe(r,"get",s),e)?a:Je(a)?o&&Fa(s)?a:a.value:de(a)?n?dl(a):Ka(a):a}}const Sh=cl(),xh=cl(!0);function cl(n=!1){return function(t,r,s,i){let o=t[r];if(Fs(o)&&Je(o)&&!Je(s))return!1;if(!n&&(!Go(s)&&!Fs(s)&&(o=re(o),s=re(s)),!j(t)&&Je(o)&&!Je(s)))return o.value=s,!0;const a=j(t)&&Fa(r)?Number(r)n,co=n=>Reflect.getPrototypeOf(n);function ii(n,e,t=!1,r=!1){n=n.__v_raw;const s=re(n),i=re(e);t||(e!==i&&qe(s,"get",e),qe(s,"get",i));const{has:o}=co(s),a=r?qa:t?Wa:ja;if(o.call(s,e))return a(n.get(e));if(o.call(s,i))return a(n.get(i));n!==s&&n.get(e)}function oi(n,e=!1){const t=this.__v_raw,r=re(t),s=re(n);return e||(n!==s&&qe(r,"has",n),qe(r,"has",s)),n===s?t.has(n):t.has(n)||t.has(s)}function ai(n,e=!1){return n=n.__v_raw,!e&&qe(re(n),"iterate",Fr),Reflect.get(n,"size",n)}function Oc(n){n=re(n);const e=re(this);return co(e).has.call(e,n)||(e.add(n),nr(e,"add",n,n)),this}function Dc(n,e){e=re(e);const t=re(this),{has:r,get:s}=co(t);let i=r.call(t,n);i||(n=re(n),i=r.call(t,n));const o=s.call(t,n);return t.set(n,e),i?Pi(e,o)&&nr(t,"set",n,e):nr(t,"add",n,e),this}function Bc(n){const e=re(this),{has:t,get:r}=co(e);let s=t.call(e,n);s||(n=re(n),s=t.call(e,n)),r&&r.call(e,n);const i=e.delete(n);return s&&nr(e,"delete",n,void 0),i}function Rc(){const n=re(this),e=n.size!==0,t=n.clear();return e&&nr(n,"clear",void 0,void 0),t}function ci(n,e){return function(r,s){const i=this,o=i.__v_raw,a=re(o),u=e?qa:n?Wa:ja;return!n&&qe(a,"iterate",Fr),o.forEach((l,h)=>r.call(s,u(l),u(h),i))}}function ui(n,e,t){return function(...r){const s=this.__v_raw,i=re(s),o=ts(i),a=n==="entries"||n===Symbol.iterator&&o,u=n==="keys"&&o,l=s[n](...r),h=t?qa:e?Wa:ja;return!e&&qe(i,"iterate",u?Wo:Fr),{next(){const{value:d,done:v}=l.next();return v?{value:d,done:v}:{value:a?[h(d[0]),h(d[1])]:h(d),done:v}},[Symbol.iterator](){return this}}}}function ar(n){return function(...e){return n==="delete"?!1:this}}function Oh(){const n={get(i){return ii(this,i)},get size(){return ai(this)},has:oi,add:Oc,set:Dc,delete:Bc,clear:Rc,forEach:ci(!1,!1)},e={get(i){return ii(this,i,!1,!0)},get size(){return ai(this)},has:oi,add:Oc,set:Dc,delete:Bc,clear:Rc,forEach:ci(!1,!0)},t={get(i){return ii(this,i,!0)},get size(){return ai(this,!0)},has(i){return oi.call(this,i,!0)},add:ar("add"),set:ar("set"),delete:ar("delete"),clear:ar("clear"),forEach:ci(!0,!1)},r={get(i){return ii(this,i,!0,!0)},get size(){return ai(this,!0)},has(i){return oi.call(this,i,!0)},add:ar("add"),set:ar("set"),delete:ar("delete"),clear:ar("clear"),forEach:ci(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(i=>{n[i]=ui(i,!1,!1),t[i]=ui(i,!0,!1),e[i]=ui(i,!1,!0),r[i]=ui(i,!0,!0)}),[n,t,e,r]}const[Dh,Bh,Rh,Fh]=Oh();function za(n,e){const t=e?n?Fh:Rh:n?Bh:Dh;return(r,s,i)=>s==="__v_isReactive"?!n:s==="__v_isReadonly"?n:s==="__v_raw"?r:Reflect.get(Z(t,s)&&s in r?t:r,s,i)}const Lh={get:za(!1,!1)},Jh={get:za(!1,!0)},Mh={get:za(!0,!1)},ll=new WeakMap,fl=new WeakMap,hl=new WeakMap,$h=new WeakMap;function Uh(n){switch(n){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function qh(n){return n.__v_skip||!Object.isExtensible(n)?0:Uh(sh(n))}function Ka(n){return Fs(n)?n:Va(n,!1,ul,Lh,ll)}function zh(n){return Va(n,!1,Ph,Jh,fl)}function dl(n){return Va(n,!0,Nh,Mh,hl)}function Va(n,e,t,r,s){if(!de(n)||n.__v_raw&&!(e&&n.__v_isReactive))return n;const i=s.get(n);if(i)return i;const o=qh(n);if(o===0)return n;const a=new Proxy(n,o===2?r:t);return s.set(n,a),a}function ns(n){return Fs(n)?ns(n.__v_raw):!!(n&&n.__v_isReactive)}function Fs(n){return!!(n&&n.__v_isReadonly)}function Go(n){return!!(n&&n.__v_isShallow)}function gl(n){return ns(n)||Fs(n)}function re(n){const e=n&&n.__v_raw;return e?re(e):n}function ml(n){return Oi(n,"__v_skip",!0),n}const ja=n=>de(n)?Ka(n):n,Wa=n=>de(n)?dl(n):n;function Kh(n){gr&>&&(n=re(n),ol(n.dep||(n.dep=Ma())))}function Vh(n,e){n=re(n);const t=n.dep;t&&Ho(t)}function Je(n){return!!(n&&n.__v_isRef===!0)}function jh(n){return Je(n)?n.value:n}const Wh={get:(n,e,t)=>jh(Reflect.get(n,e,t)),set:(n,e,t,r)=>{const s=n[e];return Je(s)&&!Je(t)?(s.value=t,!0):Reflect.set(n,e,t,r)}};function pl(n){return ns(n)?n:new Proxy(n,Wh)}class Hh{constructor(e,t,r,s){this._setter=t,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new $a(e,()=>{this._dirty||(this._dirty=!0,Vh(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!s,this.__v_isReadonly=r}get value(){const e=re(this);return Kh(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}function Gh(n,e,t=!1){let r,s;const i=_(n);return i?(r=n,s=qt):(r=n.get,s=n.set),new Hh(r,s,i||!s,t)}function mr(n,e,t,r){let s;try{s=r?n(...r):n()}catch(i){uo(i,e,t)}return s}function wt(n,e,t,r){if(_(n)){const i=mr(n,e,t,r);return i&&Xu(i)&&i.catch(o=>{uo(o,e,t)}),i}const s=[];for(let i=0;i>>1;Js(Ne[r])Pt&&Ne.splice(e,1)}function Qh(n){j(n)?rs.push(...n):(!Gt||!Gt.includes(n,n.allowRecurse?Pr+1:Pr))&&rs.push(n),vl()}function Fc(n,e=Ls?Pt+1:0){for(;eJs(t)-Js(r)),Pr=0;Prn.id==null?1/0:n.id,ed=(n,e)=>{const t=Js(n)-Js(e);if(t===0){if(n.pre&&!e.pre)return-1;if(e.pre&&!n.pre)return 1}return t};function bl(n){_o=!1,Ls=!0,Ne.sort(ed);try{for(Pt=0;PtAe(p)?p.trim():p)),d&&(s=t.map(zo))}let a,u=r[a=ko(e)]||r[a=ko(as(e))];!u&&i&&(u=r[a=ko(Kr(e))]),u&&wt(u,n,6,s);const l=r[a+"Once"];if(l){if(!n.emitted)n.emitted={};else if(n.emitted[a])return;n.emitted[a]=!0,wt(l,n,6,s)}}function Tl(n,e,t=!1){const r=e.emitsCache,s=r.get(n);if(s!==void 0)return s;const i=n.emits;let o={},a=!1;if(!_(n)){const u=l=>{const h=Tl(l,e,!0);h&&(a=!0,ke(o,h))};!t&&e.mixins.length&&e.mixins.forEach(u),n.extends&&u(n.extends),n.mixins&&n.mixins.forEach(u)}return!i&&!a?(de(n)&&r.set(n,null),null):(j(i)?i.forEach(u=>o[u]=null):ke(o,i),de(n)&&r.set(n,o),o)}function lo(n,e){return!n||!io(e)?!1:(e=e.slice(2).replace(/Once$/,""),Z(n,e[0].toLowerCase()+e.slice(1))||Z(n,Kr(e))||Z(n,e))}let mt=null,Al=null;function Di(n){const e=mt;return mt=n,Al=n&&n.type.__scopeId||null,e}function nd(n,e=mt,t){if(!e||n._n)return n;const r=(...s)=>{r._d&&Hc(-1);const i=Di(e);let o;try{o=n(...s)}finally{Di(i),r._d&&Hc(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function Eo(n){const{type:e,vnode:t,proxy:r,withProxy:s,props:i,propsOptions:[o],slots:a,attrs:u,emit:l,render:h,renderCache:d,data:v,setupState:p,ctx:A,inheritAttrs:I}=n;let D,L;const $=Di(n);try{if(t.shapeFlag&4){const U=s||r;D=Nt(h.call(U,U,d,i,p,v,A)),L=u}else{const U=e;D=Nt(U.length>1?U(i,{attrs:u,slots:a,emit:l}):U(i,null)),L=e.props?u:rd(u)}}catch(U){Ns.length=0,uo(U,n,1),D=Lr(Ms)}let V=D;if(L&&I!==!1){const U=Object.keys(L),{shapeFlag:W}=V;U.length&&W&7&&(o&&U.some(Da)&&(L=sd(L,o)),V=cs(V,L))}return t.dirs&&(V=cs(V),V.dirs=V.dirs?V.dirs.concat(t.dirs):t.dirs),t.transition&&(V.transition=t.transition),D=V,Di($),D}const rd=n=>{let e;for(const t in n)(t==="class"||t==="style"||io(t))&&((e||(e={}))[t]=n[t]);return e},sd=(n,e)=>{const t={};for(const r in n)(!Da(r)||!(r.slice(9)in e))&&(t[r]=n[r]);return t};function id(n,e,t){const{props:r,children:s,component:i}=n,{props:o,children:a,patchFlag:u}=e,l=i.emitsOptions;if(e.dirs||e.transition)return!0;if(t&&u>=0){if(u&1024)return!0;if(u&16)return r?Lc(r,o,l):!!o;if(u&8){const h=e.dynamicProps;for(let d=0;dn.__isSuspense;function cd(n,e){e&&e.pendingBranch?j(n)?e.effects.push(...n):e.effects.push(n):Qh(n)}const li={};function Co(n,e,t){return Il(n,e,t)}function Il(n,e,{immediate:t,deep:r,flush:s,onTrack:i,onTrigger:o}=ue){var a;const u=mh()===((a=Pe)==null?void 0:a.scope)?Pe:null;let l,h=!1,d=!1;if(Je(n)?(l=()=>n.value,h=Go(n)):ns(n)?(l=()=>n,r=!0):j(n)?(d=!0,h=n.some(U=>ns(U)||Go(U)),l=()=>n.map(U=>{if(Je(U))return U.value;if(ns(U))return Dr(U);if(_(U))return mr(U,u,2)})):_(n)?e?l=()=>mr(n,u,2):l=()=>{if(!(u&&u.isUnmounted))return v&&v(),wt(n,u,3,[p])}:l=qt,e&&r){const U=l;l=()=>Dr(U())}let v,p=U=>{v=$.onStop=()=>{mr(U,u,4)}},A;if(Us)if(p=qt,e?t&&wt(e,u,3,[l(),d?[]:void 0,p]):l(),s==="sync"){const U=rg();A=U.__watcherHandles||(U.__watcherHandles=[])}else return qt;let I=d?new Array(n.length).fill(li):li;const D=()=>{if($.active)if(e){const U=$.run();(r||h||(d?U.some((W,ee)=>Pi(W,I[ee])):Pi(U,I)))&&(v&&v(),wt(e,u,3,[U,I===li?void 0:d&&I[0]===li?[]:I,p]),I=U)}else $.run()};D.allowRecurse=!!e;let L;s==="sync"?L=D:s==="post"?L=()=>Me(D,u&&u.suspense):(D.pre=!0,u&&(D.id=u.uid),L=()=>Ga(D));const $=new $a(l,L);e?t?D():I=$.run():s==="post"?Me($.run.bind($),u&&u.suspense):$.run();const V=()=>{$.stop(),u&&u.scope&&Ba(u.scope.effects,$)};return A&&A.push(V),V}function ud(n,e,t){const r=this.proxy,s=Ae(n)?n.includes(".")?Sl(r,n):()=>r[n]:n.bind(r,r);let i;_(e)?i=e:(i=e.handler,t=e);const o=Pe;us(this);const a=Il(s,i.bind(r),t);return o?us(o):Jr(),a}function Sl(n,e){const t=e.split(".");return()=>{let r=n;for(let s=0;s{Dr(t,e)});else if(Qu(n))for(const t in n)Dr(n[t],e);return n}function Jc(n,e){const t=mt;if(t===null)return n;const r=mo(t)||t.proxy,s=n.dirs||(n.dirs=[]);for(let i=0;i!!n.type.__asyncLoader,xl=n=>n.type.__isKeepAlive;function ld(n,e){kl(n,"a",e)}function fd(n,e){kl(n,"da",e)}function kl(n,e,t=Pe){const r=n.__wdc||(n.__wdc=()=>{let s=t;for(;s;){if(s.isDeactivated)return;s=s.parent}return n()});if(fo(e,r,t),t){let s=t.parent;for(;s&&s.parent;)xl(s.parent.vnode)&&hd(r,e,t,s),s=s.parent}}function hd(n,e,t,r){const s=fo(e,n,r,!0);El(()=>{Ba(r[e],s)},t)}function fo(n,e,t=Pe,r=!1){if(t){const s=t[n]||(t[n]=[]),i=e.__weh||(e.__weh=(...o)=>{if(t.isUnmounted)return;vs(),us(t);const a=wt(e,t,n,o);return Jr(),ws(),a});return r?s.unshift(i):s.push(i),i}}const ir=n=>(e,t=Pe)=>(!Us||n==="sp")&&fo(n,(...r)=>e(...r),t),dd=ir("bm"),gd=ir("m"),md=ir("bu"),pd=ir("u"),yd=ir("bum"),El=ir("um"),vd=ir("sp"),wd=ir("rtg"),bd=ir("rtc");function Td(n,e=Pe){fo("ec",n,e)}const Ad=Symbol.for("v-ndc");function Mc(n,e,t,r){let s;const i=t;if(j(n)||Ae(n)){s=new Array(n.length);for(let o=0,a=n.length;oe(o,a,void 0,i));else{const o=Object.keys(n);s=new Array(o.length);for(let a=0,u=o.length;an?Ml(n)?mo(n)||n.proxy:Yo(n.parent):null,Cs=ke(Object.create(null),{$:n=>n,$el:n=>n.vnode.el,$data:n=>n.data,$props:n=>n.props,$attrs:n=>n.attrs,$slots:n=>n.slots,$refs:n=>n.refs,$parent:n=>Yo(n.parent),$root:n=>Yo(n.root),$emit:n=>n.emit,$options:n=>_a(n),$forceUpdate:n=>n.f||(n.f=()=>Ga(n.update)),$nextTick:n=>n.n||(n.n=Yh.bind(n.proxy)),$watch:n=>ud.bind(n)}),No=(n,e)=>n!==ue&&!n.__isScriptSetup&&Z(n,e),Id={get({_:n},e){const{ctx:t,setupState:r,data:s,props:i,accessCache:o,type:a,appContext:u}=n;let l;if(e[0]!=="$"){const p=o[e];if(p!==void 0)switch(p){case 1:return r[e];case 2:return s[e];case 4:return t[e];case 3:return i[e]}else{if(No(r,e))return o[e]=1,r[e];if(s!==ue&&Z(s,e))return o[e]=2,s[e];if((l=n.propsOptions[0])&&Z(l,e))return o[e]=3,i[e];if(t!==ue&&Z(t,e))return o[e]=4,t[e];Xo&&(o[e]=0)}}const h=Cs[e];let d,v;if(h)return e==="$attrs"&&qe(n,"get",e),h(n);if((d=a.__cssModules)&&(d=d[e]))return d;if(t!==ue&&Z(t,e))return o[e]=4,t[e];if(v=u.config.globalProperties,Z(v,e))return v[e]},set({_:n},e,t){const{data:r,setupState:s,ctx:i}=n;return No(s,e)?(s[e]=t,!0):r!==ue&&Z(r,e)?(r[e]=t,!0):Z(n.props,e)||e[0]==="$"&&e.slice(1)in n?!1:(i[e]=t,!0)},has({_:{data:n,setupState:e,accessCache:t,ctx:r,appContext:s,propsOptions:i}},o){let a;return!!t[o]||n!==ue&&Z(n,o)||No(e,o)||(a=i[0])&&Z(a,o)||Z(r,o)||Z(Cs,o)||Z(s.config.globalProperties,o)},defineProperty(n,e,t){return t.get!=null?n._.accessCache[e]=0:Z(t,"value")&&this.set(n,e,t.value,null),Reflect.defineProperty(n,e,t)}};function $c(n){return j(n)?n.reduce((e,t)=>(e[t]=null,e),{}):n}let Xo=!0;function Sd(n){const e=_a(n),t=n.proxy,r=n.ctx;Xo=!1,e.beforeCreate&&Uc(e.beforeCreate,n,"bc");const{data:s,computed:i,methods:o,watch:a,provide:u,inject:l,created:h,beforeMount:d,mounted:v,beforeUpdate:p,updated:A,activated:I,deactivated:D,beforeDestroy:L,beforeUnmount:$,destroyed:V,unmounted:U,render:W,renderTracked:ee,renderTriggered:oe,errorCaptured:te,serverPrefetch:Ee,expose:Ie,inheritAttrs:Ge,components:Ir,directives:ni,filters:xo}=e;if(l&&xd(l,r,null),o)for(const ge in o){const ae=o[ge];_(ae)&&(r[ge]=ae.bind(t))}if(s){const ge=s.call(t,t);de(ge)&&(n.data=Ka(ge))}if(Xo=!0,i)for(const ge in i){const ae=i[ge],Sr=_(ae)?ae.bind(t,t):_(ae.get)?ae.get.bind(t,t):qt,ri=!_(ae)&&_(ae.set)?ae.set.bind(t):qt,xr=tg({get:Sr,set:ri});Object.defineProperty(r,ge,{enumerable:!0,configurable:!0,get:()=>xr.value,set:St=>xr.value=St})}if(a)for(const ge in a)Cl(a[ge],r,t,ge);if(u){const ge=_(u)?u.call(t):u;Reflect.ownKeys(ge).forEach(ae=>{Od(ae,ge[ae])})}h&&Uc(h,n,"c");function De(ge,ae){j(ae)?ae.forEach(Sr=>ge(Sr.bind(t))):ae&&ge(ae.bind(t))}if(De(dd,d),De(gd,v),De(md,p),De(pd,A),De(ld,I),De(fd,D),De(Td,te),De(bd,ee),De(wd,oe),De(yd,$),De(El,U),De(vd,Ee),j(Ie))if(Ie.length){const ge=n.exposed||(n.exposed={});Ie.forEach(ae=>{Object.defineProperty(ge,ae,{get:()=>t[ae],set:Sr=>t[ae]=Sr})})}else n.exposed||(n.exposed={});W&&n.render===qt&&(n.render=W),Ge!=null&&(n.inheritAttrs=Ge),Ir&&(n.components=Ir),ni&&(n.directives=ni)}function xd(n,e,t=qt){j(n)&&(n=Zo(n));for(const r in n){const s=n[r];let i;de(s)?"default"in s?i=Ti(s.from||r,s.default,!0):i=Ti(s.from||r):i=Ti(s),Je(i)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):e[r]=i}}function Uc(n,e,t){wt(j(n)?n.map(r=>r.bind(e.proxy)):n.bind(e.proxy),e,t)}function Cl(n,e,t,r){const s=r.includes(".")?Sl(t,r):()=>t[r];if(Ae(n)){const i=e[n];_(i)&&Co(s,i)}else if(_(n))Co(s,n.bind(t));else if(de(n))if(j(n))n.forEach(i=>Cl(i,e,t,r));else{const i=_(n.handler)?n.handler.bind(t):e[n.handler];_(i)&&Co(s,i,n)}}function _a(n){const e=n.type,{mixins:t,extends:r}=e,{mixins:s,optionsCache:i,config:{optionMergeStrategies:o}}=n.appContext,a=i.get(e);let u;return a?u=a:!s.length&&!t&&!r?u=e:(u={},s.length&&s.forEach(l=>Bi(u,l,o,!0)),Bi(u,e,o)),de(e)&&i.set(e,u),u}function Bi(n,e,t,r=!1){const{mixins:s,extends:i}=e;i&&Bi(n,i,t,!0),s&&s.forEach(o=>Bi(n,o,t,!0));for(const o in e)if(!(r&&o==="expose")){const a=kd[o]||t&&t[o];n[o]=a?a(n[o],e[o]):e[o]}return n}const kd={data:qc,props:zc,emits:zc,methods:ks,computed:ks,beforeCreate:Be,created:Be,beforeMount:Be,mounted:Be,beforeUpdate:Be,updated:Be,beforeDestroy:Be,beforeUnmount:Be,destroyed:Be,unmounted:Be,activated:Be,deactivated:Be,errorCaptured:Be,serverPrefetch:Be,components:ks,directives:ks,watch:Cd,provide:qc,inject:Ed};function qc(n,e){return e?n?function(){return ke(_(n)?n.call(this,this):n,_(e)?e.call(this,this):e)}:e:n}function Ed(n,e){return ks(Zo(n),Zo(e))}function Zo(n){if(j(n)){const e={};for(let t=0;t1)return t&&_(e)?e.call(r&&r.proxy):e}}function Dd(n,e,t,r=!1){const s={},i={};Oi(i,go,1),n.propsDefaults=Object.create(null),Pl(n,e,s,i);for(const o in n.propsOptions[0])o in s||(s[o]=void 0);t?n.props=r?s:zh(s):n.type.props?n.props=s:n.props=i,n.attrs=i}function Bd(n,e,t,r){const{props:s,attrs:i,vnode:{patchFlag:o}}=n,a=re(s),[u]=n.propsOptions;let l=!1;if((r||o>0)&&!(o&16)){if(o&8){const h=n.vnode.dynamicProps;for(let d=0;d{u=!0;const[v,p]=Ol(d,e,!0);ke(o,v),p&&a.push(...p)};!t&&e.mixins.length&&e.mixins.forEach(h),n.extends&&h(n.extends),n.mixins&&n.mixins.forEach(h)}if(!i&&!u)return de(n)&&r.set(n,es),es;if(j(i))for(let h=0;h-1,p[1]=I<0||A-1||Z(p,"default"))&&a.push(d)}}}const l=[o,a];return de(n)&&r.set(n,l),l}function Kc(n){return n[0]!=="$"}function Vc(n){const e=n&&n.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:n===null?"null":""}function jc(n,e){return Vc(n)===Vc(e)}function Wc(n,e){return j(e)?e.findIndex(t=>jc(t,n)):_(e)&&jc(e,n)?0:-1}const Dl=n=>n[0]==="_"||n==="$stable",Ya=n=>j(n)?n.map(Nt):[Nt(n)],Rd=(n,e,t)=>{if(e._n)return e;const r=nd((...s)=>Ya(e(...s)),t);return r._c=!1,r},Bl=(n,e,t)=>{const r=n._ctx;for(const s in n){if(Dl(s))continue;const i=n[s];if(_(i))e[s]=Rd(s,i,r);else if(i!=null){const o=Ya(i);e[s]=()=>o}}},Rl=(n,e)=>{const t=Ya(e);n.slots.default=()=>t},Fd=(n,e)=>{if(n.vnode.shapeFlag&32){const t=e._;t?(n.slots=re(e),Oi(e,"_",t)):Bl(e,n.slots={})}else n.slots={},e&&Rl(n,e);Oi(n.slots,go,1)},Ld=(n,e,t)=>{const{vnode:r,slots:s}=n;let i=!0,o=ue;if(r.shapeFlag&32){const a=e._;a?t&&a===1?i=!1:(ke(s,e),!t&&a===1&&delete s._):(i=!e.$stable,Bl(e,s)),o=e}else e&&(Rl(n,e),o={default:1});if(i)for(const a in s)!Dl(a)&&!(a in o)&&delete s[a]};function ea(n,e,t,r,s=!1){if(j(n)){n.forEach((v,p)=>ea(v,e&&(j(e)?e[p]:e),t,r,s));return}if(bi(r)&&!s)return;const i=r.shapeFlag&4?mo(r.component)||r.component.proxy:r.el,o=s?null:i,{i:a,r:u}=n,l=e&&e.r,h=a.refs===ue?a.refs={}:a.refs,d=a.setupState;if(l!=null&&l!==u&&(Ae(l)?(h[l]=null,Z(d,l)&&(d[l]=null)):Je(l)&&(l.value=null)),_(u))mr(u,a,12,[o,h]);else{const v=Ae(u),p=Je(u);if(v||p){const A=()=>{if(n.f){const I=v?Z(d,u)?d[u]:h[u]:u.value;s?j(I)&&Ba(I,i):j(I)?I.includes(i)||I.push(i):v?(h[u]=[i],Z(d,u)&&(d[u]=h[u])):(u.value=[i],n.k&&(h[n.k]=u.value))}else v?(h[u]=o,Z(d,u)&&(d[u]=o)):p&&(u.value=o,n.k&&(h[n.k]=o))};o?(A.id=-1,Me(A,t)):A()}}}const Me=cd;function Jd(n){return Md(n)}function Md(n,e){const t=Ko();t.__VUE__=!0;const{insert:r,remove:s,patchProp:i,createElement:o,createText:a,createComment:u,setText:l,setElementText:h,parentNode:d,nextSibling:v,setScopeId:p=qt,insertStaticContent:A}=n,I=(g,m,T,x=null,S=null,N=null,B=!1,C=null,O=!!m.dynamicChildren)=>{if(g===m)return;g&&!As(g,m)&&(x=si(g),St(g,S,N,!0),g=null),m.patchFlag===-2&&(O=!1,m.dynamicChildren=null);const{type:k,ref:q,shapeFlag:R}=m;switch(k){case ho:D(g,m,T,x);break;case Ms:L(g,m,T,x);break;case Po:g==null&&$(m,T,x,B);break;case _e:Ir(g,m,T,x,S,N,B,C,O);break;default:R&1?W(g,m,T,x,S,N,B,C,O):R&6?ni(g,m,T,x,S,N,B,C,O):(R&64||R&128)&&k.process(g,m,T,x,S,N,B,C,O,bs)}q!=null&&S&&ea(q,g&&g.ref,N,m||g,!m)},D=(g,m,T,x)=>{if(g==null)r(m.el=a(m.children),T,x);else{const S=m.el=g.el;m.children!==g.children&&l(S,m.children)}},L=(g,m,T,x)=>{g==null?r(m.el=u(m.children||""),T,x):m.el=g.el},$=(g,m,T,x)=>{[g.el,g.anchor]=A(g.children,m,T,x,g.el,g.anchor)},V=({el:g,anchor:m},T,x)=>{let S;for(;g&&g!==m;)S=v(g),r(g,T,x),g=S;r(m,T,x)},U=({el:g,anchor:m})=>{let T;for(;g&&g!==m;)T=v(g),s(g),g=T;s(m)},W=(g,m,T,x,S,N,B,C,O)=>{B=B||m.type==="svg",g==null?ee(m,T,x,S,N,B,C,O):Ee(g,m,S,N,B,C,O)},ee=(g,m,T,x,S,N,B,C)=>{let O,k;const{type:q,props:R,shapeFlag:z,transition:H,dirs:Y}=g;if(O=g.el=o(g.type,N,R&&R.is,R),z&8?h(O,g.children):z&16&&te(g.children,O,null,x,S,N&&q!=="foreignObject",B,C),Y&&kr(g,null,x,"created"),oe(O,g,g.scopeId,B,x),R){for(const se in R)se!=="value"&&!vi(se)&&i(O,se,null,R[se],N,g.children,x,S,Vt);"value"in R&&i(O,"value",null,R.value),(k=R.onVnodeBeforeMount)&&kt(k,x,g)}Y&&kr(g,null,x,"beforeMount");const ce=(!S||S&&!S.pendingBranch)&&H&&!H.persisted;ce&&H.beforeEnter(O),r(O,m,T),((k=R&&R.onVnodeMounted)||ce||Y)&&Me(()=>{k&&kt(k,x,g),ce&&H.enter(O),Y&&kr(g,null,x,"mounted")},S)},oe=(g,m,T,x,S)=>{if(T&&p(g,T),x)for(let N=0;N{for(let k=O;k{const C=m.el=g.el;let{patchFlag:O,dynamicChildren:k,dirs:q}=m;O|=g.patchFlag&16;const R=g.props||ue,z=m.props||ue;let H;T&&Er(T,!1),(H=z.onVnodeBeforeUpdate)&&kt(H,T,m,g),q&&kr(m,g,T,"beforeUpdate"),T&&Er(T,!0);const Y=S&&m.type!=="foreignObject";if(k?Ie(g.dynamicChildren,k,C,T,x,Y,N):B||ae(g,m,C,null,T,x,Y,N,!1),O>0){if(O&16)Ge(C,m,R,z,T,x,S);else if(O&2&&R.class!==z.class&&i(C,"class",null,z.class,S),O&4&&i(C,"style",R.style,z.style,S),O&8){const ce=m.dynamicProps;for(let se=0;se{H&&kt(H,T,m,g),q&&kr(m,g,T,"updated")},x)},Ie=(g,m,T,x,S,N,B)=>{for(let C=0;C{if(T!==x){if(T!==ue)for(const C in T)!vi(C)&&!(C in x)&&i(g,C,T[C],null,B,m.children,S,N,Vt);for(const C in x){if(vi(C))continue;const O=x[C],k=T[C];O!==k&&C!=="value"&&i(g,C,k,O,B,m.children,S,N,Vt)}"value"in x&&i(g,"value",T.value,x.value)}},Ir=(g,m,T,x,S,N,B,C,O)=>{const k=m.el=g?g.el:a(""),q=m.anchor=g?g.anchor:a("");let{patchFlag:R,dynamicChildren:z,slotScopeIds:H}=m;H&&(C=C?C.concat(H):H),g==null?(r(k,T,x),r(q,T,x),te(m.children,T,q,S,N,B,C,O)):R>0&&R&64&&z&&g.dynamicChildren?(Ie(g.dynamicChildren,z,T,S,N,B,C),(m.key!=null||S&&m===S.subTree)&&Fl(g,m,!0)):ae(g,m,T,q,S,N,B,C,O)},ni=(g,m,T,x,S,N,B,C,O)=>{m.slotScopeIds=C,g==null?m.shapeFlag&512?S.ctx.activate(m,T,x,B,O):xo(m,T,x,S,N,B,O):vc(g,m,O)},xo=(g,m,T,x,S,N,B)=>{const C=g.component=_d(g,x,S);if(xl(g)&&(C.ctx.renderer=bs),Yd(C),C.asyncDep){if(S&&S.registerDep(C,De),!g.el){const O=C.subTree=Lr(Ms);L(null,O,m,T)}return}De(C,g,m,T,S,N,B)},vc=(g,m,T)=>{const x=m.component=g.component;if(id(g,m,T))if(x.asyncDep&&!x.asyncResolved){ge(x,m,T);return}else x.next=m,Zh(x.update),x.update();else m.el=g.el,x.vnode=m},De=(g,m,T,x,S,N,B)=>{const C=()=>{if(g.isMounted){let{next:q,bu:R,u:z,parent:H,vnode:Y}=g,ce=q,se;Er(g,!1),q?(q.el=Y.el,ge(g,q,B)):q=Y,R&&wi(R),(se=q.props&&q.props.onVnodeBeforeUpdate)&&kt(se,H,q,Y),Er(g,!0);const we=Eo(g),ft=g.subTree;g.subTree=we,I(ft,we,d(ft.el),si(ft),g,S,N),q.el=we.el,ce===null&&od(g,we.el),z&&Me(z,S),(se=q.props&&q.props.onVnodeUpdated)&&Me(()=>kt(se,H,q,Y),S)}else{let q;const{el:R,props:z}=m,{bm:H,m:Y,parent:ce}=g,se=bi(m);if(Er(g,!1),H&&wi(H),!se&&(q=z&&z.onVnodeBeforeMount)&&kt(q,ce,m),Er(g,!0),R&&Ac){const we=()=>{g.subTree=Eo(g),Ac(R,g.subTree,g,S,null)};se?m.type.__asyncLoader().then(()=>!g.isUnmounted&&we()):we()}else{const we=g.subTree=Eo(g);I(null,we,T,x,g,S,N),m.el=we.el}if(Y&&Me(Y,S),!se&&(q=z&&z.onVnodeMounted)){const we=m;Me(()=>kt(q,ce,we),S)}(m.shapeFlag&256||ce&&bi(ce.vnode)&&ce.vnode.shapeFlag&256)&&g.a&&Me(g.a,S),g.isMounted=!0,m=T=x=null}},O=g.effect=new $a(C,()=>Ga(k),g.scope),k=g.update=()=>O.run();k.id=g.uid,Er(g,!0),k()},ge=(g,m,T)=>{m.component=g;const x=g.vnode.props;g.vnode=m,g.next=null,Bd(g,m.props,x,T),Ld(g,m.children,T),vs(),Fc(),ws()},ae=(g,m,T,x,S,N,B,C,O=!1)=>{const k=g&&g.children,q=g?g.shapeFlag:0,R=m.children,{patchFlag:z,shapeFlag:H}=m;if(z>0){if(z&128){ri(k,R,T,x,S,N,B,C,O);return}else if(z&256){Sr(k,R,T,x,S,N,B,C,O);return}}H&8?(q&16&&Vt(k,S,N),R!==k&&h(T,R)):q&16?H&16?ri(k,R,T,x,S,N,B,C,O):Vt(k,S,N,!0):(q&8&&h(T,""),H&16&&te(R,T,x,S,N,B,C,O))},Sr=(g,m,T,x,S,N,B,C,O)=>{g=g||es,m=m||es;const k=g.length,q=m.length,R=Math.min(k,q);let z;for(z=0;zq?Vt(g,S,N,!0,!1,R):te(m,T,x,S,N,B,C,O,R)},ri=(g,m,T,x,S,N,B,C,O)=>{let k=0;const q=m.length;let R=g.length-1,z=q-1;for(;k<=R&&k<=z;){const H=g[k],Y=m[k]=O?hr(m[k]):Nt(m[k]);if(As(H,Y))I(H,Y,T,null,S,N,B,C,O);else break;k++}for(;k<=R&&k<=z;){const H=g[R],Y=m[z]=O?hr(m[z]):Nt(m[z]);if(As(H,Y))I(H,Y,T,null,S,N,B,C,O);else break;R--,z--}if(k>R){if(k<=z){const H=z+1,Y=Hz)for(;k<=R;)St(g[k],S,N,!0),k++;else{const H=k,Y=k,ce=new Map;for(k=Y;k<=z;k++){const Ke=m[k]=O?hr(m[k]):Nt(m[k]);Ke.key!=null&&ce.set(Ke.key,k)}let se,we=0;const ft=z-Y+1;let jr=!1,Ic=0;const Ts=new Array(ft);for(k=0;k=ft){St(Ke,S,N,!0);continue}let xt;if(Ke.key!=null)xt=ce.get(Ke.key);else for(se=Y;se<=z;se++)if(Ts[se-Y]===0&&As(Ke,m[se])){xt=se;break}xt===void 0?St(Ke,S,N,!0):(Ts[xt-Y]=k+1,xt>=Ic?Ic=xt:jr=!0,I(Ke,m[xt],T,null,S,N,B,C,O),we++)}const Sc=jr?$d(Ts):es;for(se=Sc.length-1,k=ft-1;k>=0;k--){const Ke=Y+k,xt=m[Ke],xc=Ke+1{const{el:N,type:B,transition:C,children:O,shapeFlag:k}=g;if(k&6){xr(g.component.subTree,m,T,x);return}if(k&128){g.suspense.move(m,T,x);return}if(k&64){B.move(g,m,T,bs);return}if(B===_e){r(N,m,T);for(let R=0;RC.enter(N),S);else{const{leave:R,delayLeave:z,afterLeave:H}=C,Y=()=>r(N,m,T),ce=()=>{R(N,()=>{Y(),H&&H()})};z?z(N,Y,ce):ce()}else r(N,m,T)},St=(g,m,T,x=!1,S=!1)=>{const{type:N,props:B,ref:C,children:O,dynamicChildren:k,shapeFlag:q,patchFlag:R,dirs:z}=g;if(C!=null&&ea(C,null,T,g,!0),q&256){m.ctx.deactivate(g);return}const H=q&1&&z,Y=!bi(g);let ce;if(Y&&(ce=B&&B.onVnodeBeforeUnmount)&&kt(ce,m,g),q&6)Zf(g.component,T,x);else{if(q&128){g.suspense.unmount(T,x);return}H&&kr(g,null,m,"beforeUnmount"),q&64?g.type.remove(g,m,T,S,bs,x):k&&(N!==_e||R>0&&R&64)?Vt(k,m,T,!1,!0):(N===_e&&R&384||!S&&q&16)&&Vt(O,m,T),x&&wc(g)}(Y&&(ce=B&&B.onVnodeUnmounted)||H)&&Me(()=>{ce&&kt(ce,m,g),H&&kr(g,null,m,"unmounted")},T)},wc=g=>{const{type:m,el:T,anchor:x,transition:S}=g;if(m===_e){Xf(T,x);return}if(m===Po){U(g);return}const N=()=>{s(T),S&&!S.persisted&&S.afterLeave&&S.afterLeave()};if(g.shapeFlag&1&&S&&!S.persisted){const{leave:B,delayLeave:C}=S,O=()=>B(T,N);C?C(g.el,N,O):O()}else N()},Xf=(g,m)=>{let T;for(;g!==m;)T=v(g),s(g),g=T;s(m)},Zf=(g,m,T)=>{const{bum:x,scope:S,update:N,subTree:B,um:C}=g;x&&wi(x),S.stop(),N&&(N.active=!1,St(B,g,m,T)),C&&Me(C,m),Me(()=>{g.isUnmounted=!0},m),m&&m.pendingBranch&&!m.isUnmounted&&g.asyncDep&&!g.asyncResolved&&g.suspenseId===m.pendingId&&(m.deps--,m.deps===0&&m.resolve())},Vt=(g,m,T,x=!1,S=!1,N=0)=>{for(let B=N;Bg.shapeFlag&6?si(g.component.subTree):g.shapeFlag&128?g.suspense.next():v(g.anchor||g.el),bc=(g,m,T)=>{g==null?m._vnode&&St(m._vnode,null,null,!0):I(m._vnode||null,g,m,null,null,null,T),Fc(),wl(),m._vnode=g},bs={p:I,um:St,m:xr,r:wc,mt:xo,mc:te,pc:ae,pbc:Ie,n:si,o:n};let Tc,Ac;return{render:bc,hydrate:Tc,createApp:Pd(bc,Tc)}}function Er({effect:n,update:e},t){n.allowRecurse=e.allowRecurse=t}function Fl(n,e,t=!1){const r=n.children,s=e.children;if(j(r)&&j(s))for(let i=0;i>1,n[t[a]]0&&(e[r]=t[i-1]),t[i]=r)}}for(i=t.length,o=t[i-1];i-- >0;)t[i]=o,o=e[o];return t}const Ud=n=>n.__isTeleport,_e=Symbol.for("v-fgt"),ho=Symbol.for("v-txt"),Ms=Symbol.for("v-cmt"),Po=Symbol.for("v-stc"),Ns=[];let pt=null;function jt(n=!1){Ns.push(pt=n?null:[])}function qd(){Ns.pop(),pt=Ns[Ns.length-1]||null}let $s=1;function Hc(n){$s+=n}function zd(n){return n.dynamicChildren=$s>0?pt||es:null,qd(),$s>0&&pt&&pt.push(n),n}function Wt(n,e,t,r,s,i){return zd(Re(n,e,t,r,s,i,!0))}function Kd(n){return n?n.__v_isVNode===!0:!1}function As(n,e){return n.type===e.type&&n.key===e.key}const go="__vInternal",Ll=({key:n})=>n??null,Ai=({ref:n,ref_key:e,ref_for:t})=>(typeof n=="number"&&(n=""+n),n!=null?Ae(n)||Je(n)||_(n)?{i:mt,r:n,k:e,f:!!t}:n:null);function Re(n,e=null,t=null,r=0,s=null,i=n===_e?0:1,o=!1,a=!1){const u={__v_isVNode:!0,__v_skip:!0,type:n,props:e,key:e&&Ll(e),ref:e&&Ai(e),scopeId:Al,slotScopeIds:null,children:t,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:mt};return a?(Xa(u,t),i&128&&n.normalize(u)):t&&(u.shapeFlag|=Ae(t)?8:16),$s>0&&!o&&pt&&(u.patchFlag>0||i&6)&&u.patchFlag!==32&&pt.push(u),u}const Lr=Vd;function Vd(n,e=null,t=null,r=0,s=null,i=!1){if((!n||n===Ad)&&(n=Ms),Kd(n)){const a=cs(n,e,!0);return t&&Xa(a,t),$s>0&&!i&&pt&&(a.shapeFlag&6?pt[pt.indexOf(n)]=a:pt.push(a)),a.patchFlag|=-2,a}if(eg(n)&&(n=n.__vccOpts),e){e=jd(e);let{class:a,style:u}=e;a&&!Ae(a)&&(e.class=Ja(a)),de(u)&&(gl(u)&&!j(u)&&(u=ke({},u)),e.style=La(u))}const o=Ae(n)?1:ad(n)?128:Ud(n)?64:de(n)?4:_(n)?2:0;return Re(n,e,t,r,s,o,i,!0)}function jd(n){return n?gl(n)||go in n?ke({},n):n:null}function cs(n,e,t=!1){const{props:r,ref:s,patchFlag:i,children:o}=n,a=e?Wd(r||{},e):r;return{__v_isVNode:!0,__v_skip:!0,type:n.type,props:a,key:a&&Ll(a),ref:e&&e.ref?t&&s?j(s)?s.concat(Ai(e)):[s,Ai(e)]:Ai(e):s,scopeId:n.scopeId,slotScopeIds:n.slotScopeIds,children:o,target:n.target,targetAnchor:n.targetAnchor,staticCount:n.staticCount,shapeFlag:n.shapeFlag,patchFlag:e&&n.type!==_e?i===-1?16:i|16:i,dynamicProps:n.dynamicProps,dynamicChildren:n.dynamicChildren,appContext:n.appContext,dirs:n.dirs,transition:n.transition,component:n.component,suspense:n.suspense,ssContent:n.ssContent&&cs(n.ssContent),ssFallback:n.ssFallback&&cs(n.ssFallback),el:n.el,anchor:n.anchor,ctx:n.ctx,ce:n.ce}}function Jl(n=" ",e=0){return Lr(ho,null,n,e)}function Nt(n){return n==null||typeof n=="boolean"?Lr(Ms):j(n)?Lr(_e,null,n.slice()):typeof n=="object"?hr(n):Lr(ho,null,String(n))}function hr(n){return n.el===null&&n.patchFlag!==-1||n.memo?n:cs(n)}function Xa(n,e){let t=0;const{shapeFlag:r}=n;if(e==null)e=null;else if(j(e))t=16;else if(typeof e=="object")if(r&65){const s=e.default;s&&(s._c&&(s._d=!1),Xa(n,s()),s._c&&(s._d=!0));return}else{t=32;const s=e._;!s&&!(go in e)?e._ctx=mt:s===3&&mt&&(mt.slots._===1?e._=1:(e._=2,n.patchFlag|=1024))}else _(e)?(e={default:e,_ctx:mt},t=32):(e=String(e),r&64?(t=16,e=[Jl(e)]):t=8);n.children=e,n.shapeFlag|=t}function Wd(...n){const e={};for(let t=0;tPe=n),Za=n=>{Wr.length>1?Wr.forEach(e=>e(n)):Wr[0](n)};const us=n=>{Za(n),n.scope.on()},Jr=()=>{Pe&&Pe.scope.off(),Za(null)};function Ml(n){return n.vnode.shapeFlag&4}let Us=!1;function Yd(n,e=!1){Us=e;const{props:t,children:r}=n.vnode,s=Ml(n);Dd(n,t,s,e),Fd(n,r);const i=s?Xd(n,e):void 0;return Us=!1,i}function Xd(n,e){const t=n.type;n.accessCache=Object.create(null),n.proxy=ml(new Proxy(n.ctx,Id));const{setup:r}=t;if(r){const s=n.setupContext=r.length>1?Qd(n):null;us(n),vs();const i=mr(r,n,0,[n.props,s]);if(ws(),Jr(),Xu(i)){if(i.then(Jr,Jr),e)return i.then(o=>{_c(n,o,e)}).catch(o=>{uo(o,n,0)});n.asyncDep=i}else _c(n,i,e)}else $l(n,e)}function _c(n,e,t){_(e)?n.type.__ssrInlineRender?n.ssrRender=e:n.render=e:de(e)&&(n.setupState=pl(e)),$l(n,t)}let Yc;function $l(n,e,t){const r=n.type;if(!n.render){if(!e&&Yc&&!r.render){const s=r.template||_a(n).template;if(s){const{isCustomElement:i,compilerOptions:o}=n.appContext.config,{delimiters:a,compilerOptions:u}=r,l=ke(ke({isCustomElement:i,delimiters:a},o),u);r.render=Yc(s,l)}}n.render=r.render||qt}us(n),vs(),Sd(n),ws(),Jr()}function Zd(n){return n.attrsProxy||(n.attrsProxy=new Proxy(n.attrs,{get(e,t){return qe(n,"get","$attrs"),e[t]}}))}function Qd(n){const e=t=>{n.exposed=t||{}};return{get attrs(){return Zd(n)},slots:n.slots,emit:n.emit,expose:e}}function mo(n){if(n.exposed)return n.exposeProxy||(n.exposeProxy=new Proxy(pl(ml(n.exposed)),{get(e,t){if(t in e)return e[t];if(t in Cs)return Cs[t](n)},has(e,t){return t in e||t in Cs}}))}function eg(n){return _(n)&&"__vccOpts"in n}const tg=(n,e)=>Gh(n,e,Us),ng=Symbol.for("v-scx"),rg=()=>Ti(ng),sg="3.3.4",ig="http://www.w3.org/2000/svg",Or=typeof document<"u"?document:null,Xc=Or&&Or.createElement("template"),og={insert:(n,e,t)=>{e.insertBefore(n,t||null)},remove:n=>{const e=n.parentNode;e&&e.removeChild(n)},createElement:(n,e,t,r)=>{const s=e?Or.createElementNS(ig,n):Or.createElement(n,t?{is:t}:void 0);return n==="select"&&r&&r.multiple!=null&&s.setAttribute("multiple",r.multiple),s},createText:n=>Or.createTextNode(n),createComment:n=>Or.createComment(n),setText:(n,e)=>{n.nodeValue=e},setElementText:(n,e)=>{n.textContent=e},parentNode:n=>n.parentNode,nextSibling:n=>n.nextSibling,querySelector:n=>Or.querySelector(n),setScopeId(n,e){n.setAttribute(e,"")},insertStaticContent(n,e,t,r,s,i){const o=t?t.previousSibling:e.lastChild;if(s&&(s===i||s.nextSibling))for(;e.insertBefore(s.cloneNode(!0),t),!(s===i||!(s=s.nextSibling)););else{Xc.innerHTML=r?`${n}`:n;const a=Xc.content;if(r){const u=a.firstChild;for(;u.firstChild;)a.appendChild(u.firstChild);a.removeChild(u)}e.insertBefore(a,t)}return[o?o.nextSibling:e.firstChild,t?t.previousSibling:e.lastChild]}};function ag(n,e,t){const r=n._vtc;r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?n.removeAttribute("class"):t?n.setAttribute("class",e):n.className=e}function cg(n,e,t){const r=n.style,s=Ae(t);if(t&&!s){if(e&&!Ae(e))for(const i in e)t[i]==null&&ta(r,i,"");for(const i in t)ta(r,i,t[i])}else{const i=r.display;s?e!==t&&(r.cssText=t):e&&n.removeAttribute("style"),"_vod"in n&&(r.display=i)}}const Zc=/\s*!important$/;function ta(n,e,t){if(j(t))t.forEach(r=>ta(n,e,r));else if(t==null&&(t=""),e.startsWith("--"))n.setProperty(e,t);else{const r=ug(n,e);Zc.test(t)?n.setProperty(Kr(r),t.replace(Zc,""),"important"):n[r]=t}}const Qc=["Webkit","Moz","ms"],Oo={};function ug(n,e){const t=Oo[e];if(t)return t;let r=as(e);if(r!=="filter"&&r in n)return Oo[e]=r;r=el(r);for(let s=0;sDo||(mg.then(()=>Do=0),Do=Date.now());function yg(n,e){const t=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=t.attached)return;wt(vg(r,t.value),e,5,[r])};return t.value=n,t.attached=pg(),t}function vg(n,e){if(j(e)){const t=n.stopImmediatePropagation;return n.stopImmediatePropagation=()=>{t.call(n),n._stopped=!0},e.map(r=>s=>!s._stopped&&r&&r(s))}else return e}const nu=/^on[a-z]/,wg=(n,e,t,r,s=!1,i,o,a,u)=>{e==="class"?ag(n,r,s):e==="style"?cg(n,t,r):io(e)?Da(e)||dg(n,e,t,r,o):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):bg(n,e,r,s))?fg(n,e,r,i,o,a,u):(e==="true-value"?n._trueValue=r:e==="false-value"&&(n._falseValue=r),lg(n,e,r,s))};function bg(n,e,t,r){return r?!!(e==="innerHTML"||e==="textContent"||e in n&&nu.test(e)&&_(t)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&n.tagName==="INPUT"||e==="type"&&n.tagName==="TEXTAREA"||nu.test(e)&&Ae(t)?!1:e in n}const ru=n=>{const e=n.props["onUpdate:modelValue"]||!1;return j(e)?t=>wi(e,t):e};function Tg(n){n.target.composing=!0}function su(n){const e=n.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const iu={created(n,{modifiers:{lazy:e,trim:t,number:r}},s){n._assign=ru(s);const i=r||s.props&&s.props.type==="number";Yr(n,e?"change":"input",o=>{if(o.target.composing)return;let a=n.value;t&&(a=a.trim()),i&&(a=zo(a)),n._assign(a)}),t&&Yr(n,"change",()=>{n.value=n.value.trim()}),e||(Yr(n,"compositionstart",Tg),Yr(n,"compositionend",su),Yr(n,"change",su))},mounted(n,{value:e}){n.value=e??""},beforeUpdate(n,{value:e,modifiers:{lazy:t,trim:r,number:s}},i){if(n._assign=ru(i),n.composing||document.activeElement===n&&n.type!=="range"&&(t||r&&n.value.trim()===e||(s||n.type==="number")&&zo(n.value)===e))return;const o=e??"";n.value!==o&&(n.value=o)}},Ag={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},fi=(n,e)=>t=>{if(!("key"in t))return;const r=Kr(t.key);if(e.some(s=>s===r||Ag[s]===r))return n(t)},Ig=ke({patchProp:wg},og);let ou;function Sg(){return ou||(ou=Jd(Ig))}const xg=(...n)=>{const e=Sg().createApp(...n),{mount:t}=e;return e.mount=r=>{const s=kg(r);if(!s)return;const i=e._component;!_(i)&&!i.render&&!i.template&&(i.template=s.innerHTML),s.innerHTML="";const o=t(s,!1,s instanceof SVGElement);return s instanceof Element&&(s.removeAttribute("v-cloak"),s.setAttribute("data-v-app","")),o},e};function kg(n){return Ae(n)?document.querySelector(n):n}var ne;(function(n){n[n.Canceled=1]="Canceled",n[n.Unknown=2]="Unknown",n[n.InvalidArgument=3]="InvalidArgument",n[n.DeadlineExceeded=4]="DeadlineExceeded",n[n.NotFound=5]="NotFound",n[n.AlreadyExists=6]="AlreadyExists",n[n.PermissionDenied=7]="PermissionDenied",n[n.ResourceExhausted=8]="ResourceExhausted",n[n.FailedPrecondition=9]="FailedPrecondition",n[n.Aborted=10]="Aborted",n[n.OutOfRange=11]="OutOfRange",n[n.Unimplemented=12]="Unimplemented",n[n.Internal=13]="Internal",n[n.Unavailable=14]="Unavailable",n[n.DataLoss=15]="DataLoss",n[n.Unauthenticated=16]="Unauthenticated"})(ne||(ne={}));function au(n){const e=ne[n];return typeof e!="string"?n.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,t=>"_"+t.toLowerCase())}class le extends Error{constructor(e,t=ne.Unknown,r,s,i){super(Eg(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(r??{}),this.details=s??[],this.cause=i}static from(e,t=ne.Unknown){return e instanceof le?e:e instanceof Error?e.name=="AbortError"?new le(e.message,ne.Canceled):new le(e.message,t,void 0,void 0,e):new le(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error?Object.getPrototypeOf(e)===le.prototype?!0:e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e:!1}findDetails(e){const t="typeName"in e?{findMessage:s=>s===e.typeName?e:void 0}:e,r=[];for(const s of this.details){if("getType"in s){t.findMessage(s.getType().typeName)&&r.push(s);continue}const i=t.findMessage(s.type);if(i)try{r.push(i.fromBinary(s.value))}catch{}}return r}}function Eg(n,e){return n.length?`[${au(e)}] ${n}`:`[${au(e)}]`}function pe(n,e){if(!n)throw new Error(e)}const Cg=34028234663852886e22,Ng=-34028234663852886e22,Pg=4294967295,Og=2147483647,Dg=-2147483648;function Ii(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>Og||nPg||n<0)throw new Error("invalid uint 32: "+n)}function Ul(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Cg||n({no:s.no,name:s.name,localName:n[s.no]})))}function Kl(n,e,t){const r=Object.create(null),s=Object.create(null),i=[];for(const o of e){const a=Vl(o);i.push(a),r[o.name]=a,s[o.no]=a}return{typeName:n,values:i,findName(o){return r[o]},findNumber(o){return s[o]}}}function Rg(n,e,t){const r={};for(const s of e){const i=Vl(s);r[i.localName]=i.no,r[i.no]=i.localName}return zl(r,n,e),r}function Vl(n){return"localName"in n?n:Object.assign(Object.assign({},n),{localName:n.name})}class P{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const r=this.getType(),s=r.runtime.bin,i=s.makeReadOptions(t);return s.readMessage(this,i.readerFactory(e),e.byteLength,i),this}fromJson(e,t){const r=this.getType(),s=r.runtime.json,i=s.makeReadOptions(t);return s.readMessage(r,e,i,this),this}fromJsonString(e,t){let r;try{r=JSON.parse(e)}catch(s){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${s instanceof Error?s.message:String(s)}`)}return this.fromJson(r,t)}toBinary(e){const t=this.getType(),r=t.runtime.bin,s=r.makeWriteOptions(e),i=s.writerFactory();return r.writeMessage(this,i,s),i.finish()}toJson(e){const t=this.getType(),r=t.runtime.json,s=r.makeWriteOptions(e);return r.writeMessage(this,s)}toJsonString(e){var t;const r=this.toJson(e);return JSON.stringify(r,null,(t=e==null?void 0:e.prettySpaces)!==null&&t!==void 0?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Fg(n,e,t,r){var s;const i=(s=r==null?void 0:r.localName)!==null&&s!==void 0?s:e.substring(e.lastIndexOf(".")+1),o={[i]:function(a){n.util.initFields(this),n.util.initPartial(a,this)}}[i];return Object.setPrototypeOf(o.prototype,new P),Object.assign(o,{runtime:n,typeName:e,fields:n.util.newFieldList(t),fromBinary(a,u){return new o().fromBinary(a,u)},fromJson(a,u){return new o().fromJson(a,u)},fromJsonString(a,u){return new o().fromJsonString(a,u)},equals(a,u){return n.util.equals(o,a,u)}}),o}function Lg(){let n=0,e=0;for(let r=0;r<28;r+=7){let s=this.buf[this.pos++];if(n|=(s&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let s=this.buf[this.pos++];if(e|=(s&127)<>>i,a=!(!(o>>>7)&&e==0),u=(a?o|128:o)&255;if(t.push(u),!a)return}const r=n>>>28&15|(e&7)<<4,s=!!(e>>3);if(t.push((s?r|128:r)&255),!!s){for(let i=3;i<31;i=i+7){const o=e>>>i,a=!!(o>>>7),u=(a?o|128:o)&255;if(t.push(u),!a)return}t.push(e>>>31&1)}}const Si=4294967296;function cu(n){const e=n[0]==="-";e&&(n=n.slice(1));const t=1e6;let r=0,s=0;function i(o,a){const u=Number(n.slice(o,a));s*=t,r=r*t+u,r>=Si&&(s=s+(r/Si|0),r=r%Si)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?Wl(r,s):Qa(r,s)}function Jg(n,e){let t=Qa(n,e);const r=t.hi&2147483648;r&&(t=Wl(t.lo,t.hi));const s=jl(t.lo,t.hi);return r?"-"+s:s}function jl(n,e){if({lo:n,hi:e}=Mg(n,e),e<=2097151)return String(Si*e+n);const t=n&16777215,r=(n>>>24|e<<8)&16777215,s=e>>16&65535;let i=t+r*6777216+s*6710656,o=r+s*8147497,a=s*2;const u=1e7;return i>=u&&(o+=Math.floor(i/u),i%=u),o>=u&&(a+=Math.floor(o/u),o%=u),a.toString()+uu(o)+uu(i)}function Mg(n,e){return{lo:n>>>0,hi:e>>>0}}function Qa(n,e){return{lo:n|0,hi:e|0}}function Wl(n,e){return e=~e,n?n=~n+1:e+=1,Qa(n,e)}const uu=n=>{const e=String(n);return"0000000".slice(e.length)+e};function lu(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function $g(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var fu={};function Ug(){const n=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"&&(typeof process!="object"||typeof fu!="object"||fu.BUF_BIGINT_DISABLE!=="1")){const s=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(u){const l=typeof u=="bigint"?u:BigInt(u);if(l>i||la||lpe(/^-?[0-9]+$/.test(s),`int64 invalid: ${s}`),r=s=>pe(/^[0-9]+$/.test(s),`uint64 invalid: ${s}`);return{zero:"0",supported:!1,parse(s){return typeof s!="string"&&(s=s.toString()),t(s),s},uParse(s){return typeof s!="string"&&(s=s.toString()),r(s),s},enc(s){return typeof s!="string"&&(s=s.toString()),t(s),cu(s)},uEnc(s){return typeof s!="string"&&(s=s.toString()),r(s),cu(s)},dec(s,i){return Jg(s,i)},uDec(s,i){return jl(s,i)}}}const fe=Ug();var b;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(b||(b={}));var br;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING"})(br||(br={}));function cr(n,e,t){if(e===t)return!0;if(n==b.BYTES){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!==t.length)return!1;for(let r=0;r>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(na(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Ii(e),lu(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Ul(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){na(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Ii(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Ii(e),e=(e<<1^e>>31)>>>0,lu(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),s=fe.enc(e);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),s=fe.uEnc(e);return r.setInt32(0,s.lo,!0),r.setInt32(4,s.hi,!0),this.raw(t)}int64(e){let t=fe.enc(e);return Bo(t.lo,t.hi,this.buf),this}sint64(e){let t=fe.enc(e),r=t.hi>>31,s=t.lo<<1^r,i=(t.hi<<1|t.lo>>>31)^r;return Bo(s,i,this.buf),this}uint64(e){let t=fe.uEnc(e);return Bo(t.lo,t.hi,this.buf),this}}class zg{constructor(e,t){this.varint64=Lg,this.uint32=$g,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case ve.Varint:for(;this.buf[this.pos++]&128;);break;case ve.Bit64:this.pos+=4;case ve.Bit32:this.pos+=4;break;case ve.LengthDelimited:let s=this.uint32();this.pos+=s;break;case ve.StartGroup:for(;;){const[i,o]=this.tag();if(o===ve.EndGroup){if(t!==void 0&&i!==t)throw new Error("invalid end group tag");break}this.skip(o,i)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return fe.dec(...this.varint64())}uint64(){return fe.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,fe.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return fe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return fe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function Kg(n,e,t,r){let s;return{typeName:e,extendee:t,get field(){if(!s){const i=typeof r=="function"?r():r;i.name=e.split(".").pop(),i.jsonName=`[${e}]`,s=n.util.newFieldList([i]).list()[0]}return s},runtime:n}}function Gl(n){const e=n.field.localName,t=Object.create(null);return t[e]=Vg(n),[t,()=>t[e]]}function Vg(n){const e=n.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return ls(e.T,e.L);case"message":const t=e.T,r=new t;return t.fieldWrapper?t.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function jg(n,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let t=n.length-1;t>=0;--t)if(n[t].no==e.no)return[n[t]];return[]}return n.filter(t=>t.no===e.no)}let Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),po=[];for(let n=0;n>4,o=i,s=2;break;case 2:t[r++]=(o&15)<<4|(i&60)>>2,o=i,s=3;break;case 3:t[r++]=(o&3)<<6|i,s=0;break}}if(s==1)throw Error("invalid base64 string.");return t.subarray(0,r)},enc(n){let e="",t=0,r,s=0;for(let i=0;i>2],s=(r&3)<<4,t=1;break;case 1:e+=Yn[s|r>>4],s=(r&15)<<2,t=2;break;case 2:e+=Yn[s|r>>6],e+=Yn[r&63],t=0;break}return t&&(e+=Yn[s],e+="=",t==1&&(e+="=")),e}};function Wg(n,e,t){Yl(e,n);const r=e.runtime.bin.makeReadOptions(t),s=jg(n.getType().runtime.bin.listUnknownFields(n),e.field),[i,o]=Gl(e);for(const a of s)e.runtime.bin.readField(i,r.readerFactory(a.data),e.field,a.wireType,r);return o()}function Hg(n,e,t,r){Yl(e,n);const s=e.runtime.bin.makeReadOptions(r),i=e.runtime.bin.makeWriteOptions(r);if(_l(n,e)){const l=n.getType().runtime.bin.listUnknownFields(n).filter(h=>h.no!=e.field.no);n.getType().runtime.bin.discardUnknownFields(n);for(const h of l)n.getType().runtime.bin.onUnknownField(n,h.no,h.wireType,h.data)}const o=i.writerFactory();let a=e.field;!a.opt&&!a.repeated&&(a.kind=="enum"||a.kind=="scalar")&&(a=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(a,t,o,i);const u=s.readerFactory(o.finish());for(;u.posr.no==e.field.no)}function Yl(n,e){pe(n.extendee.typeName==e.getType().typeName,`extension ${n.typeName} can only be applied to message ${n.extendee.typeName}`)}function Xl(n,e){const t=n.localName;if(n.repeated)return e[t].length>0;if(n.oneof)return e[n.oneof.localName].case===t;switch(n.kind){case"enum":case"scalar":return n.opt||n.req?e[t]!==void 0:n.kind=="enum"?e[t]!==n.T.values[0].no:!Hl(n.T,e[t]);case"message":return e[t]!==void 0;case"map":return Object.keys(e[t]).length>0}}function hu(n,e){const t=n.localName,r=!n.opt&&!n.req;if(n.repeated)e[t]=[];else if(n.oneof)e[n.oneof.localName]={case:void 0};else switch(n.kind){case"map":e[t]={};break;case"enum":e[t]=r?n.T.values[0].no:void 0;break;case"scalar":e[t]=r?ls(n.T,n.L):void 0;break;case"message":e[t]=void 0;break}}function Mr(n,e){if(n===null||typeof n!="object"||!Object.getOwnPropertyNames(P.prototype).every(r=>r in n&&typeof n[r]=="function"))return!1;const t=n.getType();return t===null||typeof t!="function"||!("typeName"in t)||typeof t.typeName!="string"?!1:e===void 0?!0:t.typeName==e.typeName}function Zl(n,e){return Mr(e)||!n.fieldWrapper?e:n.fieldWrapper.wrapField(e)}b.DOUBLE,b.FLOAT,b.INT64,b.UINT64,b.INT32,b.UINT32,b.BOOL,b.STRING,b.BYTES;const du={ignoreUnknownFields:!1},gu={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Gg(n){return n?Object.assign(Object.assign({},du),n):du}function _g(n){return n?Object.assign(Object.assign({},gu),n):gu}const Fi=Symbol(),xi=Symbol();function Yg(){return{makeReadOptions:Gg,makeWriteOptions:_g,readMessage(n,e,t,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${n.typeName} from JSON: ${Ct(e)}`);r=r??new n;const s=new Map,i=t.typeRegistry;for(const[o,a]of Object.entries(e)){const u=n.fields.findJsonName(o);if(u){if(u.oneof){if(a===null&&u.kind=="scalar")continue;const l=s.get(u.oneof);if(l!==void 0)throw new Error(`cannot decode message ${n.typeName} from JSON: multiple keys for oneof "${u.oneof.name}" present: "${l}", "${o}"`);s.set(u.oneof,o)}mu(r,a,u,t,n)}else{let l=!1;if(i!=null&&i.findExtension&&o.startsWith("[")&&o.endsWith("]")){const h=i.findExtension(o.substring(1,o.length-1));if(h&&h.extendee.typeName==n.typeName){l=!0;const[d,v]=Gl(h);mu(d,a,h.field,t,h),Hg(r,h,v(),t)}}if(!l&&!t.ignoreUnknownFields)throw new Error(`cannot decode message ${n.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(n,e){const t=n.getType(),r={};let s;try{for(s of t.fields.byNumber()){if(!Xl(s,n)){if(s.req)throw"required field not set";if(!e.emitDefaultValues||!Zg(s))continue}const o=s.oneof?n[s.oneof.localName].value:n[s.localName],a=pu(s,o,e);a!==void 0&&(r[e.useProtoFieldName?s.name:s.jsonName]=a)}const i=e.typeRegistry;if(i!=null&&i.findExtensionFor)for(const o of t.runtime.bin.listUnknownFields(n)){const a=i.findExtensionFor(t.typeName,o.no);if(a&&_l(n,a)){const u=Wg(n,a,e),l=pu(a.field,u,e);l!==void 0&&(r[a.field.jsonName]=l)}}}catch(i){const o=s?`cannot encode field ${t.typeName}.${s.name} to JSON`:`cannot encode message ${t.typeName} to JSON`,a=i instanceof Error?i.message:String(i);throw new Error(o+(a.length>0?`: ${a}`:""))}return r},readScalar(n,e,t){return Ps(n,e,t??br.BIGINT,!0)},writeScalar(n,e,t){if(e!==void 0&&(t||Hl(n,e)))return ki(n,e)},debug:Ct}}function Ct(n){if(n===null)return"null";switch(typeof n){case"object":return Array.isArray(n)?"array":"object";case"string":return n.length>100?"string":`"${n.split('"').join('\\"')}"`;default:return String(n)}}function mu(n,e,t,r,s){let i=t.localName;if(t.repeated){if(pe(t.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`);const o=n[i];for(const a of e){if(a===null)throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(a)}`);switch(t.kind){case"message":o.push(t.T.fromJson(a,r));break;case"enum":const u=Ro(t.T,a,r.ignoreUnknownFields,!0);u!==xi&&o.push(u);break;case"scalar":try{o.push(Ps(t.T,a,t.L,!0))}catch(l){let h=`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(a)}`;throw l instanceof Error&&l.message.length>0&&(h+=`: ${l.message}`),new Error(h)}break}}}else if(t.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`);const o=n[i];for(const[a,u]of Object.entries(e)){if(u===null)throw new Error(`cannot decode field ${s.typeName}.${t.name} from JSON: map value null`);let l;try{l=Xg(t.K,a)}catch(h){let d=`cannot decode map key for field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw h instanceof Error&&h.message.length>0&&(d+=`: ${h.message}`),new Error(d)}switch(t.V.kind){case"message":o[l]=t.V.T.fromJson(u,r);break;case"enum":const h=Ro(t.V.T,u,r.ignoreUnknownFields,!0);h!==xi&&(o[l]=h);break;case"scalar":try{o[l]=Ps(t.V.T,u,br.BIGINT,!0)}catch(d){let v=`cannot decode map value for field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw d instanceof Error&&d.message.length>0&&(v+=`: ${d.message}`),new Error(v)}break}}}else switch(t.oneof&&(n=n[t.oneof.localName]={case:i},i="value"),t.kind){case"message":const o=t.T;if(e===null&&o.typeName!="google.protobuf.Value")return;let a=n[i];Mr(a)?a.fromJson(e,r):(n[i]=a=o.fromJson(e,r),o.fieldWrapper&&!t.oneof&&(n[i]=o.fieldWrapper.unwrapField(a)));break;case"enum":const u=Ro(t.T,e,r.ignoreUnknownFields,!1);switch(u){case Fi:hu(t,n);break;case xi:break;default:n[i]=u;break}break;case"scalar":try{const l=Ps(t.T,e,t.L,!1);switch(l){case Fi:hu(t,n);break;default:n[i]=l;break}}catch(l){let h=`cannot decode field ${s.typeName}.${t.name} from JSON: ${Ct(e)}`;throw l instanceof Error&&l.message.length>0&&(h+=`: ${l.message}`),new Error(h)}break}}function Xg(n,e){if(n===b.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Ps(n,e,br.BIGINT,!0).toString()}function Ps(n,e,t,r){if(e===null)return r?ls(n,t):Fi;switch(n){case b.DOUBLE:case b.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const s=Number(e);if(Number.isNaN(s)||!Number.isFinite(s))break;return n==b.FLOAT&&Ul(s),s;case b.INT32:case b.FIXED32:case b.SFIXED32:case b.SINT32:case b.UINT32:let i;if(typeof e=="number"?i=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(i=Number(e)),i===void 0)break;return n==b.UINT32||n==b.FIXED32?na(i):Ii(i),i;case b.INT64:case b.SFIXED64:case b.SINT64:if(typeof e!="number"&&typeof e!="string")break;const o=fe.parse(e);return t?o.toString():o;case b.FIXED64:case b.UINT64:if(typeof e!="number"&&typeof e!="string")break;const a=fe.uParse(e);return t?a.toString():a;case b.BOOL:if(typeof e!="boolean")break;return e;case b.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case b.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return ec.dec(e)}throw new Error}function Ro(n,e,t,r){if(e===null)return n.typeName=="google.protobuf.NullValue"?0:r?n.values[0].no:Fi;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const s=n.findName(e);if(s!==void 0)return s.no;if(t)return xi;break}throw new Error(`cannot decode enum ${n.typeName} from JSON: ${Ct(e)}`)}function Zg(n){return n.repeated||n.kind=="map"?!0:!(n.oneof||n.kind=="message"||n.opt||n.req)}function pu(n,e,t){if(n.kind=="map"){pe(typeof e=="object"&&e!=null);const r={},s=Object.entries(e);switch(n.V.kind){case"scalar":for(const[o,a]of s)r[o.toString()]=ki(n.V.T,a);break;case"message":for(const[o,a]of s)r[o.toString()]=a.toJson(t);break;case"enum":const i=n.V.T;for(const[o,a]of s)r[o.toString()]=Fo(i,a,t.enumAsInteger);break}return t.emitDefaultValues||s.length>0?r:void 0}if(n.repeated){pe(Array.isArray(e));const r=[];switch(n.kind){case"scalar":for(let s=0;s0?r:void 0}switch(n.kind){case"scalar":return ki(n.T,e);case"enum":return Fo(n.T,e,t.enumAsInteger);case"message":return Zl(n.T,e).toJson(t)}}function Fo(n,e,t){var r;if(pe(typeof e=="number"),n.typeName=="google.protobuf.NullValue")return null;if(t)return e;const s=n.findNumber(e);return(r=s==null?void 0:s.name)!==null&&r!==void 0?r:e}function ki(n,e){switch(n){case b.INT32:case b.SFIXED32:case b.SINT32:case b.FIXED32:case b.UINT32:return pe(typeof e=="number"),e;case b.FLOAT:case b.DOUBLE:return pe(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case b.STRING:return pe(typeof e=="string"),e;case b.BOOL:return pe(typeof e=="boolean"),e;case b.UINT64:case b.FIXED64:case b.INT64:case b.SFIXED64:case b.SINT64:return pe(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case b.BYTES:return pe(e instanceof Uint8Array),ec.enc(e)}}const Hr=Symbol("@bufbuild/protobuf/unknown-fields"),yu={readUnknownFields:!0,readerFactory:n=>new zg(n)},vu={writeUnknownFields:!0,writerFactory:()=>new qg};function Qg(n){return n?Object.assign(Object.assign({},yu),n):yu}function em(n){return n?Object.assign(Object.assign({},vu),n):vu}function tm(){return{makeReadOptions:Qg,makeWriteOptions:em,listUnknownFields(n){var e;return(e=n[Hr])!==null&&e!==void 0?e:[]},discardUnknownFields(n){delete n[Hr]},writeUnknownFields(n,e){const r=n[Hr];if(r)for(const s of r)e.tag(s.no,s.wireType).raw(s.data)},onUnknownField(n,e,t,r){const s=n;Array.isArray(s[Hr])||(s[Hr]=[]),s[Hr].push({no:e,wireType:t,data:r})},readMessage(n,e,t,r,s){const i=n.getType(),o=s?e.len:e.pos+t;let a,u;for(;e.pos0&&(u=rm),i){let v=n[o];if(r==ve.LengthDelimited&&a!=b.STRING&&a!=b.BYTES){let A=e.uint32()+e.pos;for(;e.posMr(v,d)?v:new d(v));else{const v=o[s];d.fieldWrapper?d.typeName==="google.protobuf.BytesValue"?i[s]=Is(v):i[s]=v:i[s]=Mr(v,d)?v:new d(v)}break}}},equals(n,e,t){return e===t?!0:!e||!t?!1:n.fields.byMember().every(r=>{const s=e[r.localName],i=t[r.localName];if(r.repeated){if(s.length!==i.length)return!1;switch(r.kind){case"message":return s.every((o,a)=>r.T.equals(o,i[a]));case"scalar":return s.every((o,a)=>cr(r.T,o,i[a]));case"enum":return s.every((o,a)=>cr(b.INT32,o,i[a]))}throw new Error(`repeated cannot contain ${r.kind}`)}switch(r.kind){case"message":return r.T.equals(s,i);case"enum":return cr(b.INT32,s,i);case"scalar":return cr(r.T,s,i);case"oneof":if(s.case!==i.case)return!1;const o=r.findField(s.case);if(o===void 0)return!0;switch(o.kind){case"message":return o.T.equals(s.value,i.value);case"enum":return cr(b.INT32,s.value,i.value);case"scalar":return cr(o.T,s.value,i.value)}throw new Error(`oneof cannot contain ${o.kind}`);case"map":const a=Object.keys(s).concat(Object.keys(i));switch(r.V.kind){case"message":const u=r.V.T;return a.every(h=>u.equals(s[h],i[h]));case"enum":return a.every(h=>cr(b.INT32,s[h],i[h]));case"scalar":const l=r.V.T;return a.every(h=>cr(l,s[h],i[h]))}break}})},clone(n){const e=n.getType(),t=new e,r=t;for(const s of e.fields.byMember()){const i=n[s.localName];let o;if(s.repeated)o=i.map(hi);else if(s.kind=="map"){o=r[s.localName];for(const[a,u]of Object.entries(i))o[a]=hi(u)}else s.kind=="oneof"?o=s.findField(i.case)?{case:i.case,value:hi(i.value)}:{case:void 0}:o=hi(i);r[s.localName]=o}for(const s of e.runtime.bin.listUnknownFields(n))e.runtime.bin.onUnknownField(r,s.no,s.wireType,s.data);return t}}}function hi(n){if(n===void 0)return n;if(Mr(n))return n.clone();if(n instanceof Uint8Array){const e=new Uint8Array(n.byteLength);return e.set(n),e}return n}function Is(n){return n instanceof Uint8Array?n:new Uint8Array(n)}function am(n,e,t){return{syntax:n,json:Yg(),bin:tm(),util:Object.assign(Object.assign({},om()),{newFieldList:e,initFields:t}),makeMessageType(r,s,i){return Fg(this,r,s,i)},makeEnum:Rg,makeEnumType:Kl,getEnumType:Bg,makeExtension(r,s,i){return Kg(this,r,s,i)}}}class cm{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const t={};for(const r of this.list())t[r.jsonName]=t[r.name]=r;this.jsonNames=t}return this.jsonNames[e]}find(e){if(!this.numbers){const t={};for(const r of this.list())t[r.no]=r;this.numbers=t}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const r of this.list())r.oneof?r.oneof!==t&&(t=r.oneof,e.push(t)):e.push(r)}return this.members}}function ef(n,e){const t=tf(n);return e?t:gm(dm(t))}function um(n){return ef(n,!1)}const lm=tf;function tf(n){let e=!1;const t=[];for(let r=0;r`${n}$`,dm=n=>hm.has(n)?nf(n):n,gm=n=>fm.has(n)?nf(n):n;class mm{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=um(e)}addField(e){pe(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let t=0;tnew cm(n,e=>pm(e)),n=>{for(const e of n.getType().fields.byMember()){if(e.opt)continue;const t=e.localName,r=n;if(e.repeated){r[t]=[];continue}switch(e.kind){case"oneof":r[t]={case:void 0};break;case"enum":r[t]=0;break;case"map":r[t]={};break;case"scalar":r[t]=ls(e.T,e.L);break}}});var Fe;(function(n){n[n.Unary=0]="Unary",n[n.ServerStreaming=1]="ServerStreaming",n[n.ClientStreaming=2]="ClientStreaming",n[n.BiDiStreaming=3]="BiDiStreaming"})(Fe||(Fe={}));var Au;(function(n){n[n.NoSideEffects=1]="NoSideEffects",n[n.Idempotent=2]="Idempotent"})(Au||(Au={}));class Ce extends P{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${f.json.debug(e)}`);const r=e.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]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const s=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(s))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(sDate.parse("9999-12-31T23:59:59Z"))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");return this.seconds=fe.parse(s/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const t=Number(this.seconds)*1e3;if(tDate.parse("9999-12-31T23:59:59Z"))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");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const s=(this.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?r="."+s.substring(0,3)+"Z":s.substring(6)==="000"?r="."+s.substring(0,6)+"Z":r="."+s+"Z"}return new Date(t).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Ce.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Ce({seconds:fe.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return new Ce().fromBinary(e,t)}static fromJson(e,t){return new Ce().fromJson(e,t)}static fromJsonString(e,t){return new Ce().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ce,e,t)}}Ce.runtime=f;Ce.typeName="google.protobuf.Timestamp";Ce.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Xn extends P{constructor(e){super(),this.seconds=fe.zero,this.nanos=0,f.util.initPartial(e,this)}fromJson(e,t){if(typeof e!="string")throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const r=e.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(r===null)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);const s=Number(r[1]);if(s>315576e6||s<-315576e6)throw new Error(`cannot decode google.protobuf.Duration from JSON: ${f.json.debug(e)}`);if(this.seconds=fe.parse(s),typeof r[2]=="string"){const i=r[2]+"0".repeat(9-r[2].length);this.nanos=parseInt(i),(s<0||Object.is(s,-0))&&(this.nanos=-this.nanos)}return this}toJson(e){if(Number(this.seconds)>315576e6||Number(this.seconds)<-315576e6)throw new Error("cannot encode google.protobuf.Duration to JSON: value out of range");let t=this.seconds.toString();if(this.nanos!==0){let r=Math.abs(this.nanos).toString();r="0".repeat(9-r.length)+r,r.substring(3)==="000000"?r=r.substring(0,3):r.substring(6)==="000"&&(r=r.substring(0,6)),t+="."+r,this.nanos<0&&Number(this.seconds)==0&&(t="-"+t)}return t+"s"}static fromBinary(e,t){return new Xn().fromBinary(e,t)}static fromJson(e,t){return new Xn().fromJson(e,t)}static fromJsonString(e,t){return new Xn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Xn,e,t)}}Xn.runtime=f;Xn.typeName="google.protobuf.Duration";Xn.fields=f.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);class Ot extends P{constructor(e){super(),this.typeUrl="",this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){var t;if(this.typeUrl==="")return{};const r=this.typeUrlToName(this.typeUrl),s=(t=e==null?void 0:e.typeRegistry)===null||t===void 0?void 0:t.findMessage(r);if(!s)throw new Error(`cannot encode message google.protobuf.Any to JSON: "${this.typeUrl}" is not in the type registry`);let o=s.fromBinary(this.value).toJson(e);return(r.startsWith("google.protobuf.")||o===null||Array.isArray(o)||typeof o!="object")&&(o={value:o}),o["@type"]=this.typeUrl,o}fromJson(e,t){var r;if(e===null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${e===null?"null":Array.isArray(e)?"array":typeof e}`);if(Object.keys(e).length==0)return this;const s=e["@type"];if(typeof s!="string"||s=="")throw new Error('cannot decode message google.protobuf.Any from JSON: "@type" is empty');const i=this.typeUrlToName(s),o=(r=t==null?void 0:t.typeRegistry)===null||r===void 0?void 0:r.findMessage(i);if(!o)throw new Error(`cannot decode message google.protobuf.Any from JSON: ${s} is not in the type registry`);let a;if(i.startsWith("google.protobuf.")&&Object.prototype.hasOwnProperty.call(e,"value"))a=o.fromJson(e.value,t);else{const u=Object.assign({},e);delete u["@type"],a=o.fromJson(u,t)}return this.packFrom(a),this}packFrom(e){this.value=e.toBinary(),this.typeUrl=this.typeNameToUrl(e.getType().typeName)}unpackTo(e){return this.is(e.getType())?(e.fromBinary(this.value),!0):!1}unpack(e){if(this.typeUrl==="")return;const t=e.findMessage(this.typeUrlToName(this.typeUrl));if(t)return t.fromBinary(this.value)}is(e){if(this.typeUrl==="")return!1;const t=this.typeUrlToName(this.typeUrl);let r="";return typeof e=="string"?r=e:r=e.typeName,t===r}typeNameToUrl(e){return`type.googleapis.com/${e}`}typeUrlToName(e){if(!e.length)throw new Error(`invalid type url: ${e}`);const t=e.lastIndexOf("/"),r=t>=0?e.substring(t+1):e;if(!r.length)throw new Error(`invalid type url: ${e}`);return r}static pack(e){const t=new Ot;return t.packFrom(e),t}static fromBinary(e,t){return new Ot().fromBinary(e,t)}static fromJson(e,t){return new Ot().fromJson(e,t)}static fromJsonString(e,t){return new Ot().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ot,e,t)}}Ot.runtime=f;Ot.typeName="google.protobuf.Any";Ot.fields=f.util.newFieldList(()=>[{no:1,name:"type_url",kind:"scalar",T:9},{no:2,name:"value",kind:"scalar",T:12}]);class Dt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.DOUBLE,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.DOUBLE,e)}catch(r){let s='cannot decode message google.protobuf.DoubleValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Dt().fromBinary(e,t)}static fromJson(e,t){return new Dt().fromJson(e,t)}static fromJsonString(e,t){return new Dt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Dt,e,t)}}Dt.runtime=f;Dt.typeName="google.protobuf.DoubleValue";Dt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:1}]);Dt.fieldWrapper={wrapField(n){return new Dt({value:n})},unwrapField(n){return n.value}};class Bt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.FLOAT,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.FLOAT,e)}catch(r){let s='cannot decode message google.protobuf.FloatValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Bt().fromBinary(e,t)}static fromJson(e,t){return new Bt().fromJson(e,t)}static fromJsonString(e,t){return new Bt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Bt,e,t)}}Bt.runtime=f;Bt.typeName="google.protobuf.FloatValue";Bt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:2}]);Bt.fieldWrapper={wrapField(n){return new Bt({value:n})},unwrapField(n){return n.value}};class Rt extends P{constructor(e){super(),this.value=fe.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.INT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.INT64,e)}catch(r){let s='cannot decode message google.protobuf.Int64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Rt().fromBinary(e,t)}static fromJson(e,t){return new Rt().fromJson(e,t)}static fromJsonString(e,t){return new Rt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Rt,e,t)}}Rt.runtime=f;Rt.typeName="google.protobuf.Int64Value";Rt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:3}]);Rt.fieldWrapper={wrapField(n){return new Rt({value:n})},unwrapField(n){return n.value}};class Ft extends P{constructor(e){super(),this.value=fe.zero,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.UINT64,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.UINT64,e)}catch(r){let s='cannot decode message google.protobuf.UInt64Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Ft().fromBinary(e,t)}static fromJson(e,t){return new Ft().fromJson(e,t)}static fromJsonString(e,t){return new Ft().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ft,e,t)}}Ft.runtime=f;Ft.typeName="google.protobuf.UInt64Value";Ft.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:4}]);Ft.fieldWrapper={wrapField(n){return new Ft({value:n})},unwrapField(n){return n.value}};class Lt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.INT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.INT32,e)}catch(r){let s='cannot decode message google.protobuf.Int32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Lt().fromBinary(e,t)}static fromJson(e,t){return new Lt().fromJson(e,t)}static fromJsonString(e,t){return new Lt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Lt,e,t)}}Lt.runtime=f;Lt.typeName="google.protobuf.Int32Value";Lt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:5}]);Lt.fieldWrapper={wrapField(n){return new Lt({value:n})},unwrapField(n){return n.value}};class Jt extends P{constructor(e){super(),this.value=0,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.UINT32,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.UINT32,e)}catch(r){let s='cannot decode message google.protobuf.UInt32Value from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Jt().fromBinary(e,t)}static fromJson(e,t){return new Jt().fromJson(e,t)}static fromJsonString(e,t){return new Jt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Jt,e,t)}}Jt.runtime=f;Jt.typeName="google.protobuf.UInt32Value";Jt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:13}]);Jt.fieldWrapper={wrapField(n){return new Jt({value:n})},unwrapField(n){return n.value}};class Mt extends P{constructor(e){super(),this.value=!1,f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.BOOL,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.BOOL,e)}catch(r){let s='cannot decode message google.protobuf.BoolValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Mt().fromBinary(e,t)}static fromJson(e,t){return new Mt().fromJson(e,t)}static fromJsonString(e,t){return new Mt().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Mt,e,t)}}Mt.runtime=f;Mt.typeName="google.protobuf.BoolValue";Mt.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:8}]);Mt.fieldWrapper={wrapField(n){return new Mt({value:n})},unwrapField(n){return n.value}};class Ve extends P{constructor(e){super(),this.value="",f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.STRING,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.STRING,e)}catch(r){let s='cannot decode message google.protobuf.StringValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new Ve().fromBinary(e,t)}static fromJson(e,t){return new Ve().fromJson(e,t)}static fromJsonString(e,t){return new Ve().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Ve,e,t)}}Ve.runtime=f;Ve.typeName="google.protobuf.StringValue";Ve.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9}]);Ve.fieldWrapper={wrapField(n){return new Ve({value:n})},unwrapField(n){return n.value}};class $t extends P{constructor(e){super(),this.value=new Uint8Array(0),f.util.initPartial(e,this)}toJson(e){return f.json.writeScalar(b.BYTES,this.value,!0)}fromJson(e,t){try{this.value=f.json.readScalar(b.BYTES,e)}catch(r){let s='cannot decode message google.protobuf.BytesValue from JSON"';throw r instanceof Error&&r.message.length>0&&(s+=`: ${r.message}`),new Error(s)}return this}static fromBinary(e,t){return new $t().fromBinary(e,t)}static fromJson(e,t){return new $t().fromJson(e,t)}static fromJsonString(e,t){return new $t().fromJsonString(e,t)}static equals(e,t){return f.util.equals($t,e,t)}}$t.runtime=f;$t.typeName="google.protobuf.BytesValue";$t.fields=f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:12}]);$t.fieldWrapper={wrapField(n){return new $t({value:n})},unwrapField(n){return n.value}};function ym(n,e,t){try{const r=ec.dec(n);return e?e.fromBinary(r,t):r}catch(r){throw le.from(r,ne.DataLoss)}}function vm(n,e){const t={};for(const[r,s]of Object.entries(n.methods)){const i=e(Object.assign(Object.assign({},s),{localName:r,service:n}));i!=null&&(t[r]=i)}return t}function Iu(n){let e,t=new Uint8Array(0);function r(s){const i=new Uint8Array(t.length+s.length);i.set(t),i.set(s,t.length),t=i}return new ReadableStream({start(){e=n.getReader()},async pull(s){let i;for(;;){if(i===void 0&&t.byteLength>=5){let u=0;for(let l=1;l<5;l++)u=(u<<8)+t[l];i={flags:t[0],length:u}}if(i!==void 0&&t.byteLength>=i.length+5)break;const a=await e.read();if(a.done)break;r(a.value)}if(i===void 0){if(t.byteLength==0){s.close();return}s.error(new le("premature end of stream",ne.DataLoss));return}const o=t.subarray(5,5+i.length);t=t.subarray(5+i.length),s.enqueue({flags:i.flags,data:o})}})}function Su(n,e){const t=new Uint8Array(e.length+5);t.set(e,5);const r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.setUint8(0,n),r.setUint32(1,e.length),t}var wm=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,u){o=n[i](o),s(a,u,o.done,o.value)})}}function s(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}},qs=function(n){return this instanceof qs?(this.v=n,this):new qs(n)},bm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof qs?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}},Tm=function(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:qs(n[s](o)),done:!1}:i?i(o):o}:i}};function Am(n){return bm(this,arguments,function*(){yield qs(yield*Tm(wm(n)))})}var rf=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=n[i]&&function(o){return new Promise(function(a,u){o=n[i](o),s(a,u,o.done,o.value)})}}function s(i,o,a,u){Promise.resolve(u).then(function(l){i({value:l,done:a})},o)}},fs=function(n){return this instanceof fs?(this.v=n,this):new fs(n)},Im=function(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,i){e[s]=n[s]?function(o){return(t=!t)?{value:fs(n[s](o)),done:!1}:i?i(o):o}:i}},Sm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof fs?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}};function xm(n,e){return vm(n,t=>{switch(t.kind){case Fe.Unary:return km(e,n,t);case Fe.ServerStreaming:return Em(e,n,t);case Fe.ClientStreaming:return Cm(e,n,t);case Fe.BiDiStreaming:return Nm(e,n,t);default:return null}})}function km(n,e,t){return async function(r,s){var i,o;const a=await n.unary(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);return(i=s==null?void 0:s.onHeader)===null||i===void 0||i.call(s,a.header),(o=s==null?void 0:s.onTrailer)===null||o===void 0||o.call(s,a.trailer),a.message}}function Em(n,e,t){return function(r,s){return sf(n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,Am([r]),s==null?void 0:s.contextValues),s)}}function Cm(n,e,t){return async function(r,s){var i,o,a,u,l,h;const d=await n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues);(l=s==null?void 0:s.onHeader)===null||l===void 0||l.call(s,d.header);let v;try{for(var p=!0,A=rf(d.message),I;I=await A.next(),i=I.done,!i;p=!0)u=I.value,p=!1,v=u}catch(D){o={error:D}}finally{try{!p&&!i&&(a=A.return)&&await a.call(A)}finally{if(o)throw o.error}}if(!v)throw new le("protocol error: missing response message",ne.Internal);return(h=s==null?void 0:s.onTrailer)===null||h===void 0||h.call(s,d.trailer),v}}function Nm(n,e,t){return function(r,s){return sf(n.stream(e,t,s==null?void 0:s.signal,s==null?void 0:s.timeoutMs,s==null?void 0:s.headers,r,s==null?void 0:s.contextValues),s)}}function sf(n,e){const t=function(){var r,s;return Sm(this,arguments,function*(){const i=yield fs(n);(r=e==null?void 0:e.onHeader)===null||r===void 0||r.call(e,i.header),yield fs(yield*Im(rf(i.message))),(s=e==null?void 0:e.onTrailer)===null||s===void 0||s.call(e,i.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>t.next()})}}function Pm(...n){const e=new AbortController,t=n.filter(s=>s!==void 0).concat(e.signal);for(const s of t){if(s.aborted){r.apply(s);break}s.addEventListener("abort",r)}function r(){e.signal.aborted||e.abort(of(this));for(const s of t)s.removeEventListener("abort",r)}return e}function Om(n){const e=new AbortController,t=()=>{e.abort(new le("the operation timed out",ne.DeadlineExceeded))};let r;return n!==void 0&&(n<=0?t():r=setTimeout(t,n)),{signal:e.signal,cleanup:()=>clearTimeout(r)}}function of(n){if(!n.aborted)return;if(n.reason!==void 0)return n.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function xu(){return{get(n){return n.id in this?this[n.id]:n.defaultValue},set(n,e){return this[n.id]=e,this},delete(n){return delete this[n.id],this}}}const Lo=128;function ku(n){const e=new Headers,t=new TextDecoder().decode(n).split(`\r +`);for(const r of t){if(r==="")continue;const s=r.indexOf(":");if(s>0){const i=r.substring(0,s).trim(),o=r.substring(s+1).trim();e.append(i,o)}}return e}const Dm="Content-Type",Bm="Grpc-Timeout",af="Grpc-Status",cf="Grpc-Message",Rm="Grpc-Status-Details-Bin",Fm="X-User-Agent",Lm="X-Grpc-Web",Jm="application/grpc-web+proto",Mm="application/grpc-web+json";class Zn extends P{constructor(e){super(),this.code=0,this.message="",this.details=[],f.util.initPartial(e,this)}static fromBinary(e,t){return new Zn().fromBinary(e,t)}static fromJson(e,t){return new Zn().fromJson(e,t)}static fromJsonString(e,t){return new Zn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Zn,e,t)}}Zn.runtime=f;Zn.typeName="google.rpc.Status";Zn.fields=f.util.newFieldList(()=>[{no:1,name:"code",kind:"scalar",T:5},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"details",kind:"message",T:Ot,repeated:!0}]);const $m="0";function uf(n){var e;const t=n.get(Rm);if(t!=null){const s=ym(t,Zn);if(s.code==0)return;const i=new le(s.message,s.code,n);return i.details=s.details.map(o=>({type:o.typeUrl.substring(o.typeUrl.lastIndexOf("/")+1),value:o.value})),i}const r=n.get(af);if(r!=null){if(r===$m)return;const s=parseInt(r,10);return s in ne?new le(decodeURIComponent((e=n.get(cf))!==null&&e!==void 0?e:""),s,n):new le(`invalid grpc-status: ${r}`,ne.Internal,n)}}function Eu(n,e,t){const r=typeof e=="string"?e:e.typeName,s=typeof t=="string"?t:t.name;return n.toString().replace(/\/?$/,`/${r}/${s}`)}function lf(n,e){return e instanceof n?e:new n(e)}function Um(n,e){function t(r){return r.done===!0?r:{done:r.done,value:lf(n,r.value)}}return{[Symbol.asyncIterator](){const r=e[Symbol.asyncIterator](),s={next:()=>r.next().then(t)};return r.throw!==void 0&&(s.throw=i=>r.throw(i).then(t)),r.return!==void 0&&(s.return=i=>r.return(i).then(t)),s}}}function ff(n,e){var t;return(t=e==null?void 0:e.concat().reverse().reduce((r,s)=>s(r),n))!==null&&t!==void 0?t:n}function qm(n){var e;const t=Object.assign({},n);return(e=t.ignoreUnknownFields)!==null&&e!==void 0||(t.ignoreUnknownFields=!0),t}function Cu(n,e,t,r){const s=e?Nu(n.I,r):Pu(n.I,t);return{parse:(e?Nu(n.O,r):Pu(n.O,t)).parse,serialize:s.serialize}}function Nu(n,e){return{parse(t){try{return n.fromBinary(t,e)}catch(r){const s=r instanceof Error?r.message:String(r);throw new le(`parse binary: ${s}`,ne.InvalidArgument)}},serialize(t){try{return t.toBinary(e)}catch(r){const s=r instanceof Error?r.message:String(r);throw new le(`serialize binary: ${s}`,ne.Internal)}}}}function Pu(n,e){var t,r;const s=(t=e==null?void 0:e.textEncoder)!==null&&t!==void 0?t:new TextEncoder,i=(r=e==null?void 0:e.textDecoder)!==null&&r!==void 0?r:new TextDecoder,o=qm(e);return{parse(a){try{const u=i.decode(a);return n.fromJsonString(u,o)}catch(u){throw le.from(u,ne.InvalidArgument)}},serialize(a){try{const u=a.toJsonString(o);return s.encode(u)}catch(u){throw le.from(u,ne.Internal)}}}}function zm(n){const e=ff(n.next,n.interceptors),[t,r,s]=hf(n),i=Object.assign(Object.assign({},n.req),{message:lf(n.req.method.I,n.req.message),signal:t});return e(i).then(o=>(s(),o),r)}function Km(n){const e=ff(n.next,n.interceptors),[t,r,s]=hf(n),i=Object.assign(Object.assign({},n.req),{message:Um(n.req.method.I,n.req.message),signal:t});let o=!1;return t.addEventListener("abort",function(){var a,u;const l=n.req.message[Symbol.asyncIterator]();o||(a=l.throw)===null||a===void 0||a.call(l,this.reason).catch(()=>{}),(u=l.return)===null||u===void 0||u.call(l).catch(()=>{})}),e(i).then(a=>Object.assign(Object.assign({},a),{message:{[Symbol.asyncIterator](){const u=a.message[Symbol.asyncIterator]();return{next(){return u.next().then(l=>(l.done==!0&&(o=!0,s()),l),r)}}}}}),r)}function hf(n){const{signal:e,cleanup:t}=Om(n.timeoutMs),r=Pm(n.signal,e);return[r.signal,function(i){const o=le.from(e.aborted?of(e):i);return r.abort(o),t(),Promise.reject(o)},function(){t(),r.abort()}]}function Vm(){try{new Headers}catch{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.")}}function Ou(n,e){const t=uf(n);if(t)throw e.forEach((r,s)=>{t.metadata.append(s,r)}),t}function Du(n,e,t,r){const s=new Headers(t??{});return s.set(Dm,n?Jm:Mm),s.set(Lm,"1"),s.set(Fm,"connect-es/1.4.0"),e!==void 0&&s.set(Bm,`${e}m`),s}function jm(n){switch(n){case 400:return ne.Internal;case 401:return ne.Unauthenticated;case 403:return ne.PermissionDenied;case 404:return ne.Unimplemented;case 429:return ne.Unavailable;case 502:return ne.Unavailable;case 503:return ne.Unavailable;case 504:return ne.Unavailable;default:return ne.Unknown}}function Bu(n,e){var t;if(n>=200&&n<300){const r=uf(e);if(r)throw r;return{foundStatus:e.has(af)}}throw new le(decodeURIComponent((t=e.get(cf))!==null&&t!==void 0?t:`HTTP ${n}`),jm(n),e)}var Br=function(n){return this instanceof Br?(this.v=n,this):new Br(n)},Wm=function(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,i=[];return s={},a("next"),a("throw"),a("return",o),s[Symbol.asyncIterator]=function(){return this},s;function o(p){return function(A){return Promise.resolve(A).then(p,d)}}function a(p,A){r[p]&&(s[p]=function(I){return new Promise(function(D,L){i.push([p,I,D,L])>1||u(p,I)})},A&&(s[p]=A(s[p])))}function u(p,A){try{l(r[p](A))}catch(I){v(i[0][3],I)}}function l(p){p.value instanceof Br?Promise.resolve(p.value.v).then(h,d):v(i[0][2],p)}function h(p){u("next",p)}function d(p){u("throw",p)}function v(p,A){p(A),i.shift(),i.length&&u(i[0][0],i[0][1])}};function Hm(n){var e;Vm();const t=(e=n.useBinaryFormat)!==null&&e!==void 0?e:!0;return{async unary(r,s,i,o,a,u,l){var h;const{serialize:d,parse:v}=Cu(s,t,n.jsonOptions,n.binaryOptions);return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,await zm({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!1,service:r,method:s,url:Eu(n.baseUrl,r,s),init:{method:"POST",credentials:(h=n.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Du(t,o,a),contextValues:l??xu(),message:u},next:async p=>{var A;const D=await((A=n.fetch)!==null&&A!==void 0?A:globalThis.fetch)(p.url,Object.assign(Object.assign({},p.init),{headers:p.header,signal:p.signal,body:Su(0,d(p.message))}));if(Bu(D.status,D.headers),!D.body)throw"missing response body";const L=Iu(D.body).getReader();let $,V;for(;;){const U=await L.read();if(U.done)break;const{flags:W,data:ee}=U.value;if(W===Lo){if($!==void 0)throw"extra trailer";$=ku(ee);continue}if(V!==void 0)throw"extra message";V=v(ee)}if($===void 0)throw"missing trailer";if(Ou($,D.headers),V===void 0)throw"missing message";return{stream:!1,service:r,method:s,header:D.headers,message:V,trailer:$}}})},async stream(r,s,i,o,a,u,l){var h;const{serialize:d,parse:v}=Cu(s,t,n.jsonOptions,n.binaryOptions);function p(I,D,L,$){return Wm(this,arguments,function*(){const U=Iu(I).getReader();if(D){if(!(yield Br(U.read())).done)throw"extra data for trailers-only";return yield Br(void 0)}let W=!1;for(;;){const ee=yield Br(U.read());if(ee.done)break;const{flags:oe,data:te}=ee.value;if((oe&Lo)===Lo){if(W)throw"extra trailer";W=!0;const Ee=ku(te);Ou(Ee,$),Ee.forEach((Ie,Ge)=>L.set(Ge,Ie));continue}if(W)throw"extra message";yield yield Br(v(te))}if(!W)throw"missing trailer"})}async function A(I){if(s.kind!=Fe.ServerStreaming)throw"The fetch API does not support streaming request bodies";const D=await I[Symbol.asyncIterator]().next();if(D.done==!0)throw"missing request message";return Su(0,d(D.value))}return o=o===void 0?n.defaultTimeoutMs:o<=0?void 0:o,Km({interceptors:n.interceptors,signal:i,timeoutMs:o,req:{stream:!0,service:r,method:s,url:Eu(n.baseUrl,r,s),init:{method:"POST",credentials:(h=n.credentials)!==null&&h!==void 0?h:"same-origin",redirect:"error",mode:"cors"},header:Du(t,o,a),contextValues:l??xu(),message:u},next:async I=>{var D;const $=await((D=n.fetch)!==null&&D!==void 0?D:globalThis.fetch)(I.url,Object.assign(Object.assign({},I.init),{headers:I.header,signal:I.signal,body:await A(I.message)})),{foundStatus:V}=Bu($.status,$.headers);if(!$.body)throw"missing response body";const U=new Headers;return Object.assign(Object.assign({},I),{header:$.headers,trailer:U,message:p($.body,V,U,$.headers)})}})}}}var G=(n=>(n[n.NULL=0]="NULL",n[n.BOOLEAN=1]="BOOLEAN",n[n.INTEGER=2]="INTEGER",n[n.LONG=3]="LONG",n[n.DOUBLE=4]="DOUBLE",n[n.STRING=5]="STRING",n[n.BYTES=6]="BYTES",n[n.DATE=7]="DATE",n[n.JSON_OBJECT=8]="JSON_OBJECT",n[n.JSON_ARRAY=9]="JSON_ARRAY",n[n.TEXT=10]="TEXT",n[n.INTEGER_CNT=11]="INTEGER_CNT",n[n.LONG_CNT=12]="LONG_CNT",n[n.TREE=13]="TREE",n))(G||{});f.util.setEnumType(G,"yorkie.v1.ValueType",[{no:0,name:"VALUE_TYPE_NULL"},{no:1,name:"VALUE_TYPE_BOOLEAN"},{no:2,name:"VALUE_TYPE_INTEGER"},{no:3,name:"VALUE_TYPE_LONG"},{no:4,name:"VALUE_TYPE_DOUBLE"},{no:5,name:"VALUE_TYPE_STRING"},{no:6,name:"VALUE_TYPE_BYTES"},{no:7,name:"VALUE_TYPE_DATE"},{no:8,name:"VALUE_TYPE_JSON_OBJECT"},{no:9,name:"VALUE_TYPE_JSON_ARRAY"},{no:10,name:"VALUE_TYPE_TEXT"},{no:11,name:"VALUE_TYPE_INTEGER_CNT"},{no:12,name:"VALUE_TYPE_LONG_CNT"},{no:13,name:"VALUE_TYPE_TREE"}]);var $r=(n=>(n[n.DOCUMENT_CHANGED=0]="DOCUMENT_CHANGED",n[n.DOCUMENT_WATCHED=1]="DOCUMENT_WATCHED",n[n.DOCUMENT_UNWATCHED=2]="DOCUMENT_UNWATCHED",n[n.DOCUMENT_BROADCAST=3]="DOCUMENT_BROADCAST",n))($r||{});f.util.setEnumType($r,"yorkie.v1.DocEventType",[{no:0,name:"DOC_EVENT_TYPE_DOCUMENT_CHANGED"},{no:1,name:"DOC_EVENT_TYPE_DOCUMENT_WATCHED"},{no:2,name:"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED"},{no:3,name:"DOC_EVENT_TYPE_DOCUMENT_BROADCAST"}]);const _t=class _t extends P{constructor(t){super();c(this,"root");c(this,"presences",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new _t().fromBinary(t,r)}static fromJson(t,r){return new _t().fromJson(t,r)}static fromJsonString(t,r){return new _t().fromJsonString(t,r)}static equals(t,r){return f.util.equals(_t,t,r)}};c(_t,"runtime",f),c(_t,"typeName","yorkie.v1.Snapshot"),c(_t,"fields",f.util.newFieldList(()=>[{no:1,name:"root",kind:"message",T:ze},{no:2,name:"presences",kind:"map",K:9,V:{kind:"message",T:nc}}]));let ra=_t;var Xe;let or=(Xe=class extends P{constructor(t){super();c(this,"documentKey","");c(this,"checkpoint");c(this,"snapshot",new Uint8Array(0));c(this,"changes",[]);c(this,"minSyncedTicket");c(this,"isRemoved",!1);c(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xe().fromBinary(t,r)}static fromJson(t,r){return new Xe().fromJson(t,r)}static fromJsonString(t,r){return new Xe().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xe,t,r)}},c(Xe,"runtime",f),c(Xe,"typeName","yorkie.v1.ChangePack"),c(Xe,"fields",f.util.newFieldList(()=>[{no:1,name:"document_key",kind:"scalar",T:9},{no:2,name:"checkpoint",kind:"message",T:mf},{no:3,name:"snapshot",kind:"scalar",T:12},{no:4,name:"changes",kind:"message",T:df,repeated:!0},{no:5,name:"min_synced_ticket",kind:"message",T:F},{no:6,name:"is_removed",kind:"scalar",T:8},{no:7,name:"version_vector",kind:"message",T:vo}])),Xe);var Ze;let df=(Ze=class extends P{constructor(t){super();c(this,"id");c(this,"message","");c(this,"operations",[]);c(this,"presenceChange");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ze().fromBinary(t,r)}static fromJson(t,r){return new Ze().fromJson(t,r)}static fromJsonString(t,r){return new Ze().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ze,t,r)}},c(Ze,"runtime",f),c(Ze,"typeName","yorkie.v1.Change"),c(Ze,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:yo},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"operations",kind:"message",T:tc,repeated:!0},{no:4,name:"presence_change",kind:"message",T:Vs}])),Ze);var Qe;let yo=(Qe=class extends P{constructor(t){super();c(this,"clientSeq",0);c(this,"serverSeq",fe.zero);c(this,"lamport",fe.zero);c(this,"actorId",new Uint8Array(0));c(this,"versionVector");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qe().fromBinary(t,r)}static fromJson(t,r){return new Qe().fromJson(t,r)}static fromJsonString(t,r){return new Qe().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qe,t,r)}},c(Qe,"runtime",f),c(Qe,"typeName","yorkie.v1.ChangeID"),c(Qe,"fields",f.util.newFieldList(()=>[{no:1,name:"client_seq",kind:"scalar",T:13},{no:2,name:"server_seq",kind:"scalar",T:3},{no:3,name:"lamport",kind:"scalar",T:3},{no:4,name:"actor_id",kind:"scalar",T:12},{no:5,name:"version_vector",kind:"message",T:vo}])),Qe);var et;let vo=(et=class extends P{constructor(t){super();c(this,"vector",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new et().fromBinary(t,r)}static fromJson(t,r){return new et().fromJson(t,r)}static fromJsonString(t,r){return new et().fromJsonString(t,r)}static equals(t,r){return f.util.equals(et,t,r)}},c(et,"runtime",f),c(et,"typeName","yorkie.v1.VersionVector"),c(et,"fields",f.util.newFieldList(()=>[{no:1,name:"vector",kind:"map",K:9,V:{kind:"scalar",T:3}}])),et);var tt;let tc=(tt=class extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new tt().fromBinary(t,r)}static fromJson(t,r){return new tt().fromJson(t,r)}static fromJsonString(t,r){return new tt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tt,t,r)}},c(tt,"runtime",f),c(tt,"typeName","yorkie.v1.Operation"),c(tt,"fields",f.util.newFieldList(()=>[{no:1,name:"set",kind:"message",T:Ji,oneof:"body"},{no:2,name:"add",kind:"message",T:Mi,oneof:"body"},{no:3,name:"move",kind:"message",T:$i,oneof:"body"},{no:4,name:"remove",kind:"message",T:Ui,oneof:"body"},{no:5,name:"edit",kind:"message",T:qi,oneof:"body"},{no:6,name:"select",kind:"message",T:sa,oneof:"body"},{no:7,name:"style",kind:"message",T:zi,oneof:"body"},{no:8,name:"increase",kind:"message",T:Ki,oneof:"body"},{no:9,name:"tree_edit",kind:"message",T:Vi,oneof:"body"},{no:10,name:"tree_style",kind:"message",T:ji,oneof:"body"},{no:11,name:"array_set",kind:"message",T:ia,oneof:"body"}])),tt);const Yt=class Yt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"key","");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Yt().fromBinary(t,r)}static fromJson(t,r){return new Yt().fromJson(t,r)}static fromJsonString(t,r){return new Yt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Yt,t,r)}};c(Yt,"runtime",f),c(Yt,"typeName","yorkie.v1.Operation.Set"),c(Yt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let Ji=Yt;const Xt=class Xt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"prevCreatedAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Xt().fromBinary(t,r)}static fromJson(t,r){return new Xt().fromJson(t,r)}static fromJsonString(t,r){return new Xt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Xt,t,r)}};c(Xt,"runtime",f),c(Xt,"typeName","yorkie.v1.Operation.Add"),c(Xt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"prev_created_at",kind:"message",T:F},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let Mi=Xt;const Zt=class Zt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"prevCreatedAt");c(this,"createdAt");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Zt().fromBinary(t,r)}static fromJson(t,r){return new Zt().fromJson(t,r)}static fromJsonString(t,r){return new Zt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Zt,t,r)}};c(Zt,"runtime",f),c(Zt,"typeName","yorkie.v1.Operation.Move"),c(Zt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"prev_created_at",kind:"message",T:F},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"executed_at",kind:"message",T:F}]));let $i=Zt;const Qt=class Qt extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"createdAt");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Qt().fromBinary(t,r)}static fromJson(t,r){return new Qt().fromJson(t,r)}static fromJsonString(t,r){return new Qt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Qt,t,r)}};c(Qt,"runtime",f),c(Qt,"typeName","yorkie.v1.Operation.Remove"),c(Qt,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"executed_at",kind:"message",T:F}]));let Ui=Qt;const en=class en extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"createdAtMapByActor",{});c(this,"content","");c(this,"executedAt");c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new en().fromBinary(t,r)}static fromJson(t,r){return new en().fromJson(t,r)}static fromJsonString(t,r){return new en().fromJsonString(t,r)}static equals(t,r){return f.util.equals(en,t,r)}};c(en,"runtime",f),c(en,"typeName","yorkie.v1.Operation.Edit"),c(en,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}},{no:5,name:"content",kind:"scalar",T:9},{no:6,name:"executed_at",kind:"message",T:F},{no:7,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}]));let qi=en;const tn=class tn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new tn().fromBinary(t,r)}static fromJson(t,r){return new tn().fromJson(t,r)}static fromJsonString(t,r){return new tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(tn,t,r)}};c(tn,"runtime",f),c(tn,"typeName","yorkie.v1.Operation.Select"),c(tn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"executed_at",kind:"message",T:F}]));let sa=tn;const nn=class nn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"attributes",{});c(this,"executedAt");c(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new nn().fromBinary(t,r)}static fromJson(t,r){return new nn().fromJson(t,r)}static fromJsonString(t,r){return new nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nn,t,r)}};c(nn,"runtime",f),c(nn,"typeName","yorkie.v1.Operation.Style"),c(nn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:rr},{no:3,name:"to",kind:"message",T:rr},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:F},{no:6,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}}]));let zi=nn;const rn=class rn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new rn().fromBinary(t,r)}static fromJson(t,r){return new rn().fromJson(t,r)}static fromJsonString(t,r){return new rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rn,t,r)}};c(rn,"runtime",f),c(rn,"typeName","yorkie.v1.Operation.Increase"),c(rn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"value",kind:"message",T:Ye},{no:3,name:"executed_at",kind:"message",T:F}]));let Ki=rn;const sn=class sn extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"createdAtMapByActor",{});c(this,"contents",[]);c(this,"splitLevel",0);c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new sn().fromBinary(t,r)}static fromJson(t,r){return new sn().fromJson(t,r)}static fromJsonString(t,r){return new sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(sn,t,r)}};c(sn,"runtime",f),c(sn,"typeName","yorkie.v1.Operation.TreeEdit"),c(sn,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:Ur},{no:3,name:"to",kind:"message",T:Ur},{no:4,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}},{no:5,name:"contents",kind:"message",T:eo,repeated:!0},{no:7,name:"split_level",kind:"scalar",T:5},{no:6,name:"executed_at",kind:"message",T:F}]));let Vi=sn;const on=class on extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"from");c(this,"to");c(this,"attributes",{});c(this,"executedAt");c(this,"attributesToRemove",[]);c(this,"createdAtMapByActor",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new on().fromBinary(t,r)}static fromJson(t,r){return new on().fromJson(t,r)}static fromJsonString(t,r){return new on().fromJsonString(t,r)}static equals(t,r){return f.util.equals(on,t,r)}};c(on,"runtime",f),c(on,"typeName","yorkie.v1.Operation.TreeStyle"),c(on,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"from",kind:"message",T:Ur},{no:3,name:"to",kind:"message",T:Ur},{no:4,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"executed_at",kind:"message",T:F},{no:6,name:"attributes_to_remove",kind:"scalar",T:9,repeated:!0},{no:7,name:"created_at_map_by_actor",kind:"map",K:9,V:{kind:"message",T:F}}]));let ji=on;const an=class an extends P{constructor(t){super();c(this,"parentCreatedAt");c(this,"createdAt");c(this,"value");c(this,"executedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new an().fromBinary(t,r)}static fromJson(t,r){return new an().fromJson(t,r)}static fromJsonString(t,r){return new an().fromJsonString(t,r)}static equals(t,r){return f.util.equals(an,t,r)}};c(an,"runtime",f),c(an,"typeName","yorkie.v1.Operation.ArraySet"),c(an,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_created_at",kind:"message",T:F},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"value",kind:"message",T:Ye},{no:4,name:"executed_at",kind:"message",T:F}]));let ia=an;const cn=class cn extends P{constructor(t){super();c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");c(this,"type",0);c(this,"value",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new cn().fromBinary(t,r)}static fromJson(t,r){return new cn().fromJson(t,r)}static fromJsonString(t,r){return new cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(cn,t,r)}};c(cn,"runtime",f),c(cn,"typeName","yorkie.v1.JSONElementSimple"),c(cn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"moved_at",kind:"message",T:F},{no:3,name:"removed_at",kind:"message",T:F},{no:4,name:"type",kind:"enum",T:f.getEnumType(G)},{no:5,name:"value",kind:"scalar",T:12}]));let Ye=cn;const un=class un extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new un().fromBinary(t,r)}static fromJson(t,r){return new un().fromJson(t,r)}static fromJsonString(t,r){return new un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(un,t,r)}};c(un,"runtime",f),c(un,"typeName","yorkie.v1.JSONElement"),c(un,"fields",f.util.newFieldList(()=>[{no:1,name:"json_object",kind:"message",T:Wi,oneof:"body"},{no:2,name:"json_array",kind:"message",T:Hi,oneof:"body"},{no:3,name:"primitive",kind:"message",T:Gi,oneof:"body"},{no:5,name:"text",kind:"message",T:_i,oneof:"body"},{no:6,name:"counter",kind:"message",T:Yi,oneof:"body"},{no:7,name:"tree",kind:"message",T:Xi,oneof:"body"}]));let ze=un;const ln=class ln extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new ln().fromBinary(t,r)}static fromJson(t,r){return new ln().fromJson(t,r)}static fromJsonString(t,r){return new ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(ln,t,r)}};c(ln,"runtime",f),c(ln,"typeName","yorkie.v1.JSONElement.JSONObject"),c(ln,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:gf,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Wi=ln;const fn=class fn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new fn().fromBinary(t,r)}static fromJson(t,r){return new fn().fromJson(t,r)}static fromJsonString(t,r){return new fn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(fn,t,r)}};c(fn,"runtime",f),c(fn,"typeName","yorkie.v1.JSONElement.JSONArray"),c(fn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Zi,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Hi=fn;const hn=class hn extends P{constructor(t){super();c(this,"type",0);c(this,"value",new Uint8Array(0));c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new hn().fromBinary(t,r)}static fromJson(t,r){return new hn().fromJson(t,r)}static fromJsonString(t,r){return new hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(hn,t,r)}};c(hn,"runtime",f),c(hn,"typeName","yorkie.v1.JSONElement.Primitive"),c(hn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(G)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"moved_at",kind:"message",T:F},{no:5,name:"removed_at",kind:"message",T:F}]));let Gi=hn;const dn=class dn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new dn().fromBinary(t,r)}static fromJson(t,r){return new dn().fromJson(t,r)}static fromJsonString(t,r){return new dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(dn,t,r)}};c(dn,"runtime",f),c(dn,"typeName","yorkie.v1.JSONElement.Text"),c(dn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Qi,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let _i=dn;const gn=class gn extends P{constructor(t){super();c(this,"type",0);c(this,"value",new Uint8Array(0));c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new gn().fromBinary(t,r)}static fromJson(t,r){return new gn().fromJson(t,r)}static fromJsonString(t,r){return new gn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(gn,t,r)}};c(gn,"runtime",f),c(gn,"typeName","yorkie.v1.JSONElement.Counter"),c(gn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(G)},{no:2,name:"value",kind:"scalar",T:12},{no:3,name:"created_at",kind:"message",T:F},{no:4,name:"moved_at",kind:"message",T:F},{no:5,name:"removed_at",kind:"message",T:F}]));let Yi=gn;const mn=class mn extends P{constructor(t){super();c(this,"nodes",[]);c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new mn().fromBinary(t,r)}static fromJson(t,r){return new mn().fromJson(t,r)}static fromJsonString(t,r){return new mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(mn,t,r)}};c(mn,"runtime",f),c(mn,"typeName","yorkie.v1.JSONElement.Tree"),c(mn,"fields",f.util.newFieldList(()=>[{no:1,name:"nodes",kind:"message",T:Ks,repeated:!0},{no:2,name:"created_at",kind:"message",T:F},{no:3,name:"moved_at",kind:"message",T:F},{no:4,name:"removed_at",kind:"message",T:F}]));let Xi=mn;var nt;let gf=(nt=class extends P{constructor(t){super();c(this,"key","");c(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new nt().fromBinary(t,r)}static fromJson(t,r){return new nt().fromJson(t,r)}static fromJsonString(t,r){return new nt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(nt,t,r)}},c(nt,"runtime",f),c(nt,"typeName","yorkie.v1.RHTNode"),c(nt,"fields",f.util.newFieldList(()=>[{no:1,name:"key",kind:"scalar",T:9},{no:2,name:"element",kind:"message",T:ze}])),nt);const Et=class Et extends P{constructor(t){super();c(this,"next");c(this,"element");f.util.initPartial(t,this)}static fromBinary(t,r){return new Et().fromBinary(t,r)}static fromJson(t,r){return new Et().fromJson(t,r)}static fromJsonString(t,r){return new Et().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Et,t,r)}};c(Et,"runtime",f),c(Et,"typeName","yorkie.v1.RGANode"),c(Et,"fields",f.util.newFieldList(()=>[{no:1,name:"next",kind:"message",T:Et},{no:2,name:"element",kind:"message",T:ze}]));let Zi=Et;const pn=class pn extends P{constructor(t){super();c(this,"value","");c(this,"updatedAt");c(this,"isRemoved",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new pn().fromBinary(t,r)}static fromJson(t,r){return new pn().fromJson(t,r)}static fromJsonString(t,r){return new pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(pn,t,r)}};c(pn,"runtime",f),c(pn,"typeName","yorkie.v1.NodeAttr"),c(pn,"fields",f.util.newFieldList(()=>[{no:1,name:"value",kind:"scalar",T:9},{no:2,name:"updated_at",kind:"message",T:F},{no:3,name:"is_removed",kind:"scalar",T:8}]));let hs=pn;const yn=class yn extends P{constructor(t){super();c(this,"id");c(this,"value","");c(this,"removedAt");c(this,"insPrevId");c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new yn().fromBinary(t,r)}static fromJson(t,r){return new yn().fromJson(t,r)}static fromJsonString(t,r){return new yn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(yn,t,r)}};c(yn,"runtime",f),c(yn,"typeName","yorkie.v1.TextNode"),c(yn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:zs},{no:2,name:"value",kind:"scalar",T:9},{no:3,name:"removed_at",kind:"message",T:F},{no:4,name:"ins_prev_id",kind:"message",T:zs},{no:5,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let Qi=yn;const vn=class vn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new vn().fromBinary(t,r)}static fromJson(t,r){return new vn().fromJson(t,r)}static fromJsonString(t,r){return new vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(vn,t,r)}};c(vn,"runtime",f),c(vn,"typeName","yorkie.v1.TextNodeID"),c(vn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5}]));let zs=vn;const wn=class wn extends P{constructor(t){super();c(this,"id");c(this,"type","");c(this,"value","");c(this,"removedAt");c(this,"insPrevId");c(this,"insNextId");c(this,"depth",0);c(this,"attributes",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new wn().fromBinary(t,r)}static fromJson(t,r){return new wn().fromJson(t,r)}static fromJsonString(t,r){return new wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(wn,t,r)}};c(wn,"runtime",f),c(wn,"typeName","yorkie.v1.TreeNode"),c(wn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"message",T:pr},{no:2,name:"type",kind:"scalar",T:9},{no:3,name:"value",kind:"scalar",T:9},{no:4,name:"removed_at",kind:"message",T:F},{no:5,name:"ins_prev_id",kind:"message",T:pr},{no:6,name:"ins_next_id",kind:"message",T:pr},{no:7,name:"depth",kind:"scalar",T:5},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"message",T:hs}}]));let Ks=wn;const bn=class bn extends P{constructor(t){super();c(this,"content",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new bn().fromBinary(t,r)}static fromJson(t,r){return new bn().fromJson(t,r)}static fromJsonString(t,r){return new bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(bn,t,r)}};c(bn,"runtime",f),c(bn,"typeName","yorkie.v1.TreeNodes"),c(bn,"fields",f.util.newFieldList(()=>[{no:1,name:"content",kind:"message",T:Ks,repeated:!0}]));let eo=bn;const Tn=class Tn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Tn().fromBinary(t,r)}static fromJson(t,r){return new Tn().fromJson(t,r)}static fromJsonString(t,r){return new Tn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Tn,t,r)}};c(Tn,"runtime",f),c(Tn,"typeName","yorkie.v1.TreeNodeID"),c(Tn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5}]));let pr=Tn;const An=class An extends P{constructor(t){super();c(this,"parentId");c(this,"leftSiblingId");f.util.initPartial(t,this)}static fromBinary(t,r){return new An().fromBinary(t,r)}static fromJson(t,r){return new An().fromJson(t,r)}static fromJsonString(t,r){return new An().fromJsonString(t,r)}static equals(t,r){return f.util.equals(An,t,r)}};c(An,"runtime",f),c(An,"typeName","yorkie.v1.TreePos"),c(An,"fields",f.util.newFieldList(()=>[{no:1,name:"parent_id",kind:"message",T:pr},{no:2,name:"left_sibling_id",kind:"message",T:pr}]));let Ur=An;const In=class In extends P{constructor(t){super();c(this,"id","");c(this,"username","");c(this,"createdAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new In().fromBinary(t,r)}static fromJson(t,r){return new In().fromJson(t,r)}static fromJsonString(t,r){return new In().fromJsonString(t,r)}static equals(t,r){return f.util.equals(In,t,r)}};c(In,"runtime",f),c(In,"typeName","yorkie.v1.User"),c(In,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"created_at",kind:"message",T:Ce}]));let Ru=In;const Sn=class Sn extends P{constructor(t){super();c(this,"id","");c(this,"name","");c(this,"publicKey","");c(this,"secretKey","");c(this,"authWebhookUrl","");c(this,"authWebhookMethods",[]);c(this,"clientDeactivateThreshold","");c(this,"createdAt");c(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new Sn().fromBinary(t,r)}static fromJson(t,r){return new Sn().fromJson(t,r)}static fromJsonString(t,r){return new Sn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Sn,t,r)}};c(Sn,"runtime",f),c(Sn,"typeName","yorkie.v1.Project"),c(Sn,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"public_key",kind:"scalar",T:9},{no:4,name:"secret_key",kind:"scalar",T:9},{no:5,name:"auth_webhook_url",kind:"scalar",T:9},{no:6,name:"auth_webhook_methods",kind:"scalar",T:9,repeated:!0},{no:7,name:"client_deactivate_threshold",kind:"scalar",T:9},{no:8,name:"created_at",kind:"message",T:Ce},{no:9,name:"updated_at",kind:"message",T:Ce}]));let Fu=Sn;const xn=class xn extends P{constructor(t){super();c(this,"name");c(this,"authWebhookUrl");c(this,"authWebhookMethods");c(this,"clientDeactivateThreshold");f.util.initPartial(t,this)}static fromBinary(t,r){return new xn().fromBinary(t,r)}static fromJson(t,r){return new xn().fromJson(t,r)}static fromJsonString(t,r){return new xn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(xn,t,r)}};c(xn,"runtime",f),c(xn,"typeName","yorkie.v1.UpdatableProjectFields"),c(xn,"fields",f.util.newFieldList(()=>[{no:1,name:"name",kind:"message",T:Ve},{no:2,name:"auth_webhook_url",kind:"message",T:Ve},{no:3,name:"auth_webhook_methods",kind:"message",T:oa},{no:4,name:"client_deactivate_threshold",kind:"message",T:Ve}]));let Lu=xn;const kn=class kn extends P{constructor(t){super();c(this,"methods",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new kn().fromBinary(t,r)}static fromJson(t,r){return new kn().fromJson(t,r)}static fromJsonString(t,r){return new kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(kn,t,r)}};c(kn,"runtime",f),c(kn,"typeName","yorkie.v1.UpdatableProjectFields.AuthWebhookMethods"),c(kn,"fields",f.util.newFieldList(()=>[{no:1,name:"methods",kind:"scalar",T:9,repeated:!0}]));let oa=kn;const En=class En extends P{constructor(t){super();c(this,"id","");c(this,"key","");c(this,"snapshot","");c(this,"createdAt");c(this,"accessedAt");c(this,"updatedAt");f.util.initPartial(t,this)}static fromBinary(t,r){return new En().fromBinary(t,r)}static fromJson(t,r){return new En().fromJson(t,r)}static fromJsonString(t,r){return new En().fromJsonString(t,r)}static equals(t,r){return f.util.equals(En,t,r)}};c(En,"runtime",f),c(En,"typeName","yorkie.v1.DocumentSummary"),c(En,"fields",f.util.newFieldList(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"key",kind:"scalar",T:9},{no:3,name:"snapshot",kind:"scalar",T:9},{no:4,name:"created_at",kind:"message",T:Ce},{no:5,name:"accessed_at",kind:"message",T:Ce},{no:6,name:"updated_at",kind:"message",T:Ce}]));let Ju=En;const Cn=class Cn extends P{constructor(t){super();c(this,"type",0);c(this,"presence");f.util.initPartial(t,this)}static fromBinary(t,r){return new Cn().fromBinary(t,r)}static fromJson(t,r){return new Cn().fromJson(t,r)}static fromJsonString(t,r){return new Cn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Cn,t,r)}};c(Cn,"runtime",f),c(Cn,"typeName","yorkie.v1.PresenceChange"),c(Cn,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType(qr)},{no:2,name:"presence",kind:"message",T:nc}]));let Vs=Cn;var qr=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.PUT=1]="PUT",n[n.DELETE=2]="DELETE",n[n.CLEAR=3]="CLEAR",n))(qr||{});f.util.setEnumType(qr,"yorkie.v1.PresenceChange.ChangeType",[{no:0,name:"CHANGE_TYPE_UNSPECIFIED"},{no:1,name:"CHANGE_TYPE_PUT"},{no:2,name:"CHANGE_TYPE_DELETE"},{no:3,name:"CHANGE_TYPE_CLEAR"}]);var rt;let nc=(rt=class extends P{constructor(t){super();c(this,"data",{});f.util.initPartial(t,this)}static fromBinary(t,r){return new rt().fromBinary(t,r)}static fromJson(t,r){return new rt().fromJson(t,r)}static fromJsonString(t,r){return new rt().fromJsonString(t,r)}static equals(t,r){return f.util.equals(rt,t,r)}},c(rt,"runtime",f),c(rt,"typeName","yorkie.v1.Presence"),c(rt,"fields",f.util.newFieldList(()=>[{no:1,name:"data",kind:"map",K:9,V:{kind:"scalar",T:9}}])),rt);var st;let mf=(st=class extends P{constructor(t){super();c(this,"serverSeq",fe.zero);c(this,"clientSeq",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new st().fromBinary(t,r)}static fromJson(t,r){return new st().fromJson(t,r)}static fromJsonString(t,r){return new st().fromJsonString(t,r)}static equals(t,r){return f.util.equals(st,t,r)}},c(st,"runtime",f),c(st,"typeName","yorkie.v1.Checkpoint"),c(st,"fields",f.util.newFieldList(()=>[{no:1,name:"server_seq",kind:"scalar",T:3},{no:2,name:"client_seq",kind:"scalar",T:13}])),st);const Nn=class Nn extends P{constructor(t){super();c(this,"createdAt");c(this,"offset",0);c(this,"relativeOffset",0);f.util.initPartial(t,this)}static fromBinary(t,r){return new Nn().fromBinary(t,r)}static fromJson(t,r){return new Nn().fromJson(t,r)}static fromJsonString(t,r){return new Nn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Nn,t,r)}};c(Nn,"runtime",f),c(Nn,"typeName","yorkie.v1.TextNodePos"),c(Nn,"fields",f.util.newFieldList(()=>[{no:1,name:"created_at",kind:"message",T:F},{no:2,name:"offset",kind:"scalar",T:5},{no:3,name:"relative_offset",kind:"scalar",T:5}]));let rr=Nn;var it;let F=(it=class extends P{constructor(t){super();c(this,"lamport",fe.zero);c(this,"delimiter",0);c(this,"actorId",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new it().fromBinary(t,r)}static fromJson(t,r){return new it().fromJson(t,r)}static fromJsonString(t,r){return new it().fromJsonString(t,r)}static equals(t,r){return f.util.equals(it,t,r)}},c(it,"runtime",f),c(it,"typeName","yorkie.v1.TimeTicket"),c(it,"fields",f.util.newFieldList(()=>[{no:1,name:"lamport",kind:"scalar",T:3},{no:2,name:"delimiter",kind:"scalar",T:13},{no:3,name:"actor_id",kind:"scalar",T:12}])),it);const Pn=class Pn extends P{constructor(t){super();c(this,"topic","");c(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Pn().fromBinary(t,r)}static fromJson(t,r){return new Pn().fromJson(t,r)}static fromJsonString(t,r){return new Pn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Pn,t,r)}};c(Pn,"runtime",f),c(Pn,"typeName","yorkie.v1.DocEventBody"),c(Pn,"fields",f.util.newFieldList(()=>[{no:1,name:"topic",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12}]));let aa=Pn;const On=class On extends P{constructor(t){super();c(this,"type",0);c(this,"publisher","");c(this,"body");f.util.initPartial(t,this)}static fromBinary(t,r){return new On().fromBinary(t,r)}static fromJson(t,r){return new On().fromJson(t,r)}static fromJsonString(t,r){return new On().fromJsonString(t,r)}static equals(t,r){return f.util.equals(On,t,r)}};c(On,"runtime",f),c(On,"typeName","yorkie.v1.DocEvent"),c(On,"fields",f.util.newFieldList(()=>[{no:1,name:"type",kind:"enum",T:f.getEnumType($r)},{no:2,name:"publisher",kind:"scalar",T:9},{no:3,name:"body",kind:"message",T:aa}]));let ca=On;const Dn=class Dn extends P{constructor(t){super();c(this,"clientKey","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Dn().fromBinary(t,r)}static fromJson(t,r){return new Dn().fromJson(t,r)}static fromJsonString(t,r){return new Dn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Dn,t,r)}};c(Dn,"runtime",f),c(Dn,"typeName","yorkie.v1.ActivateClientRequest"),c(Dn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_key",kind:"scalar",T:9}]));let ua=Dn;const Bn=class Bn extends P{constructor(t){super();c(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Bn().fromBinary(t,r)}static fromJson(t,r){return new Bn().fromJson(t,r)}static fromJsonString(t,r){return new Bn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Bn,t,r)}};c(Bn,"runtime",f),c(Bn,"typeName","yorkie.v1.ActivateClientResponse"),c(Bn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let la=Bn;const Rn=class Rn extends P{constructor(t){super();c(this,"clientId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Rn().fromBinary(t,r)}static fromJson(t,r){return new Rn().fromJson(t,r)}static fromJsonString(t,r){return new Rn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Rn,t,r)}};c(Rn,"runtime",f),c(Rn,"typeName","yorkie.v1.DeactivateClientRequest"),c(Rn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9}]));let fa=Rn;const Fn=class Fn extends P{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Fn().fromBinary(e,t)}static fromJson(e,t){return new Fn().fromJson(e,t)}static fromJsonString(e,t){return new Fn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Fn,e,t)}};c(Fn,"runtime",f),c(Fn,"typeName","yorkie.v1.DeactivateClientResponse"),c(Fn,"fields",f.util.newFieldList(()=>[]));let ha=Fn;const Ln=class Ln extends P{constructor(t){super();c(this,"clientId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Ln().fromBinary(t,r)}static fromJson(t,r){return new Ln().fromJson(t,r)}static fromJsonString(t,r){return new Ln().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Ln,t,r)}};c(Ln,"runtime",f),c(Ln,"typeName","yorkie.v1.AttachDocumentRequest"),c(Ln,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:or}]));let da=Ln;const Jn=class Jn extends P{constructor(t){super();c(this,"documentId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Jn().fromBinary(t,r)}static fromJson(t,r){return new Jn().fromJson(t,r)}static fromJsonString(t,r){return new Jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Jn,t,r)}};c(Jn,"runtime",f),c(Jn,"typeName","yorkie.v1.AttachDocumentResponse"),c(Jn,"fields",f.util.newFieldList(()=>[{no:1,name:"document_id",kind:"scalar",T:9},{no:2,name:"change_pack",kind:"message",T:or}]));let ga=Jn;const Mn=class Mn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");c(this,"removeIfNotAttached",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new Mn().fromBinary(t,r)}static fromJson(t,r){return new Mn().fromJson(t,r)}static fromJsonString(t,r){return new Mn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Mn,t,r)}};c(Mn,"runtime",f),c(Mn,"typeName","yorkie.v1.DetachDocumentRequest"),c(Mn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or},{no:4,name:"remove_if_not_attached",kind:"scalar",T:8}]));let ma=Mn;const $n=class $n extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new $n().fromBinary(t,r)}static fromJson(t,r){return new $n().fromJson(t,r)}static fromJsonString(t,r){return new $n().fromJsonString(t,r)}static equals(t,r){return f.util.equals($n,t,r)}};c($n,"runtime",f),c($n,"typeName","yorkie.v1.DetachDocumentResponse"),c($n,"fields",f.util.newFieldList(()=>[{no:2,name:"change_pack",kind:"message",T:or}]));let pa=$n;const Un=class Un extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");f.util.initPartial(t,this)}static fromBinary(t,r){return new Un().fromBinary(t,r)}static fromJson(t,r){return new Un().fromJson(t,r)}static fromJsonString(t,r){return new Un().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Un,t,r)}};c(Un,"runtime",f),c(Un,"typeName","yorkie.v1.WatchDocumentRequest"),c(Un,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9}]));let ya=Un;const qn=class qn extends P{constructor(t){super();c(this,"body",{case:void 0});f.util.initPartial(t,this)}static fromBinary(t,r){return new qn().fromBinary(t,r)}static fromJson(t,r){return new qn().fromJson(t,r)}static fromJsonString(t,r){return new qn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(qn,t,r)}};c(qn,"runtime",f),c(qn,"typeName","yorkie.v1.WatchDocumentResponse"),c(qn,"fields",f.util.newFieldList(()=>[{no:1,name:"initialization",kind:"message",T:wa,oneof:"body"},{no:2,name:"event",kind:"message",T:ca,oneof:"body"}]));let va=qn;const zn=class zn extends P{constructor(t){super();c(this,"clientIds",[]);f.util.initPartial(t,this)}static fromBinary(t,r){return new zn().fromBinary(t,r)}static fromJson(t,r){return new zn().fromJson(t,r)}static fromJsonString(t,r){return new zn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(zn,t,r)}};c(zn,"runtime",f),c(zn,"typeName","yorkie.v1.WatchDocumentResponse.Initialization"),c(zn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_ids",kind:"scalar",T:9,repeated:!0}]));let wa=zn;const Kn=class Kn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Kn().fromBinary(t,r)}static fromJson(t,r){return new Kn().fromJson(t,r)}static fromJsonString(t,r){return new Kn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Kn,t,r)}};c(Kn,"runtime",f),c(Kn,"typeName","yorkie.v1.RemoveDocumentRequest"),c(Kn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or}]));let ba=Kn;const Vn=class Vn extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Vn().fromBinary(t,r)}static fromJson(t,r){return new Vn().fromJson(t,r)}static fromJsonString(t,r){return new Vn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Vn,t,r)}};c(Vn,"runtime",f),c(Vn,"typeName","yorkie.v1.RemoveDocumentResponse"),c(Vn,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:or}]));let Ta=Vn;const jn=class jn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"changePack");c(this,"pushOnly",!1);f.util.initPartial(t,this)}static fromBinary(t,r){return new jn().fromBinary(t,r)}static fromJson(t,r){return new jn().fromJson(t,r)}static fromJsonString(t,r){return new jn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(jn,t,r)}};c(jn,"runtime",f),c(jn,"typeName","yorkie.v1.PushPullChangesRequest"),c(jn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"change_pack",kind:"message",T:or},{no:4,name:"push_only",kind:"scalar",T:8}]));let Aa=jn;const Wn=class Wn extends P{constructor(t){super();c(this,"changePack");f.util.initPartial(t,this)}static fromBinary(t,r){return new Wn().fromBinary(t,r)}static fromJson(t,r){return new Wn().fromJson(t,r)}static fromJsonString(t,r){return new Wn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Wn,t,r)}};c(Wn,"runtime",f),c(Wn,"typeName","yorkie.v1.PushPullChangesResponse"),c(Wn,"fields",f.util.newFieldList(()=>[{no:1,name:"change_pack",kind:"message",T:or}]));let Ia=Wn;const Hn=class Hn extends P{constructor(t){super();c(this,"clientId","");c(this,"documentId","");c(this,"topic","");c(this,"payload",new Uint8Array(0));f.util.initPartial(t,this)}static fromBinary(t,r){return new Hn().fromBinary(t,r)}static fromJson(t,r){return new Hn().fromJson(t,r)}static fromJsonString(t,r){return new Hn().fromJsonString(t,r)}static equals(t,r){return f.util.equals(Hn,t,r)}};c(Hn,"runtime",f),c(Hn,"typeName","yorkie.v1.BroadcastRequest"),c(Hn,"fields",f.util.newFieldList(()=>[{no:1,name:"client_id",kind:"scalar",T:9},{no:2,name:"document_id",kind:"scalar",T:9},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"payload",kind:"scalar",T:12}]));let Sa=Hn;const Gn=class Gn extends P{constructor(e){super(),f.util.initPartial(e,this)}static fromBinary(e,t){return new Gn().fromBinary(e,t)}static fromJson(e,t){return new Gn().fromJson(e,t)}static fromJsonString(e,t){return new Gn().fromJsonString(e,t)}static equals(e,t){return f.util.equals(Gn,e,t)}};c(Gn,"runtime",f),c(Gn,"typeName","yorkie.v1.BroadcastResponse"),c(Gn,"fields",f.util.newFieldList(()=>[]));let xa=Gn;const Gm={typeName:"yorkie.v1.YorkieService",methods:{activateClient:{name:"ActivateClient",I:ua,O:la,kind:Fe.Unary},deactivateClient:{name:"DeactivateClient",I:fa,O:ha,kind:Fe.Unary},attachDocument:{name:"AttachDocument",I:da,O:ga,kind:Fe.Unary},detachDocument:{name:"DetachDocument",I:ma,O:pa,kind:Fe.Unary},removeDocument:{name:"RemoveDocument",I:ba,O:Ta,kind:Fe.Unary},pushPullChanges:{name:"PushPullChanges",I:Aa,O:Ia,kind:Fe.Unary},watchDocument:{name:"WatchDocument",I:ya,O:va,kind:Fe.ServerStreaming},broadcast:{name:"Broadcast",I:Sa,O:xa,kind:Fe.Unary}}},_m=f.makeMessageType("google.rpc.ErrorInfo",()=>[{no:1,name:"reason",kind:"scalar",T:9},{no:2,name:"domain",kind:"scalar",T:9},{no:3,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}}]);f.makeMessageType("google.rpc.RetryInfo",()=>[{no:1,name:"retry_delay",kind:"message",T:Xn}]);f.makeMessageType("google.rpc.DebugInfo",()=>[{no:1,name:"stack_entries",kind:"scalar",T:9,repeated:!0},{no:2,name:"detail",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.QuotaFailure",()=>[{no:1,name:"violations",kind:"message",T:Ym,repeated:!0}]);const Ym=f.makeMessageType("google.rpc.QuotaFailure.Violation",()=>[{no:1,name:"subject",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"QuotaFailure_Violation"});f.makeMessageType("google.rpc.PreconditionFailure",()=>[{no:1,name:"violations",kind:"message",T:Xm,repeated:!0}]);const Xm=f.makeMessageType("google.rpc.PreconditionFailure.Violation",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"subject",kind:"scalar",T:9},{no:3,name:"description",kind:"scalar",T:9}],{localName:"PreconditionFailure_Violation"});f.makeMessageType("google.rpc.BadRequest",()=>[{no:1,name:"field_violations",kind:"message",T:Zm,repeated:!0}]);const Zm=f.makeMessageType("google.rpc.BadRequest.FieldViolation",()=>[{no:1,name:"field",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}],{localName:"BadRequest_FieldViolation"});f.makeMessageType("google.rpc.RequestInfo",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"serving_data",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.ResourceInfo",()=>[{no:1,name:"resource_type",kind:"scalar",T:9},{no:2,name:"resource_name",kind:"scalar",T:9},{no:3,name:"owner",kind:"scalar",T:9},{no:4,name:"description",kind:"scalar",T:9}]);f.makeMessageType("google.rpc.Help",()=>[{no:1,name:"links",kind:"message",T:Qm,repeated:!0}]);const Qm=f.makeMessageType("google.rpc.Help.Link",()=>[{no:1,name:"description",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9}],{localName:"Help_Link"});f.makeMessageType("google.rpc.LocalizedMessage",()=>[{no:1,name:"locale",kind:"scalar",T:9},{no:2,name:"message",kind:"scalar",T:9}]);var y=(n=>(n.Ok="ok",n.ErrClientNotActivated="ErrClientNotActivated",n.ErrClientNotFound="ErrClientNotFound",n.ErrUnimplemented="ErrUnimplemented",n.ErrInvalidType="ErrInvalidType",n.ErrDummy="ErrDummy",n.ErrDocumentNotAttached="ErrDocumentNotAttached",n.ErrDocumentNotDetached="ErrDocumentNotDetached",n.ErrDocumentRemoved="ErrDocumentRemoved",n.ErrInvalidObjectKey="ErrInvalidObjectKey",n.ErrInvalidArgument="ErrInvalidArgument",n.ErrNotInitialized="ErrNotInitialized",n.ErrNotReady="ErrNotReady",n.ErrRefused="ErrRefused",n.ErrContextNotProvided="ErrContextNotProvided",n.ErrPermissionDenied="ErrPermissionDenied",n.ErrUnauthenticated="ErrUnauthenticated",n))(y||{});class w extends Error{constructor(t,r){super(r);c(this,"name","YorkieError");c(this,"stack");this.code=t,this.message=r,this.toString=()=>`[code=${this.code}]: ${this.message}`}}function dt(n){if(n instanceof Map){const e=Array.from(n);return new Map(JSON.parse(JSON.stringify(e)))}return JSON.parse(JSON.stringify(n))}const pf=n=>n?Object.entries(n).length===0:!0,ds=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.stringify(r);return e},ss=n=>{const e={};for(const[t,r]of Object.entries(n))e[t]=JSON.parse(r);return e};var Tr=(n=>(n.Put="put",n.Clear="clear",n))(Tr||{});class Jo{constructor(e,t){c(this,"context");c(this,"presence");this.context=e,this.presence=t}set(e,t){for(const r of Object.keys(e))this.presence[r]=e[r];this.context.setPresenceChange({type:"put",presence:dt(this.presence)}),this.context.setReversePresence(e,t)}get(e){return this.presence[e]}clear(){this.presence={},this.context.setPresenceChange({type:"clear"})}}const wo="000000000000000000000000";class ct{constructor(e,t,r){c(this,"lamport");c(this,"delimiter");c(this,"actorID");this.lamport=e,this.delimiter=t,this.actorID=r}static of(e,t,r){return new ct(e,t,r)}static fromStruct(e){return ct.of(BigInt(e.lamport),e.delimiter,e.actorID)}toIDString(){return`${this.lamport.toString()}:${this.actorID}:${this.delimiter}`}toStruct(){return{lamport:this.getLamportAsString(),delimiter:this.getDelimiter(),actorID:this.getActorID()}}toTestString(){return`${this.lamport.toString()}:${this.actorID.slice(-2)}:${this.delimiter}`}setActor(e){return new ct(this.lamport,this.delimiter,e)}getLamportAsString(){return this.lamport.toString()}getLamport(){return this.lamport}getDelimiter(){return this.delimiter}getActorID(){return this.actorID}after(e){return this.compare(e)>0}equals(e){return this.compare(e)===0}compare(e){if(this.lamport>e.lamport)return 1;if(e.lamport>this.lamport)return-1;const t=this.actorID.localeCompare(e.actorID);return t!==0?t:this.delimiter>e.delimiter?1:e.delimiter>this.delimiter?-1:0}}const yf=0,Ds=9223372036854775807n,bt=new ct(0n,yf,wo);function Ut(n){return n.replace(/["'\\\n\r\f\b\t\u2028\u2029]/g,function(e){switch(e){case'"':case"\\":return"\\"+e;case` `:return"\\n";case"\r":return"\\r";case"\f":return"\\f";case"\b":return"\\b";case" ":return"\\t";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return e}})}class Xs{constructor(e){c(this,"createdAt");c(this,"movedAt");c(this,"removedAt");this.createdAt=e}getCreatedAt(){return this.createdAt}getID(){return this.createdAt}getMovedAt(){return this.movedAt}getRemovedAt(){return this.removedAt}getPositionedAt(){return this.movedAt?this.movedAt:this.createdAt}setMovedAt(e){return!this.movedAt||e&&e.after(this.movedAt)?(this.movedAt=e,!0):!1}setRemovedAt(e){this.removedAt=e}remove(e){return e&&e.after(this.getPositionedAt())&&(!this.removedAt||e.after(this.removedAt))?(this.removedAt=e,!0):!1}isRemoved(){return!!this.removedAt}}class yr extends Xs{constructor(e){super(e)}}class rc{constructor(e,t){c(this,"strKey");c(this,"value");this.strKey=e,this.value=t}static of(e,t){return new rc(e,t)}isRemoved(){return this.value.isRemoved()}getStrKey(){return this.strKey}getValue(){return this.value}remove(e){return this.value.remove(e)}}class js{constructor(){c(this,"nodeMapByKey");c(this,"nodeMapByCreatedAt");this.nodeMapByKey=new Map,this.nodeMapByCreatedAt=new Map}static create(){return new js}set(e,t,r){let s;const i=this.nodeMapByKey.get(e);i!=null&&!i.isRemoved()&&i.remove(r)&&(s=i.getValue());const o=rc.of(e,t);return this.nodeMapByCreatedAt.set(t.getCreatedAt().toIDString(),o),(i==null||r.after(i.getValue().getPositionedAt()))&&(this.nodeMapByKey.set(e,o),t.setMovedAt(r)),s}delete(e,t){if(!this.nodeMapByCreatedAt.has(e.toIDString()))throw new w(y.ErrInvalidArgument,`fail to find ${e.toIDString()}`);const r=this.nodeMapByCreatedAt.get(e.toIDString());return r.remove(t),r.getValue()}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return t.getStrKey()}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new w(y.ErrInvalidArgument,`fail to find ${e.getCreatedAt().toIDString()}`);const r=this.nodeMapByKey.get(t.getStrKey());t===r&&this.nodeMapByKey.delete(r.getStrKey()),this.nodeMapByCreatedAt.delete(t.getValue().getCreatedAt().toIDString())}deleteByKey(e,t){const r=this.nodeMapByKey.get(e);if(r!=null&&r.remove(t))return r.getValue()}has(e){const t=this.nodeMapByKey.get(e);return t==null?!1:!t.isRemoved()}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}get(e){const t=this.nodeMapByKey.get(e);if(!(!t||t.isRemoved()))return t}*[Symbol.iterator](){for(const[,e]of this.nodeMapByKey)yield e}}class Ue extends yr{constructor(t,r){super(t);c(this,"memberNodes");this.memberNodes=r}static create(t,r){if(!r)return new Ue(t,js.create());const s=js.create();for(const[i,o]of Object.entries(r))s.set(i,o.deepcopy(),o.getCreatedAt());return new Ue(t,s)}subPathOf(t){return this.memberNodes.subPathOf(t)}purge(t){this.memberNodes.purge(t)}set(t,r,s){return this.memberNodes.set(t,r,s)}delete(t,r){return this.memberNodes.delete(t,r)}deleteByKey(t,r){return this.memberNodes.deleteByKey(t,r)}get(t){const r=this.memberNodes.get(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.memberNodes.getByID(t);return r==null?void 0:r.getValue()}has(t){return this.memberNodes.has(t)}toJSON(){const t=[];for(const[r,s]of this)t.push(`"${Ut(r)}":${s.toJSON()}`);return`{${t.join(",")}}`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(const[r,s]of this){const{createdAt:i,value:o,type:a}=s.toJSForTest();t[r]={key:r,createdAt:i,value:o,type:a}}return{createdAt:this.getCreatedAt().toTestString(),value:t,type:"YORKIE_OBJECT"}}getKeys(){const t=Array();for(const[r]of this)t.push(r);return t}toSortedJSON(){var s;const t=Array();for(const[i]of this)t.push(i);const r=[];for(const i of t.sort()){const o=(s=this.memberNodes.get(i))==null?void 0:s.getValue();r.push(`"${Ut(i)}":${o.toSortedJSON()}`)}return`{${r.join(",")}}`}getRHT(){return this.memberNodes}deepcopy(){const t=Ue.create(this.getCreatedAt());for(const r of this.memberNodes)t.memberNodes.set(r.getStrKey(),r.getValue().deepcopy(),this.getPositionedAt());return t.remove(this.getRemovedAt()),t}getDescendants(t){for(const r of this.memberNodes){const s=r.getValue();if(t(s,this))return;s instanceof yr&&s.getDescendants(t)}}*[Symbol.iterator](){const t=new Set;for(const r of this.memberNodes)t.has(r.getStrKey())||(t.add(r.getStrKey()),r.isRemoved()||(yield[r.getStrKey(),r.getValue()]))}}var ie=(n=>(n.Local="local",n.Remote="remote",n.UndoRedo="undoredo",n))(ie||{});class At{constructor(e,t){c(this,"parentCreatedAt");c(this,"executedAt");this.parentCreatedAt=e,this.executedAt=t}getParentCreatedAt(){return this.parentCreatedAt}getExecutedAt(){if(!this.executedAt)throw new w(y.ErrNotReady,"executedAt is not set yet");return this.executedAt}setActor(e){this.executedAt&&(this.executedAt=this.executedAt.setActor(e))}setExecutedAt(e){this.executedAt=e}}class vf{constructor(e){c(this,"value");c(this,"left");c(this,"right");c(this,"parent");c(this,"weight");this.value=e,this.initWeight()}getNodeString(){return`${this.weight}${this.value}`}getValue(){return this.value}getLeftWeight(){return this.hasLeft()?this.left.getWeight():0}getRightWeight(){return this.hasRight()?this.right.getWeight():0}getWeight(){return this.weight}getLeft(){return this.left}getRight(){return this.right}getParent(){return this.parent}hasLeft(){return!!this.left}hasRight(){return!!this.right}hasParent(){return!!this.parent}setLeft(e){this.left=e}setRight(e){this.right=e}setParent(e){this.parent=e}unlink(){this.parent=void 0,this.right=void 0,this.left=void 0}hasLinks(){return this.hasParent()||this.hasLeft()||this.hasRight()}increaseWeight(e){this.weight+=e}initWeight(){this.weight=this.getLength()}}class Ws{constructor(e){c(this,"root");this.root=e}get length(){return this.root?this.root.getWeight():0}find(e){if(!this.root||e<0)return[void 0,0];let t=this.root;for(;;)if(t.hasLeft()&&e<=t.getLeftWeight())t=t.getLeft();else if(t.hasRight()&&t.getLeftWeight()+t.getLength()t.getLength())throw new w(y.ErrInvalidArgument,`out of index range: pos: ${e} > node.length: ${t.getLength()}`);return this.splayNode(t),[t,e]}indexOf(e){return!e||e!==this.root&&!e.hasLinks()?-1:(this.splayNode(e),this.root.getLeftWeight())}getRoot(){return this.root}insert(e){return this.insertAfter(this.root,e)}insertAfter(e,t){return e?(this.splayNode(e),this.root=t,t.setRight(e.getRight()),e.hasRight()&&e.getRight().setParent(t),t.setLeft(e),e.setParent(t),e.setRight(),this.updateWeight(e),this.updateWeight(t),t):(this.root=t,t)}updateWeight(e){e.initWeight(),e.hasLeft()&&e.increaseWeight(e.getLeftWeight()),e.hasRight()&&e.increaseWeight(e.getRightWeight())}updateTreeWeight(e){for(;e;)this.updateWeight(e),e=e.getParent()}splayNode(e){if(e)for(;;)if(this.isLeftChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e),this.rotateLeft(e);else if(this.isLeftChild(e.getParent())&&this.isLeftChild(e))this.rotateRight(e.getParent()),this.rotateRight(e);else if(this.isRightChild(e.getParent())&&this.isRightChild(e))this.rotateLeft(e.getParent()),this.rotateLeft(e);else{this.isLeftChild(e)?this.rotateRight(e):this.isRightChild(e)&&this.rotateLeft(e),this.updateWeight(e);return}}delete(e){this.splayNode(e);const t=new Ws(e.getLeft());t.root&&t.root.setParent();const r=new Ws(e.getRight());if(r.root&&r.root.setParent(),t.root){const s=t.getRightmost();t.splayNode(s),t.root.setRight(r.root),r.root&&r.root.setParent(t.root),this.root=t.root}else this.root=r.root;e.unlink(),this.root&&this.updateWeight(this.root)}deleteRange(e,t){if(!t){this.splayNode(e),this.cutOffRight(e);return}this.splayNode(e),this.splayNode(t),t.getLeft()!=e&&this.rotateRight(e),this.cutOffRight(e)}cutOffRight(e){const t=[];this.traversePostorder(e.getRight(),t);for(const r of t)r.initWeight();this.updateTreeWeight(e)}toTestString(){const e=[];return this.traverseInorder(this.root,e),e.map(t=>`[${t.getWeight()},${t.getLength()}]${t.getValue()||""}`).join("")}checkWeight(){const e=[];this.traverseInorder(this.root,e);for(const t of e)if(t.getWeight()!=t.getLength()+t.getLeftWeight()+t.getRightWeight())return!1;return!0}getRightmost(){let e=this.root;for(;e.hasRight();)e=e.getRight();return e}traverseInorder(e,t){e&&(this.traverseInorder(e.getLeft(),t),t.push(e),this.traverseInorder(e.getRight(),t))}traversePostorder(e,t){e&&(this.traversePostorder(e.getLeft(),t),this.traversePostorder(e.getRight(),t),t.push(e))}rotateLeft(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setRight(e.getLeft()),t.hasRight()&&t.getRight().setParent(t),e.setLeft(t),e.getLeft().setParent(e),this.updateWeight(t),this.updateWeight(e)}rotateRight(e){const t=e.getParent();t.hasParent()?t===t.getParent().getLeft()?t.getParent().setLeft(e):t.getParent().setRight(e):this.root=e,e.setParent(t.getParent()),t.setLeft(e.getRight()),t.hasLeft()&&t.getLeft().setParent(t),e.setRight(t),e.getRight().setParent(e),this.updateWeight(t),this.updateWeight(e)}isLeftChild(e){return e&&e.hasParent()?e.getParent().getLeft()===e:!1}isRightChild(e){return e&&e.hasParent()?e.getParent().getRight()===e:!1}}/** * @license * Copyright 2009 The Closure Library Authors @@ -19,5 +19,5 @@ var Qf=Object.defineProperty;var eh=(n,e,t)=>e in n?Qf(n,e,{enumerable:!0,config * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var ot=null;try{ot=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function X(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}X.prototype.__isLong__;Object.defineProperty(X.prototype,"__isLong__",{value:!0});function Oe(n){return(n&&n.__isLong__)===!0}function Mu(n){var e=Math.clz32(n&-n);return n?31-e:e}X.isLong=Oe;var $u={},Uu={};function Vr(n,e){var t,r,s;return e?(n>>>=0,(s=0<=n&&n<256)&&(r=Uu[n],r)?r:(t=Q(n,0,!0),s&&(Uu[n]=t),t)):(n|=0,(s=-128<=n&&n<128)&&(r=$u[n],r)?r:(t=Q(n,n<0?-1:0,!1),s&&($u[n]=t),t))}X.fromInt=Vr;function at(n,e){if(isNaN(n))return e?Qn:yt;if(e){if(n<0)return Qn;if(n>=wf)return Af}else{if(n<=-zu)return $e;if(n+1>=zu)return Tf}return n<0?at(-n,e).neg():Q(n%gs|0,n/gs|0,e)}X.fromNumber=at;function Q(n,e,t){return new X(n,e,t)}X.fromBits=Q;var to=Math.pow;function sc(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?Qn:yt;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return sc(n.substring(1),e,t).neg();for(var s=at(to(t,8)),i=yt,o=0;o>>0:this.low};E.toNumber=function(){return this.unsigned?(this.high>>>0)*gs+(this.low>>>0):this.high*gs+(this.low>>>0)};E.toString=function(e){if(e=e||10,e<2||36>>0,h=l.toString(e);if(o=u,o.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}};E.getHighBits=function(){return this.high};E.getHighBitsUnsigned=function(){return this.high>>>0};E.getLowBits=function(){return this.low};E.getLowBitsUnsigned=function(){return this.low>>>0};E.getNumBitsAbs=function(){if(this.isNegative())return this.eq($e)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};E.isOdd=function(){return(this.low&1)===1};E.isEven=function(){return(this.low&1)===0};E.equals=function(e){return Oe(e)||(e=It(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};E.eq=E.equals;E.notEquals=function(e){return!this.eq(e)};E.neq=E.notEquals;E.ne=E.notEquals;E.lessThan=function(e){return this.comp(e)<0};E.lt=E.lessThan;E.lessThanOrEqual=function(e){return this.comp(e)<=0};E.lte=E.lessThanOrEqual;E.le=E.lessThanOrEqual;E.greaterThan=function(e){return this.comp(e)>0};E.gt=E.greaterThan;E.greaterThanOrEqual=function(e){return this.comp(e)>=0};E.gte=E.greaterThanOrEqual;E.ge=E.greaterThanOrEqual;E.compare=function(e){if(Oe(e)||(e=It(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};E.comp=E.compare;E.negate=function(){return!this.unsigned&&this.eq($e)?$e:this.not().add(Zr)};E.neg=E.negate;E.add=function(e){Oe(e)||(e=It(e));var t=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=e.high>>>16,a=e.high&65535,u=e.low>>>16,l=e.low&65535,h=0,d=0,v=0,p=0;return p+=i+l,v+=p>>>16,p&=65535,v+=s+u,d+=v>>>16,v&=65535,d+=r+a,h+=d>>>16,d&=65535,h+=t+o,h&=65535,Q(v<<16|p,h<<16|d,this.unsigned)};E.subtract=function(e){return Oe(e)||(e=It(e)),this.add(e.neg())};E.sub=E.subtract;E.multiply=function(e){if(this.isZero())return this;if(Oe(e)||(e=It(e)),ot){var t=ot.mul(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Qn:yt;if(this.eq($e))return e.isOdd()?$e:yt;if(e.eq($e))return this.isOdd()?$e:yt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Ku)&&e.lt(Ku))return at(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,o=this.low&65535,a=e.high>>>16,u=e.high&65535,l=e.low>>>16,h=e.low&65535,d=0,v=0,p=0,A=0;return A+=o*h,p+=A>>>16,A&=65535,p+=i*h,v+=p>>>16,p&=65535,p+=o*l,v+=p>>>16,p&=65535,v+=s*h,d+=v>>>16,v&=65535,v+=i*l,d+=v>>>16,v&=65535,v+=o*u,d+=v>>>16,v&=65535,d+=r*h+s*l+i*u+o*a,d&=65535,Q(p<<16|A,d<<16|v,this.unsigned)};E.mul=E.multiply;E.divide=function(e){if(Oe(e)||(e=It(e)),e.isZero())throw Error("division by zero");if(ot){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?ot.div_u:ot.div_s)(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Qn:yt;var r,s,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Qn;if(e.gt(this.shru(1)))return bf;i=Qn}else{if(this.eq($e)){if(e.eq(Zr)||e.eq(xa))return $e;if(e.eq($e))return Zr;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(yt)?e.isNegative()?Zr:xa:(s=this.sub(e.mul(r)),i=r.add(s.div(e)),i)}else if(e.eq($e))return this.unsigned?Qn:yt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=yt}for(s=this;s.gte(e);){r=Math.max(1,Math.floor(s.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),u=a<=48?1:to(2,a-48),l=at(r),h=l.mul(e);h.isNegative()||h.gt(s);)r-=u,l=at(r,this.unsigned),h=l.mul(e);l.isZero()&&(l=Zr),i=i.add(l),s=s.sub(h)}return i};E.div=E.divide;E.modulo=function(e){if(Oe(e)||(e=It(e)),ot){var t=(this.unsigned?ot.rem_u:ot.rem_s)(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};E.mod=E.modulo;E.rem=E.modulo;E.not=function(){return Q(~this.low,~this.high,this.unsigned)};E.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};E.clz=E.countLeadingZeros;E.countTrailingZeros=function(){return this.low?Mu(this.low):Mu(this.high)+32};E.ctz=E.countTrailingZeros;E.and=function(e){return Oe(e)||(e=It(e)),Q(this.low&e.low,this.high&e.high,this.unsigned)};E.or=function(e){return Oe(e)||(e=It(e)),Q(this.low|e.low,this.high|e.high,this.unsigned)};E.xor=function(e){return Oe(e)||(e=It(e)),Q(this.low^e.low,this.high^e.high,this.unsigned)};E.shiftLeft=function(e){return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Q(this.low<>>32-e,this.unsigned):Q(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):Q(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};E.shr=E.shiftRight;E.shiftRightUnsigned=function(e){return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Q(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?Q(this.high,0,this.unsigned):Q(this.high>>>e-32,0,this.unsigned)};E.shru=E.shiftRightUnsigned;E.shr_u=E.shiftRightUnsigned;E.rotateLeft=function(e){var t;return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Q(this.high,this.low,this.unsigned):e<32?(t=32-e,Q(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,Q(this.high<>>t,this.low<>>t,this.unsigned))};E.rotl=E.rotateLeft;E.rotateRight=function(e){var t;return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Q(this.high,this.low,this.unsigned):e<32?(t=32-e,Q(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,Q(this.low<>>e,this.high<>>e,this.unsigned))};E.rotr=E.rotateRight;E.toSigned=function(){return this.unsigned?Q(this.low,this.high,!1):this};E.toUnsigned=function(){return this.unsigned?this:Q(this.low,this.high,!0)};E.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};E.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};E.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};X.fromBytes=function(e,t,r){return r?X.fromBytesLE(e,t):X.fromBytesBE(e,t)};X.fromBytesLE=function(e,t){return new X(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};X.fromBytesBE=function(e,t){return new X(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var Te=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(Te||{});class he extends Xs{constructor(t,r){super(r);c(this,"valueType");c(this,"value");this.valueType=he.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new he(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const s=new DataView(r.buffer);return r.forEach(function(i,o){s.setUint8(o,i)}),s.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return X.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(X.fromBytesLE(Array.from(r),!0).toNumber());default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${Ut(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=he.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof X)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return he.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=X.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new w(y.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class no extends vf{constructor(t){super(t);c(this,"prev");c(this,"next");this.value=t}static createAfter(t,r){const s=new no(r),i=t.next;return t.next=s,s.prev=t,s.next=i,i&&(i.prev=s),s}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class Hs{constructor(){c(this,"dummyHead");c(this,"last");c(this,"nodeMapByIndex");c(this,"nodeMapByCreatedAt");const e=he.of(0,bt);e.setRemovedAt(bt),this.dummyHead=new no(e),this.last=this.dummyHead,this.nodeMapByIndex=new Ws,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new Hs}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new w(y.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const s=this.findNextBeforeExecutedAt(e,r),i=no.createAfter(s,t);s===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(s,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(e,t,r){const s=this.nodeMapByCreatedAt.get(e.toIDString());if(!s)throw new w(y.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new w(y.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);s!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(s.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new w(y.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let s=t;if(e===0&&t===this.dummyHead||r>0)do s&&(s=s.getNext());while(s&&s.isRemoved());return s}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),s=r.isRemoved();return r.remove(t)&&!s&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class We extends yr{constructor(t,r){super(t);c(this,"elements");this.elements=r}static create(t,r){if(!r)return new We(t,Hs.create());const s=Hs.create();for(const i of r)s.insertAfter(s.getLastCreatedAt(),i.deepcopy());return new We(t,s)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,s){this.elements.moveAfter(t,r,s)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const s=r.getValue();if(t(s,this))return;s instanceof yr&&s.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...A,value:A.value?{attributes:ss(A.value.getAttributes()),content:A.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[h,p,d,[l,l]]}setStyle(t,r,s,i,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],s),[,u]=this.rgaTreeSplit.findNodeWithSplit(t[0],s),l=[],h=this.rgaTreeSplit.findBetween(u,a),d=new Map,v=[];for(const A of h){const I=A.getCreatedAt().getActorID();let D,L=0n;if(o===void 0&&i===void 0?L=Ds:o.size()>0?L=o.get(I)?o.get(I):0n:D=i.has(I)?i.get(I):bt,A.canStyle(s,D,L)){const $=d.get(I),V=A.getCreatedAt();(!$||V.after($))&&d.set(I,V),v.push(A)}}const p=[];for(const A of v){if(A.isRemoved())continue;const[I,D]=this.rgaTreeSplit.findIndexesFromRange(A.createPosRange());l.push({type:"style",actor:s.getActorID(),from:I,to:D,value:{attributes:ss(r)}});for(const[L,$]of Object.entries(r)){const[V]=A.getValue().setAttr(L,$,s);V!==void 0&&p.push({parent:A.getValue(),child:V})}}return[d,p,l]}indexRangeToPosRange(t,r){const s=this.rgaTreeSplit.indexToPos(t);return t===r?[s,s]:[s,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const s=r.getValue();t.push({attributes:ss(s.getAttributes()),content:s.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new ut(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const s of r.getValue().getGCPairs())t.push(s)}return t}}class Qs extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"content");c(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.content=o,this.attributes=a}static create(t,r,s,i,o,a,u){return new Qs(t,r,s,i,o,a,u)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof ut))throw new w(y.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,a,u]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,s);for(const l of u)t.registerGCPair(l);return{opInfos:a.map(({from:l,to:h,value:d})=>({type:"edit",from:l,to:h,value:d,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.content;return`${t}.EDIT(${r},${s},${i})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ei extends At{constructor(t,r,s,i,o,a){super(t,a);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o}static create(t,r,s,i,o,a){return new ei(t,r,s,i,o,a)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof ut))throw new w(y.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,a,u]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,s);for(const l of a)t.registerGCPair(l);return{opInfos:u.map(({from:l,to:h,value:d})=>({type:"style",from:l,to:h,value:d,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.attributes;return`${t}.STYL(${r},${s},${JSON.stringify(i)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const tp=2,np="root",er="text";function Ss(n,e){let t=0;const r=n.children;for(let s=0;s0)throw new w(y.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===er}get paddedSize(){return this.size+(this.isText?0:tp)}isAncestorOf(e){return sp(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),s=this.value.slice(e);if(!s.length)return;this.value=r;const i=this.cloneText(e+t);return i.value=s,this.parent.insertAfterInternal(i,this),i}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new w(y.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const s=this.children.slice(0,e),i=this.children.slice(e);this._children=s,r._children=i,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(s=>!s.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function sp(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var be=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(be||{});function If(n,e,t,r){if(e>t)throw new w(y.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new w(y.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new w(y.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let s=0;for(const i of n.children){if(e-i.paddedSizei.size;(i.isText||u)&&r([i,i.isText?"Text":"Start"],l),If(i,Math.max(0,o),Math.min(a,i.size),r),l&&r([i,"End"],l)}s+=i.paddedSize}}function Sf(n,e,t=0){for(const r of n.children)Sf(r,e,t+1);e(n,t)}function wo(n,e,t=0){for(const r of n._children)wo(r,e,t+1);e(n,t)}function ka(n,e,t=!0){if(e>n.size)throw new w(y.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,s=0;for(const i of n.children){if(t&&i.isText&&i.size>=e-s)return ka(i,e-s,t);if(e===s)return{node:n,offset:r};if(!t&&i.paddedSize===e-s)return{node:n,offset:r+1};if(i.paddedSize>e-s)return ka(i,e-s-1,t);s+=i.paddedSize,r+=1}return{node:n,offset:r}}function xf(n){return n.isText||n.children.length===0?n:xf(n.children[0])}function ip(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let s=t.parent,i=t;for(;s&&i===s.left;)i=s,s=s.parent;return s}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new cp(e,t,!0);const s=this.comparator(e,r.key);return s<0?r.left=this.putInternal(e,t,r.left):s>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class vt{constructor(e,t){c(this,"parentID");c(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new vt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,s;return r.isText?(r.parent.children[0]===r&&t===0?s=r.parent:s=r,r=r.parent):t===0?s=r:s=r.children[t-1],vt.of(r.id,xe.of(s.getCreatedAt(),s.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return vt.of(xe.of(ct.fromStruct(e.parentID.createdAt),e.parentID.offset),xe.of(ct.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),s=e.findFloorNode(t);let i=e.findFloorNode(r);if(!s||!i)throw new w(y.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=e.findFloorNode(i.insPrevID)),[s,i]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class xe{constructor(e,t){c(this,"createdAt");c(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new xe(e,t)}static fromStruct(e){return xe.of(ct.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const i=s.deepcopy();return i.parent=t,i}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new w(y.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new w(y.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new je(xe.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new je(xe.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,s){const i=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,s);if(i){if(i.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=i.id,i.insNextID=this.insNextID}this.insNextID=i.id,t.registerNode(i)}return i}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,s){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,s){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new sr);const s=[];for(const[i,o]of Object.entries(t))s.push(this.attrs.set(i,o,r));return s}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Ea(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Ea)};return n.attrs&&(e.attributes=ss((t=n.attrs)==null?void 0:t.toObject())),e}function ic(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${Ut(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>ic(t)).join("")}`}function Ef(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(Ef),size:n.size,isRemoved:n.isRemoved}}class lt extends Xs{constructor(t,r){super(r);c(this,"indexTree");c(this,"nodeMapByID");this.indexTree=new op(t),this.nodeMapByID=new kf(xe.createComparator()),this.indexTree.traverseAll(s=>{this.nodeMapByID.put(s.id,s)})}static create(t,r){return new lt(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[s,i]=t.toTreeNodePair(this);let o=i;const a=s===o,u=o.parent&&!a?o.parent:s;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const l=u.allChildren,h=a?0:l.indexOf(o)+1;for(let d=h;d{const D=I.getCreatedAt().getActorID();let L,$=0n;if(o===void 0&&i===void 0?$=Ds:o.size()>0?$=o.get(D)?o.get(D):0n:L=i.has(D)?i.get(D):bt,I.canStyle(s,L,$)&&r){const V=p.get(D),U=I.getCreatedAt();(!V||U.after(V))&&p.set(D,U);const W=I.setAttrs(r,s),ee=W.reduce((Ee,[,Ie])=>(Ie&&(Ee[Ie.getKey()]=v[Ie.getKey()]),Ee),{}),oe=I.parent,te=I.prevSibling||I.parent;Object.keys(ee).length>0&&d.push({type:"style",from:this.toIndex(oe,te),to:this.toIndex(I,I),fromPath:this.toPath(oe,te),toPath:this.toPath(I,I),actor:s.getActorID(),value:ee});for(const[Ee]of W)Ee&&A.push({parent:I,child:Ee})}}),[p,A,d]}removeStyle(t,r,s,i,o){const[a,u]=this.findNodesAndSplitText(t[0],s),[l,h]=this.findNodesAndSplitText(t[1],s),d=[],v=new Map,p=[];return this.traverseInPosRange(a,u,l,h,([A])=>{const I=A.getCreatedAt().getActorID();let D,L=0n;if(o===void 0&&i===void 0?L=Ds:o.size()>0?L=o.get(I)?o.get(I):0n:D=i.has(I)?i.get(I):bt,A.canStyle(s,D,L)&&r){const $=v.get(I),V=A.getCreatedAt();(!$||V.after($))&&v.set(I,V),A.attrs||(A.attrs=new sr);for(const ee of r){const oe=A.attrs.remove(ee,s);for(const te of oe)p.push({parent:A,child:te})}const U=A.parent,W=A.prevSibling||A.parent;d.push({actor:s.getActorID(),type:"removeStyle",from:this.toIndex(U,W),to:this.toIndex(A,A),fromPath:this.toPath(U,W),toPath:this.toPath(A,A),value:r})}}),[v,p,d]}edit(t,r,s,i,o,a,u){const[l,h]=this.findNodesAndSplitText(t[0],i),[d,v]=this.findNodesAndSplitText(t[1],i),p=this.toIndex(l,h),A=this.toPath(l,h),I=[],D=[],L=[],$=new Map;this.traverseInPosRange(l,h,d,v,([W,ee],oe)=>{if(ee===be.Start&&!oe)for(const Ge of W.children)L.push(Ge);const te=W.getCreatedAt().getActorID();let Ee,Ie=0n;if(u===void 0&&a===void 0?Ie=Ds:u.size()>0?Ie=u.get(te)?u.get(te):0n:Ee=a.has(te)?a.get(te):bt,W.canDelete(i,Ee,Ie)||I.includes(W.parent)){const Ge=$.get(te),Ir=W.getCreatedAt();(!Ge||Ir.after(Ge))&&$.set(te,Ir),(ee===be.Text||ee===be.Start)&&I.push(W),D.push([W,ee])}});const V=this.makeDeletionChanges(D,i),U=[];for(const W of I)W.remove(i),W.isRemoved&&U.push({parent:this,child:W});for(const W of L)W.removedAt||l.append(W);if(s>0){let W=0,ee=l,oe=h;for(;W{l.isRemoved&&(te.remove(i),U.push({parent:this,child:te})),this.nodeMapByID.put(te.id,te)}),oe.isRemoved||W.push(oe);if(W.length){const oe=W.map(te=>Ea(te));V.length&&V[V.length-1].from===p?V[V.length-1].value=oe:V.push({type:"content",from:p,to:p,fromPath:A,toPath:A,actor:i.getActorID(),value:oe})}}return[V,U,$]}editT(t,r,s,i,o){const a=this.findPos(t[0]),u=this.findPos(t[1]);this.edit([a,u],r,s,i,o)}move(t,r,s){throw new w(y.ErrUnimplemented,`not implemented: ${t}, ${r}, ${s}`)}purge(t){var i;(i=t.parent)==null||i.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,s=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=s}if(s){const o=this.findFloorNode(s);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const s of r.getGCPairs())t.push(s)}),t}findPos(t,r=!0){const s=this.indexTree.findTreePos(t,r);return vt.fromTreePos(s)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ic(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(s,i=void 0,o=void 0,a=0)=>{var p,A,I,D;let u,l,h;const d=s.isText?{node:s,offset:0}:i&&o?this.toTreePos(i,o):null;d&&(u=this.indexTree.indexOf(d),l=this.indexTree.treePosToPath(d),h=vt.fromTreePos(d).toStruct());const v={type:s.type,parent:i==null?void 0:i.id.toTestString(),size:s.size,id:s.id.toTestString(),removedAt:(p=s.removedAt)==null?void 0:p.toTestString(),insPrev:(A=s.insPrevID)==null?void 0:A.toTestString(),insNext:(I=s.insNextID)==null?void 0:I.toTestString(),value:s.isText?s.value:void 0,isRemoved:s.isRemoved,children:[],depth:a,attributes:s.attrs?ss((D=s.attrs)==null?void 0:D.toObject()):void 0,index:u,path:l,pos:h};for(let L=0;L0&&L===s[s.length-1].to?(s[s.length-1].to=$,s[s.length-1].toPath=this.toPath(D,p)):s.push({type:"content",from:L,to:$,fromPath:this.toPath(I,d),toPath:this.toPath(D,p),actor:r.getActorID()}))}return s.reverse()}findRightToken([t,r]){if(r===be.Start){const u=t.allChildren;return u.length>0?[u[0],u[0].isText?be.Text:be.Start]:[t,be.End]}const s=t.parent,i=s.allChildren,o=i.indexOf(t);if(s&&o===i.length-1)return[s,be.End];const a=i[o+1];return[a,a.isText?be.Text:be.Start]}findLeftToken([t,r]){if(r===be.End){const u=t.allChildren;if(u.length>0){const l=u[u.length-1];return[l,l.isText?be.Text:be.End]}return[t,be.Start]}const s=t.parent,i=s.allChildren,o=i.indexOf(t);if(s&&o===0)return[s,be.Start];const a=i[o-1];return[a,a.isText?be.Text:be.End]}}class ti extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"contents");c(this,"splitLevel");c(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=s,this.contents=i,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,s,i,o,a,u){return new ti(t,r,s,i,o,a,u)}execute(t,r,s){var h;const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof lt))throw new w(y.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=i,[u,l]=a.edit([this.fromPos,this.toPos],(h=this.contents)==null?void 0:h.map(d=>d.deepcopy()),this.splitLevel,o,(()=>{let d=o.getDelimiter();return this.contents!==void 0&&(d+=this.contents.length),()=>ct.of(o.getLamport(),++d,o.getActorID())})(),this.maxCreatedAtMapByActor,s);for(const d of l)t.registerGCPair(d);return{opInfos:u.map(({from:d,to:v,value:p,splitLevel:A,fromPath:I,toPath:D})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:d,to:v,value:p,splitLevel:A,fromPath:I,toPath:D}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,i=this.contents||[];return`${t}.EDIT(${r},${s},${i.map(o=>ic(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class is{constructor(e){c(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,s]of e){const i=this.vector.get(r),o=i&&i>s?i:s;t.set(r,o)}for(const[r,s]of this){const i=e.get(r),o=i&&i>s?i:s;t.set(r,o)}return new is(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new is(e)}filter(e){const t=new Map;for(const[r]of e){const s=this.vector.get(r);s!==void 0&&t.set(r,s)}return new is(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const lp=new is(new Map);class _n{constructor(e,t,r,s,i){c(this,"clientSeq");c(this,"serverSeq");c(this,"lamport");c(this,"actor");c(this,"versionVector");this.clientSeq=e,this.serverSeq=i,this.lamport=t,this.versionVector=s,this.actor=r}static of(e,t,r,s,i){return new _n(e,t,r,s,i)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new _n(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n,r=this.versionVector.max(e.versionVector),s=new _n(this.clientSeq,t,this.actor,r);return s.versionVector.set(this.actor,t),s}setClocks(e,t){const r=e>this.lamport?e:this.lamport+1n,s=this.versionVector.max(t);return s.set(this.actor,r),_n.of(this.clientSeq,r,this.actor,s)}createTimeTicket(e){return ct.of(this.lamport,e,this.actor)}setActor(e){return new _n(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new _n(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const fp=new _n(0,0n,nc,lp);class ms{constructor({id:e,operations:t,presenceChange:r,message:s}){c(this,"id");c(this,"operations");c(this,"presenceChange");c(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=s}static create({id:e,operations:t,presenceChange:r,message:s}){return new ms({id:e,operations:t,presenceChange:r,message:s})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const s=[],i=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:u,reverseOp:l}=a;s.push(...u),l&&i.unshift(l)}return this.presenceChange&&(this.presenceChange.type===Tr.Put?t.set(this.id.getActorID(),dt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:s,reverseOps:i}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:ye.bytesToHex(ye.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>ye.bytesToHex(ye.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:s,message:i}=e;return ms.create({id:ye.bytesToChangeID(ye.hexToBytes(t)),operations:r==null?void 0:r.map(o=>ye.bytesToOperation(ye.hexToBytes(o))),presenceChange:s,message:i})}}class bo{constructor(e,t,r,s,i,o,a){c(this,"documentKey");c(this,"checkpoint");c(this,"isRemoved");c(this,"changes");c(this,"snapshot");c(this,"minSyncedTicket");c(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=s,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=i}static create(e,t,r,s,i,o,a){return new bo(e,t,r,s,i,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class os{constructor(e,t){c(this,"serverSeq");c(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new os(e,t)}increaseClientSeq(e){return e===0?this:new os(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return os.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const hp=new os(0n,0);class zt{constructor(e,t){c(this,"createdAt");c(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new zt(e,t)}static fromStruct(e){return zt.of(ct.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new zt(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const dp=zt.of(bt,0);class Tt{constructor(e,t){c(this,"id");c(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Tt(e,t)}static fromStruct(e){const t=zt.fromStruct(e.id);return Tt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return zt.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class vr extends vf{constructor(t,r,s){super(r);c(this,"id");c(this,"removedAt");c(this,"prev");c(this,"next");c(this,"insPrev");c(this,"insNext");this.id=t,this.removedAt=s}static create(t,r){return new vr(t,r)}static createComparator(){return(t,r)=>{const s=t.getCreatedAt().compare(r.getCreatedAt());return s!==0?s:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let s=e;for(;s&&s!==t;)r.push(s),s=s.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new w(y.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const s=e.getInsNext();return s&&s.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,s){if(!e.length)return[[],new Map,new Map];const[i,o]=this.filterNodes(e,t,r,s),a=new Map,u=new Map,l=this.makeChanges(o,t);for(const h of i){const d=h.getCreatedAt().getActorID();(!a.has(d)||h.getID().getCreatedAt().after(a.get(d)))&&a.set(d,h.getID().getCreatedAt()),u.set(h.getID().toIDString(),h),h.remove(t)}return this.deleteIndexNodes(o),[l,a,u]}filterNodes(e,t,r,s){const i=[],o=[],[a,u]=this.findEdgesOfCandidates(e);o.push(a);for(const l of e){const h=l.getCreatedAt().getActorID();let d,v=0n;s===void 0&&r===void 0?v=Ds:s.size()>0?v=s.get(h)?s.get(h):0n:d=r.has(h)?r.get(h):bt,l.canDelete(t,d,v)?i.push(l):o.push(l)}return o.push(u),[i,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let s,i;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var Kt=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(Kt||{});class He extends Xs{constructor(t,r,s){super(s);c(this,"valueType");c(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=X.fromNumber(r).toInt():this.value=Vu(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=X.fromNumber(r):this.value=r;break;default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,s){return new He(t,r,s)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return X.fromBytesLE(Array.from(r));default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=He.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof X?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!He.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new w(y.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(s){if(!s.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof s.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===Te.Long?this.value=this.value+t.getValue().toInt():this.value=X.fromNumber(this.value+Vu(t.getValue())).toInt(),this}}class ys extends At{constructor(t,r,s){super(t,s);c(this,"value");this.value=r}static create(t,r,s){return new ys(t,r,s)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof He))throw new w(y.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const s=r,i=this.value.deepcopy();return s.increase(i),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:i.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),s=t.getType()===Te.Long?t.getValue().multiply(-1):t.getValue()*-1;return ys.create(this.getParentCreatedAt(),he.of(s,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class tr extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"attributes");c(this,"attributesToRemove");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o,this.attributesToRemove=a}static create(t,r,s,i,o,a){return new tr(t,r,s,i,o,[],a)}static createTreeRemoveStyleOperation(t,r,s,i,o,a){return new tr(t,r,s,i,new Map,o,a)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof lt))throw new w(y.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=i;let a,u;if(this.attributes.size){const l={};[...this.attributes].forEach(([h,d])=>l[h]=d),[,u,a]=o.style([this.fromPos,this.toPos],l,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}else{const l=this.attributesToRemove;[,u,a]=o.removeStyle([this.fromPos,this.toPos],l,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}for(const l of u)t.registerGCPair(l);return{opInfos:a.map(({from:l,to:h,value:d,fromPath:v,toPath:p})=>({type:"tree-style",from:l,to:h,value:this.attributes.size?{attributes:d}:{attributesToRemove:d},fromPath:v,toPath:p,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${s},${Object.entries(this.attributes||{}).map(([i,o])=>`${i}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function gp(n){const e=new tc,t=e.data;for(const[r,s]of Object.entries(n))t[r]=JSON.stringify(s);return e}function mp(n){if(n.type===Tr.Put)return new Vs({type:qr.PUT,presence:gp(n.presence)});if(n.type===Tr.Clear)return new Vs({type:qr.CLEAR});throw new w(y.ErrUnimplemented,"unimplemented type")}function pp(n){return new mf({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function Cf(n){return new yo({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:pc(n.getActorID()),versionVector:oc(n.getVersionVector())})}function J(n){if(n)return new F({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:pc(n.getActorID())})}function oc(n){if(!n)return;const e=new vo;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function Nf(n){switch(n){case Te.Null:return G.NULL;case Te.Boolean:return G.BOOLEAN;case Te.Integer:return G.INTEGER;case Te.Long:return G.LONG;case Te.Double:return G.DOUBLE;case Te.String:return G.STRING;case Te.Bytes:return G.BYTES;case Te.Date:return G.DATE;default:throw new w(y.ErrInvalidType,`unsupported type: ${n}`)}}function Pf(n){switch(n){case Kt.IntegerCnt:return G.INTEGER_CNT;case Kt.LongCnt:return G.LONG_CNT;default:throw new w(y.ErrInvalidType,`unsupported type: ${n}`)}}function Jo(n){if(n instanceof Ue)return new Ye({type:G.JSON_OBJECT,createdAt:J(n.getCreatedAt()),value:Kf(n)});if(n instanceof We)return new Ye({type:G.JSON_ARRAY,createdAt:J(n.getCreatedAt()),value:Hp(n)});if(n instanceof ut)return new Ye({type:G.TEXT,createdAt:J(n.getCreatedAt())});if(n instanceof he)return new Ye({type:Nf(n.getType()),createdAt:J(n.getCreatedAt()),value:n.toBytes()});if(n instanceof He)return new Ye({type:Pf(n.getType()),createdAt:J(n.getCreatedAt()),value:n.toBytes()});if(n instanceof lt)return new Ye({type:G.TREE,createdAt:J(n.getCreatedAt()),value:_p(n)});throw new w(y.ErrUnimplemented,"unimplemented element")}function yp(n){return new zs({createdAt:J(n.getCreatedAt()),offset:n.getOffset()})}function di(n){return new rr({createdAt:J(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function gi(n){return new Ur({parentId:Bs(n.getParentID()),leftSiblingId:Bs(n.getLeftSiblingID())})}function Bs(n){return new pr({createdAt:J(n.getCreatedAt()),offset:n.getOffset()})}function Of(n){const e=new ec;if(n instanceof zr){const t=n,r=new Ji;r.parentCreatedAt=J(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Jo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Zs){const t=n,r=new Mi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.prevCreatedAt=J(t.getPrevCreatedAt()),r.value=Jo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof dr){const t=n,r=new $i;r.parentCreatedAt=J(t.getParentCreatedAt()),r.prevCreatedAt=J(t.getPrevCreatedAt()),r.createdAt=J(t.getCreatedAt()),r.executedAt=J(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Ar){const t=n,r=new Ui;r.parentCreatedAt=J(t.getParentCreatedAt()),r.createdAt=J(t.getCreatedAt()),r.executedAt=J(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Qs){const t=n,r=new qi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=di(t.getFromPos()),r.to=di(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);r.content=t.getContent();const i=r.attributes;for(const[o,a]of t.getAttributes())i[o]=a;r.executedAt=J(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof ei){const t=n,r=new zi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=di(t.getFromPos()),r.to=di(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);const i=r.attributes;for(const[o,a]of t.getAttributes())i[o]=a;r.executedAt=J(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof ys){const t=n,r=new Ki;r.parentCreatedAt=J(t.getParentCreatedAt()),r.value=Jo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof ti){const t=n,r=new Vi,s=r.createdAtMapByActor;for(const[i,o]of t.getMaxCreatedAtMapByActor())s[i]=J(o);r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=gi(t.getFromPos()),r.to=gi(t.getToPos()),r.contents=Sp(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=J(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof tr){const t=n,r=new ji;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=gi(t.getFromPos()),r.to=gi(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);const i=t.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{const o=r.attributes;for(const[a,u]of t.getAttributes())o[a]=u}r.executedAt=J(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new w(y.ErrUnimplemented,"unimplemented operation");return e}function vp(n){const e=[];for(const t of n)e.push(Of(t));return e}function wp(n){const e=new df({id:Cf(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=vp(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=mp(n.getPresenceChange())),e}function bp(n){const e=[];for(const t of n)e.push(wp(t));return e}function Tp(n){const e=[];for(const t of n)e.push(new gf({key:t.getStrKey(),element:cc(t.getValue())}));return e}function Ap(n){const e=[];for(const t of n)e.push(new Zi({element:cc(t.getValue())}));return e}function Ip(n){const e=[];for(const t of n){const r=new Qi;r.id=yp(t.getID()),r.value=t.getValue().getContent(),r.removedAt=J(t.getRemovedAt());const s=r.attributes,i=t.getValue().getAttrs();for(const o of i){const a=new hs;a.value=o.getValue(),a.updatedAt=J(o.getUpdatedAt()),s[o.getKey()]=a}e.push(r)}return e}function Sp(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new eo({content:ac(t)}));return e}function xp(n){const e={};for(const t of n)e[t.getKey()]=new hs({value:t.getValue(),updatedAt:J(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function ac(n){if(!n)return[];const e=[];return wo(n,(t,r)=>{const s=new Ks({id:Bs(t.id),type:t.type,removedAt:J(t.removedAt),depth:r});t.isText&&(s.value=t.value),t.insPrevID&&(s.insPrevId=Bs(t.insPrevID)),t.insNextID&&(s.insNextId=Bs(t.insNextID)),t.attrs&&(s.attributes=xp(t.attrs)),e.push(s)}),e}function kp(n){const e=new ze;return e.body.case="jsonObject",e.body.value=new Wi({nodes:Tp(n.getRHT()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Df(n){const e=new ze;return e.body.case="jsonArray",e.body.value=new Hi({nodes:Ap(n.getElements()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Ep(n){const e=new ze;return e.body.case="primitive",e.body.value=new Gi({type:Nf(n.getType()),value:n.toBytes(),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Cp(n){const e=new ze;return e.body.case="text",e.body.value=new _i({nodes:Ip(n.getRGATreeSplit()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Np(n){const e=new ze;return e.body.case="counter",e.body.value=new Yi({type:Pf(n.getType()),value:n.toBytes(),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Bf(n){const e=new ze;return e.body.case="tree",e.body.value=new Xi({nodes:ac(n.getRoot()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function cc(n){if(n instanceof Ue)return kp(n);if(n instanceof We)return Df(n);if(n instanceof he)return Ep(n);if(n instanceof ut)return Cp(n);if(n instanceof He)return Np(n);if(n instanceof lt)return Bf(n);throw new w(y.ErrUnimplemented,"unimplemented element")}function Pp(n){return new or({documentKey:n.getDocumentKey(),checkpoint:pp(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:bp(n.getChanges()),snapshot:n.getSnapshot(),versionVector:oc(n.getVersionVector()),minSyncedTicket:J(n.getMinSyncedTicket())})}function Es(n){if(!(n instanceof le))return{};const e=n.findDetails(_m);for(const t of e)return t.metadata;return{}}function Gr(n){return Es(n).code??""}function Rf(n){return _n.of(n.clientSeq,BigInt(n.lamport),gc(n.actorId),uc(n.versionVector),BigInt(n.serverSeq))}function uc(n){if(!n)return;const e=new is;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return ct.of(BigInt(n.lamport),n.delimiter,gc(n.actorId))}function lc(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function Op(n){const e=n.type;if(e===qr.PUT){const t=lc(n.presence);return{type:Tr.Put,presence:t}}if(e===qr.CLEAR)return{type:Tr.Clear};throw new w(y.ErrInvalidType,`unsupported type: ${e}`)}function Dp(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,lc(r))}),e}function Ff(n){switch(n){case G.NULL:return Te.Null;case G.BOOLEAN:return Te.Boolean;case G.INTEGER:return Te.Integer;case G.LONG:return Te.Long;case G.DOUBLE:return Te.Double;case G.STRING:return Te.String;case G.BYTES:return Te.Bytes;case G.DATE:return Te.Date}throw new w(y.ErrUnimplemented,`unimplemented value type: ${n}`)}function ro(n){switch(n){case G.INTEGER_CNT:return Kt.IntegerCnt;case G.LONG_CNT:return Kt.LongCnt}throw new w(y.ErrUnimplemented,`unimplemented value type: ${n}`)}function Mo(n){switch(n.type){case G.JSON_OBJECT:return n.value?zf(n.value):Ue.create(M(n.createdAt));case G.JSON_ARRAY:return n.value?Wp(n.value):We.create(M(n.createdAt));case G.TEXT:return ut.create(ps.create(),M(n.createdAt));case G.TREE:return Gp(n.value);case G.NULL:case G.BOOLEAN:case G.INTEGER:case G.LONG:case G.DOUBLE:case G.STRING:case G.BYTES:case G.DATE:return he.of(he.valueFromBytes(Ff(n.type),n.value),M(n.createdAt));case G.INTEGER_CNT:case G.LONG_CNT:return He.create(ro(n.type),He.valueFromBytes(ro(n.type),n.value),M(n.createdAt))}}function mi(n){return Tt.of(zt.of(M(n.createdAt),n.offset),n.relativeOffset)}function Lf(n){return zt.of(M(n.createdAt),n.offset)}function Bp(n){const e=Gs.create(n.value);Object.entries(n.attributes).forEach(([r,s])=>{e.setAttr(r,s.value,M(s.updatedAt))});const t=vr.create(Lf(n.id),e);return t.remove(M(n.removedAt)),t}function _r(n){return vt.of(Rs(n.parentId),Rs(n.leftSiblingId))}function Rs(n){return xe.of(M(n.createdAt),n.offset)}function Rp(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=fc(t.content);e.push(r)}),e}function fc(n){if(n.length===0)return;const e=[];for(const s of n)e.push(Lp(s));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let s=e.length-2;s>=0;s--)r.get(n[s].depth-1).prepend(e[s]),r.set(n[s].depth,e[s]);return t.updateDescendantsSize(),lt.create(t,bt).getRoot()}function Fp(n){const e=sr.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function Lp(n){const e=Rs(n.id),t=je.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=Fp(n.attributes)),n.insPrevId&&(t.insPrevID=Rs(n.insPrevId)),n.insNextId&&(t.insNextID=Rs(n.insNextId)),t.removedAt=M(n.removedAt),t}function Jf(n){if(n.body.case==="set"){const e=n.body.value;return zr.create(e.key,Mo(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Zs.create(M(e.parentCreatedAt),M(e.prevCreatedAt),Mo(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return dr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Ar.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([s,i])=>{t.set(s,M(i))});const r=new Map;return Object.entries(e.attributes).forEach(([s,i])=>{r.set(s,i)}),Qs.create(M(e.parentCreatedAt),mi(e.from),mi(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([s,i])=>{t.set(s,M(i))});const r=new Map;return Object.entries(e.attributes).forEach(([s,i])=>{r.set(s,i)}),ei.create(M(e.parentCreatedAt),mi(e.from),mi(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ys.create(M(e.parentCreatedAt),Mo(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,M(s))}),ti.create(M(e.parentCreatedAt),_r(e.from),_r(e.to),Rp(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,s=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([i,o])=>{s.set(i,M(o))}),(r==null?void 0:r.length)>0?tr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),_r(e.from),_r(e.to),s,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([i,o])=>{t.set(i,o)}),tr.create(M(e.parentCreatedAt),_r(e.from),_r(e.to),s,t,M(e.executedAt)))}else throw new w(y.ErrUnimplemented,"unimplemented operation")}}function Jp(n){const e=[];for(const t of n){const r=Jf(t);r&&e.push(r)}return e}function Mf(n){const e=[];for(const t of n)e.push(ms.create({id:Rf(t.id),operations:Jp(t.operations),presenceChange:t.presenceChange?Op(t.presenceChange):void 0,message:t.message}));return e}function Mp(n){return os.of(BigInt(n.serverSeq),n.clientSeq)}function $p(n){return bo.create(n.documentKey,Mp(n.checkpoint),n.isRemoved,Mf(n.changes),uc(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function $f(n){const e=new js;for(const r of n.nodes){const s=hc(r.element);e.set(r.key,s,s.getPositionedAt())}const t=new Ue(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Uf(n){const e=new Hs;for(const r of n.nodes)e.insert(hc(r.element));const t=new We(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Up(n){const e=he.of(he.valueFromBytes(Ff(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function qp(n){const e=new ps;let t=e.getHead();for(const s of n.nodes){const i=e.insertAfter(t,Bp(s));s.insPrevId&&i.setInsPrev(e.findNode(Lf(s.insPrevId))),t=i}const r=new ut(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function zp(n){const e=He.create(ro(n.type),He.valueFromBytes(ro(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function qf(n){const e=fc(n.nodes);return lt.create(e,M(n.createdAt))}function hc(n){if(n.body.case==="jsonObject")return $f(n.body.value);if(n.body.case==="jsonArray")return Uf(n.body.value);if(n.body.case==="primitive")return Up(n.body.value);if(n.body.case==="text")return qp(n.body.value);if(n.body.case==="counter")return zp(n.body.value);if(n.body.case==="tree")return qf(n.body.value);throw new w(y.ErrUnimplemented,"unimplemented element")}function Kp(n){if(!n)return{root:Ue.create(bt),presences:new Map};const e=na.fromBinary(n);return{root:hc(e.root),presences:Dp(e.presences)}}function Vp(n){const e=oc(n);return dc(e.toBinary())}function jp(n){const e=mc(n),t=vo.fromBinary(e);return uc(t)}function zf(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return $f(e.body.value)}function Kf(n){return cc(n).toBinary()}function Wp(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return Uf(e.body.value)}function Hp(n){return Df(n).toBinary()}function Gp(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return qf(e.body.value)}function _p(n){return Bf(n).toBinary()}function dc(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function gc(n){return dc(n)}function mc(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function pc(n){return mc(n)}function Yp(n){const e=yo.fromBinary(n);return Rf(e)}function Xp(n){const e=ec.fromBinary(n);return Jf(e)}const ye={fromPresence:lc,toChangePack:Pp,fromChangePack:$p,fromChanges:Mf,toTreeNodes:ac,fromTreeNodes:fc,objectToBytes:Kf,bytesToObject:zf,bytesToSnapshot:Kp,bytesToHex:dc,hexToBytes:mc,toHexString:gc,toUint8Array:pc,toOperation:Of,toChangeID:Cf,PbChangeID:yo,bytesToChangeID:Yp,bytesToOperation:Xp,versionVectorToHex:Vp,hexToVersionVector:jp};var Le=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Le||{});let Cr=3;function Vf(n){Cr=n}const K={trivial:(...n)=>{Cr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{Cr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{Cr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{Cr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{Cr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>Cr<=n};function jf(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class Zp{constructor(e,t,r,s,i){c(this,"reconnectStreamDelay");c(this,"doc");c(this,"docID");c(this,"syncMode");c(this,"remoteChangeEventReceived");c(this,"watchStream");c(this,"watchLoopTimerID");c(this,"watchAbortController");c(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=s,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ni.RealtimeSyncOff?!1:this.syncMode===Ni.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ni.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const $o=()=>{};class Qp{constructor(e){c(this,"finalized",!1);c(this,"observers",[]);c(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(!e)throw new w(y.ErrInvalidArgument,"missing observer");if(this.finalized)throw new w(y.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=$o),s.error===void 0&&(s.error=$o),s.complete===void 0&&(s.complete=$o);const i=jf(),o=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:s}),this.finalized)try{this.finalError?s.error(this.finalError):s.complete()}catch(a){K.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Qr{constructor(e,t,r,s){c(this,"id");c(this,"delimiter");c(this,"message");c(this,"root");c(this,"operations");c(this,"presenceChange");c(this,"previousPresence");c(this,"reversePresenceKeys");this.id=e,this.delimiter=yf,this.root=t,this.operations=[],this.previousPresence=dt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=s}static create(e,t,r,s){return new Qr(e,t,r,s)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ms.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class _s{constructor(e){c(this,"rootObject");c(this,"elementPairMapByCreatedAt");c(this,"gcElementSetByCreatedAt");c(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof ut||t instanceof lt)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new _s(Ue.create(bt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const s=t.element.getCreatedAt(),i=t.parent.subPathOf(s);if(i===void 0)throw new w(y.ErrInvalidArgument,`cant find the given element: ${s.toIDString()}`);r.unshift(i),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof yr&&e.getDescendants((r,s)=>(this.registerElement(r,s),!1))}deregisterElement(e){let t=0;const r=s=>{const i=s.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(i),this.gcElementSetByCreatedAt.delete(i),t++};return r(e),e instanceof yr&&e.getDescendants(s=>(r(s),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof yr&&r.element.getDescendants(s=>(e.add(s.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new _s(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const s=this.elementPairMapByCreatedAt.get(r),i=s.element.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(s.parent.purge(s.element),t+=this.deregisterElement(s.element))}for(const[,r]of this.gcPairMap){const s=r.child.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Wf(n,e){const t=new Ys(n);return new Proxy(e,t.getHandlers())}class Ys{constructor(e){c(this,"context");c(this,"handlers");this.context=e,this.handlers={set:(t,r,s)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]=${JSON.stringify(s)}`),Ys.setInternal(e,t,r,s),!0),get:(t,r)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():Nr(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]`),Ys.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,s){if(r.includes("."))throw new w(y.ErrInvalidObjectKey,"key must not contain the '.'.");const i=e.issueTimeTicket(),o=so(e,s,i),a=t.set(r,o,i);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(zr.create(r,o.deepcopy(),t.getCreatedAt(),i))}static buildObjectMembers(e,t){const r={};for(const[s,i]of Object.entries(t)){if(s.includes("."))throw new w(y.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=so(e,i,o);r[s]=a}return r}static deleteInternal(e,t,r){const s=e.issueTimeTicket(),i=t.deleteByKey(r,s);i&&(e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i))}getHandlers(){return this.handlers}}function ty(n,e){const t=new me(n,e);return new Proxy(e,t.getHandlers())}function ny(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function ry(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class me{constructor(e,t){c(this,"context");c(this,"handlers");c(this,"array");this.context=e,this.array=t,this.handlers={get:(r,s,i)=>s==="getID"?()=>r.getCreatedAt():s==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return lr(e,a)}:s==="getElementByIndex"?o=>{const a=r.get(o);return lr(e,a)}:s==="getLast"?()=>lr(e,r.getLast()):s==="deleteByID"?o=>{const a=me.deleteInternalByID(e,r,o);return lr(e,a)}:s==="insertAfter"?(o,a)=>{const u=me.insertAfterInternal(e,r,o,a);return lr(e,u)}:s==="insertBefore"?(o,a)=>{const u=me.insertBeforeInternal(e,r,o,a);return lr(e,u)}:s==="moveBefore"?(o,a)=>{me.moveBeforeInternal(e,r,o,a)}:s==="moveAfter"?(o,a)=>{me.moveAfterInternal(e,r,o,a)}:s==="moveFront"?o=>{me.moveFrontInternal(e,r,o)}:s==="moveLast"?o=>{me.moveLastInternal(e,r,o)}:ny(s)?Nr(e,r.get(Number(s))):s==="push"?o=>me.pushInternal(e,r,o):s==="splice"?(o,a,...u)=>me.splice(e,r,o,a,...u):s==="length"?r.length:typeof s=="symbol"&&s===Symbol.iterator?me.iteratorInternal.bind(this,e,r):s==="includes"?(o,a)=>me.includes(e,r,o,a):s==="indexOf"?(o,a)=>me.indexOf(e,r,o,a):s==="lastIndexOf"?(o,a)=>me.lastIndexOf(e,r,o,a):s==="toJSForTest"?()=>r.toJSForTest():s==="toTestString"?()=>me.toTestString(r):typeof s=="string"&&ry(s)?(...o)=>{const a=Array.from(r).map(u=>Nr(e,u));return Array.prototype[s].apply(a,o)}:Reflect.get(r,s,i),deleteProperty:(r,s)=>(K.isEnabled(Le.Trivial)&&K.trivial(`array[${s}]`),me.deleteInternalByIndex(e,r,Number.parseInt(s)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield lr(e,r)}static buildArrayElements(e,t){const r=[];for(const s of t){const i=e.issueTimeTicket(),o=so(e,s,i);r.push(o)}return r}static pushInternal(e,t,r){return me.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,s){const i=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,s,i),e.push(dr.create(t.getCreatedAt(),o,s,i))}static moveAfterInternal(e,t,r,s){const i=e.issueTimeTicket();t.moveAfter(r,s,i),e.push(dr.create(t.getCreatedAt(),r,s,i))}static moveFrontInternal(e,t,r){const s=e.issueTimeTicket(),i=t.getHead();t.moveAfter(i.getCreatedAt(),r,s),e.push(dr.create(t.getCreatedAt(),i.getCreatedAt(),r,s))}static moveLastInternal(e,t,r){const s=e.issueTimeTicket(),i=t.getLastCreatedAt();t.moveAfter(i,r,s),e.push(dr.create(t.getCreatedAt(),i,r,s))}static insertAfterInternal(e,t,r,s){const i=e.issueTimeTicket(),o=so(e,s,i);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Zs.create(t.getCreatedAt(),r,o.deepcopy(),i)),o}static insertBeforeInternal(e,t,r,s){return me.insertAfterInternal(e,t,t.getPrevCreatedAt(r),s)}static deleteInternalByIndex(e,t,r){const s=e.issueTimeTicket(),i=t.deleteByIndex(r,s);if(i)return e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i),i}static deleteInternalByID(e,t,r){const s=e.issueTimeTicket(),i=t.delete(r,s);return e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i),i}static splice(e,t,r,s,...i){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),u=s===void 0?o:s<0?a:Math.min(a+s,o),l=[];for(let h=a;h=i)return!1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).includes(r,o);for(let u=o;u=i)return-1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).indexOf(r,o);for(let u=o;u=i?i-1:s<0?s+i:s;if(o<0)return-1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).lastIndexOf(r,o);for(let u=o;u>0;u--)if(((a=t.get(u))==null?void 0:a.getID())===r.getID())return u;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class To{constructor(e,t){c(this,"context");c(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,s){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);K.isEnabled(Le.Debug)&&K.debug(`EDIT: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} c:${r}`);const o=s?ds(s):void 0,a=this.context.issueTimeTicket(),[u,,l,h]=this.text.edit(i,r,a,o);for(const d of l)this.context.registerGCPair(d);return this.context.push(new Qs(this.text.getCreatedAt(),i[0],i[1],u,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(h)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);K.isEnabled(Le.Debug)&&K.debug(`STYL: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} a:${JSON.stringify(r)}`);const i=ds(r),o=this.context.issueTimeTicket(),[a,u]=this.text.setStyle(s,i,o);for(const l of u)this.context.registerGCPair(l);return this.context.push(new ei(this.text.getCreatedAt(),s[0],s[1],a,new Map(Object.entries(i)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Tt.fromStruct(e[0]),Tt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class Ao{constructor(e,t){c(this,"valueType");c(this,"value");c(this,"context");c(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new w(y.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=he.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(ys.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new w(y.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function yc(n,e,t){const{type:r}=n,s=t.issueTimeTicket();if(r===er){Hf(n);const{value:i}=n,o=je.create(xe.of(s,0),r,i);e.append(o)}else{const{children:i=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!pf(o)){const l=ds(o);a=new sr;for(const[h,d]of Object.entries(l))a.set(h,d,s)}const u=je.create(xe.of(s,0),r,void 0,a);e.append(u);for(const l of i)yc(l,u,t)}}function sy(n,e){const{type:t}=e,r=n.issueTimeTicket();let s;if(e.type===er){const{value:i}=e;s=je.create(xe.of(r,0),t,i)}else if(e){const{children:i=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!pf(o)){const u=ds(o);a=new sr;for(const[l,h]of Object.entries(u))a.set(l,h,r)}s=je.create(xe.of(n.issueTimeTicket(),0),t,void 0,a);for(const u of i)yc(u,s,n)}return s}function Hf(n){if(!n.value.length)throw new w(y.ErrInvalidArgument,"text node cannot have empty value");return!0}function ju(n){if(!n.length)return!0;if(n[0].type===er)for(const t of n){const{type:r}=t;if(r!==er)throw new w(y.ErrInvalidArgument,"element node and text node cannot be passed together");Hf(t)}else for(const t of n){const{type:r}=t;if(r===er)throw new w(y.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class Io{constructor(e){c(this,"initialRoot");c(this,"context");c(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return je.create(xe.of(e.issueTimeTicket(),0),np);const t=je.create(xe.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)yc(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const[r,s]=this.tree.pathToPosRange(e),i=this.context.issueTimeTicket(),o=t?ds(t):void 0,[a]=this.tree.style([r,s],o,i);this.context.push(tr.create(this.tree.getCreatedAt(),r,s,a,o?new Map(Object.entries(o)):new Map,i))}style(e,t,r){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),i=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?ds(r):void 0,[u,l]=this.tree.style([s,i],a,o);for(const h of l)this.context.registerGCPair(h);this.context.push(tr.create(this.tree.getCreatedAt(),s,i,u,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),i=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,u]=this.tree.removeStyle([s,i],r,o);for(const l of u)this.context.registerGCPair(l);this.context.push(tr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),s,i,a,r,o))}editInternal(e,t,r,s=0){var l;if(r.length!==0&&r[0]&&(ju(r),r[0].type!==er))for(const h of r){const{children:d=[]}=h;ju(d)}const i=this.context.getLastTimeTicket();let o=new Array;if(((l=r[0])==null?void 0:l.type)===er){let h="";for(const d of r){const{value:v}=d;h+=v}o.push(je.create(xe.of(this.context.issueTimeTicket(),0),er,h))}else o=r.map(h=>h&&sy(this.context,h)).filter(h=>h);const[,a,u]=this.tree.edit([e,t],o.length?o.map(h=>h==null?void 0:h.deepcopy()):void 0,s,i,()=>this.context.issueTimeTicket());for(const h of a)this.context.registerGCPair(h);return this.context.push(ti.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,s,u,i)),!0}editByPath(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new w(y.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(i,o,r?[r]:[],s)}editBulkByPath(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new w(y.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(i,o,r,s)}edit(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(i,o,r?[r]:[],s)}editBulk(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(i,o,r,s)}toXML(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[vt.fromStruct(e[0]),vt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[vt.fromStruct(e[0]),vt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function Wu(n,e){return Wf(n,e)}function lr(n,e){if(e){if(e instanceof he)return e;if(e instanceof Ue)return Wf(n,e);if(e instanceof We)return ty(n,e);if(e instanceof ut)return new To(n,e);if(e instanceof He){const t=new Ao(Kt.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof lt){const t=new Io;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function Nr(n,e){const t=lr(n,e);return t instanceof he?t.getValue():t}function so(n,e,t){let r;if(he.isSupport(e))r=he.of(e,t);else if(Array.isArray(e))r=We.create(t,me.buildArrayElements(n,e));else if(typeof e=="object")e instanceof To?(r=ut.create(ps.create(),t),e.initialize(n,r)):e instanceof Ao?(r=He.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof Io?(r=lt.create(e.buildRoot(n),t),e.initialize(n,r)):r=Ue.create(t,Ys.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const Hu=50;class iy{constructor(){c(this,"undoStack",[]);c(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=Hu&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=Hu&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const oy="yorkie-devtools-panel",ay="yorkie-devtools-sdk";let Xr="disconnected";const Gu=new Map,Ci=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Ci);function pi(n,e){(e!=null&&e.force||Xr!=="disconnected")&&window.postMessage({source:ay,...n},"*")}function cy(n){if(!n.isEnableDevtools()||typeof window>"u"||Gu.has(n.getKey()))return;Ci.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Se.StatusChanged&&r.type!==Se.Snapshot&&r.type!==Se.LocalChange&&r.type!==Se.RemoteChange&&r.type!==Se.Initialized&&r.type!==Se.Watched&&r.type!==Se.Unwatched&&r.type!==Se.PresenceChanged)||(Ci.get(n.getKey()).push(t),Xr==="synced"&&pi({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});Gu.set(n.getKey(),[e]),pi({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var s;if(((s=t.data)==null?void 0:s.source)!==oy)return;switch(t.data.msg){case"devtools::connect":if(Xr!=="disconnected")break;Xr="connected",pi({msg:"doc::available",docKey:n.getKey()}),K.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Xr="disconnected",K.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Xr="synced",pi({msg:"doc::sync::full",docKey:n.getKey(),events:Ci.get(n.getKey())}),K.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var fr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(fr||{}),Se=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Se||{}),Ca=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Ca||{}),Na=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Na||{});class Gf{constructor(e,t){c(this,"key");c(this,"status");c(this,"opts");c(this,"changeID");c(this,"checkpoint");c(this,"localChanges");c(this,"root");c(this,"clone");c(this,"eventStream");c(this,"eventStreamObserver");c(this,"onlineClients");c(this,"presences");c(this,"history");c(this,"internalHistory");c(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=_s.create(),this.changeID=fp,this.checkpoint=hp,this.localChanges=[],this.eventStream=ey(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new iy,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},cy(this)}update(e,t){if(this.getStatus()==="removed")throw new w(y.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),s=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const i=Wu(s,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(i,new Lo(s,this.clone.presences.get(r)))}catch(i){throw this.clone=void 0,i}finally{this.isUpdating=!1}if(s.hasChange()){K.isEnabled(Le.Trivial)&&K.trivial(`trying to update a local change: ${this.toJSON()}`);const i=s.getChange(),{opInfos:o,reverseOps:a}=i.execute(this.root,this.presences,ie.Local),u=s.getReversePresence();u&&a.push({type:"presence",value:u}),this.localChanges.push(i),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=i.getID();const l=[];o.length>0&&l.push({type:"local-change",source:ie.Local,value:{message:i.getMessage()||"",operations:o,actor:r,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:ie.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(l),K.isEnabled(Le.Trivial)&&K.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,s){if(typeof e=="string"){if(typeof t!="function")throw new w(y.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="initialized"&&l.type!=="watched"&&l.type!=="unwatched"&&l.type!=="presence-changed"||a(l)},r,s)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="initialized"&&l.type!=="presence-changed"||l.type==="presence-changed"&&l.value.clientID!==this.changeID.getActorID()||a(l)},r,s)}if(e==="others"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="watched"&&l.type!=="unwatched"&&l.type!=="presence-changed"||l.value.clientID!==this.changeID.getActorID()&&a(l)},r,s)}if(e==="connection"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="connection-changed"&&a(l)},r,s)}if(e==="status"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="status-changed"&&a(l)},r,s)}if(e==="sync"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="sync-status-changed"&&a(l)},r,s)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="local-broadcast"&&a(l)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="broadcast"&&a(l)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="auth-error"&&a(l)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,s)}const i=e,o=t;return this.eventStream.subscribe(a=>{for(const u of a){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const l=[];for(const h of u.value.operations)this.isSameElementOrChildOf(h.path,i)&&l.push(h);l.length&&o({...u,value:{...u.value,operations:l}})}},r,s)}if(typeof e=="function"){const i=e,o=t,a=r;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="snapshot"&&l.type!=="local-change"&&l.type!=="remote-change"||i(l)},o,a)}throw new w(y.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((i,o)=>i===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),ie.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),K.isEnabled(Le.Trivial)&&K.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:dt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return bo.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Wu(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,s=-1){const{root:i,presences:o}=ye.bytesToSnapshot(r);this.root=new _s(i),this.presences=o,this.changeID=this.changeID.setClocks(e,t),this.clone=void 0,this.removePushedLocalChanges(s),this.applyChanges(this.localChanges,ie.Local),this.publish([{type:"snapshot",source:ie.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?ye.bytesToHex(r):void 0,snapshotVector:ye.versionVectorToHex(t)}}])}applyChanges(e,t){K.isEnabled(Le.Debug)&&K.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),K.isEnabled(Le.Trivial)&&K.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` -`));for(const r of e)this.applyChange(r,t);K.isEnabled(Le.Debug)&&K.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],s=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(s)){const o=e.getPresenceChange();switch(o.type){case Tr.Put:r.push(this.presences.has(s)?{type:"presence-changed",source:t,value:{clientID:s,presence:o.presence}}:{type:"watched",source:ie.Remote,value:{clientID:s,presence:o.presence}});break;case Tr.Clear:r.push({type:"unwatched",source:ie.Remote,value:{clientID:s,presence:this.getPresence(s)}}),this.removeOnlineClient(s);break}}const{opInfos:i}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),i.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===ie.Remote?{type:"remote-change",source:t,value:{actor:s,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:o}:{type:"local-change",source:t,value:{actor:s,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const s of t)s!==this.changeID.getActorID()&&r.add(s);this.setOnlineClients(r),this.publish([{type:"initialized",source:ie.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,s=[];if(t===$r.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&s.push({type:"watched",source:ie.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===$r.DOCUMENT_UNWATCHED){const i=this.getPresence(r);this.removeOnlineClient(r),i&&s.push({type:"unwatched",source:ie.Remote,value:{clientID:r,presence:i}})}else if(t===$r.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:i,payload:o}=e.body.value.body,a=new TextDecoder;s.push({type:"broadcast",value:{clientID:r,topic:i,payload:JSON.parse(a.decode(o))}})}s.length>0&&this.publish(s)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(nc),this.publish([{source:e==="removed"?ie.Remote:ie.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:s}=e.value;if(!t)return;this.applySnapshot(BigInt(r),ye.hexToVersionVector(s),ye.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ms.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:s}of e.value)t.add(r),this.presences.set(r,s);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new w(y.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const s of t)if(r=r[s],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?dt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?dt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?dt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:dt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:dt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new w(y.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new w(y.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const l of e){if(!(l instanceof At)){new Lo(t,dt(this.clone.presences.get(this.changeID.getActorID()))).set(l.value,{addToHistory:!0});continue}const h=t.issueTimeTicket();l.setExecutedAt(h),t.push(l)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,ie.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,ie.UndoRedo),o=t.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];s.length>0&&u.push({type:"local-change",source:ie.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:ie.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}redo(){if(this.isUpdating)throw new w(y.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new w(y.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const l of e){if(!(l instanceof At)){new Lo(t,dt(this.clone.presences.get(this.changeID.getActorID()))).set(l.value,{addToHistory:!0});continue}const h=t.issueTimeTicket();l.setExecutedAt(h),t.push(l)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,ie.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,ie.UndoRedo),o=t.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];s.length>0&&u.push({type:"local-change",source:ie.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:ie.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const s={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([s])}getVersionVector(){return this.changeID.getVersionVector()}}function uy(n,e){let t=e;return{authInterceptor:i=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await i(o)),setToken:i=>{t=i}}}const ly="yorkie-js-sdk",fy="0.5.6",hy="Yorkie JS SDK",dy="./src/yorkie.ts",gy={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},my=["dist"],py={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},yy={node:">=18.0.0",npm:">=7.1.0"},vy={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},wy={name:"hackerwins",email:"susukang98@gmail.com"},by="Apache-2.0",Ty={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},Ay="https://github.com/yorkie-team/yorkie-js-sdk#readme",Iy={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},Sy={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},_u={name:ly,version:fy,description:hy,main:dy,publishConfig:gy,files:my,scripts:py,engines:yy,repository:vy,author:wy,license:by,bugs:Ty,homepage:Ay,devDependencies:Iy,dependencies:Sy};function xy(){return n=>async e=>(e.header.set("x-yorkie-user-agent",_u.name+"/"+_u.version),await n(e))}const ky=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ni=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ni||{});const yi={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},Uo={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class _f{constructor(e,t){c(this,"id");c(this,"key");c(this,"status");c(this,"attachmentMap");c(this,"apiKey");c(this,"authTokenInjector");c(this,"conditions");c(this,"syncLoopDuration");c(this,"reconnectStreamDelay");c(this,"retrySyncLoopDelay");c(this,"rpcClient");c(this,"setAuthToken");c(this,"taskQueue");c(this,"processing",!1);c(this,"keepalive",!1);t=t||yi,this.key=t.key?t.key:jf(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??yi.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??yi.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??yi.retrySyncLoopDelay;const{authInterceptor:r,setToken:s}=uy(this.apiKey);this.setAuthToken=s,this.rpcClient=xm(Gm,Hm({baseUrl:e,interceptors:[r,xy()],fetch:(i,o)=>{const a={...o,keepalive:this.keepalive};return fetch(i,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),K.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw K.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),K.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw K.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==fr.Detached)throw new w(y.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((i,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async i=>{var h;const{topic:o,payload:a}=i.value,u=(h=i.options)==null?void 0:h.error,l=i.options;try{await this.broadcast(e.getKey(),o,a,l)}catch(d){d instanceof Error&&(u==null||u(d))}}),s=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:ye.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async i=>{const o=ye.fromChangePack(i.changePack);if(e.applyChangePack(o),e.getStatus()===fr.Removed)return e;e.applyStatus(fr.Attached),this.attachmentMap.set(e.getKey(),new Zp(this.reconnectStreamDelay,e,i.documentId,s,r)),s!=="manual"&&await this.runWatchLoop(e.getKey()),K.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const u=t.initialRoot;e.update(l=>{for(const[h,d]of Object.entries(u))if(!a.has(h)){const v=h;l[v]=d}})}return e}).catch(async i=>{throw K.error(`[AD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}detach(e,t={}){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((s,i)=>i.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:ye.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(s=>{const i=ye.fromChangePack(s.changePack);return e.applyChangePack(i),e.getStatus()!==fr.Removed&&e.applyStatus(fr.Detached),this.detachInternal(e.getKey()),K.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async s=>{throw K.error(`[DD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}async changeSyncMode(e,t){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const s=r.syncMode;return s===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),s==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw K.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw K.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=ye.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(s=>{const i=ye.fromChangePack(s.changePack);e.applyChangePack(i),this.detachInternal(e.getKey()),K.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async s=>{throw K.error(`[RD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,s){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e);if(!i)throw new w(y.ErrDocumentNotAttached,`${e} is not attached`);if(!ky(r))throw new w(y.ErrInvalidArgument,"payload is not serializable");const o=(s==null?void 0:s.maxRetries)??Uo.maxRetries,a=Uo.maxBackoff;let u=0;const l=d=>Math.min(Uo.initialRetryInterval*2**d,a),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:i.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{K.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async d=>{if(K.error(`[BC] c:"${this.getKey()}" err:`,d),await this.handleConnectError(d))if(d instanceof le&&Gr(d)===y.ErrUnauthenticated&&i.doc.publish([{type:Se.AuthError,value:{reason:Es(d).reason,method:"Broadcast"}}]),uh(),l(u-1)),K.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${o}`);else throw K.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),d;else throw d}));return h()}runSyncLoop(){const e=()=>{if(!this.isActive()){K.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async s=>{throw s instanceof le&&Gr(s)===y.ErrUnauthenticated&&r.doc.publish([{type:Se.AuthError,value:{reason:Es(s).reason,method:"PushPull"}}]),s})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{K.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};K.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new w(y.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new w(y.ErrClientNotActivated,`${this.key} is not active`));const s=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:s.signal});return t.doc.publish([{type:Se.ConnectionChanged,value:Ca.Connected}]),K.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const l of i)this.handleWatchDocumentsResponse(t,l),l.body.case==="initialization"&&o([i,s])}catch(l){t.doc.resetOnlineClients(),t.doc.publish([{type:Se.Initialized,source:ie.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Se.ConnectionChanged,value:Ca.Disconnected}]),K.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(l)?(l instanceof le&&Gr(l)===y.ErrUnauthenticated&&t.doc.publish([{type:Se.AuthError,value:{reason:Es(l).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(l)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===$r.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(fr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:s}=e,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:s,changePack:ye.toChangePack(i),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=ye.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Se.SyncStatusChanged,value:Na.Synced}]),r.getStatus()===fr.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),l=a.getChangeSize();return K.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${i.getChangeSize()} pull:${l} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Se.SyncStatusChanged,value:Na.SyncFailed}]),K.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof le))return!1;if(e.code===ne.Canceled||e.code===ne.Unknown||e.code===ne.ResourceExhausted||e.code===ne.Unavailable)return!0;if(Gr(e)===y.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Es(e).reason);this.setAuthToken(t)}return!0}return(Gr(e)===y.ErrClientNotActivated||Gr(e)===y.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{K.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Yf={Client:_f,Document:Gf,Primitive:he,Text:To,Counter:Ao,Tree:Io,LogLevel:Le,setLogLevel:Vf,IntType:Kt.IntegerCnt,LongType:Kt.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:_f,Document:Gf,Primitive:he,Text:To,Counter:Ao,Tree:Io,LogLevel:Le,setLogLevel:Vf,IntType:Kt.IntegerCnt,LongType:Kt.LongCnt});const Ey=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},Cy=[{title:"Todo",cards:[{title:"Pruning document"},{title:"Clean up codes"}]},{title:"Doing",cards:[{title:"Array operations"}]},{title:"Done",cards:[{title:"Create a sample page"},{title:"Launch demo site"}]}],ur=new Yf.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"}),Ht=new Yf.Document(`vuejs-kanban-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`,{enableDevtools:!0}),Ny={data(){return{lists:[],title:"",opened:null}},created(){this.fetchDoc()},beforeUnmount(){this.disconnect()},watch:{opened(n){this.$nextTick(function(){n===0?this.$refs.addListForm.querySelector("input").focus():n&&this.$refs.addCardForm[n-1].querySelector("input").focus(),this.title=""})}},methods:{async fetchDoc(){await ur.activate(),await ur.attach(Ht),Ht.update(n=>{n.lists||(n.lists=Cy)},"create default list if not exists"),Ht.subscribe(n=>{this.lists=Ht.getRoot().lists}),await ur.sync(),this.lists=Ht.getRoot().lists},async disconnect(){await ur.deactivate()},isOpened(n){return this.opened===n},openForm(n){this.opened=n},closeForm(){this.opened=null},addCard(n){this.title!==""&&Ht.update(e=>{e.lists.getElementByID(n.getID()).cards.push({title:this.title}),this.title=""},`add new card by ${ur.getID()}`)},deleteCard(n,e){Ht.update(t=>{t.lists.getElementByID(n.getID()).cards.deleteByID(e.getID())},`delete a card by ${ur.getID()}`)},addList(){this.title!==""&&Ht.update(n=>{n.lists.push({title:this.title,cards:[]}),this.title=""},`add new list by ${ur.getID()}`)},deleteList(n){Ht.update(e=>{e.lists.deleteByID(n.getID())},`delete a list by ${ur.getID()}`)}}},Py={class:"list"},Oy=["onClick"],Dy={class:"title"},By={class:"card"},Ry=["onClick"],Fy={key:0,class:"add-form"},Ly=["onKeyup"],Jy={class:"buttons"},My=["onClick"],$y=["onClick"],Uy={class:"add-list",ref:"addListForm"},qy={key:0,class:"add-form"},zy={class:"buttons"};function Ky(n,e,t,r,s,i){return jt(),Wt(_e,null,[(jt(!0),Wt(_e,null,Mc(s.lists,(o,a)=>(jt(),Wt("div",Py,[Re("span",{class:"delete",onClick:u=>i.deleteList(o)},"❌",8,Oy),Re("div",Dy,Ec(o.title),1),(jt(!0),Wt(_e,null,Mc(o.cards,u=>(jt(),Wt("div",By,[Re("span",{class:"delete",onClick:l=>i.deleteCard(o,u)},"❌",8,Ry),Jl(" "+Ec(u.title),1)]))),256)),Re("div",{class:"add-card",ref_for:!0,ref:"addCardForm"},[i.isOpened(a+1)?(jt(),Wt("div",Fy,[Jc(Re("input",{type:"text",placeholder:"Enter card title","onUpdate:modelValue":e[0]||(e[0]=u=>s.title=u),onKeyup:[fi(u=>i.addCard(o),["enter"]),e[1]||(e[1]=fi(u=>i.closeForm(),["esc"]))]},null,40,Ly),[[iu,s.title]]),Re("div",Jy,[Re("input",{type:"button",value:"Add",onClick:u=>i.addCard(o)},null,8,My),Re("input",{type:"button",value:"Close",class:"pull-right",onClick:e[2]||(e[2]=u=>i.closeForm())})])])):(jt(),Wt("div",{key:1,class:"add-card-opener",onClick:u=>i.openForm(a+1)}," Add another card ",8,$y))],512)]))),256)),Re("div",Uy,[i.isOpened(0)?(jt(),Wt("div",qy,[Jc(Re("input",{type:"text",placeholder:"Enter list title","onUpdate:modelValue":e[3]||(e[3]=o=>s.title=o),onKeyup:[e[4]||(e[4]=fi(o=>i.addList(),["enter"])),e[5]||(e[5]=fi(o=>i.closeForm(),["esc"]))]},null,544),[[iu,s.title]]),Re("div",zy,[Re("input",{type:"button",value:"Add",onClick:e[6]||(e[6]=o=>i.addList())}),Re("input",{type:"button",value:"Close",class:"pull-right",onClick:e[7]||(e[7]=o=>i.closeForm())})])])):(jt(),Wt("div",{key:1,class:"add-list-opener",onClick:e[8]||(e[8]=o=>i.openForm(0))}," Add another list "))],512)],64)}const Vy=Ey(Ny,[["render",Ky]]);xg(Vy).mount("#app"); + */var ot=null;try{ot=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([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])),{}).exports}catch{}function X(n,e,t){this.low=n|0,this.high=e|0,this.unsigned=!!t}X.prototype.__isLong__;Object.defineProperty(X.prototype,"__isLong__",{value:!0});function Oe(n){return(n&&n.__isLong__)===!0}function Mu(n){var e=Math.clz32(n&-n);return n?31-e:e}X.isLong=Oe;var $u={},Uu={};function Vr(n,e){var t,r,s;return e?(n>>>=0,(s=0<=n&&n<256)&&(r=Uu[n],r)?r:(t=Q(n,0,!0),s&&(Uu[n]=t),t)):(n|=0,(s=-128<=n&&n<128)&&(r=$u[n],r)?r:(t=Q(n,n<0?-1:0,!1),s&&($u[n]=t),t))}X.fromInt=Vr;function at(n,e){if(isNaN(n))return e?Qn:yt;if(e){if(n<0)return Qn;if(n>=wf)return Af}else{if(n<=-zu)return $e;if(n+1>=zu)return Tf}return n<0?at(-n,e).neg():Q(n%gs|0,n/gs|0,e)}X.fromNumber=at;function Q(n,e,t){return new X(n,e,t)}X.fromBits=Q;var to=Math.pow;function sc(n,e,t){if(n.length===0)throw Error("empty string");if(typeof e=="number"?(t=e,e=!1):e=!!e,n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return e?Qn:yt;if(t=t||10,t<2||360)throw Error("interior hyphen");if(r===0)return sc(n.substring(1),e,t).neg();for(var s=at(to(t,8)),i=yt,o=0;o>>0:this.low};E.toNumber=function(){return this.unsigned?(this.high>>>0)*gs+(this.low>>>0):this.high*gs+(this.low>>>0)};E.toString=function(e){if(e=e||10,e<2||36>>0,h=l.toString(e);if(o=u,o.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}};E.getHighBits=function(){return this.high};E.getHighBitsUnsigned=function(){return this.high>>>0};E.getLowBits=function(){return this.low};E.getLowBitsUnsigned=function(){return this.low>>>0};E.getNumBitsAbs=function(){if(this.isNegative())return this.eq($e)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,t=31;t>0&&!(e&1<=0};E.isOdd=function(){return(this.low&1)===1};E.isEven=function(){return(this.low&1)===0};E.equals=function(e){return Oe(e)||(e=It(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};E.eq=E.equals;E.notEquals=function(e){return!this.eq(e)};E.neq=E.notEquals;E.ne=E.notEquals;E.lessThan=function(e){return this.comp(e)<0};E.lt=E.lessThan;E.lessThanOrEqual=function(e){return this.comp(e)<=0};E.lte=E.lessThanOrEqual;E.le=E.lessThanOrEqual;E.greaterThan=function(e){return this.comp(e)>0};E.gt=E.greaterThan;E.greaterThanOrEqual=function(e){return this.comp(e)>=0};E.gte=E.greaterThanOrEqual;E.ge=E.greaterThanOrEqual;E.compare=function(e){if(Oe(e)||(e=It(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};E.comp=E.compare;E.negate=function(){return!this.unsigned&&this.eq($e)?$e:this.not().add(Zr)};E.neg=E.negate;E.add=function(e){Oe(e)||(e=It(e));var t=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=e.high>>>16,a=e.high&65535,u=e.low>>>16,l=e.low&65535,h=0,d=0,v=0,p=0;return p+=i+l,v+=p>>>16,p&=65535,v+=s+u,d+=v>>>16,v&=65535,d+=r+a,h+=d>>>16,d&=65535,h+=t+o,h&=65535,Q(v<<16|p,h<<16|d,this.unsigned)};E.subtract=function(e){return Oe(e)||(e=It(e)),this.add(e.neg())};E.sub=E.subtract;E.multiply=function(e){if(this.isZero())return this;if(Oe(e)||(e=It(e)),ot){var t=ot.mul(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?Qn:yt;if(this.eq($e))return e.isOdd()?$e:yt;if(e.eq($e))return this.isOdd()?$e:yt;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Ku)&&e.lt(Ku))return at(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,o=this.low&65535,a=e.high>>>16,u=e.high&65535,l=e.low>>>16,h=e.low&65535,d=0,v=0,p=0,A=0;return A+=o*h,p+=A>>>16,A&=65535,p+=i*h,v+=p>>>16,p&=65535,p+=o*l,v+=p>>>16,p&=65535,v+=s*h,d+=v>>>16,v&=65535,v+=i*l,d+=v>>>16,v&=65535,v+=o*u,d+=v>>>16,v&=65535,d+=r*h+s*l+i*u+o*a,d&=65535,Q(p<<16|A,d<<16|v,this.unsigned)};E.mul=E.multiply;E.divide=function(e){if(Oe(e)||(e=It(e)),e.isZero())throw Error("division by zero");if(ot){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var t=(this.unsigned?ot.div_u:ot.div_s)(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Qn:yt;var r,s,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Qn;if(e.gt(this.shru(1)))return bf;i=Qn}else{if(this.eq($e)){if(e.eq(Zr)||e.eq(ka))return $e;if(e.eq($e))return Zr;var o=this.shr(1);return r=o.div(e).shl(1),r.eq(yt)?e.isNegative()?Zr:ka:(s=this.sub(e.mul(r)),i=r.add(s.div(e)),i)}else if(e.eq($e))return this.unsigned?Qn:yt;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=yt}for(s=this;s.gte(e);){r=Math.max(1,Math.floor(s.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(r)/Math.LN2),u=a<=48?1:to(2,a-48),l=at(r),h=l.mul(e);h.isNegative()||h.gt(s);)r-=u,l=at(r,this.unsigned),h=l.mul(e);l.isZero()&&(l=Zr),i=i.add(l),s=s.sub(h)}return i};E.div=E.divide;E.modulo=function(e){if(Oe(e)||(e=It(e)),ot){var t=(this.unsigned?ot.rem_u:ot.rem_s)(this.low,this.high,e.low,e.high);return Q(t,ot.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};E.mod=E.modulo;E.rem=E.modulo;E.not=function(){return Q(~this.low,~this.high,this.unsigned)};E.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};E.clz=E.countLeadingZeros;E.countTrailingZeros=function(){return this.low?Mu(this.low):Mu(this.high)+32};E.ctz=E.countTrailingZeros;E.and=function(e){return Oe(e)||(e=It(e)),Q(this.low&e.low,this.high&e.high,this.unsigned)};E.or=function(e){return Oe(e)||(e=It(e)),Q(this.low|e.low,this.high|e.high,this.unsigned)};E.xor=function(e){return Oe(e)||(e=It(e)),Q(this.low^e.low,this.high^e.high,this.unsigned)};E.shiftLeft=function(e){return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Q(this.low<>>32-e,this.unsigned):Q(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):Q(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};E.shr=E.shiftRight;E.shiftRightUnsigned=function(e){return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?Q(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?Q(this.high,0,this.unsigned):Q(this.high>>>e-32,0,this.unsigned)};E.shru=E.shiftRightUnsigned;E.shr_u=E.shiftRightUnsigned;E.rotateLeft=function(e){var t;return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Q(this.high,this.low,this.unsigned):e<32?(t=32-e,Q(this.low<>>t,this.high<>>t,this.unsigned)):(e-=32,t=32-e,Q(this.high<>>t,this.low<>>t,this.unsigned))};E.rotl=E.rotateLeft;E.rotateRight=function(e){var t;return Oe(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?Q(this.high,this.low,this.unsigned):e<32?(t=32-e,Q(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,t=32-e,Q(this.low<>>e,this.high<>>e,this.unsigned))};E.rotr=E.rotateRight;E.toSigned=function(){return this.unsigned?Q(this.low,this.high,!1):this};E.toUnsigned=function(){return this.unsigned?this:Q(this.low,this.high,!0)};E.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};E.toBytesLE=function(){var e=this.high,t=this.low;return[t&255,t>>>8&255,t>>>16&255,t>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};E.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,t>>>24,t>>>16&255,t>>>8&255,t&255]};X.fromBytes=function(e,t,r){return r?X.fromBytesLE(e,t):X.fromBytesBE(e,t)};X.fromBytesLE=function(e,t){return new X(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)};X.fromBytesBE=function(e,t){return new X(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var Te=(n=>(n[n.Null=0]="Null",n[n.Boolean=1]="Boolean",n[n.Integer=2]="Integer",n[n.Long=3]="Long",n[n.Double=4]="Double",n[n.String=5]="String",n[n.Bytes=6]="Bytes",n[n.Date=7]="Date",n))(Te||{});class he extends Xs{constructor(t,r){super(r);c(this,"valueType");c(this,"value");this.valueType=he.getPrimitiveType(t),this.value=t===void 0?null:t}static of(t,r){return new he(t,r)}static valueFromBytes(t,r){switch(t){case 0:return null;case 1:return!!r[0];case 2:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 4:{const s=new DataView(r.buffer);return r.forEach(function(i,o){s.setUint8(o,i)}),s.getFloat64(0,!0)}case 5:return new TextDecoder("utf-8").decode(r);case 3:return X.fromBytesLE(Array.from(r));case 6:return r;case 7:return new Date(X.fromBytesLE(Array.from(r),!0).toNumber());default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return this.valueType===5?`"${Ut(this.value)}"`:`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_PRIMITIVE"}}deepcopy(){const t=he.of(this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t.setRemovedAt(this.getRemovedAt()),t}getType(){return this.valueType}static getPrimitiveType(t){switch(typeof t){case"undefined":return 0;case"boolean":return 1;case"number":return this.isInteger(t)?2:4;case"string":return 5;case"object":if(t===null)return 0;if(t instanceof X)return 3;if(t instanceof Uint8Array)return 6;if(t instanceof Date)return 7}}static isSupport(t){return he.getPrimitiveType(t)!==void 0}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===2||t===3||t===4}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:return new Uint8Array;case 1:return this.value?new Uint8Array([1]):new Uint8Array([0]);case 2:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 4:{const t=this.value,r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),r}case 5:return new TextEncoder().encode(this.value);case 3:{const r=this.value.toBytesLE();return Uint8Array.from(r)}case 6:return this.value;case 7:{const t=this.value,r=X.fromNumber(t.getTime(),!0).toBytesLE();return Uint8Array.from(r)}default:throw new w(y.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}}class no extends vf{constructor(t){super(t);c(this,"prev");c(this,"next");this.value=t}static createAfter(t,r){const s=new no(r),i=t.next;return t.next=s,s.prev=t,s.next=i,i&&(i.prev=s),s}remove(t){return this.value.remove(t)}getCreatedAt(){return this.value.getCreatedAt()}getPositionedAt(){return this.value.getPositionedAt()}release(){this.prev&&(this.prev.next=this.next),this.next&&(this.next.prev=this.prev),this.prev=void 0,this.next=void 0}getLength(){return this.value.isRemoved()?0:1}getPrev(){return this.prev}getNext(){return this.next}getValue(){return this.value}isRemoved(){return this.value.isRemoved()}}class Hs{constructor(){c(this,"dummyHead");c(this,"last");c(this,"nodeMapByIndex");c(this,"nodeMapByCreatedAt");const e=he.of(0,bt);e.setRemovedAt(bt),this.dummyHead=new no(e),this.last=this.dummyHead,this.nodeMapByIndex=new Ws,this.nodeMapByCreatedAt=new Map,this.nodeMapByIndex.insert(this.dummyHead),this.nodeMapByCreatedAt.set(this.dummyHead.getCreatedAt().toIDString(),this.dummyHead)}static create(){return new Hs}get length(){return this.nodeMapByIndex.length}findNextBeforeExecutedAt(e,t){let r=this.nodeMapByCreatedAt.get(e.toIDString());if(!r)throw new w(y.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);for(;r.getNext()&&r.getNext().getPositionedAt().after(t);)r=r.getNext();return r}release(e){this.last===e&&(this.last=e.getPrev()),e.release(),this.nodeMapByIndex.delete(e),this.nodeMapByCreatedAt.delete(e.getValue().getCreatedAt().toIDString())}insertAfter(e,t,r=t.getCreatedAt()){const s=this.findNextBeforeExecutedAt(e,r),i=no.createAfter(s,t);s===this.last&&(this.last=i),this.nodeMapByIndex.insertAfter(s,i),this.nodeMapByCreatedAt.set(i.getCreatedAt().toIDString(),i)}moveAfter(e,t,r){const s=this.nodeMapByCreatedAt.get(e.toIDString());if(!s)throw new w(y.ErrInvalidArgument,`cant find the given node: ${e.toIDString()}`);const i=this.nodeMapByCreatedAt.get(t.toIDString());if(!i)throw new w(y.ErrInvalidArgument,`cant find the given node: ${t.toIDString()}`);s!==i&&(!i.getValue().getMovedAt()||r.after(i.getValue().getMovedAt()))&&(this.release(i),this.insertAfter(s.getCreatedAt(),i.getValue(),r),i.getValue().setMovedAt(r))}insert(e){this.insertAfter(this.last.getCreatedAt(),e)}getByID(e){return this.nodeMapByCreatedAt.get(e.toIDString())}subPathOf(e){const t=this.nodeMapByCreatedAt.get(e.toIDString());if(t)return String(this.nodeMapByIndex.indexOf(t))}purge(e){const t=this.nodeMapByCreatedAt.get(e.getCreatedAt().toIDString());if(!t)throw new w(y.ErrInvalidArgument,`fail to find the given createdAt: ${e.getCreatedAt().toIDString()}`);this.release(t)}getByIndex(e){if(e>=this.length)return;const[t,r]=this.nodeMapByIndex.find(e);let s=t;if(e===0&&t===this.dummyHead||r>0)do s&&(s=s.getNext());while(s&&s.isRemoved());return s}getPrevCreatedAt(e){let t=this.nodeMapByCreatedAt.get(e.toIDString());do t=t.getPrev();while(this.dummyHead!==t&&t.isRemoved());return t.getValue().getCreatedAt()}delete(e,t){const r=this.nodeMapByCreatedAt.get(e.toIDString()),s=r.isRemoved();return r.remove(t)&&!s&&this.nodeMapByIndex.splayNode(r),r.getValue()}deleteByIndex(e,t){const r=this.getByIndex(e);if(r)return r.remove(t)&&this.nodeMapByIndex.splayNode(r),r.getValue()}getHead(){return this.dummyHead.getValue()}getLast(){return this.last.getValue()}getLastCreatedAt(){return this.last.getCreatedAt()}toTestString(){const e=[];for(const t of this){const r=`${t.getCreatedAt().toIDString()}:${t.getValue().toJSON()}`;t.isRemoved()?e.push(`{${r}}`):e.push(`[${r}]`)}return e.join("")}*[Symbol.iterator](){let e=this.dummyHead.getNext();for(;e;)yield e,e=e.getNext()}}class We extends yr{constructor(t,r){super(t);c(this,"elements");this.elements=r}static create(t,r){if(!r)return new We(t,Hs.create());const s=Hs.create();for(const i of r)s.insertAfter(s.getLastCreatedAt(),i.deepcopy());return new We(t,s)}subPathOf(t){return this.elements.subPathOf(t)}purge(t){this.elements.purge(t)}insertAfter(t,r){this.elements.insertAfter(t,r)}moveAfter(t,r,s){this.elements.moveAfter(t,r,s)}get(t){const r=this.elements.getByIndex(t);return r==null?void 0:r.getValue()}getByID(t){const r=this.elements.getByID(t);return r==null?void 0:r.getValue()}getHead(){return this.elements.getHead()}getLast(){return this.elements.getLast()}getPrevCreatedAt(t){return this.elements.getPrevCreatedAt(t)}delete(t,r){return this.elements.delete(t,r)}deleteByIndex(t,r){return this.elements.deleteByIndex(t,r)}getLastCreatedAt(){return this.elements.getLastCreatedAt()}get length(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)t.isRemoved()||(yield t.getValue())}toTestString(){return this.elements.toTestString()}getDescendants(t){for(const r of this.elements){const s=r.getValue();if(t(s,this))return;s instanceof yr&&s.getDescendants(t)}}toJSON(){const t=[];for(const r of this)t.push(r.toJSON());return`[${t.join(",")}]`}toJS(){return JSON.parse(this.toJSON())}toJSForTest(){const t={};for(let r=0;r({...A,value:A.value?{attributes:ss(A.value.getAttributes()),content:A.value.getContent()}:{attributes:void 0,content:""},type:"content"}));return[h,p,d,[l,l]]}setStyle(t,r,s,i,o){const[,a]=this.rgaTreeSplit.findNodeWithSplit(t[1],s),[,u]=this.rgaTreeSplit.findNodeWithSplit(t[0],s),l=[],h=this.rgaTreeSplit.findBetween(u,a),d=new Map,v=[];for(const A of h){const I=A.getCreatedAt().getActorID();let D,L=0n;if(o===void 0&&i===void 0?L=Ds:o.size()>0?L=o.get(I)?o.get(I):0n:D=i.has(I)?i.get(I):bt,A.canStyle(s,D,L)){const $=d.get(I),V=A.getCreatedAt();(!$||V.after($))&&d.set(I,V),v.push(A)}}const p=[];for(const A of v){if(A.isRemoved())continue;const[I,D]=this.rgaTreeSplit.findIndexesFromRange(A.createPosRange());l.push({type:"style",actor:s.getActorID(),from:I,to:D,value:{attributes:ss(r)}});for(const[L,$]of Object.entries(r)){const[V]=A.getValue().setAttr(L,$,s);V!==void 0&&p.push({parent:A.getValue(),child:V})}}return[d,p,l]}indexRangeToPosRange(t,r){const s=this.rgaTreeSplit.indexToPos(t);return t===r?[s,s]:[s,this.rgaTreeSplit.indexToPos(r)]}get length(){return this.rgaTreeSplit.length}getTreeByIndex(){return this.rgaTreeSplit.getTreeByIndex()}getTreeByID(){return this.rgaTreeSplit.getTreeByID()}toJSON(){const t=[];for(const r of this.rgaTreeSplit)r.isRemoved()||t.push(r.getValue().toJSON());return`[${t.join(",")}]`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TEXT"}}toString(){return this.rgaTreeSplit.toString()}values(){const t=[];for(const r of this.rgaTreeSplit)if(!r.isRemoved()){const s=r.getValue();t.push({attributes:ss(s.getAttributes()),content:s.getContent()})}return t}getRGATreeSplit(){return this.rgaTreeSplit}toTestString(){return this.rgaTreeSplit.toTestString()}deepcopy(){const t=new ut(this.rgaTreeSplit.deepcopy(),this.getCreatedAt());return t.remove(this.getRemovedAt()),t}findIndexesFromRange(t){return this.rgaTreeSplit.findIndexesFromRange(t)}getGCPairs(){const t=[];for(const r of this.rgaTreeSplit){r.getRemovedAt()&&t.push({parent:this.rgaTreeSplit,child:r});for(const s of r.getValue().getGCPairs())t.push(s)}return t}}class Qs extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"content");c(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.content=o,this.attributes=a}static create(t,r,s,i,o,a,u){return new Qs(t,r,s,i,o,a,u)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof ut))throw new w(y.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,a,u]=o.edit([this.fromPos,this.toPos],this.content,this.getExecutedAt(),Object.fromEntries(this.attributes),this.maxCreatedAtMapByActor,s);for(const l of u)t.registerGCPair(l);return{opInfos:a.map(({from:l,to:h,value:d})=>({type:"edit",from:l,to:h,value:d,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.content;return`${t}.EDIT(${r},${s},${i})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContent(){return this.content}getAttributes(){return this.attributes||new Map}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class ei extends At{constructor(t,r,s,i,o,a){super(t,a);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"attributes");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o}static create(t,r,s,i,o,a){return new ei(t,r,s,i,o,a)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof ut))throw new w(y.ErrInvalidArgument,"fail to execute, only Text can execute edit");const o=i,[,a,u]=o.setStyle([this.fromPos,this.toPos],this.attributes?Object.fromEntries(this.attributes):{},this.getExecutedAt(),this.maxCreatedAtMapByActor,s);for(const l of a)t.registerGCPair(l);return{opInfos:u.map(({from:l,to:h,value:d})=>({type:"style",from:l,to:h,value:d,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=this.fromPos.toTestString(),s=this.toPos.toTestString(),i=this.attributes;return`${t}.STYL(${r},${s},${JSON.stringify(i)})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}const tp=2,np="root",er="text";function Ss(n,e){let t=0;const r=n.children;for(let s=0;s0)throw new w(y.ErrRefused,"Text node cannot have children")}updateAncestorsSize(){let e=this.parent;const t=this.isRemoved?-1:1;for(;e&&(e.size+=this.paddedSize*t,!e.isRemoved);)e=e.parent}updateDescendantsSize(){let e=0;for(const t of this._children){const r=t.updateDescendantsSize();t.isRemoved||(e+=r)}return this.size+=e,this.paddedSize}get isText(){return this.type===er}get paddedSize(){return this.size+(this.isText?0:tp)}isAncestorOf(e){return sp(this,e)}get nextSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e+1];if(t)return t}get prevSibling(){const e=this.parent.findOffset(this),t=this.parent.children[e-1];if(t)return t}splitText(e,t){if(e===0||e===this.size)return;const r=this.value.slice(0,e),s=this.value.slice(e);if(!s.length)return;this.value=r;const i=this.cloneText(e+t);return i.value=s,this.parent.insertAfterInternal(i,this),i}get children(){return this._children.filter(e=>!e.isRemoved)}get allChildren(){return[...this._children]}hasTextChild(){return this.children.length>0&&this.children.every(e=>e.isText)}append(...e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.push(...e);for(const t of e)t.parent=this,t.updateAncestorsSize()}prepend(...e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.unshift(...e);for(const t of e)t.parent=this}insertBefore(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r),e.updateAncestorsSize()}insertAfter(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1),e.updateAncestorsSize()}insertAt(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this.insertAtInternal(e,t),e.updateAncestorsSize()}removeChild(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const t=this._children.indexOf(e);if(t===-1)throw new w(y.ErrInvalidArgument,"child not found");this._children.splice(t,1),e.parent=void 0}splitElement(e,t){const r=this.cloneElement(t);this.parent.insertAfterInternal(r,this),r.updateAncestorsSize();const s=this.children.slice(0,e),i=this.children.slice(e);this._children=s,r._children=i,this.size=this._children.reduce((o,a)=>o+a.paddedSize,0),r.size=r._children.reduce((o,a)=>o+a.paddedSize,0);for(const o of r._children)o.parent=r;return r}insertAfterInternal(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");const r=this._children.indexOf(t);if(r===-1)throw new w(y.ErrInvalidArgument,"child not found");this.insertAtInternal(e,r+1)}insertAtInternal(e,t){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");this._children.splice(t,0,e),e.parent=this}findOffset(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");if(e.isRemoved){const t=this._children.indexOf(e);return this.allChildren.splice(0,t).filter(s=>!s.isRemoved).length}return this.children.indexOf(e)}findBranchOffset(e){if(this.isText)throw new w(y.ErrRefused,"Text node cannot have children");let t=e;for(;t;){const r=this._children.indexOf(t);if(r!==-1)return r;t=t.parent}return-1}}function sp(n,e){if(n===e)return!1;for(;e.parent;){if(e.parent===n)return!0;e=e.parent}return!1}var be=(n=>(n.Start="Start",n.End="End",n.Text="Text",n))(be||{});function If(n,e,t,r){if(e>t)throw new w(y.ErrInvalidArgument,`from is greater than to: ${e} > ${t}`);if(e>n.size)throw new w(y.ErrInvalidArgument,`from is out of range: ${e} > ${n.size}`);if(t>n.size)throw new w(y.ErrInvalidArgument,`to is out of range: ${t} > ${n.size}`);if(e===t)return;let s=0;for(const i of n.children){if(e-i.paddedSizei.size;(i.isText||u)&&r([i,i.isText?"Text":"Start"],l),If(i,Math.max(0,o),Math.min(a,i.size),r),l&&r([i,"End"],l)}s+=i.paddedSize}}function Sf(n,e,t=0){for(const r of n.children)Sf(r,e,t+1);e(n,t)}function bo(n,e,t=0){for(const r of n._children)bo(r,e,t+1);e(n,t)}function Ea(n,e,t=!0){if(e>n.size)throw new w(y.ErrInvalidArgument,`index is out of range: ${e} > ${n.size}`);if(n.isText)return{node:n,offset:e};let r=0,s=0;for(const i of n.children){if(t&&i.isText&&i.size>=e-s)return Ea(i,e-s,t);if(e===s)return{node:n,offset:r};if(!t&&i.paddedSize===e-s)return{node:n,offset:r+1};if(i.paddedSize>e-s)return Ea(i,e-s-1,t);s+=i.paddedSize,r+=1}return{node:n,offset:r}}function xf(n){return n.isText||n.children.length===0?n:xf(n.children[0])}function ip(n,e){if(n.sizen===e?0:n0)if(t.right)t.right.parent=t,t=t.right;else return t;else if(r<0)if(t.left)t.left.parent=t,t=t.left;else{let s=t.parent,i=t;for(;s&&i===s.left;)i=s,s=s.parent;return s}else return t}}lastEntry(){if(!this.root)return this.root;let e=this.root;for(;e.right;)e=e.right;return e}size(){return this.counter}isEmpty(){return this.counter===0}getInternal(e,t){for(;t;){const r=this.comparator(e,t.key);if(r===0)return t;r<0?t=t.left:r>0&&(t=t.right)}}putInternal(e,t,r){if(!r)return this.counter+=1,new cp(e,t,!0);const s=this.comparator(e,r.key);return s<0?r.left=this.putInternal(e,t,r.left):s>0?r.right=this.putInternal(e,t,r.right):r.value=t,this.isRed(r.right)&&!this.isRed(r.left)&&(r=this.rotateLeft(r)),this.isRed(r.left)&&this.isRed(r.left.left)&&(r=this.rotateRight(r)),this.isRed(r.left)&&this.isRed(r.right)&&this.flipColors(r),r}removeInternal(e,t){if(this.comparator(t,e.key)<0)!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeInternal(e.left,t);else{if(this.isRed(e.left)&&(e=this.rotateRight(e)),this.comparator(t,e.key)===0&&!e.right){this.counter-=1;return}if(!this.isRed(e.right)&&!this.isRed(e.right.left)&&(e=this.moveRedRight(e)),this.comparator(t,e.key)===0){this.counter-=1;const r=this.min(e.right);e.value=r.value,e.key=r.key,e.right=this.removeMin(e.right)}else e.right=this.removeInternal(e.right,t)}return this.fixUp(e)}min(e){return e.left?this.min(e.left):e}removeMin(e){if(e.left)return!this.isRed(e.left)&&!this.isRed(e.left.left)&&(e=this.moveRedLeft(e)),e.left=this.removeMin(e.left),this.fixUp(e)}fixUp(e){return this.isRed(e.right)&&(e=this.rotateLeft(e)),this.isRed(e.left)&&this.isRed(e.left.left)&&(e=this.rotateRight(e)),this.isRed(e.left)&&this.isRed(e.right)&&this.flipColors(e),e}moveRedLeft(e){return this.flipColors(e),this.isRed(e.right.left)&&(e.right=this.rotateRight(e.right),e=this.rotateLeft(e),this.flipColors(e)),e}moveRedRight(e){return this.flipColors(e),this.isRed(e.left.left)&&(e=this.rotateRight(e),this.flipColors(e)),e}isRed(e){return e&&e.isRed}rotateLeft(e){const t=e.right;return e.right=t.left,t.left=e,t.isRed=t.left.isRed,t.left.isRed=!0,t}rotateRight(e){const t=e.left;return e.left=t.right,t.right=e,t.isRed=t.right.isRed,t.right.isRed=!0,t}flipColors(e){e.isRed=!e.isRed,e.left.isRed=!e.left.isRed,e.right.isRed=!e.right.isRed}}class vt{constructor(e,t){c(this,"parentID");c(this,"leftSiblingID");this.parentID=e,this.leftSiblingID=t}static of(e,t){return new vt(e,t)}static fromTreePos(e){const{offset:t}=e;let{node:r}=e,s;return r.isText?(r.parent.children[0]===r&&t===0?s=r.parent:s=r,r=r.parent):t===0?s=r:s=r.children[t-1],vt.of(r.id,xe.of(s.getCreatedAt(),s.getOffset()+t))}getParentID(){return this.parentID}static fromStruct(e){return vt.of(xe.of(ct.fromStruct(e.parentID.createdAt),e.parentID.offset),xe.of(ct.fromStruct(e.leftSiblingID.createdAt),e.leftSiblingID.offset))}toStruct(){return{parentID:{createdAt:this.getParentID().getCreatedAt().toStruct(),offset:this.getParentID().getOffset()},leftSiblingID:{createdAt:this.getLeftSiblingID().getCreatedAt().toStruct(),offset:this.getLeftSiblingID().getOffset()}}}toTreeNodePair(e){const t=this.getParentID(),r=this.getLeftSiblingID(),s=e.findFloorNode(t);let i=e.findFloorNode(r);if(!s||!i)throw new w(y.ErrRefused,`cannot find node of CRDTTreePos(${t.toTestString()}, ${r.toTestString()})`);return!r.equals(t)&&r.getOffset()>0&&r.getOffset()===i.id.getOffset()&&i.insPrevID&&(i=e.findFloorNode(i.insPrevID)),[s,i]}getLeftSiblingID(){return this.leftSiblingID}equals(e){return this.getParentID().getCreatedAt().equals(e.getParentID().getCreatedAt())&&this.getParentID().getOffset()===e.getParentID().getOffset()&&this.getLeftSiblingID().getCreatedAt().equals(e.getLeftSiblingID().getCreatedAt())&&this.getLeftSiblingID().getOffset()===e.getLeftSiblingID().getOffset()}}class xe{constructor(e,t){c(this,"createdAt");c(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new xe(e,t)}static fromStruct(e){return xe.of(ct.fromStruct(e.createdAt),e.offset)}static createComparator(){return(e,t)=>{const r=e.getCreatedAt().compare(t.getCreatedAt());return r!==0?r:e.getOffset()>t.getOffset()?1:e.getOffset(){const i=s.deepcopy();return i.parent=t,i}),t.insPrevID=this.insPrevID,t.insNextID=this.insNextID,t}get value(){if(!this.isText)throw new w(y.ErrInvalidType,`cannot get value of element node: ${this.type}`);return this._value}set value(t){if(!this.isText)throw new w(y.ErrInvalidType,`cannot set value of element node: ${this.type}`);this._value=t,this.size=t.length}get isRemoved(){return!!this.removedAt}remove(t){const r=!this.removedAt;(!this.removedAt||this.removedAt.compare(t)>0)&&(this.removedAt=t),r&&this.updateAncestorsSize()}cloneText(t){return new je(xe.of(this.id.getCreatedAt(),t),this.type,void 0,void 0,this.removedAt)}cloneElement(t){return new je(xe.of(t(),0),this.type,void 0,void 0,this.removedAt)}split(t,r,s){const i=this.isText?this.splitText(r,this.id.getOffset()):this.splitElement(r,s);if(i){if(i.insPrevID=this.id,this.insNextID){const o=t.findFloorNode(this.insNextID);o.insPrevID=i.id,i.insNextID=this.insNextID}this.insNextID=i.id,t.registerNode(i)}return i}getCreatedAt(){return this.id.getCreatedAt()}getOffset(){return this.id.getOffset()}canDelete(t,r,s){return(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||t.after(this.removedAt))}canStyle(t,r,s){return this.isText?!1:(r?!this.getCreatedAt().after(r):this.getCreatedAt().getLamport()<=s)&&(!this.removedAt||t.after(this.removedAt))}setAttrs(t,r){this.attrs||(this.attrs=new sr);const s=[];for(const[i,o]of Object.entries(t))s.push(this.attrs.set(i,o,r));return s}purge(t){this.attrs&&this.attrs.purge(t)}getGCPairs(){const t=[];if(!this.attrs)return t;for(const r of this.attrs)r.getRemovedAt()&&t.push({parent:this,child:r});return t}}function Ca(n){var t;if(n.isText){const r=n;return{type:r.type,value:r.value}}const e={type:n.type,children:n.children.map(Ca)};return n.attrs&&(e.attributes=ss((t=n.attrs)==null?void 0:t.toObject())),e}function ic(n){if(n.isText)return n.value;let e="";return n.attrs&&n.attrs.size()&&(e=" "+Array.from(n.attrs).filter(t=>!t.isRemoved()).sort((t,r)=>t.getKey().localeCompare(r.getKey())).map(t=>{const r=JSON.parse(t.getValue());return typeof r=="string"?`${t.getKey()}="${r}"`:`${t.getKey()}="${Ut(t.getValue())}"`}).join(" ")),`<${n.type}${e}>${n.children.map(t=>ic(t)).join("")}`}function Ef(n){if(n.isText){const e=n;return{type:e.type,value:e.value,size:e.size,isRemoved:e.isRemoved}}return{type:n.type,children:n.children.map(Ef),size:n.size,isRemoved:n.isRemoved}}class lt extends Xs{constructor(t,r){super(r);c(this,"indexTree");c(this,"nodeMapByID");this.indexTree=new op(t),this.nodeMapByID=new kf(xe.createComparator()),this.indexTree.traverseAll(s=>{this.nodeMapByID.put(s.id,s)})}static create(t,r){return new lt(t,r)}findFloorNode(t){const r=this.nodeMapByID.floorEntry(t);if(!(!r||!r.key.getCreatedAt().equals(t.getCreatedAt())))return r.value}registerNode(t){this.nodeMapByID.put(t.id,t)}findNodesAndSplitText(t,r){const[s,i]=t.toTreeNodePair(this);let o=i;const a=s===o,u=o.parent&&!a?o.parent:s;if(o.isText&&o.split(this,t.getLeftSiblingID().getOffset()-o.id.getOffset()),r){const l=u.allChildren,h=a?0:l.indexOf(o)+1;for(let d=h;d{const D=I.getCreatedAt().getActorID();let L,$=0n;if(o===void 0&&i===void 0?$=Ds:o.size()>0?$=o.get(D)?o.get(D):0n:L=i.has(D)?i.get(D):bt,I.canStyle(s,L,$)&&r){const V=p.get(D),U=I.getCreatedAt();(!V||U.after(V))&&p.set(D,U);const W=I.setAttrs(r,s),ee=W.reduce((Ee,[,Ie])=>(Ie&&(Ee[Ie.getKey()]=v[Ie.getKey()]),Ee),{}),oe=I.parent,te=I.prevSibling||I.parent;Object.keys(ee).length>0&&d.push({type:"style",from:this.toIndex(oe,te),to:this.toIndex(I,I),fromPath:this.toPath(oe,te),toPath:this.toPath(I,I),actor:s.getActorID(),value:ee});for(const[Ee]of W)Ee&&A.push({parent:I,child:Ee})}}),[p,A,d]}removeStyle(t,r,s,i,o){const[a,u]=this.findNodesAndSplitText(t[0],s),[l,h]=this.findNodesAndSplitText(t[1],s),d=[],v=new Map,p=[];return this.traverseInPosRange(a,u,l,h,([A])=>{const I=A.getCreatedAt().getActorID();let D,L=0n;if(o===void 0&&i===void 0?L=Ds:o.size()>0?L=o.get(I)?o.get(I):0n:D=i.has(I)?i.get(I):bt,A.canStyle(s,D,L)&&r){const $=v.get(I),V=A.getCreatedAt();(!$||V.after($))&&v.set(I,V),A.attrs||(A.attrs=new sr);for(const ee of r){const oe=A.attrs.remove(ee,s);for(const te of oe)p.push({parent:A,child:te})}const U=A.parent,W=A.prevSibling||A.parent;d.push({actor:s.getActorID(),type:"removeStyle",from:this.toIndex(U,W),to:this.toIndex(A,A),fromPath:this.toPath(U,W),toPath:this.toPath(A,A),value:r})}}),[v,p,d]}edit(t,r,s,i,o,a,u){const[l,h]=this.findNodesAndSplitText(t[0],i),[d,v]=this.findNodesAndSplitText(t[1],i),p=this.toIndex(l,h),A=this.toPath(l,h),I=[],D=[],L=[],$=new Map;this.traverseInPosRange(l,h,d,v,([W,ee],oe)=>{if(ee===be.Start&&!oe)for(const Ge of W.children)L.push(Ge);const te=W.getCreatedAt().getActorID();let Ee,Ie=0n;if(u===void 0&&a===void 0?Ie=Ds:u.size()>0?Ie=u.get(te)?u.get(te):0n:Ee=a.has(te)?a.get(te):bt,W.canDelete(i,Ee,Ie)||I.includes(W.parent)){const Ge=$.get(te),Ir=W.getCreatedAt();(!Ge||Ir.after(Ge))&&$.set(te,Ir),(ee===be.Text||ee===be.Start)&&I.push(W),D.push([W,ee])}});const V=this.makeDeletionChanges(D,i),U=[];for(const W of I)W.remove(i),W.isRemoved&&U.push({parent:this,child:W});for(const W of L)W.removedAt||l.append(W);if(s>0){let W=0,ee=l,oe=h;for(;W{l.isRemoved&&(te.remove(i),U.push({parent:this,child:te})),this.nodeMapByID.put(te.id,te)}),oe.isRemoved||W.push(oe);if(W.length){const oe=W.map(te=>Ca(te));V.length&&V[V.length-1].from===p?V[V.length-1].value=oe:V.push({type:"content",from:p,to:p,fromPath:A,toPath:A,actor:i.getActorID(),value:oe})}}return[V,U,$]}editT(t,r,s,i,o){const a=this.findPos(t[0]),u=this.findPos(t[1]);this.edit([a,u],r,s,i,o)}move(t,r,s){throw new w(y.ErrUnimplemented,`not implemented: ${t}, ${r}, ${s}`)}purge(t){var i;(i=t.parent)==null||i.removeChild(t),this.nodeMapByID.remove(t.id);const r=t.insPrevID,s=t.insNextID;if(r){const o=this.findFloorNode(r);o.insNextID=s}if(s){const o=this.findFloorNode(s);o.insPrevID=r}t.insPrevID=void 0,t.insNextID=void 0}getGCPairs(){const t=[];return this.indexTree.traverse(r=>{r.getRemovedAt()&&t.push({parent:this,child:r});for(const s of r.getGCPairs())t.push(s)}),t}findPos(t,r=!0){const s=this.indexTree.findTreePos(t,r);return vt.fromTreePos(s)}pathToPosRange(t){const r=this.pathToIndex(t);return[this.findPos(r),this.findPos(r+1)]}pathToPos(t){const r=this.indexTree.pathToIndex(t);return this.findPos(r)}getRoot(){return this.indexTree.getRoot()}getSize(){return this.indexTree.size}getNodeSize(){return this.nodeMapByID.size()}getIndexTree(){return this.indexTree}toXML(){return ic(this.indexTree.getRoot())}toJSON(){return JSON.stringify(this.getRootTreeNode())}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:JSON.parse(this.toJSON()),type:"YORKIE_TREE"}}toJSInfoForTest(){const t=this.indexTree.getRoot(),r=(s,i=void 0,o=void 0,a=0)=>{var p,A,I,D;let u,l,h;const d=s.isText?{node:s,offset:0}:i&&o?this.toTreePos(i,o):null;d&&(u=this.indexTree.indexOf(d),l=this.indexTree.treePosToPath(d),h=vt.fromTreePos(d).toStruct());const v={type:s.type,parent:i==null?void 0:i.id.toTestString(),size:s.size,id:s.id.toTestString(),removedAt:(p=s.removedAt)==null?void 0:p.toTestString(),insPrev:(A=s.insPrevID)==null?void 0:A.toTestString(),insNext:(I=s.insNextID)==null?void 0:I.toTestString(),value:s.isText?s.value:void 0,isRemoved:s.isRemoved,children:[],depth:a,attributes:s.attrs?ss((D=s.attrs)==null?void 0:D.toObject()):void 0,index:u,path:l,pos:h};for(let L=0;L0&&L===s[s.length-1].to?(s[s.length-1].to=$,s[s.length-1].toPath=this.toPath(D,p)):s.push({type:"content",from:L,to:$,fromPath:this.toPath(I,d),toPath:this.toPath(D,p),actor:r.getActorID()}))}return s.reverse()}findRightToken([t,r]){if(r===be.Start){const u=t.allChildren;return u.length>0?[u[0],u[0].isText?be.Text:be.Start]:[t,be.End]}const s=t.parent,i=s.allChildren,o=i.indexOf(t);if(s&&o===i.length-1)return[s,be.End];const a=i[o+1];return[a,a.isText?be.Text:be.Start]}findLeftToken([t,r]){if(r===be.End){const u=t.allChildren;if(u.length>0){const l=u[u.length-1];return[l,l.isText?be.Text:be.End]}return[t,be.Start]}const s=t.parent,i=s.allChildren,o=i.indexOf(t);if(s&&o===0)return[s,be.Start];const a=i[o-1];return[a,a.isText?be.Text:be.End]}}class ti extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"contents");c(this,"splitLevel");c(this,"maxCreatedAtMapByActor");this.fromPos=r,this.toPos=s,this.contents=i,this.splitLevel=o,this.maxCreatedAtMapByActor=a}static create(t,r,s,i,o,a,u){return new ti(t,r,s,i,o,a,u)}execute(t,r,s){var h;const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof lt))throw new w(y.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=this.getExecutedAt(),a=i,[u,l]=a.edit([this.fromPos,this.toPos],(h=this.contents)==null?void 0:h.map(d=>d.deepcopy()),this.splitLevel,o,(()=>{let d=o.getDelimiter();return this.contents!==void 0&&(d+=this.contents.length),()=>ct.of(o.getLamport(),++d,o.getActorID())})(),this.maxCreatedAtMapByActor,s);for(const d of l)t.registerGCPair(d);return{opInfos:u.map(({from:d,to:v,value:p,splitLevel:A,fromPath:I,toPath:D})=>({type:"tree-edit",path:t.createPath(this.getParentCreatedAt()),from:d,to:v,value:p,splitLevel:A,fromPath:I,toPath:D}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`,i=this.contents||[];return`${t}.EDIT(${r},${s},${i.map(o=>ic(o)).join("")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getContents(){return this.contents}getSplitLevel(){return this.splitLevel}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}class is{constructor(e){c(this,"vector");this.vector=e||new Map}set(e,t){this.vector.set(e,t)}unset(e){this.vector.delete(e)}get(e){return this.vector.get(e)}maxLamport(){let e=BigInt(0);for(const[,t]of this)t>e&&(e=t);return e}max(e){const t=new Map;for(const[r,s]of e){const i=this.vector.get(r),o=i&&i>s?i:s;t.set(r,o)}for(const[r,s]of this){const i=e.get(r),o=i&&i>s?i:s;t.set(r,o)}return new is(t)}afterOrEqual(e){const t=this.vector.get(e.getActorID());return t===void 0?!1:t>=e.getLamport()}deepcopy(){const e=new Map;for(const[t,r]of this.vector)e.set(t,r);return new is(e)}filter(e){const t=new Map;for(const[r]of e){const s=this.vector.get(r);s!==void 0&&t.set(r,s)}return new is(t)}size(){return this.vector.size}*[Symbol.iterator](){for(const[e,t]of this.vector)yield[e,t]}}const lp=new is(new Map);class _n{constructor(e,t,r,s,i){c(this,"clientSeq");c(this,"serverSeq");c(this,"lamport");c(this,"actor");c(this,"versionVector");this.clientSeq=e,this.serverSeq=i,this.lamport=t,this.versionVector=s,this.actor=r}static of(e,t,r,s,i){return new _n(e,t,r,s,i)}next(){const e=this.versionVector.deepcopy();return e.set(this.actor,this.lamport+1n),new _n(this.clientSeq+1,this.lamport+1n,this.actor,e)}syncClocks(e){const t=e.lamport>this.lamport?e.lamport+1n:this.lamport+1n;let r=e.versionVector;r.size()===0&&(r=r.deepcopy(),r.set(e.actor,e.lamport));const s=this.versionVector.max(r),i=new _n(this.clientSeq,t,this.actor,s);return i.versionVector.set(this.actor,t),i}setClocks(e,t){const r=e>this.lamport?e+1n:this.lamport+1n;t.unset(wo);const s=this.versionVector.max(t);return s.set(this.actor,r),_n.of(this.clientSeq,r,this.actor,s)}createTimeTicket(e){return ct.of(this.lamport,e,this.actor)}setActor(e){return new _n(this.clientSeq,this.lamport,e,this.versionVector,this.serverSeq)}setVersionVector(e){return new _n(this.clientSeq,this.lamport,this.actor,e,this.serverSeq)}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq?this.serverSeq.toString():""}getLamport(){return this.lamport}getLamportAsString(){return this.lamport.toString()}getActorID(){return this.actor}getVersionVector(){return this.versionVector}toTestString(){return`${this.lamport.toString()}:${this.actor.slice(-2)}:${this.clientSeq}`}}const fp=new _n(0,0n,wo,lp);class ms{constructor({id:e,operations:t,presenceChange:r,message:s}){c(this,"id");c(this,"operations");c(this,"presenceChange");c(this,"message");this.id=e,this.operations=t||[],this.presenceChange=r,this.message=s}static create({id:e,operations:t,presenceChange:r,message:s}){return new ms({id:e,operations:t,presenceChange:r,message:s})}getID(){return this.id}getMessage(){return this.message}hasOperations(){return this.operations.length>0}getOperations(){return this.operations}setActor(e){for(const t of this.operations)t.setActor(e);this.id=this.id.setActor(e)}hasPresenceChange(){return this.presenceChange!==void 0}getPresenceChange(){return this.presenceChange}execute(e,t,r){const s=[],i=[];for(const o of this.operations){const a=o.execute(e,r,this.id.getVersionVector());if(!a)continue;const{opInfos:u,reverseOp:l}=a;s.push(...u),l&&i.unshift(l)}return this.presenceChange&&(this.presenceChange.type===Tr.Put?t.set(this.id.getActorID(),dt(this.presenceChange.presence)):t.delete(this.id.getActorID())),{opInfos:s,reverseOps:i}}toTestString(){return`${this.operations.map(e=>e.toTestString()).join(",")}`}toStruct(){return{changeID:ye.bytesToHex(ye.toChangeID(this.getID()).toBinary()),message:this.getMessage(),operations:this.getOperations().map(e=>ye.bytesToHex(ye.toOperation(e).toBinary())),presenceChange:this.getPresenceChange()}}static fromStruct(e){const{changeID:t,operations:r,presenceChange:s,message:i}=e;return ms.create({id:ye.bytesToChangeID(ye.hexToBytes(t)),operations:r==null?void 0:r.map(o=>ye.bytesToOperation(ye.hexToBytes(o))),presenceChange:s,message:i})}}class To{constructor(e,t,r,s,i,o,a){c(this,"documentKey");c(this,"checkpoint");c(this,"isRemoved");c(this,"changes");c(this,"snapshot");c(this,"minSyncedTicket");c(this,"versionVector");this.documentKey=e,this.checkpoint=t,this.isRemoved=r,this.changes=s,this.snapshot=o,this.minSyncedTicket=a,this.versionVector=i}static create(e,t,r,s,i,o,a){return new To(e,t,r,s,i,o,a)}getDocumentKey(){return this.documentKey}getCheckpoint(){return this.checkpoint}getIsRemoved(){return this.isRemoved}getChanges(){return this.changes}hasChanges(){return this.changes.length>0}getChangeSize(){return this.changes.length}hasSnapshot(){return!!this.snapshot&&!!this.snapshot.length}getSnapshot(){return this.snapshot}getMinSyncedTicket(){return this.minSyncedTicket}getVersionVector(){return this.versionVector}}class os{constructor(e,t){c(this,"serverSeq");c(this,"clientSeq");this.serverSeq=e,this.clientSeq=t}static of(e,t){return new os(e,t)}increaseClientSeq(e){return e===0?this:new os(this.serverSeq,this.clientSeq+e)}forward(e){if(this.equals(e))return this;const t=this.serverSeq>e.serverSeq?this.serverSeq:e.serverSeq,r=Math.max(this.clientSeq,e.clientSeq);return os.of(t,r)}getServerSeqAsString(){return this.serverSeq.toString()}getClientSeq(){return this.clientSeq}getServerSeq(){return this.serverSeq}equals(e){return this.clientSeq===e.clientSeq&&this.serverSeq==e.serverSeq}toTestString(){return`serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`}}const hp=new os(0n,0);class zt{constructor(e,t){c(this,"createdAt");c(this,"offset");this.createdAt=e,this.offset=t}static of(e,t){return new zt(e,t)}static fromStruct(e){return zt.of(ct.fromStruct(e.createdAt),e.offset)}getCreatedAt(){return this.createdAt}getOffset(){return this.offset}equals(e){return this.createdAt.compare(e.createdAt)===0&&this.offset===e.offset}hasSameCreatedAt(e){return this.createdAt.compare(e.createdAt)===0}split(e){return new zt(this.createdAt,this.offset+e)}toStruct(){return{createdAt:this.createdAt.toStruct(),offset:this.offset}}toTestString(){return`${this.createdAt.toTestString()}:${this.offset}`}toIDString(){return`${this.createdAt.toIDString()}:${this.offset}`}}const dp=zt.of(bt,0);class Tt{constructor(e,t){c(this,"id");c(this,"relativeOffset");this.id=e,this.relativeOffset=t}static of(e,t){return new Tt(e,t)}static fromStruct(e){const t=zt.fromStruct(e.id);return Tt.of(t,e.relativeOffset)}getID(){return this.id}getRelativeOffset(){return this.relativeOffset}getAbsoluteID(){return zt.of(this.id.getCreatedAt(),this.id.getOffset()+this.relativeOffset)}toTestString(){return`${this.id.toTestString()}:${this.relativeOffset}`}toStruct(){return{id:this.id.toStruct(),relativeOffset:this.relativeOffset}}equals(e){return this.id.equals(e.id)?this.relativeOffset===e.relativeOffset:!1}}class vr extends vf{constructor(t,r,s){super(r);c(this,"id");c(this,"removedAt");c(this,"prev");c(this,"next");c(this,"insPrev");c(this,"insNext");this.id=t,this.removedAt=s}static create(t,r){return new vr(t,r)}static createComparator(){return(t,r)=>{const s=t.getCreatedAt().compare(r.getCreatedAt());return s!==0?s:t.getOffset()>r.getOffset()?1:t.getOffset()0&&t.getID().getOffset()==e.getOffset()){if(!t.hasInsPrev())return t;t=t.getInsPrev()}return t}findFloorNode(e){const t=this.treeByID.floorEntry(e);if(t&&!(!t.key.equals(e)&&!t.key.hasSameCreatedAt(e)))return t.value}findBetween(e,t){const r=[];let s=e;for(;s&&s!==t;)r.push(s),s=s.getNext();return r}splitNode(e,t){if(t>e.getContentLength())throw new w(y.ErrInvalidArgument,"offset should be less than or equal to length");if(t===0)return e;if(t===e.getContentLength())return e.getNext();const r=e.split(t);this.treeByIndex.updateWeight(r),this.insertAfter(e,r);const s=e.getInsNext();return s&&s.setInsPrev(r),r.setInsPrev(e),r}deleteNodes(e,t,r,s){if(!e.length)return[[],new Map,new Map];const[i,o]=this.filterNodes(e,t,r,s),a=new Map,u=new Map,l=this.makeChanges(o,t);for(const h of i){const d=h.getCreatedAt().getActorID();(!a.has(d)||h.getID().getCreatedAt().after(a.get(d)))&&a.set(d,h.getID().getCreatedAt()),u.set(h.getID().toIDString(),h),h.remove(t)}return this.deleteIndexNodes(o),[l,a,u]}filterNodes(e,t,r,s){const i=[],o=[],[a,u]=this.findEdgesOfCandidates(e);o.push(a);for(const l of e){const h=l.getCreatedAt().getActorID();let d,v=0n;s===void 0&&r===void 0?v=Ds:s.size()>0?v=s.get(h)?s.get(h):0n:d=r.has(h)?r.get(h):bt,l.canDelete(t,d,v)?i.push(l):o.push(l)}return o.push(u),[i,o]}findEdgesOfCandidates(e){return[e[0].getPrev(),e[e.length-1].getNext()]}makeChanges(e,t){const r=[];let s,i;for(let o=0;on<0?Math.ceil(n):Math.floor(n);var Kt=(n=>(n[n.IntegerCnt=0]="IntegerCnt",n[n.LongCnt=1]="LongCnt",n))(Kt||{});class He extends Xs{constructor(t,r,s){super(s);c(this,"valueType");c(this,"value");switch(this.valueType=t,t){case 0:typeof r=="number"?r>Math.pow(2,31)-1||r<-Math.pow(2,31)?this.value=X.fromNumber(r).toInt():this.value=Vu(r):this.value=r.toInt();break;case 1:typeof r=="number"?this.value=X.fromNumber(r):this.value=r;break;default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}static create(t,r,s){return new He(t,r,s)}static valueFromBytes(t,r){switch(t){case 0:return r[0]|r[1]<<8|r[2]<<16|r[3]<<24;case 1:return X.fromBytesLE(Array.from(r));default:throw new w(y.ErrUnimplemented,`unimplemented type: ${t}`)}}toJSON(){return`${this.value}`}toSortedJSON(){return this.toJSON()}toJSForTest(){return{createdAt:this.getCreatedAt().toTestString(),value:this.value,type:"YORKIE_COUNTER"}}deepcopy(){const t=He.create(this.valueType,this.value,this.getCreatedAt());return t.setMovedAt(this.getMovedAt()),t}getType(){return this.valueType}static getCounterType(t){switch(typeof t){case"object":return t instanceof X?1:void 0;case"number":return t>Math.pow(2,31)-1||t<-Math.pow(2,31)?1:0;default:return}}static isSupport(t){return!!He.getCounterType(t)}static isInteger(t){return t%1===0}isNumericType(){const t=this.valueType;return t===0||t===1}getValueType(){return this.valueType}getValue(){return this.value}toBytes(){switch(this.valueType){case 0:{const t=this.value;return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}case 1:{const r=this.value.toBytesLE();return Uint8Array.from(r)}default:throw new w(y.ErrUnimplemented,`unimplemented type: ${this.valueType}`)}}increase(t){function r(s){if(!s.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof s.getValue()}`)}return r(this),r(t),this.valueType===1?this.value=this.value.add(t.getValue()):t.getType()===Te.Long?this.value=this.value+t.getValue().toInt():this.value=X.fromNumber(this.value+Vu(t.getValue())).toInt(),this}}class ys extends At{constructor(t,r,s){super(t,s);c(this,"value");this.value=r}static create(t,r,s){return new ys(t,r,s)}execute(t){const r=t.findByCreatedAt(this.getParentCreatedAt());if(!r)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(r instanceof He))throw new w(y.ErrInvalidArgument,"fail to execute, only Counter can execute increase");const s=r,i=this.value.deepcopy();return s.increase(i),{opInfos:[{type:"increase",path:t.createPath(this.getParentCreatedAt()),value:i.getValue()}],reverseOp:this.toReverseOperation()}}toReverseOperation(){const t=this.value.deepcopy(),s=t.getType()===Te.Long?t.getValue().multiply(-1):t.getValue()*-1;return ys.create(this.getParentCreatedAt(),he.of(s,t.getCreatedAt()))}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){return`${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`}getValue(){return this.value}}class tr extends At{constructor(t,r,s,i,o,a,u){super(t,u);c(this,"fromPos");c(this,"toPos");c(this,"maxCreatedAtMapByActor");c(this,"attributes");c(this,"attributesToRemove");this.fromPos=r,this.toPos=s,this.maxCreatedAtMapByActor=i,this.attributes=o,this.attributesToRemove=a}static create(t,r,s,i,o,a){return new tr(t,r,s,i,o,[],a)}static createTreeRemoveStyleOperation(t,r,s,i,o,a){return new tr(t,r,s,i,new Map,o,a)}execute(t,r,s){const i=t.findByCreatedAt(this.getParentCreatedAt());if(!i)throw new w(y.ErrInvalidArgument,`fail to find ${this.getParentCreatedAt()}`);if(!(i instanceof lt))throw new w(y.ErrInvalidArgument,"fail to execute, only Tree can execute edit");const o=i;let a,u;if(this.attributes.size){const l={};[...this.attributes].forEach(([h,d])=>l[h]=d),[,u,a]=o.style([this.fromPos,this.toPos],l,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}else{const l=this.attributesToRemove;[,u,a]=o.removeStyle([this.fromPos,this.toPos],l,this.getExecutedAt(),this.maxCreatedAtMapByActor,s)}for(const l of u)t.registerGCPair(l);return{opInfos:a.map(({from:l,to:h,value:d,fromPath:v,toPath:p})=>({type:"tree-style",from:l,to:h,value:this.attributes.size?{attributes:d}:{attributesToRemove:d},fromPath:v,toPath:p,path:t.createPath(this.getParentCreatedAt())}))}}getEffectedCreatedAt(){return this.getParentCreatedAt()}toTestString(){const t=this.getParentCreatedAt().toTestString(),r=`${this.fromPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`,s=`${this.toPos.getLeftSiblingID().getCreatedAt().toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;return`${t}.STYLE(${r},${s},${Object.entries(this.attributes||{}).map(([i,o])=>`${i}:"${o}"`).join(" ")})`}getFromPos(){return this.fromPos}getToPos(){return this.toPos}getAttributes(){return this.attributes}getAttributesToRemove(){return this.attributesToRemove}getMaxCreatedAtMapByActor(){return this.maxCreatedAtMapByActor}}function gp(n){const e=new nc,t=e.data;for(const[r,s]of Object.entries(n))t[r]=JSON.stringify(s);return e}function mp(n){if(n.type===Tr.Put)return new Vs({type:qr.PUT,presence:gp(n.presence)});if(n.type===Tr.Clear)return new Vs({type:qr.CLEAR});throw new w(y.ErrUnimplemented,"unimplemented type")}function pp(n){return new mf({serverSeq:n.getServerSeq(),clientSeq:n.getClientSeq()})}function Cf(n){return new yo({clientSeq:n.getClientSeq(),lamport:n.getLamport(),actorId:pc(n.getActorID()),versionVector:oc(n.getVersionVector())})}function J(n){if(n)return new F({lamport:n.getLamport(),delimiter:n.getDelimiter(),actorId:pc(n.getActorID())})}function oc(n){if(!n)return;const e=new vo;for(const[t,r]of n)e.vector[t]=BigInt(r.toString());return e}function Nf(n){switch(n){case Te.Null:return G.NULL;case Te.Boolean:return G.BOOLEAN;case Te.Integer:return G.INTEGER;case Te.Long:return G.LONG;case Te.Double:return G.DOUBLE;case Te.String:return G.STRING;case Te.Bytes:return G.BYTES;case Te.Date:return G.DATE;default:throw new w(y.ErrInvalidType,`unsupported type: ${n}`)}}function Pf(n){switch(n){case Kt.IntegerCnt:return G.INTEGER_CNT;case Kt.LongCnt:return G.LONG_CNT;default:throw new w(y.ErrInvalidType,`unsupported type: ${n}`)}}function Mo(n){if(n instanceof Ue)return new Ye({type:G.JSON_OBJECT,createdAt:J(n.getCreatedAt()),value:Kf(n)});if(n instanceof We)return new Ye({type:G.JSON_ARRAY,createdAt:J(n.getCreatedAt()),value:Hp(n)});if(n instanceof ut)return new Ye({type:G.TEXT,createdAt:J(n.getCreatedAt())});if(n instanceof he)return new Ye({type:Nf(n.getType()),createdAt:J(n.getCreatedAt()),value:n.toBytes()});if(n instanceof He)return new Ye({type:Pf(n.getType()),createdAt:J(n.getCreatedAt()),value:n.toBytes()});if(n instanceof lt)return new Ye({type:G.TREE,createdAt:J(n.getCreatedAt()),value:_p(n)});throw new w(y.ErrUnimplemented,"unimplemented element")}function yp(n){return new zs({createdAt:J(n.getCreatedAt()),offset:n.getOffset()})}function di(n){return new rr({createdAt:J(n.getID().getCreatedAt()),offset:n.getID().getOffset(),relativeOffset:n.getRelativeOffset()})}function gi(n){return new Ur({parentId:Bs(n.getParentID()),leftSiblingId:Bs(n.getLeftSiblingID())})}function Bs(n){return new pr({createdAt:J(n.getCreatedAt()),offset:n.getOffset()})}function Of(n){const e=new tc;if(n instanceof zr){const t=n,r=new Ji;r.parentCreatedAt=J(t.getParentCreatedAt()),r.key=t.getKey(),r.value=Mo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="set",e.body.value=r}else if(n instanceof Zs){const t=n,r=new Mi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.prevCreatedAt=J(t.getPrevCreatedAt()),r.value=Mo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="add",e.body.value=r}else if(n instanceof dr){const t=n,r=new $i;r.parentCreatedAt=J(t.getParentCreatedAt()),r.prevCreatedAt=J(t.getPrevCreatedAt()),r.createdAt=J(t.getCreatedAt()),r.executedAt=J(t.getExecutedAt()),e.body.case="move",e.body.value=r}else if(n instanceof Ar){const t=n,r=new Ui;r.parentCreatedAt=J(t.getParentCreatedAt()),r.createdAt=J(t.getCreatedAt()),r.executedAt=J(t.getExecutedAt()),e.body.case="remove",e.body.value=r}else if(n instanceof Qs){const t=n,r=new qi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=di(t.getFromPos()),r.to=di(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);r.content=t.getContent();const i=r.attributes;for(const[o,a]of t.getAttributes())i[o]=a;r.executedAt=J(t.getExecutedAt()),e.body.case="edit",e.body.value=r}else if(n instanceof ei){const t=n,r=new zi;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=di(t.getFromPos()),r.to=di(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);const i=r.attributes;for(const[o,a]of t.getAttributes())i[o]=a;r.executedAt=J(t.getExecutedAt()),e.body.case="style",e.body.value=r}else if(n instanceof ys){const t=n,r=new Ki;r.parentCreatedAt=J(t.getParentCreatedAt()),r.value=Mo(t.getValue()),r.executedAt=J(t.getExecutedAt()),e.body.case="increase",e.body.value=r}else if(n instanceof ti){const t=n,r=new Vi,s=r.createdAtMapByActor;for(const[i,o]of t.getMaxCreatedAtMapByActor())s[i]=J(o);r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=gi(t.getFromPos()),r.to=gi(t.getToPos()),r.contents=Sp(t.getContents()),r.splitLevel=t.getSplitLevel(),r.executedAt=J(t.getExecutedAt()),e.body.case="treeEdit",e.body.value=r}else if(n instanceof tr){const t=n,r=new ji;r.parentCreatedAt=J(t.getParentCreatedAt()),r.from=gi(t.getFromPos()),r.to=gi(t.getToPos());const s=r.createdAtMapByActor;for(const[o,a]of t.getMaxCreatedAtMapByActor())s[o]=J(a);const i=t.getAttributesToRemove();if(i.length>0)r.attributesToRemove=i;else{const o=r.attributes;for(const[a,u]of t.getAttributes())o[a]=u}r.executedAt=J(t.getExecutedAt()),e.body.case="treeStyle",e.body.value=r}else throw new w(y.ErrUnimplemented,"unimplemented operation");return e}function vp(n){const e=[];for(const t of n)e.push(Of(t));return e}function wp(n){const e=new df({id:Cf(n.getID()),message:n.getMessage()});return n.hasOperations()&&(e.operations=vp(n.getOperations())),n.hasPresenceChange()&&(e.presenceChange=mp(n.getPresenceChange())),e}function bp(n){const e=[];for(const t of n)e.push(wp(t));return e}function Tp(n){const e=[];for(const t of n)e.push(new gf({key:t.getStrKey(),element:cc(t.getValue())}));return e}function Ap(n){const e=[];for(const t of n)e.push(new Zi({element:cc(t.getValue())}));return e}function Ip(n){const e=[];for(const t of n){const r=new Qi;r.id=yp(t.getID()),r.value=t.getValue().getContent(),r.removedAt=J(t.getRemovedAt());const s=r.attributes,i=t.getValue().getAttrs();for(const o of i){const a=new hs;a.value=o.getValue(),a.updatedAt=J(o.getUpdatedAt()),s[o.getKey()]=a}e.push(r)}return e}function Sp(n){const e=[];if(!n||!n.length)return e;for(const t of n)e.push(new eo({content:ac(t)}));return e}function xp(n){const e={};for(const t of n)e[t.getKey()]=new hs({value:t.getValue(),updatedAt:J(t.getUpdatedAt()),isRemoved:t.isRemoved()});return e}function ac(n){if(!n)return[];const e=[];return bo(n,(t,r)=>{const s=new Ks({id:Bs(t.id),type:t.type,removedAt:J(t.removedAt),depth:r});t.isText&&(s.value=t.value),t.insPrevID&&(s.insPrevId=Bs(t.insPrevID)),t.insNextID&&(s.insNextId=Bs(t.insNextID)),t.attrs&&(s.attributes=xp(t.attrs)),e.push(s)}),e}function kp(n){const e=new ze;return e.body.case="jsonObject",e.body.value=new Wi({nodes:Tp(n.getRHT()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Df(n){const e=new ze;return e.body.case="jsonArray",e.body.value=new Hi({nodes:Ap(n.getElements()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Ep(n){const e=new ze;return e.body.case="primitive",e.body.value=new Gi({type:Nf(n.getType()),value:n.toBytes(),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Cp(n){const e=new ze;return e.body.case="text",e.body.value=new _i({nodes:Ip(n.getRGATreeSplit()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Np(n){const e=new ze;return e.body.case="counter",e.body.value=new Yi({type:Pf(n.getType()),value:n.toBytes(),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function Bf(n){const e=new ze;return e.body.case="tree",e.body.value=new Xi({nodes:ac(n.getRoot()),createdAt:J(n.getCreatedAt()),movedAt:J(n.getMovedAt()),removedAt:J(n.getRemovedAt())}),e}function cc(n){if(n instanceof Ue)return kp(n);if(n instanceof We)return Df(n);if(n instanceof he)return Ep(n);if(n instanceof ut)return Cp(n);if(n instanceof He)return Np(n);if(n instanceof lt)return Bf(n);throw new w(y.ErrUnimplemented,"unimplemented element")}function Pp(n){return new or({documentKey:n.getDocumentKey(),checkpoint:pp(n.getCheckpoint()),isRemoved:n.getIsRemoved(),changes:bp(n.getChanges()),snapshot:n.getSnapshot(),versionVector:oc(n.getVersionVector()),minSyncedTicket:J(n.getMinSyncedTicket())})}function Es(n){if(!(n instanceof le))return{};const e=n.findDetails(_m);for(const t of e)return t.metadata;return{}}function Gr(n){return Es(n).code??""}function Rf(n){return _n.of(n.clientSeq,BigInt(n.lamport),gc(n.actorId),uc(n.versionVector),BigInt(n.serverSeq))}function uc(n){if(!n)return;const e=new is;return Object.entries(n.vector).forEach(([t,r])=>{e.set(t,BigInt(r.toString()))}),e}function M(n){if(n)return ct.of(BigInt(n.lamport),n.delimiter,gc(n.actorId))}function lc(n){const e={};return Object.entries(n.data).forEach(([t,r])=>{e[t]=JSON.parse(r)}),e}function Op(n){const e=n.type;if(e===qr.PUT){const t=lc(n.presence);return{type:Tr.Put,presence:t}}if(e===qr.CLEAR)return{type:Tr.Clear};throw new w(y.ErrInvalidType,`unsupported type: ${e}`)}function Dp(n){const e=new Map;return Object.entries(n).forEach(([t,r])=>{e.set(t,lc(r))}),e}function Ff(n){switch(n){case G.NULL:return Te.Null;case G.BOOLEAN:return Te.Boolean;case G.INTEGER:return Te.Integer;case G.LONG:return Te.Long;case G.DOUBLE:return Te.Double;case G.STRING:return Te.String;case G.BYTES:return Te.Bytes;case G.DATE:return Te.Date}throw new w(y.ErrUnimplemented,`unimplemented value type: ${n}`)}function ro(n){switch(n){case G.INTEGER_CNT:return Kt.IntegerCnt;case G.LONG_CNT:return Kt.LongCnt}throw new w(y.ErrUnimplemented,`unimplemented value type: ${n}`)}function $o(n){switch(n.type){case G.JSON_OBJECT:return n.value?zf(n.value):Ue.create(M(n.createdAt));case G.JSON_ARRAY:return n.value?Wp(n.value):We.create(M(n.createdAt));case G.TEXT:return ut.create(ps.create(),M(n.createdAt));case G.TREE:return Gp(n.value);case G.NULL:case G.BOOLEAN:case G.INTEGER:case G.LONG:case G.DOUBLE:case G.STRING:case G.BYTES:case G.DATE:return he.of(he.valueFromBytes(Ff(n.type),n.value),M(n.createdAt));case G.INTEGER_CNT:case G.LONG_CNT:return He.create(ro(n.type),He.valueFromBytes(ro(n.type),n.value),M(n.createdAt))}}function mi(n){return Tt.of(zt.of(M(n.createdAt),n.offset),n.relativeOffset)}function Lf(n){return zt.of(M(n.createdAt),n.offset)}function Bp(n){const e=Gs.create(n.value);Object.entries(n.attributes).forEach(([r,s])=>{e.setAttr(r,s.value,M(s.updatedAt))});const t=vr.create(Lf(n.id),e);return t.remove(M(n.removedAt)),t}function _r(n){return vt.of(Rs(n.parentId),Rs(n.leftSiblingId))}function Rs(n){return xe.of(M(n.createdAt),n.offset)}function Rp(n){if(!n.length)return;const e=[];return n.forEach(t=>{const r=fc(t.content);e.push(r)}),e}function fc(n){if(n.length===0)return;const e=[];for(const s of n)e.push(Lp(s));const t=e[e.length-1],r=new Map;r.set(n[e.length-1].depth,e[e.length-1]);for(let s=e.length-2;s>=0;s--)r.get(n[s].depth-1).prepend(e[s]),r.set(n[s].depth,e[s]);return t.updateDescendantsSize(),lt.create(t,bt).getRoot()}function Fp(n){const e=sr.create();for(const[t,r]of Object.entries(n))e.setInternal(t,r.value,M(r.updatedAt),r.isRemoved);return e}function Lp(n){const e=Rs(n.id),t=je.create(e,n.type),r=Object.entries(n.attributes);return t.isText?t.value=n.value:r.length&&(t.attrs=Fp(n.attributes)),n.insPrevId&&(t.insPrevID=Rs(n.insPrevId)),n.insNextId&&(t.insNextID=Rs(n.insNextId)),t.removedAt=M(n.removedAt),t}function Jf(n){if(n.body.case==="set"){const e=n.body.value;return zr.create(e.key,$o(e.value),M(e.parentCreatedAt),M(e.executedAt))}else if(n.body.case==="add"){const e=n.body.value;return Zs.create(M(e.parentCreatedAt),M(e.prevCreatedAt),$o(e.value),M(e.executedAt))}else if(n.body.case==="move"){const e=n.body.value;return dr.create(M(e.parentCreatedAt),M(e.prevCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="remove"){const e=n.body.value;return Ar.create(M(e.parentCreatedAt),M(e.createdAt),M(e.executedAt))}else if(n.body.case==="edit"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([s,i])=>{t.set(s,M(i))});const r=new Map;return Object.entries(e.attributes).forEach(([s,i])=>{r.set(s,i)}),Qs.create(M(e.parentCreatedAt),mi(e.from),mi(e.to),t,e.content,r,M(e.executedAt))}else if(n.body.case==="style"){const e=n.body.value,t=new Map;Object.entries(e.createdAtMapByActor).forEach(([s,i])=>{t.set(s,M(i))});const r=new Map;return Object.entries(e.attributes).forEach(([s,i])=>{r.set(s,i)}),ei.create(M(e.parentCreatedAt),mi(e.from),mi(e.to),t,r,M(e.executedAt))}else{if(n.body.case==="select")return;if(n.body.case==="increase"){const e=n.body.value;return ys.create(M(e.parentCreatedAt),$o(e.value),M(e.executedAt))}else if(n.body.case==="treeEdit"){const e=n.body.value,t=new Map;return Object.entries(e.createdAtMapByActor).forEach(([r,s])=>{t.set(r,M(s))}),ti.create(M(e.parentCreatedAt),_r(e.from),_r(e.to),Rp(e.contents),e.splitLevel,t,M(e.executedAt))}else if(n.body.case==="treeStyle"){const e=n.body.value,t=new Map,r=e.attributesToRemove,s=new Map;return e!=null&&e.createdAtMapByActor&&Object.entries(e.createdAtMapByActor).forEach(([i,o])=>{s.set(i,M(o))}),(r==null?void 0:r.length)>0?tr.createTreeRemoveStyleOperation(M(e.parentCreatedAt),_r(e.from),_r(e.to),s,r,M(e.executedAt)):(Object.entries(e.attributes).forEach(([i,o])=>{t.set(i,o)}),tr.create(M(e.parentCreatedAt),_r(e.from),_r(e.to),s,t,M(e.executedAt)))}else throw new w(y.ErrUnimplemented,"unimplemented operation")}}function Jp(n){const e=[];for(const t of n){const r=Jf(t);r&&e.push(r)}return e}function Mf(n){const e=[];for(const t of n)e.push(ms.create({id:Rf(t.id),operations:Jp(t.operations),presenceChange:t.presenceChange?Op(t.presenceChange):void 0,message:t.message}));return e}function Mp(n){return os.of(BigInt(n.serverSeq),n.clientSeq)}function $p(n){return To.create(n.documentKey,Mp(n.checkpoint),n.isRemoved,Mf(n.changes),uc(n.versionVector),n.snapshot,M(n.minSyncedTicket))}function $f(n){const e=new js;for(const r of n.nodes){const s=hc(r.element);e.set(r.key,s,s.getPositionedAt())}const t=new Ue(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Uf(n){const e=new Hs;for(const r of n.nodes)e.insert(hc(r.element));const t=new We(M(n.createdAt),e);return t.setMovedAt(M(n.movedAt)),t.setRemovedAt(M(n.removedAt)),t}function Up(n){const e=he.of(he.valueFromBytes(Ff(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function qp(n){const e=new ps;let t=e.getHead();for(const s of n.nodes){const i=e.insertAfter(t,Bp(s));s.insPrevId&&i.setInsPrev(e.findNode(Lf(s.insPrevId))),t=i}const r=new ut(e,M(n.createdAt));return r.setMovedAt(M(n.movedAt)),r.setRemovedAt(M(n.removedAt)),r}function zp(n){const e=He.create(ro(n.type),He.valueFromBytes(ro(n.type),n.value),M(n.createdAt));return e.setMovedAt(M(n.movedAt)),e.setRemovedAt(M(n.removedAt)),e}function qf(n){const e=fc(n.nodes);return lt.create(e,M(n.createdAt))}function hc(n){if(n.body.case==="jsonObject")return $f(n.body.value);if(n.body.case==="jsonArray")return Uf(n.body.value);if(n.body.case==="primitive")return Up(n.body.value);if(n.body.case==="text")return qp(n.body.value);if(n.body.case==="counter")return zp(n.body.value);if(n.body.case==="tree")return qf(n.body.value);throw new w(y.ErrUnimplemented,"unimplemented element")}function Kp(n){if(!n)return{root:Ue.create(bt),presences:new Map};const e=ra.fromBinary(n);return{root:hc(e.root),presences:Dp(e.presences)}}function Vp(n){const e=oc(n);return dc(e.toBinary())}function jp(n){const e=mc(n),t=vo.fromBinary(e);return uc(t)}function zf(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return $f(e.body.value)}function Kf(n){return cc(n).toBinary()}function Wp(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return Uf(e.body.value)}function Hp(n){return Df(n).toBinary()}function Gp(n){if(!n)throw new w(y.ErrInvalidArgument,"bytes is empty");const e=ze.fromBinary(n);return qf(e.body.value)}function _p(n){return Bf(n).toBinary()}function dc(n){return n?Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""):""}function gc(n){return dc(n)}function mc(n){return new Uint8Array(n.match(/.{1,2}/g).map(e=>parseInt(e,16)))}function pc(n){return mc(n)}function Yp(n){const e=yo.fromBinary(n);return Rf(e)}function Xp(n){const e=tc.fromBinary(n);return Jf(e)}const ye={fromPresence:lc,toChangePack:Pp,fromChangePack:$p,fromChanges:Mf,toTreeNodes:ac,fromTreeNodes:fc,objectToBytes:Kf,bytesToObject:zf,bytesToSnapshot:Kp,bytesToHex:dc,hexToBytes:mc,toHexString:gc,toUint8Array:pc,toOperation:Of,toChangeID:Cf,PbChangeID:yo,bytesToChangeID:Yp,bytesToOperation:Xp,versionVectorToHex:Vp,hexToVersionVector:jp};var Le=(n=>(n[n.Trivial=0]="Trivial",n[n.Debug=1]="Debug",n[n.Info=2]="Info",n[n.Warn=3]="Warn",n[n.Error=4]="Error",n[n.Fatal=5]="Fatal",n))(Le||{});let Cr=3;function Vf(n){Cr=n}const K={trivial:(...n)=>{Cr>0||typeof console<"u"&&console.log("YORKIE T:",...n)},debug:(...n)=>{Cr>1||typeof console<"u"&&console.log("YORKIE D:",...n)},info:(...n)=>{Cr>2||typeof console<"u"&&console.log("YORKIE I:",...n)},warn:(...n)=>{Cr>3||typeof console<"u"&&(typeof console.warn<"u"?console.warn("YORKIE W:",...n):console.log("YORKIE W:",...n))},error:(...n)=>{Cr>4||typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE E:",...n):console.log("YORKIE E:",...n))},fatal:(...n)=>{typeof console<"u"&&(typeof console.error<"u"?console.error("YORKIE F:",...n):console.log("YORKIE F:",...n))},isEnabled:n=>Cr<=n};function jf(){return"xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}class Zp{constructor(e,t,r,s,i){c(this,"reconnectStreamDelay");c(this,"doc");c(this,"docID");c(this,"syncMode");c(this,"remoteChangeEventReceived");c(this,"watchStream");c(this,"watchLoopTimerID");c(this,"watchAbortController");c(this,"unsubscribeBroadcastEvent");this.reconnectStreamDelay=e,this.doc=t,this.docID=r,this.syncMode=s,this.remoteChangeEventReceived=!1,this.unsubscribeBroadcastEvent=i}changeSyncMode(e){this.syncMode=e}needRealtimeSync(){return this.syncMode===Ni.RealtimeSyncOff?!1:this.syncMode===Ni.RealtimePushOnly?this.doc.hasLocalChanges():this.syncMode!==Ni.Manual&&(this.doc.hasLocalChanges()||this.remoteChangeEventReceived)}async runWatchLoop(e){const t=async()=>{if(this.watchStream)return Promise.resolve();this.watchLoopTimerID&&(clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0);try{[this.watchStream,this.watchAbortController]=await e(()=>{this.watchStream=void 0,this.watchAbortController=void 0,this.watchLoopTimerID=setTimeout(t,this.reconnectStreamDelay)})}catch{}};await t()}cancelWatchStream(){this.watchStream&&this.watchAbortController&&(this.watchAbortController.abort(),this.watchStream=void 0,this.watchAbortController=void 0),clearTimeout(this.watchLoopTimerID),this.watchLoopTimerID=void 0}}const Uo=()=>{};class Qp{constructor(e){c(this,"finalized",!1);c(this,"observers",[]);c(this,"finalError");try{e(this)}catch(t){this.error(t)}}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(!e)throw new w(y.ErrInvalidArgument,"missing observer");if(this.finalized)throw new w(y.ErrRefused,"observable is finalized due to previous error");typeof e=="object"?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=Uo),s.error===void 0&&(s.error=Uo),s.complete===void 0&&(s.complete=Uo);const i=jf(),o=this.unsubscribeOne.bind(this,i);if(this.observers.push({subscriptionID:i,observer:s}),this.finalized)try{this.finalError?s.error(this.finalError):s.complete()}catch(a){K.warn(a)}return o}unsubscribeOne(e){var t;this.observers=(t=this.observers)==null?void 0:t.filter(r=>r.subscriptionID!==e)}forEachObserver(e){if(!this.finalized)for(let t=0;te}}class Qr{constructor(e,t,r,s){c(this,"id");c(this,"delimiter");c(this,"message");c(this,"root");c(this,"operations");c(this,"presenceChange");c(this,"previousPresence");c(this,"reversePresenceKeys");this.id=e,this.delimiter=yf,this.root=t,this.operations=[],this.previousPresence=dt(r),this.presenceChange=void 0,this.reversePresenceKeys=new Set,this.message=s}static create(e,t,r,s){return new Qr(e,t,r,s)}push(e){this.operations.push(e)}registerElement(e,t){this.root.registerElement(e,t)}registerRemovedElement(e){this.root.registerRemovedElement(e)}registerGCPair(e){this.root.registerGCPair(e)}getChange(){return ms.create({id:this.id,operations:this.operations,presenceChange:this.presenceChange,message:this.message})}hasChange(){return this.operations.length>0||this.presenceChange!==void 0}setPresenceChange(e){this.presenceChange=e}setReversePresence(e,t){for(const r of Object.keys(e))t!=null&&t.addToHistory?this.reversePresenceKeys.add(r):this.reversePresenceKeys.delete(r)}getReversePresence(){if(this.reversePresenceKeys.size===0)return;const e={};for(const t of this.reversePresenceKeys)e[t]=this.previousPresence[t];return e}issueTimeTicket(){return this.delimiter+=1,this.id.createTimeTicket(this.delimiter)}getLastTimeTicket(){return this.id.createTimeTicket(this.delimiter)}}class _s{constructor(e){c(this,"rootObject");c(this,"elementPairMapByCreatedAt");c(this,"gcElementSetByCreatedAt");c(this,"gcPairMap");this.rootObject=e,this.elementPairMapByCreatedAt=new Map,this.gcElementSetByCreatedAt=new Set,this.gcPairMap=new Map,this.registerElement(e,void 0),e.getDescendants(t=>{if(t.getRemovedAt()&&this.registerRemovedElement(t),t instanceof ut||t instanceof lt)for(const r of t.getGCPairs())this.registerGCPair(r);return!1})}static create(){return new _s(Ue.create(bt))}findByCreatedAt(e){const t=this.elementPairMapByCreatedAt.get(e.toIDString());if(t)return t.element}findElementPairByCreatedAt(e){return this.elementPairMapByCreatedAt.get(e.toIDString())}createSubPaths(e){let t=this.elementPairMapByCreatedAt.get(e.toIDString());if(!t)return[];const r=[];for(;t.parent;){const s=t.element.getCreatedAt(),i=t.parent.subPathOf(s);if(i===void 0)throw new w(y.ErrInvalidArgument,`cant find the given element: ${s.toIDString()}`);r.unshift(i),t=this.elementPairMapByCreatedAt.get(t.parent.getCreatedAt().toIDString())}return r.unshift("$"),r}createPath(e){return this.createSubPaths(e).join(".")}registerElement(e,t){this.elementPairMapByCreatedAt.set(e.getCreatedAt().toIDString(),{parent:t,element:e}),e instanceof yr&&e.getDescendants((r,s)=>(this.registerElement(r,s),!1))}deregisterElement(e){let t=0;const r=s=>{const i=s.getCreatedAt().toIDString();this.elementPairMapByCreatedAt.delete(i),this.gcElementSetByCreatedAt.delete(i),t++};return r(e),e instanceof yr&&e.getDescendants(s=>(r(s),!1)),t}registerRemovedElement(e){this.gcElementSetByCreatedAt.add(e.getCreatedAt().toIDString())}registerGCPair(e){if(this.gcPairMap.get(e.child.toIDString())){this.gcPairMap.delete(e.child.toIDString());return}this.gcPairMap.set(e.child.toIDString(),e)}getElementMapSize(){return this.elementPairMapByCreatedAt.size}getGarbageElementSetSize(){const e=new Set;for(const t of this.gcElementSetByCreatedAt){e.add(t);const r=this.elementPairMapByCreatedAt.get(t);r.element instanceof yr&&r.element.getDescendants(s=>(e.add(s.getCreatedAt().toIDString()),!1))}return e.size}getObject(){return this.rootObject}getGarbageLen(){return this.getGarbageElementSetSize()+this.gcPairMap.size}deepcopy(){return new _s(this.rootObject.deepcopy())}garbageCollect(e){let t=0;for(const r of this.gcElementSetByCreatedAt){const s=this.elementPairMapByCreatedAt.get(r),i=s.element.getRemovedAt();i&&(e!=null&&e.afterOrEqual(i))&&(s.parent.purge(s.element),t+=this.deregisterElement(s.element))}for(const[,r]of this.gcPairMap){const s=r.child.getRemovedAt();s&&(e!=null&&e.afterOrEqual(s))&&(r.parent.purge(r.child),this.gcPairMap.delete(r.child.toIDString()),t+=1)}return t}toJSON(){return this.rootObject.toJSON()}toSortedJSON(){return this.rootObject.toSortedJSON()}getStats(){return{elements:this.getElementMapSize(),gcPairs:this.gcPairMap.size,gcElements:this.getGarbageElementSetSize()}}}function Wf(n,e){const t=new Ys(n);return new Proxy(e,t.getHandlers())}class Ys{constructor(e){c(this,"context");c(this,"handlers");this.context=e,this.handlers={set:(t,r,s)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]=${JSON.stringify(s)}`),Ys.setInternal(e,t,r,s),!0),get:(t,r)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]`),r==="getID"?()=>t.getCreatedAt():r==="toJSON"||r==="toString"?()=>t.toJSON():r==="toJS"?()=>t.toJS():r==="toJSForTest"?()=>t.toJSForTest():Nr(e,t.get(r))),ownKeys:t=>t.getKeys(),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),deleteProperty:(t,r)=>(K.isEnabled(Le.Trivial)&&K.trivial(`obj[${r}]`),Ys.deleteInternal(e,t,r),!0)}}static setInternal(e,t,r,s){if(r.includes("."))throw new w(y.ErrInvalidObjectKey,"key must not contain the '.'.");const i=e.issueTimeTicket(),o=so(e,s,i),a=t.set(r,o,i);e.registerElement(o,t),a&&e.registerRemovedElement(a),e.push(zr.create(r,o.deepcopy(),t.getCreatedAt(),i))}static buildObjectMembers(e,t){const r={};for(const[s,i]of Object.entries(t)){if(s.includes("."))throw new w(y.ErrInvalidObjectKey,"key must not contain the '.'.");const o=e.issueTimeTicket(),a=so(e,i,o);r[s]=a}return r}static deleteInternal(e,t,r){const s=e.issueTimeTicket(),i=t.deleteByKey(r,s);i&&(e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i))}getHandlers(){return this.handlers}}function ty(n,e){const t=new me(n,e);return new Proxy(e,t.getHandlers())}function ny(n){return typeof n=="string"||n instanceof String?!isNaN(n):!1}function ry(n){return["concat","entries","every","filter","find","findIndex","forEach","join","keys","map","reduce","reduceRight","slice","some","toLocaleString","toString","values"].includes(n)}class me{constructor(e,t){c(this,"context");c(this,"handlers");c(this,"array");this.context=e,this.array=t,this.handlers={get:(r,s,i)=>s==="getID"?()=>r.getCreatedAt():s==="getElementByID"?o=>{const a=r.getByID(o);if(!(!a||a.isRemoved()))return lr(e,a)}:s==="getElementByIndex"?o=>{const a=r.get(o);return lr(e,a)}:s==="getLast"?()=>lr(e,r.getLast()):s==="deleteByID"?o=>{const a=me.deleteInternalByID(e,r,o);return lr(e,a)}:s==="insertAfter"?(o,a)=>{const u=me.insertAfterInternal(e,r,o,a);return lr(e,u)}:s==="insertBefore"?(o,a)=>{const u=me.insertBeforeInternal(e,r,o,a);return lr(e,u)}:s==="moveBefore"?(o,a)=>{me.moveBeforeInternal(e,r,o,a)}:s==="moveAfter"?(o,a)=>{me.moveAfterInternal(e,r,o,a)}:s==="moveFront"?o=>{me.moveFrontInternal(e,r,o)}:s==="moveLast"?o=>{me.moveLastInternal(e,r,o)}:ny(s)?Nr(e,r.get(Number(s))):s==="push"?o=>me.pushInternal(e,r,o):s==="splice"?(o,a,...u)=>me.splice(e,r,o,a,...u):s==="length"?r.length:typeof s=="symbol"&&s===Symbol.iterator?me.iteratorInternal.bind(this,e,r):s==="includes"?(o,a)=>me.includes(e,r,o,a):s==="indexOf"?(o,a)=>me.indexOf(e,r,o,a):s==="lastIndexOf"?(o,a)=>me.lastIndexOf(e,r,o,a):s==="toJSForTest"?()=>r.toJSForTest():s==="toTestString"?()=>me.toTestString(r):typeof s=="string"&&ry(s)?(...o)=>{const a=Array.from(r).map(u=>Nr(e,u));return Array.prototype[s].apply(a,o)}:Reflect.get(r,s,i),deleteProperty:(r,s)=>(K.isEnabled(Le.Trivial)&&K.trivial(`array[${s}]`),me.deleteInternalByIndex(e,r,Number.parseInt(s)),!0)}}static*iteratorInternal(e,t){for(const r of t)yield lr(e,r)}static buildArrayElements(e,t){const r=[];for(const s of t){const i=e.issueTimeTicket(),o=so(e,s,i);r.push(o)}return r}static pushInternal(e,t,r){return me.insertAfterInternal(e,t,t.getLastCreatedAt(),r),t.length}static moveBeforeInternal(e,t,r,s){const i=e.issueTimeTicket(),o=t.getPrevCreatedAt(r);t.moveAfter(o,s,i),e.push(dr.create(t.getCreatedAt(),o,s,i))}static moveAfterInternal(e,t,r,s){const i=e.issueTimeTicket();t.moveAfter(r,s,i),e.push(dr.create(t.getCreatedAt(),r,s,i))}static moveFrontInternal(e,t,r){const s=e.issueTimeTicket(),i=t.getHead();t.moveAfter(i.getCreatedAt(),r,s),e.push(dr.create(t.getCreatedAt(),i.getCreatedAt(),r,s))}static moveLastInternal(e,t,r){const s=e.issueTimeTicket(),i=t.getLastCreatedAt();t.moveAfter(i,r,s),e.push(dr.create(t.getCreatedAt(),i,r,s))}static insertAfterInternal(e,t,r,s){const i=e.issueTimeTicket(),o=so(e,s,i);return t.insertAfter(r,o),e.registerElement(o,t),e.push(Zs.create(t.getCreatedAt(),r,o.deepcopy(),i)),o}static insertBeforeInternal(e,t,r,s){return me.insertAfterInternal(e,t,t.getPrevCreatedAt(r),s)}static deleteInternalByIndex(e,t,r){const s=e.issueTimeTicket(),i=t.deleteByIndex(r,s);if(i)return e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i),i}static deleteInternalByID(e,t,r){const s=e.issueTimeTicket(),i=t.delete(r,s);return e.push(Ar.create(t.getCreatedAt(),i.getCreatedAt(),s)),e.registerRemovedElement(i),i}static splice(e,t,r,s,...i){const o=t.length,a=r>=0?Math.min(r,o):Math.max(o+r,0),u=s===void 0?o:s<0?a:Math.min(a+s,o),l=[];for(let h=a;h=i)return!1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).includes(r,o);for(let u=o;u=i)return-1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).indexOf(r,o);for(let u=o;u=i?i-1:s<0?s+i:s;if(o<0)return-1;if(he.isSupport(r))return Array.from(t).map(l=>Nr(e,l)).lastIndexOf(r,o);for(let u=o;u>0;u--)if(((a=t.get(u))==null?void 0:a.getID())===r.getID())return u;return-1}static toTestString(e){return e.toTestString()}getHandlers(){return this.handlers}}class Ao{constructor(e,t){c(this,"context");c(this,"text");this.context=e,this.text=t}initialize(e,t){this.context=e,this.text=t}getID(){return this.text.getID()}edit(e,t,r,s){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.text.indexRangeToPosRange(e,t);K.isEnabled(Le.Debug)&&K.debug(`EDIT: f:${e}->${i[0].toTestString()}, t:${t}->${i[1].toTestString()} c:${r}`);const o=s?ds(s):void 0,a=this.context.issueTimeTicket(),[u,,l,h]=this.text.edit(i,r,a,o);for(const d of l)this.context.registerGCPair(d);return this.context.push(new Qs(this.text.getCreatedAt(),i[0],i[1],u,r,o?new Map(Object.entries(o)):new Map,a)),this.text.findIndexesFromRange(h)}delete(e,t){return this.edit(e,t,"")}empty(){return this.edit(0,this.length,"")}setStyle(e,t,r){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.text.indexRangeToPosRange(e,t);K.isEnabled(Le.Debug)&&K.debug(`STYL: f:${e}->${s[0].toTestString()}, t:${t}->${s[1].toTestString()} a:${JSON.stringify(r)}`);const i=ds(r),o=this.context.issueTimeTicket(),[a,u]=this.text.setStyle(s,i,o);for(const l of u)this.context.registerGCPair(l);return this.context.push(new ei(this.text.getCreatedAt(),s[0],s[1],a,new Map(Object.entries(i)),o)),!0}indexRangeToPosRange(e){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");const t=this.text.indexRangeToPosRange(e[0],e[1]);return[t[0].toStruct(),t[1].toStruct()]}posRangeToIndexRange(e){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");const t=this.text.findIndexesFromRange([Tt.fromStruct(e[0]),Tt.fromStruct(e[1])]);return[t[0],t[1]]}toTestString(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toTestString()}values(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.values()}get length(){return this.text.length}getTreeByIndex(){return this.text.getTreeByIndex()}getTreeByID(){return this.text.getTreeByID()}toString(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toString()}toJSON(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSON()}toJSForTest(){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.toJSForTest()}createRangeForTest(e,t){if(!this.context||!this.text)throw new w(y.ErrNotInitialized,"Text is not initialized yet");return this.text.indexRangeToPosRange(e,t)}}class Io{constructor(e,t){c(this,"valueType");c(this,"value");c(this,"context");c(this,"counter");this.valueType=e,this.value=t}initialize(e,t){this.valueType=t.getValueType(),this.context=e,this.counter=t,this.value=t.getValue()}getID(){return this.counter.getID()}getValue(){return this.value}getValueType(){return this.valueType}increase(e){if(!this.context||!this.counter)throw new w(y.ErrNotInitialized,"Counter is not initialized yet");const t=this.context.issueTimeTicket(),r=he.of(e,t);if(!r.isNumericType())throw new TypeError(`Unsupported type of value: ${typeof r.getValue()}`);return this.counter.increase(r),this.context.push(ys.create(this.counter.getCreatedAt(),r,t)),this}toJSForTest(){if(!this.context||!this.counter)throw new w(y.ErrNotInitialized,"Counter is not initialized yet");return this.counter.toJSForTest()}}function yc(n,e,t){const{type:r}=n,s=t.issueTimeTicket();if(r===er){Hf(n);const{value:i}=n,o=je.create(xe.of(s,0),r,i);e.append(o)}else{const{children:i=[]}=n,{attributes:o}=n;let a;if(typeof o=="object"&&!pf(o)){const l=ds(o);a=new sr;for(const[h,d]of Object.entries(l))a.set(h,d,s)}const u=je.create(xe.of(s,0),r,void 0,a);e.append(u);for(const l of i)yc(l,u,t)}}function sy(n,e){const{type:t}=e,r=n.issueTimeTicket();let s;if(e.type===er){const{value:i}=e;s=je.create(xe.of(r,0),t,i)}else if(e){const{children:i=[]}=e,{attributes:o}=e;let a;if(typeof o=="object"&&!pf(o)){const u=ds(o);a=new sr;for(const[l,h]of Object.entries(u))a.set(l,h,r)}s=je.create(xe.of(n.issueTimeTicket(),0),t,void 0,a);for(const u of i)yc(u,s,n)}return s}function Hf(n){if(!n.value.length)throw new w(y.ErrInvalidArgument,"text node cannot have empty value");return!0}function ju(n){if(!n.length)return!0;if(n[0].type===er)for(const t of n){const{type:r}=t;if(r!==er)throw new w(y.ErrInvalidArgument,"element node and text node cannot be passed together");Hf(t)}else for(const t of n){const{type:r}=t;if(r===er)throw new w(y.ErrInvalidArgument,"element node and text node cannot be passed together")}return!0}class So{constructor(e){c(this,"initialRoot");c(this,"context");c(this,"tree");this.initialRoot=e}initialize(e,t){this.context=e,this.tree=t}getID(){return this.tree.getID()}buildRoot(e){if(!this.initialRoot)return je.create(xe.of(e.issueTimeTicket(),0),np);const t=je.create(xe.of(e.issueTimeTicket(),0),this.initialRoot.type);for(const r of this.initialRoot.children)yc(r,t,e);return t}getSize(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getSize()}getNodeSize(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getNodeSize()}getIndexTree(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getIndexTree()}styleByPath(e,t){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(!e.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const[r,s]=this.tree.pathToPosRange(e),i=this.context.issueTimeTicket(),o=t?ds(t):void 0,[a]=this.tree.style([r,s],o,i);this.context.push(tr.create(this.tree.getCreatedAt(),r,s,a,o?new Map(Object.entries(o)):new Map,i))}style(e,t,r){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),i=this.tree.findPos(t),o=this.context.issueTimeTicket(),a=r?ds(r):void 0,[u,l]=this.tree.style([s,i],a,o);for(const h of l)this.context.registerGCPair(h);this.context.push(tr.create(this.tree.getCreatedAt(),s,i,u,a?new Map(Object.entries(a)):new Map,o))}removeStyle(e,t,r){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const s=this.tree.findPos(e),i=this.tree.findPos(t),o=this.context.issueTimeTicket(),[a,u]=this.tree.removeStyle([s,i],r,o);for(const l of u)this.context.registerGCPair(l);this.context.push(tr.createTreeRemoveStyleOperation(this.tree.getCreatedAt(),s,i,a,r,o))}editInternal(e,t,r,s=0){var l;if(r.length!==0&&r[0]&&(ju(r),r[0].type!==er))for(const h of r){const{children:d=[]}=h;ju(d)}const i=this.context.getLastTimeTicket();let o=new Array;if(((l=r[0])==null?void 0:l.type)===er){let h="";for(const d of r){const{value:v}=d;h+=v}o.push(je.create(xe.of(this.context.issueTimeTicket(),0),er,h))}else o=r.map(h=>h&&sy(this.context,h)).filter(h=>h);const[,a,u]=this.tree.edit([e,t],o.length?o.map(h=>h==null?void 0:h.deepcopy()):void 0,s,i,()=>this.context.issueTimeTicket());for(const h of a)this.context.registerGCPair(h);return this.context.push(ti.create(this.tree.getCreatedAt(),e,t,o.length?o:void 0,s,u,i)),!0}editByPath(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new w(y.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(i,o,r?[r]:[],s)}editBulkByPath(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e.length!==t.length)throw new w(y.ErrInvalidArgument,"path length should be equal");if(!e.length||!t.length)throw new w(y.ErrInvalidArgument,"path should not be empty");const i=this.tree.pathToPos(e),o=this.tree.pathToPos(t);return this.editInternal(i,o,r,s)}edit(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(i,o,r?[r]:[],s)}editBulk(e,t,r,s=0){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");if(e>t)throw new w(y.ErrInvalidArgument,"from should be less than or equal to to");const i=this.tree.findPos(e),o=this.tree.findPos(t);return this.editInternal(i,o,r,s)}toXML(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toXML()}toJSON(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSON()}toJSForTest(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSForTest()}toJSInfoForTest(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.toJSInfoForTest()}getRootTreeNode(){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.getRootTreeNode()}indexToPath(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexToPath(e)}pathToIndex(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.pathToIndex(e)}pathRangeToPosRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[this.tree.pathToIndex(e[0]),this.tree.pathToIndex(e[1])],r=this.tree.indexRangeToPosRange(t);return[r[0].toStruct(),r[1].toStruct()]}indexRangeToPosRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");return this.tree.indexRangeToPosStructRange(e)}posRangeToIndexRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[vt.fromStruct(e[0]),vt.fromStruct(e[1])];return this.tree.posRangeToIndexRange(t)}posRangeToPathRange(e){if(!this.context||!this.tree)throw new w(y.ErrNotInitialized,"Tree is not initialized yet");const t=[vt.fromStruct(e[0]),vt.fromStruct(e[1])];return this.tree.posRangeToPathRange(t)}}function Wu(n,e){return Wf(n,e)}function lr(n,e){if(e){if(e instanceof he)return e;if(e instanceof Ue)return Wf(n,e);if(e instanceof We)return ty(n,e);if(e instanceof ut)return new Ao(n,e);if(e instanceof He){const t=new Io(Kt.IntegerCnt,0);return t.initialize(n,e),t}else if(e instanceof lt){const t=new So;return t.initialize(n,e),t}}else return;throw new TypeError(`Unsupported type of element: ${typeof e}`)}function Nr(n,e){const t=lr(n,e);return t instanceof he?t.getValue():t}function so(n,e,t){let r;if(he.isSupport(e))r=he.of(e,t);else if(Array.isArray(e))r=We.create(t,me.buildArrayElements(n,e));else if(typeof e=="object")e instanceof Ao?(r=ut.create(ps.create(),t),e.initialize(n,r)):e instanceof Io?(r=He.create(e.getValueType(),e.getValue(),t),e.initialize(n,r)):e instanceof So?(r=lt.create(e.buildRoot(n),t),e.initialize(n,r)):r=Ue.create(t,Ys.buildObjectMembers(n,e));else throw new TypeError(`Unsupported type of value: ${typeof e}`);return r}const Hu=50;class iy{constructor(){c(this,"undoStack",[]);c(this,"redoStack",[])}hasUndo(){return this.undoStack.length>0}hasRedo(){return this.redoStack.length>0}pushUndo(e){this.undoStack.length>=Hu&&this.undoStack.shift(),this.undoStack.push(e)}popUndo(){return this.undoStack.pop()}pushRedo(e){this.redoStack.length>=Hu&&this.redoStack.shift(),this.redoStack.push(e)}popRedo(){return this.redoStack.pop()}clearRedo(){this.redoStack=[]}getUndoStackForTest(){return this.undoStack}getRedoStackForTest(){return this.redoStack}}const oy="yorkie-devtools-panel",ay="yorkie-devtools-sdk";let Xr="disconnected";const Gu=new Map,Ci=new Map;typeof window<"u"&&(window.transactionEventsByDocKey=Ci);function pi(n,e){(e!=null&&e.force||Xr!=="disconnected")&&window.postMessage({source:ay,...n},"*")}function cy(n){if(!n.isEnableDevtools()||typeof window>"u"||Gu.has(n.getKey()))return;Ci.set(n.getKey(),[]);const e=n.subscribe("all",t=>{t.some(r=>r.type!==Se.StatusChanged&&r.type!==Se.Snapshot&&r.type!==Se.LocalChange&&r.type!==Se.RemoteChange&&r.type!==Se.Initialized&&r.type!==Se.Watched&&r.type!==Se.Unwatched&&r.type!==Se.PresenceChanged)||(Ci.get(n.getKey()).push(t),Xr==="synced"&&pi({msg:"doc::sync::partial",docKey:n.getKey(),event:t}))});Gu.set(n.getKey(),[e]),pi({msg:"refresh-devtools"},{force:!0}),window.addEventListener("message",t=>{var s;if(((s=t.data)==null?void 0:s.source)!==oy)return;switch(t.data.msg){case"devtools::connect":if(Xr!=="disconnected")break;Xr="connected",pi({msg:"doc::available",docKey:n.getKey()}),K.info(`[YD] Devtools connected. Doc: ${n.getKey()}`);break;case"devtools::disconnect":Xr="disconnected",K.info(`[YD] Devtools disconnected. Doc: ${n.getKey()}`);break;case"devtools::subscribe":Xr="synced",pi({msg:"doc::sync::full",docKey:n.getKey(),events:Ci.get(n.getKey())}),K.info(`[YD] Devtools subscribed. Doc: ${n.getKey()}`);break}})}var fr=(n=>(n.Detached="detached",n.Attached="attached",n.Removed="removed",n))(fr||{}),Se=(n=>(n.StatusChanged="status-changed",n.ConnectionChanged="connection-changed",n.SyncStatusChanged="sync-status-changed",n.Snapshot="snapshot",n.LocalChange="local-change",n.RemoteChange="remote-change",n.Initialized="initialized",n.Watched="watched",n.Unwatched="unwatched",n.PresenceChanged="presence-changed",n.Broadcast="broadcast",n.LocalBroadcast="local-broadcast",n.AuthError="auth-error",n))(Se||{}),Na=(n=>(n.Connected="connected",n.Disconnected="disconnected",n))(Na||{}),Pa=(n=>(n.Synced="synced",n.SyncFailed="sync-failed",n))(Pa||{});class Gf{constructor(e,t){c(this,"key");c(this,"status");c(this,"opts");c(this,"changeID");c(this,"checkpoint");c(this,"localChanges");c(this,"root");c(this,"clone");c(this,"eventStream");c(this,"eventStreamObserver");c(this,"onlineClients");c(this,"presences");c(this,"history");c(this,"internalHistory");c(this,"isUpdating");this.opts=t||{},this.key=e,this.status="detached",this.root=_s.create(),this.changeID=fp,this.checkpoint=hp,this.localChanges=[],this.eventStream=ey(r=>{this.eventStreamObserver=r}),this.onlineClients=new Set,this.presences=new Map,this.isUpdating=!1,this.internalHistory=new iy,this.history={canUndo:this.canUndo.bind(this),canRedo:this.canRedo.bind(this),undo:this.undo.bind(this),redo:this.redo.bind(this)},cy(this)}update(e,t){if(this.getStatus()==="removed")throw new w(y.ErrDocumentRemoved,`${this.key} is removed`);this.ensureClone();const r=this.changeID.getActorID(),s=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(r)||{},t);try{const i=Wu(s,this.clone.root.getObject());this.presences.has(r)||this.clone.presences.set(r,{}),this.isUpdating=!0,e(i,new Jo(s,this.clone.presences.get(r)))}catch(i){throw this.clone=void 0,i}finally{this.isUpdating=!1}if(s.hasChange()){K.isEnabled(Le.Trivial)&&K.trivial(`trying to update a local change: ${this.toJSON()}`);const i=s.getChange(),{opInfos:o,reverseOps:a}=i.execute(this.root,this.presences,ie.Local),u=s.getReversePresence();u&&a.push({type:"presence",value:u}),this.localChanges.push(i),a.length>0&&this.internalHistory.pushUndo(a),o.length>0&&this.internalHistory.clearRedo(),this.changeID=i.getID();const l=[];o.length>0&&l.push({type:"local-change",source:ie.Local,value:{message:i.getMessage()||"",operations:o,actor:r,clientSeq:i.getID().getClientSeq(),serverSeq:i.getID().getServerSeq()},rawChange:this.isEnableDevtools()?i.toStruct():void 0}),i.hasPresenceChange()&&l.push({type:"presence-changed",source:ie.Local,value:{clientID:r,presence:this.getPresence(r)}}),this.publish(l),K.isEnabled(Le.Trivial)&&K.trivial(`after update a local change: ${this.toJSON()}`)}}subscribe(e,t,r,s){if(typeof e=="string"){if(typeof t!="function")throw new w(y.ErrInvalidArgument,"Second argument must be a callback function");if(e==="presence"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="initialized"&&l.type!=="watched"&&l.type!=="unwatched"&&l.type!=="presence-changed"||a(l)},r,s)}if(e==="my-presence"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="initialized"&&l.type!=="presence-changed"||l.type==="presence-changed"&&l.value.clientID!==this.changeID.getActorID()||a(l)},r,s)}if(e==="others"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="watched"&&l.type!=="unwatched"&&l.type!=="presence-changed"||l.value.clientID!==this.changeID.getActorID()&&a(l)},r,s)}if(e==="connection"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="connection-changed"&&a(l)},r,s)}if(e==="status"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="status-changed"&&a(l)},r,s)}if(e==="sync"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="sync-status-changed"&&a(l)},r,s)}if(e==="local-broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="local-broadcast"&&a(l)},r)}if(e==="broadcast"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="broadcast"&&a(l)},r)}if(e==="auth-error"){const a=t;return this.eventStream.subscribe(u=>{for(const l of u)l.type==="auth-error"&&a(l)},r)}if(e==="all"){const a=t;return this.eventStream.subscribe(a,r,s)}const i=e,o=t;return this.eventStream.subscribe(a=>{for(const u of a){if(u.type!=="local-change"&&u.type!=="remote-change")continue;const l=[];for(const h of u.value.operations)this.isSameElementOrChildOf(h.path,i)&&l.push(h);l.length&&o({...u,value:{...u.value,operations:l}})}},r,s)}if(typeof e=="function"){const i=e,o=t,a=r;return this.eventStream.subscribe(u=>{for(const l of u)l.type!=="snapshot"&&l.type!=="local-change"&&l.type!=="remote-change"||i(l)},o,a)}throw new w(y.ErrInvalidArgument,`"${e}" is not a valid`)}publish(e){this.eventStreamObserver&&this.eventStreamObserver.next(e)}isSameElementOrChildOf(e,t){if(t===e)return!0;const r=e.split(".");return t.split(".").every((i,o)=>i===r[o])}removePushedLocalChanges(e){for(;this.localChanges.length&&!(this.localChanges[0].getID().getClientSeq()>e);)this.localChanges.shift()}applyChangePack(e){const t=e.hasSnapshot();t?this.applySnapshot(e.getCheckpoint().getServerSeq(),e.getVersionVector(),e.getSnapshot(),e.getCheckpoint().getClientSeq()):(this.applyChanges(e.getChanges(),ie.Remote),this.removePushedLocalChanges(e.getCheckpoint().getClientSeq())),this.checkpoint=this.checkpoint.forward(e.getCheckpoint()),t||this.garbageCollect(e.getVersionVector()),e.getIsRemoved()&&this.applyStatus("removed"),K.isEnabled(Le.Trivial)&&K.trivial(`${this.root.toJSON()}`)}getCheckpoint(){return this.checkpoint}getChangeID(){return this.changeID}hasLocalChanges(){return this.localChanges.length>0}ensureClone(){this.clone||(this.clone={root:this.root.deepcopy(),presences:dt(this.presences)})}createChangePack(){const e=Array.from(this.localChanges),t=this.checkpoint.increaseClientSeq(e.length);return To.create(this.key,t,!1,e,this.getVersionVector())}setActor(e){for(const t of this.localChanges)t.setActor(e);this.changeID=this.changeID.setActor(e)}isEnableDevtools(){return!!this.opts.enableDevtools}getKey(){return this.key}getStatus(){return this.status}getCloneRoot(){if(this.clone)return this.clone.root.getObject()}getRoot(){this.ensureClone();const e=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});return Wu(e,this.clone.root.getObject())}garbageCollect(e){return this.opts.disableGC?0:(this.clone&&this.clone.root.garbageCollect(e),this.root.garbageCollect(e))}getRootObject(){return this.root.getObject()}getGarbageLen(){return this.root.getGarbageLen()}getGarbageLenFromClone(){return this.clone.root.getGarbageLen()}toJSON(){return this.root.toJSON()}toSortedJSON(){return this.root.toSortedJSON()}getStats(){return this.root.getStats()}toJSForTest(){return{...this.getRoot().toJSForTest(),key:"root"}}applySnapshot(e,t,r,s=-1){const{root:i,presences:o}=ye.bytesToSnapshot(r);this.root=new _s(i),this.presences=o,this.changeID=this.changeID.setClocks(t.maxLamport(),t),this.clone=void 0,this.removePushedLocalChanges(s),this.applyChanges(this.localChanges,ie.Local),this.publish([{type:"snapshot",source:ie.Remote,value:{serverSeq:e.toString(),snapshot:this.isEnableDevtools()?ye.bytesToHex(r):void 0,snapshotVector:ye.versionVectorToHex(t)}}])}applyChanges(e,t){K.isEnabled(Le.Debug)&&K.debug(`trying to apply ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`),K.isEnabled(Le.Trivial)&&K.trivial(e.map(r=>`${r.getID().toTestString()} ${r.toTestString()}`).join(` +`));for(const r of e)this.applyChange(r,t);K.isEnabled(Le.Debug)&&K.debug(`after appling ${e.length} remote changes.elements:${this.root.getElementMapSize()}, removeds:${this.root.getGarbageElementSetSize()}`)}applyChange(e,t){this.ensureClone(),e.execute(this.clone.root,this.clone.presences,t);const r=[],s=e.getID().getActorID();if(e.hasPresenceChange()&&this.onlineClients.has(s)){const o=e.getPresenceChange();switch(o.type){case Tr.Put:r.push(this.presences.has(s)?{type:"presence-changed",source:t,value:{clientID:s,presence:o.presence}}:{type:"watched",source:ie.Remote,value:{clientID:s,presence:o.presence}});break;case Tr.Clear:r.push({type:"unwatched",source:ie.Remote,value:{clientID:s,presence:this.getPresence(s)}}),this.removeOnlineClient(s);break}}const{opInfos:i}=e.execute(this.root,this.presences,t);if(this.changeID=this.changeID.syncClocks(e.getID()),i.length>0){const o=this.isEnableDevtools()?e.toStruct():void 0;r.push(t===ie.Remote?{type:"remote-change",source:t,value:{actor:s,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:o}:{type:"local-change",source:t,value:{actor:s,clientSeq:e.getID().getClientSeq(),serverSeq:e.getID().getServerSeq(),message:e.getMessage()||"",operations:i},rawChange:o})}r.length>0&&this.publish(r)}applyWatchStream(e){if(e.body.case==="initialization"){const t=e.body.value.clientIds,r=new Set;for(const s of t)s!==this.changeID.getActorID()&&r.add(s);this.setOnlineClients(r),this.publish([{type:"initialized",source:ie.Local,value:this.getPresences()}]);return}if(e.body.case==="event"){const{type:t,publisher:r}=e.body.value,s=[];if(t===$r.DOCUMENT_WATCHED){if(this.onlineClients.has(r)&&this.hasPresence(r))return;this.addOnlineClient(r),this.hasPresence(r)&&s.push({type:"watched",source:ie.Remote,value:{clientID:r,presence:this.getPresence(r)}})}else if(t===$r.DOCUMENT_UNWATCHED){const i=this.getPresence(r);this.removeOnlineClient(r),i&&s.push({type:"unwatched",source:ie.Remote,value:{clientID:r,presence:i}})}else if(t===$r.DOCUMENT_BROADCAST&&e.body.value.body){const{topic:i,payload:o}=e.body.value.body,a=new TextDecoder;s.push({type:"broadcast",value:{clientID:r,topic:i,payload:JSON.parse(a.decode(o))}})}s.length>0&&this.publish(s)}}applyStatus(e){this.status=e,e==="detached"&&this.setActor(wo),this.publish([{source:e==="removed"?ie.Remote:ie.Local,type:"status-changed",value:e==="attached"?{status:e,actorID:this.changeID.getActorID()}:{status:e}}])}applyDocEvent(e){if(e.type==="status-changed"){this.applyStatus(e.value.status),e.value.status==="attached"&&this.setActor(e.value.actorID);return}if(e.type==="snapshot"){const{snapshot:t,serverSeq:r,snapshotVector:s}=e.value;if(!t)return;this.applySnapshot(BigInt(r),ye.hexToVersionVector(s),ye.hexToBytes(t));return}if(e.type==="local-change"||e.type==="remote-change"){if(!e.rawChange)return;const t=ms.fromStruct(e.rawChange);this.applyChange(t,e.source)}if(e.type==="initialized"){const t=new Set;for(const{clientID:r,presence:s}of e.value)t.add(r),this.presences.set(r,s);this.setOnlineClients(t);return}if(e.type==="watched"){const{clientID:t,presence:r}=e.value;this.addOnlineClient(t),this.presences.set(t,r);return}if(e.type==="unwatched"){const{clientID:t}=e.value;this.removeOnlineClient(t),this.presences.delete(t)}if(e.type==="presence-changed"){const{clientID:t,presence:r}=e.value;this.presences.set(t,r)}}applyTransactionEvent(e){for(const t of e)this.applyDocEvent(t)}getValueByPath(e){if(!e.startsWith("$"))throw new w(y.ErrInvalidArgument,'path must start with "$"');const t=e.split(".");t.shift();let r=this.getRoot();for(const s of t)if(r=r[s],r===void 0)return;return r}setOnlineClients(e){this.onlineClients=e}resetOnlineClients(){this.onlineClients=new Set}addOnlineClient(e){this.onlineClients.add(e)}removeOnlineClient(e){this.onlineClients.delete(e)}hasPresence(e){return this.presences.has(e)}getMyPresence(){if(this.status!=="attached")return{};const e=this.presences.get(this.changeID.getActorID());return e?dt(e):{}}getPresence(e){if(e===this.changeID.getActorID())return this.getMyPresence();if(!this.onlineClients.has(e))return;const t=this.presences.get(e);return t?dt(t):void 0}getPresenceForTest(e){const t=this.presences.get(e);return t?dt(t):void 0}getPresences(){const e=[];e.push({clientID:this.changeID.getActorID(),presence:dt(this.getMyPresence())});for(const t of this.onlineClients)this.presences.has(t)&&e.push({clientID:t,presence:dt(this.presences.get(t))});return e}getSelfForTest(){return{clientID:this.getChangeID().getActorID(),presence:this.getMyPresence()}}getOthersForTest(){const e=this.getChangeID().getActorID();return this.getPresences().filter(t=>t.clientID!==e).sort((t,r)=>t.clientID>r.clientID?1:-1)}canUndo(){return this.internalHistory.hasUndo()&&!this.isUpdating}filterVersionVector(e){const r=this.changeID.getVersionVector().filter(e);this.changeID=this.changeID.setVersionVector(r)}canRedo(){return this.internalHistory.hasRedo()&&!this.isUpdating}undo(){if(this.isUpdating)throw new w(y.ErrRefused,"Undo is not allowed during an update");const e=this.internalHistory.popUndo();if(e===void 0)throw new w(y.ErrRefused,"There is no operation to be undone");this.ensureClone();const t=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const l of e){if(!(l instanceof At)){new Jo(t,dt(this.clone.presences.get(this.changeID.getActorID()))).set(l.value,{addToHistory:!0});continue}const h=t.issueTimeTicket();l.setExecutedAt(h),t.push(l)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,ie.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,ie.UndoRedo),o=t.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushRedo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];s.length>0&&u.push({type:"local-change",source:ie.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:ie.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}redo(){if(this.isUpdating)throw new w(y.ErrRefused,"Redo is not allowed during an update");const e=this.internalHistory.popRedo();if(e===void 0)throw new w(y.ErrRefused,"There is no operation to be redone");this.ensureClone();const t=Qr.create(this.changeID.next(),this.clone.root,this.clone.presences.get(this.changeID.getActorID())||{});for(const l of e){if(!(l instanceof At)){new Jo(t,dt(this.clone.presences.get(this.changeID.getActorID()))).set(l.value,{addToHistory:!0});continue}const h=t.issueTimeTicket();l.setExecutedAt(h),t.push(l)}const r=t.getChange();r.execute(this.clone.root,this.clone.presences,ie.UndoRedo);const{opInfos:s,reverseOps:i}=r.execute(this.root,this.presences,ie.UndoRedo),o=t.getReversePresence();if(o&&i.push({type:"presence",value:o}),i.length>0&&this.internalHistory.pushUndo(i),!r.hasPresenceChange()&&s.length===0)return;this.localChanges.push(r),this.changeID=r.getID();const a=this.changeID.getActorID(),u=[];s.length>0&&u.push({type:"local-change",source:ie.UndoRedo,value:{message:r.getMessage()||"",operations:s,actor:a,clientSeq:r.getID().getClientSeq(),serverSeq:r.getID().getServerSeq()},rawChange:this.isEnableDevtools()?r.toStruct():void 0}),r.hasPresenceChange()&&u.push({type:"presence-changed",source:ie.UndoRedo,value:{clientID:a,presence:this.getPresence(a)}}),this.publish(u)}getUndoStackForTest(){return this.internalHistory.getUndoStackForTest()}getRedoStackForTest(){return this.internalHistory.getRedoStackForTest()}broadcast(e,t,r){const s={type:"local-broadcast",value:{topic:e,payload:t},options:r};this.publish([s])}getVersionVector(){return this.changeID.getVersionVector()}}function uy(n,e){let t=e;return{authInterceptor:i=>async o=>(n&&o.header.set("x-api-key",n),t&&o.header.set("authorization",t),await i(o)),setToken:i=>{t=i}}}const ly="yorkie-js-sdk",fy="0.5.6",hy="Yorkie JS SDK",dy="./src/yorkie.ts",gy={access:"public",main:"./dist/yorkie-js-sdk.js",typings:"./dist/yorkie-js-sdk.d.ts"},my=["dist"],py={build:"tsc && vite build","build:proto":"npx buf generate","build:docs":"typedoc","build:ghpages":"mkdir -p ghpages/examples && cp -r docs ghpages/api-reference && find ../../examples -name 'dist' -type d -exec sh -c 'cp -r {} ghpages/examples/$(basename $(dirname {}))' \\;",dev:"vite build -c vite.preview.ts && vite preview",test:"vitest run","test:watch":"vitest","test:bench":"vitest bench","test:ci":"vitest run --coverage","test:yorkie.dev":"TEST_RPC_ADDR=https://api.yorkie.dev vitest run --coverage",prepare:"pnpm build"},yy={node:">=18.0.0",npm:">=7.1.0"},vy={type:"git",url:"git+https://github.com/yorkie-team/yorkie-js-sdk.git"},wy={name:"hackerwins",email:"susukang98@gmail.com"},by="Apache-2.0",Ty={url:"https://github.com/yorkie-team/yorkie-js-sdk/issues"},Ay="https://github.com/yorkie-team/yorkie-js-sdk#readme",Iy={"@buf/googleapis_googleapis.bufbuild_es":"^1.4.0-20240524201209-f0e53af8f2fc.3","@bufbuild/buf":"^1.28.1","@bufbuild/protoc-gen-es":"^1.6.0","@connectrpc/protoc-gen-connect-es":"^1.4.0","@types/express":"^4.17.21","@types/google-protobuf":"^3.15.5","@types/long":"^4.0.1","@typescript-eslint/eslint-plugin":"^6.21.0","@typescript-eslint/parser":"^6.21.0","@vitest/coverage-istanbul":"^0.34.5","@vitest/coverage-v8":"^0.34.5",axios:"^1.7.7","eslint-plugin-tsdoc":"^0.2.16",express:"^4.21.1",prettier:"^2.7.1","ts-node":"^10.9.1",typedoc:"^0.25.13",typescript:"^5.3.3","typescript-transform-paths":"^3.3.1",vite:"^5.0.12","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.9.1","vite-tsconfig-paths":"^4.3.1",vitest:"^0.34.5"},Sy={"@bufbuild/protobuf":"^1.6.0","@connectrpc/connect":"^1.4.0","@connectrpc/connect-web":"^1.4.0",long:"^5.2.0"},_u={name:ly,version:fy,description:hy,main:dy,publishConfig:gy,files:my,scripts:py,engines:yy,repository:vy,author:wy,license:by,bugs:Ty,homepage:Ay,devDependencies:Iy,dependencies:Sy};function xy(){return n=>async e=>(e.header.set("x-yorkie-user-agent",_u.name+"/"+_u.version),await n(e))}const ky=n=>{try{if(JSON.stringify(n)===void 0)return!1}catch{return!1}return!0};var Ni=(n=>(n.Manual="manual",n.Realtime="realtime",n.RealtimePushOnly="realtime-pushonly",n.RealtimeSyncOff="realtime-syncoff",n))(Ni||{});const yi={syncLoopDuration:50,retrySyncLoopDelay:1e3,reconnectStreamDelay:1e3},qo={maxRetries:1/0,initialRetryInterval:1e3,maxBackoff:2e4};class _f{constructor(e,t){c(this,"id");c(this,"key");c(this,"status");c(this,"attachmentMap");c(this,"apiKey");c(this,"authTokenInjector");c(this,"conditions");c(this,"syncLoopDuration");c(this,"reconnectStreamDelay");c(this,"retrySyncLoopDelay");c(this,"rpcClient");c(this,"setAuthToken");c(this,"taskQueue");c(this,"processing",!1);c(this,"keepalive",!1);t=t||yi,this.key=t.key?t.key:jf(),this.status="deactivated",this.attachmentMap=new Map,this.apiKey=t.apiKey||"",this.authTokenInjector=t.authTokenInjector,this.conditions={SyncLoop:!1,WatchLoop:!1},this.syncLoopDuration=t.syncLoopDuration??yi.syncLoopDuration,this.reconnectStreamDelay=t.reconnectStreamDelay??yi.reconnectStreamDelay,this.retrySyncLoopDelay=t.retrySyncLoopDelay??yi.retrySyncLoopDelay;const{authInterceptor:r,setToken:s}=uy(this.apiKey);this.setAuthToken=s,this.rpcClient=xm(Gm,Hm({baseUrl:e,interceptors:[r,xy()],fetch:(i,o)=>{const a={...o,keepalive:this.keepalive};return fetch(i,a)}})),this.taskQueue=[]}async activate(){if(this.isActive())return Promise.resolve();if(this.authTokenInjector){const e=await this.authTokenInjector();this.setAuthToken(e)}return this.enqueueTask(async()=>this.rpcClient.activateClient({clientKey:this.key},{headers:{"x-shard-key":this.apiKey}}).then(e=>{this.id=e.clientId,this.status="activated",this.runSyncLoop(),K.info(`[AC] c:"${this.getKey()}" activated, id:"${this.id}"`)}).catch(async e=>{throw K.error(`[AC] c:"${this.getKey()}" err :`,e),await this.handleConnectError(e),e}))}deactivate(e={keepalive:!1}){if(this.status==="deactivated")return Promise.resolve();const t=async()=>{try{await this.rpcClient.deactivateClient({clientId:this.id},{headers:{"x-shard-key":this.apiKey}}),this.deactivateInternal(),K.info(`[DC] c"${this.getKey()}" deactivated`)}catch(r){throw K.error(`[DC] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}};if(e.keepalive){this.keepalive=!0;const r=t();return this.keepalive=!1,r}return this.enqueueTask(t)}attach(e,t={}){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);if(e.getStatus()!==fr.Detached)throw new w(y.ErrDocumentNotDetached,`${e.getKey()} is not detached`);e.setActor(this.id),e.update((i,o)=>o.set(t.initialPresence||{}));const r=e.subscribe("local-broadcast",async i=>{var h;const{topic:o,payload:a}=i.value,u=(h=i.options)==null?void 0:h.error,l=i.options;try{await this.broadcast(e.getKey(),o,a,l)}catch(d){d instanceof Error&&(u==null||u(d))}}),s=t.syncMode??"realtime";return this.enqueueTask(async()=>this.rpcClient.attachDocument({clientId:this.id,changePack:ye.toChangePack(e.createChangePack())},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(async i=>{const o=ye.fromChangePack(i.changePack);if(e.applyChangePack(o),e.getStatus()===fr.Removed)return e;e.applyStatus(fr.Attached),this.attachmentMap.set(e.getKey(),new Zp(this.reconnectStreamDelay,e,i.documentId,s,r)),s!=="manual"&&await this.runWatchLoop(e.getKey()),K.info(`[AD] c:"${this.getKey()}" attaches d:"${e.getKey()}"`);const a=e.getRootObject();if(t.initialRoot){const u=t.initialRoot;e.update(l=>{for(const[h,d]of Object.entries(u))if(!a.has(h)){const v=h;l[v]=d}})}return e}).catch(async i=>{throw K.error(`[AD] c:"${this.getKey()}" err :`,i),await this.handleConnectError(i),i}))}detach(e,t={}){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return e.update((s,i)=>i.clear()),this.enqueueTask(async()=>this.rpcClient.detachDocument({clientId:this.id,documentId:r.docID,changePack:ye.toChangePack(e.createChangePack()),removeIfNotAttached:t.removeIfNotAttached??!1},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(s=>{const i=ye.fromChangePack(s.changePack);return e.applyChangePack(i),e.getStatus()!==fr.Removed&&e.applyStatus(fr.Detached),this.detachInternal(e.getKey()),K.info(`[DD] c:"${this.getKey()}" detaches d:"${e.getKey()}"`),e}).catch(async s=>{throw K.error(`[DD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}async changeSyncMode(e,t){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const r=this.attachmentMap.get(e.getKey());if(!r)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);const s=r.syncMode;return s===t?e:(r.changeSyncMode(t),t==="manual"?(r.cancelWatchStream(),e):(t==="realtime"&&(r.remoteChangeEventReceived=!0),s==="manual"&&await this.runWatchLoop(e.getKey()),e))}sync(e){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);if(e){const t=this.attachmentMap.get(e.getKey());if(!t)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);return this.enqueueTask(async()=>this.syncInternal(t,"realtime").catch(async r=>{throw K.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r}))}return this.enqueueTask(async()=>{const t=[];for(const[,r]of this.attachmentMap)t.push(this.syncInternal(r,r.syncMode));return Promise.all(t).catch(async r=>{throw K.error(`[SY] c:"${this.getKey()}" err :`,r),await this.handleConnectError(r),r})})}remove(e){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const t=this.attachmentMap.get(e.getKey());if(!t)throw new w(y.ErrDocumentNotAttached,`${e.getKey()} is not attached`);e.setActor(this.id);const r=ye.toChangePack(e.createChangePack());return r.isRemoved=!0,this.enqueueTask(async()=>this.rpcClient.removeDocument({clientId:this.id,documentId:t.docID,changePack:r},{headers:{"x-shard-key":`${this.apiKey}/${e.getKey()}`}}).then(s=>{const i=ye.fromChangePack(s.changePack);e.applyChangePack(i),this.detachInternal(e.getKey()),K.info(`[RD] c:"${this.getKey()}" removes d:"${e.getKey()}"`)}).catch(async s=>{throw K.error(`[RD] c:"${this.getKey()}" err :`,s),await this.handleConnectError(s),s}))}getID(){return this.id}getKey(){return this.key}isActive(){return this.status==="activated"}getStatus(){return this.status}getCondition(e){return this.conditions[e]}broadcast(e,t,r,s){if(!this.isActive())throw new w(y.ErrClientNotActivated,`${this.key} is not active`);const i=this.attachmentMap.get(e);if(!i)throw new w(y.ErrDocumentNotAttached,`${e} is not attached`);if(!ky(r))throw new w(y.ErrInvalidArgument,"payload is not serializable");const o=(s==null?void 0:s.maxRetries)??qo.maxRetries,a=qo.maxBackoff;let u=0;const l=d=>Math.min(qo.initialRetryInterval*2**d,a),h=async()=>this.enqueueTask(async()=>this.rpcClient.broadcast({clientId:this.id,documentId:i.docID,topic:t,payload:new TextEncoder().encode(JSON.stringify(r))},{headers:{"x-shard-key":`${this.apiKey}/${e}`}}).then(()=>{K.info(`[BC] c:"${this.getKey()}" broadcasts d:"${e}" t:"${t}"`)}).catch(async d=>{if(K.error(`[BC] c:"${this.getKey()}" err:`,d),await this.handleConnectError(d))if(d instanceof le&&Gr(d)===y.ErrUnauthenticated&&i.doc.publish([{type:Se.AuthError,value:{reason:Es(d).reason,method:"Broadcast"}}]),uh(),l(u-1)),K.info(`[BC] c:"${this.getKey()}" retry attempt ${u}/${o}`);else throw K.error(`[BC] c:"${this.getKey()}" exceeded maximum retry attempts`),d;else throw d}));return h()}runSyncLoop(){const e=()=>{if(!this.isActive()){K.debug(`[SL] c:"${this.getKey()}" exit sync loop`),this.conditions.SyncLoop=!1;return}const t=[];for(const[,r]of this.attachmentMap)r.needRealtimeSync()&&(r.remoteChangeEventReceived=!1,t.push(this.syncInternal(r,r.syncMode).catch(async s=>{throw s instanceof le&&Gr(s)===y.ErrUnauthenticated&&r.doc.publish([{type:Se.AuthError,value:{reason:Es(s).reason,method:"PushPull"}}]),s})));Promise.all(t).then(()=>setTimeout(e,this.syncLoopDuration)).catch(async r=>{K.error(`[SL] c:"${this.getKey()}" sync failed:`,r),await this.handleConnectError(r)?setTimeout(e,this.retrySyncLoopDelay):this.conditions.SyncLoop=!1})};K.debug(`[SL] c:"${this.getKey()}" run sync loop`),this.conditions.SyncLoop=!0,e()}async runWatchLoop(e){const t=this.attachmentMap.get(e);if(!t)throw new w(y.ErrDocumentNotAttached,`${e} is not attached`);return this.conditions.WatchLoop=!0,t.runWatchLoop(r=>{if(!this.isActive())return this.conditions.WatchLoop=!1,Promise.reject(new w(y.ErrClientNotActivated,`${this.key} is not active`));const s=new AbortController,i=this.rpcClient.watchDocument({clientId:this.id,documentId:t.docID},{headers:{"x-shard-key":`${this.apiKey}/${e}`},signal:s.signal});return t.doc.publish([{type:Se.ConnectionChanged,value:Na.Connected}]),K.info(`[WD] c:"${this.getKey()}" watches d:"${e}"`),new Promise((o,a)=>{(async()=>{try{for await(const l of i)this.handleWatchDocumentsResponse(t,l),l.body.case==="initialization"&&o([i,s])}catch(l){t.doc.resetOnlineClients(),t.doc.publish([{type:Se.Initialized,source:ie.Local,value:t.doc.getPresences()}]),t.doc.publish([{type:Se.ConnectionChanged,value:Na.Disconnected}]),K.debug(`[WD] c:"${this.getKey()}" unwatches`),await this.handleConnectError(l)?(l instanceof le&&Gr(l)===y.ErrUnauthenticated&&t.doc.publish([{type:Se.AuthError,value:{reason:Es(l).reason,method:"WatchDocuments"}}]),r()):this.conditions.WatchLoop=!1,a(l)}})()})})}handleWatchDocumentsResponse(e,t){if(t.body.case==="event"&&t.body.value.type===$r.DOCUMENT_CHANGED){e.remoteChangeEventReceived=!0;return}e.doc.applyWatchStream(t)}deactivateInternal(){this.status="deactivated";for(const[e,t]of this.attachmentMap)this.detachInternal(e),t.doc.applyStatus(fr.Detached)}detachInternal(e){const t=this.attachmentMap.get(e);t&&(t.cancelWatchStream(),t.unsubscribeBroadcastEvent(),this.attachmentMap.delete(e))}syncInternal(e,t){const{doc:r,docID:s}=e,i=r.createChangePack();return this.rpcClient.pushPullChanges({clientId:this.id,documentId:s,changePack:ye.toChangePack(i),pushOnly:t==="realtime-pushonly"},{headers:{"x-shard-key":`${this.apiKey}/${r.getKey()}`}}).then(o=>{const a=ye.fromChangePack(o.changePack);if(a.hasChanges()&&(e.syncMode==="realtime-pushonly"||e.syncMode==="realtime-syncoff"))return r;r.applyChangePack(a),e.doc.publish([{type:Se.SyncStatusChanged,value:Pa.Synced}]),r.getStatus()===fr.Removed&&this.detachInternal(r.getKey());const u=r.getKey(),l=a.getChangeSize();return K.info(`[PP] c:"${this.getKey()}" sync d:"${u}", push:${i.getChangeSize()} pull:${l} cp:${a.getCheckpoint().toTestString()}`),r}).catch(async o=>{throw r.publish([{type:Se.SyncStatusChanged,value:Pa.SyncFailed}]),K.error(`[PP] c:"${this.getKey()}" err :`,o),o})}async handleConnectError(e){if(!(e instanceof le))return!1;if(e.code===ne.Canceled||e.code===ne.Unknown||e.code===ne.ResourceExhausted||e.code===ne.Unavailable)return!0;if(Gr(e)===y.ErrUnauthenticated){if(this.authTokenInjector){const t=await this.authTokenInjector(Es(e).reason);this.setAuthToken(t)}return!0}return(Gr(e)===y.ErrClientNotActivated||Gr(e)===y.ErrClientNotFound)&&this.deactivateInternal(),!1}enqueueTask(e){return new Promise((t,r)=>{this.taskQueue.push(()=>e().then(t).catch(r)),this.processing||this.processNext()})}async processNext(){if(this.taskQueue.length===0){this.processing=!1;return}try{this.processing=!0,await this.taskQueue.shift()()}catch{K.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`)}this.processNext()}}const Yf={Client:_f,Document:Gf,Primitive:he,Text:Ao,Counter:Io,Tree:So,LogLevel:Le,setLogLevel:Vf,IntType:Kt.IntegerCnt,LongType:Kt.LongCnt};typeof globalThis<"u"&&(globalThis.yorkie={Client:_f,Document:Gf,Primitive:he,Text:Ao,Counter:Io,Tree:So,LogLevel:Le,setLogLevel:Vf,IntType:Kt.IntegerCnt,LongType:Kt.LongCnt});const Ey=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},Cy=[{title:"Todo",cards:[{title:"Pruning document"},{title:"Clean up codes"}]},{title:"Doing",cards:[{title:"Array operations"}]},{title:"Done",cards:[{title:"Create a sample page"},{title:"Launch demo site"}]}],ur=new Yf.Client("https://api.yorkie.dev",{apiKey:"cedaovjuioqlk4pjqn6g"}),Ht=new Yf.Document(`vuejs-kanban-${new Date().toISOString().substring(0,10).replace(/-/g,"")}`,{enableDevtools:!0}),Ny={data(){return{lists:[],title:"",opened:null}},created(){this.fetchDoc()},beforeUnmount(){this.disconnect()},watch:{opened(n){this.$nextTick(function(){n===0?this.$refs.addListForm.querySelector("input").focus():n&&this.$refs.addCardForm[n-1].querySelector("input").focus(),this.title=""})}},methods:{async fetchDoc(){await ur.activate(),await ur.attach(Ht),Ht.update(n=>{n.lists||(n.lists=Cy)},"create default list if not exists"),Ht.subscribe(n=>{this.lists=Ht.getRoot().lists}),await ur.sync(),this.lists=Ht.getRoot().lists},async disconnect(){await ur.deactivate()},isOpened(n){return this.opened===n},openForm(n){this.opened=n},closeForm(){this.opened=null},addCard(n){this.title!==""&&Ht.update(e=>{e.lists.getElementByID(n.getID()).cards.push({title:this.title}),this.title=""},`add new card by ${ur.getID()}`)},deleteCard(n,e){Ht.update(t=>{t.lists.getElementByID(n.getID()).cards.deleteByID(e.getID())},`delete a card by ${ur.getID()}`)},addList(){this.title!==""&&Ht.update(n=>{n.lists.push({title:this.title,cards:[]}),this.title=""},`add new list by ${ur.getID()}`)},deleteList(n){Ht.update(e=>{e.lists.deleteByID(n.getID())},`delete a list by ${ur.getID()}`)}}},Py={class:"list"},Oy=["onClick"],Dy={class:"title"},By={class:"card"},Ry=["onClick"],Fy={key:0,class:"add-form"},Ly=["onKeyup"],Jy={class:"buttons"},My=["onClick"],$y=["onClick"],Uy={class:"add-list",ref:"addListForm"},qy={key:0,class:"add-form"},zy={class:"buttons"};function Ky(n,e,t,r,s,i){return jt(),Wt(_e,null,[(jt(!0),Wt(_e,null,Mc(s.lists,(o,a)=>(jt(),Wt("div",Py,[Re("span",{class:"delete",onClick:u=>i.deleteList(o)},"❌",8,Oy),Re("div",Dy,Ec(o.title),1),(jt(!0),Wt(_e,null,Mc(o.cards,u=>(jt(),Wt("div",By,[Re("span",{class:"delete",onClick:l=>i.deleteCard(o,u)},"❌",8,Ry),Jl(" "+Ec(u.title),1)]))),256)),Re("div",{class:"add-card",ref_for:!0,ref:"addCardForm"},[i.isOpened(a+1)?(jt(),Wt("div",Fy,[Jc(Re("input",{type:"text",placeholder:"Enter card title","onUpdate:modelValue":e[0]||(e[0]=u=>s.title=u),onKeyup:[fi(u=>i.addCard(o),["enter"]),e[1]||(e[1]=fi(u=>i.closeForm(),["esc"]))]},null,40,Ly),[[iu,s.title]]),Re("div",Jy,[Re("input",{type:"button",value:"Add",onClick:u=>i.addCard(o)},null,8,My),Re("input",{type:"button",value:"Close",class:"pull-right",onClick:e[2]||(e[2]=u=>i.closeForm())})])])):(jt(),Wt("div",{key:1,class:"add-card-opener",onClick:u=>i.openForm(a+1)}," Add another card ",8,$y))],512)]))),256)),Re("div",Uy,[i.isOpened(0)?(jt(),Wt("div",qy,[Jc(Re("input",{type:"text",placeholder:"Enter list title","onUpdate:modelValue":e[3]||(e[3]=o=>s.title=o),onKeyup:[e[4]||(e[4]=fi(o=>i.addList(),["enter"])),e[5]||(e[5]=fi(o=>i.closeForm(),["esc"]))]},null,544),[[iu,s.title]]),Re("div",zy,[Re("input",{type:"button",value:"Add",onClick:e[6]||(e[6]=o=>i.addList())}),Re("input",{type:"button",value:"Close",class:"pull-right",onClick:e[7]||(e[7]=o=>i.closeForm())})])])):(jt(),Wt("div",{key:1,class:"add-list-opener",onClick:e[8]||(e[8]=o=>i.openForm(0))}," Add another list "))],512)],64)}const Vy=Ey(Ny,[["render",Ky]]);xg(Vy).mount("#app"); diff --git a/examples/vuejs-kanban/index.html b/examples/vuejs-kanban/index.html index 955a4d02f..04f0bf014 100644 --- a/examples/vuejs-kanban/index.html +++ b/examples/vuejs-kanban/index.html @@ -6,7 +6,7 @@ Vite App - +