easemob-websdk 4.24.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -39
- package/bundle/im-sdk-web.iife.js +1 -0
- package/cache/cache-crypto.d.ts +26 -0
- package/cache/cache-eviction.d.ts +16 -0
- package/cache/cache-keys.d.ts +23 -0
- package/cache/cache-manager.d.ts +254 -0
- package/cache/cache-metadata.d.ts +14 -0
- package/cache/cache-store.d.ts +19 -0
- package/cache/cache-types.d.ts +225 -0
- package/cache/cache-utils.d.ts +7 -0
- package/cache/contact-cache.d.ts +35 -0
- package/cache/conversation-cache.d.ts +21 -0
- package/cache/group-namecard-cache.d.ts +20 -0
- package/cache/index.d.ts +24 -0
- package/cache/joined-group-preview-cache.d.ts +12 -0
- package/cache/session-list-cache.d.ts +10 -0
- package/cache/user-info-cache.d.ts +16 -0
- package/chat-client.d.ts +558 -0
- package/chunks/cache-utils-BwRPIZ7n.js +1 -0
- package/chunks/cache-utils-CKbcYPlM.cjs +1 -0
- package/chunks/chat-manager-ChdK26ck.cjs +1 -0
- package/chunks/chat-manager-DH8a6Qj9.js +2 -0
- package/chunks/common-CfAlncj9.cjs +1 -0
- package/chunks/common-DN_g4O3n.js +1 -0
- package/chunks/event-system-COBJFEIq.cjs +1 -0
- package/chunks/event-system-D6IJA0C4.js +1 -0
- package/chunks/group-user-info-resolver-C5pdiqox.cjs +1 -0
- package/chunks/group-user-info-resolver-FNRqDg18.js +1 -0
- package/chunks/index-BKg4EGcI.cjs +1 -0
- package/chunks/index-CK3GHdGU.cjs +1 -0
- package/chunks/index-CjofwvEQ.js +1 -0
- package/chunks/index-uKWbjx-u.js +1 -0
- package/chunks/profile-version-DLMz8lqW.js +1 -0
- package/chunks/profile-version-njNs7R5-.cjs +1 -0
- package/chunks/reflection-proto-codec-64ocOTHU.js +1 -0
- package/chunks/reflection-proto-codec-BnQFQdZC.cjs +1 -0
- package/chunks/session-list-query-B6dh-b4Y.cjs +1 -0
- package/chunks/session-list-query-Dnp2HbpW.js +1 -0
- package/chunks/user-info-BfRwS4ZA.js +1 -0
- package/chunks/user-info-icpL0Eaw.cjs +1 -0
- package/config/cache.d.ts +12 -0
- package/config/timeouts.d.ts +34 -0
- package/core/connection/connection-manager.d.ts +228 -0
- package/core/connection/connection-retry.d.ts +47 -0
- package/core/connection/heartbeat.d.ts +68 -0
- package/core/contact-sync/contact-roster-event-sidecar.d.ts +3 -0
- package/core/contact-sync/roster-sync-client.d.ts +21 -0
- package/core/contact-sync/roster-sync-controller.d.ts +20 -0
- package/core/contact-sync/roster-sync-session.d.ts +28 -0
- package/core/contact-sync/roster-sync-types.d.ts +74 -0
- package/core/events/event-hub.d.ts +13 -0
- package/core/group-sync/group-sync-client.d.ts +19 -0
- package/core/group-sync/group-sync-controller.d.ts +11 -0
- package/core/group-sync/group-sync-merge.d.ts +3 -0
- package/core/group-sync/group-sync-normalizer.d.ts +4 -0
- package/core/group-sync/group-sync-session.d.ts +17 -0
- package/core/group-sync/group-sync-types.d.ts +24 -0
- package/core/group-sync/index.d.ts +4 -0
- package/core/index.d.ts +95 -0
- package/core/message/attachment-downloader.d.ts +7 -0
- package/core/message/chatroom-operation-types.d.ts +6 -0
- package/core/message/combine-message-downloader.d.ts +7 -0
- package/core/message/message-action-types.d.ts +22 -0
- package/core/message/message-deduplicator.d.ts +11 -0
- package/core/message/message-receiver.d.ts +65 -0
- package/core/message/message-retry.d.ts +33 -0
- package/core/message/message-sender.d.ts +63 -0
- package/core/message/profile-sync/group-namecard-hydration-queue.d.ts +33 -0
- package/core/message/profile-sync/group-namecard-hydrator.d.ts +8 -0
- package/core/message/profile-sync/latest-message-version-projector.d.ts +3 -0
- package/core/message/profile-sync/profile-version-sidecar.d.ts +9 -0
- package/core/message/profile-sync/profile-version.d.ts +3 -0
- package/core/message/profile-sync/user-info-hydration-queue.d.ts +29 -0
- package/core/message/profile-sync/user-info-hydrator.d.ts +8 -0
- package/core/message/stream-message-cache.d.ts +38 -0
- package/core/message/stream-message-handler.d.ts +22 -0
- package/core/session-list-sync/session-list-query.d.ts +26 -0
- package/core/session-list-sync/session-list-sync-controller.d.ts +17 -0
- package/core/session-list-sync/session-list-sync-merge.d.ts +17 -0
- package/core/session-list-sync/session-list-sync-normalizer.d.ts +6 -0
- package/core/session-list-sync/session-list-sync-runner.d.ts +13 -0
- package/core/session-list-sync/session-list-sync-session.d.ts +26 -0
- package/core/session-list-sync/session-list-sync-types.d.ts +24 -0
- package/core/sync/shared-sync-websocket-session.d.ts +61 -0
- package/core/user-info/group-user-info-resolver.d.ts +40 -0
- package/data-report/bridge.d.ts +11 -0
- package/data-report/constants.d.ts +25 -0
- package/data-report/data-reporter.d.ts +21 -0
- package/data-report/event-queue.d.ts +38 -0
- package/data-report/index.d.ts +3 -0
- package/data-report/network-type.d.ts +1 -0
- package/data-report/operation-map.d.ts +8 -0
- package/data-report/transport.d.ts +17 -0
- package/data-report/types.d.ts +61 -0
- package/index.cjs +1 -0
- package/index.d.ts +134 -0
- package/index.js +3 -0
- package/managers/chat/index.cjs +1 -0
- package/managers/chat/index.d.ts +1 -0
- package/managers/chat/index.js +1 -0
- package/managers/chat-manager.d.ts +880 -0
- package/managers/chat-thread/chat-thread.d.ts +126 -0
- package/managers/chat-thread/index.cjs +1 -0
- package/managers/chat-thread/index.d.ts +2 -0
- package/managers/chat-thread/index.js +1 -0
- package/managers/chat-thread-manager.d.ts +257 -0
- package/managers/chatroom/chatroom-event-mapper.d.ts +17 -0
- package/managers/chatroom/chatroom-event-user-info-resolver.d.ts +15 -0
- package/managers/chatroom/chatroom-normalizers.d.ts +23 -0
- package/managers/chatroom/chatroom.d.ts +403 -0
- package/managers/chatroom/index.cjs +1 -0
- package/managers/chatroom/index.d.ts +2 -0
- package/managers/chatroom/index.js +1 -0
- package/managers/chatroom-manager.d.ts +604 -0
- package/managers/contact/contact-user-info-resolver.d.ts +15 -0
- package/managers/contact/index.cjs +1 -0
- package/managers/contact/index.d.ts +1 -0
- package/managers/contact/index.js +1 -0
- package/managers/contact-manager.d.ts +215 -0
- package/managers/group/group-event-mapper.d.ts +18 -0
- package/managers/group/group-event-user-info-resolver.d.ts +15 -0
- package/managers/group/group-normalizers.d.ts +15 -0
- package/managers/group/group.d.ts +504 -0
- package/managers/group/index.cjs +1 -0
- package/managers/group/index.d.ts +2 -0
- package/managers/group/index.js +1 -0
- package/managers/group/internal/group-event-sync.d.ts +13 -0
- package/managers/group/internal/group-repository.d.ts +31 -0
- package/managers/group/internal/group-snapshot-mapper.d.ts +6 -0
- package/managers/group/internal/internal-group.d.ts +24 -0
- package/managers/group-manager.d.ts +371 -0
- package/managers/presence/index.cjs +1 -0
- package/managers/presence/index.d.ts +1 -0
- package/managers/presence/index.js +1 -0
- package/managers/presence-manager.d.ts +201 -0
- package/managers/push/index.cjs +1 -0
- package/managers/push/index.d.ts +1 -0
- package/managers/push/index.js +1 -0
- package/managers/push-manager.d.ts +205 -0
- package/managers/user-info/index.cjs +1 -0
- package/managers/user-info/index.d.ts +4 -0
- package/managers/user-info/index.js +1 -0
- package/managers/user-info/user-info-notify-normalizer.d.ts +2 -0
- package/managers/user-info/user-info-runtime-store.d.ts +28 -0
- package/managers/user-info-manager.d.ts +196 -0
- package/message/combine-compatible-text-sidecar.d.ts +4 -0
- package/message/combine-message-constraints.d.ts +7 -0
- package/message/combine-payload-codec.d.ts +17 -0
- package/message/create-message.d.ts +64 -0
- package/package.json +64 -16
- package/platform/capability-validator.d.ts +7 -0
- package/platform/env.d.ts +68 -0
- package/platform/factory.d.ts +7 -0
- package/platform/image/miniapp-image-processor.d.ts +45 -0
- package/platform/image/web-image-processor.d.ts +2 -0
- package/platform/index.d.ts +17 -0
- package/platform/miniapp/miniapp-adapter.d.ts +3 -0
- package/platform/proto/proto-adapter.d.ts +17 -0
- package/platform/proto/reflection-proto-codec.d.ts +8 -0
- package/platform/proto/static-proto-adapter.d.ts +8 -0
- package/platform/request/web-request-adapter.d.ts +9 -0
- package/platform/runtime/connection-event-normalizer.d.ts +14 -0
- package/platform/runtime/runtime-event-bridge.d.ts +23 -0
- package/platform/runtime/web-runtime-adapter.d.ts +26 -0
- package/platform/socket/web-socket-adapter.d.ts +8 -0
- package/platform/types.d.ts +472 -0
- package/platform/upload/react-native-upload-adapter.d.ts +14 -0
- package/platform/upload/upload-error-mapper.d.ts +7 -0
- package/platform/upload/upload-source.d.ts +20 -0
- package/platform/upload/web-upload-adapter.d.ts +10 -0
- package/protocol/joined-groups/codec.d.ts +11 -0
- package/protocol/joined-groups/gateway.d.ts +2 -0
- package/protocol/joined-groups/index.d.ts +2 -0
- package/protocol/joined-groups/proto.d.ts +174 -0
- package/protocol/joined-groups/types.d.ts +65 -0
- package/protocol/msync/codec.d.ts +191 -0
- package/protocol/msync/context.d.ts +40 -0
- package/protocol/msync/lz4-compressor/index.d.ts +40 -0
- package/protocol/msync/lz4-compressor/utils.d.ts +27 -0
- package/protocol/msync/multi-device-normalizer.d.ts +75 -0
- package/protocol/msync/proto.d.ts +1306 -0
- package/protocol/msync/root.d.ts +5 -0
- package/protocol/msync/types.d.ts +96 -0
- package/protocol/msync/utils.d.ts +26 -0
- package/protocol/protobuf/decoder.d.ts +44 -0
- package/protocol/protobuf/encoder.d.ts +23 -0
- package/protocol/protobuf/types.d.ts +53 -0
- package/protocol/roster/codec.d.ts +9 -0
- package/protocol/roster/proto.d.ts +205 -0
- package/protocol/roster/root.d.ts +5 -0
- package/protocol/roster/types.d.ts +83 -0
- package/protocol/session-list/codec.d.ts +11 -0
- package/protocol/session-list/gateway.d.ts +19 -0
- package/protocol/session-list/payload-decoder.d.ts +1 -0
- package/protocol/session-list/proto.d.ts +207 -0
- package/protocol/session-list/types.d.ts +83 -0
- package/rest/chat-management.d.ts +26 -0
- package/rest/chat-thread-management.d.ts +14 -0
- package/rest/chatroom-management.d.ts +40 -0
- package/rest/client.d.ts +86 -0
- package/rest/contact-management.d.ts +27 -0
- package/rest/contact-metadata.d.ts +11 -0
- package/rest/conversation-management.d.ts +11 -0
- package/rest/dns-config.d.ts +20 -0
- package/rest/error-map-types.d.ts +32 -0
- package/rest/error-maps/chat.d.ts +888 -0
- package/rest/error-maps/chatroom.d.ts +592 -0
- package/rest/error-maps/common.d.ts +208 -0
- package/rest/error-maps/contact.d.ts +185 -0
- package/rest/error-maps/core.d.ts +21 -0
- package/rest/error-maps/group.d.ts +500 -0
- package/rest/error-maps/index.d.ts +9 -0
- package/rest/error-maps/presence.d.ts +62 -0
- package/rest/error-maps/push.d.ts +158 -0
- package/rest/error-maps/thread.d.ts +538 -0
- package/rest/error-maps/user-info.d.ts +289 -0
- package/rest/errors.d.ts +23 -0
- package/rest/group-management.d.ts +55 -0
- package/rest/rtc-token.d.ts +14 -0
- package/rest/speech-helpers.d.ts +24 -0
- package/rest/user-info-subscription.d.ts +10 -0
- package/rest/user-info.d.ts +34 -0
- package/types/chat-client.d.ts +226 -0
- package/types/chat-manager.d.ts +641 -0
- package/types/chat-thread.d.ts +311 -0
- package/types/chatroom.d.ts +1258 -0
- package/types/connection.d.ts +111 -0
- package/types/contact.d.ts +149 -0
- package/types/conversation.d.ts +270 -0
- package/types/event-system.d.ts +721 -0
- package/types/group.d.ts +980 -0
- package/types/index.d.ts +577 -44
- package/types/manager.d.ts +99 -0
- package/types/message-conversation.d.ts +22 -0
- package/types/message-create.d.ts +173 -0
- package/types/multi-device.d.ts +275 -0
- package/types/presence.d.ts +101 -0
- package/types/push.d.ts +296 -0
- package/types/sender.d.ts +12 -0
- package/types/sync-data.d.ts +54 -0
- package/types/user-info.d.ts +178 -0
- package/upload/attachment-file-store.d.ts +11 -0
- package/upload/attachment-uploader.d.ts +36 -0
- package/upload/constants.d.ts +8 -0
- package/upload/index.d.ts +2 -0
- package/upload/multipart-upload.d.ts +14 -0
- package/upload/simple-upload.d.ts +3 -0
- package/upload/types.d.ts +79 -0
- package/upload/utils.d.ts +71 -0
- package/utils/env.d.ts +4 -0
- package/utils/error-codes.d.ts +2 -0
- package/utils/error-codes.generated.d.ts +145 -0
- package/utils/error-sanitizer.d.ts +8 -0
- package/utils/errors.d.ts +139 -0
- package/utils/log-reporter.d.ts +61 -0
- package/utils/log-sanitizer.d.ts +6 -0
- package/utils/logger.d.ts +48 -0
- package/utils/md5.d.ts +1 -0
- package/utils/message-id.d.ts +12 -0
- package/utils/provision-error-mapping.d.ts +21 -0
- package/utils/retry.d.ts +26 -0
- package/utils/runtime-global.d.ts +4 -0
- package/utils/trace-id.d.ts +5 -0
- package/utils/utf8.d.ts +2 -0
- package/validators/chat-client.d.ts +787 -0
- package/validators/message-create.d.ts +419 -0
- package/validators/search-messages.d.ts +127 -0
- package/validators/validator.d.ts +49 -0
- package/version.d.ts +2 -0
- package/Easemob-chat.d.ts +0 -8457
- package/Easemob-chat.js +0 -2
- package/chatroom/chatroom.d.ts +0 -649
- package/chatroom/chatroom.js +0 -1
- package/contact/contact.d.ts +0 -726
- package/contact/contact.js +0 -1
- package/group/group.d.ts +0 -848
- package/group/group.js +0 -1
- package/localCache/localCache.d.ts +0 -59
- package/localCache/localCache.js +0 -1
- package/message/audio.d.ts +0 -183
- package/message/channel.d.ts +0 -82
- package/message/cmd.d.ts +0 -146
- package/message/combine.d.ts +0 -132
- package/message/custom.d.ts +0 -135
- package/message/delivery.d.ts +0 -77
- package/message/file.d.ts +0 -173
- package/message/img.d.ts +0 -200
- package/message/index.d.ts +0 -211
- package/message/location.d.ts +0 -134
- package/message/read.d.ts +0 -85
- package/message/text.d.ts +0 -149
- package/message/video.d.ts +0 -180
- package/miniCore/miniCore.d.ts +0 -217
- package/miniCore/miniCore.js +0 -2
- package/miniProgram/Easemob-chat.js +0 -2
- package/miniProgram/miniProgram.zip +0 -0
- package/presence/presence.d.ts +0 -69
- package/presence/presence.js +0 -1
- package/silent/silent.d.ts +0 -128
- package/silent/silent.js +0 -1
- package/status.d.ts +0 -184
- package/thread/thread.d.ts +0 -159
- package/thread/thread.js +0 -1
- package/translation/translation.d.ts +0 -30
- package/translation/translation.js +0 -1
- package/types/chatRoomApi.d.ts +0 -226
- package/types/common.d.ts +0 -89
- package/types/engineCore.d.ts +0 -194
- package/types/error.d.ts +0 -13
- package/types/eventHandler.d.ts +0 -437
- package/types/groupApi.d.ts +0 -306
- package/types/indexApi.d.ts +0 -366
- package/types/localCache.d.ts +0 -53
- package/types/message.d.ts +0 -959
- package/types/presenceApi.d.ts +0 -61
- package/types/reactionApi.d.ts +0 -74
- package/types/restApis.d.ts +0 -6
- package/types/silentModeApi.d.ts +0 -109
- package/types/threadApi.d.ts +0 -175
- package/types/translation.d.ts +0 -25
- package/types/utils.d.ts +0 -90
- package/uniApp/Easemob-chat.js +0 -2
- package/uniApp/uniApp.zip +0 -0
- package/websdk.zip +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./cache-utils-BwRPIZ7n.js";import{p as t,V as r,E as o,S as s,A as n,Z as a,l as i,n as u,u as p,aq as d,b as c,e as m,ar as l,f as h,m as g,h as I}from"./common-DN_g4O3n.js";import{a as y}from"./profile-version-DLMz8lqW.js";import{m as f,g as w,r as _,b as G}from"./group-user-info-resolver-FNRqDg18.js";import{G as b}from"./event-system-D6IJA0C4.js";import{b as v,a as R,n as S}from"./user-info-BfRwS4ZA.js";import{L as A,a as U,l as E,b as C}from"./reflection-proto-codec-64ocOTHU.js";const O=["nickname","avatarUrl","mail","phone","gender","sign","birth","ext"],T=e=>({userId:e.userId,nickname:e.nickname,avatarUrl:e.avatarUrl,sign:e.sign,ext:e.ext}),M=e=>({userId:e}),D=(e,t,r)=>{const o={userId:r};for(const s of O){const r=t?.[s]??e?.[s];void 0!==r&&(o[s]=r)}return o},N=async(e,t)=>{const r=(e=>{const t=[],r=/* @__PURE__ */new Set;for(const o of e){const e=o.trim();e&&!r.has(e)&&(r.add(e),t.push(e))}return t})(e),o=/* @__PURE__ */new Map;if(0===r.length)return o;const s=t.cacheManager?.getUserInfoSummaries(r,!1)??[];for(const a of s)o.set(a.userId,T(a));const n=r.filter(e=>!o.has(e));if(n.length>0&&t.fetchUserInfos){const e=await t.fetchUserInfos({userIds:n});for(const t of e)o.set(t.userId,t)}for(const a of r)o.has(a)||o.set(a,M(a));return o},L=t=>e(t)?t:null,F=e=>{if("string"==typeof e)return e},P=e=>{const t=F(e)?.trim();return t||void 0},$=e=>{if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}},x=e=>{if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===e)return!0;if("false"===e)return!1}},j=e=>{const t=L(e);return t&&Array.isArray(t.data)?t.data:t&&Array.isArray(t.entities)?t.entities:Array.isArray(e)?e:[]},k=e=>{const t=L(e);return t?L(t.data)?t.data:t:null},J=(e,t)=>{const r=L(e),o=r&&L(r.params),s=o?.[t];if(Array.isArray(s)&&0!==s.length)return $(s[0])},q=(e,t)=>{const r=(e=>{const t=L(e);return t?$(t.count):void 0})(e);if(void 0!==r&&void 0!==t)return r>=t},B=e=>P(e.groupId)??P(e.groupid)??P(e.id)??"",H=e=>F(e.name)??F(e.groupname)??F(e.groupName)??"",V=e=>{const t=j(e),r=L(t[0])??k(e)??{},o=(e=>{const t=L(e);if(!t)return null;const r=B(t);return r?{groupId:r,name:H(t),description:F(t.description),memberCount:$(t.memberCount)??$(t.affiliations_count),public:x(t.public),joinApprovalRequired:x(t.joinApprovalRequired)??x(t.approval)??x(t.membersonly)??x(t.members_only),allowInvites:x(t.allowInvites)??x(t.allowinvites)??x(t.allow_user_invites),maxMembers:$(t.maxMembers)??$(t.maxusers),role:P(t.role)??P(t.permission),disabled:x(t.disabled)}:null})(r)??{groupId:B(r),name:H(r)},s=P(r.owner)??P(r.admin)??P(r.member),n=(Array.isArray(r.affiliations)?r.affiliations:[]).map(e=>L(e)).filter(e=>null!==e).map(e=>$(e.joined_time)).find(e=>void 0!==e);return{...o,owner:s?M(s):void 0,inviteNeedConfirm:x(r.inviteNeedConfirm)??x(r.invite_need_confirm),muteAllMembers:x(r.mute),ext:F(r.ext)??F(r.custom),createdAt:$(r.createdAt)??$(r.created),joinedAt:n,avatarUrl:F(r.avatar),messageBlocked:x(r.messageBlocked)??x(r.isMessageBlocked)??x(r.shieldgroup)}},K=e=>M(e),z=e=>j(e).map(e=>P(e)).filter(e=>Boolean(e)).map(e=>K(e)),W=e=>{const t=L(e);if(!t)return null;const r=P(t.fileId)??P(t.file_id);if(!r)return null;const o=F(t.fileName)??F(t.file_name)??r,s=P(t.fileOwner)??P(t.file_owner);return{fileId:r,fileName:o,fileOwner:s?K(s):void 0,fileSize:$(t.fileSize)??$(t.file_size),createdAt:$(t.createdAt)??$(t.created)}},Q=100,Y=3e3,X=e=>({...e}),Z=e=>"object"==typeof e&&null!==e,ee=e=>"DEFAULT"===e||"ALL"===e||"AT"===e||"NONE"===e?e:"mentionOnly"===e?"AT":"mute"===e?"NONE":"default"===e?"DEFAULT":2===e?"AT":3===e?"NONE":0===e?"DEFAULT":1===e?"ALL":void 0;class te{constructor(){this.items=[],this.meta={integrity:"unknown",limited:!1,storageLimit:Q,serverLimit:Y,source:"localPreview"}}load(e){if(!e)return this.items=[],void(this.meta={integrity:"unknown",limited:!1,storageLimit:Q,serverLimit:Y,source:"localPreview"});const t=Array.isArray(e.items)?e.items.map(e=>{return Z(t=e)&&"string"==typeof t.groupId&&0!==t.groupId.length?{groupId:t.groupId,name:"string"==typeof t.name?t.name:"",description:"string"==typeof t.description?t.description:void 0,memberCount:"number"==typeof t.memberCount?t.memberCount:void 0,role:"owner"===t.role||"admin"===t.role||"member"===t.role?t.role:void 0,disabled:"boolean"==typeof t.disabled?t.disabled:void 0,ownerId:"string"==typeof t.ownerId?t.ownerId:void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:void 0,muteAllMembers:"boolean"==typeof t.muteAllMembers?t.muteAllMembers:void 0,muteExpiration:"number"==typeof t.muteExpiration?t.muteExpiration:void 0,remindType:ee(t.remindType),createdAt:"number"==typeof t.createdAt?t.createdAt:void 0,updatedAt:"number"==typeof t.updatedAt?t.updatedAt:void 0,joinedAt:"number"==typeof t.joinedAt?t.joinedAt:void 0}:null;var t}).filter(e=>null!==e):[];this.items=t.slice(0,Q),this.meta=(e=>{const t=Z(e)?e:{};return{integrity:"synced"===t.integrity||"limited"===t.integrity||"incomplete"===t.integrity||"unknown"===t.integrity?t.integrity:"preview",limited:!0===t.limited,storageLimit:"number"==typeof t.storageLimit?t.storageLimit:Q,serverLimit:"number"==typeof t.serverLimit?t.serverLimit:Y,source:"localPreview",lastSyncFinishedTs:"number"==typeof t.lastSyncFinishedTs?t.lastSyncFinishedTs:void 0,lastSuccessfulAt:"number"==typeof t.lastSuccessfulAt?t.lastSuccessfulAt:void 0,reason:"string"==typeof t.reason?t.reason:void 0}})(e.meta)}setSnapshot(e){this.items=e.items.map(e=>X(e)).slice(0,Q),this.meta={...e.meta,source:"localPreview",storageLimit:Q,serverLimit:Y,integrity:e.meta.limited?"limited":e.meta.integrity}}getSnapshot(){return{items:this.items.map(e=>X(e)),meta:{...this.meta,source:"localPreview"}}}exportRecord(){return{items:this.items.map(e=>X(e)),meta:{...this.meta,source:"localPreview"}}}}class re{constructor(e,t){this.groupId=e,this.manager=t}getSummary(){return this.manager.getGroupSummaryForHandle(this.groupId)}getDetail(){return this.manager.getGroupDetailForHandle(this.groupId)}refresh(){return this.manager.refreshGroupDetailForHandle(this.groupId)}updateInfo(e){return this.manager.updateGroupInfo({groupId:this.groupId,...e})}updateConfigs(e){return this.manager.updateGroupInfo({groupId:this.groupId,...e})}changeOwner(e){return this.manager.changeGroupOwner({groupId:this.groupId,newOwner:e.newOwner})}destroy(){return this.manager.destroyGroup(this.toTarget())}leave(){return this.manager.leaveGroup(this.toTarget())}getMembers(e={}){return this.manager.getGroupMemberList({groupId:this.groupId,...e})}removeMembers(e){return this.manager.removeGroupMembers(this.toUserBatchParams(e))}getAdmins(){return this.manager.getGroupAdminList(this.toTarget())}addAdmin(e){return this.manager.addGroupAdmin({groupId:this.groupId,userId:e.userId})}removeAdmin(e){return this.manager.removeGroupAdmin({groupId:this.groupId,userId:e.userId})}getMuteList(e){return this.manager.getGroupMuteList({...this.toTarget(),...e})}muteMembers(e){return this.manager.muteGroupMembers({groupId:this.groupId,userIds:e.userIds,muteDuration:e.muteDuration})}unmuteMembers(e){return this.manager.unmuteGroupMembers(this.toUserBatchParams(e))}muteAllMembers(){return this.manager.muteAllGroupMembers(this.toTarget())}unmuteAllMembers(){return this.manager.unmuteAllGroupMembers(this.toTarget())}getBlocklist(e){return this.manager.getGroupBlocklist({...this.toTarget(),...e})}blockMembers(e){return this.manager.blockGroupMembers(this.toUserBatchParams(e))}unblockMembers(e){return this.manager.unblockGroupMembers(this.toUserBatchParams(e))}getAllowlist(){return this.manager.getGroupAllowlist(this.toTarget())}addUsersToAllowlist(e){return this.manager.addUsersToGroupAllowlist(this.toUserBatchParams(e))}removeUsersFromAllowlist(e){return this.manager.removeUsersFromGroupAllowlist(this.toUserBatchParams(e))}checkIfInAllowList(){return this.manager.checkIfInGroupAllowList({groupId:this.groupId})}checkIfInMuteList(){return this.manager.checkIfInGroupMuteList(this.toTarget())}getAnnouncement(){return this.manager.getGroupAnnouncement(this.toTarget())}updateAnnouncement(e){return this.manager.updateGroupAnnouncement({groupId:this.groupId,announcement:e.announcement})}getSharedFileList(e={}){return this.manager.getGroupSharedFileList({groupId:this.groupId,...e})}uploadSharedFile(e){return this.manager.uploadGroupSharedFile({groupId:this.groupId,...e})}deleteSharedFile(e){return this.manager.deleteGroupSharedFile({groupId:this.groupId,fileId:e.fileId})}downloadSharedFile(e){return this.manager.downloadGroupSharedFile({groupId:this.groupId,...e})}setMemberAttributes(e){return this.manager.setGroupMemberAttributes({groupId:this.groupId,userId:e.userId,memberAttributes:e.memberAttributes})}getMembersAttributes(e){return this.manager.getGroupMembersAttributes({groupId:this.groupId,userIds:e.userIds,keys:e.keys})}toTarget(){return{groupId:this.groupId}}toUserBatchParams(e){return{groupId:this.groupId,userIds:e.userIds}}}const oe=e=>{const{orgName:r,appName:o}=t(e.appKey);return{orgName:r,appName:o,encodedUserId:encodeURIComponent(e.userId),encodedResource:encodeURIComponent(e.clientResource)}},se=e=>new r(`${e} is required`,{code:o.VALIDATION_REQUIRED,details:{fields:[{path:e,message:`${e} is required`,rule:"required"}]}}),ne=(e,t)=>new r(t,{code:o.VALIDATION_INVALID_FORMAT,details:{fields:[{path:e,message:t,rule:"invalid_format"}]}}),ae=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw se(t);const r=[],o=/* @__PURE__ */new Set;if(e.forEach((e,s)=>{if("string"!=typeof e)throw ne(`${t}[${s}]`,`${t}[${s}] must be a string`);const n=e.trim();n&&!o.has(n)&&(o.add(n),r.push(n))}),0===r.length)throw se(t);return r},ie=(e,t)=>{if("string"!=typeof e||0===e.trim().length)throw se(t);return e.trim()},ue=(e,t)=>{if(void 0!==e){if("string"!=typeof e)throw ne(t,`${t} must be a string`);return e}},pe=(e,t)=>{if(void 0!==e){if("boolean"!=typeof e)throw ne(t,`${t} must be a boolean`);return e}},de=(e,t)=>`/${e.orgName}/${e.appName}${t}`,ce=/* @__PURE__ */new Set(["groupNamecard","group_namecard","group_name_card","namecard","nameCard"]),me=e=>{const t=new URLSearchParams;"number"==typeof e?.pageNum&&t.set("pagenum",String(e.pageNum)),"number"==typeof e?.pageSize&&t.set("pagesize",String(e.pageSize));const r=t.toString();return r?`?${r}`:""},le=async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups?resource=${o.encodedResource}`);return(e=>{const t=j(e),r=L(t[0]),o=k(e)??r;return{groupId:o&&B(o)||r&&B(r)||""}})(await e.post(s,{owner:t.userId,groupname:r.name,desc:r.description,members:r.memberIds?ae(r.memberIds,"params.memberIds"):[],public:r.public,approval:r.joinApprovalRequired,allowinvites:r.allowInvites,invite_need_confirm:r.inviteNeedConfirm,maxusers:r.maxMembers,custom:r.ext,avatar:r.avatar},{operation:"createGroup"}))},he=async(e,t,r)=>{const o=oe(t),s=ie(r.groupId,"params.groupId"),n=de(o,`/chatgroups/${encodeURIComponent(s)}?joined_time=true&version=v3`),a=await e.get(n,{operation:"getGroupInfo"});return V(a)},ge=async(e,t,r)=>{const o=oe(t),s=ie(r.groupId,"params.groupId"),n={},a=ue(r.name,"params.name"),i=ue(r.description,"params.description"),u=ue(r.avatar,"params.avatar"),p=ue(r.ext,"params.ext"),d=pe(r.public,"params.public"),c=pe(r.joinApprovalRequired,"params.joinApprovalRequired"),m=pe(r.allowInvites,"params.allowInvites"),l=pe(r.inviteNeedConfirm,"params.inviteNeedConfirm"),h=((e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw ne(t,`${t} must be a number`);return e}})(r.maxMembers,"params.maxMembers");if(void 0!==a&&(n.groupname=a),void 0!==i&&(n.description=i),void 0!==u&&(n.avatar=u),void 0!==p&&(n.custom=p),void 0!==d&&(n.public=d),void 0!==c&&(n.membersonly=c),void 0!==m&&(n.allowinvites=m),void 0!==l&&(n.invite_need_confirm=l),void 0!==h&&(n.maxusers=h),0===Object.keys(n).length)throw se("params");const g=de(o,`/chatgroups/${encodeURIComponent(s)}?resource=${o.encodedResource}&version=v3`);await e.put(g,n,{operation:"updateGroupInfo"})},Ie=async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/users${(e=>{const t=new URLSearchParams;return"number"==typeof e?.pageSize&&t.set("pagesize",String(e.pageSize)),"string"==typeof e?.cursor&&e.cursor.length>0&&t.set("cursor",e.cursor),t.set("version","v3"),`?${t.toString()}`})(r)}`);return(e=>{const t=[];for(const n of j(e)){const e=L(n);if(!e)continue;const r=P(e.owner),o=P(e.admin),s=P(e.member),a=r??o??s;if(!a)continue;const i=$(e.joinedAt)??$(e.joined_time);t.push({user:K(a),role:r?"owner":o?"admin":"member",...void 0===i?{}:{joinedAt:i}})}const r=J(e,"pagenum"),o=J(e,"pagesize"),s=q(e,o);return{items:t,pageNum:r,pageSize:o,...void 0===s?{}:{hasMore:s}}})(await e.get(s,{operation:"getGroupMemberList"}))},ye=async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/admin`),n=await e.get(s,{operation:"getGroupAdminList"});return z(n)},fe=async(e,t,r)=>{const o=oe(t),s=ie(r.groupId,"params.groupId"),n=me(r),a=n?"&":"",i=de(o,`/chatgroups/${encodeURIComponent(s)}/mute?version=v3${a}${n.replace("?","")}`);return(e=>{const t=[];for(const r of j(e)){const e=P(r);if(e){t.push({user:K(e)});continue}const o=L(r);if(!o)continue;const s=P(o.user);if(!s)continue;const n=$(o.expire);t.push({user:K(s),...void 0===n?{}:{muteExpire:n}})}return t})(await e.get(i,{operation:"getGroupMuteList"}))},we=async(e,t,r)=>{const o=oe(t),s=ie(r.groupId,"params.groupId"),n=me(r),a=n?"&":"",i=de(o,`/chatgroups/${encodeURIComponent(s)}/blocks/users?version=v3${a}${n.replace("?","")}`),u=await e.get(i,{operation:"getGroupBlocklist"});return z(u).map(e=>({user:e}))},_e=async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/white/users`),n=await e.get(s,{operation:"getGroupAllowlist"});return z(n).map(e=>({user:e}))},Ge=async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/announcement`);return(e=>{const t=k(e)??{};return{announcement:F(t.announcement)??""}})(await e.get(s,{operation:"getGroupAnnouncement"}))},be=async(e,t,r)=>{const o=oe(t),s=new URLSearchParams;s.set("pagenum",String(r.pageNum??1)),s.set("pagesize",String(r.pageSize??20));const n=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/share_files?${s.toString()}`);return(e=>{const t=J(e,"pagenum"),r=J(e,"pagesize"),o=q(e,r);return{items:j(e).map(e=>W(e)).filter(e=>null!==e),pageNum:t,pageSize:r,...void 0===o?{}:{hasMore:o}}})(await e.get(n,{operation:"getGroupSharedFileList"}))},ve=(e,t)=>{const r=oe(e);return de(r,`/chatgroups/${encodeURIComponent(ie(t.groupId,"params.groupId"))}/share_files/${encodeURIComponent(ie(t.fileId,"params.fileId"))}`)},Re=async(e,t,r)=>{const o=oe(t),s=ie(r.groupId,"params.groupId"),n=ie(r.userId,"params.userId"),a=((e,t,r)=>{if(t!==e.userId)return null;const o=Object.entries(r);if(0===o.length)return null;let s;for(const[n,a]of o){if(!ce.has(n)||"string"!=typeof a)return null;if(void 0!==s){if(s!==a)return null}else s=a}return void 0===s?null:{nameCard:s}})(t,n,r.memberAttributes);if(a){const t=de(o,`/sdk/chatgroups/${encodeURIComponent(s)}/nameCard`);return await e.put(t,a,{operation:"setGroupMemberAttributes"})}const i=de(o,`/sdk/metadata/chatgroup/${encodeURIComponent(s)}/user/${encodeURIComponent(n)}?resource=${o.encodedResource}`);return await e.put(i,{metaData:r.memberAttributes},{operation:"setGroupMemberAttributes"})},Se=async(e,t,r)=>{const o=oe(t),s=de(o,`/sdk/metadata/chatgroup/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/get`);return(e=>{const t=k(e)??{},r=L(t.data)??t,o={};for(const[s,n]of Object.entries(r)){const e=L(n);e&&(o[s]=Object.fromEntries(Object.entries(e).filter(e=>"string"==typeof e[1])))}return{items:o}})(await e.post(s,{targets:ae(r.userIds,"params.userIds"),properties:r.keys??[]},{operation:"getGroupMembersAttributes"}))},Ae=t=>{const r=e(t)?t:{},o=r.data,s=e(o)?o.data:void 0,n=Array.isArray(o)?o:Array.isArray(s)?s:null;if(Array.isArray(n))return Ue(n);const a=e(o)?o:r,i=e(a.namecards)?a.namecards:a,u={};for(const[p,d]of Object.entries(i)){if("string"==typeof d){u[p]={namecard:d};continue}if(!e(d))continue;const t=d.namecard??d.nameCard??d.groupNamecard??d.group_namecard??d.group_name_card;"string"==typeof t&&(u[p]={namecard:t,namecardUpdateTime:Ee(d)})}return u},Ue=t=>{const r={};return t.forEach(t=>{if(!e(t))return;const o=t.username??t.userId??t.userid??t.user_id,s=t.name_card??t.namecard??t.nameCard??t.groupNamecard??t.group_namecard??t.group_name_card;"string"==typeof o&&o.trim()&&"string"==typeof s&&(r[o.trim()]={namecard:s,namecardUpdateTime:Ee(t)})}),r},Ee=e=>y("number"==typeof e.update_timestamp?e.update_timestamp:"number"==typeof e.updateTimestamp?e.updateTimestamp:"number"==typeof e.timestamp?e.timestamp:"number"==typeof e.lastModified?e.lastModified:"number"==typeof e.last_modified?e.last_modified:void 0),Ce=t=>{if(e(t))return y("number"==typeof t.timestamp?t.timestamp:"number"==typeof t.update_timestamp?t.update_timestamp:"number"==typeof t.updateTimestamp?t.updateTimestamp:"number"==typeof t.lastModified?t.lastModified:"number"==typeof t.last_modified?t.last_modified:void 0)};class Oe{constructor(e){this.repository=e}applyPatch(e){e.shouldMarkStale&&this.repository.markStale(e.groupId);const t=this.repository.getDetailSnapshot(e.groupId);if(!e.groupPatch)return t;const r=t??{groupId:e.groupId,name:e.groupPatch.name??e.groupName??""};return this.repository.mergeDetail({...r,...e.groupPatch,groupId:e.groupId})}}const Te=e=>({...e}),Me=e=>({...e,owner:e.owner?{...e.owner}:void 0});class De{constructor(e){this.summarySnapshot=null,this.detailSnapshot=null,this.loadedSummary=!1,this.stale=!1,this.loadedDetail=!1,this.lastPatchedAt=null,this.lastHydratedAt=null,this.groupId=e}mergeSummary(e){e.groupId===this.groupId&&(this.summarySnapshot=Te({...this.summarySnapshot??{},...e,groupId:this.groupId}),this.loadedSummary=!0,this.lastPatchedAt=Date.now())}mergeDetail(e){e.groupId===this.groupId&&(this.detailSnapshot=Me({...this.detailSnapshot??this.summarySnapshot??{groupId:this.groupId,name:""},...e,groupId:this.groupId}),this.summarySnapshot=Te(this.toSummaryFromDetail(this.detailSnapshot)),this.loadedSummary=!0,this.loadedDetail=!0,this.stale=!1,this.lastPatchedAt=Date.now(),this.lastHydratedAt=Date.now())}markStale(){this.stale=!0,this.lastPatchedAt=Date.now()}clear(){this.summarySnapshot=null,this.detailSnapshot=null,this.loadedSummary=!1,this.stale=!1,this.loadedDetail=!1,this.lastPatchedAt=null,this.lastHydratedAt=null}getSummarySnapshot(){return this.summarySnapshot?Te(this.summarySnapshot):this.detailSnapshot?Te(this.toSummaryFromDetail(this.detailSnapshot)):null}getDetailSnapshot(){return this.detailSnapshot?Me(this.detailSnapshot):null}isStale(){return this.stale}hasLoadedSummary(){return this.loadedSummary}hasLoadedDetail(){return this.loadedDetail}getLastPatchedAt(){return this.lastPatchedAt}getLastHydratedAt(){return this.lastHydratedAt}toSummaryFromDetail(e){return{groupId:e.groupId,name:e.name,description:e.description,memberCount:e.memberCount,public:e.public,joinApprovalRequired:e.joinApprovalRequired,allowInvites:e.allowInvites,maxMembers:e.maxMembers,role:e.role,disabled:e.disabled}}}class Ne{toSummary(e){const t=e.getSummarySnapshot();return t?(e=>({...e}))(t):null}toDetail(e){const t=e.getDetailSnapshot();return t?(e=>({...e,owner:e.owner?{...e.owner}:void 0}))(t):null}}class Le{constructor(){this.groups=/* @__PURE__ */new Map,this.joinedGroupById=/* @__PURE__ */new Map,this.removedJoinedGroupIds=/* @__PURE__ */new Set,this.snapshotMapper=new Ne,this.joinedGroupSnapshot=null,this.sessionKey=null}ensureSession(e){return this.sessionKey!==e&&(this.sessionKey=e,this.groups.clear(),this.joinedGroupById.clear(),this.removedJoinedGroupIds.clear(),this.joinedGroupSnapshot=null,!0)}getSessionKey(){return this.sessionKey}getOrCreate(e){const t=this.groups.get(e);if(t)return t;const r=new De(e);return this.groups.set(e,r),r}mergeSummary(e){return this.getOrCreate(e.groupId).mergeSummary(e),this.getSummarySnapshot(e.groupId)??{...e}}mergeSummaries(e){return e.map(e=>this.mergeSummary(e))}applyJoinedGroupSnapshot(e){const t=e.items.filter(e=>!this.removedJoinedGroupIds.has(e.groupId));this.joinedGroupSnapshot={items:t.map(e=>({...e})),meta:{...e.meta}},this.joinedGroupById.clear();for(const r of t){const e={...r};this.joinedGroupById.set(e.groupId,e),this.mergeSummary(this.toGroupSummary(e))}}getJoinedGroupSnapshot(e){return this.joinedGroupSnapshot?{items:this.joinedGroupSnapshot.items.map(e=>({...e})),meta:{...this.joinedGroupSnapshot.meta}}:e?{items:e.items.filter(e=>!this.removedJoinedGroupIds.has(e.groupId)).map(e=>({...e})),meta:{...e.meta}}:{items:[],meta:{integrity:"unknown",limited:!1,storageLimit:100,serverLimit:3e3,source:"sync"}}}getJoinedGroupSummarySnapshot(e,t){const r=this.joinedGroupById.get(e);if(r)return{...r};if(this.removedJoinedGroupIds.has(e))return null;const o=t?.items.find(t=>t.groupId===e);return o?{...o}:null}addJoinedGroupIfAbsent(e,t){const r=this.getJoinedGroupSnapshot(t);return r.items.some(t=>t.groupId===e.groupId)?null:(this.removedJoinedGroupIds.delete(e.groupId),this.applyJoinedGroupSnapshot({items:[{...e},...r.items],meta:{...r.meta}}),this.getJoinedGroupSnapshot())}mergeJoinedGroupSummary(e,t){const r=this.joinedGroupById.get(e);if(!r||!this.joinedGroupSnapshot)return null;const o={...r,...t,groupId:e};return this.joinedGroupById.set(e,o),this.mergeSummary(this.toGroupSummary(o)),this.joinedGroupSnapshot={items:this.joinedGroupSnapshot.items.map(t=>t.groupId===e?{...o}:{...t}),meta:{...this.joinedGroupSnapshot.meta}},this.getJoinedGroupSnapshot()}mergeDetail(e){const t=this.mergeJoinedGroupFieldsIntoDetail(e);return this.getOrCreate(t.groupId).mergeDetail(t),this.getDetailSnapshot(t.groupId)??{...t}}mergeDetails(e){return e.map(e=>this.mergeDetail(e))}getSummarySnapshot(e){const t=this.groups.get(e);return t?this.snapshotMapper.toSummary(t):null}getDetailSnapshot(e){const t=this.groups.get(e);return t?this.snapshotMapper.toDetail(t):null}hasFreshDetail(e){const t=this.groups.get(e);return Boolean(t&&t.hasLoadedDetail()&&!t.isStale())}markStale(e){this.getOrCreate(e).markStale()}delete(e){this.groups.delete(e),this.joinedGroupById.delete(e),this.joinedGroupSnapshot&&(this.joinedGroupSnapshot={items:this.joinedGroupSnapshot.items.filter(t=>t.groupId!==e).map(e=>({...e})),meta:{...this.joinedGroupSnapshot.meta}})}markJoinedGroupRemoved(e){this.removedJoinedGroupIds.add(e),this.delete(e)}clear(){this.groups.clear(),this.joinedGroupById.clear(),this.removedJoinedGroupIds.clear(),this.joinedGroupSnapshot=null}mergeJoinedGroupFieldsIntoDetail(e){const t=this.joinedGroupById.get(e.groupId);return t&&void 0===e.joinedAt&&void 0!==t.joinedAt?{...e,joinedAt:t.joinedAt}:e}toGroupSummary(e){return{groupId:e.groupId,name:e.name,description:e.description,memberCount:e.memberCount,role:e.role,disabled:e.disabled}}}const Fe=0,Pe=5,$e=12,xe=13,je=0,ke=1,Je=2,qe=0,Be=1,He=2,Ve=3,Ke=e=>{const t=e.group_id?.trim();return t?{groupId:t,name:e.group_name??"",description:e.description,memberCount:e.members_count,role:(o=e.role,o===je?"owner":o===ke?"admin":o===Je?"member":void 0),disabled:e.disabled,ownerId:e.group_owner,avatarUrl:e.group_avatar,muteAllMembers:e.mute_all,muteExpiration:e.mute_expiration,remindType:(r=e.remind_type,r===qe?"DEFAULT":r===Be?"ALL":r===He?"AT":r===Ve?"NONE":void 0),createdAt:e.create_at,updatedAt:e.update_at,joinedAt:e.joined_timestamp}:null;var r,o},ze=e=>e.updatedAt??0,We=(e,t)=>{if(!e)return!0;return ze(t)>=ze(e)},Qe={nested:{easemob:{nested:{joinedgroups:{nested:{GatewayHeader:{fields:{resource:{type:"string",id:1},timestamp:{type:"int64",id:2},request_id:{type:"string",id:3},protocol_version:{type:"int32",id:4}}},GetJoinedGroupsRequest:{fields:{type:{type:"int32",id:1},header:{type:"GatewayHeader",id:2},org:{type:"string",id:3},app:{type:"string",id:4},username:{type:"string",id:5},last_sync_time:{type:"int64",id:6},cursor:{type:"string",id:7}}},GroupItem:{fields:{group_id:{type:"string",id:1},group_name:{type:"string",id:2},group_owner:{type:"string",id:3},members_count:{type:"int64",id:4},mute_all:{type:"bool",id:5},disabled:{type:"bool",id:6},description:{type:"string",id:7},group_avatar:{type:"string",id:8},role:{type:"uint32",id:9},mute_expiration:{type:"int64",id:10},remind_type:{type:"int32",id:11},create_at:{type:"uint64",id:12},update_at:{type:"uint64",id:13},joined_timestamp:{type:"int64",id:14}}},GetJoinedGroupsResponse:{fields:{type:{type:"int32",id:1},header:{type:"GatewayHeader",id:2},groups:{rule:"repeated",type:"GroupItem",id:3},is_last_batch:{type:"bool",id:4},last_sync_finished_ts:{type:"int64",id:5},cursor:{type:"string",id:6}}},ErrorDetail:{fields:{type:{type:"int32",id:1},header:{type:"GatewayHeader",id:2},code:{type:"uint32",id:3},message:{type:"string",id:4}}}}}}}}};let Ye=null,Xe=!1;const Ze=()=>Ye||(Xe||(E.util.Long=A,E.configure(),Xe=!0),U(),Ye=E.Root.fromJSON(Qe),C(Ye),Ye),et=e=>Ze().lookupType(e),tt=e=>{if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&e.length>0){const t=Number(e);return Number.isFinite(t)?t:void 0}if(A.isLong(e))return e.toNumber();if(e&&"object"==typeof e&&"toString"in e&&"function"==typeof e.toString){const t=Number(e.toString());return Number.isFinite(t)?t:void 0}},rt=e=>{if(!e||"object"!=typeof e)return;const t=e;return{resource:"string"==typeof t.resource?t.resource:"",timestamp:tt(t.timestamp)??0,requestId:"string"==typeof t.request_id?t.request_id:"string"==typeof t.requestId?t.requestId:"",protocolVersion:tt(t.protocol_version)??tt(t.protocolVersion)??0}};class ot{constructor(){this.requestType=et("easemob.joinedgroups.GetJoinedGroupsRequest"),this.responseType=et("easemob.joinedgroups.GetJoinedGroupsResponse"),this.errorType=et("easemob.joinedgroups.ErrorDetail")}encodeRequest(e){const t=this.requestType.create({type:e.type,header:e.header?{resource:e.header.resource,timestamp:e.header.timestamp,request_id:e.header.requestId,protocol_version:e.header.protocolVersion}:void 0,org:e.org,app:e.app,username:e.username,last_sync_time:e.lastSyncTime??0,cursor:e.cursor});return this.requestType.encode(t).finish()}decode(e){const t=this.tryDecodeError(e);if(t)return t;const r=this.tryDecodeResponse(e);if(r)return r;const o=this.tryDecodeRequest(e);return o||{type:Fe}}tryDecodeRequest(e){try{const t=this.requestType.toObject(this.requestType.decode(e),{longs:String,bytes:Uint8Array}),r=tt(t.type);return r!==$e?null:{type:r,header:rt(t.header),org:"string"==typeof t.org?t.org:"",app:"string"==typeof t.app?t.app:"",username:"string"==typeof t.username?t.username:"",lastSyncTime:tt(t.last_sync_time)??tt(t.lastSyncTime)??0,cursor:"string"==typeof t.cursor?t.cursor:void 0}}catch{return null}}tryDecodeResponse(e){try{const t=this.responseType.toObject(this.responseType.decode(e),{longs:String,bytes:Uint8Array}),r=tt(t.type);return r!==xe?null:{type:r,header:rt(t.header),groups:Array.isArray(t.groups)?t.groups.map(e=>(e=>{const t=e&&"object"==typeof e?e:{};return{group_id:"string"==typeof t.group_id?t.group_id:"string"==typeof t.groupId?t.groupId:void 0,group_name:"string"==typeof t.group_name?t.group_name:"string"==typeof t.groupName?t.groupName:void 0,group_owner:"string"==typeof t.group_owner?t.group_owner:"string"==typeof t.groupOwner?t.groupOwner:void 0,members_count:tt(t.members_count)??tt(t.membersCount),mute_all:"boolean"==typeof t.mute_all?t.mute_all:"boolean"==typeof t.muteAll?t.muteAll:void 0,disabled:"boolean"==typeof t.disabled?t.disabled:void 0,description:"string"==typeof t.description?t.description:void 0,group_avatar:"string"==typeof t.group_avatar?t.group_avatar:"string"==typeof t.groupAvatar?t.groupAvatar:void 0,role:tt(t.role),mute_expiration:tt(t.mute_expiration)??tt(t.muteExpiration),remind_type:tt(t.remind_type)??tt(t.remindType),create_at:tt(t.create_at)??tt(t.createAt),update_at:tt(t.update_at)??tt(t.updateAt),joined_timestamp:tt(t.joined_timestamp)??tt(t.joinedTimestamp)}})(e)):[],isLastBatch:!0===t.is_last_batch||!0===t.isLastBatch,lastSyncFinishedTs:tt(t.last_sync_finished_ts)??tt(t.lastSyncFinishedTs),cursor:"string"==typeof t.cursor?t.cursor:void 0}}catch{return null}}tryDecodeError(e){try{const t=this.errorType.toObject(this.errorType.decode(e),{longs:String,bytes:Uint8Array}),r=tt(t.type);return r!==Pe?null:{type:r,header:rt(t.header),code:tt(t.code)??0,message:"string"==typeof t.message?t.message:"Unknown joined groups sync error"}}catch{return null}}}class st{constructor(e){this.batches=[],this.done=!1,this.requestId=e}getResumeCursor(){return this.latestCursor}push(e){if(e.type!==xe)return{done:!1};const t=e.header?.requestId;if(t!==this.requestId)return{done:!1};if(this.done)throw new s("Joined groups response received after completion",o.REST_BUSINESS_UNKNOWN,{details:{stage:"response_decode",requestId:this.requestId}});if(this.batches.push(e),e.cursor&&(this.latestCursor=e.cursor),e.isLastBatch){if("number"!=typeof e.lastSyncFinishedTs)throw new s("Joined groups final batch missing lastSyncFinishedTs",o.REST_BUSINESS_UNKNOWN,{details:{stage:"completion_meta",requestId:this.requestId}});this.done=!0,this.lastSyncFinishedTs=e.lastSyncFinishedTs}return{done:this.done}}buildResult(){return{batches:this.batches.map(e=>({...e,groups:e.groups.map(e=>({...e}))})),lastSyncFinishedTs:this.lastSyncFinishedTs}}}const nt=e=>e.type===xe,at=e=>e.type===Pe;class it{constructor(e){this.codec=new ot,this.sharedSession=e}async sync(e){const t=e.request.header?.requestId??`group-sync-${Date.now()}`,r=new st(t);return await this.syncWithSharedSession(e.request,t,r)}cancel(){this.sharedSession.cancel("group-sync-cancelled")}async syncWithSharedSession(e,t,r){return await this.sharedSession.request({dataType:"group",label:"Group sync",requestId:t,encode:()=>this.codec.encodeRequest(this.buildAttemptRequest(e,t,r.getResumeCursor())),decode:e=>{const t=this.codec.decode(e);return{type:t.type,requestId:nt(t)||at(t)?t.header?.requestId:void 0,frame:t}},onFrame:e=>{try{if(nt(e)){if(!r.push(e).done)return;return{done:!0,result:r.buildResult()}}if(at(e))throw(e=>{const t=(t,r)=>({stage:t,serverCode:e.code,requestId:e.header?.requestId,retryable:r});switch(e.code){case 1601:return new s(e.message,o.VALIDATION_REQUIRED,{details:t("request_send",!1)});case 1602:return new s(e.message,o.REST_BUSINESS_UNKNOWN,{details:t("batch_merge",!0)});case 1002:return new n(e.message,{code:o.AUTH_UNAUTHORIZED,details:t("auth",!1)});case 1003:return new s(e.message,o.SERVICE_LIMIT_EXCEEDED,{details:t("server_limit",!0)});default:return new s(e.message,o.REST_BUSINESS_UNKNOWN,{details:t("response_decode",!0)})}})(e);return}catch(t){throw t instanceof s?t:new s("Joined groups frame decode failed",o.CONTACT_SYNC_PROTO_DECODE_FAILED,{details:{stage:"response_decode",cause:t instanceof Error?t.message:String(t)}})}}})}buildAttemptRequest(e,t,r){return{...e,cursor:r,lastSyncTime:0,header:{resource:e.header?.resource??"",timestamp:Date.now(),requestId:t,protocolVersion:e.header?.protocolVersion??1}}}}class ut{constructor(e){this.running=null,this.dependencies=e}async sync(){if(this.running)return await this.running;this.running=this.runSync();try{await this.running}finally{this.running=null}}cancel(){this.dependencies.getSharedSyncSession().cancel("group-sync-cancelled")}async runSync(){this.dependencies.onStart();const e=Date.now();try{const r=await this.dependencies.getSyncUrls();if(0===r.length)throw new s("Group sync websocket urls are unavailable",o.CONTACT_SYNC_SOCKET_FAILED,{details:{stage:"socket_connect",retryable:!0}});const n=this.buildRequest(),u=await new it(this.dependencies.getSharedSyncSession()).sync({urls:r,request:n}),p=u.batches.flatMap(e=>(e=>{const t=[];for(const r of e){const e=Ke(r);e&&t.push(e)}return t})(e.groups)),d=this.dependencies.getRuntimeSnapshot(),c=(e=>{const t=new Map(e.existingItems.map(e=>[e.groupId,e])),r=/* @__PURE__ */new Map;for(const s of e.incomingItems){const e=r.get(s.groupId)??t.get(s.groupId);We(e,s)?r.set(s.groupId,{...e??{},...s,groupId:s.groupId}):e&&r.set(s.groupId,{...e})}const o=r.size>=Y;return{items:Array.from(o?e.existingItems.map(e=>({...e})):r.values()).sort((e,t)=>{const r=(t.joinedAt??0)-(e.joinedAt??0);return 0!==r?r:e.groupId.localeCompare(t.groupId)}),meta:{integrity:o?"limited":"synced",limited:o,storageLimit:Q,serverLimit:Y,source:"sync",lastSyncFinishedTs:e.lastSyncFinishedTs,lastSuccessfulAt:Date.now()}}})({existingItems:d?.items??[],incomingItems:p,lastSyncFinishedTs:u.lastSyncFinishedTs}),m=this.dependencies.getCacheManager();this.dependencies.applyRuntimeSnapshot(c);const l=this.dependencies.getRuntimeSnapshot()??c;try{await m.commitJoinedGroupPreviewSnapshot(l);const e=this.dependencies.getRuntimeSnapshot();e&&!this.hasSameMembership(l,e)&&await m.commitJoinedGroupPreviewSnapshot(e)}catch(t){throw d&&this.dependencies.applyRuntimeSnapshot(d),new a("Joined-group preview persistence failed",{details:{stage:"preview_persist",cause:t instanceof Error?t.message:String(t)}})}i.warn("Group sync finished",{durationMs:Date.now()-e,itemCount:c.items.length,limited:c.meta.limited}),this.dependencies.onFinish({status:"success"})}catch(t){const r=(e=>{const t=e instanceof s?e:new s("Group sync failed",o.REST_BUSINESS_UNKNOWN,{details:{stage:"socket_connect",cause:e instanceof Error?e.message:String(e)}}),r=t.details??{},n=r.serverCode;return{dataType:"group",code:t.code,stage:(a=r.stage,"config"===a||"socket_connect"===a||"request_send"===a||"response_decode"===a||"batch_merge"===a||"preview_persist"===a||"completion_meta"===a||"auth"===a||"server_limit"===a||"cancelled"===a?a:"socket_connect"),message:t.message,retryable:!0===r.retryable,serverCode:"number"==typeof n||"string"==typeof n?n:void 0};var a})(t);i.warn("Group sync failed",{durationMs:Date.now()-e,stage:r.stage,code:r.code,serverCode:r.serverCode}),this.dependencies.onFinish({status:"failed",error:r})}}hasSameMembership(e,t){if(e.items.length!==t.items.length)return!1;const r=new Set(t.items.map(e=>e.groupId));return e.items.every(e=>r.has(e.groupId))}buildRequest(){const e=this.dependencies.getRestContext(),{orgName:r,appName:o}=t(e.appKey);return{type:$e,header:{resource:e.clientResource,timestamp:Date.now(),requestId:`group-sync-${Date.now()}`,protocolVersion:1},org:r,app:o,username:e.userId,lastSyncTime:0}}}const pt=g(I,{common:{},apis:{createGroup:{range:"4,110,204,608",errors:{invalid_parameter:{code:110,httpStatus:400,retryable:!1},illegal_argument:{code:110,httpStatus:400,retryable:!1},exceed_limit:{code:4,httpStatus:403,retryable:!1},group_name_violation:{code:608,httpStatus:403,retryable:!1,aliases:["INVALID_GROUP_NAME"]},resource_not_found:{code:204,httpStatus:404,retryable:!1,aliases:["service_resource_not_found","username_not_found"]}}},getJoinedGroupList:{range:"",errors:{}},getGroupInfo:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},getGroupInfoList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},updateGroupInfo:{range:"110,603,606,607,608",errors:{group_authorization:{code:603,httpStatus:403,retryable:!1},forbidden_op:{code:603,httpStatus:403,retryable:!1},illegal_argument:{code:110,httpStatus:400,retryable:!1},exceed_limit:{code:110,httpStatus:403,retryable:!1},group_name_violation:{code:608,httpStatus:403,retryable:!1},resource_not_found:{code:606,httpStatus:404,retryable:!1},group_disabled:{code:607,httpStatus:403,retryable:!1}}},changeGroupOwner:{range:"603,606",errors:{forbidden_op:{code:603,httpStatus:403,retryable:!1},resource_not_found:{code:606,httpStatus:404,retryable:!1}}},destroyGroup:{range:"603,606,607",errors:{group_authorization:{code:603,httpStatus:403,retryable:!1},resource_not_found:{code:606,httpStatus:404,retryable:!1},group_disabled:{code:607,httpStatus:403,retryable:!1}}},leaveGroup:{range:"602,603,606",errors:{not_joined:{code:602,retryable:!1,aliases:["GROUP_NOT_JOINED","group_not_joined"]},owner_cannot_leave:{code:603,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"owner can not quit group"},resource_not_found:{code:606,httpStatus:404,retryable:!1}}},joinGroup:{range:"600-607,613",errors:{group_invalid_id:{code:600,retryable:!1,aliases:["GROUP_INVALID_ID"]},already_joined:{code:601,retryable:!1,aliases:["ALREADY_JOINED","GROUP_ALREADY_JOINED","group_already_joined"]},not_joined:{code:602,retryable:!1,aliases:["GROUP_NOT_JOINED","group_not_joined"]},group_authorization:{code:603,httpStatus:403,retryable:!1,aliases:["NEED_APPROVAL","GROUP_PERMISSION_DENIED"]},group_full:{code:604,httpStatus:403,retryable:!1,aliases:["GROUP_FULL","GROUP_MEMBERS_FULL"],matchField:"error_description",matchPattern:"member list is full"},resource_not_found:{code:606,httpStatus:404,retryable:!1,aliases:["GROUP_NOT_FOUND","service_resource_not_found"]},group_disabled:{code:607,retryable:!1,aliases:["GROUP_DISABLED"]},group_user_in_blocklist:{code:613,httpStatus:403,retryable:!1,aliases:["GROUP_USER_IN_BLOCKLIST"],matchField:"error_description",matchPattern:"is in the blacklist"}}},inviteUsersToGroup:{range:"204,603,606,607",errors:{group_authorization:{code:603,httpStatus:400,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1,aliases:["service_resource_not_found","username_not_found"]},group_not_found:{code:606,retryable:!1,aliases:["GROUP_NOT_FOUND"]},group_disabled:{code:607,retryable:!1}}},acceptGroupJoinRequest:{range:"",errors:{}},rejectGroupJoinRequest:{range:"",errors:{}},acceptInvitation:{range:"",errors:{}},rejectInvitation:{range:"",errors:{}},removeGroupMembers:{range:"",errors:{}},addGroupAdmin:{range:"",errors:{}},removeGroupAdmin:{range:"",errors:{}},muteGroupMembers:{range:"",errors:{}},unmuteGroupMembers:{range:"",errors:{}},muteAllGroupMembers:{range:"",errors:{}},unmuteAllGroupMembers:{range:"",errors:{}},blockGroupMembers:{range:"",errors:{}},unblockGroupMembers:{range:"",errors:{}},addUsersToGroupAllowlist:{range:"",errors:{}},removeUsersFromGroupAllowlist:{range:"",errors:{}},checkIfInGroupAllowList:{range:"",errors:{}},getGroupMemberList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1,aliases:["service_resource_not_found"]}}},getGroupAdminList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},getGroupMuteList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},checkIfInGroupMuteList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},getGroupBlocklist:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},getGroupAllowlist:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},getGroupAnnouncement:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1}}},updateGroupAnnouncement:{range:"110",errors:{announcement_length_exceeded:{code:110,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"announce into length exceeds limit"},announcement_info_length_exceeded:{code:110,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"announce info length exceeds limit"}}},getGroupSharedFileList:{range:"606",errors:{resource_not_found:{code:606,httpStatus:404,retryable:!1,aliases:["RestGroupFeignException"]}}},deleteGroupSharedFile:{range:"603,605,606",errors:{group_authorization:{code:603,retryable:!1},file_not_found:{code:605,retryable:!1,aliases:["GROUP_SHARED_FILE_INVALID_ID"]},resource_not_found:{code:606,retryable:!1}}},setGroupMemberAttributes:{range:"4,210,302,305,602,609-612",errors:{attributes_reach_limit:{code:609,retryable:!1,aliases:["GROUP_MEMBER_ATTRIBUTES_REACH_LIMIT"],matchField:"error_code",matchValue:60006},attributes_update_failed:{code:610,retryable:!1,aliases:["GROUP_MEMBER_ATTRIBUTES_UPDATE_FAILED"],matchField:"error_code",matchValue:60005},attributes_key_reach_limit:{code:611,retryable:!1,aliases:["GROUP_MEMBER_ATTRIBUTES_KEY_REACH_LIMIT"],matchField:"error_code",matchValue:60009},attributes_value_reach_limit:{code:612,retryable:!1,aliases:["GROUP_MEMBER_ATTRIBUTES_VALUE_REACH_LIMIT"],matchField:"error_code",matchValue:600010},not_joined:{code:602,httpStatus:404,retryable:!1,matchField:"error_code",matchValue:60003},permission_denied:{code:210,httpStatus:401,retryable:!1,matchField:"error_code",matchValue:60001},permission_denied_403:{code:210,httpStatus:403,retryable:!1,matchField:"error_code",matchValue:60002},exceed_service_limit:{code:4,httpStatus:400,retryable:!1,matchField:"error_code",matchValue:60007},service_disabled:{code:305,httpStatus:403,retryable:!1,matchField:"error_code",matchValue:60004}}},getGroupMembersAttributes:{range:"606",errors:{resource_not_found:{code:606,retryable:!1}}},getGroupNamecards:{range:"",errors:{}}}}),dt=class{constructor(){this.capabilities=["rawNotify:group","group:namecard"],this.client=null,this.eventContext=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null,this.groupRegistry=/* @__PURE__ */new Map,this.groupRepository=null,this.groupEventSync=null}bind(e,t){this.client=e,this.eventContext=t??null,this.groupRegistry.clear(),this.groupRepository=new Le,this.groupEventSync=new Oe(this.groupRepository),this.ensureRepositorySession()}addEventHandler(e,t){this.eventContext?.addEventHandler(e,t)}removeEventHandler(e){this.eventContext?.removeEventHandler(e)}async handleRawNotify(e){if("group"!==e.type)return;const t=e.payload,r=t.eventName,o=await this.buildIncomingEventPayload(r,t);if(!o)return;if(this.eventContext?.dispatch?.(r,o),r!==b.GROUP_MEMBER_ATTRIBUTE_CHANGED)return;if(!("attribute"in o)||!("user"in o))return;const s=this.extractGroupNamecard(o.attribute);if(void 0===s||!o.user?.userId)return;const n=this.client?.getCurrentUserId();o.user.userId!==n&&(this.getCacheManager()?.setGroupNamecards([{groupId:o.groupId,userId:o.user.userId,namecard:s,lastAccess:Date.now(),lastUpdate:Date.now()}]),this.eventContext?.dispatch?.(b.USER_GROUP_NAMECARD_UPDATED,{groupId:o.groupId,userId:o.user.userId,namecard:s}))}async createGroup(e){return this.runOperation("createGroup",async()=>{const t=this.getRestContextOrThrow(),r=await le(this.getRestClient(t),t,e);return this.ensureRepositorySession(),this.addJoinedGroupIfAbsent({groupId:r.groupId,name:e.name,role:"owner",ownerId:t.userId,...void 0===e.description?{}:{description:e.description},...void 0===e.avatar?{}:{avatarUrl:e.avatar}}),r})}getJoinedGroupList(){return this.getJoinedGroupSnapshotForSync().items}getJoinedGroupSnapshotForSync(){return this.requireClient(),this.ensureRepositorySession(),this.getGroupRepository().getJoinedGroupSnapshot(this.loadJoinedGroupPreviewSnapshot())}applyJoinedGroupSnapshot(e){this.ensureRepositorySession(),this.getGroupRepository().applyJoinedGroupSnapshot(e)}getGroupSummaryForHandle(e){return this.requireClient(),this.ensureRepositorySession(),this.getGroupRepository().getJoinedGroupSummarySnapshot(e,this.loadJoinedGroupPreviewSnapshot())}getGroup(e){this.requireClient(),this.ensureRepositorySession();const t=e.trim();if(0===t.length)throw new r("groupId is required",{code:o.VALIDATION_REQUIRED,details:{fields:[{path:"groupId",message:"groupId is required",rule:"required"}]}});const s=this.groupRegistry.get(t);if(s)return s;this.getGroupSummaryForHandle(t),this.getGroupRepository().getOrCreate(t);const n=new re(t,this);return this.groupRegistry.set(t,n),n}async getGroupInfo(e){return this.runOperation("getGroupInfo",async()=>{this.ensureRepositorySession();const t=this.getRestContextOrThrow(),r=await he(this.getRestClient(t),t,e),o=await this.hydrateGroupDetailUsers(r);return this.getGroupRepository().mergeDetail(o)})}async getGroupInfoList(t){return this.runOperation("getGroupInfoList",async()=>{this.ensureRepositorySession();const r=this.getRestContextOrThrow(),o=await(async(t,r,o)=>{const s=oe(r),n=ae(o.groupIds,"params.groupIds"),a=de(s,`/chatgroups/${n.map(e=>encodeURIComponent(e)).join(",")}?joined_time=true&version=v3`),i=await t.get(a,{operation:"getGroupInfoList"});return(e(i)&&Array.isArray(i.data)?i.data:[]).map(e=>V({data:[e]}))})(this.getRestClient(r),r,t),s=await this.hydrateGroupDetailsUsers(o);return this.getGroupRepository().mergeDetails(s)})}async getGroupDetailForHandle(e){this.ensureRepositorySession();const t=this.getGroupRepository();if(t.getOrCreate(e),t.hasFreshDetail(e)){const r=t.getDetailSnapshot(e);if(r)return r}return this.getGroupInfo({groupId:e})}async refreshGroupDetailForHandle(e){return this.ensureRepositorySession(),this.getGroupRepository().getOrCreate(e),this.getGroupInfo({groupId:e})}resetSessionRuntime(){this.groupRegistry.clear(),this.getGroupRepository().ensureSession(null)}async buildIncomingEventPayload(e,t){this.ensureRepositorySession();const r=t.payload,o=e===b.GROUP_DESTROYED?this.resolveLocalGroupName(r.groupId):void 0,s=await this.resolveUserInfoMap(this.collectEventUserIds(t));switch(await this.syncRuntimeForEvent(e,r,s),e){case b.INVITATION_RECEIVED:return{groupId:r.groupId,groupName:r.groupName,inviter:this.pickEventUser(r.inviterId,s),reason:r.reason};case b.REQUEST_TO_JOIN_RECEIVED:return{groupId:r.groupId,groupName:r.groupName,applicant:this.pickEventUser(r.applicantId,s),reason:r.reason};case b.REQUEST_TO_JOIN_ACCEPTED:return{groupId:r.groupId,groupName:r.groupName,accepter:this.pickEventUser(r.accepterId,s)};case b.REQUEST_TO_JOIN_DECLINED:return{groupId:r.groupId,groupName:r.groupName,decliner:this.pickEventUser(r.declinerId,s),applicant:this.pickEventUser(r.applicantId,s),reason:r.reason};case b.INVITATION_ACCEPTED:case b.INVITATION_DECLINED:return{groupId:r.groupId,invitee:this.pickEventUser(r.inviteeId,s),reason:r.reason};case b.USER_REMOVED:return{groupId:r.groupId,groupName:r.groupName};case b.GROUP_DESTROYED:return{groupId:r.groupId,groupName:r.groupName??o};case b.AUTO_ACCEPT_INVITATION:return{groupId:r.groupId,inviter:this.pickEventUser(r.inviterId,s),inviteMessage:r.reason};case b.MUTE_LIST_ADDED:return{groupId:r.groupId,mutes:this.pickEventUsers(r.userIds,s),muteExpire:r.muteExpire};case b.MUTE_LIST_REMOVED:return{groupId:r.groupId,mutes:this.pickEventUsers(r.userIds,s)};case b.ALLOW_LIST_ADDED:case b.ALLOW_LIST_REMOVED:return{groupId:r.groupId,allowlist:this.pickEventUsers(r.userIds,s)};case b.ALL_MEMBER_MUTE_STATE_CHANGED:return{groupId:r.groupId,isMuted:Boolean(r.isMuted)};case b.ADMIN_ADDED:case b.ADMIN_REMOVED:return{groupId:r.groupId,administrator:this.pickEventUser(r.administratorId,s)};case b.OWNER_CHANGED:return{groupId:r.groupId,newOwner:this.pickEventUser(r.newOwnerId,s),oldOwner:this.pickEventUser(r.oldOwnerId,s)};case b.MEMBERS_JOINED:return{groupId:r.groupId,groupName:await this.resolveMembersJoinedGroupName(r),members:this.pickEventUsers(r.memberIds,s)};case b.MEMBERS_EXITED:return{groupId:r.groupId,members:this.pickEventUsers(r.memberIds,s)};case b.ANNOUNCEMENT_CHANGED:return{groupId:r.groupId,announcement:r.announcement??""};case b.SHARED_FILE_ADDED:return{groupId:r.groupId,sharedFile:this.hydrateEventSharedFile(r.sharedFile,s)};case b.SHARED_FILE_DELETED:return{groupId:r.groupId,fileId:r.fileId??""};case b.GROUP_INFO_CHANGED:return{groupId:r.groupId,groupInfo:await this.resolveGroupDetailForEvent(r)};case b.GROUP_DISABLED_CHANGED:{const e=await this.resolveGroupDetailForEvent(r),t=void 0===r.isDisabled?Boolean(e.disabled):Boolean(r.isDisabled);return{groupId:r.groupId,groupInfo:e,disabled:t}}case b.GROUP_MEMBER_ATTRIBUTE_CHANGED:return{groupId:r.groupId,user:this.pickEventUser(r.userId,s),attribute:r.attribute??{},from:r.from,source:r.source};default:return null}}async resolveGroupDetailForEvent(e){this.ensureRepositorySession();const t=void 0===e.isDisabled?e.groupPatch:{...e.groupPatch??{},disabled:e.isDisabled},r=this.getGroupEventSync().applyPatch({groupId:e.groupId,groupName:e.groupName,groupPatch:t,shouldMarkStale:e.shouldFetchGroupDetail});if(e.shouldFetchGroupDetail)try{return await this.getGroupInfo({groupId:e.groupId})}catch(s){i.warn("GroupManager resolveGroupDetailForEvent fallback to snapshot",{groupId:e.groupId,error:s})}if(r)return r;const o=this.getGroupRepository().getDetailSnapshot(e.groupId);return o||{groupId:e.groupId,name:t?.name??e.groupName??"",...t??{}}}async updateGroupInfo(e){return this.runOperation("updateGroupInfo",async()=>{const t=this.getRestContextOrThrow();await ge(this.getRestClient(t),t,e)})}async changeGroupOwner(e){return this.runOperation("changeGroupOwner",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}?resource=${o.encodedResource}`);await e.put(s,{newowner:ie(r.newOwner,"params.newOwner")},{operation:"changeGroupOwner"})})(this.getRestClient(t),t,e)})}async destroyGroup(e){return this.runOperation("destroyGroup",async()=>{this.ensureRepositorySession();const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}?version=v3&resource=${o.encodedResource}`);await e.delete(s,{operation:"destroyGroup"})})(this.getRestClient(t),t,e),await this.requireClient().handleGroupDestroyedConversation(e.groupId),await this.removeJoinedGroupLocal(e.groupId)})}async leaveGroup(e){return this.runOperation("leaveGroup",async()=>{this.ensureRepositorySession();const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/quit?resource=${o.encodedResource}`);await e.delete(s,{operation:"leaveGroup"})})(this.getRestClient(t),t,e),await this.removeJoinedGroupLocal(e.groupId)})}async joinGroup(e){return this.runOperation("joinGroup",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/apply?resource=${o.encodedResource}`);await e.post(s,{message:r.message??""},{operation:"joinGroup"})})(this.getRestClient(t),t,e)})}async inviteUsersToGroup(e){return this.runOperation("inviteUsersToGroup",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/invite?resource=${o.encodedResource}`);await e.post(s,{usernames:ae(r.userIds,"params.userIds")},{operation:"inviteUsersToGroup"})})(this.getRestClient(t),t,e)})}async acceptGroupJoinRequest(e){return this.runOperation("acceptGroupJoinRequest",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/apply_verify?resource=${o.encodedResource}`);await e.post(s,{applicant:ie(r.userId,"params.userId"),verifyResult:!0},{operation:"acceptGroupJoinRequest"})})(this.getRestClient(t),t,e)})}async rejectGroupJoinRequest(e){return this.runOperation("rejectGroupJoinRequest",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/apply_verify?resource=${o.encodedResource}`);await e.post(s,{applicant:ie(r.userId,"params.userId"),verifyResult:!1,reason:r.reason},{operation:"rejectGroupJoinRequest"})})(this.getRestClient(t),t,e)})}async acceptInvitation(e){return this.runOperation("acceptInvitation",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/invite_verify?resource=${o.encodedResource}`);await e.post(s,{invitee:t.userId,verifyResult:!0},{operation:"acceptInvitation"})})(this.getRestClient(t),t,e)})}async rejectInvitation(e){return this.runOperation("rejectInvitation",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/invite_verify?resource=${o.encodedResource}`);await e.post(s,{invitee:t.userId,verifyResult:!1},{operation:"rejectInvitation"})})(this.getRestClient(t),t,e)})}async getGroupMemberList(e){return this.runOperation("getGroupMemberList",async()=>{const t=this.getRestContextOrThrow(),r=await Ie(this.getRestClient(t),t,e);return{...r,items:await this.hydrateEntriesWithUsers(e.groupId,r.items)}})}async removeGroupMembers(e){return this.runOperation("removeGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=ae(r.userIds,"params.userIds"),n=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/users/${s.map(e=>encodeURIComponent(e)).join(",")}?resource=${o.encodedResource}`);await e.delete(n,{operation:"removeGroupMembers"})})(this.getRestClient(t),t,e)})}async getGroupAdminList(e){return this.runOperation("getGroupAdminList",async()=>{const t=this.getRestContextOrThrow(),r=await ye(this.getRestClient(t),t,e);return this.hydrateUserInfos(e.groupId,r)})}async addGroupAdmin(e){return this.runOperation("addGroupAdmin",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/admin?resource=${o.encodedResource}`);await e.post(s,{newadmin:r.userId},{operation:"addGroupAdmin"})})(this.getRestClient(t),t,e)})}async removeGroupAdmin(e){return this.runOperation("removeGroupAdmin",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/admin/${encodeURIComponent(r.userId)}?resource=${o.encodedResource}`);await e.delete(s,{operation:"removeGroupAdmin"})})(this.getRestClient(t),t,e)})}async getGroupMuteList(e){return this.runOperation("getGroupMuteList",async()=>{const t=this.getRestContextOrThrow(),r=await fe(this.getRestClient(t),t,e);return this.hydrateEntriesWithUsers(e.groupId,r)})}async muteGroupMembers(e){return this.runOperation("muteGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/mute?resource=${o.encodedResource}`);await e.post(s,{usernames:ae(r.userIds,"params.userIds"),mute_duration:r.muteDuration},{operation:"muteGroupMembers"})})(this.getRestClient(t),t,e)})}async unmuteGroupMembers(e){return this.runOperation("unmuteGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=ae(r.userIds,"params.userIds"),n=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/mute/${s.map(e=>encodeURIComponent(e)).join(",")}?resource=${o.encodedResource}`);await e.delete(n,{operation:"unmuteGroupMembers"})})(this.getRestClient(t),t,e)})}async muteAllGroupMembers(e){return this.runOperation("muteAllGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/ban?resource=${o.encodedResource}`);await e.post(s,void 0,{operation:"muteAllGroupMembers"})})(this.getRestClient(t),t,e)})}async unmuteAllGroupMembers(e){return this.runOperation("unmuteAllGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/ban?resource=${o.encodedResource}`);await e.delete(s,{operation:"unmuteAllGroupMembers"})})(this.getRestClient(t),t,e)})}async getGroupBlocklist(e){return this.runOperation("getGroupBlocklist",async()=>{const t=this.getRestContextOrThrow(),r=await we(this.getRestClient(t),t,e);return this.hydrateEntriesWithUsers(e.groupId,r)})}async blockGroupMembers(e){return this.runOperation("blockGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/blocks/users?resource=${o.encodedResource}`);await e.post(s,{usernames:ae(r.userIds,"params.userIds")},{operation:"blockGroupMembers"})})(this.getRestClient(t),t,e)})}async unblockGroupMembers(e){return this.runOperation("unblockGroupMembers",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=ae(r.userIds,"params.userIds"),n=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/blocks/users/${s.map(e=>encodeURIComponent(e)).join(",")}?resource=${o.encodedResource}`);await e.delete(n,{operation:"unblockGroupMembers"})})(this.getRestClient(t),t,e)})}async getGroupAllowlist(e){return this.runOperation("getGroupAllowlist",async()=>{const t=this.getRestContextOrThrow(),r=await _e(this.getRestClient(t),t,e);return this.hydrateEntriesWithUsers(e.groupId,r)})}async addUsersToGroupAllowlist(e){return this.runOperation("addUsersToGroupAllowlist",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/white/users?resource=${o.encodedResource}`);await e.post(s,{usernames:ae(r.userIds,"params.userIds")},{operation:"addUsersToGroupAllowlist"})})(this.getRestClient(t),t,e)})}async removeUsersFromGroupAllowlist(e){return this.runOperation("removeUsersFromGroupAllowlist",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=ae(r.userIds,"params.userIds"),n=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/white/users/${s.map(e=>encodeURIComponent(e)).join(",")}?resource=${o.encodedResource}`);await e.delete(n,{operation:"removeUsersFromGroupAllowlist"})})(this.getRestClient(t),t,e)})}async checkIfInGroupAllowList(t){return this.runOperation("checkIfInGroupAllowList",async()=>{const r=this.getRestContextOrThrow();return(async(t,r,o)=>{const s=oe(r),n=de(s,`/chatgroups/${encodeURIComponent(ie(o.groupId,"params.groupId"))}/white/users/${s.encodedUserId}?version=v3`),a=await t.get(n,{operation:"checkIfInGroupAllowList"});return"boolean"==typeof a?a:e(a)&&"boolean"==typeof a.data?a.data:Boolean(a)})(this.getRestClient(r),r,t)})}async checkIfInGroupMuteList(t){return this.runOperation("checkIfInGroupMuteList",async()=>{const r=this.getRestContextOrThrow();return(async(t,r,o)=>{const s=oe(r),n=de(s,`/sdk/chatgroups/${encodeURIComponent(ie(o.groupId,"params.groupId"))}/mute/${s.encodedUserId}?version=v3`),a=await t.get(n,{operation:"checkIfInGroupMuteList"});return"boolean"==typeof a?a:e(a)&&"boolean"==typeof a.data?a.data:Boolean(a)})(this.getRestClient(r),r,t)})}async getGroupAnnouncement(e){return this.runOperation("getGroupAnnouncement",async()=>{const t=this.getRestContextOrThrow();return Ge(this.getRestClient(t),t,e)})}async updateGroupAnnouncement(e){return this.runOperation("updateGroupAnnouncement",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/announcement?resource=${o.encodedResource}`);await e.post(s,{announcement:r.announcement},{operation:"updateGroupAnnouncement"})})(this.getRestClient(t),t,e)})}async getGroupSharedFileList(e){return this.runOperation("getGroupSharedFileList",async()=>{const t=this.getRestContextOrThrow(),r=await be(this.getRestClient(t),t,e),o=await this.resolveGroupContextUserInfoMap(e.groupId,r.items.map(e=>e.fileOwner).filter(e=>void 0!==e));return{...r,items:r.items.map(e=>({...e,fileOwner:e.fileOwner?.userId?o.get(e.fileOwner.userId)??e.fileOwner:e.fileOwner}))}})}async uploadGroupSharedFile(e){return this.runOperation("uploadGroupSharedFile",async()=>{const t=this.getRestContextOrThrow(),r=ve(t,{groupId:e.groupId,fileId:"__upload__"}).replace(/\/share_files\/__upload__$/,"/share_files"),n=u({file:e.file}),a=p({operationName:"GROUP_UPLOAD_SHAREDFILE",operationType:"GROUP"}),i=a?.startRequest({requestName:"GROUP_UPLOAD_SHAREDFILE",method:"POST",url:`${t.restBaseUrl}${r}`});try{const u=await(this.requireClient().getUploadAdapter()?.upload({url:`${t.restBaseUrl}${r}?resource=${encodeURIComponent(t.clientResource)}`,headers:{Authorization:`Bearer ${t.token}`,[c]:m()},source:n.source,timeoutMs:d,onProgress:e.onFileUploadProgress}));if(!u)throw new Error("platform upload adapter is unavailable");if(u.status<200||u.status>=300)throw new s("uploadGroupSharedFile failed",o.REST_HTTP_ERROR,{details:{status:u.status}});i?.finish({code:u.status,success:!0}),a?.finish({code:0,success:!0}),e.onFileUploadComplete?.(u.body)}catch(l){const t=f(l);throw i?.finish({code:t.code,success:!1,description:t.message}),a?.finish({code:t.code,success:!1,description:t.message}),t.code===o.UPLOAD_ABORTED&&e.onFileUploadCanceled?.(),e.onFileUploadError?.(t),t}})}async deleteGroupSharedFile(e){return this.runOperation("deleteGroupSharedFile",async()=>{const t=this.getRestContextOrThrow();await(async(e,t,r)=>{const o=oe(t),s=de(o,`/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/share_files/${encodeURIComponent(ie(r.fileId,"params.fileId"))}?resource=${o.encodedResource}`);await e.delete(s,{operation:"deleteGroupSharedFile"})})(this.getRestClient(t),t,e)})}async downloadGroupSharedFile(e){return this.runOperation("downloadGroupSharedFile",async()=>{let t,r;try{const n=this.getRestContextOrThrow(),a=`${n.restBaseUrl}${ve(n,e)}`;t=p({operationName:"GROUP_DOWNLOAD_SHAREDFILE",operationType:"GROUP"}),r=t?.startRequest({requestName:"GROUP_DOWNLOAD_SHAREDFILE",method:"GET",url:a});const i=this.requireClient().getRequestAdapter();if(!i)throw new s("downloadGroupSharedFile request adapter is unavailable",o.REST_NETWORK_ERROR);const u=await i.request({url:a,method:"GET",headers:{Authorization:`Bearer ${n.token}`,...e.secret?{"Share-Secret":e.secret}:{},[c]:m()},responseType:"arraybuffer",timeoutMs:l});if(u.status<200||u.status>=300)throw r?.finish({code:u.status,success:!1,description:"downloadGroupSharedFile failed"}),t?.finish({code:u.status,success:!1,description:"downloadGroupSharedFile failed"}),new s("downloadGroupSharedFile failed",o.REST_HTTP_ERROR);r?.finish({code:u.status,success:!0}),t?.finish({code:0,success:!0});const d="undefined"!=typeof Blob?new Blob([u.data]):u.data;e.onFileDownloadComplete?.(d)}catch(n){const a=n instanceof s?n.code:o.REST_NETWORK_ERROR,i=n instanceof Error?n.message:String(n);throw r?.finish({code:a,success:!1,description:i}),t?.finish({code:a,success:!1,description:i}),e.onFileDownloadError?.(n),n}})}async setGroupMemberAttributes(e){return this.runOperation("setGroupMemberAttributes",async()=>{const t=this.getRestContextOrThrow(),r=await Re(this.getRestClient(t),t,e);this.writeSelfGroupNamecardCache(t.userId,e,r)})}async getGroupMembersAttributes(e){return this.runOperation("getGroupMembersAttributes",async()=>{const t=this.getRestContextOrThrow();return Se(this.getRestClient(t),t,e)})}async hydrateMessageProfileGroupNamecards(e,t){0!==t.length&&await this.runOperation("hydrateMessageProfileGroupNamecards",async()=>{const r=this.getRestContextOrThrow(),o=t.map(e=>e.userId),s=await(async(e,t,r)=>{const o=oe(t),s=de(o,`/sdk/chatgroups/${encodeURIComponent(ie(r.groupId,"params.groupId"))}/nameCard/batch/get`),n=await e.post(s,{members:ae(r.userIds,"params.userIds")},{operation:"getGroupNamecards"});return{items:Ae(n),responseTimestamp:Ce(n)}})(this.getRestClient(r),r,{groupId:e,userIds:o}),n=new Map(t.map(e=>[e.userId,e.namecardUpdateTime])),a=[],u=/* @__PURE__ */new Set;for(const[t,i]of Object.entries(s.items))u.add(t),a.push({groupId:e,userId:t,namecard:i.namecard,namecardUpdateTime:n.get(t)??i.namecardUpdateTime,lastSyncAt:Date.now(),lastAccess:Date.now(),lastUpdate:Date.now()});const p=o.filter(e=>!u.has(e));p.length>0&&"number"==typeof s.responseTimestamp&&a.push(...p.map(t=>({groupId:e,userId:t,namecard:"",namecardUpdateTime:s.responseTimestamp,lastSyncAt:Date.now(),lastAccess:Date.now(),lastUpdate:Date.now()}))),this.getCacheManager()?.setGroupNamecards(a);for(const e of a)e.userId!==r.userId&&""!==e.namecard&&this.eventContext?.dispatch?.(b.USER_GROUP_NAMECARD_UPDATED,{groupId:e.groupId,userId:e.userId,namecard:e.namecard});p.length>0&&"number"!=typeof s.responseTimestamp&&i.warn("Group namecard hydration returned partial result",{groupId:e,requestedUserIds:o,missingUserIds:p})})}async runOperation(e,t){try{return await t()}catch(r){const t=this.normalizeSdkError(e,r);throw i.warn(`GroupManager ${e} failed`,{code:t.code,message:t.message,details:t.details}),t}}normalizeSdkError(e,t){return t instanceof s?t:t instanceof Error?new s(`GroupManager ${e} failed: ${t.message}`,o.UNKNOWN):new s(`GroupManager ${e} failed`,o.UNKNOWN)}getRestContextOrThrow(){return this.requireClient().getRestContext()}getRestClient(e){return this.restClient&&this.restBaseUrl===e.restBaseUrl&&this.restToken===e.token||(this.restClient=new h(e.restBaseUrl,{errorMap:pt,requestAdapter:this.requireClient().getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(e.token),this.restBaseUrl=e.restBaseUrl,this.restToken=e.token),this.restClient}requireClient(){if(!this.client)throw new s("GroupManager is not bound to client",o.VALIDATION_REQUIRED);return this.client}getGroupRepository(){return this.groupRepository||(this.groupRepository=new Le),this.groupRepository}getGroupEventSync(){return this.groupEventSync||(this.groupEventSync=new Oe(this.getGroupRepository())),this.groupEventSync}ensureRepositorySession(){this.getGroupRepository().ensureSession(this.resolveRepositorySessionKey())&&this.groupRegistry.clear()}resolveRepositorySessionKey(){if(!this.client)return null;const e=this.client.getCurrentUserId();if(!e)return null;try{const e=this.client.getRestContext();return`${e.restBaseUrl}:${e.userId}:${e.token}:${e.clientResource}`}catch{return`pending:${e}`}}getCacheManager(){return this.client?.getCacheManager()??null}loadJoinedGroupPreviewSnapshot(){const e=this.getCacheManager();if(e&&"function"==typeof e.loadJoinedGroupPreviewSnapshot)return e.loadJoinedGroupPreviewSnapshot()}resolveLocalGroupName(e){const t=this.getGroupRepository(),r=t.getSummarySnapshot(e)?.name;if(r)return r;const o=t.getJoinedGroupSummarySnapshot(e,this.loadJoinedGroupPreviewSnapshot())?.name;return o||void 0}async resolveMembersJoinedGroupName(e){const t=this.resolveUsableGroupName(this.resolveLocalGroupName(e.groupId),e.groupId);if(t)return t;const r=this.resolveUsableGroupName(e.groupName,e.groupId);if(r)return r;const o=this.getGroupRepository().getSessionKey();try{const t=this.getRestContextOrThrow(),r=await he(this.getRestClient(t),t,{groupId:e.groupId}),s=this.getGroupRepository();if(s.getSessionKey()!==o)return;return s.mergeDetail(r),this.resolveUsableGroupName(r.name,e.groupId)}catch(s){return void i.warn("Members joined group detail enrichment failed",{groupId:e.groupId,error:s})}}resolveUsableGroupName(e,t){const r=e?.trim();return r&&r!==t?r:void 0}writeSelfGroupNamecardCache(e,t,r){if(t.userId!==e)return;const o=this.extractGroupNamecard(t.memberAttributes);if("string"!=typeof o)return;const s=this.resolveGroupMemberAttributesUpdateTime(r,t.userId);"number"!=typeof s&&i.warn("Group member attributes update response missing server update time",{groupId:t.groupId,userId:t.userId}),this.getCacheManager()?.setGroupNamecards([{groupId:t.groupId,userId:t.userId,namecard:o,namecardUpdateTime:s,lastSyncAt:Date.now(),lastAccess:Date.now(),lastUpdate:Date.now()}])}resolveGroupMemberAttributesUpdateTime(e,t){const r=[];this.collectUpdateTimeCandidates(e,t,r);for(const o of r){const e=y("number"==typeof o?o:Number(o));if("number"==typeof e)return e}}collectUpdateTimeCandidates(t,r,o){if(!e(t))return;o.push(t.lastModified,t.last_modified,t.timestamp,t.updateTime,t.update_time,t.updatedAt,t.updated_at);const s=t.data;if(e(s)){this.collectUpdateTimeCandidates(s,r,o);const t=s[r];e(t)&&this.collectUpdateTimeCandidates(t,r,o)}const n=t.lastModified??t.last_modified;e(n)&&o.push(n[r])}getUserInfoManager(){const e=this.requireClient();if(!this.hasUserInfoCapabilityProvider(e))return null;const t=e.getManagerByCapability("userInfo:read");return t&&this.hasUserInfoReadCapability(t)?t:null}hasUserInfoCapabilityProvider(e){return"function"==typeof e.getManagerByCapability}hasUserInfoReadCapability(e){return"function"==typeof e.getUserInfoByUserId}async resolveUserInfoMap(e){return N(e,{cacheManager:this.getCacheManager(),fetchUserInfos:async({userIds:e})=>{const t=this.getUserInfoManager();if(0===e.length)return[];if(!t)return await this.fetchUserInfosFromRest(e);try{return await t.getUserInfoByUserId({userIds:e})}catch(r){return i.warn("GroupManager user info fetch failed",{userIds:e,error:r}),[]}}})}collectEventUserIds(e){const t=e.payload,r=[t.inviterId,t.applicantId,t.accepterId,t.declinerId,t.inviteeId,t.administratorId,t.oldOwnerId,t.newOwnerId,t.userId,t.sharedFile?.fileOwner?.userId,...t.memberIds??[],...t.userIds??[]],o=[],s=/* @__PURE__ */new Set;for(const n of r){if("string"!=typeof n)continue;const e=n.trim();e&&!s.has(e)&&(s.add(e),o.push(e))}return o}pickEventUser(e,t){if(e)return D(void 0,t.get(e),e)}pickEventUsers(e,t){return(e??[]).map(e=>D(void 0,t.get(e),e))}hydrateEventSharedFile(e,t){return e?.fileOwner?.userId?{...e,fileOwner:D(e.fileOwner,t.get(e.fileOwner.userId),e.fileOwner.userId)}:e}async syncRuntimeForEvent(e,t,r){switch(e){case b.ALL_MEMBER_MUTE_STATE_CHANGED:return void this.getGroupEventSync().applyPatch({groupId:t.groupId,groupName:t.groupName,groupPatch:{muteAllMembers:Boolean(t.isMuted)}});case b.OWNER_CHANGED:return void this.getGroupEventSync().applyPatch({groupId:t.groupId,groupName:t.groupName,groupPatch:{owner:this.pickEventUser(t.newOwnerId,r)}});case b.REQUEST_TO_JOIN_ACCEPTED:case b.AUTO_ACCEPT_INVITATION:return void this.addCurrentUserJoinedGroupFromEvent(t);case b.MEMBERS_JOINED:{let r=!1;if(t.memberIds?.includes(this.requireClient().getCurrentUserId()??"")&&(r=await this.addCurrentUserJoinedGroupFromEvent(t)),r)return;if(this.applyMemberCountDeltaPatch(t.groupId,t.groupName,this.getMemberEventDeltaCount(e,t)))return;return void this.getGroupEventSync().applyPatch({groupId:t.groupId,groupName:t.groupName,shouldMarkStale:!0})}case b.MEMBERS_EXITED:if(this.applyMemberCountDeltaPatch(t.groupId,t.groupName,-this.getMemberEventDeltaCount(e,t)))return;return void this.getGroupEventSync().applyPatch({groupId:t.groupId,groupName:t.groupName,shouldMarkStale:!0});case b.USER_REMOVED:case b.GROUP_DESTROYED:return void(await this.removeJoinedGroupLocal(t.groupId));case b.MUTE_LIST_ADDED:case b.MUTE_LIST_REMOVED:case b.ALLOW_LIST_ADDED:case b.ALLOW_LIST_REMOVED:case b.ADMIN_ADDED:case b.ADMIN_REMOVED:return void this.getGroupEventSync().applyPatch({groupId:t.groupId,groupName:t.groupName,shouldMarkStale:!0});default:return}}getMemberEventDeltaCount(e,t){switch(e){case b.MEMBERS_JOINED:case b.MEMBERS_EXITED:return t.memberIds?.length??0;default:return 0}}applyMemberCountDeltaPatch(e,t,r){if(0===r)return!1;const o=this.getGroupRepository().getDetailSnapshot(e);return!(!o||"number"!=typeof o.memberCount)&&(this.getGroupEventSync().applyPatch({groupId:e,groupName:t,groupPatch:{memberCount:Math.max(0,o.memberCount+r)}}),!0)}async removeJoinedGroupLocal(e){this.getGroupRepository().markJoinedGroupRemoved(e);const t=this.getCacheManager();t&&"function"==typeof t.removeJoinedGroupPreview&&await t.removeJoinedGroupPreview(e)}async addCurrentUserJoinedGroupFromEvent(e){if(!this.addJoinedGroupIfAbsent({groupId:e.groupId,name:e.groupName??"",role:"member"}))return!1;const t=this.getGroupRepository().getSessionKey();let r;try{r=this.getRestContextOrThrow()}catch(o){return i.warn("Joined group detail enrichment skipped",{groupId:e.groupId,error:o}),!1}try{return await this.enrichJoinedGroupFromDetail(e.groupId,t,r)}catch(o){return i.warn("Joined group detail enrichment failed",{groupId:e.groupId,error:o}),!1}}addJoinedGroupIfAbsent(e){const t=this.getGroupRepository().addJoinedGroupIfAbsent(e,this.loadJoinedGroupPreviewSnapshot());return!!t&&(this.persistJoinedGroupSnapshot(t),!0)}async enrichJoinedGroupFromDetail(e,t,r){const o=await he(this.getRestClient(r),r,{groupId:e}),s=this.getGroupRepository();if(s.getSessionKey()!==t)return!1;s.mergeDetail(o);const n=s.getJoinedGroupSummarySnapshot(e);if(!n)return!1;const a=s.mergeJoinedGroupSummary(e,{...n.name||!o.name?{}:{name:o.name},...void 0!==n.description||void 0===o.description?{}:{description:o.description},...void 0!==n.memberCount||void 0===o.memberCount?{}:{memberCount:o.memberCount},...void 0!==n.role||void 0===o.role?{}:{role:o.role},...void 0!==n.disabled||void 0===o.disabled?{}:{disabled:o.disabled},...n.ownerId||!o.owner?.userId?{}:{ownerId:o.owner.userId},...void 0!==n.avatarUrl||void 0===o.avatarUrl?{}:{avatarUrl:o.avatarUrl},...void 0!==n.muteAllMembers||void 0===o.muteAllMembers?{}:{muteAllMembers:o.muteAllMembers},...void 0!==n.createdAt||void 0===o.createdAt?{}:{createdAt:o.createdAt},...void 0!==n.joinedAt||void 0===o.joinedAt?{}:{joinedAt:o.joinedAt}});if(a){this.persistJoinedGroupSnapshot(a);const t=s.getJoinedGroupSummarySnapshot(e);t&&this.requireClient().refreshConversationDisplayFromJoinedGroups([{...t,name:o.name||t.name,avatarUrl:o.avatarUrl??t.avatarUrl}],"profile",{onlyWhenNameMissing:!0})}return!0}persistJoinedGroupSnapshot(e){const t=this.getCacheManager();if(t&&"function"==typeof t.applyJoinedGroupPreviewSnapshot){try{t.applyJoinedGroupPreviewSnapshot(e)}catch(r){return void i.warn("Joined group preview persistence failed",{error:r})}"function"==typeof t.flushPending&&t.flushPending().catch(e=>{i.warn("Joined group preview flush failed",{error:e})})}}async hydrateUserInfos(e,t){const r=await this.resolveGroupContextUserInfoMap(e,t);return t.map(e=>r.get(e.userId)??e)}async fetchUserInfosFromRest(e){const t=this.getRestContextOrThrow(),r=v(e),o=await this.getRestClient(t).request(R(t),{method:"POST",body:r,operation:"getUserInfoByUserId"});return S(o,r.targets)}async hydrateEntriesWithUsers(e,t){const r=await this.resolveGroupContextUserInfoMap(e,t.map(e=>e.user));return t.map(e=>({...e,user:r.get(e.user.userId)??e.user}))}extractGroupNamecard(e){return e.groupNamecard??e.group_namecard??e.group_name_card??e.namecard}async hydrateGroupDetailUsers(e){if(!e.owner?.userId)return e;const t=await this.resolveGroupContextUserInfoMap(e.groupId,[e.owner]);return{...e,owner:t.get(e.owner.userId)??e.owner}}async hydrateGroupDetailsUsers(e){const t=e.filter(e=>Boolean(e.owner?.userId)).map(e=>({groupId:e.groupId,user:e.owner}));if(0===t.length)return e;const r=await this.resolveGroupUserInfoContexts(t);return e.map(e=>e.owner?.userId?{...e,owner:r.get(w(e.groupId,e.owner.userId))??e.owner}:e)}async resolveGroupContextUserInfoMap(e,t){const r=this.isGroupNamecardEnhancementEnabled(),o=await _({groupId:e,users:t,includeNameCard:r,cacheManager:this.getCacheManager(),fetchUserInfos:async({userIds:e})=>await this.fetchGroupUserInfos(e),hydrateGroupNamecards:async(e,t)=>await this.hydrateMessageProfileGroupNamecards(e,t.map(e=>({userId:e})))});return r&&this.dispatchFetchedUserInfoUpdates(o.fetchedUserInfos),o.usersById}async resolveGroupUserInfoContexts(e){const t=this.isGroupNamecardEnhancementEnabled(),r=await G({contexts:e,includeNameCard:t,cacheManager:this.getCacheManager(),fetchUserInfos:async({userIds:e})=>await this.fetchGroupUserInfos(e),hydrateGroupNamecards:async(e,t)=>await this.hydrateMessageProfileGroupNamecards(e,t.map(e=>({userId:e})))});return t&&this.dispatchFetchedUserInfoUpdates(r.fetchedUserInfos),r.usersByContextKey}async fetchGroupUserInfos(e){if(0===e.length)return[];const t=this.getUserInfoManager();return t?await t.getUserInfoByUserId({userIds:e}):await this.fetchUserInfosFromRest(e)}isGroupNamecardEnhancementEnabled(){const e=this.requireClient(),t=e.isUserInfoSyncEnabled;return"function"==typeof t&&t.call(e)}dispatchFetchedUserInfoUpdates(e){if(0===e.length)return;const t=this.requireClient(),r=t.getCurrentUserId(),o=e.find(e=>e.userId===r),s=e.filter(e=>e.userId!==r);o&&t.dispatchOwnInfoUpdated?.(o),t.dispatchUserInfoUpdated?.(s),t.refreshConversationDisplayFromUserInfos?.(e.map(e=>({userId:e.userId})),"profile")}createSyncController(e){return new ut(e)}};dt.key="groupManager";let ct=dt;export{re as G,te as J,ct as a,W as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{V as e,E as t,p as s,S as r,A as a,l as n,f as o,m as i,h as c}from"./common-DN_g4O3n.js";import{i as d}from"./cache-utils-BwRPIZ7n.js";import{b as l,a as u,n as h}from"./user-info-BfRwS4ZA.js";import{a as p,l as g,b as m,L as y}from"./reflection-proto-codec-64ocOTHU.js";const I=e=>({userId:e}),C=e=>({userId:e.userId,nickname:e.nickname,avatarUrl:e.avatarUrl,sign:e.sign,ext:e.ext}),f=e=>e,S=async(e,t)=>{const s=(e=>{const t=[],s=/* @__PURE__ */new Set;for(const r of e){const e=r.trim();e&&!s.has(e)&&(s.add(e),t.push(e))}return t})(e),r=/* @__PURE__ */new Map;if(0===s.length)return r;const a=t.cacheManager?.getUserInfoSummaries(s,!1)??[];for(const o of a)r.set(o.userId,C(o));const n=s.filter(e=>!r.has(e));if(n.length>0&&t.fetchUserInfos){const e=await t.fetchUserInfos({userIds:n});for(const t of e)r.set(t.userId,f(t))}for(const o of s)r.has(o)||r.set(o,I(o));return r},R=async(e,t)=>((e,t,s)=>({userId:s,nickname:t?.nickname??e?.nickname,avatarUrl:t?.avatarUrl??e?.avatarUrl,mail:t?.mail??e?.mail,phone:t?.phone??e?.phone,gender:t?.gender??e?.gender,sign:t?.sign??e?.sign,birth:t?.birth??e?.birth,ext:t?.ext??e?.ext}))(void 0,(await S([e],t)).get(e),e),v={UNSPECIFIED:0,PING:1,PONG:2,REQUEST:3,RESPONSE:4,ERROR:5},E=0,T=0,_=1,U=1001,w=1002,b=1003,k=1004,N=1005,A=1101,O=e=>{const{orgName:t,appName:r}=s(e.appKey);return{orgName:t,appName:r,encodedUserId:encodeURIComponent(e.userId),encodedResource:encodeURIComponent(e.clientResource)}},M=e=>d(e)&&Array.isArray(e.data)?e.data.filter(e=>"string"==typeof e&&e.length>0):Array.isArray(e)?e.filter(e=>"string"==typeof e&&e.length>0):[],q=(s,r)=>{if(!Array.isArray(s.userIds)||0===s.userIds.length)throw new e(`${r} is required`,{code:t.VALIDATION_REQUIRED,details:{fields:[{path:r,message:`${r} is required`,rule:"required"}]}});const a=s.userIds.map((s,a)=>{if("string"!=typeof s)throw new e(`${r}[${a}] must be a string`,{code:t.VALIDATION_INVALID_FORMAT,details:{fields:[{path:`${r}[${a}]`,message:"userId must be a string",rule:"invalid_format"}]}});return s.trim()}),n=(e=>{const t=[],s=/* @__PURE__ */new Set;for(const r of e)r&&!s.has(r)&&(s.add(r),t.push(r));return t})(a);if(0===n.length)throw new e(`${r} is required`,{code:t.VALIDATION_REQUIRED,details:{fields:[{path:r,message:`${r} is required`,rule:"required"}]}});return n.length!==a.length&&d(s),n},D=async(e,t)=>{const s=O(t),r=`/${s.orgName}/${s.appName}/users/${s.encodedUserId}/blocks/users`,a=await e.get(r,{operation:"getBlocklist"});return M(a).map(e=>({userId:e}))},$=async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/sdk/user/${r.encodedUserId}/blocks?resource=${r.encodedResource}`,n=await e.post(a,{usernames:s},{operation:"addUsersToBlocklist"});return{succeeded:M(n).map(e=>({userId:e})),failed:[]}},P={nested:{easemob:{nested:{imfusion:{nested:{gateway:{nested:{v1:{nested:{MessageType:{values:{MESSAGE_TYPE_UNSPECIFIED:0,MESSAGE_TYPE_PING:1,MESSAGE_TYPE_PONG:2,MESSAGE_TYPE_ROSTER_REQUEST:3,MESSAGE_TYPE_ROSTER_RESPONSE:4,MESSAGE_TYPE_ERROR:5}},ServerStatus:{values:{SERVER_STATUS_OK:0,SERVER_STATUS_BUSY:1}},RosterResponseType:{values:{ROSTER_RESPONSE_TYPE_UNSPECIFIED:0,ROSTER_RESPONSE_TYPE_INCREMENTAL:1,ROSTER_RESPONSE_TYPE_FULL:2}},BaseMessage:{fields:{type:{type:"MessageType",id:1}}},GatewayHeader:{fields:{resource:{type:"string",id:1},timestamp:{type:"int64",id:2},requestId:{type:"string",id:3},protocolVersion:{type:"int32",id:4}}},PingRequest:{fields:{type:{type:"MessageType",id:1}}},PongResponse:{fields:{type:{type:"MessageType",id:1},status:{type:"ServerStatus",id:2}}},ErrorDetail:{fields:{type:{type:"MessageType",id:1},code:{type:"string",id:2},message:{type:"string",id:3},header:{type:"GatewayHeader",id:4}}},GetRosterRequest:{fields:{type:{type:"MessageType",id:1},header:{type:"GatewayHeader",id:2},org:{type:"string",id:3},app:{type:"string",id:4},username:{type:"string",id:5},version:{type:"string",id:6},cursor:{type:"uint64",id:7}}},RosterItem:{fields:{contact:{type:"string",id:1},remark:{type:"string",id:2},metadata:{type:"string",id:3},createdAt:{type:"int64",id:4},updatedAt:{type:"int64",id:5},metadataUpdatedAt:{type:"int64",id:6}}},GetRosterResponse:{fields:{type:{type:"MessageType",id:1},header:{type:"GatewayHeader",id:2},data:{rule:"repeated",type:"RosterItem",id:3},cursor:{type:"uint64",id:4},version:{type:"string",id:5},responseType:{type:"RosterResponseType",id:6}}}}}}}}}}}}};let B=!1,F=null;const x=()=>F||(B||(g.util.Long=y,g.configure(),B=!0),p(),F=g.Root.fromJSON(P),m(F),F),L=e=>"number"==typeof e?e:y.isLong(e)?e.toNumber():0,V=e=>{if(!e||"object"!=typeof e)return;const t=e;return{resource:"string"==typeof t.resource?t.resource:"",timestamp:L(t.timestamp),requestId:"string"==typeof t.requestId?t.requestId:"",protocolVersion:L(t.protocolVersion)}};class G{encodeRequest(e){const t=x().lookupType("easemob.imfusion.gateway.v1.GetRosterRequest");return t.encode(t.create(e)).finish()}encodePong(e=E){const t=x().lookupType("easemob.imfusion.gateway.v1.PongResponse");return t.encode(t.create({type:v.PONG,status:e})).finish()}decode(e){const t=x(),s=t.lookupType("easemob.imfusion.gateway.v1.BaseMessage").decode(e);switch(s.type){case v.PING:return{type:v.PING};case v.PONG:{const s=t.lookupType("easemob.imfusion.gateway.v1.PongResponse").decode(e);return{type:v.PONG,status:L(s.status)}}case v.RESPONSE:{const s=t.lookupType("easemob.imfusion.gateway.v1.GetRosterResponse").decode(e);return{type:v.RESPONSE,header:V(s.header),data:Array.isArray(s.data)?s.data.map(e=>(e=>{const t=e&&"object"==typeof e?e:{};return{contact:"string"==typeof t.contact?t.contact:"",remark:"string"==typeof t.remark?t.remark:"",metadata:"string"==typeof t.metadata?t.metadata:"",createdAt:L(t.createdAt),updatedAt:L(t.updatedAt),metadataUpdatedAt:L(t.metadataUpdatedAt)}})(e)):[],cursor:L(s.cursor),version:"string"==typeof s.version?s.version:"",responseType:L(s.responseType)||T}}case v.ERROR:{const s=t.lookupType("easemob.imfusion.gateway.v1.ErrorDetail").decode(e);return{type:v.ERROR,header:V(s.header),code:"string"==typeof s.code?s.code:"",message:"string"==typeof s.message?s.message:"Unknown roster error"}}default:return{type:"number"==typeof s.type?s.type:v.UNSPECIFIED}}}}class Y{constructor(e){this.pages=[],this.responseType=null,this.version="",this.nextCursor=0,this.pageCount=0,this.completed=!1,this.requestId=e}push(e){const s=e.header?.requestId;if(s&&s!==this.requestId)throw new r("Roster response requestId mismatched",t.CONTACT_SYNC_PROTO_DECODE_FAILED,{details:{stage:"response_decode",expectedRequestId:this.requestId,receivedRequestId:s}});if(this.completed)throw new r("Roster response received after completion",t.CONTACT_SYNC_CURSOR_INVALID,{details:{cursor:e.cursor}});if(null!==this.responseType&&this.responseType!==e.responseType)throw new r("Roster response type changed in same session",t.CONTACT_SYNC_CURSOR_INVALID,{details:{expected:this.responseType,received:e.responseType}});if(this.pages.length>0&&0!==e.cursor&&e.cursor===this.pages[this.pages.length-1]?.cursor)throw new r("Roster cursor duplicated",t.CONTACT_SYNC_CURSOR_INVALID,{details:{cursor:e.cursor}});return this.responseType=e.responseType,this.version=e.version||this.version,this.pages.push(e),this.nextCursor=e.cursor,this.pageCount+=1,this.completed=0===e.cursor,{done:this.completed,nextCursor:this.nextCursor,pageCount:this.pageCount}}getNextCursor(){return this.nextCursor}getPageCount(){return this.pageCount}hasPages(){return this.pages.length>0}isCompleted(){return this.completed}buildResult(){return{mode:this.responseType===_?"incremental":"full",version:this.version,pages:this.pages}}}const H=e=>e.type===v.RESPONSE,K=e=>"message"in e&&"code"in e;class W{constructor(e){this.codec=new G,this.sharedSession=e}async sync(e){const t=new Y(e.request.header.requestId);return await this.syncWithSharedSession(e.request,t)}cancel(){this.sharedSession.cancel("contact-sync-cancelled")}async syncWithSharedSession(e,s){return await this.sharedSession.request({dataType:"contact",label:"Roster sync",requestId:e.header.requestId,encode:()=>{const t=this.buildAttemptRequest(e,s.getNextCursor());return this.codec.encodeRequest(t)},decode:e=>{const t=this.codec.decode(e);return{type:t.type,requestId:H(t)||K(t)?t.header?.requestId:void 0,frame:t}},onFrame:async(e,n)=>{try{if(e.type===v.PING)return void(await n.send(this.codec.encodePong()));if(H(e)){if(!s.push(e).done)return;return{done:!0,result:s.buildResult()}}if(K(e))throw(e=>{const s=e.header?.requestId,n=t=>({stage:"sync_page",serverCode:e.code,requestId:s,retryable:t});switch(Number.parseInt(e.code,10)){case w:return new a(e.message,{code:t.AUTH_UNAUTHORIZED,details:n(!1)});case b:return new r(e.message,t.SERVICE_LIMIT_EXCEEDED,{details:n(!0)});case U:return new r(e.message,t.VALIDATION_REQUIRED,{details:n(!1)});case k:return new r(e.message,t.VALIDATION_INVALID_FORMAT,{details:n(!1)});case N:return new r(e.message,t.REST_BUSINESS_UNKNOWN,{details:n(!0)});case A:return new r(e.message,t.CONTACT_SYNC_SOCKET_FAILED,{details:n(!1)});default:return new r(e.message,t.CONTACT_SYNC_SOCKET_FAILED,{details:n(!0)})}})(e);return}catch(o){throw o instanceof r?o:new r("Roster frame decode failed",t.CONTACT_SYNC_PROTO_DECODE_FAILED,{details:{stage:"response_decode",cause:o instanceof Error?o.message:String(o)}})}}})}buildAttemptRequest(e,t){return{...e,cursor:t,header:{...e.header,timestamp:Date.now(),requestId:e.header.requestId}}}}const j=e=>e.versionState.version?"incremental":"full",Q=e=>{const{metadata:t,metadataFailed:s,state:r}=e,a=r.versionState.version;return s||!t?{decision:"complete"===r.cacheMeta.cacheIntegrity?j(r):"full",version:a}:t.requiresSync||"complete"!==r.cacheMeta.cacheIntegrity?t.requiresSync&&"complete"===r.cacheMeta.cacheIntegrity&&a?{decision:"incremental",version:t.version||a}:{decision:"full",version:t.version||a}:{decision:"skip",version:t.version||a}},z=e=>{if(!e)return{};try{const t=JSON.parse(e);return{nickname:"string"==typeof t.nickname?t.nickname:void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:"string"==typeof t.avatarurl?t.avatarurl:void 0,sign:"string"==typeof t.sign?t.sign:void 0,ext:"string"==typeof t.ext?t.ext:void 0}}catch{return{}}},J=e=>{const t=(e=>{if(!(e instanceof r&&e.details))return null;const t=e.details.httpStatus;return"number"==typeof t?t:null})(e);return 401===t||403===t||404===t},X=(e,t,s,r)=>({code:t,stage:e,message:`${e}: ${s}`,retryable:r}),Z=e=>{n.warn("Contact sync duration",e)};class ee{constructor(e){this.running=null,this.dependencies=e}async sync(){if(this.running)return await this.running;this.running=this.runSync();try{await this.running}finally{this.running=null}}cancel(){this.dependencies.getSharedSyncSession().cancel("contact-sync-cancelled")}async runSync(){const e=this.dependencies.getContextState(),s=Date.now();let a;this.dependencies.onStart();try{const t=await this.dependencies.queryMetadata(e.versionState.version);if(a=Q({metadata:t,state:e}),"skip"===a.decision)return this.dependencies.onFinish(),void Z({outcome:"skip",decision:a.decision,durationMs:Date.now()-s,version:a.version,hasUsableSnapshot:e.cachedSnapshot.complete})}catch(n){if(J(n)){const a=Q({metadataFailed:!0,state:e}),o=n instanceof r?n:new r("Contact metadata request failed",t.CONTACT_SYNC_METADATA_FAILED,{details:{stage:"metadata"}});return this.dependencies.onFinish({error:X("metadata",o.code,o.message,!1)}),void Z({outcome:"fail",decision:a.decision,durationMs:Date.now()-s,version:e.versionState.version,stage:"metadata",hasUsableSnapshot:e.cachedSnapshot.complete,source:e.cachedSnapshot.complete?e.cachedSnapshot.source:void 0})}if(a=Q({metadataFailed:!0,state:e}),e.cachedSnapshot.complete)return this.dependencies.onFinish({error:X("metadata",t.CONTACT_SYNC_METADATA_FAILED,n instanceof Error?n.message:String(n),!0)}),void Z({outcome:"fail",decision:a.decision,durationMs:Date.now()-s,version:a.version,stage:"metadata",hasUsableSnapshot:!0,source:e.cachedSnapshot.source})}try{const t=await this.dependencies.getSyncUrls(),r=this.dependencies.buildRosterRequest({decision:a.decision,version:e.versionState.version}),n=await new W(this.dependencies.getSharedSyncSession()).sync({urls:t,request:r}),o=(e=>{const t=[];for(const s of e)for(const e of s.data){const s=z(e.metadata);t.push({relation:{userId:e.contact,remark:e.remark,sign:s.sign??"",addTs:e.createdAt,updatedAt:e.updatedAt,metadataUpdatedAt:e.metadataUpdatedAt},userInfo:{userId:e.contact,nickname:s.nickname,avatarUrl:s.avatarUrl,sign:s.sign,ext:s.ext}})}return t})(n.pages),i=this.dependencies.applySyncResult({mode:n.mode,relations:o.map(e=>e.relation),userInfos:o.map(e=>e.userInfo),version:n.version,lastSyncTs:Date.now()});this.dependencies.onFinish(),Z({outcome:"finish",decision:a.decision,durationMs:Date.now()-s,version:n.version,source:"sync",changed:i.changed,hasUsableSnapshot:i.snapshot.complete})}catch(n){const o=n instanceof r?n:new r("Contact sync failed",t.CONTACT_SYNC_SOCKET_FAILED,{details:{stage:"sync_page",cause:n instanceof Error?n.message:String(n)}}),i=o.details??{},c="string"==typeof i.stage?i.stage:"sync_page";this.dependencies.onFinish({error:X(c,o.code,o.message,!0)}),Z({outcome:"fail",decision:a.decision,durationMs:Date.now()-s,version:a.version,stage:c,hasUsableSnapshot:e.cachedSnapshot.complete,source:e.cachedSnapshot.complete?e.cachedSnapshot.source:void 0})}}}const te={items:[],loaded:!1,source:"server"},se=i(c,{common:{},apis:{getContactList:{range:"",errors:{}},addContact:{range:"110,204,210,1000,1001,1002",localErrors:{addContact:{validation_invalid:{code:110,retryable:!1}}},errors:{USER_NOT_FOUND:{code:204,httpStatus:404,retryable:!1},ALREADY_FRIEND:{code:1e3,retryable:!1},BLOCKED_BY_USER:{code:210,retryable:!1},CONTACT_REACH_LIMIT:{code:1001,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"Inviter's contact max count"},CONTACT_REACH_LIMIT_PEER:{code:1002,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"Invitee's contact max count"}}},deleteContact:{range:"110,204",localErrors:{deleteContact:{validation_invalid:{code:110,retryable:!1}}},errors:{USER_NOT_FOUND:{code:204,httpStatus:404,retryable:!1}}},acceptContactInvite:{range:"110,204,1001,1002",localErrors:{acceptContactInvite:{validation_invalid:{code:110,retryable:!1}}},errors:{USER_NOT_FOUND:{code:204,httpStatus:404,retryable:!1},CONTACT_REACH_LIMIT:{code:1001,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"Inviter's contact max count"},CONTACT_REACH_LIMIT_PEER:{code:1002,httpStatus:403,retryable:!1,matchField:"error_description",matchPattern:"Invitee's contact max count"}}},declineContactInvite:{range:"110,204",localErrors:{declineContactInvite:{validation_invalid:{code:110,retryable:!1}}},errors:{USER_NOT_FOUND:{code:204,httpStatus:404,retryable:!1}}},setContactRemark:{range:"4,110,223",localErrors:{setContactRemark:{validation_invalid:{code:110,retryable:!1}}},errors:{illegal_argument:{code:223,httpStatus:400,retryable:!1,matchField:"error_description",matchPattern:"please add as a friend first"},remark_length_exceeded:{code:4,httpStatus:400,retryable:!1,matchField:"error_description",matchPattern:"remark length must less than"}}},getBlocklist:{range:"",errors:{}},addUsersToBlocklist:{range:"4,110,204",localErrors:{addUsersToBlocklist:{validation_invalid:{code:110,retryable:!1}}},errors:{service_resource_not_found:{code:204,httpStatus:404,retryable:!1},blocklist_limit_exceeded:{code:4,httpStatus:400,retryable:!1,matchField:"error_description",matchPattern:"almost reached or been greater than the upper range"}}},removeUserFromBlocklist:{range:"110",localErrors:{removeUserFromBlocklist:{validation_invalid:{code:110,retryable:!1}}},errors:{}}}}),re=class{constructor(){this.client=null,this.eventContext=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null,this.blocklistSnapshot=te,this.blocklistSessionKey=null}bind(e,t){this.client=e,this.eventContext=t??null,this.blocklistSnapshot=te,this.blocklistSessionKey=null}getContacts(){return this.client?.getContactSnapshot()?.items??[]}async addContact(e){return this.runOperation("addContact",async()=>{const t=this.validateUserId(e.userId,"params.userId"),s=this.validateOptionalString(e.message,"params.message"),r=this.getRestContextOrThrow(),a=this.getRestClient(r);n.debug("ContactManager addContact",{userId:t,hasMessage:"string"==typeof s&&s.length>0}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/users/${r.encodedUserId}/contacts/apply?resource=${r.encodedResource}`;await e.post(a,{usernames:[s.userId],reason:s.message??""},{operation:"addContact"})})(a,r,{userId:t,message:s})})}async deleteContact(e){return this.runOperation("deleteContact",async()=>{const t=this.validateUserId(e.userId,"params.userId"),s=this.getRestContextOrThrow(),r=this.getRestClient(s);n.debug("ContactManager deleteContact",{userId:t}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/users/${r.encodedUserId}/contacts/users/${encodeURIComponent(s.userId)}?resource=${r.encodedResource}`;await e.delete(a,{operation:"deleteContact"})})(r,s,{userId:t});const a=this.client?.getCacheManager()?.removeContact(t);n.debug("ContactManager deleteContact patched cache",{userId:t,changed:a?.changed??!1})})}async acceptContactInvite(e){return this.runOperation("acceptContactInvite",async()=>{const t=this.validateUserId(e.userId,"params.userId"),s=this.getRestContextOrThrow(),r=this.getRestClient(s);n.debug("ContactManager acceptContactInvite",{userId:t}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/users/${r.encodedUserId}/contacts/accept/users/${encodeURIComponent(s.userId)}?resource=${r.encodedResource}`;await e.post(a,void 0,{operation:"acceptContactInvite"})})(r,s,{userId:t}),await this.requireClient().refreshContactSnapshot()})}async declineContactInvite(e){return this.runOperation("declineContactInvite",async()=>{const t=this.validateUserId(e.userId,"params.userId"),s=this.getRestContextOrThrow(),r=this.getRestClient(s);n.debug("ContactManager declineContactInvite",{userId:t}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/users/${r.encodedUserId}/contacts/decline/users/${encodeURIComponent(s.userId)}?resource=${r.encodedResource}`;await e.post(a,void 0,{operation:"declineContactInvite"})})(r,s,{userId:t})})}async setContactRemark(e){return this.runOperation("setContactRemark",async()=>{const t=this.validateUserId(e.userId,"params.userId"),s=this.validateRemark(e.remark,"params.remark"),r=this.getRestContextOrThrow(),a=this.getRestClient(r);n.debug("ContactManager setContactRemark",{userId:t,remarkLength:s.length}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/users/${r.encodedUserId}/contacts/users/${encodeURIComponent(s.userId)}?resource=${r.encodedResource}`;await e.put(a,{remark:s.remark},{operation:"setContactRemark"})})(a,r,{userId:t,remark:s});const o=this.client?.getCacheManager()?.updateContactRemark(t,s);this.client?.refreshConversationDisplayFromUserInfos([{userId:t}],"profile"),n.debug("ContactManager setContactRemark patched cache",{userId:t,changed:o?.changed??!1})})}async getBlocklist(){return this.runOperation("getBlocklist",async()=>{const e=this.getRestContextOrThrow();this.ensureBlocklistSession(e);const t=this.getRestClient(e);if(this.blocklistSnapshot.loaded)return this.blocklistSnapshot.items;const s=await this.enrichBlocklistUsers(await D(t,e));return this.blocklistSnapshot={items:s,loaded:!0,source:"server"},n.debug("ContactManager getBlocklist",{count:s.length}),s})}async addUsersToBlocklist(e){return this.runOperation("addUsersToBlocklist",async()=>{const t=this.getRestContextOrThrow();this.ensureBlocklistSession(t);const s=q(e,"params.userIds"),r=this.getRestClient(t);n.debug("ContactManager addUsersToBlocklist",{userIds:s,inputCount:e.userIds.length,normalizedCount:s.length});const a=await $(r,t,s),o=await this.enrichBlocklistUsers(a.succeeded);return this.blocklistSnapshot=this.patchBlocklistSnapshotWithAdditions(o),{succeeded:o,failed:await this.enrichBlocklistUsers(a.failed)}})}async removeUserFromBlocklist(e){return this.runOperation("removeUserFromBlocklist",async()=>{const t=this.getRestContextOrThrow();this.ensureBlocklistSession(t);const s=q(e,"params.userIds"),r=this.getRestClient(t);n.debug("ContactManager removeUserFromBlocklist",{userIds:s,inputCount:e.userIds.length,normalizedCount:s.length}),await(async(e,t,s)=>{const r=O(t),a=`/${r.orgName}/${r.appName}/sdk/user/${r.encodedUserId}/blocks?resource=${r.encodedResource}`;await e.request(a,{method:"DELETE",body:{usernames:s},operation:"removeUserFromBlocklist"})})(r,t,s),this.blocklistSnapshot=this.patchBlocklistSnapshotWithRemovals(s)})}addEventHandler(e,t){this.eventContext?.addEventHandler(e,t)}removeEventHandler(e){this.eventContext?.removeEventHandler(e)}async runOperation(e,t){try{return await t()}catch(s){const t=this.normalizeSdkError(e,s);throw n.warn(`ContactManager ${e} failed`,{code:t.code,message:t.message,details:t.details}),t}}normalizeSdkError(e,s){return s instanceof r?s:s instanceof Error?new r(`ContactManager ${e} failed: ${s.message}`,t.UNKNOWN):new r(`ContactManager ${e} failed`,t.UNKNOWN)}requireClient(){if(!this.client)throw this.buildValidationError("ContactManager is not bound to client",[{path:"contactManager.client",message:"ContactManager is not bound to client",rule:"required"}]);return this.client}getRestContextOrThrow(){return this.requireClient().getRestContext()}getRestClient(e){return this.restClient&&this.restBaseUrl===e.restBaseUrl&&this.restToken===e.token||(this.restClient=new o(e.restBaseUrl,{errorMap:se,requestAdapter:this.requireClient().getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(e.token),this.restBaseUrl=e.restBaseUrl,this.restToken=e.token),this.restClient}ensureBlocklistSession(e){const t=`${e.restBaseUrl}:${e.userId}:${e.token}`;this.blocklistSessionKey!==t&&(this.blocklistSessionKey=t,this.blocklistSnapshot=te)}patchBlocklistSnapshotWithAdditions(e){const t=new Map(this.blocklistSnapshot.items.map(e=>[e.userId,e]));for(const s of e)t.set(s.userId,s);return{items:Array.from(t.values()),loaded:this.blocklistSnapshot.loaded,source:"mutation_patch"}}patchBlocklistSnapshotWithRemovals(e){const t=new Map(this.blocklistSnapshot.items.map(e=>[e.userId,e]));for(const s of e)t.delete(s);return{items:Array.from(t.values()),loaded:this.blocklistSnapshot.loaded,source:"mutation_patch"}}validateUserId(e,t){if("string"!=typeof e)throw this.buildValidationError("userId must be a string",[{path:t,message:"userId must be a string",rule:"invalid_format"}]);const s=e.trim();if(!s)throw this.buildValidationError("userId is required",[{path:t,message:"userId is required",rule:"required"}]);return s}validateOptionalString(e,t){if(void 0!==e){if("string"!=typeof e)throw this.buildValidationError(`${t} must be a string`,[{path:t,message:`${t} must be a string`,rule:"invalid_format"}]);return e}}validateRemark(e,t){if("string"!=typeof e)throw this.buildValidationError("remark must be a string",[{path:t,message:"remark must be a string",rule:"invalid_format"}]);return e}buildValidationError(s,r){const a=r.some(e=>"invalid_format"===e.rule)?t.VALIDATION_INVALID_FORMAT:t.VALIDATION_REQUIRED;return new e(s,{code:a,details:{fields:r}})}async enrichBlocklistUsers(e){if(0===e.length||!this.requireClient().isUserInfoSyncEnabled())return e;const t=await S(e.map(e=>e.userId),{cacheManager:this.requireClient().getCacheManager(),fetchUserInfos:async({userIds:e})=>await this.fetchUserInfos(e)});return e.map(e=>t.get(e.userId)??e)}async fetchUserInfos(e){if(0===e.length)return[];try{const t=this.getUserInfoManager();return t?await t.getUserInfoByUserId({userIds:e}):await this.fetchUserInfosFromRest(e)}catch(t){return n.warn("ContactManager user info fetch failed",{userIds:e,error:t}),[]}}async fetchUserInfosFromRest(e){const t=this.getRestContextOrThrow(),s=l(e),r=await this.getRestClient(t).request(u(t),{method:"POST",body:s,operation:"getUserInfoByUserId"});return h(r,s.targets)}getUserInfoManager(){const e=this.requireClient();if(!this.hasUserInfoCapabilityProvider(e))return null;const t=e.getManagerByCapability("userInfo:read");return t&&this.hasUserInfoReadCapability(t)?t:null}hasUserInfoCapabilityProvider(e){return"function"==typeof e.getManagerByCapability}hasUserInfoReadCapability(e){return"function"==typeof e.getUserInfoByUserId}createSyncController(e){return new ee(e)}};re.key="contactManager";let ae=re;export{ae as C,v as R,R as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=2147483647,t=t=>{const e=Number(t);if(!Number.isFinite(e)||e<=0)return;const o=Math.floor(e);return o<=0||o>r?void 0:o},e=e=>{if("number"!=typeof e||!Number.isFinite(e)||e<=0)return;const o=e>r?Math.floor(e/1e3):Math.floor(e);return t(o)};export{e as a,t as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=2147483647,e=e=>{const o=Number(e);if(!Number.isFinite(o)||o<=0)return;const t=Math.floor(o);return t<=0||t>r?void 0:t};exports.normalizeProfileVersionFromTimestamp=o=>{if("number"!=typeof o||!Number.isFinite(o)||o<=0)return;const t=o>r?Math.floor(o/1e3):Math.floor(o);return e(t)},exports.normalizeProfileVersionSeconds=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=null;try{e=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 t(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function r(e){return!0===(e&&e.__isLong__)}function i(e){var t=Math.clz32(e&-e);return e?31-t:t}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0}),t.isLong=r;var n={},o={};function s(e,t){var r,i,s;return t?(s=0<=(e>>>=0)&&e<256)&&(i=o[e])?i:(r=a(e,0,!0),s&&(o[e]=r),r):(s=-128<=(e|=0)&&e<128)&&(i=n[e])?i:(r=a(e,e<0?-1:0,!1),s&&(n[e]=r),r)}function u(e,t){if(isNaN(e))return t?g:v;if(t){if(e<0)return g;if(e>=p)return _}else{if(e<=-d)return j;if(e+1>=d)return O}return e<0?u(-e,t).neg():a(e%c|0,e/c|0,t)}function a(e,r,i){return new t(e,r,i)}t.fromInt=s,t.fromNumber=u,t.fromBits=a;var f=Math.pow;function h(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?g:v;if((r=r||10)<2||36<r)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return h(e.substring(1),t,r).neg();for(var n=u(f(r,8)),o=v,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),l=parseInt(e.substring(s,s+a),r);if(a<8){var c=u(f(r,a));o=o.mul(c).add(u(l))}else o=(o=o.mul(n)).add(u(l))}return o.unsigned=t,o}function l(e,t){return"number"==typeof e?u(e,t):"string"==typeof e?h(e,t):a(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}t.fromString=h,t.fromValue=l;var c=4294967296,p=c*c,d=p/2,y=s(1<<24),v=s(0);t.ZERO=v;var g=s(0,!0);t.UZERO=g;var m=s(1);t.ONE=m;var b=s(1,!0);t.UONE=b;var w=s(-1);t.NEG_ONE=w;var O=a(-1,2147483647,!1);t.MAX_VALUE=O;var _=a(-1,-1,!0);t.MAX_UNSIGNED_VALUE=_;var j=a(0,-2147483648,!1);t.MIN_VALUE=j;var A=t.prototype;A.toInt=function(){return this.unsigned?this.low>>>0:this.low},A.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},A.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(j)){var t=u(e),r=this.div(t),i=r.mul(t).sub(this);return r.toString(e)+i.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var n=u(f(e,6),this.unsigned),o=this,s="";;){var a=o.div(n),h=(o.sub(a.mul(n)).toInt()>>>0).toString(e);if((o=a).isZero())return h+s;for(;h.length<6;)h="0"+h;s=""+h+s}},A.getHighBits=function(){return this.high},A.getHighBitsUnsigned=function(){return this.high>>>0},A.getLowBits=function(){return this.low},A.getLowBitsUnsigned=function(){return this.low>>>0},A.getNumBitsAbs=function(){if(this.isNegative())return this.eq(j)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},A.isSafeInteger=function(){var e=this.high>>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},A.isZero=function(){return 0===this.high&&0===this.low},A.eqz=A.isZero,A.isNegative=function(){return!this.unsigned&&this.high<0},A.isPositive=function(){return this.unsigned||this.high>=0},A.isOdd=function(){return!(1&~this.low)},A.isEven=function(){return!(1&this.low)},A.equals=function(e){return r(e)||(e=l(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},A.eq=A.equals,A.notEquals=function(e){return!this.eq(e)},A.neq=A.notEquals,A.ne=A.notEquals,A.lessThan=function(e){return this.comp(e)<0},A.lt=A.lessThan,A.lessThanOrEqual=function(e){return this.comp(e)<=0},A.lte=A.lessThanOrEqual,A.le=A.lessThanOrEqual,A.greaterThan=function(e){return this.comp(e)>0},A.gt=A.greaterThan,A.greaterThanOrEqual=function(e){return this.comp(e)>=0},A.gte=A.greaterThanOrEqual,A.ge=A.greaterThanOrEqual,A.compare=function(e){if(r(e)||(e=l(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},A.comp=A.compare,A.negate=function(){return!this.unsigned&&this.eq(j)?j:this.not().add(m)},A.neg=A.negate,A.add=function(e){r(e)||(e=l(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,o=65535&this.low,s=e.high>>>16,u=65535&e.high,f=e.low>>>16,h=0,c=0,p=0,d=0;return p+=(d+=o+(65535&e.low))>>>16,c+=(p+=n+f)>>>16,h+=(c+=i+u)>>>16,h+=t+s,a((p&=65535)<<16|(d&=65535),(h&=65535)<<16|(c&=65535),this.unsigned)},A.subtract=function(e){return r(e)||(e=l(e)),this.add(e.neg())},A.sub=A.subtract,A.multiply=function(t){if(this.isZero())return this;if(r(t)||(t=l(t)),e)return a(e.mul(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned);if(t.isZero())return this.unsigned?g:v;if(this.eq(j))return t.isOdd()?j:v;if(t.eq(j))return this.isOdd()?j:v;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(y)&&t.lt(y))return u(this.toNumber()*t.toNumber(),this.unsigned);var i=this.high>>>16,n=65535&this.high,o=this.low>>>16,s=65535&this.low,f=t.high>>>16,h=65535&t.high,c=t.low>>>16,p=65535&t.low,d=0,m=0,b=0,w=0;return b+=(w+=s*p)>>>16,m+=(b+=o*p)>>>16,b&=65535,m+=(b+=s*c)>>>16,d+=(m+=n*p)>>>16,m&=65535,d+=(m+=o*c)>>>16,m&=65535,d+=(m+=s*h)>>>16,d+=i*p+n*c+o*h+s*f,a((b&=65535)<<16|(w&=65535),(d&=65535)<<16|(m&=65535),this.unsigned)},A.mul=A.multiply,A.divide=function(t){if(r(t)||(t=l(t)),t.isZero())throw Error("division by zero");var i,n,o;if(e)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?a((this.unsigned?e.div_u:e.div_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?g:v;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return g;if(t.gt(this.shru(1)))return b;o=g}else{if(this.eq(j))return t.eq(m)||t.eq(w)?j:t.eq(j)?m:(i=this.shr(1).div(t).shl(1)).eq(v)?t.isNegative()?m:w:(n=this.sub(t.mul(i)),o=i.add(n.div(t)));if(t.eq(j))return this.unsigned?g:v;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=v}for(n=this;n.gte(t);){i=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(i)/Math.LN2),h=s<=48?1:f(2,s-48),c=u(i),p=c.mul(t);p.isNegative()||p.gt(n);)p=(c=u(i-=h,this.unsigned)).mul(t);c.isZero()&&(c=m),o=o.add(c),n=n.sub(p)}return o},A.div=A.divide,A.modulo=function(t){return r(t)||(t=l(t)),e?a((this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},A.mod=A.modulo,A.rem=A.modulo,A.not=function(){return a(~this.low,~this.high,this.unsigned)},A.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},A.clz=A.countLeadingZeros,A.countTrailingZeros=function(){return this.low?i(this.low):i(this.high)+32},A.ctz=A.countTrailingZeros,A.and=function(e){return r(e)||(e=l(e)),a(this.low&e.low,this.high&e.high,this.unsigned)},A.or=function(e){return r(e)||(e=l(e)),a(this.low|e.low,this.high|e.high,this.unsigned)},A.xor=function(e){return r(e)||(e=l(e)),a(this.low^e.low,this.high^e.high,this.unsigned)},A.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?a(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):a(0,this.low<<e-32,this.unsigned)},A.shl=A.shiftLeft,A.shiftRight=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?a(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):a(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},A.shr=A.shiftRight,A.shiftRightUnsigned=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?a(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):a(32===e?this.high:this.high>>>e-32,0,this.unsigned)},A.shru=A.shiftRightUnsigned,A.shr_u=A.shiftRightUnsigned,A.rotateLeft=function(e){var t;return r(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?a(this.high,this.low,this.unsigned):e<32?(t=32-e,a(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),a(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},A.rotl=A.rotateLeft,A.rotateRight=function(e){var t;return r(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?a(this.high,this.low,this.unsigned):e<32?(t=32-e,a(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),a(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},A.rotr=A.rotateRight,A.toSigned=function(){return this.unsigned?a(this.low,this.high,!1):this},A.toUnsigned=function(){return this.unsigned?this:a(this.low,this.high,!0)},A.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},A.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},A.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},t.fromBytes=function(e,r,i){return i?t.fromBytesLE(e,r):t.fromBytesBE(e,r)},t.fromBytesLE=function(e,r){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)},t.fromBytesBE=function(e,r){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)},"function"==typeof BigInt&&(t.fromBigInt=function(e,t){return a(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},t.fromValue=function(e,r){return"bigint"==typeof e?t.fromBigInt(e,r):l(e,r)},A.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<<BigInt(32)|e});var E,k,T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={exports:{}},S={},x={};function R(){if(k)return E;return k=1,E=function(e,t){var r=new Array(arguments.length-1),i=0,n=2,o=!0;for(;n<arguments.length;)r[i++]=arguments[n++];return new Promise(function(n,s){r[i]=function(e){if(o)if(o=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];n.apply(null,t)}};try{e.apply(t||null,r)}catch(u){o&&(o=!1,s(u))}})},E}var B,I,L,F,D,P,C,$={};function q(){return C?P:(C=1,P=function(){return null})}var J,U,M,z,Z,H,V,W,G,X,K,Q,Y,ee,te={};function re(){return H||(H=1,function(){var e,t=x;function r(e,t,r){for(var i=Object.keys(t),n=0;n<i.length;++n)void 0!==e[i[n]]&&r||(e[i[n]]=t[i[n]]);return e}function i(e){function t(e,i){if(!(this instanceof t))return new t(e,i);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),i&&r(this,i)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=R(),t.base64=(B||(B=1,function(){var e=$;e.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var t=new Array(64),r=new Array(123),i=0;i<64;)r[t[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;e.encode=function(e,r,i){for(var n,o=null,s=[],u=0,a=0;r<i;){var f=e[r++];switch(a){case 0:s[u++]=t[f>>2],n=(3&f)<<4,a=1;break;case 1:s[u++]=t[n|f>>4],n=(15&f)<<2,a=2;break;case 2:s[u++]=t[n|f>>6],s[u++]=t[63&f],a=0}u>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),u=0)}return a&&(s[u++]=t[n],s[u++]=61,1===a&&(s[u++]=61)),o?(u&&o.push(String.fromCharCode.apply(String,s.slice(0,u))),o.join("")):String.fromCharCode.apply(String,s.slice(0,u))};var n="invalid encoding";e.decode=function(e,t,i){for(var o,s=i,u=0,a=0;a<e.length;){var f=e.charCodeAt(a++);if(61===f&&u>1)break;if(void 0===(f=r[f]))throw Error(n);switch(u){case 0:o=f,u=1;break;case 1:t[i++]=o<<2|(48&f)>>4,o=f,u=2;break;case 2:t[i++]=(15&o)<<4|(60&f)>>2,o=f,u=3;break;case 3:t[i++]=(3&o)<<6|f,u=0}}if(1===u)throw Error(n);return i-s},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}()),$),t.EventEmitter=function(){if(L)return I;function e(){this._listeners={}}return L=1,I=e,e.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},e.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],i=0;i<r.length;)r[i].fn===t?r.splice(i,1):++i;return this},e.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],i=1;i<arguments.length;)r.push(arguments[i++]);for(i=0;i<t.length;)t[i].fn.apply(t[i++].ctx,r)}return this},I}(),t.float=function(){if(D)return F;function e(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),i=128===r[3];function n(e,i,n){t[0]=e,i[n]=r[0],i[n+1]=r[1],i[n+2]=r[2],i[n+3]=r[3]}function o(e,i,n){t[0]=e,i[n]=r[3],i[n+1]=r[2],i[n+2]=r[1],i[n+3]=r[0]}function s(e,i){return r[0]=e[i],r[1]=e[i+1],r[2]=e[i+2],r[3]=e[i+3],t[0]}function u(e,i){return r[3]=e[i],r[2]=e[i+1],r[1]=e[i+2],r[0]=e[i+3],t[0]}e.writeFloatLE=i?n:o,e.writeFloatBE=i?o:n,e.readFloatLE=i?s:u,e.readFloatBE=i?u:s}():function(){function o(e,t,r,i){var n=t<0?1:0;if(n&&(t=-t),0===t)e(1/t>0?0:2147483648,r,i);else if(isNaN(t))e(2143289344,r,i);else if(t>34028234663852886e22)e((n<<31|2139095040)>>>0,r,i);else if(t<11754943508222875e-54)e((n<<31|Math.round(t/1401298464324817e-60))>>>0,r,i);else{var o=Math.floor(Math.log(t)/Math.LN2);e((n<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,i)}}function s(e,t,r){var i=e(t,r),n=2*(i>>31)+1,o=i>>>23&255,s=8388607&i;return 255===o?s?NaN:n*(1/0):0===o?1401298464324817e-60*n*s:n*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=o.bind(null,t),e.writeFloatBE=o.bind(null,r),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,n)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),i=128===r[7];function n(e,i,n){t[0]=e,i[n]=r[0],i[n+1]=r[1],i[n+2]=r[2],i[n+3]=r[3],i[n+4]=r[4],i[n+5]=r[5],i[n+6]=r[6],i[n+7]=r[7]}function o(e,i,n){t[0]=e,i[n]=r[7],i[n+1]=r[6],i[n+2]=r[5],i[n+3]=r[4],i[n+4]=r[3],i[n+5]=r[2],i[n+6]=r[1],i[n+7]=r[0]}function s(e,i){return r[0]=e[i],r[1]=e[i+1],r[2]=e[i+2],r[3]=e[i+3],r[4]=e[i+4],r[5]=e[i+5],r[6]=e[i+6],r[7]=e[i+7],t[0]}function u(e,i){return r[7]=e[i],r[6]=e[i+1],r[5]=e[i+2],r[4]=e[i+3],r[3]=e[i+4],r[2]=e[i+5],r[1]=e[i+6],r[0]=e[i+7],t[0]}e.writeDoubleLE=i?n:o,e.writeDoubleBE=i?o:n,e.readDoubleLE=i?s:u,e.readDoubleBE=i?u:s}():function(){function o(e,t,r,i,n,o){var s=i<0?1:0;if(s&&(i=-i),0===i)e(0,n,o+t),e(1/i>0?0:2147483648,n,o+r);else if(isNaN(i))e(0,n,o+t),e(2146959360,n,o+r);else if(i>17976931348623157e292)e(0,n,o+t),e((s<<31|2146435072)>>>0,n,o+r);else{var u;if(i<22250738585072014e-324)e((u=i/5e-324)>>>0,n,o+t),e((s<<31|u/4294967296)>>>0,n,o+r);else{var a=Math.floor(Math.log(i)/Math.LN2);1024===a&&(a=1023),e(4503599627370496*(u=i*Math.pow(2,-a))>>>0,n,o+t),e((s<<31|a+1023<<20|1048576*u&1048575)>>>0,n,o+r)}}}function s(e,t,r,i,n){var o=e(i,n+t),s=e(i,n+r),u=2*(s>>31)+1,a=s>>>20&2047,f=4294967296*(1048575&s)+o;return 2047===a?f?NaN:u*(1/0):0===a?5e-324*u*f:u*Math.pow(2,a-1075)*(f+4503599627370496)}e.writeDoubleLE=o.bind(null,t,0,4),e.writeDoubleBE=o.bind(null,r,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,n,4,0)}(),e}function t(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function r(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function n(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}return D=1,F=e(e)}(),t.inquire=q(),t.utf8=(J||(J=1,(e=te).length=function(e){for(var t=0,r=0,i=0;i<e.length;++i)(r=e.charCodeAt(i))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(i+1))?(++i,t+=4):t+=3;return t},e.read=function(e,t,r){if(r-t<1)return"";for(var i,n=null,o=[],s=0;t<r;)(i=e[t++])<128?o[s++]=i:i>191&&i<224?o[s++]=(31&i)<<6|63&e[t++]:i>239&&i<365?(i=((7&i)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(i>>10),o[s++]=56320+(1023&i)):o[s++]=(15&i)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n?(s&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))},e.write=function(e,t,r){for(var i,n,o=r,s=0;s<e.length;++s)(i=e.charCodeAt(s))<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296==(64512&i)&&56320==(64512&(n=e.charCodeAt(s+1)))?(i=65536+((1023&i)<<10)+(1023&n),++s,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-o}),te),t.pool=M?U:(M=1,U=function(e,t,r){var i=r||8192,n=i>>>1,o=null,s=i;return function(r){if(r<1||r>n)return e(r);s+r>i&&(o=e(i),s=0);var u=t.call(o,s,s+=r);return 7&s&&(s=1+(7|s)),u}}),t.LongBits=function(){if(Z)return z;Z=1,z=t;var e=re();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var i=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return r;var i=e<0;i&&(e=-e);var n=e>>>0,o=(e-n)/4294967296>>>0;return i&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)},t.from=function(i){if("number"==typeof i)return t.fromNumber(i);if(e.isString(i)){if(!e.Long)return t.fromNumber(parseInt(i,10));i=e.Long.fromString(i)}return i.low||i.high?new t(i.low>>>0,i.high>>>0):r},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var n=String.prototype.charCodeAt;return t.fromHash=function(e){return e===i?r:new t((n.call(e,0)|n.call(e,1)<<8|n.call(e,2)<<16|n.call(e,3)<<24)>>>0,(n.call(e,4)|n.call(e,5)<<8|n.call(e,6)<<16|n.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10},z}(),t.isNode=Boolean(void 0!==T&&T&&T.process&&T.process.versions&&T.process.versions.node),t.global=t.isNode&&T||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||x,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(r){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},t.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,r){var i=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(i.lo,i.hi,r):i.toNumber(Boolean(r))},t.merge=r,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=i,t.ProtocolError=i("ProtocolError"),t.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},t.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}}()),x}function ie(){if(W)return V;W=1,V=a;var e,t=re(),r=t.LongBits,i=t.base64,n=t.utf8;function o(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function s(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function a(){this.len=0,this.head=new o(s,0,0),this.tail=this.head,this.states=null}var f=function(){return t.Buffer?function(){return(a.create=function(){return new e})()}:function(){return new a}};function h(e,t,r){t[r]=255&e}function l(e,t){this.len=e,this.next=void 0,this.val=t}function c(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function p(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}a.create=f(),a.alloc=function(e){return new t.Array(e)},t.Array!==Array&&(a.alloc=t.pool(a.alloc,t.Array.prototype.subarray)),a.prototype._push=function(e,t,r){return this.tail=this.tail.next=new o(e,t,r),this.len+=t,this},l.prototype=Object.create(o.prototype),l.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},a.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new l((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},a.prototype.int32=function(e){return e<0?this._push(c,10,r.fromNumber(e)):this.uint32(e)},a.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},a.prototype.uint64=function(e){var t=r.from(e);return this._push(c,t.length(),t)},a.prototype.int64=a.prototype.uint64,a.prototype.sint64=function(e){var t=r.from(e).zzEncode();return this._push(c,t.length(),t)},a.prototype.bool=function(e){return this._push(h,1,e?1:0)},a.prototype.fixed32=function(e){return this._push(p,4,e>>>0)},a.prototype.sfixed32=a.prototype.fixed32,a.prototype.fixed64=function(e){var t=r.from(e);return this._push(p,4,t.lo)._push(p,4,t.hi)},a.prototype.sfixed64=a.prototype.fixed64,a.prototype.float=function(e){return this._push(t.float.writeFloatLE,4,e)},a.prototype.double=function(e){return this._push(t.float.writeDoubleLE,8,e)};var d=t.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var i=0;i<e.length;++i)t[r+i]=e[i]};return a.prototype.bytes=function(e){var r=e.length>>>0;if(!r)return this._push(h,1,0);if(t.isString(e)){var n=a.alloc(r=i.length(e));i.decode(e,n,0),e=n}return this.uint32(r)._push(d,r,e)},a.prototype.string=function(e){var t=n.length(e);return t?this.uint32(t)._push(n.write,t,e):this._push(h,1,0)},a.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new o(s,0,0),this.len=0,this},a.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(s,0,0),this.len=0),this},a.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},a.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},a._configure=function(t){e=t,a.create=f(),e._configure()},V}function ne(){if(Q)return K;Q=1,K=o;var e,t=re(),r=t.LongBits,i=t.utf8;function n(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function o(e){this.buf=e,this.pos=0,this.len=e.length}var s="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new o(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new o(e);throw Error("illegal buffer")},u=function(){return t.Buffer?function(r){return(o.create=function(r){return t.Buffer.isBuffer(r)?new e(r):s(r)})(r)}:s};function a(){var e=new r(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw n(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw n(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function h(){if(this.pos+8>this.len)throw n(this,8);return new r(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}return o.create=u(),o.prototype._slice=t.Array.prototype.subarray||t.Array.prototype.slice,o.prototype.uint32=/* @__PURE__ */function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return e}}(),o.prototype.int32=function(){return 0|this.uint32()},o.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},o.prototype.bool=function(){return 0!==this.uint32()},o.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return f(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return 0|f(this.buf,this.pos+=4)},o.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var e=t.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},o.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var e=t.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},o.prototype.bytes=function(){var e=this.uint32(),r=this.pos,i=this.pos+e;if(i>this.len)throw n(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(r,i);if(r===i){var o=t.Buffer;return o?o.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,r,i)},o.prototype.string=function(){var e=this.bytes();return i.read(e,0,e.length)},o.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw n(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw n(this)}while(128&this.buf[this.pos++]);return this},o.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},o._configure=function(r){e=r,o.create=u(),e._configure();var i=t.Long?"toLong":"toNumber";t.merge(o.prototype,{int64:function(){return a.call(this)[i](!1)},uint64:function(){return a.call(this)[i](!0)},sint64:function(){return a.call(this).zzDecode()[i](!1)},fixed64:function(){return h.call(this)[i](!0)},sfixed64:function(){return h.call(this)[i](!1)}})},K}var oe,se,ue,ae,fe,he,le={};function ce(){return ue||(ue=1,le.Service=function(){if(se)return oe;se=1,oe=t;var e=re();function t(t,r,i){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");e.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(r),this.responseDelimited=Boolean(i)}return(t.prototype=Object.create(e.EventEmitter.prototype)).constructor=t,t.prototype.rpcCall=function t(r,i,n,o,s){if(!o)throw TypeError("request must be specified");var u=this;if(!s)return e.asPromise(t,u,r,i,n,o);if(u.rpcImpl)try{return u.rpcImpl(r,i[u.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(e,t){if(e)return u.emit("error",e,r),s(e);if(null!==t){if(!(t instanceof n))try{t=n[u.responseDelimited?"decodeDelimited":"decode"](t)}catch(i){return u.emit("error",i,r),s(i)}return u.emit("data",t,r),s(null,t)}u.end(!0)})}catch(a){return u.emit("error",a,r),void setTimeout(function(){s(a)},0)}else setTimeout(function(){s(Error("already ended"))},0)},t.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},oe}()),le}function pe(){return fe?ae:(fe=1,ae={})}function de(){return he||(he=1,function(){var e=S;function t(){e.util._configure(),e.Writer._configure(e.BufferWriter),e.Reader._configure(e.BufferReader)}e.build="minimal",e.Writer=ie(),e.BufferWriter=function(){if(X)return G;X=1,G=r;var e=ie();(r.prototype=Object.create(e.prototype)).constructor=r;var t=re();function r(){e.call(this)}function i(e,r,i){e.length<40?t.utf8.write(e,r,i):r.utf8Write?r.utf8Write(e,i):r.write(e,i)}return r._configure=function(){r.alloc=t._Buffer_allocUnsafe,r.writeBytesBuffer=t.Buffer&&t.Buffer.prototype instanceof Uint8Array&&"set"===t.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var i=0;i<e.length;)t[r++]=e[i++]}},r.prototype.bytes=function(e){t.isString(e)&&(e=t._Buffer_from(e,"base64"));var i=e.length>>>0;return this.uint32(i),i&&this._push(r.writeBytesBuffer,i,e),this},r.prototype.string=function(e){var r=t.Buffer.byteLength(e);return this.uint32(r),r&&this._push(i,r,e),this},r._configure(),G}(),e.Reader=ne(),e.BufferReader=function(){if(ee)return Y;ee=1,Y=r;var e=ne();(r.prototype=Object.create(e.prototype)).constructor=r;var t=re();function r(t){e.call(this,t)}return r._configure=function(){t.Buffer&&(r.prototype._slice=t.Buffer.prototype.slice)},r.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},r._configure(),Y}(),e.util=re(),e.rpc=ce(),e.roots=pe(),e.configure=t,t()}()),S}var ye,ve,ge,me,be={},we={exports:{}};var Oe,_e,je,Ae,Ee,ke,Te,Ne,Se,xe,Re,Be,Ie,Le,Fe,De={};function Pe(){if(je)return _e;je=1,_e=a;var e=Ot();((a.prototype=Object.create(e.prototype)).constructor=a).className="Namespace";var t,r,i,n=bt(),o=gt(),s=wt();function u(e,t){if(e&&e.length){for(var r={},i=0;i<e.length;++i)r[e[i].name]=e[i].toJSON(t);return r}}function a(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null,this._lookupCache={},this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0}function f(e){e._nestedArray=null,e._lookupCache={};for(var t=e;t=t.parent;)t._lookupCache={};return e}return a.fromJSON=function(e,t){return new a(e,t.options).addJSON(t.nested)},a.arrayToJSON=u,a.isReservedId=function(e,t){if(e)for(var r=0;r<e.length;++r)if("string"!=typeof e[r]&&e[r][0]<=t&&e[r][1]>t)return!0;return!1},a.isReservedName=function(e,t){if(e)for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(a.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=o.toArray(this.nested))}}),a.prototype.toJSON=function(e){return o.toObject(["options",this.options,"nested",u(this.nestedArray,e)])},a.prototype.addJSON=function(e){if(e)for(var o,s=Object.keys(e),u=0;u<s.length;++u)o=e[s[u]],this.add((void 0!==o.fields?t.fromJSON:void 0!==o.values?i.fromJSON:void 0!==o.methods?r.fromJSON:void 0!==o.id?n.fromJSON:a.fromJSON)(s[u],o));return this},a.prototype.get=function(e){return this.nested&&this.nested[e]||null},a.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof i)return this.nested[e].values;throw Error("no such enum: "+e)},a.prototype.add=function(e){if(!(e instanceof n&&void 0!==e.extend||e instanceof t||e instanceof s||e instanceof i||e instanceof r||e instanceof a))throw TypeError("object must be a valid nested object");if(this.nested){var o=this.get(e.name);if(o){if(!(o instanceof a&&e instanceof a)||o instanceof t||o instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var u=o.nestedArray,h=0;h<u.length;++h)e.add(u[h]);this.remove(o),this.nested||(this.nested={}),e.setOptions(o.options,!0)}}else this.nested={};this.nested[e.name]=e,this instanceof t||this instanceof r||this instanceof i||this instanceof n||e._edition||(e._edition=e._defaultEdition),this._needsRecursiveFeatureResolution=!0,this._needsRecursiveResolve=!0;for(var l=this;l=l.parent;)l._needsRecursiveFeatureResolution=!0,l._needsRecursiveResolve=!0;return e.onAdd(this),f(this)},a.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),f(this)},a.prototype.define=function(e,t){if(o.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var i=e.shift();if(r.nested&&r.nested[i]){if(!((r=r.nested[i])instanceof a))throw Error("path conflicts with non-namespace objects")}else r.add(r=new a(i))}return t&&r.addJSON(t),r},a.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;this._resolveFeaturesRecursive(this._edition);var e=this.nestedArray,t=0;for(this.resolve();t<e.length;)e[t]instanceof a?e[t++].resolveAll():e[t++].resolve();return this._needsRecursiveResolve=!1,this},a.prototype._resolveFeaturesRecursive=function(t){return this._needsRecursiveFeatureResolution?(this._needsRecursiveFeatureResolution=!1,t=this._edition||t,e.prototype._resolveFeaturesRecursive.call(this,t),this.nestedArray.forEach(e=>{e._resolveFeaturesRecursive(t)}),this):this},a.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),o.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;var i=e.join(".");if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.root._fullyQualifiedObjects&&this.root._fullyQualifiedObjects["."+i];if(n&&(!t||t.indexOf(n.constructor)>-1))return n;if((n=this._lookupImpl(e,i))&&(!t||t.indexOf(n.constructor)>-1))return n;if(r)return null;for(var s=this;s.parent;){if((n=s.parent._lookupImpl(e,i))&&(!t||t.indexOf(n.constructor)>-1))return n;s=s.parent}return null},a.prototype._lookupImpl=function(e,t){if(Object.prototype.hasOwnProperty.call(this._lookupCache,t))return this._lookupCache[t];var r=this.get(e[0]),i=null;if(r)1===e.length?i=r:r instanceof a&&(e=e.slice(1),i=r._lookupImpl(e,e.join(".")));else for(var n=0;n<this.nestedArray.length;++n)this._nestedArray[n]instanceof a&&(r=this._nestedArray[n]._lookupImpl(e,t))&&(i=r);return this._lookupCache[t]=i,i},a.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},a.prototype.lookupEnum=function(e){var t=this.lookup(e,[i]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},a.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,i]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},a.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},a._configure=function(e,n,o){t=e,r=n,i=o},_e}function Ce(){if(Ee)return Ae;Ee=1,Ae=i;var e=bt();((i.prototype=Object.create(e.prototype)).constructor=i).className="MapField";var t=mt(),r=gt();function i(t,i,n,o,s,u){if(e.call(this,t,i,o,void 0,void 0,s,u),!r.isString(n))throw TypeError("keyType must be a string");this.keyType=n,this.resolvedKeyType=null,this.map=!0}return i.fromJSON=function(e,t){return new i(e,t.id,t.keyType,t.type,t.options,t.comment)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},i.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},i.d=function(e,t,n){return"function"==typeof n?n=r.decorateType(n).name:n&&"object"==typeof n&&(n=r.decorateEnum(n).name),function(o,s){r.decorateType(o.constructor).add(new i(s,e,t,n))}},Ae}function $e(){if(Te)return ke;Te=1,ke=r;var e=Ot();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=gt();function r(r,i,n,o,s,u,a,f,h){if(t.isObject(s)?(a=s,s=u=void 0):t.isObject(u)&&(a=u,u=void 0),void 0!==i&&!t.isString(i))throw TypeError("type must be a string");if(!t.isString(n))throw TypeError("requestType must be a string");if(!t.isString(o))throw TypeError("responseType must be a string");e.call(this,r,a),this.type=i||"rpc",this.requestType=n,this.requestStream=!!s||void 0,this.responseType=o,this.responseStream=!!u||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=f,this.parsedOptions=h}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){var r=!!e&&Boolean(e.keepComments);return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",r?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},ke}function qe(){if(Se)return Ne;Se=1,Ne=n;var e=Pe();((n.prototype=Object.create(e.prototype)).constructor=n).className="Service";var t=$e(),r=gt(),i=ce();function n(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function o(e){return e._methodsArray=null,e}return n.fromJSON=function(e,r){var i=new n(e,r.options);if(r.methods)for(var o=Object.keys(r.methods),s=0;s<o.length;++s)i.add(t.fromJSON(o[s],r.methods[o[s]]));return r.nested&&i.addJSON(r.nested),r.edition&&(i._edition=r.edition),i.comment=r.comment,i._defaultEdition="proto3",i},n.prototype.toJSON=function(t){var i=e.prototype.toJSON.call(this,t),n=!!t&&Boolean(t.keepComments);return r.toObject(["edition",this._editionToJSON(),"options",i&&i.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",i&&i.nested||void 0,"comment",n?this.comment:void 0])},Object.defineProperty(n.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),n.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},n.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;e.prototype.resolve.call(this);for(var t=this.methodsArray,r=0;r<t.length;++r)t[r].resolve();return this},n.prototype._resolveFeaturesRecursive=function(t){return this._needsRecursiveFeatureResolution?(t=this._edition||t,e.prototype._resolveFeaturesRecursive.call(this,t),this.methodsArray.forEach(e=>{e._resolveFeaturesRecursive(t)}),this):this},n.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,o(this)):e.prototype.add.call(this,r)},n.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,o(this)}return e.prototype.remove.call(this,r)},n.prototype.create=function(e,t,n){for(var o,s=new i.Service(e,t,n),u=0;u<this.methodsArray.length;++u){var a=r.lcFirst((o=this._methodsArray[u]).resolve().name).replace(/[^$\w_]/g,"");s[a]=r.codegen(["r","c"],r.isReserved(a)?a+"_":a)("return this.rpcCall(m,q,s,r,c)")({m:o,q:o.resolvedRequestType.ctor,s:o.resolvedResponseType.ctor})}return s},Ne}function Je(){if(Re)return xe;Re=1,xe=t;var e=re();function t(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)this[t[r]]=e[t[r]]}return t.create=function(e){return this.$type.create(e)},t.encode=function(e,t){return this.$type.encode(e,t)},t.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},t.decode=function(e){return this.$type.decode(e)},t.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},t.verify=function(e){return this.$type.verify(e)},t.fromObject=function(e){return this.$type.fromObject(e)},t.toObject=function(e,t){return this.$type.toObject(e,t)},t.prototype.toJSON=function(){return this.$type.toObject(this,e.toJSONOptions)},xe}function Ue(){if(Ie)return Be;Ie=1,Be=function(n){for(var o=r.codegen(["r","l","e"],n.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(n.fieldsArray.filter(function(e){return e.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()")("if(t===e)")("break")("switch(t>>>3){"),s=0;s<n.fieldsArray.length;++s){var u=n._fieldsArray[s].resolve(),a=u.resolvedType instanceof e?"int32":u.type,f="m"+r.safeProp(u.name);o("case %i: {",u.id),u.map?(o("if(%s===util.emptyObject)",f)("%s={}",f)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[u.keyType]?o("k=%j",t.defaults[u.keyType]):o("k=null"),void 0!==t.defaults[a]?o("value=%j",t.defaults[a]):o("value=null"),o("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",u.keyType)("case 2:"),void 0===t.basic[a]?o("value=types[%i].decode(r,r.uint32())",s):o("value=r.%s()",a),o("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[u.keyType]?o('%s[typeof k==="object"?util.longToHash(k):k]=value',f):o("%s[k]=value",f)):u.repeated?(o("if(!(%s&&%s.length))",f,f)("%s=[]",f),void 0!==t.packed[a]&&o("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",f,a)("}else"),void 0===t.basic[a]?o(u.delimited?"%s.push(types[%i].decode(r,undefined,((t&~7)|4)))":"%s.push(types[%i].decode(r,r.uint32()))",f,s):o("%s.push(r.%s())",f,a)):void 0===t.basic[a]?o(u.delimited?"%s=types[%i].decode(r,undefined,((t&~7)|4))":"%s=types[%i].decode(r,r.uint32())",f,s):o("%s=r.%s()",f,a),o("break")("}")}for(o("default:")("r.skipType(t&7)")("break")("}")("}"),s=0;s<n._fieldsArray.length;++s){var h=n._fieldsArray[s];h.required&&o("if(!m.hasOwnProperty(%j))",h.name)("throw util.ProtocolError(%j,{instance:m})",i(h))}return o("return m")};var e=_t(),t=mt(),r=gt();function i(e){return"missing required '"+e.name+"'"}return Be}function Me(){if(Fe)return Le;Fe=1,Le=function(e){var o=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),s=e.oneofsArray,u={};s.length&&o("var p={}");for(var a=0;a<e.fieldsArray.length;++a){var f=e._fieldsArray[a].resolve(),h="m"+t.safeProp(f.name);if(f.optional&&o("if(%s!=null&&m.hasOwnProperty(%j)){",h,f.name),f.map)o("if(!util.isObject(%s))",h)("return%j",r(f,"object"))("var k=Object.keys(%s)",h)("for(var i=0;i<k.length;++i){"),n(o,f,"k[i]"),i(o,f,a,h+"[k[i]]")("}");else if(f.repeated)o("if(!Array.isArray(%s))",h)("return%j",r(f,"array"))("for(var i=0;i<%s.length;++i){",h),i(o,f,a,h+"[i]")("}");else{if(f.partOf){var l=t.safeProp(f.partOf.name);1===u[f.partOf.name]&&o("if(p%s===1)",l)("return%j",f.partOf.name+": multiple values"),u[f.partOf.name]=1,o("p%s=1",l)}i(o,f,a,h)}f.optional&&o("}")}return o("return null")};var e=_t(),t=gt();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function i(t,i,n,o){if(i.resolvedType)if(i.resolvedType instanceof e){t("switch(%s){",o)("default:")("return%j",r(i,"enum value"));for(var s=Object.keys(i.resolvedType.values),u=0;u<s.length;++u)t("case %i:",i.resolvedType.values[s[u]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",n,o)("if(e)")("return%j+e",i.name+".")("}");else switch(i.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",o)("return%j",r(i,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",o,o,o,o)("return%j",r(i,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',o)("return%j",r(i,"number"));break;case"bool":t('if(typeof %s!=="boolean")',o)("return%j",r(i,"boolean"));break;case"string":t("if(!util.isString(%s))",o)("return%j",r(i,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',o,o,o)("return%j",r(i,"buffer"))}return t}function n(e,t,i){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",i)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",i)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",i)("return%j",r(t,"boolean key"))}return e}return Le}var ze,Ze={};function He(){return ze||(ze=1,function(){var e=Ze,t=_t(),r=gt();function i(e,r,i,n){var o=!1;if(r.resolvedType)if(r.resolvedType instanceof t){e("switch(d%s){",n);for(var s=r.resolvedType.values,u=Object.keys(s),a=0;a<u.length;++a)s[u[a]]!==r.typeDefault||o||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',n,n,n),r.repeated||e("break"),o=!0),e("case%j:",u[a])("case %i:",s[u[a]])("m%s=%j",n,s[u[a]])("break");e("}")}else e('if(typeof d%s!=="object")',n)("throw TypeError(%j)",r.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",n,i,n);else{var f=!1;switch(r.type){case"double":case"float":e("m%s=Number(d%s)",n,n);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",n,n);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",n,n);break;case"uint64":f=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,f)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,f?"true":"");break;case"bytes":e('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length >= 0)",n)("m%s=d%s",n,n);break;case"string":e("m%s=String(d%s)",n,n);break;case"bool":e("m%s=Boolean(d%s)",n,n)}}return e}function n(e,r,i,n){if(r.resolvedType)r.resolvedType instanceof t?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",n,i,n,n,i,n,n):e("d%s=types[%i].toObject(m%s,o)",n,i,n);else{var o=!1;switch(r.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,o?"true":"",n);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:e("d%s=m%s",n,n)}}return e}e.fromObject=function(e){var n=e.fieldsArray,o=r.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!n.length)return o("return new this.ctor");o("var m=new this.ctor");for(var s=0;s<n.length;++s){var u=n[s].resolve(),a=r.safeProp(u.name);u.map?(o("if(d%s){",a)('if(typeof d%s!=="object")',a)("throw TypeError(%j)",u.fullName+": object expected")("m%s={}",a)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",a),i(o,u,s,a+"[ks[i]]")("}")("}")):u.repeated?(o("if(d%s){",a)("if(!Array.isArray(d%s))",a)("throw TypeError(%j)",u.fullName+": array expected")("m%s=[]",a)("for(var i=0;i<d%s.length;++i){",a),i(o,u,s,a+"[i]")("}")("}")):(u.resolvedType instanceof t||o("if(d%s!=null){",a),i(o,u,s,a),u.resolvedType instanceof t||o("}"))}return o("return m")},e.toObject=function(e){var i=e.fieldsArray.slice().sort(r.compareFieldsById);if(!i.length)return r.codegen()("return {}");for(var o=r.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),s=[],u=[],a=[],f=0;f<i.length;++f)i[f].partOf||(i[f].resolve().repeated?s:i[f].map?u:a).push(i[f]);if(s.length){for(o("if(o.arrays||o.defaults){"),f=0;f<s.length;++f)o("d%s=[]",r.safeProp(s[f].name));o("}")}if(u.length){for(o("if(o.objects||o.defaults){"),f=0;f<u.length;++f)o("d%s={}",r.safeProp(u[f].name));o("}")}if(a.length){for(o("if(o.defaults){"),f=0;f<a.length;++f){var h=a[f],l=r.safeProp(h.name);if(h.resolvedType instanceof t)o("d%s=o.enums===String?%j:%j",l,h.resolvedType.valuesById[h.typeDefault],h.typeDefault);else if(h.long)o("if(util.Long){")("var n=new util.Long(%i,%i,%j)",h.typeDefault.low,h.typeDefault.high,h.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",l)("}else")("d%s=o.longs===String?%j:%i",l,h.typeDefault.toString(),h.typeDefault.toNumber());else if(h.bytes){var c="["+Array.prototype.slice.call(h.typeDefault).join(",")+"]";o("if(o.bytes===String)d%s=%j",l,String.fromCharCode.apply(String,h.typeDefault))("else{")("d%s=%s",l,c)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",l,l)("}")}else o("d%s=%j",l,h.typeDefault)}o("}")}var p=!1;for(f=0;f<i.length;++f){h=i[f];var d=e._fieldsArray.indexOf(h);l=r.safeProp(h.name);h.map?(p||(p=!0,o("var ks2")),o("if(m%s&&(ks2=Object.keys(m%s)).length){",l,l)("d%s={}",l)("for(var j=0;j<ks2.length;++j){"),n(o,h,d,l+"[ks2[j]]")("}")):h.repeated?(o("if(m%s&&m%s.length){",l,l)("d%s=[]",l)("for(var j=0;j<m%s.length;++j){",l),n(o,h,d,l+"[j]")("}")):(o("if(m%s!=null&&m.hasOwnProperty(%j)){",l,h.name),n(o,h,d,l),h.partOf&&o("if(o.oneofs)")("d%s=%j",r.safeProp(h.partOf.name),h.name)),o("}")}return o("return d")}}()),Ze}var Ve,We,Ge,Xe,Ke,Qe,Ye,et,tt,rt,it,nt,ot,st,ut,at,ft,ht,lt,ct,pt={};function dt(){return Ve||(Ve=1,e=pt,t=Je(),e[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var i="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===i.indexOf("/")&&(i="/"+i),this.create({type_url:i,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,r){var i="",n="";if(r&&r.json&&e.type_url&&e.value){n=e.type_url.substring(e.type_url.lastIndexOf("/")+1),i=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var o=this.lookup(n);o&&(e=o.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof t){var s=e.$type.toObject(e,r);return""===i&&(i="type.googleapis.com/"),n=i+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),s["@type"]=n,s}return this.toObject(e,r)}}),pt;var e,t}function yt(){if(Ge)return We;Ge=1,We=y;var e=Pe();((y.prototype=Object.create(e.prototype)).constructor=y).className="Type";var t=_t(),r=wt(),i=bt(),n=Ce(),o=qe(),s=Je(),u=ne(),a=ie(),f=gt(),h=jt(),l=Ue(),c=Me(),p=He(),d=dt();function y(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function v(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(y.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var r=this.fields[e[t]],i=r.id;if(this._fieldsById[i])throw Error("duplicate id "+i+" in "+this);this._fieldsById[i]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=f.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=f.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=y.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof s||((e.prototype=new s).constructor=e,f.merge(e.prototype,t)),e.$type=e.prototype.$type=this,f.merge(e,s,!0),this._ctor=e;for(var r=0;r<this.fieldsArray.length;++r)this._fieldsArray[r].resolve();var i={};for(r=0;r<this.oneofsArray.length;++r)i[this._oneofsArray[r].resolve().name]={get:f.oneOfGetter(this._oneofsArray[r].oneof),set:f.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,i)}}}),y.generateConstructor=function(e){for(var t,r=f.codegen(["p"],e.name),i=0;i<e.fieldsArray.length;++i)(t=e._fieldsArray[i]).map?r("this%s={}",f.safeProp(t.name)):t.repeated&&r("this%s=[]",f.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},y.fromJSON=function(s,u){var a=new y(s,u.options);a.extensions=u.extensions,a.reserved=u.reserved;for(var f=Object.keys(u.fields),h=0;h<f.length;++h)a.add((void 0!==u.fields[f[h]].keyType?n.fromJSON:i.fromJSON)(f[h],u.fields[f[h]]));if(u.oneofs)for(f=Object.keys(u.oneofs),h=0;h<f.length;++h)a.add(r.fromJSON(f[h],u.oneofs[f[h]]));if(u.nested)for(f=Object.keys(u.nested),h=0;h<f.length;++h){var l=u.nested[f[h]];a.add((void 0!==l.id?i.fromJSON:void 0!==l.fields?y.fromJSON:void 0!==l.values?t.fromJSON:void 0!==l.methods?o.fromJSON:e.fromJSON)(f[h],l))}return u.extensions&&u.extensions.length&&(a.extensions=u.extensions),u.reserved&&u.reserved.length&&(a.reserved=u.reserved),u.group&&(a.group=!0),u.comment&&(a.comment=u.comment),u.edition&&(a._edition=u.edition),a._defaultEdition="proto3",a},y.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),i=!!t&&Boolean(t.keepComments);return f.toObject(["edition",this._editionToJSON(),"options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter(function(e){return!e.declaringField}),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",i?this.comment:void 0])},y.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;e.prototype.resolveAll.call(this);var t=this.oneofsArray;for(i=0;i<t.length;)t[i++].resolve();for(var r=this.fieldsArray,i=0;i<r.length;)r[i++].resolve();return this},y.prototype._resolveFeaturesRecursive=function(t){return this._needsRecursiveFeatureResolution?(t=this._edition||t,e.prototype._resolveFeaturesRecursive.call(this,t),this.oneofsArray.forEach(e=>{e._resolveFeatures(t)}),this.fieldsArray.forEach(e=>{e._resolveFeatures(t)}),this):this},y.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},y.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof i&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),v(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),v(this)):e.prototype.add.call(this,t)},y.prototype.remove=function(t){if(t instanceof i&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),v(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),v(this)}return e.prototype.remove.call(this,t)},y.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},y.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},y.prototype.create=function(e){return new this.ctor(e)},y.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;r<this.fieldsArray.length;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=h(this)({Writer:a,types:t,util:f}),this.decode=l(this)({Reader:u,types:t,util:f}),this.verify=c(this)({types:t,util:f}),this.fromObject=p.fromObject(this)({types:t,util:f}),this.toObject=p.toObject(this)({types:t,util:f});var i=d[e];if(i){var n=Object.create(this);n.fromObject=this.fromObject,this.fromObject=i.fromObject.bind(n),n.toObject=this.toObject,this.toObject=i.toObject.bind(n)}return this},y.prototype.encode=function(e,t){return this.setup().encode(e,t)},y.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},y.prototype.decode=function(e,t){return this.setup().decode(e,t)},y.prototype.decodeDelimited=function(e){return e instanceof u||(e=u.create(e)),this.decode(e,e.uint32())},y.prototype.verify=function(e){return this.setup().verify(e)},y.prototype.fromObject=function(e){return this.setup().fromObject(e)},y.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},y.d=function(e){return function(t){f.decorateType(t,e)}},We}function vt(){if(Ke)return Xe;Ke=1,Xe=a;var e=Pe();((a.prototype=Object.create(e.prototype)).constructor=a).className="Root";var t,r,i,n=bt(),o=_t(),s=wt(),u=gt();function a(t){e.call(this,"",t),this.deferred=[],this.files=[],this._edition="proto2",this._fullyQualifiedObjects={}}function f(){}a.fromJSON=function(e,t){return t||(t=new a),e.options&&t.setOptions(e.options),t.addJSON(e.nested).resolveAll()},a.prototype.resolvePath=u.path.resolve,a.prototype.fetch=u.fetch,a.prototype.load=function e(t,n,o){"function"==typeof n&&(o=n,n=void 0);var s=this;if(!o)return u.asPromise(e,s,t,n);var a=o===f;function h(e,t){if(o){if(a)throw e;t&&t.resolveAll();var r=o;o=null,r(e,t)}}function l(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in i)return r}return null}function c(e,t){try{if(u.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),u.isString(t)){r.filename=e;var i,o=r(t,s,n),f=0;if(o.imports)for(;f<o.imports.length;++f)(i=l(o.imports[f])||s.resolvePath(e,o.imports[f]))&&p(i);if(o.weakImports)for(f=0;f<o.weakImports.length;++f)(i=l(o.weakImports[f])||s.resolvePath(e,o.weakImports[f]))&&p(i,!0)}else s.setOptions(t.options).addJSON(t.nested)}catch(c){h(c)}a||d||h(null,s)}function p(e,t){if(e=l(e)||e,!(s.files.indexOf(e)>-1))if(s.files.push(e),e in i)a?c(e,i[e]):(++d,setTimeout(function(){--d,c(e,i[e])}));else if(a){var r;try{r=u.fs.readFileSync(e).toString("utf8")}catch(n){return void(t||h(n))}c(e,r)}else++d,s.fetch(e,function(r,i){--d,o&&(r?t?d||h(null,s):h(r):c(e,i))})}var d=0;u.isString(t)&&(t=[t]);for(var y,v=0;v<t.length;++v)(y=s.resolvePath("",t[v]))&&p(y);return a?(s.resolveAll(),s):(d||h(null,s),s)},a.prototype.loadSync=function(e,t){if(!u.isNode)throw Error("not supported");return this.load(e,t,f)},a.prototype.resolveAll=function(){if(!this._needsRecursiveResolve)return this;if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(e){return"'extend "+e.extend+"' in "+e.parent.fullName}).join(", "));return e.prototype.resolveAll.call(this)};var h=/^[A-Z]/;function l(e,t){var r=t.parent.lookup(t.extend);if(r){var i=new n(t.fullName,t.id,t.type,t.rule,void 0,t.options);return r.get(i.name)||(i.declaringField=t,t.extensionField=i,r.add(i)),!0}return!1}return a.prototype._handleAdd=function(e){if(e instanceof n)void 0===e.extend||e.extensionField||l(0,e)||this.deferred.push(e);else if(e instanceof o)h.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof s)){if(e instanceof t)for(var r=0;r<this.deferred.length;)l(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var i=0;i<e.nestedArray.length;++i)this._handleAdd(e._nestedArray[i]);h.test(e.name)&&(e.parent[e.name]=e)}(e instanceof t||e instanceof o||e instanceof n)&&(this._fullyQualifiedObjects[e.fullName]=e)},a.prototype._handleRemove=function(t){if(t instanceof n){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof o)h.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var i=0;i<t.nestedArray.length;++i)this._handleRemove(t._nestedArray[i]);h.test(t.name)&&delete t.parent[t.name]}delete this._fullyQualifiedObjects[t.fullName]},a._configure=function(e,n,o){t=e,r=n,i=o},Xe}function gt(){if(Qe)return we.exports;Qe=1;var e,t,r,i,n,o=we.exports=re(),s=pe();o.codegen=function(){if(ve)return ye;function e(t,r){"string"==typeof t&&(r=t,t=void 0);var i=[];function n(t){if("string"!=typeof t){var r=o();if(e.verbose&&console.log("codegen: "+r),r="return "+r,t){for(var s=Object.keys(t),u=new Array(s.length+1),a=new Array(s.length),f=0;f<s.length;)u[f]=s[f],a[f]=t[s[f++]];return u[f]=r,Function.apply(null,u).apply(null,a)}return Function(r)()}for(var h=new Array(arguments.length-1),l=0;l<h.length;)h[l]=arguments[++l];if(l=0,t=t.replace(/%([%dfijs])/g,function(e,t){var r=h[l++];switch(t){case"d":case"f":return String(Number(r));case"i":return String(Math.floor(r));case"j":return JSON.stringify(r);case"s":return String(r)}return"%"}),l!==h.length)throw Error("parameter count mismatch");return i.push(t),n}function o(e){return"function "+(e||r||"")+"("+(t&&t.join(",")||"")+"){\n "+i.join("\n ")+"\n}"}return n.toString=o,n}return ve=1,ye=e,e.verbose=!1,ye}(),o.fetch=function(){if(me)return ge;me=1,ge=r;var e=R(),t=q()("fs");function r(i,n,o){return"function"==typeof n?(o=n,n={}):n||(n={}),o?!n.xhr&&t&&t.readFile?t.readFile(i,function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?r.xhr(i,n,o):e?o(e):o(null,n.binary?t:t.toString("utf8"))}):r.xhr(i,n,o):e(r,this,i,n)}return r.xhr=function(e,t,r){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(4===i.readyState){if(0!==i.status&&200!==i.status)return r(Error("status "+i.status));if(t.binary){var e=i.response;if(!e){e=[];for(var n=0;n<i.responseText.length;++n)e.push(255&i.responseText.charCodeAt(n))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,i.responseText)}},t.binary&&("overrideMimeType"in i&&i.overrideMimeType("text/plain; charset=x-user-defined"),i.responseType="arraybuffer"),i.open("GET",e),i.send()},ge}(),o.path=(Oe||(Oe=1,i=(r=De).isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=r.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=i(e),n="";r&&(n=t.shift()+"/");for(var o=0;o<t.length;)".."===t[o]?o>0&&".."!==t[o-1]?t.splice(--o,2):r?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return n+t.join("/")},r.resolve=function(e,t,r){return r||(t=n(t)),i(t)?t:(r||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}),De),o.fs=o.inquire("fs"),o.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),i=0;i<t.length;)r[i]=e[t[i++]];return r}return[]},o.toObject=function(e){for(var t={},r=0;r<e.length;){var i=e[r++],n=e[r++];void 0!==n&&(t[i]=n)}return t};var u=/\\/g,a=/"/g;o.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},o.safeProp=function(e){return!/^[$\w_]+$/.test(e)||o.isReserved(e)?'["'+e.replace(u,"\\\\").replace(a,'\\"')+'"]':"."+e},o.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var f=/_([a-z])/g;o.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(f,function(e,t){return t.toUpperCase()})},o.compareFieldsById=function(e,t){return e.id-t.id},o.decorateType=function(t,r){if(t.$type)return r&&t.$type.name!==r&&(o.decorateRoot.remove(t.$type),t.$type.name=r,o.decorateRoot.add(t.$type)),t.$type;e||(e=yt());var i=new e(r||t.name);return o.decorateRoot.add(i),i.ctor=t,Object.defineProperty(t,"$type",{value:i,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:i,enumerable:!1}),i};var h=0;return o.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=_t());var r=new t("Enum"+h++,e);return o.decorateRoot.add(r),Object.defineProperty(e,"$type",{value:r,enumerable:!1}),r},o.setProperty=function(e,t,r,i){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var o=r.shift();if("__proto__"===o||"prototype"===o)return t;if(r.length>0)t[o]=e(t[o]||{},r,n);else{var s=t[o];if(s&&i)return t;s&&(n=[].concat(s).concat(n)),t[o]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(o,"decorateRoot",{get:function(){return s.decorated||(s.decorated=new(vt()))}}),we.exports}function mt(){return Ye||(Ye=1,function(){var e=be,t=gt(),r=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function i(e,t){var i=0,n={};for(t|=0;i<e.length;)n[r[i+t]]=e[i++];return n}e.basic=i([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),e.defaults=i([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",t.emptyArray,null]),e.long=i([0,0,0,1,1],7),e.mapKey=i([0,0,0,5,5,0,0,0,1,1,0,2],2),e.packed=i([1,5,0,0,0,5,5,0,0,0,1,1,0])}()),be}function bt(){if(tt)return et;tt=1,et=s;var e=Ot();((s.prototype=Object.create(e.prototype)).constructor=s).className="Field";var t,r=_t(),i=mt(),n=gt(),o=/^required|optional|repeated$/;function s(t,r,s,u,a,f,h){if(n.isObject(u)?(h=a,f=u,u=a=void 0):n.isObject(a)&&(h=f,f=a,a=void 0),e.call(this,t,f),!n.isInteger(r)||r<0)throw TypeError("id must be a non-negative integer");if(!n.isString(s))throw TypeError("type must be a string");if(void 0!==u&&!o.test(u=u.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==a&&!n.isString(a))throw TypeError("extend must be a string");"proto3_optional"===u&&(u="optional"),this.rule=u&&"optional"!==u?u:void 0,this.type=s,this.id=r,this.extend=a||void 0,this.repeated="repeated"===u,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!n.Long&&void 0!==i.long[s],this.bytes="bytes"===s,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this.comment=h}return s.fromJSON=function(e,t){var r=new s(e,t.id,t.type,t.rule,t.extend,t.options,t.comment);return t.edition&&(r._edition=t.edition),r._defaultEdition="proto3",r},Object.defineProperty(s.prototype,"required",{get:function(){return"LEGACY_REQUIRED"===this._features.field_presence}}),Object.defineProperty(s.prototype,"optional",{get:function(){return!this.required}}),Object.defineProperty(s.prototype,"delimited",{get:function(){return this.resolvedType instanceof t&&"DELIMITED"===this._features.message_encoding}}),Object.defineProperty(s.prototype,"packed",{get:function(){return"PACKED"===this._features.repeated_field_encoding}}),Object.defineProperty(s.prototype,"hasPresence",{get:function(){return!this.repeated&&!this.map&&(this.partOf||this.declaringField||this.extensionField||"IMPLICIT"!==this._features.field_presence)}}),s.prototype.setOption=function(t,r,i){return e.prototype.setOption.call(this,t,r,i)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.toObject(["edition",this._editionToJSON(),"rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},s.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=i.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof t?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=n.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var o;n.base64.test(this.typeDefault)?n.base64.decode(this.typeDefault,o=n.newBuffer(n.base64.length(this.typeDefault)),0):n.utf8.write(this.typeDefault,o=n.newBuffer(n.utf8.length(this.typeDefault)),0),this.typeDefault=o}return this.map?this.defaultValue=n.emptyObject:this.repeated?this.defaultValue=n.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},s.prototype._inferLegacyProtoFeatures=function(e){if("proto2"!==e&&"proto3"!==e)return{};var r={};if("required"===this.rule&&(r.field_presence="LEGACY_REQUIRED"),this.parent&&void 0===i.defaults[this.type]){var n=this.parent.get(this.type.split(".").pop());n&&n instanceof t&&n.group&&(r.message_encoding="DELIMITED")}return!0===this.getOption("packed")?r.repeated_field_encoding="PACKED":!1===this.getOption("packed")&&(r.repeated_field_encoding="EXPANDED"),r},s.prototype._resolveFeatures=function(t){return e.prototype._resolveFeatures.call(this,this._edition||t)},s.d=function(e,t,r,i){return"function"==typeof t?t=n.decorateType(t).name:t&&"object"==typeof t&&(t=n.decorateEnum(t).name),function(o,u){n.decorateType(o.constructor).add(new s(u,e,t,r,{default:i}))}},s._configure=function(e){t=e},et}function wt(){if(it)return rt;it=1,rt=i;var e=Ot();((i.prototype=Object.create(e.prototype)).constructor=i).className="OneOf";var t=bt(),r=gt();function i(t,r,i,n){if(Array.isArray(r)||(i=r,r=void 0),e.call(this,t,i),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=n}function n(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return i.fromJSON=function(e,t){return new i(e,t.oneof,t.options,t.comment)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},i.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,n(this),this},i.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},i.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;r<this.oneof.length;++r){var i=t.get(this.oneof[r]);i&&!i.partOf&&(i.partOf=this,this.fieldsArray.push(i))}n(this)},i.prototype.onRemove=function(t){for(var r,i=0;i<this.fieldsArray.length;++i)(r=this.fieldsArray[i]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},Object.defineProperty(i.prototype,"isProto3Optional",{get:function(){if(null==this.fieldsArray||1!==this.fieldsArray.length)return!1;var e=this.fieldsArray[0];return null!=e.options&&!0===e.options.proto3_optional}}),i.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,n){r.decorateType(t.constructor).add(new i(n,e)),Object.defineProperty(t,n,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},rt}function Ot(){if(ot)return nt;ot=1,nt=s,s.className="ReflectionObject";const e=wt();var t,r=gt(),i={enum_type:"OPEN",field_presence:"EXPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"},n={enum_type:"CLOSED",field_presence:"EXPLICIT",json_format:"LEGACY_BEST_EFFORT",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"EXPANDED",utf8_validation:"NONE"},o={enum_type:"OPEN",field_presence:"IMPLICIT",json_format:"ALLOW",message_encoding:"LENGTH_PREFIXED",repeated_field_encoding:"PACKED",utf8_validation:"VERIFY"};function s(e,t){if(!r.isString(e))throw TypeError("name must be a string");if(t&&!r.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=e,this._edition=null,this._defaultEdition="proto2",this._features={},this._featuresResolved=!1,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(s.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),s.prototype.toJSON=function(){throw Error()},s.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var r=e.root;r instanceof t&&r._handleAdd(this)},s.prototype.onRemove=function(e){var r=e.root;r instanceof t&&r._handleRemove(this),this.parent=null,this.resolved=!1},s.prototype.resolve=function(){return this.resolved||this.root instanceof t&&(this.resolved=!0),this},s.prototype._resolveFeaturesRecursive=function(e){return this._resolveFeatures(this._edition||e)},s.prototype._resolveFeatures=function(t){if(!this._featuresResolved){var r={};if(!t)throw new Error("Unknown edition for "+this.fullName);var s=Object.assign(this.options?Object.assign({},this.options.features):{},this._inferLegacyProtoFeatures(t));if(this._edition){if("proto2"===t)r=Object.assign({},n);else if("proto3"===t)r=Object.assign({},o);else{if("2023"!==t)throw new Error("Unknown edition: "+t);r=Object.assign({},i)}return this._features=Object.assign(r,s||{}),void(this._featuresResolved=!0)}if(this.partOf instanceof e){var u=Object.assign({},this.partOf._features);this._features=Object.assign(u,s||{})}else if(this.declaringField);else{if(!this.parent)throw new Error("Unable to find a parent for "+this.fullName);var a=Object.assign({},this.parent._features);this._features=Object.assign(a,s||{})}this.extensionField&&(this.extensionField._features=this._features),this._featuresResolved=!0}},s.prototype._inferLegacyProtoFeatures=function(){return{}},s.prototype.getOption=function(e){if(this.options)return this.options[e]},s.prototype.setOption=function(e,t,i){return this.options||(this.options={}),/^features\./.test(e)?r.setProperty(this.options,e,t,i):i&&void 0!==this.options[e]||(this.getOption(e)!==t&&(this.resolved=!1),this.options[e]=t),this},s.prototype.setParsedOption=function(e,t,i){this.parsedOptions||(this.parsedOptions=[]);var n=this.parsedOptions;if(i){var o=n.find(function(t){return Object.prototype.hasOwnProperty.call(t,e)});if(o){var s=o[e];r.setProperty(s,i,t)}else(o={})[e]=r.setProperty({},i,t),n.push(o)}else{var u={};u[e]=t,n.push(u)}return this},s.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),i=0;i<r.length;++i)this.setOption(r[i],e[r[i]],t);return this},s.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},s.prototype._editionToJSON=function(){if(this._edition&&"proto3"!==this._edition)return this._edition},s._configure=function(e){t=e},nt}function _t(){if(ut)return st;ut=1,st=i;var e=Ot();((i.prototype=Object.create(e.prototype)).constructor=i).className="Enum";var t=Pe(),r=gt();function i(t,r,i,n,o,s){if(e.call(this,t,i),r&&"object"!=typeof r)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=n,this.comments=o||{},this.valuesOptions=s,this._valuesFeatures={},this.reserved=void 0,r)for(var u=Object.keys(r),a=0;a<u.length;++a)"number"==typeof r[u[a]]&&(this.valuesById[this.values[u[a]]=r[u[a]]]=u[a])}return i.prototype._resolveFeatures=function(t){return t=this._edition||t,e.prototype._resolveFeatures.call(this,t),Object.keys(this.values).forEach(e=>{var t=Object.assign({},this._features);this._valuesFeatures[e]=Object.assign(t,this.valuesOptions&&this.valuesOptions[e]&&this.valuesOptions[e].features)}),this},i.fromJSON=function(e,t){var r=new i(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,t.edition&&(r._edition=t.edition),r._defaultEdition="proto3",r},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["edition",this._editionToJSON(),"options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},i.prototype.add=function(e,t,i,n){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return n&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=n||null),this.comments[e]=i||null,this},i.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},i.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},i.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},st}function jt(){if(ft)return at;ft=1,at=function(n){for(var o,s=r.codegen(["m","w"],n.name+"$encode")("if(!w)")("w=Writer.create()"),u=n.fieldsArray.slice().sort(r.compareFieldsById),a=0;a<u.length;++a){var f=u[a].resolve(),h=n._fieldsArray.indexOf(f),l=f.resolvedType instanceof e?"int32":f.type,c=t.basic[l];o="m"+r.safeProp(f.name),f.map?(s("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",o,f.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",o)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(f.id<<3|2)>>>0,8|t.mapKey[f.keyType],f.keyType),void 0===c?s("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",h,o):s(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|c,l,o),s("}")("}")):f.repeated?(s("if(%s!=null&&%s.length){",o,o),f.packed&&void 0!==t.packed[l]?s("w.uint32(%i).fork()",(f.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",o)("w.%s(%s[i])",l,o)("w.ldelim()"):(s("for(var i=0;i<%s.length;++i)",o),void 0===c?i(s,f,h,o+"[i]"):s("w.uint32(%i).%s(%s[i])",(f.id<<3|c)>>>0,l,o)),s("}")):(f.optional&&s("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",o,f.name),void 0===c?i(s,f,h,o):s("w.uint32(%i).%s(%s)",(f.id<<3|c)>>>0,l,o))}return s("return w")};var e=_t(),t=mt(),r=gt();function i(e,t,r,i){return t.delimited?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,i,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,i,(t.id<<3|2)>>>0)}return at}var At=ct?lt:(ct=1,lt=function(){if(ht)return N.exports;ht=1;var e=N.exports=de();return e.build="light",e.load=function(t,r,i){return"function"==typeof r?(i=r,r=new e.Root):r||(r=new e.Root),r.load(t,i)},e.loadSync=function(t,r){return r||(r=new e.Root),r.loadSync(t)},e.encoder=jt(),e.decoder=Ue(),e.verifier=Me(),e.converter=He(),e.ReflectionObject=Ot(),e.Namespace=Pe(),e.Root=vt(),e.Enum=_t(),e.Type=yt(),e.Field=bt(),e.OneOf=wt(),e.MapField=Ce(),e.Service=qe(),e.Method=$e(),e.Message=Je(),e.wrappers=dt(),e.types=mt(),e.util=gt(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),N.exports}());const Et=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),kt=e=>{class t extends At.Message{constructor(e){super(),((e,t)=>{if(t)for(const r of Object.keys(t)){const i=t[r];null!=i&&(e[r]=i)}})(this,e)}}const r=t;return r.$type=e,r.prototype.$type=e,r},Tt=e=>t.isLong(e),Nt=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"number"==typeof e.byteLength,St=e=>Object.prototype.hasOwnProperty.call(At.types.packed,e),xt=e=>{const t=e.resolve();return t.resolvedType instanceof At.Enum||St(t.type)},Rt=(e,t)=>t in e?e[t]:void 0,Bt=e=>{const t=e.resolve();return t.resolvedType instanceof At.Enum?0:(r=t.type,Object.prototype.hasOwnProperty.call(At.types.basic,r)?At.types.basic[t.type]:2);var r},It=(e,r)=>Tt(e)||"number"==typeof e||"string"==typeof e?e:Et(e)&&"number"==typeof e.low&&"number"==typeof e.high?new t(e.low,e.high,r):r?t.UZERO:t.ZERO,Lt=(e,t,r)=>{switch(t){case"double":return e.double(Number(r));case"float":return e.float(Number(r));case"int32":return e.int32(Number(r));case"uint32":return e.uint32(Number(r));case"sint32":return e.sint32(Number(r));case"fixed32":return e.fixed32(Number(r));case"sfixed32":return e.sfixed32(Number(r));case"int64":return e.int64(It(r,!1));case"uint64":return e.uint64(It(r,!0));case"sint64":return e.sint64(It(r,!1));case"fixed64":return e.fixed64(It(r,!0));case"sfixed64":return e.sfixed64(It(r,!1));case"bool":return e.bool(Boolean(r));case"string":return e.string(String(r));case"bytes":return e.bytes((e=>"string"==typeof e?e:Nt(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)?Uint8Array.from(e.filter(e=>"number"==typeof e)):new Uint8Array)(r));default:throw new TypeError(`Unsupported protobuf field type: ${t}`)}},Ft=(e,t,r)=>{if(t<0||e.pos+t>r)throw RangeError(`index out of range: ${e.pos} + ${t} > ${r}`)},Dt=(e,t)=>{const r=e.uint32();return Ft(e,r,t),r},Pt=(e,t,r)=>{const i=e.len;e.len=r;try{switch(t){case 0:return void e.skip();case 1:return Ft(e,8,r),void e.skip(8);case 2:{const t=Dt(e,r);return void e.skip(t)}case 5:return Ft(e,4,r),void e.skip(4);default:throw new Error(`Unsupported protobuf wire type: ${String(t)}`)}}finally{e.len=i}},Ct=(e,t,r)=>{const i=t.resolve(),n=i.resolvedType;if(n instanceof At.Type){const t=e.fork();return qt(n,Et(r)?r:{},t),t.ldelim(),e}return n instanceof At.Enum?(e.int32("number"==typeof r?r:Number(r)),e):Lt(e,i.type,r)},$t=(e,t,r)=>{if(0===r.length)return e;const i=t.resolve();if(St(i.type)&&t.packed){e.uint32(t.id<<3|2).fork();for(const i of r)Ct(e,t,i);return e.ldelim(),e}const n=Bt(t);for(const o of r)e.uint32(t.id<<3|n),Ct(e,t,o);return e},qt=(e,t,r=At.Writer.create())=>{const i=e.fieldsArray.slice().sort(At.util.compareFieldsById);for(const n of i){const e=Rt(t,n.name);null!=e&&(n.repeated?$t(r,n,Array.isArray(e)?e:[]):(r.uint32(n.id<<3|Bt(n)),Ct(r,n,e)))}return r},Jt=(e,t,r,i)=>{const n=t.resolve(),o=n.resolvedType;return o instanceof At.Type?2!==r?void Pt(e,r,i):Ut(o,e,Dt(e,i)):o instanceof At.Enum?e.int32():((e,t)=>{switch(t){case"double":return e.double();case"float":return e.float();case"int32":return e.int32();case"uint32":return e.uint32();case"sint32":return e.sint32();case"fixed32":return e.fixed32();case"sfixed32":return e.sfixed32();case"int64":return e.int64();case"uint64":return e.uint64();case"sint64":return e.sint64();case"fixed64":return e.fixed64();case"sfixed64":return e.sfixed64();case"bool":return e.bool();case"string":return e.string();case"bytes":return e.bytes();default:throw new TypeError(`Unsupported protobuf field type: ${t}`)}})(e,n.type)},Ut=(e,t,r)=>{const i=t instanceof At.Reader?t:At.Reader.create(t),n=void 0===r?i.len:i.pos+r,o=(e=>{const t={};for(const r of e.fieldsArray)r.repeated&&(t[r.name]=[]);return t})(e),s=e.fieldsById;for(;i.pos<n;){const t=i.pos,r=i.uint32(),a=s[r>>>3],f=7&r;try{if(!a){Pt(i,f,n);continue}if(a.repeated){const e=Array.isArray(o[a.name])?o[a.name]:[];if(xt(a)&&2===f){const t=Dt(i,n)+i.pos;for(;i.pos<t;)e.push(Jt(i,a,0,t))}else{const t=Jt(i,a,f,n);void 0!==t&&e.push(t)}o[a.name]=e;continue}const e=Jt(i,a,f,n);void 0!==e&&(o[a.name]=e)}catch(u){if(u instanceof RangeError){const o=a?`${a.name}#${a.id}`:`unknown#${r>>>3}`;throw new RangeError(`${u.message}; protobufType=${e.fullName}; field=${o}; tag=${r}; wireType=${f}; tagPosition=${t}; readerPosition=${i.pos}; messageEnd=${n}`)}throw u}}return o},Mt=(e,t)=>t?.longs===String?e.toString():t?.longs===Number?e.toNumber():e,zt=(e,t)=>{const r=e.resolve();if(r.resolvedType instanceof At.Type)return null;if(r.resolvedType instanceof At.Enum){if(t?.enums===String){return r.resolvedType.valuesById[r.typeDefault]??r.typeDefault}return r.typeDefault}return"bytes"===r.type?t?.bytes===String?"":t?.bytes===Array?[]:new Uint8Array:r.long&&Tt(r.typeDefault)?Mt(r.typeDefault,t):r.typeDefault},Zt=(e,t,r)=>{const i=e.resolve();if(void 0!==t)return i.resolvedType instanceof At.Type?Et(t)?Ht(i.resolvedType,t,r):t:i.resolvedType instanceof At.Enum?r?.enums===String&&"number"==typeof t?i.resolvedType.valuesById[t]??t:t:i.long&&Tt(t)?Mt(t,r):"bytes"===i.type&&Nt(t)?((e,t)=>t?.bytes===String?At.util.base64.encode(e,0,e.length):t?.bytes===Array?Array.prototype.slice.call(e):e)(t,r):t},Ht=(e,t,r)=>{const i={};for(const n of e.fieldsArray.slice().sort(At.util.compareFieldsById)){const e=Rt(t,n.name);n.repeated?Array.isArray(e)?i[n.name]=e.map(e=>Zt(n,e,r)):(r?.arrays||r?.defaults)&&(i[n.name]=[]):null==e?r?.defaults&&(i[n.name]=zt(n,r)):i[n.name]=Zt(n,e,r)}return i},Vt=e=>{const t=e;t.__reflectionCodecInstalled||(t.__reflectionCodecInstalled=!0,e.encode=(t,r)=>qt(e,Et(t)?t:{},r),e.decode=(t,r)=>Ut(e,t,r),e.fromObject=e=>Et(e)?e:{},e.toObject=(t,r)=>Ht(e,Et(t)?t:{},r),e.create=e=>e?{...e}:{},e.verify=()=>null)},Wt=e=>{Vt(e);for(const t of e.nestedArray)if(t instanceof At.Type)Wt(t);else if(t instanceof At.Namespace)for(const e of t.nestedArray)e instanceof At.Type&&Wt(e)},Gt=e=>{for(const t of e.nestedArray)t instanceof At.Type?Wt(t):t instanceof At.Namespace&&Gt(t)},Xt=()=>{const e=At.Type;e.__reflectionRuntimeInstalled||(e.generateConstructor=e=>()=>kt(e),At.Type.prototype.setup=function(){return Vt(this),this},At.Type.prototype.create=function(e){return e?{...e}:{}},At.Type.prototype.encode=function(e,t){return qt(this,Et(e)?e:{},t)},At.Type.prototype.decode=function(e,t){return Ut(this,e,t)},At.Type.prototype.fromObject=function(e){return Et(e)?e:{}},At.Type.prototype.toObject=function(e,t){return Ht(this,Et(e)?e:{},t)},At.Type.prototype.verify=function(){return null},e.__reflectionRuntimeInstalled=!0)};export{t as L,Xt as a,Gt as b,qt as e,Wt as i,At as l};
|