diff --git a/.env.example b/.env.example index a6045b0..9995b05 100644 --- a/.env.example +++ b/.env.example @@ -226,6 +226,12 @@ REFERRAL_DAILY_CAP=2000 STARS_ENABLED=false STARS_PRICES=pass_day=50,pass_week=200,pass_month=600,credits_1000=70,credits_5000=330,credits_20000=1300 +# --- Telegram's affiliate program --------------------------------------------------- +# Explain Telegram's affiliate program in the Mini App's Earn section. Turn +# it on after opening the program for the bot in Telegram; the bot cannot +# do that itself. See docs/AFFILIATE.md. +AFFILIATE_ENABLED=false + # --- Rate limits ------------------------------------------------------------ # Links per minute. 0 means no limit. RATE_USER_PER_MINUTE=10 diff --git a/config.example.toml b/config.example.toml index 7f32888..a336f9c 100644 --- a/config.example.toml +++ b/config.example.toml @@ -36,6 +36,10 @@ referral_daily_cap = 2000 # sold for Stars. stars_enabled = false +# Explain Telegram's affiliate program in the Mini App (set it up in +# Telegram first, see docs/AFFILIATE.md). +affiliate_enabled = false + [telegram] api_url = "https://api.telegram.org" mode = "polling" # polling or webhook diff --git a/docs/AFFILIATE.md b/docs/AFFILIATE.md new file mode 100644 index 0000000..08b48cb --- /dev/null +++ b/docs/AFFILIATE.md @@ -0,0 +1,130 @@ +# Telegram's affiliate program + +Telegram lets the owner of a Mini App open an **affiliate program**. +Anyone on Telegram can join it and get a link to the Mini App. When +somebody opens the Mini App for the first time through that link and +later spends Telegram Stars in it, Telegram pays the link's owner a share +of those Stars, for as long as the program says. Telegram handles all of +it: joining, links, counting and paying out. + +The bot does not create the program and does not count affiliate +earnings. This page is about what the owner sets up by hand, and what the +bot does so the program works. + +Sources, checked on 2026-11-18: +[affiliate programs](https://core.telegram.org/api/bots/referrals), +[referral links](https://core.telegram.org/api/links#referral-links), +[Mini Apps](https://core.telegram.org/bots/webapps), +[Bot API payments](https://core.telegram.org/bots/api#payments). + +## Before you start (5 minutes) + +Affiliates only earn on **Stars purchases made inside the Mini App**, so +both of these must work first. + +1. **The Mini App.** Set `MINIAPP_ENABLED=true` and an HTTPS `PUBLIC_URL`, + and register the app in @BotFather as described in + [OPERATIONS.md](OPERATIONS.md). Open the bot and check that the menu + button opens the app. +2. **Stars payments.** Set `STARS_ENABLED=true` and your prices in + `STARS_PRICES` (or `[stars_prices]` in the config file), then restart. + In the app, open Buy, choose Telegram Stars (the switch is there when + Lightning is set up too) and check that a pass opens Telegram's payment + sheet. + +## Open the program (5 minutes) + +Use the Telegram account that owns the bot. + +1. Open the bot's profile in Telegram and choose **Edit**, or open + @BotFather, start its Mini App and pick the bot. +2. Choose **Affiliate program**. Telegram shows this option to the + owner of a bot. If you do not see it, Telegram has not made affiliate + programs available to your account or region yet. That is decided by + Telegram (the `starref_program_allowed` setting), not by the bot. +3. Pick the **commission**: the share of each Stars purchase that goes to + the affiliate, in permille. Telegram only offers values within its + allowed range (`starref_min_commission_permille` to + `starref_max_commission_permille`). The range can change, so the app + shows the current one. +4. Optionally pick a **duration** in months: how long a referred user's + purchases keep earning their affiliate. Without one the program has no + end date. +5. Confirm. The program is live. +6. Set `AFFILIATE_ENABLED=true` and restart the bot. The Mini App's Me + page then explains Telegram's program next to the sats referral, and + /referral says that Stars purchases count there. +7. Check it as an ordinary user: open the bot's profile from another + account and look for the affiliate program. + +Under the hood the apps call the MTProto method +`bots.updateStarRefProgram` with the bot, `commission_permille` and an +optional `duration_months`. This is not part of the Bot API, which is why +the bot cannot do it for you. + +## Rules to know before you choose + +- **Commission and duration can only be raised.** To lower either one, + end the program and open a new one. +- **Ending** means setting the commission to 0. The program then ends + about 24 hours later, at its `end_date`, and every affiliate link stops + working. A new program can only be opened after that; trying earlier + fails with `STARREF_AWAITING_END`. +- After the end, affiliates keep what they earned. People they referred + while the program ran keep earning them commission until the duration + that was set at the time runs out. +- **Who counts as referred:** somebody who starts the Mini App for the + first time after following an affiliate link. Their Stars purchases of + digital products in the Mini App then pay the affiliate automatically, + in Stars. + +## What the bot does + +- **Stars invoices for the Mini App.** The Buy page creates Stars + invoices with `createInvoiceLink` and opens them inside the app with + `WebApp.openInvoice`. The purchase is confirmed by the + `successful_payment` update Telegram sends to the bot, never by the + app. Telegram's page talks about purchases "within the mini app" and + does not say whether invoices sent in the bot chat count too. The chat + also offers Stars, so people can pay where they are, but **for the + affiliate program the Mini App is the way to buy**. +- **Any /start payload is fine.** Affiliate links come in two forms: + `https://t.me/?ref=`, or + `https://t.me/?start=`, where the prefixes are + Telegram's (`starref_start_param_prefixes`). Telegram resolves the + referrer. The bot only receives `/start `, which it + answers with the normal welcome. Our own referral links start with + `rf_` (older ones with `ref_`). Only those set an inviter for the sats + program; any other payload is ignored for referrals. Neither program + can get in the way of the other. A test sends every kind of payload, + including made-up and broken ones. +- **No double rewards.** One purchase earns one reward: + - A **Lightning** purchase can earn the inviter our **sats reward** + (`REFERRAL_REWARD_SATS`, once per invited user, after the first + settled Lightning purchase). + - A **Stars** purchase can only earn an affiliate **Telegram's + commission**. Our sats reward ignores Stars purchases completely. + This rule is in `billing.rewardReferrer`, and covered by + `TestStarsPurchasesEarnNoSatsReferral`. +- **No numbers of its own.** The Earn section explains how to join from + the bot's profile and has a button that opens it. It never shows + affiliate earnings: Telegram shows those to the affiliate. + +## What Telegram's pages do not say + +These are decided by Telegram and are not documented on the pages above. +The bot makes no promises about them: + +- How a user who followed several affiliate links is attributed. +- When commissions are paid out and when affiliates can withdraw them. +- The exact labels in each Telegram app; they can differ by version. + +## Not included: a command-line tool for the program + +An optional `cmd/affiliatectl` was suggested: a small MTProto tool for +`bots.getAdminedBots` and `bots.updateStarRefProgram`. It was left out. +It would add a large MTProto library to the module, and it needs the +owner's own Telegram login session. Keeping that session out of the +repository and out of the bot's runtime is easy to get wrong, and a +mistake there exposes the owner's whole account. The official apps do the +same job safely in a few taps, as described above. diff --git a/docs/ASSUMPTIONS.md b/docs/ASSUMPTIONS.md index cdf44c7..8e32496 100644 --- a/docs/ASSUMPTIONS.md +++ b/docs/ASSUMPTIONS.md @@ -1135,3 +1135,38 @@ the affiliate program. What was found and planned is in the core, which settles it from Telegram's `successful_payment` update. - `pre_checkout_query` was added to the update types the bot asks Telegram for. + +### Phase 5: Telegram affiliate program + +- **The facts were checked again on Telegram's pages** (affiliate + programs, referral links, Mini Apps) and match the brief. Two details + were added: + - The commission range comes from Telegram's client configuration, so + the docs give no fixed numbers. + - Telegram's own `/start` prefixes for affiliate links are also client + configuration (`starref_start_param_prefixes`), so the bot does not + try to recognize them. It treats every payload it does not own as + "not ours". +- **Chat invoices.** Telegram's page speaks of Stars purchases "within the + mini app" and does not say whether invoices sent in the bot chat count. + The Mini App's Buy page therefore creates its own Stars invoice links, + and the docs tell owners that the Mini App is the way to buy for the + program. The chat keeps its Stars buttons for people who are there. +- **No double rewards.** The rule is enforced in billing + (`rewardReferrer`): the sats reward only looks at Lightning purchases, + and Stars purchases are left to Telegram's commission. /referral says + so when `AFFILIATE_ENABLED` is on. +- **The Earn section** is on the Me page. It explains both programs. The + part about Telegram's program, with the steps to join from the bot's + profile and a button that opens the profile, only shows with + `AFFILIATE_ENABLED` (off by default, since the owner must open the + program first). It shows no affiliate numbers. The step to join is + worded generically ("tap the affiliate program"), because Telegram's + pages do not give the exact labels of each app. +- **The optional `cmd/affiliatectl` was skipped.** It needs a large MTProto + dependency and the owner's personal Telegram session, which is a risk + to the owner's account for something the official apps do in a few + taps. The reason is in docs/AFFILIATE.md. +- **Checked in a browser.** The Mini App browser test (headless Chromium + against a core in test mode) checks the Earn section in English, + Spanish and Dutch, and the new referral link format. diff --git a/internal/api/miniapp.go b/internal/api/miniapp.go index e478c60..47818a2 100644 --- a/internal/api/miniapp.go +++ b/internal/api/miniapp.go @@ -255,7 +255,7 @@ func (m *MiniApp) me(w http.ResponseWriter, r *http.Request, s *session) { MaxSize: dec.Limits.MaxSize, MaxDuration: dec.Limits.MaxDuration, ActiveJobs: dec.Limits.ActiveJobs, DailyDownloads: dec.Limits.DailyDownloads, DailyBytes: dec.Limits.DailyBytes, }, - "payments": m.Billing.Enabled(), + "payments": m.Billing.Enabled(), "referral_link": refLink, "referral_count": refStats.Invited, "referral_converted": refStats.Converted, @@ -264,9 +264,13 @@ func (m *MiniApp) me(w http.ResponseWriter, r *http.Request, s *session) { "referral_qr": refQR, "referral_reward": m.Cfg.Prices.ReferralReward, "referral_daily_cap": m.Cfg.ReferralDailyCap, - "support": support, - "start_param": s.init.StartParam, - "bot": m.Bot.Username(), + // Telegram's affiliate program is set up and paid by Telegram; the + // app only explains it, and shows no numbers of its own. + "affiliate_enabled": m.Cfg.AffiliateEnabled, + "stars_enabled": m.Billing.StarsEnabled(), + "support": support, + "start_param": s.init.StartParam, + "bot": m.Bot.Username(), }) } diff --git a/internal/app/flow_test.go b/internal/app/flow_test.go index d546854..0f5c5ed 100644 --- a/internal/app/flow_test.go +++ b/internal/app/flow_test.go @@ -605,3 +605,64 @@ func TestMenuButtonOpensTheAppInTheUsersLanguage(t *testing.T) { t.Fatalf("menu button after switching = %s", btn.Params["menu_button"]) } } + +// --- /start payloads of every shape ------------------------------------------ + +func TestStartPayloadsOfEveryShape(t *testing.T) { + h := startApp(t, nil, func(c *config.Config) { c.AffiliateEnabled = true }) + h.askEveryTime(alice) + code, err := h.app.Store.RefCode(context.Background(), alice) + if err != nil { + t.Fatal(err) + } + payloads := []string{ + "", + // Telegram's affiliate links: a prefix from Telegram's client + // configuration (starref_start_param_prefixes), then the referrer. + "_tgr_AbCdEf123", "_tgr_", "_tgr_" + strings.Repeat("x", 58), + // Our own links, the old ones, and broken ones. + "rf_" + code, "rf_", "rf_zzzzzzzz", "rf_" + code + "extra", "ref_", "ref_42", "ref_-5", "ref_99999999999999999999", + // Other deep links of the bot, valid and not. + "buy", "buy_", "buy_nope_best", "buy_nope_x--y", "skip_", "skip_nope", "gw_", "gw_abc", "gs_-100", "gw_-100123", + // What a person can type by hand. + "hello world", "hi", "馃挜", strings.Repeat("A", 300), "_", "-", "ref", "rf", "start", + } + for i, p := range payloads { + user := int64(5000 + i) + seq := h.srv.Seq() + h.srv.PushMessage(user, user, strings.TrimSpace("/start "+p)) + reply := h.wait(seq, "sendMessage", func(c fakeserver.Call) bool { return c.ChatID() == user }) + if strings.Contains(reply.Text(), "went wrong") { + t.Errorf("payload %q: %q", p, reply.Text()) + } + u, err := h.app.Store.GetUser(context.Background(), user) + if err != nil { + t.Fatalf("payload %q: %v", p, err) + } + // Only our own links set a referrer; Telegram's never do. + want := int64(0) + if p == "rf_"+code || p == "ref_42" { + want = alice + } + if u.ReferredBy != want { + t.Errorf("payload %q: referred by %d, want %d", p, u.ReferredBy, want) + } + } + // In a group /start with a payload is fine too. + h.meetGroup(alice) + seq := h.srv.Seq() + h.srv.PushMessage(group, alice, "/start@"+fakeserver.BotUsername+" _tgr_abc") + h.wait(seq, "sendMessage", func(c fakeserver.Call) bool { return c.ChatID() == group }) + + // /referral says which purchases count where. + seq = h.srv.Seq() + h.srv.PushMessage(alice, alice, "/referral") + ref := h.wait(seq, "sendMessage", textHas("Invite friends")) + if !strings.Contains(ref.Text(), "Telegram Stars do not count here") { + t.Fatalf("referral text = %q", ref.Text()) + } + // The Mini App knows whether to explain Telegram's program. + if me := h.must(alice, "GET", "me", nil); me.Body["affiliate_enabled"] != true { + t.Fatalf("me = %s", me.Raw) + } +} diff --git a/internal/app/stage_test.go b/internal/app/stage_test.go index 5179d63..6c64944 100644 --- a/internal/app/stage_test.go +++ b/internal/app/stage_test.go @@ -28,6 +28,8 @@ func TestMiniAppStage(t *testing.T) { } h := startApp(t, &ytdlptest.Fake{FileSize: 3000, Delay: 5 * time.Second}, func(c *config.Config) { c.Worker.Concurrency = 1 + c.StarsEnabled = true + c.AffiliateEnabled = true }) h.meetGroup(alice, bob) h.fetch(bob, link) // something for the history page diff --git a/internal/app/stars_test.go b/internal/app/stars_test.go index a29f64d..c6a5137 100644 --- a/internal/app/stars_test.go +++ b/internal/app/stars_test.go @@ -117,7 +117,9 @@ func TestStarsPurchaseInTheChat(t *testing.T) { t.Fatalf("refundStarPayment = %+v", refund.Params) } h.wait(seq, "sendMessage", func(c fakeserver.Call) bool { return c.ChatID() == alice && strings.Contains(c.Text(), "refunded") }) - h.wait(seq, "sendMessage", func(c fakeserver.Call) bool { return c.ChatID() == owner && strings.Contains(c.Text(), "Refunded 200 Stars") }) + h.wait(seq, "sendMessage", func(c fakeserver.Call) bool { + return c.ChatID() == owner && strings.Contains(c.Text(), "Refunded 200 Stars") + }) if st, _ := h.app.Billing.State(ctx, db.OwnerUser, alice); st.PassUntil != 0 { t.Fatal("the refunded pass is still active") } diff --git a/internal/bot/money.go b/internal/bot/money.go index c69dad2..881bc42 100644 --- a/internal/bot/money.go +++ b/internal/bot/money.go @@ -305,6 +305,11 @@ func (b *Bot) referralView(ctx context.Context, act actor, back bool) (string, * if c := b.cfg.ReferralDailyCap; c > 0 { text += "\n\n" + b.tr.HTML(lang, "referral.cap", i18n.Args{"Cap": b.tr.Sats(lang, c)}) } + if b.cfg.AffiliateEnabled { + // Stars purchases are rewarded by Telegram's affiliate program, + // never by ours: one purchase, one reward. + text += "\n\n" + b.tr.HTML(lang, "referral.affiliate_note", i18n.Args{"Bot": b.username}) + } rows := [][]telego.InlineKeyboardButton{ { urlButton(b.tr.T(lang, "btn.share", nil), shareURL(link, b.tr.T(lang, "referral.share_text", nil))), diff --git a/internal/config/config.go b/internal/config/config.go index a1aeace..dc926ca 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -123,6 +123,11 @@ type Config struct { // sats. A product without a price is not offered for Stars. In the // environment: STARS_PRICES="pass_day=50,credits_1000=70". StarsPrices map[string]int64 `toml:"stars_prices"` + // AffiliateEnabled shows the Earn section's part about Telegram's + // affiliate program (a share of Stars spent in the Mini App, paid by + // Telegram). Turn it on once the program is set up for the bot, see + // docs/AFFILIATE.md. + AffiliateEnabled bool `toml:"affiliate_enabled" env:"AFFILIATE_ENABLED"` } // StarsPrice returns the price in Stars of a product, or false when it diff --git a/locales/en.toml b/locales/en.toml index f964e03..80b7da2 100644 --- a/locales/en.toml +++ b/locales/en.toml @@ -858,6 +858,16 @@ one = "Usage, last day" other = "Usage, last {{.Count}} days" [app.me] +affiliate_open = "Open the bot's profile" +affiliate_step3 = "Copy the link Telegram gives you and share it." +affiliate_step2 = "Tap the affiliate program and join it." +affiliate_step1 = "Open the profile of {{.Bot}} in Telegram." +affiliate_text = "Share a Telegram affiliate link to this app. When somebody opens the app for the first time through your link, you get a share of the Stars they spend in it, for as long as the program says." +affiliate_note = "Telegram runs this program and pays your share in Stars. You see what you earn in Telegram, not here." +affiliate_title = "Telegram affiliate program" +earn_note_both = "There are two ways to earn. Our own referral pays you sats when people you invite buy over Lightning. Telegram's affiliate program pays you a share of the Stars they spend in this app. A purchase counts for one of the two, never both." +earn_note_sats = "Invite friends with your link. When somebody you invited pays for a first purchase over Lightning, you get sats in credits." +earn_title = "Earn" qr = "QR code" pending = "Waiting for the daily cap" earned = "Earned" @@ -919,6 +929,7 @@ one = "Remove {{.Count}} download from your history? Files already in this chat other = "Remove all {{.Count}} downloads from your history? Files already in this chat stay where they are." [referral] +affiliate_note = "Purchases paid with Telegram Stars do not count here: they earn through Telegram's affiliate program. You join it from the profile of @{{.Bot}} in Telegram." qr_caption = """ Your invite link as a QR code: {{.Link}}""" diff --git a/locales/es.toml b/locales/es.toml index 975745c..8308bae 100644 --- a/locales/es.toml +++ b/locales/es.toml @@ -833,6 +833,16 @@ one = "Uso, 煤ltimo d铆a" other = "Uso, 煤ltimos {{.Count}} d铆as" [app.me] +affiliate_open = "Abrir el perfil del bot" +affiliate_step3 = "Copia el enlace que te da Telegram y comp谩rtelo." +affiliate_step2 = "Toca el programa de afiliados y 煤nete." +affiliate_step1 = "Abre el perfil de {{.Bot}} en Telegram." +affiliate_text = "Comparte un enlace de afiliado de Telegram a esta app. Cuando alguien abre la app por primera vez con tu enlace, recibes una parte de las Estrellas que gasta en ella, durante el tiempo que indique el programa." +affiliate_note = "Telegram gestiona este programa y te paga tu parte en Estrellas. Lo que ganas lo ves en Telegram, no aqu铆." +affiliate_title = "Programa de afiliados de Telegram" +earn_note_both = "Hay dos formas de ganar. Nuestro programa de referidos te paga sats cuando las personas que invitas compran por Lightning. El programa de afiliados de Telegram te paga una parte de las Estrellas que gastan en esta app. Una compra cuenta para uno de los dos, nunca para ambos." +earn_note_sats = "Invita a tus amigos con tu enlace. Cuando alguien que invitaste pague una primera compra por Lightning, recibes sats en cr茅ditos." +earn_title = "Gana" qr = "C贸digo QR" pending = "En espera del tope diario" earned = "Ganado" @@ -892,6 +902,7 @@ one = "Quitar {{.Count}} descarga de tu historial? Los archivos que ya est谩n en other = "Quitar las {{.Count}} descargas de tu historial? Los archivos que ya est谩n en este chat se quedan donde est谩n." [referral] +affiliate_note = "Las compras pagadas con Estrellas de Telegram no cuentan aqu铆: generan ganancias con el programa de afiliados de Telegram. Te unes desde el perfil de @{{.Bot}} en Telegram." qr_caption = """ Tu enlace de invitaci贸n como c贸digo QR: {{.Link}}""" diff --git a/locales/nl.toml b/locales/nl.toml index f363ff2..48eec18 100644 --- a/locales/nl.toml +++ b/locales/nl.toml @@ -832,6 +832,16 @@ one = "Gebruik, afgelopen dag" other = "Gebruik, afgelopen {{.Count}} dagen" [app.me] +affiliate_open = "Profiel van de bot openen" +affiliate_step3 = "Kopieer de link die Telegram je geeft en deel hem." +affiliate_step2 = "Tik op het affiliateprogramma en doe mee." +affiliate_step1 = "Open het profiel van {{.Bot}} in Telegram." +affiliate_text = "Deel een affiliatelink van Telegram naar deze app. Als iemand de app voor het eerst via jouw link opent, krijg je een deel van de Stars die diegene erin uitgeeft, zo lang als het programma aangeeft." +affiliate_note = "Telegram regelt dit programma en betaalt je deel uit in Stars. Wat je verdient zie je in Telegram, niet hier." +affiliate_title = "Affiliateprogramma van Telegram" +earn_note_both = "Er zijn twee manieren om te verdienen. Ons eigen uitnodigingsprogramma betaalt je sats als mensen die je uitnodigt via Lightning kopen. Het affiliateprogramma van Telegram betaalt je een deel van de Stars die zij in deze app uitgeven. Een aankoop telt voor een van de twee, nooit voor allebei." +earn_note_sats = "Nodig vrienden uit met je link. Als iemand die je uitnodigde een eerste aankoop via Lightning betaalt, krijg jij sats aan tegoed." +earn_title = "Verdienen" qr = "QR-code" pending = "Wacht op de daglimiet" earned = "Verdiend" @@ -891,6 +901,7 @@ one = "{{.Count}} download uit je geschiedenis halen? Bestanden die al in deze c other = "Alle {{.Count}} downloads uit je geschiedenis halen? Bestanden die al in deze chat staan blijven staan." [referral] +affiliate_note = "Aankopen die met Telegram Stars zijn betaald tellen hier niet mee: die leveren iets op via het affiliateprogramma van Telegram. Je doet mee via het profiel van @{{.Bot}} in Telegram." qr_caption = """ Je uitnodigingslink als QR-code: {{.Link}}""" diff --git a/web/miniapp/dist/assets/app.js b/web/miniapp/dist/assets/app.js index 8a1bdfb..f5fa312 100644 --- a/web/miniapp/dist/assets/app.js +++ b/web/miniapp/dist/assets/app.js @@ -6,4 +6,4 @@ var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports) `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Re=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Le(n):``}function Be(e,t){switch(e.tag){case 26:case 27:case 5:return Le(e.type);case 16:return Le(`Lazy`);case 13:return e.child!==t&&t!==null?Le(`Suspense Fallback`):Le(`Suspense`);case 19:return Le(`SuspenseList`);case 0:case 15:return ze(e.type,!1);case 11:return ze(e.type.render,!1);case 1:return ze(e.type,!0);case 31:return Le(`Activity`);case 30:return Le(`ViewTransition`);default:return``}}function Ve(e){try{var t=``,n=null;do t+=Be(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var He=Object.prototype.hasOwnProperty,Ue=t.unstable_scheduleCallback,We=t.unstable_cancelCallback,Ge=t.unstable_shouldYield,Ke=t.unstable_requestPaint,qe=t.unstable_now,Je=t.unstable_getCurrentPriorityLevel,Ye=t.unstable_ImmediatePriority,Xe=t.unstable_UserBlockingPriority,Ze=t.unstable_NormalPriority,Qe=t.unstable_LowPriority,$e=t.unstable_IdlePriority,et=t.log,tt=t.unstable_setDisableYieldValue,nt=null,rt=null;function it(e){if(typeof et==`function`&&tt(e),rt&&typeof rt.setStrictMode==`function`)try{rt.setStrictMode(nt,e)}catch{}}var at=Math.clz32?Math.clz32:ct,ot=Math.log,st=Math.LN2;function ct(e){return e>>>=0,e===0?32:31-(ot(e)/st|0)|0}var lt=256,ut=262144,dt=4194304;function ft(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function pt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ft(n))):i=ft(o):i=ft(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ft(n))):i=ft(o)):i=ft(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function mt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ht(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function yt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function bt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=yr),Sr=` `,Cr=!1;function wr(e,t){switch(e){case`keyup`:return _r.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Tr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Er=!1;function Dr(e,t){switch(e){case`compositionend`:return Tr(t);case`keypress`:return t.which===32?(Cr=!0,Sr):null;case`textInput`:return e=t.data,e===Sr&&Cr?null:e;default:return null}}function Or(e,t){if(Er)return e===`compositionend`||!vr&&wr(e,t)?(e=Bn(),zn=Rn=Ln=null,Er=!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=Zr(n)}}function $r(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?$r(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ei(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Xr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Xr(e.document)}return t}function ti(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`)}var ni=Pn&&`documentMode`in document&&11>=document.documentMode,ri=null,ii=null,ai=null,oi=!1;function si(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;oi||ri==null||ri!==Xr(r)||(r=ri,`selectionStart`in r&&ti(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}),ai&&Yr(ai,r)||(ai=r,r=Jf(ii,`onSelect`),0>=o,i-=o,ra=1<<32-at(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),P&&aa(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),o=a(y,o,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),P&&aa(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return P&&aa(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),P&&aa(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===oe&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case ie:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===oe){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),mo(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===me&&oo(l)===r.type){n(e,r.sibling),c=i(r,a.props),mo(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===oe?(c=Wi(a.props.children,e.mode,c,a.key),mo(c,a),c.return=e,e=c):(c=Ui(a.type,a.key,a.props,null,e.mode,c),mo(c,a),c.return=e,e=c)}return o(e);case ae:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=qi(a,e.mode,c),c.return=e,e=c}return o(e);case me:return a=oo(a),_(e,r,a,c)}if(xe(a))return h(e,r,a,c);if(E(a)){if(l=E(a),typeof l!=`function`)throw Error(s(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,po(a),c);if(a.$$typeof===ue)return _(e,r,Ma(e,a),c);ho(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Gi(a,e.mode,c),c.return=e,e=c),o(e)):n(e,r)}return function(e,t,n,r){try{fo=0;var i=_(e,t,n,r);return uo=null,i}catch(t){if(t===eo||t===no)throw t;var a=zi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var _o=go(!0),vo=go(!1),yo=!1;function bo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function So(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Co(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ii(e),Fi(e,null,n),t}return Mi(e,r,t,n),Ii(e)}function wo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,St(e,n)}}function To(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={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,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,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Eo=!1;function Do(){if(Eo){var e=Ga;if(e!==null)throw e}}function Oo(e,t,n,r){Eo=!1;var i=e.updateQueue;yo=!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&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Wa&&(Eo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,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(g,d,f):m,f==null)break a;d=C({},d,f);break a;case 2:yo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else 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;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function ko(e,t){if(typeof e!=`function`)throw Error(s(191,e));e.call(t)}function Ao(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=k.T,s={};s.types=o===null?null:o.types,k.T=s,pc(e,!1,t,n);try{var c=i(),l=k.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Ja(c,r),jd(e)):fc(e,t,r,jd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{A.p=a,o!==null&&s.types!==null&&(o.types=s.types),k.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(s(476));var i=ic(e).queue;tc(e,i,t,Se,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Se,baseState:Se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:Se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},jd())}function oc(){return ja(sh)}function sc(){return B().memoizedState}function cc(){return B().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=So(n);var r=Co(t,e,n);r!==null&&(Pd(r,t,n),wo(r,t,n)),t={cache:La()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=Ni(e,t,n,r),n!==null&&(Pd(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,jd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(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,Jr(s,o))return Mi(e,t,i,0),G===null&&ji(),!1}catch{}if(n=Ni(e,t,i,r),n!==null)return Pd(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(s(479))}else t=Ni(e,n,r,2),t!==null&&Pd(t,e,2)}function mc(e){var t=e.alternate;return e===I||t!==null&&t===I}function hc(e,t){Yo=Jo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,St(e,n)}}var _c={readContext:ja,use:fs,useCallback:z,useContext:z,useEffect:z,useImperativeHandle:z,useLayoutEffect:z,useInsertionEffect:z,useMemo:z,useReducer:z,useRef:z,useState:z,useDebugValue:z,useDeferredValue:z,useTransition:z,useSyncExternalStore:z,useId:z,useHostTransitionStatus:z,useFormState:z,useActionState:z,useOptimistic:z,useMemoCache:z,useCacheRefresh:z,useEffectEvent:z},vc={readContext:ja,use:fs,useCallback:function(e,t){return ls().memoizedState=[e,t===void 0?null:t],e},useContext:ja,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=ls();t=t===void 0?null:t;var r=e();if(Xo){it(!0);try{e()}finally{it(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ls();if(n!==void 0){var i=n(t);if(Xo){it(!0);try{n(t)}finally{it(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,I,e),[r.memoizedState,e]},useRef:function(e){var t=ls();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,I,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(ls(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,I,e.queue,!0,!1),ls().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=I,i=ls();if(P){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),G===null)throw Error(s(349));q&127||ys(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Hs(xs.bind(null,r,a,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,a,n,t),null),n},useId:function(){var e=ls(),t=G.identifierPrefix;if(P){var n=ia,r=ra;n=(r&~(1<<32-at(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Zo++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?o.createElement(`select`,{is:r.is}):o.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?o.createElement(i,{is:r.is}):o.createElement(i)}}a[kt]=t,a[At]=r;a:for(o=t.child;o!==null;){if(o.tag===5||o.tag===6)a.appendChild(o.stateNode);else if(o.tag!==4&&o.tag!==27&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break a;for(;o.sibling===null;){if(o.return===null||o.return===t)break a;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;a:switch(np(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return V(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(s(166));if(e=ke.current,_a(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ua,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[kt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||ma(t,!0)}else e=lp(e).createTextNode(r),e[kt]=t,t.stateNode=e}return V(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=_a(t),n!==null){if(e===null){if(!r)throw Error(s(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(557));e[kt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),e=!1}else n=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ho(t),t):(Ho(t),null);if(t.flags&128)throw Error(s(558))}return V(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=_a(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(s(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(s(317));i[kt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),i=!1}else i=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Ho(t),t):(Ho(t),null)}return Ho(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),V(t),null);case 4:return Me(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,V(t),null;case 10:return Ta(t.type),V(t),null;case 19:if(Go(t),r=t.memoizedState,r===null)return V(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)bl(r,!1);else{if(Y!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Ko(e),a!==null){for(t.flags|=128,bl(r,!1),e=a.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Hi(n,e),n=n.sibling;return Wo(t,Uo.current&1|2),P&&aa(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&qe()>_d&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Ko(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!P)return V(t),null}else 2*qe()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=qe(),e.sibling=null,a=Uo.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||P?Wo(t,a):(n=a,j(Io,t),j(Uo,n),Lo===null&&(Lo=t)),P&&aa(t,r.treeForkCount),e}return V(t),null;case 22:case 23:return Ho(t),Fo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Ee(Xa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ta(F),V(t),null;case 25:return null;case 30:return t.flags|=33554432,V(t),null}throw Error(s(156,t.tag))}function Sl(e,t){switch(ca(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ta(F),Me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Pe(t),null;case 31:if(t.memoizedState!==null){if(Ho(t),t.alternate===null)throw Error(s(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ho(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Go(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Me(),null;case 10:return Ta(t.type),null;case 22:case 23:return Ho(t),Fo(),e!==null&&Ee(Xa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ta(F),null;case 25:return null;default:return null}}function Cl(e,t){switch(ca(t),t.tag){case 3:Ta(F),Me();break;case 26:case 27:case 5:Pe(t);break;case 4:Me();break;case 31:t.memoizedState!==null&&Ho(t);break;case 13:Ho(t);break;case 19:Go(t);break;case 10:Ta(t.type);break;case 22:case 23:Ho(t),Fo(),e!==null&&Ee(Xa);break;case 24:Ta(F)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ao(t,n)}catch(t){Z(e,e.return,t)}}}function Dl(e,t,n){n.props=Tc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=wi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);h(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[kt]=e,Ut(r),t=r;break a;case`link`:if(a=Gm(`link`,`href`,i).get(t+(n.href||``))){for(o=0;og&&(o=g,g=h,h=o);var _=Qr(s,h),v=Qr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,k.T=null,n=wd,wd=null;var a=bd,o=Sd;if(X=0,xd=bd=null,Sd=0,W&6)throw Error(s(331));var c=W;if(W|=4,Zu(a.current),Uu(a,a.current,o,n),W=c,Df(0,!1),rt&&typeof rt.onPostCommitFiberRoot==`function`)try{rt.onPostCommitFiberRoot(nt,a)}catch{}return!0}finally{A.p=i,k.T=r,uf(e,t)}}function pf(e,t,n){t=Yi(n,t),t=jc(e.stateNode,t,2),e=Co(e,t,2),e!==null&&(yt(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=Yi(n,e),n=Mc(2),r=Co(t,n,2),r!==null&&(Nc(n,r,t,e),yt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new td;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ad=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Y===4||Y===3&&(q&62914560)===q&&300>qe()-hd?W&2?ld|=n:Vd(e,0):ld|=n,dd===q&&(dd=0)),Ef(e)}function gf(e,t){t===0&&(t=_t()),e=Pi(e,t),e!==null&&(yt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(s(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Ue(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-at(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=q,a=pt(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||mt(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=qe(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}X!==0&&X!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=un(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Ut(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+un(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+un(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+un(n.imageSizes)+`"]`)):i+=`[href="`+un(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=C({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Lt]=!0,o.onload=o.onerror=function(){Wt(o)}),Ut(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+un(r)+`"][href="`+un(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=C({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Ut(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Ht(r).hoistableStyles,a=Pm(e);t=t||`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=C({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Ut(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=C({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=C({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=ke.current)?bm(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Ht(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var a=Ht(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(Fm(e)))?a._p||(o.instance=a,o.state.loading=5):(a=vm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,a)),Lm(i,e,a,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Ht(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Pm(e){return`href="`+un(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return C({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Lt]){r.loading=1;return}}else t=e.createElement(`link`),t[Lt]=!0,t.onload=t.onerror=Wt.bind(null,t),np(t,`link`,n),Ut(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+un(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+un(n.href)+`"]`);if(r)return t.instance=r,Ut(r),r;var i=C({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ut(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var a=e.querySelector(Fm(i));if(a)return t.state.loading|=4,t.instance=a,Ut(a),a;r=Im(n),(i=vm.get(i))&&Hm(r,i),a=(e.ownerDocument||e).createElement(`link`),Ut(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),t.state.loading|=4,Vm(a,n.precedence,e),t.instance=a;case`script`:return a=Rm(n.src),(i=e.querySelector(zm(a)))?(t.instance=i,Ut(i),i):(r=n,(i=vm.get(a))&&(r=C({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Ut(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ut(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{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=s()})),l=n(),u=c(),d=window.Telegram?.WebApp;function f(){return d?.initData??``}function p(e){try{e===`tap`?d?.HapticFeedback?.selectionChanged():d?.HapticFeedback?.notificationOccurred(e)}catch{}}function m(e){return new Promise(t=>{d&&d.isVersionAtLeast(`6.2`)?d.showConfirm(e,t):t(window.confirm(e))})}function h(e){d?d.openLink(e):window.open(e,`_blank`,`noopener`)}function g(e,t){d?.openInvoice?d.openInvoice(e,t):d?d.openTelegramLink(e):window.open(e,`_blank`)}function _(e){d?d.openTelegramLink(e):window.open(e,`_blank`,`noopener`)}async function v(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand(`copy`)}catch{n=!1}return t.remove(),n}}var y=class extends Error{constructor(e,t,n,r=!1){super(n),this.status=e,this.code=t,this.upgradable=r}};async function b(e,t,n){let r;try{r=await fetch(`/app/api/`+t,{method:e,headers:{Authorization:`tma `+f(),...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new y(0,`network`,``)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=i??{};throw new y(r.status,e.error??`internal`,e.message??``,e.upgradable??!1)}return i}var ee={},te=`en`,ne=new Intl.PluralRules(`en`);function re(e){try{return Intl.NumberFormat.supportedLocalesOf([e])[0]??`en`}catch{return`en`}}function x(e){ee=e.messages,te=re(e.lang),ne=new Intl.PluralRules(te),document.documentElement.lang=e.lang,document.documentElement.dir=e.dir}function S(e,t){let n=ee[e];return n===void 0?e:(typeof n!=`string`&&(n=n[ne.select(Number(t?.Count??0))]??n.other??``),n.replace(/\{(\w+)\}/g,(e,n)=>t&&n in t?String(t[n]):``))}function C(e){return new Intl.NumberFormat(te).format(e)}function w(e){return S(`unit.sats`,{Count:e,N:C(e)})}function ie(e){return S(`unit.stars`,{Count:e,N:C(e)})}function ae(e){return new Intl.NumberFormat(te,{style:`percent`,maximumFractionDigits:0}).format(e)}function oe(e){let t=(e,t)=>new Intl.NumberFormat(te,{minimumFractionDigits:0,maximumFractionDigits:t}).format(e),n=1024;if(e=100?0:1)+` MB`}return t(e/(n*n*n),2)+` GB`}function se(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=e=>String(e).padStart(2,`0`);return n>0?`${n}:${i(r)}:${i(t%60)}`:`${r}:${i(t%60)}`}function ce(e){return e<60?S(`unit.seconds`,{Count:Math.max(1,Math.round(e))}):e<3600?S(`unit.minutes`,{Count:Math.round(e/60)}):S(`unit.hours`,{Count:Math.round(e/3600)})}function le(e){return new Intl.DateTimeFormat(te,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}function ue(e){return new Intl.DateTimeFormat(te,{dateStyle:`medium`}).format(new Date(e))}function de(e){return e===`best`?S(`btn.best`):/^\d+$/.test(e)?S(`btn.res`,{Height:e}):e===`mp3`||e===`m4a`||e===`thumb`?S(`btn.`+e):e.startsWith(`subs:`)?S(`btn.subs`,{Lang:e.slice(5)}):e}var fe=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),T=e(((e,t)=>{t.exports=fe()}))(),pe=(0,l.createContext)(null);function me(){let e=(0,l.useContext)(pe);if(!e)throw Error(`no app context`);return e}function he(e){if(e instanceof y){if(e.message)return e.message;if(e.code===`network`)return S(`app.error.network`)}return S(`app.error.generic`)}function ge(e,t,n=0){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(!0),[u,d]=(0,l.useState)(0),f=(0,l.useRef)(e);return f.current=e,(0,l.useEffect)(()=>{let e=!0,t,r=()=>{f.current().then(t=>{e&&(i(t),o(null))}).catch(t=>e&&o(t)).finally(()=>{e&&(c(!1),n>0&&(t=window.setTimeout(a,n)))})},a=()=>{document.hidden?t=window.setTimeout(a,n):r()};return r(),()=>{e=!1,window.clearTimeout(t)}},[...t,u,n]),{data:r,error:a,loading:s,reload:()=>d(e=>e+1),set:i}}var _e=[],ve=!1;function ye(){d&&(ve||(d.BackButton.onClick(()=>_e[_e.length-1]?.current?.()),ve=!0),_e.length>0?d.BackButton.show():d.BackButton.hide())}function be(e){let t=(0,l.useRef)(e);t.current=e;let n=e!==null;(0,l.useEffect)(()=>{if(n)return _e.push(t),ye(),()=>{let e=_e.indexOf(t);e>=0&&_e.splice(e,1),ye()}},[n])}function E(e){return(0,T.jsxs)(`section`,{className:`section`,children:[(e.title||e.action)&&(0,T.jsxs)(`div`,{className:`section-title`,children:[(0,T.jsx)(`span`,{children:e.title}),e.action]}),(0,T.jsx)(`div`,{className:`card`,children:e.children}),e.note&&(0,T.jsx)(`div`,{className:`note`,children:e.note})]})}function D(e){let t=(0,T.jsxs)(T.Fragment,{children:[e.before,(0,T.jsxs)(`div`,{className:`cell-body`,children:[(0,T.jsx)(`div`,{className:`cell-title`+(e.wrap?` wrap`:``),children:e.title}),e.sub&&(0,T.jsx)(`div`,{className:`cell-sub`,children:e.sub})]}),(e.after||e.chevron)&&(0,T.jsxs)(`div`,{className:`cell-after`,children:[e.after,e.chevron&&(0,T.jsx)(`span`,{className:`chevron`})]})]});return e.onClick?(0,T.jsx)(`button`,{className:`cell`,onClick:e.onClick,children:t}):(0,T.jsx)(`div`,{className:`cell`,children:t})}function O(e){let[t,n]=(0,l.useState)(!1),r=(0,l.useRef)(!0);(0,l.useEffect)(()=>()=>{r.current=!1},[]);let i=()=>{if(t||!e.onClick)return;p(`tap`);let i=e.onClick();i instanceof Promise&&(n(!0),i.finally(()=>r.current&&n(!1)))},a=[`btn`,e.kind&&e.kind!==`primary`?e.kind:``,e.small?`small`:``,e.wide?`wide`:``];return(0,T.jsx)(`button`,{className:a.filter(Boolean).join(` `),onClick:i,disabled:e.disabled||t,children:t?(0,T.jsx)(`span`,{className:`spinner`}):e.children})}function xe(e){return(0,T.jsx)(`button`,{className:`switch`,role:`switch`,"aria-checked":e.checked,"aria-label":e.label,onClick:()=>{p(`tap`),e.onChange(!e.checked)}})}function k(e){return(0,T.jsx)(`select`,{className:`select`+(e.compact?` compact`:``),"aria-label":e.label,disabled:e.disabled,value:e.value,onChange:t=>e.onChange(t.target.value),children:e.options.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function A(e){return(0,T.jsx)(`div`,{className:`segmented`,role:`tablist`,children:e.options.map(t=>(0,T.jsx)(`button`,{role:`tab`,"aria-selected":t.value===e.value,onClick:()=>e.onChange(t.value),children:t.label},t.value))})}function Se(e){let t=Math.max(0,Math.min(1,e.value))*100;return(0,T.jsx)(`div`,{className:`meter`+(e.busy?` busy`:``),children:(0,T.jsx)(`div`,{style:{width:t+`%`}})})}function Ce(){return(0,T.jsx)(`div`,{className:`spinner`,role:`progressbar`})}function we(e){return(0,T.jsx)(`div`,{className:`empty`,children:e.children})}function Te(e){let{data:t,error:n,loading:r,reload:i}=e.of;return t===null?r?(0,T.jsx)(Ce,{}):(0,T.jsxs)(we,{children:[(0,T.jsx)(`p`,{children:he(n)}),(0,T.jsx)(O,{kind:`soft`,onClick:i,children:S(`app.retry`)})]}):(0,T.jsx)(T.Fragment,{children:e.children(t)})}function Ee(e){return(0,T.jsx)(`div`,{className:`sheet-back`,onClick:e.onClose,children:(0,T.jsx)(`div`,{className:`sheet`,role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:e.children})})}function j(){let{me:e,go:t}=me(),n=ge(()=>b(`GET`,`history?limit=5`),[]),r=e.pass_until>Date.now(),i=e.limits;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{children:[(0,T.jsxs)(`div`,{className:`pad`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.home.hello`,{Name:e.name})}),(0,T.jsx)(`div`,{className:`big`,children:S(r?`app.home.pass_active`:`app.home.plan_free`)}),(0,T.jsx)(`div`,{className:`hint`,children:r?S(`app.pass_until`,{Until:le(e.pass_until)}):S(`app.home.plan_free_hint`)})]}),(0,T.jsx)(D,{title:S(`app.home.balance`),after:(0,T.jsx)(`b`,{children:w(e.balance)}),chevron:e.payments,onClick:e.payments?()=>t({tab:`buy`}):void 0})]}),(0,T.jsx)(E,{title:S(`app.home.today`),children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsx)(De,{label:S(`app.home.downloads`),used:e.usage.downloads,max:i.daily_downloads,format:C}),(0,T.jsx)(De,{label:S(`app.home.volume`),used:e.usage.bytes,max:i.daily_bytes,format:oe})]})}),(0,T.jsx)(ke,{}),(0,T.jsx)(E,{title:S(`app.home.recent`),action:(0,T.jsx)(O,{kind:`plain`,onClick:()=>t({tab:`home`,page:`history`}),children:S(`app.home.all_history`)}),children:n.data&&n.data.items.length>0?n.data.items.map(e=>(0,T.jsx)(Oe,{item:e},e.id)):(0,T.jsx)(`div`,{className:`empty`,children:n.loading?``:S(`app.history.empty`)})})]})}function De(e){let t=e.max<=0;return(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`span`,{className:`grow`,children:e.label}),(0,T.jsx)(`span`,{className:`hint`,children:t?S(`app.home.used_unlimited`,{Used:e.format(e.used)}):S(`app.home.used_of`,{Used:e.format(e.used),Max:e.format(e.max)})})]}),(0,T.jsx)(Se,{value:t?0:e.used/e.max})]})}function Oe(e){let{notify:t,fail:n}=me(),r=e.item;return(0,T.jsx)(D,{title:r.title||S(`app.untitled`),sub:[de(r.profile),r.size>0?oe(r.size):``,le(r.at)].filter(Boolean).join(` 路 `),after:(0,T.jsx)(O,{small:!0,kind:`soft`,onClick:async()=>{try{await b(`POST`,`history/`+r.id+`/resend`),t(S(`app.sent_to_chat`))}catch(e){n(e)}},children:S(`app.history.resend`)})})}function ke(){let{go:e,notify:t}=me(),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),c=e=>s({text:he(e),upgradable:e instanceof y&&e.upgradable}),u=async()=>{s(null),a(null);try{a(await b(`POST`,`probe`,{url:n.trim()}))}catch(e){c(e)}},d=async n=>{if(i){s(null);try{await b(`POST`,`download`,{url:i.url,profile:n}),a(null),r(``),t(S(`app.sent_to_chat`)),e({tab:`queue`})}catch(e){c(e)}}};return(0,T.jsx)(E,{title:S(`app.home.paste_title`),children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`input`,{className:`input grow`,type:`url`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,dir:`ltr`,placeholder:S(`app.home.paste_placeholder`),value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n.trim()&&u()}}),(0,T.jsx)(O,{onClick:u,disabled:!n.trim(),children:S(`app.home.look_up`)})]}),o&&(0,T.jsxs)(`div`,{className:`stack`,children:[(0,T.jsx)(`div`,{className:`error`,children:o.text}),o.upgradable&&(0,T.jsx)(O,{kind:`soft`,onClick:()=>e({tab:`buy`}),children:S(`app.see_plans`)})]}),i&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`cell-title wrap`,children:i.title||S(`app.untitled`)}),(0,T.jsx)(`div`,{className:`hint`,children:[i.uploader,i.duration>0?se(i.duration):``,i.site].filter(Boolean).join(` 路 `)})]}),(0,T.jsx)(`div`,{className:`row wrap`,children:i.options.map(e=>(0,T.jsx)(O,{kind:`soft`,onClick:()=>d(e.profile),children:e.size?S(`btn.with_size`,{Label:de(e.profile),Size:oe(e.size)}):de(e.profile)},e.profile))})]})]})})}function Ae(e){let{notify:t,fail:n,reload:r}=me(),[i,a]=(0,l.useState)(e.purchase),[o,s]=(0,l.useState)(Date.now()),c=(0,l.useRef)(e.onPaid);c.current=e.onPaid,(0,l.useEffect)(()=>{if(i.status!==`pending`)return;let e=!0,t=window.setInterval(()=>{document.hidden||b(`GET`,`purchase/`+i.id).then(t=>{e&&t.status!==`pending`&&(a(e=>({...e,...t})),t.status===`paid`&&(p(`success`),r(),c.current?.(t)))}).catch(()=>void 0)},2500),n=window.setInterval(()=>s(Date.now()),1e3);return()=>{e=!1,window.clearInterval(t),window.clearInterval(n)}},[i.id,i.status,r]);let u=S(`product.`+i.product),d=i.method===`stars`?ie(i.stars):w(i.amount);if(i.status===`paid`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`paid-mark`,children:`鉁揱}),(0,T.jsx)(`div`,{className:`big`,children:S(`app.invoice.paid`)}),(0,T.jsx)(`div`,{children:S(`app.invoice.paid_text`,{Product:u,Amount:d})}),i.pass_until?(0,T.jsx)(`div`,{className:`hint`,children:S(`app.pass_until`,{Until:le(i.pass_until)})}):null,i.balance!==void 0&&(0,T.jsx)(`div`,{className:`hint`,children:S(`app.balance_is`,{Balance:w(i.balance)})}),(0,T.jsx)(O,{wide:!0,onClick:e.onDone,children:S(`app.done`)})]});if(i.status!==`pending`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`big`,children:S(`app.invoice.`+i.status)}),(0,T.jsx)(`div`,{className:`hint`,children:S(`app.invoice.closed_text`)}),(0,T.jsx)(O,{wide:!0,onClick:e.onDone,children:S(`app.close`)})]});if(i.method===`stars`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`hint`,children:u}),(0,T.jsx)(`div`,{className:`big`,children:d}),(0,T.jsx)(`div`,{className:`hint`,role:`status`,children:S(`app.invoice.stars_waiting`)}),i.invoice_link&&(0,T.jsx)(O,{wide:!0,onClick:()=>g(i.invoice_link??``,()=>void 0),children:S(`app.invoice.stars_pay`)}),(0,T.jsx)(O,{kind:`plain`,onClick:async()=>{try{await b(`POST`,`purchase/`+i.id+`/cancel`)}catch{}e.onDone()},children:S(`app.invoice.cancel`)})]});let f=Math.max(0,Math.floor((i.expires_at-o)/1e3)),m=i.bolt11??``;return(0,T.jsxs)(`div`,{className:`stack`,children:[(0,T.jsxs)(`div`,{className:`center`,children:[(0,T.jsx)(`div`,{className:`hint`,children:u}),(0,T.jsx)(`div`,{className:`big`,children:w(i.amount)})]}),i.qr&&(0,T.jsx)(`img`,{className:`qr`,src:i.qr,alt:S(`app.invoice.qr_alt`)}),(0,T.jsxs)(`div`,{className:`mono hint center`,children:[m.slice(0,24),`鈥,m.slice(-12)]}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:async()=>{await v(m)?t(S(`app.copied`)):n(null)},children:S(`app.invoice.copy`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>h(window.location.origin+`/pay/`+i.id),children:S(`btn.open_wallet`)})})]}),(0,T.jsx)(`div`,{className:`center hint`,role:`timer`,children:f>0?S(`app.invoice.waiting`,{Time:se(f)}):S(`app.invoice.checking`)}),(0,T.jsx)(`div`,{className:`center`,children:(0,T.jsx)(O,{kind:`plain`,onClick:async()=>{try{await b(`POST`,`purchase/`+i.id+`/cancel`)}catch{}e.onDone()},children:S(`app.invoice.cancel`)})})]})}function je(){let{notify:e,fail:t}=me(),n=ge(()=>b(`GET`,`queue`),[],2e3),[r,i]=(0,l.useState)(null),a=async r=>{if(await m(S(`app.queue.cancel_confirm`,{Title:r.title||S(`app.untitled`)}))){try{await b(`POST`,`queue/`+r.id+`/cancel`),e(S(`app.queue.cancelled`))}catch(e){t(e)}n.reload()}},o=async r=>{try{let t=await b(`POST`,`queue/`+r.id+`/prioritize`);t.done?e(S(`app.queue.prioritized`)):t.purchase&&i(t.purchase)}catch(e){t(e)}n.reload()};return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(E,{title:S(`app.queue.title`),note:S(`app.queue.note`),children:(0,T.jsx)(Te,{of:n,children:e=>e.jobs.length===0?(0,T.jsx)(we,{children:S(`app.queue.empty`)}):e.jobs.map(e=>(0,T.jsx)(Ne,{job:e,onCancel:()=>a(e),onPrioritize:()=>o(e)},e.id))})}),r&&(0,T.jsx)(Ee,{onClose:()=>i(null),children:(0,T.jsx)(Ae,{purchase:r,onPaid:()=>n.reload(),onDone:()=>{i(null),n.reload()}})})]})}function Me(e){return e.status===`queued`?S(`app.queue.waiting`,{Position:e.position??1,Wait:ce(e.wait_seconds??0)}):e.status===`delivering`||e.stage===`uploading`?S(`app.queue.sending`):e.stage===`processing`?S(`app.queue.processing`):e.progress>0?S(`app.queue.downloading_pct`,{Percent:ae(e.progress)}):S(`app.queue.downloading`)}function Ne(e){let t=e.job,n=t.status!==`queued`&&(t.progress<=0||t.stage===`processing`||t.status===`delivering`);return(0,T.jsx)(`div`,{className:`cell`,children:(0,T.jsxs)(`div`,{className:`cell-body`,children:[(0,T.jsx)(`div`,{className:`cell-title`,children:t.title||S(`app.untitled`)}),(0,T.jsxs)(`div`,{className:`cell-sub`,children:[de(t.profile),` 路 `,Me(t)]}),t.status!==`queued`&&(0,T.jsx)(Se,{value:t.progress,busy:n}),(t.can_cancel||t.can_prioritize)&&(0,T.jsxs)(`div`,{className:`row`,style:{marginBlockStart:8},children:[t.can_prioritize&&(0,T.jsx)(O,{small:!0,onClick:e.onPrioritize,children:S(`app.queue.prioritize`,{Price:w(t.skip_price??0)})}),t.can_cancel&&(0,T.jsx)(O,{small:!0,kind:`danger`,onClick:e.onCancel,children:S(`btn.cancel`)})]})]})})}function Pe(e){let{me:t,go:n,back:r,fail:i}=me(),a=ge(()=>b(`GET`,`products`),[]),o=ge(()=>b(`GET`,`groups`),[]),[s,c]=(0,l.useState)(e.target??null),[u,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),_=m??(a.data&&!a.data.lightning?`stars`:`lightning`),v=u?3:s?2:1;be(v===2&&!e.target?()=>c(null):v===3&&u?.status!==`pending`?()=>d(null):null);let y=async(e,t)=>{if(!f){p(!0);try{let n=await b(`POST`,`purchase`,{target:s,product:e,amount:t,method:_});d(n),n.method===`stars`&&n.invoice_link&&g(n.invoice_link,e=>{(e===`cancelled`||e===`failed`)&&(b(`POST`,`purchase/`+n.id+`/cancel`).catch(()=>void 0),d(null),e===`failed`&&i(null))})}catch(e){i(e)}p(!1)}},ee=o.data?.groups.find(e=>e.id===s),te=s===`me`?S(`app.buy.for_me`):ee?.title??S(`app.buy.for_group`);return(0,T.jsx)(Te,{of:a,children:i=>i.enabled?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`steps`,"aria-label":S(`app.buy.step`,{Step:v,Total:3}),children:[1,2,3].map(e=>(0,T.jsx)(`span`,{className:e<=v?`on`:``},e))}),v===1&&(0,T.jsxs)(E,{title:S(`app.buy.target_title`),note:S(`app.buy.target_note`),children:[(0,T.jsx)(D,{title:S(`app.buy.for_me`),sub:S(`app.balance_is`,{Balance:w(t.balance)}),chevron:!0,onClick:()=>c(`me`)}),o.data?.groups.map(e=>(0,T.jsx)(D,{title:e.title,sub:S(`app.balance_is`,{Balance:w(e.balance)}),chevron:!0,onClick:()=>c(e.id)},e.id))]}),v===2&&(0,T.jsxs)(T.Fragment,{children:[i.lightning&&i.stars&&(0,T.jsx)(A,{value:_,onChange:h,options:[{value:`lightning`,label:S(`app.buy.method_lightning`)},{value:`stars`,label:S(`app.buy.method_stars`)}]}),(0,T.jsx)(E,{title:S(`app.buy.pass_title`,{Target:te}),note:S(`app.buy.pass_note`),children:i.passes.filter(e=>_===`lightning`||e.stars>0).map(e=>(0,T.jsx)(D,{title:S(`product.`+e.product),after:(0,T.jsx)(`b`,{children:_===`stars`?ie(e.stars):w(e.price)}),chevron:!0,onClick:()=>y(e.product,0)},e.product))}),(0,T.jsx)(E,{title:S(`app.buy.credits_title`),note:S(`app.buy.credits_note`,{Price:w(i.credit_per_download)}),children:(_===`stars`?i.stars_packs:i.credit_packs.map(e=>({amount:e,stars:0}))).map(e=>(0,T.jsx)(D,{title:w(e.amount),sub:i.credit_per_download>0?S(`app.buy.credits_downloads`,{Count:Math.floor(e.amount/i.credit_per_download)}):void 0,after:_===`stars`?(0,T.jsx)(`b`,{children:ie(e.stars)}):void 0,chevron:!0,onClick:()=>y(`credits`,e.amount)},e.amount))}),(0,T.jsxs)(E,{title:S(`app.buy.paid_title`),children:[(0,T.jsx)(D,{title:S(`app.limit.size`),after:Fe(i.paid.max_size,oe)}),(0,T.jsx)(D,{title:S(`app.limit.duration`),after:Fe(i.paid.max_duration,se)}),(0,T.jsx)(D,{title:S(`app.limit.per_day`),after:Fe(i.paid.daily_downloads,C)}),(0,T.jsx)(D,{title:S(`app.limit.at_once`),after:Fe(i.paid.active_jobs,C)})]})]}),v===3&&u&&(0,T.jsx)(E,{children:(0,T.jsx)(`div`,{className:`pad`,children:(0,T.jsx)(Ae,{purchase:u,onPaid:e=>d(t=>t&&{...t,...e}),onDone:()=>{d(null),e.target?r():n({tab:`home`})}})})})]}):(0,T.jsx)(we,{children:S(`app.buy.unavailable`)})})}function Fe(e,t){return e>0?t(e):S(`app.limit.none`)}function Ie(){let e=ge(()=>b(`GET`,`history`),[]);return(0,T.jsx)(E,{title:S(`app.history.title`),note:S(`app.history.note`),children:(0,T.jsx)(Te,{of:e,children:e=>e.items.length===0?(0,T.jsx)(we,{children:S(`app.history.empty`)}):e.items.map(e=>(0,T.jsx)(Oe,{item:e},e.id))})})}function Le(){let{go:e}=me(),t=ge(()=>b(`GET`,`groups`),[]);return(0,T.jsx)(E,{title:S(`app.groups.title`),note:S(`app.groups.note`),children:(0,T.jsx)(Te,{of:t,children:t=>t.groups.length===0?(0,T.jsx)(we,{children:S(`app.groups.empty`)}):t.groups.map(t=>(0,T.jsx)(D,{title:t.title,sub:[S(`app.balance_is`,{Balance:w(t.balance)}),t.pass_until>Date.now()?S(`app.pass_until`,{Until:ue(t.pass_until)}):S(`app.groups.no_pass`)].join(` 路 `),chevron:!0,onClick:()=>e({tab:`groups`,group:t.id})},t.id))})})}var Re=[`overview`,`settings`,`wallet`,`usage`],ze=[``,`best`,`1080`,`720`,`480`,`mp3`];function Be(e){return ze.map(t=>({value:t,label:t===``?e:de(t)}))}function Ve(e){let[t,n]=(0,l.useState)(e.view),r=ge(()=>b(`GET`,`groups/`+e.id),[e.id]);return(0,T.jsx)(Te,{of:r,children:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`section-title`,children:(0,T.jsx)(`span`,{children:e.title})}),(0,T.jsx)(A,{value:t,onChange:n,options:Re.map(e=>({value:e,label:S(`app.group.tab.`+e)}))}),t===`overview`&&(0,T.jsx)(We,{group:e,open:n}),t===`settings`&&(0,T.jsx)(Je,{group:e,onSaved:t=>r.set({...e,settings:t})}),t===`wallet`&&(0,T.jsx)(Ye,{group:e,onSaved:t=>r.set({...e,settings:t})}),t===`usage`&&(0,T.jsx)(Xe,{id:e.id})]})})}function He(e){return S(`settings.who_`+e.who_can_use)}function Ue(e){return S(`settings.spend_`+e.spend_rule)}function We(e){let t=e.group,n=t.settings,r=t.pass_until>Date.now();return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`stats section`,children:[(0,T.jsxs)(`div`,{className:`stat`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.balance`)}),(0,T.jsx)(`div`,{className:`value`,children:w(t.balance)})]}),(0,T.jsxs)(`div`,{className:`stat`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.pass`)}),(0,T.jsx)(`div`,{className:`value`,children:S(r?`app.group.pass_on`:`app.group.pass_off`)}),r&&(0,T.jsx)(`div`,{className:`hint`,children:S(`app.pass_until`,{Until:le(t.pass_until)})})]})]}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.enabled`),after:n.enabled?S(`app.on`):S(`app.off`)}),(0,T.jsx)(D,{title:S(`settings.who`),after:He(n)}),(0,T.jsx)(D,{title:S(`settings.auto_detect`),after:n.auto_detect?S(`app.on`):S(`app.off`)}),(0,T.jsx)(D,{title:S(`settings.spend`),after:Ue(n)})]}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:()=>e.open(`settings`),children:S(`app.group.tab.settings`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>e.open(`wallet`),children:S(`app.group.tab.wallet`)})})]})]})}function Ge(e,t){let{notify:n,fail:r}=me(),[i,a]=(0,l.useState)(e.settings);return(0,l.useEffect)(()=>a(e.settings),[e.settings]),{draft:i,set:(e,t)=>a(n=>({...n,[e]:t})),dirty:JSON.stringify(i)!==JSON.stringify(e.settings),save:async()=>{try{t((await b(`PUT`,`groups/`+e.id+`/settings`,i)).settings),n(S(`app.saved`))}catch(e){r(e)}}}}function Ke(e){return(0,T.jsx)(`input`,{className:`input compact number`,type:`number`,inputMode:`numeric`,min:0,max:e.max,"aria-label":e.label,value:e.value===0?``:e.value,placeholder:`0`,onChange:t=>{let n=Math.max(0,Math.floor(Number(t.target.value)||0));e.onChange(e.max&&n>e.max?e.max:n)}})}function qe(e){let[t,n]=(0,l.useState)(``),r=()=>{let r=t.trim().toLowerCase().replace(/^[a-z]+:\/\//,``).replace(/\/.*$/,``).replace(/^www\./,``);r&&!e.value.includes(r)&&e.onChange([...e.value,r]),n(``)};return(0,T.jsx)(E,{title:e.title,note:e.note,children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[e.value.length>0&&(0,T.jsx)(`div`,{className:`chips`,children:e.value.map(t=>(0,T.jsxs)(`button`,{className:`chip`,dir:`ltr`,"aria-label":S(`app.group.remove_site`,{Site:t}),onClick:()=>e.onChange(e.value.filter(e=>e!==t)),children:[t,` 脳`]},t))}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`input`,{className:`input grow`,dir:`ltr`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:S(`app.group.site_placeholder`),value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}}),(0,T.jsx)(O,{kind:`soft`,onClick:r,disabled:!t.trim(),children:S(`app.add`)})]})]})})}function Je(e){let{me:t}=me(),{draft:n,set:r,dirty:i,save:a}=Ge(e.group,e.onSaved),o=e.group;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.enabled`),after:(0,T.jsx)(xe,{label:S(`settings.enabled`),checked:n.enabled,onChange:e=>r(`enabled`,e)})}),(0,T.jsx)(D,{title:S(`settings.auto_detect`),sub:S(`app.group.auto_detect_hint`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`settings.auto_detect`),checked:n.auto_detect,onChange:e=>r(`auto_detect`,e)})}),(0,T.jsx)(D,{title:S(`settings.delete_commands`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`settings.delete_commands`),checked:n.delete_commands,onChange:e=>r(`delete_commands`,e)})})]}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.who`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.who`),value:n.who_can_use,onChange:e=>r(`who_can_use`,e),options:[`everyone`,`pass_holders`,`admins`].map(e=>({value:e,label:S(`settings.who_`+e)}))})}),(0,T.jsx)(D,{title:S(`settings.quality`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.quality`),value:n.quality,onChange:e=>r(`quality`,e),options:Be(S(`quality.ask`))})}),(0,T.jsx)(D,{title:S(`app.group.language`),after:(0,T.jsx)(k,{compact:!0,label:S(`app.group.language`),value:n.lang,onChange:e=>r(`lang`,e),options:[{value:``,label:S(`settings.lang_auto`)},...t.languages.map(e=>({value:e.code,label:e.name}))]})})]}),(0,T.jsxs)(E,{title:S(`app.group.caps_title`),note:S(`app.group.caps_note`,{Size:oe(o.tier_max_size_mb*1048576)}),children:[(0,T.jsx)(D,{title:S(`app.group.max_size`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.max_size`),value:n.max_size_mb,max:o.tier_max_size_mb||void 0,onChange:e=>r(`max_size_mb`,e)})}),(0,T.jsx)(D,{title:S(`app.group.max_minutes`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.max_minutes`),value:Math.round(n.max_duration/60),max:o.tier_max_duration?Math.floor(o.tier_max_duration/60):void 0,onChange:e=>r(`max_duration`,e*60)})})]}),(0,T.jsx)(qe,{title:S(`app.group.allowed_title`),note:S(`app.group.allowed_note`),value:n.allowed,onChange:e=>r(`allowed`,e)}),(0,T.jsx)(qe,{title:S(`app.group.blocked_title`),note:S(`app.group.blocked_note`),value:n.blocked,onChange:e=>r(`blocked`,e)}),(0,T.jsx)(O,{wide:!0,onClick:a,disabled:!i,children:S(`app.save`)})]})}function Ye(e){let{go:t,me:n}=me(),{draft:r,set:i,dirty:a,save:o}=Ge(e.group,e.onSaved),s=e.group,c=s.pass_until>Date.now();return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(E,{children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.balance`)}),(0,T.jsx)(`div`,{className:`big`,children:w(s.balance)}),(0,T.jsx)(`div`,{className:`hint`,children:c?S(`app.pass_until`,{Until:le(s.pass_until)}):S(`app.groups.no_pass`)})]}),n.payments&&(0,T.jsx)(O,{wide:!0,onClick:()=>t({tab:`buy`,target:s.id}),children:S(`app.group.top_up`)})]})}),(0,T.jsxs)(E,{title:S(`app.group.rules_title`),note:S(`app.group.rules_note`),children:[(0,T.jsx)(D,{title:S(`settings.spend`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.spend`),value:r.spend_rule,onChange:e=>i(`spend_rule`,e),options:[`admins`,`anyone`,`capped`].map(e=>({value:e,label:S(`settings.spend_`+e)}))})}),r.spend_rule===`capped`&&(0,T.jsx)(D,{title:S(`app.group.spend_cap`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.spend_cap`),value:r.spend_cap,onChange:e=>i(`spend_cap`,e)})}),(0,T.jsx)(D,{title:S(`app.group.daily_cap`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.daily_cap`),value:r.daily_cap,onChange:e=>i(`daily_cap`,e)})})]}),(0,T.jsx)(O,{wide:!0,onClick:o,disabled:!a,children:S(`app.save`)})]})}function Xe(e){let t=ge(()=>b(`GET`,`groups/`+e.id+`/usage`),[e.id]);return(0,T.jsx)(Te,{of:t,children:e=>(0,T.jsx)(E,{title:S(`app.group.usage_title`,{Count:e.days}),children:e.members.length===0?(0,T.jsx)(we,{children:S(`app.group.usage_empty`)}):(0,T.jsxs)(`table`,{className:`table`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{children:S(`app.group.col_member`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_downloads`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_volume`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_spent`)})]})}),(0,T.jsx)(`tbody`,{children:e.members.map((e,t)=>(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`td`,{children:e.name}),(0,T.jsx)(`td`,{children:C(e.downloads)}),(0,T.jsx)(`td`,{children:oe(e.bytes)}),(0,T.jsx)(`td`,{children:w(e.sats)})]},t))})]})})})}function Ze(){let{me:e,go:t,notify:n,fail:r,reload:i}=me(),a=async e=>{try{await b(`PUT`,`me`,e),await i(),n(S(`app.saved`))}catch(e){r(e)}},o=e.quality===`mp3`,s=e.support.startsWith(`@`)?`https://t.me/`+e.support.slice(1):``;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{title:S(`app.me.downloads_title`),note:S(`app.me.quality_note`),children:[(0,T.jsx)(D,{title:S(`settings.quality`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.quality`),disabled:o,value:o?`fit`:e.quality,onChange:e=>void a({quality:e}),options:[{value:`fit`,label:S(`quality.fit`)},...Be(S(`quality.ask`)).filter(e=>e.value!==`mp3`)]})}),(0,T.jsx)(D,{title:S(`app.me.audio_only`),sub:S(`app.me.audio_only_hint`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`app.me.audio_only`),checked:o,onChange:e=>void a({quality:e?`mp3`:`fit`})})})]}),(0,T.jsx)(E,{title:S(`app.me.language_title`),children:(0,T.jsx)(D,{title:S(`app.me.language`),after:(0,T.jsx)(k,{compact:!0,label:S(`app.me.language`),value:e.lang_override,onChange:e=>void a({lang:e||`auto`}),options:[{value:``,label:S(`language.auto`)},...e.languages.map(e=>({value:e.code,label:e.name}))]})})}),(0,T.jsxs)(E,{title:S(`app.me.referral_title`),note:e.referral_reward>0?S(`app.me.referral_note`,{Reward:w(e.referral_reward)}):void 0,children:[(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsx)(`div`,{className:`mono`,children:e.referral_link}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:async()=>{await v(e.referral_link)?n(S(`app.copied`)):r(null)},children:S(`app.me.copy_link`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>_(`https://t.me/share/url?url=`+encodeURIComponent(e.referral_link)+`&text=`+encodeURIComponent(S(`referral.share_text`))),children:S(`app.me.share`)})})]}),e.referral_qr&&(0,T.jsxs)(`details`,{className:`qr-toggle`,children:[(0,T.jsx)(`summary`,{children:S(`app.me.qr`)}),(0,T.jsx)(`img`,{className:`qr`,src:e.referral_qr,alt:S(`app.me.qr`)})]})]}),(0,T.jsx)(D,{title:S(`app.me.invited`),after:S(`app.me.invited_count`,{Count:e.referral_count})}),(0,T.jsx)(D,{title:S(`app.me.converted`),after:String(e.referral_converted)}),(0,T.jsx)(D,{title:S(`app.me.earned`),after:w(e.referral_earned)}),e.referral_pending>0&&(0,T.jsx)(D,{title:S(`app.me.pending`),after:w(e.referral_pending)})]}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`app.history.title`),chevron:!0,onClick:()=>t({tab:`home`,page:`history`})}),(0,T.jsx)(D,{title:S(`app.me.support`),after:e.support,chevron:s!==``,onClick:s?()=>_(s):void 0})]})]})}var Qe={home:`M3 11.5 12 4l9 7.5M5.5 10v9.5h13V10`,queue:`M12 4v11m0 0-4-4m4 4 4-4M5 20h14`,buy:`M13 3 5 13.5h6L10 21l9-11h-6.5L13 3Z`,groups:`M9 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM3.5 19c.5-3 2.6-5 5.5-5s5 2 5.5 5M16.5 11.5a2.5 2.5 0 1 0 0-5M17 14.2c2 .3 3.3 1.9 3.7 4.3`,me:`M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM4.5 20c.7-3.5 3.7-6 7.5-6s6.8 2.5 7.5 6`},$e=[`home`,`queue`,`buy`,`groups`,`me`];function et(e){let t=new URLSearchParams(window.location.search).get(`page`)??e;return t.startsWith(`group_`)?{tab:`groups`,group:t.slice(6),view:`settings`}:t===`buy`?{tab:`buy`}:t===`queue`?{tab:`queue`}:{tab:`home`}}function tt(){let[e,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(null),[i,a]=(0,l.useState)([{tab:`home`}]),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(0),d=(0,l.useRef)(void 0),f=(0,l.useRef)(!1),m=(0,l.useCallback)(async()=>{let[e,n]=await Promise.all([b(`GET`,`me`),b(`GET`,`i18n`)]);return x(n),document.title=S(`app.title`),t(e),e},[]);(0,l.useEffect)(()=>{f.current||(f.current=!0,m().then(e=>a([et(e.start_param)])).catch(r))},[m]),(0,l.useEffect)(()=>{if(!e)return;let t=!0,n=()=>{document.hidden||b(`GET`,`queue`).then(e=>t&&u(e.jobs.length)).catch(()=>void 0)};n();let r=window.setInterval(n,5e3);return()=>{t=!1,window.clearInterval(r)}},[e]);let h=i[i.length-1],g=(0,l.useCallback)((e,t=!1)=>{window.clearTimeout(d.current),s({text:e,bad:t}),p(t?`error`:`success`),d.current=window.setTimeout(()=>s(null),3500)},[]),_=(0,l.useMemo)(()=>e?{me:e,route:h,go:e=>{let t=`page`in e||`group`in e||`target`in e;a(n=>t?[...n,e]:[e]),window.scrollTo(0,0)},back:()=>a(e=>e.length>1?e.slice(0,-1):[{tab:e[0].tab}]),notify:g,fail:e=>g(he(e),!0),reload:async()=>{await m()}}:null,[e,h,g,m]);if(be(_&&i.length>1?_.back:null),n){let e=n instanceof y?n.message:``;return(0,T.jsx)(`div`,{className:`app`,children:(0,T.jsxs)(`div`,{className:`empty`,children:[(0,T.jsx)(`p`,{className:`big`,children:`:(`}),(0,T.jsx)(`p`,{children:e}),!(n instanceof y&&n.status===401)&&(0,T.jsx)(`button`,{className:`btn soft`,"aria-label":`retry`,onClick:()=>window.location.reload(),children:`鈫籤})]})})}if(!_)return(0,T.jsx)(`div`,{className:`app`,children:(0,T.jsx)(Ce,{})});let v;return v=`group`in h?(0,T.jsx)(Ve,{id:h.group,view:h.view??`overview`},h.group):`page`in h?(0,T.jsx)(Ie,{}):h.tab===`queue`?(0,T.jsx)(je,{}):h.tab===`buy`?(0,T.jsx)(Pe,{target:`target`in h?h.target:void 0},`target`in h?h.target:`me`):h.tab===`groups`?(0,T.jsx)(Le,{}):h.tab===`me`?(0,T.jsx)(Ze,{}):(0,T.jsx)(j,{}),(0,T.jsxs)(pe.Provider,{value:_,children:[(0,T.jsx)(`main`,{className:`app`,children:v}),o&&(0,T.jsx)(`div`,{className:`toast`+(o.bad?` bad`:``),role:`status`,children:o.text}),(0,T.jsx)(`nav`,{className:`tabs`,children:$e.map(e=>(0,T.jsxs)(`button`,{"aria-current":h.tab===e?`page`:void 0,onClick:()=>_.go({tab:e}),children:[(0,T.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,T.jsx)(`path`,{d:Qe[e]})}),S(`app.tab.`+e),e===`queue`&&c>0&&(0,T.jsx)(`span`,{className:`badge`,children:c})]},e))})]})}d?.ready(),d?.expand(),(0,u.createRoot)(document.getElementById(`root`)).render((0,T.jsx)(l.StrictMode,{children:(0,T.jsx)(tt,{})})); \ No newline at end of file +`).replace(Qf,``)}function ep(e,t){return t=$f(t),$f(e)===t}function $(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||_n(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&_n(e,``+r);else return;break;case`className`:tn(e,`class`,r);break;case`tabIndex`:tn(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:tn(e,n,r);break;case`style`:bn(e,r,a);return;case`data`:if(t!==`object`){tn(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=wn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,i.name,i,null),$(e,t,`formEncType`,i.formEncType,i,null),$(e,t,`formMethod`,i.formMethod,i,null),$(e,t,`formTarget`,i.formTarget,i,null)):($(e,t,`encType`,i.encType,i,null),$(e,t,`method`,i.method,i,null),$(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=wn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Tn);return;case`onScroll`:r!=null&&Q(`scroll`,e);return;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(s(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(s(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=wn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),en(e,`popover`,r);break;case`xlinkActuate`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:en(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=un(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Ut(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+un(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+un(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+un(n.imageSizes)+`"]`)):i+=`[href="`+un(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=C({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Lt]=!0,o.onload=o.onerror=function(){Wt(o)}),Ut(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+un(r)+`"][href="`+un(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=C({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Ut(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Ht(r).hoistableStyles,a=Pm(e);t=t||`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=C({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Ut(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=C({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=C({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=ke.current)?bm(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Ht(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var a=Ht(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(Fm(e)))?a._p||(o.instance=a,o.state.loading=5):(a=vm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,a)),Lm(i,e,a,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Ht(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Pm(e){return`href="`+un(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return C({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Lt]){r.loading=1;return}}else t=e.createElement(`link`),t[Lt]=!0,t.onload=t.onerror=Wt.bind(null,t),np(t,`link`,n),Ut(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+un(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+un(n.href)+`"]`);if(r)return t.instance=r,Ut(r),r;var i=C({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ut(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var a=e.querySelector(Fm(i));if(a)return t.state.loading|=4,t.instance=a,Ut(a),a;r=Im(n),(i=vm.get(i))&&Hm(r,i),a=(e.ownerDocument||e).createElement(`link`),Ut(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),t.state.loading|=4,Vm(a,n.precedence,e),t.instance=a;case`script`:return a=Rm(n.src),(i=e.querySelector(zm(a)))?(t.instance=i,Ut(i),i):(r=n,(i=vm.get(a))&&(r=C({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Ut(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ut(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{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=s()})),l=n(),u=c(),d=window.Telegram?.WebApp;function f(){return d?.initData??``}function p(e){try{e===`tap`?d?.HapticFeedback?.selectionChanged():d?.HapticFeedback?.notificationOccurred(e)}catch{}}function m(e){return new Promise(t=>{d&&d.isVersionAtLeast(`6.2`)?d.showConfirm(e,t):t(window.confirm(e))})}function h(e){d?d.openLink(e):window.open(e,`_blank`,`noopener`)}function g(e,t){d?.openInvoice?d.openInvoice(e,t):d?d.openTelegramLink(e):window.open(e,`_blank`)}function _(e){d?d.openTelegramLink(e):window.open(e,`_blank`,`noopener`)}async function v(e){try{return await navigator.clipboard.writeText(e),!0}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=!1;try{n=document.execCommand(`copy`)}catch{n=!1}return t.remove(),n}}var y=class extends Error{constructor(e,t,n,r=!1){super(n),this.status=e,this.code=t,this.upgradable=r}};async function b(e,t,n){let r;try{r=await fetch(`/app/api/`+t,{method:e,headers:{Authorization:`tma `+f(),...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)})}catch{throw new y(0,`network`,``)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=i??{};throw new y(r.status,e.error??`internal`,e.message??``,e.upgradable??!1)}return i}var ee={},te=`en`,ne=new Intl.PluralRules(`en`);function re(e){try{return Intl.NumberFormat.supportedLocalesOf([e])[0]??`en`}catch{return`en`}}function x(e){ee=e.messages,te=re(e.lang),ne=new Intl.PluralRules(te),document.documentElement.lang=e.lang,document.documentElement.dir=e.dir}function S(e,t){let n=ee[e];return n===void 0?e:(typeof n!=`string`&&(n=n[ne.select(Number(t?.Count??0))]??n.other??``),n.replace(/\{(\w+)\}/g,(e,n)=>t&&n in t?String(t[n]):``))}function C(e){return new Intl.NumberFormat(te).format(e)}function w(e){return S(`unit.sats`,{Count:e,N:C(e)})}function ie(e){return S(`unit.stars`,{Count:e,N:C(e)})}function ae(e){return new Intl.NumberFormat(te,{style:`percent`,maximumFractionDigits:0}).format(e)}function oe(e){let t=(e,t)=>new Intl.NumberFormat(te,{minimumFractionDigits:0,maximumFractionDigits:t}).format(e),n=1024;if(e=100?0:1)+` MB`}return t(e/(n*n*n),2)+` GB`}function se(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=e=>String(e).padStart(2,`0`);return n>0?`${n}:${i(r)}:${i(t%60)}`:`${r}:${i(t%60)}`}function ce(e){return e<60?S(`unit.seconds`,{Count:Math.max(1,Math.round(e))}):e<3600?S(`unit.minutes`,{Count:Math.round(e/60)}):S(`unit.hours`,{Count:Math.round(e/3600)})}function le(e){return new Intl.DateTimeFormat(te,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}function ue(e){return new Intl.DateTimeFormat(te,{dateStyle:`medium`}).format(new Date(e))}function de(e){return e===`best`?S(`btn.best`):/^\d+$/.test(e)?S(`btn.res`,{Height:e}):e===`mp3`||e===`m4a`||e===`thumb`?S(`btn.`+e):e.startsWith(`subs:`)?S(`btn.subs`,{Lang:e.slice(5)}):e}var fe=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),T=e(((e,t)=>{t.exports=fe()}))(),pe=(0,l.createContext)(null);function me(){let e=(0,l.useContext)(pe);if(!e)throw Error(`no app context`);return e}function he(e){if(e instanceof y){if(e.message)return e.message;if(e.code===`network`)return S(`app.error.network`)}return S(`app.error.generic`)}function ge(e,t,n=0){let[r,i]=(0,l.useState)(null),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(!0),[u,d]=(0,l.useState)(0),f=(0,l.useRef)(e);return f.current=e,(0,l.useEffect)(()=>{let e=!0,t,r=()=>{f.current().then(t=>{e&&(i(t),o(null))}).catch(t=>e&&o(t)).finally(()=>{e&&(c(!1),n>0&&(t=window.setTimeout(a,n)))})},a=()=>{document.hidden?t=window.setTimeout(a,n):r()};return r(),()=>{e=!1,window.clearTimeout(t)}},[...t,u,n]),{data:r,error:a,loading:s,reload:()=>d(e=>e+1),set:i}}var _e=[],ve=!1;function ye(){d&&(ve||(d.BackButton.onClick(()=>_e[_e.length-1]?.current?.()),ve=!0),_e.length>0?d.BackButton.show():d.BackButton.hide())}function be(e){let t=(0,l.useRef)(e);t.current=e;let n=e!==null;(0,l.useEffect)(()=>{if(n)return _e.push(t),ye(),()=>{let e=_e.indexOf(t);e>=0&&_e.splice(e,1),ye()}},[n])}function E(e){return(0,T.jsxs)(`section`,{className:`section`,children:[(e.title||e.action)&&(0,T.jsxs)(`div`,{className:`section-title`,children:[(0,T.jsx)(`span`,{children:e.title}),e.action]}),(0,T.jsx)(`div`,{className:`card`,children:e.children}),e.note&&(0,T.jsx)(`div`,{className:`note`,children:e.note})]})}function D(e){let t=(0,T.jsxs)(T.Fragment,{children:[e.before,(0,T.jsxs)(`div`,{className:`cell-body`,children:[(0,T.jsx)(`div`,{className:`cell-title`+(e.wrap?` wrap`:``),children:e.title}),e.sub&&(0,T.jsx)(`div`,{className:`cell-sub`,children:e.sub})]}),(e.after||e.chevron)&&(0,T.jsxs)(`div`,{className:`cell-after`,children:[e.after,e.chevron&&(0,T.jsx)(`span`,{className:`chevron`})]})]});return e.onClick?(0,T.jsx)(`button`,{className:`cell`,onClick:e.onClick,children:t}):(0,T.jsx)(`div`,{className:`cell`,children:t})}function O(e){let[t,n]=(0,l.useState)(!1),r=(0,l.useRef)(!0);(0,l.useEffect)(()=>()=>{r.current=!1},[]);let i=()=>{if(t||!e.onClick)return;p(`tap`);let i=e.onClick();i instanceof Promise&&(n(!0),i.finally(()=>r.current&&n(!1)))},a=[`btn`,e.kind&&e.kind!==`primary`?e.kind:``,e.small?`small`:``,e.wide?`wide`:``];return(0,T.jsx)(`button`,{className:a.filter(Boolean).join(` `),onClick:i,disabled:e.disabled||t,children:t?(0,T.jsx)(`span`,{className:`spinner`}):e.children})}function xe(e){return(0,T.jsx)(`button`,{className:`switch`,role:`switch`,"aria-checked":e.checked,"aria-label":e.label,onClick:()=>{p(`tap`),e.onChange(!e.checked)}})}function k(e){return(0,T.jsx)(`select`,{className:`select`+(e.compact?` compact`:``),"aria-label":e.label,disabled:e.disabled,value:e.value,onChange:t=>e.onChange(t.target.value),children:e.options.map(e=>(0,T.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function A(e){return(0,T.jsx)(`div`,{className:`segmented`,role:`tablist`,children:e.options.map(t=>(0,T.jsx)(`button`,{role:`tab`,"aria-selected":t.value===e.value,onClick:()=>e.onChange(t.value),children:t.label},t.value))})}function Se(e){let t=Math.max(0,Math.min(1,e.value))*100;return(0,T.jsx)(`div`,{className:`meter`+(e.busy?` busy`:``),children:(0,T.jsx)(`div`,{style:{width:t+`%`}})})}function Ce(){return(0,T.jsx)(`div`,{className:`spinner`,role:`progressbar`})}function we(e){return(0,T.jsx)(`div`,{className:`empty`,children:e.children})}function Te(e){let{data:t,error:n,loading:r,reload:i}=e.of;return t===null?r?(0,T.jsx)(Ce,{}):(0,T.jsxs)(we,{children:[(0,T.jsx)(`p`,{children:he(n)}),(0,T.jsx)(O,{kind:`soft`,onClick:i,children:S(`app.retry`)})]}):(0,T.jsx)(T.Fragment,{children:e.children(t)})}function Ee(e){return(0,T.jsx)(`div`,{className:`sheet-back`,onClick:e.onClose,children:(0,T.jsx)(`div`,{className:`sheet`,role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:e.children})})}function j(){let{me:e,go:t}=me(),n=ge(()=>b(`GET`,`history?limit=5`),[]),r=e.pass_until>Date.now(),i=e.limits;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{children:[(0,T.jsxs)(`div`,{className:`pad`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.home.hello`,{Name:e.name})}),(0,T.jsx)(`div`,{className:`big`,children:S(r?`app.home.pass_active`:`app.home.plan_free`)}),(0,T.jsx)(`div`,{className:`hint`,children:r?S(`app.pass_until`,{Until:le(e.pass_until)}):S(`app.home.plan_free_hint`)})]}),(0,T.jsx)(D,{title:S(`app.home.balance`),after:(0,T.jsx)(`b`,{children:w(e.balance)}),chevron:e.payments,onClick:e.payments?()=>t({tab:`buy`}):void 0})]}),(0,T.jsx)(E,{title:S(`app.home.today`),children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsx)(De,{label:S(`app.home.downloads`),used:e.usage.downloads,max:i.daily_downloads,format:C}),(0,T.jsx)(De,{label:S(`app.home.volume`),used:e.usage.bytes,max:i.daily_bytes,format:oe})]})}),(0,T.jsx)(ke,{}),(0,T.jsx)(E,{title:S(`app.home.recent`),action:(0,T.jsx)(O,{kind:`plain`,onClick:()=>t({tab:`home`,page:`history`}),children:S(`app.home.all_history`)}),children:n.data&&n.data.items.length>0?n.data.items.map(e=>(0,T.jsx)(Oe,{item:e},e.id)):(0,T.jsx)(`div`,{className:`empty`,children:n.loading?``:S(`app.history.empty`)})})]})}function De(e){let t=e.max<=0;return(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`span`,{className:`grow`,children:e.label}),(0,T.jsx)(`span`,{className:`hint`,children:t?S(`app.home.used_unlimited`,{Used:e.format(e.used)}):S(`app.home.used_of`,{Used:e.format(e.used),Max:e.format(e.max)})})]}),(0,T.jsx)(Se,{value:t?0:e.used/e.max})]})}function Oe(e){let{notify:t,fail:n}=me(),r=e.item;return(0,T.jsx)(D,{title:r.title||S(`app.untitled`),sub:[de(r.profile),r.size>0?oe(r.size):``,le(r.at)].filter(Boolean).join(` 路 `),after:(0,T.jsx)(O,{small:!0,kind:`soft`,onClick:async()=>{try{await b(`POST`,`history/`+r.id+`/resend`),t(S(`app.sent_to_chat`))}catch(e){n(e)}},children:S(`app.history.resend`)})})}function ke(){let{go:e,notify:t}=me(),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),c=e=>s({text:he(e),upgradable:e instanceof y&&e.upgradable}),u=async()=>{s(null),a(null);try{a(await b(`POST`,`probe`,{url:n.trim()}))}catch(e){c(e)}},d=async n=>{if(i){s(null);try{await b(`POST`,`download`,{url:i.url,profile:n}),a(null),r(``),t(S(`app.sent_to_chat`)),e({tab:`queue`})}catch(e){c(e)}}};return(0,T.jsx)(E,{title:S(`app.home.paste_title`),children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`input`,{className:`input grow`,type:`url`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,dir:`ltr`,placeholder:S(`app.home.paste_placeholder`),value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&n.trim()&&u()}}),(0,T.jsx)(O,{onClick:u,disabled:!n.trim(),children:S(`app.home.look_up`)})]}),o&&(0,T.jsxs)(`div`,{className:`stack`,children:[(0,T.jsx)(`div`,{className:`error`,children:o.text}),o.upgradable&&(0,T.jsx)(O,{kind:`soft`,onClick:()=>e({tab:`buy`}),children:S(`app.see_plans`)})]}),i&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`cell-title wrap`,children:i.title||S(`app.untitled`)}),(0,T.jsx)(`div`,{className:`hint`,children:[i.uploader,i.duration>0?se(i.duration):``,i.site].filter(Boolean).join(` 路 `)})]}),(0,T.jsx)(`div`,{className:`row wrap`,children:i.options.map(e=>(0,T.jsx)(O,{kind:`soft`,onClick:()=>d(e.profile),children:e.size?S(`btn.with_size`,{Label:de(e.profile),Size:oe(e.size)}):de(e.profile)},e.profile))})]})]})})}function Ae(e){let{notify:t,fail:n,reload:r}=me(),[i,a]=(0,l.useState)(e.purchase),[o,s]=(0,l.useState)(Date.now()),c=(0,l.useRef)(e.onPaid);c.current=e.onPaid,(0,l.useEffect)(()=>{if(i.status!==`pending`)return;let e=!0,t=window.setInterval(()=>{document.hidden||b(`GET`,`purchase/`+i.id).then(t=>{e&&t.status!==`pending`&&(a(e=>({...e,...t})),t.status===`paid`&&(p(`success`),r(),c.current?.(t)))}).catch(()=>void 0)},2500),n=window.setInterval(()=>s(Date.now()),1e3);return()=>{e=!1,window.clearInterval(t),window.clearInterval(n)}},[i.id,i.status,r]);let u=S(`product.`+i.product),d=i.method===`stars`?ie(i.stars):w(i.amount);if(i.status===`paid`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`paid-mark`,children:`鉁揱}),(0,T.jsx)(`div`,{className:`big`,children:S(`app.invoice.paid`)}),(0,T.jsx)(`div`,{children:S(`app.invoice.paid_text`,{Product:u,Amount:d})}),i.pass_until?(0,T.jsx)(`div`,{className:`hint`,children:S(`app.pass_until`,{Until:le(i.pass_until)})}):null,i.balance!==void 0&&(0,T.jsx)(`div`,{className:`hint`,children:S(`app.balance_is`,{Balance:w(i.balance)})}),(0,T.jsx)(O,{wide:!0,onClick:e.onDone,children:S(`app.done`)})]});if(i.status!==`pending`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`big`,children:S(`app.invoice.`+i.status)}),(0,T.jsx)(`div`,{className:`hint`,children:S(`app.invoice.closed_text`)}),(0,T.jsx)(O,{wide:!0,onClick:e.onDone,children:S(`app.close`)})]});if(i.method===`stars`)return(0,T.jsxs)(`div`,{className:`stack center`,children:[(0,T.jsx)(`div`,{className:`hint`,children:u}),(0,T.jsx)(`div`,{className:`big`,children:d}),(0,T.jsx)(`div`,{className:`hint`,role:`status`,children:S(`app.invoice.stars_waiting`)}),i.invoice_link&&(0,T.jsx)(O,{wide:!0,onClick:()=>g(i.invoice_link??``,()=>void 0),children:S(`app.invoice.stars_pay`)}),(0,T.jsx)(O,{kind:`plain`,onClick:async()=>{try{await b(`POST`,`purchase/`+i.id+`/cancel`)}catch{}e.onDone()},children:S(`app.invoice.cancel`)})]});let f=Math.max(0,Math.floor((i.expires_at-o)/1e3)),m=i.bolt11??``;return(0,T.jsxs)(`div`,{className:`stack`,children:[(0,T.jsxs)(`div`,{className:`center`,children:[(0,T.jsx)(`div`,{className:`hint`,children:u}),(0,T.jsx)(`div`,{className:`big`,children:w(i.amount)})]}),i.qr&&(0,T.jsx)(`img`,{className:`qr`,src:i.qr,alt:S(`app.invoice.qr_alt`)}),(0,T.jsxs)(`div`,{className:`mono hint center`,children:[m.slice(0,24),`鈥,m.slice(-12)]}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:async()=>{await v(m)?t(S(`app.copied`)):n(null)},children:S(`app.invoice.copy`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>h(window.location.origin+`/pay/`+i.id),children:S(`btn.open_wallet`)})})]}),(0,T.jsx)(`div`,{className:`center hint`,role:`timer`,children:f>0?S(`app.invoice.waiting`,{Time:se(f)}):S(`app.invoice.checking`)}),(0,T.jsx)(`div`,{className:`center`,children:(0,T.jsx)(O,{kind:`plain`,onClick:async()=>{try{await b(`POST`,`purchase/`+i.id+`/cancel`)}catch{}e.onDone()},children:S(`app.invoice.cancel`)})})]})}function je(){let{notify:e,fail:t}=me(),n=ge(()=>b(`GET`,`queue`),[],2e3),[r,i]=(0,l.useState)(null),a=async r=>{if(await m(S(`app.queue.cancel_confirm`,{Title:r.title||S(`app.untitled`)}))){try{await b(`POST`,`queue/`+r.id+`/cancel`),e(S(`app.queue.cancelled`))}catch(e){t(e)}n.reload()}},o=async r=>{try{let t=await b(`POST`,`queue/`+r.id+`/prioritize`);t.done?e(S(`app.queue.prioritized`)):t.purchase&&i(t.purchase)}catch(e){t(e)}n.reload()};return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(E,{title:S(`app.queue.title`),note:S(`app.queue.note`),children:(0,T.jsx)(Te,{of:n,children:e=>e.jobs.length===0?(0,T.jsx)(we,{children:S(`app.queue.empty`)}):e.jobs.map(e=>(0,T.jsx)(Ne,{job:e,onCancel:()=>a(e),onPrioritize:()=>o(e)},e.id))})}),r&&(0,T.jsx)(Ee,{onClose:()=>i(null),children:(0,T.jsx)(Ae,{purchase:r,onPaid:()=>n.reload(),onDone:()=>{i(null),n.reload()}})})]})}function Me(e){return e.status===`queued`?S(`app.queue.waiting`,{Position:e.position??1,Wait:ce(e.wait_seconds??0)}):e.status===`delivering`||e.stage===`uploading`?S(`app.queue.sending`):e.stage===`processing`?S(`app.queue.processing`):e.progress>0?S(`app.queue.downloading_pct`,{Percent:ae(e.progress)}):S(`app.queue.downloading`)}function Ne(e){let t=e.job,n=t.status!==`queued`&&(t.progress<=0||t.stage===`processing`||t.status===`delivering`);return(0,T.jsx)(`div`,{className:`cell`,children:(0,T.jsxs)(`div`,{className:`cell-body`,children:[(0,T.jsx)(`div`,{className:`cell-title`,children:t.title||S(`app.untitled`)}),(0,T.jsxs)(`div`,{className:`cell-sub`,children:[de(t.profile),` 路 `,Me(t)]}),t.status!==`queued`&&(0,T.jsx)(Se,{value:t.progress,busy:n}),(t.can_cancel||t.can_prioritize)&&(0,T.jsxs)(`div`,{className:`row`,style:{marginBlockStart:8},children:[t.can_prioritize&&(0,T.jsx)(O,{small:!0,onClick:e.onPrioritize,children:S(`app.queue.prioritize`,{Price:w(t.skip_price??0)})}),t.can_cancel&&(0,T.jsx)(O,{small:!0,kind:`danger`,onClick:e.onCancel,children:S(`btn.cancel`)})]})]})})}function Pe(e){let{me:t,go:n,back:r,fail:i}=me(),a=ge(()=>b(`GET`,`products`),[]),o=ge(()=>b(`GET`,`groups`),[]),[s,c]=(0,l.useState)(e.target??null),[u,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),_=m??(a.data&&!a.data.lightning?`stars`:`lightning`),v=u?3:s?2:1;be(v===2&&!e.target?()=>c(null):v===3&&u?.status!==`pending`?()=>d(null):null);let y=async(e,t)=>{if(!f){p(!0);try{let n=await b(`POST`,`purchase`,{target:s,product:e,amount:t,method:_});d(n),n.method===`stars`&&n.invoice_link&&g(n.invoice_link,e=>{(e===`cancelled`||e===`failed`)&&(b(`POST`,`purchase/`+n.id+`/cancel`).catch(()=>void 0),d(null),e===`failed`&&i(null))})}catch(e){i(e)}p(!1)}},ee=o.data?.groups.find(e=>e.id===s),te=s===`me`?S(`app.buy.for_me`):ee?.title??S(`app.buy.for_group`);return(0,T.jsx)(Te,{of:a,children:i=>i.enabled?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`steps`,"aria-label":S(`app.buy.step`,{Step:v,Total:3}),children:[1,2,3].map(e=>(0,T.jsx)(`span`,{className:e<=v?`on`:``},e))}),v===1&&(0,T.jsxs)(E,{title:S(`app.buy.target_title`),note:S(`app.buy.target_note`),children:[(0,T.jsx)(D,{title:S(`app.buy.for_me`),sub:S(`app.balance_is`,{Balance:w(t.balance)}),chevron:!0,onClick:()=>c(`me`)}),o.data?.groups.map(e=>(0,T.jsx)(D,{title:e.title,sub:S(`app.balance_is`,{Balance:w(e.balance)}),chevron:!0,onClick:()=>c(e.id)},e.id))]}),v===2&&(0,T.jsxs)(T.Fragment,{children:[i.lightning&&i.stars&&(0,T.jsx)(A,{value:_,onChange:h,options:[{value:`lightning`,label:S(`app.buy.method_lightning`)},{value:`stars`,label:S(`app.buy.method_stars`)}]}),(0,T.jsx)(E,{title:S(`app.buy.pass_title`,{Target:te}),note:S(`app.buy.pass_note`),children:i.passes.filter(e=>_===`lightning`||e.stars>0).map(e=>(0,T.jsx)(D,{title:S(`product.`+e.product),after:(0,T.jsx)(`b`,{children:_===`stars`?ie(e.stars):w(e.price)}),chevron:!0,onClick:()=>y(e.product,0)},e.product))}),(0,T.jsx)(E,{title:S(`app.buy.credits_title`),note:S(`app.buy.credits_note`,{Price:w(i.credit_per_download)}),children:(_===`stars`?i.stars_packs:i.credit_packs.map(e=>({amount:e,stars:0}))).map(e=>(0,T.jsx)(D,{title:w(e.amount),sub:i.credit_per_download>0?S(`app.buy.credits_downloads`,{Count:Math.floor(e.amount/i.credit_per_download)}):void 0,after:_===`stars`?(0,T.jsx)(`b`,{children:ie(e.stars)}):void 0,chevron:!0,onClick:()=>y(`credits`,e.amount)},e.amount))}),(0,T.jsxs)(E,{title:S(`app.buy.paid_title`),children:[(0,T.jsx)(D,{title:S(`app.limit.size`),after:Fe(i.paid.max_size,oe)}),(0,T.jsx)(D,{title:S(`app.limit.duration`),after:Fe(i.paid.max_duration,se)}),(0,T.jsx)(D,{title:S(`app.limit.per_day`),after:Fe(i.paid.daily_downloads,C)}),(0,T.jsx)(D,{title:S(`app.limit.at_once`),after:Fe(i.paid.active_jobs,C)})]})]}),v===3&&u&&(0,T.jsx)(E,{children:(0,T.jsx)(`div`,{className:`pad`,children:(0,T.jsx)(Ae,{purchase:u,onPaid:e=>d(t=>t&&{...t,...e}),onDone:()=>{d(null),e.target?r():n({tab:`home`})}})})})]}):(0,T.jsx)(we,{children:S(`app.buy.unavailable`)})})}function Fe(e,t){return e>0?t(e):S(`app.limit.none`)}function Ie(){let e=ge(()=>b(`GET`,`history`),[]);return(0,T.jsx)(E,{title:S(`app.history.title`),note:S(`app.history.note`),children:(0,T.jsx)(Te,{of:e,children:e=>e.items.length===0?(0,T.jsx)(we,{children:S(`app.history.empty`)}):e.items.map(e=>(0,T.jsx)(Oe,{item:e},e.id))})})}function Le(){let{go:e}=me(),t=ge(()=>b(`GET`,`groups`),[]);return(0,T.jsx)(E,{title:S(`app.groups.title`),note:S(`app.groups.note`),children:(0,T.jsx)(Te,{of:t,children:t=>t.groups.length===0?(0,T.jsx)(we,{children:S(`app.groups.empty`)}):t.groups.map(t=>(0,T.jsx)(D,{title:t.title,sub:[S(`app.balance_is`,{Balance:w(t.balance)}),t.pass_until>Date.now()?S(`app.pass_until`,{Until:ue(t.pass_until)}):S(`app.groups.no_pass`)].join(` 路 `),chevron:!0,onClick:()=>e({tab:`groups`,group:t.id})},t.id))})})}var Re=[`overview`,`settings`,`wallet`,`usage`],ze=[``,`best`,`1080`,`720`,`480`,`mp3`];function Be(e){return ze.map(t=>({value:t,label:t===``?e:de(t)}))}function Ve(e){let[t,n]=(0,l.useState)(e.view),r=ge(()=>b(`GET`,`groups/`+e.id),[e.id]);return(0,T.jsx)(Te,{of:r,children:e=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`section-title`,children:(0,T.jsx)(`span`,{children:e.title})}),(0,T.jsx)(A,{value:t,onChange:n,options:Re.map(e=>({value:e,label:S(`app.group.tab.`+e)}))}),t===`overview`&&(0,T.jsx)(We,{group:e,open:n}),t===`settings`&&(0,T.jsx)(Je,{group:e,onSaved:t=>r.set({...e,settings:t})}),t===`wallet`&&(0,T.jsx)(Ye,{group:e,onSaved:t=>r.set({...e,settings:t})}),t===`usage`&&(0,T.jsx)(Xe,{id:e.id})]})})}function He(e){return S(`settings.who_`+e.who_can_use)}function Ue(e){return S(`settings.spend_`+e.spend_rule)}function We(e){let t=e.group,n=t.settings,r=t.pass_until>Date.now();return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`stats section`,children:[(0,T.jsxs)(`div`,{className:`stat`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.balance`)}),(0,T.jsx)(`div`,{className:`value`,children:w(t.balance)})]}),(0,T.jsxs)(`div`,{className:`stat`,children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.pass`)}),(0,T.jsx)(`div`,{className:`value`,children:S(r?`app.group.pass_on`:`app.group.pass_off`)}),r&&(0,T.jsx)(`div`,{className:`hint`,children:S(`app.pass_until`,{Until:le(t.pass_until)})})]})]}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.enabled`),after:n.enabled?S(`app.on`):S(`app.off`)}),(0,T.jsx)(D,{title:S(`settings.who`),after:He(n)}),(0,T.jsx)(D,{title:S(`settings.auto_detect`),after:n.auto_detect?S(`app.on`):S(`app.off`)}),(0,T.jsx)(D,{title:S(`settings.spend`),after:Ue(n)})]}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:()=>e.open(`settings`),children:S(`app.group.tab.settings`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>e.open(`wallet`),children:S(`app.group.tab.wallet`)})})]})]})}function Ge(e,t){let{notify:n,fail:r}=me(),[i,a]=(0,l.useState)(e.settings);return(0,l.useEffect)(()=>a(e.settings),[e.settings]),{draft:i,set:(e,t)=>a(n=>({...n,[e]:t})),dirty:JSON.stringify(i)!==JSON.stringify(e.settings),save:async()=>{try{t((await b(`PUT`,`groups/`+e.id+`/settings`,i)).settings),n(S(`app.saved`))}catch(e){r(e)}}}}function Ke(e){return(0,T.jsx)(`input`,{className:`input compact number`,type:`number`,inputMode:`numeric`,min:0,max:e.max,"aria-label":e.label,value:e.value===0?``:e.value,placeholder:`0`,onChange:t=>{let n=Math.max(0,Math.floor(Number(t.target.value)||0));e.onChange(e.max&&n>e.max?e.max:n)}})}function qe(e){let[t,n]=(0,l.useState)(``),r=()=>{let r=t.trim().toLowerCase().replace(/^[a-z]+:\/\//,``).replace(/\/.*$/,``).replace(/^www\./,``);r&&!e.value.includes(r)&&e.onChange([...e.value,r]),n(``)};return(0,T.jsx)(E,{title:e.title,note:e.note,children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[e.value.length>0&&(0,T.jsx)(`div`,{className:`chips`,children:e.value.map(t=>(0,T.jsxs)(`button`,{className:`chip`,dir:`ltr`,"aria-label":S(`app.group.remove_site`,{Site:t}),onClick:()=>e.onChange(e.value.filter(e=>e!==t)),children:[t,` 脳`]},t))}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`input`,{className:`input grow`,dir:`ltr`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:S(`app.group.site_placeholder`),value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}}),(0,T.jsx)(O,{kind:`soft`,onClick:r,disabled:!t.trim(),children:S(`app.add`)})]})]})})}function Je(e){let{me:t}=me(),{draft:n,set:r,dirty:i,save:a}=Ge(e.group,e.onSaved),o=e.group;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.enabled`),after:(0,T.jsx)(xe,{label:S(`settings.enabled`),checked:n.enabled,onChange:e=>r(`enabled`,e)})}),(0,T.jsx)(D,{title:S(`settings.auto_detect`),sub:S(`app.group.auto_detect_hint`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`settings.auto_detect`),checked:n.auto_detect,onChange:e=>r(`auto_detect`,e)})}),(0,T.jsx)(D,{title:S(`settings.delete_commands`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`settings.delete_commands`),checked:n.delete_commands,onChange:e=>r(`delete_commands`,e)})})]}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`settings.who`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.who`),value:n.who_can_use,onChange:e=>r(`who_can_use`,e),options:[`everyone`,`pass_holders`,`admins`].map(e=>({value:e,label:S(`settings.who_`+e)}))})}),(0,T.jsx)(D,{title:S(`settings.quality`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.quality`),value:n.quality,onChange:e=>r(`quality`,e),options:Be(S(`quality.ask`))})}),(0,T.jsx)(D,{title:S(`app.group.language`),after:(0,T.jsx)(k,{compact:!0,label:S(`app.group.language`),value:n.lang,onChange:e=>r(`lang`,e),options:[{value:``,label:S(`settings.lang_auto`)},...t.languages.map(e=>({value:e.code,label:e.name}))]})})]}),(0,T.jsxs)(E,{title:S(`app.group.caps_title`),note:S(`app.group.caps_note`,{Size:oe(o.tier_max_size_mb*1048576)}),children:[(0,T.jsx)(D,{title:S(`app.group.max_size`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.max_size`),value:n.max_size_mb,max:o.tier_max_size_mb||void 0,onChange:e=>r(`max_size_mb`,e)})}),(0,T.jsx)(D,{title:S(`app.group.max_minutes`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.max_minutes`),value:Math.round(n.max_duration/60),max:o.tier_max_duration?Math.floor(o.tier_max_duration/60):void 0,onChange:e=>r(`max_duration`,e*60)})})]}),(0,T.jsx)(qe,{title:S(`app.group.allowed_title`),note:S(`app.group.allowed_note`),value:n.allowed,onChange:e=>r(`allowed`,e)}),(0,T.jsx)(qe,{title:S(`app.group.blocked_title`),note:S(`app.group.blocked_note`),value:n.blocked,onChange:e=>r(`blocked`,e)}),(0,T.jsx)(O,{wide:!0,onClick:a,disabled:!i,children:S(`app.save`)})]})}function Ye(e){let{go:t,me:n}=me(),{draft:r,set:i,dirty:a,save:o}=Ge(e.group,e.onSaved),s=e.group,c=s.pass_until>Date.now();return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(E,{children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`hint`,children:S(`app.group.balance`)}),(0,T.jsx)(`div`,{className:`big`,children:w(s.balance)}),(0,T.jsx)(`div`,{className:`hint`,children:c?S(`app.pass_until`,{Until:le(s.pass_until)}):S(`app.groups.no_pass`)})]}),n.payments&&(0,T.jsx)(O,{wide:!0,onClick:()=>t({tab:`buy`,target:s.id}),children:S(`app.group.top_up`)})]})}),(0,T.jsxs)(E,{title:S(`app.group.rules_title`),note:S(`app.group.rules_note`),children:[(0,T.jsx)(D,{title:S(`settings.spend`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.spend`),value:r.spend_rule,onChange:e=>i(`spend_rule`,e),options:[`admins`,`anyone`,`capped`].map(e=>({value:e,label:S(`settings.spend_`+e)}))})}),r.spend_rule===`capped`&&(0,T.jsx)(D,{title:S(`app.group.spend_cap`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.spend_cap`),value:r.spend_cap,onChange:e=>i(`spend_cap`,e)})}),(0,T.jsx)(D,{title:S(`app.group.daily_cap`),wrap:!0,after:(0,T.jsx)(Ke,{label:S(`app.group.daily_cap`),value:r.daily_cap,onChange:e=>i(`daily_cap`,e)})})]}),(0,T.jsx)(O,{wide:!0,onClick:o,disabled:!a,children:S(`app.save`)})]})}function Xe(e){let t=ge(()=>b(`GET`,`groups/`+e.id+`/usage`),[e.id]);return(0,T.jsx)(Te,{of:t,children:e=>(0,T.jsx)(E,{title:S(`app.group.usage_title`,{Count:e.days}),children:e.members.length===0?(0,T.jsx)(we,{children:S(`app.group.usage_empty`)}):(0,T.jsxs)(`table`,{className:`table`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{children:S(`app.group.col_member`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_downloads`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_volume`)}),(0,T.jsx)(`th`,{children:S(`app.group.col_spent`)})]})}),(0,T.jsx)(`tbody`,{children:e.members.map((e,t)=>(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`td`,{children:e.name}),(0,T.jsx)(`td`,{children:C(e.downloads)}),(0,T.jsx)(`td`,{children:oe(e.bytes)}),(0,T.jsx)(`td`,{children:w(e.sats)})]},t))})]})})})}function Ze(){let{me:e,go:t,notify:n,fail:r,reload:i}=me(),a=async e=>{try{await b(`PUT`,`me`,e),await i(),n(S(`app.saved`))}catch(e){r(e)}},o=e.quality===`mp3`,s=e.support.startsWith(`@`)?`https://t.me/`+e.support.slice(1):``;return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(E,{title:S(`app.me.downloads_title`),note:S(`app.me.quality_note`),children:[(0,T.jsx)(D,{title:S(`settings.quality`),after:(0,T.jsx)(k,{compact:!0,label:S(`settings.quality`),disabled:o,value:o?`fit`:e.quality,onChange:e=>void a({quality:e}),options:[{value:`fit`,label:S(`quality.fit`)},...Be(S(`quality.ask`)).filter(e=>e.value!==`mp3`)]})}),(0,T.jsx)(D,{title:S(`app.me.audio_only`),sub:S(`app.me.audio_only_hint`),wrap:!0,after:(0,T.jsx)(xe,{label:S(`app.me.audio_only`),checked:o,onChange:e=>void a({quality:e?`mp3`:`fit`})})})]}),(0,T.jsx)(E,{title:S(`app.me.language_title`),children:(0,T.jsx)(D,{title:S(`app.me.language`),after:(0,T.jsx)(k,{compact:!0,label:S(`app.me.language`),value:e.lang_override,onChange:e=>void a({lang:e||`auto`}),options:[{value:``,label:S(`language.auto`)},...e.languages.map(e=>({value:e.code,label:e.name}))]})})}),(0,T.jsx)(E,{title:S(`app.me.earn_title`),children:(0,T.jsx)(`div`,{className:`pad`,children:S(e.affiliate_enabled?`app.me.earn_note_both`:`app.me.earn_note_sats`)})}),(0,T.jsxs)(E,{title:S(`app.me.referral_title`),note:e.referral_reward>0?S(`app.me.referral_note`,{Reward:w(e.referral_reward)}):void 0,children:[(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsx)(`div`,{className:`mono`,children:e.referral_link}),(0,T.jsxs)(`div`,{className:`row`,children:[(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:async()=>{await v(e.referral_link)?n(S(`app.copied`)):r(null)},children:S(`app.me.copy_link`)})}),(0,T.jsx)(`div`,{className:`grow`,children:(0,T.jsx)(O,{wide:!0,onClick:()=>_(`https://t.me/share/url?url=`+encodeURIComponent(e.referral_link)+`&text=`+encodeURIComponent(S(`referral.share_text`))),children:S(`app.me.share`)})})]}),e.referral_qr&&(0,T.jsxs)(`details`,{className:`qr-toggle`,children:[(0,T.jsx)(`summary`,{children:S(`app.me.qr`)}),(0,T.jsx)(`img`,{className:`qr`,src:e.referral_qr,alt:S(`app.me.qr`)})]})]}),(0,T.jsx)(D,{title:S(`app.me.invited`),after:S(`app.me.invited_count`,{Count:e.referral_count})}),(0,T.jsx)(D,{title:S(`app.me.converted`),after:String(e.referral_converted)}),(0,T.jsx)(D,{title:S(`app.me.earned`),after:w(e.referral_earned)}),e.referral_pending>0&&(0,T.jsx)(D,{title:S(`app.me.pending`),after:w(e.referral_pending)})]}),e.affiliate_enabled&&(0,T.jsx)(E,{title:S(`app.me.affiliate_title`),note:S(`app.me.affiliate_note`),children:(0,T.jsxs)(`div`,{className:`pad stack`,children:[(0,T.jsx)(`div`,{children:S(`app.me.affiliate_text`)}),(0,T.jsxs)(`ol`,{className:`steps-list`,children:[(0,T.jsx)(`li`,{children:S(`app.me.affiliate_step1`,{Bot:`@`+e.bot})}),(0,T.jsx)(`li`,{children:S(`app.me.affiliate_step2`)}),(0,T.jsx)(`li`,{children:S(`app.me.affiliate_step3`)})]}),(0,T.jsx)(O,{wide:!0,kind:`soft`,onClick:()=>_(`https://t.me/`+e.bot),children:S(`app.me.affiliate_open`)})]})}),(0,T.jsxs)(E,{children:[(0,T.jsx)(D,{title:S(`app.history.title`),chevron:!0,onClick:()=>t({tab:`home`,page:`history`})}),(0,T.jsx)(D,{title:S(`app.me.support`),after:e.support,chevron:s!==``,onClick:s?()=>_(s):void 0})]})]})}var Qe={home:`M3 11.5 12 4l9 7.5M5.5 10v9.5h13V10`,queue:`M12 4v11m0 0-4-4m4 4 4-4M5 20h14`,buy:`M13 3 5 13.5h6L10 21l9-11h-6.5L13 3Z`,groups:`M9 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM3.5 19c.5-3 2.6-5 5.5-5s5 2 5.5 5M16.5 11.5a2.5 2.5 0 1 0 0-5M17 14.2c2 .3 3.3 1.9 3.7 4.3`,me:`M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM4.5 20c.7-3.5 3.7-6 7.5-6s6.8 2.5 7.5 6`},$e=[`home`,`queue`,`buy`,`groups`,`me`];function et(e){let t=new URLSearchParams(window.location.search).get(`page`)??e;return t.startsWith(`group_`)?{tab:`groups`,group:t.slice(6),view:`settings`}:t===`buy`?{tab:`buy`}:t===`queue`?{tab:`queue`}:{tab:`home`}}function tt(){let[e,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(null),[i,a]=(0,l.useState)([{tab:`home`}]),[o,s]=(0,l.useState)(null),[c,u]=(0,l.useState)(0),d=(0,l.useRef)(void 0),f=(0,l.useRef)(!1),m=(0,l.useCallback)(async()=>{let[e,n]=await Promise.all([b(`GET`,`me`),b(`GET`,`i18n`)]);return x(n),document.title=S(`app.title`),t(e),e},[]);(0,l.useEffect)(()=>{f.current||(f.current=!0,m().then(e=>a([et(e.start_param)])).catch(r))},[m]),(0,l.useEffect)(()=>{if(!e)return;let t=!0,n=()=>{document.hidden||b(`GET`,`queue`).then(e=>t&&u(e.jobs.length)).catch(()=>void 0)};n();let r=window.setInterval(n,5e3);return()=>{t=!1,window.clearInterval(r)}},[e]);let h=i[i.length-1],g=(0,l.useCallback)((e,t=!1)=>{window.clearTimeout(d.current),s({text:e,bad:t}),p(t?`error`:`success`),d.current=window.setTimeout(()=>s(null),3500)},[]),_=(0,l.useMemo)(()=>e?{me:e,route:h,go:e=>{let t=`page`in e||`group`in e||`target`in e;a(n=>t?[...n,e]:[e]),window.scrollTo(0,0)},back:()=>a(e=>e.length>1?e.slice(0,-1):[{tab:e[0].tab}]),notify:g,fail:e=>g(he(e),!0),reload:async()=>{await m()}}:null,[e,h,g,m]);if(be(_&&i.length>1?_.back:null),n){let e=n instanceof y?n.message:``;return(0,T.jsx)(`div`,{className:`app`,children:(0,T.jsxs)(`div`,{className:`empty`,children:[(0,T.jsx)(`p`,{className:`big`,children:`:(`}),(0,T.jsx)(`p`,{children:e}),!(n instanceof y&&n.status===401)&&(0,T.jsx)(`button`,{className:`btn soft`,"aria-label":`retry`,onClick:()=>window.location.reload(),children:`鈫籤})]})})}if(!_)return(0,T.jsx)(`div`,{className:`app`,children:(0,T.jsx)(Ce,{})});let v;return v=`group`in h?(0,T.jsx)(Ve,{id:h.group,view:h.view??`overview`},h.group):`page`in h?(0,T.jsx)(Ie,{}):h.tab===`queue`?(0,T.jsx)(je,{}):h.tab===`buy`?(0,T.jsx)(Pe,{target:`target`in h?h.target:void 0},`target`in h?h.target:`me`):h.tab===`groups`?(0,T.jsx)(Le,{}):h.tab===`me`?(0,T.jsx)(Ze,{}):(0,T.jsx)(j,{}),(0,T.jsxs)(pe.Provider,{value:_,children:[(0,T.jsx)(`main`,{className:`app`,children:v}),o&&(0,T.jsx)(`div`,{className:`toast`+(o.bad?` bad`:``),role:`status`,children:o.text}),(0,T.jsx)(`nav`,{className:`tabs`,children:$e.map(e=>(0,T.jsxs)(`button`,{"aria-current":h.tab===e?`page`:void 0,onClick:()=>_.go({tab:e}),children:[(0,T.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,T.jsx)(`path`,{d:Qe[e]})}),S(`app.tab.`+e),e===`queue`&&c>0&&(0,T.jsx)(`span`,{className:`badge`,children:c})]},e))})]})}d?.ready(),d?.expand(),(0,u.createRoot)(document.getElementById(`root`)).render((0,T.jsx)(l.StrictMode,{children:(0,T.jsx)(tt,{})})); \ No newline at end of file diff --git a/web/miniapp/dist/assets/index.css b/web/miniapp/dist/assets/index.css index 9b29b97..008fa75 100644 --- a/web/miniapp/dist/assets/index.css +++ b/web/miniapp/dist/assets/index.css @@ -1 +1 @@ -:root{--bg:var(--tg-theme-secondary-bg-color,#efeff4);--card:var(--tg-theme-section-bg-color,var(--tg-theme-bg-color,#fff));--text:var(--tg-theme-text-color,#111);--hint:var(--tg-theme-hint-color,#8a8a8f);--link:var(--tg-theme-link-color,#2481cc);--accent:var(--tg-theme-button-color,#2481cc);--on-accent:var(--tg-theme-button-text-color,#fff);--danger:var(--tg-theme-destructive-text-color,#d93025);--line:var(--tg-theme-section-separator-color,#80808040);--header:var(--tg-theme-section-header-text-color,var(--hint));--bar:var(--tg-theme-bottom-bar-bg-color,var(--card));--ok:#2e9e5b;--radius:12px;--safe-bottom:max(env(safe-area-inset-bottom,0px), var(--tg-safe-area-inset-bottom,0px));--safe-top:var(--tg-content-safe-area-inset-top,0px)}@media (prefers-color-scheme:dark){:root{--bg:var(--tg-theme-secondary-bg-color,#111114);--card:var(--tg-theme-section-bg-color,var(--tg-theme-bg-color,#1c1c1f));--text:var(--tg-theme-text-color,#f2f2f2)}}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html,body{background:var(--bg);color:var(--text);overscroll-behavior-y:none;margin:0;font:16px/1.4 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}button,input,select{font:inherit;color:inherit}.app{min-height:100vh;padding:calc(8px + var(--safe-top)) 12px calc(76px + var(--safe-bottom));max-width:640px;margin:0 auto}.section{margin-block-start:0;margin-block-end:16px}.section-title{text-transform:uppercase;letter-spacing:.03em;color:var(--header);justify-content:space-between;align-items:baseline;gap:8px;padding:8px 12px 6px;font-size:13px;display:flex}.section-title button{text-transform:none;letter-spacing:0}.card{background:var(--card);border-radius:var(--radius);overflow:hidden}.pad{padding:12px}.cell{border:0;border-block-end:1px solid var(--line);text-align:start;background:0 0;align-items:center;gap:12px;width:100%;min-height:48px;padding:10px 12px;display:flex}.cell:last-child{border-block-end:0}button.cell{cursor:pointer}button.cell:active{background:var(--line)}.cell-body{flex:1;min-width:0}.cell-title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.cell-title.wrap{white-space:normal}.cell-sub{color:var(--hint);overflow-wrap:anywhere;font-size:13px}.cell-after{color:var(--hint);flex-shrink:0;align-items:center;gap:8px;display:flex}.chevron{border-block-start:2px solid var(--hint);border-inline-end:2px solid var(--hint);opacity:.6;width:8px;height:8px;transform:rotate(45deg)}[dir=rtl] .chevron{transform:rotate(-135deg)}.check{color:var(--accent);font-weight:700}.hint{color:var(--hint);font-size:13px}.note{color:var(--hint);padding:6px 12px 0;font-size:13px}.big{font-size:28px;font-weight:700;line-height:1.15}.error{color:var(--danger)}.center{text-align:center}.empty{text-align:center;color:var(--hint);padding:28px 16px}.mono{overflow-wrap:anywhere;direction:ltr;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}.btn{background:var(--accent);min-height:44px;color:var(--on-accent);cursor:pointer;border:0;border-radius:10px;justify-content:center;align-items:center;gap:6px;padding:8px 16px;font-weight:600;display:inline-flex}.btn.wide{width:100%}.btn.small{min-height:32px;padding:4px 12px;font-size:14px}.btn.soft{background:color-mix(in srgb, var(--accent) 14%, transparent);color:var(--accent)}.btn.danger{background:color-mix(in srgb, var(--danger) 12%, transparent);color:var(--danger)}.btn.plain{color:var(--link);background:0 0;min-height:0;padding-inline-start:4px;padding-inline-end:4px;font-weight:500}.btn:disabled{opacity:.5;cursor:default}.btn:active:not(:disabled){filter:brightness(.93)}.row{align-items:center;gap:8px;display:flex}.row.wrap{flex-wrap:wrap}.row>.grow{flex:1;min-width:0}.stack{flex-direction:column;gap:10px;display:flex}.input,.select{border:1px solid var(--line);background:var(--bg);border-radius:10px;outline:none;width:100%;min-height:44px;padding:8px 12px}.input:focus,.select:focus{border-color:var(--accent)}.select:disabled{opacity:.5}.select.compact,.input.compact{width:auto;max-width:55vw;min-height:36px;padding:4px 8px}.input.number{text-align:end;width:110px}.switch{background:var(--line);cursor:pointer;border:0;border-radius:15px;flex-shrink:0;width:50px;height:30px;transition:background .15s;position:relative}.switch:after{content:"";background:#fff;border-radius:50%;width:24px;height:24px;position:absolute;top:3px;box-shadow:0 1px 3px #0000004d}.switch:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{transition:left .15s;left:3px}.switch:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{transition:left .15s;left:3px}.switch:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{transition:right .15s;right:3px}.switch:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{transition:right .15s;right:3px}.switch[aria-checked=true]{background:var(--accent)}.switch[aria-checked=true]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{left:23px}.switch[aria-checked=true]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{left:23px}.switch[aria-checked=true]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{right:23px}.switch[aria-checked=true]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{right:23px}.segmented{background:var(--line);border-radius:10px;margin-block-end:12px;padding:3px;display:flex}.segmented button{cursor:pointer;background:0 0;border:0;border-radius:8px;flex:1;min-height:34px;padding:4px 6px;font-size:14px}.segmented button[aria-selected=true]{background:var(--card);font-weight:600;box-shadow:0 1px 2px #00000026}.chips{flex-wrap:wrap;gap:6px;display:flex}.chip{background:color-mix(in srgb, var(--accent) 14%, transparent);color:var(--accent);cursor:pointer;border:0;border-radius:14px;align-items:center;gap:6px;padding:4px 10px;font-size:14px;display:inline-flex}.meter{background:var(--line);border-radius:3px;height:6px;margin-block-start:6px;margin-block-end:2px;overflow:hidden}.meter>div{background:var(--accent);border-radius:3px;height:100%;transition:width .4s}.meter.busy>div{animation:1.2s ease-in-out infinite alternate slide;width:35%!important}@keyframes slide{0%{margin-inline-start:0}to{margin-inline-start:65%}}.spinner{border:3px solid var(--line);border-block-start-color:var(--accent);border-radius:50%;width:22px;height:22px;margin:24px auto;animation:.8s linear infinite spin}.btn .spinner{border-width:2px;border-color:color-mix(in srgb, currentColor 30%, transparent);border-block-start-color:currentColor;width:16px;height:16px;margin:0}@keyframes spin{to{transform:rotate(360deg)}}.stats{grid-template-columns:1fr 1fr;gap:8px;display:grid}.stat{border-radius:var(--radius);background:var(--card);padding:12px}.stat .value{font-size:20px;font-weight:700}.steps{gap:6px;margin:4px 0 14px;display:flex}.steps span{background:var(--line);border-radius:2px;flex:1;height:4px}.steps span.on{background:var(--accent)}.qr{width:min(260px,70vw);height:auto;image-rendering:pixelated;background:#fff;border-radius:12px;margin:8px auto;padding:8px;display:block}.qr-toggle summary{cursor:pointer;color:var(--accent);text-align:center}.paid-mark{background:var(--ok);color:#fff;text-align:center;border-radius:50%;width:72px;height:72px;margin:12px auto;font-size:40px;line-height:72px}.table{border-collapse:collapse;width:100%;font-size:14px}.table th,.table td{border-block-end:1px solid var(--line);text-align:end;white-space:nowrap;padding:10px 12px}.table th{color:var(--hint);font-size:12px;font-weight:500}.table th:first-child,.table td:first-child{text-align:start;white-space:normal;overflow-wrap:anywhere}.table tr:last-child td{border-block-end:0}.tabs{z-index:10;background:var(--bar);border-block-start:1px solid var(--line);justify-content:center;padding-block-end:var(--safe-bottom);display:flex;position:fixed;bottom:0;left:0;right:0}.tabs button{max-width:128px;min-height:56px;color:var(--hint);cursor:pointer;background:0 0;border:0;flex:1;padding:6px 2px 4px;font-size:11px;position:relative}.tabs button[aria-current=page]{color:var(--accent)}.tabs svg{width:24px;height:24px;margin:0 auto 2px;display:block}.badge{background:var(--accent);min-width:18px;color:var(--on-accent);border-radius:9px;padding:0 5px;font-size:11px;line-height:18px;position:absolute;top:4px}.badge:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:calc(50% + 6px)}.badge:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:calc(50% + 6px)}.badge:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:calc(50% + 6px)}.badge:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:calc(50% + 6px)}.sheet-back{z-index:20;background:#00000073;justify-content:center;align-items:flex-end;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.sheet{width:100%;max-width:640px;max-height:92vh;padding:16px 16px calc(16px + var(--safe-bottom));background:var(--card);border-radius:16px 16px 0 0;overflow-y:auto}.toast{z-index:30;color:#fff;text-align:center;background:#1e1e20f0;border-radius:12px;max-width:616px;margin:0 auto;padding:12px 14px;font-size:14px;position:fixed;bottom:calc(72px + var(--safe-bottom));left:12px;right:12px}.toast.bad{background:var(--danger)} +:root{--bg:var(--tg-theme-secondary-bg-color,#efeff4);--card:var(--tg-theme-section-bg-color,var(--tg-theme-bg-color,#fff));--text:var(--tg-theme-text-color,#111);--hint:var(--tg-theme-hint-color,#8a8a8f);--link:var(--tg-theme-link-color,#2481cc);--accent:var(--tg-theme-button-color,#2481cc);--on-accent:var(--tg-theme-button-text-color,#fff);--danger:var(--tg-theme-destructive-text-color,#d93025);--line:var(--tg-theme-section-separator-color,#80808040);--header:var(--tg-theme-section-header-text-color,var(--hint));--bar:var(--tg-theme-bottom-bar-bg-color,var(--card));--ok:#2e9e5b;--radius:12px;--safe-bottom:max(env(safe-area-inset-bottom,0px), var(--tg-safe-area-inset-bottom,0px));--safe-top:var(--tg-content-safe-area-inset-top,0px)}@media (prefers-color-scheme:dark){:root{--bg:var(--tg-theme-secondary-bg-color,#111114);--card:var(--tg-theme-section-bg-color,var(--tg-theme-bg-color,#1c1c1f));--text:var(--tg-theme-text-color,#f2f2f2)}}*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html,body{background:var(--bg);color:var(--text);overscroll-behavior-y:none;margin:0;font:16px/1.4 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}button,input,select{font:inherit;color:inherit}.app{min-height:100vh;padding:calc(8px + var(--safe-top)) 12px calc(76px + var(--safe-bottom));max-width:640px;margin:0 auto}.section{margin-block-start:0;margin-block-end:16px}.section-title{text-transform:uppercase;letter-spacing:.03em;color:var(--header);justify-content:space-between;align-items:baseline;gap:8px;padding:8px 12px 6px;font-size:13px;display:flex}.section-title button{text-transform:none;letter-spacing:0}.card{background:var(--card);border-radius:var(--radius);overflow:hidden}.pad{padding:12px}.cell{border:0;border-block-end:1px solid var(--line);text-align:start;background:0 0;align-items:center;gap:12px;width:100%;min-height:48px;padding:10px 12px;display:flex}.cell:last-child{border-block-end:0}button.cell{cursor:pointer}button.cell:active{background:var(--line)}.cell-body{flex:1;min-width:0}.cell-title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.cell-title.wrap{white-space:normal}.cell-sub{color:var(--hint);overflow-wrap:anywhere;font-size:13px}.cell-after{color:var(--hint);flex-shrink:0;align-items:center;gap:8px;display:flex}.chevron{border-block-start:2px solid var(--hint);border-inline-end:2px solid var(--hint);opacity:.6;width:8px;height:8px;transform:rotate(45deg)}[dir=rtl] .chevron{transform:rotate(-135deg)}.check{color:var(--accent);font-weight:700}.hint{color:var(--hint);font-size:13px}.note{color:var(--hint);padding:6px 12px 0;font-size:13px}.big{font-size:28px;font-weight:700;line-height:1.15}.error{color:var(--danger)}.center{text-align:center}.empty{text-align:center;color:var(--hint);padding:28px 16px}.mono{overflow-wrap:anywhere;direction:ltr;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}.btn{background:var(--accent);min-height:44px;color:var(--on-accent);cursor:pointer;border:0;border-radius:10px;justify-content:center;align-items:center;gap:6px;padding:8px 16px;font-weight:600;display:inline-flex}.btn.wide{width:100%}.btn.small{min-height:32px;padding:4px 12px;font-size:14px}.btn.soft{background:color-mix(in srgb, var(--accent) 14%, transparent);color:var(--accent)}.btn.danger{background:color-mix(in srgb, var(--danger) 12%, transparent);color:var(--danger)}.btn.plain{color:var(--link);background:0 0;min-height:0;padding-inline-start:4px;padding-inline-end:4px;font-weight:500}.btn:disabled{opacity:.5;cursor:default}.btn:active:not(:disabled){filter:brightness(.93)}.row{align-items:center;gap:8px;display:flex}.row.wrap{flex-wrap:wrap}.row>.grow{flex:1;min-width:0}.stack{flex-direction:column;gap:10px;display:flex}.input,.select{border:1px solid var(--line);background:var(--bg);border-radius:10px;outline:none;width:100%;min-height:44px;padding:8px 12px}.input:focus,.select:focus{border-color:var(--accent)}.select:disabled{opacity:.5}.select.compact,.input.compact{width:auto;max-width:55vw;min-height:36px;padding:4px 8px}.input.number{text-align:end;width:110px}.switch{background:var(--line);cursor:pointer;border:0;border-radius:15px;flex-shrink:0;width:50px;height:30px;transition:background .15s;position:relative}.switch:after{content:"";background:#fff;border-radius:50%;width:24px;height:24px;position:absolute;top:3px;box-shadow:0 1px 3px #0000004d}.switch:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{transition:left .15s;left:3px}.switch:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{transition:left .15s;left:3px}.switch:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{transition:right .15s;right:3px}.switch:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{transition:right .15s;right:3px}.switch[aria-checked=true]{background:var(--accent)}.switch[aria-checked=true]:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{left:23px}.switch[aria-checked=true]:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))):after{left:23px}.switch[aria-checked=true]:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{right:23px}.switch[aria-checked=true]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)):after{right:23px}.segmented{background:var(--line);border-radius:10px;margin-block-end:12px;padding:3px;display:flex}.segmented button{cursor:pointer;background:0 0;border:0;border-radius:8px;flex:1;min-height:34px;padding:4px 6px;font-size:14px}.segmented button[aria-selected=true]{background:var(--card);font-weight:600;box-shadow:0 1px 2px #00000026}.chips{flex-wrap:wrap;gap:6px;display:flex}.chip{background:color-mix(in srgb, var(--accent) 14%, transparent);color:var(--accent);cursor:pointer;border:0;border-radius:14px;align-items:center;gap:6px;padding:4px 10px;font-size:14px;display:inline-flex}.meter{background:var(--line);border-radius:3px;height:6px;margin-block-start:6px;margin-block-end:2px;overflow:hidden}.meter>div{background:var(--accent);border-radius:3px;height:100%;transition:width .4s}.meter.busy>div{animation:1.2s ease-in-out infinite alternate slide;width:35%!important}@keyframes slide{0%{margin-inline-start:0}to{margin-inline-start:65%}}.spinner{border:3px solid var(--line);border-block-start-color:var(--accent);border-radius:50%;width:22px;height:22px;margin:24px auto;animation:.8s linear infinite spin}.btn .spinner{border-width:2px;border-color:color-mix(in srgb, currentColor 30%, transparent);border-block-start-color:currentColor;width:16px;height:16px;margin:0}@keyframes spin{to{transform:rotate(360deg)}}.stats{grid-template-columns:1fr 1fr;gap:8px;display:grid}.stat{border-radius:var(--radius);background:var(--card);padding:12px}.stat .value{font-size:20px;font-weight:700}.steps{gap:6px;margin:4px 0 14px;display:flex}.steps span{background:var(--line);border-radius:2px;flex:1;height:4px}.steps span.on{background:var(--accent)}.qr{width:min(260px,70vw);height:auto;image-rendering:pixelated;background:#fff;border-radius:12px;margin:8px auto;padding:8px;display:block}.steps-list{margin:0;padding-left:20px}.steps-list li+li{margin-top:4px}.qr-toggle summary{cursor:pointer;color:var(--accent);text-align:center}.paid-mark{background:var(--ok);color:#fff;text-align:center;border-radius:50%;width:72px;height:72px;margin:12px auto;font-size:40px;line-height:72px}.table{border-collapse:collapse;width:100%;font-size:14px}.table th,.table td{border-block-end:1px solid var(--line);text-align:end;white-space:nowrap;padding:10px 12px}.table th{color:var(--hint);font-size:12px;font-weight:500}.table th:first-child,.table td:first-child{text-align:start;white-space:normal;overflow-wrap:anywhere}.table tr:last-child td{border-block-end:0}.tabs{z-index:10;background:var(--bar);border-block-start:1px solid var(--line);justify-content:center;padding-block-end:var(--safe-bottom);display:flex;position:fixed;bottom:0;left:0;right:0}.tabs button{max-width:128px;min-height:56px;color:var(--hint);cursor:pointer;background:0 0;border:0;flex:1;padding:6px 2px 4px;font-size:11px;position:relative}.tabs button[aria-current=page]{color:var(--accent)}.tabs svg{width:24px;height:24px;margin:0 auto 2px;display:block}.badge{background:var(--accent);min-width:18px;color:var(--on-accent);border-radius:9px;padding:0 5px;font-size:11px;line-height:18px;position:absolute;top:4px}.badge:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:calc(50% + 6px)}.badge:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){left:calc(50% + 6px)}.badge:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:calc(50% + 6px)}.badge:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){right:calc(50% + 6px)}.sheet-back{z-index:20;background:#00000073;justify-content:center;align-items:flex-end;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.sheet{width:100%;max-width:640px;max-height:92vh;padding:16px 16px calc(16px + var(--safe-bottom));background:var(--card);border-radius:16px 16px 0 0;overflow-y:auto}.toast{z-index:30;color:#fff;text-align:center;background:#1e1e20f0;border-radius:12px;max-width:616px;margin:0 auto;padding:12px 14px;font-size:14px;position:fixed;bottom:calc(72px + var(--safe-bottom));left:12px;right:12px}.toast.bad{background:var(--danger)} diff --git a/web/miniapp/dist/source.sha256 b/web/miniapp/dist/source.sha256 index d3d0866..5b7a64e 100644 --- a/web/miniapp/dist/source.sha256 +++ b/web/miniapp/dist/source.sha256 @@ -1 +1 @@ -3c98bec15c044f90e699f7a6b50fb1e6b1bb05928f40e22039c610dcbde14a31 +234ea8b6124984bf38cb7b276a74e1b6b49c6fffc85e50a91be7d7822930d8fa diff --git a/web/miniapp/e2e/smoke.mjs b/web/miniapp/e2e/smoke.mjs index 6acad3d..910f967 100644 --- a/web/miniapp/e2e/smoke.mjs +++ b/web/miniapp/e2e/smoke.mjs @@ -220,7 +220,14 @@ try { await page.locator('[role="switch"][aria-checked="true"]').waitFor(); await page.getByRole("button", { name: "Copy link" }).click(); const link = await page.evaluate(() => navigator.clipboard.readText()); - if (!/\?start=ref_\d+$/.test(link)) throw new Error("referral link = " + link); + if (!/\?start=rf_[A-Z2-7]{8}$/.test(link)) throw new Error("referral link = " + link); + // Both ways to earn are explained: our sats referral and Telegram's + // affiliate program, which the app only describes. + await page.getByText("Earn", { exact: true }).waitFor(); + await page.getByText("Telegram affiliate program", { exact: true }).waitFor(); + await page.getByRole("button", { name: "Open the bot's profile" }).click(); + const profile = await page.evaluate(() => window.__opened.at(-1)); + if (!/^https:\/\/t\.me\/[A-Za-z0-9_]+$/.test(profile || "")) throw new Error("profile link = " + profile); await page.getByRole("button", { name: "Share" }).click(); const shared = await page.evaluate(() => window.__opened.at(-1)); if (!shared.startsWith("https://t.me/share/url?url=")) throw new Error("share link = " + shared); @@ -230,10 +237,15 @@ try { await page.getByLabel("Language", { exact: true }).selectOption("es"); await tab(page, "Inicio").waitFor(); await page.getByText("Invita a tus amigos").waitFor(); + await page.getByText("Gana", { exact: true }).waitFor(); + await page.getByText("Programa de afiliados de Telegram", { exact: true }).waitFor(); if ((await page.evaluate(() => document.documentElement.lang)) !== "es") throw new Error("html lang was not updated"); await shot(page, "me-spanish"); await page.getByLabel("Idioma", { exact: true }).selectOption("nl"); await tab(page, "Start").waitFor(); + await page.getByText("Verdienen", { exact: true }).waitFor(); + await page.getByText("Affiliateprogramma van Telegram", { exact: true }).waitFor(); + await shot(page, "me-dutch"); await page.getByLabel("Taal", { exact: true }).selectOption(""); await tab(page, "Home").waitFor(); }); diff --git a/web/miniapp/src/api.ts b/web/miniapp/src/api.ts index 2e40384..0aefaf7 100644 --- a/web/miniapp/src/api.ts +++ b/web/miniapp/src/api.ts @@ -71,6 +71,8 @@ export interface Me { referral_qr: string; referral_reward: number; referral_daily_cap: number; + affiliate_enabled: boolean; + stars_enabled: boolean; support: string; start_param: string; bot: string; diff --git a/web/miniapp/src/pages/Profile.tsx b/web/miniapp/src/pages/Profile.tsx index afc9ab4..d0be077 100644 --- a/web/miniapp/src/pages/Profile.tsx +++ b/web/miniapp/src/pages/Profile.tsx @@ -65,6 +65,10 @@ export function Profile() { /> +
+
{t(me.affiliate_enabled ? "app.me.earn_note_both" : "app.me.earn_note_sats")}
+
+
0 ? t("app.me.referral_note", { Reward: sats(me.referral_reward) }) : undefined} @@ -113,6 +117,24 @@ export function Profile() { {me.referral_pending > 0 && }
+ {me.affiliate_enabled && ( + // Telegram runs this program and pays it out; the app explains how + // to join and shows no earnings of its own. +
+
+
{t("app.me.affiliate_text")}
+
    +
  1. {t("app.me.affiliate_step1", { Bot: "@" + me.bot })}
  2. +
  3. {t("app.me.affiliate_step2")}
  4. +
  5. {t("app.me.affiliate_step3")}
  6. +
+ +
+
+ )} +
go({ tab: "home", page: "history" })} />