diff --git a/.env.example b/.env.example index ad5a1bd8..4637a35a 100644 --- a/.env.example +++ b/.env.example @@ -22,6 +22,8 @@ TELESRV_ADVERTISE_IP=127.0.0.1 # Which "data center" number this server presents itself as. There's only # ever one physical server, so this normally stays 2 -- no need to change it. TELESRV_DC=2 +# ISO 3166-1 alpha-2 code returned by help.getNearestDc. CN preselects +86. +TELESRV_DEFAULT_COUNTRY_CODE=CN ## Phone Login Codes -- How a login code gets to a phone number when someone signs in. @@ -117,6 +119,19 @@ TELESRV_ADMIN_SESSION_KEY= TELESRV_ADMIN_API_ADDR= # Address the admin panel's own web UI listens on. TELESRV_ADMIN_UI_ADDR=127.0.0.1:2600 +# Permissions granted to an Admin UI session that logged in with +# TELESRV_ADMIN_UI_PASSWORD / _TOKEN. Comma-separated; "*" means every +# permission and is the default, so enabling RBAC never locks an operator out of +# a panel that worked before. Names are letters/digits/._:- and may end in +# "namespace.*" to grant a whole namespace. +TELESRV_ADMIN_UI_PERMISSIONS=* +# Additional Admin API bearer tokens with a bounded permission set each, so an +# integration gets exactly the rights it needs instead of the unrestricted +# TELESRV_ADMIN_API_TOKEN. Format: "name:token:perm1,perm2" entries separated by +# ';'. A token may not contain ':' or whitespace, names and tokens must be +# unique, and reusing TELESRV_ADMIN_API_TOKEN here is refused; any malformed +# entry fails startup rather than silently granting or dropping rights. +TELESRV_ADMIN_SCOPED_TOKENS= ## Bot API Gateway -- Optional HTTP gateway for bot libraries (e.g. python-telegram-bot). @@ -242,15 +257,12 @@ TELESRV_MTPROTO_RPC_TIMEOUT=30s TELESRV_MTPROTO_RPC_GLOBAL_WORKERS=256 TELESRV_MTPROTO_RPC_GLOBAL_MAX_TASKS=8192 TELESRV_MTPROTO_RPC_GLOBAL_MAX_BYTES=536870912 -# In-memory cache of recent RPC results, used to safely retry a request the -# client resends. Keep the limits ordered global >= auth >= session. -TELESRV_MTPROTO_RPC_RESULT_CACHE_MAX_ENTRIES=262144 -TELESRV_MTPROTO_RPC_RESULT_CACHE_MAX_BYTES=67108864 -TELESRV_MTPROTO_RPC_RESULT_CACHE_AUTH_MAX_ENTRIES=32768 -TELESRV_MTPROTO_RPC_RESULT_CACHE_AUTH_MAX_BYTES=33554432 -TELESRV_MTPROTO_RPC_RESULT_CACHE_SESSION_MAX_ENTRIES=16384 -TELESRV_MTPROTO_RPC_RESULT_CACHE_SESSION_MAX_BYTES=16777216 -TELESRV_MTPROTO_RPC_RESULT_PENDING_PER_AUTH=2048 +# Metadata-only rpc_result receipt budgets: global >= auth >= session. ACK deletes immediately; +# 331s is only the no-ACK horizon. Payloads live solely in the logical-session outbound budget. +TELESRV_MTPROTO_RPC_EXECUTION_MAX_ENTRIES=262144 +TELESRV_MTPROTO_RPC_EXECUTION_AUTH_MAX_ENTRIES=32768 +TELESRV_MTPROTO_RPC_EXECUTION_SESSION_MAX_ENTRIES=16384 +TELESRV_MTPROTO_RPC_EXECUTION_PENDING_PER_AUTH=2048 # Process-wide in-flight transport wire + decrypted plaintext reservation. TELESRV_MTPROTO_INBOUND_FRAME_GLOBAL_MAX_BYTES=536870912 # Per-connection outbound mailboxes (normal/control) and process-wide resend pending bodies. @@ -365,6 +377,93 @@ TELESRV_STARGIFT_RESELL_DELAY=0s TELESRV_STARGIFT_CRAFT_DELAY=0s TELESRV_STARGIFT_CRAFT_CHANCE_PERMILLE=250 +# Local admin-only composite account rating. It is not projected into Telegram's +# userFull.stars_rating fields. Disabling it refuses local rating writes. +TELESRV_RATING_ENABLED=true +# A local rating increase is parked for this long before it becomes the visible +# admin level; a decrease always applies immediately. 0 applies every change at once. +TELESRV_RATING_PENDING_DELAY=24h +# Background recompute worker: the rating derives from signals owned by other +# subsystems, so freshness is a worker property rather than a write-path one. +TELESRV_RATING_RECOMPUTE_INTERVAL=15m +TELESRV_RATING_RECOMPUTE_BATCH=500 +TELESRV_RATING_STALE_AFTER=6h +# Integer composite weights; the defaults below are exactly the shipped domain +# formula. Penalties are magnitudes that the formula subtracts, so every value is +# non-negative and a negative one fails startup. +TELESRV_RATING_WEIGHT_STARS_RECEIVED_PERMILLE=1000 +TELESRV_RATING_WEIGHT_STARS_SPENT_PERMILLE=250 +TELESRV_RATING_WEIGHT_MESSAGE_SENT=1 +TELESRV_RATING_WEIGHT_ACCOUNT_AGE_DAY=2 +TELESRV_RATING_WEIGHT_GIFT_RECEIVED=25 +TELESRV_RATING_WEIGHT_MODERATION_CASE=150 +TELESRV_RATING_WEIGHT_SCAM_PENALTY=5000 +TELESRV_RATING_WEIGHT_FAKE_PENALTY=5000 +# Upper bound of the activity component so activity alone cannot outweigh Stars +# and moderation; 0 leaves it uncapped. +TELESRV_RATING_ACTIVITY_CAP=5000 + +# Landing URL recorded on a minted collectible (NFT) username when the mint +# command carries no explicit URL. Empty derives +# /nft/username/. A template may carry the +# {username} placeholder; without it the name is appended as the last path +# segment. No external marketplace is contacted. +TELESRV_COLLECTIBLE_USERNAME_URL_TEMPLATE= + +# Official platform verification: applications filed through the built-in +# @verifybot and decided in the admin panel. An approval flips the platform +# verified flag on the target peer and nothing else; it is not the third-party +# bot verification icon. Disabling refuses every verification use case, while +# peers already carrying the badge keep it. +TELESRV_VERIFICATION_ENABLED=true +# Plain user accounts as verification subjects. Off by default: the official +# process verifies a public presence (bot, public channel, public supergroup). +TELESRV_VERIFICATION_ALLOW_USER_TARGETS=false +# How long an applicant must wait before filing the same target again after a +# rejection, measured from the decision so a slow review never shortens it. +# 0 disables the cooldown; must be 0..8760h. +TELESRV_VERIFICATION_REJECT_COOLDOWN=720h +# Applications one applicant may create per window. Either value 0 disables the +# budget; a positive limit requires a positive window. +TELESRV_VERIFICATION_APPLY_RATE_LIMIT=3 +TELESRV_VERIFICATION_APPLY_RATE_WINDOW=24h +# @verifybot dialog rate per applicant, independent of how many applications are +# actually created. Either value 0 disables it. +TELESRV_VERIFICATION_BOT_RATE_LIMIT=30 +TELESRV_VERIFICATION_BOT_RATE_WINDOW=1m +# Applicant notification worker. A decision commits with its outbox row, never +# with a message send, so delivery is a separate retrying cycle over durable +# rows. Interval must be positive; batch must be 1..500. +TELESRV_VERIFICATION_NOTIFY_INTERVAL=15s +TELESRV_VERIFICATION_NOTIFY_BATCH=50 +# Applications one applicant may keep open at once; 0 disables the cap, maximum +# is 50. +TELESRV_VERIFICATION_MAX_ACTIVE_PER_USER=3 + +# Third-party bot verification (core.telegram.org/api/bots/verification): a +# verifier bot marks peers with its OWN icon and description, which clients render +# before the name. This is NOT the platform checkmark above: the operator grants +# verifier status to a bot, and the two mechanisms never read each other's state. +# Disabling refuses every third-party mutation (grants, revocations, applications, +# icon catalogue edits) while the marks already granted keep rendering -- blanking +# one verifier's badges is what its per-verifier kill switch is for. +TELESRV_BOT_VERIFICATION_ENABLED=true +# Peers one verifier bot may mark. Verifier status is granted per deployment rather +# than earned per peer, so an unbounded verifier would be an unbounded badge +# printer. 0 disables the service bound and leaves only the storage bound, which is +# also the maximum accepted here (10000). +TELESRV_BOT_VERIFICATION_MAX_PER_VERIFIER=10000 +# Verification applications one applicant may file per window, across all verifier +# bots. Either value 0 disables the budget; a positive limit requires a positive +# window. Looser than the official budget on purpose: a deployment can run several +# verifier companies, and filing with a second one is not a retry of the first. +TELESRV_BOT_VERIFICATION_REQUEST_RATE_LIMIT=5 +TELESRV_BOT_VERIFICATION_REQUEST_RATE_WINDOW=24h + +# Optional Premium feature-preview media export. Missing directory keeps the +# no-video fallback; an existing but incomplete/invalid directory fails startup. +TELESRV_PREMIUM_PROMO_SEED_DIR=data/premium-promo + # 1-to-1 call timing/limits. TELESRV_CALL_RING_TIMEOUT=90s TELESRV_CALL_TOMBSTONE_TTL=60s diff --git a/cmd/bots/botcheck/main.go b/cmd/bots/botcheck/main.go index 705fbe73..4a66b6c3 100644 --- a/cmd/bots/botcheck/main.go +++ b/cmd/bots/botcheck/main.go @@ -9,8 +9,8 @@ // go run ./cmd/bots/botcheck -token ":" # 仅登录自检 // go run ./cmd/bots/botcheck -token ":" -echo # 自检后持续 echo // -// 连接生产 telesrv(obfuscated TCP)靠 DCOption.TCPObfuscatedOnly=true, -// gotd dcs.Plain 据此自动走 MTProto TCP obfuscation。 +// 以 obfuscated TCP 连接生产 telesrv:server 会逐连接自动区分 plain/obfuscated; +// 此探针靠 DCOption.TCPObfuscatedOnly=true 让 gotd 客户端选择 MTProto TCP obfuscation。 package main import ( @@ -42,7 +42,7 @@ import ( ) // obfuscatedResolver 用标准无-secret MTProto TCP obfuscation(obfuscated2)连接, -// 匹配 telesrv 生产 server 的 transport.ObfuscatedListener(obfuscated2.Accept(conn, nil))。 +// 匹配 telesrv 生产 server 自动检测后的 obfuscated2.Accept(conn, nil) 路径。 // gotd 内置 dcs.Plain 的 obfuscated 路径走 MTProxy(强制 secret),不适用这里。 type obfuscatedResolver struct { host string diff --git a/cmd/bots/botdemo/main.go b/cmd/bots/botdemo/main.go index 03de5db8..5f2e2153 100644 --- a/cmd/bots/botdemo/main.go +++ b/cmd/bots/botdemo/main.go @@ -64,8 +64,8 @@ import ( ) // obfuscatedResolver 用标准无-secret MTProto TCP obfuscation(obfuscated2)连接 telesrv, -// 匹配生产 server 的 transport.ObfuscatedListener。gotd 内置 dcs.Plain 的 obfuscated 路径 -// 走 MTProxy(强制 secret),不适用这里,所以自定义一个 Resolver。 +// 匹配生产 server 自动检测后的 obfuscated2 路径。gotd 内置 dcs.Plain 的 +// TCPObfuscatedOnly 路径走 MTProxy(强制 secret),不适用这里,所以自定义 Resolver。 type obfuscatedResolver struct { host string port int diff --git a/cmd/giftfetch/main.go b/cmd/giftfetch/main.go index 7736ab6e..bad96e32 100644 --- a/cmd/giftfetch/main.go +++ b/cmd/giftfetch/main.go @@ -830,12 +830,13 @@ func downloadPartSize(expectedSize int64) int { if expectedSize <= 0 || expectedSize >= max { return int(max) } - // Choose a valid 4 KiB-aligned limit strictly larger than the file whenever - // possible, so downloader.Stream recognizes the first short chunk as final - // without an extra EOF probe. - partSize := ((expectedSize + 1 + unit - 1) / unit) * unit - if partSize > max { - partSize = max + // Non-precise upload.getFile limits must use the client-compatible chunk + // ladder (4, 8, ..., 512 KiB), whose values also divide a 1 MiB window. + // Merely rounding to an arbitrary 4 KiB multiple (for example 48 KiB) + // is rejected with LIMIT_INVALID by some official file DCs. + partSize := unit + for partSize <= expectedSize && partSize < max { + partSize *= 2 } return int(partSize) } diff --git a/cmd/giftfetch/main_test.go b/cmd/giftfetch/main_test.go index 93233f80..da4a62c9 100644 --- a/cmd/giftfetch/main_test.go +++ b/cmd/giftfetch/main_test.go @@ -69,6 +69,7 @@ func TestDownloadPartSize(t *testing.T) { {size: 1, want: 4 << 10}, {size: (4 << 10) - 1, want: 4 << 10}, {size: 4 << 10, want: 8 << 10}, + {size: 48_632, want: 64 << 10}, {size: (512 << 10) - 1, want: 512 << 10}, {size: 512 << 10, want: 512 << 10}, {size: 1 << 20, want: 512 << 10}, @@ -80,6 +81,22 @@ func TestDownloadPartSize(t *testing.T) { } } +func TestDownloadPartSizeUsesNonPreciseChunkLadder(t *testing.T) { + const oneMiB = 1 << 20 + for size := int64(1); size < 512<<10; size += 997 { + partSize := downloadPartSize(size) + if partSize < 4<<10 || partSize > 512<<10 || partSize%(4<<10) != 0 { + t.Fatalf("downloadPartSize(%d) = %d is outside the valid 4 KiB-aligned range", size, partSize) + } + if oneMiB%partSize != 0 { + t.Fatalf("downloadPartSize(%d) = %d does not divide a 1 MiB request window", size, partSize) + } + if int64(partSize) <= size { + t.Fatalf("downloadPartSize(%d) = %d does not cover the known-size single chunk", size, partSize) + } + } +} + func TestParseAllowedMissingThumbs(t *testing.T) { allowed, err := parseAllowedMissingThumbs("5417911440709285239:photo:m,42:video:v") if err != nil { diff --git a/cmd/telesrv-admin/botverification.go b/cmd/telesrv-admin/botverification.go new file mode 100644 index 00000000..8b2b53ef --- /dev/null +++ b/cmd/telesrv-admin/botverification.go @@ -0,0 +1,569 @@ +package main + +import ( + "errors" + "net/http" + "strconv" + "strings" + + "telesrv/internal/admin" + "telesrv/internal/domain" +) + +// Third-party bot verification in the panel BFF +// (core.telegram.org/api/bots/verification). +// +// This is NOT the official platform badge (see verification.go): third-party +// verification is an attributed mark granted by a verifier bot, carrying that +// verifier's own custom emoji icon and description. The two mechanisms own +// separate tables (verification_icons / bot_verifier_settings / +// custom_verifications / custom_verification_requests vs +// verification_applications), separate permissions (botverification.* vs +// verification.*) and separate routes, and neither reads the other's state. +// +// Reads come straight from PostgreSQL, like every other table view, so the tables +// page without a hop through the admin API and peers can be resolved by a join. +// Every mutation goes the other way -- always through the admin API, so the command +// journal, the status machine and the optimistic lock are enforced in one place and +// a panel action is indistinguishable from an API one in the audit trail. + +// botVerificationRead mounts a route behind a session and botverification.review. +func (s *server) botVerificationRead(handler http.HandlerFunc) http.Handler { + return s.requireAuthAPI(s.requirePermission(permissionBotVerificationReview, handler)) +} + +// botVerificationManage mounts a route behind a session and botverification.manage. +// +// The manage right is checked on its own rather than on top of review: appointing +// a verifier and working its queue are different jobs, so an operator may hold +// either without the other. +func (s *server) botVerificationManage(handler http.HandlerFunc) http.Handler { + return s.requireAuthAPI(s.requirePermission(permissionBotVerificationManage, handler)) +} + +// --------------------------------------------------------------------------- +// Reads +// --------------------------------------------------------------------------- + +func (s *server) handleBotVerifiersAPI(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + rows, err := s.read.ListBotVerifiers(r.Context(), queryFlag(query.Get("enabled_only")), limit) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{"rows": rows}) +} + +func (s *server) handleVerificationIconsAPI(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + rows, err := s.read.ListVerificationIcons(r.Context(), queryFlag(query.Get("active_only")), limit) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{"rows": rows}) +} + +// handleCustomVerificationsAPI pages granted marks. The filter is validated before +// the read store is consulted: a malformed query is a 400 whether or not the +// database happens to be reachable. +func (s *server) handleCustomVerificationsAPI(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + peerType := strings.TrimSpace(query.Get("peer_type")) + if !validMarkablePeerType(peerType) { + writeAPIError(w, http.StatusBadRequest, "invalid peer_type") + return + } + verifierBotID, err := parseInt64(query.Get("verifier_bot_id")) + if err != nil || verifierBotID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid verifier_bot_id") + return + } + beforeID, err := parseInt64(query.Get("before_id")) + if err != nil || beforeID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid before_id") + return + } + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + rows, hasMore, err := s.read.ListCustomVerifications(r.Context(), verifierBotID, peerType, query.Get("q"), beforeID, limit) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + nextBeforeID := "" + if hasMore && len(rows) > 0 { + nextBeforeID = strconv.FormatInt(rows[len(rows)-1].ID, 10) + } + writeJSON(w, http.StatusOK, map[string]any{ + "rows": rows, + "has_more": hasMore, + "next_before_id": nextBeforeID, + }) +} + +func (s *server) handleCustomVerificationRequestsAPI(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + status := strings.TrimSpace(query.Get("status")) + if status != "" && !domain.CustomVerificationRequestStatus(status).Valid() { + writeAPIError(w, http.StatusBadRequest, "invalid status") + return + } + peerType := strings.TrimSpace(query.Get("peer_type")) + if !validMarkablePeerType(peerType) { + writeAPIError(w, http.StatusBadRequest, "invalid peer_type") + return + } + verifierBotID, err := parseInt64(query.Get("verifier_bot_id")) + if err != nil || verifierBotID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid verifier_bot_id") + return + } + beforeID, err := parseInt64(query.Get("before_id")) + if err != nil || beforeID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid before_id") + return + } + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + rows, hasMore, err := s.read.ListCustomVerificationRequests( + r.Context(), status, verifierBotID, peerType, query.Get("q"), beforeID, limit, + ) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + nextBeforeID := "" + if hasMore && len(rows) > 0 { + nextBeforeID = strconv.FormatInt(rows[len(rows)-1].ID, 10) + } + writeJSON(w, http.StatusOK, map[string]any{ + "rows": rows, + "has_more": hasMore, + "next_before_id": nextBeforeID, + }) +} + +func (s *server) handleCustomVerificationRequestDetailAPI(w http.ResponseWriter, r *http.Request) { + id, ok := botVerificationPathID(w, r) + if !ok { + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + detail, err := s.read.CustomVerificationRequestDetail(r.Context(), id) + if err != nil { + if errors.Is(err, errReadNotFound) { + writeAPIError(w, http.StatusNotFound, "custom verification request not found") + return + } + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{ + "request": detail.Request, + "verifier": detail.Verifier, + // mark_active describes the peer as it is now, not as the status implies: a + // reviewer has to see that an approved mark was since stripped by the + // operator before deciding anything else about it. + "mark_active": detail.MarkActive, + }) +} + +func (s *server) handleCustomVerificationCountsAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + counts, err := s.read.CustomVerificationRequestCounts(r.Context()) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{"counts": counts}) +} + +// --------------------------------------------------------------------------- +// Queue decisions +// --------------------------------------------------------------------------- + +// botVerificationDecisionAPIRequest is the decision payload shared by the three +// per-application actions. version is the optimistic-locking token the reviewer +// read; internal_note is operator-only and is not part of what the applicant is +// told. It is optional everywhere, so one panel form can drive all three actions +// without tripping the strict decoder. +type botVerificationDecisionAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Version flexInt64 `json:"version"` + InternalNote string `json:"internal_note"` +} + +func (s *server) handleApproveBotVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := botVerificationPathID(w, r) + if !ok { + return + } + var body botVerificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.ApproveBotVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "approve-bot-verification"), + RequestID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), botVerificationDecisionPath(id, "approve"), req) + writeBotVerificationResultAPI(w, result, status, err) +} + +func (s *server) handleRejectBotVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := botVerificationPathID(w, r) + if !ok { + return + } + var body botVerificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.RejectBotVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "reject-bot-verification"), + RequestID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), botVerificationDecisionPath(id, "reject"), req) + writeBotVerificationResultAPI(w, result, status, err) +} + +func (s *server) handleRevokeBotVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := botVerificationPathID(w, r) + if !ok { + return + } + var body botVerificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.RevokeBotVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "revoke-bot-verification"), + RequestID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), botVerificationDecisionPath(id, "revoke"), req) + writeBotVerificationResultAPI(w, result, status, err) +} + +// --------------------------------------------------------------------------- +// Operator actions +// --------------------------------------------------------------------------- + +// grantBotVerifierAPIRequest appoints a bot as a verifier or reconfigures one. +// version is 0 for a new grant and the token the operator read for an update, so +// two operators editing the same verifier cannot clobber each other. enabled is +// deliberately absent: the kill switch is its own action. +type grantBotVerifierAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + BotID flexInt64 `json:"bot_id"` + IconDocumentID flexInt64 `json:"icon_document_id"` + CompanyName string `json:"company_name"` + DefaultDescription string `json:"default_description"` + CanModifyCustomDescription bool `json:"can_modify_custom_description"` + Version flexInt64 `json:"version"` +} + +func (s *server) handleGrantBotVerifierAPI(w http.ResponseWriter, r *http.Request) { + var body grantBotVerifierAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.BotID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid bot_id") + return + } + if body.IconDocumentID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid icon_document_id") + return + } + if strings.TrimSpace(body.CompanyName) == "" { + writeAPIError(w, http.StatusBadRequest, "company_name is required") + return + } + if body.Version.Int64() < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid version") + return + } + req := admin.GrantBotVerifierRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "grant-bot-verifier"), + BotID: body.BotID.Int64(), + IconDocumentID: body.IconDocumentID.Int64(), + CompanyName: body.CompanyName, + DefaultDescription: body.DefaultDescription, + CanModifyCustomDescription: body.CanModifyCustomDescription, + Version: body.Version.Int64(), + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/verifiers/grant", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +type setBotVerifierEnabledAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + BotID flexInt64 `json:"bot_id"` + Enabled bool `json:"enabled"` +} + +func (s *server) handleSetBotVerifierEnabledAPI(w http.ResponseWriter, r *http.Request) { + var body setBotVerifierEnabledAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.BotID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid bot_id") + return + } + req := admin.SetBotVerifierEnabledRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "set-bot-verifier-enabled"), + BotID: body.BotID.Int64(), + Enabled: body.Enabled, + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/verifiers/set-enabled", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +type revokeBotVerifierAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + BotID flexInt64 `json:"bot_id"` +} + +func (s *server) handleRevokeBotVerifierAPI(w http.ResponseWriter, r *http.Request) { + var body revokeBotVerifierAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.BotID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid bot_id") + return + } + req := admin.RevokeBotVerifierRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "revoke-bot-verifier"), + BotID: body.BotID.Int64(), + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/verifiers/revoke", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +// upsertVerificationIconAPIRequest adds or updates a catalogue entry. owner_bot_id +// is optional: absent (or 0) means a shared entry any verifier may use. +type upsertVerificationIconAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + DocumentID flexInt64 `json:"document_id"` + Name string `json:"name"` + OwnerBotID flexInt64 `json:"owner_bot_id"` +} + +func (s *server) handleUpsertVerificationIconAPI(w http.ResponseWriter, r *http.Request) { + var body upsertVerificationIconAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.DocumentID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid document_id") + return + } + if strings.TrimSpace(body.Name) == "" { + writeAPIError(w, http.StatusBadRequest, "name is required") + return + } + if body.OwnerBotID.Int64() < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid owner_bot_id") + return + } + req := admin.UpsertVerificationIconRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "upsert-verification-icon"), + DocumentID: body.DocumentID.Int64(), + Name: body.Name, + OwnerBotID: body.OwnerBotID.Int64(), + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/icons/upsert", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +type setVerificationIconActiveAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + IconID flexInt64 `json:"icon_id"` + Active bool `json:"active"` +} + +func (s *server) handleSetVerificationIconActiveAPI(w http.ResponseWriter, r *http.Request) { + var body setVerificationIconActiveAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.IconID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid icon_id") + return + } + req := admin.SetVerificationIconActiveRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "set-verification-icon-active"), + IconID: body.IconID.Int64(), + Active: body.Active, + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/icons/set-active", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +// revokeCustomVerificationAPIRequest strips one verifier's mark from a peer. It +// addresses the (verifier, peer) pair rather than an application, because the +// operator may have to strip a mark no application ever produced. +type revokeCustomVerificationAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + VerifierBotID flexInt64 `json:"verifier_bot_id"` + PeerType string `json:"peer_type"` + PeerID flexInt64 `json:"peer_id"` +} + +func (s *server) handleRevokeCustomVerificationAPI(w http.ResponseWriter, r *http.Request) { + var body revokeCustomVerificationAPIRequest + if !decodeAction(w, r, &body) { + return + } + if body.VerifierBotID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid verifier_bot_id") + return + } + peerType := strings.TrimSpace(body.PeerType) + if peerType == "" || !validMarkablePeerType(peerType) { + writeAPIError(w, http.StatusBadRequest, "invalid peer_type") + return + } + if body.PeerID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid peer_id") + return + } + req := admin.RevokeCustomVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "revoke-custom-verification"), + VerifierBotID: body.VerifierBotID.Int64(), + PeerType: domain.PeerType(peerType), + PeerID: body.PeerID.Int64(), + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/botverification/marks/revoke", req) + writeBotVerificationResultAPI(w, result, status, err) +} + +// --------------------------------------------------------------------------- +// Shared helpers +// --------------------------------------------------------------------------- + +func botVerificationPathID(w http.ResponseWriter, r *http.Request) (int64, bool) { + id, err := parseInt64(r.PathValue("id")) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid id") + return 0, false + } + return id, true +} + +func botVerificationDecisionPath(requestID int64, action string) string { + return "/v1/botverification/requests/" + strconv.FormatInt(requestID, 10) + "/" + action +} + +// validMarkablePeerType accepts the peer kinds a third-party mark can sit on, plus +// the empty string for "no filter". An unmodelled value is refused rather than +// silently returning nothing, so a typo is reported. +func validMarkablePeerType(peerType string) bool { + switch domain.PeerType(peerType) { + case "", domain.PeerTypeUser, domain.PeerTypeChannel: + return true + default: + return false + } +} + +// queryFlag reads a boolean query flag the way the panel writes it. +func queryFlag(raw string) bool { + switch strings.ToLower(strings.TrimSpace(raw)) { + case "1", "true", "yes", "on": + return true + default: + return false + } +} + +// writeBotVerificationResultAPI relays the admin API's own status to the browser. +// +// The generic action handlers flatten every upstream failure into 502, which is +// fine when the only failure mode is "bad request". These have more: 409 when +// another operator changed the row first or a verifier hit its mark bound, and 404 +// for a row that is gone. Those have to reach the panel intact, because 409 is the +// one failure it resolves by reloading rather than by asking the operator to change +// something. +func writeBotVerificationResultAPI(w http.ResponseWriter, result admin.CommandResult, status int, err error) { + if err == nil { + writeJSON(w, http.StatusOK, result) + return + } + if result.Status == "" { + result.Status = "failed" + } + if result.Message == "" { + result.Message = "command failed" + } + if result.Error == "" { + result.Error = err.Error() + } + if status < 400 { + // No HTTP answer at all: the admin API was unreachable or unparsable. + status = http.StatusBadGateway + } + writeJSON(w, status, result) +} diff --git a/cmd/telesrv-admin/botverification_test.go b/cmd/telesrv-admin/botverification_test.go new file mode 100644 index 00000000..741a6a50 --- /dev/null +++ b/cmd/telesrv-admin/botverification_test.go @@ -0,0 +1,559 @@ +package main + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "telesrv/internal/admin" +) + +// Third-party bot verification in the panel BFF. The section is separate from the +// official verification one in every dimension that matters here: its own routes, +// its own two permissions, and no overlap with verification.* in either direction. + +// botVerificationRoute is one panel route with a body its handler accepts. +type panelBotVerificationRoute struct { + method string + path string + body string +} + +var panelBotVerificationReadRoutes = []panelBotVerificationRoute{ + {http.MethodGet, "/api/botverification/verifiers", ""}, + {http.MethodGet, "/api/botverification/icons", ""}, + {http.MethodGet, "/api/botverification/marks", ""}, + {http.MethodGet, "/api/botverification/requests", ""}, + {http.MethodGet, "/api/botverification/requests/7", ""}, + {http.MethodGet, "/api/botverification/counts", ""}, + {http.MethodPost, "/api/botverification/requests/7/approve", `{}`}, + {http.MethodPost, "/api/botverification/requests/7/reject", `{}`}, + {http.MethodPost, "/api/botverification/requests/7/revoke", `{}`}, +} + +var panelBotVerificationManageRoutes = []panelBotVerificationRoute{ + {http.MethodPost, "/api/actions/grant-bot-verifier", `{}`}, + {http.MethodPost, "/api/actions/set-bot-verifier-enabled", `{}`}, + {http.MethodPost, "/api/actions/revoke-bot-verifier", `{}`}, + {http.MethodPost, "/api/actions/upsert-verification-icon", `{}`}, + {http.MethodPost, "/api/actions/set-verification-icon-active", `{}`}, + {http.MethodPost, "/api/actions/revoke-custom-verification", `{}`}, +} + +func panelBotVerificationRoutes() []panelBotVerificationRoute { + out := make([]panelBotVerificationRoute, 0, + len(panelBotVerificationReadRoutes)+len(panelBotVerificationManageRoutes)) + out = append(out, panelBotVerificationReadRoutes...) + return append(out, panelBotVerificationManageRoutes...) +} + +func TestBotVerificationPanelRoutesRequireASession(t *testing.T) { + srv := panelServer(t, permissionAll) + for _, item := range panelBotVerificationRoutes() { + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, httptest.NewRequest(item.method, item.path, strings.NewReader(`{}`))) + if rec.Code != http.StatusUnauthorized { + t.Fatalf("%s %s status=%d, want 401", item.method, item.path, rec.Code) + } + } +} + +// Every mutating route in the section is behind the double-submit CSRF token, like +// every other one in the panel: a cookie-authenticated request forged by another +// origin must not be able to appoint a verifier. +func TestBotVerificationMutationsRequireTheCSRFHeader(t *testing.T) { + srv := panelServer(t, permissionAll) + cookies, token := signIn(t, srv) + for _, item := range panelBotVerificationRoutes() { + if item.method != http.MethodPost { + continue + } + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies( + httptest.NewRequest(item.method, item.path, strings.NewReader(item.body)), cookies)) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), csrfHeaderName) { + t.Fatalf("%s status=%d body=%s, want 403 without a csrf header", item.path, rec.Code, rec.Body.String()) + } + } + // A foreign origin is refused even when the token is right. + req := withCookies(httptest.NewRequest(http.MethodPost, "/api/actions/grant-bot-verifier", + strings.NewReader(`{}`)), cookies) + req.Header.Set(csrfHeaderName, token) + req.Header.Set("Origin", "https://evil.example") + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), "origin") { + t.Fatalf("foreign origin status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } +} + +// Reads do not need the token: they change nothing, and requiring it would break +// the panel without adding protection. +func TestBotVerificationReadsDoNotNeedTheCSRFHeader(t *testing.T) { + srv := panelServer(t, permissionBotVerificationReview) + cookies, _ := signIn(t, srv) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies( + httptest.NewRequest(http.MethodGet, "/api/botverification/verifiers", nil), cookies)) + // No read store is wired in this fixture, so the gate passing is what is under + // test: 503 means the request got past authorisation and CSRF. + if rec.Code != http.StatusServiceUnavailable { + t.Fatalf("GET status=%d body=%s, want the gate passed without a token", rec.Code, rec.Body.String()) + } +} + +func TestBotVerificationRoutesRefuseASessionWithoutTheRight(t *testing.T) { + // A session holding only the OFFICIAL verification rights: the two mechanisms + // are separate, so it must not reach this section at all. + srv := panelServer(t, permissionVerificationReview, permissionVerificationRevoke) + cookies, token := signIn(t, srv) + + check := func(item panelBotVerificationRoute, wantPermission string) { + var req *http.Request + if item.body == "" { + req = httptest.NewRequest(item.method, item.path, nil) + } else { + req = httptest.NewRequest(item.method, item.path, strings.NewReader(item.body)) + req.Header.Set(csrfHeaderName, token) + } + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(req, cookies)) + if rec.Code != http.StatusForbidden { + t.Fatalf("%s %s status=%d body=%s, want 403", item.method, item.path, rec.Code, rec.Body.String()) + } + var body map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("decode 403 body: %v", err) + } + if body["code"] != "FORBIDDEN" || body["permission"] != wantPermission { + t.Fatalf("%s 403 body=%+v, want %s named", item.path, body, wantPermission) + } + } + for _, item := range panelBotVerificationReadRoutes { + check(item, permissionBotVerificationReview) + } + for _, item := range panelBotVerificationManageRoutes { + check(item, permissionBotVerificationManage) + } +} + +// The two halves are independent: the review right does not appoint verifiers, and +// the manage right does not decide applications. +func TestBotVerificationReviewAndManageAreIndependent(t *testing.T) { + reviewOnly := panelServer(t, permissionBotVerificationReview) + cookies, token := signIn(t, reviewOnly) + req := withCookies(httptest.NewRequest(http.MethodPost, "/api/actions/grant-bot-verifier", + strings.NewReader(`{"reason":"partner","confirm":true,"bot_id":3003,"icon_document_id":900,"company_name":"x"}`)), cookies) + req.Header.Set(csrfHeaderName, token) + rec := httptest.NewRecorder() + reviewOnly.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), permissionBotVerificationManage) { + t.Fatalf("review-only on grant status=%d body=%s, want 403 naming manage", rec.Code, rec.Body.String()) + } + + manageOnly := panelServer(t, permissionBotVerificationManage) + cookies, token = signIn(t, manageOnly) + req = withCookies(httptest.NewRequest(http.MethodPost, "/api/botverification/requests/7/approve", + strings.NewReader(`{"reason":"verified","confirm":true,"version":3}`)), cookies) + req.Header.Set(csrfHeaderName, token) + rec = httptest.NewRecorder() + manageOnly.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), permissionBotVerificationReview) { + t.Fatalf("manage-only on approve status=%d body=%s, want 403 naming review", rec.Code, rec.Body.String()) + } +} + +// A session holding the third-party rights must not reach the official section +// either: the separation is symmetric. +func TestBotVerificationSessionCannotReachTheOfficialSection(t *testing.T) { + srv := panelServer(t, permissionBotVerificationReview, permissionBotVerificationManage) + cookies, _ := signIn(t, srv) + for _, path := range []string{"/api/verification/applications", "/api/verification/counts"} { + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodGet, path, nil), cookies)) + if rec.Code != http.StatusForbidden { + t.Fatalf("%s status=%d body=%s, want 403", path, rec.Code, rec.Body.String()) + } + } +} + +func TestApproveBotVerificationBFFForwardsActorVersionAndNote(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/botverification/requests/88/approve", strings.NewReader(`{ + "reason":"the outlet checks out","confirm":true,"version":"9223372036854775807", + "internal_note":"contact came through the press office" + }`)) + req.SetPathValue("id", "88") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleApproveBotVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if upstream.path != "/v1/botverification/requests/88/approve" { + t.Fatalf("upstream path=%q", upstream.path) + } + var got admin.ApproveBotVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded approval: %v (%s)", err, upstream.raw) + } + if got.Actor != "operator" { + t.Fatalf("actor=%q, want the signed-in operator", got.Actor) + } + // The version arrives as a decimal string from the browser and must survive + // exactly: a rounded version would decide the wrong revision of the row. + if got.RequestID != 88 || got.Version != 9223372036854775807 { + t.Fatalf("forwarded approval=%+v, want the exact int64 version", got) + } + if got.InternalNote != "contact came through the press office" || got.DryRun { + t.Fatalf("forwarded approval=%+v", got) + } + if got.CommandID == "" { + t.Fatal("no command id was minted for the idempotency key") + } +} + +// confirm=false is a rehearsal: nothing may be written until the operator confirms. +func TestBotVerificationBFFDefaultsToADryRun(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed", DryRun: true}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/botverification/requests/88/reject", strings.NewReader( + `{"reason":"not an outlet","confirm":false,"version":3}`)) + req.SetPathValue("id", "88") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleRejectBotVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var got admin.RejectBotVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded rejection: %v", err) + } + if !got.DryRun || got.Version != 3 || got.RequestID != 88 { + t.Fatalf("forwarded rejection=%+v", got) + } + + // The same on an operator action. + req = requestWithActor(httptest.NewRequest(http.MethodPost, "/api/actions/revoke-bot-verifier", strings.NewReader( + `{"reason":"programme ended","confirm":false,"bot_id":3003}`)), "operator") + rec = httptest.NewRecorder() + srv.handleRevokeBotVerifierAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("revoke status=%d body=%s", rec.Code, rec.Body.String()) + } + var revoke admin.RevokeBotVerifierRequest + if err := json.Unmarshal(upstream.raw, &revoke); err != nil { + t.Fatalf("decode forwarded revocation: %v", err) + } + if !revoke.DryRun || revoke.BotID != 3003 { + t.Fatalf("forwarded revocation=%+v", revoke) + } +} + +func TestGrantBotVerifierBFFForwardsThePayloadAndRejectsBadShapes(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := requestWithActor(httptest.NewRequest(http.MethodPost, "/api/actions/grant-bot-verifier", strings.NewReader(`{ + "reason":"partner programme","confirm":true, + "bot_id":"9223372036854775807","icon_document_id":"9223372036854775806", + "company_name":"Example Trust","default_description":"verified by Example Trust", + "can_modify_custom_description":true,"version":"4" + }`)), "operator") + rec := httptest.NewRecorder() + srv.handleGrantBotVerifierAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if upstream.path != "/v1/botverification/verifiers/grant" { + t.Fatalf("upstream path=%q", upstream.path) + } + var got admin.GrantBotVerifierRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded grant: %v", err) + } + if got.BotID != 9223372036854775807 || got.IconDocumentID != 9223372036854775806 || + got.Version != 4 || got.Actor != "operator" || got.DryRun { + t.Fatalf("forwarded grant=%+v, want the exact int64s", got) + } + if got.CompanyName != "Example Trust" || !got.CanModifyCustomDescription { + t.Fatalf("forwarded grant=%+v", got) + } + + for _, payload := range []string{ + `{"reason":"x","confirm":true,"bot_id":0,"icon_document_id":900,"company_name":"y"}`, + `{"reason":"x","confirm":true,"bot_id":3003,"icon_document_id":0,"company_name":"y"}`, + `{"reason":"x","confirm":true,"bot_id":3003,"icon_document_id":900,"company_name":" "}`, + `{"reason":"x","confirm":true,"bot_id":3003,"icon_document_id":900,"company_name":"y","version":-1}`, + } { + rec := httptest.NewRecorder() + srv.handleGrantBotVerifierAPI(rec, requestWithActor( + httptest.NewRequest(http.MethodPost, "/api/actions/grant-bot-verifier", strings.NewReader(payload)), "operator")) + if rec.Code != http.StatusBadRequest { + t.Fatalf("payload %s status=%d body=%s, want 400", payload, rec.Code, rec.Body.String()) + } + } +} + +func TestBotVerificationOperatorActionsForwardTheirPayloads(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + + rec := httptest.NewRecorder() + srv.handleSetBotVerifierEnabledAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/set-bot-verifier-enabled", strings.NewReader( + `{"reason":"abuse report","confirm":true,"bot_id":"3003","enabled":false}`)), "operator")) + if rec.Code != http.StatusOK || upstream.path != "/v1/botverification/verifiers/set-enabled" { + t.Fatalf("set-enabled status=%d path=%q body=%s", rec.Code, upstream.path, rec.Body.String()) + } + var setEnabled admin.SetBotVerifierEnabledRequest + if err := json.Unmarshal(upstream.raw, &setEnabled); err != nil { + t.Fatalf("decode: %v", err) + } + if setEnabled.BotID != 3003 || setEnabled.Enabled || setEnabled.Actor != "operator" { + t.Fatalf("forwarded=%+v", setEnabled) + } + + rec = httptest.NewRecorder() + srv.handleUpsertVerificationIconAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/upsert-verification-icon", strings.NewReader( + `{"reason":"new icon","confirm":true,"document_id":"9223372036854775807","name":"blue check","owner_bot_id":"3003"}`)), "operator")) + if rec.Code != http.StatusOK || upstream.path != "/v1/botverification/icons/upsert" { + t.Fatalf("upsert-icon status=%d path=%q body=%s", rec.Code, upstream.path, rec.Body.String()) + } + var icon admin.UpsertVerificationIconRequest + if err := json.Unmarshal(upstream.raw, &icon); err != nil { + t.Fatalf("decode: %v", err) + } + if icon.DocumentID != 9223372036854775807 || icon.Name != "blue check" || icon.OwnerBotID != 3003 { + t.Fatalf("forwarded=%+v", icon) + } + // owner_bot_id is optional: absent means a shared catalogue entry. + rec = httptest.NewRecorder() + srv.handleUpsertVerificationIconAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/upsert-verification-icon", strings.NewReader( + `{"reason":"new icon","confirm":true,"document_id":900,"name":"shared"}`)), "operator")) + if rec.Code != http.StatusOK { + t.Fatalf("shared icon status=%d body=%s", rec.Code, rec.Body.String()) + } + // A fresh target: owner_bot_id is omitted when zero, so decoding into the + // previous value would silently keep the reserved owner. + var shared admin.UpsertVerificationIconRequest + if err := json.Unmarshal(upstream.raw, &shared); err != nil { + t.Fatalf("decode: %v", err) + } + if shared.OwnerBotID != 0 || shared.Name != "shared" { + t.Fatalf("forwarded=%+v, want a shared entry", shared) + } + + rec = httptest.NewRecorder() + srv.handleSetVerificationIconActiveAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/set-verification-icon-active", strings.NewReader( + `{"reason":"retired","confirm":true,"icon_id":"501","active":false}`)), "operator")) + if rec.Code != http.StatusOK || upstream.path != "/v1/botverification/icons/set-active" { + t.Fatalf("set-icon-active status=%d path=%q", rec.Code, upstream.path) + } + var iconActive admin.SetVerificationIconActiveRequest + if err := json.Unmarshal(upstream.raw, &iconActive); err != nil { + t.Fatalf("decode: %v", err) + } + if iconActive.IconID != 501 || iconActive.Active { + t.Fatalf("forwarded=%+v", iconActive) + } + + rec = httptest.NewRecorder() + srv.handleRevokeCustomVerificationAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/revoke-custom-verification", strings.NewReader( + `{"reason":"impersonation","confirm":true,"verifier_bot_id":"3003","peer_type":"channel","peer_id":"9223372036854775807"}`)), "operator")) + if rec.Code != http.StatusOK || upstream.path != "/v1/botverification/marks/revoke" { + t.Fatalf("revoke-mark status=%d path=%q body=%s", rec.Code, upstream.path, rec.Body.String()) + } + var mark admin.RevokeCustomVerificationRequest + if err := json.Unmarshal(upstream.raw, &mark); err != nil { + t.Fatalf("decode: %v", err) + } + if mark.VerifierBotID != 3003 || mark.PeerType != "channel" || mark.PeerID != 9223372036854775807 { + t.Fatalf("forwarded=%+v", mark) + } + + for _, payload := range []string{ + `{"reason":"x","confirm":true,"verifier_bot_id":0,"peer_type":"channel","peer_id":5}`, + `{"reason":"x","confirm":true,"verifier_bot_id":3003,"peer_type":"chat","peer_id":5}`, + `{"reason":"x","confirm":true,"verifier_bot_id":3003,"peer_type":"","peer_id":5}`, + `{"reason":"x","confirm":true,"verifier_bot_id":3003,"peer_type":"channel","peer_id":0}`, + } { + rec := httptest.NewRecorder() + srv.handleRevokeCustomVerificationAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/revoke-custom-verification", strings.NewReader(payload)), "operator")) + if rec.Code != http.StatusBadRequest { + t.Fatalf("payload %s status=%d body=%s, want 400", payload, rec.Code, rec.Body.String()) + } + } +} + +// A body may not smuggle in an actor: the signed-in operator is the audit identity, +// and the strict decoder is what enforces it. +func TestBotVerificationRequestsRejectUnknownFields(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "api-secret"}} + + req := httptest.NewRequest(http.MethodPost, "/api/botverification/requests/88/approve", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3,"actor":"attacker"}`)) + req.SetPathValue("id", "88") + rec := httptest.NewRecorder() + srv.handleApproveBotVerificationAPI(rec, requestWithActor(req, "operator")) + if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "actor") { + t.Fatalf("status=%d body=%s, want 400 rejecting the injected actor", rec.Code, rec.Body.String()) + } + + // enabled is not part of the grant form: the kill switch is its own action, and + // a silently ignored field would hide that from the operator. + rec = httptest.NewRecorder() + srv.handleGrantBotVerifierAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/grant-bot-verifier", strings.NewReader( + `{"reason":"x","confirm":true,"bot_id":3003,"icon_document_id":900,"company_name":"y","enabled":true}`)), "operator")) + if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "enabled") { + t.Fatalf("status=%d body=%s, want 400 naming the unknown field", rec.Code, rec.Body.String()) + } +} + +func TestBotVerificationPathIDIsValidated(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "api-secret"}} + for _, id := range []string{"", "0", "-1", "abc"} { + req := httptest.NewRequest(http.MethodPost, "/api/botverification/requests/x/approve", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3}`)) + req.SetPathValue("id", id) + rec := httptest.NewRecorder() + srv.handleApproveBotVerificationAPI(rec, requestWithActor(req, "operator")) + if rec.Code != http.StatusBadRequest { + t.Fatalf("id=%q status=%d, want 400", id, rec.Code) + } + } +} + +// A flattened 502 would hide the one failure the panel resolves by reloading. +func TestBotVerificationConflictReachesThePanelAs409(t *testing.T) { + upstream := &verificationUpstream{ + status: http.StatusConflict, + body: admin.CommandResult{ + CommandID: "c1", Status: "failed", + Error: admin.CodeCustomVerificationConflict + ": custom verification changed concurrently", + Message: "another operator changed this row first; reload it and try again", + }, + } + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/botverification/requests/88/approve", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3}`)) + req.SetPathValue("id", "88") + rec := httptest.NewRecorder() + srv.handleApproveBotVerificationAPI(rec, requestWithActor(req, "operator")) + if rec.Code != http.StatusConflict { + t.Fatalf("status=%d body=%s, want 409", rec.Code, rec.Body.String()) + } + var result admin.CommandResult + if err := json.Unmarshal(rec.Body.Bytes(), &result); err != nil { + t.Fatalf("decode conflict: %v", err) + } + if !strings.Contains(result.Error, admin.CodeCustomVerificationConflict) || + !strings.Contains(result.Message, "reload") { + t.Fatalf("result=%+v", result) + } + + // The manage half too: two operators can race one verifier row. + rec = httptest.NewRecorder() + srv.handleGrantBotVerifierAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/grant-bot-verifier", strings.NewReader( + `{"reason":"x","confirm":true,"bot_id":3003,"icon_document_id":900,"company_name":"y","version":3}`)), "operator")) + if rec.Code != http.StatusConflict { + t.Fatalf("grant status=%d body=%s, want 409", rec.Code, rec.Body.String()) + } + + // A 404 from upstream is preserved as well, so a decision on a row that is gone + // is not reported as an upstream outage. + upstream.status = http.StatusNotFound + upstream.body = admin.CommandResult{CommandID: "c2", Status: "failed", + Error: admin.CodeCustomVerificationRequestNotFound + ": custom verification request not found"} + req = httptest.NewRequest(http.MethodPost, "/api/botverification/requests/88/reject", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3}`)) + req.SetPathValue("id", "88") + rec = httptest.NewRecorder() + srv.handleRejectBotVerificationAPI(rec, requestWithActor(req, "operator")) + if rec.Code != http.StatusNotFound { + t.Fatalf("status=%d body=%s, want 404", rec.Code, rec.Body.String()) + } +} + +// An unreachable admin API is the one case with no upstream status at all. +func TestBotVerificationUnreachableUpstreamIs502(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "api-secret"}} + rec := httptest.NewRecorder() + srv.handleRevokeBotVerifierAPI(rec, requestWithActor(httptest.NewRequest( + http.MethodPost, "/api/actions/revoke-bot-verifier", strings.NewReader( + `{"reason":"x","confirm":true,"bot_id":3003}`)), "operator")) + if rec.Code != http.StatusBadGateway { + t.Fatalf("status=%d body=%s, want 502", rec.Code, rec.Body.String()) + } +} + +func TestBotVerificationReadFiltersAreValidatedBeforeTheStore(t *testing.T) { + // No read store: a malformed query still has to be a 400, so the panel is told + // what it got wrong whether or not the database is reachable. + srv := &server{} + cases := []struct { + handler http.HandlerFunc + path string + }{ + {srv.handleCustomVerificationsAPI, "/api/botverification/marks?peer_type=chat"}, + {srv.handleCustomVerificationsAPI, "/api/botverification/marks?verifier_bot_id=abc"}, + {srv.handleCustomVerificationsAPI, "/api/botverification/marks?before_id=-1"}, + {srv.handleCustomVerificationsAPI, "/api/botverification/marks?limit=abc"}, + {srv.handleCustomVerificationRequestsAPI, "/api/botverification/requests?status=in_review"}, + {srv.handleCustomVerificationRequestsAPI, "/api/botverification/requests?peer_type=chat"}, + {srv.handleCustomVerificationRequestsAPI, "/api/botverification/requests?limit=-1"}, + {srv.handleBotVerifiersAPI, "/api/botverification/verifiers?limit=abc"}, + {srv.handleVerificationIconsAPI, "/api/botverification/icons?limit=-2"}, + } + for _, item := range cases { + rec := httptest.NewRecorder() + item.handler(rec, httptest.NewRequest(http.MethodGet, item.path, nil)) + if rec.Code != http.StatusBadRequest { + t.Fatalf("%s status=%d body=%s, want 400", item.path, rec.Code, rec.Body.String()) + } + } + // A well-formed query with no store wired reports the store, not the query. + rec := httptest.NewRecorder() + srv.handleCustomVerificationRequestsAPI(rec, httptest.NewRequest( + http.MethodGet, "/api/botverification/requests?status=pending&peer_type=channel&limit=10", nil)) + if rec.Code != http.StatusServiceUnavailable { + t.Fatalf("status=%d body=%s, want 503", rec.Code, rec.Body.String()) + } +} + +func TestQueryFlagReadsThePanelsBooleans(t *testing.T) { + for _, raw := range []string{"1", "true", "TRUE", " yes ", "on"} { + if !queryFlag(raw) { + t.Fatalf("queryFlag(%q) = false", raw) + } + } + for _, raw := range []string{"", "0", "false", "no", "maybe"} { + if queryFlag(raw) { + t.Fatalf("queryFlag(%q) = true", raw) + } + } +} diff --git a/cmd/telesrv-admin/main.go b/cmd/telesrv-admin/main.go index 953b79a2..597d84db 100644 --- a/cmd/telesrv-admin/main.go +++ b/cmd/telesrv-admin/main.go @@ -71,6 +71,11 @@ type uiConfig struct { Password string Token string SessionKey []byte + // Permissions is the right set a panel session is issued with, from + // TELESRV_ADMIN_UI_PERMISSIONS. The shipped default is the single wildcard + // entry, so introducing the permission model never locks an operator out of a + // panel that worked before. + Permissions []string } // loadConfig 通过 internal/config.Load() 加载 .env 配置文件与环境变量, @@ -105,6 +110,7 @@ func loadConfig() (uiConfig, error) { Password: appCfg.AdminUIPassword, Token: appCfg.AdminUIToken, SessionKey: sum[:], + Permissions: appCfg.AdminUIPermissions, }, nil } diff --git a/cmd/telesrv-admin/readstore.go b/cmd/telesrv-admin/readstore.go index 94a01a0d..32633438 100644 --- a/cmd/telesrv-admin/readstore.go +++ b/cmd/telesrv-admin/readstore.go @@ -23,8 +23,38 @@ const ( channelListDefaultLimit = 50 channelListMaxLimit = 100 messagePageLimit = 100 + // Collectible username and account rating pages. The bounds mirror the + // use-case layer, so a table page costs the same whichever surface asks. + collectibleListDefaultLimit = 50 + collectibleListMaxLimit = 200 + collectibleTransferLimit = 50 + ratingListDefaultLimit = 50 + ratingListMaxLimit = 200 + ratingEventLimit = 50 + // Verification review queue pages. The bounds mirror app/verification, so the + // panel and the admin API page the queue identically. + verificationListDefaultLimit = 50 + verificationListMaxLimit = 200 + verificationEventLimit = 100 + // Third-party bot verification pages. The bounds mirror app/botverification, so + // the panel and the admin API page the verifier tables identically. + botVerificationListDefaultLimit = 50 + botVerificationListMaxLimit = 200 ) +// errReadNotFound reports a detail row that does not exist, so the API layer can +// answer 404 without importing the driver's sentinel. +var errReadNotFound = errors.New("read row not found") + +// escapeLikePattern neutralises LIKE metacharacters in an operator query. +// Usernames legitimately contain '_', so an unescaped search for "crypto_" would +// silently match "cryptoX" instead of the name the operator typed. +func escapeLikePattern(value string) string { + replaced := strings.ReplaceAll(value, `\`, `\\`) + replaced = strings.ReplaceAll(replaced, "%", `\%`) + return strings.ReplaceAll(replaced, "_", `\_`) +} + type readStore struct { pool *pgxpool.Pool } @@ -33,12 +63,27 @@ func newReadStore(pool *pgxpool.Pool) *readStore { return &readStore{pool: pool} } +// AccountUsername is one collectible (Fragment-style) username a peer holds. +// +// Active mirrors the username#b4073647 flag: an inactive collectible is still +// owned, it just does not resolve publicly, and an operator has to be able to +// tell those two apart -- so the row is listed either way and carries the flag +// rather than being filtered out. +type AccountUsername struct { + Username string + Active bool +} + type AccountRow struct { - ID int64 - Phone string - Username string - FirstName string - LastName string + ID int64 + Phone string + Username string + FirstName string + LastName string + // Collectibles are the peer's collectible usernames in the order clients + // project them. The editable slot in Username is never repeated here: it is a + // different kind of row that a different RPC owns. + Collectibles []AccountUsername CreatedAt time.Time UpdatedAt time.Time Frozen bool @@ -52,6 +97,22 @@ type AccountRow struct { LoginEmail string } +// accountCollectibleUsernamesColumn aggregates a peer's collectible usernames +// into one jsonb value, so a list page costs one indexed subquery per row instead +// of a second round trip per account. +// +// The object keys are the AccountUsername field names on purpose: pgx unmarshals +// jsonb straight into the Go value, and matching the field names keeps the panel's +// JSON shape identical to every other field on the row (PascalCase) instead of +// introducing one lowercase island. Ordering matches domain.SortUsernames for +// collectible rows -- stored order, then the name as a stable tiebreak. +const accountCollectibleUsernamesColumn = `COALESCE(( + SELECT jsonb_agg(jsonb_build_object('Username', pc.username, 'Active', pc.active) + ORDER BY pc.sort_order, pc.username_lower) + FROM peer_usernames pc + WHERE pc.peer_type = 'user' AND pc.peer_id = u.id AND pc.collectible_id IS NOT NULL +), '[]'::jsonb)` + type AccountDetail struct { Account AccountRow About string @@ -320,7 +381,7 @@ SELECT u.id, u.phone, u.username, u.first_name, u.last_name, u.created_at, u.upd COALESCE(ap.login_email, '') FROM users u LEFT JOIN account_restrictions r ON r.user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable LEFT JOIN auth a ON a.user_id = u.id LEFT JOIN account_passwords ap ON ap.user_id = u.id WHERE NOT u.is_bot @@ -438,7 +499,7 @@ SELECT u.id, COALESCE(NULLIF(u.username, ''), p.username_lower, ''), u.first_nam COALESCE(b.owner_user_id, 0), u.created_at, u.updated_at FROM users u LEFT JOIN bots b ON b.bot_user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable WHERE u.is_bot AND u.deleted_at IS NULL AND ($1::bigint = 0 OR u.id < $1) ORDER BY u.id DESC LIMIT $2`, beforeID, limit+1) @@ -480,7 +541,7 @@ SELECT u.id, COALESCE(NULLIF(u.username, ''), p.username_lower, ''), u.first_nam COALESCE(b.owner_user_id, 0), u.created_at, u.updated_at FROM users u LEFT JOIN bots b ON b.bot_user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable WHERE u.is_bot AND u.deleted_at IS NULL AND (u.id = $1 OR lower(u.username) = $2 OR p.username_lower = $2) ORDER BY u.id DESC LIMIT $3`, id, username, accountSearchLimit) @@ -508,7 +569,7 @@ SELECT u.id, COALESCE(NULLIF(u.username, ''), p.username_lower, ''), u.first_nam u.created_at, u.updated_at FROM users u LEFT JOIN bots b ON b.bot_user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable WHERE u.id = $1 AND u.is_bot AND u.deleted_at IS NULL`, botUserID).Scan( &out.Bot.ID, &out.Bot.Username, &out.Bot.FirstName, &out.About, &out.Bot.Verified, &out.Bot.Scam, &out.Bot.Fake, &out.Bot.OwnerUserID, &out.Description, &out.Bot.CreatedAt, &out.Bot.UpdatedAt, @@ -522,7 +583,7 @@ WHERE u.id = $1 AND u.is_bot AND u.deleted_at IS NULL`, botUserID).Scan( if err := s.pool.QueryRow(ctx, ` SELECT COALESCE(NULLIF(u.username, ''), p.username_lower, '') FROM users u -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable WHERE u.id = $1`, out.Bot.OwnerUserID).Scan(&ownerUsername); err != nil && err != pgx.ErrNoRows { return out, fmt.Errorf("get bot owner: %w", err) } else { @@ -554,7 +615,7 @@ SELECT c.id, c.access_hash, c.creator_user_id, c.title, c.about, c.participants_count, c.admins_count, c.kicked_count, c.banned_count, c.top_message_id, c.pinned_message_id, c.pts, c.date, c.created_at, c.updated_at FROM channels c -LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id +LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id AND p.editable WHERE NOT c.deleted AND NOT c.monoforum AND (c.broadcast OR c.megagroup) @@ -588,7 +649,7 @@ SELECT c.id, c.access_hash, c.creator_user_id, c.title, c.about, c.participants_count, c.admins_count, c.kicked_count, c.banned_count, c.top_message_id, c.pinned_message_id, c.pts, c.date, c.created_at, c.updated_at FROM channels c -LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id +LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id AND p.editable WHERE NOT c.deleted AND NOT c.monoforum AND (c.broadcast OR c.megagroup) @@ -622,7 +683,7 @@ SELECT c.id, c.access_hash, c.creator_user_id, c.title, c.about, c.top_message_id, c.pinned_message_id, c.pts, c.date, c.created_at, c.updated_at, row_to_json(c)::jsonb FROM channels c -LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id +LEFT JOIN peer_usernames p ON p.peer_type = 'channel' AND p.peer_id = c.id AND p.editable WHERE c.id = $1 AND NOT c.deleted AND NOT c.monoforum @@ -691,11 +752,12 @@ SELECT u.id, u.phone, u.username, u.first_name, u.last_name, u.created_at, u.upd COALESCE(EXTRACT(EPOCH FROM u.premium_expires_at), 0)::bigint, auth.last_active_at, auth.device_count, COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS display_username, - COALESCE(ap.login_email, '') + COALESCE(ap.login_email, ''), + `+accountCollectibleUsernamesColumn+` AS collectibles FROM users u JOIN auth ON auth.user_id = u.id LEFT JOIN account_restrictions r ON r.user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable LEFT JOIN account_passwords ap ON ap.user_id = u.id WHERE NOT u.is_bot AND ($1::bigint = 0 OR (auth.last_active_at, u.id) < (to_timestamp(($1::double precision) / 1000000.0), $2::bigint)) @@ -708,7 +770,7 @@ LIMIT $3`, beforeActiveUS, beforeID, limit+1) out := make([]AccountRow, 0, limit+1) for rows.Next() { var item AccountRow - if err := rows.Scan(&item.ID, &item.Phone, &item.Username, &item.FirstName, &item.LastName, &item.CreatedAt, &item.UpdatedAt, &item.Frozen, &item.Reason, &item.Verified, &item.Scam, &item.Fake, &item.PremiumUntil, &item.LastActiveAt, &item.DeviceCount, &item.Username, &item.LoginEmail); err != nil { + if err := rows.Scan(&item.ID, &item.Phone, &item.Username, &item.FirstName, &item.LastName, &item.CreatedAt, &item.UpdatedAt, &item.Frozen, &item.Reason, &item.Verified, &item.Scam, &item.Fake, &item.PremiumUntil, &item.LastActiveAt, &item.DeviceCount, &item.Username, &item.LoginEmail, &item.Collectibles); err != nil { return nil, false, err } out = append(out, item) @@ -731,15 +793,17 @@ SELECT u.id, u.phone, u.username, u.first_name, u.last_name, u.created_at, u.upd COALESCE(r.frozen, false), COALESCE(r.reason, ''), COALESCE(EXTRACT(EPOCH FROM u.premium_expires_at), 0)::bigint, COALESCE(sb.balance, 0)::bigint, COALESCE(sb.granted, false), - COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS display_username + COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS display_username, + `+accountCollectibleUsernamesColumn+` AS collectibles FROM users u LEFT JOIN account_restrictions r ON r.user_id = u.id LEFT JOIN stars_balances sb ON sb.user_id = u.id -LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable WHERE u.id = $1`, userID).Scan( &out.Account.ID, &out.Account.Phone, &out.Account.Username, &out.Account.FirstName, &out.Account.LastName, &out.Account.CreatedAt, &out.Account.UpdatedAt, &out.About, &out.LastSeenAt, &out.Verified, &out.Scam, &out.Fake, &out.Support, &out.Bot, &out.Account.Frozen, &out.Account.Reason, &out.Account.PremiumUntil, &out.StarsBalance, &out.StarsGranted, &out.Account.Username, + &out.Account.Collectibles, ) if err != nil { return out, fmt.Errorf("get account: %w", err) @@ -1227,3 +1291,1253 @@ LIMIT $3`, id, q, emojiListMaxLimit) defer rows.Close() return scanEmojiRows(rows) } + +// CollectibleUsernameRow is one collectible (Fragment-style) username asset with +// its holder resolved for display. +// +// Every int64 is tagged as a JSON string: asset ids, nanoton amounts and the +// optimistic-concurrency version all exceed the range a JSON number represents +// exactly, and a rounded id would address the wrong asset. +type CollectibleUsernameRow struct { + ID int64 `json:"ID,string"` + Username string + Status string + OwnerPeerType string + OwnerPeerID int64 `json:"OwnerPeerID,string"` + OwnerUsername string + OwnerName string + PurchaseDate time.Time + Currency string + Amount int64 `json:"Amount,string"` + CryptoCurrency string + CryptoAmount int64 `json:"CryptoAmount,string"` + URL string + OriginalOwnerPeerType string + OriginalOwnerPeerID int64 `json:"OriginalOwnerPeerID,string"` + OriginalOwnerUsername string + TransferCount int + Version int64 `json:"Version,string"` + CreatedAt time.Time + UpdatedAt time.Time + // RegistryActive / RegistrySortOrder mirror the holder's username registry + // row, so the panel can tell an owned-but-hidden name from an active one. + RegistryActive bool + RegistrySortOrder int +} + +// CollectibleUsernameTransferRow is one provenance log entry. +type CollectibleUsernameTransferRow struct { + ID int64 `json:"ID,string"` + CollectibleID int64 `json:"CollectibleID,string"` + Kind string + FromPeerType string + FromPeerID int64 `json:"FromPeerID,string"` + FromUsername string + ToPeerType string + ToPeerID int64 `json:"ToPeerID,string"` + ToUsername string + Currency string + Amount int64 `json:"Amount,string"` + Actor string + Reason string + CommandKey string + CreatedAt time.Time +} + +// CollectibleUsernameDetail is the asset plus its provenance log. +type CollectibleUsernameDetail struct { + Asset CollectibleUsernameRow + Transfers []CollectibleUsernameTransferRow +} + +const collectibleUsernameSelectColumns = `cu.id, cu.username, cu.status, + cu.owner_peer_type, cu.owner_peer_id, + COALESCE(NULLIF(ou.username, ''), NULLIF(oc.username, ''), '') AS owner_username, + COALESCE(NULLIF(ou.first_name, ''), NULLIF(oc.title, ''), '') AS owner_name, + cu.purchase_date, cu.currency, cu.amount, cu.crypto_currency, cu.crypto_amount, cu.url, + cu.original_owner_peer_type, cu.original_owner_peer_id, + COALESCE(NULLIF(gu.username, ''), NULLIF(gc.username, ''), '') AS original_owner_username, + cu.transfer_count, cu.version, cu.created_at, cu.updated_at, + COALESCE(pu.active, false), COALESCE(pu.sort_order, 0)` + +// collectibleUsernameJoins resolves the current holder, the original holder and +// the holder's registry row. Owners are users or channels, so both sides are +// joined and the peer type decides which one contributes. +const collectibleUsernameJoins = ` +FROM collectible_usernames cu +LEFT JOIN users ou ON cu.owner_peer_type = 'user' AND ou.id = cu.owner_peer_id +LEFT JOIN channels oc ON cu.owner_peer_type = 'channel' AND oc.id = cu.owner_peer_id +LEFT JOIN users gu ON cu.original_owner_peer_type = 'user' AND gu.id = cu.original_owner_peer_id +LEFT JOIN channels gc ON cu.original_owner_peer_type = 'channel' AND gc.id = cu.original_owner_peer_id +LEFT JOIN peer_usernames pu ON pu.collectible_id = cu.id` + +func collectibleUsernameScanDest(item *CollectibleUsernameRow) []any { + return []any{ + &item.ID, &item.Username, &item.Status, + &item.OwnerPeerType, &item.OwnerPeerID, &item.OwnerUsername, &item.OwnerName, + &item.PurchaseDate, &item.Currency, &item.Amount, &item.CryptoCurrency, &item.CryptoAmount, &item.URL, + &item.OriginalOwnerPeerType, &item.OriginalOwnerPeerID, &item.OriginalOwnerUsername, + &item.TransferCount, &item.Version, &item.CreatedAt, &item.UpdatedAt, + &item.RegistryActive, &item.RegistrySortOrder, + } +} + +// ListCollectibleUsernames pages over collectible assets newest first, keyset by +// descending id. status/ownerUserID/q are optional filters; q matches a username +// prefix, which is how an operator looks a name up. +func (s *readStore) ListCollectibleUsernames(ctx context.Context, status string, ownerUserID, beforeID int64, q string, limit int) ([]CollectibleUsernameRow, bool, error) { + if limit <= 0 { + limit = collectibleListDefaultLimit + } + if limit > collectibleListMaxLimit { + limit = collectibleListMaxLimit + } + status = strings.TrimSpace(status) + query := escapeLikePattern(strings.ToLower(strings.TrimPrefix(strings.TrimSpace(q), "@"))) + rows, err := s.pool.Query(ctx, ` +SELECT `+collectibleUsernameSelectColumns+collectibleUsernameJoins+` +WHERE ($1 = '' OR cu.status = $1) + AND ($2::bigint = 0 OR (cu.owner_peer_type = 'user' AND cu.owner_peer_id = $2)) + AND ($3 = '' OR cu.username_lower LIKE $3 || '%') + AND ($4::bigint = 0 OR cu.id < $4) +ORDER BY cu.id DESC +LIMIT $5`, status, ownerUserID, query, beforeID, limit+1) + if err != nil { + return nil, false, fmt.Errorf("list collectible usernames: %w", err) + } + defer rows.Close() + out := make([]CollectibleUsernameRow, 0, limit+1) + for rows.Next() { + var item CollectibleUsernameRow + if err := rows.Scan(collectibleUsernameScanDest(&item)...); err != nil { + return nil, false, err + } + out = append(out, item) + } + if err := rows.Err(); err != nil { + return nil, false, err + } + hasMore := len(out) > limit + if hasMore { + out = out[:limit] + } + return out, hasMore, nil +} + +// CollectibleUsernameDetail returns one asset with its provenance log. A missing +// asset reports errReadNotFound so the API answers 404 rather than 500. +func (s *readStore) CollectibleUsernameDetail(ctx context.Context, id int64) (CollectibleUsernameDetail, error) { + var out CollectibleUsernameDetail + err := s.pool.QueryRow(ctx, ` +SELECT `+collectibleUsernameSelectColumns+collectibleUsernameJoins+` +WHERE cu.id = $1`, id).Scan(collectibleUsernameScanDest(&out.Asset)...) + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return out, errReadNotFound + } + return out, fmt.Errorf("get collectible username: %w", err) + } + out.Transfers, err = s.collectibleUsernameTransfers(ctx, id) + if err != nil { + return out, err + } + return out, nil +} + +func (s *readStore) collectibleUsernameTransfers(ctx context.Context, collectibleID int64) ([]CollectibleUsernameTransferRow, error) { + rows, err := s.pool.Query(ctx, ` +SELECT t.id, t.collectible_id, t.kind, + t.from_peer_type, t.from_peer_id, + COALESCE(NULLIF(fu.username, ''), NULLIF(fc.username, ''), '') AS from_username, + t.to_peer_type, t.to_peer_id, + COALESCE(NULLIF(tu.username, ''), NULLIF(tc.username, ''), '') AS to_username, + t.currency, t.amount, t.actor, t.reason, COALESCE(t.command_key, ''), t.created_at +FROM collectible_username_transfers t +LEFT JOIN users fu ON t.from_peer_type = 'user' AND fu.id = t.from_peer_id +LEFT JOIN channels fc ON t.from_peer_type = 'channel' AND fc.id = t.from_peer_id +LEFT JOIN users tu ON t.to_peer_type = 'user' AND tu.id = t.to_peer_id +LEFT JOIN channels tc ON t.to_peer_type = 'channel' AND tc.id = t.to_peer_id +WHERE t.collectible_id = $1 +ORDER BY t.id DESC +LIMIT $2`, collectibleID, collectibleTransferLimit) + if err != nil { + return nil, fmt.Errorf("list collectible username transfers: %w", err) + } + defer rows.Close() + out := make([]CollectibleUsernameTransferRow, 0) + for rows.Next() { + var item CollectibleUsernameTransferRow + if err := rows.Scan( + &item.ID, &item.CollectibleID, &item.Kind, + &item.FromPeerType, &item.FromPeerID, &item.FromUsername, + &item.ToPeerType, &item.ToPeerID, &item.ToUsername, + &item.Currency, &item.Amount, &item.Actor, &item.Reason, &item.CommandKey, &item.CreatedAt, + ); err != nil { + return nil, err + } + out = append(out, item) + } + return out, rows.Err() +} + +// AccountRatingRow is one user's composite rating projection with the account +// resolved for display. The score and every component are int64 decimal strings +// for the same exactness reason as the collectible amounts. +type AccountRatingRow struct { + UserID int64 `json:"UserID,string"` + Username string + FirstName string + Level int + Stars int64 `json:"Stars,string"` + CurrentLevelStars int64 `json:"CurrentLevelStars,string"` + NextLevelStars int64 `json:"NextLevelStars,string"` + HasNextLevel bool + StarsComponent int64 `json:"StarsComponent,string"` + ActivityComponent int64 `json:"ActivityComponent,string"` + PenaltyComponent int64 `json:"PenaltyComponent,string"` + ManualComponent int64 `json:"ManualComponent,string"` + PendingStars int64 `json:"PendingStars,string"` + PendingDate time.Time + ComputedAt time.Time + UpdatedAt time.Time + Version int64 `json:"Version,string"` + // Computed is false for an account that has no stored projection yet. The + // detail view still renders it, so the operator can trigger the first + // recompute instead of facing a dead end. + Computed bool +} + +// AccountRatingEventRow is one contribution ledger entry. +type AccountRatingEventRow struct { + ID int64 `json:"ID,string"` + UserID int64 `json:"UserID,string"` + Kind string + Amount int64 `json:"Amount,string"` + Reason string + Actor string + CommandKey string + CreatedAt time.Time +} + +// AccountRatingDetail is the projection plus the ledger that explains it. +type AccountRatingDetail struct { + Rating AccountRatingRow + Events []AccountRatingEventRow +} + +const accountRatingSelectColumns = `r.user_id, + COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS display_username, + COALESCE(u.first_name, ''), + r.level, r.stars, r.current_level_stars, r.next_level_stars, + r.stars_component, r.activity_component, r.penalty_component, r.manual_component, + r.pending_stars, r.pending_date, r.computed_at, r.updated_at, r.version` + +const accountRatingJoins = ` +FROM account_rating r +LEFT JOIN users u ON u.id = r.user_id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = r.user_id AND p.editable` + +func scanAccountRatingRow(scan func(dest ...any) error, item *AccountRatingRow) error { + // next_level_stars and pending_date are nullable: the first is NULL at the top + // level, the second whenever no score is parked. + var nextLevelStars *int64 + var pendingDate *time.Time + if err := scan( + &item.UserID, &item.Username, &item.FirstName, + &item.Level, &item.Stars, &item.CurrentLevelStars, &nextLevelStars, + &item.StarsComponent, &item.ActivityComponent, &item.PenaltyComponent, &item.ManualComponent, + &item.PendingStars, &pendingDate, &item.ComputedAt, &item.UpdatedAt, &item.Version, + ); err != nil { + return err + } + // A NULL next threshold is the maxed-out level: the TL flag is omitted, so the + // panel must render "no next level" instead of a next level of zero. + item.HasNextLevel = nextLevelStars != nil + if nextLevelStars != nil { + item.NextLevelStars = *nextLevelStars + } + if pendingDate != nil { + item.PendingDate = pendingDate.UTC() + } + item.Computed = true + return nil +} + +// ListAccountRatings pages the leaderboard. Ordering and the keyset predicate +// mirror the rating store exactly -- (level DESC, stars DESC, user_id) with the +// cursor row resolved from beforeID -- so both surfaces page identically. +// ListAccountRatings pages the leaderboard. query is a free-text operator search: +// it matches a username prefix (editable or collectible), a first/last name +// prefix, and -- when the term is numeric -- the user id, so an operator can find +// an account the same way they do on the accounts tab. +func (s *readStore) ListAccountRatings(ctx context.Context, minLevel int, userID, beforeID int64, limit int, query string) ([]AccountRatingRow, bool, error) { + if limit <= 0 { + limit = ratingListDefaultLimit + } + if limit > ratingListMaxLimit { + limit = ratingListMaxLimit + } + if minLevel < 0 { + minLevel = 0 + } + if minLevel > domain.MaxAccountRatingLevel { + minLevel = domain.MaxAccountRatingLevel + } + query = strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(query), "@")) + pattern := "" + queryUserID := int64(0) + if query != "" { + pattern = strings.ToLower(escapeLikePattern(query)) + "%" + if parsed, err := strconv.ParseInt(query, 10, 64); err == nil && parsed > 0 { + queryUserID = parsed + } + } + rows, err := s.pool.Query(ctx, ` +WITH cursor_row AS ( + SELECT level AS c_level, stars AS c_stars, user_id AS c_user_id + FROM account_rating WHERE $3::bigint <> 0 AND user_id = $3 +) +SELECT `+accountRatingSelectColumns+accountRatingJoins+` +LEFT JOIN cursor_row c ON true +WHERE r.level >= $1 + AND ($2::bigint = 0 OR r.user_id = $2) + AND ($5::text = '' OR ( + ($6::bigint <> 0 AND r.user_id = $6) + OR lower(COALESCE(u.username, '')) LIKE $5 + OR lower(COALESCE(u.first_name, '')) LIKE $5 + OR lower(COALESCE(u.last_name, '')) LIKE $5 + OR EXISTS ( + SELECT 1 FROM peer_usernames pu + WHERE pu.peer_type = 'user' AND pu.peer_id = r.user_id + AND pu.username_lower LIKE $5 + ) + )) + AND ( + c.c_user_id IS NULL + OR r.level < c.c_level + OR (r.level = c.c_level AND r.stars < c.c_stars) + OR (r.level = c.c_level AND r.stars = c.c_stars AND r.user_id > c.c_user_id) + ) +ORDER BY r.level DESC, r.stars DESC, r.user_id +LIMIT $4`, minLevel, userID, beforeID, limit+1, pattern, queryUserID) + if err != nil { + return nil, false, fmt.Errorf("list account ratings: %w", err) + } + defer rows.Close() + out := make([]AccountRatingRow, 0, limit+1) + for rows.Next() { + var item AccountRatingRow + if err := scanAccountRatingRow(rows.Scan, &item); err != nil { + return nil, false, err + } + out = append(out, item) + } + if err := rows.Err(); err != nil { + return nil, false, err + } + hasMore := len(out) > limit + if hasMore { + out = out[:limit] + } + return out, hasMore, nil +} + +// AccountRatingDetail returns one user's projection with its contribution +// ledger. +// +// An account that exists but was never computed is answered with a zero-valued +// projection carrying Computed=false, because the recompute command lives on this +// very page: reporting "not found" for a real account would leave the operator +// with no way to create the first projection. Only an unknown account is a 404. +func (s *readStore) AccountRatingDetail(ctx context.Context, userID int64) (AccountRatingDetail, error) { + var out AccountRatingDetail + row := s.pool.QueryRow(ctx, ` +SELECT `+accountRatingSelectColumns+accountRatingJoins+` +WHERE r.user_id = $1`, userID) + err := scanAccountRatingRow(row.Scan, &out.Rating) + switch { + case err == nil: + case errors.Is(err, pgx.ErrNoRows): + placeholder, uncomputedErr := s.uncomputedAccountRating(ctx, userID) + if uncomputedErr != nil { + return out, uncomputedErr + } + out.Rating = placeholder + default: + return out, fmt.Errorf("get account rating: %w", err) + } + events, err := s.accountRatingEvents(ctx, userID) + if err != nil { + return out, err + } + out.Events = events + return out, nil +} + +// uncomputedAccountRating renders the projection an account would start from, +// derived through the same threshold policy the store persists, so the panel's +// level maths does not have to special-case a missing row. +func (s *readStore) uncomputedAccountRating(ctx context.Context, userID int64) (AccountRatingRow, error) { + var row AccountRatingRow + err := s.pool.QueryRow(ctx, ` +SELECT u.id, COALESCE(NULLIF(u.username, ''), p.username_lower, ''), u.first_name +FROM users u +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = u.id AND p.editable +WHERE u.id = $1`, userID).Scan(&row.UserID, &row.Username, &row.FirstName) + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return row, errReadNotFound + } + return row, fmt.Errorf("get account for rating: %w", err) + } + level, current, next, hasNext := domain.AccountRatingLevelForStars(0) + row.Level = level + row.CurrentLevelStars = current + row.NextLevelStars = next + row.HasNextLevel = hasNext + return row, nil +} + +func (s *readStore) accountRatingEvents(ctx context.Context, userID int64) ([]AccountRatingEventRow, error) { + rows, err := s.pool.Query(ctx, ` +SELECT id, user_id, kind, amount, reason, actor, COALESCE(command_key, ''), created_at +FROM account_rating_events +WHERE user_id = $1 +ORDER BY id DESC +LIMIT $2`, userID, ratingEventLimit) + if err != nil { + return nil, fmt.Errorf("list account rating events: %w", err) + } + defer rows.Close() + out := make([]AccountRatingEventRow, 0) + for rows.Next() { + var item AccountRatingEventRow + if err := rows.Scan(&item.ID, &item.UserID, &item.Kind, &item.Amount, &item.Reason, &item.Actor, &item.CommandKey, &item.CreatedAt); err != nil { + return nil, err + } + out = append(out, item) + } + return out, rows.Err() +} + +// Official platform verification review queue. +// +// The application record is the audit subject and is read here directly, with the +// applicant resolved through the same users/peer_usernames join every other view +// uses. target_verified is read from the live peer rather than from the +// submission snapshot: a reviewer has to see the badge as it is now, and the +// snapshot columns exist precisely because the live peer may have drifted. +// +// Every int64 is tagged as a JSON string. Application ids, peer ids and the +// optimistic-locking version all exceed the range a JSON number represents +// exactly, and a rounded version would send a decision against the wrong +// revision of the row. +type VerificationApplicationRow struct { + ID int64 `json:"ID,string"` + ApplicantUserID int64 `json:"ApplicantUserID,string"` + ApplicantUsername string + ApplicantName string + TargetType string + TargetID int64 `json:"TargetID,string"` + TargetTitle string + TargetUsername string + TargetVerified bool + Category string + Description string + OfficialWebsite string + SocialLinks []string + PressLinks []string + AdditionalNote string + Status string + ReviewerAdminID string + DecisionReason string + // InternalNote is operator-only: it is the reviewer handover note and is never + // projected to the applicant. Every caller of this store already holds + // verification.review. + InternalNote string + CorrelationID string + CreatedAt time.Time + UpdatedAt time.Time + SubmittedAt time.Time + ReviewedAt time.Time + Version int64 `json:"Version,string"` +} + +// VerificationEventRow is one entry of the immutable application history. +type VerificationEventRow struct { + ID int64 `json:"ID,string"` + Kind string + FromStatus string + ToStatus string + Actor string + Reason string + Note string + CreatedAt time.Time +} + +// VerificationApplicationDetail is the application, its history, and whether the +// applicant still controls the target. +type VerificationApplicationDetail struct { + Application VerificationApplicationRow + Events []VerificationEventRow + // ApplicantControlsTarget re-derives ownership from the live records, using the + // same authorities the use-case layer does: the bots table for a bot, the + // public-channel admin index for a channel or supergroup, identity for a user. + // Control can be lost between submission and review, and approving a peer the + // applicant no longer holds is exactly what the flag exists to prevent. + ApplicantControlsTarget bool +} + +const verificationSelectColumns = `va.id, va.applicant_user_id, + COALESCE(NULLIF(au.username, ''), p.username_lower, '') AS applicant_username, + TRIM(BOTH ' ' FROM COALESCE(au.first_name, '') || ' ' || COALESCE(au.last_name, '')) AS applicant_name, + va.target_type, va.target_id, va.target_title, va.target_username, + COALESCE(tu.verified, tc.verified, false) AS target_verified, + va.category, va.description, va.official_website, va.social_links, va.press_links, + va.additional_note, va.status, va.reviewer_admin_id, va.decision_reason, + va.internal_note, va.correlation_id, + va.created_at, va.updated_at, va.submitted_at, va.reviewed_at, va.version` + +// verificationJoins resolves the applicant and the live target. Bots and users +// live in the user namespace, channels and supergroups in the channel one, so +// both sides are joined and the target type decides which one contributes. +const verificationJoins = ` +FROM verification_applications va +LEFT JOIN users au ON au.id = va.applicant_user_id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = va.applicant_user_id AND p.editable +LEFT JOIN users tu ON va.target_type IN ('bot', 'user') AND tu.id = va.target_id +LEFT JOIN channels tc ON va.target_type IN ('channel', 'supergroup') AND tc.id = va.target_id` + +func scanVerificationApplicationRow(scan func(dest ...any) error, item *VerificationApplicationRow) error { + // submitted_at is NULL while the application is still a draft and reviewed_at + // until a reviewer closes it. + var submittedAt, reviewedAt *time.Time + if err := scan( + &item.ID, &item.ApplicantUserID, &item.ApplicantUsername, &item.ApplicantName, + &item.TargetType, &item.TargetID, &item.TargetTitle, &item.TargetUsername, &item.TargetVerified, + &item.Category, &item.Description, &item.OfficialWebsite, &item.SocialLinks, &item.PressLinks, + &item.AdditionalNote, &item.Status, &item.ReviewerAdminID, &item.DecisionReason, + &item.InternalNote, &item.CorrelationID, + &item.CreatedAt, &item.UpdatedAt, &submittedAt, &reviewedAt, &item.Version, + ); err != nil { + return err + } + if submittedAt != nil { + item.SubmittedAt = submittedAt.UTC() + } + if reviewedAt != nil { + item.ReviewedAt = reviewedAt.UTC() + } + if item.SocialLinks == nil { + item.SocialLinks = []string{} + } + if item.PressLinks == nil { + item.PressLinks = []string{} + } + return nil +} + +// ListVerificationApplications pages the review queue newest first, keyset by +// descending id. status/targetType/reviewer are exact filters; q matches an +// application id, a target peer id, or a target/applicant username prefix, which +// is how an operator looks a case up from a report. +func (s *readStore) ListVerificationApplications( + ctx context.Context, + status, targetType, reviewer, q string, + beforeID int64, + limit int, +) ([]VerificationApplicationRow, bool, error) { + if limit <= 0 { + limit = verificationListDefaultLimit + } + if limit > verificationListMaxLimit { + limit = verificationListMaxLimit + } + status = strings.TrimSpace(status) + targetType = strings.TrimSpace(targetType) + reviewer = strings.TrimSpace(reviewer) + query := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(q), "@")) + pattern := "" + queryID := int64(0) + if query != "" { + pattern = strings.ToLower(escapeLikePattern(query)) + "%" + if parsed, err := strconv.ParseInt(query, 10, 64); err == nil && parsed > 0 { + queryID = parsed + } + } + rows, err := s.pool.Query(ctx, ` +SELECT `+verificationSelectColumns+verificationJoins+` +WHERE ($1 = '' OR va.status = $1) + AND ($2 = '' OR va.target_type = $2) + AND ($3 = '' OR va.reviewer_admin_id = $3) + AND ($4::bigint = 0 OR va.id < $4) + AND ($5::text = '' OR ( + ($6::bigint <> 0 AND (va.id = $6 OR va.target_id = $6 OR va.applicant_user_id = $6)) + OR lower(va.target_username) LIKE $5 + OR lower(va.target_title) LIKE $5 + OR lower(COALESCE(au.username, '')) LIKE $5 + )) +ORDER BY va.id DESC +LIMIT $7`, status, targetType, reviewer, beforeID, pattern, queryID, limit+1) + if err != nil { + return nil, false, fmt.Errorf("list verification applications: %w", err) + } + defer rows.Close() + out := make([]VerificationApplicationRow, 0, limit+1) + for rows.Next() { + var item VerificationApplicationRow + if err := scanVerificationApplicationRow(rows.Scan, &item); err != nil { + return nil, false, err + } + out = append(out, item) + } + if err := rows.Err(); err != nil { + return nil, false, err + } + hasMore := len(out) > limit + if hasMore { + out = out[:limit] + } + return out, hasMore, nil +} + +// VerificationApplicationDetail returns one application with its history and the +// live ownership check. A missing application reports errReadNotFound so the API +// answers 404 rather than 500. +func (s *readStore) VerificationApplicationDetail(ctx context.Context, id int64) (VerificationApplicationDetail, error) { + var out VerificationApplicationDetail + row := s.pool.QueryRow(ctx, ` +SELECT `+verificationSelectColumns+verificationJoins+` +WHERE va.id = $1`, id) + // The single-row path reuses the list scanner, so one column order serves + // both: a drift between them would silently mis-assign columns. + err := scanVerificationApplicationRow(row.Scan, &out.Application) + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return out, errReadNotFound + } + return out, fmt.Errorf("get verification application: %w", err) + } + out.Events, err = s.verificationApplicationEvents(ctx, id) + if err != nil { + return out, err + } + controls, err := s.applicantControlsVerificationTarget( + ctx, out.Application.ApplicantUserID, out.Application.TargetType, out.Application.TargetID, + ) + if err != nil { + return out, err + } + out.ApplicantControlsTarget = controls + return out, nil +} + +func (s *readStore) verificationApplicationEvents(ctx context.Context, applicationID int64) ([]VerificationEventRow, error) { + rows, err := s.pool.Query(ctx, ` +SELECT id, kind, from_status, to_status, actor, reason, note, created_at +FROM verification_application_events +WHERE application_id = $1 +ORDER BY id DESC +LIMIT $2`, applicationID, verificationEventLimit) + if err != nil { + return nil, fmt.Errorf("list verification application events: %w", err) + } + defer rows.Close() + out := make([]VerificationEventRow, 0) + for rows.Next() { + var item VerificationEventRow + if err := rows.Scan( + &item.ID, &item.Kind, &item.FromStatus, &item.ToStatus, + &item.Actor, &item.Reason, &item.Note, &item.CreatedAt, + ); err != nil { + return nil, err + } + out = append(out, item) + } + return out, rows.Err() +} + +// VerificationStatusCounts is the queue summary above the list. Every modelled +// status is present with a zero, so the panel never has to tell "none" from +// "missing", and the counts are decimal strings for the same exactness reason as +// the ids. +func (s *readStore) VerificationStatusCounts(ctx context.Context) (map[string]string, error) { + out := map[string]string{} + for _, status := range []domain.VerificationStatus{ + domain.VerificationStatusDraft, + domain.VerificationStatusSubmitted, + domain.VerificationStatusInReview, + domain.VerificationStatusApproved, + domain.VerificationStatusRejected, + domain.VerificationStatusCancelled, + } { + out[string(status)] = "0" + } + rows, err := s.pool.Query(ctx, ` +SELECT status, count(*) FROM verification_applications GROUP BY status`) + if err != nil { + return nil, fmt.Errorf("count verification applications: %w", err) + } + defer rows.Close() + for rows.Next() { + var status string + var count int64 + if err := rows.Scan(&status, &count); err != nil { + return nil, err + } + out[status] = strconv.FormatInt(count, 10) + } + return out, rows.Err() +} + +// applicantControlsVerificationTarget re-derives ownership from the live records. +// +// The authorities are the ones app/verification uses, so the panel's answer and +// the approval path's answer cannot disagree: the bots table for a bot (minus +// BotFather, which nobody owns), the public-channel admin index for a channel or +// supergroup, and plain identity for a user account. +func (s *readStore) applicantControlsVerificationTarget(ctx context.Context, applicantUserID int64, targetType string, targetID int64) (bool, error) { + if applicantUserID <= 0 || targetID <= 0 { + return false, nil + } + switch domain.VerificationTargetType(targetType) { + case domain.VerificationTargetUser: + return applicantUserID == targetID, nil + case domain.VerificationTargetBot: + var owns bool + err := s.pool.QueryRow(ctx, ` +SELECT EXISTS ( + SELECT 1 FROM bots b + WHERE b.bot_user_id = $1 AND b.owner_user_id = $2 AND b.bot_user_id <> $3 +)`, targetID, applicantUserID, domain.BotFatherUserID).Scan(&owns) + if err != nil { + return false, fmt.Errorf("check verification bot ownership: %w", err) + } + return owns, nil + case domain.VerificationTargetChannel, domain.VerificationTargetSupergroup: + var admins bool + err := s.pool.QueryRow(ctx, ` +SELECT EXISTS ( + SELECT 1 FROM user_channel_member_index i + WHERE i.user_id = $1 AND i.channel_id = $2 + AND i.status = 'active' AND i.role IN ('creator', 'admin') + AND i.public_username AND NOT i.deleted +)`, applicantUserID, targetID).Scan(&admins) + if err != nil { + return false, fmt.Errorf("check verification channel ownership: %w", err) + } + return admins, nil + default: + return false, nil + } +} + +// Third-party bot verification (core.telegram.org/api/bots/verification). +// +// This is NOT the official platform badge read above. Official verification is a +// boolean on the peer that only the operator sets; third-party verification is an +// attributed mark granted by a verifier bot, carrying that verifier's own custom +// emoji icon and description. The two mechanisms own separate tables and neither +// reads the other's, which is why these queries never touch +// verification_applications or users.verified. +// +// Peer titles and usernames are resolved from the live peer rather than from the +// application's snapshot columns: an operator has to see the peer as it is now, +// and the snapshot is only the fallback for a peer that has since gone. Usernames +// come from the same users/channels + peer_usernames join every other view uses, +// with `AND p.editable` on the peer_usernames side -- a collectible username sits +// in the same table and is not the peer's own editable handle, so joining without +// the predicate would report somebody else's asset as the peer's name. +// +// Every int64 is tagged as a JSON string. Bot ids, peer ids, custom emoji document +// ids and the optimistic-locking version all exceed the range a JSON number +// represents exactly, and a rounded version would send a decision against the +// wrong revision of the row. + +// BotVerifierRow is one verifier bot: its operator-granted settings, the catalogue +// name of the icon it marks with, and how many peers it has marked. +type BotVerifierRow struct { + BotID int64 `json:"BotID,string"` + BotUsername string + BotName string + IconDocumentID int64 `json:"IconDocumentID,string"` + IconName string + CompanyName string + DefaultDescription string + CanModifyCustomDescription bool + Enabled bool + GrantedBy string + GrantReason string + // MarkCount is how many peers this verifier currently marks. It is the number + // that would cascade away with a revocation, so it is counted rather than + // estimated. + MarkCount int64 `json:"MarkCount,string"` + CreatedAt time.Time + UpdatedAt time.Time + Version int64 `json:"Version,string"` +} + +// VerificationIconRow is one catalogue entry. +type VerificationIconRow struct { + ID int64 `json:"ID,string"` + DocumentID int64 `json:"DocumentID,string"` + // OwnerBotID is 0 for a shared entry and a bot id when the operator reserved + // the icon for one verifier. + OwnerBotID int64 `json:"OwnerBotID,string"` + OwnerBotUsername string + Name string + Active bool + // UsedByVerifiers is a plain number: it counts verifier rows pointing at this + // document and can never approach the exactness limit an id can. + UsedByVerifiers int `json:"UsedByVerifiers"` + CreatedAt time.Time + UpdatedAt time.Time +} + +// CustomVerificationRow is one granted mark. +type CustomVerificationRow struct { + ID int64 `json:"ID,string"` + VerifierBotID int64 `json:"VerifierBotID,string"` + VerifierBotUsername string + CompanyName string + PeerType string + PeerID int64 `json:"PeerID,string"` + PeerTitle string + PeerUsername string + // IconDocumentID is the icon the mark was granted with, denormalised at grant + // time, so it keeps rendering even after the verifier changes its own. + IconDocumentID int64 `json:"IconDocumentID,string"` + Description string + CreatedAt time.Time + UpdatedAt time.Time + Version int64 `json:"Version,string"` +} + +// CustomVerificationRequestRow is one application filed with a verifier bot. +type CustomVerificationRequestRow struct { + ID int64 `json:"ID,string"` + VerifierBotID int64 `json:"VerifierBotID,string"` + VerifierBotUsername string + ApplicantUserID int64 `json:"ApplicantUserID,string"` + ApplicantUsername string + PeerType string + PeerID int64 `json:"PeerID,string"` + PeerTitle string + PeerUsername string + Reason string + RequestedDescription string + Status string + DecidedBy string + DecisionReason string + // InternalNote is operator-only: it is the reviewer handover note and is never + // projected to the applicant. Every caller of this store already holds + // botverification.review. + InternalNote string + CorrelationID string + CreatedAt time.Time + UpdatedAt time.Time + ApprovedAt time.Time + RejectedAt time.Time + Version int64 `json:"Version,string"` +} + +// CustomVerificationRequestDetail is one application, the verifier behind it, and +// whether the mark is on the peer right now. +type CustomVerificationRequestDetail struct { + Request CustomVerificationRequestRow + Verifier BotVerifierRow + // MarkActive tells "approved" apart from "approved and since stripped by the + // operator", which is the one thing the status alone cannot say. + MarkActive bool +} + +const botVerifierSelectColumns = `s.bot_id, + COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS bot_username, + TRIM(BOTH ' ' FROM COALESCE(u.first_name, '') || ' ' || COALESCE(u.last_name, '')) AS bot_name, + s.icon_document_id, COALESCE(i.name, '') AS icon_name, + s.company_name, s.default_description, s.can_modify_custom_description, + s.enabled, s.granted_by, s.grant_reason, + (SELECT count(*) FROM custom_verifications cv WHERE cv.verifier_bot_id = s.bot_id) AS mark_count, + s.created_at, s.updated_at, s.version` + +// botVerifierJoins resolves the bot account behind the verifier row and the +// catalogue label of its icon. The icon join is by document id, not by catalogue +// id: the settings row stores the document, and an icon dropped from the catalogue +// must still leave the verifier readable. +const botVerifierJoins = ` +FROM bot_verifier_settings s +LEFT JOIN users u ON u.id = s.bot_id +LEFT JOIN peer_usernames p ON p.peer_type = 'user' AND p.peer_id = s.bot_id AND p.editable +LEFT JOIN verification_icons i ON i.document_id = s.icon_document_id` + +func scanBotVerifierRow(scan func(dest ...any) error, item *BotVerifierRow) error { + return scan( + &item.BotID, &item.BotUsername, &item.BotName, + &item.IconDocumentID, &item.IconName, + &item.CompanyName, &item.DefaultDescription, &item.CanModifyCustomDescription, + &item.Enabled, &item.GrantedBy, &item.GrantReason, &item.MarkCount, + &item.CreatedAt, &item.UpdatedAt, &item.Version, + ) +} + +// ListBotVerifiers lists verifier bots, ordered by bot id so the table is stable +// across reloads. enabledOnly hides the ones the operator switched off. +func (s *readStore) ListBotVerifiers(ctx context.Context, enabledOnly bool, limit int) ([]BotVerifierRow, error) { + limit = clampBotVerificationLimit(limit) + rows, err := s.pool.Query(ctx, ` +SELECT `+botVerifierSelectColumns+botVerifierJoins+` +WHERE NOT $1::boolean OR s.enabled +ORDER BY s.bot_id +LIMIT $2`, enabledOnly, limit) + if err != nil { + return nil, fmt.Errorf("list bot verifiers: %w", err) + } + defer rows.Close() + out := make([]BotVerifierRow, 0, limit) + for rows.Next() { + var item BotVerifierRow + if err := scanBotVerifierRow(rows.Scan, &item); err != nil { + return nil, err + } + out = append(out, item) + } + return out, rows.Err() +} + +// BotVerifier reads one verifier row, enabled or not: the panel needs the disabled +// one too, to render the kill switch. A missing row reports errReadNotFound. +func (s *readStore) BotVerifier(ctx context.Context, botID int64) (BotVerifierRow, error) { + var out BotVerifierRow + row := s.pool.QueryRow(ctx, ` +SELECT `+botVerifierSelectColumns+botVerifierJoins+` +WHERE s.bot_id = $1`, botID) + // The single-row path reuses the list scanner, so one column order serves both: + // a drift between them would silently mis-assign columns. + if err := scanBotVerifierRow(row.Scan, &out); err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return out, errReadNotFound + } + return out, fmt.Errorf("get bot verifier: %w", err) + } + return out, nil +} + +// ListVerificationIcons lists the icon catalogue newest first, with the number of +// verifiers each entry is currently configured on -- retiring an entry that +// verifiers still point at is the operator's decision to make knowingly. +func (s *readStore) ListVerificationIcons(ctx context.Context, activeOnly bool, limit int) ([]VerificationIconRow, error) { + limit = clampBotVerificationLimit(limit) + rows, err := s.pool.Query(ctx, ` +SELECT i.id, i.document_id, i.owner_bot_id, + COALESCE(NULLIF(u.username, ''), p.username_lower, '') AS owner_bot_username, + i.name, i.active, + (SELECT count(*) FROM bot_verifier_settings s WHERE s.icon_document_id = i.document_id) AS used_by_verifiers, + i.created_at, i.updated_at +FROM verification_icons i +LEFT JOIN users u ON i.owner_bot_id <> 0 AND u.id = i.owner_bot_id +LEFT JOIN peer_usernames p ON i.owner_bot_id <> 0 + AND p.peer_type = 'user' AND p.peer_id = i.owner_bot_id AND p.editable +WHERE NOT $1::boolean OR i.active +ORDER BY i.id DESC +LIMIT $2`, activeOnly, limit) + if err != nil { + return nil, fmt.Errorf("list verification icons: %w", err) + } + defer rows.Close() + out := make([]VerificationIconRow, 0, limit) + for rows.Next() { + var item VerificationIconRow + if err := rows.Scan( + &item.ID, &item.DocumentID, &item.OwnerBotID, &item.OwnerBotUsername, + &item.Name, &item.Active, &item.UsedByVerifiers, + &item.CreatedAt, &item.UpdatedAt, + ); err != nil { + return nil, err + } + out = append(out, item) + } + return out, rows.Err() +} + +// customVerificationPeerJoins resolves a marked or applied-for peer on both sides +// of the namespace. A third-party mark can sit on a user (bots included) or a +// channel, so both are joined and the row's peer_type decides which contributes. +// Each username side carries `AND editable`, so a collectible username parked in +// peer_usernames is never mistaken for the peer's own handle. +const customVerificationPeerJoins = ` +LEFT JOIN users tu ON %[1]s.peer_type = 'user' AND tu.id = %[1]s.peer_id +LEFT JOIN peer_usernames tup ON %[1]s.peer_type = 'user' + AND tup.peer_type = 'user' AND tup.peer_id = %[1]s.peer_id AND tup.editable +LEFT JOIN channels tc ON %[1]s.peer_type = 'channel' AND tc.id = %[1]s.peer_id +LEFT JOIN peer_usernames tcp ON %[1]s.peer_type = 'channel' + AND tcp.peer_type = 'channel' AND tcp.peer_id = %[1]s.peer_id AND tcp.editable` + +// ListCustomVerifications pages granted marks newest first, keyset by descending +// id. verifierBotID/peerType are exact filters; q matches a mark id, a peer id, or +// a peer username prefix, which is how an operator looks a badge up from a report. +func (s *readStore) ListCustomVerifications( + ctx context.Context, + verifierBotID int64, + peerType, q string, + beforeID int64, + limit int, +) ([]CustomVerificationRow, bool, error) { + limit = clampBotVerificationLimit(limit) + peerType = strings.TrimSpace(peerType) + pattern, queryID := botVerificationSearchTerms(q) + rows, err := s.pool.Query(ctx, ` +SELECT cv.id, cv.verifier_bot_id, + COALESCE(NULLIF(vu.username, ''), vp.username_lower, '') AS verifier_bot_username, + COALESCE(s.company_name, '') AS company_name, + cv.peer_type, cv.peer_id, + CASE cv.peer_type + WHEN 'user' THEN TRIM(BOTH ' ' FROM COALESCE(tu.first_name, '') || ' ' || COALESCE(tu.last_name, '')) + ELSE COALESCE(tc.title, '') + END AS peer_title, + CASE cv.peer_type + WHEN 'user' THEN COALESCE(NULLIF(tu.username, ''), tup.username_lower, '') + ELSE COALESCE(NULLIF(tc.username, ''), tcp.username_lower, '') + END AS peer_username, + cv.icon_document_id, cv.description, cv.created_at, cv.updated_at, cv.version +FROM custom_verifications cv +LEFT JOIN users vu ON vu.id = cv.verifier_bot_id +LEFT JOIN peer_usernames vp ON vp.peer_type = 'user' AND vp.peer_id = cv.verifier_bot_id AND vp.editable +LEFT JOIN bot_verifier_settings s ON s.bot_id = cv.verifier_bot_id`+ + fmt.Sprintf(customVerificationPeerJoins, "cv")+` +WHERE ($1::bigint = 0 OR cv.verifier_bot_id = $1) + AND ($2::text = '' OR cv.peer_type = $2) + AND ($3::bigint = 0 OR cv.id < $3) + AND ($4::text = '' OR ( + ($5::bigint <> 0 AND (cv.id = $5 OR cv.peer_id = $5 OR cv.verifier_bot_id = $5)) + OR lower(COALESCE(tu.username, '')) LIKE $4 + OR lower(COALESCE(tc.username, '')) LIKE $4 + OR lower(COALESCE(tc.title, '')) LIKE $4 + )) +ORDER BY cv.id DESC +LIMIT $6`, verifierBotID, peerType, beforeID, pattern, queryID, limit+1) + if err != nil { + return nil, false, fmt.Errorf("list custom verifications: %w", err) + } + defer rows.Close() + out := make([]CustomVerificationRow, 0, limit+1) + for rows.Next() { + var item CustomVerificationRow + if err := rows.Scan( + &item.ID, &item.VerifierBotID, &item.VerifierBotUsername, &item.CompanyName, + &item.PeerType, &item.PeerID, &item.PeerTitle, &item.PeerUsername, + &item.IconDocumentID, &item.Description, + &item.CreatedAt, &item.UpdatedAt, &item.Version, + ); err != nil { + return nil, false, err + } + out = append(out, item) + } + if err := rows.Err(); err != nil { + return nil, false, err + } + hasMore := len(out) > limit + if hasMore { + out = out[:limit] + } + return out, hasMore, nil +} + +const customVerificationRequestSelectColumns = `r.id, r.verifier_bot_id, + COALESCE(NULLIF(vu.username, ''), vp.username_lower, '') AS verifier_bot_username, + r.applicant_user_id, + COALESCE(NULLIF(au.username, ''), ap.username_lower, '') AS applicant_username, + r.peer_type, r.peer_id, + CASE r.peer_type + WHEN 'user' THEN COALESCE(NULLIF(TRIM(BOTH ' ' FROM COALESCE(tu.first_name, '') || ' ' || COALESCE(tu.last_name, '')), ''), r.peer_title) + ELSE COALESCE(NULLIF(tc.title, ''), r.peer_title) + END AS peer_title, + CASE r.peer_type + WHEN 'user' THEN COALESCE(NULLIF(tu.username, ''), NULLIF(tup.username_lower, ''), r.peer_username) + ELSE COALESCE(NULLIF(tc.username, ''), NULLIF(tcp.username_lower, ''), r.peer_username) + END AS peer_username, + r.reason, r.requested_description, r.status, r.decided_by, r.decision_reason, + r.internal_note, r.correlation_id, + r.created_at, r.updated_at, r.approved_at, r.rejected_at, r.version` + +// customVerificationRequestJoins resolves the verifier bot, the applicant and the +// target peer. The peer title and username fall back to the application's snapshot +// columns: a peer deleted since it applied still has to render as something the +// reviewer recognises. +var customVerificationRequestJoins = ` +FROM custom_verification_requests r +LEFT JOIN users vu ON vu.id = r.verifier_bot_id +LEFT JOIN peer_usernames vp ON vp.peer_type = 'user' AND vp.peer_id = r.verifier_bot_id AND vp.editable +LEFT JOIN users au ON au.id = r.applicant_user_id +LEFT JOIN peer_usernames ap ON ap.peer_type = 'user' AND ap.peer_id = r.applicant_user_id AND ap.editable` + + fmt.Sprintf(customVerificationPeerJoins, "r") + +func scanCustomVerificationRequestRow(scan func(dest ...any) error, item *CustomVerificationRequestRow) error { + // approved_at is NULL until an approval and rejected_at until a rejection; the + // table's CHECK constraints keep each in step with the status. + var approvedAt, rejectedAt *time.Time + if err := scan( + &item.ID, &item.VerifierBotID, &item.VerifierBotUsername, + &item.ApplicantUserID, &item.ApplicantUsername, + &item.PeerType, &item.PeerID, &item.PeerTitle, &item.PeerUsername, + &item.Reason, &item.RequestedDescription, &item.Status, + &item.DecidedBy, &item.DecisionReason, &item.InternalNote, &item.CorrelationID, + &item.CreatedAt, &item.UpdatedAt, &approvedAt, &rejectedAt, &item.Version, + ); err != nil { + return err + } + if approvedAt != nil { + item.ApprovedAt = approvedAt.UTC() + } + if rejectedAt != nil { + item.RejectedAt = rejectedAt.UTC() + } + return nil +} + +// ListCustomVerificationRequests pages the third-party review queue newest first, +// keyset by descending id. status/verifierBotID/peerType are exact filters; q +// matches an application id, a peer id, a verifier id, or a peer/applicant +// username prefix. +func (s *readStore) ListCustomVerificationRequests( + ctx context.Context, + status string, + verifierBotID int64, + peerType, q string, + beforeID int64, + limit int, +) ([]CustomVerificationRequestRow, bool, error) { + limit = clampBotVerificationLimit(limit) + status = strings.TrimSpace(status) + peerType = strings.TrimSpace(peerType) + pattern, queryID := botVerificationSearchTerms(q) + rows, err := s.pool.Query(ctx, ` +SELECT `+customVerificationRequestSelectColumns+customVerificationRequestJoins+` +WHERE ($1::text = '' OR r.status = $1) + AND ($2::bigint = 0 OR r.verifier_bot_id = $2) + AND ($3::text = '' OR r.peer_type = $3) + AND ($4::bigint = 0 OR r.id < $4) + AND ($5::text = '' OR ( + ($6::bigint <> 0 AND (r.id = $6 OR r.peer_id = $6 OR r.verifier_bot_id = $6 OR r.applicant_user_id = $6)) + OR lower(r.peer_username) LIKE $5 + OR lower(r.peer_title) LIKE $5 + OR lower(COALESCE(tu.username, '')) LIKE $5 + OR lower(COALESCE(tc.username, '')) LIKE $5 + OR lower(COALESCE(au.username, '')) LIKE $5 + )) +ORDER BY r.id DESC +LIMIT $7`, status, verifierBotID, peerType, beforeID, pattern, queryID, limit+1) + if err != nil { + return nil, false, fmt.Errorf("list custom verification requests: %w", err) + } + defer rows.Close() + out := make([]CustomVerificationRequestRow, 0, limit+1) + for rows.Next() { + var item CustomVerificationRequestRow + if err := scanCustomVerificationRequestRow(rows.Scan, &item); err != nil { + return nil, false, err + } + out = append(out, item) + } + if err := rows.Err(); err != nil { + return nil, false, err + } + hasMore := len(out) > limit + if hasMore { + out = out[:limit] + } + return out, hasMore, nil +} + +// CustomVerificationRequestDetail returns one application with the verifier behind +// it and whether the mark is live. A missing application reports errReadNotFound so +// the API answers 404 rather than 500. +func (s *readStore) CustomVerificationRequestDetail(ctx context.Context, id int64) (CustomVerificationRequestDetail, error) { + var out CustomVerificationRequestDetail + row := s.pool.QueryRow(ctx, ` +SELECT `+customVerificationRequestSelectColumns+customVerificationRequestJoins+` +WHERE r.id = $1`, id) + if err := scanCustomVerificationRequestRow(row.Scan, &out.Request); err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return out, errReadNotFound + } + return out, fmt.Errorf("get custom verification request: %w", err) + } + // The verifier may have been revoked since the application was filed, and the + // application survives that (it references users, not the settings row). An + // absent verifier is reported as a row carrying only its id, so the reviewer can + // still see which bot it was. + verifier, err := s.BotVerifier(ctx, out.Request.VerifierBotID) + switch { + case err == nil: + out.Verifier = verifier + case errors.Is(err, errReadNotFound): + out.Verifier = BotVerifierRow{BotID: out.Request.VerifierBotID} + default: + return out, err + } + if err := s.pool.QueryRow(ctx, ` +SELECT EXISTS ( + SELECT 1 FROM custom_verifications + WHERE verifier_bot_id = $1 AND peer_type = $2 AND peer_id = $3 +)`, out.Request.VerifierBotID, out.Request.PeerType, out.Request.PeerID).Scan(&out.MarkActive); err != nil { + return out, fmt.Errorf("check custom verification mark: %w", err) + } + return out, nil +} + +// CustomVerificationRequestCounts is the queue summary above the list. Every +// modelled status is present, so the panel never has to tell "zero" from "absent", +// and the values are decimal strings for the same exactness reason as the ids. +func (s *readStore) CustomVerificationRequestCounts(ctx context.Context) (map[string]string, error) { + out := map[string]string{} + for _, status := range []domain.CustomVerificationRequestStatus{ + domain.CustomVerificationPending, + domain.CustomVerificationApproved, + domain.CustomVerificationRejected, + domain.CustomVerificationRevoked, + } { + out[string(status)] = "0" + } + rows, err := s.pool.Query(ctx, ` +SELECT status, count(*) FROM custom_verification_requests GROUP BY status`) + if err != nil { + return nil, fmt.Errorf("count custom verification requests: %w", err) + } + defer rows.Close() + for rows.Next() { + var status string + var count int64 + if err := rows.Scan(&status, &count); err != nil { + return nil, err + } + out[status] = strconv.FormatInt(count, 10) + } + return out, rows.Err() +} + +// botVerificationSearchTerms turns an operator query into the LIKE pattern and the +// optional exact id the list predicates use. LIKE metacharacters are escaped: +// usernames legitimately contain '_', so an unescaped search for "crypto_" would +// match "cryptoX" instead of the name that was typed. +func botVerificationSearchTerms(q string) (string, int64) { + query := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(q), "@")) + if query == "" { + return "", 0 + } + pattern := strings.ToLower(escapeLikePattern(query)) + "%" + queryID := int64(0) + if parsed, err := strconv.ParseInt(query, 10, 64); err == nil && parsed > 0 { + queryID = parsed + } + return pattern, queryID +} + +func clampBotVerificationLimit(limit int) int { + if limit <= 0 { + return botVerificationListDefaultLimit + } + if limit > botVerificationListMaxLimit { + return botVerificationListMaxLimit + } + return limit +} diff --git a/cmd/telesrv-admin/readstore_accounts_integration_test.go b/cmd/telesrv-admin/readstore_accounts_integration_test.go new file mode 100644 index 00000000..59db4ee6 --- /dev/null +++ b/cmd/telesrv-admin/readstore_accounts_integration_test.go @@ -0,0 +1,146 @@ +package main + +import ( + "context" + "fmt" + "testing" + "time" +) + +// The Accounts tab is hand-written SQL, so the collectible-username aggregation +// can only be proven against the real schema: the jsonb keys have to match the +// AccountUsername field names for pgx to unmarshal them, the ordering has to match +// the projection order clients see, and the editable slot must not leak into the +// collectible list. Gated on TELESRV_TEST_POSTGRES_DSN like the rest. +func TestReadStoreAccountsCarryCollectibleUsernames(t *testing.T) { + store, pool := verificationReadStore(t) + ctx := context.Background() + suffix := fmt.Sprintf("%d", time.Now().UnixNano()%1_000_000) + userID := 3_600_000_000 + time.Now().UnixNano()%1_000_000 + + editable := "slot" + suffix + // Deliberately out of alphabetical order and with a gap in sort_order, so a + // query that sorted by name or by insertion order would produce a different + // answer than the stored one. + collectibles := []struct { + name string + sortOrder int + active bool + collecting bool + }{ + {name: "zeta" + suffix, sortOrder: 0, active: true, collecting: true}, + {name: "alpha" + suffix, sortOrder: 5, active: false, collecting: true}, + {name: "mid" + suffix, sortOrder: 2, active: true, collecting: true}, + } + + t.Cleanup(func() { + _, _ = pool.Exec(ctx, `DELETE FROM peer_usernames WHERE peer_type='user' AND peer_id=$1`, userID) + _, _ = pool.Exec(ctx, `DELETE FROM collectible_usernames WHERE username_lower LIKE $1`, "%"+suffix) + _, _ = pool.Exec(ctx, `DELETE FROM authorizations WHERE user_id=$1`, userID) + _, _ = pool.Exec(ctx, `DELETE FROM auth_keys WHERE auth_key_id=$1`, userID) + _, _ = pool.Exec(ctx, `DELETE FROM users WHERE id=$1`, userID) + }) + + if _, err := pool.Exec(ctx, ` +INSERT INTO users (id, access_hash, phone, first_name, last_name, username, created_at, updated_at) +VALUES ($1, $2, $3, 'Collector', '', $4, now(), now())`, + userID, userID, "+1889"+suffix, editable); err != nil { + t.Fatalf("seed user: %v", err) + } + // The list query joins authorizations, so an account with no device never + // appears there at all; an authorization in turn needs its auth key to exist. + if _, err := pool.Exec(ctx, ` +INSERT INTO auth_keys (auth_key_id, body, server_salt) VALUES ($1, '\x00', 0)`, userID); err != nil { + t.Fatalf("seed auth key: %v", err) + } + if _, err := pool.Exec(ctx, ` +INSERT INTO authorizations (user_id, auth_key_id, created_at, active_at) +VALUES ($1, $2, now(), now())`, userID, userID); err != nil { + t.Fatalf("seed authorization: %v", err) + } + if _, err := pool.Exec(ctx, ` +INSERT INTO peer_usernames (username_lower, username, peer_type, peer_id, active, editable, sort_order) +VALUES (lower($1), lower($1), 'user', $2, true, true, 0)`, editable, userID); err != nil { + t.Fatalf("seed editable slot: %v", err) + } + for _, item := range collectibles { + var collectibleID int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO collectible_usernames (username, username_lower, status, owner_peer_type, owner_peer_id, + original_owner_peer_type, original_owner_peer_id, purchase_date, currency, amount, created_at, updated_at) +VALUES ($1, lower($1), 'owned', 'user', $2, 'user', $2, now(), 'XTR', 0, now(), now()) +RETURNING id`, item.name, userID).Scan(&collectibleID); err != nil { + t.Fatalf("seed collectible %s: %v", item.name, err) + } + if _, err := pool.Exec(ctx, ` +INSERT INTO peer_usernames (username_lower, username, peer_type, peer_id, active, editable, sort_order, collectible_id) +VALUES (lower($1), lower($1), 'user', $2, $3, false, $4, $5)`, + item.name, userID, item.active, item.sortOrder, collectibleID); err != nil { + t.Fatalf("attach collectible %s: %v", item.name, err) + } + } + + want := []AccountUsername{ + {Username: "zeta" + suffix, Active: true}, + {Username: "mid" + suffix, Active: true}, + {Username: "alpha" + suffix, Active: false}, + } + + detail, err := store.AccountDetail(ctx, userID) + if err != nil { + t.Fatalf("AccountDetail: %v", err) + } + assertCollectibles(t, "AccountDetail", detail.Account, editable, want) + + rows, _, err := store.ListAccounts(ctx, 0, 0, 200) + if err != nil { + t.Fatalf("ListAccounts: %v", err) + } + var listed *AccountRow + for i := range rows { + if rows[i].ID == userID { + listed = &rows[i] + break + } + } + if listed == nil { + t.Fatalf("seeded account %d is absent from the first page of %d accounts", userID, len(rows)) + } + assertCollectibles(t, "ListAccounts", *listed, editable, want) + + // An account holding nothing collectible reports an empty list, not null: the + // panel iterates it unconditionally. + if _, err := pool.Exec(ctx, `DELETE FROM peer_usernames +WHERE peer_type='user' AND peer_id=$1 AND collectible_id IS NOT NULL`, userID); err != nil { + t.Fatalf("drop collectibles: %v", err) + } + bare, err := store.AccountDetail(ctx, userID) + if err != nil { + t.Fatalf("AccountDetail without collectibles: %v", err) + } + if bare.Account.Collectibles == nil || len(bare.Account.Collectibles) != 0 { + t.Fatalf("collectibles without any rows = %#v, want an empty slice", bare.Account.Collectibles) + } +} + +func assertCollectibles(t *testing.T, surface string, row AccountRow, editable string, want []AccountUsername) { + t.Helper() + if row.Username != editable { + t.Fatalf("%s: editable username = %q, want %q", surface, row.Username, editable) + } + if len(row.Collectibles) != len(want) { + t.Fatalf("%s: collectibles = %#v, want %#v", surface, row.Collectibles, want) + } + for i := range want { + if row.Collectibles[i] != want[i] { + t.Fatalf("%s: collectibles = %#v, want %#v", surface, row.Collectibles, want) + } + } + // The editable slot is a different kind of row and must never be repeated in + // the collectible list. + for _, item := range row.Collectibles { + if item.Username == editable { + t.Fatalf("%s: editable slot leaked into the collectible list: %#v", surface, row.Collectibles) + } + } +} diff --git a/cmd/telesrv-admin/readstore_botverification_integration_test.go b/cmd/telesrv-admin/readstore_botverification_integration_test.go new file mode 100644 index 00000000..2a67e10e --- /dev/null +++ b/cmd/telesrv-admin/readstore_botverification_integration_test.go @@ -0,0 +1,571 @@ +package main + +import ( + "context" + "strconv" + "testing" + "time" + + "github.com/jackc/pgx/v5/pgxpool" +) + +// The third-party verification tables are read with hand-written SQL, so the only +// thing that can prove the column names, the CASE-per-peer-namespace projections +// and the `AND editable` username joins are right is running them against the real +// schema. Gated on TELESRV_TEST_POSTGRES_DSN, like every other integration test in +// the repo, and reusing verificationReadStore for the pool and the migration. + +// botVerificationFixture seeds two verifier bots (one enabled, one switched off), +// a shared and a reserved icon, marks on a user peer and a channel peer, and +// applications in three states. +type botVerificationFixture struct { + verifierBot int64 + disabledBot int64 + applicant int64 + userPeer int64 + channel int64 + sharedIcon int64 + reservedIcon int64 + sharedDoc int64 + reservedDoc int64 + userMark int64 + channelMark int64 + pendingReq int64 + approvedReq int64 + rejectedReq int64 + suffix string +} + +func seedBotVerificationFixture(t *testing.T, pool *pgxpool.Pool) botVerificationFixture { + t.Helper() + ctx := context.Background() + var fx botVerificationFixture + now := time.Now().UTC().Truncate(time.Microsecond) + // Usernames, channel ids and icon document ids are globally unique, so every run + // needs its own suffix: this database may still hold rows another run left. + unique := now.UnixNano() & 0x7fffffff + suffix := strconv.FormatInt(unique, 10) + fx.suffix = suffix + nextChannelID := 1_200_000_000 + unique%100_000_000 + fx.sharedDoc = 7_000_000_000 + unique%1_000_000 + fx.reservedDoc = fx.sharedDoc + 1 + + insertUser := func(first, username string, isBot bool) int64 { + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO users (access_hash, phone, first_name, last_name, username, is_bot) +VALUES ($1, $2, $3, 'Fixture', $4, $5) +RETURNING id`, unique, "71"+strconv.FormatInt(unique, 10), first, username, isBot).Scan(&id); err != nil { + t.Fatalf("insert user %s: %v", first, err) + } + unique++ + return id + } + + fx.verifierBot = insertUser("Verifierbot", "verifierbot"+suffix, true) + fx.disabledBot = insertUser("Disabledbot", "disabledbot"+suffix, true) + fx.applicant = insertUser("Applicant", "bvapplicant"+suffix, false) + fx.userPeer = insertUser("Marked", "markeduser"+suffix, false) + + fx.channel = nextChannelID + if _, err := pool.Exec(ctx, ` +INSERT INTO channels ( + id, access_hash, creator_user_id, title, username, broadcast, megagroup, + participants_count, admins_count, top_message_id, pts, date +) +VALUES ($1, $2, $3, $4, $5, true, false, 1, 1, 1, 1, $6)`, + fx.channel, unique, fx.applicant, "Fixture Marked News", "markednews"+suffix, int32(now.Unix())); err != nil { + t.Fatalf("insert channel: %v", err) + } + unique++ + + insertIcon := func(documentID, ownerBotID int64, name string, active bool) int64 { + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO verification_icons (document_id, owner_bot_id, name, active, created_at, updated_at) +VALUES ($1, $2, $3, $4, $5, $5) RETURNING id`, + documentID, ownerBotID, name, active, now).Scan(&id); err != nil { + t.Fatalf("insert icon %s: %v", name, err) + } + return id + } + fx.sharedIcon = insertIcon(fx.sharedDoc, 0, "shared check "+suffix, true) + // Reserved to the verifier bot and retired, so both the owner join and the + // active filter have a case to answer. + fx.reservedIcon = insertIcon(fx.reservedDoc, fx.verifierBot, "reserved check "+suffix, false) + + insertVerifier := func(botID, documentID int64, company string, enabled, canModify bool) { + if _, err := pool.Exec(ctx, ` +INSERT INTO bot_verifier_settings ( + bot_id, icon_document_id, company_name, default_description, + can_modify_custom_description, enabled, granted_by, grant_reason, + created_at, updated_at, version +) VALUES ($1, $2, $3, 'verified by the fixture', $4, $5, 'alice', 'partner programme', $6, $6, 4)`, + botID, documentID, company, canModify, enabled, now); err != nil { + t.Fatalf("insert verifier %d: %v", botID, err) + } + } + insertVerifier(fx.verifierBot, fx.sharedDoc, "Fixture Trust "+suffix, true, true) + insertVerifier(fx.disabledBot, fx.sharedDoc, "Switched Off "+suffix, false, false) + + insertMark := func(peerType string, peerID int64, description string) int64 { + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO custom_verifications ( + verifier_bot_id, peer_type, peer_id, icon_document_id, description, + granted_by_user_id, created_at, updated_at, version +) VALUES ($1, $2, $3, $4, $5, $1, $6, $6, 2) RETURNING id`, + fx.verifierBot, peerType, peerID, fx.sharedDoc, description, now).Scan(&id); err != nil { + t.Fatalf("insert %s mark: %v", peerType, err) + } + return id + } + fx.userMark = insertMark("user", fx.userPeer, "verified individual") + fx.channelMark = insertMark("channel", fx.channel, "verified outlet") + + insertRequest := func(peerType string, peerID int64, status, reason string) int64 { + var approvedAt, rejectedAt *time.Time + decisionReason := "" + decidedBy := "" + switch status { + case "approved": + approvedAt = &now + decidedBy = "alice" + case "rejected": + rejectedAt = &now + decidedBy = "bob" + decisionReason = reason + } + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO custom_verification_requests ( + verifier_bot_id, applicant_user_id, peer_type, peer_id, peer_title, peer_username, + reason, requested_description, status, decided_by, decision_reason, internal_note, + correlation_id, created_at, updated_at, approved_at, rejected_at, version +) VALUES ( + $1, $2, $3, $4, $5, $6, 'we are the outlet', 'verified partner', $7, $8, $9, + 'operator only', $10, $11, $11, $12, $13, 3 +) RETURNING id`, + fx.verifierBot, fx.applicant, peerType, peerID, + "Snapshot "+peerType, "snapshot"+peerType+suffix, + status, decidedBy, decisionReason, "bvcorr-"+status, + now, approvedAt, rejectedAt, + ).Scan(&id); err != nil { + t.Fatalf("insert %s request: %v", status, err) + } + return id + } + // One live application per (verifier, peer) pair, so the three seeded rows have + // to name three different peers: the partial unique index enforces it. + fx.pendingReq = insertRequest("channel", fx.channel, "pending", "") + fx.approvedReq = insertRequest("user", fx.userPeer, "approved", "") + // Filed against a peer that does not exist, so the live-peer join has a negative + // case and the snapshot fallback is exercised. + fx.rejectedReq = insertRequest("user", fx.userPeer+9_000_000, "rejected", "not an outlet") + + t.Cleanup(func() { + reqIDs := []int64{fx.pendingReq, fx.approvedReq, fx.rejectedReq} + _, _ = pool.Exec(ctx, "DELETE FROM custom_verification_requests WHERE id = ANY($1::bigint[])", reqIDs) + _, _ = pool.Exec(ctx, "DELETE FROM custom_verifications WHERE id = ANY($1::bigint[])", + []int64{fx.userMark, fx.channelMark}) + _, _ = pool.Exec(ctx, "DELETE FROM bot_verifier_settings WHERE bot_id = ANY($1::bigint[])", + []int64{fx.verifierBot, fx.disabledBot}) + _, _ = pool.Exec(ctx, "DELETE FROM verification_icons WHERE id = ANY($1::bigint[])", + []int64{fx.sharedIcon, fx.reservedIcon}) + _, _ = pool.Exec(ctx, "DELETE FROM channels WHERE id = $1", fx.channel) + _, _ = pool.Exec(ctx, "DELETE FROM users WHERE id = ANY($1::bigint[])", + []int64{fx.verifierBot, fx.disabledBot, fx.applicant, fx.userPeer}) + }) + return fx +} + +func TestBotVerificationReadStoreVerifiers(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedBotVerificationFixture(t, pool) + ctx := context.Background() + + rows, err := store.ListBotVerifiers(ctx, false, 200) + if err != nil { + t.Fatalf("list verifiers: %v", err) + } + byID := map[int64]BotVerifierRow{} + for _, row := range rows { + byID[row.BotID] = row + } + verifier, ok := byID[fx.verifierBot] + if !ok { + t.Fatal("enabled verifier missing from the listing") + } + // The bot account is resolved through the join, and the icon's catalogue label + // comes from the entry the document id points at. + if verifier.BotUsername != "verifierbot"+fx.suffix || verifier.IconName != "shared check "+fx.suffix { + t.Fatalf("verifier projection = %+v", verifier) + } + if verifier.BotName == "" || verifier.CompanyName != "Fixture Trust "+fx.suffix { + t.Fatalf("verifier names = %+v", verifier) + } + if !verifier.Enabled || !verifier.CanModifyCustomDescription || verifier.Version != 4 || + verifier.GrantedBy != "alice" || verifier.GrantReason != "partner programme" { + t.Fatalf("verifier settings = %+v", verifier) + } + // Both seeded marks belong to this verifier, and mark_count is what would + // cascade away with a revocation. + if verifier.MarkCount != 2 { + t.Fatalf("mark count = %d, want 2", verifier.MarkCount) + } + if disabled := byID[fx.disabledBot]; disabled.Enabled || disabled.MarkCount != 0 { + t.Fatalf("disabled verifier = %+v", disabled) + } + + // enabled_only hides the switched-off verifier without dropping its row. + enabled, err := store.ListBotVerifiers(ctx, true, 200) + if err != nil { + t.Fatalf("list enabled verifiers: %v", err) + } + for _, row := range enabled { + if !row.Enabled { + t.Fatalf("enabled_only leaked %+v", row) + } + if row.BotID == fx.disabledBot { + t.Fatal("enabled_only returned the switched-off verifier") + } + } + + // The detail read reuses the list scanner, so one column order serves both. + one, err := store.BotVerifier(ctx, fx.verifierBot) + if err != nil { + t.Fatalf("get verifier: %v", err) + } + if one.BotID != fx.verifierBot || one.MarkCount != 2 || one.IconName != verifier.IconName { + t.Fatalf("verifier detail = %+v", one) + } + if _, err := store.BotVerifier(ctx, fx.applicant); err == nil { + t.Fatal("a non-verifier resolved as one") + } + + // The page bound is honoured. + page, err := store.ListBotVerifiers(ctx, false, 1) + if err != nil { + t.Fatalf("bounded list: %v", err) + } + if len(page) != 1 { + t.Fatalf("bounded page len=%d", len(page)) + } +} + +func TestBotVerificationReadStoreIcons(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedBotVerificationFixture(t, pool) + ctx := context.Background() + + rows, err := store.ListVerificationIcons(ctx, false, 200) + if err != nil { + t.Fatalf("list icons: %v", err) + } + byID := map[int64]VerificationIconRow{} + for _, row := range rows { + byID[row.ID] = row + } + shared, ok := byID[fx.sharedIcon] + if !ok { + t.Fatal("shared icon missing from the catalogue listing") + } + if shared.OwnerBotID != 0 || shared.OwnerBotUsername != "" || !shared.Active { + t.Fatalf("shared icon = %+v, want no owner", shared) + } + // Both seeded verifiers point at the shared document, so retiring it is a + // decision the operator has to make knowingly. + if shared.UsedByVerifiers != 2 { + t.Fatalf("shared icon used_by_verifiers = %d, want 2", shared.UsedByVerifiers) + } + reserved, ok := byID[fx.reservedIcon] + if !ok { + t.Fatal("reserved icon missing from the catalogue listing") + } + if reserved.OwnerBotID != fx.verifierBot || reserved.OwnerBotUsername != "verifierbot"+fx.suffix { + t.Fatalf("reserved icon = %+v, want the owner resolved", reserved) + } + if reserved.Active || reserved.UsedByVerifiers != 0 { + t.Fatalf("reserved icon = %+v", reserved) + } + + // active_only hides the retired entry. + active, err := store.ListVerificationIcons(ctx, true, 200) + if err != nil { + t.Fatalf("list active icons: %v", err) + } + for _, row := range active { + if !row.Active { + t.Fatalf("active_only leaked %+v", row) + } + if row.ID == fx.reservedIcon { + t.Fatal("active_only returned the retired entry") + } + } + // Newest first. + if len(rows) >= 2 && rows[0].ID < rows[1].ID { + t.Fatalf("catalogue is not ordered newest first: %d before %d", rows[0].ID, rows[1].ID) + } +} + +func TestBotVerificationReadStoreMarks(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedBotVerificationFixture(t, pool) + ctx := context.Background() + + rows, _, err := store.ListCustomVerifications(ctx, fx.verifierBot, "", "", 0, 200) + if err != nil { + t.Fatalf("list marks: %v", err) + } + byID := map[int64]CustomVerificationRow{} + for _, row := range rows { + byID[row.ID] = row + } + // A user peer resolves through users; the verifier's company comes from its + // settings row. + userMark, ok := byID[fx.userMark] + if !ok { + t.Fatal("user mark missing from the listing") + } + if userMark.PeerType != "user" || userMark.PeerID != fx.userPeer || + userMark.PeerUsername != "markeduser"+fx.suffix { + t.Fatalf("user mark peer = %+v", userMark) + } + if userMark.PeerTitle == "" || userMark.VerifierBotUsername != "verifierbot"+fx.suffix || + userMark.CompanyName != "Fixture Trust "+fx.suffix { + t.Fatalf("user mark projection = %+v", userMark) + } + if userMark.IconDocumentID != fx.sharedDoc || userMark.Description != "verified individual" || + userMark.Version != 2 { + t.Fatalf("user mark = %+v", userMark) + } + // A channel peer resolves through channels: the CASE picks the right namespace. + channelMark, ok := byID[fx.channelMark] + if !ok { + t.Fatal("channel mark missing from the listing") + } + if channelMark.PeerType != "channel" || channelMark.PeerTitle != "Fixture Marked News" || + channelMark.PeerUsername != "markednews"+fx.suffix { + t.Fatalf("channel mark peer = %+v", channelMark) + } + + // Filters. + typed, _, err := store.ListCustomVerifications(ctx, fx.verifierBot, "channel", "", 0, 50) + if err != nil { + t.Fatalf("peer_type list: %v", err) + } + for _, row := range typed { + if row.PeerType != "channel" { + t.Fatalf("peer_type filter leaked %+v", row) + } + } + other, _, err := store.ListCustomVerifications(ctx, fx.disabledBot, "", "", 0, 50) + if err != nil { + t.Fatalf("verifier filter list: %v", err) + } + for _, row := range other { + if row.VerifierBotID != fx.disabledBot { + t.Fatalf("verifier filter leaked %+v", row) + } + } + + // q matches a mark id, a peer id, a verifier id and a username or title prefix. + for _, query := range []string{ + strconv.FormatInt(fx.channelMark, 10), + strconv.FormatInt(fx.channel, 10), + strconv.FormatInt(fx.verifierBot, 10), + "markednews" + fx.suffix, + "@markeduser" + fx.suffix, + "fixture marked", + } { + found, _, err := store.ListCustomVerifications(ctx, 0, "", query, 0, 50) + if err != nil { + t.Fatalf("search %q: %v", query, err) + } + if len(found) == 0 { + t.Fatalf("search %q returned nothing", query) + } + } + + // The keyset cursor excludes the row it points at. + after, _, err := store.ListCustomVerifications(ctx, fx.verifierBot, "", "", fx.channelMark, 50) + if err != nil { + t.Fatalf("keyset list: %v", err) + } + for _, row := range after { + if row.ID >= fx.channelMark { + t.Fatalf("keyset page leaked id %d at or after the cursor %d", row.ID, fx.channelMark) + } + } + // The page bound is honoured and reports more. + page, more, err := store.ListCustomVerifications(ctx, fx.verifierBot, "", "", 0, 1) + if err != nil { + t.Fatalf("bounded list: %v", err) + } + if len(page) != 1 || !more { + t.Fatalf("bounded page len=%d hasMore=%v", len(page), more) + } +} + +func TestBotVerificationReadStoreRequestsAndDetail(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedBotVerificationFixture(t, pool) + ctx := context.Background() + + rows, _, err := store.ListCustomVerificationRequests(ctx, "", fx.verifierBot, "", "", 0, 200) + if err != nil { + t.Fatalf("list requests: %v", err) + } + byID := map[int64]CustomVerificationRequestRow{} + for _, row := range rows { + byID[row.ID] = row + } + pending, ok := byID[fx.pendingReq] + if !ok { + t.Fatal("pending application missing from the queue") + } + if pending.ApplicantUserID != fx.applicant || pending.ApplicantUsername != "bvapplicant"+fx.suffix || + pending.VerifierBotUsername != "verifierbot"+fx.suffix { + t.Fatalf("applicant/verifier projection = %+v", pending) + } + // The peer is read live, not from the snapshot columns: an operator has to see + // the peer as it is now. + if pending.PeerTitle != "Fixture Marked News" || pending.PeerUsername != "markednews"+fx.suffix { + t.Fatalf("live peer projection = %+v, want the channel as it is now", pending) + } + if pending.Status != "pending" || pending.InternalNote != "operator only" || + pending.CorrelationID != "bvcorr-pending" || pending.Version != 3 { + t.Fatalf("operator fields = %+v", pending) + } + if !pending.ApprovedAt.IsZero() || !pending.RejectedAt.IsZero() { + t.Fatalf("timestamps approved=%v rejected=%v, want an undecided application", + pending.ApprovedAt, pending.RejectedAt) + } + if approved := byID[fx.approvedReq]; approved.ApprovedAt.IsZero() || approved.DecidedBy != "alice" { + t.Fatalf("approved application = %+v", approved) + } + if rejected := byID[fx.rejectedReq]; rejected.RejectedAt.IsZero() || rejected.DecisionReason == "" { + t.Fatalf("rejected application = %+v", rejected) + } + // A peer that does not exist falls back to the snapshot the applicant filed + // with, so the row still renders as something the reviewer recognises. + if gone := byID[fx.rejectedReq]; gone.PeerTitle != "Snapshot user" || + gone.PeerUsername != "snapshotuser"+fx.suffix { + t.Fatalf("missing peer = %+v, want the snapshot fallback", gone) + } + + // Filters. + filtered, _, err := store.ListCustomVerificationRequests(ctx, "pending", 0, "", "", 0, 50) + if err != nil { + t.Fatalf("status list: %v", err) + } + for _, row := range filtered { + if row.Status != "pending" { + t.Fatalf("status filter leaked %+v", row) + } + } + typed, _, err := store.ListCustomVerificationRequests(ctx, "", 0, "channel", "", 0, 50) + if err != nil { + t.Fatalf("peer_type list: %v", err) + } + for _, row := range typed { + if row.PeerType != "channel" { + t.Fatalf("peer_type filter leaked %+v", row) + } + } + // q matches an application id, a peer id, the applicant id, and username or + // title prefixes on both the live peer and the snapshot. + for _, query := range []string{ + strconv.FormatInt(fx.pendingReq, 10), + strconv.FormatInt(fx.channel, 10), + strconv.FormatInt(fx.applicant, 10), + "markednews" + fx.suffix, + "snapshotchannel" + fx.suffix, + "@bvapplicant" + fx.suffix, + "snapshot ", + } { + found, _, err := store.ListCustomVerificationRequests(ctx, "", 0, "", query, 0, 50) + if err != nil { + t.Fatalf("search %q: %v", query, err) + } + if len(found) == 0 { + t.Fatalf("search %q returned nothing", query) + } + } + + // The keyset cursor excludes the row it points at, and the bound reports more. + after, _, err := store.ListCustomVerificationRequests(ctx, "", fx.verifierBot, "", "", fx.pendingReq, 50) + if err != nil { + t.Fatalf("keyset list: %v", err) + } + for _, row := range after { + if row.ID >= fx.pendingReq { + t.Fatalf("keyset page leaked id %d at or after the cursor %d", row.ID, fx.pendingReq) + } + } + page, more, err := store.ListCustomVerificationRequests(ctx, "", fx.verifierBot, "", "", 0, 1) + if err != nil { + t.Fatalf("bounded list: %v", err) + } + if len(page) != 1 || !more { + t.Fatalf("bounded page len=%d hasMore=%v", len(page), more) + } + + // The detail read carries the verifier and the live mark state. + detail, err := store.CustomVerificationRequestDetail(ctx, fx.approvedReq) + if err != nil { + t.Fatalf("detail: %v", err) + } + if detail.Request.ID != fx.approvedReq || detail.Verifier.BotID != fx.verifierBot || + detail.Verifier.CompanyName != "Fixture Trust "+fx.suffix { + t.Fatalf("detail = %+v verifier=%+v", detail.Request, detail.Verifier) + } + // The approved application's peer really carries the mark. + if !detail.MarkActive { + t.Fatal("mark_active did not follow the granted mark") + } + // The pending application names the channel, which the fixture also marks, so + // the channel side of the EXISTS probe is covered too. + pendingDetail, err := store.CustomVerificationRequestDetail(ctx, fx.pendingReq) + if err != nil { + t.Fatalf("pending detail: %v", err) + } + if !pendingDetail.MarkActive { + t.Fatal("the channel mark was not seen by the detail read") + } + // The rejected one names a peer nobody marked: mark_active must say so, which is + // what tells "approved" apart from "approved and since stripped". + goneDetail, err := store.CustomVerificationRequestDetail(ctx, fx.rejectedReq) + if err != nil { + t.Fatalf("rejected detail: %v", err) + } + if goneDetail.MarkActive { + t.Fatal("an unmarked peer was reported as carrying a mark") + } + + if _, err := store.CustomVerificationRequestDetail(ctx, 0); err == nil { + t.Fatal("detail of a missing application succeeded") + } +} + +func TestBotVerificationReadStoreCounts(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedBotVerificationFixture(t, pool) + ctx := context.Background() + + counts, err := store.CustomVerificationRequestCounts(ctx) + if err != nil { + t.Fatalf("counts: %v", err) + } + // Every modelled status is present, so the panel never tells "none" from + // "missing". + for _, status := range []string{"pending", "approved", "rejected", "revoked"} { + if _, ok := counts[status]; !ok { + t.Fatalf("counts %+v missing %q", counts, status) + } + } + if counts["pending"] == "0" || counts["approved"] == "0" || counts["rejected"] == "0" { + t.Fatalf("counts %+v did not see the seeded applications (%d/%d/%d)", + counts, fx.pendingReq, fx.approvedReq, fx.rejectedReq) + } +} diff --git a/cmd/telesrv-admin/readstore_verification_integration_test.go b/cmd/telesrv-admin/readstore_verification_integration_test.go new file mode 100644 index 00000000..4b1e57ae --- /dev/null +++ b/cmd/telesrv-admin/readstore_verification_integration_test.go @@ -0,0 +1,354 @@ +package main + +import ( + "context" + "os" + "strconv" + "strings" + "testing" + "time" + + "github.com/jackc/pgx/v5/pgxpool" + + "telesrv/internal/domain" + "telesrv/internal/store/postgres" +) + +// The verification review queue is read with hand-written SQL, so the only thing +// that can prove the column names, the array and nullable-timestamp scans, and the +// ownership predicates are right is running them against the real schema. Gated on +// TELESRV_TEST_POSTGRES_DSN, like every other integration test in the repo. + +func verificationReadStore(t *testing.T) (*readStore, *pgxpool.Pool) { + t.Helper() + dsn := os.Getenv("TELESRV_TEST_POSTGRES_DSN") + if dsn == "" { + t.Skip("set TELESRV_TEST_POSTGRES_DSN to run postgres integration test") + } + parsed, err := pgxpool.ParseConfig(dsn) + if err != nil { + t.Fatalf("parse TELESRV_TEST_POSTGRES_DSN: %v", err) + } + if !strings.Contains(strings.ToLower(parsed.ConnConfig.Database), "test") { + t.Fatalf("TELESRV_TEST_POSTGRES_DSN must name a dedicated test database, got %q", parsed.ConnConfig.Database) + } + if err := postgres.Migrate(dsn); err != nil { + t.Fatalf("migrate: %v", err) + } + pool, err := pgxpool.New(context.Background(), dsn) + if err != nil { + t.Fatalf("open pool: %v", err) + } + t.Cleanup(pool.Close) + return newReadStore(pool), pool +} + +// verificationFixture seeds one applicant who owns a bot and administers a public +// channel, plus one unrelated channel nobody controls, and files an application +// against each. It returns the applicant id and the three application ids. +type verificationFixture struct { + applicant int64 + bot int64 + channel int64 + foreign int64 + botApp int64 + channelApp int64 + rejectedApp int64 + searchSuffix string +} + +func seedVerificationFixture(t *testing.T, pool *pgxpool.Pool) verificationFixture { + t.Helper() + ctx := context.Background() + var fx verificationFixture + now := time.Now().UTC().Truncate(time.Microsecond) + // Usernames and channel ids are globally unique, so every run needs its own + // suffix; tests in this package may run against a database another run left + // rows in. + unique := now.UnixNano() & 0x7fffffff + suffix := strconv.FormatInt(unique, 10) + // channels.id carries no sequence: the caller assigns it. + nextChannelID := 1_000_000_000 + unique%100_000_000 + + insertUser := func(name, username string, isBot, verified bool) int64 { + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO users (access_hash, phone, first_name, last_name, username, is_bot, verified) +VALUES ($1, $2, $3, 'Reviewer', $4, $5, $6) +RETURNING id`, unique, "70"+strconv.FormatInt(unique, 10), name, username, isBot, verified).Scan(&id); err != nil { + t.Fatalf("insert user %s: %v", name, err) + } + unique++ + return id + } + insertChannel := func(title, username string, verified bool) int64 { + id := nextChannelID + nextChannelID++ + if _, err := pool.Exec(ctx, ` +INSERT INTO channels ( + id, access_hash, creator_user_id, title, username, broadcast, megagroup, + participants_count, admins_count, top_message_id, pts, date, verified +) +VALUES ($1, $2, $3, $4, $5, true, false, 1, 1, 1, 1, $6, $7)`, + id, unique, fx.applicant, title, username, int32(now.Unix()), verified); err != nil { + t.Fatalf("insert channel %s: %v", title, err) + } + unique++ + return id + } + + fx.applicant = insertUser("Applicant", "applicant"+suffix, false, false) + fx.bot = insertUser("Fixturebot", "fixturebot"+suffix, true, false) + if _, err := pool.Exec(ctx, ` +INSERT INTO bots (bot_user_id, owner_user_id, token_secret) VALUES ($1, $2, 'secret')`, + fx.bot, fx.applicant); err != nil { + t.Fatalf("insert bot: %v", err) + } + fx.channel = insertChannel("Fixture News", "fixturenews"+suffix, true) + fx.foreign = insertChannel("Foreign Channel", "foreignchannel"+suffix, false) + if _, err := pool.Exec(ctx, ` +INSERT INTO user_channel_member_index (user_id, channel_id, status, role, broadcast, public_username) +VALUES ($1, $2, 'active', 'creator', true, true)`, fx.applicant, fx.channel); err != nil { + t.Fatalf("insert member index: %v", err) + } + + insertApplication := func( + targetType string, targetID int64, status, reviewer, reason string, + reviewed bool, + ) int64 { + var reviewedAt *time.Time + if reviewed { + reviewedAt = &now + } + var id int64 + if err := pool.QueryRow(ctx, ` +INSERT INTO verification_applications ( + applicant_user_id, target_type, target_id, target_title, target_username, + category, description, official_website, social_links, press_links, additional_note, + status, reviewer_admin_id, decision_reason, internal_note, correlation_id, + created_at, updated_at, submitted_at, reviewed_at, version +) VALUES ( + $1, $2, $3, $4, $5, + 'media', 'a description long enough to satisfy the domain bar for submission', + 'https://example.test', $6, $7, 'note', + $8, $9, $10, 'operator only', $11, + $12, $12, $12, $13, 3 +) RETURNING id`, + fx.applicant, targetType, targetID, "Snapshot "+targetType, "snapshot"+targetType+suffix, + []string{"https://social.example.test/a"}, + []string{"https://press.example.test/a", "https://press.example.test/b"}, + status, reviewer, reason, "corr-"+status, + now, reviewedAt, + ).Scan(&id); err != nil { + t.Fatalf("insert %s application: %v", status, err) + } + return id + } + + fx.channelApp = insertApplication("channel", fx.channel, "submitted", "", "", false) + fx.botApp = insertApplication("bot", fx.bot, "in_review", "alice", "", false) + // Filed as a user target against an id the applicant is not, so the ownership + // predicate has a negative case to answer. + fx.rejectedApp = insertApplication("user", fx.foreign, "rejected", "bob", "press links are self-published", true) + fx.searchSuffix = suffix + + if _, err := pool.Exec(ctx, ` +INSERT INTO verification_application_events + (application_id, kind, from_status, to_status, actor, reason, note, correlation_id, created_at) +VALUES + ($1, 'submitted', 'draft', 'submitted', '', '', '', 'corr-submitted', $2), + ($1, 'claimed', 'submitted', 'in_review', 'alice', '', 'handover note', 'corr-claimed', $2)`, + fx.channelApp, now); err != nil { + t.Fatalf("insert events: %v", err) + } + + t.Cleanup(func() { + ids := []int64{fx.channelApp, fx.botApp, fx.rejectedApp} + _, _ = pool.Exec(ctx, "DELETE FROM verification_notification_outbox WHERE application_id = ANY($1::bigint[])", ids) + _, _ = pool.Exec(ctx, "DELETE FROM verification_application_events WHERE application_id = ANY($1::bigint[])", ids) + _, _ = pool.Exec(ctx, "DELETE FROM verification_applications WHERE id = ANY($1::bigint[])", ids) + _, _ = pool.Exec(ctx, "DELETE FROM user_channel_member_index WHERE user_id = $1", fx.applicant) + _, _ = pool.Exec(ctx, "DELETE FROM channels WHERE id = ANY($1::bigint[])", []int64{fx.channel, fx.foreign}) + _, _ = pool.Exec(ctx, "DELETE FROM bots WHERE bot_user_id = $1", fx.bot) + _, _ = pool.Exec(ctx, "DELETE FROM users WHERE id = ANY($1::bigint[])", []int64{fx.applicant, fx.bot}) + }) + return fx +} + +func TestVerificationReadStoreQueue(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedVerificationFixture(t, pool) + ctx := context.Background() + + rows, hasMore, err := store.ListVerificationApplications(ctx, "", "", "", "", 0, 200) + if err != nil { + t.Fatalf("list: %v", err) + } + byID := map[int64]VerificationApplicationRow{} + for _, row := range rows { + byID[row.ID] = row + } + channelRow, ok := byID[fx.channelApp] + if !ok { + t.Fatalf("submitted application missing from the queue (hasMore=%v)", hasMore) + } + // The applicant is resolved through the join, the arrays survive the scan, and + // the live target badge is read from the peer rather than the snapshot. + if channelRow.ApplicantUserID != fx.applicant || channelRow.ApplicantUsername != "applicant"+fx.searchSuffix { + t.Fatalf("applicant projection = %+v", channelRow) + } + if !strings.Contains(channelRow.ApplicantName, "Applicant") { + t.Fatalf("applicant name = %q", channelRow.ApplicantName) + } + if len(channelRow.SocialLinks) != 1 || len(channelRow.PressLinks) != 2 { + t.Fatalf("link arrays = %+v / %+v", channelRow.SocialLinks, channelRow.PressLinks) + } + if !channelRow.TargetVerified { + t.Fatal("target_verified did not follow the live channel record") + } + if channelRow.InternalNote != "operator only" || channelRow.CorrelationID != "corr-submitted" { + t.Fatalf("operator fields = %+v", channelRow) + } + if channelRow.SubmittedAt.IsZero() || !channelRow.ReviewedAt.IsZero() { + t.Fatalf("timestamps submitted=%v reviewed=%v, want an undecided application", channelRow.SubmittedAt, channelRow.ReviewedAt) + } + if decided := byID[fx.rejectedApp]; decided.ReviewedAt.IsZero() || decided.DecisionReason == "" { + t.Fatalf("decided application = %+v", decided) + } + + // Filters. + filtered, _, err := store.ListVerificationApplications(ctx, "in_review", "", "alice", "", 0, 50) + if err != nil { + t.Fatalf("filtered list: %v", err) + } + for _, row := range filtered { + if row.Status != "in_review" || row.ReviewerAdminID != "alice" { + t.Fatalf("status/reviewer filter leaked %+v", row) + } + } + typed, _, err := store.ListVerificationApplications(ctx, "", "bot", "", "", 0, 50) + if err != nil { + t.Fatalf("target_type list: %v", err) + } + for _, row := range typed { + if row.TargetType != "bot" { + t.Fatalf("target_type filter leaked %+v", row) + } + } + // q matches the application id, the target id and a username prefix. + for _, query := range []string{ + strconv.FormatInt(fx.channelApp, 10), + strconv.FormatInt(fx.channel, 10), + "snapshotchannel" + fx.searchSuffix, + "@applicant" + fx.searchSuffix, + } { + found, _, err := store.ListVerificationApplications(ctx, "", "", "", query, 0, 50) + if err != nil { + t.Fatalf("search %q: %v", query, err) + } + if len(found) == 0 { + t.Fatalf("search %q returned nothing", query) + } + } + // The keyset cursor excludes the row it points at. + after, _, err := store.ListVerificationApplications(ctx, "", "", "", "", fx.channelApp, 50) + if err != nil { + t.Fatalf("keyset list: %v", err) + } + for _, row := range after { + if row.ID >= fx.channelApp { + t.Fatalf("keyset page leaked id %d at or after the cursor %d", row.ID, fx.channelApp) + } + } + // The page bound is honoured and reports more. + page, more, err := store.ListVerificationApplications(ctx, "", "", "", "", 0, 1) + if err != nil { + t.Fatalf("bounded list: %v", err) + } + if len(page) != 1 || !more { + t.Fatalf("bounded page len=%d hasMore=%v", len(page), more) + } +} + +func TestVerificationReadStoreDetailAndOwnership(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedVerificationFixture(t, pool) + ctx := context.Background() + + detail, err := store.VerificationApplicationDetail(ctx, fx.channelApp) + if err != nil { + t.Fatalf("detail: %v", err) + } + if detail.Application.ID != fx.channelApp || len(detail.Events) != 2 { + t.Fatalf("detail = %+v events=%d", detail.Application, len(detail.Events)) + } + // Newest first, and the operator-only note travels with the event. + if detail.Events[0].Kind != string(domain.VerificationEventClaimed) || + detail.Events[0].Note != "handover note" || detail.Events[0].Actor != "alice" { + t.Fatalf("events = %+v", detail.Events) + } + if !detail.ApplicantControlsTarget { + t.Fatal("channel creator was not recognised as controlling the target") + } + + // A bot the applicant owns. + botDetail, err := store.VerificationApplicationDetail(ctx, fx.botApp) + if err != nil { + t.Fatalf("bot detail: %v", err) + } + if !botDetail.ApplicantControlsTarget { + t.Fatal("bot owner was not recognised as controlling the target") + } + + // A target the applicant has nothing to do with: the application was filed as + // a user target against a foreign channel id, so identity does not match. + foreignDetail, err := store.VerificationApplicationDetail(ctx, fx.rejectedApp) + if err != nil { + t.Fatalf("foreign detail: %v", err) + } + if foreignDetail.ApplicantControlsTarget { + t.Fatal("an unrelated target was reported as controlled") + } + + if _, err := store.VerificationApplicationDetail(ctx, 0); err == nil { + t.Fatal("detail of a missing application succeeded") + } + + // A user target that is the applicant themself is controlled by definition. + controls, err := store.applicantControlsVerificationTarget(ctx, fx.applicant, "user", fx.applicant) + if err != nil || !controls { + t.Fatalf("self target controls=%v err=%v", controls, err) + } + // BotFather is owned by nobody, whatever the bots table says. + controls, err = store.applicantControlsVerificationTarget(ctx, fx.applicant, "bot", domain.BotFatherUserID) + if err != nil || controls { + t.Fatalf("botfather controls=%v err=%v", controls, err) + } + // An unmodelled target type is never controlled. + controls, err = store.applicantControlsVerificationTarget(ctx, fx.applicant, "group", fx.channel) + if err != nil || controls { + t.Fatalf("unmodelled target controls=%v err=%v", controls, err) + } +} + +func TestVerificationReadStoreCounts(t *testing.T) { + store, pool := verificationReadStore(t) + fx := seedVerificationFixture(t, pool) + ctx := context.Background() + + counts, err := store.VerificationStatusCounts(ctx) + if err != nil { + t.Fatalf("counts: %v", err) + } + // Every modelled status is present, so the panel never tells "none" from + // "missing". + for _, status := range []string{"draft", "submitted", "in_review", "approved", "rejected", "cancelled"} { + if _, ok := counts[status]; !ok { + t.Fatalf("counts %+v missing %q", counts, status) + } + } + if counts["submitted"] == "0" || counts["in_review"] == "0" || counts["rejected"] == "0" { + t.Fatalf("counts %+v did not see the seeded applications (%d/%d/%d)", + counts, fx.channelApp, fx.botApp, fx.rejectedApp) + } +} diff --git a/cmd/telesrv-admin/security.go b/cmd/telesrv-admin/security.go new file mode 100644 index 00000000..cf180864 --- /dev/null +++ b/cmd/telesrv-admin/security.go @@ -0,0 +1,210 @@ +package main + +import ( + "context" + "crypto/subtle" + "net/http" + "net/url" + "strings" + "time" +) + +// Panel session authorisation and CSRF. +// +// The panel authenticates with a cookie, which is what makes it a CSRF target: +// a request forged by any other origin arrives with the operator's session +// attached. Two independent checks close that. +// +// 1. Double-submit token. At login the server mints a random token, publishes it +// in a readable cookie (telesrv_admin_csrf) and requires the same value in the +// X-CSRF-Token header of every mutating request. A cross-origin page can make +// the browser *send* the cookie but cannot read it, so it cannot produce the +// header. Double-submit is the right shape here specifically because this +// process keeps no server-side session store: the session lives entirely in a +// signed cookie, so there is nowhere to park a per-session token, and the +// stateless variant is the one that survives a restart and a second replica. +// The token is additionally bound into the signed session claims, so a +// cookie-writing neighbour (a sibling subdomain) cannot supply a matching +// cookie/header pair of its own choosing either. +// +// 2. Origin agreement. When the browser states an Origin, it must be this host. +// That catches a forged request from a page that somehow does hold a token. +// +// Both comparisons are constant time, for the same reason the session MAC is. + +// Panel permission names. They match the strings an operator configures in +// TELESRV_ADMIN_UI_PERMISSIONS and the ones the admin API enforces. +const ( + permissionAll = "*" + permissionVerificationReview = "verification.review" + permissionVerificationRevoke = "verification.revoke" + // Third-party bot verification. Deliberately not implied by the official + // verification rights above: the two are separate mechanisms over separate + // tables, so a session trusted with one queue is not thereby trusted with the + // other. review reads and decides applications; manage appoints verifiers, + // curates the icon catalogue and strips granted marks. + permissionBotVerificationReview = "botverification.review" + permissionBotVerificationManage = "botverification.manage" +) + +type permissionsKey struct{} + +// requireAuthAPI is the gate on every authenticated API route: a valid session, +// and -- for a mutating request -- a valid CSRF token. +func (s *server) requireAuthAPI(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + cookie, err := r.Cookie(sessionCookieName) + if err != nil { + writeAPIError(w, http.StatusUnauthorized, "not authenticated") + return + } + claims, ok := verifySession(s.cfg.SessionKey, cookie.Value, time.Now()) + if !ok { + clearSessionCookie(w) + writeAPIError(w, http.StatusUnauthorized, "not authenticated") + return + } + if !checkMutationSafety(w, r, claims) { + return + } + ctx := context.WithValue(r.Context(), actorKey{}, claims.Actor) + ctx = context.WithValue(ctx, permissionsKey{}, newPanelPermissions(claims.Permissions)) + next.ServeHTTP(w, r.WithContext(ctx)) + }) +} + +// requirePermission refuses a session that was not granted the right, before the +// request ever reaches the admin API. The panel is the only caller that can be +// driven by a browser, so the check belongs here as well as upstream: a 403 from +// this process costs no round trip and cannot be confused with a domain failure. +func (s *server) requirePermission(permission string, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if !permissionsFromContext(r.Context()).Has(permission) { + writeJSON(w, http.StatusForbidden, map[string]any{ + "error": "permission " + permission + " is required", + "code": "FORBIDDEN", + "permission": permission, + }) + return + } + next.ServeHTTP(w, r) + }) +} + +// checkMutationSafety enforces the CSRF contract on a mutating request. +func checkMutationSafety(w http.ResponseWriter, r *http.Request, claims sessionClaims) bool { + if !mutatingMethod(r.Method) { + return true + } + if !sameOriginRequest(r) { + writeAPIError(w, http.StatusForbidden, "origin is not allowed") + return false + } + cookie, err := r.Cookie(csrfCookieName) + if err != nil || cookie.Value == "" { + writeAPIError(w, http.StatusForbidden, "missing "+csrfCookieName+" cookie; sign in again") + return false + } + header := strings.TrimSpace(r.Header.Get(csrfHeaderName)) + if header == "" { + writeAPIError(w, http.StatusForbidden, "missing "+csrfHeaderName+" header") + return false + } + if subtle.ConstantTimeCompare([]byte(header), []byte(cookie.Value)) != 1 { + writeAPIError(w, http.StatusForbidden, csrfHeaderName+" does not match the "+csrfCookieName+" cookie") + return false + } + // The signed session is the third leg: it pins the pair to the session this + // server issued. A session minted before the token existed carries no CSRF + // claim and is refused, which forces one re-login rather than leaving a + // half-protected session running. + if claims.CSRF == "" || subtle.ConstantTimeCompare([]byte(header), []byte(claims.CSRF)) != 1 { + writeAPIError(w, http.StatusForbidden, "csrf token is not bound to this session; sign in again") + return false + } + return true +} + +// mutatingMethod reports whether the method changes state. GET/HEAD/OPTIONS are +// the safe ones; everything else has to carry a token. +func mutatingMethod(method string) bool { + switch strings.ToUpper(method) { + case http.MethodGet, http.MethodHead, http.MethodOptions: + return false + default: + return true + } +} + +// sameOriginRequest checks the Origin header against the request host. +// +// An absent Origin is accepted: browsers omit it on same-origin requests and +// non-browser callers (curl, tests) never send it, so requiring it would break +// the panel without adding protection the token does not already give. A present +// Origin must be this host -- including the literal "null" a sandboxed or +// privacy-stripped context sends, which is by definition not this host. +// +// This compares against r.Host, so a reverse proxy in front of the panel has to +// preserve it (nginx: proxy_set_header Host $host). +func sameOriginRequest(r *http.Request) bool { + origin := strings.TrimSpace(r.Header.Get("Origin")) + if origin == "" { + return true + } + parsed, err := url.Parse(origin) + if err != nil || parsed.Host == "" { + return false + } + return strings.EqualFold(parsed.Host, r.Host) +} + +// panelPermissions is a resolved session permission set. +type panelPermissions struct { + all bool + names map[string]struct{} + list []string +} + +func newPanelPermissions(permissions []string) panelPermissions { + set := panelPermissions{names: make(map[string]struct{}, len(permissions))} + for _, permission := range permissions { + permission = strings.TrimSpace(permission) + if permission == "" { + continue + } + if _, dup := set.names[permission]; dup { + continue + } + if permission == permissionAll { + set.all = true + } + set.names[permission] = struct{}{} + set.list = append(set.list, permission) + } + return set +} + +// Has reports whether the session was granted the permission. +func (p panelPermissions) Has(permission string) bool { + if p.all { + return true + } + _, ok := p.names[permission] + return ok +} + +// List is what the panel is told about itself, so the UI can hide a section the +// session may not use instead of rendering it into a 403. +func (p panelPermissions) List() []string { + if p.list == nil { + return []string{} + } + return p.list +} + +func permissionsFromContext(ctx context.Context) panelPermissions { + if permissions, ok := ctx.Value(permissionsKey{}).(panelPermissions); ok { + return permissions + } + return panelPermissions{} +} diff --git a/cmd/telesrv-admin/server.go b/cmd/telesrv-admin/server.go index 5157b4da..536477ce 100644 --- a/cmd/telesrv-admin/server.go +++ b/cmd/telesrv-admin/server.go @@ -47,7 +47,10 @@ func newServer(cfg uiConfig, read *readStore) (*server, error) { func (s *server) routes() http.Handler { mux := http.NewServeMux() mux.HandleFunc("POST /api/login", s.handleAPILogin) - mux.HandleFunc("POST /api/logout", s.handleAPILogout) + // Logout goes through the same gate as every other mutating route: a forced + // logout is a state change, and an invalid session is cleared by the gate + // itself, so nothing is stranded by protecting it. + mux.Handle("POST /api/logout", s.requireAuthAPI(http.HandlerFunc(s.handleAPILogout))) mux.Handle("GET /api/session", s.requireAuthAPI(http.HandlerFunc(s.handleSession))) mux.Handle("GET /api/accounts", s.requireAuthAPI(http.HandlerFunc(s.handleAccountsAPI))) mux.Handle("GET /api/accounts/stats", s.requireAuthAPI(http.HandlerFunc(s.handleAccountsStatsAPI))) @@ -71,6 +74,16 @@ func (s *server) routes() http.Handler { mux.Handle("GET /api/gifts/{id}/animation", s.requireAuthAPI(http.HandlerFunc(s.handleStarGiftAnimationAPI))) mux.Handle("GET /api/gifts/{id}/collectibles", s.requireAuthAPI(http.HandlerFunc(s.handleStarGiftCollectiblesAPI))) mux.Handle("GET /api/gifts/{id}/collectibles/{kind}/{attribute_id}/animation", s.requireAuthAPI(http.HandlerFunc(s.handleStarGiftCollectibleAnimationAPI))) + mux.Handle("GET /api/collectible-usernames", s.requireAuthAPI(http.HandlerFunc(s.handleCollectibleUsernamesAPI))) + mux.Handle("GET /api/collectible-usernames/{id}", s.requireAuthAPI(http.HandlerFunc(s.handleCollectibleUsernameDetailAPI))) + mux.Handle("GET /api/account-ratings", s.requireAuthAPI(http.HandlerFunc(s.handleAccountRatingsAPI))) + mux.Handle("GET /api/account-ratings/{user_id}", s.requireAuthAPI(http.HandlerFunc(s.handleAccountRatingDetailAPI))) + mux.Handle("GET /api/moderation/cases", s.requireAuthAPI(http.HandlerFunc(s.handleModerationCasesAPI))) + mux.Handle("GET /api/moderation/cases/{id}", s.requireAuthAPI(http.HandlerFunc(s.handleModerationCaseAPI))) + mux.Handle("GET /api/moderation/reports/{id}", s.requireAuthAPI(http.HandlerFunc(s.handleModerationReportAPI))) + mux.Handle("POST /api/moderation/cases/{id}/claim", s.requireAuthAPI(http.HandlerFunc(s.handleClaimModerationCaseAPI))) + mux.Handle("POST /api/moderation/cases/{id}/decide", s.requireAuthAPI(http.HandlerFunc(s.handleDecideModerationCaseAPI))) + mux.Handle("POST /api/moderation/cases/{id}/appeals/{appeal_id}/review", s.requireAuthAPI(http.HandlerFunc(s.handleReviewModerationAppealAPI))) mux.Handle("POST /api/actions/set-frozen", s.requireAuthAPI(http.HandlerFunc(s.handleSetAccountFrozenAPI))) mux.Handle("POST /api/actions/grant-premium", s.requireAuthAPI(http.HandlerFunc(s.handleGrantPremiumAPI))) mux.Handle("POST /api/actions/grant-stars", s.requireAuthAPI(http.HandlerFunc(s.handleGrantStarsAPI))) @@ -110,6 +123,43 @@ func (s *server) routes() http.Handler { mux.Handle("POST /api/actions/add-sticker-to-set", s.requireAuthAPI(http.HandlerFunc(s.handleAddStickerToSetAPI))) mux.Handle("POST /api/actions/remove-sticker-from-set", s.requireAuthAPI(http.HandlerFunc(s.handleRemoveStickerFromSetAPI))) mux.Handle("POST /api/actions/give-gift", s.requireAuthAPI(http.HandlerFunc(s.handleGiveGiftAPI))) + mux.Handle("POST /api/actions/mint-collectible-username", s.requireAuthAPI(http.HandlerFunc(s.handleMintCollectibleUsernameAPI))) + mux.Handle("POST /api/actions/transfer-collectible-username", s.requireAuthAPI(http.HandlerFunc(s.handleTransferCollectibleUsernameAPI))) + mux.Handle("POST /api/actions/revoke-collectible-username", s.requireAuthAPI(http.HandlerFunc(s.handleRevokeCollectibleUsernameAPI))) + mux.Handle("POST /api/actions/delete-collectible-username", s.requireAuthAPI(http.HandlerFunc(s.handleDeleteCollectibleUsernameAPI))) + mux.Handle("POST /api/actions/recompute-account-rating", s.requireAuthAPI(http.HandlerFunc(s.handleRecomputeAccountRatingAPI))) + mux.Handle("POST /api/actions/adjust-account-rating", s.requireAuthAPI(http.HandlerFunc(s.handleAdjustAccountRatingAPI))) + // Official platform verification. Every route needs verification.review; + // clearing an existing badge needs verification.revoke on top of it. + mux.Handle("GET /api/verification/applications", s.verificationRead(s.handleVerificationApplicationsAPI)) + mux.Handle("GET /api/verification/applications/{id}", s.verificationRead(s.handleVerificationApplicationDetailAPI)) + mux.Handle("GET /api/verification/counts", s.verificationRead(s.handleVerificationCountsAPI)) + mux.Handle("POST /api/verification/applications/{id}/claim", s.verificationRead(s.handleClaimVerificationAPI)) + mux.Handle("POST /api/verification/applications/{id}/approve", s.verificationRead(s.handleApproveVerificationAPI)) + mux.Handle("POST /api/verification/applications/{id}/reject", s.verificationRead(s.handleRejectVerificationAPI)) + mux.Handle("POST /api/actions/revoke-verification", s.requireAuthAPI( + s.requirePermission(permissionVerificationReview, + s.requirePermission(permissionVerificationRevoke, http.HandlerFunc(s.handleRevokeVerificationAPI))))) + // Third-party bot verification. A separate section from the official + // verification block above -- separate tables, separate rights, separate routes. + // Reads and queue decisions need botverification.review; appointing verifiers, + // curating the icon catalogue and stripping a granted mark need + // botverification.manage. + mux.Handle("GET /api/botverification/verifiers", s.botVerificationRead(s.handleBotVerifiersAPI)) + mux.Handle("GET /api/botverification/icons", s.botVerificationRead(s.handleVerificationIconsAPI)) + mux.Handle("GET /api/botverification/marks", s.botVerificationRead(s.handleCustomVerificationsAPI)) + mux.Handle("GET /api/botverification/requests", s.botVerificationRead(s.handleCustomVerificationRequestsAPI)) + mux.Handle("GET /api/botverification/requests/{id}", s.botVerificationRead(s.handleCustomVerificationRequestDetailAPI)) + mux.Handle("GET /api/botverification/counts", s.botVerificationRead(s.handleCustomVerificationCountsAPI)) + mux.Handle("POST /api/botverification/requests/{id}/approve", s.botVerificationRead(s.handleApproveBotVerificationAPI)) + mux.Handle("POST /api/botverification/requests/{id}/reject", s.botVerificationRead(s.handleRejectBotVerificationAPI)) + mux.Handle("POST /api/botverification/requests/{id}/revoke", s.botVerificationRead(s.handleRevokeBotVerificationAPI)) + mux.Handle("POST /api/actions/grant-bot-verifier", s.botVerificationManage(s.handleGrantBotVerifierAPI)) + mux.Handle("POST /api/actions/set-bot-verifier-enabled", s.botVerificationManage(s.handleSetBotVerifierEnabledAPI)) + mux.Handle("POST /api/actions/revoke-bot-verifier", s.botVerificationManage(s.handleRevokeBotVerifierAPI)) + mux.Handle("POST /api/actions/upsert-verification-icon", s.botVerificationManage(s.handleUpsertVerificationIconAPI)) + mux.Handle("POST /api/actions/set-verification-icon-active", s.botVerificationManage(s.handleSetVerificationIconActiveAPI)) + mux.Handle("POST /api/actions/revoke-custom-verification", s.botVerificationManage(s.handleRevokeCustomVerificationAPI)) mux.HandleFunc("/api/", func(w http.ResponseWriter, _ *http.Request) { writeAPIError(w, http.StatusNotFound, "api route not found") }) @@ -119,23 +169,6 @@ func (s *server) routes() http.Handler { type actorKey struct{} -func (s *server) requireAuthAPI(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - cookie, err := r.Cookie(sessionCookieName) - if err != nil { - writeAPIError(w, http.StatusUnauthorized, "not authenticated") - return - } - claims, ok := verifySession(s.cfg.SessionKey, cookie.Value, time.Now()) - if !ok { - clearSessionCookie(w) - writeAPIError(w, http.StatusUnauthorized, "not authenticated") - return - } - next.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), actorKey{}, claims.Actor))) - }) -} - func actorFromContext(ctx context.Context) string { if actor, ok := ctx.Value(actorKey{}).(string); ok && actor != "" { return actor @@ -160,7 +193,18 @@ type loginRequest struct { Secret string `json:"secret"` } +// sessionTTL bounds a signed panel session and the CSRF cookie that goes with it, +// so the two never outlive each other. +const sessionTTL = 12 * time.Hour + func (s *server) handleAPILogin(w http.ResponseWriter, r *http.Request) { + // Login is the one mutating route without a CSRF token, because no session + // exists yet to bind one to. The Origin check still applies, and the request + // carries the operator credential, which a forging page does not have. + if !sameOriginRequest(r) { + writeAPIError(w, http.StatusForbidden, "origin is not allowed") + return + } var req loginRequest if err := decodeJSON(r, &req); err != nil { writeAPIError(w, http.StatusBadRequest, err.Error()) @@ -170,10 +214,18 @@ func (s *server) handleAPILogin(w http.ResponseWriter, r *http.Request) { writeAPIError(w, http.StatusUnauthorized, "invalid credential") return } + csrfToken, err := newCSRFToken() + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + permissions := newPanelPermissions(s.cfg.Permissions) value, err := signSession(s.cfg.SessionKey, sessionClaims{ - Actor: "admin", - Exp: time.Now().Add(12 * time.Hour).Unix(), - Nonce: newCommandID("sess"), + Actor: "admin", + Exp: time.Now().Add(sessionTTL).Unix(), + Nonce: newCommandID("sess"), + Permissions: permissions.List(), + CSRF: csrfToken, }) if err != nil { writeAPIError(w, http.StatusInternalServerError, err.Error()) @@ -183,11 +235,16 @@ func (s *server) handleAPILogin(w http.ResponseWriter, r *http.Request) { Name: sessionCookieName, Value: value, Path: "/", - MaxAge: int((12 * time.Hour).Seconds()), + MaxAge: int(sessionTTL.Seconds()), HttpOnly: true, SameSite: http.SameSiteLaxMode, }) - writeJSON(w, http.StatusOK, map[string]any{"actor": "admin"}) + setCSRFCookie(w, csrfToken, sessionTTL) + writeJSON(w, http.StatusOK, map[string]any{ + "actor": "admin", + "permissions": permissions.List(), + "csrf_token": csrfToken, + }) } func (s *server) validSecret(secret string) bool { @@ -205,8 +262,14 @@ func (s *server) handleAPILogout(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, map[string]any{"ok": true}) } +// handleSession is what the panel asks on load. It reports the permissions the +// session carries, so the UI can hide a section the operator may not use rather +// than letting them walk into a 403. func (s *server) handleSession(w http.ResponseWriter, r *http.Request) { - writeJSON(w, http.StatusOK, map[string]any{"actor": actorFromContext(r.Context())}) + writeJSON(w, http.StatusOK, map[string]any{ + "actor": actorFromContext(r.Context()), + "permissions": permissionsFromContext(r.Context()).List(), + }) } func (s *server) handleStarGiftsAPI(w http.ResponseWriter, r *http.Request) { @@ -370,6 +433,20 @@ func (s *server) handleStarGiftCollectibleAnimationAPI(w http.ResponseWriter, r } func (s *server) proxyAdminJSON(w http.ResponseWriter, r *http.Request, apiPath string, maxBytes int64) { + s.proxyAdminJSONWithCache(w, r, apiPath, maxBytes, "private, max-age=30") +} + +func (s *server) proxyAdminJSONNoStore(w http.ResponseWriter, r *http.Request, apiPath string, maxBytes int64) { + s.proxyAdminJSONWithCache(w, r, apiPath, maxBytes, "no-store") +} + +func (s *server) proxyAdminJSONWithCache( + w http.ResponseWriter, + r *http.Request, + apiPath string, + maxBytes int64, + cacheControl string, +) { req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, s.cfg.AdminAPIURL+apiPath, nil) if err != nil { writeAPIError(w, http.StatusInternalServerError, err.Error()) @@ -392,11 +469,115 @@ func (s *server) proxyAdminJSON(w http.ResponseWriter, r *http.Request, apiPath return } w.Header().Set("Content-Type", "application/json; charset=utf-8") - w.Header().Set("Cache-Control", "private, max-age=30") + w.Header().Set("Cache-Control", cacheControl) w.WriteHeader(http.StatusOK) _, _ = w.Write(raw) } +func (s *server) handleModerationCasesAPI(w http.ResponseWriter, r *http.Request) { + apiPath := "/v1/moderation/cases" + if r.URL.RawQuery != "" { + apiPath += "?" + r.URL.RawQuery + } + s.proxyAdminJSONNoStore(w, r, apiPath, 4<<20) +} + +func (s *server) handleModerationCaseAPI(w http.ResponseWriter, r *http.Request) { + id, err := strconv.ParseInt(r.PathValue("id"), 10, 64) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid moderation case id") + return + } + s.proxyAdminJSONNoStore(w, r, fmt.Sprintf("/v1/moderation/cases/%d", id), 4<<20) +} + +func (s *server) handleModerationReportAPI(w http.ResponseWriter, r *http.Request) { + id, err := strconv.ParseInt(r.PathValue("id"), 10, 64) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid moderation report id") + return + } + s.proxyAdminJSONNoStore(w, r, fmt.Sprintf("/v1/moderation/reports/%d", id), 4<<20) +} + +func (s *server) handleClaimModerationCaseAPI(w http.ResponseWriter, r *http.Request) { + s.proxyModerationWrite(w, r, "claim", false) +} + +func (s *server) handleDecideModerationCaseAPI(w http.ResponseWriter, r *http.Request) { + s.proxyModerationWrite(w, r, "decide", true) +} + +func (s *server) handleReviewModerationAppealAPI(w http.ResponseWriter, r *http.Request) { + s.proxyModerationWrite(w, r, "appeals/"+r.PathValue("appeal_id")+"/review", true) +} + +func (s *server) proxyModerationWrite(w http.ResponseWriter, r *http.Request, suffix string, needsCommand bool) { + caseID, err := strconv.ParseInt(r.PathValue("id"), 10, 64) + if err != nil || caseID <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid moderation case id") + return + } + if strings.HasPrefix(suffix, "appeals/") { + appealID, err := strconv.ParseInt(r.PathValue("appeal_id"), 10, 64) + if err != nil || appealID <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid moderation appeal id") + return + } + } + defer r.Body.Close() + var payload map[string]any + decoder := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20)) + if err := decoder.Decode(&payload); err != nil { + writeAPIError(w, http.StatusBadRequest, "invalid json") + return + } + payload["actor"] = actorFromContext(r.Context()) + if needsCommand { + commandID, _ := payload["command_id"].(string) + if strings.TrimSpace(commandID) == "" { + payload["command_id"] = newCommandID("moderation") + } + } + raw, err := json.Marshal(payload) + if err != nil { + writeAPIError(w, http.StatusBadRequest, err.Error()) + return + } + s.relayAdminJSON( + w, r, http.MethodPost, + fmt.Sprintf("/v1/moderation/cases/%d/%s", caseID, suffix), + raw, 4<<20, + ) +} + +func (s *server) relayAdminJSON(w http.ResponseWriter, r *http.Request, method, apiPath string, body []byte, maxBytes int64) { + req, err := http.NewRequestWithContext( + r.Context(), method, s.cfg.AdminAPIURL+apiPath, bytes.NewReader(body), + ) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + req.Header.Set("Authorization", "Bearer "+s.cfg.AdminAPIToken) + req.Header.Set("Content-Type", "application/json") + resp, err := http.DefaultClient.Do(req) + if err != nil { + writeAPIError(w, http.StatusBadGateway, err.Error()) + return + } + defer resp.Body.Close() + raw, err := io.ReadAll(io.LimitReader(resp.Body, maxBytes+1)) + if err != nil || int64(len(raw)) > maxBytes { + writeAPIError(w, http.StatusBadGateway, "invalid admin api response") + return + } + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Cache-Control", "no-store") + w.WriteHeader(resp.StatusCode) + _, _ = w.Write(raw) +} + func (s *server) handleAccountsAPI(w http.ResponseWriter, r *http.Request) { if s.read == nil { writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") @@ -1825,6 +2006,367 @@ func (s *server) handleGiveGiftAPI(w http.ResponseWriter, r *http.Request) { writeCommandResultAPI(w, result, err) } +// flexInt64 decodes an int64 the panel may send either as a JSON number or as a +// decimal string. Ids and nanoton amounts are sent as strings to stay exact past +// 2^53, while a picker-supplied peer id arrives as a plain number; an empty +// string and null both mean "unset", which is how an untouched form field looks. +type flexInt64 int64 + +// Int64 returns the decoded value. +func (v flexInt64) Int64() int64 { return int64(v) } + +func (v *flexInt64) UnmarshalJSON(raw []byte) error { + text, empty := flexScalarText(raw) + if empty { + *v = 0 + return nil + } + parsed, err := strconv.ParseInt(text, 10, 64) + if err != nil { + return fmt.Errorf("invalid integer %s", string(raw)) + } + *v = flexInt64(parsed) + return nil +} + +// flexUnix decodes an optional timestamp as a Unix second count. A date input +// produces an RFC3339 string and a scripted call a plain number, so both are +// accepted; empty means "unset", which the mint command stamps with its clock. +type flexUnix int64 + +// Unix returns the decoded timestamp in seconds, or zero when unset. +func (v flexUnix) Unix() int64 { return int64(v) } + +func (v *flexUnix) UnmarshalJSON(raw []byte) error { + text, empty := flexScalarText(raw) + if empty { + *v = 0 + return nil + } + if parsed, err := strconv.ParseInt(text, 10, 64); err == nil { + *v = flexUnix(parsed) + return nil + } + for _, layout := range []string{time.RFC3339, "2006-01-02"} { + if parsed, err := time.Parse(layout, text); err == nil { + *v = flexUnix(parsed.UTC().Unix()) + return nil + } + } + return fmt.Errorf("invalid timestamp %s", string(raw)) +} + +// flexScalarText unwraps a JSON scalar to its textual form and reports whether +// it carries no value at all (null, empty string, blank). +func flexScalarText(raw []byte) (string, bool) { + text := strings.TrimSpace(string(raw)) + if text == "" || text == "null" { + return "", true + } + if unquoted, err := strconv.Unquote(text); err == nil { + text = strings.TrimSpace(unquoted) + } + if text == "" { + return "", true + } + return text, false +} + +type mintCollectibleUsernameAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Username string `json:"username"` + OwnerUserID flexInt64 `json:"owner_user_id"` + OwnerChannelID flexInt64 `json:"owner_channel_id"` + Currency string `json:"currency"` + Amount flexInt64 `json:"amount"` + CryptoCurrency string `json:"crypto_currency"` + CryptoAmount flexInt64 `json:"crypto_amount"` + URL string `json:"url"` + PurchaseDate flexUnix `json:"purchase_date"` +} + +func (s *server) handleMintCollectibleUsernameAPI(w http.ResponseWriter, r *http.Request) { + var body mintCollectibleUsernameAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.MintCollectibleUsernameRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "mint-collectible-username"), + Username: body.Username, + OwnerUserID: body.OwnerUserID.Int64(), + OwnerChannelID: body.OwnerChannelID.Int64(), + Currency: body.Currency, + Amount: body.Amount.Int64(), + CryptoCurrency: body.CryptoCurrency, + CryptoAmount: body.CryptoAmount.Int64(), + URL: body.URL, + PurchaseDate: body.PurchaseDate.Unix(), + } + result, err := s.callAdminAPI(r.Context(), "/v1/collectible-usernames/mint", req) + writeCommandResultAPI(w, result, err) +} + +type transferCollectibleUsernameAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Username string `json:"username"` + ToUserID flexInt64 `json:"to_user_id"` + ToChannelID flexInt64 `json:"to_channel_id"` +} + +func (s *server) handleTransferCollectibleUsernameAPI(w http.ResponseWriter, r *http.Request) { + var body transferCollectibleUsernameAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.TransferCollectibleUsernameRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "transfer-collectible-username"), + Username: body.Username, + ToUserID: body.ToUserID.Int64(), + ToChannelID: body.ToChannelID.Int64(), + } + result, err := s.callAdminAPI(r.Context(), "/v1/collectible-usernames/transfer", req) + writeCommandResultAPI(w, result, err) +} + +type revokeCollectibleUsernameAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Username string `json:"username"` + Burn bool `json:"burn"` +} + +func (s *server) handleRevokeCollectibleUsernameAPI(w http.ResponseWriter, r *http.Request) { + var body revokeCollectibleUsernameAPIRequest + if !decodeAction(w, r, &body) { + return + } + prefix := "revoke-collectible-username" + if body.Burn { + prefix = "burn-collectible-username" + } + req := admin.RevokeCollectibleUsernameRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, prefix), + Username: body.Username, + Burn: body.Burn, + } + result, err := s.callAdminAPI(r.Context(), "/v1/collectible-usernames/revoke", req) + writeCommandResultAPI(w, result, err) +} + +type deleteCollectibleUsernameAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Username string `json:"username"` +} + +// handleDeleteCollectibleUsernameAPI erases an asset and its provenance. The +// panel gates it behind the same reason + dry-run + confirm flow as a burn, but +// the outcome differs: the name becomes issuable again from scratch. +func (s *server) handleDeleteCollectibleUsernameAPI(w http.ResponseWriter, r *http.Request) { + var body deleteCollectibleUsernameAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.DeleteCollectibleUsernameRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "delete-collectible-username"), + Username: body.Username, + } + result, err := s.callAdminAPI(r.Context(), "/v1/collectible-usernames/delete", req) + writeCommandResultAPI(w, result, err) +} + +type recomputeAccountRatingAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + UserID flexInt64 `json:"user_id"` +} + +func (s *server) handleRecomputeAccountRatingAPI(w http.ResponseWriter, r *http.Request) { + var body recomputeAccountRatingAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.RecomputeAccountRatingRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "recompute-account-rating"), + UserID: body.UserID.Int64(), + } + result, err := s.callAdminAPI(r.Context(), "/v1/account-ratings/recompute", req) + writeCommandResultAPI(w, result, err) +} + +type adjustAccountRatingAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + UserID flexInt64 `json:"user_id"` + Amount flexInt64 `json:"amount"` +} + +func (s *server) handleAdjustAccountRatingAPI(w http.ResponseWriter, r *http.Request) { + var body adjustAccountRatingAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.AdjustAccountRatingRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "adjust-account-rating"), + UserID: body.UserID.Int64(), + Amount: body.Amount.Int64(), + } + result, err := s.callAdminAPI(r.Context(), "/v1/account-ratings/adjust", req) + writeCommandResultAPI(w, result, err) +} + +// handleCollectibleUsernamesAPI pages the collectible asset table straight from +// PostgreSQL, like every other table view, and echoes the keyset cursor as a +// decimal string so an int64 id survives the round trip through the browser. +func (s *server) handleCollectibleUsernamesAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + query := r.URL.Query() + status := strings.TrimSpace(query.Get("status")) + switch status { + case "", string(domain.CollectibleUsernameStatusVault), + string(domain.CollectibleUsernameStatusOwned), + string(domain.CollectibleUsernameStatusBurned): + default: + writeAPIError(w, http.StatusBadRequest, "invalid status") + return + } + ownerUserID, err := parseInt64(query.Get("owner_user_id")) + if err != nil || ownerUserID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid owner_user_id") + return + } + beforeID, err := parseInt64(query.Get("before_id")) + if err != nil || beforeID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid before_id") + return + } + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + rows, hasMore, err := s.read.ListCollectibleUsernames(r.Context(), status, ownerUserID, beforeID, query.Get("q"), limit) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + nextBeforeID := "" + if hasMore && len(rows) > 0 { + nextBeforeID = strconv.FormatInt(rows[len(rows)-1].ID, 10) + } + writeJSON(w, http.StatusOK, map[string]any{ + "rows": rows, + "has_more": hasMore, + "next_before_id": nextBeforeID, + }) +} + +func (s *server) handleCollectibleUsernameDetailAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + id, err := parseInt64(r.PathValue("id")) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid id") + return + } + detail, err := s.read.CollectibleUsernameDetail(r.Context(), id) + if err != nil { + if errors.Is(err, errReadNotFound) { + writeAPIError(w, http.StatusNotFound, "collectible username not found") + return + } + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{ + "asset": detail.Asset, + "transfers": detail.Transfers, + }) +} + +// handleAccountRatingsAPI pages the leaderboard. next_before_id is the last +// user id: the keyset predicate resolves the full (level, stars, user_id) cursor +// from it, so one opaque-looking value is enough to continue the page. +func (s *server) handleAccountRatingsAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + query := r.URL.Query() + minLevel, err := parseInt(query.Get("min_level")) + if err != nil || minLevel < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid min_level") + return + } + userID, err := parseInt64(query.Get("user_id")) + if err != nil || userID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid user_id") + return + } + beforeID, err := parseInt64(query.Get("before_id")) + if err != nil || beforeID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid before_id") + return + } + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + rows, hasMore, err := s.read.ListAccountRatings(r.Context(), minLevel, userID, beforeID, limit, query.Get("q")) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + nextBeforeID := "" + if hasMore && len(rows) > 0 { + nextBeforeID = strconv.FormatInt(rows[len(rows)-1].UserID, 10) + } + writeJSON(w, http.StatusOK, map[string]any{ + "rows": rows, + "has_more": hasMore, + "next_before_id": nextBeforeID, + }) +} + +func (s *server) handleAccountRatingDetailAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + userID, err := parseInt64(r.PathValue("user_id")) + if err != nil || userID <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid user_id") + return + } + detail, err := s.read.AccountRatingDetail(r.Context(), userID) + if err != nil { + if errors.Is(err, errReadNotFound) { + writeAPIError(w, http.StatusNotFound, "account rating not found") + return + } + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{ + "rating": detail.Rating, + "events": detail.Events, + }) +} + func (s *server) commandMetaFromAPI(r *http.Request, commandID, reason string, confirm bool, prefix string) admin.CommandMeta { commandID = strings.TrimSpace(commandID) if confirm && strings.HasPrefix(commandID, "dry-") { @@ -1876,6 +2418,42 @@ func (s *server) callAdminAPI(ctx context.Context, apiPath string, payload any) return result, nil } +// callAdminCommand is callAdminAPI with the upstream status preserved. +// +// callAdminAPI deliberately loses it: every caller it has answers 502 for any +// failure. A verification decision needs the distinction, so this variant returns +// the HTTP status alongside the result and lets the handler map it. A status of 0 +// means no HTTP answer was obtained at all. +func (s *server) callAdminCommand(ctx context.Context, apiPath string, payload any) (admin.CommandResult, int, error) { + body, err := json.Marshal(payload) + if err != nil { + return admin.CommandResult{}, 0, err + } + req, err := http.NewRequestWithContext(ctx, http.MethodPost, s.cfg.AdminAPIURL+apiPath, bytes.NewReader(body)) + if err != nil { + return admin.CommandResult{}, 0, err + } + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Authorization", "Bearer "+s.cfg.AdminAPIToken) + resp, err := http.DefaultClient.Do(req) + if err != nil { + return admin.CommandResult{}, 0, err + } + defer resp.Body.Close() + raw, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) + var result admin.CommandResult + if err := json.Unmarshal(raw, &result); err != nil { + return result, 0, fmt.Errorf("admin api %s: status=%d body=%s", apiPath, resp.StatusCode, string(raw)) + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + if result.Error == "" { + result.Error = resp.Status + } + return result, resp.StatusCode, errors.New(result.Error) + } + return result, resp.StatusCode, nil +} + func (s *server) callAdminMultipart(ctx context.Context, apiPath string, metadata any, fileName string, data []byte) (admin.CommandResult, error) { var body bytes.Buffer writer := multipart.NewWriter(&body) diff --git a/cmd/telesrv-admin/session.go b/cmd/telesrv-admin/session.go index d66ef12e..86ac8888 100644 --- a/cmd/telesrv-admin/session.go +++ b/cmd/telesrv-admin/session.go @@ -2,6 +2,7 @@ package main import ( "crypto/hmac" + "crypto/rand" "crypto/sha256" "crypto/subtle" "encoding/base64" @@ -13,10 +14,29 @@ import ( const sessionCookieName = "telesrv_admin_session" +// csrfCookieName is the double-submit cookie. It is deliberately NOT HttpOnly: +// the panel's own JavaScript has to read it back to echo it in the X-CSRF-Token +// header, which is the whole mechanism. +const csrfCookieName = "telesrv_admin_csrf" + +// csrfHeaderName is the header the panel echoes the cookie in. +const csrfHeaderName = "X-CSRF-Token" + type sessionClaims struct { Actor string `json:"actor"` Exp int64 `json:"exp"` Nonce string `json:"nonce"` + // Permissions is the right set granted to this session, taken from + // TELESRV_ADMIN_UI_PERMISSIONS at login. It travels inside the signed cookie + // rather than being re-read per request, so a session keeps the rights it was + // issued with, and it cannot be edited by the browser: the HMAC covers it. + Permissions []string `json:"permissions,omitempty"` + // CSRF is the double-submit token bound to this session. Binding it into the + // signed claims is what makes the cookie/header pair unforgeable by a sibling + // origin that can only *write* cookies (a subdomain, say): such an attacker + // can set both the cookie and the header to a value they know, but they cannot + // produce a session cookie that agrees with it. + CSRF string `json:"csrf,omitempty"` } func signSession(key []byte, claims sessionClaims) (string, error) { @@ -56,6 +76,28 @@ func verifySession(key []byte, value string, now time.Time) (sessionClaims, bool return claims, true } +// newCSRFToken mints a fresh double-submit token. +func newCSRFToken() (string, error) { + var raw [32]byte + if _, err := rand.Read(raw[:]); err != nil { + return "", err + } + return base64.RawURLEncoding.EncodeToString(raw[:]), nil +} + +// setCSRFCookie publishes the token to the browser. +func setCSRFCookie(w http.ResponseWriter, token string, ttl time.Duration) { + http.SetCookie(w, &http.Cookie{ + Name: csrfCookieName, + Value: token, + Path: "/", + MaxAge: int(ttl.Seconds()), + // Readable by the panel's script on purpose; see csrfCookieName. + HttpOnly: false, + SameSite: http.SameSiteLaxMode, + }) +} + func clearSessionCookie(w http.ResponseWriter) { http.SetCookie(w, &http.Cookie{ Name: sessionCookieName, @@ -65,4 +107,12 @@ func clearSessionCookie(w http.ResponseWriter) { HttpOnly: true, SameSite: http.SameSiteLaxMode, }) + http.SetCookie(w, &http.Cookie{ + Name: csrfCookieName, + Value: "", + Path: "/", + MaxAge: -1, + HttpOnly: false, + SameSite: http.SameSiteLaxMode, + }) } diff --git a/cmd/telesrv-admin/session_test.go b/cmd/telesrv-admin/session_test.go index 47d9d5c1..a53b1510 100644 --- a/cmd/telesrv-admin/session_test.go +++ b/cmd/telesrv-admin/session_test.go @@ -83,6 +83,67 @@ func TestSetAccountFrozenBFFForwardsClientVisibleState(t *testing.T) { } } +func TestModerationReadAPIDisablesBrowserCaching(t *testing.T) { + tests := []struct { + name string + requestPath string + upstreamPath string + invoke func(*server, http.ResponseWriter, *http.Request) + }{ + { + name: "case list", + requestPath: "/api/moderation/cases?status=open", + upstreamPath: "/v1/moderation/cases?status=open", + invoke: (*server).handleModerationCasesAPI, + }, + { + name: "case detail", + requestPath: "/api/moderation/cases/7", + upstreamPath: "/v1/moderation/cases/7", + invoke: func(s *server, w http.ResponseWriter, r *http.Request) { + r.SetPathValue("id", "7") + s.handleModerationCaseAPI(w, r) + }, + }, + { + name: "report detail", + requestPath: "/api/moderation/reports/9", + upstreamPath: "/v1/moderation/reports/9", + invoke: func(s *server, w http.ResponseWriter, r *http.Request) { + r.SetPathValue("id", "9") + s.handleModerationReportAPI(w, r) + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if got := r.URL.RequestURI(); got != test.upstreamPath { + t.Fatalf("upstream request URI = %q, want %q", got, test.upstreamPath) + } + if got := r.Header.Get("Authorization"); got != "Bearer secret" { + t.Fatalf("upstream authorization = %q", got) + } + _, _ = w.Write([]byte(`{}`)) + })) + defer upstream.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: upstream.URL, AdminAPIToken: "secret"}} + req := httptest.NewRequest(http.MethodGet, test.requestPath, nil) + rec := httptest.NewRecorder() + test.invoke(srv, rec, req) + + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if got := rec.Header().Get("Cache-Control"); got != "no-store" { + t.Fatalf("Cache-Control = %q, want no-store", got) + } + }) + } +} + func TestStarGiftRowJSONPreservesInt64AsDecimalStrings(t *testing.T) { const maxInt64 = int64(9223372036854775807) raw, err := json.Marshal(StarGiftRow{ @@ -168,3 +229,214 @@ func TestSetStarGiftEnabledBFFForwardsExactInt64(t *testing.T) { t.Fatalf("forwarded gift request = %+v", got) } } + +func TestMintCollectibleUsernameBFFForwardsActorAndTolerantScalars(t *testing.T) { + const maxInt64 = int64(9223372036854775807) + var got admin.MintCollectibleUsernameRequest + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/v1/collectible-usernames/mint" || r.Header.Get("Authorization") != "Bearer secret" { + t.Fatalf("upstream request path=%q authorization=%q", r.URL.Path, r.Header.Get("Authorization")) + } + if err := json.NewDecoder(r.Body).Decode(&got); err != nil { + t.Fatal(err) + } + _ = json.NewEncoder(w).Encode(admin.CommandResult{CommandID: got.CommandID, Status: "completed", DryRun: got.DryRun}) + })) + defer upstream.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: upstream.URL, AdminAPIToken: "secret"}} + // The panel sends a picker id as a number, a nanoton amount as a string and an + // RFC3339 purchase date; all three have to survive the hop unchanged. + req := httptest.NewRequest(http.MethodPost, "/api/actions/mint-collectible-username", strings.NewReader(`{ + "reason":"fragment import","confirm":false, + "username":"@Durov","owner_user_id":1001,"currency":"TON", + "amount":"9223372036854775807","crypto_currency":"TON","crypto_amount":"250000000000", + "url":"https://fragment.example/durov","purchase_date":"2026-07-26T00:00:00Z" + }`)) + req = req.WithContext(context.WithValue(req.Context(), actorKey{}, "operator")) + rec := httptest.NewRecorder() + srv.handleMintCollectibleUsernameAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if got.Actor != "operator" || !got.DryRun || got.CommandID == "" { + t.Fatalf("forwarded command meta = %+v", got.CommandMeta) + } + if got.Username != "@Durov" || got.OwnerUserID != 1001 || got.Amount != maxInt64 || + got.CryptoAmount != 250000000000 || got.PurchaseDate != time.Date(2026, 7, 26, 0, 0, 0, 0, time.UTC).Unix() { + t.Fatalf("forwarded mint request = %+v", got) + } +} + +func TestAdjustAccountRatingBFFForwardsNumericPayload(t *testing.T) { + var got admin.AdjustAccountRatingRequest + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/v1/account-ratings/adjust" { + t.Fatalf("upstream path=%q", r.URL.Path) + } + if err := json.NewDecoder(r.Body).Decode(&got); err != nil { + t.Fatal(err) + } + _ = json.NewEncoder(w).Encode(admin.CommandResult{CommandID: got.CommandID, Status: "completed"}) + })) + defer upstream.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: upstream.URL, AdminAPIToken: "secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/actions/adjust-account-rating", strings.NewReader( + `{"reason":"manual penalty","confirm":true,"user_id":1001,"amount":-2500}`)) + req = req.WithContext(context.WithValue(req.Context(), actorKey{}, "operator")) + rec := httptest.NewRecorder() + srv.handleAdjustAccountRatingAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if got.Actor != "operator" || got.UserID != 1001 || got.Amount != -2500 || got.DryRun { + t.Fatalf("forwarded adjust request = %+v", got) + } +} + +func TestRevokeCollectibleUsernameBFFRejectsUnknownFields(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/actions/revoke-collectible-username", strings.NewReader( + `{"reason":"fraud","confirm":true,"username":"durov","burn":true,"actor":"attacker"}`)) + req = req.WithContext(context.WithValue(req.Context(), actorKey{}, "operator")) + rec := httptest.NewRecorder() + srv.handleRevokeCollectibleUsernameAPI(rec, req) + if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "actor") { + t.Fatalf("status=%d body=%s, want 400 rejecting the unknown actor field", rec.Code, rec.Body.String()) + } +} + +func TestCollectibleUsernameAndRatingRowsJSONPreserveInt64AsDecimalStrings(t *testing.T) { + const maxInt64 = int64(9223372036854775807) + raw, err := json.Marshal(CollectibleUsernameRow{ + ID: maxInt64, OwnerPeerID: maxInt64, Amount: maxInt64, CryptoAmount: maxInt64, + OriginalOwnerPeerID: maxInt64, Version: maxInt64, + }) + if err != nil { + t.Fatalf("marshal collectible username row: %v", err) + } + var asset map[string]any + if err := json.Unmarshal(raw, &asset); err != nil { + t.Fatalf("unmarshal collectible username row: %v", err) + } + for _, field := range []string{"ID", "OwnerPeerID", "Amount", "CryptoAmount", "OriginalOwnerPeerID", "Version"} { + if asset[field] != "9223372036854775807" { + t.Fatalf("asset %s = %#v, want exact decimal string", field, asset[field]) + } + } + + raw, err = json.Marshal(AccountRatingRow{ + UserID: maxInt64, Stars: maxInt64, CurrentLevelStars: maxInt64, NextLevelStars: maxInt64, + StarsComponent: maxInt64, ActivityComponent: maxInt64, PenaltyComponent: maxInt64, + ManualComponent: -maxInt64, PendingStars: maxInt64, Version: maxInt64, + }) + if err != nil { + t.Fatalf("marshal account rating row: %v", err) + } + var rating map[string]any + if err := json.Unmarshal(raw, &rating); err != nil { + t.Fatalf("unmarshal account rating row: %v", err) + } + for _, field := range []string{ + "UserID", "Stars", "CurrentLevelStars", "NextLevelStars", + "StarsComponent", "ActivityComponent", "PenaltyComponent", "PendingStars", "Version", + } { + if rating[field] != "9223372036854775807" { + t.Fatalf("rating %s = %#v, want exact decimal string", field, rating[field]) + } + } + if rating["ManualComponent"] != "-9223372036854775807" { + t.Fatalf("rating ManualComponent = %#v, want signed decimal string", rating["ManualComponent"]) + } + + transfer, err := json.Marshal(CollectibleUsernameTransferRow{ + ID: maxInt64, CollectibleID: maxInt64, FromPeerID: maxInt64, ToPeerID: maxInt64, Amount: maxInt64, + }) + if err != nil { + t.Fatalf("marshal transfer row: %v", err) + } + var log map[string]any + if err := json.Unmarshal(transfer, &log); err != nil { + t.Fatalf("unmarshal transfer row: %v", err) + } + for _, field := range []string{"ID", "CollectibleID", "FromPeerID", "ToPeerID", "Amount"} { + if log[field] != "9223372036854775807" { + t.Fatalf("transfer %s = %#v, want exact decimal string", field, log[field]) + } + } +} + +func TestFlexScalarsAcceptNumbersStringsAndBlanks(t *testing.T) { + var body mintCollectibleUsernameAPIRequest + req := httptest.NewRequest(http.MethodPost, "/api/actions/mint-collectible-username", strings.NewReader(`{ + "username":"durov","currency":"XTR","amount":"","owner_user_id":null, + "crypto_amount":"9223372036854775807","purchase_date":"2026-07-26" + }`)) + if err := decodeJSON(req, &body); err != nil { + t.Fatalf("decode mint action: %v", err) + } + if body.Amount.Int64() != 0 || body.OwnerUserID.Int64() != 0 || + body.CryptoAmount.Int64() != 9223372036854775807 || + body.PurchaseDate.Unix() != time.Date(2026, 7, 26, 0, 0, 0, 0, time.UTC).Unix() { + t.Fatalf("decoded mint action = %+v", body) + } + + var rating adjustAccountRatingAPIRequest + numeric := httptest.NewRequest(http.MethodPost, "/api/actions/adjust-account-rating", strings.NewReader( + `{"user_id":1001,"amount":-2500}`)) + if err := decodeJSON(numeric, &rating); err != nil { + t.Fatalf("decode adjust action: %v", err) + } + if rating.UserID.Int64() != 1001 || rating.Amount.Int64() != -2500 { + t.Fatalf("decoded adjust action = %+v", rating) + } + + var broken adjustAccountRatingAPIRequest + invalid := httptest.NewRequest(http.MethodPost, "/api/actions/adjust-account-rating", strings.NewReader( + `{"user_id":"not-a-number"}`)) + if err := decodeJSON(invalid, &broken); err == nil { + t.Fatal("decoded a non-numeric user_id") + } +} + +func TestNewCollectibleAndRatingRoutesRequireSession(t *testing.T) { + srv, err := newServer(uiConfig{SessionKey: []byte("01234567890123456789012345678901")}, nil) + if err != nil { + t.Fatalf("newServer: %v", err) + } + cases := []struct { + method string + path string + }{ + {http.MethodGet, "/api/collectible-usernames"}, + {http.MethodGet, "/api/collectible-usernames/7"}, + {http.MethodGet, "/api/account-ratings"}, + {http.MethodGet, "/api/account-ratings/7"}, + {http.MethodPost, "/api/actions/mint-collectible-username"}, + {http.MethodPost, "/api/actions/transfer-collectible-username"}, + {http.MethodPost, "/api/actions/revoke-collectible-username"}, + {http.MethodPost, "/api/actions/recompute-account-rating"}, + {http.MethodPost, "/api/actions/adjust-account-rating"}, + } + for _, item := range cases { + req := httptest.NewRequest(item.method, item.path, strings.NewReader(`{}`)) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusUnauthorized { + t.Fatalf("%s %s status=%d, want 401", item.method, item.path, rec.Code) + } + } +} + +func TestEscapeLikePatternKeepsUsernameSearchLiteral(t *testing.T) { + if got := escapeLikePattern("crypto_king"); got != `crypto\_king` { + t.Fatalf("escapeLikePattern underscore = %q", got) + } + if got := escapeLikePattern(`100%_\x`); got != `100\%\_\\x` { + t.Fatalf("escapeLikePattern metacharacters = %q", got) + } + if got := escapeLikePattern(""); got != "" { + t.Fatalf("escapeLikePattern empty = %q", got) + } +} diff --git a/cmd/telesrv-admin/verification.go b/cmd/telesrv-admin/verification.go new file mode 100644 index 00000000..e3074326 --- /dev/null +++ b/cmd/telesrv-admin/verification.go @@ -0,0 +1,262 @@ +package main + +import ( + "errors" + "net/http" + "strconv" + "strings" + + "telesrv/internal/admin" + "telesrv/internal/domain" +) + +// Official platform verification in the panel BFF. +// +// Reads come straight from PostgreSQL, like every other table view, so the queue +// pages without a hop through the admin API and the applicant can be resolved by +// a join. Decisions go the other way -- always through the admin API, so the +// command journal, the status machine and the optimistic lock are enforced in one +// place and a panel action is indistinguishable from an API one in the audit +// trail. + +// verificationRead mounts a route behind a session and the verification.review +// right. +func (s *server) verificationRead(handler http.HandlerFunc) http.Handler { + return s.requireAuthAPI(s.requirePermission(permissionVerificationReview, handler)) +} + +// handleVerificationApplicationsAPI pages the review queue. The filter is +// validated before the read store is consulted: a malformed query is a 400 +// whether or not the database happens to be reachable. +func (s *server) handleVerificationApplicationsAPI(w http.ResponseWriter, r *http.Request) { + query := r.URL.Query() + status := strings.TrimSpace(query.Get("status")) + if status != "" && !domain.VerificationStatus(status).Valid() { + writeAPIError(w, http.StatusBadRequest, "invalid status") + return + } + targetType := strings.TrimSpace(query.Get("target_type")) + if targetType != "" && !domain.VerificationTargetType(targetType).Valid() { + writeAPIError(w, http.StatusBadRequest, "invalid target_type") + return + } + beforeID, err := parseInt64(query.Get("before_id")) + if err != nil || beforeID < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid before_id") + return + } + limit, err := parseInt(query.Get("limit")) + if err != nil || limit < 0 { + writeAPIError(w, http.StatusBadRequest, "invalid limit") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + rows, hasMore, err := s.read.ListVerificationApplications( + r.Context(), status, targetType, strings.TrimSpace(query.Get("reviewer")), query.Get("q"), beforeID, limit, + ) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + nextBeforeID := "" + if hasMore && len(rows) > 0 { + nextBeforeID = strconv.FormatInt(rows[len(rows)-1].ID, 10) + } + writeJSON(w, http.StatusOK, map[string]any{ + "rows": rows, + "has_more": hasMore, + "next_before_id": nextBeforeID, + }) +} + +func (s *server) handleVerificationApplicationDetailAPI(w http.ResponseWriter, r *http.Request) { + id, err := parseInt64(r.PathValue("id")) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid id") + return + } + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + detail, err := s.read.VerificationApplicationDetail(r.Context(), id) + if err != nil { + if errors.Is(err, errReadNotFound) { + writeAPIError(w, http.StatusNotFound, "verification application not found") + return + } + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{ + "application": detail.Application, + "events": detail.Events, + // Both flags describe the target as it is now, not as it was at + // submission: a reviewer has to see that the applicant lost control of the + // peer, or that the badge is already on, before deciding. + "applicant_controls_target": detail.ApplicantControlsTarget, + "target_verified": detail.Application.TargetVerified, + }) +} + +func (s *server) handleVerificationCountsAPI(w http.ResponseWriter, r *http.Request) { + if s.read == nil { + writeAPIError(w, http.StatusServiceUnavailable, "read store is not configured") + return + } + counts, err := s.read.VerificationStatusCounts(r.Context()) + if err != nil { + writeAPIError(w, http.StatusInternalServerError, err.Error()) + return + } + writeJSON(w, http.StatusOK, map[string]any{"counts": counts}) +} + +// verificationDecisionAPIRequest is the decision payload shared by all three +// per-application actions. version is the optimistic-locking token the reviewer +// read; internal_note is operator-only and is not part of what the applicant is +// told. It is optional everywhere, including on a claim, so one panel form can +// drive all three actions without tripping the strict decoder. +type verificationDecisionAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + Version flexInt64 `json:"version"` + InternalNote string `json:"internal_note"` +} + +func (s *server) handleClaimVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := verificationPathID(w, r) + if !ok { + return + } + var body verificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.ClaimVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "claim-verification"), + ApplicationID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), verificationDecisionPath(id, "claim"), req) + writeVerificationResultAPI(w, result, status, err) +} + +func (s *server) handleApproveVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := verificationPathID(w, r) + if !ok { + return + } + var body verificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.ApproveVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "approve-verification"), + ApplicationID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), verificationDecisionPath(id, "approve"), req) + writeVerificationResultAPI(w, result, status, err) +} + +func (s *server) handleRejectVerificationAPI(w http.ResponseWriter, r *http.Request) { + id, ok := verificationPathID(w, r) + if !ok { + return + } + var body verificationDecisionAPIRequest + if !decodeAction(w, r, &body) { + return + } + req := admin.RejectVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "reject-verification"), + ApplicationID: id, + Version: body.Version.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), verificationDecisionPath(id, "reject"), req) + writeVerificationResultAPI(w, result, status, err) +} + +// revokeVerificationAPIRequest clears a badge. It addresses the target, not an +// application: the approved application stays approved as history. +type revokeVerificationAPIRequest struct { + CommandID string `json:"command_id"` + Reason string `json:"reason"` + Confirm bool `json:"confirm"` + TargetType string `json:"target_type"` + TargetID flexInt64 `json:"target_id"` + InternalNote string `json:"internal_note"` +} + +func (s *server) handleRevokeVerificationAPI(w http.ResponseWriter, r *http.Request) { + var body revokeVerificationAPIRequest + if !decodeAction(w, r, &body) { + return + } + targetType := domain.VerificationTargetType(strings.TrimSpace(body.TargetType)) + if !targetType.Valid() { + writeAPIError(w, http.StatusBadRequest, "invalid target_type") + return + } + if body.TargetID.Int64() <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid target_id") + return + } + req := admin.RevokeVerificationRequest{ + CommandMeta: s.commandMetaFromAPI(r, body.CommandID, body.Reason, body.Confirm, "revoke-verification"), + TargetType: targetType, + TargetID: body.TargetID.Int64(), + InternalNote: body.InternalNote, + } + result, status, err := s.callAdminCommand(r.Context(), "/v1/verification/revoke", req) + writeVerificationResultAPI(w, result, status, err) +} + +func verificationPathID(w http.ResponseWriter, r *http.Request) (int64, bool) { + id, err := parseInt64(r.PathValue("id")) + if err != nil || id <= 0 { + writeAPIError(w, http.StatusBadRequest, "invalid id") + return 0, false + } + return id, true +} + +func verificationDecisionPath(applicationID int64, action string) string { + return "/v1/verification/applications/" + strconv.FormatInt(applicationID, 10) + "/" + action +} + +// writeVerificationResultAPI relays the admin API's own status to the browser. +// +// The other action handlers flatten every upstream failure into 502, which is +// fine when the only failure mode is "bad request". A verification decision has +// one more: 409 when another reviewer decided first. That has to reach the panel +// as 409, because it is the single case the panel resolves by reloading the +// application rather than by asking the operator to change something. +func writeVerificationResultAPI(w http.ResponseWriter, result admin.CommandResult, status int, err error) { + if err == nil { + writeJSON(w, http.StatusOK, result) + return + } + if result.Status == "" { + result.Status = "failed" + } + if result.Message == "" { + result.Message = "command failed" + } + if result.Error == "" { + result.Error = err.Error() + } + if status < 400 { + // No HTTP answer at all: the admin API was unreachable or unparsable. + status = http.StatusBadGateway + } + writeJSON(w, status, result) +} diff --git a/cmd/telesrv-admin/verification_test.go b/cmd/telesrv-admin/verification_test.go new file mode 100644 index 00000000..3d49c0cf --- /dev/null +++ b/cmd/telesrv-admin/verification_test.go @@ -0,0 +1,690 @@ +package main + +import ( + "context" + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "telesrv/internal/admin" +) + +const testSessionKey = "01234567890123456789012345678901" + +// panelServer builds a BFF whose sessions carry the given permissions. +func panelServer(t *testing.T, permissions ...string) *server { + t.Helper() + srv, err := newServer(uiConfig{ + SessionKey: []byte(testSessionKey), + Password: "letmein", + Permissions: permissions, + }, nil) + if err != nil { + t.Fatalf("newServer: %v", err) + } + return srv +} + +// signIn performs a real login against the routed server and returns the cookies +// plus the CSRF token the panel would echo, so the tests exercise the same pairing +// the browser gets. +func signIn(t *testing.T, srv *server) ([]*http.Cookie, string) { + t.Helper() + rec := httptest.NewRecorder() + req := httptest.NewRequest(http.MethodPost, "/api/login", strings.NewReader(`{"secret":"letmein"}`)) + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("login status=%d body=%s", rec.Code, rec.Body.String()) + } + var body struct { + Actor string `json:"actor"` + Permissions []string `json:"permissions"` + CSRFToken string `json:"csrf_token"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("decode login: %v", err) + } + if body.CSRFToken == "" { + t.Fatal("login did not mint a csrf token") + } + cookies := rec.Result().Cookies() + var sawCSRFCookie bool + for _, cookie := range cookies { + if cookie.Name != csrfCookieName { + continue + } + sawCSRFCookie = true + if cookie.HttpOnly { + t.Fatal("csrf cookie is HttpOnly; the panel could not read it back") + } + if cookie.Value != body.CSRFToken || cookie.Path != "/" || cookie.SameSite != http.SameSiteLaxMode { + t.Fatalf("csrf cookie=%+v", cookie) + } + } + if !sawCSRFCookie { + t.Fatal("login did not set the csrf cookie") + } + return cookies, body.CSRFToken +} + +func withCookies(req *http.Request, cookies []*http.Cookie) *http.Request { + for _, cookie := range cookies { + req.AddCookie(cookie) + } + return req +} + +func TestPanelSessionReportsPermissions(t *testing.T) { + srv := panelServer(t, permissionVerificationReview) + cookies, _ := signIn(t, srv) + + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodGet, "/api/session", nil), cookies)) + if rec.Code != http.StatusOK { + t.Fatalf("session status=%d body=%s", rec.Code, rec.Body.String()) + } + var body struct { + Actor string `json:"actor"` + Permissions []string `json:"permissions"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("decode session: %v", err) + } + if body.Actor != "admin" || len(body.Permissions) != 1 || body.Permissions[0] != permissionVerificationReview { + t.Fatalf("session=%+v, want the granted permissions reported to the panel", body) + } +} + +func TestPanelSessionReportsTheWildcardDefault(t *testing.T) { + // The shipped default is the wildcard, so an operator upgrading into the + // permission model keeps every section. + srv := panelServer(t, permissionAll) + cookies, _ := signIn(t, srv) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodGet, "/api/session", nil), cookies)) + if !strings.Contains(rec.Body.String(), `"*"`) { + t.Fatalf("session body=%s, want the wildcard reported", rec.Body.String()) + } +} + +func TestMutatingRequestsRequireTheCSRFHeader(t *testing.T) { + srv := panelServer(t, permissionAll) + cookies, token := signIn(t, srv) + const path = "/api/actions/set-verified" + const payload = `{"reason":"official","confirm":false,"user_id":1001,"verified":true}` + + // No header at all. + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodPost, path, strings.NewReader(payload)), cookies)) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), csrfHeaderName) { + t.Fatalf("missing header status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } + + // A header that does not match the cookie. + rec = httptest.NewRecorder() + req := withCookies(httptest.NewRequest(http.MethodPost, path, strings.NewReader(payload)), cookies) + req.Header.Set(csrfHeaderName, token+"-tampered") + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden { + t.Fatalf("mismatched header status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } + + // A matching header from a different session's token: it agrees with the + // cookie the attacker planted but not with the signed session. + otherSrv := panelServer(t, permissionAll) + _, otherToken := signIn(t, otherSrv) + rec = httptest.NewRecorder() + req = httptest.NewRequest(http.MethodPost, path, strings.NewReader(payload)) + for _, cookie := range cookies { + if cookie.Name == sessionCookieName { + req.AddCookie(cookie) + } + } + req.AddCookie(&http.Cookie{Name: csrfCookieName, Value: otherToken}) + req.Header.Set(csrfHeaderName, otherToken) + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), "not bound to this session") { + t.Fatalf("foreign token status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } + + // A session minted before the CSRF token existed is refused rather than left + // half protected. + legacy, err := signSession([]byte(testSessionKey), sessionClaims{ + Actor: "admin", Exp: time.Now().Add(time.Hour).Unix(), Nonce: "n", + Permissions: []string{permissionAll}, + }) + if err != nil { + t.Fatalf("signSession: %v", err) + } + rec = httptest.NewRecorder() + req = httptest.NewRequest(http.MethodPost, path, strings.NewReader(payload)) + req.AddCookie(&http.Cookie{Name: sessionCookieName, Value: legacy}) + req.AddCookie(&http.Cookie{Name: csrfCookieName, Value: "anything"}) + req.Header.Set(csrfHeaderName, "anything") + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden { + t.Fatalf("pre-CSRF session status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } +} + +func TestCSRFProtectionCoversEveryExistingMutatingRoute(t *testing.T) { + srv := panelServer(t, permissionAll) + cookies, _ := signIn(t, srv) + // A representative slice of the routes that predate CSRF: they must all be + // closed, not just the new ones. + for _, path := range []string{ + "/api/logout", + "/api/actions/set-frozen", + "/api/actions/grant-stars", + "/api/actions/delete-bot", + "/api/actions/revoke-collectible-username", + "/api/actions/adjust-account-rating", + "/api/moderation/cases/7/claim", + "/api/verification/applications/7/approve", + "/api/actions/revoke-verification", + } { + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodPost, path, strings.NewReader(`{}`)), cookies)) + if rec.Code != http.StatusForbidden { + t.Fatalf("%s status=%d body=%s, want 403 without a csrf header", path, rec.Code, rec.Body.String()) + } + } +} + +func TestReadRequestsDoNotNeedTheCSRFHeader(t *testing.T) { + srv := panelServer(t, permissionAll) + cookies, _ := signIn(t, srv) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(httptest.NewRequest(http.MethodGet, "/api/session", nil), cookies)) + if rec.Code != http.StatusOK { + t.Fatalf("GET status=%d body=%s, want a token-free read", rec.Code, rec.Body.String()) + } +} + +func TestForeignOriginIsRefusedEvenWithAValidToken(t *testing.T) { + srv := panelServer(t, permissionAll) + cookies, token := signIn(t, srv) + req := withCookies(httptest.NewRequest(http.MethodPost, "/api/actions/set-verified", strings.NewReader( + `{"reason":"official","confirm":false,"user_id":1001,"verified":true}`)), cookies) + req.Header.Set(csrfHeaderName, token) + req.Header.Set("Origin", "https://evil.example") + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden || !strings.Contains(rec.Body.String(), "origin") { + t.Fatalf("foreign origin status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } + + // The panel's own origin is accepted. + if !sameOriginRequest(originRequest("https://panel.example", "panel.example")) { + t.Fatal("same origin refused") + } + // A missing Origin is accepted: browsers omit it and non-browser callers never + // send it, and the token check still applies. + if !sameOriginRequest(originRequest("", "panel.example")) { + t.Fatal("absent origin refused") + } + // An opaque origin is not this host. + if sameOriginRequest(originRequest("null", "panel.example")) { + t.Fatal("opaque origin accepted") + } + if sameOriginRequest(originRequest("not a url", "panel.example")) { + t.Fatal("unparsable origin accepted") + } +} + +func originRequest(origin, host string) *http.Request { + req := httptest.NewRequest(http.MethodPost, "/api/actions/set-verified", nil) + req.Host = host + if origin != "" { + req.Header.Set("Origin", origin) + } + return req +} + +func TestLoginRefusesAForeignOrigin(t *testing.T) { + srv := panelServer(t, permissionAll) + req := httptest.NewRequest(http.MethodPost, "/api/login", strings.NewReader(`{"secret":"letmein"}`)) + req.Header.Set("Origin", "https://evil.example") + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden { + t.Fatalf("cross-origin login status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } +} + +func TestVerificationRoutesRefuseASessionWithoutTheReviewRight(t *testing.T) { + srv := panelServer(t, "gifts.import") + cookies, token := signIn(t, srv) + cases := []struct { + method string + path string + body string + }{ + {http.MethodGet, "/api/verification/applications", ""}, + {http.MethodGet, "/api/verification/applications/7", ""}, + {http.MethodGet, "/api/verification/counts", ""}, + {http.MethodPost, "/api/verification/applications/7/claim", `{}`}, + {http.MethodPost, "/api/verification/applications/7/approve", `{}`}, + {http.MethodPost, "/api/verification/applications/7/reject", `{}`}, + {http.MethodPost, "/api/actions/revoke-verification", `{}`}, + } + for _, item := range cases { + var req *http.Request + if item.body == "" { + req = httptest.NewRequest(item.method, item.path, nil) + } else { + req = httptest.NewRequest(item.method, item.path, strings.NewReader(item.body)) + req.Header.Set(csrfHeaderName, token) + } + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies(req, cookies)) + if rec.Code != http.StatusForbidden { + t.Fatalf("%s %s status=%d body=%s, want 403", item.method, item.path, rec.Code, rec.Body.String()) + } + var body map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("decode 403 body: %v", err) + } + if body["code"] != "FORBIDDEN" || body["permission"] != permissionVerificationReview { + t.Fatalf("%s 403 body=%+v, want the missing permission named", item.path, body) + } + } +} + +func TestRevokeVerificationNeedsTheRevokeRightOnTopOfReview(t *testing.T) { + srv := panelServer(t, permissionVerificationReview) + cookies, token := signIn(t, srv) + req := withCookies(httptest.NewRequest(http.MethodPost, "/api/actions/revoke-verification", strings.NewReader( + `{"reason":"impersonation","confirm":true,"target_type":"channel","target_id":5005}`)), cookies) + req.Header.Set(csrfHeaderName, token) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusForbidden { + t.Fatalf("status=%d body=%s, want 403", rec.Code, rec.Body.String()) + } + var body map[string]any + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("decode 403 body: %v", err) + } + if body["permission"] != permissionVerificationRevoke { + t.Fatalf("403 body=%+v, want verification.revoke named", body) + } +} + +func TestVerificationRoutesRequireASession(t *testing.T) { + srv := panelServer(t, permissionAll) + cases := []struct { + method string + path string + }{ + {http.MethodGet, "/api/verification/applications"}, + {http.MethodGet, "/api/verification/applications/7"}, + {http.MethodGet, "/api/verification/counts"}, + {http.MethodPost, "/api/verification/applications/7/claim"}, + {http.MethodPost, "/api/verification/applications/7/approve"}, + {http.MethodPost, "/api/verification/applications/7/reject"}, + {http.MethodPost, "/api/actions/revoke-verification"}, + } + for _, item := range cases { + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, httptest.NewRequest(item.method, item.path, strings.NewReader(`{}`))) + if rec.Code != http.StatusUnauthorized { + t.Fatalf("%s %s status=%d, want 401", item.method, item.path, rec.Code) + } + } +} + +// verificationUpstream stands in for the admin API and records what the BFF sent. +type verificationUpstream struct { + path string + raw []byte + status int + body any +} + +func (u *verificationUpstream) handler(t *testing.T) http.HandlerFunc { + t.Helper() + return func(w http.ResponseWriter, r *http.Request) { + if r.Header.Get("Authorization") != "Bearer api-secret" { + t.Fatalf("upstream authorization=%q", r.Header.Get("Authorization")) + } + u.path = r.URL.Path + defer r.Body.Close() + raw, err := io.ReadAll(r.Body) + if err != nil { + t.Fatalf("read upstream body: %v", err) + } + u.raw = raw + status := u.status + if status == 0 { + status = http.StatusOK + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(u.body) + } +} + +// requestWithActor stands in for the session middleware, which is what puts the +// signed-in operator into the request context. +func requestWithActor(r *http.Request, actor string) *http.Request { + return r.WithContext(context.WithValue(r.Context(), actorKey{}, actor)) +} + +func TestApproveVerificationBFFForwardsActorVersionAndNote(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/approve", strings.NewReader(`{ + "reason":"press coverage verified","confirm":true,"version":"9223372036854775807", + "internal_note":"contact came through the press office" + }`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleApproveVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if upstream.path != "/v1/verification/applications/77/approve" { + t.Fatalf("upstream path=%q", upstream.path) + } + var got admin.ApproveVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded approval: %v (%s)", err, upstream.raw) + } + if got.Actor != "operator" { + t.Fatalf("actor=%q, want the signed-in operator", got.Actor) + } + if got.ApplicationID != 77 || got.Version != 9223372036854775807 { + t.Fatalf("forwarded approval=%+v, want the exact int64 version", got) + } + if got.InternalNote != "contact came through the press office" || got.DryRun { + t.Fatalf("forwarded approval=%+v", got) + } + if got.CommandID == "" { + t.Fatal("no command id was minted for the idempotency key") + } +} + +func TestClaimVerificationBFFDefaultsToADryRun(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed", DryRun: true}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/claim", strings.NewReader( + `{"reason":"queue sweep","confirm":false,"version":3}`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleClaimVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var got admin.ClaimVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded claim: %v", err) + } + // confirm=false is a rehearsal: nothing may be written until the operator + // confirms. + if !got.DryRun || got.Version != 3 || got.ApplicationID != 77 { + t.Fatalf("forwarded claim=%+v", got) + } +} + +func TestRevokeVerificationBFFForwardsTargetAndRejectsBadShapes(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := requestWithActor(httptest.NewRequest(http.MethodPost, "/api/actions/revoke-verification", strings.NewReader(`{ + "reason":"impersonation confirmed","confirm":true,"target_type":"channel", + "target_id":"9223372036854775807","internal_note":"legal asked for it" + }`)), "operator") + rec := httptest.NewRecorder() + srv.handleRevokeVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + if upstream.path != "/v1/verification/revoke" { + t.Fatalf("upstream path=%q", upstream.path) + } + var got admin.RevokeVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded revocation: %v", err) + } + if got.TargetID != 9223372036854775807 || got.TargetType != "channel" || + got.Actor != "operator" || got.InternalNote != "legal asked for it" || got.DryRun { + t.Fatalf("forwarded revocation=%+v", got) + } + + for _, payload := range []string{ + `{"reason":"x","confirm":true,"target_type":"group","target_id":5}`, + `{"reason":"x","confirm":true,"target_type":"channel","target_id":0}`, + } { + rec := httptest.NewRecorder() + srv.handleRevokeVerificationAPI(rec, requestWithActor( + httptest.NewRequest(http.MethodPost, "/api/actions/revoke-verification", strings.NewReader(payload)), "operator")) + if rec.Code != http.StatusBadRequest { + t.Fatalf("payload %s status=%d body=%s, want 400", payload, rec.Code, rec.Body.String()) + } + } +} + +func TestVerificationDecisionRejectsUnknownFields(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/approve", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3,"actor":"attacker"}`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleApproveVerificationAPI(rec, req) + if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "actor") { + t.Fatalf("status=%d body=%s, want 400 rejecting the injected actor", rec.Code, rec.Body.String()) + } +} + +func TestVerificationVersionConflictReachesThePanelAs409(t *testing.T) { + upstream := &verificationUpstream{ + status: http.StatusConflict, + body: admin.CommandResult{ + CommandID: "c1", Status: "failed", + Error: admin.CodeVerificationConflict + ": verification application changed concurrently", + Message: "another reviewer changed this application first; reload it and decide again", + }, + } + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/approve", strings.NewReader( + `{"reason":"ok","confirm":true,"version":3}`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleApproveVerificationAPI(rec, req) + // A flattened 502 would hide the one failure the panel resolves by reloading. + if rec.Code != http.StatusConflict { + t.Fatalf("status=%d body=%s, want 409", rec.Code, rec.Body.String()) + } + var result admin.CommandResult + if err := json.Unmarshal(rec.Body.Bytes(), &result); err != nil { + t.Fatalf("decode conflict: %v", err) + } + if !strings.Contains(result.Error, admin.CodeVerificationConflict) || !strings.Contains(result.Message, "reload") { + t.Fatalf("relayed result=%+v", result) + } +} + +func TestVerificationUnreachableAdminAPIIsABadGateway(t *testing.T) { + srv := &server{cfg: uiConfig{AdminAPIURL: "http://127.0.0.1:1", AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/reject", strings.NewReader( + `{"reason":"press links are self-published","confirm":true,"version":3}`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleRejectVerificationAPI(rec, req) + if rec.Code != http.StatusBadGateway { + t.Fatalf("status=%d body=%s, want 502", rec.Code, rec.Body.String()) + } +} + +func TestVerificationRowsJSONPreserveInt64AsDecimalStrings(t *testing.T) { + const maxInt64 = int64(9223372036854775807) + raw, err := json.Marshal(VerificationApplicationRow{ + ID: maxInt64, ApplicantUserID: maxInt64, TargetID: maxInt64, Version: maxInt64, + }) + if err != nil { + t.Fatalf("marshal verification row: %v", err) + } + var application map[string]any + if err := json.Unmarshal(raw, &application); err != nil { + t.Fatalf("unmarshal verification row: %v", err) + } + for _, field := range []string{"ID", "ApplicantUserID", "TargetID", "Version"} { + if application[field] != "9223372036854775807" { + t.Fatalf("application %s = %#v, want an exact decimal string", field, application[field]) + } + } + + raw, err = json.Marshal(VerificationEventRow{ID: maxInt64}) + if err != nil { + t.Fatalf("marshal verification event row: %v", err) + } + var event map[string]any + if err := json.Unmarshal(raw, &event); err != nil { + t.Fatalf("unmarshal verification event row: %v", err) + } + if event["ID"] != "9223372036854775807" { + t.Fatalf("event ID = %#v, want an exact decimal string", event["ID"]) + } +} + +func TestVerificationQueryValidationRejectsUnmodelledFilters(t *testing.T) { + srv := panelServer(t, permissionVerificationReview) + cookies, _ := signIn(t, srv) + for _, query := range []string{"?status=pending", "?target_type=group", "?before_id=-1", "?limit=abc"} { + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies( + httptest.NewRequest(http.MethodGet, "/api/verification/applications"+query, nil), cookies)) + // The read store is absent in this fixture, so a rejected filter is a 400 + // and an accepted one would be a 503: either way the validation is proven. + if rec.Code != http.StatusBadRequest { + t.Fatalf("%s status=%d body=%s, want 400", query, rec.Code, rec.Body.String()) + } + } + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, withCookies( + httptest.NewRequest(http.MethodGet, "/api/verification/applications?status=submitted&target_type=channel", nil), cookies)) + if rec.Code != http.StatusServiceUnavailable { + t.Fatalf("valid filter status=%d body=%s, want the read store to be reached", rec.Code, rec.Body.String()) + } +} + +func TestPanelPermissionsWildcardAndMembership(t *testing.T) { + all := newPanelPermissions([]string{permissionAll}) + if !all.Has(permissionVerificationReview) || !all.Has(permissionVerificationRevoke) { + t.Fatal("wildcard session refused a permission") + } + bounded := newPanelPermissions([]string{" verification.review ", "", "verification.review"}) + if !bounded.Has(permissionVerificationReview) || bounded.Has(permissionVerificationRevoke) { + t.Fatalf("bounded session = %+v", bounded.List()) + } + if len(bounded.List()) != 1 { + t.Fatalf("bounded list=%+v, want the duplicate collapsed", bounded.List()) + } + if got := newPanelPermissions(nil).List(); got == nil || len(got) != 0 { + t.Fatalf("empty list=%#v, want an empty array rather than null", got) + } +} + +// The CSRF gate must let a correctly-tokened request through -- including on the +// routes that predate it -- or the panel is simply broken rather than protected. +func TestExistingMutatingRoutesStillWorkWithAValidToken(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed", DryRun: true}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := panelServer(t, permissionAll) + srv.cfg.AdminAPIURL = api.URL + srv.cfg.AdminAPIToken = "api-secret" + cookies, token := signIn(t, srv) + + req := withCookies(httptest.NewRequest(http.MethodPost, "/api/actions/set-verified", strings.NewReader( + `{"reason":"official","confirm":false,"user_id":1001,"verified":true}`)), cookies) + req.Header.Set(csrfHeaderName, token) + rec := httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("tokened legacy action status=%d body=%s", rec.Code, rec.Body.String()) + } + if upstream.path != "/v1/accounts/set-verified" { + t.Fatalf("upstream path=%q", upstream.path) + } + + // And logout, which is now behind the same gate. + req = withCookies(httptest.NewRequest(http.MethodPost, "/api/logout", nil), cookies) + req.Header.Set(csrfHeaderName, token) + rec = httptest.NewRecorder() + srv.routes().ServeHTTP(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("tokened logout status=%d body=%s", rec.Code, rec.Body.String()) + } + // Both cookies are cleared, so the browser cannot keep replaying either half. + cleared := map[string]bool{} + for _, cookie := range rec.Result().Cookies() { + if cookie.MaxAge < 0 { + cleared[cookie.Name] = true + } + } + if !cleared[sessionCookieName] || !cleared[csrfCookieName] { + t.Fatalf("logout cleared=%+v, want both cookies expired", cleared) + } +} + +// The panel drives claim, approve and reject from one form, so a claim carrying an +// internal note must not be rejected by the strict decoder. +func TestClaimVerificationAcceptsAnOptionalInternalNote(t *testing.T) { + upstream := &verificationUpstream{body: admin.CommandResult{CommandID: "c1", Status: "completed"}} + api := httptest.NewServer(upstream.handler(t)) + defer api.Close() + + srv := &server{cfg: uiConfig{AdminAPIURL: api.URL, AdminAPIToken: "api-secret"}} + req := httptest.NewRequest(http.MethodPost, "/api/verification/applications/77/claim", strings.NewReader( + `{"reason":"queue sweep","confirm":true,"version":3,"internal_note":"waiting on legal"}`)) + req.SetPathValue("id", "77") + req = requestWithActor(req, "operator") + rec := httptest.NewRecorder() + srv.handleClaimVerificationAPI(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var got admin.ClaimVerificationRequest + if err := json.Unmarshal(upstream.raw, &got); err != nil { + t.Fatalf("decode forwarded claim: %v", err) + } + if got.InternalNote != "waiting on legal" { + t.Fatalf("forwarded claim=%+v", got) + } +} + +func TestMutatingMethodClassification(t *testing.T) { + for _, method := range []string{http.MethodGet, http.MethodHead, http.MethodOptions, "get"} { + if mutatingMethod(method) { + t.Fatalf("%s classified as mutating", method) + } + } + for _, method := range []string{http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete} { + if !mutatingMethod(method) { + t.Fatalf("%s classified as safe", method) + } + } +} diff --git a/cmd/telesrv-admin/web/dist/assets/index-65rEwtSD.js b/cmd/telesrv-admin/web/dist/assets/index-65rEwtSD.js new file mode 100644 index 00000000..cde06b40 --- /dev/null +++ b/cmd/telesrv-admin/web/dist/assets/index-65rEwtSD.js @@ -0,0 +1,10 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m)if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e){return l.call(m,e)?!0:l.call(p,e)?!1:d.test(e)?m[e]=!0:(p[e]=!0,!1)}function g(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function _(e,t,n,r){if(t==null||g(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` +`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{re=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?ne(e):``}function ae(e){switch(e.tag){case 5:return ne(e.type);case 16:return ne(`Lazy`);case 13:return ne(`Suspense`);case 19:return ne(`SuspenseList`);case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return``}}function oe(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case M:return`Suspense`;case N:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case A:return(e.displayName||`Context`)+`.Consumer`;case k:return(e._context.displayName||`Context`)+`.Provider`;case j:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case P:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case F:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}function se(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return oe(t);case 8:return t===D?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function ce(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function le(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function ue(e){var t=le(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function z(e){e._valueTracker||=ue(e)}function de(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=le(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function fe(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function pe(e,t){var n=t.checked;return R({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function me(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=ce(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function he(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function ge(e,t){he(e,t);var n=ce(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?ve(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&ve(e,t.type,ce(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function _e(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function ve(e,t,n){(t!==`number`||fe(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var ye=Array.isArray;function be(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ee.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oe(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ke={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ae=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(ke).forEach(function(e){Ae.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ke[t]=ke[e]})});function je(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||ke.hasOwnProperty(e)&&ke[e]?(``+t).trim():t+`px`}function Me(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=je(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Ne=R({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Pe(e,t){if(t){if(Ne[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Fe(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ie=null;function Le(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Re=null,ze=null,Be=null;function Ve(e){if(e=Ai(e)){if(typeof Re!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Mi(t),Re(e.stateNode,e.type,t))}}function He(e){ze?Be?Be.push(e):Be=[e]:ze=e}function Ue(){if(ze){var e=ze,t=Be;if(Be=ze=null,Ve(e),t)for(e=0;e>>=0,e===0?32:31-(xt(e)/St|0)|0}var K=64,q=4194304;function J(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function wt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=J(a))):r=J(s)}else o=n&~i,o===0?a!==0&&(r=J(a)):r=J(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Ot(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-G(t),e[t]=n}function kt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Wn),qn=` `,Jn=!1;function Yn(e,t){switch(e){case`keyup`:return Hn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Xn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Zn=!1;function Qn(e,t){switch(e){case`compositionend`:return Xn(t);case`keypress`:return t.which===32?(Jn=!0,qn):null;case`textInput`:return e=t.data,e===qn&&Jn?null:e;default:return null}}function $n(e,t){if(Zn)return e===`compositionend`||!Un&&Yn(e,t)?(e=pn(),fn=dn=un=null,Zn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=br(n)}}function Sr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Sr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Cr(){for(var e=window,t=fe();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=fe(e.document)}return t}function wr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Tr(e){var t=Cr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Sr(n.ownerDocument.documentElement,n)){if(r!==null&&wr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=xr(n,a);var o=xr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Dr=null,Or=null,kr=null,Ar=!1;function jr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ar||Dr==null||Dr!==fe(r)||(r=Dr,`selectionStart`in r&&wr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),kr&&yr(kr,r)||(kr=r,r=ri(Or,`onSelect`),0Pi||(e.current=Ni[Pi],Ni[Pi]=null,Pi--)}function Li(e,t){Pi++,Ni[Pi]=e.current,e.current=t}var Ri={},zi=Fi(Ri),Bi=Fi(!1),Vi=Ri;function Hi(e,t){var n=e.type.contextTypes;if(!n)return Ri;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Ui(e){return e=e.childContextTypes,e!=null}function Wi(){Ii(Bi),Ii(zi)}function Gi(e,t,n){if(zi.current!==Ri)throw Error(r(168));Li(zi,t),Li(Bi,n)}function Ki(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,se(e)||`Unknown`,a));return R({},n,i)}function qi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ri,Vi=zi.current,Li(zi,e),Li(Bi,Bi.current),!0}function Ji(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=Ki(e,t,Vi),i.__reactInternalMemoizedMergedChildContext=e,Ii(Bi),Ii(zi),Li(zi,e)):Ii(Bi),Li(Bi,n)}var Yi=null,Xi=!1,Zi=!1;function Qi(e){Yi===null?Yi=[e]:Yi.push(e)}function $i(e){Xi=!0,Qi(e)}function ea(){if(!Zi&&Yi!==null){Zi=!0;var e=0,t=jt;try{var n=Yi;for(jt=1;e>=o,i-=o,ca=1<<32-G(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),ga&&ua(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),ga&&ua(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return ga&&ua(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ga&&ua(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===F&&Aa(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Oa(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=Oa(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case F:return l=i._init,_(e,r,l(i._payload),o)}if(ye(i))return h(e,r,i,o);if(ee(i))return g(e,r,i,o);ka(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Ma=ja(!0),Na=ja(!1),Pa=Fi(null),Fa=null,Ia=null,La=null;function Ra(){La=Ia=Fa=null}function za(e){var t=Pa.current;Ii(Pa),e._currentValue=t}function Ba(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Va(e,t){Fa=e,La=Ia=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(js=!0),e.firstContext=null)}function Ha(e){var t=e._currentValue;if(La!==e)if(e={context:e,memoizedValue:t,next:null},Ia===null){if(Fa===null)throw Error(r(308));Ia=e,Fa.dependencies={lanes:0,firstContext:e}}else Ia=Ia.next=e;return t}var Ua=null;function Wa(e){Ua===null?Ua=[e]:Ua.push(e)}function Ga(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Wa(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ka(e,r)}function Ka(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var qa=!1;function Ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ya(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xa(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Bc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ka(e,n)}return i=r.interleaved,i===null?(t.next=t,Wa(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ka(e,n)}function Qa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,At(e,n)}}function $a(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function eo(e,t,n,r){var i=e.updateQueue;qa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=R({},d,f);break a;case 2:qa=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function to(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=_o.transition;_o.transition={};try{e(!1),t()}finally{jt=n,_o.transition=r}}function is(){return jo().memoizedState}function as(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ss(e))cs(t,n);else if(n=Ga(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),ls(n,t,r)}}function os(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ss(e))cs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Q(s,o)){var c=t.interleaved;c===null?(i.next=i,Wa(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ga(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),ls(n,t,r))}}function ss(e){var t=e.alternate;return e===yo||t!==null&&t===yo}function cs(e,t){Co=So=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ls(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,At(e,n)}}var us={readContext:Ha,useCallback:Eo,useContext:Eo,useEffect:Eo,useImperativeHandle:Eo,useInsertionEffect:Eo,useLayoutEffect:Eo,useMemo:Eo,useReducer:Eo,useRef:Eo,useState:Eo,useDebugValue:Eo,useDeferredValue:Eo,useTransition:Eo,useMutableSource:Eo,useSyncExternalStore:Eo,useId:Eo,unstable_isNewReconciler:!1},ds={readContext:Ha,useCallback:function(e,t){return Ao().memoizedState=[e,t===void 0?null:t],e},useContext:Ha,useEffect:qo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Go(4194308,4,Zo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Go(4194308,4,e,t)},useInsertionEffect:function(e,t){return Go(4,2,e,t)},useMemo:function(e,t){var n=Ao();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ao();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=as.bind(null,yo,e),[r.memoizedState,e]},useRef:function(e){var t=Ao();return e={current:e},t.memoizedState=e},useState:Ho,useDebugValue:$o,useDeferredValue:function(e){return Ao().memoizedState=e},useTransition:function(){var e=Ho(!1),t=e[0];return e=rs.bind(null,e[1]),Ao().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=yo,a=Ao();if(ga){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Vc===null)throw Error(r(349));vo&30||Lo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,qo(zo.bind(null,i,o,e),[e]),i.flags|=2048,Uo(9,Ro.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Ao(),t=Vc.identifierPrefix;if(ga){var n=la,r=ca;n=(r&~(1<<32-G(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=wo++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ci]=t,e[wi]=i,tc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Fe(n,i),n){case`dialog`:Xr(`cancel`,e),Xr(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:Xr(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;oel&&(t.flags|=128,i=!0,ic(s,!1),t.lanes=4194304)}else{if(!i)if(e=po(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ic(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!ga)return ac(t),null}else 2*dt()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,i=!0,ic(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(ac(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=dt(),t.sibling=null,n=fo.current,Li(fo,i?n&1|2:n&1),t);case 22:case 23:return wl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Wc&1073741824&&(ac(t),t.subtreeFlags&6&&(t.flags|=8192)):ac(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function sc(e,t){switch(pa(t),t.tag){case 1:return Ui(t.type)&&Wi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return co(),Ii(Bi),Ii(zi),ho(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return uo(t),null;case 13:if(Ii(fo),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ta()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ii(fo),null;case 4:return co(),null;case 10:return za(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var cc=!1,lc=!1,uc=typeof WeakSet==`function`?WeakSet:Set,$=null;function dc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}function fc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var pc=!1;function mc(e,t){if(di=nn,e=Cr(),wr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(fi={focusedElem:e,selectionRange:n},nn=!1,$=t;$!==null;)if(t=$,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,$=e;else for(;$!==null;){t=$;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:ms(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,$=e;break}$=t.return}return h=pc,pc=!1,h}function hc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&fc(t,n,a)}i=i.next}while(i!==r)}}function gc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function _c(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function vc(e){var t=e.alternate;t!==null&&(e.alternate=null,vc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ci],delete t[wi],delete t[Ei],delete t[Di],delete t[Oi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function yc(e){return e.tag===5||e.tag===3||e.tag===4}function bc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||yc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ui));else if(r!==4&&(e=e.child,e!==null))for(xc(e,t,n),e=e.sibling;e!==null;)xc(e,t,n),e=e.sibling}function Sc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}var Cc=null,wc=!1;function Tc(e,t,n){for(n=n.child;n!==null;)Ec(e,t,n),n=n.sibling}function Ec(e,t,n){if(yt&&typeof yt.onCommitFiberUnmount==`function`)try{yt.onCommitFiberUnmount(vt,n)}catch{}switch(n.tag){case 5:lc||dc(n,t);case 6:var r=Cc,i=wc;Cc=null,Tc(e,t,n),Cc=r,wc=i,Cc!==null&&(wc?(e=Cc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Cc.removeChild(n.stateNode));break;case 18:Cc!==null&&(wc?(e=Cc,n=n.stateNode,e.nodeType===8?yi(e.parentNode,n):e.nodeType===1&&yi(e,n),Z(e)):yi(Cc,n.stateNode));break;case 4:r=Cc,i=wc,Cc=n.stateNode.containerInfo,wc=!0,Tc(e,t,n),Cc=r,wc=i;break;case 0:case 11:case 14:case 15:if(!lc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&fc(n,t,o),i=i.next}while(i!==r)}Tc(e,t,n);break;case 1:if(!lc&&(dc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Tc(e,t,n);break;case 21:Tc(e,t,n);break;case 22:n.mode&1?(lc=(r=lc)||n.memoizedState!==null,Tc(e,t,n),lc=r):Tc(e,t,n);break;default:Tc(e,t,n)}}function Dc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new uc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Oc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=dt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Ic(i/1960))-i,10e?16:e,ol===null)var i=!1;else{if(e=ol,ol=null,sl=0,Bc&6)throw Error(r(331));var a=Bc;for(Bc|=4,$=e.current;$!==null;){var o=$,s=o.child;if($.flags&16){var c=o.deletions;if(c!==null){for(var l=0;ldt()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=q,q<<=1,!(q&130023424)&&(q=4194304)):t=1);var n=fl();e=Ka(e,t),e!==null&&(Ot(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Bi.current)js=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return js=!1,ec(e,t,n);js=!!(e.flags&131072)}else js=!1,ga&&t.flags&1048576&&da(t,ia,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;Qs(e,t),e=t.pendingProps;var a=Hi(t,zi.current);Va(t,n),a=Oo(null,t,i,e,a,n);var o=ko();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ui(i)?(o=!0,qi(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ja(t),a.updater=gs,t.stateNode=a,a._reactInternals=t,bs(t,i,e,n),t=Bs(null,t,i,!0,o,n)):(t.tag=0,ga&&o&&fa(t),Ms(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(Qs(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Jl(i),e=ms(i,e),a){case 0:t=Rs(null,t,i,e,n);break a;case 1:t=zs(null,t,i,e,n);break a;case 11:t=Ns(null,t,i,e,n);break a;case 14:t=Ps(null,t,i,ms(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ms(i,a),Rs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ms(i,a),zs(e,t,i,a,n);case 3:a:{if(Vs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,Ya(e,t),eo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=xs(Error(r(423)),t),t=Hs(e,t,i,n,a);break a}else if(i!==a){a=xs(Error(r(424)),t),t=Hs(e,t,i,n,a);break a}else for(ha=bi(t.stateNode.containerInfo.firstChild),ma=t,ga=!0,_a=null,n=Na(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ta(),i===a){t=$s(e,t,n);break a}Ms(e,t,i,n)}t=t.child}return t;case 5:return lo(t),e===null&&xa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,pi(i,a)?s=null:o!==null&&pi(i,o)&&(t.flags|=32),Ls(e,t),Ms(e,t,s,n),t.child;case 6:return e===null&&xa(t),null;case 13:return Gs(e,t,n);case 4:return so(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ma(t,null,i,n):Ms(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ms(i,a),Ns(e,t,i,a,n);case 7:return Ms(e,t,t.pendingProps,n),t.child;case 8:return Ms(e,t,t.pendingProps.children,n),t.child;case 12:return Ms(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Li(Pa,i._currentValue),i._currentValue=s,o!==null)if(Q(o.value,s)){if(o.children===a.children&&!Bi.current){t=$s(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=Xa(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ba(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ba(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Ms(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Va(t,n),a=Ha(a),i=i(a),t.flags|=1,Ms(e,t,i,n),t.child;case 14:return i=t.type,a=ms(i,t.pendingProps),a=ms(i.type,a),Ps(e,t,i,a,n);case 15:return Fs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ms(i,a),Qs(e,t),t.tag=1,Ui(i)?(e=!0,qi(t)):e=!1,Va(t,n),vs(t,i,a),bs(t,i,a,n),Bs(null,t,i,!0,e,n);case 19:return Zs(e,t,n);case 22:return Is(e,t,n)}throw Error(r(156,t.tag))};function Wl(e,t){return st(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===j)return 11;if(e===P)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return Zl(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Kl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case M:return e=Kl(13,n,t,a),e.elementType=M,e.lanes=o,e;case N:return e=Kl(19,n,t,a),e.elementType=N,e.lanes=o,e;case I:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case j:s=11;break a;case P:s=14;break a;case F:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=I,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dt(0),this.expirationTimes=Dt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ja(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u()),_=c(h(),1),v=class extends Error{status;constructor(e,t){super(t),this.status=e}},y=`telesrv_admin_csrf`,b=`X-CSRF-Token`,x=``;function S(e){x=(e??``).trim()}function C(){if(typeof document>`u`)return``;for(let e of document.cookie.split(`;`)){let t=e.trim(),n=t.indexOf(`=`);if(!(n<=0||t.slice(0,n)!==y))try{return decodeURIComponent(t.slice(n+1))}catch{return t.slice(n+1)}}return``}function w(){return C()||x}function T(e){let t=(e??`GET`).toUpperCase();return t!==`GET`&&t!==`HEAD`&&t!==`OPTIONS`}function E(e){if(!e)return{};if(e instanceof Headers){let t={};return e.forEach((e,n)=>{t[n]=e}),t}return Array.isArray(e)?Object.fromEntries(e):{...e}}async function D(e,t={}){let n=typeof FormData<`u`&&t.body instanceof FormData?{}:{"Content-Type":`application/json`};if(Object.assign(n,E(t.headers)),T(t.method)){let e=w();e&&(n[b]=e)}let r=await fetch(e,{credentials:`same-origin`,...t,headers:n}),i=await r.text(),a=i?JSON.parse(i):null;if(!r.ok){let e=a?.error||a?.Error||a?.message||r.statusText;throw new v(r.status,e)}return a}function O(e){return e instanceof Error?e.message:String(e)}var k={session:()=>D(`/api/session`),login:async e=>{let t=await D(`/api/login`,{method:`POST`,body:JSON.stringify({secret:e})});return S(t.csrf_token),t},logout:()=>D(`/api/logout`,{method:`POST`,body:`{}`}),accounts:e=>D(`/api/accounts?${e.toString()}`),accountStats:()=>D(`/api/accounts/stats`),account:e=>D(`/api/accounts/${e}`),channels:e=>D(`/api/channels?${e.toString()}`),channel:e=>D(`/api/channels/${e}`),bots:e=>D(`/api/bots?${e.toString()}`),bot:e=>D(`/api/bots/${e}`),collectibleUsernames:e=>D(`/api/collectible-usernames?${e.toString()}`),collectibleUsername:e=>D(`/api/collectible-usernames/${encodeURIComponent(e)}`),accountRatings:e=>D(`/api/account-ratings?${e.toString()}`),accountRating:e=>D(`/api/account-ratings/${encodeURIComponent(e)}`),verificationApplications:e=>D(`/api/verification/applications?${e.toString()}`),verificationApplication:e=>D(`/api/verification/applications/${encodeURIComponent(e)}`),verificationCounts:()=>D(`/api/verification/counts`),botVerifiers:e=>D(`/api/botverification/verifiers?${e.toString()}`),verificationIcons:e=>D(`/api/botverification/icons?${e.toString()}`),customVerifications:e=>D(`/api/botverification/marks?${e.toString()}`),customVerificationRequests:e=>D(`/api/botverification/requests?${e.toString()}`),customVerificationRequest:e=>D(`/api/botverification/requests/${encodeURIComponent(e)}`),botVerificationCounts:()=>D(`/api/botverification/counts`),emoji:e=>D(`/api/emoji?${e.toString()}`),emojiAnimation:e=>D(`/api/emoji/${encodeURIComponent(e)}/animation`),messages:e=>D(`/api/messages?${e.toString()}`),message:(e,t)=>D(`/api/messages/detail?${new URLSearchParams({owner_user_id:String(e),msg_id:String(t)}).toString()}`),groupMessages:e=>D(`/api/messages/groups?${e.toString()}`),groupMessage:(e,t)=>D(`/api/messages/groups/detail?${new URLSearchParams({channel_id:String(e),msg_id:String(t)}).toString()}`),moderationCases:e=>D(`/api/moderation/cases?${e.toString()}`),moderationCase:e=>D(`/api/moderation/cases/${e}`),moderationReport:e=>D(`/api/moderation/reports/${e}`),claimModerationCase:(e,t)=>D(`/api/moderation/cases/${e}/claim`,{method:`POST`,body:JSON.stringify({expected_version:t})}),decideModerationCase:(e,t)=>D(`/api/moderation/cases/${e}/decide`,{method:`POST`,body:JSON.stringify(t)}),reviewModerationAppeal:(e,t,n)=>D(`/api/moderation/cases/${e}/appeals/${t}/review`,{method:`POST`,body:JSON.stringify(n)}),gifts:()=>D(`/api/gifts`),stickerSets:e=>D(`/api/stickers?kind=${encodeURIComponent(e)}`),stickerSetDocuments:e=>D(`/api/stickers/${encodeURIComponent(e)}/documents`),stickerDocumentAnimationURL:e=>`/api/stickers/documents/${encodeURIComponent(e)}/animation`,createStickerSet:e=>D(`/api/actions/create-sticker-set`,{method:`POST`,body:e}),addStickerToSet:e=>D(`/api/actions/add-sticker-to-set`,{method:`POST`,body:e}),defaultGifts:()=>D(`/api/default-gifts`),defaultGiftAnimation:e=>D(`/api/default-gifts/${e}/animation`),officialGifts:()=>D(`/api/official-gifts`),officialGiftAnimation:e=>D(`/api/official-gifts/${encodeURIComponent(e)}/animation`),giftAnimation:e=>D(`/api/gifts/${encodeURIComponent(e)}/animation`),giftCollectibles:e=>D(`/api/gifts/${encodeURIComponent(e)}/collectibles`),giftCollectibleAnimation:(e,t,n)=>D(`/api/gifts/${encodeURIComponent(e)}/collectibles/${t}/${encodeURIComponent(n)}/animation`),importGift:e=>D(`/api/actions/import-gift`,{method:`POST`,body:e}),importDefaultGift:e=>D(`/api/actions/import-default-gift`,{method:`POST`,body:JSON.stringify(e)}),importOfficialGift:e=>D(`/api/actions/import-official-gift`,{method:`POST`,body:JSON.stringify(e)}),publishGiftCollectibles:(e,t)=>D(`/api/actions/publish-gift-collectibles?gift_id=${encodeURIComponent(e)}`,{method:`POST`,body:t}),action:(e,t)=>D(e,{method:`POST`,body:JSON.stringify(t)})},A=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),j=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),M={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},N=(0,g.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,g.createElement)(`svg`,{ref:c,...M,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:j(`lucide`,i),...s},[...o.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(a)?a:[a]])),P=(e,t)=>{let n=(0,g.forwardRef)(({className:n,...r},i)=>(0,g.createElement)(N,{ref:i,iconNode:t,className:j(`lucide-${A(e)}`,n),...r}));return n.displayName=`${e}`,n},F=P(`BadgeCheck`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),I=P(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),L=P(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ee=P(`CircleX`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),R=P(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),te=P(`ShieldX`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]]),ne=P(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),re=P(`ArrowLeftRight`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),ie=P(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ae=P(`AtSign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),oe=P(`Ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.9 4.9 14.2 14.2`,key:`1m5liu`}]]),se=P(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ce=P(`Building2`,[[`path`,{d:`M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z`,key:`1b4qmf`}],[`path`,{d:`M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2`,key:`i71pzd`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2`,key:`10jefs`}],[`path`,{d:`M10 6h4`,key:`1itunk`}],[`path`,{d:`M10 10h4`,key:`tcdvrf`}],[`path`,{d:`M10 14h4`,key:`kelpxr`}],[`path`,{d:`M10 18h4`,key:`1ulq68`}]]),le=P(`Cable`,[[`path`,{d:`M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1`,key:`10bnsj`}],[`path`,{d:`M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9`,key:`1eqmu1`}],[`path`,{d:`M21 21v-2h-4`,key:`14zm7j`}],[`path`,{d:`M3 5h4V3`,key:`z442eg`}],[`path`,{d:`M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3`,key:`ebdjd7`}]]),ue=P(`Calculator`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`,key:`x4nwl0`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`,key:`wjye3r`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]),z=P(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),de=P(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),fe=P(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),pe=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),me=P(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),he=P(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ge=P(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),_e=P(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ve=P(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),ye=P(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),be=P(`Flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),xe=P(`Gem`,[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),B=P(`Gift`,[[`rect`,{x:`3`,y:`8`,width:`18`,height:`4`,rx:`1`,key:`bkv52`}],[`path`,{d:`M12 8v13`,key:`1c76mn`}],[`path`,{d:`M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7`,key:`6wjy6b`}],[`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5`,key:`1ihvrl`}]]),Se=P(`Handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),Ce=P(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),we=P(`ImageOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),Te=P(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ee=P(`LayoutDashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),De=P(`LifeBuoy`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),Oe=P(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),ke=P(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),Ae=P(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),je=P(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),Me=P(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),Ne=P(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),Pe=P(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fe=P(`PowerOff`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=P(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Le=P(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Re=P(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ze=P(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Be=P(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Ve=P(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),He=P(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Ue=P(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),V=P(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),We=P(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Ge=P(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Ke=P(`Smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),qe=P(`Stamp`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z`,key:`1sy9ra`}],[`path`,{d:`M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13`,key:`cnxgux`}]]),Je=P(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),Ye=P(`Sticker`,[[`path`,{d:`M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z`,key:`1wis1t`}],[`path`,{d:`M14 3v4a2 2 0 0 0 2 2h4`,key:`36rjfy`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M10 16s.8 1 2 1c1.3 0 2-1 2-1`,key:`1vvgv3`}]]),Xe=P(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),H=P(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Ze=P(`Trophy`,[[`path`,{d:`M6 9H4.5a2.5 2.5 0 0 1 0-5H6`,key:`17hqa7`}],[`path`,{d:`M18 9h1.5a2.5 2.5 0 0 0 0-5H18`,key:`lmptdp`}],[`path`,{d:`M4 22h16`,key:`57wxv0`}],[`path`,{d:`M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22`,key:`1nw9bq`}],[`path`,{d:`M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22`,key:`1np0yb`}],[`path`,{d:`M18 2H6v7a6 6 0 0 0 12 0V2Z`,key:`u46fv3`}]]),Qe=P(`Undo2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),$e=P(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),et=P(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),tt=P(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),nt=P(`Vault`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}],[`path`,{d:`m7.9 7.9 2.7 2.7`,key:`hpeyl3`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}],[`path`,{d:`m13.4 10.6 2.7-2.7`,key:`264c1n`}],[`circle`,{cx:`7.5`,cy:`16.5`,r:`.5`,fill:`currentColor`,key:`nkw3mc`}],[`path`,{d:`m7.9 16.1 2.7-2.7`,key:`p81g5e`}],[`circle`,{cx:`16.5`,cy:`16.5`,r:`.5`,fill:`currentColor`,key:`fubopw`}],[`path`,{d:`m13.4 13.4 2.7 2.7`,key:`abhel3`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),rt=P(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function it(e){let t=e.trim();return!t||t.startsWith(`+`)?t:/^\d+$/.test(t)?`+${t}`:t}function U(e){let t=e.trim();return t?t.startsWith(`@`)?t:`@${t}`:``}function at(e){return`${e.FirstName||``} ${e.LastName||``}`.trim()||`-`}function ot(e){return e.Broadcast&&!e.Megagroup?`Channel`:e.Megagroup&&e.Forum?`Supergroup / Forum`:e.Megagroup?`Supergroup`:`Channel / Group`}function W(e){if(!e||e.startsWith(`0001-`))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function st(e){if(!e||e<=0)return``;let t=new Date(e*1e3);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function ct(e){let t=(e??``).trim();if(!/^https?:\/\//i.test(t))return``;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?``:e.href}catch{return``}}function lt(e){if(!e.trim())return 0;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:0}function ut(e){let t=(e??``).trim();if(!t)return 0;let n=Number(t);return Number.isFinite(n)?n:0}function dt(e){let t=(e??``).trim();if(!t)return`0`;let n=Number(t);return Number.isFinite(n)?n.toLocaleString():t}var ft={XTR:0,TON:9,USD:2,EUR:2,RUB:2};function pt(e){let t=(e??``).trim().toUpperCase();return t in ft?ft[t]:2}function mt(e,t){let n=(e??``).trim();if(!n)return`0`;if(!/^-?\d+$/.test(n))return n;let r=pt(t),i=n.startsWith(`-`),a=(i?n.slice(1):n).replace(/^0+(?=\d)/,``).padStart(r+1,`0`),o=a.slice(0,a.length-r)||`0`,s=r>0?a.slice(a.length-r):``;r>2&&(s=s.replace(/0+$/,``));let c=i?`-`:``;return s?`${c}${ht(o)}.${s}`:`${c}${ht(o)}`}function ht(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,` `)}function gt(e,t){let n=(t??``).trim().toUpperCase(),r=mt(e,n);return n?`${r} ${n}`:r}function _t(e,t){let n=(e??``).trim().replace(/\s+/g,``).replace(`,`,`.`);if(!n)return`0`;if(!/^\d*(\.\d*)?$/.test(n)||n===`.`)return null;let r=pt(t),[i,a=``]=n.split(`.`);if(a.length>r)return null;let o=`${i||`0`}${a.padEnd(r,`0`)}`.replace(/^0+(?=\d)/,``);return o===``?`0`:o}function vt(e){let t=(e??``).trim();if(!t)return`0`;let n=Number(t);return Number.isFinite(n)?n>0?`+${n.toLocaleString()}`:n.toLocaleString():t}function yt(e,t=`msg ids invalid`){let n=e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean).map(e=>Number.parseInt(e,10));if(n.length===0||n.some(e=>!Number.isFinite(e)||e<=0))throw Error(t);return n}var bt=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),G=o(((e,t)=>{t.exports=bt()}))();function xt({title:e,eyebrow:t,children:n,actions:r}){return(0,G.jsxs)(`div`,{className:`page-frame`,children:[(0,G.jsxs)(`div`,{className:`page-title-row`,children:[(0,G.jsxs)(`div`,{children:[t&&(0,G.jsx)(`div`,{className:`eyebrow`,children:t}),(0,G.jsx)(`h2`,{children:e})]}),r&&(0,G.jsx)(`div`,{className:`page-actions`,children:r})]}),n]})}function St({children:e}){return(0,G.jsx)(`div`,{className:`query-panel`,children:e})}function Ct({main:e,side:t}){return(0,G.jsxs)(`div`,{className:`split-layout`,children:[(0,G.jsx)(`div`,{className:`split-main`,children:e}),(0,G.jsx)(`aside`,{className:`split-side`,children:t})]})}function K({title:e,text:t,action:n}){return(0,G.jsxs)(`div`,{className:`section-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{children:e}),t&&(0,G.jsx)(`p`,{children:t})]}),n&&(0,G.jsx)(`div`,{className:`section-action`,children:n})]})}function q({children:e}){return(0,G.jsxs)(`div`,{className:`alert`,children:[(0,G.jsx)(I,{size:16}),` `,(0,G.jsx)(`span`,{children:e})]})}function J({children:e,tone:t=`neutral`}){return(0,G.jsx)(`span`,{className:`badge ${t}`,children:e})}function wt({label:e,value:t,tone:n}){return(0,G.jsxs)(`div`,{className:`status-item ${n}`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`strong`,{children:t})]})}function Y({label:e,value:t,tone:n=`neutral`,mono:r=!1}){return(0,G.jsxs)(`div`,{className:`metric ${n}`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`strong`,{className:r?`mono`:``,children:t})]})}function X({label:e,value:t,mono:n=!1}){return(0,G.jsxs)(`div`,{className:`summary-item`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`strong`,{className:n?`mono`:``,children:t})]})}function Tt({rows:e}){return(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Command ID`}),(0,G.jsx)(`th`,{children:`Action`}),(0,G.jsx)(`th`,{children:`Actor`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Dry-run`}),(0,G.jsx)(`th`,{children:`Reason`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:e.ID}),(0,G.jsx)(`td`,{className:`mono`,children:e.CommandID}),(0,G.jsx)(`td`,{children:e.Action}),(0,G.jsx)(`td`,{children:e.Actor}),(0,G.jsx)(`td`,{children:e.Status}),(0,G.jsx)(`td`,{children:e.DryRun?`Yes`:`No`}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Reason}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)})]},e.ID)),e.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})})}function Et({colSpan:e}){return(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:e,className:`empty-cell`,children:`No results`})})}function Dt({label:e}){return(0,G.jsx)(`section`,{className:`surface`,children:(0,G.jsx)(`div`,{className:`loading-line`,children:e})})}function Ot({value:e}){return(0,G.jsx)(`pre`,{className:`json-block`,children:e||`{}`})}function kt({username:e,collectibles:t}){let n=U(e??``),r=t??[];return r.length===0?(0,G.jsx)(G.Fragment,{children:n||`-`}):(0,G.jsxs)(G.Fragment,{children:[n,(0,G.jsx)(`ul`,{className:`username-branch`,children:r.map(e=>(0,G.jsxs)(`li`,{className:e.Active?``:`inactive`,children:[(0,G.jsx)(`span`,{children:U(e.Username)}),!e.Active&&(0,G.jsx)(`em`,{children:`inactive`})]},e.Username))})]})}var At=`verification.review`,jt=`botverification.review`,Mt=`botverification.manage`,Nt=(0,g.createContext)([]);function Pt({permissions:e,children:t}){return(0,G.jsx)(Nt.Provider,{value:e,children:t})}function Ft(){let e=(0,g.useContext)(Nt);return(0,g.useMemo)(()=>({permissions:e,can:t=>e.includes(`*`)||e.includes(t)}),[e])}function It(e){return Ft().can(e)}function Lt({permission:e,children:t}){let{can:n}=Ft();return n(e)?(0,G.jsx)(G.Fragment,{children:t}):(0,G.jsx)(Rt,{permission:e})}function Rt({permission:e}){return(0,G.jsxs)(xt,{title:`Not enough rights`,eyebrow:`Console / Access`,children:[(0,G.jsx)(q,{children:`This session was not granted the ${e} permission, so the section stays closed.`}),(0,G.jsx)(`section`,{className:`section-block`,children:(0,G.jsx)(`div`,{className:`entity-head`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`entity-title`,children:[(0,G.jsx)(V,{size:16}),` `,`Section unavailable`]}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:`Ask an operator to add the permission to TELESRV_ADMIN_UI_PERMISSIONS and sign in again.`})]})})})]})}function zt(){return{href:`${window.location.pathname}${window.location.search}`,path:window.location.pathname,search:new URLSearchParams(window.location.search)}}function Bt(e){return e.startsWith(`/bot-verification`)?`Third-party verification`:e.startsWith(`/verification`)?`Official Verification`:e.startsWith(`/collectible-usernames`)?`Collectible Usernames`:e.startsWith(`/account-ratings`)?`Account Rating`:e.startsWith(`/accounts`)?`Accounts`:e.startsWith(`/channels`)?`Supergroups and Channels`:e.startsWith(`/bots`)?`Bots`:e.startsWith(`/moderation`)?`Reports and Moderation`:e.startsWith(`/emoji`)?`Emoji`:e.startsWith(`/messages`)?`Message Audit`:e.startsWith(`/give-gifts`)?`Give Gifts`:e.startsWith(`/gifts`)?`Star Gifts`:e.startsWith(`/stickers`)?`Stickers`:e.startsWith(`/emoji`)?`Emoji`:`Operations Console`}function Vt(e){return e.startsWith(`/bot-verification`)?`Console / Third-party verification`:e.startsWith(`/verification`)?`Console / Verification`:e.startsWith(`/collectible-usernames`)?`Console / Collectible usernames`:e.startsWith(`/account-ratings`)?`Console / Account rating`:e.startsWith(`/accounts`)?`Console / Accounts`:e.startsWith(`/channels`)?`Console / Channels`:e.startsWith(`/bots`)?`Console / Bots`:e.startsWith(`/moderation`)?`Console / Moderation`:e.startsWith(`/emoji`)?`Console / Emoji`:e.startsWith(`/messages`)?`Console / Messages`:e.startsWith(`/give-gifts`)?`Console / Give Gifts`:e.startsWith(`/gifts`)?`Console / Star Gifts`:e.startsWith(`/stickers`)?`Console / Stickers`:e.startsWith(`/emoji`)?`Console / Emoji`:`Console / Overview`}var Ht=`telesrv.admin.theme`,Ut=(0,g.createContext)(null);function Wt(e){document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=e}function Gt({children:e}){let[t,n]=(0,g.useState)(()=>Jt());(0,g.useEffect)(()=>{Wt(t);try{localStorage.setItem(Ht,t)}catch{}},[t]),(0,g.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=e=>{let t=null;try{t=localStorage.getItem(Ht)}catch{t=null}t!==`light`&&t!==`dark`&&n(e.matches?`dark`:`light`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let r=(0,g.useCallback)(e=>n(e),[]),i=(0,g.useCallback)(()=>n(e=>e===`dark`?`light`:`dark`),[]),a=(0,g.useMemo)(()=>({theme:t,setTheme:r,toggleTheme:i}),[t,r,i]);return(0,G.jsx)(Ut.Provider,{value:a,children:e})}function Kt(){let e=(0,g.useContext)(Ut);if(!e)throw Error(`useTheme must be used inside ThemeProvider`);return e}function qt(){let{theme:e,toggleTheme:t}=Kt(),n=e===`light`?`Switch to dark theme`:`Switch to light theme`;return(0,G.jsx)(`button`,{className:`theme-toggle`,type:`button`,onClick:t,"aria-label":n,title:n,children:e===`dark`?(0,G.jsx)(Xe,{size:16}):(0,G.jsx)(Ae,{size:16})})}function Jt(){try{let e=localStorage.getItem(Ht);if(e===`light`||e===`dark`)return e}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function Yt({href:e,navigate:t,className:n,children:r}){return(0,G.jsx)(`a`,{className:n,href:e,onClick:n=>{n.preventDefault(),t(e)},children:r})}function Xt(){return(0,G.jsxs)(`div`,{className:`boot-screen`,children:[(0,G.jsxs)(`div`,{className:`brand compact brand-elevated`,children:[(0,G.jsx)(`span`,{className:`brand-mark`,children:(0,G.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:`OwpenGram`}),(0,G.jsx)(`small`,{children:`Admin Console`})]})]}),(0,G.jsx)(`div`,{className:`loader-bar`})]})}function Zt({actor:e,route:t,navigate:n,onLogout:r,children:i}){let a=It(At),o=It(jt),s=t.path.startsWith(`/messages`),[c,l]=(0,g.useState)(s);(0,g.useEffect)(()=>{s&&l(!0)},[s]);async function u(){await k.logout().catch(()=>void 0),r()}return(0,G.jsxs)(`div`,{className:`shell`,children:[(0,G.jsxs)(`aside`,{className:`sidebar`,children:[(0,G.jsxs)(Yt,{className:`brand`,href:`/`,navigate:n,children:[(0,G.jsx)(`span`,{className:`brand-mark`,children:(0,G.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:`OwpenGram`}),(0,G.jsx)(`small`,{children:`Admin Console`})]})]}),(0,G.jsx)(`div`,{className:`sidebar-label`,children:`Navigation`}),(0,G.jsxs)(`nav`,{className:`nav-list`,"aria-label":`Primary navigation`,children:[(0,G.jsx)(Qt,{icon:(0,G.jsx)(Ee,{size:16}),href:`/`,route:t,navigate:n,children:`Overview`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(tt,{size:16}),href:`/accounts`,route:t,navigate:n,children:`Accounts`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(Ue,{size:16}),href:`/channels`,route:t,navigate:n,children:`Supergroups / Channels`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(se,{size:16}),href:`/bots`,route:t,navigate:n,children:`Bots`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(He,{size:16}),href:`/moderation`,route:t,navigate:n,children:`Reports / Moderation`}),a&&(0,G.jsx)(Qt,{icon:(0,G.jsx)(F,{size:16}),href:`/verification`,route:t,navigate:n,children:`Verification`}),o&&(0,G.jsx)(Qt,{icon:(0,G.jsx)(qe,{size:16}),href:`/bot-verification`,route:t,navigate:n,children:`Third-party marks`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(ae,{size:16}),href:`/collectible-usernames`,route:t,navigate:n,children:`NFT Usernames`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(Ze,{size:16}),href:`/account-ratings`,route:t,navigate:n,children:`Account Rating`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(B,{size:16}),href:`/gifts`,route:t,navigate:n,children:`Star Gifts`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(ze,{size:16}),href:`/give-gifts`,route:t,navigate:n,children:`Give Gifts`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(Ye,{size:16}),href:`/stickers`,route:t,navigate:n,children:`Stickers`}),(0,G.jsx)(Qt,{icon:(0,G.jsx)(Ke,{size:16}),href:`/emoji`,route:t,navigate:n,children:`Emoji`}),(0,G.jsxs)(`div`,{className:`nav-section ${s?`active`:``} ${c?`open`:``}`,children:[(0,G.jsxs)(`button`,{className:`nav-section-toggle`,type:`button`,"aria-expanded":c,onClick:()=>l(e=>!e),children:[(0,G.jsx)(ke,{size:16}),(0,G.jsx)(`span`,{children:`Messages`}),(0,G.jsx)(de,{className:`nav-section-chevron`,size:15})]}),c&&(0,G.jsxs)(`div`,{className:`nav-children`,children:[(0,G.jsx)(Qt,{href:`/messages/private`,route:t,navigate:n,activeWhen:e=>e===`/messages`||e===`/messages/detail`||e.startsWith(`/messages/private`),children:`Private`}),(0,G.jsx)(Qt,{href:`/messages/groups`,route:t,navigate:n,activeWhen:e=>e.startsWith(`/messages/groups`),children:`Groups`})]})]})]}),(0,G.jsxs)(`div`,{className:`sidebar-status`,children:[(0,G.jsx)(`div`,{className:`sidebar-label`,children:`Runtime`}),(0,G.jsxs)(`div`,{className:`runtime-row`,children:[(0,G.jsx)(Be,{size:14}),(0,G.jsx)(`span`,{children:`Admin backend`}),(0,G.jsx)(`strong`,{children:`Ready`})]}),(0,G.jsxs)(`div`,{className:`runtime-row`,children:[(0,G.jsx)(he,{size:14}),(0,G.jsx)(`span`,{children:`PG read`}),(0,G.jsx)(`strong`,{children:`Read-only`})]}),(0,G.jsxs)(`div`,{className:`runtime-row`,children:[(0,G.jsx)(We,{size:14}),(0,G.jsx)(`span`,{children:`Write operations`}),(0,G.jsx)(`strong`,{children:`Dry-run`})]})]})]}),(0,G.jsxs)(`div`,{className:`workspace`,children:[(0,G.jsxs)(`header`,{className:`topbar`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:Vt(t.path)}),(0,G.jsx)(`h1`,{children:Bt(t.path)})]}),(0,G.jsxs)(`div`,{className:`topbar-actions`,children:[(0,G.jsx)(qt,{}),(0,G.jsx)(`span`,{className:`actor-pill`,children:`Actor: ${e}`}),(0,G.jsxs)(`button`,{className:`btn ghost icon-text`,type:`button`,onClick:u,title:`Log out`,children:[(0,G.jsx)(Oe,{size:16}),` `,`Log out`]})]})]}),(0,G.jsx)(`main`,{className:`content`,children:i})]})]})}function Qt({href:e,route:t,navigate:n,icon:r,children:i,activeWhen:a}){return(0,G.jsxs)(Yt,{className:`nav-item ${(a?a(t.path):e===`/`?t.path===`/`:t.path.startsWith(e))?`active`:``}`,href:e,navigate:n,children:[r??(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`nav-dot`}),(0,G.jsx)(`span`,{children:i})]})}function $t({onLogin:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1);async function s(n){n.preventDefault(),o(!0),i(``);try{let n=await k.login(t);e({actor:n.actor,permissions:n.permissions??[]})}catch(e){i(O(e))}finally{o(!1)}}return(0,G.jsxs)(`main`,{className:`login-page`,children:[(0,G.jsxs)(`div`,{className:`bg-orbs`,"aria-hidden":`true`,children:[(0,G.jsx)(`div`,{className:`bg-orb bg-orb--1`}),(0,G.jsx)(`div`,{className:`bg-orb bg-orb--2`}),(0,G.jsx)(`div`,{className:`bg-orb bg-orb--3`})]}),(0,G.jsxs)(`section`,{className:`login-panel`,children:[(0,G.jsxs)(`div`,{className:`login-head`,children:[(0,G.jsxs)(`div`,{className:`brand brand-elevated`,children:[(0,G.jsx)(`span`,{className:`brand-mark`,children:(0,G.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{children:`OwpenGram`}),(0,G.jsx)(`small`,{children:`Admin Console`})]})]}),(0,G.jsxs)(`div`,{className:`login-head-actions`,children:[(0,G.jsx)(qt,{}),(0,G.jsx)(`span`,{className:`login-chip`,children:`Local access`})]})]}),(0,G.jsxs)(`div`,{className:`login-copy`,children:[(0,G.jsx)(`h1`,{children:`Operations Admin`}),(0,G.jsx)(`p`,{children:`Enter credentials to open the console.`})]}),r&&(0,G.jsx)(q,{children:r}),(0,G.jsxs)(`form`,{className:`form-stack`,onSubmit:s,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Admin password or token`}),(0,G.jsx)(`input`,{autoFocus:!0,type:`password`,value:t,autoComplete:`current-password`,onChange:e=>n(e.target.value)})]}),(0,G.jsx)(`button`,{className:`btn primary full`,type:`submit`,disabled:a,children:a?`Logging in`:`Log in`})]})]})]})}var en=m();function Z({label:e,path:t,payload:n,icon:r,compact:i=!1,tone:a=`danger`,disabled:o=!1,onDone:s,onError:c}){let[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(!1);function b(){f(``),m(null),_(``)}async function x(e){if(!d.trim()){_(`Please enter an operation reason`);return}y(!0),_(``);try{let r={...n(),reason:d,confirm:e};m(await k.action(t,r)),e&&s?.()}catch(e){_(c?.(e)||O(e))}finally{y(!1)}}let S=p?.dry_run&&!p.error,C=`btn ${a===`danger`?`danger`:a===`warn`?`warn`:``} ${i?`compact-btn`:``}`,w=(0,g.useMemo)(()=>{try{return n()}catch(e){return{payload_error:O(e)}}},[l,n]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:C,type:`button`,disabled:o,onClick:()=>{b(),u(!0)},children:[r,e]}),l&&(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Action Flow`}),(0,G.jsx)(`h2`,{children:e})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:()=>u(!1),"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body`,children:[(0,G.jsxs)(`div`,{className:`command-steps`,children:[(0,G.jsxs)(`div`,{className:`command-step ${d.trim()?`done`:`active`}`,children:[(0,G.jsx)(`span`,{children:`1`}),(0,G.jsx)(`strong`,{children:`Enter reason`})]}),(0,G.jsxs)(`div`,{className:`command-step ${p?.dry_run?`done`:d.trim()?`active`:``}`,children:[(0,G.jsx)(`span`,{children:`2`}),(0,G.jsx)(`strong`,{children:`Dry-run check`})]}),(0,G.jsxs)(`div`,{className:`command-step ${p&&!p.dry_run&&!p.error?`done`:S?`active`:``}`,children:[(0,G.jsx)(`span`,{children:`3`}),(0,G.jsx)(`strong`,{children:`Confirm execution`})]})]}),(0,G.jsxs)(`label`,{className:`form-field`,children:[(0,G.jsx)(`span`,{children:`Operation reason`}),(0,G.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:3,placeholder:`Describe why this operation is being performed`})]}),(0,G.jsxs)(`div`,{className:`command-preview`,children:[(0,G.jsxs)(`div`,{className:`preview-head`,children:[(0,G.jsx)(ye,{size:14}),` `,`Request preview`]}),(0,G.jsx)(Ot,{value:JSON.stringify(w,null,2)})]}),h&&(0,G.jsx)(q,{children:h}),p&&(0,G.jsxs)(`div`,{className:`result-box`,children:[(0,G.jsxs)(`div`,{className:`result-title`,children:[p.error?(0,G.jsx)(I,{size:16}):(0,G.jsx)(L,{size:16}),(0,G.jsx)(`strong`,{children:p.message||p.error||`Action result`})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Command ID`}),(0,G.jsx)(`strong`,{children:p.command_id})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsx)(`strong`,{children:p.status})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Dry-run`}),(0,G.jsx)(`strong`,{children:p.dry_run?`Yes`:`No`})]}),(0,G.jsx)(`div`,{className:`result-message`,children:p.message||p.error}),p.details&&(0,G.jsx)(Ot,{value:JSON.stringify(p.details,null,2)})]})]}),(0,G.jsxs)(`div`,{className:`modal-actions`,children:[(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>u(!1),children:`Close`}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>x(!1),disabled:v,children:[v?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Ne,{size:15}),p?`Run dry-run again`:`Run dry-run first`]}),(0,G.jsxs)(`button`,{className:`btn danger icon-text`,type:`button`,onClick:()=>x(!0),disabled:v||!S,children:[(0,G.jsx)(L,{size:15}),`Confirm execution`]})]})]})}),document.body)]})}function tn({rows:e,userID:t,onDone:n}){let[r,i]=(0,g.useState)(()=>new Set);(0,g.useEffect)(()=>{i(new Set)},[t]);let a=(0,g.useMemo)(()=>e.filter(e=>!r.has(e.Hash)),[e,r]);function o(e){i(t=>e(t)),n()}return(0,G.jsxs)(`div`,{className:`authorization-block`,children:[(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table authorization-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Device`}),(0,G.jsx)(`th`,{children:`Platform`}),(0,G.jsx)(`th`,{children:`IP`}),(0,G.jsx)(`th`,{children:`Last active`}),(0,G.jsx)(`th`,{className:`device-actions-head`,children:`Actions`})]})}),(0,G.jsxs)(`tbody`,{children:[a.map(n=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`td`,{className:`device-text`,children:[n.DeviceModel,` `,n.SystemVersion]}),(0,G.jsxs)(`td`,{className:`device-text`,children:[n.Platform,` `,n.AppVersion]}),(0,G.jsx)(`td`,{children:n.IP}),(0,G.jsx)(`td`,{children:W(n.ActiveAt)}),(0,G.jsx)(`td`,{className:`device-actions-cell`,children:(0,G.jsxs)(`div`,{className:`device-actions`,children:[(0,G.jsx)(Z,{label:`Revoke current`,icon:(0,G.jsx)(Oe,{size:13}),compact:!0,path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,hash:n.Hash}),onDone:()=>o(e=>new Set([...e,n.Hash]))}),(0,G.jsx)(Z,{label:`Keep current`,icon:(0,G.jsx)(Ue,{size:13}),compact:!0,path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,keep_hash:n.Hash}),onDone:()=>o(()=>new Set(e.filter(e=>e.Hash!==n.Hash).map(e=>e.Hash)))})]})})]},n.Hash)),a.length===0&&(0,G.jsx)(Et,{colSpan:5})]})]})}),(0,G.jsx)(`div`,{className:`danger-zone`,children:(0,G.jsx)(Z,{label:`Revoke all devices`,icon:(0,G.jsx)(le,{size:15}),path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,revoke_all:!0}),onDone:()=>o(()=>new Set(e.map(e=>e.Hash)))})})]})}function nn({scam:e,fake:t}){return!e&&!t?null:(0,G.jsxs)(G.Fragment,{children:[e&&(0,G.jsx)(J,{tone:`danger`,children:`SCAM`}),t&&(0,G.jsx)(J,{tone:`danger`,children:`FAKE`})]})}function rn({idKey:e,id:t,path:n,scam:r,fake:i,onDone:a}){return(0,G.jsxs)(`div`,{className:`action-stack`,children:[(0,G.jsx)(Z,{label:r?`Clear SCAM`:`Mark as SCAM`,icon:(0,G.jsx)(He,{size:15}),tone:`danger`,path:n,payload:()=>({[e]:t,scam:!r,fake:r?i:!1}),onDone:a}),(0,G.jsx)(Z,{label:i?`Clear FAKE`:`Mark as FAKE`,icon:(0,G.jsx)(te,{size:15}),tone:`danger`,path:n,payload:()=>({[e]:t,fake:!i,scam:i?r:!1}),onDone:a})]})}function an({id:e,support:t,onDone:n}){return(0,G.jsx)(Z,{label:t?`Clear support`:`Mark as support`,icon:(0,G.jsx)(De,{size:15}),tone:`neutral`,path:`/api/actions/set-support`,payload:()=>({user_id:e,support:!t}),onDone:n})}function on({idKey:e,id:t,path:n,current:r,onDone:i}){let[a,o]=(0,g.useState)(r.replace(/^@/,``));return(0,G.jsxs)(`div`,{className:`attr-block`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Username`}),(0,G.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`username`})]}),(0,G.jsx)(Z,{label:`Set username`,icon:(0,G.jsx)(ae,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,username:a.trim().replace(/^@/,``)}),onDone:i})]})}function sn({idKey:e,id:t,path:n,onDone:r}){let[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!0),[c,l]=(0,g.useState)(`0`),[u,d]=(0,g.useState)(``);return(0,G.jsxs)(`div`,{className:`attr-block`,children:[(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),` `,`Profile color`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),` `,`Enable color`]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Color index`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`20`,value:c,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Background emoji ID`}),(0,G.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`0`})]}),(0,G.jsx)(Z,{label:`Set color`,icon:(0,G.jsx)(je,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,for_profile:i,has_color:o,color:lt(c),background_emoji_id:u.trim()||`0`}),onDone:r})]})}function cn({idKey:e,id:t,path:n,onDone:r}){let[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`0`);return(0,G.jsxs)(`div`,{className:`attr-block`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Emoji document ID`}),(0,G.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`0 = clear`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Until (unix, 0 = permanent)`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,value:o,onChange:e=>s(e.target.value)})]}),(0,G.jsx)(Z,{label:`Set emoji status`,icon:(0,G.jsx)(Ke,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,document_id:i.trim()||`0`,until:lt(o)}),onDone:r})]})}function ln({channel:e,onDone:t}){let[n,r]=(0,g.useState)(e.Gigagroup),[i,a]=(0,g.useState)(e.AntiSpam),[o,s]=(0,g.useState)(e.ParticipantsHidden),[c,l]=(0,g.useState)(e.NoForwards),[u,d]=(0,g.useState)(e.JoinToSend),[f,p]=(0,g.useState)(e.JoinRequest),[m,h]=(0,g.useState)(String(e.SlowmodeSeconds));(0,g.useEffect)(()=>{r(e.Gigagroup),a(e.AntiSpam),s(e.ParticipantsHidden),l(e.NoForwards),d(e.JoinToSend),p(e.JoinRequest),h(String(e.SlowmodeSeconds))},[e]);function _(){let t={channel_id:e.ID};return n!==e.Gigagroup&&(t.gigagroup=n),i!==e.AntiSpam&&(t.antispam=i),o!==e.ParticipantsHidden&&(t.participants_hidden=o),c!==e.NoForwards&&(t.noforwards=c),u!==e.JoinToSend&&(t.join_to_send=u),f!==e.JoinRequest&&(t.join_request=f),lt(m)!==e.SlowmodeSeconds&&(t.slowmode_seconds=lt(m)),t}return(0,G.jsxs)(`div`,{className:`attr-block`,children:[(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),` `,`Gigagroup`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),` `,`Aggressive anti-spam`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),` `,`Hide members`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),` `,`Restrict forwarding`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),` `,`Join to send messages`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,`Join by request`]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Slowmode (seconds)`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`86400`,value:m,onChange:e=>h(e.target.value)})]}),(0,G.jsx)(Z,{label:`Apply settings`,icon:(0,G.jsx)(Ve,{size:15}),tone:`warn`,path:`/api/actions/set-channel-settings`,payload:_,onDone:t})]})}function un({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(`1`),[u,d]=(0,g.useState)(`1000`),[f,p]=(0,g.useState)(()=>dn(new Date(Date.now()+7*864e5))),[m,h]=(0,g.useState)(``);async function _(){s(!0),a(``);try{let t=await k.account(e);r(t),t.Restriction.Frozen&&(t.Restriction.Until&&p(dn(new Date(t.Restriction.Until))),h(t.Restriction.AppealURL||``))}catch(e){a(O(e))}finally{s(!1)}}if((0,g.useEffect)(()=>{_()},[e]),i)return(0,G.jsx)(q,{children:i});if(!n)return(0,G.jsx)(Dt,{label:o?`Loading account detail`:`Waiting for data`});let v=n.Account;return(0,G.jsx)(xt,{title:`Account #${v.ID}`,eyebrow:`Account Profile`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/accounts`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),children:(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:at(v)}),(0,G.jsxs)(`div`,{className:`entity-subtitle`,children:[U(v.Username)||`No username`,` · `,it(v.Phone)||`No phone`]}),v.Collectibles?.length>0&&(0,G.jsx)(`div`,{className:`entity-subtitle`,children:(0,G.jsx)(kt,{username:``,collectibles:v.Collectibles})})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[v.PremiumUntil>0?(0,G.jsx)(J,{tone:`good`,children:`Premium`}):(0,G.jsx)(J,{children:`Not premium`}),n.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Not verified`}),(0,G.jsx)(nn,{scam:n.Scam,fake:n.Fake}),v.Frozen?(0,G.jsx)(J,{tone:`danger`,children:`Account frozen`}):(0,G.jsx)(J,{children:`Account active`})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`User ID`,value:String(v.ID),mono:!0}),(0,G.jsx)(X,{label:`Last active`,value:st(n.LastSeenAt)||`-`}),(0,G.jsx)(X,{label:`Premium expires`,value:v.PremiumUntil>0?st(v.PremiumUntil):`None`}),(0,G.jsx)(X,{label:`Stars balance`,value:`${n.StarsBalance} / ${n.StarsGranted?`initial grant applied`:`initial grant pending`}`}),(0,G.jsx)(X,{label:`Updated`,value:W(v.UpdatedAt)||`-`}),(0,G.jsx)(X,{label:`Authorized devices`,value:String(n.Authorizations.length)}),(0,G.jsx)(X,{label:`Account flags`,value:`support=${n.Support} bot=${n.Bot}`}),(0,G.jsx)(X,{label:`Restriction`,value:n.HasRestriction?n.Restriction.Reason||`Restricted`:`None`}),(0,G.jsx)(X,{label:`Frozen since`,value:n.Restriction.Since?W(n.Restriction.Since):`None`}),(0,G.jsx)(X,{label:`Appeal deadline`,value:n.Restriction.Until?W(n.Restriction.Until):`None`}),(0,G.jsx)(X,{label:`Appeal URL`,value:n.Restriction.AppealURL||`None`}),(0,G.jsx)(X,{label:`Created`,value:W(v.CreatedAt)||`-`})]}),n.About&&(0,G.jsx)(`p`,{className:`about-text`,children:n.About}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Authorized Devices`,text:`${n.Authorizations.length} authorizations`}),(0,G.jsx)(tn,{rows:n.Authorizations,userID:v.ID,onDone:_})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Recent Admin Actions`,text:`Last 30 audit rows`}),(0,G.jsx)(Tt,{rows:n.AuditLogs})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Account Actions`}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Appeal deadline`}),(0,G.jsx)(`input`,{"aria-label":`Freeze appeal deadline`,value:f,onChange:e=>p(e.target.value),type:`datetime-local`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Appeal URL`}),(0,G.jsx)(`input`,{"aria-label":`Freeze appeal URL`,value:m,onChange:e=>h(e.target.value),type:`url`,placeholder:`https://...`})]}),(0,G.jsx)(Z,{label:v.Frozen?`Update freeze`:`Freeze account`,icon:(0,G.jsx)(I,{size:15}),path:`/api/actions/set-frozen`,payload:()=>({user_id:v.ID,frozen:!0,freeze_until:new Date(f).toISOString(),freeze_appeal_url:m.trim()}),onDone:_}),v.Frozen&&(0,G.jsx)(Z,{label:`Unfreeze account`,icon:(0,G.jsx)(I,{size:15}),path:`/api/actions/set-frozen`,payload:()=>({user_id:v.ID,frozen:!1}),onDone:_}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Premium duration (months)`}),(0,G.jsx)(`input`,{"aria-label":`Set premium duration in months`,value:c,onChange:e=>l(e.target.value),type:`number`,min:`1`,max:`120`})]}),(0,G.jsxs)(`div`,{className:`action-stack`,children:[(0,G.jsx)(Z,{label:`Set premium`,icon:(0,G.jsx)(ne,{size:15}),tone:`warn`,path:`/api/actions/grant-premium`,payload:()=>({user_id:v.ID,months:lt(c)}),onDone:_}),(0,G.jsx)(Z,{label:`Clear premium`,icon:(0,G.jsx)(ne,{size:15}),tone:`warn`,path:`/api/actions/grant-premium`,payload:()=>({user_id:v.ID,months:0}),onDone:_}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Stars to grant`}),(0,G.jsx)(`input`,{"aria-label":`Set Stars amount to grant`,value:u,onChange:e=>d(e.target.value),type:`number`,min:`1`,max:`1000000000`})]}),(0,G.jsx)(Z,{label:`Grant Stars`,icon:(0,G.jsx)(Je,{size:15}),tone:`warn`,path:`/api/actions/grant-stars`,payload:()=>({user_id:v.ID,amount:lt(u)}),onDone:_}),(0,G.jsx)(Z,{label:n.Verified?`Clear verified`:`Set verified`,icon:(0,G.jsx)(F,{size:15}),tone:`warn`,path:`/api/actions/set-verified`,payload:()=>({user_id:v.ID,verified:!n.Verified}),onDone:_})]}),(0,G.jsx)(rn,{idKey:`user_id`,id:v.ID,path:`/api/actions/set-account-flags`,scam:n.Scam,fake:n.Fake,onDone:_}),(0,G.jsx)(`div`,{className:`dock-title`,children:`Attributes`}),(0,G.jsx)(an,{id:v.ID,support:n.Support,onDone:_}),(0,G.jsx)(on,{idKey:`user_id`,id:v.ID,path:`/api/actions/set-account-username`,current:v.Username,onDone:_}),(0,G.jsx)(sn,{idKey:`user_id`,id:v.ID,path:`/api/actions/set-account-color`,onDone:_}),(0,G.jsx)(cn,{idKey:`user_id`,id:v.ID,path:`/api/actions/set-account-emoji-status`,onDone:_})]})})})}function dn(e){return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function fn({navigate:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(`50`),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``);async function v(e=!1){let n=r.trim();m(!0),_(``);let i=new URLSearchParams({limit:a});t.trim()&&i.set(`min_level`,t.trim()),n&&i.set(`q`,n),e&&d&&i.set(`before_id`,d);try{let t=await k.accountRatings(i),n=t.rows??[];c(t=>e?[...t,...n]:n),f(t.next_before_id??``),u(!!t.has_more)}catch(e){_(O(e))}finally{m(!1)}}(0,g.useEffect)(()=>{v(!1)},[]);let y=s.reduce((e,t)=>Math.max(e,t.Level),0),b=s.filter(e=>ut(e.PendingStars)!==0).length,x=s.length>0?(s.reduce((e,t)=>e+t.Level,0)/s.length).toFixed(1):`0`;return(0,G.jsxs)(xt,{title:`Account rating leaderboard`,eyebrow:`Rating / Leaderboard`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>v(!1),disabled:p,children:[(0,G.jsx)(Le,{size:15,className:p?`spin`:``}),` `,`Refresh`]}),children:[h&&(0,G.jsx)(q,{children:h}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Loaded rows`,value:String(s.length)}),(0,G.jsx)(Y,{label:`Top level`,value:String(y),tone:`good`}),(0,G.jsx)(Y,{label:`Average level`,value:x}),(0,G.jsx)(Y,{label:`With pending points`,value:String(b),tone:b?`warn`:`neutral`})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),v(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search by username, name or user ID`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Min level`}),(0,G.jsx)(`input`,{className:`small-input`,value:t,onChange:e=>n(e.target.value),type:`number`,min:`0`,placeholder:`0`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:a,onChange:e=>o(e.target.value),type:`number`,min:`1`,max:`200`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:p,children:[p?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`User ID`}),(0,G.jsx)(`th`,{children:`Username`}),(0,G.jsx)(`th`,{children:`Level`}),(0,G.jsx)(`th`,{children:`Points`}),(0,G.jsx)(`th`,{children:`Progress to next level`}),(0,G.jsx)(`th`,{children:`Pending`}),(0,G.jsx)(`th`,{children:`Computed`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[s.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:t.UserID}),(0,G.jsx)(`td`,{children:U(t.Username)||t.FirstName||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsx)(pn,{level:t.Level})}),(0,G.jsx)(`td`,{className:`mono`,children:dt(t.Stars)}),(0,G.jsx)(`td`,{children:(0,G.jsx)(hn,{row:t})}),(0,G.jsx)(`td`,{className:`mono`,children:ut(t.PendingStars)===0?`-`:dt(t.PendingStars)}),(0,G.jsx)(`td`,{children:W(t.ComputedAt)||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/account-ratings/${t.UserID}`),children:[(0,G.jsx)(Ze,{size:14}),` `,`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.UserID)),s.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})}),l&&(0,G.jsx)(`div`,{className:`toolbar`,children:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>v(!0),disabled:p,children:[p?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(de,{size:15}),` `,`Load more`]})})]})}function pn({level:e}){return(0,G.jsx)(J,{tone:e>=10?`good`:e>=5?`warn`:`neutral`,children:`Level ${e}`})}function mn(e){let t=ut(e.Stars),n=ut(e.CurrentLevelStars),r=ut(e.NextLevelStars),i=r-n;return{percent:i>0?Math.min(100,Math.max(0,(t-n)/i*100)):0,remaining:Math.max(0,r-t),target:r,stars:t}}function hn({row:e}){if(!e.HasNextLevel)return(0,G.jsx)(`span`,{className:`progress-note`,children:`Max level reached`});let{percent:t,remaining:n,target:r}=mn(e);return(0,G.jsxs)(`div`,{className:`progress-cell`,children:[(0,G.jsx)(`div`,{className:`progress-bar`,role:`img`,"aria-label":`${Math.round(t)}%`,children:(0,G.jsx)(`span`,{style:{width:`${t}%`}})}),(0,G.jsx)(`small`,{children:`${dt(String(n))} left to reach ${dt(String(r))}`})]})}function gn({userID:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``);async function u(){s(!0),a(``);try{r(await k.accountRating(e))}catch(e){a(O(e))}finally{s(!1)}}if((0,g.useEffect)(()=>{u()},[e]),i&&!n)return(0,G.jsx)(q,{children:i});if(!n)return(0,G.jsx)(Dt,{label:o?`Loading account rating…`:`Waiting for data`});let d=n.rating,f=n.events??[],p=ut(d.PendingStars),m=mn(d),h=d.UserID||e;return(0,G.jsxs)(xt,{title:`Rating of ${U(d.Username)||d.FirstName||d.UserID}`,eyebrow:`Rating / Component breakdown`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/account-ratings`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:u,disabled:o,children:[(0,G.jsx)(Le,{size:15,className:o?`spin`:``}),` `,`Refresh`]})]}),children:[i&&(0,G.jsx)(q,{children:i}),(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:U(d.Username)||d.FirstName||`Unnamed bot`}),(0,G.jsxs)(`div`,{className:`entity-subtitle`,children:[`User ID`,`: `,d.UserID]})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(pn,{level:d.Level}),p!==0&&(0,G.jsx)(J,{tone:`warn`,children:`Pending ${vt(d.PendingStars)}`})]})]}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Points`,value:dt(d.Stars),mono:!0}),(0,G.jsx)(Y,{label:`Level`,value:String(d.Level),tone:`good`}),(0,G.jsx)(Y,{label:`Next level threshold`,value:d.HasNextLevel?dt(d.NextLevelStars):`Max level reached`,mono:d.HasNextLevel}),(0,G.jsx)(Y,{label:`Points to next level`,value:d.HasNextLevel?dt(String(m.remaining)):`-`,mono:!0,tone:d.HasNextLevel&&m.percent>=80?`good`:`neutral`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`How the rating adds up`,text:`Contribution of every source: stars, activity, moderation penalties and manual corrections.`}),(0,G.jsx)(_n,{rating:d}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Current level threshold`,value:dt(d.CurrentLevelStars),mono:!0}),(0,G.jsx)(X,{label:`Next level threshold`,value:d.HasNextLevel?dt(d.NextLevelStars):`Max level reached`,mono:d.HasNextLevel}),(0,G.jsx)(X,{label:`Computed`,value:W(d.ComputedAt)||`-`}),(0,G.jsx)(X,{label:`Updated`,value:W(d.UpdatedAt)||`-`})]}),(0,G.jsx)(`div`,{className:`progress-wide`,children:(0,G.jsx)(hn,{row:d})})]}),p!==0&&(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Pending points`,text:`Already earned, but counted towards the rating only on the date below.`}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Pending`,value:vt(d.PendingStars),mono:!0}),(0,G.jsx)(X,{label:`Applied on`,value:W(d.PendingDate)||`-`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Rating events`,text:`Every rating change with its source, actor and reason.`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Source`}),(0,G.jsx)(`th`,{children:`Change`}),(0,G.jsx)(`th`,{children:`Reason`}),(0,G.jsx)(`th`,{children:`Actor`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[f.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:e.ID}),(0,G.jsx)(`td`,{children:(0,G.jsx)(yn,{kind:e.Kind})}),(0,G.jsx)(`td`,{className:`mono`,children:vt(e.Amount)}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Reason||`-`}),(0,G.jsx)(`td`,{children:e.Actor||`-`}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)||`-`})]},e.ID)),f.length===0&&(0,G.jsx)(Et,{colSpan:6})]})]})})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Rating operations`}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/accounts/${d.UserID}`),children:[(0,G.jsx)(et,{size:15}),` `,`Open account`]}),(0,G.jsx)(`div`,{className:`action-stack`,children:(0,G.jsx)(Z,{label:`Recompute`,icon:(0,G.jsx)(ue,{size:15}),tone:`neutral`,path:`/api/actions/recompute-account-rating`,payload:()=>({user_id:h}),onDone:u})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Rebuilds the rating from stars, activity, penalties and manual corrections.`}),(0,G.jsx)(`div`,{className:`dock-title`,children:`Manual correction`}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Value (negative allowed)`}),(0,G.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),type:`number`,step:`1`,placeholder:`-500`})]}),(0,G.jsx)(`div`,{className:`action-stack`,children:(0,G.jsx)(Z,{label:`Apply correction`,icon:(0,G.jsx)(Ge,{size:15}),tone:`warn`,path:`/api/actions/adjust-account-rating`,payload:()=>({user_id:h,amount:String(Number.parseInt(c.trim()||`0`,10)||0)}),onDone:()=>{l(``),u()}})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The value is added to the manual component; a negative number lowers the rating.`})]})})]})}function _n({rating:e}){let t=[{key:`stars`,label:`Stars`,hint:`Purchased and received stars`,value:ut(e.StarsComponent)},{key:`activity`,label:`Activity`,hint:`Messages, sessions and long-term engagement`,value:ut(e.ActivityComponent)},{key:`penalty`,label:`Penalties`,hint:`Moderation decisions and restrictions`,value:-ut(e.PenaltyComponent)},{key:`manual`,label:`Manual corrections`,hint:`Adjustments made by admins`,value:ut(e.ManualComponent)}],n=Math.max(1,...t.map(e=>Math.abs(e.value))),r=Math.max(0,t.reduce((e,t)=>e+t.value,0)),i=ut(e.Stars),a=ut(e.PendingStars);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`breakdown-list`,children:[t.map(e=>{let t=Math.min(100,Math.abs(e.value)/n*100),r=e.value<0?`danger`:e.value>0?`good`:``;return(0,G.jsxs)(`div`,{className:`breakdown-row`,children:[(0,G.jsxs)(`div`,{className:`breakdown-label`,children:[(0,G.jsx)(`strong`,{children:e.label}),(0,G.jsx)(`small`,{children:e.hint})]}),(0,G.jsx)(`div`,{className:`progress-bar ${r}`,role:`img`,"aria-label":String(e.value),children:(0,G.jsx)(`span`,{style:{width:`${t}%`}})}),(0,G.jsx)(`div`,{className:`breakdown-value mono ${r}`,children:vt(String(e.value))})]},e.key)}),(0,G.jsxs)(`div`,{className:`breakdown-row total`,children:[(0,G.jsx)(`div`,{className:`breakdown-label`,children:(0,G.jsx)(`strong`,{children:`Total rating`})}),(0,G.jsx)(`div`,{className:`breakdown-value mono`,children:dt(e.Stars)})]})]}),a===0&&r!==i&&(0,G.jsx)(q,{children:`Components add up to ${dt(String(r))} while the stored rating is ${dt(e.Stars)}. Recompute to resolve the drift.`}),a!==0&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Components already include ${vt(e.PendingStars)} that reaches the score only on the date below.`})]})}var vn={stars:`Stars`,activity:`Activity`,moderation:`Moderation`,manual:`Manual`,recompute:`Recompute`};function yn({kind:e}){return(0,G.jsx)(J,{tone:e===`moderation`?`danger`:e===`manual`?`warn`:e===`recompute`?`neutral`:`good`,children:vn[e]})}var bn=[[`#FF885E`,`#FF516A`],[`#FFCD6A`,`#FFA85C`],[`#82B1FF`,`#665FFF`],[`#A0DE7E`,`#54CB68`],[`#53EDD6`,`#28C9B7`],[`#72D5FD`,`#2A9EF1`],[`#E0A2F3`,`#D669ED`]];function xn(e){return bn[Math.abs(e)%bn.length]}function Sn(e){let t=Array.from(e);return t.length>0?t[0]:``}function Cn(e,t,n){let r=`${e} ${t}`.trim().split(/\s+/).filter(Boolean),i=r.length>0?r:n?[n]:[];if(i.length===0)return`T`;let a=Sn(i[0]);return i.length>1&&(a+=Sn(i[i.length-1])),a.toUpperCase()}function wn({userID:e,firstName:t,lastName:n,username:r=``,size:i=34}){let[a,o]=(0,g.useState)(!1);if((0,g.useEffect)(()=>{o(!1)},[e]),a){let[a,o]=xn(e);return(0,G.jsx)(`div`,{className:`avatar-fallback`,style:{width:i,height:i,background:`linear-gradient(135deg, ${a}, ${o})`,fontSize:Math.round(i*.42)},children:Cn(t,n,r)})}return(0,G.jsx)(`img`,{className:`avatar-photo-img`,src:`/api/accounts/${e}/avatar`,alt:``,loading:`lazy`,style:{width:i,height:i},onError:()=>o(!0)})}function Tn(e){return e.reduce((e,t)=>(e.devices+=t.DeviceCount,e),{devices:0})}function En(e){return e.reduce((e,t)=>(t.Megagroup&&(e.megagroups+=1),t.Broadcast&&(e.broadcasts+=1),t.Verified&&(e.verified+=1),e),{megagroups:0,broadcasts:0,verified:0})}var Dn={beforeID:0,beforeActiveUS:0};function On({navigate:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(50),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)([]),[d,f]=(0,g.useState)(Dn),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``);async function v(e,t){m(!0),_(``);let n=new URLSearchParams({limit:String(r)});e.trim()&&n.set(`q`,e.trim()),(t.beforeID||t.beforeActiveUS)&&(n.set(`before_id`,String(t.beforeID)),n.set(`before_active_us`,String(t.beforeActiveUS)));try{let e=await k.accounts(n);return o(e),e}catch(e){return _(O(e)),null}finally{m(!1)}}async function y(){u([]),f(Dn),await v(t,Dn)}async function b(){if(!a?.has_more)return;let e={beforeID:a.next_before_id,beforeActiveUS:a.next_before_active_us};await v(t,e)&&(u(e=>[...e,d]),f(e))}async function x(){if(l.length===0)return;let e=l[l.length-1];await v(t,e)&&(u(e=>e.slice(0,-1)),f(e))}async function S(){try{c(await k.accountStats())}catch{}}(0,g.useEffect)(()=>{y(),S()},[]);let C=Tn(a?.rows??[]),w=l.length>0&&!p,T=!!a?.has_more&&!p;return(0,G.jsxs)(xt,{title:`Accounts`,eyebrow:a?.listing===!1?`Search results`:`Recently active accounts`,actions:(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>{y(),S()},disabled:p,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),children:[h&&(0,G.jsx)(q,{children:h}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Total users`,value:s?String(s.total):`…`}),(0,G.jsx)(Y,{label:`Online now`,value:s?String(s.online):`…`,tone:`good`}),(0,G.jsx)(Y,{label:`Online device records`,value:String(C.devices)})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`User ID / phone / username`})]}),(0,G.jsxs)(`label`,{className:`gift-page-size`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsxs)(`select`,{value:String(r),onChange:e=>i(Number(e.target.value)),children:[(0,G.jsx)(`option`,{value:`10`,children:`10`}),(0,G.jsx)(`option`,{value:`20`,children:`20`}),(0,G.jsx)(`option`,{value:`50`,children:`50`}),(0,G.jsx)(`option`,{value:`100`,children:`100`})]})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:p,children:[p?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>void x(),disabled:!w,children:[(0,G.jsx)(fe,{size:15}),` `,`Previous page`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>void b(),disabled:!T,children:[(0,G.jsx)(pe,{size:15}),` `,`Next page`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`avatar-col`}),(0,G.jsx)(`th`,{children:`User ID`}),(0,G.jsx)(`th`,{children:`Phone`}),(0,G.jsx)(`th`,{children:`Username`}),(0,G.jsx)(`th`,{children:`Name`}),(0,G.jsx)(`th`,{children:`Login email`}),(0,G.jsx)(`th`,{children:`Device`}),(0,G.jsx)(`th`,{children:`Last active`}),(0,G.jsx)(`th`,{children:`Premium`}),(0,G.jsx)(`th`,{children:`Verified`}),(0,G.jsx)(`th`,{children:`Frozen`}),(0,G.jsx)(`th`,{children:`Updated`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[a?.rows.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`avatar-col`,children:(0,G.jsx)(wn,{userID:t.ID,firstName:t.FirstName,lastName:t.LastName,username:t.Username})}),(0,G.jsx)(`td`,{className:`mono`,children:t.ID}),(0,G.jsx)(`td`,{children:it(t.Phone)}),(0,G.jsx)(`td`,{children:(0,G.jsx)(kt,{username:t.Username,collectibles:t.Collectibles})}),(0,G.jsx)(`td`,{children:at(t)}),(0,G.jsx)(`td`,{children:t.LoginEmail||(0,G.jsx)(`span`,{className:`muted-cell`,children:`None`})}),(0,G.jsx)(`td`,{children:t.DeviceCount}),(0,G.jsx)(`td`,{children:W(t.LastActiveAt)}),(0,G.jsx)(`td`,{children:t.PremiumUntil>0?(0,G.jsxs)(J,{tone:`good`,children:[`Premium`,` `,st(t.PremiumUntil)]}):(0,G.jsx)(J,{children:`None`})}),(0,G.jsxs)(`td`,{children:[t.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Not verified`}),` `,(0,G.jsx)(nn,{scam:t.Scam,fake:t.Fake})]}),(0,G.jsx)(`td`,{children:t.Frozen?(0,G.jsx)(J,{tone:`danger`,children:`Frozen`}):(0,G.jsx)(J,{children:`Normal`})}),(0,G.jsx)(`td`,{children:W(t.UpdatedAt)}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/accounts/${t.ID}`),children:[`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),(!a||a.rows.length===0)&&(0,G.jsx)(Et,{colSpan:12})]})]})})]})}function kn({label:e,value:t,onChange:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(``);async function d(){c(!0),u(``);let e=new URLSearchParams({limit:`20`});r.trim()&&e.set(`q`,r.trim());try{o((await k.accounts(e)).rows)}catch(e){u(O(e))}finally{c(!1)}}return(0,g.useEffect)(()=>{d()},[]),(0,G.jsxs)(`div`,{className:`entity-picker`,children:[(0,G.jsxs)(`div`,{className:`picker-head`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsxs)(`button`,{className:`link-button`,type:`button`,onClick:()=>n(null),children:[(0,G.jsx)(rt,{size:13}),` `,`Clear`]}):null]}),t?(0,G.jsxs)(`div`,{className:`selected-entity`,children:[(0,G.jsx)(z,{size:15}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:at(t)}),(0,G.jsx)(`span`,{className:`mono`,children:t.ID})]}),(0,G.jsx)(`span`,{children:U(t.Username)||it(t.Phone)||`-`})]}):null,(0,G.jsxs)(`div`,{className:`picker-search`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())},placeholder:`Search user_id / phone / username`}),(0,G.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:d,disabled:s,children:s?(0,G.jsx)(R,{size:14,className:`spin`}):`Search`})]}),l&&(0,G.jsx)(`div`,{className:`picker-error`,children:l}),(0,G.jsxs)(`div`,{className:`picker-results`,children:[a.map(e=>(0,G.jsxs)(`button`,{className:`picker-row ${t?.ID===e.ID?`selected`:``}`,type:`button`,onClick:()=>n(e),children:[(0,G.jsx)(`span`,{className:`mono`,children:e.ID}),(0,G.jsx)(`strong`,{children:at(e)}),(0,G.jsx)(`span`,{children:U(e.Username)||it(e.Phone)||`-`}),e.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Regular`})]},e.ID)),a.length===0&&!s?(0,G.jsx)(`div`,{className:`picker-empty`,children:`No results`}):null]})]})}function An({label:e,value:t,onChange:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(``);async function d(){c(!0),u(``);let e=new URLSearchParams({limit:`20`});r.trim()&&e.set(`q`,r.trim().replace(/^@/,``));try{o((await k.bots(e)).rows??[])}catch(e){u(O(e))}finally{c(!1)}}return(0,g.useEffect)(()=>{d()},[]),(0,G.jsxs)(`div`,{className:`entity-picker`,children:[(0,G.jsxs)(`div`,{className:`picker-head`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsxs)(`button`,{className:`link-button`,type:`button`,onClick:()=>n(null),children:[(0,G.jsx)(rt,{size:13}),` `,`Clear`]}):null]}),t?(0,G.jsxs)(`div`,{className:`selected-entity`,children:[(0,G.jsx)(z,{size:15}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:t.FirstName||`-`}),(0,G.jsx)(`span`,{className:`mono`,children:t.ID})]}),(0,G.jsx)(`span`,{children:U(t.Username)||`-`})]}):null,(0,G.jsxs)(`div`,{className:`picker-search`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())},placeholder:`Bot username or id`}),(0,G.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:d,disabled:s,children:s?(0,G.jsx)(R,{size:14,className:`spin`}):`Search`})]}),l&&(0,G.jsx)(`div`,{className:`picker-error`,children:l}),(0,G.jsxs)(`div`,{className:`picker-results`,children:[a.map(e=>(0,G.jsxs)(`button`,{className:`picker-row ${t?.ID===e.ID?`selected`:``}`,type:`button`,onClick:()=>n(e),children:[(0,G.jsx)(`span`,{className:`mono`,children:e.ID}),(0,G.jsx)(`strong`,{children:e.FirstName||`-`}),(0,G.jsx)(`span`,{children:U(e.Username)||`-`}),e.System?(0,G.jsx)(J,{tone:`warn`,children:`System`}):(0,G.jsx)(J,{children:`Regular`})]},e.ID)),a.length===0&&!s?(0,G.jsx)(`div`,{className:`picker-empty`,children:`No results`}):null]})]})}function jn({label:e,value:t,onChange:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(``);async function d(){c(!0),u(``);let e=new URLSearchParams({limit:`20`});r.trim()&&e.set(`q`,r.trim());try{o((await k.channels(e)).rows)}catch(e){u(O(e))}finally{c(!1)}}return(0,g.useEffect)(()=>{d()},[]),(0,G.jsxs)(`div`,{className:`entity-picker`,children:[(0,G.jsxs)(`div`,{className:`picker-head`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsxs)(`button`,{className:`link-button`,type:`button`,onClick:()=>n(null),children:[(0,G.jsx)(rt,{size:13}),` `,`Clear`]}):null]}),t?(0,G.jsxs)(`div`,{className:`selected-entity`,children:[(0,G.jsx)(z,{size:15}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:t.Title||`-`}),(0,G.jsx)(`span`,{className:`mono`,children:t.ID})]}),(0,G.jsx)(`span`,{children:U(t.Username)||ot(t)})]}):null,(0,G.jsxs)(`div`,{className:`picker-search`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())},placeholder:`Search channel_id / username / title`}),(0,G.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:d,disabled:s,children:s?(0,G.jsx)(R,{size:14,className:`spin`}):`Search`})]}),l&&(0,G.jsx)(`div`,{className:`picker-error`,children:l}),(0,G.jsxs)(`div`,{className:`picker-results`,children:[a.map(e=>(0,G.jsxs)(`button`,{className:`picker-row ${t?.ID===e.ID?`selected`:``}`,type:`button`,onClick:()=>n(e),children:[(0,G.jsx)(`span`,{className:`mono`,children:e.ID}),(0,G.jsx)(`strong`,{children:e.Title||`-`}),(0,G.jsx)(`span`,{children:U(e.Username)||ot(e)}),e.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:ot(e)})]},e.ID)),a.length===0&&!s?(0,G.jsx)(`div`,{className:`picker-empty`,children:`No results`}):null]})]})}function Mn({navigate:e}){let[t,n]=(0,g.useState)(`all`),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(`50`),[s,c]=(0,g.useState)([]),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(`vault`),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(null),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(`XTR`),[A,j]=(0,g.useState)(``),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(``),[I,L]=(0,g.useState)(``),[ee,te]=(0,g.useState)(``),[ne,re]=(0,g.useState)(``);async function ie(e=!1){m(!0),_(``);let n=new URLSearchParams({limit:a});t!==`all`&&n.set(`status`,t),r.trim()&&n.set(`q`,r.trim().replace(/^@/,``)),e&&d&&n.set(`before_id`,d);try{let t=await k.collectibleUsernames(n),r=t.rows??[];c(t=>e?[...t,...r]:r),f(t.next_before_id??``),u(!!t.has_more)}catch(e){_(O(e))}finally{m(!1)}}(0,g.useEffect)(()=>{ie(!1)},[]);let oe=s.filter(e=>e.Status===`vault`).length,se=s.filter(e=>e.Status===`owned`).length,ce=s.filter(e=>e.Status===`burned`).length,le=_t(A,E),ue=M?_t(P,M):`0`,z=le===null,fe=ue===null;function me(){let e={username:w.trim().replace(/^@/,``),currency:E,amount:le??`0`};if(v===`user`&&b&&(e.owner_user_id=String(b.ID)),v===`channel`&&S&&(e.owner_channel_id=String(S.ID)),M&&(e.crypto_currency=M,e.crypto_amount=ue??`0`),I.trim()&&(e.url=I.trim()),ee){let t=Date.parse(`${ee}T${ne||`00:00`}:00Z`);Number.isFinite(t)&&(e.purchase_date=Math.floor(t/1e3))}return e}return(0,G.jsxs)(xt,{title:`Collectible usernames`,eyebrow:`NFT usernames / Registry`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>ie(!1),disabled:p,children:[(0,G.jsx)(Le,{size:15,className:p?`spin`:``}),` `,`Refresh`]}),children:[h&&(0,G.jsx)(q,{children:h}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Loaded rows`,value:String(s.length)}),(0,G.jsx)(Y,{label:`In vault`,value:String(oe)}),(0,G.jsx)(Y,{label:`Held by owners`,value:String(se),tone:`good`}),(0,G.jsx)(Y,{label:`Burned`,value:String(ce),tone:ce?`danger`:`neutral`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Mint a collectible username`,text:`Creates the asset together with its purchase record. Keep the owner as vault to mint it unassigned.`}),(0,G.jsxs)(`div`,{className:`toolbar`,role:`group`,"aria-label":`Owner type`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn ${v===`vault`?`primary`:``}`,onClick:()=>y(`vault`),children:[(0,G.jsx)(nt,{size:15}),` `,`Vault (no owner)`]}),(0,G.jsx)(`button`,{type:`button`,className:`btn ${v===`user`?`primary`:``}`,onClick:()=>y(`user`),children:`User owner`}),(0,G.jsx)(`button`,{type:`button`,className:`btn ${v===`channel`?`primary`:``}`,onClick:()=>y(`channel`),children:`Channel owner`})]}),v===`user`&&(0,G.jsx)(kn,{label:`User owner`,value:b,onChange:x}),v===`channel`&&(0,G.jsx)(jn,{label:`Channel owner`,value:S,onChange:C}),(0,G.jsxs)(`div`,{className:`bot-create-fields`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Username`}),(0,G.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`durov`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Currency`}),(0,G.jsxs)(`select`,{value:E,onChange:e=>D(e.target.value),children:[(0,G.jsx)(`option`,{value:`XTR`,children:`XTR`}),(0,G.jsx)(`option`,{value:`TON`,children:`TON`}),(0,G.jsx)(`option`,{value:`USD`,children:`USD`})]})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Amount (${E})`}),(0,G.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),inputMode:`decimal`,placeholder:`1000`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Crypto currency`}),(0,G.jsxs)(`select`,{value:M,onChange:e=>N(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`None`}),(0,G.jsx)(`option`,{value:`TON`,children:`TON`})]})]}),M!==``&&(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Crypto amount (${M})`}),(0,G.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),inputMode:`decimal`,placeholder:`12.5`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Marketplace URL`}),(0,G.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),placeholder:`https://fragment.com/username/durov`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Purchase date (UTC)`}),(0,G.jsx)(`input`,{value:ee,onChange:e=>te(e.target.value),type:`date`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Purchase time (UTC)`}),(0,G.jsx)(`input`,{value:ne,onChange:e=>re(e.target.value),type:`time`,step:60,disabled:!ee})]})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Amounts are typed in whole ${E} and stored as the smallest units the API and fragment.collectibleInfo carry, so clients render the price you meant. Up to ${String(pt(E))} decimal places. Clients will show: ${gt(le??`0`,E)}.`}),z&&(0,G.jsx)(q,{children:`That is not a valid ${E} amount: digits only, with at most ${String(pt(E))} decimal places.`}),M!==``&&fe&&(0,G.jsx)(q,{children:`That is not a valid ${M} amount: digits only, with at most ${String(pt(M))} decimal places.`}),(0,G.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,G.jsx)(`span`,{className:`bot-create-note`,children:`Username, currency and amount are required; the dry-run checks availability first.`}),(0,G.jsx)(Z,{disabled:z||fe,label:`Mint username`,icon:(0,G.jsx)(Pe,{size:15}),tone:`neutral`,path:`/api/actions/mint-collectible-username`,payload:me,onDone:()=>ie(!1)})]})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),ie(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search by username`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,G.jsx)(`option`,{value:`vault`,children:`Vault`}),(0,G.jsx)(`option`,{value:`owned`,children:`Owned`}),(0,G.jsx)(`option`,{value:`burned`,children:`Burned`})]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:a,onChange:e=>o(e.target.value),type:`number`,min:`1`,max:`200`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:p,children:[p?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Username`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Owner`}),(0,G.jsx)(`th`,{children:`Price`}),(0,G.jsx)(`th`,{children:`Purchase date (UTC)`}),(0,G.jsx)(`th`,{children:`Transfers`}),(0,G.jsx)(`th`,{children:`Updated`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[s.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`strong`,{children:U(t.Username)})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(Nn,{status:t.Status})}),(0,G.jsx)(`td`,{children:Pn(t,`Vault`)}),(0,G.jsx)(`td`,{className:`mono`,children:Fn(t)}),(0,G.jsx)(`td`,{children:W(t.PurchaseDate)||`-`}),(0,G.jsx)(`td`,{className:`mono`,children:t.TransferCount}),(0,G.jsx)(`td`,{children:W(t.UpdatedAt)||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/collectible-usernames/${t.ID}`),children:[(0,G.jsx)(ae,{size:14}),` `,`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),s.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})}),l&&(0,G.jsx)(`div`,{className:`toolbar`,children:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>ie(!0),disabled:p,children:[p?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(de,{size:15}),` `,`Load more`]})})]})}function Nn({status:e}){return e===`owned`?(0,G.jsx)(J,{tone:`good`,children:`Owned`}):e===`burned`?(0,G.jsxs)(J,{tone:`danger`,children:[(0,G.jsx)(be,{size:12}),` `,`Burned`]}):(0,G.jsxs)(J,{children:[(0,G.jsx)(nt,{size:12}),` `,`Vault`]})}function Pn(e,t){return!e.OwnerPeerType||e.OwnerPeerID===``||e.OwnerPeerID===`0`?t:`${U(e.OwnerUsername)||e.OwnerName||e.OwnerPeerID} · ${e.OwnerPeerType}:${e.OwnerPeerID}`}function Fn(e){let t=gt(e.Amount,e.Currency);return e.CryptoCurrency&&e.CryptoAmount&&e.CryptoAmount!==`0`?`${t} (${gt(e.CryptoAmount,e.CryptoCurrency)})`:t}function In({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(`user`),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(null);async function m(){s(!0),a(``);try{r(await k.collectibleUsername(e))}catch(e){a(O(e))}finally{s(!1)}}if((0,g.useEffect)(()=>{m()},[e]),i&&!n)return(0,G.jsx)(q,{children:i});if(!n)return(0,G.jsx)(Dt,{label:o?`Loading collectible username…`:`Waiting for data`});let h=n.asset,_=n.transfers??[],v=`Vault`,y=!!h.OwnerPeerType&&h.OwnerPeerID!==``&&h.OwnerPeerID!==`0`,b=h.Status===`burned`;function x(){y&&t(h.OwnerPeerType===`channel`?`/channels/${h.OwnerPeerID}`:`/accounts/${h.OwnerPeerID}`)}function S(){let e={username:h.Username};return c===`user`&&u&&(e.to_user_id=String(u.ID)),c===`channel`&&f&&(e.to_channel_id=String(f.ID)),e}return(0,G.jsxs)(xt,{title:`Collectible ${U(h.Username)}`,eyebrow:`NFT usernames / Asset`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/collectible-usernames`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:m,disabled:o,children:[(0,G.jsx)(Le,{size:15,className:o?`spin`:``}),` `,`Refresh`]})]}),children:[i&&(0,G.jsx)(q,{children:i}),(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:U(h.Username)}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:`Asset #${h.ID}`})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(Nn,{status:h.Status}),(0,G.jsx)(J,{tone:h.TransferCount>0?`warn`:`neutral`,children:`${h.TransferCount} transfers`}),h.Status===`owned`&&(0,G.jsx)(J,{tone:h.RegistryActive?`good`:`warn`,children:h.RegistryActive?`Active in profile`:`Hidden in profile`})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Owner`,value:Pn(h,v)}),(0,G.jsx)(X,{label:`Price`,value:Fn(h),mono:!0}),(0,G.jsx)(X,{label:`Purchase date (UTC)`,value:W(h.PurchaseDate)||`-`}),(0,G.jsx)(X,{label:`Original owner`,value:zn(h.OriginalOwnerPeerType,h.OriginalOwnerPeerID,v,h.OriginalOwnerUsername)}),(0,G.jsx)(X,{label:`Transfers`,value:String(h.TransferCount),mono:!0}),(0,G.jsx)(X,{label:`Created`,value:W(h.CreatedAt)||`-`}),(0,G.jsx)(X,{label:`Updated`,value:W(h.UpdatedAt)||`-`})]}),(0,G.jsxs)(`div`,{className:`toolbar`,children:[y&&(0,G.jsx)(`button`,{className:`row-link`,type:`button`,onClick:x,children:h.OwnerPeerType===`channel`?`Open owner channel`:`Open owner account`}),h.URL&&(0,G.jsxs)(`a`,{className:`row-link`,href:h.URL,target:`_blank`,rel:`noreferrer noopener`,children:[(0,G.jsx)(ge,{size:14}),` `,`Open marketplace page`]})]}),!b&&(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Transfer ownership`,text:`Pick the recipient; the transfer is appended to the provenance history.`}),(0,G.jsxs)(`div`,{className:`toolbar`,role:`group`,"aria-label":`Recipient type`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn ${c===`user`?`primary`:``}`,onClick:()=>l(`user`),children:`To user`}),(0,G.jsx)(`button`,{type:`button`,className:`btn ${c===`channel`?`primary`:``}`,onClick:()=>l(`channel`),children:`To channel`})]}),c===`user`?(0,G.jsx)(kn,{label:`To user`,value:u,onChange:d}):(0,G.jsx)(jn,{label:`To channel`,value:f,onChange:p}),(0,G.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,G.jsx)(`span`,{className:`bot-create-note`,children:`The current owner loses the username immediately after confirmation.`}),(0,G.jsx)(Z,{label:`Transfer`,icon:(0,G.jsx)(re,{size:15}),tone:`warn`,path:`/api/actions/transfer-collectible-username`,payload:S,onDone:m})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Provenance history`,text:`Mint, transfer, revoke and burn events in chronological order.`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Event`}),(0,G.jsx)(`th`,{children:`From`}),(0,G.jsx)(`th`,{children:`To`}),(0,G.jsx)(`th`,{children:`Price`}),(0,G.jsx)(`th`,{children:`Actor`}),(0,G.jsx)(`th`,{children:`Reason`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[_.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:e.ID}),(0,G.jsx)(`td`,{children:(0,G.jsx)(Rn,{kind:e.Kind})}),(0,G.jsx)(`td`,{className:`mono`,children:zn(e.FromPeerType,e.FromPeerID,v,e.FromUsername)}),(0,G.jsx)(`td`,{className:`mono`,children:zn(e.ToPeerType,e.ToPeerID,v,e.ToUsername)}),(0,G.jsx)(`td`,{className:`mono`,children:e.Amount&&e.Amount!==`0`?gt(e.Amount,e.Currency):`-`}),(0,G.jsx)(`td`,{children:e.Actor||`-`}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Reason||`-`}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)||`-`})]},e.ID)),_.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Asset operations`}),b?(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This username is burned — no further operations are possible.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`action-stack`,children:(0,G.jsx)(Z,{label:`Revoke to vault`,icon:(0,G.jsx)(Qe,{size:15}),tone:`warn`,path:`/api/actions/revoke-collectible-username`,payload:()=>({username:h.Username,burn:!1}),onDone:m})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Takes the username away from its owner and returns it to the vault; it can be issued again later.`}),(0,G.jsxs)(`div`,{className:`danger-zone`,children:[(0,G.jsx)(Z,{label:`Burn permanently`,icon:(0,G.jsx)(be,{size:15}),tone:`danger`,path:`/api/actions/revoke-collectible-username`,payload:()=>({username:h.Username,burn:!0}),onDone:m}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Irreversible: the username is destroyed and can never be issued again.`}),(0,G.jsx)(Z,{label:`Delete record`,icon:(0,G.jsx)(H,{size:15}),tone:`danger`,path:`/api/actions/delete-collectible-username`,payload:()=>({username:h.Username}),onDone:()=>t(`/collectible-usernames`)}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Erases the asset and its ownership history, and frees the username for a fresh issue. Use this for a username issued by mistake; a burn keeps the history instead.`})]})]})]})})]})}var Ln={mint:`Mint`,transfer:`Transfer`,burn:`Burn`,revoke:`Revoke`};function Rn({kind:e}){return(0,G.jsx)(J,{tone:e===`burn`?`danger`:e===`revoke`?`warn`:e===`mint`?`good`:`neutral`,children:Ln[e]})}function zn(e,t,n,r=``){if(!e||t===``||t===`0`)return n;let i=U(r);return i?`${i} · ${e}:${t}`:`${e}:${t}`}function Bn({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``);async function o(){a(``);try{r(await k.channel(e))}catch(e){a(O(e))}}if((0,g.useEffect)(()=>{o()},[e]),i)return(0,G.jsx)(q,{children:i});if(!n)return(0,G.jsx)(Dt,{label:`Loading channel detail`});let s=n.Channel;return(0,G.jsx)(xt,{title:`${ot(s)} #${s.ID}`,eyebrow:`Channel Profile`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/channels`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),children:(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:s.Title||`-`}),(0,G.jsxs)(`div`,{className:`entity-subtitle`,children:[U(s.Username)||`No username`,` · `,`Creator ${s.CreatorUserID}`]})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(J,{children:ot(s)}),s.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Not verified`}),(0,G.jsx)(nn,{scam:s.Scam,fake:s.Fake}),s.Deleted?(0,G.jsx)(J,{tone:`danger`,children:`Deleted`}):(0,G.jsx)(J,{children:`Valid`})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Channel ID`,value:String(s.ID),mono:!0}),(0,G.jsx)(X,{label:`access_hash`,value:String(s.AccessHash),mono:!0}),(0,G.jsx)(X,{label:`Members`,value:`${s.ParticipantsCount} / Admins ${s.AdminsCount}`}),(0,G.jsx)(X,{label:`Moderation`,value:`Banned ${s.BannedCount} / Kicked ${s.KickedCount}`}),(0,G.jsx)(X,{label:`Channel flags`,value:`broadcast=${s.Broadcast} megagroup=${s.Megagroup} forum=${s.Forum}`}),(0,G.jsx)(X,{label:`top / pinned / PTS`,value:`${s.TopMessageID} / ${s.PinnedMessageID} / ${s.PTS}`}),(0,G.jsx)(X,{label:`Created`,value:st(s.Date)||`-`}),(0,G.jsx)(X,{label:`Updated`,value:W(s.UpdatedAt)||`-`})]}),s.About&&(0,G.jsx)(`p`,{className:`about-text`,children:s.About}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Recent Admin Actions`,text:`Last 30 audit rows`}),(0,G.jsx)(Tt,{rows:n.AuditLogs})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Channel Raw Row`,text:`Database read-only snapshot`}),(0,G.jsx)(Ot,{value:n.ChannelJSON})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Channel Actions`}),(0,G.jsx)(Z,{label:s.Verified?`Clear verified`:`Set verified`,icon:(0,G.jsx)(F,{size:15}),tone:`warn`,path:`/api/actions/set-channel-verified`,payload:()=>({channel_id:s.ID,verified:!s.Verified}),onDone:o}),(0,G.jsx)(rn,{idKey:`channel_id`,id:s.ID,path:`/api/actions/set-channel-flags`,scam:s.Scam,fake:s.Fake,onDone:o}),(0,G.jsx)(`div`,{className:`dock-title`,children:`Settings`}),(0,G.jsx)(ln,{channel:s,onDone:o}),(0,G.jsx)(`div`,{className:`dock-title`,children:`Attributes`}),(0,G.jsx)(on,{idKey:`channel_id`,id:s.ID,path:`/api/actions/set-channel-username`,current:s.Username,onDone:o}),(0,G.jsx)(sn,{idKey:`channel_id`,id:s.ID,path:`/api/actions/set-channel-color`,onDone:o}),(0,G.jsx)(cn,{idKey:`channel_id`,id:s.ID,path:`/api/actions/set-channel-emoji-status`,onDone:o})]})})})}function Vn({navigate:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(`50`),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)({beforeID:0,beforeUpdatedUS:0}),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``);async function p(e=!1){u(!0),f(``);let n=new URLSearchParams({limit:r});t.trim()?n.set(`q`,t.trim()):e&&(n.set(`before_id`,String(s.beforeID)),n.set(`before_updated_us`,String(s.beforeUpdatedUS)));try{let e=await k.channels(n);o(e),c({beforeID:e.next_before_id,beforeUpdatedUS:e.next_before_updated_us})}catch(e){f(O(e))}finally{u(!1)}}(0,g.useEffect)(()=>{p(!1)},[]);let m=En(a?.rows??[]);return(0,G.jsxs)(xt,{title:`Supergroups and Channels`,eyebrow:a?.listing===!1?`Search results`:`Recently updated`,actions:(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>p(!1),disabled:l,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),children:[d&&(0,G.jsx)(q,{children:d}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Entities on page`,value:String(a?.rows.length??0)}),(0,G.jsx)(Y,{label:`Supergroups`,value:String(m.megagroups)}),(0,G.jsx)(Y,{label:`Channels`,value:String(m.broadcasts)}),(0,G.jsx)(Y,{label:`Verified`,value:String(m.verified),tone:`good`})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),p(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Channel ID / username / title`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:r,onChange:e=>i(e.target.value),type:`number`,min:`1`,max:`100`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:l,children:[l?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]}),a?.listing&&a.has_more&&(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>p(!0),disabled:l,children:[(0,G.jsx)(pe,{size:15}),` `,`Next page`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Channel ID`}),(0,G.jsx)(`th`,{children:`Kind`}),(0,G.jsx)(`th`,{children:`Username`}),(0,G.jsx)(`th`,{children:`Title`}),(0,G.jsx)(`th`,{children:`Members`}),(0,G.jsx)(`th`,{children:`Admins`}),(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Verified`}),(0,G.jsx)(`th`,{children:`Updated`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[a?.rows.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:t.ID}),(0,G.jsx)(`td`,{children:ot(t)}),(0,G.jsx)(`td`,{children:U(t.Username)}),(0,G.jsx)(`td`,{children:t.Title}),(0,G.jsx)(`td`,{children:t.ParticipantsCount}),(0,G.jsx)(`td`,{children:t.AdminsCount}),(0,G.jsx)(`td`,{children:t.PTS}),(0,G.jsxs)(`td`,{children:[t.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Not verified`}),` `,(0,G.jsx)(nn,{scam:t.Scam,fake:t.Fake})]}),(0,G.jsx)(`td`,{children:W(t.UpdatedAt)}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/channels/${t.ID}`),children:[`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),(!a||a.rows.length===0)&&(0,G.jsx)(Et,{colSpan:10})]})]})})]})}function Hn({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1);async function c(){s(!0),a(``);try{r(await k.bot(e))}catch(e){a(O(e))}finally{s(!1)}}if((0,g.useEffect)(()=>{c()},[e]),i)return(0,G.jsx)(q,{children:i});if(!n)return(0,G.jsx)(Dt,{label:o?`Loading bot detail`:`Waiting for data`});let l=n.Bot;return(0,G.jsx)(xt,{title:`Bot #${l.ID}`,eyebrow:`Bot Profile`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/bots`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),children:(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:l.FirstName||`Unnamed bot`}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:U(l.Username)||`No username`})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(J,{tone:l.System?`warn`:`neutral`,children:l.System?`System`:`User`}),l.Verified?(0,G.jsx)(J,{tone:`good`,children:`Verified`}):(0,G.jsx)(J,{children:`Not verified`}),(0,G.jsx)(nn,{scam:l.Scam,fake:l.Fake})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Bot ID`,value:String(l.ID),mono:!0}),(0,G.jsx)(X,{label:`Owner`,value:l.OwnerUserID>0?`${l.OwnerUserID} ${U(n.OwnerUsername)}`.trim():`None`}),(0,G.jsx)(X,{label:`Type`,value:l.System?`System`:`User`}),(0,G.jsx)(X,{label:`Updated`,value:W(l.UpdatedAt)||`-`}),(0,G.jsx)(X,{label:`Created`,value:W(l.CreatedAt)||`-`})]}),n.About&&(0,G.jsx)(`p`,{className:`about-text`,children:n.About}),n.Description&&n.Description.trim()!==n.About.trim()&&(0,G.jsx)(`p`,{className:`about-text`,children:n.Description}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Recent Admin Actions`,text:`Last 30 audit rows`}),(0,G.jsx)(Tt,{rows:n.AuditLogs})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Bot Actions`}),(0,G.jsx)(`div`,{className:`action-stack`,children:(0,G.jsx)(Z,{label:l.Verified?`Clear verified`:`Set verified`,icon:(0,G.jsx)(F,{size:15}),tone:`neutral`,path:`/api/actions/set-verified`,payload:()=>({user_id:l.ID,verified:!l.Verified}),onDone:c})}),(0,G.jsx)(rn,{idKey:`user_id`,id:l.ID,path:`/api/actions/set-account-flags`,scam:l.Scam,fake:l.Fake,onDone:c}),(0,G.jsx)(`div`,{className:`dock-title`,children:`Attributes`}),(0,G.jsx)(on,{idKey:`user_id`,id:l.ID,path:`/api/actions/set-account-username`,current:l.Username,onDone:c}),(0,G.jsx)(sn,{idKey:`user_id`,id:l.ID,path:`/api/actions/set-account-color`,onDone:c}),(0,G.jsx)(cn,{idKey:`user_id`,id:l.ID,path:`/api/actions/set-account-emoji-status`,onDone:c}),l.System?(0,G.jsx)(`p`,{className:`bot-create-note`,children:`System bots are built in and cannot be deleted.`}):(0,G.jsxs)(`div`,{className:`danger-zone`,children:[(0,G.jsx)(Z,{label:`Delete bot`,icon:(0,G.jsx)(H,{size:15}),tone:`danger`,path:`/api/actions/delete-bot`,payload:()=>({bot_user_id:l.ID}),onDone:()=>t(`/bots`)}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Permanently deletes this user-created bot and invalidates its token. This cannot be undone.`})]})]})})})}function Un({navigate:e}){let[t,n]=(0,g.useState)(``),[r,i]=(0,g.useState)(`50`),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(0),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``);async function b(e=!1){u(!0),f(``);let n=new URLSearchParams({limit:r});t.trim()?n.set(`q`,t.trim()):e&&n.set(`before_id`,String(s));try{let e=await k.bots(n);o(e),c(e.next_before_id)}catch(e){f(O(e))}finally{u(!1)}}(0,g.useEffect)(()=>{b(!1)},[]);let x=a?.rows??[],S=x.filter(e=>e.Verified).length,C=x.filter(e=>e.System).length;return(0,G.jsxs)(xt,{title:`Bots`,eyebrow:a?.listing===!1?`Search results`:`Recently created bots`,actions:(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>b(!1),disabled:l,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),children:[d&&(0,G.jsx)(q,{children:d}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Bots on page`,value:String(x.length)}),(0,G.jsx)(Y,{label:`Verified`,value:String(S),tone:`good`}),(0,G.jsx)(Y,{label:`System`,value:String(C)})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(`div`,{className:`section-head`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{children:`Create a system bot`}),(0,G.jsx)(`p`,{children:`Provision a bot account owned by the given user. The token is shown once after confirmation.`})]})}),(0,G.jsxs)(`div`,{className:`bot-create-fields`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Owner user ID`}),(0,G.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),type:`number`,min:`1`,placeholder:`123456789`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Display name`}),(0,G.jsx)(`input`,{value:h,onChange:e=>_(e.target.value),placeholder:`e.g. Service Bot`,maxLength:64})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Username`}),(0,G.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`my_service_bot`})]})]}),(0,G.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,G.jsx)(`span`,{className:`bot-create-note`,children:`Username must be 5-32 characters and end with 'bot'.`}),(0,G.jsx)(Z,{label:`Create bot`,icon:(0,G.jsx)(Pe,{size:15}),tone:`neutral`,path:`/api/actions/create-bot`,payload:()=>({owner_user_id:lt(p),name:h.trim(),username:v.trim().replace(/^@/,``)}),onDone:()=>b(!1)})]})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),b(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Bot ID / username`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:r,onChange:e=>i(e.target.value),type:`number`,min:`1`,max:`100`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:l,children:[l?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]}),a?.listing&&a.has_more&&(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>b(!0),disabled:l,children:[(0,G.jsx)(pe,{size:15}),` `,`Next page`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Bot ID`}),(0,G.jsx)(`th`,{children:`Username`}),(0,G.jsx)(`th`,{children:`Name`}),(0,G.jsx)(`th`,{children:`Owner`}),(0,G.jsx)(`th`,{children:`Verified`}),(0,G.jsx)(`th`,{children:`Type`}),(0,G.jsx)(`th`,{children:`Created`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[x.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:t.ID}),(0,G.jsx)(`td`,{children:U(t.Username)||`-`}),(0,G.jsx)(`td`,{children:t.FirstName||`-`}),(0,G.jsx)(`td`,{className:`mono`,children:t.OwnerUserID>0?t.OwnerUserID:`-`}),(0,G.jsxs)(`td`,{children:[t.Verified?(0,G.jsxs)(J,{tone:`good`,children:[(0,G.jsx)(F,{size:12}),` `,`Verified`]}):(0,G.jsx)(J,{children:`Not verified`}),` `,(0,G.jsx)(nn,{scam:t.Scam,fake:t.Fake})]}),(0,G.jsx)(`td`,{children:t.System?(0,G.jsx)(J,{tone:`warn`,children:`System`}):(0,G.jsx)(J,{children:`User`})}),(0,G.jsx)(`td`,{children:W(t.CreatedAt)}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/bots/${t.ID}`),children:[(0,G.jsx)(se,{size:14}),` `,`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),x.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})})]})}function Wn({navigate:e}){return(0,G.jsxs)(`div`,{className:`dashboard-layout`,children:[(0,G.jsxs)(`section`,{className:`overview-band`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Runtime Overview`}),(0,G.jsx)(`h2`,{children:`Console Overview`})]}),(0,G.jsxs)(`div`,{className:`overview-metrics`,children:[(0,G.jsx)(wt,{label:`Read path`,value:`PG read-only`,tone:`neutral`}),(0,G.jsx)(wt,{label:`Write path`,value:`Admin API`,tone:`good`}),(0,G.jsx)(wt,{label:`Execution policy`,value:`Dry-run first`,tone:`warn`})]})]}),(0,G.jsxs)(`div`,{className:`command-grid`,children:[(0,G.jsx)(Gn,{icon:(0,G.jsx)(tt,{}),title:`Accounts`,text:`Account status, premium, verification, sessions.`,href:`/accounts`,navigate:e}),(0,G.jsx)(Gn,{icon:(0,G.jsx)(Ue,{}),title:`Supergroups and Channels`,text:`Public entities, member counts, verification state.`,href:`/channels`,navigate:e}),(0,G.jsx)(Gn,{icon:(0,G.jsx)(ke,{}),title:`Message Audit`,text:`Message boxes, updates, outbox state.`,href:`/messages`,navigate:e})]}),(0,G.jsxs)(`section`,{className:`work-strip`,children:[(0,G.jsxs)(`div`,{className:`strip-item`,children:[(0,G.jsx)(L,{size:16}),(0,G.jsx)(`span`,{children:`All dangerous actions start with dry-run`})]}),(0,G.jsxs)(`div`,{className:`strip-item`,children:[(0,G.jsx)(Te,{size:16}),(0,G.jsx)(`span`,{children:`Browser never stores internal tokens`})]}),(0,G.jsxs)(`div`,{className:`strip-item`,children:[(0,G.jsx)(me,{size:16}),(0,G.jsx)(`span`,{children:`Lists use cursor pagination`})]}),(0,G.jsxs)(`div`,{className:`strip-item`,children:[(0,G.jsx)(ye,{size:16}),(0,G.jsx)(`span`,{children:`Detail pages retain raw state snapshots`})]})]})]})}function Gn({icon:e,title:t,text:n,href:r,navigate:i}){return(0,G.jsxs)(Yt,{className:`launcher`,href:r,navigate:i,children:[(0,G.jsx)(`span`,{className:`launcher-icon`,children:e}),(0,G.jsxs)(`span`,{className:`launcher-copy`,children:[(0,G.jsx)(`strong`,{children:t}),(0,G.jsx)(`span`,{children:n})]}),(0,G.jsx)(pe,{size:16})]})}function Kn({channelID:e,msgID:t,navigate:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``);async function s(){o(``);try{i(await k.groupMessage(e,t))}catch(e){o(O(e))}}if((0,g.useEffect)(()=>{s()},[e,t]),a)return(0,G.jsx)(q,{children:a});if(!r)return(0,G.jsx)(Dt,{label:`Loading`});let c=r.Message;return(0,G.jsx)(xt,{title:`Group Message #${c.ID}`,eyebrow:`Message Detail`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>n(`/messages/groups`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to group messages`]}),children:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:`Channel / Group ${c.ChannelID}`}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:`Sender ${c.SenderUserID} · ${st(c.Date)}`})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[c.Deleted?(0,G.jsx)(J,{tone:`danger`,children:`Deleted`}):(0,G.jsx)(J,{children:`Live`}),c.Pinned&&(0,G.jsx)(J,{tone:`warn`,children:`Pinned`}),c.Post&&(0,G.jsx)(J,{children:`Channel post`}),(0,G.jsxs)(J,{children:[`pts `,c.PTS]})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Message ID`,value:String(c.ID),mono:!0}),(0,G.jsx)(X,{label:`Channel / Group`,value:String(c.ChannelID),mono:!0}),(0,G.jsx)(X,{label:`From Peer`,value:`${c.FromPeerType}:${c.FromPeerID}`,mono:!0}),(0,G.jsx)(X,{label:`Views`,value:String(c.ViewsCount)})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Channel Message Row`,text:`channel_messages read-only snapshot`}),(0,G.jsx)(Ot,{value:r.MessageJSON})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Channel Row`,text:`channels read-only snapshot`}),(0,G.jsx)(Ot,{value:r.ChannelJSON})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Channel Update Events`,text:`durable channel_update_events`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Count`}),(0,G.jsx)(`th`,{children:`Type`}),(0,G.jsx)(`th`,{children:`Message ID`}),(0,G.jsx)(`th`,{children:`Sender`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[r.UpdateEvents.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:e.PTS}),(0,G.jsx)(`td`,{children:e.PTSCount}),(0,G.jsx)(`td`,{children:e.Type}),(0,G.jsx)(`td`,{children:e.MessageID}),(0,G.jsx)(`td`,{children:e.SenderUserID}),(0,G.jsx)(`td`,{children:st(e.Date)})]},`${e.PTS}-${e.Type}-${e.MessageID}`)),r.UpdateEvents.length===0&&(0,G.jsx)(Et,{colSpan:6})]})]})})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Event JSON`}),(0,G.jsxs)(`div`,{className:`raw-grid`,children:[r.UpdateEvents.map(e=>(0,G.jsx)(Ot,{value:e.JSON},`${e.PTS}-${e.Type}-json`)),r.UpdateEvents.length===0&&(0,G.jsx)(`div`,{className:`empty-panel`,children:`No results`})]})]})]})})}function qn({navigate:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(`100`),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(``);async function p(e=!1){if(f(``),!t){f(`Search and select a supergroup or channel first`);return}let n=new URLSearchParams({channel_id:String(t.ID),limit:s});if(e&&l?.rows.length){let e=l.rows[l.rows.length-1];n.set(`before_date`,String(e.Date)),n.set(`before_id`,String(e.ID)),i(String(e.Date)),o(String(e.ID))}else r&&n.set(`before_date`,r),a&&n.set(`before_id`,a);try{u(await k.groupMessages(n))}catch(e){f(O(e))}}function m(e){n(e),i(``),o(``),u(null)}let h=l?.rows??[];return(0,G.jsxs)(xt,{title:`Group Messages`,eyebrow:`Supergroup / channel messages`,children:[d&&(0,G.jsx)(q,{children:d}),(0,G.jsxs)(St,{children:[(0,G.jsx)(`div`,{className:`message-selector-grid single`,children:(0,G.jsx)(jn,{label:`Channel / Group`,value:t,onChange:m})}),(0,G.jsxs)(`form`,{className:`toolbar message-query`,onSubmit:e=>{e.preventDefault(),p(!1)},children:[(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`before_date cursor`}),(0,G.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`before_msg_id cursor`}),(0,G.jsx)(`input`,{className:`small-input`,value:s,onChange:e=>c(e.target.value),placeholder:`limit <= 100`}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,children:[(0,G.jsx)(Re,{size:15}),` `,`Search messages`]}),h.length?(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>p(!0),children:[(0,G.jsx)(pe,{size:15}),` `,`Next page`]}):null]})]}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Messages on page`,value:String(h.length)}),(0,G.jsx)(Y,{label:`With media`,value:String(h.filter(e=>e.Media&&e.Media!==`{}`).length)}),(0,G.jsx)(Y,{label:`Channel posts`,value:String(h.filter(e=>e.Post).length)}),(0,G.jsx)(Y,{label:`Channel / Group`,value:t?`${t.Title||ot(t)} (${t.ID})`:`-`})]}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Message ID`}),(0,G.jsx)(`th`,{children:`Time`}),(0,G.jsx)(`th`,{children:`Sender`}),(0,G.jsx)(`th`,{children:`From Peer`}),(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Views`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Body`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[h.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:t.ID}),(0,G.jsx)(`td`,{children:st(t.Date)}),(0,G.jsx)(`td`,{className:`mono`,children:t.SenderUserID}),(0,G.jsxs)(`td`,{className:`mono`,children:[t.FromPeerType,`:`,t.FromPeerID]}),(0,G.jsx)(`td`,{children:t.PTS}),(0,G.jsx)(`td`,{children:t.ViewsCount}),(0,G.jsx)(`td`,{children:t.Deleted?(0,G.jsx)(J,{tone:`danger`,children:`Deleted`}):t.Pinned?(0,G.jsx)(J,{tone:`warn`,children:`Pinned`}):(0,G.jsx)(J,{children:`Live`})}),(0,G.jsx)(`td`,{className:`truncate`,children:t.Body}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/messages/groups/detail?channel_id=${t.ChannelID}&msg_id=${t.ID}`),children:[`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},`${t.ChannelID}-${t.ID}`)),h.length===0&&(0,G.jsx)(Et,{colSpan:9})]})]})})]})}function Jn({ownerUserID:e,msgID:t,navigate:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``);async function s(){o(``);try{i(await k.message(e,t))}catch(e){o(O(e))}}if((0,g.useEffect)(()=>{s()},[e,t]),a)return(0,G.jsx)(q,{children:a});if(!r)return(0,G.jsx)(Dt,{label:`Loading`});let c=r.Message;return(0,G.jsx)(xt,{title:`Message #${c.BoxID}`,eyebrow:`Message Detail`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>n(`/messages/private`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to private messages`]}),children:(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:`Owner ${c.OwnerUserID} · Peer ${c.PeerID}`}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:`Sender ${c.FromUserID} · ${st(c.Date)}`})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[c.Deleted?(0,G.jsx)(J,{tone:`danger`,children:`Deleted`}):(0,G.jsx)(J,{children:`Live`}),(0,G.jsxs)(J,{children:[`pts `,c.PTS]}),(0,G.jsx)(J,{children:c.Outgoing?`Outgoing`:`Incoming`})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Message box ID`,value:String(c.BoxID),mono:!0}),(0,G.jsx)(X,{label:`Private message ID`,value:String(c.PrivateMessageID),mono:!0}),(0,G.jsx)(X,{label:`Message sender`,value:String(c.MessageSenderID),mono:!0}),(0,G.jsx)(X,{label:`Time`,value:st(c.Date)})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Message Box`,text:`message_boxes read-only snapshot`}),(0,G.jsx)(Ot,{value:r.MessageJSON})]}),(0,G.jsxs)(`div`,{className:`raw-grid`,children:[(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Dialog Row`,text:`dialogs read-only snapshot`}),(0,G.jsx)(Ot,{value:r.DialogJSON})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Private Message Row`,text:`private_messages read-only snapshot`}),(0,G.jsx)(Ot,{value:r.PrivateJSON})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Update Events`,text:`durable user_update_events`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Count`}),(0,G.jsx)(`th`,{children:`Type`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[r.UpdateEvents.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:e.PTS}),(0,G.jsx)(`td`,{children:e.PTSCount}),(0,G.jsx)(`td`,{children:e.Type}),(0,G.jsx)(`td`,{children:st(e.Date)})]},`${e.PTS}-${e.Type}`)),r.UpdateEvents.length===0&&(0,G.jsx)(Et,{colSpan:4})]})]})})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Dispatch Queue`,text:`online/offline dispatch_outbox`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`User ID`}),(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Type`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Attempts`}),(0,G.jsx)(`th`,{children:`Updated`})]})}),(0,G.jsxs)(`tbody`,{children:[r.Outbox.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:e.ID}),(0,G.jsx)(`td`,{children:e.TargetUserID}),(0,G.jsx)(`td`,{children:e.PTS}),(0,G.jsx)(`td`,{children:e.EventType}),(0,G.jsx)(`td`,{children:e.Status}),(0,G.jsx)(`td`,{children:e.Attempts}),(0,G.jsx)(`td`,{children:W(e.UpdatedAt)})]},e.ID)),r.Outbox.length===0&&(0,G.jsx)(Et,{colSpan:7})]})]})})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Operations`}),(0,G.jsx)(Z,{label:`Delete this message`,icon:(0,G.jsx)(H,{size:15}),path:`/api/actions/delete-messages`,payload:()=>({owner_user_id:c.OwnerUserID,peer_id:c.PeerID,ids:[c.BoxID],revoke:!0}),onDone:s})]})})})}function Yn({navigate:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(`100`),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(!0),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(`1`),[S,C]=(0,g.useState)(null),[w,T]=(0,g.useState)(``);async function E(e=!1){if(T(``),!t||!r){T(`Search and select the owner user and peer user first`);return}let n=new URLSearchParams({owner_user_id:String(t.ID),peer_id:String(r.ID),limit:l});if(e&&S?.rows.length){let e=S.rows[S.rows.length-1];n.set(`before_date`,String(e.Date)),n.set(`before_id`,String(e.BoxID)),o(String(e.Date)),c(String(e.BoxID))}else a&&n.set(`before_date`,a),s&&n.set(`before_id`,s);try{C(await k.messages(n))}catch(e){T(O(e))}}function D(e){n(e),o(``),c(``),C(null)}function A(e){i(e),o(``),c(``),C(null)}return(0,G.jsxs)(xt,{title:`Private Messages`,eyebrow:`Private message boxes`,children:[w&&(0,G.jsx)(q,{children:w}),(0,G.jsxs)(St,{children:[(0,G.jsxs)(`div`,{className:`message-selector-grid`,children:[(0,G.jsx)(kn,{label:`Owner user`,value:t,onChange:D}),(0,G.jsx)(kn,{label:`Peer user`,value:r,onChange:A})]}),(0,G.jsxs)(`form`,{className:`toolbar message-query`,onSubmit:e=>{e.preventDefault(),E(!1)},children:[(0,G.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`before_date cursor`}),(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`before_msg_id cursor`}),(0,G.jsx)(`input`,{className:`small-input`,value:l,onChange:e=>u(e.target.value),placeholder:`limit <= 100`}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,children:[(0,G.jsx)(Re,{size:15}),` `,`Search messages`]}),S?.rows.length?(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>E(!0),children:[(0,G.jsx)(pe,{size:15}),` `,`Next page`]}):null]})]}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Messages on page`,value:String(S?.rows.length??0)}),(0,G.jsx)(Y,{label:`Deleted`,value:String((S?.rows??[]).filter(e=>e.Deleted).length),tone:`danger`}),(0,G.jsx)(Y,{label:`Outgoing`,value:String((S?.rows??[]).filter(e=>e.Outgoing).length)}),(0,G.jsx)(Y,{label:`Owner / Peer`,value:t&&r?`${at(t)} / ${at(r)}`:`-`})]}),(0,G.jsxs)(`div`,{className:`operation-row`,children:[(0,G.jsxs)(`div`,{className:`operation-box`,children:[(0,G.jsxs)(`div`,{className:`operation-title`,children:[(0,G.jsx)(H,{size:15}),` `,`Delete selected messages`]}),(0,G.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`Message IDs, comma separated`}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,`Revoke for both sides`]}),(0,G.jsx)(Z,{path:`/api/actions/delete-messages`,label:`Dry-run delete`,payload:()=>({owner_user_id:t?.ID??0,peer_id:r?.ID??0,ids:yt(d,`Message IDs are invalid`),revoke:p})})]}),(0,G.jsxs)(`div`,{className:`operation-box`,children:[(0,G.jsxs)(`div`,{className:`operation-title`,children:[(0,G.jsx)(Ce,{size:15}),` `,`Clear private history`]}),(0,G.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`max_id cutoff`}),(0,G.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:`max_batches`}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,`Revoke for both sides`]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked)}),` `,`Clear only this side`]}),(0,G.jsx)(Z,{path:`/api/actions/delete-history`,label:`Dry-run clear history`,payload:()=>({owner_user_id:t?.ID??0,peer_id:r?.ID??0,max_id:lt(v),max_batches:lt(b),just_clear:h,revoke:p})})]})]}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Message ID`}),(0,G.jsx)(`th`,{children:`Time`}),(0,G.jsx)(`th`,{children:`Sender`}),(0,G.jsx)(`th`,{children:`Direction`}),(0,G.jsx)(`th`,{children:`PTS`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Body`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[S?.rows.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:t.BoxID}),(0,G.jsx)(`td`,{children:st(t.Date)}),(0,G.jsx)(`td`,{className:`mono`,children:t.FromUserID}),(0,G.jsx)(`td`,{children:t.Outgoing?`Outgoing`:`Incoming`}),(0,G.jsx)(`td`,{children:t.PTS}),(0,G.jsx)(`td`,{children:t.Deleted?(0,G.jsx)(J,{tone:`danger`,children:`Deleted`}):(0,G.jsx)(J,{children:`Live`})}),(0,G.jsx)(`td`,{className:`truncate`,children:t.Body}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/messages/private/detail?owner_user_id=${t.OwnerUserID}&msg_id=${t.BoxID}`),children:[`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},`${t.OwnerUserID}-${t.BoxID}`)),(!S||S.rows.length===0)&&(0,G.jsx)(Et,{colSpan:8})]})]})})]})}var Xn=c(o(((e,t)=>{typeof document<`u`&&typeof navigator<`u`&&(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.lottie=r())})(e,(function(){var n=``,r=!1,i=-999999,a=function(e){r=!!e},o=function(){return r},s=function(e){n=e},c=function(){return n};function l(e){return document.createElement(e)}function u(e,t){var n,r=e.length,i;for(n=0;n1?n[1]=1:n[1]<=0&&(n[1]=0),L(n[0],n[1],n[2])}function te(e,t){var n=ee(e[0]*255,e[1]*255,e[2]*255);return n[2]+=t,n[2]>1?n[2]=1:n[2]<0&&(n[2]=0),L(n[0],n[1],n[2])}function ne(e,t){var n=ee(e[0]*255,e[1]*255,e[2]*255);return n[0]+=t/360,n[0]>1?--n[0]:n[0]<0&&(n[0]+=1),L(n[0],n[1],n[2])}(function(){var e=[],t,n;for(t=0;t<256;t+=1)n=t.toString(16),e[t]=n.length===1?`0`+n:n;return function(t,n,r){return t<0&&(t=0),n<0&&(n=0),r<0&&(r=0),`#`+e[t]+e[n]+e[r]}})();var re=function(e){g=!!e},ie=function(){return g},ae=function(e){_=e},oe=function(){return _},se=function(){return v},ce=function(e){E=e},le=function(){return E},ue=function(e){y=e};function z(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}function de(e){"@babel/helpers - typeof";return de=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},de(e)}var fe=function(){var e=1,t=[],n,r,i={onmessage:function(){},postMessage:function(e){n({data:e})}},a={postMessage:function(e){i.onmessage({data:e})}};function s(e){if(window.Worker&&window.Blob&&o()){var t=new Blob([`var _workerSelf = self; self.onmessage = `,e.toString()],{type:`text/javascript`}),r=URL.createObjectURL(t);return new Worker(r)}return n=e,i}function c(){r||(r=s(function(e){function t(){function e(t,n){var o,s,c=t.length,l,u,d,f;for(s=0;s=0;--t)if(e[t].ty===`sh`)if(e[t].ks.k.i)a(e[t].ks.k);else for(o=e[t].ks.k.length,r=0;rn[0]?!0:n[0]>e[0]?!1:e[1]>n[1]?!0:n[1]>e[1]?!1:e[2]>n[2]?!0:n[2]>e[2]?!1:null}var s=function(){var e=[4,4,14];function t(e){var t=e.t.d;e.t.d={k:[{s:t,t:0}]}}function n(e){var n,r=e.length;for(n=0;n=0;--n)if(e[n].ty===`sh`)if(e[n].ks.k.i)e[n].ks.k.c=e[n].closed;else for(a=e[n].ks.k.length,i=0;i500)&&(this._imageLoaded(),clearInterval(n)),t+=1}.bind(this),50)}function a(t){var n=r(t,this.assetsPath,this.path),i=z(`image`);b?this.testImageLoaded(i):i.addEventListener(`load`,this._imageLoaded,!1),i.addEventListener(`error`,function(){a.img=e,this._imageLoaded()}.bind(this),!1),i.setAttributeNS(`http://www.w3.org/1999/xlink`,`href`,n),this._elementHelper.append?this._elementHelper.append(i):this._elementHelper.appendChild(i);var a={img:i,assetData:t};return a}function o(t){var n=r(t,this.assetsPath,this.path),i=l(`img`);i.crossOrigin=`anonymous`,i.addEventListener(`load`,this._imageLoaded,!1),i.addEventListener(`error`,function(){a.img=e,this._imageLoaded()}.bind(this),!1),i.src=n;var a={img:i,assetData:t};return a}function s(e){var t={assetData:e},n=r(e,this.assetsPath,this.path);return fe.loadData(n,function(e){t.img=e,this._footageLoaded()}.bind(this),function(){t.img={},this._footageLoaded()}.bind(this)),t}function c(e,t){this.imagesLoadedCb=t;var n,r=e.length;for(n=0;nthis.animationData.op&&(this.animationData.op=e.op,this.totalFrames=Math.floor(e.op-this.animationData.ip));var t=this.animationData.layers,n,r=t.length,i=e.layers,a,o=i.length;for(a=0;athis.timeCompleted&&(this.currentFrame=this.timeCompleted),this.trigger(`enterFrame`),this.renderFrame(),this.trigger(`drawnFrame`)},B.prototype.renderFrame=function(){if(!(this.isLoaded===!1||!this.renderer))try{this.expressionsPlugin&&this.expressionsPlugin.resetFrame(),this.renderer.renderFrame(this.currentFrame+this.firstFrame)}catch(e){this.triggerRenderFrameError(e)}},B.prototype.play=function(e){e&&this.name!==e||this.isPaused===!0&&(this.isPaused=!1,this.trigger(`_play`),this.audioController.resume(),this._idle&&(this._idle=!1,this.trigger(`_active`)))},B.prototype.pause=function(e){e&&this.name!==e||this.isPaused===!1&&(this.isPaused=!0,this.trigger(`_pause`),this._idle=!0,this.trigger(`_idle`),this.audioController.pause())},B.prototype.togglePause=function(e){e&&this.name!==e||(this.isPaused===!0?this.play():this.pause())},B.prototype.stop=function(e){e&&this.name!==e||(this.pause(),this.playCount=0,this._completedLoop=!1,this.setCurrentRawFrameValue(0))},B.prototype.getMarkerData=function(e){for(var t,n=0;n=this.totalFrames-1&&this.frameModifier>0?!this.loop||this.playCount===this.loop?this.checkSegments(t>this.totalFrames?t%this.totalFrames:0)||(n=!0,t=this.totalFrames-1):t>=this.totalFrames?(this.playCount+=1,this.checkSegments(t%this.totalFrames)||(this.setCurrentRawFrameValue(t%this.totalFrames),this._completedLoop=!0,this.trigger(`loopComplete`))):this.setCurrentRawFrameValue(t):t<0?this.checkSegments(t%this.totalFrames)||(this.loop&&!(this.playCount--<=0&&this.loop!==!0)?(this.setCurrentRawFrameValue(this.totalFrames+t%this.totalFrames),this._completedLoop?this.trigger(`loopComplete`):this._completedLoop=!0):(n=!0,t=0)):this.setCurrentRawFrameValue(t),n&&(this.setCurrentRawFrameValue(t),this.pause(),this.trigger(`complete`))}},B.prototype.adjustSegment=function(e,t){this.playCount=0,e[1]0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(-1)),this.totalFrames=e[0]-e[1],this.timeCompleted=this.totalFrames,this.firstFrame=e[1],this.setCurrentRawFrameValue(this.totalFrames-.001-t)):e[1]>e[0]&&(this.frameModifier<0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(1)),this.totalFrames=e[1]-e[0],this.timeCompleted=this.totalFrames,this.firstFrame=e[0],this.setCurrentRawFrameValue(.001+t)),this.trigger(`segmentStart`)},B.prototype.setSegment=function(e,t){var n=-1;this.isPaused&&(this.currentRawFrame+this.firstFramet&&(n=t-e)),this.firstFrame=e,this.totalFrames=t-e,this.timeCompleted=this.totalFrames,n!==-1&&this.goToAndStop(n,!0)},B.prototype.playSegments=function(e,t){if(t&&(this.segments.length=0),xe(e[0])===`object`){var n,r=e.length;for(n=0;n=0;--n)t[n].animation.destroy(e)}function T(e,t,n){var r=[].concat([].slice.call(document.getElementsByClassName(`lottie`)),[].slice.call(document.getElementsByClassName(`bodymovin`))),i,a=r.length;for(i=0;i0?n=c:t=c;while(Math.abs(s)>a&&++l=i?g(e,d,t,n):f===0?d:h(e,a,a+c,t,n)}},e}(),we=function(){function e(e){return e.concat(m(e.length))}return{double:e}}(),Te=function(){return function(e,t,n){var r=0,i=e,a=m(i),o={newElement:s,release:c};function s(){var e;return r?(--r,e=a[r]):e=t(),e}function c(e){r===i&&(a=we.double(a),i*=2),n&&n(e),a[r]=e,r+=1}return o}}(),Ee=function(){function e(){return{addedLength:0,percents:p(`float32`,le()),lengths:p(`float32`,le())}}return Te(8,e)}(),De=function(){function e(){return{lengths:[],totalLength:0}}function t(e){var t,n=e.lengths.length;for(t=0;t-.001&&o<.001}function n(n,r,i,a,o,s,c,l,u){if(i===0&&s===0&&u===0)return t(n,r,a,o,c,l);var d=e.sqrt(e.pow(a-n,2)+e.pow(o-r,2)+e.pow(s-i,2)),f=e.sqrt(e.pow(c-n,2)+e.pow(l-r,2)+e.pow(u-i,2)),p=e.sqrt(e.pow(c-a,2)+e.pow(l-o,2)+e.pow(u-s,2)),m=d>f?d>p?d-f-p:p-f-d:p>f?p-f-d:f-d-p;return m>-1e-4&&m<1e-4}var r=function(){return function(e,t,n,r){var i=le(),a,o,s,c,l,u=0,d,f=[],p=[],m=Ee.newElement();for(s=n.length,a=0;ao?-1:1,l=!0;l;)if(r[a]<=o&&r[a+1]>o?(s=(o-r[a])/(r[a+1]-r[a]),l=!1):a+=c,a<0||a>=i-1){if(a===i-1)return n[a];l=!1}return n[a]+(n[a+1]-n[a])*s}function l(t,n,r,i,a,o){var s=c(a,o),l=1-s;return[e.round((l*l*l*t[0]+(s*l*l+l*s*l+l*l*s)*r[0]+(s*s*l+l*s*s+s*l*s)*i[0]+s*s*s*n[0])*1e3)/1e3,e.round((l*l*l*t[1]+(s*l*l+l*s*l+l*l*s)*r[1]+(s*s*l+l*s*s+s*l*s)*i[1]+s*s*s*n[1])*1e3)/1e3]}var u=p(`float32`,8);function d(t,n,r,i,a,o,s){a<0?a=0:a>1&&(a=1);var l=c(a,s);o=o>1?1:o;var d=c(o,s),f,p=t.length,m=1-l,h=1-d,g=m*m*m,_=l*m*m*3,v=l*l*m*3,y=l*l*l,b=m*m*h,x=l*m*h+m*l*h+m*m*d,S=l*l*h+m*l*d+l*m*d,C=l*l*d,w=m*h*h,T=l*h*h+m*d*h+m*h*d,E=l*d*h+m*d*d+l*h*d,D=l*d*d,O=h*h*h,k=d*h*h+h*d*h+h*h*d,A=d*d*h+h*d*d+d*h*d,j=d*d*d;for(f=0;f=l.t-n){c.h&&(c=l),i=0;break}if(l.t-n>e){i=a;break}a=v||e=v?x.points.length-1:0;for(f=x.points[S].point.length,d=0;d=T&&C=v)r[0]=b[0],r[1]=b[1],r[2]=b[2];else if(e<=y)r[0]=c.s[0],r[1]=c.s[1],r[2]=c.s[2];else{var j=Fe(c.s),M=Fe(b),N=(e-y)/(v-y);Pe(r,Ne(j,M,N))}else for(a=0;a=v?m=1:e1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-n)*f)/m,g=Math.sin(n*f)/m):(h=1-n,g=n),r[0]=h*i+g*c,r[1]=h*a+g*l,r[2]=h*o+g*u,r[3]=h*s+g*d,r}function Pe(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=Math.atan2(2*r*a-2*n*i,1-2*r*r-2*i*i),s=Math.asin(2*n*r+2*i*a),c=Math.atan2(2*n*a-2*r*i,1-2*n*n-2*i*i);e[0]=o/D,e[1]=s/D,e[2]=c/D}function Fe(e){var t=e[0]*D,n=e[1]*D,r=e[2]*D,i=Math.cos(t/2),a=Math.cos(n/2),o=Math.cos(r/2),s=Math.sin(t/2),c=Math.sin(n/2),l=Math.sin(r/2),u=i*a*o-s*c*l;return[s*c*o+i*a*l,s*a*o+i*c*l,i*c*o-s*a*l,u]}function Ie(){var e=this.comp.renderedFrame-this.offsetTime,t=this.keyframes[0].t-this.offsetTime,n=this.keyframes[this.keyframes.length-1].t-this.offsetTime;if(!(e===this._caching.lastFrame||this._caching.lastFrame!==Ae&&(this._caching.lastFrame>=n&&e>=n||this._caching.lastFrame=e&&(this._caching._lastKeyframeIndex=-1,this._caching.lastIndex=0);var r=this.interpolateValue(e,this._caching);this.pv=r}return this._caching.lastFrame=e,this.pv}function Le(e){var t;if(this.propType===`unidimensional`)t=e*this.mult,je(this.v-t)>1e-5&&(this.v=t,this._mdf=!0);else for(var n=0,r=this.v.length;n1e-5&&(this.v[n]=t,this._mdf=!0),n+=1}function Re(){if(!(this.elem.globalData.frameId===this.frameId||!this.effectsSequence.length)){if(this.lock){this.setVValue(this.pv);return}this.lock=!0,this._mdf=this._isFirstFrame;var e,t=this.effectsSequence.length,n=this.kf?this.pv:this.data.k;for(e=0;e=this._maxLength&&this.doubleArrayLength(),n){case`v`:a=this.v;break;case`i`:a=this.i;break;case`o`:a=this.o;break;default:a=[];break}(!a[r]||a[r]&&!i)&&(a[r]=Ge.newElement()),a[r][0]=e,a[r][1]=t},Ke.prototype.setTripleAt=function(e,t,n,r,i,a,o,s){this.setXYAt(e,t,`v`,o,s),this.setXYAt(n,r,`o`,o,s),this.setXYAt(i,a,`i`,o,s)},Ke.prototype.reverse=function(){var e=new Ke;e.setPathData(this.c,this._length);var t=this.v,n=this.o,r=this.i,i=0;this.c&&(e.setTripleAt(t[0][0],t[0][1],r[0][0],r[0][1],n[0][0],n[0][1],0,!1),i=1);var a=this._length-1,o=this._length,s;for(s=i;s=p[p.length-1].t-this.offsetTime)i=p[p.length-1].s?p[p.length-1].s[0]:p[p.length-2].e[0],o=!0;else{for(var m=r,h=p.length-1,g=!0,_,v,y;g&&(_=p[m],v=p[m+1],!(v.t-this.offsetTime>e));)m=v.t-this.offsetTime)d=1;else if(e<_.t-this.offsetTime)d=0;else{var b;y.__fnct?b=y.__fnct:(b=Ce.getBezierEasing(_.o.x,_.o.y,_.i.x,_.i.y).get,y.__fnct=b),d=b((e-(_.t-this.offsetTime))/(v.t-this.offsetTime-(_.t-this.offsetTime)))}a=v.s?v.s[0]:_.e[0]}i=_.s[0]}for(l=t._length,u=i.i[0].length,n.lastIndex=r,s=0;sr&&t>r)||(this._caching.lastIndex=i0||e>-1e-6&&e<0?r(e*t)/t:e}function P(){var e=this.props,t=N(e[0]),n=N(e[1]),r=N(e[4]),i=N(e[5]),a=N(e[12]),o=N(e[13]);return`matrix(`+t+`,`+n+`,`+r+`,`+i+`,`+a+`,`+o+`)`}return function(){this.reset=i,this.rotate=a,this.rotateX=o,this.rotateY=s,this.rotateZ=c,this.skew=u,this.skewFromAxis=d,this.shear=l,this.scale=f,this.setTransform=m,this.translate=h,this.transform=g,this.multiply=_,this.applyToPoint=S,this.applyToX=C,this.applyToY=w,this.applyToZ=T,this.applyToPointArray=A,this.applyToTriplePoints=k,this.applyToPointStringified=j,this.toCSS=M,this.to2dCSS=P,this.clone=b,this.cloneFromProps=x,this.equals=y,this.inversePoints=O,this.inversePoint=D,this.getInverseMatrix=E,this._t=this.transform,this.isIdentity=v,this._identity=!0,this._identityCalculated=!1,this.props=p(`float32`,16),this.reset()}}();function Ze(e){"@babel/helpers - typeof";return Ze=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ze(e)}var Qe={},$e=`__[STANDALONE]__`,et=`__[ANIMATIONDATA]__`,tt=``;function nt(e){s(e)}function rt(){$e===!0?Se.searchAnimations(et,$e,tt):Se.searchAnimations()}function it(e){re(e)}function U(e){ue(e)}function at(e){return $e===!0&&(e.animationData=JSON.parse(et)),Se.loadAnimation(e)}function ot(e){if(typeof e==`string`)switch(e){case`high`:ce(200);break;default:case`medium`:ce(50);break;case`low`:ce(10);break}else!isNaN(e)&&e>1&&ce(e)}function W(){return typeof navigator<`u`}function st(e,t){e===`expressions`&&ae(t)}function ct(e){switch(e){case`propertyFactory`:return V;case`shapePropertyFactory`:return Xe;case`matrix`:return H;default:return null}}Qe.play=Se.play,Qe.pause=Se.pause,Qe.setLocationHref=nt,Qe.togglePause=Se.togglePause,Qe.setSpeed=Se.setSpeed,Qe.setDirection=Se.setDirection,Qe.stop=Se.stop,Qe.searchAnimations=rt,Qe.registerAnimation=Se.registerAnimation,Qe.loadAnimation=at,Qe.setSubframeRendering=it,Qe.resize=Se.resize,Qe.goToAndStop=Se.goToAndStop,Qe.destroy=Se.destroy,Qe.setQuality=ot,Qe.inBrowser=W,Qe.installPlugin=st,Qe.freeze=Se.freeze,Qe.unfreeze=Se.unfreeze,Qe.setVolume=Se.setVolume,Qe.mute=Se.mute,Qe.unmute=Se.unmute,Qe.getRegisteredAnimations=Se.getRegisteredAnimations,Qe.useWebWorker=a,Qe.setIDPrefix=U,Qe.__getFactory=ct,Qe.version=`5.13.0`;function lt(){document.readyState===`complete`&&(clearInterval(mt),rt())}function ut(e){for(var t=dt.split(`&`),n=0;n=1?a.push({s:e-1,e:t-1}):(a.push({s:e,e:1}),a.push({s:0,e:t-1}));var o=[],s,c=a.length,l;for(s=0;sr+n)){var u=l.s*i<=r?0:(l.s*i-r)/n,d=l.e*i>=r+n?1:(l.e*i-r)/n;o.push([u,d])}return o.length||o.push([0,0]),o},_t.prototype.releasePathsData=function(e){var t,n=e.length;for(t=0;t1?1+r:this.s.v<0?0+r:this.s.v+r,n=this.e.v>1?1+r:this.e.v<0?0+r:this.e.v+r,t>n){var i=t;t=n,n=i}t=Math.round(t*1e4)*1e-4,n=Math.round(n*1e4)*1e-4,this.sValue=t,this.eValue=n}else t=this.sValue,n=this.eValue;var a,o,s=this.shapes.length,c,l,u,d,f,p=0;if(n===t)for(o=0;o=0;--o)if(h=this.shapes[o],h.shape._mdf){for(g=h.localShapeCollection,g.releaseShapes(),this.m===2&&s>1?(b=this.calculateShapeEdges(t,n,h.totalShapeLength,y,p),y+=h.totalShapeLength):b=[[_,v]],l=b.length,c=0;c=1?m.push({s:h.totalShapeLength*(_-1),e:h.totalShapeLength*(v-1)}):(m.push({s:h.totalShapeLength*_,e:h.totalShapeLength}),m.push({s:0,e:h.totalShapeLength*(v-1)}));var x=this.addShapes(h,m[0]);if(m[0].s!==m[0].e){if(m.length>1)if(h.shape.paths.shapes[h.shape.paths._length-1].c){var S=x.pop();this.addPaths(x,g),x=this.addShapes(h,m[1],S)}else this.addPaths(x,g),x=this.addShapes(h,m[1]);this.addPaths(x,g)}}h.shape.paths=g}}else if(this._mdf)for(o=0;ot.e){n.c=!1;break}else t.s<=l&&t.e>=l+u.addedLength?(this.addSegment(i[a].v[s-1],i[a].o[s-1],i[a].i[s],i[a].v[s],n,d,g),g=!1):(p=ke.getNewSegment(i[a].v[s-1],i[a].v[s],i[a].o[s-1],i[a].i[s],(t.s-l)/u.addedLength,(t.e-l)/u.addedLength,f[s-1]),this.addSegmentFromArray(p,n,d,g),g=!1,n.c=!1),l+=u.addedLength,d+=1;if(i[a].c&&f.length){if(u=f[s-1],l<=t.e){var _=f[s-1].addedLength;t.s<=l&&t.e>=l+_?(this.addSegment(i[a].v[s-1],i[a].o[s-1],i[a].i[0],i[a].v[0],n,d,g),g=!1):(p=ke.getNewSegment(i[a].v[s-1],i[a].v[0],i[a].o[s-1],i[a].i[0],(t.s-l)/_,(t.e-l)/_,f[s-1]),this.addSegmentFromArray(p,n,d,g),g=!1,n.c=!1)}else n.c=!1;l+=u.addedLength,d+=1}if(n._length&&(n.setXYAt(n.v[h][0],n.v[h][1],`i`,h),n.setXYAt(n.v[n._length-1][0],n.v[n._length-1][1],`o`,n._length-1)),l>t.e)break;a=this.p.keyframes[this.p.keyframes.length-1].t?(r=this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length-1].t/n,0),i=this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length-1].t-.05)/n,0)):(r=this.p.pv,i=this.p.getValueAtTime((this.p._caching.lastFrame+this.p.offsetTime-.01)/n,this.p.offsetTime));else if(this.px&&this.px.keyframes&&this.py.keyframes&&this.px.getValueAtTime&&this.py.getValueAtTime){r=[],i=[];var a=this.px,o=this.py;a._caching.lastFrame+a.offsetTime<=a.keyframes[0].t?(r[0]=a.getValueAtTime((a.keyframes[0].t+.01)/n,0),r[1]=o.getValueAtTime((o.keyframes[0].t+.01)/n,0),i[0]=a.getValueAtTime(a.keyframes[0].t/n,0),i[1]=o.getValueAtTime(o.keyframes[0].t/n,0)):a._caching.lastFrame+a.offsetTime>=a.keyframes[a.keyframes.length-1].t?(r[0]=a.getValueAtTime(a.keyframes[a.keyframes.length-1].t/n,0),r[1]=o.getValueAtTime(o.keyframes[o.keyframes.length-1].t/n,0),i[0]=a.getValueAtTime((a.keyframes[a.keyframes.length-1].t-.01)/n,0),i[1]=o.getValueAtTime((o.keyframes[o.keyframes.length-1].t-.01)/n,0)):(r=[a.pv,o.pv],i[0]=a.getValueAtTime((a._caching.lastFrame+a.offsetTime-.01)/n,a.offsetTime),i[1]=o.getValueAtTime((o._caching.lastFrame+o.offsetTime-.01)/n,o.offsetTime))}else i=e,r=i;this.v.rotate(-Math.atan2(r[1]-i[1],r[0]-i[0]))}this.data.p&&this.data.p.s?this.data.p.z?this.v.translate(this.px.v,this.py.v,-this.pz.v):this.v.translate(this.px.v,this.py.v,0):this.v.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}this.frameId=this.elem.globalData.frameId}}function r(){if(this.appliedTransformations=0,this.pre.reset(),!this.a.effectsSequence.length)this.pre.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.appliedTransformations=1;else return;if(!this.s.effectsSequence.length)this.pre.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.appliedTransformations=2;else return;if(this.sk)if(!this.sk.effectsSequence.length&&!this.sa.effectsSequence.length)this.pre.skewFromAxis(-this.sk.v,this.sa.v),this.appliedTransformations=3;else return;this.r?this.r.effectsSequence.length||(this.pre.rotate(-this.r.v),this.appliedTransformations=4):!this.rz.effectsSequence.length&&!this.ry.effectsSequence.length&&!this.rx.effectsSequence.length&&!this.or.effectsSequence.length&&(this.pre.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.appliedTransformations=4)}function i(){}function a(e){this._addDynamicProperty(e),this.elem.addDynamicProperty(e),this._isDirty=!0}function o(e,t,n){if(this.elem=e,this.frameId=-1,this.propType=`transform`,this.data=t,this.v=new H,this.pre=new H,this.appliedTransformations=0,this.initDynamicPropertyContainer(n||e),t.p&&t.p.s?(this.px=V.getProp(e,t.p.x,0,0,this),this.py=V.getProp(e,t.p.y,0,0,this),t.p.z&&(this.pz=V.getProp(e,t.p.z,0,0,this))):this.p=V.getProp(e,t.p||{k:[0,0,0]},1,0,this),t.rx){if(this.rx=V.getProp(e,t.rx,0,D,this),this.ry=V.getProp(e,t.ry,0,D,this),this.rz=V.getProp(e,t.rz,0,D,this),t.or.k[0].ti){var r,i=t.or.k.length;for(r=0;r0;)--n,this._elements.unshift(t[n]);this.dynamicProperties.length?this.k=!0:this.getValue(!0)},bt.prototype.resetElements=function(e){var t,n=e.length;for(t=0;t0?Math.floor(f):Math.ceil(f),h=this.pMatrix.props,g=this.rMatrix.props,_=this.sMatrix.props;this.pMatrix.reset(),this.rMatrix.reset(),this.sMatrix.reset(),this.tMatrix.reset(),this.matrix.reset();var v=0;if(f>0){for(;vm;)this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!0),--v;p&&(this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,-p,!0),v-=p)}r=this.data.m===1?0:this._currentCopies-1,i=this.data.m===1?1:-1,a=this._currentCopies;for(var y,b;a;){if(t=this.elemsData[r].it,n=t[t.length-1].transform.mProps.v.props,b=n.length,t[t.length-1].transform.mProps._mdf=!0,t[t.length-1].transform.op._mdf=!0,t[t.length-1].transform.op.v=this._currentCopies===1?this.so.v:this.so.v+(this.eo.v-this.so.v)*(r/(this._currentCopies-1)),v!==0){for((r!==0&&i===1||r!==this._currentCopies-1&&i===-1)&&this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!1),this.matrix.transform(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]),this.matrix.transform(_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15]),this.matrix.transform(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],h[8],h[9],h[10],h[11],h[12],h[13],h[14],h[15]),y=0;y0&&r<1?[t]:[]:[t-r,t+r].filter(function(e){return e>0&&e<1})},Y.prototype.split=function(e){if(e<=0)return[wt(this.points[0]),this];if(e>=1)return[this,wt(this.points[this.points.length-1])];var t=K(this.points[0],this.points[1],e),n=K(this.points[1],this.points[2],e),r=K(this.points[2],this.points[3],e),i=K(t,n,e),a=K(n,r,e),o=K(i,a,e);return[new Y(this.points[0],t,i,o,!0),new Y(o,a,r,this.points[3],!0)]};function X(e,t){var n=e.points[0][t],r=e.points[e.points.length-1][t];if(n>r){var i=r;r=n,n=i}for(var a=q(3*e.a[t],2*e.b[t],e.c[t]),o=0;o0&&a[o]<1){var s=e.point(a[o])[t];sr&&(r=s)}return{min:n,max:r}}Y.prototype.bounds=function(){return{x:X(this,0),y:X(this,1)}},Y.prototype.boundingBox=function(){var e=this.bounds();return{left:e.x.min,right:e.x.max,top:e.y.min,bottom:e.y.max,width:e.x.max-e.x.min,height:e.y.max-e.y.min,cx:(e.x.max+e.x.min)/2,cy:(e.y.max+e.y.min)/2}};function Tt(e,t,n){var r=e.boundingBox();return{cx:r.cx,cy:r.cy,width:r.width,height:r.height,bez:e,t:(t+n)/2,t1:t,t2:n}}function Et(e){var t=e.bez.split(.5);return[Tt(t[0],e.t1,e.t),Tt(t[1],e.t,e.t2)]}function Dt(e,t){return Math.abs(e.cx-t.cx)*2=a||e.width<=r&&e.height<=r&&t.width<=r&&t.height<=r){i.push([e.t,t.t]);return}var o=Et(e),s=Et(t);Ot(o[0],s[0],n+1,r,i,a),Ot(o[0],s[1],n+1,r,i,a),Ot(o[1],s[0],n+1,r,i,a),Ot(o[1],s[1],n+1,r,i,a)}}Y.prototype.intersections=function(e,t,n){t===void 0&&(t=2),n===void 0&&(n=7);var r=[];return Ot(Tt(this,0,1),Tt(e,0,1),0,t,r,n),r},Y.shapeSegment=function(e,t){var n=(t+1)%e.length();return new Y(e.v[t],e.o[t],e.i[n],e.v[n],!0)},Y.shapeSegmentInverted=function(e,t){var n=(t+1)%e.length();return new Y(e.v[n],e.i[n],e.o[t],e.v[t],!0)};function kt(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function At(e,t,n,r){var i=[e[0],e[1],1],a=[t[0],t[1],1],o=[n[0],n[1],1],s=[r[0],r[1],1],c=kt(kt(i,a),kt(o,s));return St(c[2])?null:[c[0]/c[2],c[1]/c[2]]}function jt(e,t,n){return[e[0]+Math.cos(t)*n,e[1]-Math.sin(t)*n]}function Mt(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1])}function Nt(e,t){return xt(e[0],t[0])&&xt(e[1],t[1])}function Pt(){}u([gt],Pt),Pt.prototype.initModifierProperties=function(e,t){this.getValue=this.processKeys,this.amplitude=V.getProp(e,t.s,0,null,this),this.frequency=V.getProp(e,t.r,0,null,this),this.pointsType=V.getProp(e,t.pt,0,null,this),this._isAnimated=this.amplitude.effectsSequence.length!==0||this.frequency.effectsSequence.length!==0||this.pointsType.effectsSequence.length!==0};function Ft(e,t,n,r,i,a,o){var s=n-Math.PI/2,c=n+Math.PI/2,l=t[0]+Math.cos(n)*r*i,u=t[1]-Math.sin(n)*r*i;e.setTripleAt(l,u,l+Math.cos(s)*a,u-Math.sin(s)*a,l+Math.cos(c)*o,u-Math.sin(c)*o,e.length())}function It(e,t){var n=[t[0]-e[0],t[1]-e[1]],r=-Math.PI*.5;return[Math.cos(r)*n[0]-Math.sin(r)*n[1],Math.sin(r)*n[0]+Math.cos(r)*n[1]]}function Lt(e,t){var n=t===0?e.length()-1:t-1,r=(t+1)%e.length(),i=e.v[n],a=e.v[r],o=It(i,a);return Math.atan2(0,1)-Math.atan2(o[1],o[0])}function Rt(e,t,n,r,i,a,o){var s=Lt(t,n),c=t.v[n%t._length],l=t.v[n===0?t._length-1:n-1],u=t.v[(n+1)%t._length],d=a===2?Math.sqrt((c[0]-l[0])**2+(c[1]-l[1])**2):0,f=a===2?Math.sqrt((c[0]-u[0])**2+(c[1]-u[1])**2):0;Ft(e,t.v[n%t._length],s,o,r,f/((i+1)*2),d/((i+1)*2),a)}function zt(e,t,n,r,i,a){for(var o=0;o1&&t.length>1&&(i=Ut(e[0],t[t.length-1]),i)?[[e[0].split(i[0])[0]],[t[t.length-1].split(i[1])[1]]]:[n,r]}function Gt(e){for(var t,n=1;n1&&(t=Wt(e[e.length-1],e[0]),e[e.length-1]=t[0],e[0]=t[1]),e}function Kt(e,t){var n=e.inflectionPoints(),r,i,a,o;if(n.length===0)return[Vt(e,t)];if(n.length===1||xt(n[1],1))return a=e.split(n[0]),r=a[0],i=a[1],[Vt(r,t),Vt(i,t)];a=e.split(n[0]),r=a[0];var s=(n[1]-n[0])/(1-n[0]);return a=a[1].split(s),o=a[0],i=a[1],[Vt(r,t),Vt(o,t),Vt(i,t)]}function qt(){}u([gt],qt),qt.prototype.initModifierProperties=function(e,t){this.getValue=this.processKeys,this.amount=V.getProp(e,t.a,0,null,this),this.miterLimit=V.getProp(e,t.ml,0,null,this),this.lineJoin=t.lj,this._isAnimated=this.amount.effectsSequence.length!==0},qt.prototype.processPath=function(e,t,n,r){var i=qe.newElement();i.c=e.c;var a=e.length();e.c||--a;var o,s,c,l=[];for(o=0;o=0;--o)c=Y.shapeSegmentInverted(e,o),l.push(Kt(c,t));l=Gt(l);var u=null,d=null;for(o=0;o0&&(o=!1),o){var u=l(`style`);u.setAttribute(`f-forigin`,n[r].fOrigin),u.setAttribute(`f-origin`,n[r].origin),u.setAttribute(`f-family`,n[r].fFamily),u.type=`text/css`,u.innerText=`@font-face {font-family: `+n[r].fFamily+`; font-style: normal; src: url('`+n[r].fPath+`');}`,t.appendChild(u)}}else if(n[r].fOrigin===`g`||n[r].origin===1){for(s=document.querySelectorAll(`link[f-forigin="g"], link[f-origin="1"]`),c=0;c=55296&&n<=56319){var r=e.charCodeAt(1);r>=56320&&r<=57343&&(t=(n-55296)*1024+r-56320+65536)}return t}function S(e,t){var n=e.toString(16)+t.toString(16);return d.indexOf(n)!==-1}function C(e){return e===s}function w(e){return e===o}function T(e){var t=x(e);return t>=c&&t<=u}function E(e){return T(e.substr(0,2))&&T(e.substr(2,2))}function D(e){return t.indexOf(e)!==-1}function O(e,t){var o=x(e.substr(t,2));if(o!==n)return!1;var s=0;for(t+=2;s<5;){if(o=x(e.substr(t,2)),oa)return!1;s+=1,t+=2}return x(e.substr(t,2))===r}function k(){this.isLoaded=!0}var A=function(){this.fonts=[],this.chars=null,this.typekitLoaded=0,this.isLoaded=!1,this._warned=!1,this.initTime=Date.now(),this.setIsLoadedBinded=this.setIsLoaded.bind(this),this.checkLoadedFontsBinded=this.checkLoadedFonts.bind(this)};return A.isModifier=S,A.isZeroWidthJoiner=C,A.isFlagEmoji=E,A.isRegionalCode=T,A.isCombinedCharacter=D,A.isRegionalFlag=O,A.isVariationSelector=w,A.BLACK_FLAG_CODE_POINT=n,A.prototype={addChars:_,addFonts:g,getCharData:v,getFontByName:b,measureText:y,checkLoadedFonts:m,setIsLoaded:k},A}();function Xt(e){this.animationData=e}Xt.prototype.getProp=function(e){return this.animationData.slots&&this.animationData.slots[e.sid]?Object.assign(e,this.animationData.slots[e.sid].p):e};function Zt(e){return new Xt(e)}function Qt(){}Qt.prototype={initRenderable:function(){this.isInRange=!1,this.hidden=!1,this.isTransparent=!1,this.renderableComponents=[]},addRenderableComponent:function(e){this.renderableComponents.indexOf(e)===-1&&this.renderableComponents.push(e)},removeRenderableComponent:function(e){this.renderableComponents.indexOf(e)!==-1&&this.renderableComponents.splice(this.renderableComponents.indexOf(e),1)},prepareRenderableFrame:function(e){this.checkLayerLimits(e)},checkTransparency:function(){this.finalTransform.mProp.o.v<=0?!this.isTransparent&&this.globalData.renderConfig.hideOnTransparent&&(this.isTransparent=!0,this.hide()):this.isTransparent&&(this.isTransparent=!1,this.show())},checkLayerLimits:function(e){this.data.ip-this.data.st<=e&&this.data.op-this.data.st>e?this.isInRange!==!0&&(this.globalData._mdf=!0,this._mdf=!0,this.isInRange=!0,this.show()):this.isInRange!==!1&&(this.globalData._mdf=!0,this.isInRange=!1,this.hide())},renderRenderable:function(){var e,t=this.renderableComponents.length;for(e=0;e.1)&&this.audio.seek(this._currentTime/this.globalData.frameRate):(this.audio.play(),this.audio.seek(this._currentTime/this.globalData.frameRate),this._isPlaying=!0))},pn.prototype.show=function(){},pn.prototype.hide=function(){this.audio.pause(),this._isPlaying=!1},pn.prototype.pause=function(){this.audio.pause(),this._isPlaying=!1,this._canPlay=!1},pn.prototype.resume=function(){this._canPlay=!0},pn.prototype.setRate=function(e){this.audio.rate(e)},pn.prototype.volume=function(e){this._volumeMultiplier=e,this._previousVolume=e*this._volume,this.audio.volume(this._previousVolume)},pn.prototype.getBaseElement=function(){return null},pn.prototype.destroy=function(){},pn.prototype.sourceRectAtTime=function(){},pn.prototype.initExpressions=function(){};function mn(){}mn.prototype.checkLayers=function(e){var t,n=this.layers.length,r;for(this.completeLayers=!0,t=n-1;t>=0;--t)this.elements[t]||(r=this.layers[t],r.ip-r.st<=e-this.layers[t].st&&r.op-r.st>e-this.layers[t].st&&this.buildItem(t)),this.completeLayers=this.elements[t]?this.completeLayers:!1;this.checkPendingElements()},mn.prototype.createItem=function(e){switch(e.ty){case 2:return this.createImage(e);case 0:return this.createComp(e);case 1:return this.createSolid(e);case 3:return this.createNull(e);case 4:return this.createShape(e);case 5:return this.createText(e);case 6:return this.createAudio(e);case 13:return this.createCamera(e);case 15:return this.createFootage(e);default:return this.createNull(e)}},mn.prototype.createCamera=function(){throw Error(`You're using a 3d camera. Try the html renderer.`)},mn.prototype.createAudio=function(e){return new pn(e,this.globalData,this)},mn.prototype.createFootage=function(e){return new fn(e,this.globalData,this)},mn.prototype.buildAllItems=function(){var e,t=this.layers.length;for(e=0;e0&&(this.maskElement.setAttribute(`id`,p),this.element.maskedElement.setAttribute(b,`url(`+c()+`#`+p+`)`),r.appendChild(this.maskElement)),this.viewData.length&&this.element.addRenderableComponent(this)}_n.prototype.getMaskProperty=function(e){return this.viewData[e].prop},_n.prototype.renderFrame=function(e){var t=this.element.finalTransform.mat,n,r=this.masksProperties.length;for(n=0;n1&&(r+=` C`+t.o[i-1][0]+`,`+t.o[i-1][1]+` `+t.i[0][0]+`,`+t.i[0][1]+` `+t.v[0][0]+`,`+t.v[0][1]),n.lastPath!==r){var o=``;n.elem&&(t.c&&(o=e.inv?this.solidPath+r:r),n.elem.setAttribute(`d`,o)),n.lastPath=r}},_n.prototype.destroy=function(){this.element=null,this.globalData=null,this.maskElement=null,this.data=null,this.masksProperties=null};var vn=function(){var e={};e.createFilter=t,e.createAlphaToLuminanceFilter=n;function t(e,t){var n=z(`filter`);return n.setAttribute(`id`,e),t!==!0&&(n.setAttribute(`filterUnits`,`objectBoundingBox`),n.setAttribute(`x`,`0%`),n.setAttribute(`y`,`0%`),n.setAttribute(`width`,`100%`),n.setAttribute(`height`,`100%`)),n}function n(){var e=z(`feColorMatrix`);return e.setAttribute(`type`,`matrix`),e.setAttribute(`color-interpolation-filters`,`sRGB`),e.setAttribute(`values`,`0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1`),e}return e}(),yn=function(){var e={maskType:!0,svgLumaHidden:!0,offscreenCanvas:typeof OffscreenCanvas<`u`};return(/MSIE 10/i.test(navigator.userAgent)||/MSIE 9/i.test(navigator.userAgent)||/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))&&(e.maskType=!1),/firefox/i.test(navigator.userAgent)&&(e.svgLumaHidden=!1),e}(),bn={},xn=`filter_result_`;function Sn(e){var t,n=`SourceGraphic`,r=e.data.ef?e.data.ef.length:0,i=I(),a=vn.createFilter(i,!0),o=0;this.filters=[];var s;for(t=0;t=0&&(n=this.shapeModifiers[e].processShapes(this._isFirstFrame),!n);--e);}},searchProcessedElement:function(e){for(var t=this.processedElements,n=0,r=t.length;n.01)return!1;n+=1}return!0},Ln.prototype.checkCollapsable=function(){if(this.o.length/2!=this.c.length/4)return!1;if(this.data.k.k[0].s)for(var e=0,t=this.data.k.k.length;e0;)c=r.transformers[g].mProps._mdf||c,--h,--g;if(c)for(h=f-r.styles[u].lvl,g=r.transformers.length-1;h>0;)m.multiply(r.transformers[g].mProps.v),--h,--g}else m=e;if(p=r.sh.paths,o=p._length,c){for(s=``,a=0;a=1?v=.99:v<=-1&&(v=-.99);var y=g*v,b=Math.cos(_+t.a.v)*y+a[0],x=Math.sin(_+t.a.v)*y+a[1];r.setAttribute(`fx`,b),r.setAttribute(`fy`,x),i&&!t.g._collapsable&&(t.of.setAttribute(`fx`,b),t.of.setAttribute(`fy`,x))}}}function u(e,t,n){var r=t.style,i=t.d;i&&(i._mdf||n)&&i.dashStr&&(r.pElem.setAttribute(`stroke-dasharray`,i.dashStr),r.pElem.setAttribute(`stroke-dashoffset`,i.dashoffset[0])),t.c&&(t.c._mdf||n)&&r.pElem.setAttribute(`stroke`,`rgb(`+C(t.c.v[0])+`,`+C(t.c.v[1])+`,`+C(t.c.v[2])+`)`),(t.o._mdf||n)&&r.pElem.setAttribute(`stroke-opacity`,t.o.v),(t.w._mdf||n)&&(r.pElem.setAttribute(`stroke-width`,t.w.v),r.msElem&&r.msElem.setAttribute(`stroke-width`,t.w.v))}return n}();function Wn(e,t,n){this.shapes=[],this.shapesData=e.shapes,this.stylesList=[],this.shapeModifiers=[],this.itemsData=[],this.processedElements=[],this.animatedContents=[],this.initElement(e,t,n),this.prevViewData=[]}u([un,gn,Cn,On,wn,dn,Tn],Wn),Wn.prototype.initSecondaryElement=function(){},Wn.prototype.identityMatrix=new H,Wn.prototype.buildExpressionInterface=function(){},Wn.prototype.createContent=function(){this.searchShapes(this.shapesData,this.itemsData,this.prevViewData,this.layerElement,0,[],!0),this.filterUniqueShapes()},Wn.prototype.filterUniqueShapes=function(){var e,t=this.shapes.length,n,r,i=this.stylesList.length,a,o=[],s=!1;for(r=0;r1&&s&&this.setShapesAsAnimated(o)}},Wn.prototype.setShapesAsAnimated=function(e){var t,n=e.length;for(t=0;t=0;--c){if(g=this.searchProcessedElement(e[c]),g?t[c]=n[g-1]:e[c]._render=o,e[c].ty===`fl`||e[c].ty===`st`||e[c].ty===`gf`||e[c].ty===`gs`||e[c].ty===`no`)g?t[c].style.closed=e[c].hd:t[c]=this.createStyleElement(e[c],i),e[c]._render&&t[c].style.pElem.parentNode!==r&&r.appendChild(t[c].style.pElem),f.push(t[c].style);else if(e[c].ty===`gr`){if(!g)t[c]=this.createGroupElement(e[c]);else for(d=t[c].it.length,u=0;u1,this.kf&&this.addEffect(this.getKeyframeValue.bind(this)),this.kf},Kn.prototype.addEffect=function(e){this.effectsSequence.push(e),this.elem.addDynamicProperty(this)},Kn.prototype.getValue=function(e){if(!((this.elem.globalData.frameId===this.frameId||!this.effectsSequence.length)&&!e)){this.currentData.t=this.data.d.k[this.keysIndex].s.t;var t=this.currentData,n=this.keysIndex;if(this.lock){this.setCurrentData(this.currentData);return}this.lock=!0,this._mdf=!1;var r,i=this.effectsSequence.length,a=e||this.data.d.k[this.keysIndex].s;for(r=0;rt);)n+=1;return this.keysIndex!==n&&(this.keysIndex=n),this.data.d.k[this.keysIndex].s},Kn.prototype.buildFinalText=function(e){for(var t=[],n=0,r=e.length,i,a,o=!1,s=!1,c=``;n=55296&&i<=56319?Yt.isRegionalFlag(e,n)?c=e.substr(n,14):(a=e.charCodeAt(n+1),a>=56320&&a<=57343&&(Yt.isModifier(i,a)?(c=e.substr(n,2),o=!0):c=Yt.isFlagEmoji(e.substr(n,4))?e.substr(n,4):e.substr(n,2))):i>56319?(a=e.charCodeAt(n+1),Yt.isVariationSelector(i)&&(o=!0)):Yt.isZeroWidthJoiner(i)&&(o=!0,s=!0),o?(t[t.length-1]+=c,o=!1):t.push(c),n+=c.length;return t},Kn.prototype.completeTextData=function(e){e.__complete=!0;var t=this.elem.globalData.fontManager,n=this.data,r=[],i,a,o,s=0,c,l=n.m.g,u=0,d=0,f=0,p=[],m=0,h=0,g,_,v=t.getFontByName(e.f),y,b=0,x=Jt(v);e.fWeight=x.weight,e.fStyle=x.style,e.finalSize=e.s,e.finalText=this.buildFinalText(e.t),a=e.finalText.length,e.finalLineHeight=e.lh;var S=e.tr/1e3*e.finalSize,C;if(e.sz)for(var w=!0,T=e.sz[0],E=e.sz[1],D,O;w;){O=this.buildFinalText(e.t),D=0,m=0,a=O.length,S=e.tr/1e3*e.finalSize;var k=-1;for(i=0;iT&&O[i]!==` `?(k===-1?a+=1:i=k,D+=e.finalLineHeight||e.finalSize*1.2,O.splice(i,+(k===i),`\r`),k=-1,m=0):(m+=b,m+=S);D+=v.ascent*e.finalSize/100,this.canResize&&e.finalSize>this.minimumFontSize&&Eh?m:h,m=-2*S,c=``,o=!0,f+=1):c=j,t.chars?(y=t.getCharData(j,v.fStyle,t.getFontByName(e.f).fFamily),b=o?0:y.w*e.finalSize/100):b=t.measureText(c,e.f,e.finalSize),j===` `?A+=b+S:(m+=b+S+A,A=0),r.push({l:b,an:b,add:u,n:o,anIndexes:[],val:c,line:f,animatorJustifyOffset:0}),l==2){if(u+=b,c===``||c===` `||i===a-1){for((c===``||c===` `)&&(u-=b);d<=i;)r[d].an=u,r[d].ind=s,r[d].extra=b,d+=1;s+=1,u=0}}else if(l==3){if(u+=b,c===``||i===a-1){for(c===``&&(u-=b);d<=i;)r[d].an=u,r[d].ind=s,r[d].extra=b,d+=1;u=0,s+=1}}else r[s].ind=s,r[s].extra=0,s+=1;if(e.l=r,h=m>h?m:h,p.push(m),e.sz)e.boxWidth=e.sz[0],e.justifyOffset=0;else switch(e.boxWidth=h,e.j){case 1:e.justifyOffset=-e.boxWidth;break;case 2:e.justifyOffset=-e.boxWidth/2;break;default:e.justifyOffset=0}e.lineWidths=p;var M=n.a,N,P;_=M.length;var F,I,L=[];for(g=0;g<_;g+=1){for(N=M[g],N.a.sc&&(e.strokeColorAnim=!0),N.a.sw&&(e.strokeWidthAnim=!0),(N.a.fc||N.a.fh||N.a.fs||N.a.fb)&&(e.fillColorAnim=!0),I=0,F=N.s.b,i=0;i0?i=this.ne.v/100:a=-this.ne.v/100,this.xe.v>0?o=1-this.xe.v/100:s=1+this.xe.v/100;var c=Ce.getBezierEasing(i,a,o,s).get,l=0,u=this.finalS,d=this.finalE,f=this.data.sh;if(f===2)l=d===u?+(r>=d):e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l=c(l);else if(f===3)l=d===u?r>=d?0:1:1-e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l=c(l);else if(f===4)d===u?l=0:(l=e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l<.5?l*=2:l=1-2*(l-.5)),l=c(l);else if(f===5){if(d===u)l=0;else{var p=d-u;r=t(e(0,r+.5-u),d-u);var m=-p/2+r,h=p/2;l=Math.sqrt(1-m*m/(h*h))}l=c(l)}else f===6?(d===u?l=0:(r=t(e(0,r+.5-u),d-u),l=(1+Math.cos(Math.PI+Math.PI*2*r/(d-u)))/2),l=c(l)):(r>=n(u)&&(l=r-u<0?e(0,t(t(d,1)-(u-r),1)):e(0,t(d-r,1))),l=c(l));if(this.sm.v!==100){var g=this.sm.v*.01;g===0&&(g=1e-8);var _=.5-g*.5;l<_?l=0:(l=(l-_)/g,l>1&&(l=1))}return l*this.a.v},getValue:function(e){this.iterateDynamicProperties(),this._mdf=e||this._mdf,this._currentTextLength=this.elem.textProperty.currentData.l.length||0,e&&this.data.r===2&&(this.e.v=this._currentTextLength);var t=this.data.r===2?1:100/this.data.totalChars,n=this.o.v/t,r=this.s.v/t+n,i=this.e.v/t+n;if(r>i){var a=r;r=i,i=a}this.finalS=r,this.finalE=i}},u([We],r);function i(e,t,n){return new r(e,t,n)}return{getTextSelectorProp:i}}();function Jn(e,t,n){var r={propType:!1},i=V.getProp,a=t.a;this.a={r:a.r?i(e,a.r,0,D,n):r,rx:a.rx?i(e,a.rx,0,D,n):r,ry:a.ry?i(e,a.ry,0,D,n):r,sk:a.sk?i(e,a.sk,0,D,n):r,sa:a.sa?i(e,a.sa,0,D,n):r,s:a.s?i(e,a.s,1,.01,n):r,a:a.a?i(e,a.a,1,0,n):r,o:a.o?i(e,a.o,0,.01,n):r,p:a.p?i(e,a.p,1,0,n):r,sw:a.sw?i(e,a.sw,0,0,n):r,sc:a.sc?i(e,a.sc,1,0,n):r,fc:a.fc?i(e,a.fc,1,0,n):r,fh:a.fh?i(e,a.fh,0,0,n):r,fs:a.fs?i(e,a.fs,0,.01,n):r,fb:a.fb?i(e,a.fb,0,.01,n):r,t:a.t?i(e,a.t,0,0,n):r},this.s=qn.getTextSelectorProp(e,t.s,n),this.s.t=t.s.t}function Yn(e,t,n){this._isFirstFrame=!0,this._hasMaskedPath=!1,this._frameId=-1,this._textData=e,this._renderType=t,this._elem=n,this._animatorsData=m(this._textData.a.length),this._pathData={},this._moreOptions={alignment:{}},this.renderedLetters=[],this.lettersChangedFlag=!1,this.initDynamicPropertyContainer(n)}Yn.prototype.searchProperties=function(){var e,t=this._textData.a.length,n,r=V.getProp;for(e=0;e=m+we||!x?(T=(m+we-g)/h.partialLength,ie=b.point[0]+(h.point[0]-b.point[0])*T,ae=b.point[1]+(h.point[1]-b.point[1])*T,a.translate(-n[0]*f[u].an*.005,-(n[1]*A)*.01),_=!1):x&&(g+=h.partialLength,v+=1,v>=x.length&&(v=0,y+=1,S[y]?x=S[y].points:D.v.c?(v=0,y=0,x=S[y].points):(g-=h.partialLength,x=null)),x&&(b=h,h=x[v],C=h.partialLength));re=f[u].an/2-f[u].add,a.translate(-re,0,0)}else re=f[u].an/2-f[u].add,a.translate(-re,0,0),a.translate(-n[0]*f[u].an*.005,-n[1]*A*.01,0);for(P=0;Pe?this.textSpans[e].span:z(s?`g`:`text`),b<=e){if(c.setAttribute(`stroke-linecap`,`butt`),c.setAttribute(`stroke-linejoin`,`round`),c.setAttribute(`stroke-miterlimit`,`4`),this.textSpans[e].span=c,s){var S=z(`g`);c.appendChild(S),this.textSpans[e].childSpan=S}this.textSpans[e].span=c,this.layerElement.appendChild(c)}c.style.display=`inherit`}if(l.reset(),d&&(o[e].n&&(f=-g,p+=n.yOffset,p+=+!!h,h=!1),this.applyTextPropertiesToMatrix(n,l,o[e].line,f,p),f+=o[e].l||0,f+=g),s){x=this.globalData.fontManager.getCharData(n.finalText[e],r.fStyle,this.globalData.fontManager.getFontByName(n.f).fFamily);var C;if(x.t===1)C=new rr(x.data,this.globalData,this);else{var w=Zn;x.data&&x.data.shapes&&(w=this.buildShapeData(x.data,n.finalSize)),C=new Wn(w,this.globalData,this)}if(this.textSpans[e].glyph){var T=this.textSpans[e].glyph;this.textSpans[e].childSpan.removeChild(T.layerElement),T.destroy()}this.textSpans[e].glyph=C,C._debug=!0,C.prepareFrame(0),C.renderFrame(),this.textSpans[e].childSpan.appendChild(C.layerElement),x.t===1&&this.textSpans[e].childSpan.setAttribute(`transform`,`scale(`+n.finalSize/100+`,`+n.finalSize/100+`)`)}else d&&c.setAttribute(`transform`,`translate(`+l.props[12]+`,`+l.props[13]+`)`),c.textContent=o[e].val,c.setAttributeNS(`http://www.w3.org/XML/1998/namespace`,`xml:space`,`preserve`)}d&&c&&c.setAttribute(`d`,u)}for(;e=0;--t)(this.completeLayers||this.elements[t])&&this.elements[t].prepareFrame(e-this.layers[t].st);if(this.globalData._mdf)for(t=0;t=0;--n)(this.completeLayers||this.elements[n])&&(this.elements[n].prepareFrame(this.renderedFrame-this.layers[n].st),this.elements[n]._mdf&&(this._mdf=!0))}},nr.prototype.renderInnerContent=function(){var e,t=this.layers.length;for(e=0;e=0;--n)e.finalTransform.multiply(e.transforms[n].transform.mProps.v);e._mdf=i},processSequences:function(e){var t,n=this.sequenceList.length;for(t=0;t=1){this.buffers=[];var e=this.globalData.canvasContext,t=cr.createCanvas(e.canvas.width,e.canvas.height);this.buffers.push(t);var n=cr.createCanvas(e.canvas.width,e.canvas.height);this.buffers.push(n),this.data.tt>=3&&!document._isProxy&&cr.loadLumaCanvas()}this.canvasContext=this.globalData.canvasContext,this.transformCanvas=this.globalData.transformCanvas,this.renderableEffectsManager=new ur(this),this.searchEffectTransforms()},createContent:function(){},setBlendMode:function(){var e=this.globalData;if(e.blendMode!==this.data.bm){e.blendMode=this.data.bm;var t=$t(this.data.bm);e.canvasContext.globalCompositeOperation=t}},createRenderableComponents:function(){this.maskManager=new dr(this.data,this),this.transformEffects=this.renderableEffectsManager.getEffects(hn.TRANSFORM_EFFECT)},hideElement:function(){!this.hidden&&(!this.isInRange||this.isTransparent)&&(this.hidden=!0)},showElement:function(){this.isInRange&&!this.isTransparent&&(this.hidden=!1,this._isFirstFrame=!0,this.maskManager._isFirstFrame=!0)},clearCanvas:function(e){e.clearRect(this.transformCanvas.tx,this.transformCanvas.ty,this.transformCanvas.w*this.transformCanvas.sx,this.transformCanvas.h*this.transformCanvas.sy)},prepareLayer:function(){if(this.data.tt>=1){var e=this.buffers[0].getContext(`2d`);this.clearCanvas(e),e.drawImage(this.canvasContext.canvas,0,0),this.currentTransform=this.canvasContext.getTransform(),this.canvasContext.setTransform(1,0,0,1,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.setTransform(this.currentTransform)}},exitLayer:function(){if(this.data.tt>=1){var e=this.buffers[1],t=e.getContext(`2d`);if(this.clearCanvas(t),t.drawImage(this.canvasContext.canvas,0,0),this.canvasContext.setTransform(1,0,0,1,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.setTransform(this.currentTransform),this.comp.getElementById(`tp`in this.data?this.data.tp:this.data.ind-1).renderFrame(!0),this.canvasContext.setTransform(1,0,0,1,0,0),this.data.tt>=3&&!document._isProxy){var n=cr.getLumaCanvas(this.canvasContext.canvas);n.getContext(`2d`).drawImage(this.canvasContext.canvas,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.drawImage(n,0,0)}this.canvasContext.globalCompositeOperation=pr[this.data.tt],this.canvasContext.drawImage(e,0,0),this.canvasContext.globalCompositeOperation=`destination-over`,this.canvasContext.drawImage(this.buffers[0],0,0),this.canvasContext.setTransform(this.currentTransform),this.canvasContext.globalCompositeOperation=`source-over`}},renderFrame:function(e){if(!(this.hidden||this.data.hd)&&!(this.data.td===1&&!e)){this.renderTransform(),this.renderRenderable(),this.renderLocalTransform(),this.setBlendMode();var t=this.data.ty===0;this.prepareLayer(),this.globalData.renderer.save(t),this.globalData.renderer.ctxTransform(this.finalTransform.localMat.props),this.globalData.renderer.ctxOpacity(this.finalTransform.localOpacity),this.renderInnerContent(),this.globalData.renderer.restore(t),this.exitLayer(),this.maskManager.hasMasks&&this.globalData.renderer.restore(!0),this._isFirstFrame&&=!1}},destroy:function(){this.canvasContext=null,this.data=null,this.globalData=null,this.maskManager.destroy()},mHelper:new H},fr.prototype.hide=fr.prototype.hideElement,fr.prototype.show=fr.prototype.showElement;function mr(e,t,n,r){this.styledShapes=[],this.tr=[0,0,0,0,0,0];var i=4;t.ty===`rc`?i=5:t.ty===`el`?i=6:t.ty===`sr`&&(i=7),this.sh=Xe.getShapeProp(e,t,i,e);var a,o=n.length,s;for(a=0;a=0;--a){if(d=this.searchProcessedElement(e[a]),d?t[a]=n[d-1]:e[a]._shouldRender=r,e[a].ty===`fl`||e[a].ty===`st`||e[a].ty===`gf`||e[a].ty===`gs`)d?t[a].style.closed=!1:t[a]=this.createStyleElement(e[a],m),l.push(t[a].style);else if(e[a].ty===`gr`){if(!d)t[a]=this.createGroupElement(e[a]);else for(c=t[a].it.length,s=0;s=0;--i)t[i].ty===`tr`?(o=n[i].transform,this.renderShapeTransform(e,o)):t[i].ty===`sh`||t[i].ty===`el`||t[i].ty===`rc`||t[i].ty===`sr`?this.renderPath(t[i],n[i]):t[i].ty===`fl`?this.renderFill(t[i],n[i],o):t[i].ty===`st`?this.renderStroke(t[i],n[i],o):t[i].ty===`gf`||t[i].ty===`gs`?this.renderGradientFill(t[i],n[i],o):t[i].ty===`gr`?this.renderShape(o,t[i].it,n[i].it):t[i].ty;r&&this.drawLayer()},hr.prototype.renderStyledShape=function(e,t){if(this._isFirstFrame||t._mdf||e.transforms._mdf){var n=e.trNodes,r=t.paths,i,a,o,s=r._length;n.length=0;var c=e.transforms.finalTransform;for(o=0;o=1?u=.99:u<=-1&&(u=-.99);var d=c*u,f=Math.cos(l+t.a.v)*d+o[0],p=Math.sin(l+t.a.v)*d+o[1];i=a.createRadialGradient(f,p,0,o[0],o[1],c)}var m,h=e.g.p,g=t.g.c,_=1;for(m=0;ma&&c===`xMidYMid slice`||ii&&s===`meet`||ai&&s===`slice`)?this.transformCanvas.tx=(n-this.transformCanvas.w*(r/this.transformCanvas.h))/2*this.renderConfig.dpr:l===`xMax`&&(ai&&s===`slice`)?this.transformCanvas.tx=(n-this.transformCanvas.w*(r/this.transformCanvas.h))*this.renderConfig.dpr:this.transformCanvas.tx=0,u===`YMid`&&(a>i&&s===`meet`||ai&&s===`meet`||a=0;--e)this.elements[e]&&this.elements[e].destroy&&this.elements[e].destroy();this.elements.length=0,this.globalData.canvasContext=null,this.animationItem.container=null,this.destroyed=!0},Q.prototype.renderFrame=function(e,t){if(!(this.renderedFrame===e&&this.renderConfig.clearCanvas===!0&&!t||this.destroyed||e===-1)){this.renderedFrame=e,this.globalData.frameNum=e-this.animationItem._isFirstFrame,this.globalData.frameId+=1,this.globalData._mdf=!this.renderConfig.clearCanvas||t,this.globalData.projectInterface.currentFrame=e;var n,r=this.layers.length;for(this.completeLayers||this.checkLayers(e),n=r-1;n>=0;--n)(this.completeLayers||this.elements[n])&&this.elements[n].prepareFrame(e-this.layers[n].st);if(this.globalData._mdf){for(this.renderConfig.clearCanvas===!0?this.canvasContext.clearRect(0,0,this.transformCanvas.w,this.transformCanvas.h):this.save(),n=r-1;n>=0;--n)(this.completeLayers||this.elements[n])&&this.elements[n].renderFrame();this.renderConfig.clearCanvas!==!0&&this.restore()}}},Q.prototype.buildItem=function(e){var t=this.elements;if(!(t[e]||this.layers[e].ty===99)){var n=this.createItem(this.layers[e],this,this.globalData);t[e]=n,n.initExpressions()}},Q.prototype.checkPendingElements=function(){for(;this.pendingElements.length;)this.pendingElements.pop().checkParenting()},Q.prototype.hide=function(){this.animationItem.container.style.display=`none`},Q.prototype.show=function(){this.animationItem.container.style.display=`block`};function yr(){this.opacity=-1,this.transform=p(`float32`,16),this.fillStyle=``,this.strokeStyle=``,this.lineWidth=``,this.lineCap=``,this.lineJoin=``,this.miterLimit=``,this.id=Math.random()}function br(){this.stack=[],this.cArrPos=0,this.cTr=new H;var e,t=15;for(e=0;e=0;--t)(this.completeLayers||this.elements[t])&&this.elements[t].renderFrame()},xr.prototype.destroy=function(){var e;for(e=this.layers.length-1;e>=0;--e)this.elements[e]&&this.elements[e].destroy();this.layers=null,this.elements=null},xr.prototype.createComp=function(e){return new xr(e,this.globalData,this)};function Sr(e,t){this.animationItem=e,this.renderConfig={clearCanvas:t&&t.clearCanvas!==void 0?t.clearCanvas:!0,context:t&&t.context||null,progressiveLoad:t&&t.progressiveLoad||!1,preserveAspectRatio:t&&t.preserveAspectRatio||`xMidYMid meet`,imagePreserveAspectRatio:t&&t.imagePreserveAspectRatio||`xMidYMid slice`,contentVisibility:t&&t.contentVisibility||`visible`,className:t&&t.className||``,id:t&&t.id||``,runExpressions:!t||t.runExpressions===void 0||t.runExpressions},this.renderConfig.dpr=t&&t.dpr||1,this.animationItem.wrapper&&(this.renderConfig.dpr=t&&t.dpr||window.devicePixelRatio||1),this.renderedFrame=-1,this.globalData={frameNum:-1,_mdf:!1,renderConfig:this.renderConfig,currentGlobalAlpha:-1},this.contextData=new br,this.elements=[],this.pendingElements=[],this.transformMat=new H,this.completeLayers=!1,this.rendererType=`canvas`,this.renderConfig.clearCanvas&&(this.ctxTransform=this.contextData.transform.bind(this.contextData),this.ctxOpacity=this.contextData.opacity.bind(this.contextData),this.ctxFillStyle=this.contextData.fillStyle.bind(this.contextData),this.ctxStrokeStyle=this.contextData.strokeStyle.bind(this.contextData),this.ctxLineWidth=this.contextData.lineWidth.bind(this.contextData),this.ctxLineCap=this.contextData.lineCap.bind(this.contextData),this.ctxLineJoin=this.contextData.lineJoin.bind(this.contextData),this.ctxMiterLimit=this.contextData.miterLimit.bind(this.contextData),this.ctxFill=this.contextData.fill.bind(this.contextData),this.ctxFillRect=this.contextData.fillRect.bind(this.contextData),this.ctxStroke=this.contextData.stroke.bind(this.contextData),this.save=this.contextData.save.bind(this.contextData))}return u([Q],Sr),Sr.prototype.createComp=function(e){return new xr(e,this.globalData,this)},ve(`canvas`,Sr),ht.registerModifier(`tm`,_t),ht.registerModifier(`pb`,vt),ht.registerModifier(`rp`,bt),ht.registerModifier(`rd`,G),ht.registerModifier(`zz`,Pt),ht.registerModifier(`op`,qt),Qe}))}))(),1),Zn=0,Qn=e=>`${e}-${++Zn}`,$n=[{center:`#6f5bea`,edge:`#34278f`,pattern:`#a89df5`,text:`#ffffff`},{center:`#32a86b`,edge:`#17613e`,pattern:`#8ee0b3`,text:`#ffffff`},{center:`#df8d2f`,edge:`#8c421e`,pattern:`#ffd08a`,text:`#ffffff`},{center:`#d95878`,edge:`#7b2944`,pattern:`#f5a1b6`,text:`#ffffff`}];function er(e){if(!e.length)return e;let t=Math.floor(1e3/e.length),n=1e3%e.length;return e.map((e,r)=>({...e,rarity:String(t+ +(r({key:Qn(e),name:``,rarity:`1`,sortOrder:String(t),file:null,animation:null,fileError:``});function nr(e){let t=e.reduce((e,t)=>{let n=Number(t.backdropID);return Number.isInteger(n)?Math.max(e,n):e},0)+1,n=$n[e.length%$n.length];return{key:Qn(`backdrop`),name:``,backdropID:String(t),rarity:`1`,sortOrder:String(e.length),...n}}var rr=e=>er([tr(e,0),tr(e,1)]),ir=()=>{let e=nr([]);return er([e,nr([e])])};function ar({data:e,compact:t=!1}){let n=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!n.current)return;let t=Xn.default.loadAnimation({container:n.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)});return()=>t.destroy()},[e]),(0,G.jsx)(`div`,{className:`collectible-animation ${t?`compact`:``}`,ref:n})}function or({giftID:e,attribute:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{let n=!1;return a(!1),k.giftCollectibleAnimation(e,t.kind,t.id).then(e=>{n||r(e)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t.id,t.kind]),i?(0,G.jsx)(`div`,{className:`collectible-animation compact failed`,children:`!`}):n?(0,G.jsx)(ar,{data:n,compact:!0}):(0,G.jsx)(`div`,{className:`collectible-animation compact loading`,children:(0,G.jsx)(R,{className:`spin`,size:15})})}async function sr(e){let t=new Uint8Array(await e.arrayBuffer()),n=t;if(t.length>=2&&t[0]===31&&t[1]===139){if(!(`DecompressionStream`in window))throw Error(`This browser cannot preview TGS files`);let e=new Blob([t]).stream().pipeThrough(new DecompressionStream(`gzip`));n=new Uint8Array(await new Response(e).arrayBuffer())}let r=JSON.parse(new TextDecoder().decode(n));if(!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid Lottie JSON`);return r}var cr=e=>Number.parseInt(e.replace(`#`,``),16),lr=e=>e.rarity_kind===`permille`?`${e.rarity_permille}‰`:e.rarity_kind,ur={models:`Models`,patterns:`Patterns`},dr={model:`Model`,pattern:`Pattern`,backdrop:`Backdrop`},fr={center:`Center`,edge:`Edge`,pattern:`Pattern`,text:`Text`};function pr({gift:e,onClose:t,onPublished:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(`100`),[h,_]=(0,g.useState)(`1000`),[v,y]=(0,g.useState)(`gift-${e.GiftID}`),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(()=>rr(`model`)),[w,T]=(0,g.useState)(()=>rr(`pattern`)),[E,D]=(0,g.useState)(ir);(0,g.useEffect)(()=>{let t=!1;return k.giftCollectibles(e.GiftID).then(n=>{t||(i(n),n.found&&(m(String(n.upgrade_stars??100)),_(String(n.supply_total??1e3)),y(n.slug_prefix??`gift-${e.GiftID}`)))}).catch(e=>u(O(e))).finally(()=>{t||o(!1)}),()=>{t=!0}},[e.GiftID]);let A=(0,g.useMemo)(()=>({models:S.reduce((e,t)=>e+Number(t.rarity||0),0),patterns:w.reduce((e,t)=>e+Number(t.rarity||0),0),backdrops:E.reduce((e,t)=>e+Number(t.rarity||0),0)}),[S,w,E]),j=()=>f(null),M=(e,t,n)=>{(e===`models`?C:T)(e=>e.map(e=>e.key===t?{...e,...n}:e)),j()};async function N(e,t,n){if(M(e,t.key,{file:n,animation:null,fileError:``}),n)try{let r=await sr(n);M(e,t.key,{animation:r,fileError:``})}catch(n){M(e,t.key,{animation:null,fileError:O(n)})}}function P(e,t=``){if(!b.trim())throw Error(`Please enter an operation reason`);if(S.length<2||w.length<2||E.length<2)throw Error(`Models, patterns, and backdrops must each contain at least two attributes.`);let n=E.map(e=>Number(e.backdropID));if(new Set(n).size!==n.length)throw Error(`Backdrop IDs must be unique within the pool.`);for(let e of[...S,...w])if(!e.file)throw Error(`Every model and pattern needs a TGS or Lottie file.`);let r=new FormData,i=e=>e.map(e=>({name:e.name.trim(),rarity_permille:Number(e.rarity),sort_order:Number(e.sortOrder),file_key:e.key}));r.set(`metadata`,JSON.stringify({command_id:t,reason:b.trim(),confirm:e,upgrade_stars:p,supply_total:Number(h),slug_prefix:v.trim().toLowerCase(),models:i(S),patterns:i(w),backdrops:E.map(e=>({name:e.name.trim(),backdrop_id:Number(e.backdropID),rarity_permille:Number(e.rarity),sort_order:Number(e.sortOrder),center_color:cr(e.center),edge_color:cr(e.edge),pattern_color:cr(e.pattern),text_color:cr(e.text)}))}));for(let e of[...S,...w])r.set(e.key,e.file,e.file.name);return r}async function F(){c(!0),u(``),f(null);try{f(await k.publishGiftCollectibles(e.GiftID,P(!1)))}catch(e){u(O(e))}finally{c(!1)}}async function I(){if(d){c(!0),u(``);try{await k.publishGiftCollectibles(e.GiftID,P(!0,d.command_id)),n(),t()}catch(e){u(O(e))}finally{c(!1)}}}let ee=(e,t,n)=>(0,G.jsxs)(`section`,{className:`collectible-section`,children:[(0,G.jsxs)(`div`,{className:`collectible-section-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:ur[e]}),(0,G.jsx)(`span`,{children:`Permille values are relative regular-upgrade weights; their total does not need to equal 1000.`})]}),(0,G.jsxs)(`div`,{className:`collectible-section-tools`,children:[(0,G.jsxs)(J,{tone:A[e]>0?`good`:`neutral`,children:[A[e],`‰`]}),(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>{n(er([...t,tr(e===`models`?`model`:`pattern`,t.length)])),j()},children:[(0,G.jsx)(Pe,{size:13}),`Add`]})]})]}),(0,G.jsx)(`div`,{className:`collectible-rows`,children:t.map((r,i)=>(0,G.jsxs)(`div`,{className:`collectible-row animated`,children:[(0,G.jsx)(`div`,{className:`collectible-row-index`,children:i+1}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`input`,{value:r.name,maxLength:128,onChange:t=>M(e,r.key,{name:t.target.value})})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Rarity ‰`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`1000`,value:r.rarity,onChange:t=>M(e,r.key,{rarity:t.target.value})})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Sort order`}),(0,G.jsx)(`input`,{type:`number`,value:r.sortOrder,onChange:t=>M(e,r.key,{sortOrder:t.target.value})})]}),(0,G.jsxs)(`label`,{className:`collectible-file`,children:[(0,G.jsx)(`span`,{children:`Animation file`}),(0,G.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.lottie,application/json,application/x-tgsticker`,onChange:t=>void N(e,r,t.target.files?.[0]??null)}),(0,G.jsxs)(`em`,{children:[(0,G.jsx)(ve,{size:13}),r.file?.name??`Choose file`]})]}),(0,G.jsx)(`div`,{className:`collectible-inline-preview`,children:r.animation?(0,G.jsx)(ar,{data:r.animation,compact:!0}):(0,G.jsx)(ne,{size:16})}),(0,G.jsx)(`button`,{className:`icon-btn danger`,type:`button`,disabled:t.length<=2,onClick:()=>{n(er(t.filter(e=>e.key!==r.key))),j()},"aria-label":`Remove attribute`,children:(0,G.jsx)(H,{size:14})}),r.fileError&&(0,G.jsx)(`span`,{className:`collectible-file-error`,children:r.fileError})]},r.key))})]});return(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal collectible-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Collectible pool · Gift #${e.GiftID}`,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Unique gift attributes`}),(0,G.jsx)(`h2`,{children:`Collectible pool · Gift #${e.GiftID}`}),(0,G.jsx)(`p`,{children:e.Title||`Gift #${e.GiftID}`})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,disabled:s,"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body collectible-modal-body`,children:[a?(0,G.jsxs)(`div`,{className:`collectible-loading`,children:[(0,G.jsx)(R,{className:`spin`}),`Loading`]}):r?.found?(0,G.jsxs)(`section`,{className:`collectible-active`,children:[(0,G.jsxs)(`div`,{className:`collectible-active-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(xe,{size:18}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Published revision ${r.revision??0}`}),(0,G.jsxs)(`span`,{children:[r.slug_prefix,` · ⭐ `,r.upgrade_stars,` · `,r.issued,` / `,r.supply_total]})]})]}),(0,G.jsx)(J,{tone:`good`,children:`Published`})]}),(0,G.jsxs)(`div`,{className:`collectible-active-grid`,children:[[...r.models??[],...r.patterns??[]].map(t=>(0,G.jsxs)(`article`,{children:[(0,G.jsx)(or,{giftID:e.GiftID,attribute:t}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`strong`,{children:[t.name,t.crafted&&(0,G.jsx)(J,{children:`crafted`})]}),(0,G.jsxs)(`span`,{children:[dr[t.kind],` · `,lr(t)]})]})]},`${t.kind}-${t.id}`)),(r.backdrops??[]).map(e=>(0,G.jsxs)(`article`,{children:[(0,G.jsx)(`div`,{className:`collectible-backdrop-preview`,style:{background:`radial-gradient(circle, #${(e.center_color??0).toString(16).padStart(6,`0`)}, #${(e.edge_color??0).toString(16).padStart(6,`0`)})`,color:`#${(e.text_color??16777215).toString(16).padStart(6,`0`)}`},children:`Aa`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.name}),(0,G.jsxs)(`span`,{children:[`Backdrop`,` · `,lr(e)]})]})]},`backdrop-${e.id}`))]})]}):(0,G.jsxs)(`div`,{className:`collectible-empty`,children:[(0,G.jsx)(xe,{size:22}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`No collectible pool published`}),(0,G.jsx)(`span`,{children:`Publish models, patterns and backdrops to enable upgrades.`})]})]}),(0,G.jsxs)(`section`,{className:`collectible-definition`,children:[(0,G.jsxs)(`div`,{className:`collectible-definition-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Publish a new immutable revision`}),(0,G.jsx)(`span`,{children:`Dry-run checks every file and rarity total before the revision becomes active.`})]}),(0,G.jsxs)(`div`,{className:`gift-format-chips`,children:[(0,G.jsx)(`span`,{children:`TGS`}),(0,G.jsx)(`span`,{children:`Lottie JSON`})]})]}),(0,G.jsxs)(`div`,{className:`gift-fields-grid collectible-main-fields`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Upgrade price in Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:p,onChange:e=>{m(e.target.value),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Unique supply`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:h,onChange:e=>{_(e.target.value),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Public slug prefix`}),(0,G.jsx)(`input`,{value:v,maxLength:48,onChange:e=>{y(e.target.value.toLowerCase()),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Audit reason`}),(0,G.jsx)(`input`,{value:b,maxLength:1e3,placeholder:`Briefly describe why this gift is being imported`,onChange:e=>x(e.target.value)})]})]}),ee(`models`,S,C),ee(`patterns`,w,T),(0,G.jsxs)(`section`,{className:`collectible-section`,children:[(0,G.jsxs)(`div`,{className:`collectible-section-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Backdrops`}),(0,G.jsx)(`span`,{children:`Colors are stored as 24-bit RGB values.`})]}),(0,G.jsxs)(`div`,{className:`collectible-section-tools`,children:[(0,G.jsxs)(J,{tone:A.backdrops>0?`good`:`neutral`,children:[A.backdrops,`‰`]}),(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>{D(er([...E,nr(E)])),j()},children:[(0,G.jsx)(Pe,{size:13}),`Add`]})]})]}),(0,G.jsx)(`div`,{className:`collectible-rows`,children:E.map((e,t)=>(0,G.jsxs)(`div`,{className:`collectible-row backdrop`,children:[(0,G.jsx)(`div`,{className:`collectible-row-index`,children:t+1}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`input`,{value:e.name,maxLength:128,onChange:t=>{D(E.map(n=>n.key===e.key?{...n,name:t.target.value}:n)),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Backdrop ID`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,value:e.backdropID,onChange:t=>{D(E.map(n=>n.key===e.key?{...n,backdropID:t.target.value}:n)),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Rarity ‰`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`1000`,value:e.rarity,onChange:t=>{D(E.map(n=>n.key===e.key?{...n,rarity:t.target.value}:n)),j()}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Sort order`}),(0,G.jsx)(`input`,{type:`number`,value:e.sortOrder,onChange:t=>{D(E.map(n=>n.key===e.key?{...n,sortOrder:t.target.value}:n)),j()}})]}),[`center`,`edge`,`pattern`,`text`].map(t=>(0,G.jsxs)(`label`,{className:`collectible-color`,children:[(0,G.jsx)(`span`,{children:fr[t]}),(0,G.jsx)(`input`,{type:`color`,value:e[t],onChange:n=>{D(E.map(r=>r.key===e.key?{...r,[t]:n.target.value}:r)),j()}})]},t)),(0,G.jsx)(`div`,{className:`collectible-backdrop-preview`,style:{background:`radial-gradient(circle, ${e.center}, ${e.edge})`,color:e.text},children:`Aa`}),(0,G.jsx)(`button`,{className:`icon-btn danger`,type:`button`,disabled:E.length<=2,onClick:()=>{D(er(E.filter(t=>t.key!==e.key))),j()},"aria-label":`Remove attribute`,children:(0,G.jsx)(H,{size:14})})]},e.key))})]})]}),l&&(0,G.jsx)(q,{children:l}),d&&(0,G.jsxs)(`div`,{className:`gift-validation`,children:[(0,G.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,G.jsx)(L,{size:17}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Attribute pool is valid`}),(0,G.jsx)(`span`,{children:`Review the normalized assets, then publish this immutable revision.`})]})]}),(0,G.jsx)(`pre`,{children:JSON.stringify(d.details,null,2)})]})]}),(0,G.jsxs)(`div`,{className:`modal-actions`,children:[(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:t,disabled:s,children:`Close`}),(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:F,disabled:s,children:[s?(0,G.jsx)(R,{className:`spin`,size:15}):(0,G.jsx)(Ue,{size:15}),`Dry-run validation`]}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:I,disabled:s||!d,children:[(0,G.jsx)($e,{size:15}),`Publish revision`]})]})]})}),document.body)}var mr={all:`All`,upgrade:`Upgradable`,craft:`Craftable`,basic:`Not upgradable`},hr=!1;function gr(e){return e.model_count+e.pattern_count+e.backdrop_count}function _r(e){let t=Number(e);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function vr({giftID:e,revision:t,compact:n=!1}){let r=(0,g.useRef)(null),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``);(0,g.useEffect)(()=>{let t=!1;return k.giftAnimation(e).then(e=>{t||!r.current||(i.current?.destroy(),i.current=Xn.default.loadAnimation({container:r.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)}))}).catch(e=>c(O(e))),()=>{t=!0,i.current?.destroy(),i.current=null}},[e,t]);function l(){i.current&&(a?i.current.pause():i.current.play(),o(!a))}return(0,G.jsxs)(`div`,{className:`gift-animation-shell ${n?`compact`:``}`,children:[(0,G.jsx)(`div`,{className:`gift-animation`,ref:r,children:s&&(0,G.jsx)(`span`,{children:s})}),(0,G.jsx)(`button`,{className:`gift-play`,type:`button`,onClick:l,"aria-label":a?`Pause`:`Play`,children:a?(0,G.jsx)(Me,{size:14}):(0,G.jsx)(Ne,{size:14})})]})}function Q({sourceGiftID:e}){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let n=!1,r=null;return k.officialGiftAnimation(e).then(e=>{n||!t.current||(r=Xn.default.loadAnimation({container:t.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)}))}).catch(()=>void 0),()=>{n=!0,r?.destroy()}},[e]),(0,G.jsx)(`div`,{className:`gift-animation-shell`,children:(0,G.jsx)(`div`,{className:`gift-animation`,ref:t})})}function yr(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(`official`),[f,p]=(0,g.useState)([]),[m,h]=(0,g.useState)(0),[_,y]=(0,g.useState)([]),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(`all`),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(!0),[A,j]=(0,g.useState)(`0`),[M,N]=(0,g.useState)(`0`),[P,F]=(0,g.useState)(``),[I,ee]=(0,g.useState)(`0`),[te,ne]=(0,g.useState)(``),[re,ie]=(0,g.useState)(`50`),[ae,oe]=(0,g.useState)(`50`),[se,ce]=(0,g.useState)(`0`),[le,ue]=(0,g.useState)(!0),[z,de]=(0,g.useState)(``),[me,he]=(0,g.useState)(null),[ge,_e]=(0,g.useState)(!1),[ye,be]=(0,g.useState)(``),[B,Se]=(0,g.useState)(``),[Ce,we]=(0,g.useState)(null),[Te,Ee]=(0,g.useState)([]),[De,Oe]=(0,g.useState)(!0),[ke,Ae]=(0,g.useState)(``),[je,Ne]=(0,g.useState)(!1),[Fe,Ie]=(0,g.useState)({done:0,total:0}),[ze,Be]=(0,g.useState)(``),[Ve,He]=(0,g.useState)(null),[V,We]=(0,g.useState)(new Set),[Ge,Ke]=(0,g.useState)(``),[qe,Je]=(0,g.useState)(!1),[Ye,Xe]=(0,g.useState)(``),[H,Ze]=(0,g.useState)(10),[Qe,et]=(0,g.useState)(1);async function tt(){be(``);try{t((await k.gifts()).Gifts??[])}catch(e){be(O(e))}}(0,g.useEffect)(()=>{tt()},[]),(0,g.useEffect)(()=>{!i||u!=="default"||f.length>0||k.defaultGifts().then(e=>p(e.gifts??[])).catch(e=>Se(O(e)))},[i,u,f.length]),(0,g.useEffect)(()=>{!i||u!==`official`||_.length>0||k.officialGifts().then(e=>y(e.gifts??[])).catch(e=>Se(O(e)))},[i,u,_.length]),(0,g.useMemo)(()=>f.find(e=>e.id===m)??null,[f,m]);let nt=(0,g.useMemo)(()=>_.find(e=>e.source_gift_id===w)??null,[_,w]),it=(0,g.useMemo)(()=>({all:_.length,upgrade:_.filter(e=>e.can_upgrade).length,craft:_.filter(e=>e.can_craft).length,basic:_.filter(e=>!e.can_upgrade).length}),[_]),U=(0,g.useMemo)(()=>{let e=b.trim().toLowerCase();return _.filter(t=>(S===`all`||S===`upgrade`&&t.can_upgrade||S===`craft`&&t.can_craft||S===`basic`&&!t.can_upgrade)&&(!e||t.source_gift_id.includes(e)||t.title.toLowerCase().includes(e)))},[_,b,S]),at=(0,g.useMemo)(()=>{let t=n.trim().toLowerCase();return t?e.filter(e=>String(e.GiftID).includes(t)||e.Title.toLowerCase().includes(t)||e.SourceFormat.toLowerCase().includes(t)):e},[e,n]);(0,g.useEffect)(()=>{et(1)},[n,H]);let ot=H===`all`?1:Math.max(1,Math.ceil(at.length/H)),st=Math.min(Qe,ot),ct=(0,g.useMemo)(()=>{if(H===`all`)return at;let e=(st-1)*H;return at.slice(e,e+H)},[at,st,H]),lt=ct.length===0?0:H===`all`?1:(st-1)*H+1,ut=lt===0?0:lt+ct.length-1,dt=ct.length>0&&ct.every(e=>V.has(e.GiftID));function ft(e){We(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pt(){We(e=>{if(dt){let t=new Set(e);for(let e of ct)t.delete(e.GiftID);return t}let t=new Set(e);for(let e of ct)t.add(e.GiftID);return t})}async function mt(e){if(!Ge.trim()){Xe(`Please enter an operation reason`);return}Je(!0),Xe(``);let t=Array.from(V),n=0;for(let r of t)try{await k.action(`/api/actions/set-gift-enabled`,{gift_id:r,enabled:e,reason:Ge.trim(),confirm:!0})}catch{n++}Je(!1),n>0?Xe(`${n} of ${t.length} failed`):(We(new Set),Ke(``)),await tt()}function ht(e,t=``){if(!c)throw Error(`Choose a TGS or Lottie file first`);if(!z.trim())throw Error(`Please enter an operation reason`);let n=new FormData;return n.set(`metadata`,JSON.stringify({command_id:t,reason:z.trim(),confirm:e,gift_id:I,title:te.trim(),stars:re,convert_stars:ae,enabled:le,sort_order:Number(se)})),n.set(`file`,c,c.name),n}function gt(e,t=``){if(!m)throw Error(`Choose a default gift first`);if(!z.trim())throw Error(`Please enter an operation reason`);return{command_id:t,reason:z.trim(),confirm:e,id:m}}function _t(e,t=``){if(!w)throw Error(`Choose an official gift first`);if(!z.trim())throw Error(`Please enter an operation reason`);return{command_id:t,reason:z.trim(),confirm:e,source_gift_id:w,gift_id:I,title:te.trim(),stars:re,convert_stars:ae,enabled:le,sort_order:Number(se),include_collectible:E,upgrade_stars:A,supply_total:Number(M),slug_prefix:P.trim().toLowerCase()}}function vt(e){T(e.source_gift_id),ne(e.title||`Unnamed official gift #${e.source_gift_id}`),ie(String(e.stars)),oe(String(e.convert_stars)),D(e.can_upgrade),j(e.upgrade_stars),N(String(e.availability_total||1)),F(`official-${e.source_gift_id}`),he(null)}async function yt(e){we(e),Ee([]),Oe(!0),Ae(``),Ne(!1),Ie({done:0,total:0}),Be(``),He(null);try{Ee(e==="default"?f.length>0?f:(await k.defaultGifts()).gifts??[]:_.length>0?_:(await k.officialGifts()).gifts??[])}catch(e){Be(O(e))}}function bt(){je||we(null)}async function Ct(){if(!Ce)return;if(!ke.trim()){Be(`Please enter an operation reason`);return}let e=Ce;Ne(!0),Be(``),He(null),Ie({done:0,total:Te.length});let t=0,n=0,r=0,i=[];for(let a of Te){let o=e==="default"?a.title:a.title||`#${a.source_gift_id}`;try{let r=e==="default"?await k.importDefaultGift({command_id:`bulk-default-gift-${a.id}`,reason:ke.trim(),confirm:!0,id:a.id,enabled:De}):await k.importOfficialGift({command_id:`bulk-official-gift-${a.source_gift_id}`,reason:ke.trim(),confirm:!0,source_gift_id:a.source_gift_id,include_collectible:a.can_upgrade,enabled:De});r.already_executed||r.details?.skipped?n++:t++}catch(e){e instanceof v&&e.message===`COMMAND_ID_CONFLICT`?n++:(r++,i.push(`${o}: ${O(e)}`))}Ie(e=>({...e,done:e.done+1}))}Ne(!1),He({imported:t,skipped:n,failed:r,errors:i}),await tt()}async function K(){_e(!0),Se(``),he(null);try{he(u==="default"?await k.importDefaultGift(gt(!1)):u===`official`?await k.importOfficialGift(_t(!1)):await k.importGift(ht(!1)))}catch(e){Se(O(e))}finally{_e(!1)}}async function wt(){if(me){_e(!0),Se(``);try{u==="default"?await k.importDefaultGift(gt(!0,me.command_id)):u===`official`?await k.importOfficialGift(_t(!0,me.command_id)):await k.importGift(ht(!0,me.command_id)),he(null),l(null),ee(`0`),ne(``),h(0),T(``),await tt(),a(!1)}catch(e){Se(O(e))}finally{_e(!1)}}}function X(){ee(`0`),ne(``),ie(`50`),oe(`50`),ce(`0`),ue(!0),de(``),l(null),he(null),Se(``),d(`official`),h(0),T(``),x(``),C(`all`),Ne(!1),Ie({done:0,total:0}),Be(``),a(!0)}function Tt(e){ee(e.GiftID),ne(e.Title),ie(String(e.Stars)),oe(String(e.ConvertStars)),ce(String(e.SortOrder)),ue(e.Enabled),de(``),l(null),he(null),Se(``),d(`file`),h(0),T(``),a(!0)}let Dt=u==="default"?m>0:u===`official`?!!w:!!c;return(0,G.jsxs)(xt,{title:`Star Gift Catalog`,eyebrow:`Catalog, immutable revisions and animation assets`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>tt(),disabled:ge,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:X,children:[(0,G.jsx)(Pe,{size:15}),` `,`Add gift`]})]}),children:[ye&&(0,G.jsx)(q,{children:ye}),(0,G.jsxs)(`div`,{className:`metric-row gift-metrics`,children:[(0,G.jsx)(Y,{label:`Catalog entries`,value:String(e.length)}),(0,G.jsx)(Y,{label:`Enabled`,value:String(e.filter(e=>e.Enabled).length),tone:`good`}),(0,G.jsx)(Y,{label:`Received gifts`,value:e.reduce((e,t)=>e+BigInt(t.ReceivedCount),0n).toString()}),(0,G.jsx)(Y,{label:`Accepted formats`,value:`TGS / Lottie`})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`div`,{className:`toolbar`,children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search gift ID, title or format`})]}),(0,G.jsxs)(`label`,{className:`gift-page-size`,children:[(0,G.jsx)(`span`,{children:`Per page`}),(0,G.jsxs)(`select`,{value:String(H),onChange:e=>Ze(e.target.value===`all`?`all`:Number(e.target.value)),children:[(0,G.jsx)(`option`,{value:`10`,children:`10`}),(0,G.jsx)(`option`,{value:`20`,children:`20`}),(0,G.jsx)(`option`,{value:`50`,children:`50`}),(0,G.jsx)(`option`,{value:`100`,children:`100`}),(0,G.jsx)(`option`,{value:`all`,children:`All`})]})]}),(0,G.jsx)(`span`,{className:`gift-list-summary`,children:`Showing ${at.length} of ${e.length}`})]})}),V.size>0&&(0,G.jsxs)(`div`,{className:`gift-bulk-toolbar`,children:[(0,G.jsx)(`span`,{className:`gift-bulk-count`,children:`${V.size} selected`}),(0,G.jsxs)(`label`,{className:`gift-reason-field gift-bulk-reason`,children:[(0,G.jsx)(`span`,{children:`Audit reason`}),(0,G.jsx)(`input`,{value:Ge,placeholder:`Briefly describe why this gift is being imported`,onChange:e=>Ke(e.target.value)})]}),(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>mt(!0),disabled:qe,children:[qe?(0,G.jsx)(R,{className:`spin`,size:14}):(0,G.jsx)(L,{size:14}),` `,`Enable selected`]}),(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>mt(!1),disabled:qe,children:[qe?(0,G.jsx)(R,{className:`spin`,size:14}):(0,G.jsx)(Me,{size:14}),` `,`Disable selected`]}),(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>{We(new Set),Xe(``)},disabled:qe,children:`Close`}),Ye&&(0,G.jsx)(`span`,{className:`gift-bulk-error`,children:Ye})]}),(0,G.jsx)(`div`,{className:`table-wrap gift-table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table gift-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`gift-select-col`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:dt,onChange:pt,"aria-label":`Select all visible gifts`})}),(0,G.jsx)(`th`,{children:`Animation file`}),(0,G.jsx)(`th`,{children:`ID / Revision`}),(0,G.jsx)(`th`,{children:`Display title`}),(0,G.jsx)(`th`,{children:`Price / Conversion`}),(0,G.jsx)(`th`,{children:`Source`}),(0,G.jsx)(`th`,{children:`Received gifts`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Updated`}),(0,G.jsx)(`th`,{children:`Actions`})]})}),(0,G.jsxs)(`tbody`,{children:[ct.map(e=>(0,G.jsxs)(`tr`,{className:e.Enabled?``:`gift-row-disabled`,children:[(0,G.jsx)(`td`,{className:`gift-select-col`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:V.has(e.GiftID),onChange:()=>ft(e.GiftID),"aria-label":`Select gift ${e.GiftID}`})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(vr,{giftID:e.GiftID,revision:e.Revision,compact:!0})}),(0,G.jsxs)(`td`,{className:`mono`,children:[e.GiftID,` / `,e.Revision]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{className:`gift-table-title`,children:e.Title||`Gift #${e.GiftID}`}),(0,G.jsxs)(`span`,{className:`gift-sort-order`,children:[`Sort order`,`: `,e.SortOrder]})]}),(0,G.jsxs)(`td`,{children:[(0,G.jsxs)(`strong`,{className:`gift-table-price`,children:[`⭐ `,e.Stars]}),(0,G.jsxs)(`span`,{className:`gift-convert-price`,children:[`→ `,e.ConvertStars]})]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(J,{children:e.SourceFormat}),(0,G.jsx)(`span`,{className:`gift-source-size`,children:_r(e.AnimationSize)})]}),(0,G.jsx)(`td`,{children:e.ReceivedCount}),(0,G.jsx)(`td`,{children:(0,G.jsx)(J,{tone:e.Enabled?`good`:`neutral`,children:e.Enabled?`Enabled`:`Disabled`})}),(0,G.jsx)(`td`,{children:W(e.UpdatedAt)}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`div`,{className:`gift-table-actions`,children:[(0,G.jsxs)(`button`,{className:`btn compact-btn collectible-button`,type:`button`,onClick:()=>s(e),children:[(0,G.jsx)(xe,{size:13}),`Attribute pool`]}),(0,G.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>Tt(e),children:`New revision`}),(0,G.jsx)(Z,{compact:!0,tone:`neutral`,label:e.Enabled?`Disable`:`Enable`,path:`/api/actions/set-gift-enabled`,payload:()=>({gift_id:e.GiftID,enabled:!e.Enabled}),onDone:()=>void tt()})]})})]},e.GiftID)),ct.length===0&&(0,G.jsx)(Et,{colSpan:10})]})]})}),H!==`all`&&at.length>0&&(0,G.jsxs)(`div`,{className:`gift-pager`,children:[(0,G.jsx)(`span`,{className:`gift-pager-range`,children:`Showing ${lt}-${ut} of ${at.length}`}),(0,G.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>et(e=>Math.max(1,e-1)),disabled:st<=1,children:[(0,G.jsx)(fe,{size:14}),` `,`Previous`]}),(0,G.jsx)(`span`,{className:`gift-pager-page`,children:`Page ${st} of ${ot}`}),(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>et(e=>Math.min(ot,e+1)),disabled:st>=ot,children:[`Next`,` `,(0,G.jsx)(pe,{size:14})]})]})]}),i&&(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal gift-import-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":I===`0`?`Import a Star Gift`:`Create revision for gift #${I}`,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Gift catalog operation`}),(0,G.jsx)(`h2`,{children:I===`0`?`Import a Star Gift`:`Create revision for gift #${I}`})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:()=>a(!1),disabled:ge,"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body gift-import-modal-body`,children:[(0,G.jsxs)(`div`,{className:`command-steps`,children:[(0,G.jsxs)(`div`,{className:`command-step ${Dt?`done`:`active`}`,children:[(0,G.jsx)(`span`,{children:`1`}),(0,G.jsx)(`strong`,{children:`File and details`})]}),(0,G.jsxs)(`div`,{className:`command-step ${me?`done`:Dt?`active`:``}`,children:[(0,G.jsx)(`span`,{children:`2`}),(0,G.jsx)(`strong`,{children:`Dry-run validation`})]}),(0,G.jsxs)(`div`,{className:`command-step ${me?`active`:``}`,children:[(0,G.jsx)(`span`,{children:`3`}),(0,G.jsx)(`strong`,{children:`Confirm import`})]})]}),I===`0`&&(0,G.jsxs)(`div`,{className:`gift-source-tabs`,children:[hr,(0,G.jsx)(`button`,{className:`btn ${u===`official`?`primary`:``}`,type:`button`,onClick:()=>{d(`official`),he(null)},children:`Official snapshot`}),(0,G.jsx)(`button`,{className:`btn ${u===`file`?`primary`:``}`,type:`button`,onClick:()=>{d(`file`),he(null)},children:`Upload file`})]}),u===`official`&&I===`0`?(0,G.jsxs)(`section`,{className:`official-gift-picker`,children:[(0,G.jsxs)(`div`,{className:`gift-import-note`,children:[(0,G.jsx)(`span`,{children:`Choose a verified gift from data/official-gifts. Complete collectible pools are imported atomically.`}),(0,G.jsxs)(`div`,{className:`gift-format-chips`,children:[(0,G.jsx)(`span`,{children:_.length}),(0,G.jsx)(`span`,{children:`SHA-256`})]})]}),(0,G.jsx)(`div`,{className:`official-gift-bulk-import`,children:(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>yt(`official`),children:[(0,G.jsx)($e,{size:14}),` `,`Import all official gifts`]})}),(0,G.jsxs)(`div`,{className:`official-gift-tools`,children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),placeholder:`Search official gift ID or title`})]}),(0,G.jsx)(`span`,{children:`Showing ${U.length} of ${_.length}`})]}),(0,G.jsx)(`div`,{className:`official-gift-categories`,role:`group`,"aria-label":`Official gift capability category`,children:[`all`,`upgrade`,`craft`,`basic`].map(e=>(0,G.jsxs)(`button`,{className:S===e?`active`:``,type:`button`,"aria-pressed":S===e,onClick:()=>C(e),children:[mr[e],(0,G.jsx)(`span`,{children:it[e]})]},e))}),(0,G.jsxs)(`div`,{className:`official-gift-list`,role:`listbox`,"aria-label":`Choose an official gift`,children:[U.map(e=>{let t=e.source_gift_id===w;return(0,G.jsxs)(`button`,{className:`official-gift-option ${t?`selected`:``}`,type:`button`,role:`option`,"aria-selected":t,onClick:()=>vt(e),children:[(0,G.jsxs)(`span`,{className:`official-gift-option-head`,children:[(0,G.jsx)(`strong`,{children:e.title||`Unnamed official gift #${e.source_gift_id}`}),(0,G.jsxs)(`span`,{className:`mono`,children:[`#`,e.source_gift_id]})]}),(0,G.jsxs)(`span`,{className:`official-gift-option-meta`,children:[(0,G.jsxs)(`span`,{children:[`⭐ `,e.stars]}),(0,G.jsx)(`span`,{children:`${gr(e)} attributes`})]}),(0,G.jsxs)(`span`,{className:`official-gift-capabilities`,children:[(0,G.jsx)(`span`,{className:e.can_upgrade?`yes`:`no`,children:e.can_upgrade?`Can upgrade`:`Cannot upgrade`}),(0,G.jsx)(`span`,{className:e.can_craft?`craft`:`no`,children:e.can_craft?`Can Craft`:`Cannot Craft`})]})]},e.source_gift_id)}),U.length===0&&(0,G.jsx)(`div`,{className:`official-gift-empty`,children:`No official gifts match this category and search.`})]}),nt&&(0,G.jsxs)(`div`,{className:`official-gift-selected`,children:[(0,G.jsx)(Q,{sourceGiftID:nt.source_gift_id}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:nt.title||`Unnamed official gift #${nt.source_gift_id}`}),(0,G.jsx)(`span`,{className:`mono`,children:nt.source_gift_id}),(0,G.jsxs)(`small`,{children:[nt.model_count,` `,`Models`,` · `,nt.pattern_count,` `,`Patterns`,` · `,nt.backdrop_count,` `,`Backdrops`]}),(0,G.jsxs)(`span`,{className:`official-gift-capabilities`,children:[(0,G.jsx)(`span`,{className:nt.can_upgrade?`yes`:`no`,children:nt.can_upgrade?`Can upgrade`:`Cannot upgrade`}),(0,G.jsx)(`span`,{className:nt.can_craft?`craft`:`no`,children:nt.can_craft?`Can Craft`:`Cannot Craft`})]})]})]}),nt?.can_upgrade&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>{D(e.target.checked),he(null)}}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Import the complete collectible pool, including crafted models`})]}),E&&(0,G.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Upgrade price in Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:A,onChange:e=>{j(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Unique supply`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:M,onChange:e=>{N(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Public slug prefix`}),(0,G.jsx)(`input`,{value:P,maxLength:48,onChange:e=>{F(e.target.value.toLowerCase()),he(null)}})]})]})]}),(0,G.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Display title`}),(0,G.jsx)(`input`,{value:te,maxLength:128,placeholder:`e.g. Celebration Star`,onChange:e=>{ne(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Price in Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:re,onChange:e=>{ie(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Conversion Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,value:ae,onChange:e=>{oe(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Sort order`}),(0,G.jsx)(`input`,{type:`number`,value:se,onChange:e=>{ce(e.target.value),he(null)}})]})]}),(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:le,onChange:e=>{ue(e.target.checked),he(null)}}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Enable after import`})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`gift-import-note`,children:[(0,G.jsx)(`span`,{children:`Upload TGS or plain Lottie JSON. Lottie is normalized and compressed to TGS.`}),(0,G.jsxs)(`div`,{className:`gift-format-chips`,"aria-label":`Accepted formats`,children:[(0,G.jsx)(`span`,{children:`TGS`}),(0,G.jsx)(`span`,{children:`Lottie JSON`})]})]}),(0,G.jsxs)(`label`,{className:`gift-file-picker ${c?`has-file`:``}`,children:[(0,G.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.lottie,application/json,application/x-tgsticker`,onChange:e=>{l(e.target.files?.[0]??null),he(null)}}),(0,G.jsx)(`span`,{className:`gift-file-icon`,children:(0,G.jsx)(ve,{size:22})}),(0,G.jsxs)(`span`,{className:`gift-file-copy`,children:[(0,G.jsx)(`span`,{className:`gift-field-label`,children:`Animation file`}),(0,G.jsx)(`strong`,{children:c?c.name:`Drop or choose a TGS / Lottie file`}),(0,G.jsx)(`small`,{children:c?_r(c.size):`TGS, JSON or Lottie · validated before import`})]}),(0,G.jsx)(`span`,{className:`gift-file-action`,children:c?`Change file`:`Choose file`})]}),(0,G.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Display title`}),(0,G.jsx)(`input`,{value:te,maxLength:128,placeholder:`e.g. Celebration Star`,onChange:e=>{ne(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Price in Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`1`,value:re,onChange:e=>{ie(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Conversion Stars`}),(0,G.jsx)(`input`,{type:`number`,min:`0`,value:ae,onChange:e=>{oe(e.target.value),he(null)}})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Sort order`}),(0,G.jsx)(`input`,{type:`number`,value:se,onChange:e=>{ce(e.target.value),he(null)}})]})]}),(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:le,onChange:e=>{ue(e.target.checked),he(null)}}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Enable after import`})]})]}),(0,G.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,G.jsx)(`span`,{children:`Audit reason`}),(0,G.jsx)(`input`,{value:z,placeholder:`Briefly describe why this gift is being imported`,onChange:e=>de(e.target.value)})]}),B&&(0,G.jsx)(q,{children:B}),me&&(0,G.jsxs)(`div`,{className:`gift-validation`,children:[(0,G.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,G.jsx)(L,{size:17}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Validation passed`}),(0,G.jsx)(`span`,{children:`Review the normalized metadata, then confirm the import.`})]})]}),(0,G.jsx)(`pre`,{children:JSON.stringify(me.details,null,2)})]})]}),(0,G.jsxs)(`div`,{className:`modal-actions`,children:[(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>a(!1),disabled:ge,children:`Close`}),(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:K,disabled:ge,children:[ge?(0,G.jsx)(R,{className:`spin`,size:15}):(0,G.jsx)(Ue,{size:15}),`Dry-run validation`]}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:wt,disabled:ge||!me,children:[(0,G.jsx)($e,{size:15}),`Confirm import`]})]})]})}),document.body),Ce&&(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal gift-bulk-import-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":Ce==="default"?`Import all default gifts`:`Import all official gifts`,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Gift catalog operation`}),(0,G.jsx)(`h2`,{children:Ce==="default"?`Import all default gifts`:`Import all official gifts`})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:bt,disabled:je,"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body`,children:[(0,G.jsx)(`div`,{className:`gift-import-note`,children:(0,G.jsx)(`span`,{children:`${Te.length} gifts available to import`})}),(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:De,disabled:je,onChange:e=>Oe(e.target.checked)}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Enable after import`})]}),(0,G.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,G.jsx)(`span`,{children:`Audit reason`}),(0,G.jsx)(`input`,{value:ke,placeholder:`Briefly describe why this gift is being imported`,disabled:je,onChange:e=>Ae(e.target.value)})]}),je&&(0,G.jsxs)(`div`,{className:`gift-bulk-import-progress`,children:[(0,G.jsx)(`div`,{className:`gift-bulk-import-progress-bar`,children:(0,G.jsx)(`div`,{style:{width:`${Fe.total?Math.round(Fe.done/Fe.total*100):0}%`}})}),(0,G.jsx)(`span`,{children:`Importing ${Fe.done} of ${Fe.total}`})]}),ze&&(0,G.jsx)(q,{children:ze}),Ve&&(0,G.jsxs)(`div`,{className:`gift-validation`,children:[(0,G.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,G.jsx)(L,{size:17}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Import complete`}),(0,G.jsx)(`span`,{children:`Imported ${Ve.imported}, skipped ${Ve.skipped}, failed ${Ve.failed}`})]})]}),Ve.errors.length>0&&(0,G.jsx)(`pre`,{children:Ve.errors.join(` +`)})]})]}),(0,G.jsxs)(`div`,{className:`modal-actions`,children:[(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:bt,disabled:je,children:`Close`}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:Ct,disabled:je||Te.length===0,children:[je?(0,G.jsx)(R,{className:`spin`,size:15}):(0,G.jsx)($e,{size:15}),` `,`Start import`]})]})]})}),document.body),o&&(0,G.jsx)(pr,{gift:o,onClose:()=>s(null),onPublished:()=>void tt()})]})}function br({documentID:e,className:t=``,showError:n=!0}){let r=(0,g.useRef)(null),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let t=!1,n=null;return o(``),c(null),fetch(k.stickerDocumentAnimationURL(e),{credentials:`same-origin`}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||e.statusText)}if((e.headers.get(`content-type`)??``).includes(`json`)){let n=await e.json();if(t||!r.current)return;i.current?.destroy(),i.current=Xn.default.loadAnimation({container:r.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:n});return}let a=await e.blob();t||(n=URL.createObjectURL(a),c(n))}).catch(e=>{t||o(O(e))}),()=>{t=!0,i.current?.destroy(),i.current=null,n&&URL.revokeObjectURL(n)}},[e]),(0,G.jsxs)(`div`,{className:`sticker-doc-cell ${t}`.trim(),children:[s?(0,G.jsx)(`img`,{className:`sticker-doc-image`,src:s,alt:``}):(0,G.jsx)(`div`,{className:`sticker-doc-canvas`,ref:r}),a&&n&&(0,G.jsx)(`span`,{className:`sticker-doc-error`,children:a})]})}function xr({kind:e,onClose:t,onCreated:n}){let r=e===`emoji`?`emoji`:`sticker`,[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(``);async function y(){if(!i.trim()||!o.trim()||!c.trim()||!u){v(`Title, short name, emoji and a first ${r} file are required.`);return}if(!f.trim()){v(`Please enter an operation reason`);return}h(!0),v(``);try{let r=new FormData;r.set(`metadata`,JSON.stringify({command_id:``,reason:f.trim(),confirm:!0,title:i.trim(),short_name:o.trim().toLowerCase(),kind:e,emoji:c.trim()})),r.set(`file`,u,u.name),await k.createStickerSet(r),n(),t()}catch(e){v(O(e))}finally{h(!1)}}return(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Create a new ${r} pack`,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`New set`}),(0,G.jsx)(`h2`,{children:`Create a new ${r} pack`})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,disabled:m,"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body`,children:[(0,G.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Title`}),(0,G.jsx)(`input`,{value:i,maxLength:64,onChange:e=>a(e.target.value)})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Short name`}),(0,G.jsx)(`input`,{value:o,maxLength:32,onChange:e=>s(e.target.value),placeholder:`lowercase_short_name`})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Emoji`}),(0,G.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`e.g. 😀`})]})]}),(0,G.jsxs)(`label`,{className:`gift-file-picker ${u?`has-file`:``}`,children:[(0,G.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.webp,application/json,application/x-tgsticker,image/webp`,onChange:e=>d(e.target.files?.[0]??null)}),(0,G.jsxs)(`span`,{className:`gift-file-copy`,children:[(0,G.jsx)(`span`,{className:`gift-field-label`,children:`First ${r}`}),(0,G.jsx)(`strong`,{children:u?u.name:`Choose a TGS, Lottie JSON, or WebP file`})]}),(0,G.jsx)(`span`,{className:`gift-file-action`,children:u?`Change file`:`Choose file`})]}),(0,G.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,G.jsx)(`span`,{children:`Audit reason`}),(0,G.jsx)(`input`,{value:f,placeholder:`Briefly describe why this gift is being imported`,onChange:e=>p(e.target.value)})]}),_&&(0,G.jsx)(q,{children:_})]}),(0,G.jsxs)(`div`,{className:`modal-actions`,children:[(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:t,disabled:m,children:`Close`}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:y,disabled:m,children:[m?(0,G.jsx)(R,{className:`spin`,size:15}):(0,G.jsx)($e,{size:15}),`Create ${r} pack`]})]})]})}),document.body)}var Sr=24;function Cr({set:e,onClose:t}){let n=e.Kind===`emoji`?`emoji`:`sticker`,[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(1),l=(0,g.useCallback)(()=>{let t=!1;return o(``),k.stickerSetDocuments(e.ID).then(e=>{t||i(e.document_ids??[])}).catch(e=>{t||o(O(e))}),()=>{t=!0}},[e.ID]);(0,g.useEffect)(()=>(i(null),c(1),l()),[l]);let u=r?.length??0,d=Math.max(1,Math.ceil(u/Sr)),f=Math.min(s,d),p=(f-1)*Sr,m=r?.slice(p,p+Sr)??[],h=m.length===0?0:p+1,_=h===0?0:h+m.length-1;return(0,en.createPortal)((0,G.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,G.jsxs)(`section`,{className:`modal command-modal sticker-preview-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e.Title||`#${e.ID}`,children:[(0,G.jsxs)(`div`,{className:`modal-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`eyebrow`,children:`Set contents`}),(0,G.jsx)(`h2`,{children:e.Title||`#${e.ID}`})]}),(0,G.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,"aria-label":`Close`,children:(0,G.jsx)(rt,{size:15})})]}),(0,G.jsxs)(`div`,{className:`command-body`,children:[(0,G.jsx)(wr,{setID:e.ID,noun:n,onAdded:l}),a&&(0,G.jsx)(q,{children:a}),!a&&r===null&&(0,G.jsxs)(`div`,{className:`loading-line`,children:[(0,G.jsx)(R,{className:`spin`,size:18}),` `,`Loading`]}),r!==null&&u===0&&!a&&(0,G.jsx)(`div`,{className:`empty-panel`,children:`This set has no documents.`}),m.length>0&&(0,G.jsx)(`div`,{className:`sticker-doc-grid`,children:m.map(t=>(0,G.jsxs)(`div`,{className:`sticker-doc-grid-cell`,children:[(0,G.jsx)(br,{documentID:t}),(0,G.jsx)(Z,{compact:!0,tone:`danger`,label:`Remove`,icon:(0,G.jsx)(H,{size:12}),path:`/api/actions/remove-sticker-from-set`,payload:()=>({set_id:e.ID,document_id:t}),onDone:l})]},t))},f),u>Sr&&(0,G.jsxs)(`div`,{className:`gift-pager`,children:[(0,G.jsx)(`span`,{className:`gift-pager-range`,children:`Showing ${h}-${_} of ${u}`}),(0,G.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>c(e=>Math.max(1,e-1)),disabled:f<=1,children:[(0,G.jsx)(fe,{size:14}),` `,`Previous`]}),(0,G.jsx)(`span`,{className:`gift-pager-page`,children:`Page ${f} of ${d}`}),(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>c(e=>Math.min(d,e+1)),disabled:f>=d,children:[`Next`,` `,(0,G.jsx)(pe,{size:14})]})]})]})]})]})}),document.body)}function wr({setID:e,noun:t,onAdded:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``);async function p(){if(!r){f(`Choose a ${t} file first`);return}if(!a.trim()){f(`An emoji is required.`);return}if(!s.trim()){f(`Please enter an operation reason`);return}u(!0),f(``);try{let t=new FormData;t.set(`metadata`,JSON.stringify({command_id:``,reason:s.trim(),confirm:!0,set_id:e,emoji:a.trim()})),t.set(`file`,r,r.name),await k.addStickerToSet(t),i(null),o(``),c(``),n()}catch(e){f(O(e))}finally{u(!1)}}return(0,G.jsxs)(`div`,{className:`sticker-add-form`,children:[(0,G.jsxs)(`label`,{className:`gift-file-picker compact ${r?`has-file`:``}`,children:[(0,G.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.webp,application/json,application/x-tgsticker,image/webp`,onChange:e=>i(e.target.files?.[0]??null)}),(0,G.jsx)(`span`,{className:`gift-file-copy`,children:(0,G.jsx)(`strong`,{children:r?r.name:`Choose a TGS, Lottie JSON, or WebP file`})})]}),(0,G.jsx)(`input`,{className:`small-input`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. 😀`}),(0,G.jsx)(`input`,{className:`small-input`,value:s,onChange:e=>c(e.target.value),placeholder:`Describe why this operation is being performed`}),(0,G.jsxs)(`button`,{className:`btn primary compact-btn`,type:`button`,onClick:p,disabled:l,children:[l?(0,G.jsx)(R,{className:`spin`,size:14}):(0,G.jsx)(Pe,{size:14}),` `,`Add ${t}`]}),d&&(0,G.jsx)(`span`,{className:`sticker-add-form-error`,children:d})]})}function Tr({kind:e}){let[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(10),[d,f]=(0,g.useState)(1),[p,m]=(0,g.useState)({}),[h,_]=(0,g.useState)({}),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),S=e===`emoji`?`Emoji`:`Stickers`,C=e===`emoji`?`Custom-emoji packs — system packs aren't shown here, they're not hand-edited`:`Sticker packs — system packs (dice, animated emoji, gifts) aren't shown here, they're not hand-edited`,w=e===`emoji`?`emoji`:`sticker`;async function T(){o(!0),c(``);try{n((await k.stickerSets(e)).rows??[])}catch(e){c(O(e))}finally{o(!1)}}(0,g.useEffect)(()=>{T()},[e]);let E=(0,g.useMemo)(()=>{let e=r.trim().toLowerCase();return e?t.filter(t=>String(t.ID).includes(e)||t.ShortName.toLowerCase().includes(e)||t.Title.toLowerCase().includes(e)):t},[t,r]);(0,g.useEffect)(()=>{f(1)},[r,l,e]);let D=l===`all`?1:Math.max(1,Math.ceil(E.length/l)),A=Math.min(d,D),j=(0,g.useMemo)(()=>{if(l===`all`)return E;let e=(A-1)*l;return E.slice(e,e+l)},[E,A,l]),M=j.length===0?0:l===`all`?1:(A-1)*l+1,N=M===0?0:M+j.length-1,P=(0,g.useMemo)(()=>({total:t.length,official:t.filter(e=>e.Official).length,archived:t.filter(e=>e.Archived).length}),[t]);return(0,G.jsxs)(xt,{title:S,eyebrow:C,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>T(),disabled:a,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),(0,G.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:()=>x(!0),children:[(0,G.jsx)(Pe,{size:15}),` `,`Create ${w} pack`]})]}),children:[s&&(0,G.jsx)(q,{children:s}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Total sets`,value:String(P.total)}),(0,G.jsx)(Y,{label:`Official`,value:String(P.official),tone:`good`}),(0,G.jsx)(Y,{label:`Archived`,value:String(P.archived),tone:P.archived>0?`warn`:`neutral`})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`div`,{className:`toolbar`,children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search set ID, short name or title`})]}),(0,G.jsxs)(`label`,{className:`gift-page-size`,children:[(0,G.jsx)(`span`,{children:`Per page`}),(0,G.jsxs)(`select`,{value:String(l),onChange:e=>u(e.target.value===`all`?`all`:Number(e.target.value)),children:[(0,G.jsx)(`option`,{value:`10`,children:`10`}),(0,G.jsx)(`option`,{value:`20`,children:`20`}),(0,G.jsx)(`option`,{value:`50`,children:`50`}),(0,G.jsx)(`option`,{value:`100`,children:`100`}),(0,G.jsx)(`option`,{value:`all`,children:`All`})]})]}),(0,G.jsx)(`span`,{className:`gift-list-summary`,children:`Showing ${E.length} of ${t.length}`})]})}),(0,G.jsx)(`div`,{className:`table-wrap gift-table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Logo`}),(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Short name`}),(0,G.jsx)(`th`,{children:`Title`}),(0,G.jsx)(`th`,{children:`Documents`}),(0,G.jsx)(`th`,{children:`Official`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Sort order`}),(0,G.jsx)(`th`,{children:`Actions`})]})}),(0,G.jsxs)(`tbody`,{children:[j.map(e=>(0,G.jsxs)(`tr`,{className:e.Archived?`gift-row-disabled`:``,children:[(0,G.jsx)(`td`,{children:e.CoverDocumentID?(0,G.jsx)(br,{documentID:e.CoverDocumentID,className:`list-thumb`,showError:!1}):(0,G.jsx)(`div`,{className:`sticker-list-thumb-empty`,children:(0,G.jsx)(we,{size:14})})}),(0,G.jsx)(`td`,{className:`mono`,children:e.ID}),(0,G.jsx)(`td`,{className:`mono`,children:e.ShortName||(0,G.jsx)(`span`,{className:`muted-cell`,children:`None`})}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`div`,{className:`sort-order-editor`,children:[(0,G.jsx)(`input`,{className:`small-input title-input`,value:h[e.ID]??e.Title,onChange:t=>_(n=>({...n,[e.ID]:t.target.value}))}),(0,G.jsx)(Z,{compact:!0,tone:`neutral`,label:`Save`,path:`/api/actions/rename-sticker-set`,payload:()=>({set_id:e.ID,title:(h[e.ID]??e.Title).trim()}),onDone:()=>void T()})]})}),(0,G.jsx)(`td`,{children:e.Count}),(0,G.jsx)(`td`,{children:e.Official?(0,G.jsx)(J,{tone:`good`,children:`Yes`}):(0,G.jsx)(J,{children:`No`})}),(0,G.jsx)(`td`,{children:e.Archived?(0,G.jsx)(J,{tone:`danger`,children:`Archived`}):(0,G.jsx)(J,{tone:`good`,children:`Enabled`})}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`div`,{className:`sort-order-editor`,children:[(0,G.jsx)(`input`,{type:`number`,className:`small-input`,value:p[e.ID]??String(e.SortOrder),onChange:t=>m(n=>({...n,[e.ID]:t.target.value}))}),(0,G.jsx)(Z,{compact:!0,tone:`neutral`,label:`Save`,path:`/api/actions/set-sticker-set-sort-order`,payload:()=>({set_id:e.ID,sort_order:Number(p[e.ID]??e.SortOrder)}),onDone:()=>void T()})]})}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`div`,{className:`gift-table-actions`,children:[(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>y(e),children:[(0,G.jsx)(_e,{size:13}),` `,`View`]}),(0,G.jsx)(Z,{compact:!0,tone:`neutral`,label:e.Archived?`Unarchive`:`Archive`,path:`/api/actions/set-sticker-set-archived`,payload:()=>({set_id:e.ID,archived:!e.Archived}),onDone:()=>void T()}),(0,G.jsx)(Z,{compact:!0,tone:`danger`,label:`Delete`,path:`/api/actions/delete-sticker-set`,payload:()=>({set_id:e.ID}),onDone:()=>void T()})]})})]},e.ID)),j.length===0&&(0,G.jsx)(Et,{colSpan:9})]})]})}),l!==`all`&&E.length>0&&(0,G.jsxs)(`div`,{className:`gift-pager`,children:[(0,G.jsx)(`span`,{className:`gift-pager-range`,children:`Showing ${M}-${N} of ${E.length}`}),(0,G.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>f(e=>Math.max(1,e-1)),disabled:A<=1,children:[(0,G.jsx)(fe,{size:14}),` `,`Previous`]}),(0,G.jsx)(`span`,{className:`gift-pager-page`,children:`Page ${A} of ${D}`}),(0,G.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>f(e=>Math.min(D,e+1)),disabled:A>=D,children:[`Next`,` `,(0,G.jsx)(pe,{size:14})]})]})]}),v&&(0,G.jsx)(Cr,{set:v,onClose:()=>y(null)}),b&&(0,G.jsx)(xr,{kind:e,onClose:()=>x(!1),onCreated:()=>void T()})]})}function Er({loader:e,cacheKey:t,className:n,playOnHover:r=!0,onError:i}){let a=(0,g.useRef)(null),o=(0,g.useRef)(null);(0,g.useEffect)(()=>{let t=!1;return e().then(e=>{t||!a.current||(o.current?.destroy(),o.current=Xn.default.loadAnimation({container:a.current,renderer:`canvas`,loop:!0,autoplay:!1,animationData:structuredClone(e)}),o.current.goToAndStop(0,!0))}).catch(()=>i?.()),()=>{t=!0,o.current?.destroy(),o.current=null}},[t]);function s(){r&&o.current?.play()}function c(){r&&o.current?.goToAndStop(0,!0)}return(0,G.jsx)(`div`,{className:n,ref:a,onMouseEnter:s,onMouseLeave:c})}var Dr=`777000`;function Or(e){let t=e.rarity_permille>0?` · ${(e.rarity_permille/10).toFixed(1)}%`:``;return`${e.name||`#${e.id}`}${t}`}function kr({gift:e,onDone:t}){let[n,r]=(0,g.useState)(`user`),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(`0`),[x,S]=(0,g.useState)(`0`),[C,w]=(0,g.useState)(`0`),[T,E]=(0,g.useState)(``),[D,A]=(0,g.useState)(null),[j,M]=(0,g.useState)(``),[N,P]=(0,g.useState)(!1),F=n===`user`?i?.ID??0:o?.ID??0,ee=n===`user`&&f;(0,g.useEffect)(()=>{p(!1),h(null),v(``),b(`0`),S(`0`),w(`0`),A(null),M(``)},[e.GiftID]),(0,g.useEffect)(()=>{if(!ee||m)return;let t=!1;return v(``),k.giftCollectibles(e.GiftID).then(e=>{t||h(e)}).catch(e=>{t||v(O(e))}),()=>{t=!0}},[ee,m,e.GiftID]);function te(t){return{gift_id:e.GiftID,sender_user_id:Number(Dr),user_id:n===`user`?F:0,channel_id:n===`channel`?F:0,hide_name:u,message:c.trim(),upgrade:ee,model_attribute_id:ee?y:`0`,pattern_attribute_id:ee?x:`0`,backdrop_attribute_id:ee?C:`0`,reason:T.trim(),confirm:t}}let ne=(0,g.useMemo)(()=>te(!1),[e.GiftID,n,F,c,u,f,y,x,C,T]),re=D?.dry_run&&!D.error;async function ie(e){if(F<=0){M(`Select a recipient first`);return}if(!T.trim()){M(`Please enter an operation reason`);return}P(!0),M(``);try{let n=await k.action(`/api/actions/give-gift`,te(e));A(n),e&&!n.error&&t?.()}catch(e){M(O(e))}finally{P(!1)}}return(0,G.jsxs)(`div`,{className:`give-gift-form`,children:[(0,G.jsxs)(`div`,{className:`give-gift-summary`,children:[(0,G.jsx)(B,{size:16}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.Title||`Gift #${e.GiftID}`}),(0,G.jsxs)(`span`,{className:`mono`,children:[`#`,e.GiftID,` · ⭐ `,e.Stars]})]})]}),(0,G.jsxs)(`div`,{className:`give-gift-tabs`,role:`group`,"aria-label":`Recipient type`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn ${n===`user`?`primary`:``}`,onClick:()=>{r(`user`),A(null)},children:[(0,G.jsx)(et,{size:15}),` `,`User`]}),(0,G.jsxs)(`button`,{type:`button`,className:`btn ${n===`channel`?`primary`:``}`,onClick:()=>{r(`channel`),p(!1),A(null)},children:[(0,G.jsx)(tt,{size:15}),` `,`Channel`]})]}),n===`user`?(0,G.jsx)(kn,{label:`Recipient user`,value:i,onChange:e=>{a(e),A(null)}}):(0,G.jsx)(jn,{label:`Recipient channel`,value:o,onChange:e=>{s(e),A(null)}}),(0,G.jsxs)(`label`,{className:`form-field`,children:[(0,G.jsx)(`span`,{children:`Sender account ID`}),(0,G.jsx)(`input`,{value:Dr,disabled:!0,readOnly:!0}),(0,G.jsx)(`small`,{className:`field-hint`,children:`Gifts are always sent from the system account 777000 (Telesrv).`})]}),(0,G.jsxs)(`label`,{className:`form-field`,children:[(0,G.jsx)(`span`,{children:`Attached message (optional)`}),(0,G.jsx)(`textarea`,{value:c,rows:2,maxLength:128,onChange:e=>{l(e.target.value),A(null)},placeholder:`Shown with the gift`})]}),(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>{d(e.target.checked),A(null)}}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Hide sender name from recipient`})]}),n===`user`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`gift-switch`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>{p(e.target.checked),e.target.checked||(b(`0`),S(`0`),w(`0`)),A(null)}}),(0,G.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,G.jsx)(`span`,{})}),(0,G.jsx)(`span`,{children:`Deliver as upgraded collectible`})]}),f&&(0,G.jsx)(`p`,{className:`give-gift-upgrade-note`,children:`The gift is minted as a unique collectible. Pick specific attributes below, or leave them on Random to draw from the published pool. The collectible number is assigned automatically. Requires a published collectible upgrade with remaining supply.`}),f&&_&&(0,G.jsx)(q,{children:_}),f&&m&&(0,G.jsxs)(`div`,{className:`gift-fields-grid give-gift-attrs`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Model`}),(0,G.jsxs)(`select`,{value:y,onChange:e=>{b(e.target.value),A(null)},children:[(0,G.jsx)(`option`,{value:`0`,children:`Random`}),(m.models??[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:Or(e)},e.id))]})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Pattern`}),(0,G.jsxs)(`select`,{value:x,onChange:e=>{S(e.target.value),A(null)},children:[(0,G.jsx)(`option`,{value:`0`,children:`Random`}),(m.patterns??[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:Or(e)},e.id))]})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsx)(`span`,{children:`Backdrop`}),(0,G.jsxs)(`select`,{value:C,onChange:e=>{w(e.target.value),A(null)},children:[(0,G.jsx)(`option`,{value:`0`,children:`Random`}),(m.backdrops??[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:Or(e)},e.id))]})]})]})]}),(0,G.jsxs)(`label`,{className:`form-field`,children:[(0,G.jsx)(`span`,{children:`Operation reason`}),(0,G.jsx)(`textarea`,{value:T,rows:2,onChange:e=>E(e.target.value),placeholder:`Describe why this operation is being performed`})]}),(0,G.jsxs)(`div`,{className:`command-preview`,children:[(0,G.jsx)(`div`,{className:`preview-head`,children:`Request preview`}),(0,G.jsx)(Ot,{value:JSON.stringify(ne,null,2)})]}),j&&(0,G.jsx)(q,{children:j}),D&&(0,G.jsxs)(`div`,{className:`result-box`,children:[(0,G.jsxs)(`div`,{className:`result-title`,children:[D.error?(0,G.jsx)(I,{size:16}):(0,G.jsx)(L,{size:16}),(0,G.jsx)(`strong`,{children:D.message||D.error||`Action result`})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Command ID`}),(0,G.jsx)(`strong`,{children:D.command_id})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsx)(`strong`,{children:D.status})]}),(0,G.jsxs)(`div`,{className:`result-line`,children:[(0,G.jsx)(`span`,{children:`Dry-run`}),(0,G.jsx)(`strong`,{children:D.dry_run?`Yes`:`No`})]}),D.details&&(0,G.jsx)(Ot,{value:JSON.stringify(D.details,null,2)})]}),(0,G.jsxs)(`div`,{className:`give-gift-form-actions`,children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>ie(!1),disabled:N,children:[N?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Ne,{size:15}),D?`Run dry-run again`:`Run dry-run first`]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`button`,onClick:()=>ie(!0),disabled:N||!re,children:[(0,G.jsx)(B,{size:15}),`Give gift`]})]})]})}function Ar(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1);async function u(){l(!0),s(``);try{let e=(await k.gifts()).Gifts??[];t(e),a(t=>t??e[0]??null)}catch(e){s(O(e))}finally{l(!1)}}(0,g.useEffect)(()=>{u()},[]);let d=(0,g.useMemo)(()=>{let t=n.trim().toLowerCase();return t?e.filter(e=>String(e.GiftID).includes(t)||e.Title.toLowerCase().includes(t)):e},[e,n]);return(0,G.jsxs)(xt,{title:`Give Gifts`,eyebrow:`Grant catalog gifts to any user or channel`,actions:(0,G.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>u(),disabled:c,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]}),children:[o&&(0,G.jsx)(q,{children:o}),(0,G.jsx)(`p`,{className:`give-gift-upgrade-note`,children:`Pick a gift to grant. Delivery is free of charge and sent from the system account 777000 (Telesrv) by default.`}),(0,G.jsxs)(`div`,{className:`give-gift-layout`,children:[(0,G.jsxs)(`section`,{className:`give-gift-picker`,children:[(0,G.jsxs)(`div`,{className:`give-gift-picker-head`,children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search by title or gift ID`})]}),(0,G.jsx)(`span`,{className:`gift-list-summary`,children:`Showing ${d.length} of ${e.length}`})]}),(0,G.jsxs)(`div`,{className:`give-gift-picker-list`,role:`listbox`,"aria-label":`Select a gift`,children:[d.map(e=>{let t=i?.GiftID===e.GiftID;return(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`give-gift-option ${t?`selected`:``} ${e.Enabled?``:`gift-row-disabled`}`,onClick:()=>a(e),children:[(0,G.jsx)(Er,{className:`give-gift-thumb`,cacheKey:`${e.GiftID}:${e.Revision}`,loader:()=>k.giftAnimation(e.GiftID)}),(0,G.jsxs)(`span`,{className:`give-gift-option-info`,children:[(0,G.jsx)(`strong`,{children:e.Title||`Gift #${e.GiftID}`}),(0,G.jsxs)(`span`,{className:`mono`,children:[`#`,e.GiftID]})]}),(0,G.jsx)(`span`,{className:`give-gift-option-price`,children:e.Enabled?(0,G.jsxs)(J,{children:[`⭐ `,e.Stars]}):(0,G.jsx)(J,{tone:`neutral`,children:`Disabled`})})]},e.GiftID)}),d.length===0&&!c&&(0,G.jsx)(`div`,{className:`official-gift-empty`,children:`No results`})]})]}),(0,G.jsx)(`section`,{className:`give-gift-panel`,children:i?(0,G.jsx)(kr,{gift:i,onDone:()=>void u()},i.GiftID):(0,G.jsxs)(`div`,{className:`give-gift-empty-panel`,children:[(0,G.jsx)(B,{size:26}),(0,G.jsx)(`p`,{children:`Select a gift from the list to start.`})]})})]})]})}var jr=`open,in_review,action_pending,action_failed,appeal_review`,Mr=[{value:jr,label:`Active queue`},{value:`open,in_review,action_pending,action_failed,resolved,dismissed,appeal_review`,label:`All statuses`},{value:`open`,label:`Open`},{value:`in_review`,label:`In review`},{value:`action_pending`,label:`Action pending`},{value:`action_failed`,label:`Action failed`},{value:`appeal_review`,label:`Appeal review`},{value:`resolved`,label:`Resolved`},{value:`dismissed`,label:`Dismissed`}];function Nr({navigate:e}){let[t,n]=(0,g.useState)(jr),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)([]),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(``);async function d(){c(!0),u(``);try{let e=new URLSearchParams({statuses:t,limit:`100`});r.trim()&&e.set(`assigned_to`,r.trim()),o((await k.moderationCases(e)).cases)}catch(e){u(O(e))}finally{c(!1)}}(0,g.useEffect)(()=>{d()},[]);let f=a.filter(e=>e.Status===`action_pending`||e.Status===`action_failed`).length,p=a.filter(e=>e.Severity===4).length;return(0,G.jsxs)(xt,{title:`Reports and Moderation`,eyebrow:`Moderation / Cases`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:d,disabled:s,children:[(0,G.jsx)(Le,{size:15,className:s?`spin`:``}),` `,`Refresh`]}),children:[l&&(0,G.jsx)(q,{children:l}),(0,G.jsxs)(`div`,{className:`metric-row`,children:[(0,G.jsx)(Y,{label:`Current queue`,value:String(a.length)}),(0,G.jsx)(Y,{label:`Critical cases`,value:String(p),tone:p?`danger`:`neutral`}),(0,G.jsx)(Y,{label:`Pending / failed actions`,value:String(f),tone:f?`warn`:`good`})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsx)(`select`,{"aria-label":`Case status filter`,value:t,onChange:e=>n(e.target.value),children:Mr.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Reviewer`}),(0,G.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Leave blank for all`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:s,children:[(0,G.jsx)(He,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Case`}),(0,G.jsx)(`th`,{children:`Target`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Severity`}),(0,G.jsx)(`th`,{children:`Reports / Reporters`}),(0,G.jsx)(`th`,{children:`Reviewer`}),(0,G.jsx)(`th`,{children:`Latest report`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[a.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`td`,{className:`mono`,children:[`#`,t.ID]}),(0,G.jsx)(`td`,{className:`mono`,children:zr(t.Target.Type,t.Target.ID)}),(0,G.jsx)(`td`,{children:(0,G.jsx)(Pr,{status:t.Status})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(Ir,{value:t.Severity})}),(0,G.jsxs)(`td`,{children:[t.ReportCount,` / `,t.DistinctReporterCount]}),(0,G.jsx)(`td`,{children:t.AssignedTo||`-`}),(0,G.jsx)(`td`,{children:W(t.LastReportAt)}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/moderation/${t.ID}`),children:[`Review`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),a.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})})]})}function Pr({status:e}){return(0,G.jsx)(J,{tone:e===`resolved`||e===`dismissed`?`good`:e===`action_failed`?`danger`:e===`action_pending`?`warn`:`neutral`,children:Rr(`status`,e)})}var Fr={low:`Low`,medium:`Medium`,high:`High`,critical:`Critical`};function Ir({value:e}){let t=[``,`low`,`medium`,`high`,`critical`][e];return(0,G.jsx)(J,{tone:e>=4?`danger`:e>=3?`warn`:`neutral`,children:t?Fr[t]:e})}var Lr={status:{open:`Open`,in_review:`In review`,action_pending:`Action pending`,action_failed:`Action failed`,appeal_review:`Appeal review`,resolved:`Resolved`,dismissed:`Dismissed`},targetType:{channel:`Channel`,chat:`Group`,user:`Account`},source:{account_peer:`Account / peer`,antispam_false_positive:`Anti-spam false positive`,channel_spam:`Channel spam`,encrypted_spam:`Encrypted-chat spam`,ephemeral:`Ephemeral media`,messages:`Messages`,messages_spam:`Message spam`,profile_photo:`Profile photo`,reaction:`Reaction`,sponsored:`Sponsored message`,story:`Story`},reason:{child_abuse:`Child abuse`,copyright:`Copyright`,fake:`Fake`,geo_irrelevant:`Location-irrelevant`,illegal_drugs:`Illegal drugs`,other:`Other`,personal_details:`Personal details`,pornography:`Pornography`,spam:`Spam`,violence:`Violence`}};function Rr(e,t){return Lr[e]?.[t]??t}function zr(e,t){return`${Rr(`targetType`,e)} #${t}`}function Br({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(`no_violation`),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(!0),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(``);function x(e){a(e),e&&(d(e.Items.filter(e=>e.Kind===`message`).map(e=>Number(e.ItemID)).filter(e=>Number.isSafeInteger(e)&&e>0).join(`, `)),p(String(e.ReporterUserID)))}async function S(){b(``);try{let t=await k.moderationCase(e);r(t);let n=t.ReportIDs[0];x(n?await k.moderationReport(n):null)}catch(e){b(O(e))}}(0,g.useEffect)(()=>{S()},[e]);let C=(0,g.useMemo)(()=>Vr(c,n?.Case.Target.Type,Hr(u),Number(f),m),[c,n?.Case.Target.Type,u,f,m]),w=(0,g.useMemo)(()=>n?Ur(n):{actions:[],label:`None`,blocked:!1},[n]);async function T(){if(n){v(!0),b(``);try{await k.claimModerationCase(e,n.Case.Version),await S()}catch(e){b(O(e))}finally{v(!1)}}}async function E(){if(!n||!o.trim()){b(`A review reason is required.`);return}if(c===`delete_messages`&&C.length===0){b(n.Case.Target.Type===`user`?`Private-message deletion requires valid evidence message IDs and the reporter's owner_user_id.`:`Channel-message deletion requires at least one valid evidence message ID.`);return}if(window.confirm(`Submit the “${Wr(c)}” decision? The action will run through the durable action queue.`)){v(!0),b(``);try{r((await k.decideModerationCase(e,{expected_version:n.Case.Version,reason:o.trim(),kind:c===`no_violation`?`no_violation`:`violation`,actions:C})).case),s(``)}catch(e){b(O(e))}finally{v(!1)}}}async function D(t,i){if(!n||!o.trim()){b(`An appeal review reason is required.`);return}if(window.confirm(i?`Grant this appeal?`:`Deny this appeal?`)){v(!0);try{r((await k.reviewModerationAppeal(e,t,{expected_version:n.Case.Version,reason:o.trim(),granted:i,actions:i?w.actions:[]})).case),s(``)}catch(e){b(O(e))}finally{v(!1)}}}if(y&&!n)return(0,G.jsx)(q,{children:y});if(!n)return(0,G.jsx)(Dt,{label:`Loading moderation case…`});let A=n.Case,j=A.Status===`open`||A.Status===`in_review`||A.Status===`appeal_review`,M=(A.Status===`in_review`||A.Status===`action_failed`)&&!!A.AssignedTo,N=M&&(A.Status!==`action_failed`||c!==`no_violation`),P=n.Appeals.find(e=>e.Status===`pending`);return(0,G.jsxs)(xt,{title:`Review case #${A.ID}`,eyebrow:`Moderation / Case detail`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/moderation`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to queue`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,onClick:S,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]})]}),children:[y&&(0,G.jsx)(q,{children:y}),(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:zr(A.Target.Type,A.Target.ID)}),(0,G.jsx)(`div`,{className:`entity-subtitle`,children:`Version ${A.Version} · Updated ${W(A.UpdatedAt)}`})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(Pr,{status:A.Status}),(0,G.jsx)(Ir,{value:A.Severity})]})]}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Target`,value:zr(A.Target.Type,A.Target.ID),mono:!0}),(0,G.jsx)(X,{label:`Reports`,value:`${A.ReportCount} reports from ${A.DistinctReporterCount} reporters`}),(0,G.jsx)(X,{label:`Reviewer`,value:A.AssignedTo||`-`}),(0,G.jsx)(X,{label:`First / latest report`,value:`${W(A.FirstReportAt)} / ${W(A.LastReportAt)}`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Report evidence`,text:`Shows up to the latest 100 reports; snapshots are frozen when reports are admitted.`}),(0,G.jsx)(`div`,{className:`toolbar`,children:n.ReportIDs.map(e=>(0,G.jsxs)(`button`,{className:`btn`,onClick:async()=>x(await k.moderationReport(e)),children:[`#`,e]},e))}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Source / Reason`,value:`${Rr(`source`,i.Source)} / ${Rr(`reason`,i.Reason)}`}),(0,G.jsx)(X,{label:`Reporter`,value:String(i.ReporterUserID),mono:!0}),(0,G.jsx)(X,{label:`Option`,value:i.Option,mono:!0}),(0,G.jsx)(X,{label:`Time`,value:W(i.CreatedAt)})]}),i.Comment&&(0,G.jsx)(`p`,{className:`about-text`,children:i.Comment}),(0,G.jsx)(Ot,{value:JSON.stringify(i,null,2)})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Decision and action audit`,text:`Actions run idempotently through a lease worker; failures retain their error and attempt count.`}),(0,G.jsx)(Ot,{value:JSON.stringify({decisions:n.Decisions,actions:n.Actions},null,2)})]}),n.Appeals.length>0&&(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Appeals`}),(0,G.jsx)(Ot,{value:JSON.stringify(n.Appeals,null,2)})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Case actions`}),j&&(0,G.jsxs)(`button`,{className:`btn primary icon-text`,disabled:_,onClick:T,children:[(0,G.jsx)(Ue,{size:15}),` `,A.AssignedTo?`Renew claim`:`Claim case`]}),(0,G.jsxs)(`label`,{className:`field`,children:[(0,G.jsx)(`span`,{children:`Review reason`}),(0,G.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),rows:5})]}),(0,G.jsxs)(`label`,{className:`field`,children:[(0,G.jsx)(`span`,{children:`Decision template`}),(0,G.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,G.jsx)(`option`,{value:`no_violation`,children:`No violation (dismiss report)`}),(0,G.jsx)(`option`,{value:`scam`,children:`Mark as SCAM`}),(0,G.jsx)(`option`,{value:`fake`,children:`Mark as FAKE`}),(0,G.jsx)(`option`,{value:`freeze`,children:`Freeze account`}),(0,G.jsx)(`option`,{value:`scam_freeze`,children:`SCAM + freeze`}),(0,G.jsx)(`option`,{value:`fake_freeze`,children:`FAKE + freeze`}),(0,G.jsx)(`option`,{value:`delete_messages`,children:`Delete messages covered by evidence`}),(0,G.jsx)(`option`,{value:`delete_account`,children:`Delete account`})]})]}),c===`delete_messages`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`field`,children:[(0,G.jsx)(`span`,{children:`Evidence message IDs (comma-separated)`}),(0,G.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`101, 102`})]}),A.Target.Type===`user`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`field`,children:[(0,G.jsx)(`span`,{children:`Private-chat owner_user_id`}),(0,G.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),inputMode:`numeric`})]}),(0,G.jsxs)(`label`,{className:`field checkbox-field`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),(0,G.jsx)(`span`,{children:`Revoke for both sides`})]})]}),(0,G.jsx)(q,{children:`The server will verify again that every message ID exists in this case's immutable report evidence.`})]}),A.Status===`action_failed`&&c===`no_violation`&&(0,G.jsx)(q,{children:`The action was partially executed and cannot be changed directly to no violation. Select a new action to retry while retaining the previous failure audit.`}),M&&(0,G.jsxs)(`button`,{className:`btn danger icon-text`,disabled:_||!N,onClick:E,children:[(0,G.jsx)(L,{size:15}),` `,A.Status===`action_failed`?`Retry action`:`Submit decision`]}),P&&A.AssignedTo&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Appeal review #${P.ID}`}),(0,G.jsx)(X,{label:`Automatic remedy after approval`,value:w.label}),w.blocked&&(0,G.jsx)(q,{children:`The case contains a completed irreversible deletion. It cannot be marked as approved and restored; deny it or escalate for manual handling.`}),(0,G.jsx)(`button`,{className:`btn`,disabled:_,onClick:()=>D(P.ID,!1),children:`Deny appeal`}),(0,G.jsx)(`button`,{className:`btn primary`,disabled:_||w.blocked,onClick:()=>D(P.ID,!0),children:`Grant appeal`})]})]})})]})}function Vr(e,t,n,r,i){switch(e){case`scam`:return[{kind:`mark_scam`,payload:{}}];case`fake`:return[{kind:`mark_fake`,payload:{}}];case`freeze`:return[{kind:`freeze_account`,payload:{}}];case`scam_freeze`:return[{kind:`mark_scam`,payload:{}},{kind:`freeze_account`,payload:{}}];case`fake_freeze`:return[{kind:`mark_fake`,payload:{}},{kind:`freeze_account`,payload:{}}];case`delete_messages`:return n.length===0?[]:t===`channel`?[{kind:`delete_channel_message`,payload:{ids:n}}]:t===`user`&&Number.isSafeInteger(r)&&r>0?[{kind:`delete_private_message`,payload:{owner_user_id:r,ids:n,revoke:i}}]:[];case`delete_account`:return[{kind:`delete_account`,payload:{}}];default:return[]}}function Hr(e){let t=e.split(/[,\s]+/).filter(Boolean).map(Number);return t.length===0||t.some(e=>!Number.isSafeInteger(e)||e<=0)?[]:[...new Set(t)]}function Ur(e){let t=!1,n=!1,r=!1;for(let i of[...e.Actions].sort((e,t)=>e.ID-t.ID))if(i.Status===`succeeded`)switch(i.Kind){case`mark_scam`:case`mark_fake`:t=!0;break;case`clear_peer_flags`:t=!1;break;case`freeze_account`:n=!0;break;case`unfreeze_account`:n=!1;break;case`delete_private_message`:case`delete_channel_message`:case`delete_account`:r=!0;break}let i=[],a=[];return t&&(i.push({kind:`clear_peer_flags`,payload:{}}),a.push(`Clear SCAM / FAKE`)),n&&(i.push({kind:`unfreeze_account`,payload:{}}),a.push(`Unfreeze account`)),{actions:i,label:a.join(` + `)||`No recovery action needed`,blocked:r}}function Wr(e){return{no_violation:`No violation (dismiss report)`,scam:`Mark as SCAM`,fake:`Mark as FAKE`,freeze:`Freeze account`,scam_freeze:`SCAM + freeze`,fake_freeze:`FAKE + freeze`,delete_messages:`Delete messages covered by evidence`,delete_account:`Delete account`}[e]}var Gr=[`pending`,`approved`,`rejected`,`revoked`],Kr=[`user`,`channel`],qr={pending:`Pending`,approved:`Approved`,rejected:`Rejected`,revoked:`Mark revoked`},Jr={user:`Account`,channel:`Channel`};function Yr({navigate:e}){let{can:t}=Ft(),n=t(Mt),r=t(At),[i,a]=(0,g.useState)(`requests`),[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1);async function m(){d(``),p(!1);try{let[e,t]=await Promise.all([k.botVerifiers(new URLSearchParams({limit:`200`})),k.verificationIcons(new URLSearchParams({limit:`200`}))]);s(e.rows??[]),l(t.rows??[])}catch(e){if(e instanceof v&&e.status===403){s([]),l([]),p(!0);return}d(O(e))}}return(0,g.useEffect)(()=>{m()},[]),(0,G.jsxs)(xt,{title:`Third-party verification`,eyebrow:`Third-party verification / Verifiers, icons, marks`,actions:r?(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>e(`/verification`),children:[(0,G.jsx)(ge,{size:15}),` `,`Official verification`]}):void 0,children:[u&&(0,G.jsx)(q,{children:u}),f&&(0,G.jsx)(q,{children:`The server refused the verifier roster and the icon catalogue for this session (403), so both lists are empty here — applications can still be reviewed.`}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`A verifier company's icon — not the official checkmark`,text:`A third-party mark is a verifier bot's own icon, drawn right BEFORE the name of an account, a bot or a channel, plus one line of description in the profile. It says “this verifier vouches for this peer”, and nothing more.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The icon is a custom emoji document. The client fetches it through messages.getCustomEmojiDocuments, so a document id that resolves to nothing renders as no badge at all — which is why marks are granted from the catalogue below rather than from a typed number.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The official checkmark is a different mechanism, granted by the platform in the Verification section. The two are stored, shown and taken away separately, and neither one implies the other.`}),!n&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This session can read the section and decide applications, but not change verifiers or the icon catalogue — that needs the botverification.manage permission.`})]}),(0,G.jsx)(`div`,{className:`toolbar`,role:`group`,"aria-label":`Third-party verification`,children:[{key:`requests`,label:`Applications`,icon:(0,G.jsx)(qe,{size:15})},{key:`verifiers`,label:`Verifiers`,icon:(0,G.jsx)(ce,{size:15})},{key:`icons`,label:`Icon catalogue`,icon:(0,G.jsx)(Ye,{size:15})},{key:`marks`,label:`Granted marks`,icon:(0,G.jsx)(F,{size:15})}].map(e=>(0,G.jsxs)(`button`,{className:`btn icon-text ${i===e.key?`primary`:``}`,type:`button`,"aria-pressed":i===e.key,onClick:()=>a(e.key),children:[e.icon,` `,e.label]},e.key))}),i===`requests`&&(0,G.jsx)(Xr,{navigate:e,verifiers:o}),i===`verifiers`&&(0,G.jsx)(Zr,{verifiers:o,icons:c,canManage:n,onChanged:m,navigate:e}),i===`icons`&&(0,G.jsx)(Qr,{icons:c,verifiers:o,canManage:n,onChanged:m}),i===`marks`&&(0,G.jsx)($r,{verifiers:o,canManage:n,navigate:e})]})}function Xr({navigate:e,verifiers:t}){let[n,r]=(0,g.useState)(`pending`),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`all`),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(`50`),[f,p]=(0,g.useState)([]),[m,h]=(0,g.useState)({}),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(``);async function T(e=!1){S(!0),w(``);let t=new URLSearchParams({limit:u});n!==`all`&&t.set(`status`,n),i&&t.set(`verifier_bot_id`,i),o!==`all`&&t.set(`peer_type`,o),c.trim()&&t.set(`q`,c.trim().replace(/^@/,``)),e&&y&&t.set(`before_id`,y);try{let n=await k.customVerificationRequests(t),r=n.rows??[];p(t=>e?[...t,...r]:r),b(n.next_before_id??``),v(!!n.has_more)}catch(e){w(O(e))}finally{S(!1)}}async function E(){try{h((await k.botVerificationCounts()).counts??{})}catch(e){w(O(e))}}(0,g.useEffect)(()=>{T(!1),E()},[]);function D(){T(!1),E()}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Application queue`,text:`Applications filed with a verifier bot by the owner of the peer. The counters cover the whole queue, not the page below.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:D,disabled:x,children:[(0,G.jsx)(Le,{size:15,className:x?`spin`:``}),` `,`Refresh`]})}),C&&(0,G.jsx)(q,{children:C}),(0,G.jsx)(`div`,{className:`metric-row`,children:Gr.map(e=>(0,G.jsx)(Y,{label:qr[e],value:m[e]??`0`,mono:!0,tone:ri(e,m[e]??`0`)},e))})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),T(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Application id, peer id, username or title`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All statuses`}),Gr.map(e=>(0,G.jsx)(`option`,{value:e,children:qr[e]},e))]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Verifier`}),(0,G.jsx)(ei,{value:i,verifiers:t,onChange:a})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Peer type`}),(0,G.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All types`}),Kr.map(e=>(0,G.jsx)(`option`,{value:e,children:Jr[e]},e))]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:u,onChange:e=>d(e.target.value),type:`number`,min:`1`,max:`200`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:x,children:[x?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Verifier`}),(0,G.jsx)(`th`,{children:`Peer`}),(0,G.jsx)(`th`,{children:`Applicant`}),(0,G.jsx)(`th`,{children:`Stated reason`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Filed`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[f.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/bot-verification/${t.ID}`),children:[`#`,t.ID]})}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{children:U(t.VerifierBotUsername)||t.VerifierBotID}),(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:t.VerifierBotID})]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{children:ii(t)}),(0,G.jsxs)(`div`,{className:`entity-subtitle mono`,children:[Jr[t.PeerType],` · `,t.PeerID]})]}),(0,G.jsxs)(`td`,{children:[U(t.ApplicantUsername)||`-`,(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:t.ApplicantUserID})]}),(0,G.jsx)(`td`,{className:`truncate`,children:t.Reason||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsx)(ti,{status:t.Status})}),(0,G.jsx)(`td`,{children:W(t.CreatedAt)||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/bot-verification/${t.ID}`),children:[(0,G.jsx)(qe,{size:14}),` `,`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),f.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})}),_&&(0,G.jsx)(`div`,{className:`toolbar`,children:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>T(!0),disabled:x,children:[x?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(de,{size:15}),` `,`Load more`]})})]})}function Zr({verifiers:e,icons:t,canManage:n,onChanged:r,navigate:i}){let[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),v=t.filter(e=>e.Active),y=v.map(e=>({value:e.DocumentID,label:`${e.Name} · ${e.DocumentID}`}));if(l&&!y.some(e=>e.value===l)){let e=t.find(e=>e.DocumentID===l);y.unshift({value:l,label:`${e?.Name??l} · ${l} (Retired)`})}function b(e){c(e),o(null),u(e.IconDocumentID),f(e.CompanyName),m(e.DefaultDescription),_(e.CanModifyCustomDescription)}function x(){c(null),o(null),u(``),f(``),m(``),_(!1)}function S(){return{bot_id:s?s.BotID:a?String(a.ID):`0`,icon_document_id:l||`0`,company_name:d.trim(),default_description:p.trim(),can_modify_custom_description:h,version:s?s.Version:`0`}}return(0,G.jsxs)(G.Fragment,{children:[n&&(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:s?`Update verifier`:`Grant verifier status`,text:`The bot gets an icon from the catalogue and a company name to vouch under. The same call updates an existing verifier, which is why it carries a version.`,action:s?(0,G.jsx)(`button`,{className:`btn icon-text`,type:`button`,onClick:x,children:`Cancel update`}):void 0}),s?(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Updating ${U(s.BotUsername)||s.BotID} — version ${s.Version} is sent as the optimistic lock, so a row somebody else changed meanwhile is refused instead of overwritten.`}):(0,G.jsx)(An,{label:`Bot`,value:a,onChange:o}),(0,G.jsxs)(`div`,{className:`bot-create-fields`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Icon from the catalogue`}),(0,G.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`Pick an icon`}),y.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Company`}),(0,G.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`Acme Verification Ltd`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Default description`}),(0,G.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`Verified by Acme`})]})]}),(0,G.jsxs)(`label`,{className:`checkline`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked)}),`The verifier may replace the description per peer`]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This is botVerifierSettings.can_modify_custom_description: with it off, every mark this verifier grants carries the default description above, whatever the applicant asked for.`}),v.length===0&&(0,G.jsx)(q,{children:`The catalogue has no active icon, so there is nothing to grant. Add one in the icon catalogue first.`}),(0,G.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,G.jsx)(`span`,{className:`bot-create-note`,children:`The bot can mark peers as soon as the row exists and is enabled.`}),(0,G.jsx)(Z,{label:s?`Update verifier`:`Grant verifier status`,icon:(0,G.jsx)(Pe,{size:15}),tone:`neutral`,path:`/api/actions/grant-bot-verifier`,payload:S,onDone:()=>{x(),r()}})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Verifier bots`,text:`Bots allowed to hand out their own mark. Verifier status is granted per deployment, so every row here is a badge printer an operator switched on by hand.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:r,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Bot`}),(0,G.jsx)(`th`,{children:`Company`}),(0,G.jsx)(`th`,{children:`Icon`}),(0,G.jsx)(`th`,{children:`Own description`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Marks`}),(0,G.jsx)(`th`,{children:`Granted by`}),(0,G.jsx)(`th`,{children:`Updated`}),n&&(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`button`,{className:`row-link`,type:`button`,onClick:()=>i(`/bots/${e.BotID}`),children:(0,G.jsx)(`strong`,{children:U(e.BotUsername)||e.BotName||e.BotID})}),(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:e.BotID})]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{children:e.CompanyName||`-`}),(0,G.jsx)(`div`,{className:`entity-subtitle truncate`,children:e.DefaultDescription||`Not set`})]}),(0,G.jsxs)(`td`,{children:[e.IconName||`-`,(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:e.IconDocumentID})]}),(0,G.jsx)(`td`,{children:e.CanModifyCustomDescription?`Yes`:`No`}),(0,G.jsx)(`td`,{children:e.Enabled?(0,G.jsx)(J,{tone:`good`,children:`Enabled`}):(0,G.jsx)(J,{tone:`warn`,children:`disabled`})}),(0,G.jsx)(`td`,{className:`mono`,children:String(e.MarkCount??`0`)}),(0,G.jsxs)(`td`,{children:[e.GrantedBy||`-`,(0,G.jsx)(`div`,{className:`entity-subtitle truncate`,children:e.GrantReason||`-`})]}),(0,G.jsx)(`td`,{children:W(e.UpdatedAt)||`-`}),n&&(0,G.jsx)(`td`,{children:(0,G.jsxs)(`div`,{className:`row-actions`,children:[(0,G.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>b(e),children:`Edit`}),(0,G.jsx)(Z,{label:e.Enabled?`Disable`:`Enable`,icon:e.Enabled?(0,G.jsx)(Fe,{size:14}):(0,G.jsx)(Ie,{size:14}),tone:e.Enabled?`warn`:`neutral`,compact:!0,path:`/api/actions/set-bot-verifier-enabled`,payload:()=>({bot_id:e.BotID,enabled:!e.Enabled}),onDone:r}),(0,G.jsx)(Z,{label:`Revoke status`,icon:(0,G.jsx)(H,{size:14}),tone:`danger`,compact:!0,path:`/api/actions/revoke-bot-verifier`,payload:()=>({bot_id:e.BotID}),onDone:r})]})})]},e.BotID)),e.length===0&&(0,G.jsx)(Et,{colSpan:n?9:8})]})]})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Disabling is the per-verifier kill switch: the marks already granted keep rendering, but the bot can no longer mark anything new and its settings stop being projected into botInfo.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Revoking verifier status removes the row and every mark this verifier granted — the icon disappears from all of its peers at once.`})]})]})}function Qr({icons:e,verifiers:t,canManage:n,onChanged:r}){let[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``);function u(){let e={document_id:i.trim()||`0`,name:o.trim()};return c&&(e.owner_bot_id=c),e}return(0,G.jsxs)(G.Fragment,{children:[n&&(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Add or rename an icon`,text:`The document id has to name a real custom emoji document on this deployment; the Emoji section lists them with their ids. Adding an id that already exists renames it instead of duplicating it.`}),(0,G.jsxs)(`div`,{className:`bot-create-fields`,children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Document ID`}),(0,G.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),inputMode:`numeric`,placeholder:`5361371319611781774`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Acme blue tick`})]}),(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Owner`}),(0,G.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`Shared`}),t.map(e=>(0,G.jsx)(`option`,{value:e.BotID,children:`${e.CompanyName||e.BotID} · ${U(e.BotUsername)||e.BotID}`},e.BotID))]})]})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`A document id that resolves to nothing produces an invisible badge: the peer is marked in the database and the client draws nothing.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`A shared icon may be granted to any verifier; picking an owner reserves it for that one bot.`}),(0,G.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,G.jsx)(`span`,{className:`bot-create-note`,children:`Adding an icon grants nothing by itself — it only makes the document available to grant.`}),(0,G.jsx)(Z,{label:`Save icon`,icon:(0,G.jsx)(Pe,{size:15}),tone:`neutral`,path:`/api/actions/upsert-verification-icon`,payload:u,onDone:()=>{a(``),s(``),l(``),r()}})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Icon catalogue`,text:`The custom emoji documents a verifier may mark with. Nothing else can be used as an icon, so the catalogue is where a wrong badge is prevented rather than fixed.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:r,children:[(0,G.jsx)(Le,{size:15}),` `,`Refresh`]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Document ID`}),(0,G.jsx)(`th`,{children:`Name`}),(0,G.jsx)(`th`,{children:`Owner`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Verifiers using it`}),(0,G.jsx)(`th`,{children:`Filed`}),n&&(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:e.DocumentID}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`strong`,{children:e.Name||`-`})}),(0,G.jsx)(`td`,{children:e.OwnerBotID&&e.OwnerBotID!==`0`?(0,G.jsxs)(G.Fragment,{children:[U(e.OwnerBotUsername)||e.OwnerBotID,(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:e.OwnerBotID})]}):(0,G.jsx)(J,{children:`Shared`})}),(0,G.jsx)(`td`,{children:e.Active?(0,G.jsx)(J,{tone:`good`,children:`Active`}):(0,G.jsx)(J,{tone:`warn`,children:`Retired`})}),(0,G.jsx)(`td`,{className:`mono`,children:String(e.UsedByVerifiers??`0`)}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)||`-`}),n&&(0,G.jsx)(`td`,{children:(0,G.jsx)(`div`,{className:`row-actions`,children:(0,G.jsx)(Z,{label:e.Active?`Retire`:`Activate`,icon:e.Active?(0,G.jsx)(Fe,{size:14}):(0,G.jsx)(Ie,{size:14}),tone:e.Active?`warn`:`neutral`,compact:!0,path:`/api/actions/set-verification-icon-active`,payload:()=>({icon_id:e.ID,active:!e.Active}),onDone:r})})})]},e.ID)),e.length===0&&(0,G.jsx)(Et,{colSpan:n?7:6})]})]})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Retiring an icon stops it from being granted to anybody new. Marks already carrying it keep it: the icon is copied onto the mark when it is granted.`})]})]})}function $r({verifiers:e,canManage:t,navigate:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(`all`),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(`50`),[d,f]=(0,g.useState)([]),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(``);async function S(e=!1){y(!0),x(``);let t=new URLSearchParams({limit:l});r&&t.set(`verifier_bot_id`,r),a!==`all`&&t.set(`peer_type`,a),s.trim()&&t.set(`q`,s.trim().replace(/^@/,``)),e&&h&&t.set(`before_id`,h);try{let n=await k.customVerifications(t),r=n.rows??[];f(t=>e?[...t,...r]:r),_(n.next_before_id??``),m(!!n.has_more)}catch(e){x(O(e))}finally{y(!1)}}return(0,g.useEffect)(()=>{S(!1)},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Granted marks`,text:`Every peer currently carrying a third-party mark, whoever granted it — an operator decision, the verifier bot itself, or the peer's owner through bots.setCustomVerification.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>S(!1),disabled:v,children:[(0,G.jsx)(Le,{size:15,className:v?`spin`:``}),` `,`Refresh`]})}),b&&(0,G.jsx)(q,{children:b})]}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),S(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Peer id, username or title`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Verifier`}),(0,G.jsx)(ei,{value:r,verifiers:e,onChange:i})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Peer type`}),(0,G.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All types`}),Kr.map(e=>(0,G.jsx)(`option`,{value:e,children:Jr[e]},e))]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:l,onChange:e=>u(e.target.value),type:`number`,min:`1`,max:`200`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:v,children:[v?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Verifier`}),(0,G.jsx)(`th`,{children:`Peer`}),(0,G.jsx)(`th`,{children:`Description`}),(0,G.jsx)(`th`,{children:`Icon`}),(0,G.jsx)(`th`,{children:`Filed`}),t&&(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[d.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsxs)(`td`,{className:`mono`,children:[`#`,e.ID]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{children:e.CompanyName||U(e.VerifierBotUsername)||e.VerifierBotID}),(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:U(e.VerifierBotUsername)||e.VerifierBotID})]}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`button`,{className:`row-link`,type:`button`,onClick:()=>n(ai(e.PeerType,e.PeerID)),children:(0,G.jsx)(`strong`,{children:ii(e)})}),(0,G.jsxs)(`div`,{className:`entity-subtitle mono`,children:[Jr[e.PeerType],` · `,e.PeerID]})]}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Description||`Not set`}),(0,G.jsx)(`td`,{className:`mono`,children:e.IconDocumentID}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)||`-`}),t&&(0,G.jsx)(`td`,{children:(0,G.jsx)(`div`,{className:`row-actions`,children:(0,G.jsx)(Z,{label:`Remove mark`,icon:(0,G.jsx)(oe,{size:14}),tone:`danger`,compact:!0,path:`/api/actions/revoke-custom-verification`,payload:()=>({verifier_bot_id:e.VerifierBotID,peer_type:e.PeerType,peer_id:e.PeerID}),onDone:()=>S(!1)})})})]},e.ID)),d.length===0&&(0,G.jsx)(Et,{colSpan:t?7:6})]})]})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Removing a mark clears the icon and the description from the peer. The application it came from keeps its history.`}),p&&(0,G.jsx)(`div`,{className:`toolbar`,children:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>S(!0),disabled:v,children:[v?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(de,{size:15}),` `,`Load more`]})})]})}function ei({value:e,verifiers:t,onChange:n}){return(0,G.jsxs)(`select`,{value:e,onChange:e=>n(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`All verifiers`}),t.map(e=>(0,G.jsx)(`option`,{value:e.BotID,children:`${e.CompanyName||e.BotID} · ${U(e.BotUsername)||e.BotID}`+(e.Enabled?``:` (disabled)`)},e.BotID))]})}function ti({status:e}){return(0,G.jsx)(J,{tone:ni(e),children:qr[e]})}function ni(e){return e===`approved`?`good`:e===`pending`?`warn`:e===`rejected`?`danger`:`neutral`}function ri(e,t){return e===`pending`?t!==`0`&&t!==``?`warn`:`neutral`:e===`approved`?`good`:`neutral`}function ii(e){return U(e.PeerUsername)||e.PeerTitle||`#${e.PeerID}`}function ai(e,t){return e===`channel`?`/channels/${t}`:`/accounts/${t}`}function oi({id:e,navigate:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(``);async function f(){l(!0),d(``);try{r(await k.customVerificationRequest(e))}catch(e){d(O(e))}finally{l(!1)}}function p(){s(!1),f()}(0,g.useEffect)(()=>{f()},[e]);function m(e){if(e instanceof v&&e.status===409)return s(!0),f(),`Another admin has already changed this application. The data has been reloaded — check the status before deciding again.`}if(u&&!n)return(0,G.jsx)(q,{children:u});if(!n)return(0,G.jsx)(Dt,{label:`Loading the application…`});let h=n.request,_=ci(n.verifier),y=n.mark_active,b=h.Status===`pending`,x=h.Status===`approved`,S=i.trim(),C=h.RequestedDescription.trim(),w=!!_?.CanModifyCustomDescription&&C!==``,T=w?C:(_?.DefaultDescription??``).trim();function E(){let e={version:h.Version};return S&&(e.internal_note=S),e}function D(){a(``),s(!1),f()}return(0,G.jsxs)(xt,{title:`Application #${h.ID}`,eyebrow:`Third-party verification / Review`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/bot-verification`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:p,disabled:c,children:[(0,G.jsx)(Le,{size:15,className:c?`spin`:``}),` `,`Refresh`]})]}),children:[u&&(0,G.jsx)(q,{children:u}),o&&(0,G.jsx)(q,{children:`Another admin has already changed this application. The data has been reloaded — check the status before deciding again.`}),(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:ii(h)}),(0,G.jsxs)(`div`,{className:`entity-subtitle mono`,children:[`#`,h.ID,` · `,Jr[h.PeerType],`:`,h.PeerID,` · v`,h.Version]})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(ti,{status:h.Status}),y?(0,G.jsxs)(J,{tone:`good`,children:[(0,G.jsx)(F,{size:12}),` `,`Mark is live`]}):(0,G.jsx)(J,{tone:`neutral`,children:`No mark on the peer`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`A verifier company's icon — not the official checkmark`,text:`A third-party mark is a verifier bot's own icon, drawn right BEFORE the name of an account, a bot or a channel, plus one line of description in the profile. It says “this verifier vouches for this peer”, and nothing more.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The icon is a custom emoji document. The client fetches it through messages.getCustomEmojiDocuments, so a document id that resolves to nothing renders as no badge at all — which is why marks are granted from the catalogue below rather than from a typed number.`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Verifier`,text:`The company whose icon the peer would carry, as its row stands right now.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/bots/${h.VerifierBotID}`),children:[(0,G.jsx)(ce,{size:15}),` `,`Open verifier bot`]})}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Company`,value:_?.CompanyName||`-`}),(0,G.jsx)(X,{label:`Bot`,value:U(h.VerifierBotUsername)||`-`}),(0,G.jsx)(X,{label:`Verifier bot ID`,value:h.VerifierBotID,mono:!0}),(0,G.jsx)(X,{label:`Document ID`,value:_?.IconDocumentID||`-`,mono:!0}),(0,G.jsx)(X,{label:`Name`,value:_?.IconName||`-`}),(0,G.jsx)(X,{label:`Own description`,value:_?.CanModifyCustomDescription?`Yes`:`No`})]}),(0,G.jsx)(si,{label:`Default description`,children:_?.DefaultDescription?(0,G.jsx)(`p`,{className:`about-text`,children:_.DefaultDescription}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not set`})}),!_&&(0,G.jsx)(q,{children:`The verifier row is gone: its status was revoked after this application was filed. There is no icon to grant, so the application can only be rejected.`}),_&&!_.Enabled&&(0,G.jsx)(q,{children:`This verifier is disabled. It cannot mark anything new until an operator enables it again.`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Peer`,text:`The account, bot or channel the icon would be attached to.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(ai(h.PeerType,h.PeerID)),children:[(0,G.jsx)(ge,{size:15}),` `,`Open peer`]})}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Type`,value:Jr[h.PeerType]}),(0,G.jsx)(X,{label:`Username`,value:U(h.PeerUsername)||`-`}),(0,G.jsx)(X,{label:`Title`,value:h.PeerTitle||`-`}),(0,G.jsx)(X,{label:`Peer ID`,value:h.PeerID,mono:!0})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Applicant`,text:`Who filed the application with the verifier bot.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/accounts/${h.ApplicantUserID}`),children:[(0,G.jsx)(et,{size:15}),` `,`Open account`]})}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Username`,value:U(h.ApplicantUsername)||`-`}),(0,G.jsx)(X,{label:`User ID`,value:h.ApplicantUserID,mono:!0}),(0,G.jsx)(X,{label:`Filed`,value:W(h.CreatedAt)||`-`}),(0,G.jsx)(X,{label:`Updated`,value:W(h.UpdatedAt)||`-`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Application`,text:`What the applicant wrote, rendered as plain text.`}),(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Correlation ID`,value:h.CorrelationID||`-`,mono:!0}),(0,G.jsx)(X,{label:`Status`,value:qr[h.Status]})]}),(0,G.jsx)(si,{label:`Stated reason`,children:h.Reason?(0,G.jsx)(`p`,{className:`about-text`,children:h.Reason}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not set`})}),(0,G.jsx)(si,{label:`Requested description`,children:C?(0,G.jsx)(`p`,{className:`about-text`,children:C}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not set`})}),(0,G.jsx)(si,{label:`Description the mark would carry`,children:T?(0,G.jsx)(`p`,{className:`about-text`,children:T}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not set`})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Resolved the same way the backend resolves it: the applicant's wording only when this verifier may set its own description, otherwise the verifier's default.`}),C!==``&&!w&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This verifier may not set a per-peer description, so the requested wording is ignored and the default is applied.`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Decision`,text:`What was decided, by whom, and with which wording.`}),(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Decided by`,value:h.DecidedBy||`-`}),(0,G.jsx)(X,{label:`Approved`,value:W(h.ApprovedAt)||`-`}),(0,G.jsx)(X,{label:`Rejected`,value:W(h.RejectedAt)||`-`}),(0,G.jsx)(X,{label:`Version (optimistic lock)`,value:h.Version,mono:!0})]}),(0,G.jsx)(si,{label:`Decision reason`,children:h.DecisionReason?(0,G.jsx)(`p`,{className:`about-text`,children:h.DecisionReason}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`No decision yet`})}),(0,G.jsx)(si,{label:`Internal note · admins only`,children:h.InternalNote?(0,G.jsx)(`p`,{className:`about-text`,children:h.InternalNote}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not set`})})]})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsxs)(`div`,{className:`dock-title`,children:[(0,G.jsx)(qe,{size:14}),` `,`Decision`]}),!b&&!x&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This status has no available actions.`}),(b||x)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Internal note`}),(0,G.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),rows:3,placeholder:`Handover note for other admins`})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Optional. Stored with the decision and visible to admins only — never sent to the applicant.`})]}),b&&(0,G.jsxs)(G.Fragment,{children:[!_&&(0,G.jsx)(q,{children:`The verifier row is gone: its status was revoked after this application was filed. There is no icon to grant, so the application can only be rejected.`}),_&&!_.Enabled&&(0,G.jsx)(q,{children:`This verifier is disabled. It cannot mark anything new until an operator enables it again.`}),y&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This peer already carries this verifier's mark; approving refreshes the description and records the decision.`}),(0,G.jsxs)(`div`,{className:`action-stack`,children:[(0,G.jsx)(Z,{label:`Approve`,icon:(0,G.jsx)(L,{size:15}),tone:`neutral`,path:`/api/botverification/requests/${h.ID}/approve`,payload:E,onDone:D,onError:m}),(0,G.jsx)(Z,{label:`Reject`,icon:(0,G.jsx)(ee,{size:15}),tone:`warn`,path:`/api/botverification/requests/${h.ID}/reject`,payload:E,onDone:D,onError:m})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Puts the verifier's icon before the peer's name and its description in the profile, and messages the applicant.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The reason is mandatory: it is the wording the applicant is told, so write what exactly was missing.`})]}),x&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`dock-title`,children:[(0,G.jsx)(V,{size:14}),` `,`Danger zone`]}),(0,G.jsxs)(`div`,{className:`danger-zone`,children:[(0,G.jsx)(Z,{label:`Revoke mark`,icon:(0,G.jsx)(oe,{size:15}),tone:`danger`,path:`/api/botverification/requests/${h.ID}/revoke`,payload:E,onDone:D,onError:m}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Takes the icon and the description off the peer and closes the application as revoked. The official checkmark, if the peer has one, is untouched.`}),!y&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The peer carries no mark right now — revoking only closes the application.`})]})]})]})})]})}function si({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:e}),t]})}function ci(e){return!e||!e.BotID||e.BotID===`0`?null:e}var li=[`draft`,`submitted`,`in_review`,`approved`,`rejected`,`cancelled`],ui=[`bot`,`channel`,`supergroup`,`user`],di={draft:`Draft`,submitted:`Submitted`,in_review:`In review`,approved:`Approved`,rejected:`Rejected`,cancelled:`Cancelled`},fi={bot:`Bot`,channel:`Channel`,supergroup:`Supergroup`,user:`User`};function pi({navigate:e}){let[t,n]=(0,g.useState)(`all`),[r,i]=(0,g.useState)(`all`),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(`50`),[d,f]=(0,g.useState)([]),[p,m]=(0,g.useState)({}),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(``);async function w(e=!1){x(!0),C(``);let n=new URLSearchParams({limit:l});t!==`all`&&n.set(`status`,t),r!==`all`&&n.set(`target_type`,r),a.trim()&&n.set(`reviewer`,a.trim()),s.trim()&&n.set(`q`,s.trim().replace(/^@/,``)),e&&v&&n.set(`before_id`,v);try{let t=await k.verificationApplications(n),r=t.rows??[];f(t=>e?[...t,...r]:r),y(t.next_before_id??``),_(!!t.has_more)}catch(e){C(O(e))}finally{x(!1)}}async function T(){try{m((await k.verificationCounts()).counts??{})}catch(e){C(O(e))}}(0,g.useEffect)(()=>{w(!1),T()},[]);function E(){w(!1),T()}return(0,G.jsxs)(xt,{title:`Verification queue`,eyebrow:`Verification / Queue`,actions:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:E,disabled:b,children:[(0,G.jsx)(Le,{size:15,className:b?`spin`:``}),` `,`Refresh`]}),children:[S&&(0,G.jsx)(q,{children:S}),(0,G.jsx)(`div`,{className:`metric-row`,children:li.map(e=>(0,G.jsx)(Y,{label:di[e],value:p[e]??`0`,mono:!0,tone:gi(e,p[e]??`0`)},e))}),(0,G.jsx)(St,{children:(0,G.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),w(!1)},children:[(0,G.jsxs)(`label`,{className:`searchbox`,children:[(0,G.jsx)(Re,{size:15}),(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Application id, peer id, username or title`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Status`}),(0,G.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All statuses`}),li.map(e=>(0,G.jsx)(`option`,{value:e,children:di[e]},e))]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Target type`}),(0,G.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),children:[(0,G.jsx)(`option`,{value:`all`,children:`All types`}),ui.map(e=>(0,G.jsx)(`option`,{value:e,children:fi[e]},e))]})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Reviewer`}),(0,G.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Any reviewer`})]}),(0,G.jsxs)(`label`,{className:`field-inline`,children:[(0,G.jsx)(`span`,{children:`Limit`}),(0,G.jsx)(`input`,{className:`small-input`,value:l,onChange:e=>u(e.target.value),type:`number`,min:`1`,max:`200`})]}),(0,G.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:b,children:[b?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(Re,{size:15}),` `,`Search`]})]})}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`ID`}),(0,G.jsx)(`th`,{children:`Target`}),(0,G.jsx)(`th`,{children:`Applicant`}),(0,G.jsx)(`th`,{children:`Category`}),(0,G.jsx)(`th`,{children:`Status`}),(0,G.jsx)(`th`,{children:`Submitted`}),(0,G.jsx)(`th`,{children:`Reviewer`}),(0,G.jsx)(`th`,{})]})}),(0,G.jsxs)(`tbody`,{children:[d.map(t=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{className:`mono`,children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/verification/${t.ID}`),children:[`#`,t.ID]})}),(0,G.jsxs)(`td`,{children:[(0,G.jsx)(`strong`,{children:_i(t)}),(0,G.jsxs)(`div`,{className:`entity-subtitle mono`,children:[fi[t.TargetType],` · `,t.TargetID]}),t.TargetVerified&&(0,G.jsxs)(J,{tone:`good`,children:[(0,G.jsx)(F,{size:12}),` `,`Badge already on`]})]}),(0,G.jsxs)(`td`,{children:[U(t.ApplicantUsername)||t.ApplicantName||`-`,(0,G.jsx)(`div`,{className:`entity-subtitle mono`,children:t.ApplicantUserID})]}),(0,G.jsx)(`td`,{children:t.Category||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsx)(mi,{status:t.Status})}),(0,G.jsx)(`td`,{children:W(t.SubmittedAt)||`-`}),(0,G.jsx)(`td`,{children:t.ReviewerAdminID||`-`}),(0,G.jsx)(`td`,{children:(0,G.jsxs)(`button`,{className:`row-link`,type:`button`,onClick:()=>e(`/verification/${t.ID}`),children:[(0,G.jsx)(Ue,{size:14}),` `,`Details`,` `,(0,G.jsx)(pe,{size:14})]})})]},t.ID)),d.length===0&&(0,G.jsx)(Et,{colSpan:8})]})]})}),h&&(0,G.jsx)(`div`,{className:`toolbar`,children:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>w(!0),disabled:b,children:[b?(0,G.jsx)(R,{size:15,className:`spin`}):(0,G.jsx)(de,{size:15}),` `,`Load more`]})})]})}function mi({status:e}){return(0,G.jsx)(J,{tone:hi(e),children:di[e]})}function hi(e){return e===`approved`?`good`:e===`submitted`||e===`in_review`?`warn`:e===`rejected`?`danger`:`neutral`}function gi(e,t){return e===`submitted`||e===`in_review`?t!==`0`&&t!==``?`warn`:`neutral`:e===`approved`?`good`:`neutral`}function _i(e){return U(e.TargetUsername)||e.TargetTitle||`#${e.TargetID}`}function vi(e){return e.TargetType===`bot`?`/bots/${e.TargetID}`:e.TargetType===`user`?`/accounts/${e.TargetID}`:`/channels/${e.TargetID}`}var yi={created:`Created`,updated:`Updated`,submitted:`Submitted`,claimed:`Claimed`,approved:`Approved`,rejected:`Rejected`,cancelled:`Cancelled`,revoked:`Badge revoked`,notified:`Applicant notified`};function bi({id:e,navigate:t}){let{can:n}=Ft(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``);async function p(){u(!0),f(``);try{i(await k.verificationApplication(e))}catch(e){f(O(e))}finally{u(!1)}}function m(){c(!1),p()}(0,g.useEffect)(()=>{p()},[e]);function h(e){if(e instanceof v&&e.status===409)return c(!0),p(),`Another admin has already changed this application. The data has been reloaded — check the status before deciding again.`}if(d&&!r)return(0,G.jsx)(q,{children:d});if(!r)return(0,G.jsx)(Dt,{label:`Loading the application…`});let _=r.application,y=r.events??[],b=r.applicant_controls_target,x=r.target_verified,S=_.Status===`submitted`,C=_.Status===`submitted`||_.Status===`in_review`,w=_.Status===`approved`&&n(`verification.revoke`),T=a.trim();function E(){let e={version:_.Version};return T&&(e.internal_note=T),e}function D(){o(``),c(!1),p()}return(0,G.jsxs)(xt,{title:`Application #${_.ID}`,eyebrow:`Verification / Review`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/verification`),children:[(0,G.jsx)(ie,{size:15}),` `,`Back to list`]}),(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:m,disabled:l,children:[(0,G.jsx)(Le,{size:15,className:l?`spin`:``}),` `,`Refresh`]})]}),children:[d&&(0,G.jsx)(q,{children:d}),s&&(0,G.jsx)(q,{children:`Another admin has already changed this application. The data has been reloaded — check the status before deciding again.`}),(0,G.jsx)(Ct,{main:(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`section`,{className:`entity-head`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`entity-title`,children:_i(_)}),(0,G.jsxs)(`div`,{className:`entity-subtitle mono`,children:[`#`,_.ID,` · `,fi[_.TargetType],`:`,_.TargetID,` · v`,_.Version]})]}),(0,G.jsxs)(`div`,{className:`entity-badges`,children:[(0,G.jsx)(mi,{status:_.Status}),x&&(0,G.jsxs)(J,{tone:`good`,children:[(0,G.jsx)(F,{size:12}),` `,`Badge already on`]}),(0,G.jsx)(J,{tone:b?`good`:`danger`,children:b?`Control confirmed`:`No control over the target`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Target`,text:`The peer the badge would be attached to, as it exists right now.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(vi(_)),children:[(0,G.jsx)(ge,{size:15}),` `,`Open target`]})}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Type`,value:fi[_.TargetType]}),(0,G.jsx)(X,{label:`Username`,value:U(_.TargetUsername)||`-`}),(0,G.jsx)(X,{label:`Title`,value:_.TargetTitle||`-`}),(0,G.jsx)(X,{label:`Peer ID`,value:_.TargetID,mono:!0})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Applicant`,text:`Who filed the application and whether they still hold rights on the target.`,action:(0,G.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>t(`/accounts/${_.ApplicantUserID}`),children:[(0,G.jsx)(et,{size:15}),` `,`Open account`]})}),(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Username`,value:U(_.ApplicantUsername)||`-`}),(0,G.jsx)(X,{label:`Name`,value:_.ApplicantName||`-`}),(0,G.jsx)(X,{label:`User ID`,value:_.ApplicantUserID,mono:!0}),(0,G.jsx)(X,{label:`Submitted`,value:W(_.SubmittedAt)||`-`})]}),b?(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The applicant controls the target right now — checked against the live records, not against the submission snapshot.`}):(0,G.jsx)(q,{children:`The applicant no longer controls the target. Approving would hand the badge to someone who does not hold the peer — normally a reason to reject.`})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Application`,text:`Everything the applicant submitted, rendered as plain text.`}),(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Category`,value:_.Category||`-`}),(0,G.jsx)(X,{label:`Correlation ID`,value:_.CorrelationID||`-`,mono:!0}),(0,G.jsx)(X,{label:`Created`,value:W(_.CreatedAt)||`-`}),(0,G.jsx)(X,{label:`Updated`,value:W(_.UpdatedAt)||`-`})]}),(0,G.jsx)(xi,{label:`Description`,children:_.Description?(0,G.jsx)(`p`,{className:`about-text`,children:_.Description}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not provided`})}),(0,G.jsx)(xi,{label:`Official website`,children:_.OfficialWebsite?(0,G.jsx)(`div`,{className:`about-text`,children:(0,G.jsx)(Si,{value:_.OfficialWebsite})}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not provided`})}),(0,G.jsx)(xi,{label:`Social links`,children:(0,G.jsx)(Ci,{values:_.SocialLinks})}),(0,G.jsx)(xi,{label:`Press coverage`,children:(0,G.jsx)(Ci,{values:_.PressLinks})}),(0,G.jsx)(xi,{label:`Applicant comment`,children:_.AdditionalNote?(0,G.jsx)(`p`,{className:`about-text`,children:_.AdditionalNote}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not provided`})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Only http:// and https:// links are clickable and open in a new tab; anything else is shown as text.`})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`Decision`,text:`What was decided, by whom, and with which wording.`}),(0,G.jsxs)(`div`,{className:`stacked-sections`,children:[(0,G.jsxs)(`div`,{className:`summary-grid`,children:[(0,G.jsx)(X,{label:`Reviewer`,value:_.ReviewerAdminID||`-`}),(0,G.jsx)(X,{label:`Decided`,value:W(_.ReviewedAt)||`-`}),(0,G.jsx)(X,{label:`Status`,value:di[_.Status]}),(0,G.jsx)(X,{label:`Version (optimistic lock)`,value:_.Version,mono:!0})]}),(0,G.jsx)(xi,{label:`Decision reason`,children:_.DecisionReason?(0,G.jsx)(`p`,{className:`about-text`,children:_.DecisionReason}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`No decision yet`})}),(0,G.jsx)(xi,{label:`Internal note · admins only`,children:_.InternalNote?(0,G.jsx)(`p`,{className:`about-text`,children:_.InternalNote}):(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not provided`})})]})]}),(0,G.jsxs)(`section`,{className:`section-block`,children:[(0,G.jsx)(K,{title:`History`,text:`Immutable trail of every status transition, with actor and reason.`}),(0,G.jsx)(`div`,{className:`table-wrap`,children:(0,G.jsxs)(`table`,{className:`data-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{children:`Event`}),(0,G.jsx)(`th`,{children:`From → to`}),(0,G.jsx)(`th`,{children:`Actor`}),(0,G.jsx)(`th`,{children:`Reason`}),(0,G.jsx)(`th`,{children:`Internal note`}),(0,G.jsx)(`th`,{children:`Time`})]})}),(0,G.jsxs)(`tbody`,{children:[y.map(e=>(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(wi,{kind:e.Kind})}),(0,G.jsxs)(`td`,{className:`mono`,children:[e.FromStatus||`-`,` → `,e.ToStatus||`-`]}),(0,G.jsx)(`td`,{children:e.Actor||`-`}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Reason||`-`}),(0,G.jsx)(`td`,{className:`truncate`,children:e.Note||`-`}),(0,G.jsx)(`td`,{children:W(e.CreatedAt)||`-`})]},e.ID)),y.length===0&&(0,G.jsx)(Et,{colSpan:6})]})]})})]})]}),side:(0,G.jsxs)(`section`,{className:`action-dock`,children:[(0,G.jsx)(`div`,{className:`dock-title`,children:`Review actions`}),!S&&!C&&!w&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`This status has no available actions.`}),S&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`action-stack`,children:(0,G.jsx)(Z,{label:`Take into review`,icon:(0,G.jsx)(Se,{size:15}),tone:`neutral`,path:`/api/verification/applications/${_.ID}/claim`,payload:()=>({version:_.Version}),onDone:D,onError:h})}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Assigns the application to you and moves it to in review, so two reviewers never work on the same one.`})]}),(C||w)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:`Internal note`}),(0,G.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),rows:3,placeholder:`Handover note for other reviewers`})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Optional. Stored with the decision and visible to admins only — never sent to the applicant.`})]}),C&&(0,G.jsxs)(G.Fragment,{children:[!b&&(0,G.jsx)(q,{children:`The applicant no longer controls the target. Approving would hand the badge to someone who does not hold the peer — normally a reason to reject.`}),x&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The target already carries the badge; approving only records the decision.`}),(0,G.jsxs)(`div`,{className:`action-stack`,children:[(0,G.jsx)(Z,{label:`Approve`,icon:(0,G.jsx)(L,{size:15}),tone:`neutral`,path:`/api/verification/applications/${_.ID}/approve`,payload:E,onDone:D,onError:h}),(0,G.jsx)(Z,{label:`Reject`,icon:(0,G.jsx)(ee,{size:15}),tone:`warn`,path:`/api/verification/applications/${_.ID}/reject`,payload:E,onDone:D,onError:h})]}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Grants the official badge to the target and closes the application.`}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The reason is mandatory: it is the wording the applicant is told, so write what exactly was missing.`})]}),w&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`dock-title`,children:[(0,G.jsx)(V,{size:14}),` `,`Danger zone`]}),(0,G.jsxs)(`div`,{className:`danger-zone`,children:[(0,G.jsx)(Z,{label:`Revoke verification`,icon:(0,G.jsx)(oe,{size:15}),tone:`danger`,path:`/api/actions/revoke-verification`,payload:()=>{let e={target_type:_.TargetType,target_id:_.TargetID};return T&&(e.internal_note=T),e},onDone:D,onError:h}),(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Clears the badge from the target. The approved application stays in history.`}),!x&&(0,G.jsx)(`p`,{className:`bot-create-note`,children:`The target carries no badge right now — there is nothing to revoke.`})]})]})]})})]})}function xi({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`duration-field`,children:[(0,G.jsx)(`span`,{children:e}),t]})}function Si({value:e}){let t=ct(e);return t?(0,G.jsxs)(`a`,{className:`row-link`,href:t,target:`_blank`,rel:`noopener noreferrer`,children:[e,` `,(0,G.jsx)(ge,{size:13})]}):(0,G.jsx)(`span`,{className:`mono`,children:e})}function Ci({values:e}){let t=(e??[]).filter(e=>e.trim()!==``);return t.length===0?(0,G.jsx)(`p`,{className:`bot-create-note`,children:`Not provided`}):(0,G.jsx)(`div`,{className:`about-text`,children:t.map((e,t)=>(0,G.jsx)(`div`,{children:(0,G.jsx)(Si,{value:e})},`${t}-${e}`))})}function wi({kind:e}){return(0,G.jsx)(J,{tone:e===`approved`?`good`:e===`rejected`||e===`revoked`||e===`cancelled`?`danger`:e===`submitted`||e===`claimed`?`warn`:`neutral`,children:yi[e]})}function Ti({route:e,navigate:t}){let n=e.path.match(/^\/accounts\/(\d+)$/)?.[1],r=e.path.match(/^\/channels\/(\d+)$/)?.[1],i=e.path.match(/^\/bots\/(\d+)$/)?.[1],a=e.path.match(/^\/moderation\/(\d+)$/)?.[1],o=e.path.match(/^\/collectible-usernames\/(\d+)$/)?.[1],s=e.path.match(/^\/account-ratings\/(\d+)$/)?.[1],c=e.path.match(/^\/verification\/(\d+)$/)?.[1],l=e.path.match(/^\/bot-verification\/(\d+)$/)?.[1];return l?(0,G.jsx)(Lt,{permission:jt,children:(0,G.jsx)(oi,{id:l,navigate:t})}):e.path===`/bot-verification`?(0,G.jsx)(Lt,{permission:jt,children:(0,G.jsx)(Yr,{navigate:t})}):c?(0,G.jsx)(Lt,{permission:At,children:(0,G.jsx)(bi,{id:c,navigate:t})}):e.path===`/verification`?(0,G.jsx)(Lt,{permission:At,children:(0,G.jsx)(pi,{navigate:t})}):o?(0,G.jsx)(In,{id:o,navigate:t}):s?(0,G.jsx)(gn,{userID:s,navigate:t}):e.path===`/collectible-usernames`?(0,G.jsx)(Mn,{navigate:t}):e.path===`/account-ratings`?(0,G.jsx)(fn,{navigate:t}):n?(0,G.jsx)(un,{id:Number(n),navigate:t}):r?(0,G.jsx)(Bn,{id:Number(r),navigate:t}):i?(0,G.jsx)(Hn,{id:Number(i),navigate:t}):a?(0,G.jsx)(Br,{id:Number(a),navigate:t}):e.path===`/accounts`?(0,G.jsx)(On,{navigate:t}):e.path===`/channels`?(0,G.jsx)(Vn,{navigate:t}):e.path===`/bots`?(0,G.jsx)(Un,{navigate:t}):e.path===`/moderation`?(0,G.jsx)(Nr,{navigate:t}):e.path===`/emoji`?(0,G.jsx)(Tr,{kind:`emoji`}):e.path===`/gifts`?(0,G.jsx)(yr,{}):e.path===`/stickers`?(0,G.jsx)(Tr,{kind:`stickers`}):e.path===`/give-gifts`?(0,G.jsx)(Ar,{}):e.path===`/messages/detail`||e.path===`/messages/private/detail`?(0,G.jsx)(Jn,{ownerUserID:Number(e.search.get(`owner_user_id`)||`0`),msgID:Number(e.search.get(`msg_id`)||`0`),navigate:t}):e.path===`/messages/groups/detail`?(0,G.jsx)(Kn,{channelID:Number(e.search.get(`channel_id`)||`0`),msgID:Number(e.search.get(`msg_id`)||`0`),navigate:t}):e.path===`/messages/groups`?(0,G.jsx)(qn,{navigate:t}):e.path===`/messages`||e.path===`/messages/private`?(0,G.jsx)(Yn,{navigate:t}):(0,G.jsx)(Wn,{navigate:t})}function Ei(){let[e,t]=(0,g.useState)(void 0),[n,r]=(0,g.useState)(()=>zt());(0,g.useEffect)(()=>{let e=()=>r(zt());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,g.useEffect)(()=>{k.session().then(e=>t(e)).catch(()=>t(null))},[]);let i=e=>{window.history.pushState(null,``,e),r(zt())};return e===void 0?(0,G.jsx)(Xt,{}):e===null?(0,G.jsx)($t,{onLogin:t}):(0,G.jsx)(Pt,{permissions:e.permissions??[],children:(0,G.jsx)(Zt,{actor:e.actor,route:n,navigate:i,onLogout:()=>t(null),children:(0,G.jsx)(Ti,{route:n,navigate:i})})})}_.createRoot(document.getElementById(`root`)).render((0,G.jsx)(g.StrictMode,{children:(0,G.jsx)(Gt,{children:(0,G.jsx)(Ei,{})})})); \ No newline at end of file diff --git a/cmd/telesrv-admin/web/dist/assets/index-CKoIcj6p.css b/cmd/telesrv-admin/web/dist/assets/index-CKoIcj6p.css new file mode 100644 index 00000000..864a3ecc --- /dev/null +++ b/cmd/telesrv-admin/web/dist/assets/index-CKoIcj6p.css @@ -0,0 +1 @@ +@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/plus-jakarta-sans-400.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/plus-jakarta-sans-500.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/plus-jakarta-sans-600.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/plus-jakarta-sans-700.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:800;font-display:swap;src:url(/fonts/plus-jakarta-sans-800.woff2)format("woff2")}:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f7f9fc;--bg-accent:#eef1f5;--panel:#fff;--panel-subtle:#f7f9fc;--panel-strong:#f1f5f9;--surface-soft:#f2f7fd;--overlay:#18222f6b;--topbar-bg:#fffffff0;--line:#e2e8f0;--line-strong:#cbd5e1;--heading:#101828;--text:#0f1720;--text-soft:#344054;--muted:#64748b;--muted-2:#94a3b8;--brand:#2563eb;--brand-strong:#1d4ed8;--brand-2:#38bdf8;--grad:linear-gradient(135deg, #38bdf8 0%, #2563eb 55%, #1e40af 100%);--brand-tint:#eaf2fd;--brand-tint-border:#c7dcf9;--brand-tint-text:#1e3a8a;--good:#167447;--good-tint:#eaf6ef;--good-border:#c1e1cf;--warn:#a15c07;--warn-tint:#fcf4e4;--warn-border:#e7d09e;--danger:#b42318;--danger-tint:#fcefec;--danger-border:#eecac3;--danger-text:#8f2f27;--purple:#6a4fa3;--purple-tint:#f4effb;--purple-border:#dcd0f0;--purple-text:#5a4590;--input-bg:#fff;--btn-bg:#fff;--btn-text:#29323d;--btn-hover:#f4f7fa;--switch-track:#c8d0d6;--code-bg:#1b2733;--code-text:#d6e3ef;--code-border:#2b3a49;--sidebar:#08080e;--sidebar-soft:#12121a;--sidebar-line:#222228;--sidebar-row:#17171f;--sidebar-text:#c6d0dc;--sidebar-muted:#8fa0b4;--sidebar-faint:#8492a6;--sidebar-heading:#fff;--focus:#2563eb29;--shadow:0 28px 70px -36px #05050859;--shadow-sm:0 2px 10px #1827380d;--shadow-brand:0 8px 22px #2563eb38;--hero-glow:#2563eb24;--hero-grid:#0505080a;--radius-xs:8px;--radius-sm:9px;--radius:11px;--radius-lg:14px}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0f141a;--bg-accent:#131a22;--panel:#171f28;--panel-subtle:#1c2530;--panel-strong:#212c38;--surface-soft:#1a232d;--overlay:#05080c9e;--topbar-bg:#151c24db;--line:#29333f;--line-strong:#38434f;--heading:#eef3f8;--text:#d5dde6;--text-soft:#c2ccd6;--muted:#98a4b1;--muted-2:#6d7885;--brand:#5b9dff;--brand-strong:#7db4ff;--brand-2:#7cd1fb;--brand-tint:#142a4a;--brand-tint-border:#24466e;--brand-tint-text:#9dc3f5;--good:#47c281;--good-tint:#12301f;--good-border:#245639;--warn:#e0aa4d;--warn-tint:#322810;--warn-border:#574413;--danger:#e6695c;--danger-tint:#35201d;--danger-border:#5c332d;--danger-text:#f0a49b;--purple:#ac90e2;--purple-tint:#221b31;--purple-border:#3d3357;--purple-text:#c9b6ef;--input-bg:#131a22;--btn-bg:#1e2731;--btn-text:#dbe2ea;--btn-hover:#26313d;--switch-track:#3a454f;--code-bg:#0c1218;--code-text:#cdd9e5;--code-border:#232f3b;--sidebar:#10151b;--sidebar-soft:#1c242f;--sidebar-line:#262f3a;--sidebar-row:#161d25;--sidebar-text:#cbd4de;--sidebar-muted:#7c8794;--sidebar-faint:#6f7b88;--sidebar-heading:#f0f4f8;--focus:#5b9dff3d;--shadow:0 16px 40px #00000075;--shadow-sm:0 2px 12px #00000061;--shadow-brand:0 8px 22px #5b9dff42;--hero-glow:#5b9dff40;--hero-grid:#ffffff0a}*{box-sizing:border-box}html,body,#root{min-height:100%}body{color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;margin:0;font:13px/1.45 Plus Jakarta Sans,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;transition:background-color .2s,color .2s}button,input,select,textarea{font:inherit}a{color:inherit;text-decoration:none}.shell{grid-template-columns:232px minmax(0,1fr);min-height:100vh;display:grid}.sidebar{height:100vh;color:var(--sidebar-text);background:var(--sidebar);border-right:1px solid var(--sidebar-line);flex-direction:column;gap:16px;padding:18px 12px;display:flex;position:sticky;top:0;overflow-y:auto}.brand{align-items:center;gap:10px;min-height:42px;padding:0 4px;display:flex}.brand.compact{justify-content:center}.brand-mark{place-items:center;width:34px;height:34px;display:grid}.brand-mark img{object-fit:contain;width:100%;height:100%;display:block}.brand strong{font-size:14px;line-height:1.1;display:block}.brand small{color:var(--sidebar-muted);margin-top:3px;font-size:11px;display:block}.sidebar-label{color:var(--sidebar-faint);text-transform:uppercase;letter-spacing:.04em;padding:0 8px;font-size:11px;font-weight:700}.nav-list,.nav-section{gap:4px;display:grid}.nav-section-toggle{width:100%;min-height:38px;color:var(--sidebar-muted);border-radius:var(--radius-sm);cursor:pointer;text-align:left;background:0 0;border:1px solid #0000;grid-template-columns:18px minmax(0,1fr) 16px;align-items:center;gap:9px;padding:0 10px;font-size:12px;font-weight:800;transition:color .14s,background-color .14s,border-color .14s;display:grid}.nav-section-toggle:hover,.nav-section.active .nav-section-toggle{color:var(--sidebar-heading);background:var(--sidebar-soft);border-color:#34404d}.nav-section-chevron{color:var(--sidebar-muted);justify-self:end;transition:transform .14s}.nav-section.open .nav-section-chevron{transform:rotate(180deg)}.nav-children{gap:4px;padding:2px 0 2px 18px;display:grid}.nav-item{min-height:38px;color:var(--sidebar-text);border-radius:var(--radius-sm);border:1px solid #0000;grid-template-columns:18px minmax(0,1fr);align-items:center;gap:9px;padding:0 10px;transition:color .14s,background-color .14s,border-color .14s;display:grid}.nav-dot{background:var(--sidebar-faint);border-radius:999px;justify-self:center;width:6px;height:6px}.nav-item:hover,.nav-item.active{color:var(--sidebar-heading);background:var(--sidebar-soft);border-color:#34404d}.nav-item.active .nav-dot{background:var(--brand)}.sidebar-status{gap:7px;margin-top:auto;display:grid}.runtime-row{min-height:32px;color:var(--sidebar-text);background:var(--sidebar-row);border-radius:var(--radius-sm);border:1px solid #27313c;grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:7px;padding:0 8px;display:grid}.runtime-row strong{color:var(--sidebar-heading);font-size:11px}.workspace{min-width:0}.topbar{z-index:20;background:var(--topbar-bg);border-bottom:1px solid var(--line);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);justify-content:space-between;align-items:center;gap:18px;min-height:66px;padding:12px 24px;display:flex;position:sticky;top:0}.topbar h1{color:var(--heading);margin:2px 0 0;font-size:20px;line-height:1.2}.topbar-actions,.page-actions,.section-action,.entity-badges,.row-actions,.modal-actions{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.theme-toggle{width:34px;height:34px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);cursor:pointer;border-radius:999px;place-items:center;transition:color .16s,background-color .16s,border-color .16s;display:inline-grid}.theme-toggle:hover{color:var(--brand);border-color:var(--brand-tint-border);background:var(--brand-tint)}.theme-toggle:focus-visible{outline:2px solid var(--brand);outline-offset:2px}.actor-pill{min-height:30px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:999px;align-items:center;padding:0 10px;display:inline-flex}.content{gap:16px;padding:18px 24px 30px;display:grid}.eyebrow{color:var(--muted);text-transform:uppercase;letter-spacing:.04em;font-size:11px;font-weight:800}.dashboard-layout,.stacked-sections{gap:14px;display:grid}.overview-band,.page-frame{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-width:0;box-shadow:var(--shadow-sm)}.overview-band{grid-template-columns:minmax(220px,1fr) minmax(420px,.9fr);align-items:center;gap:16px;padding:16px;display:grid}.overview-band h2,.page-title-row h2,.section-head h2,.modal h2{color:var(--heading);margin:0;font-size:18px;line-height:1.25}.overview-metrics,.metric-row{grid-template-columns:repeat(4,minmax(120px,1fr));gap:8px;display:grid}.overview-metrics{grid-template-columns:repeat(3,minmax(120px,1fr))}.status-item,.metric,.summary-item{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);min-width:0;padding:10px}.status-item span,.metric span,.summary-item span{color:var(--muted);margin-bottom:6px;font-size:11px;display:block}.status-item strong,.metric strong,.summary-item strong{overflow-wrap:anywhere;color:var(--text);font-weight:800;display:block}.status-item.good,.metric.good{border-color:var(--good-border)}.status-item.warn,.metric.warn{border-color:var(--warn-border)}.metric.danger{border-color:var(--danger-border)}.command-grid{grid-template-columns:repeat(3,minmax(220px,1fr));gap:12px;display:grid}.launcher{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-height:94px;box-shadow:var(--shadow-sm);grid-template-columns:38px minmax(0,1fr) 18px;align-items:center;gap:12px;padding:14px;transition:border-color .16s,box-shadow .16s,transform .16s;display:grid}.launcher:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.launcher-icon{width:38px;height:38px;color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);place-items:center;display:grid}.launcher-copy{gap:4px;display:grid}.launcher-copy strong{color:var(--heading);font-size:15px}.launcher-copy span{color:var(--muted)}.work-strip{grid-template-columns:repeat(4,minmax(160px,1fr));gap:8px;display:grid}.strip-item{min-height:38px;color:var(--text-soft);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:flex}.page-frame{gap:14px;padding:14px;display:grid}.page-title-row{border-bottom:1px solid var(--line);justify-content:space-between;align-items:flex-start;gap:14px;padding-bottom:12px;display:flex}.query-panel{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);padding:10px}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.message-query input{width:150px}.message-selector-grid{grid-template-columns:repeat(2,minmax(280px,1fr));gap:10px;margin-bottom:10px;display:grid}.message-selector-grid.single{grid-template-columns:minmax(320px,620px)}.entity-picker{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-sm);gap:8px;min-width:0;padding:10px;display:grid}.picker-head{min-height:24px;color:var(--text-soft);justify-content:space-between;align-items:center;gap:8px;font-weight:800;display:flex}.selected-entity{min-height:40px;color:var(--brand-tint-text);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:8px;padding:7px 9px;display:grid}.selected-entity strong,.selected-entity span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.selected-entity div{gap:2px;min-width:0;display:grid}.selected-entity div span{color:var(--brand-tint-text);opacity:.85;font-size:11px}.picker-search{background:var(--panel-subtle);border:1px solid var(--line-strong);border-radius:var(--radius-sm);grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:7px;height:34px;padding:0 6px 0 9px;display:grid}.picker-search input{width:100%;height:30px;box-shadow:none;background:0 0;border:0;padding:0}.picker-results{border:1px solid var(--line);border-radius:var(--radius-sm);max-height:236px;display:grid;overflow:auto}.picker-row{min-height:36px;color:var(--text);background:var(--panel);border:0;border-bottom:1px solid var(--line);cursor:pointer;text-align:left;grid-template-columns:96px minmax(120px,1fr) minmax(120px,1fr) auto;align-items:center;gap:8px;padding:6px 8px;display:grid}.picker-row:last-child{border-bottom:0}.picker-row:hover,.picker-row.selected{background:var(--surface-soft)}.picker-row strong,.picker-row span{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.picker-empty,.picker-error{color:var(--muted);text-align:center;padding:9px}.picker-error{color:var(--danger);background:var(--danger-tint);border:1px solid var(--danger-border);border-radius:var(--radius-sm)}input,select,textarea{color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);outline:none;transition:border-color .14s,box-shadow .14s}input::placeholder,textarea::placeholder{color:var(--muted-2)}input,select{width:190px;height:34px;padding:0 10px}select{min-width:220px;height:34px;font:inherit;appearance:none;cursor:pointer;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right 10px center;background-repeat:no-repeat;padding:0 30px 0 10px;font-weight:600}select:disabled{color:var(--muted-2);cursor:not-allowed}textarea{resize:vertical;width:100%;padding:9px 10px}input:focus,select:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus)}.small-input{width:88px}.sort-order-editor{align-items:center;gap:6px;display:flex}.sort-order-editor .small-input{width:64px;height:32px}.sort-order-editor .title-input{width:160px}.field-inline{color:var(--muted);align-items:center;gap:6px;display:inline-flex}.field-inline span{font-size:11px;font-weight:700}.searchbox{width:min(380px,100%);height:34px;color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:inline-flex}.searchbox input{width:100%;height:30px;box-shadow:none;border:0;padding:0}.btn{min-height:34px;color:var(--btn-text);background:var(--btn-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);cursor:pointer;white-space:nowrap;justify-content:center;align-items:center;gap:6px;padding:0 12px;transition:background-color .14s,border-color .14s,color .14s,box-shadow .14s;display:inline-flex}.btn:hover:not(:disabled){background:var(--btn-hover)}.btn:disabled{color:var(--muted-2);cursor:not-allowed}.btn.primary{color:#fff;background:var(--brand);border-color:var(--brand)}.btn.primary:hover:not(:disabled){background:var(--brand-strong);border-color:var(--brand-strong)}.btn.ghost{background:var(--panel-subtle)}.btn.danger{color:var(--danger);background:var(--danger-tint);border-color:var(--danger-border)}.btn.danger:hover:not(:disabled){background:var(--danger-tint);border-color:var(--danger)}.btn.warn{color:var(--warn);background:var(--warn-tint);border-color:var(--warn-border)}.btn.warn:hover:not(:disabled){background:var(--warn-tint);border-color:var(--warn)}.btn:disabled,.btn.primary:disabled,.btn.warn:disabled,.btn.danger:disabled{color:var(--muted-2);background:var(--panel-strong);border-color:var(--line);cursor:not-allowed}.btn.full{width:100%}.icon-text{gap:7px}.compact-btn{min-height:28px;padding:0 8px;font-size:12px}.row-link,.link-button{color:var(--brand-2);cursor:pointer;background:0 0;border:0;align-items:center;gap:4px;padding:0;display:inline-flex}.table-wrap{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);width:100%;overflow-x:auto}.data-table{border-collapse:collapse;width:100%;font-size:12.5px}.data-table th,.data-table td{border-bottom:1px solid var(--line);text-align:left;vertical-align:middle;white-space:nowrap;height:38px;padding:7px 9px}.data-table th{z-index:0;color:var(--muted);background:var(--panel-strong);font-weight:800;position:sticky;top:0}.data-table tbody tr:hover{background:var(--panel-subtle)}.data-table tr:last-child td{border-bottom:0}.mono{font-family:SFMono-Regular,Consolas,Liberation Mono,monospace}.truncate{text-overflow:ellipsis;max-width:380px;overflow:hidden}.badge{min-height:22px;color:var(--muted);background:var(--panel-strong);border:1px solid var(--line-strong);white-space:nowrap;border-radius:999px;align-items:center;padding:1px 8px;display:inline-flex}.badge.good{color:var(--good);background:var(--good-tint);border-color:var(--good-border)}.badge.danger{color:var(--danger);background:var(--danger-tint);border-color:var(--danger-border)}.badge.warn{color:var(--warn);background:var(--warn-tint);border-color:var(--warn-border)}.empty-cell{color:var(--muted);text-align:center}.bot-create-fields{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;display:grid}.bot-create-fields .duration-field input{width:100%}.bot-create-actions{border-top:1px solid var(--line);justify-content:space-between;align-items:center;gap:14px;margin-top:14px;padding-top:14px;display:flex}.bot-create-note{color:var(--muted);font-size:12px;line-height:1.4}@media (width<=760px){.bot-create-fields{grid-template-columns:1fr}.bot-create-actions{flex-direction:column;align-items:stretch}}.progress-cell{gap:4px;min-width:130px;display:grid}.progress-cell small,.progress-note{color:var(--muted);font-size:11px}.progress-bar{background:var(--panel-subtle);border:1px solid var(--line);border-radius:999px;width:100%;height:6px;overflow:hidden}.progress-bar>span{background:var(--brand-2);height:100%;display:block}.progress-bar.good>span{background:var(--good)}.progress-bar.danger>span{background:var(--danger)}.progress-wide .progress-cell{min-width:0}.split-layout{grid-template-columns:minmax(0,1fr) 330px;align-items:start;gap:14px;display:grid}.split-main,.split-side{min-width:0}.entity-head{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);justify-content:space-between;align-items:flex-start;gap:14px;padding:14px;display:flex}.entity-title{color:var(--heading);font-size:20px;font-weight:800;line-height:1.25}.entity-subtitle{color:var(--muted);margin-top:4px}.summary-grid{grid-template-columns:repeat(4,minmax(150px,1fr));gap:8px;display:grid}.about-text{color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);margin:0;padding:10px}.section-block,.action-dock,.surface{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-width:0;box-shadow:var(--shadow-sm);padding:12px}.section-head{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:10px;display:flex}.section-head p{color:var(--muted);margin:5px 0 0}.action-dock{gap:10px;display:grid;position:sticky;top:82px}.dock-title{color:var(--text-soft);border-bottom:1px solid var(--line);padding-bottom:4px;font-weight:800}.action-dock>.btn,.action-dock .action-stack .btn{justify-content:center;width:100%}.duration-field{gap:4px;display:grid}.duration-field span{color:var(--muted);font-size:11px;font-weight:800}.duration-field input,.duration-field select{width:100%}.action-stack{gap:10px;display:grid}.action-stack .btn,.action-dock>.btn{min-height:42px}.danger-zone{border-top:1px solid var(--line);flex-wrap:wrap;gap:8px;margin-top:10px;padding-top:10px;display:flex}.dock-title+.danger-zone{border-top:0;margin-top:0;padding-top:0}.authorization-block{gap:10px;display:grid}.authorization-table{table-layout:fixed;min-width:720px}.authorization-table th,.authorization-table td{height:46px}.device-text{text-overflow:ellipsis;max-width:260px;overflow:hidden}.device-actions-head{width:190px}.device-actions-cell{width:190px;min-width:190px}.device-actions{white-space:normal;grid-template-columns:repeat(2,minmax(82px,1fr));gap:6px;min-width:178px;display:grid}.device-actions .btn{justify-content:center;width:100%}.operation-row{grid-template-columns:repeat(2,minmax(280px,1fr));gap:10px;display:grid}.operation-box{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);flex-wrap:wrap;align-items:center;gap:8px;padding:10px;display:flex}.operation-title{width:100%;color:var(--heading);align-items:center;gap:6px;font-weight:800;display:flex}.checkline{color:var(--muted);align-items:center;gap:6px;display:inline-flex}.checkline input{width:auto;height:auto}.alert{color:var(--danger-text);background:var(--danger-tint);border:1px solid var(--danger-border);border-radius:var(--radius);align-items:flex-start;gap:8px;padding:9px 10px;display:flex}.json-block{max-height:520px;color:var(--code-text);background:var(--code-bg);border:1px solid var(--code-border);border-radius:var(--radius);margin:0;padding:12px;font-size:12px;overflow:auto}.raw-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.loading-line{min-height:80px;color:var(--muted);place-items:center;display:grid}.empty-panel{min-height:92px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);place-items:center;display:grid}.gift-metrics .metric{background:var(--panel-subtle);min-height:68px;padding:12px}.gift-metrics .metric strong{font-size:17px}.gift-file-icon{color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);flex:none;place-items:center;display:grid}.gift-format-chips{flex-wrap:wrap;flex:none;justify-content:flex-end;gap:6px;display:flex}.gift-format-chips span{color:var(--brand-tint-text);background:var(--brand-tint);border:1px solid var(--brand-tint-border);letter-spacing:.02em;border-radius:999px;padding:4px 8px;font-size:10px;font-weight:800}.gift-list-summary{color:var(--muted);margin-left:auto;font-size:11px;font-weight:700}.gift-import-modal{width:min(860px,100%)}.gift-bulk-import-modal{width:min(480px,100%)}.gift-bulk-import-modal .command-body{gap:14px;padding:16px 18px;display:grid}.gift-import-modal-body{gap:14px}.gift-source-tabs{gap:8px;display:flex}.give-gift-summary{background:var(--panel-subtle);border:1px solid var(--line-strong);color:var(--text-soft);border-radius:12px;align-items:center;gap:11px;padding:11px 13px;display:flex}.give-gift-summary>svg{color:var(--brand);flex:none}.give-gift-summary strong{color:var(--text);font-size:13px;display:block}.give-gift-summary .mono{color:var(--muted);font-size:11px}.give-gift-tabs{background:var(--panel-subtle);border:1px solid var(--line-strong);border-radius:12px;gap:4px;width:100%;padding:4px;display:flex}.give-gift-tabs .btn{min-height:36px;box-shadow:none;color:var(--text-soft);background:0 0;border:1px solid #0000;border-radius:9px;flex:1 1 0;justify-content:center;transition:color .15s,background .15s,border-color .15s,box-shadow .15s}.give-gift-tabs .btn:not(.primary):hover{color:var(--brand);background:var(--brand-tint)}.give-gift-tabs .btn.primary{color:#fff;background:var(--brand);border-color:var(--brand);box-shadow:var(--shadow-brand)}.give-gift-upgrade-note{background:var(--brand-tint);border:1px solid var(--brand-tint-border);color:var(--text-soft);border-radius:10px;margin:0;padding:9px 12px;font-size:11px;font-weight:650;line-height:1.45}.give-gift-attrs{grid-template-columns:repeat(3,minmax(0,1fr));align-items:end}.give-gift-attrs select,.give-gift-attrs input{width:100%;min-width:0;height:38px;color:var(--text);background-color:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);font:inherit;appearance:none;cursor:pointer;padding:0 32px 0 10px;font-size:12px;font-weight:600}.give-gift-attrs input{cursor:text;text-overflow:ellipsis;padding-right:10px}.give-gift-attrs select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right 11px center;background-repeat:no-repeat}.give-gift-attrs select:focus,.give-gift-attrs input:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus);outline:none}.give-gift-layout{grid-template-columns:minmax(220px,280px) minmax(0,1fr);align-items:start;gap:16px;display:grid}.give-gift-picker{align-content:start;gap:10px;display:grid}.give-gift-picker-head{align-items:center;gap:12px;display:flex}.give-gift-picker-head .searchbox{flex:auto}.give-gift-picker-list{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-lg);gap:8px;max-height:640px;padding:8px;display:grid;overflow-y:auto}.give-gift-option{text-align:left;min-width:0;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);cursor:pointer;box-shadow:var(--shadow-sm);grid-template-columns:46px minmax(0,1fr) auto;align-items:center;gap:11px;padding:9px 11px;transition:border-color .15s,box-shadow .15s,transform .15s;display:grid}.give-gift-option:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.give-gift-option.selected{border-color:var(--brand);box-shadow:0 0 0 2px var(--focus), var(--shadow)}.give-gift-thumb{place-items:center;width:46px;height:46px;display:grid}.give-gift-thumb canvas{width:100%!important;height:100%!important}.give-gift-option-info{gap:3px;min-width:0;display:grid}.give-gift-option-info strong{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.give-gift-option-info .mono{color:var(--muted);font-size:10px}.give-gift-option-price{white-space:nowrap;justify-self:end}.give-gift-panel{background:var(--panel);border:1px solid var(--line-strong);border-radius:var(--radius-lg);gap:12px;min-width:0;padding:16px;display:grid}.give-gift-form{gap:12px;min-width:0;display:grid}.give-gift-form-actions{flex-wrap:wrap;justify-content:flex-end;gap:10px;padding-top:4px;display:flex}.give-gift-empty-panel{color:var(--muted);text-align:center;place-items:center;gap:10px;padding:48px 20px;display:grid}.give-gift-empty-panel svg{color:var(--brand);opacity:.8}.official-gift-picker{gap:12px;min-width:0;display:grid}.official-gift-bulk-import{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.gift-bulk-import-progress{align-items:center;gap:8px;min-width:180px;display:flex}.gift-bulk-import-progress-bar{background:#e3e8ef;border-radius:999px;flex:auto;width:120px;height:6px;overflow:hidden}.gift-bulk-import-progress-bar>div{background:var(--brand);border-radius:999px;height:100%;transition:width .2s}.gift-bulk-import-progress span{color:var(--muted);white-space:nowrap;font-size:11px;font-weight:700}.official-gift-tools{align-items:center;gap:12px;display:flex}.official-gift-tools .searchbox{width:100%}.official-gift-tools>span{color:var(--muted);flex:none;font-size:11px;font-weight:750}.official-gift-categories{flex-wrap:wrap;gap:7px;display:flex}.official-gift-categories button{min-height:32px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line-strong);font:inherit;cursor:pointer;border-radius:999px;align-items:center;gap:7px;padding:5px 10px;font-size:11px;font-weight:800;transition:color .15s,background .15s,border-color .15s,box-shadow .15s;display:inline-flex}.official-gift-categories button:hover{color:var(--brand);border-color:var(--brand-tint-border)}.official-gift-categories button.active{color:#fff;background:var(--brand);border-color:var(--brand);box-shadow:var(--shadow-brand)}.official-gift-categories button span{min-width:20px;height:20px;color:inherit;background:#7d8c9b38;border-radius:999px;place-items:center;padding:0 5px;font-size:10px;display:grid}.official-gift-categories button.active span{color:var(--brand);background:#ffffffd9}.official-gift-list{border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--panel-subtle);scrollbar-gutter:stable;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;min-height:126px;max-height:314px;padding:8px;display:grid;overflow:auto}.official-gift-option{text-align:left;min-width:0;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);cursor:pointer;box-shadow:var(--shadow-sm);gap:8px;padding:11px 12px;transition:border-color .15s,box-shadow .15s,transform .15s;display:grid}.official-gift-option:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.official-gift-option.selected{border-color:var(--brand);box-shadow:0 0 0 2px var(--focus), var(--shadow)}.official-gift-option-head{grid-template-columns:minmax(0,1fr) auto;align-items:baseline;gap:8px;display:grid}.official-gift-option-head strong{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.official-gift-option-head .mono{color:var(--muted);font-size:9px}.official-gift-option-meta{color:var(--muted);flex-wrap:wrap;gap:10px;font-size:10px;font-weight:700;display:flex}.official-gift-capabilities{flex-wrap:wrap;gap:5px;display:flex}.official-gift-capabilities>span{letter-spacing:.01em;border:1px solid #0000;border-radius:999px;padding:3px 7px;font-size:9px;font-weight:850}.official-gift-capabilities>span.yes{color:var(--good);background:var(--good-tint);border-color:var(--good-border)}.official-gift-capabilities>span.craft{color:var(--purple);background:var(--purple-tint);border-color:var(--purple-border)}.official-gift-capabilities>span.no{color:var(--muted);background:var(--panel-strong);border-color:var(--line-strong)}.official-gift-empty{min-height:108px;color:var(--muted);text-align:center;grid-column:1/-1;place-items:center;padding:20px;font-size:12px;display:grid}.official-gift-selected{border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface-soft);grid-template-columns:108px minmax(0,1fr);align-items:center;gap:14px;padding:12px;display:grid}.official-gift-selected .gift-animation-shell{border-radius:12px;width:96px;height:96px;min-height:96px;overflow:hidden}.official-gift-selected .gift-animation{width:96px;height:96px}.official-gift-selected>div:last-child{gap:5px;min-width:0;display:grid}.official-gift-selected small{color:var(--muted)}.gift-import-note{color:var(--muted);justify-content:space-between;align-items:center;gap:12px;line-height:1.45;display:flex}.gift-file-picker{min-height:78px;color:var(--text);background:var(--panel);border:1px dashed var(--line-strong);border-radius:var(--radius);cursor:pointer;grid-template-columns:42px minmax(0,1fr) auto;align-items:center;gap:12px;padding:12px 14px;transition:border-color .16s,background .16s,box-shadow .16s;display:grid;position:relative}.gift-file-picker:hover,.gift-file-picker.has-file{background:var(--brand-tint);border-color:var(--brand);box-shadow:0 0 0 2px var(--focus)}.gift-file-picker.compact{grid-template-columns:minmax(0,1fr);min-height:44px;padding:8px 12px}.gift-file-picker input{opacity:0;pointer-events:none;width:1px;height:1px;position:absolute}.gift-file-icon{border-radius:var(--radius-sm);width:40px;height:40px}.gift-file-copy{gap:2px;min-width:0;display:grid}.gift-field-label{color:var(--muted);text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:800}.gift-file-copy strong{color:var(--heading);text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.gift-file-copy small{color:var(--muted);font-size:11px;font-weight:500}.gift-file-action{color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);padding:7px 10px;font-size:11px;font-weight:800}.gift-fields-grid{grid-template-columns:minmax(200px,1.5fr) repeat(3,minmax(120px,1fr));gap:10px;display:grid}.gift-fields-grid label,.gift-reason-field{color:var(--muted);gap:6px;font-size:11px;font-weight:700;display:grid}.gift-fields-grid input,.gift-reason-field input{width:100%;min-width:0;height:38px;color:var(--text);background:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);padding:0 10px}.gift-fields-grid input:focus,.gift-reason-field input:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus);outline:none}.gift-switch{color:var(--text-soft);cursor:pointer;align-items:center;gap:9px;font-size:12px;font-weight:700;display:inline-flex}.gift-switch input{opacity:0;width:1px;height:1px;position:absolute}.gift-switch-track{background:var(--switch-track);border-radius:999px;align-items:center;width:34px;height:19px;padding:2px;transition:background .16s;display:flex}.gift-switch-track span{background:#fff;border-radius:50%;width:15px;height:15px;transition:transform .16s;box-shadow:0 1px 3px #10182838}.gift-switch input:checked+.gift-switch-track{background:var(--brand)}.gift-switch input:checked+.gift-switch-track span{transform:translate(15px)}.gift-switch input:focus-visible+.gift-switch-track{outline:3px solid var(--focus);outline-offset:2px}.gift-validation{color:var(--code-text);background:var(--code-bg);border:1px solid var(--code-border);border-radius:var(--radius-sm);overflow:hidden}.gift-validation-head{color:var(--code-text);background:#ffffff09;border-bottom:1px solid #ffffff17;align-items:center;gap:9px;padding:10px 12px;display:flex}.gift-validation-head div{gap:2px;display:grid}.gift-validation-head span{color:var(--brand);font-size:10px}.gift-validation pre{max-height:180px;color:var(--code-text);margin:0;padding:11px 12px;font-size:11px;overflow:auto}.sticker-preview-modal{width:min(760px,100%)}.sticker-doc-grid{grid-template-columns:repeat(auto-fill,minmax(84px,1fr));gap:8px;max-height:420px;padding:2px;display:grid;overflow:auto}.sticker-doc-cell{aspect-ratio:1;background:var(--panel-strong);border:1px solid var(--line);border-radius:10px;place-items:center;display:grid;position:relative;overflow:hidden}.sticker-doc-canvas{width:100%;height:100%}.sticker-doc-canvas canvas{width:100%!important;height:100%!important}.sticker-doc-image{object-fit:contain;width:100%;height:100%}.sticker-doc-cell.list-thumb{flex:0 0 40px;width:40px}.sticker-list-thumb-empty{background:var(--panel-strong);border:1px solid var(--line);width:40px;height:40px;color:var(--muted);border-radius:9px;place-items:center;display:grid}.sticker-doc-grid-cell{gap:4px;display:grid}.sticker-doc-grid-cell .btn{justify-content:center;width:100%}.sticker-add-form{background:var(--panel-strong);border:1px solid var(--line);border-radius:10px;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:14px;padding:10px;display:flex}.sticker-add-form .gift-file-picker.compact{flex:220px;min-width:180px}.sticker-add-form .small-input{flex:0 140px}.sticker-add-form-error{color:var(--danger);flex-basis:100%;font-size:12px}.sticker-doc-error{color:var(--danger);text-align:center;place-items:center;padding:4px;font-size:9px;display:grid;position:absolute;inset:0}.gift-animation-shell{background:var(--surface-soft);place-items:center;min-height:210px;display:grid;position:relative}.gift-animation{width:200px;height:200px}.gift-animation canvas{width:100%!important;height:100%!important}.gift-play{width:30px;height:30px;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:50%;place-items:center;display:grid;position:absolute;bottom:8px;right:8px}.gift-table-wrap{background:var(--panel)}.gift-table{min-width:1080px}.gift-table th:nth-child(2){width:74px}.gift-table td{vertical-align:middle}.gift-select-col{text-align:center;width:34px}.gift-select-col input{width:15px;height:15px}.avatar-col{width:44px}.muted-cell{color:var(--muted)}.avatar-photo-img,.avatar-fallback{object-fit:cover;border-radius:50%;display:block}.avatar-fallback{color:#fff;letter-spacing:-.02em;place-items:center;font-weight:800;display:grid}.gift-bulk-toolbar{background:var(--panel-strong);border:1px solid var(--line);border-radius:9px;align-items:center;gap:10px;margin-bottom:10px;padding:9px 12px;display:flex}.gift-bulk-count{color:var(--text);white-space:nowrap;font-size:12px;font-weight:700}.gift-bulk-reason{flex:1;min-width:160px}.gift-bulk-reason input{height:34px}.gift-bulk-error{color:var(--danger);font-size:11px;font-weight:700}.gift-page-size{color:var(--muted);white-space:nowrap;align-items:center;gap:6px;font-size:11px;font-weight:700;display:inline-flex}.gift-page-size select{height:30px;color:var(--text);background:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);font:inherit;padding:0 8px;font-weight:700}.gift-pager{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-top:10px;display:flex}.gift-pager-range{color:var(--muted);font-size:11px;font-weight:700}.gift-pager-controls{align-items:center;gap:10px;display:flex}.gift-pager-page{color:var(--text);white-space:nowrap;font-size:12px;font-weight:700}.gift-animation-shell.compact{border:1px solid var(--line);border-radius:var(--radius-sm);width:56px;min-height:56px;overflow:hidden}.gift-animation-shell.compact .gift-animation{width:54px;height:54px}.gift-animation-shell.compact .gift-play{width:20px;height:20px;bottom:3px;right:3px}.gift-row-disabled{opacity:.68}.gift-table-title,.gift-sort-order,.gift-source-size,.gift-convert-price{display:block}.gift-table-title{text-overflow:ellipsis;white-space:nowrap;max-width:220px;overflow:hidden}.gift-sort-order,.gift-source-size,.gift-convert-price{color:var(--muted);margin-top:3px;font-size:10px}.gift-table-price{color:var(--warn)}.gift-table-actions{align-items:center;gap:6px;display:flex}.collectible-button{color:var(--purple);background:var(--purple-tint);border-color:var(--purple-border)}.collectible-button:hover{background:var(--purple-tint);border-color:var(--purple)}.collectible-modal{width:min(1180px,100%);max-height:min(92vh,980px)}.collectible-modal .modal-head p{color:var(--muted);margin:4px 0 0;font-size:11px}.collectible-modal-body{background:var(--bg);gap:16px;padding:16px 18px 22px;overflow:auto}.collectible-loading{min-height:90px;color:var(--muted);justify-content:center;align-items:center;gap:8px;display:flex}.collectible-empty{color:var(--purple-text);background:var(--purple-tint);border:1px dashed var(--purple-border);border-radius:var(--radius);align-items:center;gap:12px;padding:16px;display:flex}.collectible-empty div,.collectible-definition-head>div:first-child,.collectible-section-head>div:first-child{gap:3px;display:grid}.collectible-empty span,.collectible-definition-head span,.collectible-section-head span{color:var(--muted);font-size:10px;font-weight:500}.collectible-active{background:var(--panel);border:1px solid var(--purple-border);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}.collectible-active-head{background:var(--purple-tint);border-bottom:1px solid var(--purple-border);justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;display:flex}.collectible-active-head>div{color:var(--purple-text);align-items:center;gap:9px;display:flex}.collectible-active-head>div>div{gap:2px;display:grid}.collectible-active-head span{color:var(--muted);font-size:10px}.collectible-active-grid{background:var(--line);grid-template-columns:repeat(auto-fill,minmax(145px,1fr));gap:1px;display:grid}.collectible-active-grid article{background:var(--panel);align-items:center;gap:9px;min-width:0;padding:9px 11px;display:flex}.collectible-active-grid article>div:last-child{gap:2px;min-width:0;display:grid}.collectible-active-grid article strong{text-overflow:ellipsis;white-space:nowrap;font-size:11px;overflow:hidden}.collectible-active-grid article span{color:var(--muted);font-size:9px}.collectible-definition{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}.collectible-definition-head{background:var(--panel-subtle);border-bottom:1px solid var(--line);justify-content:space-between;align-items:center;gap:12px;padding:14px 16px;display:flex}.collectible-main-fields{background:var(--panel-subtle);border-bottom:1px solid var(--line);padding:14px 16px}.collectible-section{border-bottom:1px solid var(--line);padding:14px 16px}.collectible-section:last-child{border-bottom:0}.collectible-section-head{justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.collectible-section-tools{align-items:center;gap:7px;display:flex}.collectible-rows{gap:7px;display:grid}.collectible-row{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:end;gap:7px;padding:9px 9px 9px 36px;display:grid;position:relative}.collectible-row:hover{background:var(--panel);border-color:var(--line-strong);box-shadow:var(--shadow-sm)}.collectible-row.animated{grid-template-columns:minmax(120px,1.2fr) 90px 78px minmax(160px,1.4fr) 48px 30px}.collectible-row.backdrop{grid-template-columns:minmax(110px,1.2fr) 70px 80px 70px repeat(4,52px) 48px 30px}.collectible-row-index{width:27px;color:var(--purple-text);background:var(--purple-tint);border-right:1px solid var(--purple-border);border-radius:var(--radius-xs) 0 0 var(--radius-xs);place-items:center;font-size:10px;font-weight:800;display:grid;position:absolute;top:0;bottom:0;left:0}.collectible-row label{gap:4px;min-width:0;display:grid}.collectible-row label>span{color:var(--muted);text-transform:uppercase;letter-spacing:.025em;font-size:9px;font-weight:800}.collectible-row input:not([type=file]){width:100%;min-width:0;height:32px;color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);font:inherit;padding:0 8px;font-size:11px}.collectible-row input:focus{border-color:var(--purple);box-shadow:0 0 0 3px var(--purple-tint);outline:none}.collectible-file input{opacity:0;pointer-events:none;width:1px;height:1px;position:absolute}.collectible-file em{min-width:0;height:32px;color:var(--purple-text);background:var(--purple-tint);border:1px dashed var(--purple-border);border-radius:var(--radius-sm);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;align-items:center;gap:5px;padding:0 8px;font-size:10px;font-style:normal;font-weight:700;display:flex;overflow:hidden}.collectible-inline-preview{width:42px;height:42px;color:var(--purple);background:var(--purple-tint);border:1px solid var(--purple-border);border-radius:var(--radius-sm);place-items:center;display:grid;overflow:hidden}.collectible-animation{width:100%;height:100%;overflow:hidden}.collectible-animation.compact{background:var(--purple-tint);border:1px solid var(--purple-border);border-radius:var(--radius-sm);flex:0 0 42px;place-items:center;width:42px;height:42px;display:grid}.collectible-animation canvas{width:100%!important;height:100%!important}.collectible-animation.failed{color:var(--danger);background:var(--danger-tint)}.collectible-animation.loading{color:var(--purple-text)}.collectible-file-error{color:var(--danger);grid-column:1/-1;font-size:10px}.collectible-color input{cursor:pointer;height:32px!important;padding:3px!important}.collectible-backdrop-preview{border-radius:var(--radius-sm);border:1px solid #2a1f472e;flex:0 0 42px;place-items:center;width:42px;height:42px;font-size:11px;font-weight:900;display:grid;box-shadow:inset 0 0 0 1px #fff3}.collectible-row .icon-btn{align-self:center}.collectible-row .icon-btn:disabled{opacity:.28}@media (width<=900px){.gift-fields-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.give-gift-layout{grid-template-columns:1fr}.give-gift-picker-list{max-height:320px}.collectible-row.animated,.collectible-row.backdrop{grid-template-columns:repeat(2,minmax(0,1fr))}.collectible-inline-preview,.collectible-backdrop-preview,.collectible-row .icon-btn{place-self:center start}}@media (width<=620px){.gift-import-note{flex-direction:column;align-items:flex-start}.gift-format-chips{justify-content:flex-start}.gift-file-picker{grid-template-columns:40px minmax(0,1fr)}.gift-file-action{display:none}.gift-fields-grid{grid-template-columns:1fr}.gift-list-summary{width:100%;margin-left:0}.official-gift-tools{flex-direction:column;align-items:stretch}.official-gift-list{grid-template-columns:1fr;max-height:340px}.official-gift-selected{grid-template-columns:82px minmax(0,1fr)}.official-gift-selected .gift-animation-shell{width:72px;height:72px}.collectible-modal-body{padding:10px}.collectible-definition-head,.collectible-section-head{flex-direction:column;align-items:flex-start}.collectible-row.animated,.collectible-row.backdrop{grid-template-columns:1fr}.collectible-active-grid{grid-template-columns:1fr 1fr}}.attr-block{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);gap:8px;padding:10px;display:grid}.attr-block .duration-field input,.duration-field select{width:100%}.attr-block .btn{justify-content:center;width:100%}.emoji-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;display:grid}.emoji-card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);gap:8px;padding:12px;display:grid}.emoji-preview{background:var(--surface-soft);border:1px solid var(--line);border-radius:var(--radius-sm);place-items:center;height:88px;display:grid}.emoji-anim{width:80px;height:80px}.emoji-anim canvas{width:100%!important;height:100%!important}.emoji-glyph{font-size:46px;line-height:1}.emoji-meta{gap:4px;min-width:0;display:grid}.emoji-alt{font-size:18px;line-height:1.2}.emoji-id{width:100%;min-width:0;color:var(--text);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);cursor:pointer;justify-content:space-between;align-items:center;gap:6px;padding:4px 8px;font-size:11px;display:flex}.emoji-id .mono{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;overflow:hidden}.emoji-id svg{flex:none}.emoji-id:hover{border-color:var(--brand-tint-border);color:var(--brand)}.emoji-sub{color:var(--muted);text-overflow:ellipsis;white-space:nowrap;font-size:11px;overflow:hidden}.breakdown-list{gap:8px;margin-bottom:10px;display:grid}.breakdown-row{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);grid-template-columns:minmax(140px,260px) 1fr minmax(80px,auto);align-items:center;gap:12px;padding:9px 10px;display:grid}.breakdown-row.total{background:0 0;grid-template-columns:1fr minmax(80px,auto)}.breakdown-label{gap:2px;min-width:0;display:grid}.breakdown-label strong{color:var(--text);font-weight:800}.breakdown-label small{color:var(--muted);font-size:11px;line-height:1.35}.breakdown-value{color:var(--text);text-align:right;font-weight:800}.breakdown-value.good{color:var(--good)}.breakdown-value.danger{color:var(--danger-text)}@media (width<=760px){.breakdown-row,.breakdown-row.total{grid-template-columns:1fr}.breakdown-value{text-align:left}}.username-branch{margin:2px 0 0;padding:0;list-style:none}.username-branch li{color:var(--text-soft);padding-left:14px;font-size:12px;line-height:1.7;position:relative}.username-branch li:before{border-left:1px solid var(--line-strong,var(--line));border-bottom:1px solid var(--line-strong,var(--line));content:"";width:6px;height:11px;position:absolute;top:0;left:3px}.username-branch li.inactive{color:var(--muted)}.username-branch li.inactive span{text-decoration:line-through}.username-branch li em{text-transform:uppercase;letter-spacing:.04em;margin-left:6px;font-size:10px;font-style:normal;font-weight:800}.modal-backdrop{z-index:10000;background:var(--overlay);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);place-items:center;padding:24px;display:grid;position:fixed;inset:0}.modal{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-lg);width:min(760px,100%);max-height:min(820px,100vh - 48px);box-shadow:var(--shadow);padding:0;overflow:hidden}.command-modal{flex-direction:column;display:flex}.command-modal>.modal-head,.command-modal>.modal-actions{flex:none}.modal-head{border-bottom:1px solid var(--line);justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 18px 12px;display:flex}.icon-btn{width:30px;height:30px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);cursor:pointer;place-items:center;transition:background-color .14s,border-color .14s,color .14s;display:grid}.icon-btn:hover{background:var(--btn-hover);border-color:var(--line-strong)}.command-steps{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;display:grid}.command-body{grid-auto-rows:max-content;gap:12px;min-height:0;padding:14px 18px;display:grid;overflow:auto}.command-step{min-height:38px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:flex}.command-step span{background:var(--panel);border:1px solid var(--line);border-radius:999px;place-items:center;width:20px;height:20px;font-size:11px;font-weight:800;display:grid}.command-step.active{color:var(--brand);border-color:var(--brand-tint-border)}.command-step.done{color:var(--good);border-color:var(--good-border)}.form-field{gap:6px;display:grid}.form-field span,.form-stack span{color:var(--text-soft);font-weight:800}.form-field input:disabled,.form-field textarea:disabled{opacity:.6;cursor:not-allowed}.command-preview{gap:8px;display:grid}.command-preview .json-block{max-height:150px}.preview-head,.result-title{color:var(--text-soft);align-items:center;gap:7px;font-weight:800;display:flex}.result-box{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);gap:8px;padding:10px;display:grid}.result-line{grid-template-columns:92px minmax(0,1fr);gap:8px;display:grid}.result-line span{color:var(--muted)}.result-line strong{overflow-wrap:anywhere}.result-message{color:var(--text-soft)}.modal-actions{background:var(--panel);border-top:1px solid var(--line);justify-content:flex-end;padding:12px 18px}.login-page{background:var(--bg);background-image:radial-gradient(900px 480px at 50% -8%, var(--hero-glow) 0%, #0000 70%), linear-gradient(var(--hero-grid) 1px, transparent 1px), linear-gradient(90deg, var(--hero-grid) 1px, transparent 1px);background-size:auto,44px 44px,44px 44px;place-items:center;min-height:100vh;padding:24px;display:grid;position:relative;overflow:hidden}.login-page .bg-orbs{z-index:0;pointer-events:none;position:absolute;inset:-60px}.login-page .bg-orb{filter:blur(100px);pointer-events:none;border-radius:50%;position:absolute}.login-page .bg-orb--1{background:color-mix(in srgb, var(--brand-2) 40%, transparent);width:700px;height:700px;animation:20s ease-in-out infinite loginOrbFloat1;top:-15%;left:-10%}.login-page .bg-orb--2{background:color-mix(in srgb, var(--brand) 38%, transparent);width:600px;height:600px;animation:24s ease-in-out infinite loginOrbFloat2;top:25%;right:-15%}.login-page .bg-orb--3{background:color-mix(in srgb, var(--brand-2) 30%, transparent);width:500px;height:500px;animation:28s ease-in-out infinite loginOrbFloat3;bottom:-15%;left:30%}@keyframes loginOrbFloat1{0%,to{transform:translate(0)scale(1)}33%{transform:translate(60px,-40px)scale(1.08)}66%{transform:translate(-30px,30px)scale(.92)}}@keyframes loginOrbFloat2{0%,to{transform:translate(0)scale(1)}33%{transform:translate(-50px,-35px)scale(.93)}66%{transform:translate(45px,25px)scale(1.07)}}@keyframes loginOrbFloat3{0%,to{transform:translate(0)scale(1)}33%{transform:translate(40px,45px)scale(1.06)}66%{transform:translate(-55px,-25px)scale(.94)}}@media (width<=720px){.login-page .bg-orb{filter:blur(60px)}.login-page .bg-orb--1{width:350px;height:350px}.login-page .bg-orb--2{width:300px;height:300px}.login-page .bg-orb--3{width:250px;height:250px}}@media (prefers-reduced-motion:reduce){.login-page .bg-orb{animation:none}}.login-page .login-panel{z-index:1;position:relative}.login-panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-lg);width:min(420px,100%);box-shadow:var(--shadow);gap:18px;padding:22px;display:grid}.login-head{justify-content:space-between;align-items:center;gap:12px;display:flex}.login-head-actions{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.login-chip{min-height:24px;color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:999px;align-items:center;padding:0 8px;font-size:12px;display:inline-flex}.login-copy h1{color:var(--heading);margin:0;font-size:22px}.login-copy p{color:var(--muted);margin:8px 0 0}.form-stack{gap:12px;display:grid}.form-stack label{gap:6px;display:grid}.form-stack input{width:100%}.boot-screen{background:var(--bg);align-content:center;place-items:center;gap:18px;min-height:100vh;display:grid}.loader-bar{background:var(--line-strong);border-radius:999px;width:180px;height:4px;overflow:hidden}.loader-bar:before{content:"";background:var(--brand);width:42%;height:100%;animation:1s ease-in-out infinite load;display:block}.spin{animation:.8s linear infinite spin}@keyframes load{0%{transform:translate(-120%)}to{transform:translate(260%)}}@keyframes spin{to{transform:rotate(360deg)}}@media (width<=1120px){.shell{grid-template-columns:1fr}.sidebar{height:auto;position:static}.nav-list{grid-template-columns:repeat(4,minmax(0,1fr))}.sidebar-status{display:none}.overview-band,.split-layout,.operation-row,.raw-grid,.message-selector-grid,.message-selector-grid.single{grid-template-columns:1fr}.action-dock{position:static}}@media (width<=760px){.content,.topbar{padding-left:14px;padding-right:14px}.command-grid,.work-strip,.overview-metrics,.metric-row,.summary-grid,.command-steps{grid-template-columns:1fr}.sidebar{gap:12px;padding:14px}.nav-list{grid-template-columns:repeat(2,minmax(0,1fr))}.topbar,.page-title-row,.entity-head{flex-direction:column;align-items:flex-start}input,.searchbox{width:100%}.toolbar{align-items:stretch}.picker-row,.selected-entity{grid-template-columns:1fr}} diff --git a/cmd/telesrv-admin/web/dist/assets/index-DjPaQXsn.css b/cmd/telesrv-admin/web/dist/assets/index-DjPaQXsn.css deleted file mode 100644 index 89879456..00000000 --- a/cmd/telesrv-admin/web/dist/assets/index-DjPaQXsn.css +++ /dev/null @@ -1 +0,0 @@ -@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/plus-jakarta-sans-400.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/plus-jakarta-sans-500.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/plus-jakarta-sans-600.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/plus-jakarta-sans-700.woff2)format("woff2")}@font-face{font-family:Plus Jakarta Sans;font-style:normal;font-weight:800;font-display:swap;src:url(/fonts/plus-jakarta-sans-800.woff2)format("woff2")}:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f7f9fc;--bg-accent:#eef1f5;--panel:#fff;--panel-subtle:#f7f9fc;--panel-strong:#f1f5f9;--surface-soft:#f2f7fd;--overlay:#18222f6b;--topbar-bg:#fffffff0;--line:#e2e8f0;--line-strong:#cbd5e1;--heading:#101828;--text:#0f1720;--text-soft:#344054;--muted:#64748b;--muted-2:#94a3b8;--brand:#2563eb;--brand-strong:#1d4ed8;--brand-2:#38bdf8;--grad:linear-gradient(135deg, #38bdf8 0%, #2563eb 55%, #1e40af 100%);--brand-tint:#eaf2fd;--brand-tint-border:#c7dcf9;--brand-tint-text:#1e3a8a;--good:#167447;--good-tint:#eaf6ef;--good-border:#c1e1cf;--warn:#a15c07;--warn-tint:#fcf4e4;--warn-border:#e7d09e;--danger:#b42318;--danger-tint:#fcefec;--danger-border:#eecac3;--danger-text:#8f2f27;--purple:#6a4fa3;--purple-tint:#f4effb;--purple-border:#dcd0f0;--purple-text:#5a4590;--input-bg:#fff;--btn-bg:#fff;--btn-text:#29323d;--btn-hover:#f4f7fa;--switch-track:#c8d0d6;--code-bg:#1b2733;--code-text:#d6e3ef;--code-border:#2b3a49;--sidebar:#08080e;--sidebar-soft:#12121a;--sidebar-line:#222228;--sidebar-row:#17171f;--sidebar-text:#c6d0dc;--sidebar-muted:#8fa0b4;--sidebar-faint:#8492a6;--sidebar-heading:#fff;--focus:#2563eb29;--shadow:0 28px 70px -36px #05050859;--shadow-sm:0 2px 10px #1827380d;--shadow-brand:0 8px 22px #2563eb38;--hero-glow:#2563eb24;--hero-grid:#0505080a;--radius-xs:8px;--radius-sm:9px;--radius:11px;--radius-lg:14px}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0f141a;--bg-accent:#131a22;--panel:#171f28;--panel-subtle:#1c2530;--panel-strong:#212c38;--surface-soft:#1a232d;--overlay:#05080c9e;--topbar-bg:#151c24db;--line:#29333f;--line-strong:#38434f;--heading:#eef3f8;--text:#d5dde6;--text-soft:#c2ccd6;--muted:#98a4b1;--muted-2:#6d7885;--brand:#5b9dff;--brand-strong:#7db4ff;--brand-2:#7cd1fb;--brand-tint:#142a4a;--brand-tint-border:#24466e;--brand-tint-text:#9dc3f5;--good:#47c281;--good-tint:#12301f;--good-border:#245639;--warn:#e0aa4d;--warn-tint:#322810;--warn-border:#574413;--danger:#e6695c;--danger-tint:#35201d;--danger-border:#5c332d;--danger-text:#f0a49b;--purple:#ac90e2;--purple-tint:#221b31;--purple-border:#3d3357;--purple-text:#c9b6ef;--input-bg:#131a22;--btn-bg:#1e2731;--btn-text:#dbe2ea;--btn-hover:#26313d;--switch-track:#3a454f;--code-bg:#0c1218;--code-text:#cdd9e5;--code-border:#232f3b;--sidebar:#10151b;--sidebar-soft:#1c242f;--sidebar-line:#262f3a;--sidebar-row:#161d25;--sidebar-text:#cbd4de;--sidebar-muted:#7c8794;--sidebar-faint:#6f7b88;--sidebar-heading:#f0f4f8;--focus:#5b9dff3d;--shadow:0 16px 40px #00000075;--shadow-sm:0 2px 12px #00000061;--shadow-brand:0 8px 22px #5b9dff42;--hero-glow:#5b9dff40;--hero-grid:#ffffff0a}*{box-sizing:border-box}html,body,#root{min-height:100%}body{color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;margin:0;font:13px/1.45 Plus Jakarta Sans,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;transition:background-color .2s,color .2s}button,input,textarea{font:inherit}a{color:inherit;text-decoration:none}.shell{grid-template-columns:232px minmax(0,1fr);min-height:100vh;display:grid}.sidebar{height:100vh;color:var(--sidebar-text);background:var(--sidebar);border-right:1px solid var(--sidebar-line);flex-direction:column;gap:16px;padding:18px 12px;display:flex;position:sticky;top:0;overflow-y:auto}.brand{align-items:center;gap:10px;min-height:42px;padding:0 4px;display:flex}.brand.compact{justify-content:center}.brand-mark{place-items:center;width:34px;height:34px;display:grid}.brand-mark img{object-fit:contain;width:100%;height:100%;display:block}.brand strong{font-size:14px;line-height:1.1;display:block}.brand small{color:var(--sidebar-muted);margin-top:3px;font-size:11px;display:block}.sidebar-label{color:var(--sidebar-faint);text-transform:uppercase;letter-spacing:.04em;padding:0 8px;font-size:11px;font-weight:700}.nav-list,.nav-section{gap:4px;display:grid}.nav-section-toggle{width:100%;min-height:38px;color:var(--sidebar-muted);border-radius:var(--radius-sm);cursor:pointer;text-align:left;background:0 0;border:1px solid #0000;grid-template-columns:18px minmax(0,1fr) 16px;align-items:center;gap:9px;padding:0 10px;font-size:12px;font-weight:800;transition:color .14s,background-color .14s,border-color .14s;display:grid}.nav-section-toggle:hover,.nav-section.active .nav-section-toggle{color:var(--sidebar-heading);background:var(--sidebar-soft);border-color:#34404d}.nav-section-chevron{color:var(--sidebar-muted);justify-self:end;transition:transform .14s}.nav-section.open .nav-section-chevron{transform:rotate(180deg)}.nav-children{gap:4px;padding:2px 0 2px 18px;display:grid}.nav-item{min-height:38px;color:var(--sidebar-text);border-radius:var(--radius-sm);border:1px solid #0000;grid-template-columns:18px minmax(0,1fr);align-items:center;gap:9px;padding:0 10px;transition:color .14s,background-color .14s,border-color .14s;display:grid}.nav-dot{background:var(--sidebar-faint);border-radius:999px;justify-self:center;width:6px;height:6px}.nav-item:hover,.nav-item.active{color:var(--sidebar-heading);background:var(--sidebar-soft);border-color:#34404d}.nav-item.active .nav-dot{background:var(--brand)}.sidebar-status{gap:7px;margin-top:auto;display:grid}.runtime-row{min-height:32px;color:var(--sidebar-text);background:var(--sidebar-row);border-radius:var(--radius-sm);border:1px solid #27313c;grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:7px;padding:0 8px;display:grid}.runtime-row strong{color:var(--sidebar-heading);font-size:11px}.workspace{min-width:0}.topbar{z-index:20;background:var(--topbar-bg);border-bottom:1px solid var(--line);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);justify-content:space-between;align-items:center;gap:18px;min-height:66px;padding:12px 24px;display:flex;position:sticky;top:0}.topbar h1{color:var(--heading);margin:2px 0 0;font-size:20px;line-height:1.2}.topbar-actions,.page-actions,.section-action,.entity-badges,.row-actions,.modal-actions{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.theme-toggle{width:34px;height:34px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);cursor:pointer;border-radius:999px;place-items:center;transition:color .16s,background-color .16s,border-color .16s;display:inline-grid}.theme-toggle:hover{color:var(--brand);border-color:var(--brand-tint-border);background:var(--brand-tint)}.theme-toggle:focus-visible{outline:2px solid var(--brand);outline-offset:2px}.actor-pill{min-height:30px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:999px;align-items:center;padding:0 10px;display:inline-flex}.content{gap:16px;padding:18px 24px 30px;display:grid}.eyebrow{color:var(--muted);text-transform:uppercase;letter-spacing:.04em;font-size:11px;font-weight:800}.dashboard-layout,.stacked-sections{gap:14px;display:grid}.overview-band,.page-frame{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-width:0;box-shadow:var(--shadow-sm)}.overview-band{grid-template-columns:minmax(220px,1fr) minmax(420px,.9fr);align-items:center;gap:16px;padding:16px;display:grid}.overview-band h2,.page-title-row h2,.section-head h2,.modal h2{color:var(--heading);margin:0;font-size:18px;line-height:1.25}.overview-metrics,.metric-row{grid-template-columns:repeat(4,minmax(120px,1fr));gap:8px;display:grid}.overview-metrics{grid-template-columns:repeat(3,minmax(120px,1fr))}.status-item,.metric,.summary-item{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);min-width:0;padding:10px}.status-item span,.metric span,.summary-item span{color:var(--muted);margin-bottom:6px;font-size:11px;display:block}.status-item strong,.metric strong,.summary-item strong{overflow-wrap:anywhere;color:var(--text);font-weight:800;display:block}.status-item.good,.metric.good{border-color:var(--good-border)}.status-item.warn,.metric.warn{border-color:var(--warn-border)}.metric.danger{border-color:var(--danger-border)}.command-grid{grid-template-columns:repeat(3,minmax(220px,1fr));gap:12px;display:grid}.launcher{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-height:94px;box-shadow:var(--shadow-sm);grid-template-columns:38px minmax(0,1fr) 18px;align-items:center;gap:12px;padding:14px;transition:border-color .16s,box-shadow .16s,transform .16s;display:grid}.launcher:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.launcher-icon{width:38px;height:38px;color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);place-items:center;display:grid}.launcher-copy{gap:4px;display:grid}.launcher-copy strong{color:var(--heading);font-size:15px}.launcher-copy span{color:var(--muted)}.work-strip{grid-template-columns:repeat(4,minmax(160px,1fr));gap:8px;display:grid}.strip-item{min-height:38px;color:var(--text-soft);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:flex}.page-frame{gap:14px;padding:14px;display:grid}.page-title-row{border-bottom:1px solid var(--line);justify-content:space-between;align-items:flex-start;gap:14px;padding-bottom:12px;display:flex}.query-panel{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);padding:10px}.toolbar{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.message-query input{width:150px}.message-selector-grid{grid-template-columns:repeat(2,minmax(280px,1fr));gap:10px;margin-bottom:10px;display:grid}.message-selector-grid.single{grid-template-columns:minmax(320px,620px)}.entity-picker{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-sm);gap:8px;min-width:0;padding:10px;display:grid}.picker-head{min-height:24px;color:var(--text-soft);justify-content:space-between;align-items:center;gap:8px;font-weight:800;display:flex}.selected-entity{min-height:40px;color:var(--brand-tint-text);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:8px;padding:7px 9px;display:grid}.selected-entity strong,.selected-entity span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.selected-entity div{gap:2px;min-width:0;display:grid}.selected-entity div span{color:var(--brand-tint-text);opacity:.85;font-size:11px}.picker-search{background:var(--panel-subtle);border:1px solid var(--line-strong);border-radius:var(--radius-sm);grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:7px;height:34px;padding:0 6px 0 9px;display:grid}.picker-search input{width:100%;height:30px;box-shadow:none;background:0 0;border:0;padding:0}.picker-results{border:1px solid var(--line);border-radius:var(--radius-sm);max-height:236px;display:grid;overflow:auto}.picker-row{min-height:36px;color:var(--text);background:var(--panel);border:0;border-bottom:1px solid var(--line);cursor:pointer;text-align:left;grid-template-columns:96px minmax(120px,1fr) minmax(120px,1fr) auto;align-items:center;gap:8px;padding:6px 8px;display:grid}.picker-row:last-child{border-bottom:0}.picker-row:hover,.picker-row.selected{background:var(--surface-soft)}.picker-row strong,.picker-row span{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.picker-empty,.picker-error{color:var(--muted);text-align:center;padding:9px}.picker-error{color:var(--danger);background:var(--danger-tint);border:1px solid var(--danger-border);border-radius:var(--radius-sm)}input,textarea{color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);outline:none;transition:border-color .14s,box-shadow .14s}input::placeholder,textarea::placeholder{color:var(--muted-2)}input{width:190px;height:34px;padding:0 10px}textarea{resize:vertical;width:100%;padding:9px 10px}input:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus)}.small-input{width:88px}.sort-order-editor{align-items:center;gap:6px;display:flex}.sort-order-editor .small-input{width:64px;height:32px}.sort-order-editor .title-input{width:160px}.field-inline{color:var(--muted);align-items:center;gap:6px;display:inline-flex}.field-inline span{font-size:11px;font-weight:700}.searchbox{width:min(380px,100%);height:34px;color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:inline-flex}.searchbox input{width:100%;height:30px;box-shadow:none;border:0;padding:0}.btn{min-height:34px;color:var(--btn-text);background:var(--btn-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);cursor:pointer;white-space:nowrap;justify-content:center;align-items:center;gap:6px;padding:0 12px;transition:background-color .14s,border-color .14s,color .14s,box-shadow .14s;display:inline-flex}.btn:hover:not(:disabled){background:var(--btn-hover)}.btn:disabled{color:var(--muted-2);cursor:not-allowed}.btn.primary{color:#fff;background:var(--brand);border-color:var(--brand)}.btn.primary:hover:not(:disabled){background:var(--brand-strong);border-color:var(--brand-strong)}.btn.ghost{background:var(--panel-subtle)}.btn.danger{color:var(--danger);background:var(--danger-tint);border-color:var(--danger-border)}.btn.danger:hover:not(:disabled){background:var(--danger-tint);border-color:var(--danger)}.btn.warn{color:var(--warn);background:var(--warn-tint);border-color:var(--warn-border)}.btn.warn:hover:not(:disabled){background:var(--warn-tint);border-color:var(--warn)}.btn:disabled,.btn.primary:disabled,.btn.warn:disabled,.btn.danger:disabled{color:var(--muted-2);background:var(--panel-strong);border-color:var(--line);cursor:not-allowed}.btn.full{width:100%}.icon-text{gap:7px}.compact-btn{min-height:28px;padding:0 8px;font-size:12px}.row-link,.link-button{color:var(--brand-2);cursor:pointer;background:0 0;border:0;align-items:center;gap:4px;padding:0;display:inline-flex}.table-wrap{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);width:100%;overflow-x:auto}.data-table{border-collapse:collapse;width:100%;font-size:12.5px}.data-table th,.data-table td{border-bottom:1px solid var(--line);text-align:left;vertical-align:middle;white-space:nowrap;height:38px;padding:7px 9px}.data-table th{z-index:0;color:var(--muted);background:var(--panel-strong);font-weight:800;position:sticky;top:0}.data-table tbody tr:hover{background:var(--panel-subtle)}.data-table tr:last-child td{border-bottom:0}.mono{font-family:SFMono-Regular,Consolas,Liberation Mono,monospace}.truncate{text-overflow:ellipsis;max-width:380px;overflow:hidden}.badge{min-height:22px;color:var(--muted);background:var(--panel-strong);border:1px solid var(--line-strong);white-space:nowrap;border-radius:999px;align-items:center;padding:1px 8px;display:inline-flex}.badge.good{color:var(--good);background:var(--good-tint);border-color:var(--good-border)}.badge.danger{color:var(--danger);background:var(--danger-tint);border-color:var(--danger-border)}.badge.warn{color:var(--warn);background:var(--warn-tint);border-color:var(--warn-border)}.empty-cell{color:var(--muted);text-align:center}.bot-create-fields{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;display:grid}.bot-create-fields .duration-field input{width:100%}.bot-create-actions{border-top:1px solid var(--line);justify-content:space-between;align-items:center;gap:14px;margin-top:14px;padding-top:14px;display:flex}.bot-create-note{color:var(--muted);font-size:12px;line-height:1.4}@media (width<=760px){.bot-create-fields{grid-template-columns:1fr}.bot-create-actions{flex-direction:column;align-items:stretch}}.split-layout{grid-template-columns:minmax(0,1fr) 330px;align-items:start;gap:14px;display:grid}.split-main,.split-side{min-width:0}.entity-head{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);justify-content:space-between;align-items:flex-start;gap:14px;padding:14px;display:flex}.entity-title{color:var(--heading);font-size:20px;font-weight:800;line-height:1.25}.entity-subtitle{color:var(--muted);margin-top:4px}.summary-grid{grid-template-columns:repeat(4,minmax(150px,1fr));gap:8px;display:grid}.about-text{color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);margin:0;padding:10px}.section-block,.action-dock,.surface{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);min-width:0;box-shadow:var(--shadow-sm);padding:12px}.section-head{justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:10px;display:flex}.section-head p{color:var(--muted);margin:5px 0 0}.action-dock{gap:10px;display:grid;position:sticky;top:82px}.dock-title{color:var(--text-soft);border-bottom:1px solid var(--line);padding-bottom:4px;font-weight:800}.action-dock>.btn,.action-dock .action-stack .btn{justify-content:center;width:100%}.duration-field{gap:4px;display:grid}.duration-field span{color:var(--muted);font-size:11px;font-weight:800}.duration-field input{width:100%}.action-stack{gap:10px;display:grid}.action-stack .btn,.action-dock>.btn{min-height:42px}.danger-zone{border-top:1px solid var(--line);flex-wrap:wrap;gap:8px;margin-top:10px;padding-top:10px;display:flex}.authorization-block{gap:10px;display:grid}.authorization-table{table-layout:fixed;min-width:720px}.authorization-table th,.authorization-table td{height:46px}.device-text{text-overflow:ellipsis;max-width:260px;overflow:hidden}.device-actions-head{width:190px}.device-actions-cell{width:190px;min-width:190px}.device-actions{white-space:normal;grid-template-columns:repeat(2,minmax(82px,1fr));gap:6px;min-width:178px;display:grid}.device-actions .btn{justify-content:center;width:100%}.operation-row{grid-template-columns:repeat(2,minmax(280px,1fr));gap:10px;display:grid}.operation-box{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);flex-wrap:wrap;align-items:center;gap:8px;padding:10px;display:flex}.operation-title{width:100%;color:var(--heading);align-items:center;gap:6px;font-weight:800;display:flex}.checkline{color:var(--muted);align-items:center;gap:6px;display:inline-flex}.checkline input{width:auto;height:auto}.alert{color:var(--danger-text);background:var(--danger-tint);border:1px solid var(--danger-border);border-radius:var(--radius);align-items:flex-start;gap:8px;padding:9px 10px;display:flex}.json-block{max-height:520px;color:var(--code-text);background:var(--code-bg);border:1px solid var(--code-border);border-radius:var(--radius);margin:0;padding:12px;font-size:12px;overflow:auto}.raw-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;display:grid}.loading-line{min-height:80px;color:var(--muted);place-items:center;display:grid}.empty-panel{min-height:92px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);place-items:center;display:grid}.gift-metrics .metric{background:var(--panel-subtle);min-height:68px;padding:12px}.gift-metrics .metric strong{font-size:17px}.gift-file-icon{color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);flex:none;place-items:center;display:grid}.gift-format-chips{flex-wrap:wrap;flex:none;justify-content:flex-end;gap:6px;display:flex}.gift-format-chips span{color:var(--brand-tint-text);background:var(--brand-tint);border:1px solid var(--brand-tint-border);letter-spacing:.02em;border-radius:999px;padding:4px 8px;font-size:10px;font-weight:800}.gift-list-summary{color:var(--muted);margin-left:auto;font-size:11px;font-weight:700}.gift-import-modal{width:min(860px,100%)}.gift-bulk-import-modal{width:min(480px,100%)}.gift-bulk-import-modal .command-body{gap:14px;padding:16px 18px;display:grid}.gift-import-modal-body{gap:14px}.gift-source-tabs{gap:8px;display:flex}.give-gift-summary{background:var(--panel-subtle);border:1px solid var(--line-strong);color:var(--text-soft);border-radius:12px;align-items:center;gap:11px;padding:11px 13px;display:flex}.give-gift-summary>svg{color:var(--brand);flex:none}.give-gift-summary strong{color:var(--text);font-size:13px;display:block}.give-gift-summary .mono{color:var(--muted);font-size:11px}.give-gift-tabs{background:var(--panel-subtle);border:1px solid var(--line-strong);border-radius:12px;gap:4px;width:100%;padding:4px;display:flex}.give-gift-tabs .btn{min-height:36px;box-shadow:none;color:var(--text-soft);background:0 0;border:1px solid #0000;border-radius:9px;flex:1 1 0;justify-content:center;transition:color .15s,background .15s,border-color .15s,box-shadow .15s}.give-gift-tabs .btn:not(.primary):hover{color:var(--brand);background:var(--brand-tint)}.give-gift-tabs .btn.primary{color:#fff;background:var(--brand);border-color:var(--brand);box-shadow:var(--shadow-brand)}.give-gift-upgrade-note{background:var(--brand-tint);border:1px solid var(--brand-tint-border);color:var(--text-soft);border-radius:10px;margin:0;padding:9px 12px;font-size:11px;font-weight:650;line-height:1.45}.give-gift-attrs{grid-template-columns:repeat(3,minmax(0,1fr));align-items:end}.give-gift-attrs select,.give-gift-attrs input{width:100%;min-width:0;height:38px;color:var(--text);background-color:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);font:inherit;appearance:none;cursor:pointer;padding:0 32px 0 10px;font-size:12px;font-weight:600}.give-gift-attrs input{cursor:text;text-overflow:ellipsis;padding-right:10px}.give-gift-attrs select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right 11px center;background-repeat:no-repeat}.give-gift-attrs select:focus,.give-gift-attrs input:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus);outline:none}.give-gift-layout{grid-template-columns:minmax(220px,280px) minmax(0,1fr);align-items:start;gap:16px;display:grid}.give-gift-picker{align-content:start;gap:10px;display:grid}.give-gift-picker-head{align-items:center;gap:12px;display:flex}.give-gift-picker-head .searchbox{flex:auto}.give-gift-picker-list{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-lg);gap:8px;max-height:640px;padding:8px;display:grid;overflow-y:auto}.give-gift-option{text-align:left;min-width:0;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);cursor:pointer;box-shadow:var(--shadow-sm);grid-template-columns:46px minmax(0,1fr) auto;align-items:center;gap:11px;padding:9px 11px;transition:border-color .15s,box-shadow .15s,transform .15s;display:grid}.give-gift-option:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.give-gift-option.selected{border-color:var(--brand);box-shadow:0 0 0 2px var(--focus), var(--shadow)}.give-gift-thumb{place-items:center;width:46px;height:46px;display:grid}.give-gift-thumb canvas{width:100%!important;height:100%!important}.give-gift-option-info{gap:3px;min-width:0;display:grid}.give-gift-option-info strong{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.give-gift-option-info .mono{color:var(--muted);font-size:10px}.give-gift-option-price{white-space:nowrap;justify-self:end}.give-gift-panel{background:var(--panel);border:1px solid var(--line-strong);border-radius:var(--radius-lg);gap:12px;min-width:0;padding:16px;display:grid}.give-gift-form{gap:12px;min-width:0;display:grid}.give-gift-form-actions{flex-wrap:wrap;justify-content:flex-end;gap:10px;padding-top:4px;display:flex}.give-gift-empty-panel{color:var(--muted);text-align:center;place-items:center;gap:10px;padding:48px 20px;display:grid}.give-gift-empty-panel svg{color:var(--brand);opacity:.8}.official-gift-picker{gap:12px;min-width:0;display:grid}.official-gift-bulk-import{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.gift-bulk-import-progress{align-items:center;gap:8px;min-width:180px;display:flex}.gift-bulk-import-progress-bar{background:#e3e8ef;border-radius:999px;flex:auto;width:120px;height:6px;overflow:hidden}.gift-bulk-import-progress-bar>div{background:var(--brand);border-radius:999px;height:100%;transition:width .2s}.gift-bulk-import-progress span{color:var(--muted);white-space:nowrap;font-size:11px;font-weight:700}.official-gift-tools{align-items:center;gap:12px;display:flex}.official-gift-tools .searchbox{width:100%}.official-gift-tools>span{color:var(--muted);flex:none;font-size:11px;font-weight:750}.official-gift-categories{flex-wrap:wrap;gap:7px;display:flex}.official-gift-categories button{min-height:32px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line-strong);font:inherit;cursor:pointer;border-radius:999px;align-items:center;gap:7px;padding:5px 10px;font-size:11px;font-weight:800;transition:color .15s,background .15s,border-color .15s,box-shadow .15s;display:inline-flex}.official-gift-categories button:hover{color:var(--brand);border-color:var(--brand-tint-border)}.official-gift-categories button.active{color:#fff;background:var(--brand);border-color:var(--brand);box-shadow:var(--shadow-brand)}.official-gift-categories button span{min-width:20px;height:20px;color:inherit;background:#7d8c9b38;border-radius:999px;place-items:center;padding:0 5px;font-size:10px;display:grid}.official-gift-categories button.active span{color:var(--brand);background:#ffffffd9}.official-gift-list{border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--panel-subtle);scrollbar-gutter:stable;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;min-height:126px;max-height:314px;padding:8px;display:grid;overflow:auto}.official-gift-option{text-align:left;min-width:0;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);cursor:pointer;box-shadow:var(--shadow-sm);gap:8px;padding:11px 12px;transition:border-color .15s,box-shadow .15s,transform .15s;display:grid}.official-gift-option:hover{border-color:var(--brand-tint-border);box-shadow:var(--shadow);transform:translateY(-1px)}.official-gift-option.selected{border-color:var(--brand);box-shadow:0 0 0 2px var(--focus), var(--shadow)}.official-gift-option-head{grid-template-columns:minmax(0,1fr) auto;align-items:baseline;gap:8px;display:grid}.official-gift-option-head strong{text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.official-gift-option-head .mono{color:var(--muted);font-size:9px}.official-gift-option-meta{color:var(--muted);flex-wrap:wrap;gap:10px;font-size:10px;font-weight:700;display:flex}.official-gift-capabilities{flex-wrap:wrap;gap:5px;display:flex}.official-gift-capabilities>span{letter-spacing:.01em;border:1px solid #0000;border-radius:999px;padding:3px 7px;font-size:9px;font-weight:850}.official-gift-capabilities>span.yes{color:var(--good);background:var(--good-tint);border-color:var(--good-border)}.official-gift-capabilities>span.craft{color:var(--purple);background:var(--purple-tint);border-color:var(--purple-border)}.official-gift-capabilities>span.no{color:var(--muted);background:var(--panel-strong);border-color:var(--line-strong)}.official-gift-empty{min-height:108px;color:var(--muted);text-align:center;grid-column:1/-1;place-items:center;padding:20px;font-size:12px;display:grid}.official-gift-selected{border:1px solid var(--line);border-radius:var(--radius-lg);background:var(--surface-soft);grid-template-columns:108px minmax(0,1fr);align-items:center;gap:14px;padding:12px;display:grid}.official-gift-selected .gift-animation-shell{border-radius:12px;width:96px;height:96px;min-height:96px;overflow:hidden}.official-gift-selected .gift-animation{width:96px;height:96px}.official-gift-selected>div:last-child{gap:5px;min-width:0;display:grid}.official-gift-selected small{color:var(--muted)}.gift-import-note{color:var(--muted);justify-content:space-between;align-items:center;gap:12px;line-height:1.45;display:flex}.gift-file-picker{min-height:78px;color:var(--text);background:var(--panel);border:1px dashed var(--line-strong);border-radius:var(--radius);cursor:pointer;grid-template-columns:42px minmax(0,1fr) auto;align-items:center;gap:12px;padding:12px 14px;transition:border-color .16s,background .16s,box-shadow .16s;display:grid;position:relative}.gift-file-picker:hover,.gift-file-picker.has-file{background:var(--brand-tint);border-color:var(--brand);box-shadow:0 0 0 2px var(--focus)}.gift-file-picker.compact{grid-template-columns:minmax(0,1fr);min-height:44px;padding:8px 12px}.gift-file-picker input{opacity:0;pointer-events:none;width:1px;height:1px;position:absolute}.gift-file-icon{border-radius:var(--radius-sm);width:40px;height:40px}.gift-file-copy{gap:2px;min-width:0;display:grid}.gift-field-label{color:var(--muted);text-transform:uppercase;letter-spacing:.04em;font-size:10px;font-weight:800}.gift-file-copy strong{color:var(--heading);text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.gift-file-copy small{color:var(--muted);font-size:11px;font-weight:500}.gift-file-action{color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:var(--radius-sm);padding:7px 10px;font-size:11px;font-weight:800}.gift-fields-grid{grid-template-columns:minmax(200px,1.5fr) repeat(3,minmax(120px,1fr));gap:10px;display:grid}.gift-fields-grid label,.gift-reason-field{color:var(--muted);gap:6px;font-size:11px;font-weight:700;display:grid}.gift-fields-grid input,.gift-reason-field input{width:100%;min-width:0;height:38px;color:var(--text);background:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);padding:0 10px}.gift-fields-grid input:focus,.gift-reason-field input:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--focus);outline:none}.gift-switch{color:var(--text-soft);cursor:pointer;align-items:center;gap:9px;font-size:12px;font-weight:700;display:inline-flex}.gift-switch input{opacity:0;width:1px;height:1px;position:absolute}.gift-switch-track{background:var(--switch-track);border-radius:999px;align-items:center;width:34px;height:19px;padding:2px;transition:background .16s;display:flex}.gift-switch-track span{background:#fff;border-radius:50%;width:15px;height:15px;transition:transform .16s;box-shadow:0 1px 3px #10182838}.gift-switch input:checked+.gift-switch-track{background:var(--brand)}.gift-switch input:checked+.gift-switch-track span{transform:translate(15px)}.gift-switch input:focus-visible+.gift-switch-track{outline:3px solid var(--focus);outline-offset:2px}.gift-validation{color:var(--code-text);background:var(--code-bg);border:1px solid var(--code-border);border-radius:var(--radius-sm);overflow:hidden}.gift-validation-head{color:var(--code-text);background:#ffffff09;border-bottom:1px solid #ffffff17;align-items:center;gap:9px;padding:10px 12px;display:flex}.gift-validation-head div{gap:2px;display:grid}.gift-validation-head span{color:var(--brand);font-size:10px}.gift-validation pre{max-height:180px;color:var(--code-text);margin:0;padding:11px 12px;font-size:11px;overflow:auto}.sticker-preview-modal{width:min(760px,100%)}.sticker-doc-grid{grid-template-columns:repeat(auto-fill,minmax(84px,1fr));gap:8px;max-height:420px;padding:2px;display:grid;overflow:auto}.sticker-doc-cell{aspect-ratio:1;background:var(--panel-strong);border:1px solid var(--line);border-radius:10px;place-items:center;display:grid;position:relative;overflow:hidden}.sticker-doc-canvas{width:100%;height:100%}.sticker-doc-canvas canvas{width:100%!important;height:100%!important}.sticker-doc-image{object-fit:contain;width:100%;height:100%}.sticker-doc-cell.list-thumb{flex:0 0 40px;width:40px}.sticker-list-thumb-empty{background:var(--panel-strong);border:1px solid var(--line);width:40px;height:40px;color:var(--muted);border-radius:9px;place-items:center;display:grid}.sticker-doc-grid-cell{gap:4px;display:grid}.sticker-doc-grid-cell .btn{justify-content:center;width:100%}.sticker-add-form{background:var(--panel-strong);border:1px solid var(--line);border-radius:10px;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:14px;padding:10px;display:flex}.sticker-add-form .gift-file-picker.compact{flex:220px;min-width:180px}.sticker-add-form .small-input{flex:0 140px}.sticker-add-form-error{color:var(--danger);flex-basis:100%;font-size:12px}.sticker-doc-error{color:var(--danger);text-align:center;place-items:center;padding:4px;font-size:9px;display:grid;position:absolute;inset:0}.gift-animation-shell{background:var(--surface-soft);place-items:center;min-height:210px;display:grid;position:relative}.gift-animation{width:200px;height:200px}.gift-animation canvas{width:100%!important;height:100%!important}.gift-play{width:30px;height:30px;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:50%;place-items:center;display:grid;position:absolute;bottom:8px;right:8px}.gift-table-wrap{background:var(--panel)}.gift-table{min-width:1080px}.gift-table th:nth-child(2){width:74px}.gift-table td{vertical-align:middle}.gift-select-col{text-align:center;width:34px}.gift-select-col input{width:15px;height:15px}.avatar-col{width:44px}.muted-cell{color:var(--muted)}.avatar-photo-img,.avatar-fallback{object-fit:cover;border-radius:50%;display:block}.avatar-fallback{color:#fff;letter-spacing:-.02em;place-items:center;font-weight:800;display:grid}.gift-bulk-toolbar{background:var(--panel-strong);border:1px solid var(--line);border-radius:9px;align-items:center;gap:10px;margin-bottom:10px;padding:9px 12px;display:flex}.gift-bulk-count{color:var(--text);white-space:nowrap;font-size:12px;font-weight:700}.gift-bulk-reason{flex:1;min-width:160px}.gift-bulk-reason input{height:34px}.gift-bulk-error{color:var(--danger);font-size:11px;font-weight:700}.gift-page-size{color:var(--muted);white-space:nowrap;align-items:center;gap:6px;font-size:11px;font-weight:700;display:inline-flex}.gift-page-size select{height:30px;color:var(--text);background:var(--input-bg);border:1px solid var(--line);border-radius:var(--radius-sm);font:inherit;padding:0 8px;font-weight:700}.gift-pager{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-top:10px;display:flex}.gift-pager-range{color:var(--muted);font-size:11px;font-weight:700}.gift-pager-controls{align-items:center;gap:10px;display:flex}.gift-pager-page{color:var(--text);white-space:nowrap;font-size:12px;font-weight:700}.gift-animation-shell.compact{border:1px solid var(--line);border-radius:var(--radius-sm);width:56px;min-height:56px;overflow:hidden}.gift-animation-shell.compact .gift-animation{width:54px;height:54px}.gift-animation-shell.compact .gift-play{width:20px;height:20px;bottom:3px;right:3px}.gift-row-disabled{opacity:.68}.gift-table-title,.gift-sort-order,.gift-source-size,.gift-convert-price{display:block}.gift-table-title{text-overflow:ellipsis;white-space:nowrap;max-width:220px;overflow:hidden}.gift-sort-order,.gift-source-size,.gift-convert-price{color:var(--muted);margin-top:3px;font-size:10px}.gift-table-price{color:var(--warn)}.gift-table-actions{align-items:center;gap:6px;display:flex}.collectible-button{color:var(--purple);background:var(--purple-tint);border-color:var(--purple-border)}.collectible-button:hover{background:var(--purple-tint);border-color:var(--purple)}.collectible-modal{width:min(1180px,100%);max-height:min(92vh,980px)}.collectible-modal .modal-head p{color:var(--muted);margin:4px 0 0;font-size:11px}.collectible-modal-body{background:var(--bg);gap:16px;padding:16px 18px 22px;overflow:auto}.collectible-loading{min-height:90px;color:var(--muted);justify-content:center;align-items:center;gap:8px;display:flex}.collectible-empty{color:var(--purple-text);background:var(--purple-tint);border:1px dashed var(--purple-border);border-radius:var(--radius);align-items:center;gap:12px;padding:16px;display:flex}.collectible-empty div,.collectible-definition-head>div:first-child,.collectible-section-head>div:first-child{gap:3px;display:grid}.collectible-empty span,.collectible-definition-head span,.collectible-section-head span{color:var(--muted);font-size:10px;font-weight:500}.collectible-active{background:var(--panel);border:1px solid var(--purple-border);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}.collectible-active-head{background:var(--purple-tint);border-bottom:1px solid var(--purple-border);justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;display:flex}.collectible-active-head>div{color:var(--purple-text);align-items:center;gap:9px;display:flex}.collectible-active-head>div>div{gap:2px;display:grid}.collectible-active-head span{color:var(--muted);font-size:10px}.collectible-active-grid{background:var(--line);grid-template-columns:repeat(auto-fill,minmax(145px,1fr));gap:1px;display:grid}.collectible-active-grid article{background:var(--panel);align-items:center;gap:9px;min-width:0;padding:9px 11px;display:flex}.collectible-active-grid article>div:last-child{gap:2px;min-width:0;display:grid}.collectible-active-grid article strong{text-overflow:ellipsis;white-space:nowrap;font-size:11px;overflow:hidden}.collectible-active-grid article span{color:var(--muted);font-size:9px}.collectible-definition{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}.collectible-definition-head{background:var(--panel-subtle);border-bottom:1px solid var(--line);justify-content:space-between;align-items:center;gap:12px;padding:14px 16px;display:flex}.collectible-main-fields{background:var(--panel-subtle);border-bottom:1px solid var(--line);padding:14px 16px}.collectible-section{border-bottom:1px solid var(--line);padding:14px 16px}.collectible-section:last-child{border-bottom:0}.collectible-section-head{justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;display:flex}.collectible-section-tools{align-items:center;gap:7px;display:flex}.collectible-rows{gap:7px;display:grid}.collectible-row{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:end;gap:7px;padding:9px 9px 9px 36px;display:grid;position:relative}.collectible-row:hover{background:var(--panel);border-color:var(--line-strong);box-shadow:var(--shadow-sm)}.collectible-row.animated{grid-template-columns:minmax(120px,1.2fr) 90px 78px minmax(160px,1.4fr) 48px 30px}.collectible-row.backdrop{grid-template-columns:minmax(110px,1.2fr) 70px 80px 70px repeat(4,52px) 48px 30px}.collectible-row-index{width:27px;color:var(--purple-text);background:var(--purple-tint);border-right:1px solid var(--purple-border);border-radius:var(--radius-xs) 0 0 var(--radius-xs);place-items:center;font-size:10px;font-weight:800;display:grid;position:absolute;top:0;bottom:0;left:0}.collectible-row label{gap:4px;min-width:0;display:grid}.collectible-row label>span{color:var(--muted);text-transform:uppercase;letter-spacing:.025em;font-size:9px;font-weight:800}.collectible-row input:not([type=file]){width:100%;min-width:0;height:32px;color:var(--text);background:var(--input-bg);border:1px solid var(--line-strong);border-radius:var(--radius-sm);font:inherit;padding:0 8px;font-size:11px}.collectible-row input:focus{border-color:var(--purple);box-shadow:0 0 0 3px var(--purple-tint);outline:none}.collectible-file input{opacity:0;pointer-events:none;width:1px;height:1px;position:absolute}.collectible-file em{min-width:0;height:32px;color:var(--purple-text);background:var(--purple-tint);border:1px dashed var(--purple-border);border-radius:var(--radius-sm);text-overflow:ellipsis;white-space:nowrap;cursor:pointer;align-items:center;gap:5px;padding:0 8px;font-size:10px;font-style:normal;font-weight:700;display:flex;overflow:hidden}.collectible-inline-preview{width:42px;height:42px;color:var(--purple);background:var(--purple-tint);border:1px solid var(--purple-border);border-radius:var(--radius-sm);place-items:center;display:grid;overflow:hidden}.collectible-animation{width:100%;height:100%;overflow:hidden}.collectible-animation.compact{background:var(--purple-tint);border:1px solid var(--purple-border);border-radius:var(--radius-sm);flex:0 0 42px;place-items:center;width:42px;height:42px;display:grid}.collectible-animation canvas{width:100%!important;height:100%!important}.collectible-animation.failed{color:var(--danger);background:var(--danger-tint)}.collectible-animation.loading{color:var(--purple-text)}.collectible-file-error{color:var(--danger);grid-column:1/-1;font-size:10px}.collectible-color input{cursor:pointer;height:32px!important;padding:3px!important}.collectible-backdrop-preview{border-radius:var(--radius-sm);border:1px solid #2a1f472e;flex:0 0 42px;place-items:center;width:42px;height:42px;font-size:11px;font-weight:900;display:grid;box-shadow:inset 0 0 0 1px #fff3}.collectible-row .icon-btn{align-self:center}.collectible-row .icon-btn:disabled{opacity:.28}@media (width<=900px){.gift-fields-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.give-gift-layout{grid-template-columns:1fr}.give-gift-picker-list{max-height:320px}.collectible-row.animated,.collectible-row.backdrop{grid-template-columns:repeat(2,minmax(0,1fr))}.collectible-inline-preview,.collectible-backdrop-preview,.collectible-row .icon-btn{place-self:center start}}@media (width<=620px){.gift-import-note{flex-direction:column;align-items:flex-start}.gift-format-chips{justify-content:flex-start}.gift-file-picker{grid-template-columns:40px minmax(0,1fr)}.gift-file-action{display:none}.gift-fields-grid{grid-template-columns:1fr}.gift-list-summary{width:100%;margin-left:0}.official-gift-tools{flex-direction:column;align-items:stretch}.official-gift-list{grid-template-columns:1fr;max-height:340px}.official-gift-selected{grid-template-columns:82px minmax(0,1fr)}.official-gift-selected .gift-animation-shell{width:72px;height:72px}.collectible-modal-body{padding:10px}.collectible-definition-head,.collectible-section-head{flex-direction:column;align-items:flex-start}.collectible-row.animated,.collectible-row.backdrop{grid-template-columns:1fr}.collectible-active-grid{grid-template-columns:1fr 1fr}}.attr-block{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);gap:8px;padding:10px;display:grid}.attr-block .duration-field input{width:100%}.attr-block .btn{justify-content:center;width:100%}.emoji-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;display:grid}.emoji-card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);gap:8px;padding:12px;display:grid}.emoji-preview{background:var(--surface-soft);border:1px solid var(--line);border-radius:var(--radius-sm);place-items:center;height:88px;display:grid}.emoji-anim{width:80px;height:80px}.emoji-anim canvas{width:100%!important;height:100%!important}.emoji-glyph{font-size:46px;line-height:1}.emoji-meta{gap:4px;min-width:0;display:grid}.emoji-alt{font-size:18px;line-height:1.2}.emoji-id{width:100%;min-width:0;color:var(--text);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);cursor:pointer;justify-content:space-between;align-items:center;gap:6px;padding:4px 8px;font-size:11px;display:flex}.emoji-id .mono{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;overflow:hidden}.emoji-id svg{flex:none}.emoji-id:hover{border-color:var(--brand-tint-border);color:var(--brand)}.emoji-sub{color:var(--muted);text-overflow:ellipsis;white-space:nowrap;font-size:11px;overflow:hidden}.modal-backdrop{z-index:10000;background:var(--overlay);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);place-items:center;padding:24px;display:grid;position:fixed;inset:0}.modal{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-lg);width:min(760px,100%);max-height:min(820px,100vh - 48px);box-shadow:var(--shadow);padding:0;overflow:hidden}.command-modal{flex-direction:column;display:flex}.command-modal>.modal-head,.command-modal>.modal-actions{flex:none}.modal-head{border-bottom:1px solid var(--line);justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 18px 12px;display:flex}.icon-btn{width:30px;height:30px;color:var(--text-soft);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);cursor:pointer;place-items:center;transition:background-color .14s,border-color .14s,color .14s;display:grid}.icon-btn:hover{background:var(--btn-hover);border-color:var(--line-strong)}.command-steps{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;display:grid}.command-body{grid-auto-rows:max-content;gap:12px;min-height:0;padding:14px 18px;display:grid;overflow:auto}.command-step{min-height:38px;color:var(--muted);background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius-sm);align-items:center;gap:8px;padding:0 10px;display:flex}.command-step span{background:var(--panel);border:1px solid var(--line);border-radius:999px;place-items:center;width:20px;height:20px;font-size:11px;font-weight:800;display:grid}.command-step.active{color:var(--brand);border-color:var(--brand-tint-border)}.command-step.done{color:var(--good);border-color:var(--good-border)}.form-field{gap:6px;display:grid}.form-field span,.form-stack span{color:var(--text-soft);font-weight:800}.form-field input:disabled,.form-field textarea:disabled{opacity:.6;cursor:not-allowed}.command-preview{gap:8px;display:grid}.command-preview .json-block{max-height:150px}.preview-head,.result-title{color:var(--text-soft);align-items:center;gap:7px;font-weight:800;display:flex}.result-box{background:var(--panel-subtle);border:1px solid var(--line);border-radius:var(--radius);gap:8px;padding:10px;display:grid}.result-line{grid-template-columns:92px minmax(0,1fr);gap:8px;display:grid}.result-line span{color:var(--muted)}.result-line strong{overflow-wrap:anywhere}.result-message{color:var(--text-soft)}.modal-actions{background:var(--panel);border-top:1px solid var(--line);justify-content:flex-end;padding:12px 18px}.login-page{background:var(--bg);background-image:radial-gradient(900px 480px at 50% -8%, var(--hero-glow) 0%, #0000 70%), linear-gradient(var(--hero-grid) 1px, transparent 1px), linear-gradient(90deg, var(--hero-grid) 1px, transparent 1px);background-size:auto,44px 44px,44px 44px;place-items:center;min-height:100vh;padding:24px;display:grid;position:relative;overflow:hidden}.login-page .bg-orbs{z-index:0;pointer-events:none;position:absolute;inset:-60px}.login-page .bg-orb{filter:blur(100px);pointer-events:none;border-radius:50%;position:absolute}.login-page .bg-orb--1{background:color-mix(in srgb, var(--brand-2) 40%, transparent);width:700px;height:700px;animation:20s ease-in-out infinite loginOrbFloat1;top:-15%;left:-10%}.login-page .bg-orb--2{background:color-mix(in srgb, var(--brand) 38%, transparent);width:600px;height:600px;animation:24s ease-in-out infinite loginOrbFloat2;top:25%;right:-15%}.login-page .bg-orb--3{background:color-mix(in srgb, var(--brand-2) 30%, transparent);width:500px;height:500px;animation:28s ease-in-out infinite loginOrbFloat3;bottom:-15%;left:30%}@keyframes loginOrbFloat1{0%,to{transform:translate(0)scale(1)}33%{transform:translate(60px,-40px)scale(1.08)}66%{transform:translate(-30px,30px)scale(.92)}}@keyframes loginOrbFloat2{0%,to{transform:translate(0)scale(1)}33%{transform:translate(-50px,-35px)scale(.93)}66%{transform:translate(45px,25px)scale(1.07)}}@keyframes loginOrbFloat3{0%,to{transform:translate(0)scale(1)}33%{transform:translate(40px,45px)scale(1.06)}66%{transform:translate(-55px,-25px)scale(.94)}}@media (width<=720px){.login-page .bg-orb{filter:blur(60px)}.login-page .bg-orb--1{width:350px;height:350px}.login-page .bg-orb--2{width:300px;height:300px}.login-page .bg-orb--3{width:250px;height:250px}}@media (prefers-reduced-motion:reduce){.login-page .bg-orb{animation:none}}.login-page .login-panel{z-index:1;position:relative}.login-panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-lg);width:min(420px,100%);box-shadow:var(--shadow);gap:18px;padding:22px;display:grid}.login-head{justify-content:space-between;align-items:center;gap:12px;display:flex}.login-head-actions{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;display:flex}.login-chip{min-height:24px;color:var(--brand);background:var(--brand-tint);border:1px solid var(--brand-tint-border);border-radius:999px;align-items:center;padding:0 8px;font-size:12px;display:inline-flex}.login-copy h1{color:var(--heading);margin:0;font-size:22px}.login-copy p{color:var(--muted);margin:8px 0 0}.form-stack{gap:12px;display:grid}.form-stack label{gap:6px;display:grid}.form-stack input{width:100%}.boot-screen{background:var(--bg);align-content:center;place-items:center;gap:18px;min-height:100vh;display:grid}.loader-bar{background:var(--line-strong);border-radius:999px;width:180px;height:4px;overflow:hidden}.loader-bar:before{content:"";background:var(--brand);width:42%;height:100%;animation:1s ease-in-out infinite load;display:block}.spin{animation:.8s linear infinite spin}@keyframes load{0%{transform:translate(-120%)}to{transform:translate(260%)}}@keyframes spin{to{transform:rotate(360deg)}}@media (width<=1120px){.shell{grid-template-columns:1fr}.sidebar{height:auto;position:static}.nav-list{grid-template-columns:repeat(4,minmax(0,1fr))}.sidebar-status{display:none}.overview-band,.split-layout,.operation-row,.raw-grid,.message-selector-grid,.message-selector-grid.single{grid-template-columns:1fr}.action-dock{position:static}}@media (width<=760px){.content,.topbar{padding-left:14px;padding-right:14px}.command-grid,.work-strip,.overview-metrics,.metric-row,.summary-grid,.command-steps{grid-template-columns:1fr}.sidebar{gap:12px;padding:14px}.nav-list{grid-template-columns:repeat(2,minmax(0,1fr))}.topbar,.page-title-row,.entity-head{flex-direction:column;align-items:flex-start}input,.searchbox{width:100%}.toolbar{align-items:stretch}.picker-row,.selected-entity{grid-template-columns:1fr}} diff --git a/cmd/telesrv-admin/web/dist/assets/index-kK52bvQu.js b/cmd/telesrv-admin/web/dist/assets/index-kK52bvQu.js deleted file mode 100644 index 051eb5e9..00000000 --- a/cmd/telesrv-admin/web/dist/assets/index-kK52bvQu.js +++ /dev/null @@ -1,10 +0,0 @@ -var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m)if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function h(e){return l.call(m,e)?!0:l.call(p,e)?!1:d.test(e)?m[e]=!0:(p[e]=!0,!1)}function g(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function _(e,t,n,r){if(t==null||g(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` -`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{re=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?ne(e):``}function ae(e){switch(e.tag){case 5:return ne(e.type);case 16:return ne(`Lazy`);case 13:return ne(`Suspense`);case 19:return ne(`SuspenseList`);case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return``}}function oe(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case M:return`Suspense`;case N:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case A:return(e.displayName||`Context`)+`.Consumer`;case k:return(e._context.displayName||`Context`)+`.Provider`;case j:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case P:return t=e.displayName||null,t===null?oe(e.type)||`Memo`:t;case F:t=e._payload,e=e._init;try{return oe(e(t))}catch{}}return null}function se(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return oe(t);case 8:return t===D?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function ce(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function le(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function ue(e){var t=le(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function z(e){e._valueTracker||=ue(e)}function de(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=le(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function fe(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function pe(e,t){var n=t.checked;return R({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function me(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=ce(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function he(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function ge(e,t){he(e,t);var n=ce(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?ve(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&ve(e,t.type,ce(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function _e(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function ve(e,t,n){(t!==`number`||fe(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var ye=Array.isArray;function be(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Te.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function De(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Oe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ke=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Oe).forEach(function(e){ke.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Oe[t]=Oe[e]})});function Ae(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Oe.hasOwnProperty(e)&&Oe[e]?(``+t).trim():t+`px`}function je(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ae(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Me=R({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ne(e,t){if(t){if(Me[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Pe(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Fe=null;function H(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ie=null,Le=null,Re=null;function ze(e){if(e=ji(e)){if(typeof Ie!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Ni(t),Ie(e.stateNode,e.type,t))}}function U(e){Le?Re?Re.push(e):Re=[e]:Le=e}function Be(){if(Le){var e=Le,t=Re;if(Re=Le=null,ze(e),t)for(e=0;e>>=0,e===0?32:31-(vt(e)/yt|0)|0}var Y=64,xt=4194304;function St(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ct(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=St(a))):r=St(s)}else o=n&~i,o===0?a!==0&&(r=St(a)):r=St(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function kt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-_t(t),e[t]=n}function At(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Gn),Jn=` `,Yn=!1;function Xn(e,t){switch(e){case`keyup`:return Un.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Zn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Qn=!1;function $n(e,t){switch(e){case`compositionend`:return Zn(t);case`keypress`:return t.which===32?(Yn=!0,Jn):null;case`textInput`:return e=t.data,e===Jn&&Yn?null:e;default:return null}}function er(e,t){if(Qn)return e===`compositionend`||!Wn&&Xn(e,t)?(e=mn(),pn=fn=dn=null,Qn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=xr(n)}}function Cr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Cr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wr(){for(var e=window,t=fe();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=fe(e.document)}return t}function Tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Er(e){var t=wr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Cr(n.ownerDocument.documentElement,n)){if(r!==null&&Tr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Sr(n,a);var o=Sr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Or=null,kr=null,Ar=null,jr=!1;function Mr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;jr||Or==null||Or!==fe(r)||(r=Or,`selectionStart`in r&&Tr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ar&&br(Ar,r)||(Ar=r,r=ii(kr,`onSelect`),0Fi||(e.current=Pi[Fi],Pi[Fi]=null,Fi--)}function Ri(e,t){Fi++,Pi[Fi]=e.current,e.current=t}var zi={},Bi=Ii(zi),Vi=Ii(!1),Hi=zi;function Ui(e,t){var n=e.type.contextTypes;if(!n)return zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Wi(e){return e=e.childContextTypes,e!=null}function Gi(){Li(Vi),Li(Bi)}function Ki(e,t,n){if(Bi.current!==zi)throw Error(r(168));Ri(Bi,t),Ri(Vi,n)}function qi(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,se(e)||`Unknown`,a));return R({},n,i)}function Ji(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zi,Hi=Bi.current,Ri(Bi,e),Ri(Vi,Vi.current),!0}function Yi(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=qi(e,t,Hi),i.__reactInternalMemoizedMergedChildContext=e,Li(Vi),Li(Bi),Ri(Bi,e)):Li(Vi),Ri(Vi,n)}var Xi=null,Zi=!1,Qi=!1;function $i(e){Xi===null?Xi=[e]:Xi.push(e)}function ea(e){Zi=!0,$i(e)}function ta(){if(!Qi&&Xi!==null){Qi=!0;var e=0,t=X;try{var n=Xi;for(X=1;e>=o,i-=o,la=1<<32-_t(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),_a&&da(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),_a&&da(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return _a&&da(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),_a&&da(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===F&&ja(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ka(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=Zl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Xl(i.type,i.key,i.props,null,e.mode,o),o.ref=ka(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=eu(i,e.mode,o),r.return=e,e=r}return s(e);case F:return l=i._init,_(e,r,l(i._payload),o)}if(ye(i))return h(e,r,i,o);if(ee(i))return g(e,r,i,o);Aa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=$l(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Na=Ma(!0),Pa=Ma(!1),Fa=Ii(null),Ia=null,La=null,Ra=null;function za(){Ra=La=Ia=null}function Ba(e){var t=Fa.current;Li(Fa),e._currentValue=t}function Va(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ha(e,t){Ia=e,Ra=La=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ms=!0),e.firstContext=null)}function Ua(e){var t=e._currentValue;if(Ra!==e)if(e={context:e,memoizedValue:t,next:null},La===null){if(Ia===null)throw Error(r(308));La=e,Ia.dependencies={lanes:0,firstContext:e}}else La=La.next=e;return t}var Wa=null;function Ga(e){Wa===null?Wa=[e]:Wa.push(e)}function Ka(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ga(t)):(n.next=i.next,i.next=n),t.interleaved=n,qa(e,r)}function qa(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ja=!1;function Ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Za(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qa(e,n)}return i=r.interleaved,i===null?(t.next=t,Ga(r)):(t.next=i.next,i.next=t),r.interleaved=t,qa(e,n)}function $a(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,jt(e,n)}}function eo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function to(e,t,n,r){var i=e.updateQueue;Ja=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=R({},d,f);break a;case 2:Ja=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Jc|=o,e.lanes=o,e.memoizedState=d}}function no(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vo.transition;vo.transition={};try{e(!1),t()}finally{X=n,vo.transition=r}}function as(){return Mo().memoizedState}function os(e,t,n){var r=pl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},cs(e))ls(t,n);else if(n=Ka(e,t,n,r),n!==null){var i=fl();ml(n,e,r,i),us(n,t,r)}}function ss(e,t,n){var r=pl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(cs(e))ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Z(s,o)){var c=t.interleaved;c===null?(i.next=i,Ga(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ka(e,t,i,r),n!==null&&(i=fl(),ml(n,e,r,i),us(n,t,r))}}function cs(e){var t=e.alternate;return e===bo||t!==null&&t===bo}function ls(e,t){wo=Co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function us(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,jt(e,n)}}var ds={readContext:Ua,useCallback:Do,useContext:Do,useEffect:Do,useImperativeHandle:Do,useInsertionEffect:Do,useLayoutEffect:Do,useMemo:Do,useReducer:Do,useRef:Do,useState:Do,useDebugValue:Do,useDeferredValue:Do,useTransition:Do,useMutableSource:Do,useSyncExternalStore:Do,useId:Do,unstable_isNewReconciler:!1},fs={readContext:Ua,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:Ua,useEffect:Jo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Ko(4194308,4,Qo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ko(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ko(4,2,e,t)},useMemo:function(e,t){var n=jo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=jo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=os.bind(null,bo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:Uo,useDebugValue:es,useDeferredValue:function(e){return jo().memoizedState=e},useTransition:function(){var e=Uo(!1),t=e[0];return e=is.bind(null,e[1]),jo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=bo,a=jo();if(_a){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Vc===null)throw Error(r(349));yo&30||Ro(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Jo(Bo.bind(null,i,o,e),[e]),i.flags|=2048,Wo(9,zo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=jo(),t=Vc.identifierPrefix;if(_a){var n=ua,r=la;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=To++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[wi]=t,e[Ti]=i,nc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Pe(n,i),n){case`dialog`:Zr(`cancel`,e),Zr(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:Zr(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;oel&&(t.flags|=128,i=!0,ac(s,!1),t.lanes=4194304)}else{if(!i)if(e=mo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ac(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!_a)return oc(t),null}else 2*ut()-s.renderingStartTime>el&&n!==1073741824&&(t.flags|=128,i=!0,ac(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(oc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=ut(),t.sibling=null,n=po.current,Ri(po,i?n&1|2:n&1),t);case 22:case 23:return wl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Wc&1073741824&&(oc(t),t.subtreeFlags&6&&(t.flags|=8192)):oc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function cc(e,t){switch(ma(t),t.tag){case 1:return Wi(t.type)&&Gi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lo(),Li(Vi),Li(Bi),go(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fo(t),null;case 13:if(Li(po),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ea()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Li(po),null;case 4:return lo(),null;case 10:return Ba(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var lc=!1,uc=!1,dc=typeof WeakSet==`function`?WeakSet:Set,Q=null;function fc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Rl(e,t,n)}else n.current=null}function pc(e,t,n){try{n()}catch(n){Rl(e,t,n)}}var mc=!1;function hc(e,t){if(fi=rn,e=wr(),Tr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(pi={focusedElem:e,selectionRange:n},rn=!1,Q=t;Q!==null;)if(t=Q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Q=e;else for(;Q!==null;){t=Q;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:hs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Rl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Q=e;break}Q=t.return}return h=mc,mc=!1,h}function gc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&pc(t,n,a)}i=i.next}while(i!==r)}}function _c(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function yc(e){var t=e.alternate;t!==null&&(e.alternate=null,yc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Ti],delete t[Di],delete t[Oi],delete t[ki])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bc(e){return e.tag===5||e.tag===3||e.tag===4}function xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||bc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=di));else if(r!==4&&(e=e.child,e!==null))for(Sc(e,t,n),e=e.sibling;e!==null;)Sc(e,t,n),e=e.sibling}function Cc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Cc(e,t,n),e=e.sibling;e!==null;)Cc(e,t,n),e=e.sibling}var wc=null,Tc=!1;function Ec(e,t,n){for(n=n.child;n!==null;)Dc(e,t,n),n=n.sibling}function Dc(e,t,n){if(ht&&typeof ht.onCommitFiberUnmount==`function`)try{ht.onCommitFiberUnmount(J,n)}catch{}switch(n.tag){case 5:uc||fc(n,t);case 6:var r=wc,i=Tc;wc=null,Ec(e,t,n),wc=r,Tc=i,wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wc.removeChild(n.stateNode));break;case 18:wc!==null&&(Tc?(e=wc,n=n.stateNode,e.nodeType===8?bi(e.parentNode,n):e.nodeType===1&&bi(e,n),tn(e)):bi(wc,n.stateNode));break;case 4:r=wc,i=Tc,wc=n.stateNode.containerInfo,Tc=!0,Ec(e,t,n),wc=r,Tc=i;break;case 0:case 11:case 14:case 15:if(!uc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&pc(n,t,o),i=i.next}while(i!==r)}Ec(e,t,n);break;case 1:if(!uc&&(fc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Rl(n,t,e)}Ec(e,t,n);break;case 21:Ec(e,t,n);break;case 22:n.mode&1?(uc=(r=uc)||n.memoizedState!==null,Ec(e,t,n),uc=r):Ec(e,t,n);break;default:Ec(e,t,n)}}function Oc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new dc),t.forEach(function(t){var r=Hl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function kc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=ut()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Lc(i/1960))-i,10e?16:e,ol===null)var i=!1;else{if(e=ol,ol=null,sl=0,$&6)throw Error(r(331));var a=$;for($|=4,Q=e.current;Q!==null;){var o=Q,s=o.child;if(Q.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lut()-$c?Tl(e,0):Xc|=n),hl(e,t)}function Bl(e,t){t===0&&(e.mode&1?(t=xt,xt<<=1,!(xt&130023424)&&(xt=4194304)):t=1);var n=fl();e=qa(e,t),e!==null&&(kt(e,t,n),hl(e,n))}function Vl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bl(e,n)}function Hl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Bl(e,n)}var Ul=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Vi.current)Ms=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ms=!1,tc(e,t,n);Ms=!!(e.flags&131072)}else Ms=!1,_a&&t.flags&1048576&&fa(t,aa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;$s(e,t),e=t.pendingProps;var a=Ui(t,Bi.current);Ha(t,n),a=ko(null,t,i,e,a,n);var o=Ao();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wi(i)?(o=!0,Ji(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Ya(t),a.updater=_s,t.stateNode=a,a._reactInternals=t,xs(t,i,e,n),t=Vs(null,t,i,!0,o,n)):(t.tag=0,_a&&o&&pa(t),Ns(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch($s(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Jl(i),e=hs(i,e),a){case 0:t=zs(null,t,i,e,n);break a;case 1:t=Bs(null,t,i,e,n);break a;case 11:t=Ps(null,t,i,e,n);break a;case 14:t=Fs(null,t,i,hs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:hs(i,a),zs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:hs(i,a),Bs(e,t,i,a,n);case 3:a:{if(Hs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,Xa(e,t),to(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ss(Error(r(423)),t),t=Us(e,t,i,n,a);break a}else if(i!==a){a=Ss(Error(r(424)),t),t=Us(e,t,i,n,a);break a}else for(ga=xi(t.stateNode.containerInfo.firstChild),ha=t,_a=!0,va=null,n=Pa(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ea(),i===a){t=ec(e,t,n);break a}Ns(e,t,i,n)}t=t.child}return t;case 5:return uo(t),e===null&&Sa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,mi(i,a)?s=null:o!==null&&mi(i,o)&&(t.flags|=32),Rs(e,t),Ns(e,t,s,n),t.child;case 6:return e===null&&Sa(t),null;case 13:return Ks(e,t,n);case 4:return co(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Na(t,null,i,n):Ns(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:hs(i,a),Ps(e,t,i,a,n);case 7:return Ns(e,t,t.pendingProps,n),t.child;case 8:return Ns(e,t,t.pendingProps.children,n),t.child;case 12:return Ns(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ri(Fa,i._currentValue),i._currentValue=s,o!==null)if(Z(o.value,s)){if(o.children===a.children&&!Vi.current){t=ec(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=Za(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Va(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Va(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Ns(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Ha(t,n),a=Ua(a),i=i(a),t.flags|=1,Ns(e,t,i,n),t.child;case 14:return i=t.type,a=hs(i,t.pendingProps),a=hs(i.type,a),Fs(e,t,i,a,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:hs(i,a),$s(e,t),t.tag=1,Wi(i)?(e=!0,Ji(t)):e=!1,Ha(t,n),ys(t,i,a),xs(t,i,a,n),Vs(null,t,i,!0,e,n);case 19:return Qs(e,t,n);case 22:return Ls(e,t,n)}throw Error(r(156,t.tag))};function Wl(e,t){return ot(e,t)}function Gl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Kl(e,t,n,r){return new Gl(e,t,n,r)}function ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jl(e){if(typeof e==`function`)return+!!ql(e);if(e!=null){if(e=e.$$typeof,e===j)return 11;if(e===P)return 14}return 2}function Yl(e,t){var n=e.alternate;return n===null?(n=Kl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Xl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return Zl(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Kl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case M:return e=Kl(13,n,t,a),e.elementType=M,e.lanes=o,e;case N:return e=Kl(19,n,t,a),e.elementType=N,e.lanes=o,e;case I:return Ql(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case j:s=11;break a;case P:s=14;break a;case F:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Kl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Zl(e,t,n,r){return e=Kl(7,e,r,t),e.lanes=n,e}function Ql(e,t,n,r){return e=Kl(22,e,r,t),e.elementType=I,e.lanes=n,e.stateNode={isHidden:!1},e}function $l(e,t,n){return e=Kl(6,e,null,t),e.lanes=n,e}function eu(e,t,n){return t=Kl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function tu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ot(0),this.expirationTimes=Ot(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function nu(e,t,n,r,i,a,o,s,c){return e=new tu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Kl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ya(a),e}function ru(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u()),_=c(h(),1),v=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function y(e,t={}){let n=typeof FormData<`u`&&t.body instanceof FormData,r=await fetch(e,{credentials:`same-origin`,headers:n?t.headers:{"Content-Type":`application/json`,...t.headers??{}},...t}),i=await r.text(),a=i?JSON.parse(i):null;if(!r.ok){let e=a?.error||a?.Error||a?.message||r.statusText;throw new v(r.status,e)}return a}function b(e){return e instanceof Error?e.message:String(e)}var x={session:()=>y(`/api/session`),login:e=>y(`/api/login`,{method:`POST`,body:JSON.stringify({secret:e})}),logout:()=>y(`/api/logout`,{method:`POST`,body:`{}`}),accounts:e=>y(`/api/accounts?${e.toString()}`),accountStats:()=>y(`/api/accounts/stats`),account:e=>y(`/api/accounts/${e}`),channels:e=>y(`/api/channels?${e.toString()}`),channel:e=>y(`/api/channels/${e}`),bots:e=>y(`/api/bots?${e.toString()}`),bot:e=>y(`/api/bots/${e}`),emoji:e=>y(`/api/emoji?${e.toString()}`),emojiAnimation:e=>y(`/api/emoji/${encodeURIComponent(e)}/animation`),messages:e=>y(`/api/messages?${e.toString()}`),message:(e,t)=>y(`/api/messages/detail?${new URLSearchParams({owner_user_id:String(e),msg_id:String(t)}).toString()}`),groupMessages:e=>y(`/api/messages/groups?${e.toString()}`),groupMessage:(e,t)=>y(`/api/messages/groups/detail?${new URLSearchParams({channel_id:String(e),msg_id:String(t)}).toString()}`),gifts:()=>y(`/api/gifts`),stickerSets:e=>y(`/api/stickers?kind=${encodeURIComponent(e)}`),stickerSetDocuments:e=>y(`/api/stickers/${encodeURIComponent(e)}/documents`),stickerDocumentAnimationURL:e=>`/api/stickers/documents/${encodeURIComponent(e)}/animation`,createStickerSet:e=>y(`/api/actions/create-sticker-set`,{method:`POST`,body:e}),addStickerToSet:e=>y(`/api/actions/add-sticker-to-set`,{method:`POST`,body:e}),defaultGifts:()=>y(`/api/default-gifts`),defaultGiftAnimation:e=>y(`/api/default-gifts/${e}/animation`),officialGifts:()=>y(`/api/official-gifts`),officialGiftAnimation:e=>y(`/api/official-gifts/${encodeURIComponent(e)}/animation`),giftAnimation:e=>y(`/api/gifts/${encodeURIComponent(e)}/animation`),giftCollectibles:e=>y(`/api/gifts/${encodeURIComponent(e)}/collectibles`),giftCollectibleAnimation:(e,t,n)=>y(`/api/gifts/${encodeURIComponent(e)}/collectibles/${t}/${encodeURIComponent(n)}/animation`),importGift:e=>y(`/api/actions/import-gift`,{method:`POST`,body:e}),importDefaultGift:e=>y(`/api/actions/import-default-gift`,{method:`POST`,body:JSON.stringify(e)}),importOfficialGift:e=>y(`/api/actions/import-official-gift`,{method:`POST`,body:JSON.stringify(e)}),publishGiftCollectibles:(e,t)=>y(`/api/actions/publish-gift-collectibles?gift_id=${encodeURIComponent(e)}`,{method:`POST`,body:t}),action:(e,t)=>y(e,{method:`POST`,body:JSON.stringify(t)})},S=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),C=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),w={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},T=(0,g.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,g.createElement)(`svg`,{ref:c,...w,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:C(`lucide`,i),...s},[...o.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(a)?a:[a]])),E=(e,t)=>{let n=(0,g.forwardRef)(({className:n,...r},i)=>(0,g.createElement)(T,{ref:i,iconNode:t,className:C(`lucide-${S(e)}`,n),...r}));return n.displayName=`${e}`,n},D=E(`BadgeCheck`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),O=E(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),k=E(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),A=E(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),j=E(`ShieldX`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m14.5 9.5-5 5`,key:`17q4r4`}],[`path`,{d:`m9.5 9.5 5 5`,key:`18nt4w`}]]),M=E(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),N=E(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),P=E(`AtSign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),F=E(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),I=E(`Cable`,[[`path`,{d:`M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1`,key:`10bnsj`}],[`path`,{d:`M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9`,key:`1eqmu1`}],[`path`,{d:`M21 21v-2h-4`,key:`14zm7j`}],[`path`,{d:`M3 5h4V3`,key:`z442eg`}],[`path`,{d:`M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3`,key:`ebdjd7`}]]),L=E(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),ee=E(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),R=E(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),te=E(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ne=E(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),re=E(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ie=E(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ae=E(`FileJson2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`fq0c9t`}],[`path`,{d:`M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`4gibmv`}]]),oe=E(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),se=E(`Gem`,[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),ce=E(`Gift`,[[`rect`,{x:`3`,y:`8`,width:`18`,height:`4`,rx:`1`,key:`bkv52`}],[`path`,{d:`M12 8v13`,key:`1c76mn`}],[`path`,{d:`M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7`,key:`6wjy6b`}],[`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5`,key:`1ihvrl`}]]),le=E(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ue=E(`ImageOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),z=E(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),de=E(`LayoutDashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),fe=E(`LifeBuoy`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m4.93 4.93 4.24 4.24`,key:`1ymg45`}],[`path`,{d:`m14.83 9.17 4.24-4.24`,key:`1cb5xl`}],[`path`,{d:`m14.83 14.83 4.24 4.24`,key:`q42g0n`}],[`path`,{d:`m9.17 14.83-4.24 4.24`,key:`bqpfvv`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),pe=E(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),me=E(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),he=E(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),ge=E(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),_e=E(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),ve=E(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),ye=E(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),be=E(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),xe=E(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),B=E(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),V=E(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Se=E(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ce=E(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),we=E(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=E(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Ee=E(`Smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),De=E(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),Oe=E(`Sticker`,[[`path`,{d:`M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z`,key:`1wis1t`}],[`path`,{d:`M14 3v4a2 2 0 0 0 2 2h4`,key:`36rjfy`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M10 16s.8 1 2 1c1.3 0 2-1 2-1`,key:`1vvgv3`}]]),ke=E(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Ae=E(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),je=E(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),Me=E(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ne=E(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),Pe=E(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Fe=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),H=o(((e,t)=>{t.exports=Fe()}))(),Ie=`telesrv.admin.lang`,Le={en:{"app.adminConsole":`Admin Console`,"app.localAccess":`Local access`,"app.title":`OwpenGram Admin`,"common.actions":`Actions`,"common.admins":`Admins`,"common.backToList":`Back to list`,"common.channel":`Channel`,"common.channelOrGroup":`Channel / Group`,"common.clear":`Clear`,"common.close":`Close`,"common.count":`Count`,"common.deleted":`Deleted`,"common.detail":`Details`,"common.device":`Device`,"common.disabled":`Disabled`,"common.enabled":`Enabled`,"common.fromPeer":`From Peer`,"common.group":`Group`,"common.id":`ID`,"common.limit":`Limit`,"common.loading":`Loading`,"common.member":`Member`,"common.members":`Members`,"common.messageId":`Message ID`,"common.name":`Name`,"common.next":`Next page`,"common.no":`No`,"common.noResults":`No results`,"common.none":`None`,"common.normal":`Normal`,"common.operations":`Operations`,"common.previous":`Previous page`,"common.owner":`Owner`,"common.platform":`Platform`,"common.refresh":`Refresh`,"common.search":`Search`,"common.sender":`Sender`,"common.status":`Status`,"common.survived":`Live`,"common.time":`Time`,"common.type":`Type`,"common.updatedAt":`Updated`,"common.username":`Username`,"common.valid":`Valid`,"common.verified":`Verified`,"common.views":`Views`,"common.yes":`Yes`,"route.accounts":`Accounts`,"route.accountsSubtitle":`Console / Accounts`,"route.channels":`Supergroups and Channels`,"route.channelsSubtitle":`Console / Channels`,"route.dashboard":`Operations Console`,"route.dashboardSubtitle":`Console / Overview`,"route.messages":`Message Audit`,"route.messagesSubtitle":`Console / Messages`,"route.gifts":`Star Gifts`,"route.giftsSubtitle":`Console / Star Gifts`,"route.giveGifts":`Give Gifts`,"route.giveGiftsSubtitle":`Console / Give Gifts`,"layout.navigation":`Navigation`,"layout.primaryNav":`Primary navigation`,"layout.dashboard":`Overview`,"layout.accounts":`Accounts`,"layout.channels":`Supergroups / Channels`,"layout.messages":`Messages`,"layout.gifts":`Star Gifts`,"layout.giveGifts":`Give Gifts`,"layout.privateMessages":`Private`,"layout.groupMessages":`Groups`,"layout.runtime":`Runtime`,"layout.adminBackend":`Admin backend`,"layout.ready":`Ready`,"layout.pgRead":`PG read`,"layout.readOnly":`Read-only`,"layout.writeOps":`Write operations`,"layout.dryRun":`Dry-run`,"layout.actor":`Actor: {actor}`,"layout.logout":`Log out`,"language.en":`EN`,"language.zh":`中文`,"language.ru":`RU`,"theme.switchToDark":`Switch to dark theme`,"theme.switchToLight":`Switch to light theme`,"login.heading":`Operations Admin`,"login.body":`Enter credentials to open the console.`,"login.secret":`Admin password or token`,"login.submit":`Log in`,"login.submitting":`Logging in`,"dashboard.eyebrow":`Runtime Overview`,"dashboard.title":`Console Overview`,"dashboard.readPath":`Read path`,"dashboard.readPathValue":`PG read-only`,"dashboard.writePath":`Write path`,"dashboard.executionPolicy":`Execution policy`,"dashboard.dryRunFirst":`Dry-run first`,"dashboard.accountsText":`Account status, premium, verification, sessions.`,"dashboard.channelsText":`Public entities, member counts, verification state.`,"dashboard.messagesText":`Message boxes, updates, outbox state.`,"dashboard.strip.dryRun":`All dangerous actions start with dry-run`,"dashboard.strip.token":`Browser never stores internal tokens`,"dashboard.strip.pagination":`Lists use cursor pagination`,"dashboard.strip.snapshot":`Detail pages retain raw state snapshots`,"account.pageTitle":`Accounts`,"account.queryResults":`Search results`,"account.recentActive":`Recently active accounts`,"account.currentPage":`Accounts on page`,"account.onlineDevices":`Online device records`,"account.totalUsers":`Total users`,"account.onlineNow":`Online now`,"account.premium":`Premium`,"account.frozen":`Frozen`,"account.searchPlaceholder":`User ID / phone / username`,"account.userID":`User ID`,"account.phone":`Phone`,"account.lastActive":`Last active`,"account.notVerified":`Not verified`,"account.notPremium":`Not premium`,"account.premiumUntil":`Premium expires`,"account.starsBalance":`Stars balance`,"account.startingGrantApplied":`initial grant applied`,"account.startingGrantPending":`initial grant pending`,"account.activeSessions":`Authorized devices`,"account.accountFlags":`Account flags`,"account.restriction":`Restriction`,"account.restricted":`Restricted`,"account.createdAt":`Created`,"account.detailTitle":`Account #{id}`,"account.profile":`Account Profile`,"account.loadingDetail":`Loading account detail`,"account.waitingData":`Waiting for data`,"account.noUsername":`No username`,"account.noPhone":`No phone`,"account.accountFrozen":`Account frozen`,"account.accountActive":`Account active`,"account.authorizationsTitle":`Authorized Devices`,"account.authorizationsCount":`{count} authorizations`,"account.recentAdminOps":`Recent Admin Actions`,"account.recent30Audit":`Last 30 audit rows`,"account.actionDock":`Account Actions`,"account.freezeAccount":`Freeze account`,"account.updateFreeze":`Update freeze`,"account.unfreezeAccount":`Unfreeze account`,"account.freezeSince":`Frozen since`,"account.freezeUntil":`Appeal deadline`,"account.freezeUntilAria":`Freeze appeal deadline`,"account.freezeAppealURL":`Appeal URL`,"account.freezeAppealURLAria":`Freeze appeal URL`,"account.premiumMonths":`Premium duration (months)`,"account.premiumMonthsAria":`Set premium duration in months`,"account.setPremium":`Set premium`,"account.clearPremium":`Clear premium`,"account.starsAmount":`Stars to grant`,"account.starsAmountAria":`Set Stars amount to grant`,"account.grantStars":`Grant Stars`,"account.setVerified":`Set verified`,"account.clearVerified":`Clear verified`,"channel.pageTitle":`Supergroups and Channels`,"channel.recentUpdated":`Recently updated`,"channel.currentPage":`Entities on page`,"channel.megagroups":`Supergroups`,"channel.broadcasts":`Channels`,"channel.verifiedCount":`Verified`,"channel.searchPlaceholder":`Channel ID / username / title`,"channel.channelID":`Channel ID`,"channel.kind":`Kind`,"channel.title":`Title`,"channel.pts":`PTS`,"channel.detailProfile":`Channel Profile`,"channel.loadingDetail":`Loading channel detail`,"channel.creator":`Creator {id}`,"channel.governance":`Moderation`,"channel.governanceValue":`Banned {banned} / Kicked {kicked}`,"channel.flags":`Channel flags`,"channel.rawRow":`Channel Raw Row`,"channel.rawRowText":`Database read-only snapshot`,"channel.actionDock":`Channel Actions`,"channel.setVerified":`Set verified`,"channel.clearVerified":`Clear verified`,"channel.kind.broadcast":`Channel`,"channel.kind.forum":`Supergroup / Forum`,"channel.kind.megagroup":`Supergroup`,"channel.kind.generic":`Channel / Group`,"route.bots":`Bots`,"route.botsSubtitle":`Console / Bots`,"layout.bots":`Bots`,"bots.pageTitle":`Bots`,"bots.queryResults":`Search results`,"bots.recent":`Recently created bots`,"bots.currentPage":`Bots on page`,"bots.banned":`Banned`,"bots.active":`Active`,"bots.createTitle":`Create a system bot`,"bots.createHint":`Provision a bot account owned by the given user. The token is shown once after confirmation.`,"bots.ownerUserID":`Owner user ID`,"bots.name":`Display name`,"bots.namePlaceholder":`e.g. Service Bot`,"bots.username":`Username`,"bots.usernameHint":`Username must be 5-32 characters and end with 'bot'.`,"bots.create":`Create bot`,"bots.searchPlaceholder":`Bot ID / username`,"bots.botID":`Bot ID`,"bots.owner":`Owner`,"bots.status":`Status`,"bots.detailTitle":`Bot #{id}`,"bots.profile":`Bot Profile`,"bots.loadingDetail":`Loading bot detail`,"bots.unnamed":`Unnamed bot`,"bots.restriction":`Restriction`,"bots.actionDock":`Bot Actions`,"bots.banUntil":`Ban until`,"bots.ban":`Ban bot`,"bots.updateBan":`Update ban`,"bots.unban":`Unban bot`,"bots.type":`Type`,"bots.system":`System`,"bots.user":`User`,"bots.delete":`Delete bot`,"bots.deleteHint":`Permanently deletes this user-created bot and invalidates its token. This cannot be undone.`,"bots.systemHint":`System bots are built in and cannot be deleted.`,"flags.scam":`SCAM`,"flags.fake":`FAKE`,"flags.setScam":`Mark as SCAM`,"flags.clearScam":`Clear SCAM`,"flags.setFake":`Mark as FAKE`,"flags.clearFake":`Clear FAKE`,"attr.attributes":`Attributes`,"attr.settings":`Settings`,"attr.username":`Username`,"attr.setUsername":`Set username`,"attr.setSupport":`Mark as support`,"attr.clearSupport":`Clear support`,"attr.forProfile":`Profile color`,"attr.hasColor":`Enable color`,"attr.colorIndex":`Color index`,"attr.bgEmojiID":`Background emoji ID`,"attr.setColor":`Set color`,"attr.emojiDocID":`Emoji document ID`,"attr.emojiUntil":`Until (unix, 0 = permanent)`,"attr.setEmojiStatus":`Set emoji status`,"attr.gigagroup":`Gigagroup`,"attr.antispam":`Aggressive anti-spam`,"attr.participantsHidden":`Hide members`,"attr.noforwards":`Restrict forwarding`,"attr.joinToSend":`Join to send messages`,"attr.joinRequest":`Join by request`,"attr.slowmode":`Slowmode (seconds)`,"attr.applySettings":`Apply settings`,"route.emoji":`Emoji`,"route.emojiSubtitle":`Console / Emoji`,"layout.emoji":`Emoji`,"emoji.pageTitle":`Custom Emoji`,"emoji.queryResults":`Search results`,"emoji.recent":`Custom emoji catalog`,"emoji.currentPage":`Emoji on page`,"emoji.searchPlaceholder":`Document ID or emoji`,"emoji.copyID":`Copy document ID`,"emoji.noSet":`No set`,"emoji.hint":`Document IDs here can be pasted into the Emoji status field on account, bot and channel profiles.`,"messages.privateTitle":`Private Messages`,"messages.privateEyebrow":`Private message boxes`,"messages.groupTitle":`Group Messages`,"messages.groupEyebrow":`Supergroup / channel messages`,"messages.selectPrivatePeers":`Search and select the owner user and peer user first`,"messages.selectChannel":`Search and select a supergroup or channel first`,"messages.ownerUser":`Owner user`,"messages.peerUser":`Peer user`,"messages.beforeDatePlaceholder":`before_date cursor`,"messages.beforeIDPlaceholder":`before_msg_id cursor`,"messages.limitPlaceholder":`limit <= 100`,"messages.searchMessages":`Search messages`,"messages.nextPage":`Next page`,"messages.currentPage":`Messages on page`,"messages.deleted":`Deleted`,"messages.outgoing":`Outgoing`,"messages.incoming":`Incoming`,"messages.ownerPeer":`Owner / Peer`,"messages.deleteSelected":`Delete selected messages`,"messages.idsPlaceholder":`Message IDs, comma separated`,"messages.revoke":`Revoke for both sides`,"messages.previewDelete":`Dry-run delete`,"messages.clearHistory":`Clear private history`,"messages.maxIDPlaceholder":`max_id cutoff`,"messages.maxBatchesPlaceholder":`max_batches`,"messages.justClear":`Clear only this side`,"messages.previewClearHistory":`Dry-run clear history`,"messages.direction":`Direction`,"messages.body":`Body`,"messages.privateDetailTitle":`Message #{id}`,"messages.detailEyebrow":`Message Detail`,"messages.backPrivate":`Back to private messages`,"messages.backGroup":`Back to group messages`,"messages.ownerPeerTitle":`Owner {owner} · Peer {peer}`,"messages.senderSubtitle":`Sender {sender} · {date}`,"messages.boxID":`Message box ID`,"messages.privateMessageID":`Private message ID`,"messages.messageSender":`Message sender`,"messages.messageBox":`Message Box`,"messages.dialogRow":`Dialog Row`,"messages.privateRow":`Private Message Row`,"messages.channelMessageRow":`Channel Message Row`,"messages.channelRow":`Channel Row`,"messages.userUpdateEvents":`Update Events`,"messages.channelUpdateEvents":`Channel Update Events`,"messages.eventJson":`Event JSON`,"messages.dispatchOutbox":`Dispatch Queue`,"messages.messageBoxesSnapshot":`message_boxes read-only snapshot`,"messages.dialogSnapshot":`dialogs read-only snapshot`,"messages.privateSnapshot":`private_messages read-only snapshot`,"messages.channelMessagesSnapshot":`channel_messages read-only snapshot`,"messages.channelSnapshot":`channels read-only snapshot`,"messages.userEventsSource":`durable user_update_events`,"messages.channelEventsSource":`durable channel_update_events`,"messages.outboxSource":`online/offline dispatch_outbox`,"messages.attempts":`Attempts`,"messages.deleteThis":`Delete this message`,"messages.groupDetailTitle":`Group Message #{id}`,"messages.channelGroupTitle":`Channel / Group {id}`,"messages.mediaCount":`With media`,"messages.channelPosts":`Channel posts`,"messages.channelGroup":`Channel / Group`,"messages.pinned":`Pinned`,"messages.channelPost":`Channel post`,"gifts.pageTitle":`Star Gift Catalog`,"giveGift.action":`Give`,"giveGift.eyebrow":`Grant a gift · no charge`,"giveGift.title":`Give gift`,"giveGift.recipientKind":`Recipient type`,"giveGift.recipientUser":`User`,"giveGift.recipientChannel":`Channel`,"giveGift.pickUser":`Recipient user`,"giveGift.pickChannel":`Recipient channel`,"giveGift.recipientRequired":`Select a recipient first`,"giveGift.sender":`Sender account ID`,"giveGift.senderHint":`Gifts are always sent from the system account 777000 (Telesrv).`,"giveGift.message":`Attached message (optional)`,"giveGift.messagePlaceholder":`Shown with the gift`,"giveGift.hideName":`Hide sender name from recipient`,"giveGift.upgrade":`Deliver as upgraded collectible`,"giveGift.upgradeNote":`The gift is minted as a unique collectible. Pick specific attributes below, or leave them on Random to draw from the published pool. The collectible number is assigned automatically. Requires a published collectible upgrade with remaining supply.`,"giveGift.model":`Model`,"giveGift.pattern":`Pattern`,"giveGift.backdrop":`Backdrop`,"giveGift.random":`Random`,"giveGift.confirm":`Give gift`,"giveGifts.pageTitle":`Give Gifts`,"giveGifts.eyebrow":`Grant catalog gifts to any user or channel`,"giveGifts.available":`Available gifts`,"giveGifts.sender":`Default sender`,"giveGifts.searchPlaceholder":`Search by title or gift ID`,"giveGifts.hint":`Pick a gift to grant. Delivery is free of charge and sent from the system account 777000 (Telesrv) by default.`,"giveGifts.pickGift":`Select a gift`,"giveGifts.selectPrompt":`Select a gift from the list to start.`,"gifts.eyebrow":`Catalog, immutable revisions and animation assets`,"gifts.total":`Catalog entries`,"gifts.enabled":`Enabled`,"gifts.received":`Received gifts`,"gifts.formats":`Accepted formats`,"gifts.add":`Add gift`,"gifts.searchPlaceholder":`Search gift ID, title or format`,"gifts.listSummary":`Showing {shown} of {total}`,"gifts.idRevision":`ID / Revision`,"gifts.price":`Price / Conversion`,"gifts.importTitle":`Import a Star Gift`,"gifts.importEyebrow":`Gift catalog operation`,"gifts.newRevision":`Create revision for gift #{id}`,"gifts.importHint":`Upload TGS or plain Lottie JSON. Lottie is normalized and compressed to TGS.`,"gifts.officialSource":`Official snapshot`,"gifts.fileSource":`Upload file`,"gifts.officialHint":`Choose a verified gift from data/official-gifts. Complete collectible pools are imported atomically.`,"gifts.officialSearch":`Search official gift ID or title`,"gifts.officialSelect":`Choose an official gift`,"gifts.officialRequired":`Choose an official gift first`,"gifts.officialResults":`Showing {shown} of {total}`,"gifts.officialCategoryLabel":`Official gift capability category`,"gifts.officialCategory.all":`All`,"gifts.officialCategory.upgrade":`Upgradable`,"gifts.officialCategory.craft":`Craftable`,"gifts.officialCategory.basic":`Not upgradable`,"gifts.officialUnnamed":`Unnamed official gift #{id}`,"gifts.officialAttributes":`{count} attributes`,"gifts.canUpgrade":`Can upgrade`,"gifts.cannotUpgrade":`Cannot upgrade`,"gifts.canCraft":`Can Craft`,"gifts.cannotCraft":`Cannot Craft`,"gifts.officialEmpty":`No official gifts match this category and search.`,"gifts.includeCollectible":`Import the complete collectible pool, including crafted models`,"gifts.animation":`Animation file`,"gifts.filePrompt":`Drop or choose a TGS / Lottie file`,"gifts.fileHint":`TGS, JSON or Lottie · validated before import`,"gifts.chooseFile":`Choose file`,"gifts.changeFile":`Change file`,"gifts.title":`Display title`,"gifts.titlePlaceholder":`e.g. Celebration Star`,"gifts.stars":`Price in Stars`,"gifts.convertStars":`Conversion Stars`,"gifts.sortOrder":`Sort order`,"gifts.reason":`Audit reason`,"gifts.reasonPlaceholder":`Briefly describe why this gift is being imported`,"gifts.enableAfterImport":`Enable after import`,"gifts.validate":`Dry-run validation`,"gifts.confirmImport":`Confirm import`,"gifts.stepDetails":`File and details`,"gifts.stepValidate":`Dry-run validation`,"gifts.stepImport":`Confirm import`,"gifts.fileRequired":`Choose a TGS or Lottie file first`,"gifts.source":`Source`,"gifts.replace":`New revision`,"gifts.disable":`Disable`,"gifts.enable":`Enable`,"gifts.empty":`No Star Gifts have been imported.`,"gifts.emptyHint":`Import the first animation above to build the gift catalog.`,"gifts.validationReady":`Validation passed`,"gifts.validationHint":`Review the normalized metadata, then confirm the import.`,"gifts.confirmState":`Apply the validated state change to gift #{id}?`,"collectibles.manage":`Attribute pool`,"collectibles.title":`Collectible pool · Gift #{id}`,"collectibles.eyebrow":`Unique gift attributes`,"collectibles.activeRevision":`Published revision {revision}`,"collectibles.published":`Published`,"collectibles.noPool":`No collectible pool published`,"collectibles.noPoolHint":`Publish models, patterns and backdrops to enable upgrades.`,"collectibles.publishNew":`Publish a new immutable revision`,"collectibles.immutableHint":`Dry-run checks every file and rarity total before the revision becomes active.`,"collectibles.upgradeStars":`Upgrade price in Stars`,"collectibles.supply":`Unique supply`,"collectibles.slug":`Public slug prefix`,"collectibles.models":`Models`,"collectibles.patterns":`Patterns`,"collectibles.backdrops":`Backdrops`,"collectibles.model":`Model`,"collectibles.pattern":`Pattern`,"collectibles.backdrop":`Backdrop`,"collectibles.rarity":`Rarity ‰`,"collectibles.rarityHint":`Permille values are relative regular-upgrade weights; their total does not need to equal 1000.`,"collectibles.minimumAttributes":`Models, patterns, and backdrops must each contain at least two attributes.`,"collectibles.duplicateBackdropID":`Backdrop IDs must be unique within the pool.`,"collectibles.colorHint":`Colors are stored as 24-bit RGB values.`,"collectibles.addAttribute":`Add`,"collectibles.remove":`Remove attribute`,"collectibles.fileRequired":`Every model and pattern needs a TGS or Lottie file.`,"collectibles.backdropID":`Backdrop ID`,"collectibles.color.center":`Center`,"collectibles.color.edge":`Edge`,"collectibles.color.pattern":`Pattern`,"collectibles.color.text":`Text`,"collectibles.validationReady":`Attribute pool is valid`,"collectibles.validationHint":`Review the normalized assets, then publish this immutable revision.`,"collectibles.publish":`Publish revision`,"messages.msgIDsInvalid":`Message IDs are invalid`,"auth.device":`Device`,"auth.platform":`Platform`,"auth.ip":`IP`,"auth.lastActive":`Last active`,"auth.revokeCurrent":`Revoke current`,"auth.keepCurrent":`Keep current`,"auth.revokeAll":`Revoke all devices`,"picker.userPlaceholder":`Search user_id / phone / username`,"picker.channelPlaceholder":`Search channel_id / username / title`,"picker.verified":`Verified`,"picker.regular":`Regular`,"action.reasonRequired":`Please enter an operation reason`,"action.flow":`Action Flow`,"action.close":`Close`,"action.stepReason":`Enter reason`,"action.stepDryRun":`Dry-run check`,"action.stepConfirm":`Confirm execution`,"action.reason":`Operation reason`,"action.reasonPlaceholder":`Describe why this operation is being performed`,"action.requestPreview":`Request preview`,"action.result":`Action result`,"action.commandID":`Command ID`,"action.status":`Status`,"action.dryRun":`Dry-run`,"action.runAgain":`Run dry-run again`,"action.runDry":`Run dry-run first`,"action.confirm":`Confirm execution`,"audit.id":`ID`,"audit.commandID":`Command ID`,"audit.action":`Action`,"audit.actor":`Actor`,"audit.status":`Status`,"audit.dryRun":`Dry-run`,"audit.reason":`Reason`,"audit.time":`Time`,"route.stickers":`Stickers`,"route.stickersSubtitle":`Console / Stickers`,"layout.stickers":`Stickers`,"account.loginEmail":`Login email`,"gifts.importAllDefault":`Import all default gifts`,"gifts.defaultSource":`Default gifts`,"gifts.defaultHint":`Import our built-in original OwpenGram gifts. Complete collectible pools (upgrade + craft) are imported atomically.`,"gifts.defaultSelect":`Choose a default gift`,"gifts.defaultRequired":`Choose a default gift first`,"gifts.defaultEmpty":`No default gifts are available.`,"gifts.importAllOfficial":`Import all official gifts`,"gifts.importingProgress":`Importing {done} of {total}`,"gifts.bulkImportCount":`{count} gifts available to import`,"gifts.bulkImportDone":`Import complete`,"gifts.bulkImportSummary":`Imported {imported}, skipped {skipped}, failed {failed}`,"gifts.startBulkImport":`Start import`,"gifts.limited":`Limited · {total}`,"gifts.premium":`Premium only`,"gifts.bulkSelected":`{count} selected`,"gifts.bulkSelectAll":`Select all visible gifts`,"gifts.bulkSelectOne":`Select gift {id}`,"gifts.bulkEnable":`Enable selected`,"gifts.bulkDisable":`Disable selected`,"gifts.bulkStatusFailed":`{failed} of {total} failed`,"gifts.perPage":`Per page`,"gifts.perPageAll":`All`,"gifts.pageRange":`Showing {start}-{end} of {total}`,"gifts.pagePrev":`Previous`,"gifts.pageNext":`Next`,"gifts.pageOf":`Page {page} of {total}`,"stickers.pageTitle":`Stickers`,"stickers.eyebrow":`Sticker packs — system packs (dice, animated emoji, gifts) aren't shown here, they're not hand-edited`,"stickers.emojiPageTitle":`Emoji`,"stickers.emojiEyebrow":`Custom-emoji packs — system packs aren't shown here, they're not hand-edited`,"stickers.total":`Total sets`,"stickers.searchPlaceholder":`Search set ID, short name or title`,"stickers.listSummary":`Showing {shown} of {total}`,"stickers.logo":`Logo`,"stickers.id":`ID`,"stickers.shortName":`Short name`,"stickers.title":`Title`,"stickers.count":`Documents`,"stickers.official":`Official`,"stickers.archived":`Archived`,"stickers.sortOrder":`Sort order`,"stickers.createdAt":`Created`,"stickers.archive":`Archive`,"stickers.unarchive":`Unarchive`,"stickers.saveOrder":`Save`,"stickers.saveTitle":`Save`,"stickers.delete":`Delete`,"stickers.view":`View`,"stickers.previewEyebrow":`Set contents`,"stickers.previewEmpty":`This set has no documents.`,"stickers.create":`Create {noun} pack`,"stickers.createTitle":`Create a new {noun} pack`,"stickers.createEyebrow":`New set`,"stickers.createFieldsRequired":`Title, short name, emoji and a first {noun} file are required.`,"stickers.shortNamePlaceholder":`lowercase_short_name`,"stickers.firstSticker":`First {noun}`,"stickers.filePrompt":`Choose a TGS, Lottie JSON, or WebP file`,"stickers.emoji":`Emoji`,"stickers.emojiPlaceholder":`e.g. 😀`,"stickers.emojiRequired":`An emoji is required.`,"stickers.addSticker":`Add {noun}`,"stickers.fileRequired":`Choose a {noun} file first`,"stickers.removeSticker":`Remove`},zh:{"app.adminConsole":`管理控制台`,"app.localAccess":`本地访问`,"app.title":`telesrv 管理后台`,"common.actions":`操作`,"common.admins":`管理员`,"common.backToList":`返回列表`,"common.channel":`频道`,"common.channelOrGroup":`频道/群`,"common.clear":`清除`,"common.close":`关闭`,"common.count":`数量`,"common.deleted":`已删除`,"common.detail":`详情`,"common.device":`设备`,"common.disabled":`已禁用`,"common.enabled":`已启用`,"common.fromPeer":`From Peer`,"common.group":`群组`,"common.id":`ID`,"common.limit":`条数`,"common.loading":`加载中`,"common.member":`成员`,"common.members":`成员`,"common.messageId":`消息 ID`,"common.name":`姓名`,"common.next":`下一页`,"common.no":`否`,"common.noResults":`无结果`,"common.none":`无`,"common.normal":`正常`,"common.operations":`操作`,"common.previous":`上一页`,"common.owner":`所属`,"common.platform":`平台`,"common.refresh":`刷新`,"common.search":`查询`,"common.sender":`发送方`,"common.status":`状态`,"common.survived":`存活`,"common.time":`时间`,"common.type":`类型`,"common.updatedAt":`更新时间`,"common.username":`用户名`,"common.valid":`有效`,"common.verified":`已认证`,"common.views":`浏览`,"common.yes":`是`,"route.accounts":`账号管理`,"route.accountsSubtitle":`控制台 / 账号`,"route.channels":`超级群与频道`,"route.channelsSubtitle":`控制台 / 频道`,"route.dashboard":`运维控制台`,"route.dashboardSubtitle":`控制台 / 总览`,"route.messages":`消息审计`,"route.messagesSubtitle":`控制台 / 消息`,"route.gifts":`星星礼物`,"route.giftsSubtitle":`控制台 / 星星礼物`,"route.giveGifts":`赠送礼物`,"route.giveGiftsSubtitle":`控制台 / 赠送礼物`,"layout.navigation":`导航`,"layout.primaryNav":`主导航`,"layout.dashboard":`总览`,"layout.accounts":`账号`,"layout.channels":`超级群/频道`,"layout.messages":`消息`,"layout.gifts":`礼物目录`,"layout.giveGifts":`赠送礼物`,"layout.privateMessages":`私聊`,"layout.groupMessages":`群聊`,"layout.runtime":`运行状态`,"layout.adminBackend":`管理后台`,"layout.ready":`就绪`,"layout.pgRead":`PG 读取`,"layout.readOnly":`只读`,"layout.writeOps":`写操作`,"layout.dryRun":`预演`,"layout.actor":`操作者:{actor}`,"layout.logout":`退出`,"language.en":`EN`,"language.zh":`中文`,"language.ru":`RU`,"theme.switchToDark":`切换到深色主题`,"theme.switchToLight":`切换到浅色主题`,"login.heading":`运维后台`,"login.body":`输入凭据后进入控制台。`,"login.secret":`管理员密码或 token`,"login.submit":`登录`,"login.submitting":`登录中`,"dashboard.eyebrow":`运行总览`,"dashboard.title":`控制台总览`,"dashboard.readPath":`读路径`,"dashboard.readPathValue":`PG 只读`,"dashboard.writePath":`写路径`,"dashboard.executionPolicy":`执行策略`,"dashboard.dryRunFirst":`先预演`,"dashboard.accountsText":`账号状态、会员、认证、会话。`,"dashboard.channelsText":`公开实体、成员计数、认证状态。`,"dashboard.messagesText":`消息盒、update、outbox 状态。`,"dashboard.strip.dryRun":`所有危险操作先预演`,"dashboard.strip.token":`浏览器不持有内部 token`,"dashboard.strip.pagination":`列表使用游标分页`,"dashboard.strip.snapshot":`详情页保留原始状态快照`,"account.pageTitle":`账号`,"account.queryResults":`查询结果`,"account.recentActive":`最近活跃账号`,"account.currentPage":`当前页账号`,"account.onlineDevices":`在线设备记录`,"account.totalUsers":`用户总数`,"account.onlineNow":`当前在线`,"account.premium":`会员`,"account.frozen":`冻结`,"account.searchPlaceholder":`用户 ID / 手机号 / 用户名`,"account.userID":`用户 ID`,"account.phone":`手机号`,"account.lastActive":`最近活跃`,"account.notVerified":`未认证`,"account.notPremium":`非会员`,"account.premiumUntil":`会员到期`,"account.starsBalance":`Stars 余额`,"account.startingGrantApplied":`初始赠送已发放`,"account.startingGrantPending":`初始赠送未触发`,"account.activeSessions":`授权设备`,"account.accountFlags":`账号标记`,"account.restriction":`限制状态`,"account.restricted":`已限制`,"account.createdAt":`创建时间`,"account.detailTitle":`账号 #{id}`,"account.profile":`账号档案`,"account.loadingDetail":`加载账号详情`,"account.waitingData":`等待数据`,"account.noUsername":`无用户名`,"account.noPhone":`无手机号`,"account.accountFrozen":`账号已冻结`,"account.accountActive":`账号正常`,"account.authorizationsTitle":`授权设备`,"account.authorizationsCount":`共 {count} 个授权`,"account.recentAdminOps":`最近后台操作`,"account.recent30Audit":`最近 30 条审计`,"account.actionDock":`账号操作`,"account.freezeAccount":`冻结账号`,"account.updateFreeze":`更新冻结信息`,"account.unfreezeAccount":`解冻账号`,"account.freezeSince":`冻结开始时间`,"account.freezeUntil":`申诉截止时间`,"account.freezeUntilAria":`账号冻结申诉截止时间`,"account.freezeAppealURL":`申诉链接`,"account.freezeAppealURLAria":`账号冻结申诉链接`,"account.premiumMonths":`会员时长(月)`,"account.premiumMonthsAria":`设置会员时长,单位月`,"account.setPremium":`设置会员`,"account.clearPremium":`取消会员`,"account.starsAmount":`赠送 Stars 数量`,"account.starsAmountAria":`设置要赠送的 Stars 数量`,"account.grantStars":`赠送 Stars`,"account.setVerified":`设置认证`,"account.clearVerified":`取消认证`,"channel.pageTitle":`超级群与频道`,"channel.recentUpdated":`最近更新`,"channel.currentPage":`当前页实体`,"channel.megagroups":`超级群`,"channel.broadcasts":`频道`,"channel.verifiedCount":`已认证`,"channel.searchPlaceholder":`频道 ID / 用户名 / 标题`,"channel.channelID":`频道 ID`,"channel.kind":`类型`,"channel.title":`标题`,"channel.pts":`PTS`,"channel.detailProfile":`频道档案`,"channel.loadingDetail":`加载频道详情`,"channel.creator":`创建者 {id}`,"channel.governance":`治理状态`,"channel.governanceValue":`封禁 {banned} / 踢出 {kicked}`,"channel.flags":`频道标记`,"channel.rawRow":`频道原始行`,"channel.rawRowText":`数据库只读快照`,"channel.actionDock":`频道操作`,"channel.setVerified":`设置认证`,"channel.clearVerified":`取消认证`,"channel.kind.broadcast":`频道`,"channel.kind.forum":`超级群/论坛`,"channel.kind.megagroup":`超级群`,"channel.kind.generic":`频道/群`,"route.bots":`机器人`,"route.botsSubtitle":`控制台 / 机器人`,"layout.bots":`机器人`,"bots.pageTitle":`机器人`,"bots.queryResults":`查询结果`,"bots.recent":`最近创建的机器人`,"bots.currentPage":`当前页机器人`,"bots.banned":`已封禁`,"bots.active":`正常`,"bots.createTitle":`创建系统机器人`,"bots.createHint":`为指定用户创建机器人账号。确认后 token 只显示一次。`,"bots.ownerUserID":`所属用户 ID`,"bots.name":`显示名称`,"bots.namePlaceholder":`例如:服务机器人`,"bots.username":`用户名`,"bots.usernameHint":`用户名需 5-32 个字符,且以 bot 结尾。`,"bots.create":`创建机器人`,"bots.searchPlaceholder":`机器人 ID / 用户名`,"bots.botID":`机器人 ID`,"bots.owner":`所属用户`,"bots.status":`状态`,"bots.detailTitle":`机器人 #{id}`,"bots.profile":`机器人档案`,"bots.loadingDetail":`加载机器人详情`,"bots.unnamed":`未命名机器人`,"bots.restriction":`限制状态`,"bots.actionDock":`机器人操作`,"bots.banUntil":`封禁至`,"bots.ban":`封禁机器人`,"bots.updateBan":`更新封禁`,"bots.unban":`解封机器人`,"bots.type":`类型`,"bots.system":`系统`,"bots.user":`用户`,"bots.delete":`删除机器人`,"bots.deleteHint":`永久删除该用户创建的机器人并使其 token 失效。此操作不可撤销。`,"bots.systemHint":`系统内置机器人不可删除。`,"flags.scam":`SCAM`,"flags.fake":`FAKE`,"flags.setScam":`标记为 SCAM`,"flags.clearScam":`移除 SCAM`,"flags.setFake":`标记为 FAKE`,"flags.clearFake":`移除 FAKE`,"attr.attributes":`属性`,"attr.settings":`设置`,"attr.username":`用户名`,"attr.setUsername":`设置用户名`,"attr.setSupport":`标记为客服`,"attr.clearSupport":`取消客服`,"attr.forProfile":`资料颜色`,"attr.hasColor":`启用颜色`,"attr.colorIndex":`颜色编号`,"attr.bgEmojiID":`背景 emoji ID`,"attr.setColor":`设置颜色`,"attr.emojiDocID":`Emoji 文档 ID`,"attr.emojiUntil":`有效期 (unix, 0 = 永久)`,"attr.setEmojiStatus":`设置 emoji 状态`,"attr.gigagroup":`广播群 (gigagroup)`,"attr.antispam":`激进反垃圾`,"attr.participantsHidden":`隐藏成员`,"attr.noforwards":`禁止转发`,"attr.joinToSend":`先加入才能发言`,"attr.joinRequest":`加入需审批`,"attr.slowmode":`慢速模式 (秒)`,"attr.applySettings":`应用设置`,"route.emoji":`Emoji`,"route.emojiSubtitle":`控制台 / Emoji`,"layout.emoji":`Emoji`,"emoji.pageTitle":`自定义 Emoji`,"emoji.queryResults":`查询结果`,"emoji.recent":`自定义 Emoji 目录`,"emoji.currentPage":`当前页 Emoji`,"emoji.searchPlaceholder":`文档 ID 或表情`,"emoji.copyID":`复制文档 ID`,"emoji.noSet":`无所属集合`,"emoji.hint":`这里的文档 ID 可直接填入账号、机器人和频道资料的 Emoji 状态字段。`,"messages.privateTitle":`私聊消息`,"messages.privateEyebrow":`私聊消息盒`,"messages.groupTitle":`群聊消息`,"messages.groupEyebrow":`超级群 / 频道消息`,"messages.selectPrivatePeers":`请先搜索并选择所属用户和对端用户`,"messages.selectChannel":`请先搜索并选择超级群或频道`,"messages.ownerUser":`所属用户`,"messages.peerUser":`对端用户`,"messages.beforeDatePlaceholder":`before_date 游标`,"messages.beforeIDPlaceholder":`before_msg_id 游标`,"messages.limitPlaceholder":`条数 <= 100`,"messages.searchMessages":`查询消息`,"messages.nextPage":`下一页`,"messages.currentPage":`当前页消息`,"messages.deleted":`已删除`,"messages.outgoing":`发出消息`,"messages.incoming":`收到`,"messages.ownerPeer":`所属 / 对端`,"messages.deleteSelected":`删除指定消息`,"messages.idsPlaceholder":`消息 ID,逗号分隔`,"messages.revoke":`同步撤回`,"messages.previewDelete":`预演删除`,"messages.clearHistory":`清空私聊历史`,"messages.maxIDPlaceholder":`max_id 截止消息`,"messages.maxBatchesPlaceholder":`max_batches 批次数`,"messages.justClear":`仅清本侧`,"messages.previewClearHistory":`预演清历史`,"messages.direction":`方向`,"messages.body":`正文`,"messages.privateDetailTitle":`消息 #{id}`,"messages.detailEyebrow":`消息详情`,"messages.backPrivate":`返回私聊消息`,"messages.backGroup":`返回群聊消息`,"messages.ownerPeerTitle":`所属 {owner} · 对端 {peer}`,"messages.senderSubtitle":`发送方 {sender} · {date}`,"messages.boxID":`消息盒 ID`,"messages.privateMessageID":`私聊消息 ID`,"messages.messageSender":`发送方`,"messages.messageBox":`消息盒`,"messages.dialogRow":`会话行`,"messages.privateRow":`私聊消息行`,"messages.channelMessageRow":`消息行`,"messages.channelRow":`频道行`,"messages.userUpdateEvents":`更新事件`,"messages.channelUpdateEvents":`频道更新事件`,"messages.eventJson":`事件 JSON`,"messages.dispatchOutbox":`分发队列`,"messages.messageBoxesSnapshot":`message_boxes 只读快照`,"messages.dialogSnapshot":`dialogs 只读快照`,"messages.privateSnapshot":`private_messages 只读快照`,"messages.channelMessagesSnapshot":`channel_messages 只读快照`,"messages.channelSnapshot":`channels 只读快照`,"messages.userEventsSource":`durable user_update_events`,"messages.channelEventsSource":`durable channel_update_events`,"messages.outboxSource":`在线/离线 dispatch_outbox`,"messages.attempts":`尝试`,"messages.deleteThis":`删除此消息`,"messages.groupDetailTitle":`群聊消息 #{id}`,"messages.channelGroupTitle":`频道/群 {id}`,"messages.mediaCount":`有媒体`,"messages.channelPosts":`频道帖子`,"messages.channelGroup":`频道 / 群`,"messages.pinned":`置顶`,"messages.channelPost":`频道帖子`,"gifts.pageTitle":`星星礼物目录`,"giveGift.action":`赠送`,"giveGift.eyebrow":`发放礼物 · 免费`,"giveGift.title":`赠送礼物`,"giveGift.recipientKind":`接收方类型`,"giveGift.recipientUser":`用户`,"giveGift.recipientChannel":`频道`,"giveGift.pickUser":`接收用户`,"giveGift.pickChannel":`接收频道`,"giveGift.recipientRequired":`请先选择接收方`,"giveGift.sender":`发送方账号 ID`,"giveGift.senderHint":`礼物始终由系统账号 777000(Telesrv)发送。`,"giveGift.message":`附加留言(可选)`,"giveGift.messagePlaceholder":`随礼物一起显示`,"giveGift.hideName":`对接收方隐藏发送方名称`,"giveGift.upgrade":`作为升级收藏品发放`,"giveGift.upgradeNote":`礼物将铸造为唯一收藏品。可在下方指定具体属性,或保持“随机”从已发布的属性池中抽取。编号自动分配。需要存在有剩余供应量的已发布收藏品升级。`,"giveGift.model":`模型`,"giveGift.pattern":`图案`,"giveGift.backdrop":`背景`,"giveGift.random":`随机`,"giveGift.confirm":`赠送礼物`,"giveGifts.pageTitle":`赠送礼物`,"giveGifts.eyebrow":`向任意用户或频道发放目录礼物`,"giveGifts.available":`可用礼物`,"giveGifts.sender":`默认发送方`,"giveGifts.searchPlaceholder":`按标题或礼物 ID 搜索`,"giveGifts.hint":`选择要发放的礼物。发放免费,默认由系统账号 777000(Telesrv)发送。`,"giveGifts.pickGift":`选择礼物`,"giveGifts.selectPrompt":`从列表中选择一个礼物开始。`,"gifts.eyebrow":`目录、不可变版本与动画资源`,"gifts.total":`目录条目`,"gifts.enabled":`已启用`,"gifts.received":`已领取礼物`,"gifts.formats":`支持格式`,"gifts.add":`添加礼物`,"gifts.searchPlaceholder":`搜索礼物 ID、标题或格式`,"gifts.listSummary":`显示 {shown} / {total} 项`,"gifts.idRevision":`ID / 版本`,"gifts.price":`售价 / 兑换`,"gifts.importTitle":`导入星星礼物`,"gifts.importEyebrow":`礼物目录操作`,"gifts.newRevision":`为礼物 #{id} 创建新版本`,"gifts.importHint":`支持 TGS 或纯 Lottie JSON;Lottie 会规范化并压缩成 TGS。`,"gifts.officialSource":`官方资源库`,"gifts.fileSource":`上传文件`,"gifts.officialHint":`从 data/official-gifts 的已校验快照中选择;完整 collectible 属性池会与礼物原子导入。`,"gifts.officialSearch":`搜索官方礼物 ID 或标题`,"gifts.officialSelect":`请选择官方礼物`,"gifts.officialRequired":`请先选择一个官方礼物`,"gifts.officialResults":`显示 {shown} / {total} 项`,"gifts.officialCategoryLabel":`官方礼物能力分类`,"gifts.officialCategory.all":`全部`,"gifts.officialCategory.upgrade":`可升级`,"gifts.officialCategory.craft":`可 Craft`,"gifts.officialCategory.basic":`不可升级`,"gifts.officialUnnamed":`未命名官方礼物 #{id}`,"gifts.officialAttributes":`{count} 个属性`,"gifts.canUpgrade":`可升级`,"gifts.cannotUpgrade":`不可升级`,"gifts.canCraft":`可 Craft`,"gifts.cannotCraft":`不可 Craft`,"gifts.officialEmpty":`当前分类和搜索条件下没有官方礼物。`,"gifts.includeCollectible":`完整导入 collectible 属性池(包含 crafted 模型)`,"gifts.animation":`动画文件`,"gifts.filePrompt":`拖放或选择 TGS / Lottie 文件`,"gifts.fileHint":`支持 TGS、JSON、Lottie,导入前会先进行校验`,"gifts.chooseFile":`选择文件`,"gifts.changeFile":`更换文件`,"gifts.title":`显示标题`,"gifts.titlePlaceholder":`例如:庆典星星`,"gifts.stars":`售价 Stars`,"gifts.convertStars":`可兑换 Stars`,"gifts.sortOrder":`排序值`,"gifts.reason":`审计原因`,"gifts.reasonPlaceholder":`简要说明本次导入礼物的原因`,"gifts.enableAfterImport":`导入后启用`,"gifts.validate":`Dry-run 校验`,"gifts.confirmImport":`确认导入`,"gifts.stepDetails":`文件与信息`,"gifts.stepValidate":`Dry-run 校验`,"gifts.stepImport":`确认导入`,"gifts.fileRequired":`请先选择 TGS 或 Lottie 文件`,"gifts.source":`来源`,"gifts.replace":`创建新版本`,"gifts.disable":`停用`,"gifts.enable":`启用`,"gifts.empty":`尚未导入星星礼物。`,"gifts.emptyHint":`从上方导入第一个动画,开始搭建礼物目录。`,"gifts.validationReady":`校验已通过`,"gifts.validationHint":`确认规范化后的元数据无误,再执行正式导入。`,"gifts.confirmState":`确认执行礼物 #{id} 的状态变更吗?`,"collectibles.manage":`属性池`,"collectibles.title":`Collectibles 属性池 · 礼物 #{id}`,"collectibles.eyebrow":`唯一礼物属性管理`,"collectibles.activeRevision":`已发布版本 {revision}`,"collectibles.published":`已发布`,"collectibles.noPool":`尚未发布 Collectibles 属性池`,"collectibles.noPoolHint":`发布模型、图案与背景后,客户端即可升级为唯一礼物。`,"collectibles.publishNew":`发布新的不可变版本`,"collectibles.immutableHint":`Dry-run 会校验全部文件和属性池结构,通过后才切换为当前版本。`,"collectibles.upgradeStars":`升级价格 Stars`,"collectibles.supply":`唯一礼物总量`,"collectibles.slug":`公开 Slug 前缀`,"collectibles.models":`模型`,"collectibles.patterns":`图案`,"collectibles.backdrops":`背景`,"collectibles.model":`模型`,"collectibles.pattern":`图案`,"collectibles.backdrop":`背景`,"collectibles.rarity":`稀有度 ‰`,"collectibles.rarityHint":`每类至少保留两项。Permille 是普通升级的相对权重,增删时会自动重新分配为 1000。`,"collectibles.minimumAttributes":`模型、图案和背景每类都必须至少包含两个属性。`,"collectibles.duplicateBackdropID":`同一属性池中的背景 ID 必须唯一。`,"collectibles.colorHint":`颜色会按 24 位 RGB 数值保存。`,"collectibles.addAttribute":`添加`,"collectibles.remove":`删除属性`,"collectibles.fileRequired":`每个模型和图案都必须选择 TGS 或 Lottie 文件。`,"collectibles.backdropID":`背景 ID`,"collectibles.color.center":`中心色`,"collectibles.color.edge":`边缘色`,"collectibles.color.pattern":`图案色`,"collectibles.color.text":`文字色`,"collectibles.validationReady":`属性池校验通过`,"collectibles.validationHint":`确认规范化资源无误后,即可发布这个不可变版本。`,"collectibles.publish":`发布版本`,"messages.msgIDsInvalid":`消息 ID 无效`,"auth.device":`设备`,"auth.platform":`平台`,"auth.ip":`IP`,"auth.lastActive":`最近活跃`,"auth.revokeCurrent":`撤销当前`,"auth.keepCurrent":`保留当前`,"auth.revokeAll":`撤销全部设备`,"picker.userPlaceholder":`搜索 user_id / phone / username`,"picker.channelPlaceholder":`搜索 channel_id / username / title`,"picker.verified":`认证`,"picker.regular":`普通`,"action.reasonRequired":`请填写操作原因`,"action.flow":`操作流程`,"action.close":`关闭`,"action.stepReason":`填写原因`,"action.stepDryRun":`预演检查`,"action.stepConfirm":`确认执行`,"action.reason":`操作原因`,"action.reasonPlaceholder":`说明本次操作原因`,"action.requestPreview":`请求预览`,"action.result":`操作结果`,"action.commandID":`命令 ID`,"action.status":`状态`,"action.dryRun":`预演`,"action.runAgain":`重新预演`,"action.runDry":`先预演`,"action.confirm":`确认执行`,"audit.id":`ID`,"audit.commandID":`命令 ID`,"audit.action":`动作`,"audit.actor":`操作者`,"audit.status":`状态`,"audit.dryRun":`预演`,"audit.reason":`原因`,"audit.time":`时间`},ru:{"app.adminConsole":`Панель администратора`,"app.localAccess":`Локальный доступ`,"app.title":`telesrv admin`,"common.actions":`Действия`,"common.admins":`Администраторы`,"common.backToList":`Назад к списку`,"common.channel":`Канал`,"common.channelOrGroup":`Канал / Группа`,"common.clear":`Очистить`,"common.close":`Закрыть`,"common.count":`Количество`,"common.deleted":`Удалено`,"common.detail":`Детали`,"common.device":`Устройство`,"common.disabled":`Отключено`,"common.enabled":`Включено`,"common.fromPeer":`От пира`,"common.group":`Группа`,"common.id":`ID`,"common.limit":`Лимит`,"common.loading":`Загрузка…`,"common.member":`Участник`,"common.members":`Участники`,"common.messageId":`ID сообщения`,"common.name":`Имя`,"common.next":`Следующая страница`,"common.no":`Нет`,"common.noResults":`Нет результатов`,"common.none":`Нет`,"common.normal":`Обычный`,"common.operations":`Операции`,"common.previous":`Предыдущая страница`,"common.owner":`Владелец`,"common.platform":`Платформа`,"common.refresh":`Обновить`,"common.search":`Поиск`,"common.sender":`Отправитель`,"common.status":`Статус`,"common.survived":`Уцелело`,"common.time":`Время`,"common.type":`Тип`,"common.updatedAt":`Обновлено`,"common.username":`Имя пользователя`,"common.valid":`Действителен`,"common.verified":`Подтверждён`,"common.views":`Просмотры`,"common.yes":`Да`,"route.accounts":`Аккаунты`,"route.accountsSubtitle":`Консоль / Аккаунты`,"route.channels":`Супергруппы и каналы`,"route.channelsSubtitle":`Консоль / Каналы`,"route.dashboard":`Панель управления`,"route.dashboardSubtitle":`Консоль / Обзор`,"route.messages":`Аудит сообщений`,"route.messagesSubtitle":`Консоль / Сообщения`,"route.gifts":`Звёздные подарки`,"route.giftsSubtitle":`Консоль / Звёздные подарки`,"route.giveGifts":`Выдача подарков`,"route.giveGiftsSubtitle":`Консоль / Выдача подарков`,"layout.navigation":`Навигация`,"layout.primaryNav":`Основное меню`,"layout.dashboard":`Обзор`,"layout.accounts":`Аккаунты`,"layout.channels":`Супергруппы / Каналы`,"layout.messages":`Сообщения`,"layout.gifts":`Звёздные подарки`,"layout.giveGifts":`Выдача подарков`,"layout.privateMessages":`Личные`,"layout.groupMessages":`Группы`,"layout.runtime":`Среда выполнения`,"layout.adminBackend":`Админ-бэкенд`,"layout.ready":`Готов`,"layout.pgRead":`Чтение из PG`,"layout.readOnly":`Только чтение`,"layout.writeOps":`Операции записи`,"layout.dryRun":`Тестовый запуск`,"layout.actor":`Вы вошли как: {actor}`,"layout.logout":`Выйти`,"language.en":`EN`,"language.zh":`中文`,"language.ru":`RU`,"theme.switchToDark":`Тёмная тема`,"theme.switchToLight":`Светлая тема`,"login.heading":`Панель администратора`,"login.body":`Введите учётные данные для входа в консоль.`,"login.secret":`Пароль или токен администратора`,"login.submit":`Войти`,"login.submitting":`Вход…`,"dashboard.eyebrow":`Состояние системы`,"dashboard.title":`Обзор консоли`,"dashboard.readPath":`Путь чтения`,"dashboard.readPathValue":`PG только для чтения`,"dashboard.writePath":`Путь записи`,"dashboard.executionPolicy":`Политика выполнения`,"dashboard.dryRunFirst":`Сначала тестовый запуск`,"dashboard.accountsText":`Статус аккаунтов, Premium, подтверждение, сессии.`,"dashboard.channelsText":`Публичные каналы и группы, число участников, статус подтверждения.`,"dashboard.messagesText":`Ящики сообщений, обновления, состояние исходящих.`,"dashboard.strip.dryRun":`Все опасные действия начинаются с тестового запуска`,"dashboard.strip.token":`Браузер никогда не сохраняет внутренние токены`,"dashboard.strip.pagination":`Списки используют курсорную пагинацию`,"dashboard.strip.snapshot":`Детальные страницы сохраняют моментальные снимки исходного состояния`,"account.pageTitle":`Аккаунты`,"account.queryResults":`Результаты поиска`,"account.recentActive":`Недавно активные аккаунты`,"account.currentPage":`Аккаунты на странице`,"account.onlineDevices":`Активные сессии устройств`,"account.totalUsers":`Всего пользователей`,"account.onlineNow":`Сейчас онлайн`,"account.premium":`Premium`,"account.frozen":`Заморожен`,"account.searchPlaceholder":`ID пользователя / телефон / имя пользователя`,"account.userID":`ID пользователя`,"account.phone":`Телефон`,"account.lastActive":`Последняя активность`,"account.notVerified":`Не подтверждён`,"account.notPremium":`Без Premium`,"account.premiumUntil":`Premium истекает`,"account.starsBalance":`Баланс Звёзд`,"account.startingGrantApplied":`стартовый бонус начислен`,"account.startingGrantPending":`ожидает стартового бонуса`,"account.activeSessions":`Авторизованные устройства`,"account.accountFlags":`Флаги аккаунта`,"account.restriction":`Ограничение`,"account.restricted":`Ограничен`,"account.createdAt":`Создан`,"account.detailTitle":`Аккаунт #{id}`,"account.profile":`Профиль аккаунта`,"account.loadingDetail":`Загрузка данных аккаунта`,"account.waitingData":`Ожидание данных`,"account.noUsername":`Нет имени пользователя`,"account.noPhone":`Нет телефона`,"account.accountFrozen":`Аккаунт заморожен`,"account.accountActive":`Аккаунт активен`,"account.authorizationsTitle":`Авторизованные устройства`,"account.authorizationsCount":`Авторизаций: {count}`,"account.recentAdminOps":`Последние действия администратора`,"account.recent30Audit":`Последние 30 записей аудита`,"account.actionDock":`Действия с аккаунтом`,"account.freezeAccount":`Заморозить аккаунт`,"account.updateFreeze":`Обновить параметры заморозки`,"account.unfreezeAccount":`Разморозить аккаунт`,"account.freezeSince":`Заморожен с`,"account.freezeUntil":`Срок подачи апелляции`,"account.freezeUntilAria":`Срок подачи апелляции на заморозку`,"account.freezeAppealURL":`URL для апелляции`,"account.freezeAppealURLAria":`URL для апелляции на заморозку`,"account.premiumMonths":`Срок действия Premium (в месяцах)`,"account.premiumMonthsAria":`Указать срок действия Premium в месяцах`,"account.setPremium":`Выдать Premium`,"account.clearPremium":`Снять Premium`,"account.starsAmount":`Количество Звёзд`,"account.starsAmountAria":`Указать количество начисляемых Звёзд`,"account.grantStars":`Начислить Звёзды`,"account.setVerified":`Подтвердить аккаунт`,"account.clearVerified":`Снять подтверждение`,"channel.pageTitle":`Супергруппы и каналы`,"channel.recentUpdated":`Недавно обновлённые`,"channel.currentPage":`Объекты на странице`,"channel.megagroups":`Супергруппы`,"channel.broadcasts":`Каналы`,"channel.verifiedCount":`Подтверждённые`,"channel.searchPlaceholder":`ID канала / имя пользователя / название`,"channel.channelID":`ID канала`,"channel.kind":`Тип`,"channel.title":`Название`,"channel.pts":`PTS`,"channel.detailProfile":`Профиль канала`,"channel.loadingDetail":`Загрузка данных канала`,"channel.creator":`Создатель: {id}`,"channel.governance":`Модерация`,"channel.governanceValue":`Заблокировано {banned} / Исключено {kicked}`,"channel.flags":`Флаги канала`,"channel.rawRow":`Исходная строка БД`,"channel.rawRowText":`Снимок базы данных только для чтения`,"channel.actionDock":`Действия с каналом`,"channel.setVerified":`Подтвердить канал`,"channel.clearVerified":`Снять подтверждение`,"channel.kind.broadcast":`Канал`,"channel.kind.forum":`Супергруппа / Форум`,"channel.kind.megagroup":`Супергруппа`,"channel.kind.generic":`Канал / Группа`,"route.bots":`Боты`,"route.botsSubtitle":`Консоль / Боты`,"layout.bots":`Боты`,"bots.pageTitle":`Боты`,"bots.queryResults":`Результаты поиска`,"bots.recent":`Недавно созданные боты`,"bots.currentPage":`Боты на странице`,"bots.banned":`Забанен`,"bots.active":`Активен`,"bots.createTitle":`Создать системного бота`,"bots.createHint":`Создаёт бота, принадлежащего указанному пользователю. Токен показывается один раз после подтверждения.`,"bots.ownerUserID":`ID владельца`,"bots.name":`Отображаемое имя`,"bots.namePlaceholder":`например, Service Bot`,"bots.username":`Имя пользователя`,"bots.usernameHint":`Имя пользователя: 5–32 символа, обязательно оканчивается на «bot».`,"bots.create":`Создать бота`,"bots.searchPlaceholder":`ID бота / имя пользователя`,"bots.botID":`ID бота`,"bots.owner":`Владелец`,"bots.status":`Статус`,"bots.detailTitle":`Бот #{id}`,"bots.profile":`Профиль бота`,"bots.loadingDetail":`Загрузка данных бота`,"bots.unnamed":`Без имени`,"bots.restriction":`Ограничение`,"bots.actionDock":`Действия с ботом`,"bots.banUntil":`Забанить до`,"bots.ban":`Забанить бота`,"bots.updateBan":`Обновить бан`,"bots.unban":`Разбанить бота`,"bots.type":`Тип`,"bots.system":`Системный`,"bots.user":`Пользовательский`,"bots.delete":`Удалить бота`,"bots.deleteHint":`Безвозвратно удаляет созданного пользователем бота и аннулирует его токен. Действие необратимо.`,"bots.systemHint":`Системные боты встроены и не могут быть удалены.`,"flags.scam":`SCAM`,"flags.fake":`FAKE`,"flags.setScam":`Пометить как SCAM`,"flags.clearScam":`Снять метку SCAM`,"flags.setFake":`Пометить как FAKE`,"flags.clearFake":`Снять метку FAKE`,"attr.attributes":`Атрибуты`,"attr.settings":`Настройки`,"attr.username":`Имя пользователя`,"attr.setUsername":`Задать имя пользователя`,"attr.setSupport":`Пометить как support`,"attr.clearSupport":`Снять support`,"attr.forProfile":`Цвет профиля`,"attr.hasColor":`Включить цвет`,"attr.colorIndex":`Индекс цвета`,"attr.bgEmojiID":`ID фонового эмодзи`,"attr.setColor":`Задать цвет`,"attr.emojiDocID":`ID документа эмодзи`,"attr.emojiUntil":`До (unix, 0 = бессрочно)`,"attr.setEmojiStatus":`Задать emoji-статус`,"attr.gigagroup":`Гигагруппа`,"attr.antispam":`Агрессивный антиспам`,"attr.participantsHidden":`Скрыть участников`,"attr.noforwards":`Запретить пересылку`,"attr.joinToSend":`Вступление для отправки`,"attr.joinRequest":`Вступление по заявке`,"attr.slowmode":`Медленный режим (сек)`,"attr.applySettings":`Применить настройки`,"route.emoji":`Emoji`,"route.emojiSubtitle":`Консоль / Emoji`,"layout.emoji":`Emoji`,"emoji.pageTitle":`Кастом-эмодзи`,"emoji.queryResults":`Результаты поиска`,"emoji.recent":`Каталог кастом-эмодзи`,"emoji.currentPage":`Эмодзи на странице`,"emoji.searchPlaceholder":`ID документа или эмодзи`,"emoji.copyID":`Скопировать ID документа`,"emoji.noSet":`Без набора`,"emoji.hint":`ID документов отсюда можно вставлять в поле Emoji-статуса в профилях аккаунтов, ботов и каналов.`,"messages.privateTitle":`Личные сообщения`,"messages.privateEyebrow":`Личные ящики сообщений`,"messages.groupTitle":`Групповые сообщения`,"messages.groupEyebrow":`Сообщения супергрупп и каналов`,"messages.selectPrivatePeers":`Сначала найдите и выберите владельца и собеседника`,"messages.selectChannel":`Сначала найдите и выберите супергруппу или канал`,"messages.ownerUser":`Пользователь-владелец`,"messages.peerUser":`Собеседник`,"messages.beforeDatePlaceholder":`курсор before_date`,"messages.beforeIDPlaceholder":`курсор before_msg_id`,"messages.limitPlaceholder":`лимит <= 100`,"messages.searchMessages":`Поиск сообщений`,"messages.nextPage":`Следующая страница`,"messages.currentPage":`Сообщения на странице`,"messages.deleted":`Удалено`,"messages.outgoing":`Исходящее`,"messages.incoming":`Входящее`,"messages.ownerPeer":`Владелец / Собеседник`,"messages.deleteSelected":`Удалить выбранные сообщения`,"messages.idsPlaceholder":`ID сообщений через запятую`,"messages.revoke":`Удалить для обеих сторон`,"messages.previewDelete":`Тестовое удаление`,"messages.clearHistory":`Очистить историю личной переписки`,"messages.maxIDPlaceholder":`граница max_id`,"messages.maxBatchesPlaceholder":`max_batches`,"messages.justClear":`Очистить только у себя`,"messages.previewClearHistory":`Тестовая очистка истории`,"messages.direction":`Направление`,"messages.body":`Текст сообщения`,"messages.privateDetailTitle":`Сообщение #{id}`,"messages.detailEyebrow":`Детали сообщения`,"messages.backPrivate":`Назад к личным сообщениям`,"messages.backGroup":`Назад к групповым сообщениям`,"messages.ownerPeerTitle":`Владелец {owner} · Собеседник {peer}`,"messages.senderSubtitle":`Отправитель {sender} · {date}`,"messages.boxID":`ID ящика сообщений`,"messages.privateMessageID":`ID личного сообщения`,"messages.messageSender":`Отправитель сообщения`,"messages.messageBox":`Ящик сообщений`,"messages.dialogRow":`Строка диалога`,"messages.privateRow":`Строка личного сообщения`,"messages.channelMessageRow":`Строка сообщения канала`,"messages.channelRow":`Строка канала`,"messages.userUpdateEvents":`События обновления пользователей`,"messages.channelUpdateEvents":`События обновления каналов`,"messages.eventJson":`JSON события`,"messages.dispatchOutbox":`Очередь отправки (Outbox)`,"messages.messageBoxesSnapshot":`Снимок message_boxes только для чтения`,"messages.dialogSnapshot":`Снимок dialogs только для чтения`,"messages.privateSnapshot":`Снимок private_messages только для чтения`,"messages.channelMessagesSnapshot":`Снимок channel_messages только для чтения`,"messages.channelSnapshot":`Снимок channels только для чтения`,"messages.userEventsSource":`постоянные user_update_events`,"messages.channelEventsSource":`постоянные channel_update_events`,"messages.outboxSource":`онлайн/офлайн dispatch_outbox`,"messages.attempts":`Попытки`,"messages.deleteThis":`Удалить это сообщение`,"messages.groupDetailTitle":`Групповое сообщение #{id}`,"messages.channelGroupTitle":`Канал / Группа {id}`,"messages.mediaCount":`С медиафайлами`,"messages.channelPosts":`Посты канала`,"messages.channelGroup":`Канал / Группа`,"messages.pinned":`Закреплено`,"messages.channelPost":`Пост в канале`,"gifts.pageTitle":`Каталог звёздных подарков`,"giveGift.action":`Выдать`,"giveGift.eyebrow":`Выдача подарка · без списания`,"giveGift.title":`Выдать подарок`,"giveGift.recipientKind":`Тип получателя`,"giveGift.recipientUser":`Пользователь`,"giveGift.recipientChannel":`Канал`,"giveGift.pickUser":`Получатель (пользователь)`,"giveGift.pickChannel":`Получатель (канал)`,"giveGift.recipientRequired":`Сначала выберите получателя`,"giveGift.sender":`ID аккаунта-отправителя`,"giveGift.senderHint":`Подарки всегда отправляются от системного аккаунта 777000 (Telesrv).`,"giveGift.message":`Сообщение к подарку (необязательно)`,"giveGift.messagePlaceholder":`Показывается вместе с подарком`,"giveGift.hideName":`Скрыть имя отправителя от получателя`,"giveGift.upgrade":`Выдать как улучшенный коллекционный`,"giveGift.upgradeNote":`Подарок будет отчеканен как уникальный коллекционный. Ниже можно выбрать конкретные атрибуты или оставить «Случайно» для выбора из опубликованного пула. Номер присваивается автоматически. Требуется опубликованное коллекционное улучшение с остатком тиража.`,"giveGift.model":`Модель`,"giveGift.pattern":`Узор`,"giveGift.backdrop":`Фон`,"giveGift.random":`Случайно`,"giveGift.confirm":`Выдать подарок`,"giveGifts.pageTitle":`Выдача подарков`,"giveGifts.eyebrow":`Выдача каталожных подарков любому пользователю или каналу`,"giveGifts.available":`Доступно подарков`,"giveGifts.sender":`Отправитель по умолчанию`,"giveGifts.searchPlaceholder":`Поиск по названию или ID подарка`,"giveGifts.hint":`Выберите подарок для выдачи. Выдача бесплатна и по умолчанию отправляется от системного аккаунта 777000 (Telesrv).`,"giveGifts.pickGift":`Выберите подарок`,"giveGifts.selectPrompt":`Выберите подарок из списка, чтобы начать.`,"gifts.eyebrow":`Каталог, неизменяемые версии и файлы анимаций`,"gifts.total":`Подарков в каталоге`,"gifts.enabled":`Включено`,"gifts.received":`Полученные подарки`,"gifts.formats":`Поддерживаемые форматы`,"gifts.add":`Добавить подарок`,"gifts.searchPlaceholder":`Поиск по ID подарка, названию или формату`,"gifts.listSummary":`Показано {shown} из {total}`,"gifts.idRevision":`ID / Версия`,"gifts.price":`Цена / Конвертация`,"gifts.importTitle":`Импорт звёздного подарка`,"gifts.importEyebrow":`Управление каталогом подарков`,"gifts.newRevision":`Создать версию для подарка #{id}`,"gifts.importHint":`Загрузите файл TGS или обычный Lottie JSON. Lottie нормализуется и сжимается в формат TGS.`,"gifts.officialSource":`Официальный снимок`,"gifts.fileSource":`Загрузить файл`,"gifts.officialHint":`Выберите проверенный подарок из data/official-gifts. Полные пулы коллекционных предметов импортируются атомарно.`,"gifts.officialSearch":`Поиск по ID или названию официального подарка`,"gifts.officialSelect":`Выберите официальный подарок`,"gifts.officialRequired":`Сначала выберите официальный подарок`,"gifts.officialResults":`Показано {shown} из {total}`,"gifts.officialCategoryLabel":`Категория возможностей официального подарка`,"gifts.officialCategory.all":`Все`,"gifts.officialCategory.upgrade":`Можно улучшить`,"gifts.officialCategory.craft":`Можно создать`,"gifts.officialCategory.basic":`Нельзя улучшить`,"gifts.officialUnnamed":`Официальный подарок без названия #{id}`,"gifts.officialAttributes":`Атрибутов: {count}`,"gifts.canUpgrade":`Можно улучшить`,"gifts.cannotUpgrade":`Нельзя улучшить`,"gifts.canCraft":`Можно создать`,"gifts.cannotCraft":`Нельзя создать`,"gifts.officialEmpty":`Нет подарков, соответствующих категории и поиску.`,"gifts.includeCollectible":`Импортировать полный пул коллекционных предметов, включая созданные модели`,"gifts.animation":`Файл анимации`,"gifts.filePrompt":`Перетащите или выберите файл TGS / Lottie`,"gifts.fileHint":`TGS, JSON или Lottie · файл проверяется перед импортом`,"gifts.chooseFile":`Выбрать файл`,"gifts.changeFile":`Изменить файл`,"gifts.title":`Отображаемое название`,"gifts.titlePlaceholder":`например, Праздничная звезда`,"gifts.stars":`Цена в Звёздах`,"gifts.convertStars":`Звёзд при конвертации`,"gifts.sortOrder":`Порядок сортировки`,"gifts.reason":`Причина для аудита`,"gifts.reasonPlaceholder":`Кратко опишите причину импорта этого подарка`,"gifts.enableAfterImport":`Включить после импорта`,"gifts.validate":`Тестовая проверка`,"gifts.confirmImport":`Подтвердить импорт`,"gifts.stepDetails":`Файл и описание`,"gifts.stepValidate":`Тестовая проверка`,"gifts.stepImport":`Подтверждение импорта`,"gifts.fileRequired":`Сначала выберите файл TGS или Lottie`,"gifts.source":`Источник`,"gifts.replace":`Новая версия`,"gifts.disable":`Отключить`,"gifts.enable":`Включить`,"gifts.empty":`Звёздные подарки ещё не импортированы.`,"gifts.emptyHint":`Импортируйте первую анимацию, чтобы начать наполнение каталога.`,"gifts.validationReady":`Проверка пройдена`,"gifts.validationHint":`Проверьте нормализованные метаданные и подтвердите импорт.`,"gifts.confirmState":`Применить проверенные изменения состояния к подарку #{id}?`,"collectibles.manage":`Пул атрибутов`,"collectibles.title":`Пул коллекционных предметов · Подарок #{id}`,"collectibles.eyebrow":`Уникальные атрибуты подарка`,"collectibles.activeRevision":`Опубликованная версия {revision}`,"collectibles.published":`Опубликовано`,"collectibles.noPool":`Нет опубликованного пула коллекционных предметов`,"collectibles.noPoolHint":`Опубликуйте модели, узоры и фоны для активации улучшений.`,"collectibles.publishNew":`Опубликовать новую неизменяемую версию`,"collectibles.immutableHint":`Тестовый запуск проверяет каждый файл и структуру набора атрибутов перед активацией версии.`,"collectibles.upgradeStars":`Цена улучшения в Звёздах`,"collectibles.supply":`Уникальный тираж`,"collectibles.slug":`Публичный префикс ссылки (slug)`,"collectibles.models":`Модели`,"collectibles.patterns":`Узоры`,"collectibles.backdrops":`Фоны`,"collectibles.model":`Модель`,"collectibles.pattern":`Узор`,"collectibles.backdrop":`Фон`,"collectibles.rarity":`Редкость ‰`,"collectibles.rarityHint":`В каждой категории должно быть не менее двух атрибутов. Значения в промилле задают относительные веса обычного улучшения; при добавлении или удалении они перераспределяются до суммы 1000.`,"collectibles.minimumAttributes":`Модели, узоры и фоны должны содержать не менее двух атрибутов в каждой категории.`,"collectibles.duplicateBackdropID":`ID фонов в одном наборе должны быть уникальными.`,"collectibles.colorHint":`Цвета сохраняются как 24-битные RGB-значения.`,"collectibles.addAttribute":`Добавить`,"collectibles.remove":`Удалить атрибут`,"collectibles.fileRequired":`Для каждой модели и узора требуется файл TGS или Lottie.`,"collectibles.backdropID":`ID фона`,"collectibles.color.center":`Центр`,"collectibles.color.edge":`Край`,"collectibles.color.pattern":`Узор`,"collectibles.color.text":`Текст`,"collectibles.validationReady":`Пул атрибутов корректен`,"collectibles.validationHint":`Проверьте нормализованные ресурсы и опубликуйте эту неизменяемую версию.`,"collectibles.publish":`Опубликовать версию`,"messages.msgIDsInvalid":`Некорректные ID сообщений`,"auth.device":`Устройство`,"auth.platform":`Платформа`,"auth.ip":`IP-адрес`,"auth.lastActive":`Последняя активность`,"auth.revokeCurrent":`Отозвать текущую`,"auth.keepCurrent":`Оставить текущую`,"auth.revokeAll":`Отозвать все устройства`,"picker.userPlaceholder":`Поиск по user_id / телефону / имени пользователя`,"picker.channelPlaceholder":`Поиск по channel_id / имени пользователя / названию`,"picker.verified":`Подтверждённые`,"picker.regular":`Обычные`,"action.reasonRequired":`Пожалуйста, укажите причину операции`,"action.flow":`Процесс выполнения`,"action.close":`Закрыть`,"action.stepReason":`Укажите причину`,"action.stepDryRun":`Тестовый запуск`,"action.stepConfirm":`Подтверждение выполнения`,"action.reason":`Причина операции`,"action.reasonPlaceholder":`Опишите, почему выполняется эта операция`,"action.requestPreview":`Запросить предпросмотр`,"action.result":`Результат действия`,"action.commandID":`ID команды`,"action.status":`Статус`,"action.dryRun":`Тестовый запуск`,"action.runAgain":`Повторить тестовый запуск`,"action.runDry":`Сначала выполните тестовый запуск`,"action.confirm":`Подтвердить выполнение`,"audit.id":`ID`,"audit.commandID":`ID команды`,"audit.action":`Действие`,"audit.actor":`Исполнитель`,"audit.status":`Статус`,"audit.dryRun":`Тестовый запуск`,"audit.reason":`Причина`,"audit.time":`Время`}},Re=(0,g.createContext)(null);function ze({children:e}){let[t,n]=(0,g.useState)(()=>W());(0,g.useEffect)(()=>{try{localStorage.setItem(Ie,t)}catch{}let e=t===`zh`?`zh-CN`:t===`ru`?`ru`:`en`;document.documentElement.lang=e,document.documentElement.dir=`ltr`,document.documentElement.setAttribute(`translate`,`no`),document.body.classList.add(`notranslate`),document.title=Be(t,`app.title`)},[t]);let r=(0,g.useMemo)(()=>({lang:t,setLang:n,t:(e,n)=>Be(t,e,n)}),[t]);return(0,H.jsx)(Re.Provider,{value:r,children:e})}function U(){let e=(0,g.useContext)(Re);if(!e)throw Error(`useI18n must be used inside I18nProvider`);return e}function Be(e,t,n){let r=Le[e][t]??Le.en[t]??t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>String(n[t]??``)):r}function W(){try{let e=Ve(new URLSearchParams(window.location.search).get(`lang`));if(e)return e}catch{}try{let e=Ve(localStorage.getItem(Ie));if(e)return e}catch{}let e=navigator.languages?.length?navigator.languages:[navigator.language];for(let t of e){let e=Ve(t);if(e)return e}return`en`}function Ve(e){if(!e)return null;let t=e.trim().toLowerCase().replace(`_`,`-`);return t===`zh`||t.startsWith(`zh-`)?`zh`:t===`en`||t.startsWith(`en-`)?`en`:t===`ru`||t.startsWith(`ru-`)?`ru`:null}function He(){return{href:`${window.location.pathname}${window.location.search}`,path:window.location.pathname,search:new URLSearchParams(window.location.search)}}function Ue(e,t){return e.startsWith(`/accounts`)?t(`route.accounts`):e.startsWith(`/channels`)?t(`route.channels`):e.startsWith(`/bots`)?t(`route.bots`):e.startsWith(`/emoji`)?t(`route.emoji`):e.startsWith(`/messages`)?t(`route.messages`):e.startsWith(`/give-gifts`)?t(`route.giveGifts`):e.startsWith(`/gifts`)?t(`route.gifts`):e.startsWith(`/stickers`)?t(`route.stickers`):e.startsWith(`/emoji`)?t(`route.emoji`):t(`route.dashboard`)}function We(e,t){return e.startsWith(`/accounts`)?t(`route.accountsSubtitle`):e.startsWith(`/channels`)?t(`route.channelsSubtitle`):e.startsWith(`/bots`)?t(`route.botsSubtitle`):e.startsWith(`/emoji`)?t(`route.emojiSubtitle`):e.startsWith(`/messages`)?t(`route.messagesSubtitle`):e.startsWith(`/give-gifts`)?t(`route.giveGiftsSubtitle`):e.startsWith(`/gifts`)?t(`route.giftsSubtitle`):e.startsWith(`/stickers`)?t(`route.stickersSubtitle`):e.startsWith(`/emoji`)?t(`route.emojiSubtitle`):t(`route.dashboardSubtitle`)}var Ge=`telesrv.admin.theme`,Ke=(0,g.createContext)(null);function qe(e){document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=e}function Je({children:e}){let[t,n]=(0,g.useState)(()=>Xe());(0,g.useEffect)(()=>{qe(t);try{localStorage.setItem(Ge,t)}catch{}},[t]),(0,g.useEffect)(()=>{if(!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=e=>{let t=null;try{t=localStorage.getItem(Ge)}catch{t=null}t!==`light`&&t!==`dark`&&n(e.matches?`dark`:`light`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let r=(0,g.useCallback)(e=>n(e),[]),i=(0,g.useCallback)(()=>n(e=>e===`dark`?`light`:`dark`),[]),a=(0,g.useMemo)(()=>({theme:t,setTheme:r,toggleTheme:i}),[t,r,i]);return(0,H.jsx)(Ke.Provider,{value:a,children:e})}function Ye(){let e=(0,g.useContext)(Ke);if(!e)throw Error(`useTheme must be used inside ThemeProvider`);return e}function G(){let{theme:e,toggleTheme:t}=Ye(),{t:n}=U(),r=n(e===`light`?`theme.switchToDark`:`theme.switchToLight`);return(0,H.jsx)(`button`,{className:`theme-toggle`,type:`button`,onClick:t,"aria-label":r,title:r,children:e===`dark`?(0,H.jsx)(ke,{size:16}):(0,H.jsx)(he,{size:16})})}function Xe(){try{let e=localStorage.getItem(Ge);if(e===`light`||e===`dark`)return e}catch{}try{if(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function Ze({href:e,navigate:t,className:n,children:r}){return(0,H.jsx)(`a`,{className:n,href:e,onClick:n=>{n.preventDefault(),t(e)},children:r})}function Qe(){let{t:e}=U();return(0,H.jsxs)(`div`,{className:`boot-screen`,children:[(0,H.jsxs)(`div`,{className:`brand compact brand-elevated`,children:[(0,H.jsx)(`span`,{className:`brand-mark`,children:(0,H.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`strong`,{children:`OwpenGram`}),(0,H.jsx)(`small`,{children:e(`app.adminConsole`)})]})]}),(0,H.jsx)(`div`,{className:`loader-bar`})]})}function $e({actor:e,route:t,navigate:n,onLogout:r,children:i}){let{t:a}=U(),o=t.path.startsWith(`/messages`),[s,c]=(0,g.useState)(o);(0,g.useEffect)(()=>{o&&c(!0)},[o]);async function l(){await x.logout().catch(()=>void 0),r()}return(0,H.jsxs)(`div`,{className:`shell`,children:[(0,H.jsxs)(`aside`,{className:`sidebar`,children:[(0,H.jsxs)(Ze,{className:`brand`,href:`/`,navigate:n,children:[(0,H.jsx)(`span`,{className:`brand-mark`,children:(0,H.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`strong`,{children:`OwpenGram`}),(0,H.jsx)(`small`,{children:a(`app.adminConsole`)})]})]}),(0,H.jsx)(`div`,{className:`sidebar-label`,children:a(`layout.navigation`)}),(0,H.jsxs)(`nav`,{className:`nav-list`,"aria-label":a(`layout.primaryNav`),children:[(0,H.jsx)(et,{icon:(0,H.jsx)(de,{size:16}),href:`/`,route:t,navigate:n,children:a(`layout.dashboard`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(Ne,{size:16}),href:`/accounts`,route:t,navigate:n,children:a(`layout.accounts`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(we,{size:16}),href:`/channels`,route:t,navigate:n,children:a(`layout.channels`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(F,{size:16}),href:`/bots`,route:t,navigate:n,children:a(`layout.bots`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(ce,{size:16}),href:`/gifts`,route:t,navigate:n,children:a(`layout.gifts`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(B,{size:16}),href:`/give-gifts`,route:t,navigate:n,children:a(`layout.giveGifts`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(Oe,{size:16}),href:`/stickers`,route:t,navigate:n,children:a(`layout.stickers`)}),(0,H.jsx)(et,{icon:(0,H.jsx)(Ee,{size:16}),href:`/emoji`,route:t,navigate:n,children:a(`layout.emoji`)}),(0,H.jsxs)(`div`,{className:`nav-section ${o?`active`:``} ${s?`open`:``}`,children:[(0,H.jsxs)(`button`,{className:`nav-section-toggle`,type:`button`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,H.jsx)(me,{size:16}),(0,H.jsx)(`span`,{children:a(`layout.messages`)}),(0,H.jsx)(ee,{className:`nav-section-chevron`,size:15})]}),s&&(0,H.jsxs)(`div`,{className:`nav-children`,children:[(0,H.jsx)(et,{href:`/messages/private`,route:t,navigate:n,activeWhen:e=>e===`/messages`||e===`/messages/detail`||e.startsWith(`/messages/private`),children:a(`layout.privateMessages`)}),(0,H.jsx)(et,{href:`/messages/groups`,route:t,navigate:n,activeWhen:e=>e.startsWith(`/messages/groups`),children:a(`layout.groupMessages`)})]})]})]}),(0,H.jsxs)(`div`,{className:`sidebar-status`,children:[(0,H.jsx)(`div`,{className:`sidebar-label`,children:a(`layout.runtime`)}),(0,H.jsxs)(`div`,{className:`runtime-row`,children:[(0,H.jsx)(V,{size:14}),(0,H.jsx)(`span`,{children:a(`layout.adminBackend`)}),(0,H.jsx)(`strong`,{children:a(`layout.ready`)})]}),(0,H.jsxs)(`div`,{className:`runtime-row`,children:[(0,H.jsx)(re,{size:14}),(0,H.jsx)(`span`,{children:a(`layout.pgRead`)}),(0,H.jsx)(`strong`,{children:a(`layout.readOnly`)})]}),(0,H.jsxs)(`div`,{className:`runtime-row`,children:[(0,H.jsx)(Te,{size:14}),(0,H.jsx)(`span`,{children:a(`layout.writeOps`)}),(0,H.jsx)(`strong`,{children:a(`layout.dryRun`)})]})]})]}),(0,H.jsxs)(`div`,{className:`workspace`,children:[(0,H.jsxs)(`header`,{className:`topbar`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:We(t.path,a)}),(0,H.jsx)(`h1`,{children:Ue(t.path,a)})]}),(0,H.jsxs)(`div`,{className:`topbar-actions`,children:[(0,H.jsx)(G,{}),(0,H.jsx)(`span`,{className:`actor-pill`,children:a(`layout.actor`,{actor:e})}),(0,H.jsxs)(`button`,{className:`btn ghost icon-text`,type:`button`,onClick:l,title:a(`layout.logout`),children:[(0,H.jsx)(pe,{size:16}),` `,a(`layout.logout`)]})]})]}),(0,H.jsx)(`main`,{className:`content`,children:i})]})]})}function et({href:e,route:t,navigate:n,icon:r,children:i,activeWhen:a}){return(0,H.jsxs)(Ze,{className:`nav-item ${(a?a(t.path):e===`/`?t.path===`/`:t.path.startsWith(e))?`active`:``}`,href:e,navigate:n,children:[r??(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`nav-dot`}),(0,H.jsx)(`span`,{children:i})]})}function tt(e){let t=e.trim();return!t||t.startsWith(`+`)?t:/^\d+$/.test(t)?`+${t}`:t}function nt(e){let t=e.trim();return t?t.startsWith(`@`)?t:`@${t}`:``}function rt(e){return`${e.FirstName||``} ${e.LastName||``}`.trim()||`-`}function it(e,t){let n=t??(e=>({"channel.kind.broadcast":`Channel`,"channel.kind.forum":`Supergroup / Forum`,"channel.kind.megagroup":`Supergroup`,"channel.kind.generic":`Channel / Group`})[e]??e);return e.Broadcast&&!e.Megagroup?n(`channel.kind.broadcast`):e.Megagroup&&e.Forum?n(`channel.kind.forum`):e.Megagroup?n(`channel.kind.megagroup`):n(`channel.kind.generic`)}function at(e){if(!e||e.startsWith(`0001-`))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function ot(e){if(!e||e<=0)return``;let t=new Date(e*1e3);return Number.isNaN(t.getTime())?``:t.toLocaleString()}function st(e){if(!e.trim())return 0;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:0}function ct(e,t=`msg ids invalid`){let n=e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean).map(e=>Number.parseInt(e,10));if(n.length===0||n.some(e=>!Number.isFinite(e)||e<=0))throw Error(t);return n}function lt({title:e,eyebrow:t,children:n,actions:r}){return(0,H.jsxs)(`div`,{className:`page-frame`,children:[(0,H.jsxs)(`div`,{className:`page-title-row`,children:[(0,H.jsxs)(`div`,{children:[t&&(0,H.jsx)(`div`,{className:`eyebrow`,children:t}),(0,H.jsx)(`h2`,{children:e})]}),r&&(0,H.jsx)(`div`,{className:`page-actions`,children:r})]}),n]})}function ut({children:e}){return(0,H.jsx)(`div`,{className:`query-panel`,children:e})}function dt({main:e,side:t}){return(0,H.jsxs)(`div`,{className:`split-layout`,children:[(0,H.jsx)(`div`,{className:`split-main`,children:e}),(0,H.jsx)(`aside`,{className:`split-side`,children:t})]})}function ft({title:e,text:t,action:n}){return(0,H.jsxs)(`div`,{className:`section-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{children:e}),t&&(0,H.jsx)(`p`,{children:t})]}),n&&(0,H.jsx)(`div`,{className:`section-action`,children:n})]})}function pt({children:e}){return(0,H.jsxs)(`div`,{className:`alert`,children:[(0,H.jsx)(O,{size:16}),` `,(0,H.jsx)(`span`,{children:e})]})}function K({children:e,tone:t=`neutral`}){return(0,H.jsx)(`span`,{className:`badge ${t}`,children:e})}function mt({label:e,value:t,tone:n}){return(0,H.jsxs)(`div`,{className:`status-item ${n}`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(`strong`,{children:t})]})}function q({label:e,value:t,tone:n=`neutral`,mono:r=!1}){return(0,H.jsxs)(`div`,{className:`metric ${n}`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(`strong`,{className:r?`mono`:``,children:t})]})}function J({label:e,value:t,mono:n=!1}){return(0,H.jsxs)(`div`,{className:`summary-item`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(`strong`,{className:n?`mono`:``,children:t})]})}function ht({rows:e}){let{t}=U();return(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`audit.id`)}),(0,H.jsx)(`th`,{children:t(`audit.commandID`)}),(0,H.jsx)(`th`,{children:t(`audit.action`)}),(0,H.jsx)(`th`,{children:t(`audit.actor`)}),(0,H.jsx)(`th`,{children:t(`audit.status`)}),(0,H.jsx)(`th`,{children:t(`audit.dryRun`)}),(0,H.jsx)(`th`,{children:t(`audit.reason`)}),(0,H.jsx)(`th`,{children:t(`audit.time`)})]})}),(0,H.jsxs)(`tbody`,{children:[e.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{children:e.ID}),(0,H.jsx)(`td`,{className:`mono`,children:e.CommandID}),(0,H.jsx)(`td`,{children:e.Action}),(0,H.jsx)(`td`,{children:e.Actor}),(0,H.jsx)(`td`,{children:e.Status}),(0,H.jsx)(`td`,{children:e.DryRun?t(`common.yes`):t(`common.no`)}),(0,H.jsx)(`td`,{className:`truncate`,children:e.Reason}),(0,H.jsx)(`td`,{children:at(e.CreatedAt)})]},e.ID)),e.length===0&&(0,H.jsx)(gt,{colSpan:8})]})]})})}function gt({colSpan:e}){let{t}=U();return(0,H.jsx)(`tr`,{children:(0,H.jsx)(`td`,{colSpan:e,className:`empty-cell`,children:t(`common.noResults`)})})}function _t({label:e}){return(0,H.jsx)(`section`,{className:`surface`,children:(0,H.jsx)(`div`,{className:`loading-line`,children:e})})}function vt({value:e}){return(0,H.jsx)(`pre`,{className:`json-block`,children:e||`{}`})}function yt({onLogin:e}){let{t}=U(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1);async function c(t){t.preventDefault(),s(!0),a(``);try{e((await x.login(n)).actor)}catch(e){a(b(e))}finally{s(!1)}}return(0,H.jsxs)(`main`,{className:`login-page`,children:[(0,H.jsxs)(`div`,{className:`bg-orbs`,"aria-hidden":`true`,children:[(0,H.jsx)(`div`,{className:`bg-orb bg-orb--1`}),(0,H.jsx)(`div`,{className:`bg-orb bg-orb--2`}),(0,H.jsx)(`div`,{className:`bg-orb bg-orb--3`})]}),(0,H.jsxs)(`section`,{className:`login-panel`,children:[(0,H.jsxs)(`div`,{className:`login-head`,children:[(0,H.jsxs)(`div`,{className:`brand brand-elevated`,children:[(0,H.jsx)(`span`,{className:`brand-mark`,children:(0,H.jsx)(`img`,{src:`/logo.png`,alt:`OwpenGram`})}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`strong`,{children:`OwpenGram`}),(0,H.jsx)(`small`,{children:t(`app.adminConsole`)})]})]}),(0,H.jsxs)(`div`,{className:`login-head-actions`,children:[(0,H.jsx)(G,{}),(0,H.jsx)(`span`,{className:`login-chip`,children:t(`app.localAccess`)})]})]}),(0,H.jsxs)(`div`,{className:`login-copy`,children:[(0,H.jsx)(`h1`,{children:t(`login.heading`)}),(0,H.jsx)(`p`,{children:t(`login.body`)})]}),i&&(0,H.jsx)(pt,{children:i}),(0,H.jsxs)(`form`,{className:`form-stack`,onSubmit:c,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:t(`login.secret`)}),(0,H.jsx)(`input`,{autoFocus:!0,type:`password`,value:n,autoComplete:`current-password`,onChange:e=>r(e.target.value)})]}),(0,H.jsx)(`button`,{className:`btn primary full`,type:`submit`,disabled:o,children:t(o?`login.submitting`:`login.submit`)})]})]})]})}var bt=m();function Y({label:e,path:t,payload:n,icon:r,compact:i=!1,tone:a=`danger`,onDone:o}){let{t:s}=U(),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(!1);function y(){d(``),p(null),h(``)}async function S(e){if(!u.trim()){h(s(`action.reasonRequired`));return}v(!0),h(``);try{let r={...n(),reason:u,confirm:e};p(await x.action(t,r)),e&&o?.()}catch(e){h(b(e))}finally{v(!1)}}let C=f?.dry_run&&!f.error,w=`btn ${a===`danger`?`danger`:a===`warn`?`warn`:``} ${i?`compact-btn`:``}`,T=(0,g.useMemo)(()=>{try{return n()}catch(e){return{payload_error:b(e)}}},[c,n]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{className:w,type:`button`,onClick:()=>{y(),l(!0)},children:[r,e]}),c&&(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e,children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:s(`action.flow`)}),(0,H.jsx)(`h2`,{children:e})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:()=>l(!1),"aria-label":s(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body`,children:[(0,H.jsxs)(`div`,{className:`command-steps`,children:[(0,H.jsxs)(`div`,{className:`command-step ${u.trim()?`done`:`active`}`,children:[(0,H.jsx)(`span`,{children:`1`}),(0,H.jsx)(`strong`,{children:s(`action.stepReason`)})]}),(0,H.jsxs)(`div`,{className:`command-step ${f?.dry_run?`done`:u.trim()?`active`:``}`,children:[(0,H.jsx)(`span`,{children:`2`}),(0,H.jsx)(`strong`,{children:s(`action.stepDryRun`)})]}),(0,H.jsxs)(`div`,{className:`command-step ${f&&!f.dry_run&&!f.error?`done`:C?`active`:``}`,children:[(0,H.jsx)(`span`,{children:`3`}),(0,H.jsx)(`strong`,{children:s(`action.stepConfirm`)})]})]}),(0,H.jsxs)(`label`,{className:`form-field`,children:[(0,H.jsx)(`span`,{children:s(`action.reason`)}),(0,H.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),rows:3,placeholder:s(`action.reasonPlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`command-preview`,children:[(0,H.jsxs)(`div`,{className:`preview-head`,children:[(0,H.jsx)(oe,{size:14}),` `,s(`action.requestPreview`)]}),(0,H.jsx)(vt,{value:JSON.stringify(T,null,2)})]}),m&&(0,H.jsx)(pt,{children:m}),f&&(0,H.jsxs)(`div`,{className:`result-box`,children:[(0,H.jsxs)(`div`,{className:`result-title`,children:[f.error?(0,H.jsx)(O,{size:16}):(0,H.jsx)(k,{size:16}),(0,H.jsx)(`strong`,{children:f.message||f.error||s(`action.result`)})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:s(`action.commandID`)}),(0,H.jsx)(`strong`,{children:f.command_id})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:s(`action.status`)}),(0,H.jsx)(`strong`,{children:f.status})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:s(`action.dryRun`)}),(0,H.jsx)(`strong`,{children:f.dry_run?s(`common.yes`):s(`common.no`)})]}),(0,H.jsx)(`div`,{className:`result-message`,children:f.message||f.error}),f.details&&(0,H.jsx)(vt,{value:JSON.stringify(f.details,null,2)})]})]}),(0,H.jsxs)(`div`,{className:`modal-actions`,children:[(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>l(!1),children:s(`common.close`)}),(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>S(!1),disabled:_,children:[_?(0,H.jsx)(A,{size:15,className:`spin`}):(0,H.jsx)(ve,{size:15}),s(f?`action.runAgain`:`action.runDry`)]}),(0,H.jsxs)(`button`,{className:`btn danger icon-text`,type:`button`,onClick:()=>S(!0),disabled:_||!C,children:[(0,H.jsx)(k,{size:15}),s(`action.confirm`)]})]})]})}),document.body)]})}function xt({rows:e,userID:t,onDone:n}){let{t:r}=U(),[i,a]=(0,g.useState)(()=>new Set);(0,g.useEffect)(()=>{a(new Set)},[t]);let o=(0,g.useMemo)(()=>e.filter(e=>!i.has(e.Hash)),[e,i]);function s(e){a(t=>e(t)),n()}return(0,H.jsxs)(`div`,{className:`authorization-block`,children:[(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table authorization-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:r(`auth.device`)}),(0,H.jsx)(`th`,{children:r(`auth.platform`)}),(0,H.jsx)(`th`,{children:r(`auth.ip`)}),(0,H.jsx)(`th`,{children:r(`auth.lastActive`)}),(0,H.jsx)(`th`,{className:`device-actions-head`,children:r(`common.actions`)})]})}),(0,H.jsxs)(`tbody`,{children:[o.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsxs)(`td`,{className:`device-text`,children:[n.DeviceModel,` `,n.SystemVersion]}),(0,H.jsxs)(`td`,{className:`device-text`,children:[n.Platform,` `,n.AppVersion]}),(0,H.jsx)(`td`,{children:n.IP}),(0,H.jsx)(`td`,{children:at(n.ActiveAt)}),(0,H.jsx)(`td`,{className:`device-actions-cell`,children:(0,H.jsxs)(`div`,{className:`device-actions`,children:[(0,H.jsx)(Y,{label:r(`auth.revokeCurrent`),icon:(0,H.jsx)(pe,{size:13}),compact:!0,path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,hash:n.Hash}),onDone:()=>s(e=>new Set([...e,n.Hash]))}),(0,H.jsx)(Y,{label:r(`auth.keepCurrent`),icon:(0,H.jsx)(we,{size:13}),compact:!0,path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,keep_hash:n.Hash}),onDone:()=>s(()=>new Set(e.filter(e=>e.Hash!==n.Hash).map(e=>e.Hash)))})]})})]},n.Hash)),o.length===0&&(0,H.jsx)(gt,{colSpan:5})]})]})}),(0,H.jsx)(`div`,{className:`danger-zone`,children:(0,H.jsx)(Y,{label:r(`auth.revokeAll`),icon:(0,H.jsx)(I,{size:15}),path:`/api/actions/revoke-sessions`,payload:()=>({user_id:t,revoke_all:!0}),onDone:()=>s(()=>new Set(e.map(e=>e.Hash)))})})]})}function St({scam:e,fake:t}){let{t:n}=U();return!e&&!t?null:(0,H.jsxs)(H.Fragment,{children:[e&&(0,H.jsx)(K,{tone:`danger`,children:n(`flags.scam`)}),t&&(0,H.jsx)(K,{tone:`danger`,children:n(`flags.fake`)})]})}function Ct({idKey:e,id:t,path:n,scam:r,fake:i,onDone:a}){let{t:o}=U();return(0,H.jsxs)(`div`,{className:`action-stack`,children:[(0,H.jsx)(Y,{label:o(r?`flags.clearScam`:`flags.setScam`),icon:(0,H.jsx)(Ce,{size:15}),tone:`danger`,path:n,payload:()=>({[e]:t,scam:!r,fake:r?i:!1}),onDone:a}),(0,H.jsx)(Y,{label:o(i?`flags.clearFake`:`flags.setFake`),icon:(0,H.jsx)(j,{size:15}),tone:`danger`,path:n,payload:()=>({[e]:t,fake:!i,scam:i?r:!1}),onDone:a})]})}function wt({id:e,support:t,onDone:n}){let{t:r}=U();return(0,H.jsx)(Y,{label:r(t?`attr.clearSupport`:`attr.setSupport`),icon:(0,H.jsx)(fe,{size:15}),tone:`neutral`,path:`/api/actions/set-support`,payload:()=>({user_id:e,support:!t}),onDone:n})}function Tt({idKey:e,id:t,path:n,current:r,onDone:i}){let{t:a}=U(),[o,s]=(0,g.useState)(r.replace(/^@/,``));return(0,H.jsxs)(`div`,{className:`attr-block`,children:[(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:a(`attr.username`)}),(0,H.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`username`})]}),(0,H.jsx)(Y,{label:a(`attr.setUsername`),icon:(0,H.jsx)(P,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,username:o.trim().replace(/^@/,``)}),onDone:i})]})}function Et({idKey:e,id:t,path:n,onDone:r}){let{t:i}=U(),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!0),[l,u]=(0,g.useState)(`0`),[d,f]=(0,g.useState)(``);return(0,H.jsxs)(`div`,{className:`attr-block`,children:[(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),` `,i(`attr.forProfile`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),` `,i(`attr.hasColor`)]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:i(`attr.colorIndex`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,max:`20`,value:l,onChange:e=>u(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:i(`attr.bgEmojiID`)}),(0,H.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`0`})]}),(0,H.jsx)(Y,{label:i(`attr.setColor`),icon:(0,H.jsx)(ge,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,for_profile:a,has_color:s,color:st(l),background_emoji_id:d.trim()||`0`}),onDone:r})]})}function Dt({idKey:e,id:t,path:n,onDone:r}){let{t:i}=U(),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(`0`);return(0,H.jsxs)(`div`,{className:`attr-block`,children:[(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:i(`attr.emojiDocID`)}),(0,H.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`0 = clear`})]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:i(`attr.emojiUntil`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,value:s,onChange:e=>c(e.target.value)})]}),(0,H.jsx)(Y,{label:i(`attr.setEmojiStatus`),icon:(0,H.jsx)(Ee,{size:15}),tone:`neutral`,path:n,payload:()=>({[e]:t,document_id:a.trim()||`0`,until:st(s)}),onDone:r})]})}function Ot({channel:e,onDone:t}){let{t:n}=U(),[r,i]=(0,g.useState)(e.Gigagroup),[a,o]=(0,g.useState)(e.AntiSpam),[s,c]=(0,g.useState)(e.ParticipantsHidden),[l,u]=(0,g.useState)(e.NoForwards),[d,f]=(0,g.useState)(e.JoinToSend),[p,m]=(0,g.useState)(e.JoinRequest),[h,_]=(0,g.useState)(String(e.SlowmodeSeconds));(0,g.useEffect)(()=>{i(e.Gigagroup),o(e.AntiSpam),c(e.ParticipantsHidden),u(e.NoForwards),f(e.JoinToSend),m(e.JoinRequest),_(String(e.SlowmodeSeconds))},[e]);function v(){let t={channel_id:e.ID};return r!==e.Gigagroup&&(t.gigagroup=r),a!==e.AntiSpam&&(t.antispam=a),s!==e.ParticipantsHidden&&(t.participants_hidden=s),l!==e.NoForwards&&(t.noforwards=l),d!==e.JoinToSend&&(t.join_to_send=d),p!==e.JoinRequest&&(t.join_request=p),st(h)!==e.SlowmodeSeconds&&(t.slowmode_seconds=st(h)),t}return(0,H.jsxs)(`div`,{className:`attr-block`,children:[(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),` `,n(`attr.gigagroup`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),` `,n(`attr.antispam`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),` `,n(`attr.participantsHidden`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),` `,n(`attr.noforwards`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),` `,n(`attr.joinToSend`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,n(`attr.joinRequest`)]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:n(`attr.slowmode`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,max:`86400`,value:h,onChange:e=>_(e.target.value)})]}),(0,H.jsx)(Y,{label:n(`attr.applySettings`),icon:(0,H.jsx)(Se,{size:15}),tone:`warn`,path:`/api/actions/set-channel-settings`,payload:v,onDone:t})]})}function kt({id:e,navigate:t}){let{t:n}=U(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(`1`),[d,f]=(0,g.useState)(`1000`),[p,m]=(0,g.useState)(()=>At(new Date(Date.now()+7*864e5))),[h,_]=(0,g.useState)(``);async function v(){c(!0),o(``);try{let t=await x.account(e);i(t),t.Restriction.Frozen&&(t.Restriction.Until&&m(At(new Date(t.Restriction.Until))),_(t.Restriction.AppealURL||``))}catch(e){o(b(e))}finally{c(!1)}}if((0,g.useEffect)(()=>{v()},[e]),a)return(0,H.jsx)(pt,{children:a});if(!r)return(0,H.jsx)(_t,{label:n(s?`account.loadingDetail`:`account.waitingData`)});let y=r.Account;return(0,H.jsx)(lt,{title:n(`account.detailTitle`,{id:y.ID}),eyebrow:n(`account.profile`),actions:(0,H.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/accounts`),children:[(0,H.jsx)(N,{size:15}),` `,n(`common.backToList`)]}),children:(0,H.jsx)(dt,{main:(0,H.jsxs)(`div`,{className:`stacked-sections`,children:[(0,H.jsxs)(`section`,{className:`entity-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`entity-title`,children:rt(y)}),(0,H.jsxs)(`div`,{className:`entity-subtitle`,children:[nt(y.Username)||n(`account.noUsername`),` · `,tt(y.Phone)||n(`account.noPhone`)]})]}),(0,H.jsxs)(`div`,{className:`entity-badges`,children:[y.PremiumUntil>0?(0,H.jsx)(K,{tone:`good`,children:n(`account.premium`)}):(0,H.jsx)(K,{children:n(`account.notPremium`)}),r.Verified?(0,H.jsx)(K,{tone:`good`,children:n(`common.verified`)}):(0,H.jsx)(K,{children:n(`account.notVerified`)}),(0,H.jsx)(St,{scam:r.Scam,fake:r.Fake}),y.Frozen?(0,H.jsx)(K,{tone:`danger`,children:n(`account.accountFrozen`)}):(0,H.jsx)(K,{children:n(`account.accountActive`)})]})]}),(0,H.jsxs)(`div`,{className:`summary-grid`,children:[(0,H.jsx)(J,{label:n(`account.userID`),value:String(y.ID),mono:!0}),(0,H.jsx)(J,{label:n(`account.lastActive`),value:ot(r.LastSeenAt)||`-`}),(0,H.jsx)(J,{label:n(`account.premiumUntil`),value:y.PremiumUntil>0?ot(y.PremiumUntil):n(`common.none`)}),(0,H.jsx)(J,{label:n(`account.starsBalance`),value:`${r.StarsBalance} / ${r.StarsGranted?n(`account.startingGrantApplied`):n(`account.startingGrantPending`)}`}),(0,H.jsx)(J,{label:n(`common.updatedAt`),value:at(y.UpdatedAt)||`-`}),(0,H.jsx)(J,{label:n(`account.activeSessions`),value:String(r.Authorizations.length)}),(0,H.jsx)(J,{label:n(`account.accountFlags`),value:`support=${r.Support} bot=${r.Bot}`}),(0,H.jsx)(J,{label:n(`account.restriction`),value:r.HasRestriction?r.Restriction.Reason||n(`account.restricted`):n(`common.none`)}),(0,H.jsx)(J,{label:n(`account.freezeSince`),value:r.Restriction.Since?at(r.Restriction.Since):n(`common.none`)}),(0,H.jsx)(J,{label:n(`account.freezeUntil`),value:r.Restriction.Until?at(r.Restriction.Until):n(`common.none`)}),(0,H.jsx)(J,{label:n(`account.freezeAppealURL`),value:r.Restriction.AppealURL||n(`common.none`)}),(0,H.jsx)(J,{label:n(`account.createdAt`),value:at(y.CreatedAt)||`-`})]}),r.About&&(0,H.jsx)(`p`,{className:`about-text`,children:r.About}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:n(`account.authorizationsTitle`),text:n(`account.authorizationsCount`,{count:r.Authorizations.length})}),(0,H.jsx)(xt,{rows:r.Authorizations,userID:y.ID,onDone:v})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:n(`account.recentAdminOps`),text:n(`account.recent30Audit`)}),(0,H.jsx)(ht,{rows:r.AuditLogs})]})]}),side:(0,H.jsxs)(`section`,{className:`action-dock`,children:[(0,H.jsx)(`div`,{className:`dock-title`,children:n(`account.actionDock`)}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:n(`account.freezeUntil`)}),(0,H.jsx)(`input`,{"aria-label":n(`account.freezeUntilAria`),value:p,onChange:e=>m(e.target.value),type:`datetime-local`})]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:n(`account.freezeAppealURL`)}),(0,H.jsx)(`input`,{"aria-label":n(`account.freezeAppealURLAria`),value:h,onChange:e=>_(e.target.value),type:`url`,placeholder:`https://...`})]}),(0,H.jsx)(Y,{label:y.Frozen?n(`account.updateFreeze`):n(`account.freezeAccount`),icon:(0,H.jsx)(O,{size:15}),path:`/api/actions/set-frozen`,payload:()=>({user_id:y.ID,frozen:!0,freeze_until:new Date(p).toISOString(),freeze_appeal_url:h.trim()}),onDone:v}),y.Frozen&&(0,H.jsx)(Y,{label:n(`account.unfreezeAccount`),icon:(0,H.jsx)(O,{size:15}),path:`/api/actions/set-frozen`,payload:()=>({user_id:y.ID,frozen:!1}),onDone:v}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:n(`account.premiumMonths`)}),(0,H.jsx)(`input`,{"aria-label":n(`account.premiumMonthsAria`),value:l,onChange:e=>u(e.target.value),type:`number`,min:`1`,max:`120`})]}),(0,H.jsxs)(`div`,{className:`action-stack`,children:[(0,H.jsx)(Y,{label:n(`account.setPremium`),icon:(0,H.jsx)(M,{size:15}),tone:`warn`,path:`/api/actions/grant-premium`,payload:()=>({user_id:y.ID,months:st(l)}),onDone:v}),(0,H.jsx)(Y,{label:n(`account.clearPremium`),icon:(0,H.jsx)(M,{size:15}),tone:`warn`,path:`/api/actions/grant-premium`,payload:()=>({user_id:y.ID,months:0}),onDone:v}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:n(`account.starsAmount`)}),(0,H.jsx)(`input`,{"aria-label":n(`account.starsAmountAria`),value:d,onChange:e=>f(e.target.value),type:`number`,min:`1`,max:`1000000000`})]}),(0,H.jsx)(Y,{label:n(`account.grantStars`),icon:(0,H.jsx)(De,{size:15}),tone:`warn`,path:`/api/actions/grant-stars`,payload:()=>({user_id:y.ID,amount:st(d)}),onDone:v}),(0,H.jsx)(Y,{label:r.Verified?n(`account.clearVerified`):n(`account.setVerified`),icon:(0,H.jsx)(D,{size:15}),tone:`warn`,path:`/api/actions/set-verified`,payload:()=>({user_id:y.ID,verified:!r.Verified}),onDone:v})]}),(0,H.jsx)(Ct,{idKey:`user_id`,id:y.ID,path:`/api/actions/set-account-flags`,scam:r.Scam,fake:r.Fake,onDone:v}),(0,H.jsx)(`div`,{className:`dock-title`,children:n(`attr.attributes`)}),(0,H.jsx)(wt,{id:y.ID,support:r.Support,onDone:v}),(0,H.jsx)(Tt,{idKey:`user_id`,id:y.ID,path:`/api/actions/set-account-username`,current:y.Username,onDone:v}),(0,H.jsx)(Et,{idKey:`user_id`,id:y.ID,path:`/api/actions/set-account-color`,onDone:v}),(0,H.jsx)(Dt,{idKey:`user_id`,id:y.ID,path:`/api/actions/set-account-emoji-status`,onDone:v})]})})})}function At(e){return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}var jt=[[`#FF885E`,`#FF516A`],[`#FFCD6A`,`#FFA85C`],[`#82B1FF`,`#665FFF`],[`#A0DE7E`,`#54CB68`],[`#53EDD6`,`#28C9B7`],[`#72D5FD`,`#2A9EF1`],[`#E0A2F3`,`#D669ED`]];function X(e){return jt[Math.abs(e)%jt.length]}function Mt(e){let t=Array.from(e);return t.length>0?t[0]:``}function Nt(e,t,n){let r=`${e} ${t}`.trim().split(/\s+/).filter(Boolean),i=r.length>0?r:n?[n]:[];if(i.length===0)return`T`;let a=Mt(i[0]);return i.length>1&&(a+=Mt(i[i.length-1])),a.toUpperCase()}function Pt({userID:e,firstName:t,lastName:n,username:r=``,size:i=34}){let[a,o]=(0,g.useState)(!1);if((0,g.useEffect)(()=>{o(!1)},[e]),a){let[a,o]=X(e);return(0,H.jsx)(`div`,{className:`avatar-fallback`,style:{width:i,height:i,background:`linear-gradient(135deg, ${a}, ${o})`,fontSize:Math.round(i*.42)},children:Nt(t,n,r)})}return(0,H.jsx)(`img`,{className:`avatar-photo-img`,src:`/api/accounts/${e}/avatar`,alt:``,loading:`lazy`,style:{width:i,height:i},onError:()=>o(!0)})}function Ft(e){return e.reduce((e,t)=>(e.devices+=t.DeviceCount,e),{devices:0})}function It(e){return e.reduce((e,t)=>(t.Megagroup&&(e.megagroups+=1),t.Broadcast&&(e.broadcasts+=1),t.Verified&&(e.verified+=1),e),{megagroups:0,broadcasts:0,verified:0})}var Lt={beforeID:0,beforeActiveUS:0};function Rt({navigate:e}){let{t}=U(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(50),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)([]),[f,p]=(0,g.useState)(Lt),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(``);async function y(e,t){h(!0),v(``);let n=new URLSearchParams({limit:String(i)});e.trim()&&n.set(`q`,e.trim()),(t.beforeID||t.beforeActiveUS)&&(n.set(`before_id`,String(t.beforeID)),n.set(`before_active_us`,String(t.beforeActiveUS)));try{let e=await x.accounts(n);return s(e),e}catch(e){return v(b(e)),null}finally{h(!1)}}async function S(){d([]),p(Lt),await y(n,Lt)}async function C(){if(!o?.has_more)return;let e={beforeID:o.next_before_id,beforeActiveUS:o.next_before_active_us};await y(n,e)&&(d(e=>[...e,f]),p(e))}async function w(){if(u.length===0)return;let e=u[u.length-1];await y(n,e)&&(d(e=>e.slice(0,-1)),p(e))}async function T(){try{l(await x.accountStats())}catch{}}(0,g.useEffect)(()=>{S(),T()},[]);let E=Ft(o?.rows??[]),D=u.length>0&&!m,O=!!o?.has_more&&!m;return(0,H.jsxs)(lt,{title:t(`account.pageTitle`),eyebrow:o?.listing===!1?t(`account.queryResults`):t(`account.recentActive`),actions:(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>{S(),T()},disabled:m,children:[(0,H.jsx)(be,{size:15}),` `,t(`common.refresh`)]}),children:[_&&(0,H.jsx)(pt,{children:_}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`account.totalUsers`),value:c?String(c.total):`…`}),(0,H.jsx)(q,{label:t(`account.onlineNow`),value:c?String(c.online):`…`,tone:`good`}),(0,H.jsx)(q,{label:t(`account.onlineDevices`),value:String(E.devices)})]}),(0,H.jsx)(ut,{children:(0,H.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:t(`account.searchPlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`gift-page-size`,children:[(0,H.jsx)(`span`,{children:t(`common.limit`)}),(0,H.jsxs)(`select`,{value:String(i),onChange:e=>a(Number(e.target.value)),children:[(0,H.jsx)(`option`,{value:`10`,children:`10`}),(0,H.jsx)(`option`,{value:`20`,children:`20`}),(0,H.jsx)(`option`,{value:`50`,children:`50`}),(0,H.jsx)(`option`,{value:`100`,children:`100`})]})]}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:m,children:[m?(0,H.jsx)(A,{size:15,className:`spin`}):(0,H.jsx)(xe,{size:15}),` `,t(`common.search`)]}),(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>void w(),disabled:!D,children:[(0,H.jsx)(R,{size:15}),` `,t(`common.previous`)]}),(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>void C(),disabled:!O,children:[(0,H.jsx)(te,{size:15}),` `,t(`common.next`)]})]})}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{className:`avatar-col`}),(0,H.jsx)(`th`,{children:t(`account.userID`)}),(0,H.jsx)(`th`,{children:t(`account.phone`)}),(0,H.jsx)(`th`,{children:t(`common.username`)}),(0,H.jsx)(`th`,{children:t(`common.name`)}),(0,H.jsx)(`th`,{children:t(`account.loginEmail`)}),(0,H.jsx)(`th`,{children:t(`common.device`)}),(0,H.jsx)(`th`,{children:t(`account.lastActive`)}),(0,H.jsx)(`th`,{children:t(`account.premium`)}),(0,H.jsx)(`th`,{children:t(`common.verified`)}),(0,H.jsx)(`th`,{children:t(`account.frozen`)}),(0,H.jsx)(`th`,{children:t(`common.updatedAt`)}),(0,H.jsx)(`th`,{})]})}),(0,H.jsxs)(`tbody`,{children:[o?.rows.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`avatar-col`,children:(0,H.jsx)(Pt,{userID:n.ID,firstName:n.FirstName,lastName:n.LastName,username:n.Username})}),(0,H.jsx)(`td`,{className:`mono`,children:n.ID}),(0,H.jsx)(`td`,{children:tt(n.Phone)}),(0,H.jsx)(`td`,{children:nt(n.Username)}),(0,H.jsx)(`td`,{children:rt(n)}),(0,H.jsx)(`td`,{children:n.LoginEmail||(0,H.jsx)(`span`,{className:`muted-cell`,children:t(`common.none`)})}),(0,H.jsx)(`td`,{children:n.DeviceCount}),(0,H.jsx)(`td`,{children:at(n.LastActiveAt)}),(0,H.jsx)(`td`,{children:n.PremiumUntil>0?(0,H.jsxs)(K,{tone:`good`,children:[t(`account.premium`),` `,ot(n.PremiumUntil)]}):(0,H.jsx)(K,{children:t(`common.none`)})}),(0,H.jsxs)(`td`,{children:[n.Verified?(0,H.jsx)(K,{tone:`good`,children:t(`common.verified`)}):(0,H.jsx)(K,{children:t(`account.notVerified`)}),` `,(0,H.jsx)(St,{scam:n.Scam,fake:n.Fake})]}),(0,H.jsx)(`td`,{children:n.Frozen?(0,H.jsx)(K,{tone:`danger`,children:t(`account.frozen`)}):(0,H.jsx)(K,{children:t(`common.normal`)})}),(0,H.jsx)(`td`,{children:at(n.UpdatedAt)}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/accounts/${n.ID}`),children:[t(`common.detail`),` `,(0,H.jsx)(te,{size:14})]})})]},n.ID)),(!o||o.rows.length===0)&&(0,H.jsx)(gt,{colSpan:12})]})]})})]})}function zt({id:e,navigate:t}){let{t:n}=U(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``);async function s(){o(``);try{i(await x.channel(e))}catch(e){o(b(e))}}if((0,g.useEffect)(()=>{s()},[e]),a)return(0,H.jsx)(pt,{children:a});if(!r)return(0,H.jsx)(_t,{label:n(`channel.loadingDetail`)});let c=r.Channel;return(0,H.jsx)(lt,{title:`${it(c,n)} #${c.ID}`,eyebrow:n(`channel.detailProfile`),actions:(0,H.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/channels`),children:[(0,H.jsx)(N,{size:15}),` `,n(`common.backToList`)]}),children:(0,H.jsx)(dt,{main:(0,H.jsxs)(`div`,{className:`stacked-sections`,children:[(0,H.jsxs)(`section`,{className:`entity-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`entity-title`,children:c.Title||`-`}),(0,H.jsxs)(`div`,{className:`entity-subtitle`,children:[nt(c.Username)||n(`account.noUsername`),` · `,n(`channel.creator`,{id:c.CreatorUserID})]})]}),(0,H.jsxs)(`div`,{className:`entity-badges`,children:[(0,H.jsx)(K,{children:it(c,n)}),c.Verified?(0,H.jsx)(K,{tone:`good`,children:n(`common.verified`)}):(0,H.jsx)(K,{children:n(`account.notVerified`)}),(0,H.jsx)(St,{scam:c.Scam,fake:c.Fake}),c.Deleted?(0,H.jsx)(K,{tone:`danger`,children:n(`common.deleted`)}):(0,H.jsx)(K,{children:n(`common.valid`)})]})]}),(0,H.jsxs)(`div`,{className:`summary-grid`,children:[(0,H.jsx)(J,{label:n(`channel.channelID`),value:String(c.ID),mono:!0}),(0,H.jsx)(J,{label:`access_hash`,value:String(c.AccessHash),mono:!0}),(0,H.jsx)(J,{label:n(`common.members`),value:`${c.ParticipantsCount} / ${n(`common.admins`)} ${c.AdminsCount}`}),(0,H.jsx)(J,{label:n(`channel.governance`),value:n(`channel.governanceValue`,{banned:c.BannedCount,kicked:c.KickedCount})}),(0,H.jsx)(J,{label:n(`channel.flags`),value:`broadcast=${c.Broadcast} megagroup=${c.Megagroup} forum=${c.Forum}`}),(0,H.jsx)(J,{label:`top / pinned / PTS`,value:`${c.TopMessageID} / ${c.PinnedMessageID} / ${c.PTS}`}),(0,H.jsx)(J,{label:n(`account.createdAt`),value:ot(c.Date)||`-`}),(0,H.jsx)(J,{label:n(`common.updatedAt`),value:at(c.UpdatedAt)||`-`})]}),c.About&&(0,H.jsx)(`p`,{className:`about-text`,children:c.About}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:n(`account.recentAdminOps`),text:n(`account.recent30Audit`)}),(0,H.jsx)(ht,{rows:r.AuditLogs})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:n(`channel.rawRow`),text:n(`channel.rawRowText`)}),(0,H.jsx)(vt,{value:r.ChannelJSON})]})]}),side:(0,H.jsxs)(`section`,{className:`action-dock`,children:[(0,H.jsx)(`div`,{className:`dock-title`,children:n(`channel.actionDock`)}),(0,H.jsx)(Y,{label:c.Verified?n(`channel.clearVerified`):n(`channel.setVerified`),icon:(0,H.jsx)(D,{size:15}),tone:`warn`,path:`/api/actions/set-channel-verified`,payload:()=>({channel_id:c.ID,verified:!c.Verified}),onDone:s}),(0,H.jsx)(Ct,{idKey:`channel_id`,id:c.ID,path:`/api/actions/set-channel-flags`,scam:c.Scam,fake:c.Fake,onDone:s}),(0,H.jsx)(`div`,{className:`dock-title`,children:n(`attr.settings`)}),(0,H.jsx)(Ot,{channel:c,onDone:s}),(0,H.jsx)(`div`,{className:`dock-title`,children:n(`attr.attributes`)}),(0,H.jsx)(Tt,{idKey:`channel_id`,id:c.ID,path:`/api/actions/set-channel-username`,current:c.Username,onDone:s}),(0,H.jsx)(Et,{idKey:`channel_id`,id:c.ID,path:`/api/actions/set-channel-color`,onDone:s}),(0,H.jsx)(Dt,{idKey:`channel_id`,id:c.ID,path:`/api/actions/set-channel-emoji-status`,onDone:s})]})})})}function Bt({navigate:e}){let{t}=U(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(`50`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({beforeID:0,beforeUpdatedUS:0}),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``);async function m(e=!1){d(!0),p(``);let t=new URLSearchParams({limit:i});n.trim()?t.set(`q`,n.trim()):e&&(t.set(`before_id`,String(c.beforeID)),t.set(`before_updated_us`,String(c.beforeUpdatedUS)));try{let e=await x.channels(t);s(e),l({beforeID:e.next_before_id,beforeUpdatedUS:e.next_before_updated_us})}catch(e){p(b(e))}finally{d(!1)}}(0,g.useEffect)(()=>{m(!1)},[]);let h=It(o?.rows??[]);return(0,H.jsxs)(lt,{title:t(`channel.pageTitle`),eyebrow:o?.listing===!1?t(`account.queryResults`):t(`channel.recentUpdated`),actions:(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>m(!1),disabled:u,children:[(0,H.jsx)(be,{size:15}),` `,t(`common.refresh`)]}),children:[f&&(0,H.jsx)(pt,{children:f}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`channel.currentPage`),value:String(o?.rows.length??0)}),(0,H.jsx)(q,{label:t(`channel.megagroups`),value:String(h.megagroups)}),(0,H.jsx)(q,{label:t(`channel.broadcasts`),value:String(h.broadcasts)}),(0,H.jsx)(q,{label:t(`channel.verifiedCount`),value:String(h.verified),tone:`good`})]}),(0,H.jsx)(ut,{children:(0,H.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),m(!1)},children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:t(`channel.searchPlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`field-inline`,children:[(0,H.jsx)(`span`,{children:t(`common.limit`)}),(0,H.jsx)(`input`,{className:`small-input`,value:i,onChange:e=>a(e.target.value),type:`number`,min:`1`,max:`100`})]}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:u,children:[u?(0,H.jsx)(A,{size:15,className:`spin`}):(0,H.jsx)(xe,{size:15}),` `,t(`common.search`)]}),o?.listing&&o.has_more&&(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>m(!0),disabled:u,children:[(0,H.jsx)(te,{size:15}),` `,t(`messages.nextPage`)]})]})}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`channel.channelID`)}),(0,H.jsx)(`th`,{children:t(`channel.kind`)}),(0,H.jsx)(`th`,{children:t(`common.username`)}),(0,H.jsx)(`th`,{children:t(`channel.title`)}),(0,H.jsx)(`th`,{children:t(`common.members`)}),(0,H.jsx)(`th`,{children:t(`common.admins`)}),(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:t(`common.verified`)}),(0,H.jsx)(`th`,{children:t(`common.updatedAt`)}),(0,H.jsx)(`th`,{})]})}),(0,H.jsxs)(`tbody`,{children:[o?.rows.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`mono`,children:n.ID}),(0,H.jsx)(`td`,{children:it(n,t)}),(0,H.jsx)(`td`,{children:nt(n.Username)}),(0,H.jsx)(`td`,{children:n.Title}),(0,H.jsx)(`td`,{children:n.ParticipantsCount}),(0,H.jsx)(`td`,{children:n.AdminsCount}),(0,H.jsx)(`td`,{children:n.PTS}),(0,H.jsxs)(`td`,{children:[n.Verified?(0,H.jsx)(K,{tone:`good`,children:t(`common.verified`)}):(0,H.jsx)(K,{children:t(`account.notVerified`)}),` `,(0,H.jsx)(St,{scam:n.Scam,fake:n.Fake})]}),(0,H.jsx)(`td`,{children:at(n.UpdatedAt)}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/channels/${n.ID}`),children:[t(`common.detail`),` `,(0,H.jsx)(te,{size:14})]})})]},n.ID)),(!o||o.rows.length===0)&&(0,H.jsx)(gt,{colSpan:10})]})]})})]})}function Vt({id:e,navigate:t}){let{t:n}=U(),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(!1);async function l(){c(!0),o(``);try{i(await x.bot(e))}catch(e){o(b(e))}finally{c(!1)}}if((0,g.useEffect)(()=>{l()},[e]),a)return(0,H.jsx)(pt,{children:a});if(!r)return(0,H.jsx)(_t,{label:n(s?`bots.loadingDetail`:`account.waitingData`)});let u=r.Bot;return(0,H.jsx)(lt,{title:n(`bots.detailTitle`,{id:u.ID}),eyebrow:n(`bots.profile`),actions:(0,H.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>t(`/bots`),children:[(0,H.jsx)(N,{size:15}),` `,n(`common.backToList`)]}),children:(0,H.jsx)(dt,{main:(0,H.jsxs)(`div`,{className:`stacked-sections`,children:[(0,H.jsxs)(`section`,{className:`entity-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`entity-title`,children:u.FirstName||n(`bots.unnamed`)}),(0,H.jsx)(`div`,{className:`entity-subtitle`,children:nt(u.Username)||n(`account.noUsername`)})]}),(0,H.jsxs)(`div`,{className:`entity-badges`,children:[(0,H.jsx)(K,{tone:u.System?`warn`:`neutral`,children:u.System?n(`bots.system`):n(`bots.user`)}),u.Verified?(0,H.jsx)(K,{tone:`good`,children:n(`common.verified`)}):(0,H.jsx)(K,{children:n(`account.notVerified`)}),(0,H.jsx)(St,{scam:u.Scam,fake:u.Fake})]})]}),(0,H.jsxs)(`div`,{className:`summary-grid`,children:[(0,H.jsx)(J,{label:n(`bots.botID`),value:String(u.ID),mono:!0}),(0,H.jsx)(J,{label:n(`bots.owner`),value:u.OwnerUserID>0?`${u.OwnerUserID} ${nt(r.OwnerUsername)}`.trim():n(`common.none`)}),(0,H.jsx)(J,{label:n(`bots.type`),value:u.System?n(`bots.system`):n(`bots.user`)}),(0,H.jsx)(J,{label:n(`common.updatedAt`),value:at(u.UpdatedAt)||`-`}),(0,H.jsx)(J,{label:n(`account.createdAt`),value:at(u.CreatedAt)||`-`})]}),r.About&&(0,H.jsx)(`p`,{className:`about-text`,children:r.About}),r.Description&&r.Description.trim()!==r.About.trim()&&(0,H.jsx)(`p`,{className:`about-text`,children:r.Description}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:n(`account.recentAdminOps`),text:n(`account.recent30Audit`)}),(0,H.jsx)(ht,{rows:r.AuditLogs})]})]}),side:(0,H.jsxs)(`section`,{className:`action-dock`,children:[(0,H.jsx)(`div`,{className:`dock-title`,children:n(`bots.actionDock`)}),(0,H.jsx)(`div`,{className:`action-stack`,children:(0,H.jsx)(Y,{label:u.Verified?n(`account.clearVerified`):n(`account.setVerified`),icon:(0,H.jsx)(D,{size:15}),tone:`neutral`,path:`/api/actions/set-verified`,payload:()=>({user_id:u.ID,verified:!u.Verified}),onDone:l})}),(0,H.jsx)(Ct,{idKey:`user_id`,id:u.ID,path:`/api/actions/set-account-flags`,scam:u.Scam,fake:u.Fake,onDone:l}),(0,H.jsx)(`div`,{className:`dock-title`,children:n(`attr.attributes`)}),(0,H.jsx)(Tt,{idKey:`user_id`,id:u.ID,path:`/api/actions/set-account-username`,current:u.Username,onDone:l}),(0,H.jsx)(Et,{idKey:`user_id`,id:u.ID,path:`/api/actions/set-account-color`,onDone:l}),(0,H.jsx)(Dt,{idKey:`user_id`,id:u.ID,path:`/api/actions/set-account-emoji-status`,onDone:l}),u.System?(0,H.jsx)(`p`,{className:`bot-create-note`,children:n(`bots.systemHint`)}):(0,H.jsxs)(`div`,{className:`danger-zone`,children:[(0,H.jsx)(Y,{label:n(`bots.delete`),icon:(0,H.jsx)(Ae,{size:15}),tone:`danger`,path:`/api/actions/delete-bot`,payload:()=>({bot_user_id:u.ID}),onDone:()=>t(`/bots`)}),(0,H.jsx)(`p`,{className:`bot-create-note`,children:n(`bots.deleteHint`)})]})]})})})}function Ht({navigate:e}){let{t}=U(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(`50`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(0),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,S]=(0,g.useState)(``);async function C(e=!1){d(!0),p(``);let t=new URLSearchParams({limit:i});n.trim()?t.set(`q`,n.trim()):e&&t.set(`before_id`,String(c));try{let e=await x.bots(t);s(e),l(e.next_before_id)}catch(e){p(b(e))}finally{d(!1)}}(0,g.useEffect)(()=>{C(!1)},[]);let w=o?.rows??[],T=w.filter(e=>e.Verified).length,E=w.filter(e=>e.System).length;return(0,H.jsxs)(lt,{title:t(`bots.pageTitle`),eyebrow:o?.listing===!1?t(`bots.queryResults`):t(`bots.recent`),actions:(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>C(!1),disabled:u,children:[(0,H.jsx)(be,{size:15}),` `,t(`common.refresh`)]}),children:[f&&(0,H.jsx)(pt,{children:f}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`bots.currentPage`),value:String(w.length)}),(0,H.jsx)(q,{label:t(`common.verified`),value:String(T),tone:`good`}),(0,H.jsx)(q,{label:t(`bots.system`),value:String(E)})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(`div`,{className:`section-head`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{children:t(`bots.createTitle`)}),(0,H.jsx)(`p`,{children:t(`bots.createHint`)})]})}),(0,H.jsxs)(`div`,{className:`bot-create-fields`,children:[(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:t(`bots.ownerUserID`)}),(0,H.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),type:`number`,min:`1`,placeholder:`123456789`})]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:t(`bots.name`)}),(0,H.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:t(`bots.namePlaceholder`),maxLength:64})]}),(0,H.jsxs)(`label`,{className:`duration-field`,children:[(0,H.jsx)(`span`,{children:t(`bots.username`)}),(0,H.jsx)(`input`,{value:y,onChange:e=>S(e.target.value),placeholder:`my_service_bot`})]})]}),(0,H.jsxs)(`div`,{className:`bot-create-actions`,children:[(0,H.jsx)(`span`,{className:`bot-create-note`,children:t(`bots.usernameHint`)}),(0,H.jsx)(Y,{label:t(`bots.create`),icon:(0,H.jsx)(ye,{size:15}),tone:`neutral`,path:`/api/actions/create-bot`,payload:()=>({owner_user_id:st(m),name:_.trim(),username:y.trim().replace(/^@/,``)}),onDone:()=>C(!1)})]})]}),(0,H.jsx)(ut,{children:(0,H.jsxs)(`form`,{className:`toolbar`,onSubmit:e=>{e.preventDefault(),C(!1)},children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:t(`bots.searchPlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`field-inline`,children:[(0,H.jsx)(`span`,{children:t(`common.limit`)}),(0,H.jsx)(`input`,{className:`small-input`,value:i,onChange:e=>a(e.target.value),type:`number`,min:`1`,max:`100`})]}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,disabled:u,children:[u?(0,H.jsx)(A,{size:15,className:`spin`}):(0,H.jsx)(xe,{size:15}),` `,t(`common.search`)]}),o?.listing&&o.has_more&&(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>C(!0),disabled:u,children:[(0,H.jsx)(te,{size:15}),` `,t(`messages.nextPage`)]})]})}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`bots.botID`)}),(0,H.jsx)(`th`,{children:t(`common.username`)}),(0,H.jsx)(`th`,{children:t(`common.name`)}),(0,H.jsx)(`th`,{children:t(`bots.owner`)}),(0,H.jsx)(`th`,{children:t(`common.verified`)}),(0,H.jsx)(`th`,{children:t(`bots.type`)}),(0,H.jsx)(`th`,{children:t(`account.createdAt`)}),(0,H.jsx)(`th`,{})]})}),(0,H.jsxs)(`tbody`,{children:[w.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`mono`,children:n.ID}),(0,H.jsx)(`td`,{children:nt(n.Username)||`-`}),(0,H.jsx)(`td`,{children:n.FirstName||`-`}),(0,H.jsx)(`td`,{className:`mono`,children:n.OwnerUserID>0?n.OwnerUserID:`-`}),(0,H.jsxs)(`td`,{children:[n.Verified?(0,H.jsxs)(K,{tone:`good`,children:[(0,H.jsx)(D,{size:12}),` `,t(`common.verified`)]}):(0,H.jsx)(K,{children:t(`account.notVerified`)}),` `,(0,H.jsx)(St,{scam:n.Scam,fake:n.Fake})]}),(0,H.jsx)(`td`,{children:n.System?(0,H.jsx)(K,{tone:`warn`,children:t(`bots.system`)}):(0,H.jsx)(K,{children:t(`bots.user`)})}),(0,H.jsx)(`td`,{children:at(n.CreatedAt)}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/bots/${n.ID}`),children:[(0,H.jsx)(F,{size:14}),` `,t(`common.detail`),` `,(0,H.jsx)(te,{size:14})]})})]},n.ID)),w.length===0&&(0,H.jsx)(gt,{colSpan:8})]})]})})]})}function Ut({navigate:e}){let{t}=U();return(0,H.jsxs)(`div`,{className:`dashboard-layout`,children:[(0,H.jsxs)(`section`,{className:`overview-band`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:t(`dashboard.eyebrow`)}),(0,H.jsx)(`h2`,{children:t(`dashboard.title`)})]}),(0,H.jsxs)(`div`,{className:`overview-metrics`,children:[(0,H.jsx)(mt,{label:t(`dashboard.readPath`),value:t(`dashboard.readPathValue`),tone:`neutral`}),(0,H.jsx)(mt,{label:t(`dashboard.writePath`),value:`Admin API`,tone:`good`}),(0,H.jsx)(mt,{label:t(`dashboard.executionPolicy`),value:t(`dashboard.dryRunFirst`),tone:`warn`})]})]}),(0,H.jsxs)(`div`,{className:`command-grid`,children:[(0,H.jsx)(Wt,{icon:(0,H.jsx)(Ne,{}),title:t(`route.accounts`),text:t(`dashboard.accountsText`),href:`/accounts`,navigate:e}),(0,H.jsx)(Wt,{icon:(0,H.jsx)(we,{}),title:t(`route.channels`),text:t(`dashboard.channelsText`),href:`/channels`,navigate:e}),(0,H.jsx)(Wt,{icon:(0,H.jsx)(me,{}),title:t(`route.messages`),text:t(`dashboard.messagesText`),href:`/messages`,navigate:e})]}),(0,H.jsxs)(`section`,{className:`work-strip`,children:[(0,H.jsxs)(`div`,{className:`strip-item`,children:[(0,H.jsx)(k,{size:16}),(0,H.jsx)(`span`,{children:t(`dashboard.strip.dryRun`)})]}),(0,H.jsxs)(`div`,{className:`strip-item`,children:[(0,H.jsx)(z,{size:16}),(0,H.jsx)(`span`,{children:t(`dashboard.strip.token`)})]}),(0,H.jsxs)(`div`,{className:`strip-item`,children:[(0,H.jsx)(ne,{size:16}),(0,H.jsx)(`span`,{children:t(`dashboard.strip.pagination`)})]}),(0,H.jsxs)(`div`,{className:`strip-item`,children:[(0,H.jsx)(oe,{size:16}),(0,H.jsx)(`span`,{children:t(`dashboard.strip.snapshot`)})]})]})]})}function Wt({icon:e,title:t,text:n,href:r,navigate:i}){return(0,H.jsxs)(Ze,{className:`launcher`,href:r,navigate:i,children:[(0,H.jsx)(`span`,{className:`launcher-icon`,children:e}),(0,H.jsxs)(`span`,{className:`launcher-copy`,children:[(0,H.jsx)(`strong`,{children:t}),(0,H.jsx)(`span`,{children:n})]}),(0,H.jsx)(te,{size:16})]})}function Gt({channelID:e,msgID:t,navigate:n}){let{t:r}=U(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``);async function c(){s(``);try{a(await x.groupMessage(e,t))}catch(e){s(b(e))}}if((0,g.useEffect)(()=>{c()},[e,t]),o)return(0,H.jsx)(pt,{children:o});if(!i)return(0,H.jsx)(_t,{label:r(`common.loading`)});let l=i.Message;return(0,H.jsx)(lt,{title:r(`messages.groupDetailTitle`,{id:l.ID}),eyebrow:r(`messages.detailEyebrow`),actions:(0,H.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>n(`/messages/groups`),children:[(0,H.jsx)(N,{size:15}),` `,r(`messages.backGroup`)]}),children:(0,H.jsxs)(`div`,{className:`stacked-sections`,children:[(0,H.jsxs)(`section`,{className:`entity-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`entity-title`,children:r(`messages.channelGroupTitle`,{id:l.ChannelID})}),(0,H.jsx)(`div`,{className:`entity-subtitle`,children:r(`messages.senderSubtitle`,{sender:l.SenderUserID,date:ot(l.Date)})})]}),(0,H.jsxs)(`div`,{className:`entity-badges`,children:[l.Deleted?(0,H.jsx)(K,{tone:`danger`,children:r(`common.deleted`)}):(0,H.jsx)(K,{children:r(`common.survived`)}),l.Pinned&&(0,H.jsx)(K,{tone:`warn`,children:r(`messages.pinned`)}),l.Post&&(0,H.jsx)(K,{children:r(`messages.channelPost`)}),(0,H.jsxs)(K,{children:[`pts `,l.PTS]})]})]}),(0,H.jsxs)(`div`,{className:`summary-grid`,children:[(0,H.jsx)(J,{label:r(`common.messageId`),value:String(l.ID),mono:!0}),(0,H.jsx)(J,{label:r(`messages.channelGroup`),value:String(l.ChannelID),mono:!0}),(0,H.jsx)(J,{label:`From Peer`,value:`${l.FromPeerType}:${l.FromPeerID}`,mono:!0}),(0,H.jsx)(J,{label:r(`common.views`),value:String(l.ViewsCount)})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.channelMessageRow`),text:r(`messages.channelMessagesSnapshot`)}),(0,H.jsx)(vt,{value:i.MessageJSON})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.channelRow`),text:r(`messages.channelSnapshot`)}),(0,H.jsx)(vt,{value:i.ChannelJSON})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.channelUpdateEvents`),text:r(`messages.channelEventsSource`)}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:r(`common.count`)}),(0,H.jsx)(`th`,{children:r(`common.type`)}),(0,H.jsx)(`th`,{children:r(`common.messageId`)}),(0,H.jsx)(`th`,{children:r(`common.sender`)}),(0,H.jsx)(`th`,{children:r(`common.time`)})]})}),(0,H.jsxs)(`tbody`,{children:[i.UpdateEvents.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{children:e.PTS}),(0,H.jsx)(`td`,{children:e.PTSCount}),(0,H.jsx)(`td`,{children:e.Type}),(0,H.jsx)(`td`,{children:e.MessageID}),(0,H.jsx)(`td`,{children:e.SenderUserID}),(0,H.jsx)(`td`,{children:ot(e.Date)})]},`${e.PTS}-${e.Type}-${e.MessageID}`)),i.UpdateEvents.length===0&&(0,H.jsx)(gt,{colSpan:6})]})]})})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.eventJson`)}),(0,H.jsxs)(`div`,{className:`raw-grid`,children:[i.UpdateEvents.map(e=>(0,H.jsx)(vt,{value:e.JSON},`${e.PTS}-${e.Type}-json`)),i.UpdateEvents.length===0&&(0,H.jsx)(`div`,{className:`empty-panel`,children:r(`common.noResults`)})]})]})]})})}function Kt({label:e,value:t,onChange:n}){let{t:r}=U(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(``);async function f(){l(!0),d(``);let e=new URLSearchParams({limit:`20`});i.trim()&&e.set(`q`,i.trim());try{s((await x.accounts(e)).rows)}catch(e){d(b(e))}finally{l(!1)}}return(0,g.useEffect)(()=>{f()},[]),(0,H.jsxs)(`div`,{className:`entity-picker`,children:[(0,H.jsxs)(`div`,{className:`picker-head`,children:[(0,H.jsx)(`span`,{children:e}),t?(0,H.jsxs)(`button`,{className:`link-button`,type:`button`,onClick:()=>n(null),children:[(0,H.jsx)(Pe,{size:13}),` `,r(`common.clear`)]}):null]}),t?(0,H.jsxs)(`div`,{className:`selected-entity`,children:[(0,H.jsx)(L,{size:15}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:rt(t)}),(0,H.jsx)(`span`,{className:`mono`,children:t.ID})]}),(0,H.jsx)(`span`,{children:nt(t.Username)||tt(t.Phone)||`-`})]}):null,(0,H.jsxs)(`div`,{className:`picker-search`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())},placeholder:r(`picker.userPlaceholder`)}),(0,H.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:f,disabled:c,children:c?(0,H.jsx)(A,{size:14,className:`spin`}):r(`common.search`)})]}),u&&(0,H.jsx)(`div`,{className:`picker-error`,children:u}),(0,H.jsxs)(`div`,{className:`picker-results`,children:[o.map(e=>(0,H.jsxs)(`button`,{className:`picker-row ${t?.ID===e.ID?`selected`:``}`,type:`button`,onClick:()=>n(e),children:[(0,H.jsx)(`span`,{className:`mono`,children:e.ID}),(0,H.jsx)(`strong`,{children:rt(e)}),(0,H.jsx)(`span`,{children:nt(e.Username)||tt(e.Phone)||`-`}),e.Verified?(0,H.jsx)(K,{tone:`good`,children:r(`picker.verified`)}):(0,H.jsx)(K,{children:r(`picker.regular`)})]},e.ID)),o.length===0&&!c?(0,H.jsx)(`div`,{className:`picker-empty`,children:r(`common.noResults`)}):null]})]})}function qt({label:e,value:t,onChange:n}){let{t:r}=U(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(``);async function f(){l(!0),d(``);let e=new URLSearchParams({limit:`20`});i.trim()&&e.set(`q`,i.trim());try{s((await x.channels(e)).rows)}catch(e){d(b(e))}finally{l(!1)}}return(0,g.useEffect)(()=>{f()},[]),(0,H.jsxs)(`div`,{className:`entity-picker`,children:[(0,H.jsxs)(`div`,{className:`picker-head`,children:[(0,H.jsx)(`span`,{children:e}),t?(0,H.jsxs)(`button`,{className:`link-button`,type:`button`,onClick:()=>n(null),children:[(0,H.jsx)(Pe,{size:13}),` `,r(`common.clear`)]}):null]}),t?(0,H.jsxs)(`div`,{className:`selected-entity`,children:[(0,H.jsx)(L,{size:15}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:t.Title||`-`}),(0,H.jsx)(`span`,{className:`mono`,children:t.ID})]}),(0,H.jsx)(`span`,{children:nt(t.Username)||it(t,r)})]}):null,(0,H.jsxs)(`div`,{className:`picker-search`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())},placeholder:r(`picker.channelPlaceholder`)}),(0,H.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:f,disabled:c,children:c?(0,H.jsx)(A,{size:14,className:`spin`}):r(`common.search`)})]}),u&&(0,H.jsx)(`div`,{className:`picker-error`,children:u}),(0,H.jsxs)(`div`,{className:`picker-results`,children:[o.map(e=>(0,H.jsxs)(`button`,{className:`picker-row ${t?.ID===e.ID?`selected`:``}`,type:`button`,onClick:()=>n(e),children:[(0,H.jsx)(`span`,{className:`mono`,children:e.ID}),(0,H.jsx)(`strong`,{children:e.Title||`-`}),(0,H.jsx)(`span`,{children:nt(e.Username)||it(e,r)}),e.Verified?(0,H.jsx)(K,{tone:`good`,children:r(`picker.verified`)}):(0,H.jsx)(K,{children:it(e,r)})]},e.ID)),o.length===0&&!c?(0,H.jsx)(`div`,{className:`picker-empty`,children:r(`common.noResults`)}):null]})]})}function Jt({navigate:e}){let{t}=U(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(`100`),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(``);async function m(e=!1){if(p(``),!n){p(t(`messages.selectChannel`));return}let r=new URLSearchParams({channel_id:String(n.ID),limit:c});if(e&&u?.rows.length){let e=u.rows[u.rows.length-1];r.set(`before_date`,String(e.Date)),r.set(`before_id`,String(e.ID)),a(String(e.Date)),s(String(e.ID))}else i&&r.set(`before_date`,i),o&&r.set(`before_id`,o);try{d(await x.groupMessages(r))}catch(e){p(b(e))}}function h(e){r(e),a(``),s(``),d(null)}let _=u?.rows??[];return(0,H.jsxs)(lt,{title:t(`messages.groupTitle`),eyebrow:t(`messages.groupEyebrow`),children:[f&&(0,H.jsx)(pt,{children:f}),(0,H.jsxs)(ut,{children:[(0,H.jsx)(`div`,{className:`message-selector-grid single`,children:(0,H.jsx)(qt,{label:t(`messages.channelGroup`),value:n,onChange:h})}),(0,H.jsxs)(`form`,{className:`toolbar message-query`,onSubmit:e=>{e.preventDefault(),m(!1)},children:[(0,H.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:t(`messages.beforeDatePlaceholder`)}),(0,H.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:t(`messages.beforeIDPlaceholder`)}),(0,H.jsx)(`input`,{className:`small-input`,value:c,onChange:e=>l(e.target.value),placeholder:t(`messages.limitPlaceholder`)}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,children:[(0,H.jsx)(xe,{size:15}),` `,t(`messages.searchMessages`)]}),_.length?(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>m(!0),children:[(0,H.jsx)(te,{size:15}),` `,t(`messages.nextPage`)]}):null]})]}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`messages.currentPage`),value:String(_.length)}),(0,H.jsx)(q,{label:t(`messages.mediaCount`),value:String(_.filter(e=>e.Media&&e.Media!==`{}`).length)}),(0,H.jsx)(q,{label:t(`messages.channelPosts`),value:String(_.filter(e=>e.Post).length)}),(0,H.jsx)(q,{label:t(`messages.channelGroup`),value:n?`${n.Title||it(n,t)} (${n.ID})`:`-`})]}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`common.messageId`)}),(0,H.jsx)(`th`,{children:t(`common.time`)}),(0,H.jsx)(`th`,{children:t(`common.sender`)}),(0,H.jsx)(`th`,{children:`From Peer`}),(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:t(`common.views`)}),(0,H.jsx)(`th`,{children:t(`common.status`)}),(0,H.jsx)(`th`,{children:t(`messages.body`)}),(0,H.jsx)(`th`,{})]})}),(0,H.jsxs)(`tbody`,{children:[_.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`mono`,children:n.ID}),(0,H.jsx)(`td`,{children:ot(n.Date)}),(0,H.jsx)(`td`,{className:`mono`,children:n.SenderUserID}),(0,H.jsxs)(`td`,{className:`mono`,children:[n.FromPeerType,`:`,n.FromPeerID]}),(0,H.jsx)(`td`,{children:n.PTS}),(0,H.jsx)(`td`,{children:n.ViewsCount}),(0,H.jsx)(`td`,{children:n.Deleted?(0,H.jsx)(K,{tone:`danger`,children:t(`common.deleted`)}):n.Pinned?(0,H.jsx)(K,{tone:`warn`,children:t(`messages.pinned`)}):(0,H.jsx)(K,{children:t(`common.survived`)})}),(0,H.jsx)(`td`,{className:`truncate`,children:n.Body}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/messages/groups/detail?channel_id=${n.ChannelID}&msg_id=${n.ID}`),children:[t(`common.detail`),` `,(0,H.jsx)(te,{size:14})]})})]},`${n.ChannelID}-${n.ID}`)),_.length===0&&(0,H.jsx)(gt,{colSpan:9})]})]})})]})}function Yt({ownerUserID:e,msgID:t,navigate:n}){let{t:r}=U(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``);async function c(){s(``);try{a(await x.message(e,t))}catch(e){s(b(e))}}if((0,g.useEffect)(()=>{c()},[e,t]),o)return(0,H.jsx)(pt,{children:o});if(!i)return(0,H.jsx)(_t,{label:r(`common.loading`)});let l=i.Message;return(0,H.jsx)(lt,{title:r(`messages.privateDetailTitle`,{id:l.BoxID}),eyebrow:r(`messages.detailEyebrow`),actions:(0,H.jsxs)(`button`,{className:`btn icon-text`,onClick:()=>n(`/messages/private`),children:[(0,H.jsx)(N,{size:15}),` `,r(`messages.backPrivate`)]}),children:(0,H.jsx)(dt,{main:(0,H.jsxs)(`div`,{className:`stacked-sections`,children:[(0,H.jsxs)(`section`,{className:`entity-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`entity-title`,children:r(`messages.ownerPeerTitle`,{owner:l.OwnerUserID,peer:l.PeerID})}),(0,H.jsx)(`div`,{className:`entity-subtitle`,children:r(`messages.senderSubtitle`,{sender:l.FromUserID,date:ot(l.Date)})})]}),(0,H.jsxs)(`div`,{className:`entity-badges`,children:[l.Deleted?(0,H.jsx)(K,{tone:`danger`,children:r(`common.deleted`)}):(0,H.jsx)(K,{children:r(`common.survived`)}),(0,H.jsxs)(K,{children:[`pts `,l.PTS]}),(0,H.jsx)(K,{children:l.Outgoing?r(`messages.outgoing`):r(`messages.incoming`)})]})]}),(0,H.jsxs)(`div`,{className:`summary-grid`,children:[(0,H.jsx)(J,{label:r(`messages.boxID`),value:String(l.BoxID),mono:!0}),(0,H.jsx)(J,{label:r(`messages.privateMessageID`),value:String(l.PrivateMessageID),mono:!0}),(0,H.jsx)(J,{label:r(`messages.messageSender`),value:String(l.MessageSenderID),mono:!0}),(0,H.jsx)(J,{label:r(`common.time`),value:ot(l.Date)})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.messageBox`),text:r(`messages.messageBoxesSnapshot`)}),(0,H.jsx)(vt,{value:i.MessageJSON})]}),(0,H.jsxs)(`div`,{className:`raw-grid`,children:[(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.dialogRow`),text:r(`messages.dialogSnapshot`)}),(0,H.jsx)(vt,{value:i.DialogJSON})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.privateRow`),text:r(`messages.privateSnapshot`)}),(0,H.jsx)(vt,{value:i.PrivateJSON})]})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.userUpdateEvents`),text:r(`messages.userEventsSource`)}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:r(`common.count`)}),(0,H.jsx)(`th`,{children:r(`common.type`)}),(0,H.jsx)(`th`,{children:r(`common.time`)})]})}),(0,H.jsxs)(`tbody`,{children:[i.UpdateEvents.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{children:e.PTS}),(0,H.jsx)(`td`,{children:e.PTSCount}),(0,H.jsx)(`td`,{children:e.Type}),(0,H.jsx)(`td`,{children:ot(e.Date)})]},`${e.PTS}-${e.Type}`)),i.UpdateEvents.length===0&&(0,H.jsx)(gt,{colSpan:4})]})]})})]}),(0,H.jsxs)(`section`,{className:`section-block`,children:[(0,H.jsx)(ft,{title:r(`messages.dispatchOutbox`),text:r(`messages.outboxSource`)}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:`ID`}),(0,H.jsx)(`th`,{children:r(`account.userID`)}),(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:r(`common.type`)}),(0,H.jsx)(`th`,{children:r(`common.status`)}),(0,H.jsx)(`th`,{children:r(`messages.attempts`)}),(0,H.jsx)(`th`,{children:r(`common.updatedAt`)})]})}),(0,H.jsxs)(`tbody`,{children:[i.Outbox.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{children:e.ID}),(0,H.jsx)(`td`,{children:e.TargetUserID}),(0,H.jsx)(`td`,{children:e.PTS}),(0,H.jsx)(`td`,{children:e.EventType}),(0,H.jsx)(`td`,{children:e.Status}),(0,H.jsx)(`td`,{children:e.Attempts}),(0,H.jsx)(`td`,{children:at(e.UpdatedAt)})]},e.ID)),i.Outbox.length===0&&(0,H.jsx)(gt,{colSpan:7})]})]})})]})]}),side:(0,H.jsxs)(`section`,{className:`action-dock`,children:[(0,H.jsx)(`div`,{className:`dock-title`,children:r(`common.operations`)}),(0,H.jsx)(Y,{label:r(`messages.deleteThis`),icon:(0,H.jsx)(Ae,{size:15}),path:`/api/actions/delete-messages`,payload:()=>({owner_user_id:l.OwnerUserID,peer_id:l.PeerID,ids:[l.BoxID],revoke:!0}),onDone:c})]})})})}function Xt({navigate:e}){let{t}=U(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(`100`),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(!0),[_,v]=(0,g.useState)(!1),[y,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(`1`),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(``);async function k(e=!1){if(O(``),!n||!i){O(t(`messages.selectPrivatePeers`));return}let r=new URLSearchParams({owner_user_id:String(n.ID),peer_id:String(i.ID),limit:u});if(e&&T?.rows.length){let e=T.rows[T.rows.length-1];r.set(`before_date`,String(e.Date)),r.set(`before_id`,String(e.BoxID)),s(String(e.Date)),l(String(e.BoxID))}else o&&r.set(`before_date`,o),c&&r.set(`before_id`,c);try{E(await x.messages(r))}catch(e){O(b(e))}}function A(e){r(e),s(``),l(``),E(null)}function j(e){a(e),s(``),l(``),E(null)}return(0,H.jsxs)(lt,{title:t(`messages.privateTitle`),eyebrow:t(`messages.privateEyebrow`),children:[D&&(0,H.jsx)(pt,{children:D}),(0,H.jsxs)(ut,{children:[(0,H.jsxs)(`div`,{className:`message-selector-grid`,children:[(0,H.jsx)(Kt,{label:t(`messages.ownerUser`),value:n,onChange:A}),(0,H.jsx)(Kt,{label:t(`messages.peerUser`),value:i,onChange:j})]}),(0,H.jsxs)(`form`,{className:`toolbar message-query`,onSubmit:e=>{e.preventDefault(),k(!1)},children:[(0,H.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:t(`messages.beforeDatePlaceholder`)}),(0,H.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:t(`messages.beforeIDPlaceholder`)}),(0,H.jsx)(`input`,{className:`small-input`,value:u,onChange:e=>d(e.target.value),placeholder:t(`messages.limitPlaceholder`)}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`submit`,children:[(0,H.jsx)(xe,{size:15}),` `,t(`messages.searchMessages`)]}),T?.rows.length?(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>k(!0),children:[(0,H.jsx)(te,{size:15}),` `,t(`messages.nextPage`)]}):null]})]}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`messages.currentPage`),value:String(T?.rows.length??0)}),(0,H.jsx)(q,{label:t(`messages.deleted`),value:String((T?.rows??[]).filter(e=>e.Deleted).length),tone:`danger`}),(0,H.jsx)(q,{label:t(`messages.outgoing`),value:String((T?.rows??[]).filter(e=>e.Outgoing).length)}),(0,H.jsx)(q,{label:t(`messages.ownerPeer`),value:n&&i?`${rt(n)} / ${rt(i)}`:`-`})]}),(0,H.jsxs)(`div`,{className:`operation-row`,children:[(0,H.jsxs)(`div`,{className:`operation-box`,children:[(0,H.jsxs)(`div`,{className:`operation-title`,children:[(0,H.jsx)(Ae,{size:15}),` `,t(`messages.deleteSelected`)]}),(0,H.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:t(`messages.idsPlaceholder`)}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),` `,t(`messages.revoke`)]}),(0,H.jsx)(Y,{path:`/api/actions/delete-messages`,label:t(`messages.previewDelete`),payload:()=>({owner_user_id:n?.ID??0,peer_id:i?.ID??0,ids:ct(f,t(`messages.msgIDsInvalid`)),revoke:m})})]}),(0,H.jsxs)(`div`,{className:`operation-box`,children:[(0,H.jsxs)(`div`,{className:`operation-title`,children:[(0,H.jsx)(le,{size:15}),` `,t(`messages.clearHistory`)]}),(0,H.jsx)(`input`,{value:y,onChange:e=>S(e.target.value),placeholder:t(`messages.maxIDPlaceholder`)}),(0,H.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:t(`messages.maxBatchesPlaceholder`)}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),` `,t(`messages.revoke`)]}),(0,H.jsxs)(`label`,{className:`checkline`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` `,t(`messages.justClear`)]}),(0,H.jsx)(Y,{path:`/api/actions/delete-history`,label:t(`messages.previewClearHistory`),payload:()=>({owner_user_id:n?.ID??0,peer_id:i?.ID??0,max_id:st(y),max_batches:st(C),just_clear:_,revoke:m})})]})]}),(0,H.jsx)(`div`,{className:`table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`common.messageId`)}),(0,H.jsx)(`th`,{children:t(`common.time`)}),(0,H.jsx)(`th`,{children:t(`common.sender`)}),(0,H.jsx)(`th`,{children:t(`messages.direction`)}),(0,H.jsx)(`th`,{children:`PTS`}),(0,H.jsx)(`th`,{children:t(`common.status`)}),(0,H.jsx)(`th`,{children:t(`messages.body`)}),(0,H.jsx)(`th`,{})]})}),(0,H.jsxs)(`tbody`,{children:[T?.rows.map(n=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`mono`,children:n.BoxID}),(0,H.jsx)(`td`,{children:ot(n.Date)}),(0,H.jsx)(`td`,{className:`mono`,children:n.FromUserID}),(0,H.jsx)(`td`,{children:n.Outgoing?t(`messages.outgoing`):t(`messages.incoming`)}),(0,H.jsx)(`td`,{children:n.PTS}),(0,H.jsx)(`td`,{children:n.Deleted?(0,H.jsx)(K,{tone:`danger`,children:t(`common.deleted`)}):(0,H.jsx)(K,{children:t(`common.survived`)})}),(0,H.jsx)(`td`,{className:`truncate`,children:n.Body}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`button`,{className:`row-link`,onClick:()=>e(`/messages/private/detail?owner_user_id=${n.OwnerUserID}&msg_id=${n.BoxID}`),children:[t(`common.detail`),` `,(0,H.jsx)(te,{size:14})]})})]},`${n.OwnerUserID}-${n.BoxID}`)),(!T||T.rows.length===0)&&(0,H.jsx)(gt,{colSpan:8})]})]})})]})}var Zt=c(o(((e,t)=>{typeof document<`u`&&typeof navigator<`u`&&(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.lottie=r())})(e,(function(){var n=``,r=!1,i=-999999,a=function(e){r=!!e},o=function(){return r},s=function(e){n=e},c=function(){return n};function l(e){return document.createElement(e)}function u(e,t){var n,r=e.length,i;for(n=0;n1?n[1]=1:n[1]<=0&&(n[1]=0),L(n[0],n[1],n[2])}function te(e,t){var n=ee(e[0]*255,e[1]*255,e[2]*255);return n[2]+=t,n[2]>1?n[2]=1:n[2]<0&&(n[2]=0),L(n[0],n[1],n[2])}function ne(e,t){var n=ee(e[0]*255,e[1]*255,e[2]*255);return n[0]+=t/360,n[0]>1?--n[0]:n[0]<0&&(n[0]+=1),L(n[0],n[1],n[2])}(function(){var e=[],t,n;for(t=0;t<256;t+=1)n=t.toString(16),e[t]=n.length===1?`0`+n:n;return function(t,n,r){return t<0&&(t=0),n<0&&(n=0),r<0&&(r=0),`#`+e[t]+e[n]+e[r]}})();var re=function(e){g=!!e},ie=function(){return g},ae=function(e){_=e},oe=function(){return _},se=function(){return v},ce=function(e){E=e},le=function(){return E},ue=function(e){y=e};function z(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}function de(e){"@babel/helpers - typeof";return de=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},de(e)}var fe=function(){var e=1,t=[],n,r,i={onmessage:function(){},postMessage:function(e){n({data:e})}},a={postMessage:function(e){i.onmessage({data:e})}};function s(e){if(window.Worker&&window.Blob&&o()){var t=new Blob([`var _workerSelf = self; self.onmessage = `,e.toString()],{type:`text/javascript`}),r=URL.createObjectURL(t);return new Worker(r)}return n=e,i}function c(){r||(r=s(function(e){function t(){function e(t,n){var o,s,c=t.length,l,u,d,f;for(s=0;s=0;--t)if(e[t].ty===`sh`)if(e[t].ks.k.i)a(e[t].ks.k);else for(o=e[t].ks.k.length,r=0;rn[0]?!0:n[0]>e[0]?!1:e[1]>n[1]?!0:n[1]>e[1]?!1:e[2]>n[2]?!0:n[2]>e[2]?!1:null}var s=function(){var e=[4,4,14];function t(e){var t=e.t.d;e.t.d={k:[{s:t,t:0}]}}function n(e){var n,r=e.length;for(n=0;n=0;--n)if(e[n].ty===`sh`)if(e[n].ks.k.i)e[n].ks.k.c=e[n].closed;else for(a=e[n].ks.k.length,i=0;i500)&&(this._imageLoaded(),clearInterval(n)),t+=1}.bind(this),50)}function a(t){var n=r(t,this.assetsPath,this.path),i=z(`image`);b?this.testImageLoaded(i):i.addEventListener(`load`,this._imageLoaded,!1),i.addEventListener(`error`,function(){a.img=e,this._imageLoaded()}.bind(this),!1),i.setAttributeNS(`http://www.w3.org/1999/xlink`,`href`,n),this._elementHelper.append?this._elementHelper.append(i):this._elementHelper.appendChild(i);var a={img:i,assetData:t};return a}function o(t){var n=r(t,this.assetsPath,this.path),i=l(`img`);i.crossOrigin=`anonymous`,i.addEventListener(`load`,this._imageLoaded,!1),i.addEventListener(`error`,function(){a.img=e,this._imageLoaded()}.bind(this),!1),i.src=n;var a={img:i,assetData:t};return a}function s(e){var t={assetData:e},n=r(e,this.assetsPath,this.path);return fe.loadData(n,function(e){t.img=e,this._footageLoaded()}.bind(this),function(){t.img={},this._footageLoaded()}.bind(this)),t}function c(e,t){this.imagesLoadedCb=t;var n,r=e.length;for(n=0;nthis.animationData.op&&(this.animationData.op=e.op,this.totalFrames=Math.floor(e.op-this.animationData.ip));var t=this.animationData.layers,n,r=t.length,i=e.layers,a,o=i.length;for(a=0;athis.timeCompleted&&(this.currentFrame=this.timeCompleted),this.trigger(`enterFrame`),this.renderFrame(),this.trigger(`drawnFrame`)},B.prototype.renderFrame=function(){if(!(this.isLoaded===!1||!this.renderer))try{this.expressionsPlugin&&this.expressionsPlugin.resetFrame(),this.renderer.renderFrame(this.currentFrame+this.firstFrame)}catch(e){this.triggerRenderFrameError(e)}},B.prototype.play=function(e){e&&this.name!==e||this.isPaused===!0&&(this.isPaused=!1,this.trigger(`_play`),this.audioController.resume(),this._idle&&(this._idle=!1,this.trigger(`_active`)))},B.prototype.pause=function(e){e&&this.name!==e||this.isPaused===!1&&(this.isPaused=!0,this.trigger(`_pause`),this._idle=!0,this.trigger(`_idle`),this.audioController.pause())},B.prototype.togglePause=function(e){e&&this.name!==e||(this.isPaused===!0?this.play():this.pause())},B.prototype.stop=function(e){e&&this.name!==e||(this.pause(),this.playCount=0,this._completedLoop=!1,this.setCurrentRawFrameValue(0))},B.prototype.getMarkerData=function(e){for(var t,n=0;n=this.totalFrames-1&&this.frameModifier>0?!this.loop||this.playCount===this.loop?this.checkSegments(t>this.totalFrames?t%this.totalFrames:0)||(n=!0,t=this.totalFrames-1):t>=this.totalFrames?(this.playCount+=1,this.checkSegments(t%this.totalFrames)||(this.setCurrentRawFrameValue(t%this.totalFrames),this._completedLoop=!0,this.trigger(`loopComplete`))):this.setCurrentRawFrameValue(t):t<0?this.checkSegments(t%this.totalFrames)||(this.loop&&!(this.playCount--<=0&&this.loop!==!0)?(this.setCurrentRawFrameValue(this.totalFrames+t%this.totalFrames),this._completedLoop?this.trigger(`loopComplete`):this._completedLoop=!0):(n=!0,t=0)):this.setCurrentRawFrameValue(t),n&&(this.setCurrentRawFrameValue(t),this.pause(),this.trigger(`complete`))}},B.prototype.adjustSegment=function(e,t){this.playCount=0,e[1]0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(-1)),this.totalFrames=e[0]-e[1],this.timeCompleted=this.totalFrames,this.firstFrame=e[1],this.setCurrentRawFrameValue(this.totalFrames-.001-t)):e[1]>e[0]&&(this.frameModifier<0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(1)),this.totalFrames=e[1]-e[0],this.timeCompleted=this.totalFrames,this.firstFrame=e[0],this.setCurrentRawFrameValue(.001+t)),this.trigger(`segmentStart`)},B.prototype.setSegment=function(e,t){var n=-1;this.isPaused&&(this.currentRawFrame+this.firstFramet&&(n=t-e)),this.firstFrame=e,this.totalFrames=t-e,this.timeCompleted=this.totalFrames,n!==-1&&this.goToAndStop(n,!0)},B.prototype.playSegments=function(e,t){if(t&&(this.segments.length=0),xe(e[0])===`object`){var n,r=e.length;for(n=0;n=0;--n)t[n].animation.destroy(e)}function T(e,t,n){var r=[].concat([].slice.call(document.getElementsByClassName(`lottie`)),[].slice.call(document.getElementsByClassName(`bodymovin`))),i,a=r.length;for(i=0;i0?n=c:t=c;while(Math.abs(s)>a&&++l=i?g(e,d,t,n):f===0?d:h(e,a,a+c,t,n)}},e}(),Ce=function(){function e(e){return e.concat(m(e.length))}return{double:e}}(),we=function(){return function(e,t,n){var r=0,i=e,a=m(i),o={newElement:s,release:c};function s(){var e;return r?(--r,e=a[r]):e=t(),e}function c(e){r===i&&(a=Ce.double(a),i*=2),n&&n(e),a[r]=e,r+=1}return o}}(),Te=function(){function e(){return{addedLength:0,percents:p(`float32`,le()),lengths:p(`float32`,le())}}return we(8,e)}(),Ee=function(){function e(){return{lengths:[],totalLength:0}}function t(e){var t,n=e.lengths.length;for(t=0;t-.001&&o<.001}function n(n,r,i,a,o,s,c,l,u){if(i===0&&s===0&&u===0)return t(n,r,a,o,c,l);var d=e.sqrt(e.pow(a-n,2)+e.pow(o-r,2)+e.pow(s-i,2)),f=e.sqrt(e.pow(c-n,2)+e.pow(l-r,2)+e.pow(u-i,2)),p=e.sqrt(e.pow(c-a,2)+e.pow(l-o,2)+e.pow(u-s,2)),m=d>f?d>p?d-f-p:p-f-d:p>f?p-f-d:f-d-p;return m>-1e-4&&m<1e-4}var r=function(){return function(e,t,n,r){var i=le(),a,o,s,c,l,u=0,d,f=[],p=[],m=Te.newElement();for(s=n.length,a=0;ao?-1:1,l=!0;l;)if(r[a]<=o&&r[a+1]>o?(s=(o-r[a])/(r[a+1]-r[a]),l=!1):a+=c,a<0||a>=i-1){if(a===i-1)return n[a];l=!1}return n[a]+(n[a+1]-n[a])*s}function l(t,n,r,i,a,o){var s=c(a,o),l=1-s;return[e.round((l*l*l*t[0]+(s*l*l+l*s*l+l*l*s)*r[0]+(s*s*l+l*s*s+s*l*s)*i[0]+s*s*s*n[0])*1e3)/1e3,e.round((l*l*l*t[1]+(s*l*l+l*s*l+l*l*s)*r[1]+(s*s*l+l*s*s+s*l*s)*i[1]+s*s*s*n[1])*1e3)/1e3]}var u=p(`float32`,8);function d(t,n,r,i,a,o,s){a<0?a=0:a>1&&(a=1);var l=c(a,s);o=o>1?1:o;var d=c(o,s),f,p=t.length,m=1-l,h=1-d,g=m*m*m,_=l*m*m*3,v=l*l*m*3,y=l*l*l,b=m*m*h,x=l*m*h+m*l*h+m*m*d,S=l*l*h+m*l*d+l*m*d,C=l*l*d,w=m*h*h,T=l*h*h+m*d*h+m*h*d,E=l*d*h+m*d*d+l*h*d,D=l*d*d,O=h*h*h,k=d*h*h+h*d*h+h*h*d,A=d*d*h+h*d*d+d*h*d,j=d*d*d;for(f=0;f=l.t-n){c.h&&(c=l),i=0;break}if(l.t-n>e){i=a;break}a=v||e=v?x.points.length-1:0;for(f=x.points[S].point.length,d=0;d=T&&C=v)r[0]=b[0],r[1]=b[1],r[2]=b[2];else if(e<=y)r[0]=c.s[0],r[1]=c.s[1],r[2]=c.s[2];else{var j=Pe(c.s),M=Pe(b),N=(e-y)/(v-y);Ne(r,Me(j,M,N))}else for(a=0;a=v?m=1:e1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-n)*f)/m,g=Math.sin(n*f)/m):(h=1-n,g=n),r[0]=h*i+g*c,r[1]=h*a+g*l,r[2]=h*o+g*u,r[3]=h*s+g*d,r}function Ne(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=Math.atan2(2*r*a-2*n*i,1-2*r*r-2*i*i),s=Math.asin(2*n*r+2*i*a),c=Math.atan2(2*n*a-2*r*i,1-2*n*n-2*i*i);e[0]=o/D,e[1]=s/D,e[2]=c/D}function Pe(e){var t=e[0]*D,n=e[1]*D,r=e[2]*D,i=Math.cos(t/2),a=Math.cos(n/2),o=Math.cos(r/2),s=Math.sin(t/2),c=Math.sin(n/2),l=Math.sin(r/2),u=i*a*o-s*c*l;return[s*c*o+i*a*l,s*a*o+i*c*l,i*c*o-s*a*l,u]}function Fe(){var e=this.comp.renderedFrame-this.offsetTime,t=this.keyframes[0].t-this.offsetTime,n=this.keyframes[this.keyframes.length-1].t-this.offsetTime;if(!(e===this._caching.lastFrame||this._caching.lastFrame!==ke&&(this._caching.lastFrame>=n&&e>=n||this._caching.lastFrame=e&&(this._caching._lastKeyframeIndex=-1,this._caching.lastIndex=0);var r=this.interpolateValue(e,this._caching);this.pv=r}return this._caching.lastFrame=e,this.pv}function H(e){var t;if(this.propType===`unidimensional`)t=e*this.mult,Ae(this.v-t)>1e-5&&(this.v=t,this._mdf=!0);else for(var n=0,r=this.v.length;n1e-5&&(this.v[n]=t,this._mdf=!0),n+=1}function Ie(){if(!(this.elem.globalData.frameId===this.frameId||!this.effectsSequence.length)){if(this.lock){this.setVValue(this.pv);return}this.lock=!0,this._mdf=this._isFirstFrame;var e,t=this.effectsSequence.length,n=this.kf?this.pv:this.data.k;for(e=0;e=this._maxLength&&this.doubleArrayLength(),n){case`v`:a=this.v;break;case`i`:a=this.i;break;case`o`:a=this.o;break;default:a=[];break}(!a[r]||a[r]&&!i)&&(a[r]=He.newElement()),a[r][0]=e,a[r][1]=t},Ue.prototype.setTripleAt=function(e,t,n,r,i,a,o,s){this.setXYAt(e,t,`v`,o,s),this.setXYAt(n,r,`o`,o,s),this.setXYAt(i,a,`i`,o,s)},Ue.prototype.reverse=function(){var e=new Ue;e.setPathData(this.c,this._length);var t=this.v,n=this.o,r=this.i,i=0;this.c&&(e.setTripleAt(t[0][0],t[0][1],r[0][0],r[0][1],n[0][0],n[0][1],0,!1),i=1);var a=this._length-1,o=this._length,s;for(s=i;s=p[p.length-1].t-this.offsetTime)i=p[p.length-1].s?p[p.length-1].s[0]:p[p.length-2].e[0],o=!0;else{for(var m=r,h=p.length-1,g=!0,_,v,y;g&&(_=p[m],v=p[m+1],!(v.t-this.offsetTime>e));)m=v.t-this.offsetTime)d=1;else if(e<_.t-this.offsetTime)d=0;else{var b;y.__fnct?b=y.__fnct:(b=Se.getBezierEasing(_.o.x,_.o.y,_.i.x,_.i.y).get,y.__fnct=b),d=b((e-(_.t-this.offsetTime))/(v.t-this.offsetTime-(_.t-this.offsetTime)))}a=v.s?v.s[0]:_.e[0]}i=_.s[0]}for(l=t._length,u=i.i[0].length,n.lastIndex=r,s=0;sr&&t>r)||(this._caching.lastIndex=i0||e>-1e-6&&e<0?r(e*t)/t:e}function P(){var e=this.props,t=N(e[0]),n=N(e[1]),r=N(e[4]),i=N(e[5]),a=N(e[12]),o=N(e[13]);return`matrix(`+t+`,`+n+`,`+r+`,`+i+`,`+a+`,`+o+`)`}return function(){this.reset=i,this.rotate=a,this.rotateX=o,this.rotateY=s,this.rotateZ=c,this.skew=u,this.skewFromAxis=d,this.shear=l,this.scale=f,this.setTransform=m,this.translate=h,this.transform=g,this.multiply=_,this.applyToPoint=S,this.applyToX=C,this.applyToY=w,this.applyToZ=T,this.applyToPointArray=A,this.applyToTriplePoints=k,this.applyToPointStringified=j,this.toCSS=M,this.to2dCSS=P,this.clone=b,this.cloneFromProps=x,this.equals=y,this.inversePoints=O,this.inversePoint=D,this.getInverseMatrix=E,this._t=this.transform,this.isIdentity=v,this._identity=!0,this._identityCalculated=!1,this.props=p(`float32`,16),this.reset()}}();function Ye(e){"@babel/helpers - typeof";return Ye=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ye(e)}var G={},Xe=`__[STANDALONE]__`,Ze=`__[ANIMATIONDATA]__`,Qe=``;function $e(e){s(e)}function et(){Xe===!0?V.searchAnimations(Ze,Xe,Qe):V.searchAnimations()}function tt(e){re(e)}function nt(e){ue(e)}function rt(e){return Xe===!0&&(e.animationData=JSON.parse(Ze)),V.loadAnimation(e)}function it(e){if(typeof e==`string`)switch(e){case`high`:ce(200);break;default:case`medium`:ce(50);break;case`low`:ce(10);break}else!isNaN(e)&&e>1&&ce(e)}function at(){return typeof navigator<`u`}function ot(e,t){e===`expressions`&&ae(t)}function st(e){switch(e){case`propertyFactory`:return W;case`shapePropertyFactory`:return qe;case`matrix`:return Je;default:return null}}G.play=V.play,G.pause=V.pause,G.setLocationHref=$e,G.togglePause=V.togglePause,G.setSpeed=V.setSpeed,G.setDirection=V.setDirection,G.stop=V.stop,G.searchAnimations=et,G.registerAnimation=V.registerAnimation,G.loadAnimation=rt,G.setSubframeRendering=tt,G.resize=V.resize,G.goToAndStop=V.goToAndStop,G.destroy=V.destroy,G.setQuality=it,G.inBrowser=at,G.installPlugin=ot,G.freeze=V.freeze,G.unfreeze=V.unfreeze,G.setVolume=V.setVolume,G.mute=V.mute,G.unmute=V.unmute,G.getRegisteredAnimations=V.getRegisteredAnimations,G.useWebWorker=a,G.setIDPrefix=nt,G.__getFactory=st,G.version=`5.13.0`;function ct(){document.readyState===`complete`&&(clearInterval(pt),et())}function lt(e){for(var t=ut.split(`&`),n=0;n=1?a.push({s:e-1,e:t-1}):(a.push({s:e,e:1}),a.push({s:0,e:t-1}));var o=[],s,c=a.length,l;for(s=0;sr+n)){var u=l.s*i<=r?0:(l.s*i-r)/n,d=l.e*i>=r+n?1:(l.e*i-r)/n;o.push([u,d])}return o.length||o.push([0,0]),o},q.prototype.releasePathsData=function(e){var t,n=e.length;for(t=0;t1?1+r:this.s.v<0?0+r:this.s.v+r,n=this.e.v>1?1+r:this.e.v<0?0+r:this.e.v+r,t>n){var i=t;t=n,n=i}t=Math.round(t*1e4)*1e-4,n=Math.round(n*1e4)*1e-4,this.sValue=t,this.eValue=n}else t=this.sValue,n=this.eValue;var a,o,s=this.shapes.length,c,l,u,d,f,p=0;if(n===t)for(o=0;o=0;--o)if(h=this.shapes[o],h.shape._mdf){for(g=h.localShapeCollection,g.releaseShapes(),this.m===2&&s>1?(b=this.calculateShapeEdges(t,n,h.totalShapeLength,y,p),y+=h.totalShapeLength):b=[[_,v]],l=b.length,c=0;c=1?m.push({s:h.totalShapeLength*(_-1),e:h.totalShapeLength*(v-1)}):(m.push({s:h.totalShapeLength*_,e:h.totalShapeLength}),m.push({s:0,e:h.totalShapeLength*(v-1)}));var x=this.addShapes(h,m[0]);if(m[0].s!==m[0].e){if(m.length>1)if(h.shape.paths.shapes[h.shape.paths._length-1].c){var S=x.pop();this.addPaths(x,g),x=this.addShapes(h,m[1],S)}else this.addPaths(x,g),x=this.addShapes(h,m[1]);this.addPaths(x,g)}}h.shape.paths=g}}else if(this._mdf)for(o=0;ot.e){n.c=!1;break}else t.s<=l&&t.e>=l+u.addedLength?(this.addSegment(i[a].v[s-1],i[a].o[s-1],i[a].i[s],i[a].v[s],n,d,g),g=!1):(p=Oe.getNewSegment(i[a].v[s-1],i[a].v[s],i[a].o[s-1],i[a].i[s],(t.s-l)/u.addedLength,(t.e-l)/u.addedLength,f[s-1]),this.addSegmentFromArray(p,n,d,g),g=!1,n.c=!1),l+=u.addedLength,d+=1;if(i[a].c&&f.length){if(u=f[s-1],l<=t.e){var _=f[s-1].addedLength;t.s<=l&&t.e>=l+_?(this.addSegment(i[a].v[s-1],i[a].o[s-1],i[a].i[0],i[a].v[0],n,d,g),g=!1):(p=Oe.getNewSegment(i[a].v[s-1],i[a].v[0],i[a].o[s-1],i[a].i[0],(t.s-l)/_,(t.e-l)/_,f[s-1]),this.addSegmentFromArray(p,n,d,g),g=!1,n.c=!1)}else n.c=!1;l+=u.addedLength,d+=1}if(n._length&&(n.setXYAt(n.v[h][0],n.v[h][1],`i`,h),n.setXYAt(n.v[n._length-1][0],n.v[n._length-1][1],`o`,n._length-1)),l>t.e)break;a=this.p.keyframes[this.p.keyframes.length-1].t?(r=this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length-1].t/n,0),i=this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length-1].t-.05)/n,0)):(r=this.p.pv,i=this.p.getValueAtTime((this.p._caching.lastFrame+this.p.offsetTime-.01)/n,this.p.offsetTime));else if(this.px&&this.px.keyframes&&this.py.keyframes&&this.px.getValueAtTime&&this.py.getValueAtTime){r=[],i=[];var a=this.px,o=this.py;a._caching.lastFrame+a.offsetTime<=a.keyframes[0].t?(r[0]=a.getValueAtTime((a.keyframes[0].t+.01)/n,0),r[1]=o.getValueAtTime((o.keyframes[0].t+.01)/n,0),i[0]=a.getValueAtTime(a.keyframes[0].t/n,0),i[1]=o.getValueAtTime(o.keyframes[0].t/n,0)):a._caching.lastFrame+a.offsetTime>=a.keyframes[a.keyframes.length-1].t?(r[0]=a.getValueAtTime(a.keyframes[a.keyframes.length-1].t/n,0),r[1]=o.getValueAtTime(o.keyframes[o.keyframes.length-1].t/n,0),i[0]=a.getValueAtTime((a.keyframes[a.keyframes.length-1].t-.01)/n,0),i[1]=o.getValueAtTime((o.keyframes[o.keyframes.length-1].t-.01)/n,0)):(r=[a.pv,o.pv],i[0]=a.getValueAtTime((a._caching.lastFrame+a.offsetTime-.01)/n,a.offsetTime),i[1]=o.getValueAtTime((o._caching.lastFrame+o.offsetTime-.01)/n,o.offsetTime))}else i=e,r=i;this.v.rotate(-Math.atan2(r[1]-i[1],r[0]-i[0]))}this.data.p&&this.data.p.s?this.data.p.z?this.v.translate(this.px.v,this.py.v,-this.pz.v):this.v.translate(this.px.v,this.py.v,0):this.v.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}this.frameId=this.elem.globalData.frameId}}function r(){if(this.appliedTransformations=0,this.pre.reset(),!this.a.effectsSequence.length)this.pre.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.appliedTransformations=1;else return;if(!this.s.effectsSequence.length)this.pre.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.appliedTransformations=2;else return;if(this.sk)if(!this.sk.effectsSequence.length&&!this.sa.effectsSequence.length)this.pre.skewFromAxis(-this.sk.v,this.sa.v),this.appliedTransformations=3;else return;this.r?this.r.effectsSequence.length||(this.pre.rotate(-this.r.v),this.appliedTransformations=4):!this.rz.effectsSequence.length&&!this.ry.effectsSequence.length&&!this.rx.effectsSequence.length&&!this.or.effectsSequence.length&&(this.pre.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.appliedTransformations=4)}function i(){}function a(e){this._addDynamicProperty(e),this.elem.addDynamicProperty(e),this._isDirty=!0}function o(e,t,n){if(this.elem=e,this.frameId=-1,this.propType=`transform`,this.data=t,this.v=new Je,this.pre=new Je,this.appliedTransformations=0,this.initDynamicPropertyContainer(n||e),t.p&&t.p.s?(this.px=W.getProp(e,t.p.x,0,0,this),this.py=W.getProp(e,t.p.y,0,0,this),t.p.z&&(this.pz=W.getProp(e,t.p.z,0,0,this))):this.p=W.getProp(e,t.p||{k:[0,0,0]},1,0,this),t.rx){if(this.rx=W.getProp(e,t.rx,0,D,this),this.ry=W.getProp(e,t.ry,0,D,this),this.rz=W.getProp(e,t.rz,0,D,this),t.or.k[0].ti){var r,i=t.or.k.length;for(r=0;r0;)--n,this._elements.unshift(t[n]);this.dynamicProperties.length?this.k=!0:this.getValue(!0)},gt.prototype.resetElements=function(e){var t,n=e.length;for(t=0;t0?Math.floor(f):Math.ceil(f),h=this.pMatrix.props,g=this.rMatrix.props,_=this.sMatrix.props;this.pMatrix.reset(),this.rMatrix.reset(),this.sMatrix.reset(),this.tMatrix.reset(),this.matrix.reset();var v=0;if(f>0){for(;vm;)this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!0),--v;p&&(this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,-p,!0),v-=p)}r=this.data.m===1?0:this._currentCopies-1,i=this.data.m===1?1:-1,a=this._currentCopies;for(var y,b;a;){if(t=this.elemsData[r].it,n=t[t.length-1].transform.mProps.v.props,b=n.length,t[t.length-1].transform.mProps._mdf=!0,t[t.length-1].transform.op._mdf=!0,t[t.length-1].transform.op.v=this._currentCopies===1?this.so.v:this.so.v+(this.eo.v-this.so.v)*(r/(this._currentCopies-1)),v!==0){for((r!==0&&i===1||r!==this._currentCopies-1&&i===-1)&&this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!1),this.matrix.transform(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]),this.matrix.transform(_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],_[8],_[9],_[10],_[11],_[12],_[13],_[14],_[15]),this.matrix.transform(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],h[8],h[9],h[10],h[11],h[12],h[13],h[14],h[15]),y=0;y0&&r<1?[t]:[]:[t-r,t+r].filter(function(e){return e>0&&e<1})},wt.prototype.split=function(e){if(e<=0)return[Ct(this.points[0]),this];if(e>=1)return[this,Ct(this.points[this.points.length-1])];var t=Y(this.points[0],this.points[1],e),n=Y(this.points[1],this.points[2],e),r=Y(this.points[2],this.points[3],e),i=Y(t,n,e),a=Y(n,r,e),o=Y(i,a,e);return[new wt(this.points[0],t,i,o,!0),new wt(o,a,r,this.points[3],!0)]};function Tt(e,t){var n=e.points[0][t],r=e.points[e.points.length-1][t];if(n>r){var i=r;r=n,n=i}for(var a=xt(3*e.a[t],2*e.b[t],e.c[t]),o=0;o0&&a[o]<1){var s=e.point(a[o])[t];sr&&(r=s)}return{min:n,max:r}}wt.prototype.bounds=function(){return{x:Tt(this,0),y:Tt(this,1)}},wt.prototype.boundingBox=function(){var e=this.bounds();return{left:e.x.min,right:e.x.max,top:e.y.min,bottom:e.y.max,width:e.x.max-e.x.min,height:e.y.max-e.y.min,cx:(e.x.max+e.x.min)/2,cy:(e.y.max+e.y.min)/2}};function Et(e,t,n){var r=e.boundingBox();return{cx:r.cx,cy:r.cy,width:r.width,height:r.height,bez:e,t:(t+n)/2,t1:t,t2:n}}function Dt(e){var t=e.bez.split(.5);return[Et(t[0],e.t1,e.t),Et(t[1],e.t,e.t2)]}function Ot(e,t){return Math.abs(e.cx-t.cx)*2=a||e.width<=r&&e.height<=r&&t.width<=r&&t.height<=r){i.push([e.t,t.t]);return}var o=Dt(e),s=Dt(t);kt(o[0],s[0],n+1,r,i,a),kt(o[0],s[1],n+1,r,i,a),kt(o[1],s[0],n+1,r,i,a),kt(o[1],s[1],n+1,r,i,a)}}wt.prototype.intersections=function(e,t,n){t===void 0&&(t=2),n===void 0&&(n=7);var r=[];return kt(Et(this,0,1),Et(e,0,1),0,t,r,n),r},wt.shapeSegment=function(e,t){var n=(t+1)%e.length();return new wt(e.v[t],e.o[t],e.i[n],e.v[n],!0)},wt.shapeSegmentInverted=function(e,t){var n=(t+1)%e.length();return new wt(e.v[n],e.i[n],e.o[t],e.v[t],!0)};function At(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function jt(e,t,n,r){var i=[e[0],e[1],1],a=[t[0],t[1],1],o=[n[0],n[1],1],s=[r[0],r[1],1],c=At(At(i,a),At(o,s));return yt(c[2])?null:[c[0]/c[2],c[1]/c[2]]}function X(e,t,n){return[e[0]+Math.cos(t)*n,e[1]-Math.sin(t)*n]}function Mt(e,t){return Math.hypot(e[0]-t[0],e[1]-t[1])}function Nt(e,t){return vt(e[0],t[0])&&vt(e[1],t[1])}function Pt(){}u([mt],Pt),Pt.prototype.initModifierProperties=function(e,t){this.getValue=this.processKeys,this.amplitude=W.getProp(e,t.s,0,null,this),this.frequency=W.getProp(e,t.r,0,null,this),this.pointsType=W.getProp(e,t.pt,0,null,this),this._isAnimated=this.amplitude.effectsSequence.length!==0||this.frequency.effectsSequence.length!==0||this.pointsType.effectsSequence.length!==0};function Ft(e,t,n,r,i,a,o){var s=n-Math.PI/2,c=n+Math.PI/2,l=t[0]+Math.cos(n)*r*i,u=t[1]-Math.sin(n)*r*i;e.setTripleAt(l,u,l+Math.cos(s)*a,u-Math.sin(s)*a,l+Math.cos(c)*o,u-Math.sin(c)*o,e.length())}function It(e,t){var n=[t[0]-e[0],t[1]-e[1]],r=-Math.PI*.5;return[Math.cos(r)*n[0]-Math.sin(r)*n[1],Math.sin(r)*n[0]+Math.cos(r)*n[1]]}function Lt(e,t){var n=t===0?e.length()-1:t-1,r=(t+1)%e.length(),i=e.v[n],a=e.v[r],o=It(i,a);return Math.atan2(0,1)-Math.atan2(o[1],o[0])}function Rt(e,t,n,r,i,a,o){var s=Lt(t,n),c=t.v[n%t._length],l=t.v[n===0?t._length-1:n-1],u=t.v[(n+1)%t._length],d=a===2?Math.sqrt((c[0]-l[0])**2+(c[1]-l[1])**2):0,f=a===2?Math.sqrt((c[0]-u[0])**2+(c[1]-u[1])**2):0;Ft(e,t.v[n%t._length],s,o,r,f/((i+1)*2),d/((i+1)*2),a)}function zt(e,t,n,r,i,a){for(var o=0;o1&&t.length>1&&(i=Ut(e[0],t[t.length-1]),i)?[[e[0].split(i[0])[0]],[t[t.length-1].split(i[1])[1]]]:[n,r]}function Gt(e){for(var t,n=1;n1&&(t=Wt(e[e.length-1],e[0]),e[e.length-1]=t[0],e[0]=t[1]),e}function Kt(e,t){var n=e.inflectionPoints(),r,i,a,o;if(n.length===0)return[Vt(e,t)];if(n.length===1||vt(n[1],1))return a=e.split(n[0]),r=a[0],i=a[1],[Vt(r,t),Vt(i,t)];a=e.split(n[0]),r=a[0];var s=(n[1]-n[0])/(1-n[0]);return a=a[1].split(s),o=a[0],i=a[1],[Vt(r,t),Vt(o,t),Vt(i,t)]}function qt(){}u([mt],qt),qt.prototype.initModifierProperties=function(e,t){this.getValue=this.processKeys,this.amount=W.getProp(e,t.a,0,null,this),this.miterLimit=W.getProp(e,t.ml,0,null,this),this.lineJoin=t.lj,this._isAnimated=this.amount.effectsSequence.length!==0},qt.prototype.processPath=function(e,t,n,r){var i=We.newElement();i.c=e.c;var a=e.length();e.c||--a;var o,s,c,l=[];for(o=0;o=0;--o)c=wt.shapeSegmentInverted(e,o),l.push(Kt(c,t));l=Gt(l);var u=null,d=null;for(o=0;o0&&(o=!1),o){var u=l(`style`);u.setAttribute(`f-forigin`,n[r].fOrigin),u.setAttribute(`f-origin`,n[r].origin),u.setAttribute(`f-family`,n[r].fFamily),u.type=`text/css`,u.innerText=`@font-face {font-family: `+n[r].fFamily+`; font-style: normal; src: url('`+n[r].fPath+`');}`,t.appendChild(u)}}else if(n[r].fOrigin===`g`||n[r].origin===1){for(s=document.querySelectorAll(`link[f-forigin="g"], link[f-origin="1"]`),c=0;c=55296&&n<=56319){var r=e.charCodeAt(1);r>=56320&&r<=57343&&(t=(n-55296)*1024+r-56320+65536)}return t}function S(e,t){var n=e.toString(16)+t.toString(16);return d.indexOf(n)!==-1}function C(e){return e===s}function w(e){return e===o}function T(e){var t=x(e);return t>=c&&t<=u}function E(e){return T(e.substr(0,2))&&T(e.substr(2,2))}function D(e){return t.indexOf(e)!==-1}function O(e,t){var o=x(e.substr(t,2));if(o!==n)return!1;var s=0;for(t+=2;s<5;){if(o=x(e.substr(t,2)),oa)return!1;s+=1,t+=2}return x(e.substr(t,2))===r}function k(){this.isLoaded=!0}var A=function(){this.fonts=[],this.chars=null,this.typekitLoaded=0,this.isLoaded=!1,this._warned=!1,this.initTime=Date.now(),this.setIsLoadedBinded=this.setIsLoaded.bind(this),this.checkLoadedFontsBinded=this.checkLoadedFonts.bind(this)};return A.isModifier=S,A.isZeroWidthJoiner=C,A.isFlagEmoji=E,A.isRegionalCode=T,A.isCombinedCharacter=D,A.isRegionalFlag=O,A.isVariationSelector=w,A.BLACK_FLAG_CODE_POINT=n,A.prototype={addChars:_,addFonts:g,getCharData:v,getFontByName:b,measureText:y,checkLoadedFonts:m,setIsLoaded:k},A}();function Xt(e){this.animationData=e}Xt.prototype.getProp=function(e){return this.animationData.slots&&this.animationData.slots[e.sid]?Object.assign(e,this.animationData.slots[e.sid].p):e};function Zt(e){return new Xt(e)}function Qt(){}Qt.prototype={initRenderable:function(){this.isInRange=!1,this.hidden=!1,this.isTransparent=!1,this.renderableComponents=[]},addRenderableComponent:function(e){this.renderableComponents.indexOf(e)===-1&&this.renderableComponents.push(e)},removeRenderableComponent:function(e){this.renderableComponents.indexOf(e)!==-1&&this.renderableComponents.splice(this.renderableComponents.indexOf(e),1)},prepareRenderableFrame:function(e){this.checkLayerLimits(e)},checkTransparency:function(){this.finalTransform.mProp.o.v<=0?!this.isTransparent&&this.globalData.renderConfig.hideOnTransparent&&(this.isTransparent=!0,this.hide()):this.isTransparent&&(this.isTransparent=!1,this.show())},checkLayerLimits:function(e){this.data.ip-this.data.st<=e&&this.data.op-this.data.st>e?this.isInRange!==!0&&(this.globalData._mdf=!0,this._mdf=!0,this.isInRange=!0,this.show()):this.isInRange!==!1&&(this.globalData._mdf=!0,this.isInRange=!1,this.hide())},renderRenderable:function(){var e,t=this.renderableComponents.length;for(e=0;e.1)&&this.audio.seek(this._currentTime/this.globalData.frameRate):(this.audio.play(),this.audio.seek(this._currentTime/this.globalData.frameRate),this._isPlaying=!0))},mn.prototype.show=function(){},mn.prototype.hide=function(){this.audio.pause(),this._isPlaying=!1},mn.prototype.pause=function(){this.audio.pause(),this._isPlaying=!1,this._canPlay=!1},mn.prototype.resume=function(){this._canPlay=!0},mn.prototype.setRate=function(e){this.audio.rate(e)},mn.prototype.volume=function(e){this._volumeMultiplier=e,this._previousVolume=e*this._volume,this.audio.volume(this._previousVolume)},mn.prototype.getBaseElement=function(){return null},mn.prototype.destroy=function(){},mn.prototype.sourceRectAtTime=function(){},mn.prototype.initExpressions=function(){};function hn(){}hn.prototype.checkLayers=function(e){var t,n=this.layers.length,r;for(this.completeLayers=!0,t=n-1;t>=0;--t)this.elements[t]||(r=this.layers[t],r.ip-r.st<=e-this.layers[t].st&&r.op-r.st>e-this.layers[t].st&&this.buildItem(t)),this.completeLayers=this.elements[t]?this.completeLayers:!1;this.checkPendingElements()},hn.prototype.createItem=function(e){switch(e.ty){case 2:return this.createImage(e);case 0:return this.createComp(e);case 1:return this.createSolid(e);case 3:return this.createNull(e);case 4:return this.createShape(e);case 5:return this.createText(e);case 6:return this.createAudio(e);case 13:return this.createCamera(e);case 15:return this.createFootage(e);default:return this.createNull(e)}},hn.prototype.createCamera=function(){throw Error(`You're using a 3d camera. Try the html renderer.`)},hn.prototype.createAudio=function(e){return new mn(e,this.globalData,this)},hn.prototype.createFootage=function(e){return new pn(e,this.globalData,this)},hn.prototype.buildAllItems=function(){var e,t=this.layers.length;for(e=0;e0&&(this.maskElement.setAttribute(`id`,p),this.element.maskedElement.setAttribute(b,`url(`+c()+`#`+p+`)`),r.appendChild(this.maskElement)),this.viewData.length&&this.element.addRenderableComponent(this)}vn.prototype.getMaskProperty=function(e){return this.viewData[e].prop},vn.prototype.renderFrame=function(e){var t=this.element.finalTransform.mat,n,r=this.masksProperties.length;for(n=0;n1&&(r+=` C`+t.o[i-1][0]+`,`+t.o[i-1][1]+` `+t.i[0][0]+`,`+t.i[0][1]+` `+t.v[0][0]+`,`+t.v[0][1]),n.lastPath!==r){var o=``;n.elem&&(t.c&&(o=e.inv?this.solidPath+r:r),n.elem.setAttribute(`d`,o)),n.lastPath=r}},vn.prototype.destroy=function(){this.element=null,this.globalData=null,this.maskElement=null,this.data=null,this.masksProperties=null};var yn=function(){var e={};e.createFilter=t,e.createAlphaToLuminanceFilter=n;function t(e,t){var n=z(`filter`);return n.setAttribute(`id`,e),t!==!0&&(n.setAttribute(`filterUnits`,`objectBoundingBox`),n.setAttribute(`x`,`0%`),n.setAttribute(`y`,`0%`),n.setAttribute(`width`,`100%`),n.setAttribute(`height`,`100%`)),n}function n(){var e=z(`feColorMatrix`);return e.setAttribute(`type`,`matrix`),e.setAttribute(`color-interpolation-filters`,`sRGB`),e.setAttribute(`values`,`0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1`),e}return e}(),bn=function(){var e={maskType:!0,svgLumaHidden:!0,offscreenCanvas:typeof OffscreenCanvas<`u`};return(/MSIE 10/i.test(navigator.userAgent)||/MSIE 9/i.test(navigator.userAgent)||/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))&&(e.maskType=!1),/firefox/i.test(navigator.userAgent)&&(e.svgLumaHidden=!1),e}(),xn={},Sn=`filter_result_`;function Cn(e){var t,n=`SourceGraphic`,r=e.data.ef?e.data.ef.length:0,i=I(),a=yn.createFilter(i,!0),o=0;this.filters=[];var s;for(t=0;t=0&&(n=this.shapeModifiers[e].processShapes(this._isFirstFrame),!n);--e);}},searchProcessedElement:function(e){for(var t=this.processedElements,n=0,r=t.length;n.01)return!1;n+=1}return!0},Rn.prototype.checkCollapsable=function(){if(this.o.length/2!=this.c.length/4)return!1;if(this.data.k.k[0].s)for(var e=0,t=this.data.k.k.length;e0;)c=r.transformers[g].mProps._mdf||c,--h,--g;if(c)for(h=f-r.styles[u].lvl,g=r.transformers.length-1;h>0;)m.multiply(r.transformers[g].mProps.v),--h,--g}else m=e;if(p=r.sh.paths,o=p._length,c){for(s=``,a=0;a=1?v=.99:v<=-1&&(v=-.99);var y=g*v,b=Math.cos(_+t.a.v)*y+a[0],x=Math.sin(_+t.a.v)*y+a[1];r.setAttribute(`fx`,b),r.setAttribute(`fy`,x),i&&!t.g._collapsable&&(t.of.setAttribute(`fx`,b),t.of.setAttribute(`fy`,x))}}}function u(e,t,n){var r=t.style,i=t.d;i&&(i._mdf||n)&&i.dashStr&&(r.pElem.setAttribute(`stroke-dasharray`,i.dashStr),r.pElem.setAttribute(`stroke-dashoffset`,i.dashoffset[0])),t.c&&(t.c._mdf||n)&&r.pElem.setAttribute(`stroke`,`rgb(`+C(t.c.v[0])+`,`+C(t.c.v[1])+`,`+C(t.c.v[2])+`)`),(t.o._mdf||n)&&r.pElem.setAttribute(`stroke-opacity`,t.o.v),(t.w._mdf||n)&&(r.pElem.setAttribute(`stroke-width`,t.w.v),r.msElem&&r.msElem.setAttribute(`stroke-width`,t.w.v))}return n}();function Gn(e,t,n){this.shapes=[],this.shapesData=e.shapes,this.stylesList=[],this.shapeModifiers=[],this.itemsData=[],this.processedElements=[],this.animatedContents=[],this.initElement(e,t,n),this.prevViewData=[]}u([dn,_n,wn,kn,Tn,fn,En],Gn),Gn.prototype.initSecondaryElement=function(){},Gn.prototype.identityMatrix=new Je,Gn.prototype.buildExpressionInterface=function(){},Gn.prototype.createContent=function(){this.searchShapes(this.shapesData,this.itemsData,this.prevViewData,this.layerElement,0,[],!0),this.filterUniqueShapes()},Gn.prototype.filterUniqueShapes=function(){var e,t=this.shapes.length,n,r,i=this.stylesList.length,a,o=[],s=!1;for(r=0;r1&&s&&this.setShapesAsAnimated(o)}},Gn.prototype.setShapesAsAnimated=function(e){var t,n=e.length;for(t=0;t=0;--c){if(g=this.searchProcessedElement(e[c]),g?t[c]=n[g-1]:e[c]._render=o,e[c].ty===`fl`||e[c].ty===`st`||e[c].ty===`gf`||e[c].ty===`gs`||e[c].ty===`no`)g?t[c].style.closed=e[c].hd:t[c]=this.createStyleElement(e[c],i),e[c]._render&&t[c].style.pElem.parentNode!==r&&r.appendChild(t[c].style.pElem),f.push(t[c].style);else if(e[c].ty===`gr`){if(!g)t[c]=this.createGroupElement(e[c]);else for(d=t[c].it.length,u=0;u1,this.kf&&this.addEffect(this.getKeyframeValue.bind(this)),this.kf},qn.prototype.addEffect=function(e){this.effectsSequence.push(e),this.elem.addDynamicProperty(this)},qn.prototype.getValue=function(e){if(!((this.elem.globalData.frameId===this.frameId||!this.effectsSequence.length)&&!e)){this.currentData.t=this.data.d.k[this.keysIndex].s.t;var t=this.currentData,n=this.keysIndex;if(this.lock){this.setCurrentData(this.currentData);return}this.lock=!0,this._mdf=!1;var r,i=this.effectsSequence.length,a=e||this.data.d.k[this.keysIndex].s;for(r=0;rt);)n+=1;return this.keysIndex!==n&&(this.keysIndex=n),this.data.d.k[this.keysIndex].s},qn.prototype.buildFinalText=function(e){for(var t=[],n=0,r=e.length,i,a,o=!1,s=!1,c=``;n=55296&&i<=56319?Yt.isRegionalFlag(e,n)?c=e.substr(n,14):(a=e.charCodeAt(n+1),a>=56320&&a<=57343&&(Yt.isModifier(i,a)?(c=e.substr(n,2),o=!0):c=Yt.isFlagEmoji(e.substr(n,4))?e.substr(n,4):e.substr(n,2))):i>56319?(a=e.charCodeAt(n+1),Yt.isVariationSelector(i)&&(o=!0)):Yt.isZeroWidthJoiner(i)&&(o=!0,s=!0),o?(t[t.length-1]+=c,o=!1):t.push(c),n+=c.length;return t},qn.prototype.completeTextData=function(e){e.__complete=!0;var t=this.elem.globalData.fontManager,n=this.data,r=[],i,a,o,s=0,c,l=n.m.g,u=0,d=0,f=0,p=[],m=0,h=0,g,_,v=t.getFontByName(e.f),y,b=0,x=Jt(v);e.fWeight=x.weight,e.fStyle=x.style,e.finalSize=e.s,e.finalText=this.buildFinalText(e.t),a=e.finalText.length,e.finalLineHeight=e.lh;var S=e.tr/1e3*e.finalSize,C;if(e.sz)for(var w=!0,T=e.sz[0],E=e.sz[1],D,O;w;){O=this.buildFinalText(e.t),D=0,m=0,a=O.length,S=e.tr/1e3*e.finalSize;var k=-1;for(i=0;iT&&O[i]!==` `?(k===-1?a+=1:i=k,D+=e.finalLineHeight||e.finalSize*1.2,O.splice(i,+(k===i),`\r`),k=-1,m=0):(m+=b,m+=S);D+=v.ascent*e.finalSize/100,this.canResize&&e.finalSize>this.minimumFontSize&&Eh?m:h,m=-2*S,c=``,o=!0,f+=1):c=j,t.chars?(y=t.getCharData(j,v.fStyle,t.getFontByName(e.f).fFamily),b=o?0:y.w*e.finalSize/100):b=t.measureText(c,e.f,e.finalSize),j===` `?A+=b+S:(m+=b+S+A,A=0),r.push({l:b,an:b,add:u,n:o,anIndexes:[],val:c,line:f,animatorJustifyOffset:0}),l==2){if(u+=b,c===``||c===` `||i===a-1){for((c===``||c===` `)&&(u-=b);d<=i;)r[d].an=u,r[d].ind=s,r[d].extra=b,d+=1;s+=1,u=0}}else if(l==3){if(u+=b,c===``||i===a-1){for(c===``&&(u-=b);d<=i;)r[d].an=u,r[d].ind=s,r[d].extra=b,d+=1;u=0,s+=1}}else r[s].ind=s,r[s].extra=0,s+=1;if(e.l=r,h=m>h?m:h,p.push(m),e.sz)e.boxWidth=e.sz[0],e.justifyOffset=0;else switch(e.boxWidth=h,e.j){case 1:e.justifyOffset=-e.boxWidth;break;case 2:e.justifyOffset=-e.boxWidth/2;break;default:e.justifyOffset=0}e.lineWidths=p;var M=n.a,N,P;_=M.length;var F,I,L=[];for(g=0;g<_;g+=1){for(N=M[g],N.a.sc&&(e.strokeColorAnim=!0),N.a.sw&&(e.strokeWidthAnim=!0),(N.a.fc||N.a.fh||N.a.fs||N.a.fb)&&(e.fillColorAnim=!0),I=0,F=N.s.b,i=0;i0?i=this.ne.v/100:a=-this.ne.v/100,this.xe.v>0?o=1-this.xe.v/100:s=1+this.xe.v/100;var c=Se.getBezierEasing(i,a,o,s).get,l=0,u=this.finalS,d=this.finalE,f=this.data.sh;if(f===2)l=d===u?+(r>=d):e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l=c(l);else if(f===3)l=d===u?r>=d?0:1:1-e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l=c(l);else if(f===4)d===u?l=0:(l=e(0,t(.5/(d-u)+(r-u)/(d-u),1)),l<.5?l*=2:l=1-2*(l-.5)),l=c(l);else if(f===5){if(d===u)l=0;else{var p=d-u;r=t(e(0,r+.5-u),d-u);var m=-p/2+r,h=p/2;l=Math.sqrt(1-m*m/(h*h))}l=c(l)}else f===6?(d===u?l=0:(r=t(e(0,r+.5-u),d-u),l=(1+Math.cos(Math.PI+Math.PI*2*r/(d-u)))/2),l=c(l)):(r>=n(u)&&(l=r-u<0?e(0,t(t(d,1)-(u-r),1)):e(0,t(d-r,1))),l=c(l));if(this.sm.v!==100){var g=this.sm.v*.01;g===0&&(g=1e-8);var _=.5-g*.5;l<_?l=0:(l=(l-_)/g,l>1&&(l=1))}return l*this.a.v},getValue:function(e){this.iterateDynamicProperties(),this._mdf=e||this._mdf,this._currentTextLength=this.elem.textProperty.currentData.l.length||0,e&&this.data.r===2&&(this.e.v=this._currentTextLength);var t=this.data.r===2?1:100/this.data.totalChars,n=this.o.v/t,r=this.s.v/t+n,i=this.e.v/t+n;if(r>i){var a=r;r=i,i=a}this.finalS=r,this.finalE=i}},u([Ve],r);function i(e,t,n){return new r(e,t,n)}return{getTextSelectorProp:i}}();function Yn(e,t,n){var r={propType:!1},i=W.getProp,a=t.a;this.a={r:a.r?i(e,a.r,0,D,n):r,rx:a.rx?i(e,a.rx,0,D,n):r,ry:a.ry?i(e,a.ry,0,D,n):r,sk:a.sk?i(e,a.sk,0,D,n):r,sa:a.sa?i(e,a.sa,0,D,n):r,s:a.s?i(e,a.s,1,.01,n):r,a:a.a?i(e,a.a,1,0,n):r,o:a.o?i(e,a.o,0,.01,n):r,p:a.p?i(e,a.p,1,0,n):r,sw:a.sw?i(e,a.sw,0,0,n):r,sc:a.sc?i(e,a.sc,1,0,n):r,fc:a.fc?i(e,a.fc,1,0,n):r,fh:a.fh?i(e,a.fh,0,0,n):r,fs:a.fs?i(e,a.fs,0,.01,n):r,fb:a.fb?i(e,a.fb,0,.01,n):r,t:a.t?i(e,a.t,0,0,n):r},this.s=Jn.getTextSelectorProp(e,t.s,n),this.s.t=t.s.t}function Xn(e,t,n){this._isFirstFrame=!0,this._hasMaskedPath=!1,this._frameId=-1,this._textData=e,this._renderType=t,this._elem=n,this._animatorsData=m(this._textData.a.length),this._pathData={},this._moreOptions={alignment:{}},this.renderedLetters=[],this.lettersChangedFlag=!1,this.initDynamicPropertyContainer(n)}Xn.prototype.searchProperties=function(){var e,t=this._textData.a.length,n,r=W.getProp;for(e=0;e=m+Ce||!x?(T=(m+Ce-g)/h.partialLength,ie=b.point[0]+(h.point[0]-b.point[0])*T,ae=b.point[1]+(h.point[1]-b.point[1])*T,a.translate(-n[0]*f[u].an*.005,-(n[1]*A)*.01),_=!1):x&&(g+=h.partialLength,v+=1,v>=x.length&&(v=0,y+=1,S[y]?x=S[y].points:D.v.c?(v=0,y=0,x=S[y].points):(g-=h.partialLength,x=null)),x&&(b=h,h=x[v],C=h.partialLength));re=f[u].an/2-f[u].add,a.translate(-re,0,0)}else re=f[u].an/2-f[u].add,a.translate(-re,0,0),a.translate(-n[0]*f[u].an*.005,-n[1]*A*.01,0);for(P=0;Pe?this.textSpans[e].span:z(s?`g`:`text`),b<=e){if(c.setAttribute(`stroke-linecap`,`butt`),c.setAttribute(`stroke-linejoin`,`round`),c.setAttribute(`stroke-miterlimit`,`4`),this.textSpans[e].span=c,s){var S=z(`g`);c.appendChild(S),this.textSpans[e].childSpan=S}this.textSpans[e].span=c,this.layerElement.appendChild(c)}c.style.display=`inherit`}if(l.reset(),d&&(o[e].n&&(f=-g,p+=n.yOffset,p+=+!!h,h=!1),this.applyTextPropertiesToMatrix(n,l,o[e].line,f,p),f+=o[e].l||0,f+=g),s){x=this.globalData.fontManager.getCharData(n.finalText[e],r.fStyle,this.globalData.fontManager.getFontByName(n.f).fFamily);var C;if(x.t===1)C=new ir(x.data,this.globalData,this);else{var w=Qn;x.data&&x.data.shapes&&(w=this.buildShapeData(x.data,n.finalSize)),C=new Gn(w,this.globalData,this)}if(this.textSpans[e].glyph){var T=this.textSpans[e].glyph;this.textSpans[e].childSpan.removeChild(T.layerElement),T.destroy()}this.textSpans[e].glyph=C,C._debug=!0,C.prepareFrame(0),C.renderFrame(),this.textSpans[e].childSpan.appendChild(C.layerElement),x.t===1&&this.textSpans[e].childSpan.setAttribute(`transform`,`scale(`+n.finalSize/100+`,`+n.finalSize/100+`)`)}else d&&c.setAttribute(`transform`,`translate(`+l.props[12]+`,`+l.props[13]+`)`),c.textContent=o[e].val,c.setAttributeNS(`http://www.w3.org/XML/1998/namespace`,`xml:space`,`preserve`)}d&&c&&c.setAttribute(`d`,u)}for(;e=0;--t)(this.completeLayers||this.elements[t])&&this.elements[t].prepareFrame(e-this.layers[t].st);if(this.globalData._mdf)for(t=0;t=0;--n)(this.completeLayers||this.elements[n])&&(this.elements[n].prepareFrame(this.renderedFrame-this.layers[n].st),this.elements[n]._mdf&&(this._mdf=!0))}},rr.prototype.renderInnerContent=function(){var e,t=this.layers.length;for(e=0;e=0;--n)e.finalTransform.multiply(e.transforms[n].transform.mProps.v);e._mdf=i},processSequences:function(e){var t,n=this.sequenceList.length;for(t=0;t=1){this.buffers=[];var e=this.globalData.canvasContext,t=lr.createCanvas(e.canvas.width,e.canvas.height);this.buffers.push(t);var n=lr.createCanvas(e.canvas.width,e.canvas.height);this.buffers.push(n),this.data.tt>=3&&!document._isProxy&&lr.loadLumaCanvas()}this.canvasContext=this.globalData.canvasContext,this.transformCanvas=this.globalData.transformCanvas,this.renderableEffectsManager=new dr(this),this.searchEffectTransforms()},createContent:function(){},setBlendMode:function(){var e=this.globalData;if(e.blendMode!==this.data.bm){e.blendMode=this.data.bm;var t=$t(this.data.bm);e.canvasContext.globalCompositeOperation=t}},createRenderableComponents:function(){this.maskManager=new fr(this.data,this),this.transformEffects=this.renderableEffectsManager.getEffects(gn.TRANSFORM_EFFECT)},hideElement:function(){!this.hidden&&(!this.isInRange||this.isTransparent)&&(this.hidden=!0)},showElement:function(){this.isInRange&&!this.isTransparent&&(this.hidden=!1,this._isFirstFrame=!0,this.maskManager._isFirstFrame=!0)},clearCanvas:function(e){e.clearRect(this.transformCanvas.tx,this.transformCanvas.ty,this.transformCanvas.w*this.transformCanvas.sx,this.transformCanvas.h*this.transformCanvas.sy)},prepareLayer:function(){if(this.data.tt>=1){var e=this.buffers[0].getContext(`2d`);this.clearCanvas(e),e.drawImage(this.canvasContext.canvas,0,0),this.currentTransform=this.canvasContext.getTransform(),this.canvasContext.setTransform(1,0,0,1,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.setTransform(this.currentTransform)}},exitLayer:function(){if(this.data.tt>=1){var e=this.buffers[1],t=e.getContext(`2d`);if(this.clearCanvas(t),t.drawImage(this.canvasContext.canvas,0,0),this.canvasContext.setTransform(1,0,0,1,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.setTransform(this.currentTransform),this.comp.getElementById(`tp`in this.data?this.data.tp:this.data.ind-1).renderFrame(!0),this.canvasContext.setTransform(1,0,0,1,0,0),this.data.tt>=3&&!document._isProxy){var n=lr.getLumaCanvas(this.canvasContext.canvas);n.getContext(`2d`).drawImage(this.canvasContext.canvas,0,0),this.clearCanvas(this.canvasContext),this.canvasContext.drawImage(n,0,0)}this.canvasContext.globalCompositeOperation=mr[this.data.tt],this.canvasContext.drawImage(e,0,0),this.canvasContext.globalCompositeOperation=`destination-over`,this.canvasContext.drawImage(this.buffers[0],0,0),this.canvasContext.setTransform(this.currentTransform),this.canvasContext.globalCompositeOperation=`source-over`}},renderFrame:function(e){if(!(this.hidden||this.data.hd)&&!(this.data.td===1&&!e)){this.renderTransform(),this.renderRenderable(),this.renderLocalTransform(),this.setBlendMode();var t=this.data.ty===0;this.prepareLayer(),this.globalData.renderer.save(t),this.globalData.renderer.ctxTransform(this.finalTransform.localMat.props),this.globalData.renderer.ctxOpacity(this.finalTransform.localOpacity),this.renderInnerContent(),this.globalData.renderer.restore(t),this.exitLayer(),this.maskManager.hasMasks&&this.globalData.renderer.restore(!0),this._isFirstFrame&&=!1}},destroy:function(){this.canvasContext=null,this.data=null,this.globalData=null,this.maskManager.destroy()},mHelper:new Je},pr.prototype.hide=pr.prototype.hideElement,pr.prototype.show=pr.prototype.showElement;function hr(e,t,n,r){this.styledShapes=[],this.tr=[0,0,0,0,0,0];var i=4;t.ty===`rc`?i=5:t.ty===`el`?i=6:t.ty===`sr`&&(i=7),this.sh=qe.getShapeProp(e,t,i,e);var a,o=n.length,s;for(a=0;a=0;--a){if(d=this.searchProcessedElement(e[a]),d?t[a]=n[d-1]:e[a]._shouldRender=r,e[a].ty===`fl`||e[a].ty===`st`||e[a].ty===`gf`||e[a].ty===`gs`)d?t[a].style.closed=!1:t[a]=this.createStyleElement(e[a],m),l.push(t[a].style);else if(e[a].ty===`gr`){if(!d)t[a]=this.createGroupElement(e[a]);else for(c=t[a].it.length,s=0;s=0;--i)t[i].ty===`tr`?(o=n[i].transform,this.renderShapeTransform(e,o)):t[i].ty===`sh`||t[i].ty===`el`||t[i].ty===`rc`||t[i].ty===`sr`?this.renderPath(t[i],n[i]):t[i].ty===`fl`?this.renderFill(t[i],n[i],o):t[i].ty===`st`?this.renderStroke(t[i],n[i],o):t[i].ty===`gf`||t[i].ty===`gs`?this.renderGradientFill(t[i],n[i],o):t[i].ty===`gr`?this.renderShape(o,t[i].it,n[i].it):t[i].ty;r&&this.drawLayer()},gr.prototype.renderStyledShape=function(e,t){if(this._isFirstFrame||t._mdf||e.transforms._mdf){var n=e.trNodes,r=t.paths,i,a,o,s=r._length;n.length=0;var c=e.transforms.finalTransform;for(o=0;o=1?u=.99:u<=-1&&(u=-.99);var d=c*u,f=Math.cos(l+t.a.v)*d+o[0],p=Math.sin(l+t.a.v)*d+o[1];i=a.createRadialGradient(f,p,0,o[0],o[1],c)}var m,h=e.g.p,g=t.g.c,_=1;for(m=0;ma&&c===`xMidYMid slice`||ii&&s===`meet`||ai&&s===`slice`)?this.transformCanvas.tx=(n-this.transformCanvas.w*(r/this.transformCanvas.h))/2*this.renderConfig.dpr:l===`xMax`&&(ai&&s===`slice`)?this.transformCanvas.tx=(n-this.transformCanvas.w*(r/this.transformCanvas.h))*this.renderConfig.dpr:this.transformCanvas.tx=0,u===`YMid`&&(a>i&&s===`meet`||ai&&s===`meet`||a=0;--e)this.elements[e]&&this.elements[e].destroy&&this.elements[e].destroy();this.elements.length=0,this.globalData.canvasContext=null,this.animationItem.container=null,this.destroyed=!0},Z.prototype.renderFrame=function(e,t){if(!(this.renderedFrame===e&&this.renderConfig.clearCanvas===!0&&!t||this.destroyed||e===-1)){this.renderedFrame=e,this.globalData.frameNum=e-this.animationItem._isFirstFrame,this.globalData.frameId+=1,this.globalData._mdf=!this.renderConfig.clearCanvas||t,this.globalData.projectInterface.currentFrame=e;var n,r=this.layers.length;for(this.completeLayers||this.checkLayers(e),n=r-1;n>=0;--n)(this.completeLayers||this.elements[n])&&this.elements[n].prepareFrame(e-this.layers[n].st);if(this.globalData._mdf){for(this.renderConfig.clearCanvas===!0?this.canvasContext.clearRect(0,0,this.transformCanvas.w,this.transformCanvas.h):this.save(),n=r-1;n>=0;--n)(this.completeLayers||this.elements[n])&&this.elements[n].renderFrame();this.renderConfig.clearCanvas!==!0&&this.restore()}}},Z.prototype.buildItem=function(e){var t=this.elements;if(!(t[e]||this.layers[e].ty===99)){var n=this.createItem(this.layers[e],this,this.globalData);t[e]=n,n.initExpressions()}},Z.prototype.checkPendingElements=function(){for(;this.pendingElements.length;)this.pendingElements.pop().checkParenting()},Z.prototype.hide=function(){this.animationItem.container.style.display=`none`},Z.prototype.show=function(){this.animationItem.container.style.display=`block`};function br(){this.opacity=-1,this.transform=p(`float32`,16),this.fillStyle=``,this.strokeStyle=``,this.lineWidth=``,this.lineCap=``,this.lineJoin=``,this.miterLimit=``,this.id=Math.random()}function xr(){this.stack=[],this.cArrPos=0,this.cTr=new Je;var e,t=15;for(e=0;e=0;--t)(this.completeLayers||this.elements[t])&&this.elements[t].renderFrame()},Sr.prototype.destroy=function(){var e;for(e=this.layers.length-1;e>=0;--e)this.elements[e]&&this.elements[e].destroy();this.layers=null,this.elements=null},Sr.prototype.createComp=function(e){return new Sr(e,this.globalData,this)};function Cr(e,t){this.animationItem=e,this.renderConfig={clearCanvas:t&&t.clearCanvas!==void 0?t.clearCanvas:!0,context:t&&t.context||null,progressiveLoad:t&&t.progressiveLoad||!1,preserveAspectRatio:t&&t.preserveAspectRatio||`xMidYMid meet`,imagePreserveAspectRatio:t&&t.imagePreserveAspectRatio||`xMidYMid slice`,contentVisibility:t&&t.contentVisibility||`visible`,className:t&&t.className||``,id:t&&t.id||``,runExpressions:!t||t.runExpressions===void 0||t.runExpressions},this.renderConfig.dpr=t&&t.dpr||1,this.animationItem.wrapper&&(this.renderConfig.dpr=t&&t.dpr||window.devicePixelRatio||1),this.renderedFrame=-1,this.globalData={frameNum:-1,_mdf:!1,renderConfig:this.renderConfig,currentGlobalAlpha:-1},this.contextData=new xr,this.elements=[],this.pendingElements=[],this.transformMat=new Je,this.completeLayers=!1,this.rendererType=`canvas`,this.renderConfig.clearCanvas&&(this.ctxTransform=this.contextData.transform.bind(this.contextData),this.ctxOpacity=this.contextData.opacity.bind(this.contextData),this.ctxFillStyle=this.contextData.fillStyle.bind(this.contextData),this.ctxStrokeStyle=this.contextData.strokeStyle.bind(this.contextData),this.ctxLineWidth=this.contextData.lineWidth.bind(this.contextData),this.ctxLineCap=this.contextData.lineCap.bind(this.contextData),this.ctxLineJoin=this.contextData.lineJoin.bind(this.contextData),this.ctxMiterLimit=this.contextData.miterLimit.bind(this.contextData),this.ctxFill=this.contextData.fill.bind(this.contextData),this.ctxFillRect=this.contextData.fillRect.bind(this.contextData),this.ctxStroke=this.contextData.stroke.bind(this.contextData),this.save=this.contextData.save.bind(this.contextData))}return u([Z],Cr),Cr.prototype.createComp=function(e){return new Sr(e,this.globalData,this)},ve(`canvas`,Cr),K.registerModifier(`tm`,q),K.registerModifier(`pb`,J),K.registerModifier(`rp`,gt),K.registerModifier(`rd`,_t),K.registerModifier(`zz`,Pt),K.registerModifier(`op`,qt),G}))}))(),1),Qt=0,$t=e=>`${e}-${++Qt}`,en=[{center:`#6f5bea`,edge:`#34278f`,pattern:`#a89df5`,text:`#ffffff`},{center:`#32a86b`,edge:`#17613e`,pattern:`#8ee0b3`,text:`#ffffff`},{center:`#df8d2f`,edge:`#8c421e`,pattern:`#ffd08a`,text:`#ffffff`},{center:`#d95878`,edge:`#7b2944`,pattern:`#f5a1b6`,text:`#ffffff`}];function tn(e){if(!e.length)return e;let t=Math.floor(1e3/e.length),n=1e3%e.length;return e.map((e,r)=>({...e,rarity:String(t+ +(r({key:$t(e),name:``,rarity:`1`,sortOrder:String(t),file:null,animation:null,fileError:``});function rn(e){let t=e.reduce((e,t)=>{let n=Number(t.backdropID);return Number.isInteger(n)?Math.max(e,n):e},0)+1,n=en[e.length%en.length];return{key:$t(`backdrop`),name:``,backdropID:String(t),rarity:`1`,sortOrder:String(e.length),...n}}var an=e=>tn([nn(e,0),nn(e,1)]),on=()=>{let e=rn([]);return tn([e,rn([e])])};function sn({data:e,compact:t=!1}){let n=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!n.current)return;let t=Zt.default.loadAnimation({container:n.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)});return()=>t.destroy()},[e]),(0,H.jsx)(`div`,{className:`collectible-animation ${t?`compact`:``}`,ref:n})}function cn({giftID:e,attribute:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{let n=!1;return a(!1),x.giftCollectibleAnimation(e,t.kind,t.id).then(e=>{n||r(e)}).catch(()=>{n||a(!0)}),()=>{n=!0}},[e,t.id,t.kind]),i?(0,H.jsx)(`div`,{className:`collectible-animation compact failed`,children:`!`}):n?(0,H.jsx)(sn,{data:n,compact:!0}):(0,H.jsx)(`div`,{className:`collectible-animation compact loading`,children:(0,H.jsx)(A,{className:`spin`,size:15})})}async function ln(e){let t=new Uint8Array(await e.arrayBuffer()),n=t;if(t.length>=2&&t[0]===31&&t[1]===139){if(!(`DecompressionStream`in window))throw Error(`This browser cannot preview TGS files`);let e=new Blob([t]).stream().pipeThrough(new DecompressionStream(`gzip`));n=new Uint8Array(await new Response(e).arrayBuffer())}let r=JSON.parse(new TextDecoder().decode(n));if(!r||typeof r!=`object`||Array.isArray(r))throw Error(`Invalid Lottie JSON`);return r}var un=e=>Number.parseInt(e.replace(`#`,``),16),dn=e=>e.rarity_kind===`permille`?`${e.rarity_permille}‰`:e.rarity_kind;function fn({gift:e,onClose:t,onPublished:n}){let{t:r}=U(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!0),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(`100`),[_,v]=(0,g.useState)(`1000`),[y,S]=(0,g.useState)(`gift-${e.GiftID}`),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(()=>an(`model`)),[D,O]=(0,g.useState)(()=>an(`pattern`)),[j,N]=(0,g.useState)(on);(0,g.useEffect)(()=>{let t=!1;return x.giftCollectibles(e.GiftID).then(n=>{t||(a(n),n.found&&(h(String(n.upgrade_stars??100)),v(String(n.supply_total??1e3)),S(n.slug_prefix??`gift-${e.GiftID}`)))}).catch(e=>d(b(e))).finally(()=>{t||s(!1)}),()=>{t=!0}},[e.GiftID]);let P=(0,g.useMemo)(()=>({models:T.reduce((e,t)=>e+Number(t.rarity||0),0),patterns:D.reduce((e,t)=>e+Number(t.rarity||0),0),backdrops:j.reduce((e,t)=>e+Number(t.rarity||0),0)}),[T,D,j]),F=()=>p(null),I=(e,t,n)=>{(e===`models`?E:O)(e=>e.map(e=>e.key===t?{...e,...n}:e)),F()};async function L(e,t,n){if(I(e,t.key,{file:n,animation:null,fileError:``}),n)try{let r=await ln(n);I(e,t.key,{animation:r,fileError:``})}catch(n){I(e,t.key,{animation:null,fileError:b(n)})}}function ee(e,t=``){if(!C.trim())throw Error(r(`action.reasonRequired`));if(T.length<2||D.length<2||j.length<2)throw Error(r(`collectibles.minimumAttributes`));let n=j.map(e=>Number(e.backdropID));if(new Set(n).size!==n.length)throw Error(r(`collectibles.duplicateBackdropID`));for(let e of[...T,...D])if(!e.file)throw Error(r(`collectibles.fileRequired`));let i=new FormData,a=e=>e.map(e=>({name:e.name.trim(),rarity_permille:Number(e.rarity),sort_order:Number(e.sortOrder),file_key:e.key}));i.set(`metadata`,JSON.stringify({command_id:t,reason:C.trim(),confirm:e,upgrade_stars:m,supply_total:Number(_),slug_prefix:y.trim().toLowerCase(),models:a(T),patterns:a(D),backdrops:j.map(e=>({name:e.name.trim(),backdrop_id:Number(e.backdropID),rarity_permille:Number(e.rarity),sort_order:Number(e.sortOrder),center_color:un(e.center),edge_color:un(e.edge),pattern_color:un(e.pattern),text_color:un(e.text)}))}));for(let e of[...T,...D])i.set(e.key,e.file,e.file.name);return i}async function R(){l(!0),d(``),p(null);try{p(await x.publishGiftCollectibles(e.GiftID,ee(!1)))}catch(e){d(b(e))}finally{l(!1)}}async function te(){if(f){l(!0),d(``);try{await x.publishGiftCollectibles(e.GiftID,ee(!0,f.command_id)),n(),t()}catch(e){d(b(e))}finally{l(!1)}}}let ne=(e,t,n)=>(0,H.jsxs)(`section`,{className:`collectible-section`,children:[(0,H.jsxs)(`div`,{className:`collectible-section-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.${e}`)}),(0,H.jsx)(`span`,{children:r(`collectibles.rarityHint`)})]}),(0,H.jsxs)(`div`,{className:`collectible-section-tools`,children:[(0,H.jsxs)(K,{tone:P[e]>0?`good`:`neutral`,children:[P[e],`‰`]}),(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>{n(tn([...t,nn(e===`models`?`model`:`pattern`,t.length)])),F()},children:[(0,H.jsx)(ye,{size:13}),r(`collectibles.addAttribute`)]})]})]}),(0,H.jsx)(`div`,{className:`collectible-rows`,children:t.map((i,a)=>(0,H.jsxs)(`div`,{className:`collectible-row animated`,children:[(0,H.jsx)(`div`,{className:`collectible-row-index`,children:a+1}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`common.name`)}),(0,H.jsx)(`input`,{value:i.name,maxLength:128,onChange:t=>I(e,i.key,{name:t.target.value})})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.rarity`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,max:`1000`,value:i.rarity,onChange:t=>I(e,i.key,{rarity:t.target.value})})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`gifts.sortOrder`)}),(0,H.jsx)(`input`,{type:`number`,value:i.sortOrder,onChange:t=>I(e,i.key,{sortOrder:t.target.value})})]}),(0,H.jsxs)(`label`,{className:`collectible-file`,children:[(0,H.jsx)(`span`,{children:r(`gifts.animation`)}),(0,H.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.lottie,application/json,application/x-tgsticker`,onChange:t=>void L(e,i,t.target.files?.[0]??null)}),(0,H.jsxs)(`em`,{children:[(0,H.jsx)(ae,{size:13}),i.file?.name??r(`gifts.chooseFile`)]})]}),(0,H.jsx)(`div`,{className:`collectible-inline-preview`,children:i.animation?(0,H.jsx)(sn,{data:i.animation,compact:!0}):(0,H.jsx)(M,{size:16})}),(0,H.jsx)(`button`,{className:`icon-btn danger`,type:`button`,disabled:t.length<=2,onClick:()=>{n(tn(t.filter(e=>e.key!==i.key))),F()},"aria-label":r(`collectibles.remove`),children:(0,H.jsx)(Ae,{size:14})}),i.fileError&&(0,H.jsx)(`span`,{className:`collectible-file-error`,children:i.fileError})]},i.key))})]});return(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal collectible-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`collectibles.title`,{id:e.GiftID}),children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:r(`collectibles.eyebrow`)}),(0,H.jsx)(`h2`,{children:r(`collectibles.title`,{id:e.GiftID})}),(0,H.jsx)(`p`,{children:e.Title||`Gift #${e.GiftID}`})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,disabled:c,"aria-label":r(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body collectible-modal-body`,children:[o?(0,H.jsxs)(`div`,{className:`collectible-loading`,children:[(0,H.jsx)(A,{className:`spin`}),r(`common.loading`)]}):i?.found?(0,H.jsxs)(`section`,{className:`collectible-active`,children:[(0,H.jsxs)(`div`,{className:`collectible-active-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(se,{size:18}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.activeRevision`,{revision:i.revision??0})}),(0,H.jsxs)(`span`,{children:[i.slug_prefix,` · ⭐ `,i.upgrade_stars,` · `,i.issued,` / `,i.supply_total]})]})]}),(0,H.jsx)(K,{tone:`good`,children:r(`collectibles.published`)})]}),(0,H.jsxs)(`div`,{className:`collectible-active-grid`,children:[[...i.models??[],...i.patterns??[]].map(t=>(0,H.jsxs)(`article`,{children:[(0,H.jsx)(cn,{giftID:e.GiftID,attribute:t}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`strong`,{children:[t.name,t.crafted&&(0,H.jsx)(K,{children:`crafted`})]}),(0,H.jsxs)(`span`,{children:[r(`collectibles.${t.kind}`),` · `,dn(t)]})]})]},`${t.kind}-${t.id}`)),(i.backdrops??[]).map(e=>(0,H.jsxs)(`article`,{children:[(0,H.jsx)(`div`,{className:`collectible-backdrop-preview`,style:{background:`radial-gradient(circle, #${(e.center_color??0).toString(16).padStart(6,`0`)}, #${(e.edge_color??0).toString(16).padStart(6,`0`)})`,color:`#${(e.text_color??16777215).toString(16).padStart(6,`0`)}`},children:`Aa`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:e.name}),(0,H.jsxs)(`span`,{children:[r(`collectibles.backdrop`),` · `,dn(e)]})]})]},`backdrop-${e.id}`))]})]}):(0,H.jsxs)(`div`,{className:`collectible-empty`,children:[(0,H.jsx)(se,{size:22}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.noPool`)}),(0,H.jsx)(`span`,{children:r(`collectibles.noPoolHint`)})]})]}),(0,H.jsxs)(`section`,{className:`collectible-definition`,children:[(0,H.jsxs)(`div`,{className:`collectible-definition-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.publishNew`)}),(0,H.jsx)(`span`,{children:r(`collectibles.immutableHint`)})]}),(0,H.jsxs)(`div`,{className:`gift-format-chips`,children:[(0,H.jsx)(`span`,{children:`TGS`}),(0,H.jsx)(`span`,{children:`Lottie JSON`})]})]}),(0,H.jsxs)(`div`,{className:`gift-fields-grid collectible-main-fields`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.upgradeStars`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:m,onChange:e=>{h(e.target.value),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.supply`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:_,onChange:e=>{v(e.target.value),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.slug`)}),(0,H.jsx)(`input`,{value:y,maxLength:48,onChange:e=>{S(e.target.value.toLowerCase()),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`gifts.reason`)}),(0,H.jsx)(`input`,{value:C,maxLength:1e3,placeholder:r(`gifts.reasonPlaceholder`),onChange:e=>w(e.target.value)})]})]}),ne(`models`,T,E),ne(`patterns`,D,O),(0,H.jsxs)(`section`,{className:`collectible-section`,children:[(0,H.jsxs)(`div`,{className:`collectible-section-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.backdrops`)}),(0,H.jsx)(`span`,{children:r(`collectibles.colorHint`)})]}),(0,H.jsxs)(`div`,{className:`collectible-section-tools`,children:[(0,H.jsxs)(K,{tone:P.backdrops>0?`good`:`neutral`,children:[P.backdrops,`‰`]}),(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>{N(tn([...j,rn(j)])),F()},children:[(0,H.jsx)(ye,{size:13}),r(`collectibles.addAttribute`)]})]})]}),(0,H.jsx)(`div`,{className:`collectible-rows`,children:j.map((e,t)=>(0,H.jsxs)(`div`,{className:`collectible-row backdrop`,children:[(0,H.jsx)(`div`,{className:`collectible-row-index`,children:t+1}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`common.name`)}),(0,H.jsx)(`input`,{value:e.name,maxLength:128,onChange:t=>{N(j.map(n=>n.key===e.key?{...n,name:t.target.value}:n)),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.backdropID`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,value:e.backdropID,onChange:t=>{N(j.map(n=>n.key===e.key?{...n,backdropID:t.target.value}:n)),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`collectibles.rarity`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,max:`1000`,value:e.rarity,onChange:t=>{N(j.map(n=>n.key===e.key?{...n,rarity:t.target.value}:n)),F()}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`gifts.sortOrder`)}),(0,H.jsx)(`input`,{type:`number`,value:e.sortOrder,onChange:t=>{N(j.map(n=>n.key===e.key?{...n,sortOrder:t.target.value}:n)),F()}})]}),[`center`,`edge`,`pattern`,`text`].map(t=>(0,H.jsxs)(`label`,{className:`collectible-color`,children:[(0,H.jsx)(`span`,{children:r(`collectibles.color.${t}`)}),(0,H.jsx)(`input`,{type:`color`,value:e[t],onChange:n=>{N(j.map(r=>r.key===e.key?{...r,[t]:n.target.value}:r)),F()}})]},t)),(0,H.jsx)(`div`,{className:`collectible-backdrop-preview`,style:{background:`radial-gradient(circle, ${e.center}, ${e.edge})`,color:e.text},children:`Aa`}),(0,H.jsx)(`button`,{className:`icon-btn danger`,type:`button`,disabled:j.length<=2,onClick:()=>{N(tn(j.filter(t=>t.key!==e.key))),F()},"aria-label":r(`collectibles.remove`),children:(0,H.jsx)(Ae,{size:14})})]},e.key))})]})]}),u&&(0,H.jsx)(pt,{children:u}),f&&(0,H.jsxs)(`div`,{className:`gift-validation`,children:[(0,H.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,H.jsx)(k,{size:17}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:r(`collectibles.validationReady`)}),(0,H.jsx)(`span`,{children:r(`collectibles.validationHint`)})]})]}),(0,H.jsx)(`pre`,{children:JSON.stringify(f.details,null,2)})]})]}),(0,H.jsxs)(`div`,{className:`modal-actions`,children:[(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:t,disabled:c,children:r(`common.close`)}),(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:R,disabled:c,children:[c?(0,H.jsx)(A,{className:`spin`,size:15}):(0,H.jsx)(we,{size:15}),r(`gifts.validate`)]}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:te,disabled:c||!f,children:[(0,H.jsx)(je,{size:15}),r(`collectibles.publish`)]})]})]})}),document.body)}var pn=!1;function mn(e){return e.model_count+e.pattern_count+e.backdrop_count}function hn(e){let t=Number(e);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function gn({giftID:e,revision:t,compact:n=!1}){let r=(0,g.useRef)(null),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``);(0,g.useEffect)(()=>{let t=!1;return x.giftAnimation(e).then(e=>{t||!r.current||(i.current?.destroy(),i.current=Zt.default.loadAnimation({container:r.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)}))}).catch(e=>c(b(e))),()=>{t=!0,i.current?.destroy(),i.current=null}},[e,t]);function l(){i.current&&(a?i.current.pause():i.current.play(),o(!a))}return(0,H.jsxs)(`div`,{className:`gift-animation-shell ${n?`compact`:``}`,children:[(0,H.jsx)(`div`,{className:`gift-animation`,ref:r,children:s&&(0,H.jsx)(`span`,{children:s})}),(0,H.jsx)(`button`,{className:`gift-play`,type:`button`,onClick:l,"aria-label":a?`Pause`:`Play`,children:a?(0,H.jsx)(_e,{size:14}):(0,H.jsx)(ve,{size:14})})]})}function _n({sourceGiftID:e}){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let n=!1,r=null;return x.officialGiftAnimation(e).then(e=>{n||!t.current||(r=Zt.default.loadAnimation({container:t.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:structuredClone(e)}))}).catch(()=>void 0),()=>{n=!0,r?.destroy()}},[e]),(0,H.jsx)(`div`,{className:`gift-animation-shell`,children:(0,H.jsx)(`div`,{className:`gift-animation`,ref:t})})}function vn(){let{t:e}=U(),[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(`official`),[p,m]=(0,g.useState)([]),[h,_]=(0,g.useState)(0),[y,S]=(0,g.useState)([]),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(`all`),[D,O]=(0,g.useState)(``),[j,M]=(0,g.useState)(!0),[N,P]=(0,g.useState)(`0`),[F,I]=(0,g.useState)(`0`),[L,ee]=(0,g.useState)(``),[ne,re]=(0,g.useState)(`0`),[ie,oe]=(0,g.useState)(``),[ce,le]=(0,g.useState)(`50`),[ue,z]=(0,g.useState)(`50`),[de,fe]=(0,g.useState)(`0`),[pe,me]=(0,g.useState)(!0),[he,ge]=(0,g.useState)(``),[ve,B]=(0,g.useState)(null),[V,Se]=(0,g.useState)(!1),[Ce,Te]=(0,g.useState)(``),[Ee,De]=(0,g.useState)(``),[Oe,ke]=(0,g.useState)(null),[Ae,Me]=(0,g.useState)([]),[Ne,Fe]=(0,g.useState)(!0),[Ie,Le]=(0,g.useState)(``),[Re,ze]=(0,g.useState)(!1),[Be,W]=(0,g.useState)({done:0,total:0}),[Ve,He]=(0,g.useState)(``),[Ue,We]=(0,g.useState)(null),[Ge,Ke]=(0,g.useState)(new Set),[qe,Je]=(0,g.useState)(``),[Ye,G]=(0,g.useState)(!1),[Xe,Ze]=(0,g.useState)(``),[Qe,$e]=(0,g.useState)(10),[et,tt]=(0,g.useState)(1);async function nt(){Te(``);try{n((await x.gifts()).Gifts??[])}catch(e){Te(b(e))}}(0,g.useEffect)(()=>{nt()},[]),(0,g.useEffect)(()=>{!a||d!=="default"||p.length>0||x.defaultGifts().then(e=>m(e.gifts??[])).catch(e=>De(b(e)))},[a,d,p.length]),(0,g.useEffect)(()=>{!a||d!==`official`||y.length>0||x.officialGifts().then(e=>S(e.gifts??[])).catch(e=>De(b(e)))},[a,d,y.length]),(0,g.useMemo)(()=>p.find(e=>e.id===h)??null,[p,h]);let rt=(0,g.useMemo)(()=>y.find(e=>e.source_gift_id===D)??null,[y,D]),it=(0,g.useMemo)(()=>({all:y.length,upgrade:y.filter(e=>e.can_upgrade).length,craft:y.filter(e=>e.can_craft).length,basic:y.filter(e=>!e.can_upgrade).length}),[y]),ot=(0,g.useMemo)(()=>{let e=C.trim().toLowerCase();return y.filter(t=>(T===`all`||T===`upgrade`&&t.can_upgrade||T===`craft`&&t.can_craft||T===`basic`&&!t.can_upgrade)&&(!e||t.source_gift_id.includes(e)||t.title.toLowerCase().includes(e)))},[y,C,T]),st=(0,g.useMemo)(()=>{let e=r.trim().toLowerCase();return e?t.filter(t=>String(t.GiftID).includes(e)||t.Title.toLowerCase().includes(e)||t.SourceFormat.toLowerCase().includes(e)):t},[t,r]);(0,g.useEffect)(()=>{tt(1)},[r,Qe]);let ct=Qe===`all`?1:Math.max(1,Math.ceil(st.length/Qe)),dt=Math.min(et,ct),ft=(0,g.useMemo)(()=>{if(Qe===`all`)return st;let e=(dt-1)*Qe;return st.slice(e,e+Qe)},[st,dt,Qe]),mt=ft.length===0?0:Qe===`all`?1:(dt-1)*Qe+1,J=mt===0?0:mt+ft.length-1,ht=ft.length>0&&ft.every(e=>Ge.has(e.GiftID));function _t(e){Ke(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function vt(){Ke(e=>{if(ht){let t=new Set(e);for(let e of ft)t.delete(e.GiftID);return t}let t=new Set(e);for(let e of ft)t.add(e.GiftID);return t})}async function yt(t){if(!qe.trim()){Ze(e(`action.reasonRequired`));return}G(!0),Ze(``);let n=Array.from(Ge),r=0;for(let e of n)try{await x.action(`/api/actions/set-gift-enabled`,{gift_id:e,enabled:t,reason:qe.trim(),confirm:!0})}catch{r++}G(!1),r>0?Ze(e(`gifts.bulkStatusFailed`,{failed:r,total:n.length})):(Ke(new Set),Je(``)),await nt()}function xt(t,n=``){if(!l)throw Error(e(`gifts.fileRequired`));if(!he.trim())throw Error(e(`action.reasonRequired`));let r=new FormData;return r.set(`metadata`,JSON.stringify({command_id:n,reason:he.trim(),confirm:t,gift_id:ne,title:ie.trim(),stars:ce,convert_stars:ue,enabled:pe,sort_order:Number(de)})),r.set(`file`,l,l.name),r}function St(t,n=``){if(!h)throw Error(e(`gifts.defaultRequired`));if(!he.trim())throw Error(e(`action.reasonRequired`));return{command_id:n,reason:he.trim(),confirm:t,id:h}}function Ct(t,n=``){if(!D)throw Error(e(`gifts.officialRequired`));if(!he.trim())throw Error(e(`action.reasonRequired`));return{command_id:n,reason:he.trim(),confirm:t,source_gift_id:D,gift_id:ne,title:ie.trim(),stars:ce,convert_stars:ue,enabled:pe,sort_order:Number(de),include_collectible:j,upgrade_stars:N,supply_total:Number(F),slug_prefix:L.trim().toLowerCase()}}function wt(t){O(t.source_gift_id),oe(t.title||e(`gifts.officialUnnamed`,{id:t.source_gift_id})),le(String(t.stars)),z(String(t.convert_stars)),M(t.can_upgrade),P(t.upgrade_stars),I(String(t.availability_total||1)),ee(`official-${t.source_gift_id}`),B(null)}async function Tt(e){ke(e),Me([]),Fe(!0),Le(``),ze(!1),W({done:0,total:0}),He(``),We(null);try{Me(e==="default"?p.length>0?p:(await x.defaultGifts()).gifts??[]:y.length>0?y:(await x.officialGifts()).gifts??[])}catch(e){He(b(e))}}function Et(){Re||ke(null)}async function Dt(){if(!Oe)return;if(!Ie.trim()){He(e(`action.reasonRequired`));return}let t=Oe;ze(!0),He(``),We(null),W({done:0,total:Ae.length});let n=0,r=0,i=0,a=[];for(let e of Ae){let o=t==="default"?e.title:e.title||`#${e.source_gift_id}`;try{let i=t==="default"?await x.importDefaultGift({command_id:`bulk-default-gift-${e.id}`,reason:Ie.trim(),confirm:!0,id:e.id,enabled:Ne}):await x.importOfficialGift({command_id:`bulk-official-gift-${e.source_gift_id}`,reason:Ie.trim(),confirm:!0,source_gift_id:e.source_gift_id,include_collectible:e.can_upgrade,enabled:Ne});i.already_executed||i.details?.skipped?r++:n++}catch(e){e instanceof v&&e.message===`COMMAND_ID_CONFLICT`?r++:(i++,a.push(`${o}: ${b(e)}`))}W(e=>({...e,done:e.done+1}))}ze(!1),We({imported:n,skipped:r,failed:i,errors:a}),await nt()}async function Ot(){Se(!0),De(``),B(null);try{B(d==="default"?await x.importDefaultGift(St(!1)):d===`official`?await x.importOfficialGift(Ct(!1)):await x.importGift(xt(!1)))}catch(e){De(b(e))}finally{Se(!1)}}async function kt(){if(ve){Se(!0),De(``);try{d==="default"?await x.importDefaultGift(St(!0,ve.command_id)):d===`official`?await x.importOfficialGift(Ct(!0,ve.command_id)):await x.importGift(xt(!0,ve.command_id)),B(null),u(null),re(`0`),oe(``),_(0),O(``),await nt(),o(!1)}catch(e){De(b(e))}finally{Se(!1)}}}function At(){re(`0`),oe(``),le(`50`),z(`50`),fe(`0`),me(!0),ge(``),u(null),B(null),De(``),f(`official`),_(0),O(``),w(``),E(`all`),ze(!1),W({done:0,total:0}),He(``),o(!0)}function jt(e){re(e.GiftID),oe(e.Title),le(String(e.Stars)),z(String(e.ConvertStars)),fe(String(e.SortOrder)),me(e.Enabled),ge(``),u(null),B(null),De(``),f(`file`),_(0),O(``),o(!0)}let X=d==="default"?h>0:d===`official`?!!D:!!l;return(0,H.jsxs)(lt,{title:e(`gifts.pageTitle`),eyebrow:e(`gifts.eyebrow`),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>nt(),disabled:V,children:[(0,H.jsx)(be,{size:15}),` `,e(`common.refresh`)]}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:At,children:[(0,H.jsx)(ye,{size:15}),` `,e(`gifts.add`)]})]}),children:[Ce&&(0,H.jsx)(pt,{children:Ce}),(0,H.jsxs)(`div`,{className:`metric-row gift-metrics`,children:[(0,H.jsx)(q,{label:e(`gifts.total`),value:String(t.length)}),(0,H.jsx)(q,{label:e(`gifts.enabled`),value:String(t.filter(e=>e.Enabled).length),tone:`good`}),(0,H.jsx)(q,{label:e(`gifts.received`),value:t.reduce((e,t)=>e+BigInt(t.ReceivedCount),0n).toString()}),(0,H.jsx)(q,{label:e(`gifts.formats`),value:`TGS / Lottie`})]}),(0,H.jsx)(ut,{children:(0,H.jsxs)(`div`,{className:`toolbar`,children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:e(`gifts.searchPlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`gift-page-size`,children:[(0,H.jsx)(`span`,{children:e(`gifts.perPage`)}),(0,H.jsxs)(`select`,{value:String(Qe),onChange:e=>$e(e.target.value===`all`?`all`:Number(e.target.value)),children:[(0,H.jsx)(`option`,{value:`10`,children:`10`}),(0,H.jsx)(`option`,{value:`20`,children:`20`}),(0,H.jsx)(`option`,{value:`50`,children:`50`}),(0,H.jsx)(`option`,{value:`100`,children:`100`}),(0,H.jsx)(`option`,{value:`all`,children:e(`gifts.perPageAll`)})]})]}),(0,H.jsx)(`span`,{className:`gift-list-summary`,children:e(`gifts.listSummary`,{shown:st.length,total:t.length})})]})}),Ge.size>0&&(0,H.jsxs)(`div`,{className:`gift-bulk-toolbar`,children:[(0,H.jsx)(`span`,{className:`gift-bulk-count`,children:e(`gifts.bulkSelected`,{count:Ge.size})}),(0,H.jsxs)(`label`,{className:`gift-reason-field gift-bulk-reason`,children:[(0,H.jsx)(`span`,{children:e(`gifts.reason`)}),(0,H.jsx)(`input`,{value:qe,placeholder:e(`gifts.reasonPlaceholder`),onChange:e=>Je(e.target.value)})]}),(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>yt(!0),disabled:Ye,children:[Ye?(0,H.jsx)(A,{className:`spin`,size:14}):(0,H.jsx)(k,{size:14}),` `,e(`gifts.bulkEnable`)]}),(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>yt(!1),disabled:Ye,children:[Ye?(0,H.jsx)(A,{className:`spin`,size:14}):(0,H.jsx)(_e,{size:14}),` `,e(`gifts.bulkDisable`)]}),(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>{Ke(new Set),Ze(``)},disabled:Ye,children:e(`common.close`)}),Xe&&(0,H.jsx)(`span`,{className:`gift-bulk-error`,children:Xe})]}),(0,H.jsx)(`div`,{className:`table-wrap gift-table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table gift-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{className:`gift-select-col`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:ht,onChange:vt,"aria-label":e(`gifts.bulkSelectAll`)})}),(0,H.jsx)(`th`,{children:e(`gifts.animation`)}),(0,H.jsx)(`th`,{children:e(`gifts.idRevision`)}),(0,H.jsx)(`th`,{children:e(`gifts.title`)}),(0,H.jsx)(`th`,{children:e(`gifts.price`)}),(0,H.jsx)(`th`,{children:e(`gifts.source`)}),(0,H.jsx)(`th`,{children:e(`gifts.received`)}),(0,H.jsx)(`th`,{children:e(`common.status`)}),(0,H.jsx)(`th`,{children:e(`common.updatedAt`)}),(0,H.jsx)(`th`,{children:e(`common.actions`)})]})}),(0,H.jsxs)(`tbody`,{children:[ft.map(t=>(0,H.jsxs)(`tr`,{className:t.Enabled?``:`gift-row-disabled`,children:[(0,H.jsx)(`td`,{className:`gift-select-col`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:Ge.has(t.GiftID),onChange:()=>_t(t.GiftID),"aria-label":e(`gifts.bulkSelectOne`,{id:t.GiftID})})}),(0,H.jsx)(`td`,{children:(0,H.jsx)(gn,{giftID:t.GiftID,revision:t.Revision,compact:!0})}),(0,H.jsxs)(`td`,{className:`mono`,children:[t.GiftID,` / `,t.Revision]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(`strong`,{className:`gift-table-title`,children:t.Title||`Gift #${t.GiftID}`}),(0,H.jsxs)(`span`,{className:`gift-sort-order`,children:[e(`gifts.sortOrder`),`: `,t.SortOrder]})]}),(0,H.jsxs)(`td`,{children:[(0,H.jsxs)(`strong`,{className:`gift-table-price`,children:[`⭐ `,t.Stars]}),(0,H.jsxs)(`span`,{className:`gift-convert-price`,children:[`→ `,t.ConvertStars]})]}),(0,H.jsxs)(`td`,{children:[(0,H.jsx)(K,{children:t.SourceFormat}),(0,H.jsx)(`span`,{className:`gift-source-size`,children:hn(t.AnimationSize)})]}),(0,H.jsx)(`td`,{children:t.ReceivedCount}),(0,H.jsx)(`td`,{children:(0,H.jsx)(K,{tone:t.Enabled?`good`:`neutral`,children:t.Enabled?e(`common.enabled`):e(`common.disabled`)})}),(0,H.jsx)(`td`,{children:at(t.UpdatedAt)}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`div`,{className:`gift-table-actions`,children:[(0,H.jsxs)(`button`,{className:`btn compact-btn collectible-button`,type:`button`,onClick:()=>c(t),children:[(0,H.jsx)(se,{size:13}),e(`collectibles.manage`)]}),(0,H.jsx)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>jt(t),children:e(`gifts.replace`)}),(0,H.jsx)(Y,{compact:!0,tone:`neutral`,label:t.Enabled?e(`gifts.disable`):e(`gifts.enable`),path:`/api/actions/set-gift-enabled`,payload:()=>({gift_id:t.GiftID,enabled:!t.Enabled}),onDone:()=>void nt()})]})})]},t.GiftID)),ft.length===0&&(0,H.jsx)(gt,{colSpan:10})]})]})}),Qe!==`all`&&st.length>0&&(0,H.jsxs)(`div`,{className:`gift-pager`,children:[(0,H.jsx)(`span`,{className:`gift-pager-range`,children:e(`gifts.pageRange`,{start:mt,end:J,total:st.length})}),(0,H.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>tt(e=>Math.max(1,e-1)),disabled:dt<=1,children:[(0,H.jsx)(R,{size:14}),` `,e(`gifts.pagePrev`)]}),(0,H.jsx)(`span`,{className:`gift-pager-page`,children:e(`gifts.pageOf`,{page:dt,total:ct})}),(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>tt(e=>Math.min(ct,e+1)),disabled:dt>=ct,children:[e(`gifts.pageNext`),` `,(0,H.jsx)(te,{size:14})]})]})]}),a&&(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal gift-import-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":ne===`0`?e(`gifts.importTitle`):e(`gifts.newRevision`,{id:ne}),children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:e(`gifts.importEyebrow`)}),(0,H.jsx)(`h2`,{children:ne===`0`?e(`gifts.importTitle`):e(`gifts.newRevision`,{id:ne})})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:()=>o(!1),disabled:V,"aria-label":e(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body gift-import-modal-body`,children:[(0,H.jsxs)(`div`,{className:`command-steps`,children:[(0,H.jsxs)(`div`,{className:`command-step ${X?`done`:`active`}`,children:[(0,H.jsx)(`span`,{children:`1`}),(0,H.jsx)(`strong`,{children:e(`gifts.stepDetails`)})]}),(0,H.jsxs)(`div`,{className:`command-step ${ve?`done`:X?`active`:``}`,children:[(0,H.jsx)(`span`,{children:`2`}),(0,H.jsx)(`strong`,{children:e(`gifts.stepValidate`)})]}),(0,H.jsxs)(`div`,{className:`command-step ${ve?`active`:``}`,children:[(0,H.jsx)(`span`,{children:`3`}),(0,H.jsx)(`strong`,{children:e(`gifts.stepImport`)})]})]}),ne===`0`&&(0,H.jsxs)(`div`,{className:`gift-source-tabs`,children:[pn,(0,H.jsx)(`button`,{className:`btn ${d===`official`?`primary`:``}`,type:`button`,onClick:()=>{f(`official`),B(null)},children:e(`gifts.officialSource`)}),(0,H.jsx)(`button`,{className:`btn ${d===`file`?`primary`:``}`,type:`button`,onClick:()=>{f(`file`),B(null)},children:e(`gifts.fileSource`)})]}),d===`official`&&ne===`0`?(0,H.jsxs)(`section`,{className:`official-gift-picker`,children:[(0,H.jsxs)(`div`,{className:`gift-import-note`,children:[(0,H.jsx)(`span`,{children:e(`gifts.officialHint`)}),(0,H.jsxs)(`div`,{className:`gift-format-chips`,children:[(0,H.jsx)(`span`,{children:y.length}),(0,H.jsx)(`span`,{children:`SHA-256`})]})]}),(0,H.jsx)(`div`,{className:`official-gift-bulk-import`,children:(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>Tt(`official`),children:[(0,H.jsx)(je,{size:14}),` `,e(`gifts.importAllOfficial`)]})}),(0,H.jsxs)(`div`,{className:`official-gift-tools`,children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),placeholder:e(`gifts.officialSearch`)})]}),(0,H.jsx)(`span`,{children:e(`gifts.officialResults`,{shown:ot.length,total:y.length})})]}),(0,H.jsx)(`div`,{className:`official-gift-categories`,role:`group`,"aria-label":e(`gifts.officialCategoryLabel`),children:[`all`,`upgrade`,`craft`,`basic`].map(t=>(0,H.jsxs)(`button`,{className:T===t?`active`:``,type:`button`,"aria-pressed":T===t,onClick:()=>E(t),children:[e(`gifts.officialCategory.${t}`),(0,H.jsx)(`span`,{children:it[t]})]},t))}),(0,H.jsxs)(`div`,{className:`official-gift-list`,role:`listbox`,"aria-label":e(`gifts.officialSelect`),children:[ot.map(t=>{let n=t.source_gift_id===D;return(0,H.jsxs)(`button`,{className:`official-gift-option ${n?`selected`:``}`,type:`button`,role:`option`,"aria-selected":n,onClick:()=>wt(t),children:[(0,H.jsxs)(`span`,{className:`official-gift-option-head`,children:[(0,H.jsx)(`strong`,{children:t.title||e(`gifts.officialUnnamed`,{id:t.source_gift_id})}),(0,H.jsxs)(`span`,{className:`mono`,children:[`#`,t.source_gift_id]})]}),(0,H.jsxs)(`span`,{className:`official-gift-option-meta`,children:[(0,H.jsxs)(`span`,{children:[`⭐ `,t.stars]}),(0,H.jsx)(`span`,{children:e(`gifts.officialAttributes`,{count:mn(t)})})]}),(0,H.jsxs)(`span`,{className:`official-gift-capabilities`,children:[(0,H.jsx)(`span`,{className:t.can_upgrade?`yes`:`no`,children:t.can_upgrade?e(`gifts.canUpgrade`):e(`gifts.cannotUpgrade`)}),(0,H.jsx)(`span`,{className:t.can_craft?`craft`:`no`,children:t.can_craft?e(`gifts.canCraft`):e(`gifts.cannotCraft`)})]})]},t.source_gift_id)}),ot.length===0&&(0,H.jsx)(`div`,{className:`official-gift-empty`,children:e(`gifts.officialEmpty`)})]}),rt&&(0,H.jsxs)(`div`,{className:`official-gift-selected`,children:[(0,H.jsx)(_n,{sourceGiftID:rt.source_gift_id}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:rt.title||e(`gifts.officialUnnamed`,{id:rt.source_gift_id})}),(0,H.jsx)(`span`,{className:`mono`,children:rt.source_gift_id}),(0,H.jsxs)(`small`,{children:[rt.model_count,` `,e(`collectibles.models`),` · `,rt.pattern_count,` `,e(`collectibles.patterns`),` · `,rt.backdrop_count,` `,e(`collectibles.backdrops`)]}),(0,H.jsxs)(`span`,{className:`official-gift-capabilities`,children:[(0,H.jsx)(`span`,{className:rt.can_upgrade?`yes`:`no`,children:rt.can_upgrade?e(`gifts.canUpgrade`):e(`gifts.cannotUpgrade`)}),(0,H.jsx)(`span`,{className:rt.can_craft?`craft`:`no`,children:rt.can_craft?e(`gifts.canCraft`):e(`gifts.cannotCraft`)})]})]})]}),rt?.can_upgrade&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>{M(e.target.checked),B(null)}}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:e(`gifts.includeCollectible`)})]}),j&&(0,H.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`collectibles.upgradeStars`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:N,onChange:e=>{P(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`collectibles.supply`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:F,onChange:e=>{I(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`collectibles.slug`)}),(0,H.jsx)(`input`,{value:L,maxLength:48,onChange:e=>{ee(e.target.value.toLowerCase()),B(null)}})]})]})]}),(0,H.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.title`)}),(0,H.jsx)(`input`,{value:ie,maxLength:128,placeholder:e(`gifts.titlePlaceholder`),onChange:e=>{oe(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.stars`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:ce,onChange:e=>{le(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.convertStars`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,value:ue,onChange:e=>{z(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.sortOrder`)}),(0,H.jsx)(`input`,{type:`number`,value:de,onChange:e=>{fe(e.target.value),B(null)}})]})]}),(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>{me(e.target.checked),B(null)}}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:e(`gifts.enableAfterImport`)})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`gift-import-note`,children:[(0,H.jsx)(`span`,{children:e(`gifts.importHint`)}),(0,H.jsxs)(`div`,{className:`gift-format-chips`,"aria-label":e(`gifts.formats`),children:[(0,H.jsx)(`span`,{children:`TGS`}),(0,H.jsx)(`span`,{children:`Lottie JSON`})]})]}),(0,H.jsxs)(`label`,{className:`gift-file-picker ${l?`has-file`:``}`,children:[(0,H.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.lottie,application/json,application/x-tgsticker`,onChange:e=>{u(e.target.files?.[0]??null),B(null)}}),(0,H.jsx)(`span`,{className:`gift-file-icon`,children:(0,H.jsx)(ae,{size:22})}),(0,H.jsxs)(`span`,{className:`gift-file-copy`,children:[(0,H.jsx)(`span`,{className:`gift-field-label`,children:e(`gifts.animation`)}),(0,H.jsx)(`strong`,{children:l?l.name:e(`gifts.filePrompt`)}),(0,H.jsx)(`small`,{children:l?hn(l.size):e(`gifts.fileHint`)})]}),(0,H.jsx)(`span`,{className:`gift-file-action`,children:e(l?`gifts.changeFile`:`gifts.chooseFile`)})]}),(0,H.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.title`)}),(0,H.jsx)(`input`,{value:ie,maxLength:128,placeholder:e(`gifts.titlePlaceholder`),onChange:e=>{oe(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.stars`)}),(0,H.jsx)(`input`,{type:`number`,min:`1`,value:ce,onChange:e=>{le(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.convertStars`)}),(0,H.jsx)(`input`,{type:`number`,min:`0`,value:ue,onChange:e=>{z(e.target.value),B(null)}})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:e(`gifts.sortOrder`)}),(0,H.jsx)(`input`,{type:`number`,value:de,onChange:e=>{fe(e.target.value),B(null)}})]})]}),(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>{me(e.target.checked),B(null)}}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:e(`gifts.enableAfterImport`)})]})]}),(0,H.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,H.jsx)(`span`,{children:e(`gifts.reason`)}),(0,H.jsx)(`input`,{value:he,placeholder:e(`gifts.reasonPlaceholder`),onChange:e=>ge(e.target.value)})]}),Ee&&(0,H.jsx)(pt,{children:Ee}),ve&&(0,H.jsxs)(`div`,{className:`gift-validation`,children:[(0,H.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,H.jsx)(k,{size:17}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:e(`gifts.validationReady`)}),(0,H.jsx)(`span`,{children:e(`gifts.validationHint`)})]})]}),(0,H.jsx)(`pre`,{children:JSON.stringify(ve.details,null,2)})]})]}),(0,H.jsxs)(`div`,{className:`modal-actions`,children:[(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>o(!1),disabled:V,children:e(`common.close`)}),(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:Ot,disabled:V,children:[V?(0,H.jsx)(A,{className:`spin`,size:15}):(0,H.jsx)(we,{size:15}),e(`gifts.validate`)]}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:kt,disabled:V||!ve,children:[(0,H.jsx)(je,{size:15}),e(`gifts.confirmImport`)]})]})]})}),document.body),Oe&&(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal gift-bulk-import-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(Oe==="default"?`gifts.importAllDefault`:`gifts.importAllOfficial`),children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:e(`gifts.importEyebrow`)}),(0,H.jsx)(`h2`,{children:e(Oe==="default"?`gifts.importAllDefault`:`gifts.importAllOfficial`)})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:Et,disabled:Re,"aria-label":e(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body`,children:[(0,H.jsx)(`div`,{className:`gift-import-note`,children:(0,H.jsx)(`span`,{children:e(`gifts.bulkImportCount`,{count:Ae.length})})}),(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:Ne,disabled:Re,onChange:e=>Fe(e.target.checked)}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:e(`gifts.enableAfterImport`)})]}),(0,H.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,H.jsx)(`span`,{children:e(`gifts.reason`)}),(0,H.jsx)(`input`,{value:Ie,placeholder:e(`gifts.reasonPlaceholder`),disabled:Re,onChange:e=>Le(e.target.value)})]}),Re&&(0,H.jsxs)(`div`,{className:`gift-bulk-import-progress`,children:[(0,H.jsx)(`div`,{className:`gift-bulk-import-progress-bar`,children:(0,H.jsx)(`div`,{style:{width:`${Be.total?Math.round(Be.done/Be.total*100):0}%`}})}),(0,H.jsx)(`span`,{children:e(`gifts.importingProgress`,{done:Be.done,total:Be.total})})]}),Ve&&(0,H.jsx)(pt,{children:Ve}),Ue&&(0,H.jsxs)(`div`,{className:`gift-validation`,children:[(0,H.jsxs)(`div`,{className:`gift-validation-head`,children:[(0,H.jsx)(k,{size:17}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:e(`gifts.bulkImportDone`)}),(0,H.jsx)(`span`,{children:e(`gifts.bulkImportSummary`,{imported:Ue.imported,skipped:Ue.skipped,failed:Ue.failed})})]})]}),Ue.errors.length>0&&(0,H.jsx)(`pre`,{children:Ue.errors.join(` -`)})]})]}),(0,H.jsxs)(`div`,{className:`modal-actions`,children:[(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:Et,disabled:Re,children:e(`common.close`)}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:Dt,disabled:Re||Ae.length===0,children:[Re?(0,H.jsx)(A,{className:`spin`,size:15}):(0,H.jsx)(je,{size:15}),` `,e(`gifts.startBulkImport`)]})]})]})}),document.body),s&&(0,H.jsx)(fn,{gift:s,onClose:()=>c(null),onPublished:()=>void nt()})]})}function yn({documentID:e,className:t=``,showError:n=!0}){let r=(0,g.useRef)(null),i=(0,g.useRef)(null),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let t=!1,n=null;return o(``),c(null),fetch(x.stickerDocumentAnimationURL(e),{credentials:`same-origin`}).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||e.statusText)}if((e.headers.get(`content-type`)??``).includes(`json`)){let n=await e.json();if(t||!r.current)return;i.current?.destroy(),i.current=Zt.default.loadAnimation({container:r.current,renderer:`canvas`,loop:!0,autoplay:!0,animationData:n});return}let a=await e.blob();t||(n=URL.createObjectURL(a),c(n))}).catch(e=>{t||o(b(e))}),()=>{t=!0,i.current?.destroy(),i.current=null,n&&URL.revokeObjectURL(n)}},[e]),(0,H.jsxs)(`div`,{className:`sticker-doc-cell ${t}`.trim(),children:[s?(0,H.jsx)(`img`,{className:`sticker-doc-image`,src:s,alt:``}):(0,H.jsx)(`div`,{className:`sticker-doc-canvas`,ref:r}),a&&n&&(0,H.jsx)(`span`,{className:`sticker-doc-error`,children:a})]})}function bn({kind:e,onClose:t,onCreated:n}){let{t:r}=U(),i=e===`emoji`?`emoji`:`sticker`,[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(``);async function S(){if(!a.trim()||!s.trim()||!l.trim()||!d){y(r(`stickers.createFieldsRequired`,{noun:i}));return}if(!p.trim()){y(r(`action.reasonRequired`));return}_(!0),y(``);try{let r=new FormData;r.set(`metadata`,JSON.stringify({command_id:``,reason:p.trim(),confirm:!0,title:a.trim(),short_name:s.trim().toLowerCase(),kind:e,emoji:l.trim()})),r.set(`file`,d,d.name),await x.createStickerSet(r),n(),t()}catch(e){y(b(e))}finally{_(!1)}}return(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`stickers.createTitle`,{noun:i}),children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:r(`stickers.createEyebrow`)}),(0,H.jsx)(`h2`,{children:r(`stickers.createTitle`,{noun:i})})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,disabled:h,"aria-label":r(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body`,children:[(0,H.jsxs)(`div`,{className:`gift-fields-grid`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`stickers.title`)}),(0,H.jsx)(`input`,{value:a,maxLength:64,onChange:e=>o(e.target.value)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`stickers.shortName`)}),(0,H.jsx)(`input`,{value:s,maxLength:32,onChange:e=>c(e.target.value),placeholder:r(`stickers.shortNamePlaceholder`)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:r(`stickers.emoji`)}),(0,H.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:r(`stickers.emojiPlaceholder`)})]})]}),(0,H.jsxs)(`label`,{className:`gift-file-picker ${d?`has-file`:``}`,children:[(0,H.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.webp,application/json,application/x-tgsticker,image/webp`,onChange:e=>f(e.target.files?.[0]??null)}),(0,H.jsxs)(`span`,{className:`gift-file-copy`,children:[(0,H.jsx)(`span`,{className:`gift-field-label`,children:r(`stickers.firstSticker`,{noun:i})}),(0,H.jsx)(`strong`,{children:d?d.name:r(`stickers.filePrompt`)})]}),(0,H.jsx)(`span`,{className:`gift-file-action`,children:r(d?`gifts.changeFile`:`gifts.chooseFile`)})]}),(0,H.jsxs)(`label`,{className:`gift-reason-field`,children:[(0,H.jsx)(`span`,{children:r(`gifts.reason`)}),(0,H.jsx)(`input`,{value:p,placeholder:r(`gifts.reasonPlaceholder`),onChange:e=>m(e.target.value)})]}),v&&(0,H.jsx)(pt,{children:v})]}),(0,H.jsxs)(`div`,{className:`modal-actions`,children:[(0,H.jsx)(`button`,{className:`btn`,type:`button`,onClick:t,disabled:h,children:r(`common.close`)}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:S,disabled:h,children:[h?(0,H.jsx)(A,{className:`spin`,size:15}):(0,H.jsx)(je,{size:15}),r(`stickers.create`,{noun:i})]})]})]})}),document.body)}var xn=24;function Sn({set:e,onClose:t}){let{t:n}=U(),r=e.Kind===`emoji`?`emoji`:`sticker`,[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(1),u=(0,g.useCallback)(()=>{let t=!1;return s(``),x.stickerSetDocuments(e.ID).then(e=>{t||a(e.document_ids??[])}).catch(e=>{t||s(b(e))}),()=>{t=!0}},[e.ID]);(0,g.useEffect)(()=>(a(null),l(1),u()),[u]);let d=i?.length??0,f=Math.max(1,Math.ceil(d/xn)),p=Math.min(c,f),m=(p-1)*xn,h=i?.slice(m,m+xn)??[],_=h.length===0?0:m+1,v=_===0?0:_+h.length-1;return(0,bt.createPortal)((0,H.jsx)(`div`,{className:`modal-backdrop`,role:`presentation`,children:(0,H.jsxs)(`section`,{className:`modal command-modal sticker-preview-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e.Title||`#${e.ID}`,children:[(0,H.jsxs)(`div`,{className:`modal-head`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`eyebrow`,children:n(`stickers.previewEyebrow`)}),(0,H.jsx)(`h2`,{children:e.Title||`#${e.ID}`})]}),(0,H.jsx)(`button`,{className:`icon-btn`,type:`button`,onClick:t,"aria-label":n(`action.close`),children:(0,H.jsx)(Pe,{size:15})})]}),(0,H.jsxs)(`div`,{className:`command-body`,children:[(0,H.jsx)(Cn,{setID:e.ID,noun:r,onAdded:u}),o&&(0,H.jsx)(pt,{children:o}),!o&&i===null&&(0,H.jsxs)(`div`,{className:`loading-line`,children:[(0,H.jsx)(A,{className:`spin`,size:18}),` `,n(`common.loading`)]}),i!==null&&d===0&&!o&&(0,H.jsx)(`div`,{className:`empty-panel`,children:n(`stickers.previewEmpty`)}),h.length>0&&(0,H.jsx)(`div`,{className:`sticker-doc-grid`,children:h.map(t=>(0,H.jsxs)(`div`,{className:`sticker-doc-grid-cell`,children:[(0,H.jsx)(yn,{documentID:t}),(0,H.jsx)(Y,{compact:!0,tone:`danger`,label:n(`stickers.removeSticker`,{noun:r}),icon:(0,H.jsx)(Ae,{size:12}),path:`/api/actions/remove-sticker-from-set`,payload:()=>({set_id:e.ID,document_id:t}),onDone:u})]},t))},p),d>xn&&(0,H.jsxs)(`div`,{className:`gift-pager`,children:[(0,H.jsx)(`span`,{className:`gift-pager-range`,children:n(`gifts.pageRange`,{start:_,end:v,total:d})}),(0,H.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>l(e=>Math.max(1,e-1)),disabled:p<=1,children:[(0,H.jsx)(R,{size:14}),` `,n(`gifts.pagePrev`)]}),(0,H.jsx)(`span`,{className:`gift-pager-page`,children:n(`gifts.pageOf`,{page:p,total:f})}),(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>l(e=>Math.min(f,e+1)),disabled:p>=f,children:[n(`gifts.pageNext`),` `,(0,H.jsx)(te,{size:14})]})]})]})]})]})}),document.body)}function Cn({setID:e,noun:t,onAdded:n}){let{t:r}=U(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``);async function m(){if(!i){p(r(`stickers.fileRequired`,{noun:t}));return}if(!o.trim()){p(r(`stickers.emojiRequired`));return}if(!c.trim()){p(r(`action.reasonRequired`));return}d(!0),p(``);try{let t=new FormData;t.set(`metadata`,JSON.stringify({command_id:``,reason:c.trim(),confirm:!0,set_id:e,emoji:o.trim()})),t.set(`file`,i,i.name),await x.addStickerToSet(t),a(null),s(``),l(``),n()}catch(e){p(b(e))}finally{d(!1)}}return(0,H.jsxs)(`div`,{className:`sticker-add-form`,children:[(0,H.jsxs)(`label`,{className:`gift-file-picker compact ${i?`has-file`:``}`,children:[(0,H.jsx)(`input`,{type:`file`,accept:`.tgs,.json,.webp,application/json,application/x-tgsticker,image/webp`,onChange:e=>a(e.target.files?.[0]??null)}),(0,H.jsx)(`span`,{className:`gift-file-copy`,children:(0,H.jsx)(`strong`,{children:i?i.name:r(`stickers.filePrompt`)})})]}),(0,H.jsx)(`input`,{className:`small-input`,value:o,onChange:e=>s(e.target.value),placeholder:r(`stickers.emojiPlaceholder`)}),(0,H.jsx)(`input`,{className:`small-input`,value:c,onChange:e=>l(e.target.value),placeholder:r(`action.reasonPlaceholder`)}),(0,H.jsxs)(`button`,{className:`btn primary compact-btn`,type:`button`,onClick:m,disabled:u,children:[u?(0,H.jsx)(A,{className:`spin`,size:14}):(0,H.jsx)(ye,{size:14}),` `,r(`stickers.addSticker`,{noun:t})]}),f&&(0,H.jsx)(`span`,{className:`sticker-add-form-error`,children:f})]})}function wn({kind:e}){let{t}=U(),[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(10),[f,p]=(0,g.useState)(1),[m,h]=(0,g.useState)({}),[_,v]=(0,g.useState)({}),[y,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(!1),T=e===`emoji`?`stickers.emojiPageTitle`:`stickers.pageTitle`,E=e===`emoji`?`stickers.emojiEyebrow`:`stickers.eyebrow`,D=e===`emoji`?`emoji`:`sticker`;async function O(){s(!0),l(``);try{r((await x.stickerSets(e)).rows??[])}catch(e){l(b(e))}finally{s(!1)}}(0,g.useEffect)(()=>{O()},[e]);let k=(0,g.useMemo)(()=>{let e=i.trim().toLowerCase();return e?n.filter(t=>String(t.ID).includes(e)||t.ShortName.toLowerCase().includes(e)||t.Title.toLowerCase().includes(e)):n},[n,i]);(0,g.useEffect)(()=>{p(1)},[i,u,e]);let A=u===`all`?1:Math.max(1,Math.ceil(k.length/u)),j=Math.min(f,A),M=(0,g.useMemo)(()=>{if(u===`all`)return k;let e=(j-1)*u;return k.slice(e,e+u)},[k,j,u]),N=M.length===0?0:u===`all`?1:(j-1)*u+1,P=N===0?0:N+M.length-1,F=(0,g.useMemo)(()=>({total:n.length,official:n.filter(e=>e.Official).length,archived:n.filter(e=>e.Archived).length}),[n]);return(0,H.jsxs)(lt,{title:t(T),eyebrow:t(E),actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>O(),disabled:o,children:[(0,H.jsx)(be,{size:15}),` `,t(`common.refresh`)]}),(0,H.jsxs)(`button`,{className:`btn primary`,type:`button`,onClick:()=>w(!0),children:[(0,H.jsx)(ye,{size:15}),` `,t(`stickers.create`,{noun:D})]})]}),children:[c&&(0,H.jsx)(pt,{children:c}),(0,H.jsxs)(`div`,{className:`metric-row`,children:[(0,H.jsx)(q,{label:t(`stickers.total`),value:String(F.total)}),(0,H.jsx)(q,{label:t(`stickers.official`),value:String(F.official),tone:`good`}),(0,H.jsx)(q,{label:t(`stickers.archived`),value:String(F.archived),tone:F.archived>0?`warn`:`neutral`})]}),(0,H.jsx)(ut,{children:(0,H.jsxs)(`div`,{className:`toolbar`,children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:t(`stickers.searchPlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`gift-page-size`,children:[(0,H.jsx)(`span`,{children:t(`gifts.perPage`)}),(0,H.jsxs)(`select`,{value:String(u),onChange:e=>d(e.target.value===`all`?`all`:Number(e.target.value)),children:[(0,H.jsx)(`option`,{value:`10`,children:`10`}),(0,H.jsx)(`option`,{value:`20`,children:`20`}),(0,H.jsx)(`option`,{value:`50`,children:`50`}),(0,H.jsx)(`option`,{value:`100`,children:`100`}),(0,H.jsx)(`option`,{value:`all`,children:t(`gifts.perPageAll`)})]})]}),(0,H.jsx)(`span`,{className:`gift-list-summary`,children:t(`stickers.listSummary`,{shown:k.length,total:n.length})})]})}),(0,H.jsx)(`div`,{className:`table-wrap gift-table-wrap`,children:(0,H.jsxs)(`table`,{className:`data-table`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{children:t(`stickers.logo`)}),(0,H.jsx)(`th`,{children:t(`stickers.id`)}),(0,H.jsx)(`th`,{children:t(`stickers.shortName`)}),(0,H.jsx)(`th`,{children:t(`stickers.title`)}),(0,H.jsx)(`th`,{children:t(`stickers.count`)}),(0,H.jsx)(`th`,{children:t(`stickers.official`)}),(0,H.jsx)(`th`,{children:t(`common.status`)}),(0,H.jsx)(`th`,{children:t(`stickers.sortOrder`)}),(0,H.jsx)(`th`,{children:t(`common.actions`)})]})}),(0,H.jsxs)(`tbody`,{children:[M.map(e=>(0,H.jsxs)(`tr`,{className:e.Archived?`gift-row-disabled`:``,children:[(0,H.jsx)(`td`,{children:e.CoverDocumentID?(0,H.jsx)(yn,{documentID:e.CoverDocumentID,className:`list-thumb`,showError:!1}):(0,H.jsx)(`div`,{className:`sticker-list-thumb-empty`,children:(0,H.jsx)(ue,{size:14})})}),(0,H.jsx)(`td`,{className:`mono`,children:e.ID}),(0,H.jsx)(`td`,{className:`mono`,children:e.ShortName||(0,H.jsx)(`span`,{className:`muted-cell`,children:t(`common.none`)})}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`div`,{className:`sort-order-editor`,children:[(0,H.jsx)(`input`,{className:`small-input title-input`,value:_[e.ID]??e.Title,onChange:t=>v(n=>({...n,[e.ID]:t.target.value}))}),(0,H.jsx)(Y,{compact:!0,tone:`neutral`,label:t(`stickers.saveTitle`),path:`/api/actions/rename-sticker-set`,payload:()=>({set_id:e.ID,title:(_[e.ID]??e.Title).trim()}),onDone:()=>void O()})]})}),(0,H.jsx)(`td`,{children:e.Count}),(0,H.jsx)(`td`,{children:e.Official?(0,H.jsx)(K,{tone:`good`,children:t(`common.yes`)}):(0,H.jsx)(K,{children:t(`common.no`)})}),(0,H.jsx)(`td`,{children:e.Archived?(0,H.jsx)(K,{tone:`danger`,children:t(`stickers.archived`)}):(0,H.jsx)(K,{tone:`good`,children:t(`common.enabled`)})}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`div`,{className:`sort-order-editor`,children:[(0,H.jsx)(`input`,{type:`number`,className:`small-input`,value:m[e.ID]??String(e.SortOrder),onChange:t=>h(n=>({...n,[e.ID]:t.target.value}))}),(0,H.jsx)(Y,{compact:!0,tone:`neutral`,label:t(`stickers.saveOrder`),path:`/api/actions/set-sticker-set-sort-order`,payload:()=>({set_id:e.ID,sort_order:Number(m[e.ID]??e.SortOrder)}),onDone:()=>void O()})]})}),(0,H.jsx)(`td`,{children:(0,H.jsxs)(`div`,{className:`gift-table-actions`,children:[(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>S(e),children:[(0,H.jsx)(ie,{size:13}),` `,t(`stickers.view`)]}),(0,H.jsx)(Y,{compact:!0,tone:`neutral`,label:e.Archived?t(`stickers.unarchive`):t(`stickers.archive`),path:`/api/actions/set-sticker-set-archived`,payload:()=>({set_id:e.ID,archived:!e.Archived}),onDone:()=>void O()}),(0,H.jsx)(Y,{compact:!0,tone:`danger`,label:t(`stickers.delete`),path:`/api/actions/delete-sticker-set`,payload:()=>({set_id:e.ID}),onDone:()=>void O()})]})})]},e.ID)),M.length===0&&(0,H.jsx)(gt,{colSpan:9})]})]})}),u!==`all`&&k.length>0&&(0,H.jsxs)(`div`,{className:`gift-pager`,children:[(0,H.jsx)(`span`,{className:`gift-pager-range`,children:t(`gifts.pageRange`,{start:N,end:P,total:k.length})}),(0,H.jsxs)(`div`,{className:`gift-pager-controls`,children:[(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>p(e=>Math.max(1,e-1)),disabled:j<=1,children:[(0,H.jsx)(R,{size:14}),` `,t(`gifts.pagePrev`)]}),(0,H.jsx)(`span`,{className:`gift-pager-page`,children:t(`gifts.pageOf`,{page:j,total:A})}),(0,H.jsxs)(`button`,{className:`btn compact-btn`,type:`button`,onClick:()=>p(e=>Math.min(A,e+1)),disabled:j>=A,children:[t(`gifts.pageNext`),` `,(0,H.jsx)(te,{size:14})]})]})]}),y&&(0,H.jsx)(Sn,{set:y,onClose:()=>S(null)}),C&&(0,H.jsx)(bn,{kind:e,onClose:()=>w(!1),onCreated:()=>void O()})]})}function Tn({loader:e,cacheKey:t,className:n,playOnHover:r=!0,onError:i}){let a=(0,g.useRef)(null),o=(0,g.useRef)(null);(0,g.useEffect)(()=>{let t=!1;return e().then(e=>{t||!a.current||(o.current?.destroy(),o.current=Zt.default.loadAnimation({container:a.current,renderer:`canvas`,loop:!0,autoplay:!1,animationData:structuredClone(e)}),o.current.goToAndStop(0,!0))}).catch(()=>i?.()),()=>{t=!0,o.current?.destroy(),o.current=null}},[t]);function s(){r&&o.current?.play()}function c(){r&&o.current?.goToAndStop(0,!0)}return(0,H.jsx)(`div`,{className:n,ref:a,onMouseEnter:s,onMouseLeave:c})}var En=`777000`;function Dn(e){let t=e.rarity_permille>0?` · ${(e.rarity_permille/10).toFixed(1)}%`:``;return`${e.name||`#${e.id}`}${t}`}function On({gift:e,onDone:t}){let{t:n}=U(),[r,i]=(0,g.useState)(`user`),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(``),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(null),[v,y]=(0,g.useState)(``),[S,C]=(0,g.useState)(`0`),[w,T]=(0,g.useState)(`0`),[E,D]=(0,g.useState)(`0`),[j,M]=(0,g.useState)(``),[N,P]=(0,g.useState)(null),[F,I]=(0,g.useState)(``),[L,ee]=(0,g.useState)(!1),R=r===`user`?a?.ID??0:s?.ID??0,te=r===`user`&&p;(0,g.useEffect)(()=>{m(!1),_(null),y(``),C(`0`),T(`0`),D(`0`),P(null),I(``)},[e.GiftID]),(0,g.useEffect)(()=>{if(!te||h)return;let t=!1;return y(``),x.giftCollectibles(e.GiftID).then(e=>{t||_(e)}).catch(e=>{t||y(b(e))}),()=>{t=!0}},[te,h,e.GiftID]);function ne(t){return{gift_id:e.GiftID,sender_user_id:Number(En),user_id:r===`user`?R:0,channel_id:r===`channel`?R:0,hide_name:d,message:l.trim(),upgrade:te,model_attribute_id:te?S:`0`,pattern_attribute_id:te?w:`0`,backdrop_attribute_id:te?E:`0`,reason:j.trim(),confirm:t}}let re=(0,g.useMemo)(()=>ne(!1),[e.GiftID,r,R,l,d,p,S,w,E,j]),ie=N?.dry_run&&!N.error;async function ae(e){if(R<=0){I(n(`giveGift.recipientRequired`));return}if(!j.trim()){I(n(`action.reasonRequired`));return}ee(!0),I(``);try{let n=await x.action(`/api/actions/give-gift`,ne(e));P(n),e&&!n.error&&t?.()}catch(e){I(b(e))}finally{ee(!1)}}return(0,H.jsxs)(`div`,{className:`give-gift-form`,children:[(0,H.jsxs)(`div`,{className:`give-gift-summary`,children:[(0,H.jsx)(ce,{size:16}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`strong`,{children:e.Title||`Gift #${e.GiftID}`}),(0,H.jsxs)(`span`,{className:`mono`,children:[`#`,e.GiftID,` · ⭐ `,e.Stars]})]})]}),(0,H.jsxs)(`div`,{className:`give-gift-tabs`,role:`group`,"aria-label":n(`giveGift.recipientKind`),children:[(0,H.jsxs)(`button`,{type:`button`,className:`btn ${r===`user`?`primary`:``}`,onClick:()=>{i(`user`),P(null)},children:[(0,H.jsx)(Me,{size:15}),` `,n(`giveGift.recipientUser`)]}),(0,H.jsxs)(`button`,{type:`button`,className:`btn ${r===`channel`?`primary`:``}`,onClick:()=>{i(`channel`),m(!1),P(null)},children:[(0,H.jsx)(Ne,{size:15}),` `,n(`giveGift.recipientChannel`)]})]}),r===`user`?(0,H.jsx)(Kt,{label:n(`giveGift.pickUser`),value:a,onChange:e=>{o(e),P(null)}}):(0,H.jsx)(qt,{label:n(`giveGift.pickChannel`),value:s,onChange:e=>{c(e),P(null)}}),(0,H.jsxs)(`label`,{className:`form-field`,children:[(0,H.jsx)(`span`,{children:n(`giveGift.sender`)}),(0,H.jsx)(`input`,{value:En,disabled:!0,readOnly:!0}),(0,H.jsx)(`small`,{className:`field-hint`,children:n(`giveGift.senderHint`)})]}),(0,H.jsxs)(`label`,{className:`form-field`,children:[(0,H.jsx)(`span`,{children:n(`giveGift.message`)}),(0,H.jsx)(`textarea`,{value:l,rows:2,maxLength:128,onChange:e=>{u(e.target.value),P(null)},placeholder:n(`giveGift.messagePlaceholder`)})]}),(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>{f(e.target.checked),P(null)}}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:n(`giveGift.hideName`)})]}),r===`user`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`gift-switch`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>{m(e.target.checked),e.target.checked||(C(`0`),T(`0`),D(`0`)),P(null)}}),(0,H.jsx)(`span`,{className:`gift-switch-track`,"aria-hidden":`true`,children:(0,H.jsx)(`span`,{})}),(0,H.jsx)(`span`,{children:n(`giveGift.upgrade`)})]}),p&&(0,H.jsx)(`p`,{className:`give-gift-upgrade-note`,children:n(`giveGift.upgradeNote`)}),p&&v&&(0,H.jsx)(pt,{children:v}),p&&h&&(0,H.jsxs)(`div`,{className:`gift-fields-grid give-gift-attrs`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:n(`giveGift.model`)}),(0,H.jsxs)(`select`,{value:S,onChange:e=>{C(e.target.value),P(null)},children:[(0,H.jsx)(`option`,{value:`0`,children:n(`giveGift.random`)}),(h.models??[]).map(e=>(0,H.jsx)(`option`,{value:e.id,children:Dn(e)},e.id))]})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:n(`giveGift.pattern`)}),(0,H.jsxs)(`select`,{value:w,onChange:e=>{T(e.target.value),P(null)},children:[(0,H.jsx)(`option`,{value:`0`,children:n(`giveGift.random`)}),(h.patterns??[]).map(e=>(0,H.jsx)(`option`,{value:e.id,children:Dn(e)},e.id))]})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:n(`giveGift.backdrop`)}),(0,H.jsxs)(`select`,{value:E,onChange:e=>{D(e.target.value),P(null)},children:[(0,H.jsx)(`option`,{value:`0`,children:n(`giveGift.random`)}),(h.backdrops??[]).map(e=>(0,H.jsx)(`option`,{value:e.id,children:Dn(e)},e.id))]})]})]})]}),(0,H.jsxs)(`label`,{className:`form-field`,children:[(0,H.jsx)(`span`,{children:n(`action.reason`)}),(0,H.jsx)(`textarea`,{value:j,rows:2,onChange:e=>M(e.target.value),placeholder:n(`action.reasonPlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`command-preview`,children:[(0,H.jsx)(`div`,{className:`preview-head`,children:n(`action.requestPreview`)}),(0,H.jsx)(vt,{value:JSON.stringify(re,null,2)})]}),F&&(0,H.jsx)(pt,{children:F}),N&&(0,H.jsxs)(`div`,{className:`result-box`,children:[(0,H.jsxs)(`div`,{className:`result-title`,children:[N.error?(0,H.jsx)(O,{size:16}):(0,H.jsx)(k,{size:16}),(0,H.jsx)(`strong`,{children:N.message||N.error||n(`action.result`)})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:n(`action.commandID`)}),(0,H.jsx)(`strong`,{children:N.command_id})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:n(`action.status`)}),(0,H.jsx)(`strong`,{children:N.status})]}),(0,H.jsxs)(`div`,{className:`result-line`,children:[(0,H.jsx)(`span`,{children:n(`action.dryRun`)}),(0,H.jsx)(`strong`,{children:N.dry_run?n(`common.yes`):n(`common.no`)})]}),N.details&&(0,H.jsx)(vt,{value:JSON.stringify(N.details,null,2)})]}),(0,H.jsxs)(`div`,{className:`give-gift-form-actions`,children:[(0,H.jsxs)(`button`,{className:`btn icon-text`,type:`button`,onClick:()=>ae(!1),disabled:L,children:[L?(0,H.jsx)(A,{size:15,className:`spin`}):(0,H.jsx)(ve,{size:15}),n(N?`action.runAgain`:`action.runDry`)]}),(0,H.jsxs)(`button`,{className:`btn primary icon-text`,type:`button`,onClick:()=>ae(!0),disabled:L||!ie,children:[(0,H.jsx)(ce,{size:15}),n(`giveGift.confirm`)]})]})]})}function kn(){let{t:e}=U(),[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(!1);async function d(){u(!0),c(``);try{let e=(await x.gifts()).Gifts??[];n(e),o(t=>t??e[0]??null)}catch(e){c(b(e))}finally{u(!1)}}(0,g.useEffect)(()=>{d()},[]);let f=(0,g.useMemo)(()=>{let e=r.trim().toLowerCase();return e?t.filter(t=>String(t.GiftID).includes(e)||t.Title.toLowerCase().includes(e)):t},[t,r]);return(0,H.jsxs)(lt,{title:e(`giveGifts.pageTitle`),eyebrow:e(`giveGifts.eyebrow`),actions:(0,H.jsxs)(`button`,{className:`btn`,type:`button`,onClick:()=>d(),disabled:l,children:[(0,H.jsx)(be,{size:15}),` `,e(`common.refresh`)]}),children:[s&&(0,H.jsx)(pt,{children:s}),(0,H.jsx)(`p`,{className:`give-gift-upgrade-note`,children:e(`giveGifts.hint`)}),(0,H.jsxs)(`div`,{className:`give-gift-layout`,children:[(0,H.jsxs)(`section`,{className:`give-gift-picker`,children:[(0,H.jsxs)(`div`,{className:`give-gift-picker-head`,children:[(0,H.jsxs)(`label`,{className:`searchbox`,children:[(0,H.jsx)(xe,{size:15}),(0,H.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:e(`giveGifts.searchPlaceholder`)})]}),(0,H.jsx)(`span`,{className:`gift-list-summary`,children:e(`gifts.listSummary`,{shown:f.length,total:t.length})})]}),(0,H.jsxs)(`div`,{className:`give-gift-picker-list`,role:`listbox`,"aria-label":e(`giveGifts.pickGift`),children:[f.map(t=>{let n=a?.GiftID===t.GiftID;return(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`give-gift-option ${n?`selected`:``} ${t.Enabled?``:`gift-row-disabled`}`,onClick:()=>o(t),children:[(0,H.jsx)(Tn,{className:`give-gift-thumb`,cacheKey:`${t.GiftID}:${t.Revision}`,loader:()=>x.giftAnimation(t.GiftID)}),(0,H.jsxs)(`span`,{className:`give-gift-option-info`,children:[(0,H.jsx)(`strong`,{children:t.Title||`Gift #${t.GiftID}`}),(0,H.jsxs)(`span`,{className:`mono`,children:[`#`,t.GiftID]})]}),(0,H.jsx)(`span`,{className:`give-gift-option-price`,children:t.Enabled?(0,H.jsxs)(K,{children:[`⭐ `,t.Stars]}):(0,H.jsx)(K,{tone:`neutral`,children:e(`common.disabled`)})})]},t.GiftID)}),f.length===0&&!l&&(0,H.jsx)(`div`,{className:`official-gift-empty`,children:e(`common.noResults`)})]})]}),(0,H.jsx)(`section`,{className:`give-gift-panel`,children:a?(0,H.jsx)(On,{gift:a,onDone:()=>void d()},a.GiftID):(0,H.jsxs)(`div`,{className:`give-gift-empty-panel`,children:[(0,H.jsx)(ce,{size:26}),(0,H.jsx)(`p`,{children:e(`giveGifts.selectPrompt`)})]})})]})]})}function An({route:e,navigate:t}){let n=e.path.match(/^\/accounts\/(\d+)$/)?.[1],r=e.path.match(/^\/channels\/(\d+)$/)?.[1],i=e.path.match(/^\/bots\/(\d+)$/)?.[1];return n?(0,H.jsx)(kt,{id:Number(n),navigate:t}):r?(0,H.jsx)(zt,{id:Number(r),navigate:t}):i?(0,H.jsx)(Vt,{id:Number(i),navigate:t}):e.path===`/accounts`?(0,H.jsx)(Rt,{navigate:t}):e.path===`/channels`?(0,H.jsx)(Bt,{navigate:t}):e.path===`/bots`?(0,H.jsx)(Ht,{navigate:t}):e.path===`/emoji`?(0,H.jsx)(wn,{kind:`emoji`}):e.path===`/gifts`?(0,H.jsx)(vn,{}):e.path===`/stickers`?(0,H.jsx)(wn,{kind:`stickers`}):e.path===`/give-gifts`?(0,H.jsx)(kn,{}):e.path===`/messages/detail`||e.path===`/messages/private/detail`?(0,H.jsx)(Yt,{ownerUserID:Number(e.search.get(`owner_user_id`)||`0`),msgID:Number(e.search.get(`msg_id`)||`0`),navigate:t}):e.path===`/messages/groups/detail`?(0,H.jsx)(Gt,{channelID:Number(e.search.get(`channel_id`)||`0`),msgID:Number(e.search.get(`msg_id`)||`0`),navigate:t}):e.path===`/messages/groups`?(0,H.jsx)(Jt,{navigate:t}):e.path===`/messages`||e.path===`/messages/private`?(0,H.jsx)(Xt,{navigate:t}):(0,H.jsx)(Ut,{navigate:t})}function jn(){let[e,t]=(0,g.useState)(void 0),[n,r]=(0,g.useState)(()=>He());(0,g.useEffect)(()=>{let e=()=>r(He());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,g.useEffect)(()=>{x.session().then(e=>t(e.actor)).catch(e=>{if(e instanceof v&&e.status===401){t(null);return}t(null)})},[]);let i=e=>{window.history.pushState(null,``,e),r(He())};return e===void 0?(0,H.jsx)(Qe,{}):e===null?(0,H.jsx)(yt,{onLogin:t}):(0,H.jsx)($e,{actor:e,route:n,navigate:i,onLogout:()=>t(null),children:(0,H.jsx)(An,{route:n,navigate:i})})}_.createRoot(document.getElementById(`root`)).render((0,H.jsx)(g.StrictMode,{children:(0,H.jsx)(Je,{children:(0,H.jsx)(ze,{children:(0,H.jsx)(jn,{})})})})); \ No newline at end of file diff --git a/cmd/telesrv-admin/web/dist/index.html b/cmd/telesrv-admin/web/dist/index.html index 4a6087f2..fb7d30dd 100644 --- a/cmd/telesrv-admin/web/dist/index.html +++ b/cmd/telesrv-admin/web/dist/index.html @@ -23,8 +23,8 @@ })(); - - + +
diff --git a/cmd/telesrv-admin/web/package-lock.json b/cmd/telesrv-admin/web/package-lock.json index 52c8bdd2..18e4c2de 100644 --- a/cmd/telesrv-admin/web/package-lock.json +++ b/cmd/telesrv-admin/web/package-lock.json @@ -758,9 +758,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.15", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.15.tgz", - "integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==", + "version": "3.3.16", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz", + "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==", "dev": true, "funding": [ { @@ -797,9 +797,9 @@ } }, "node_modules/postcss": { - "version": "8.5.16", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.16.tgz", - "integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==", + "version": "8.5.23", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.23.tgz", + "integrity": "sha512-g50586zr4bZmwFiTlflMu8E0bDTb5I5gertgwAKmsdUlTQIhZtunzUlD1WSzwcVWPoAVpsrA6vlfCD7oXvRwgg==", "dev": true, "funding": [ { @@ -817,7 +817,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.12", + "nanoid": "^3.3.16", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, diff --git a/cmd/telesrv-admin/web/src/App.tsx b/cmd/telesrv-admin/web/src/App.tsx index bbde52f0..deefcc9d 100644 --- a/cmd/telesrv-admin/web/src/App.tsx +++ b/cmd/telesrv-admin/web/src/App.tsx @@ -1,12 +1,16 @@ import { useEffect, useState } from "react"; -import { api, APIError } from "./api"; +import { api } from "./api"; import { BootScreen, Shell } from "./components/Layout"; import { LoginPage } from "./pages/LoginPage"; +import { PermissionsProvider } from "./permissions"; import { Routes } from "./pages/Routes"; import { currentRoute, type RouteState } from "./routing"; +import type { AdminSession } from "./types"; export function App() { - const [actor, setActor] = useState(undefined); + // One GET /api/session at boot carries both the actor and the permission set the + // signed session was issued with. + const [session, setSession] = useState(undefined); const [route, setRoute] = useState(() => currentRoute()); useEffect(() => { @@ -17,14 +21,10 @@ export function App() { useEffect(() => { api.session() - .then((session) => setActor(session.actor)) - .catch((error) => { - if (error instanceof APIError && error.status === 401) { - setActor(null); - return; - } - setActor(null); - }); + .then((next) => setSession(next)) + // A 401 and an unreachable backend both end at the login screen; there is + // nothing the panel can render without a session. + .catch(() => setSession(null)); }, []); const navigate = (href: string) => { @@ -32,17 +32,19 @@ export function App() { setRoute(currentRoute()); }; - if (actor === undefined) { + if (session === undefined) { return ; } - if (actor === null) { - return ; + if (session === null) { + return ; } return ( - setActor(null)}> - - + + setSession(null)}> + + + ); } diff --git a/cmd/telesrv-admin/web/src/api.ts b/cmd/telesrv-admin/web/src/api.ts index b5e82595..1f5ab346 100644 --- a/cmd/telesrv-admin/web/src/api.ts +++ b/cmd/telesrv-admin/web/src/api.ts @@ -1,22 +1,40 @@ import type { AccountDetail, AccountListResponse, + AccountRatingDetail, + AccountRatingListResponse, AccountStatsResponse, + AdminLoginResult, + AdminSession, BotDetail, BotListResponse, + BotVerificationCountsResponse, + BotVerifierListResponse, ChannelDetail, + CustomVerificationListResponse, + CustomVerificationRequestDetail, + CustomVerificationRequestListResponse, + VerificationIconListResponse, EmojiListResponse, ChannelListResponse, + CollectibleUsernameDetail, + CollectibleUsernameListResponse, CommandResult, GroupMessageDetail, GroupMessageListResponse, MessageDetail, MessageListResponse, DefaultGiftListResponse, + ModerationCaseDetail, + ModerationCaseRow, + ModerationReport, OfficialStarGiftListResponse, StarGiftCollectiblePreview, StarGiftListResponse, - StickerSetListResponse + StickerSetListResponse, + VerificationApplicationDetail, + VerificationApplicationListResponse, + VerificationCountsResponse } from "./types"; export class APIError extends Error { @@ -28,12 +46,81 @@ export class APIError extends Error { } } +// The backend publishes the CSRF token in a deliberately readable cookie and +// refuses every mutating request whose X-CSRF-Token header does not repeat it +// (cmd/telesrv-admin/security.go). Echoing it here — inside request — is what +// keeps a new endpoint from silently shipping without the header. +const csrfCookieName = "telesrv_admin_csrf"; +const csrfHeaderName = "X-CSRF-Token"; + +// Login answers with the token in the body as well as in Set-Cookie. Keeping the +// body value is the fallback for the window where the browser has not applied +// the cookie yet, or where the cookie is not readable back to the script. +let issuedCSRFToken = ""; + +export function rememberCSRFToken(token: string | undefined): void { + issuedCSRFToken = (token ?? "").trim(); +} + +function readCSRFCookie(): string { + if (typeof document === "undefined") return ""; + for (const chunk of document.cookie.split(";")) { + const entry = chunk.trim(); + const separator = entry.indexOf("="); + if (separator <= 0 || entry.slice(0, separator) !== csrfCookieName) continue; + try { + return decodeURIComponent(entry.slice(separator + 1)); + } catch { + return entry.slice(separator + 1); + } + } + return ""; +} + +// The cookie wins: it is the value the server compares against, and it survives +// a page reload that the in-memory copy does not. +export function csrfToken(): string { + return readCSRFCookie() || issuedCSRFToken; +} + +// Same classification the backend uses: GET/HEAD/OPTIONS are safe, everything +// else carries a token. +function mutatingMethod(method: string | undefined): boolean { + const verb = (method ?? "GET").toUpperCase(); + return verb !== "GET" && verb !== "HEAD" && verb !== "OPTIONS"; +} + +function plainHeaders(source: HeadersInit | undefined): Record { + if (!source) return {}; + if (source instanceof Headers) { + const out: Record = {}; + source.forEach((value, key) => { + out[key] = value; + }); + return out; + } + if (Array.isArray(source)) { + return Object.fromEntries(source); + } + return { ...source }; +} + async function request(url: string, init: RequestInit = {}): Promise { const isForm = typeof FormData !== "undefined" && init.body instanceof FormData; + // A multipart body must keep the boundary the browser generates, so its + // Content-Type is left alone; the CSRF header is added either way. + const headers: Record = isForm ? {} : { "Content-Type": "application/json" }; + Object.assign(headers, plainHeaders(init.headers)); + if (mutatingMethod(init.method)) { + const token = csrfToken(); + if (token) { + headers[csrfHeaderName] = token; + } + } const response = await fetch(url, { credentials: "same-origin", - headers: isForm ? init.headers : { "Content-Type": "application/json", ...(init.headers ?? {}) }, - ...init + ...init, + headers }); const text = await response.text(); const data = text ? JSON.parse(text) : null; @@ -52,11 +139,16 @@ export function errorMessage(error: unknown): string { } export const api = { - session: () => request<{ actor: string }>("/api/session"), - login: (secret: string) => request<{ actor: string }>("/api/login", { - method: "POST", - body: JSON.stringify({ secret }) - }), + session: () => request("/api/session"), + login: async (secret: string) => { + const result = await request("/api/login", { + method: "POST", + body: JSON.stringify({ secret }) + }); + // Stashed here rather than in the caller so no login path can forget it. + rememberCSRFToken(result.csrf_token); + return result; + }, logout: () => request<{ ok: boolean }>("/api/logout", { method: "POST", body: "{}" }), accounts: (params: URLSearchParams) => request(`/api/accounts?${params.toString()}`), accountStats: () => request("/api/accounts/stats"), @@ -65,6 +157,36 @@ export const api = { channel: (id: number) => request(`/api/channels/${id}`), bots: (params: URLSearchParams) => request(`/api/bots?${params.toString()}`), bot: (id: number) => request(`/api/bots/${id}`), + collectibleUsernames: (params: URLSearchParams) => + request(`/api/collectible-usernames?${params.toString()}`), + collectibleUsername: (id: string) => + request(`/api/collectible-usernames/${encodeURIComponent(id)}`), + accountRatings: (params: URLSearchParams) => + request(`/api/account-ratings?${params.toString()}`), + accountRating: (userID: string) => + request(`/api/account-ratings/${encodeURIComponent(userID)}`), + verificationApplications: (params: URLSearchParams) => + request(`/api/verification/applications?${params.toString()}`), + // The application id is an int64 decimal string end to end, so it is never + // parsed into a number on the way to the URL. + verificationApplication: (id: string) => + request(`/api/verification/applications/${encodeURIComponent(id)}`), + verificationCounts: () => request("/api/verification/counts"), + // Third-party verification lives under its own prefix: the two mechanisms share + // no state, so they share no route either. + botVerifiers: (params: URLSearchParams) => + request(`/api/botverification/verifiers?${params.toString()}`), + verificationIcons: (params: URLSearchParams) => + request(`/api/botverification/icons?${params.toString()}`), + customVerifications: (params: URLSearchParams) => + request(`/api/botverification/marks?${params.toString()}`), + customVerificationRequests: (params: URLSearchParams) => + request(`/api/botverification/requests?${params.toString()}`), + // The application id is an int64 decimal string end to end, so it is never parsed + // into a number on the way to the URL. + customVerificationRequest: (id: string) => + request(`/api/botverification/requests/${encodeURIComponent(id)}`), + botVerificationCounts: () => request("/api/botverification/counts"), emoji: (params: URLSearchParams) => request(`/api/emoji?${params.toString()}`), emojiAnimation: (documentID: string) => request>(`/api/emoji/${encodeURIComponent(documentID)}/animation`), messages: (params: URLSearchParams) => request(`/api/messages?${params.toString()}`), @@ -77,6 +199,27 @@ export const api = { const params = new URLSearchParams({ channel_id: String(channelID), msg_id: String(msgID) }); return request(`/api/messages/groups/detail?${params.toString()}`); }, + moderationCases: (params: URLSearchParams) => + request<{ cases: ModerationCaseRow[] }>(`/api/moderation/cases?${params.toString()}`), + moderationCase: (id: number) => + request(`/api/moderation/cases/${id}`), + moderationReport: (id: number) => + request(`/api/moderation/reports/${id}`), + claimModerationCase: (id: number, expectedVersion: number) => + request(`/api/moderation/cases/${id}/claim`, { + method: "POST", + body: JSON.stringify({ expected_version: expectedVersion }) + }), + decideModerationCase: (id: number, payload: Record) => + request<{ created: boolean; case: ModerationCaseDetail }>(`/api/moderation/cases/${id}/decide`, { + method: "POST", + body: JSON.stringify(payload) + }), + reviewModerationAppeal: (caseID: number, appealID: number, payload: Record) => + request<{ created: boolean; case: ModerationCaseDetail }>(`/api/moderation/cases/${caseID}/appeals/${appealID}/review`, { + method: "POST", + body: JSON.stringify(payload) + }), gifts: () => request("/api/gifts"), stickerSets: (kind: string) => request(`/api/stickers?kind=${encodeURIComponent(kind)}`), stickerSetDocuments: (setID: string) => request<{ document_ids: string[] }>(`/api/stickers/${encodeURIComponent(setID)}/documents`), diff --git a/cmd/telesrv-admin/web/src/components/ActionButton.tsx b/cmd/telesrv-admin/web/src/components/ActionButton.tsx index e2d41ad1..53fc4a25 100644 --- a/cmd/telesrv-admin/web/src/components/ActionButton.tsx +++ b/cmd/telesrv-admin/web/src/components/ActionButton.tsx @@ -3,7 +3,6 @@ import type { ReactNode } from "react"; import { useMemo, useState } from "react"; import { createPortal } from "react-dom"; import { api, errorMessage } from "../api"; -import { useI18n } from "../i18n"; import type { CommandResult } from "../types"; import { Alert, JsonBlock } from "./ui"; @@ -16,7 +15,9 @@ export function ActionButton({ icon, compact = false, tone = "danger", - onDone + disabled = false, + onDone, + onError }: { label: string; path: string; @@ -24,9 +25,16 @@ export function ActionButton({ icon?: ReactNode; compact?: boolean; tone?: ActionTone; + // disabled keeps a form from opening the confirm flow at all while its own + // validation is unhappy, so the operator fixes the field instead of reading a + // backend rejection. + disabled?: boolean; onDone?: () => void; + // onError lets a page react to a failure the operator cannot fix by editing the + // form — an optimistic-locking 409, say — and replace the raw backend text with + // an explanation by returning it. + onError?: (error: unknown) => string | undefined; }) { - const { t } = useI18n(); const [open, setOpen] = useState(false); const [reason, setReason] = useState(""); const [result, setResult] = useState(null); @@ -41,7 +49,7 @@ export function ActionButton({ async function run(confirm: boolean) { if (!reason.trim()) { - setError(t("action.reasonRequired")); + setError("Please enter an operation reason"); return; } setBusy(true); @@ -54,7 +62,7 @@ export function ActionButton({ onDone?.(); } } catch (err) { - setError(errorMessage(err)); + setError(onError?.(err) || errorMessage(err)); } finally { setBusy(false); } @@ -75,6 +83,7 @@ export function ActionButton({ +
- 1{t("action.stepReason")} + 1{"Enter reason"}
- 2{t("action.stepDryRun")} + 2{"Dry-run check"}
- 3{t("action.stepConfirm")} + 3{"Confirm execution"}