From 380735ee476625011434823a2003db252ddc1420 Mon Sep 17 00:00:00 2001 From: Mark Bundschuh Date: Sat, 12 Oct 2024 22:00:26 -0400 Subject: [PATCH] Rework divisions (#8) * Only one division per team * Only team captain must fulfill division requirements * In rust challenge point calculation and custom scoring functions * Custom flag functions * Email partial partials instead of full reload --- .github/workflows/deploy-demo.yaml | 1 + Cargo.lock | 11 +- .../challenges/my-first-misc/challenge.yaml | 3 +- .../challenges/my-first-pwn/challenge.yaml | 3 +- .../challenges/my-first-web/challenge.yaml | 3 +- examples/demo/src/main.rs | 83 +-- .../challenges/my-first-pwn/challenge.yaml | 5 +- .../challenges/my-first-web/challenge.yaml | 6 +- examples/standalone/config.yaml | 6 +- rhombus/Cargo.toml | 2 +- rhombus/build.mjs | 11 +- rhombus/frontend/app.tsx | 33 +- rhombus/migrations/libsql/0001_setup.up.sql | 97 +--- rhombus/package.json | 1 - rhombus/src/builder.rs | 30 +- rhombus/src/challenge_loader_plugin.rs | 51 +- rhombus/src/internal/auth.rs | 93 +--- rhombus/src/internal/database/cache.rs | 220 ++++---- rhombus/src/internal/database/libsql.rs | 480 +++++++----------- rhombus/src/internal/database/postgres.rs | 44 +- rhombus/src/internal/database/provider.rs | 72 +-- rhombus/src/internal/discord.rs | 50 +- rhombus/src/internal/division.rs | 1 + rhombus/src/internal/open_graph.rs | 8 +- rhombus/src/internal/router.rs | 30 +- rhombus/src/internal/routes/account.rs | 179 ++++--- rhombus/src/internal/routes/challenges.rs | 235 +++++++-- rhombus/src/internal/routes/public.rs | 8 +- rhombus/src/internal/routes/team.rs | 183 +++---- rhombus/src/plugin.rs | 17 +- rhombus/static/app.js | 6 +- rhombus/static/tailwind.css | 28 - rhombus/templates/account-emails.html | 31 ++ rhombus/templates/account.html | 102 +--- rhombus/templates/challenge.html | 11 +- rhombus/templates/join-error-division.html | 86 ---- rhombus/templates/og-team.svg | 13 +- rhombus/templates/public-team.html | 34 +- rhombus/templates/public-user.html | 3 +- rhombus/templates/standing-table.html | 25 - rhombus/templates/team-divisions.html | 90 ++-- .../templates/team-set-division-partial.html | 1 - rhombus/templates/team.html | 31 +- 43 files changed, 1088 insertions(+), 1339 deletions(-) create mode 100644 rhombus/templates/account-emails.html delete mode 100644 rhombus/templates/join-error-division.html delete mode 100644 rhombus/templates/standing-table.html diff --git a/.github/workflows/deploy-demo.yaml b/.github/workflows/deploy-demo.yaml index 4607e22..71baad8 100644 --- a/.github/workflows/deploy-demo.yaml +++ b/.github/workflows/deploy-demo.yaml @@ -1,5 +1,6 @@ name: Deploy Demo to Fly.io on: + workflow_dispatch: push: branches: - main diff --git a/Cargo.lock b/Cargo.lock index 62edc68..e8a1093 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3337,14 +3337,15 @@ dependencies = [ [[package]] name = "minijinja" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7d3e3a3eece1fa4618237ad41e1de855ced47eab705cec1c9a920e1d1c5aad" +checksum = "1028b628753a7e1a88fc59c9ba4b02ecc3bc0bd3c7af23df667bc28df9b3310e" dependencies = [ "memo-map", "self_cell 1.0.4", "serde", "serde_json", + "v_htmlescape", ] [[package]] @@ -6697,6 +6698,12 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4bf03e0ca70d626ecc4ba6b0763b934b6f2976e8c744088bb3c1d646fbb1ad0" +[[package]] +name = "v_htmlescape" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8257fbc510f0a46eb602c10215901938b5c2a7d5e70fc11483b1d3c9b5b18c" + [[package]] name = "valuable" version = "0.1.0" diff --git a/examples/demo/challenges/my-first-misc/challenge.yaml b/examples/demo/challenges/my-first-misc/challenge.yaml index 07f66e3..4b1746b 100644 --- a/examples/demo/challenges/my-first-misc/challenge.yaml +++ b/examples/demo/challenges/my-first-misc/challenge.yaml @@ -5,12 +5,11 @@ description: | flag: flag{this_is_a_fake_flag} category: misc author: mbund -points: dynamic files: - src: hello.py dst: main.py - url: https://upload.wikimedia.org/wikipedia/commons/1/14/Symmetries_of_square.svg - dst: statue.svg + dst: quadrilaterals.svg ticket_template: | # Misc template healthscript: https://example.com diff --git a/examples/demo/challenges/my-first-pwn/challenge.yaml b/examples/demo/challenges/my-first-pwn/challenge.yaml index eb9ecc0..799e276 100644 --- a/examples/demo/challenges/my-first-pwn/challenge.yaml +++ b/examples/demo/challenges/my-first-pwn/challenge.yaml @@ -4,11 +4,10 @@ description: asjdlfhljasdfhjls flag: flag{this_is_a_fake_flag} category: pwn author: mbund -points: dynamic files: - src: hello.py dst: main.py - - url: https://demo.ctfd.io/files/5bb49e6f5bb44f2eaa4c2e4ee76d685c/statue.jpg + - url: https://upload.wikimedia.org/wikipedia/commons/f/f6/Great_Sphinx_of_Giza_-_20080716a.jpg dst: statue.jpg ticket_template: | # Web template diff --git a/examples/demo/challenges/my-first-web/challenge.yaml b/examples/demo/challenges/my-first-web/challenge.yaml index 2a8327d..607e703 100644 --- a/examples/demo/challenges/my-first-web/challenge.yaml +++ b/examples/demo/challenges/my-first-web/challenge.yaml @@ -5,12 +5,11 @@ description: | flag: flag{this_is_a_fake_flag} category: web author: mbund -points: dynamic files: - src: hello.py dst: main.py - url: https://upload.wikimedia.org/wikipedia/commons/1/14/Symmetries_of_square.svg - dst: statue.svg + dst: quadrilaterals.svg ticket_template: | # Web template healthscript: https://example.com diff --git a/examples/demo/src/main.rs b/examples/demo/src/main.rs index 5ca8ed9..05ce895 100644 --- a/examples/demo/src/main.rs +++ b/examples/demo/src/main.rs @@ -1,4 +1,4 @@ -use std::{path::PathBuf, sync::Arc, time::Duration}; +use std::{collections::BTreeMap, path::PathBuf, sync::Arc, time::Duration}; use chrono::prelude::*; use fake::{ @@ -12,7 +12,7 @@ use rand::{ Rng, }; use sha2::{Digest, Sha256}; -use tokio::sync::RwLock; +use tokio::sync::{Mutex, RwLock}; use tracing_subscriber::EnvFilter; use rhombus::{ @@ -25,6 +25,7 @@ use rhombus::{ libsql::{LibSQL, LibSQLConnection}, provider::{Connection, Database}, }, + routes::challenges::ChallengePoints, settings::Settings, }, libsql::params, @@ -128,8 +129,11 @@ impl Plugin for DemoPlugin { }; randomize_jwt(context.settings.clone()).await; - - solver(libsql.clone(), context.db.clone()); + solver( + libsql.clone(), + context.db.clone(), + context.score_type_map.clone(), + ); team_creator(libsql.clone(), context.db.clone()); let plugin_state = DemoState::new(libsql.clone()); @@ -181,21 +185,6 @@ async fn set_user_to_bot(libsql: Arc, user_id: i64) -> Result<()> { Ok(()) } -async fn join_to_divisons( - db: Connection, - division_ids: &[i64], - user_id: i64, - team_id: i64, -) -> Result<()> { - for division_id in division_ids { - db.set_user_division(user_id, team_id, *division_id, true) - .await?; - db.set_team_division(team_id, *division_id, true).await?; - } - - Ok(()) -} - async fn create_team(libsql: Arc, db: Connection) -> Result<()> { let dummy_user = create_dummy_user(); @@ -208,11 +197,9 @@ async fn create_team(libsql: Arc, db: Connection) -> Result<()> { .collect::>(); let mut rng = rand::rngs::OsRng; - let num_divisions = rng.gen_range(1..=division_ids.len().max(1)); - let division_ids = division_ids - .choose_multiple(&mut rng, num_divisions) - .copied() - .collect::>(); + let Some(division_id) = division_ids.choose(&mut rng) else { + return Ok(()); + }; let Some((user_id, team_id)) = db .upsert_user_by_credentials( @@ -225,7 +212,10 @@ async fn create_team(libsql: Arc, db: Connection) -> Result<()> { panic!() }; - join_to_divisons(db.clone(), &division_ids, user_id, team_id).await?; + let team = db.get_team_from_id(team_id).await?; + let now = Utc::now(); + db.set_team_division(team_id, team.division_id, *division_id, now) + .await?; set_user_to_bot(libsql.clone(), user_id).await?; let num_members = rng.gen_range(0..3); @@ -242,7 +232,6 @@ async fn create_team(libsql: Arc, db: Connection) -> Result<()> { else { continue; }; - join_to_divisons(db.clone(), &division_ids, user_id, team_id).await?; set_user_to_bot(libsql.clone(), user_id).await?; db.add_user_to_team(user_id, team_id, None).await?; } @@ -250,13 +239,19 @@ async fn create_team(libsql: Arc, db: Connection) -> Result<()> { Ok(()) } -async fn solve_challenge(libsql: Arc, db: Connection) -> Result<()> { +async fn solve_challenge( + libsql: Arc, + db: Connection, + score_type_map: Arc>>>, +) -> Result<()> { let conn = libsql.connect().await?; - if let Some((user_id, team_id)) = conn + if let Some((user_id, team_id, division_id)) = conn .query( " - SELECT id, team_id FROM rhombus_user + SELECT rhombus_user.id, rhombus_user.team_id, rhombus_team.division_id + FROM rhombus_user + JOIN rhombus_team ON rhombus_user.team_id = rhombus_team.id WHERE is_bot = 1 ORDER BY RANDOM() LIMIT 1 @@ -266,11 +261,29 @@ async fn solve_challenge(libsql: Arc, db: Connection) -> Result<()> { .await? .next() .await? - .map(|row| (row.get::(0).unwrap(), row.get::(1).unwrap())) + .map(|row| { + ( + row.get::(0).unwrap(), + row.get::(1).unwrap(), + row.get::(2).unwrap(), + ) + }) { let mut rng = rand::rngs::OsRng; if let Some(challenge) = db.get_challenges().await?.challenges.choose(&mut rng) { - db.solve_challenge(user_id, team_id, challenge).await?; + let user = db.get_user_from_id(user_id).await?; + let team = db.get_team_from_id(team_id).await?; + let next_points = score_type_map + .lock() + .await + .get(challenge.score_type.as_str()) + .unwrap() + .next(&user, &team, challenge) + .await + .unwrap(); + + db.solve_challenge(user_id, team_id, division_id, challenge, next_points) + .await?; tracing::info!(user_id, challenge_id = challenge.id, "Solved challenge"); } } @@ -278,11 +291,15 @@ async fn solve_challenge(libsql: Arc, db: Connection) -> Result<()> { Ok(()) } -fn solver(libsql: Arc, db: Connection) { +fn solver( + libsql: Arc, + db: Connection, + score_type_map: Arc>>>, +) { tokio::task::spawn(async move { loop { tokio::time::sleep(Duration::from_secs(10)).await; - _ = solve_challenge(libsql.clone(), db.clone()).await; + _ = solve_challenge(libsql.clone(), db.clone(), score_type_map.clone()).await; } }); } diff --git a/examples/standalone/challenges/my-first-pwn/challenge.yaml b/examples/standalone/challenges/my-first-pwn/challenge.yaml index 829a7f6..50ad44e 100644 --- a/examples/standalone/challenges/my-first-pwn/challenge.yaml +++ b/examples/standalone/challenges/my-first-pwn/challenge.yaml @@ -7,11 +7,12 @@ description: | flag: flag{this_is_a_fake_flag} category: pwn author: mbund -points: dynamic +score_type: static +points: 100 files: - src: hello.py dst: main.py - - url: https://demo.ctfd.io/files/5bb49e6f5bb44f2eaa4c2e4ee76d685c/statue.jpg + - url: https://upload.wikimedia.org/wikipedia/commons/f/f6/Great_Sphinx_of_Giza_-_20080716a.jpg dst: statue.jpg ticket_template: | # Web template diff --git a/examples/standalone/challenges/my-first-web/challenge.yaml b/examples/standalone/challenges/my-first-web/challenge.yaml index 7d94e84..09e1607 100644 --- a/examples/standalone/challenges/my-first-web/challenge.yaml +++ b/examples/standalone/challenges/my-first-web/challenge.yaml @@ -7,12 +7,14 @@ description: | flag: flag{this_is_a_fake_flag} category: web author: mbund -points: dynamic +score_type: dynamic +dynamic: + decay: 20 files: - src: hello.py dst: main.py - url: https://upload.wikimedia.org/wikipedia/commons/1/14/Symmetries_of_square.svg - dst: statue.svg + dst: quadrilaterals.svg ticket_template: | # Web template healthscript: https://example.com diff --git a/examples/standalone/config.yaml b/examples/standalone/config.yaml index 8e287fe..38dd947 100644 --- a/examples/standalone/config.yaml +++ b/examples/standalone/config.yaml @@ -26,16 +26,16 @@ divisions: - name: Undergraduate description: Undergraduate university students globally email_regex: ^.*.edu$ - requirement: Must verify a valid university .edu email address. Max of up to 4 players + requirement: Must verify a valid university .edu email address - name: OSU description: OSU undergraduate students email_regex: ^.*\.\d+@(buckeyemail\.)?osu\.edu$ - requirement: Must verify a valid OSU email address + requirement: Must verify a valid OSU email address. Max of up to 4 players max_players: 4 discord: guild_id: 1160610137703186636 client_id: 1160076447977848945 # author_role_id: 1198496803130183770 -# first_blood_channel_id: 1240422645938389102 + first_blood_channel_id: 1240422645938389102 support_channel_id: 1173026578385617010 # verified_role_id: 1170429782270431283 diff --git a/rhombus/Cargo.toml b/rhombus/Cargo.toml index cce9c54..42fec58 100644 --- a/rhombus/Cargo.toml +++ b/rhombus/Cargo.toml @@ -39,7 +39,7 @@ mail-parser = "0.9.4" markdown = "1.0.0-alpha.20" mime_guess = "2.0.5" minify-html-onepass = "0.15.0" -minijinja = { version = "2.2.0", features = ["json", "loader"] } +minijinja = { version = "2.3.1", features = ["json", "loader", "speedups"] } petname = "2.0.2" pin-project-lite = "0.2.14" poise = "0.6.1" diff --git a/rhombus/build.mjs b/rhombus/build.mjs index fd8d51d..acc1b4c 100644 --- a/rhombus/build.mjs +++ b/rhombus/build.mjs @@ -1,21 +1,20 @@ -import { build } from "esbuild"; -import { context } from "esbuild"; +import { build, context } from "esbuild"; import { solidPlugin } from "esbuild-plugin-solid"; const options = { - entryPoints: ['frontend/app.tsx'], + entryPoints: ["frontend/app.tsx"], bundle: true, minify: true, - outfile: 'static/app.js', + outfile: "static/app.js", globalName: "rhombus", plugins: [solidPlugin()], }; -if (process.env.WATCH === 'true') { +if (process.env.WATCH === "true") { const ctx = await context(options); await ctx.watch(); - console.log('Watching client js...'); + console.log("Watching client js..."); } else { build(options).catch(() => process.exit(1)); } diff --git a/rhombus/frontend/app.tsx b/rhombus/frontend/app.tsx index 6580015..caa4490 100644 --- a/rhombus/frontend/app.tsx +++ b/rhombus/frontend/app.tsx @@ -10,7 +10,6 @@ import { onCleanup, } from "solid-js"; import { customElement } from "solid-element"; -import { SolidMarkdown } from "solid-markdown"; import { SunIcon, MoonIcon, @@ -401,10 +400,7 @@ const ChallengesComponent = ({ .challenges.filter( (challenge) => challenge.category_id === category.id, ) - .sort( - (a, b) => - a.division_points[0].points - b.division_points[0].points, - ); + .sort((a, b) => a.points - b.points); return (
@@ -533,24 +529,19 @@ const ChallengesComponent = ({ - {challenge.division_points.map( - (division_points) => ( + {challenge.division_solves.map( + (division_solves) => ( - @@ -562,8 +553,12 @@ const ChallengesComponent = ({ {translate("solves-points", { - solves: challenge.division_points[0].solves, - points: challenge.division_points[0].points, + solves: challenge.division_solves.find( + (division_solves) => + division_solves.division_id === + data().division_id, + ).solves, + points: solve?.points || challenge.points, })} @@ -693,6 +688,7 @@ type CommandPaletteData = { }; type ChallengesData = { + division_id: number; ticket_enabled: boolean; challenges: { id: number; @@ -704,9 +700,9 @@ type ChallengesData = { } | null; category_id: number; author_id: number; - division_points: { + points: number; + division_solves: { division_id: number; - points: number; solves: number; }[]; attachments: { @@ -745,6 +741,7 @@ type ChallengesData = { { solved_at: Date; user_id: number; + points: number | null; } >; }; diff --git a/rhombus/migrations/libsql/0001_setup.up.sql b/rhombus/migrations/libsql/0001_setup.up.sql index 48a1829..24f95a0 100644 --- a/rhombus/migrations/libsql/0001_setup.up.sql +++ b/rhombus/migrations/libsql/0001_setup.up.sql @@ -13,8 +13,9 @@ CREATE TABLE IF NOT EXISTS rhombus_challenge ( healthscript TEXT, healthy BOOLEAN, last_healthcheck INTEGER, - score_type INTEGER NOT NULL, - static_points INTEGER, + score_type TEXT NOT NULL, + metadata TEXT, + points INTEGER, FOREIGN KEY (category_id) REFERENCES rhombus_category(id), FOREIGN KEY (author_id) REFERENCES rhombus_author(id) ); @@ -38,7 +39,8 @@ CREATE TABLE IF NOT EXISTS rhombus_file ( CREATE TABLE IF NOT EXISTS rhombus_division ( id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL UNIQUE, - description TEXT NOT NULL + description TEXT NOT NULL, + is_default BOOLEAN NOT NULL DEFAULT(FALSE) ); CREATE TABLE IF NOT EXISTS rhombus_author ( @@ -70,6 +72,7 @@ CREATE TABLE IF NOT EXISTS rhombus_solve ( user_id INTEGER NOT NULL, team_id INTEGER NOT NULL, solved_at INTEGER NOT NULL DEFAULT(strftime('%s', 'now')), + points INTEGER, PRIMARY KEY (challenge_id, team_id), FOREIGN KEY (challenge_id) REFERENCES rhombus_challenge(id), FOREIGN KEY (user_id) REFERENCES rhombus_user(id), @@ -91,6 +94,9 @@ CREATE TABLE IF NOT EXISTS rhombus_user ( FOREIGN KEY (owner_team_id) REFERENCES rhombus_team(id) ON DELETE CASCADE ); +CREATE INDEX IF NOT EXISTS rhombus_user_team_id ON rhombus_user(team_id); +CREATE INDEX IF NOT EXISTS rhombus_user_owner_team_id ON rhombus_user(owner_team_id); + CREATE TABLE IF NOT EXISTS rhombus_user_historical_names ( user_id INTEGER NOT NULL, name TEXT NOT NULL, @@ -99,14 +105,6 @@ CREATE TABLE IF NOT EXISTS rhombus_user_historical_names ( FOREIGN KEY (user_id) REFERENCES rhombus_user(id) ); -CREATE TABLE IF NOT EXISTS rhombus_user_division ( - user_id INTEGER NOT NULL, - division_id INTEGER NOT NULL, - PRIMARY KEY (user_id, division_id), - FOREIGN KEY (user_id) REFERENCES rhombus_user(id), - FOREIGN KEY (division_id) REFERENCES rhombus_division(id) -); - CREATE TABLE IF NOT EXISTS rhombus_email ( email TEXT NOT NULL UNIQUE, user_id INTEGER NOT NULL, @@ -142,9 +140,16 @@ CREATE TABLE IF NOT EXISTS rhombus_team ( id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL UNIQUE, invite_token TEXT NOT NULL, - ctftime_id INTEGER UNIQUE + ctftime_id INTEGER UNIQUE, + division_id INTEGER NOT NULL, + last_division_change INTEGER, + FOREIGN KEY (division_id) REFERENCES rhombus_division(id) ); +CREATE INDEX IF NOT EXISTS rhombus_team_division_id ON rhombus_team(division_id); +CREATE INDEX IF NOT EXISTS rhombus_team_invite_token ON rhombus_team(invite_token); +CREATE INDEX IF NOT EXISTS rhombus_team_ctftime_id ON rhombus_team(ctftime_id); + CREATE TABLE IF NOT EXISTS rhombus_team_historical_names ( team_id INTEGER NOT NULL, name TEXT NOT NULL, @@ -153,23 +158,6 @@ CREATE TABLE IF NOT EXISTS rhombus_team_historical_names ( FOREIGN KEY (team_id) REFERENCES rhombus_team(id) ); -CREATE TABLE IF NOT EXISTS rhombus_team_division ( - team_id INTEGER NOT NULL, - division_id INTEGER NOT NULL, - PRIMARY KEY (team_id, division_id), - FOREIGN KEY (team_id) REFERENCES rhombus_team(id), - FOREIGN KEY (division_id) REFERENCES rhombus_division(id) -); - -CREATE TABLE IF NOT EXISTS rhombus_team_division_last_edit ( - team_id INTEGER NOT NULL, - division_id INTEGER NOT NULL, - last_edit_at INTEGER NOT NULL DEFAULT(strftime('%s', 'now')), - PRIMARY KEY (team_id, division_id), - FOREIGN KEY (team_id) REFERENCES rhombus_team(id), - FOREIGN KEY (division_id) REFERENCES rhombus_division(id) -); - CREATE TABLE IF NOT EXISTS rhombus_ticket ( ticket_number INTEGER NOT NULL UNIQUE, user_id INTEGER NOT NULL, @@ -201,48 +189,17 @@ CREATE TABLE IF NOT EXISTS rhombus_config ( config TEXT ); -CREATE VIEW IF NOT EXISTS rhombus_challenge_division_points AS -SELECT - rhombus_challenge.id AS challenge_id, - rhombus_division.id AS division_id, - CASE - WHEN rhombus_challenge.score_type = 0 THEN - MAX(ROUND((((100 - 500) / (50. * 50)) * (COUNT(DISTINCT rhombus_team.id) * COUNT(DISTINCT rhombus_team.id))) + 500), 100) - ELSE rhombus_challenge.static_points - END AS points, - COUNT(DISTINCT rhombus_team.id) AS solves -FROM rhombus_challenge -CROSS JOIN rhombus_division -LEFT JOIN rhombus_solve ON - rhombus_challenge.id = rhombus_solve.challenge_id AND - rhombus_solve.team_id IN ( - SELECT rhombus_team.id - FROM rhombus_team - JOIN rhombus_team_division ON rhombus_team.id = rhombus_team_division.team_id - WHERE rhombus_team_division.division_id = rhombus_division.id - ) -LEFT JOIN rhombus_team ON rhombus_solve.team_id = rhombus_team.id -GROUP BY rhombus_challenge.id, rhombus_division.id; +CREATE VIEW IF NOT EXISTS rhombus_challenge_division_solves AS +SELECT rhombus_solve.challenge_id, rhombus_team.division_id, COUNT(*) AS solves +FROM rhombus_solve +JOIN rhombus_team ON rhombus_solve.team_id = rhombus_team.id +GROUP BY rhombus_solve.challenge_id, rhombus_team.division_id; -CREATE VIEW IF NOT EXISTS rhombus_team_division_points AS -SELECT tdp.team_id, division_id, points, last_solved_at -FROM -( - SELECT rhombus_team_division.team_id, rhombus_team_division.division_id, SUM(points) as points - FROM rhombus_team_division - JOIN ( - SELECT DISTINCT rhombus_solve.team_id, rhombus_challenge_division_points.challenge_id, rhombus_challenge_division_points.division_id, rhombus_challenge_division_points.points - FROM rhombus_challenge_division_points - JOIN rhombus_solve ON rhombus_challenge_division_points.challenge_id = rhombus_solve.challenge_id - ) AS unique_solves ON rhombus_team_division.team_id = unique_solves.team_id AND rhombus_team_division.division_id = unique_solves.division_id - GROUP BY rhombus_team_division.team_id, rhombus_team_division.division_id -) as tdp -JOIN ( - SELECT rhombus_team.id as team_id, MAX(rhombus_solve.solved_at) as last_solved_at - FROM rhombus_team JOIN rhombus_solve ON rhombus_solve.team_id = rhombus_team.id - GROUP BY rhombus_team.id -) as ls -ON tdp.team_id = ls.team_id; +CREATE VIEW IF NOT EXISTS rhombus_team_points AS +SELECT rhombus_solve.team_id, SUM(COALESCE(rhombus_solve.points, rhombus_challenge.points)) AS points, MAX(rhombus_solve.solved_at) AS last_solved_at +FROM rhombus_solve +JOIN rhombus_challenge ON rhombus_solve.challenge_id = rhombus_challenge.id +GROUP BY rhombus_solve.team_id; CREATE TABLE IF NOT EXISTS rhombus_track ( id INTEGER PRIMARY KEY NOT NULL, diff --git a/rhombus/package.json b/rhombus/package.json index 41ab7cf..d78e7af 100644 --- a/rhombus/package.json +++ b/rhombus/package.json @@ -23,7 +23,6 @@ "lucide-solid": "^0.379.0", "solid-element": "^1.8.0", "solid-js": "^1.8.17", - "solid-markdown": "^2.0.13", "solid-toast": "^0.5.0", "tailwindcss": "^3.4.3", "tailwindcss-animate": "^1.0.7" diff --git a/rhombus/src/builder.rs b/rhombus/src/builder.rs index f19c6f5..18eae2a 100644 --- a/rhombus/src/builder.rs +++ b/rhombus/src/builder.rs @@ -1,5 +1,6 @@ use std::{ any::Any, + collections::BTreeMap, fmt::Debug, hash::{BuildHasher, BuildHasherDefault, Hasher}, num::NonZeroU32, @@ -66,7 +67,7 @@ use crate::{ challenges::{ route_challenge_submit, route_challenge_view, route_challenges, route_ticket_submit, route_ticket_view, route_writeup_delete, route_writeup_submit, - TEAM_BURSTED_POINTS, + ChallengePoints, DynamicPoints, StaticPoints, TEAM_BURSTED_POINTS, }, home::route_home, meta::{page_meta_middleware, route_robots_txt, GlobalPageMeta}, @@ -446,7 +447,8 @@ impl { - let duration = 360; + let duration = 180; info!(duration, "Enabling default in memory cache"); database_cache_evictor(duration, db.clone()); Arc::new(DbCache::new(db.clone())) @@ -657,6 +661,14 @@ impl> = + BTreeMap::new(); + score_type_map.insert("static".to_owned(), Box::new(StaticPoints)); + score_type_map.insert("dynamic".to_owned(), Box::new(DynamicPoints)); + let score_type_map = Arc::new(Mutex::new(score_type_map)); + + let flag_fn_map = Arc::default(); + let (plugin_router, upload_router) = { let plugin_upload_provider_builder = UploadProviderContext { settings: &old_settings, @@ -678,6 +690,8 @@ impl() .unwrap(); + let metadata = Config::builder() + .add_source(config::File::from(path.as_path())) + .build() + .unwrap() + .try_deserialize::() + .unwrap(); let root = path.parent().unwrap().to_path_buf(); ChallengeIntermediate { stable_id: challenge.stable_id, @@ -73,10 +79,11 @@ impl Plugin for ChallengeLoaderPlugin { category: challenge.category, author: challenge.author, ticket_template: challenge.ticket_template, - points: challenge.points, + score_type: challenge.score_type.unwrap_or("dynamic".to_owned()), files: challenge.files, healthscript: challenge.healthscript, root, + metadata: serde_json::to_string(&metadata).unwrap(), } }) .collect::>(); @@ -229,12 +236,6 @@ impl Plugin for ChallengeLoaderPlugin { ); let id = hash(challenge.stable_id.as_ref().unwrap_or(&challenge.name)); - let (score_type, static_points) = if challenge.points == "dynamic" { - (0, None) - } else { - (1, Some(challenge.points.parse::().unwrap())) - }; - tracing::info!(name = challenge.name); let description = markdown::to_html_with_options( @@ -250,11 +251,31 @@ impl Plugin for ChallengeLoaderPlugin { ) .unwrap(); + let points = context + .score_type_map + .lock() + .await + .get(challenge.score_type.as_str()) + .unwrap() + .initial(&serde_json::from_str(&challenge.metadata).unwrap()) + .await + .unwrap(); + _ = tx .execute( " - INSERT OR REPLACE INTO rhombus_challenge (id, name, description, flag, category_id, author_id, ticket_template, score_type, static_points, healthscript) - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10) + INSERT INTO rhombus_challenge (id, name, description, flag, category_id, author_id, ticket_template, healthscript, score_type, points, metadata) + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11) + ON CONFLICT(id) DO UPDATE SET + name = excluded.name, + description = excluded.description, + flag = excluded.flag, + category_id = excluded.category_id, + author_id = excluded.author_id, + ticket_template = excluded.ticket_template, + healthscript = excluded.healthscript, + score_type = excluded.score_type, + metadata = excluded.metadata ", params!( id, @@ -264,9 +285,10 @@ impl Plugin for ChallengeLoaderPlugin { category_id, author_id, challenge.ticket_template.as_str(), - score_type, - static_points, - challenge.healthscript.as_deref() + challenge.healthscript.as_deref(), + challenge.score_type.as_str(), + points, + challenge.metadata.as_str(), ), ) .await?; @@ -390,7 +412,7 @@ pub struct Challenge { pub category: String, pub author: String, pub ticket_template: String, - pub points: String, + pub score_type: Option, pub files: Vec, pub healthscript: Option, } @@ -404,10 +426,11 @@ pub struct ChallengeIntermediate { pub category: String, pub author: String, pub ticket_template: String, - pub points: String, + pub score_type: String, pub files: Vec, pub healthscript: Option, pub root: PathBuf, + pub metadata: String, } #[derive(Debug, Deserialize, Serialize, Clone)] diff --git a/rhombus/src/internal/auth.rs b/rhombus/src/internal/auth.rs index 4f2c961..7bc2e5b 100644 --- a/rhombus/src/internal/auth.rs +++ b/rhombus/src/internal/auth.rs @@ -164,11 +164,6 @@ pub async fn route_signin( // you cannot join a team if your current team has more than just you on it let old_team = state.db.get_team_from_id(user.team_id).await.unwrap(); if old_team.users.len() > 1 { - // return Json(json!({ - // "message": "You cannot join a team while your old team has other members in it." - // })) - // .into_response(); - let html = state .jinja .get_template("join-error-existing-team.html") @@ -186,76 +181,35 @@ pub async fn route_signin( // you cannot join a team if the new team if, as a result of you joining it would // lead to the team having more players than the minimum required by any division - let team_divisions = state.db.get_team_divisions(team_meta.id).await.unwrap(); - let user_divisions = state.db.get_user_divisions(user.id).await.unwrap(); - - let max_players = state + let max_players = &state .divisions .iter() - .filter(|division| team_divisions.contains(&division.id)) - .filter_map(|division| match division.max_players { - MaxDivisionPlayers::Unlimited => None, - MaxDivisionPlayers::Limited(max) => Some(max), - }) - .min() - .map(MaxDivisionPlayers::Limited) - .unwrap_or(MaxDivisionPlayers::Unlimited); + .find(|division| division.id == new_team.division_id) + .unwrap() + .max_players; + match max_players { MaxDivisionPlayers::Unlimited => {} MaxDivisionPlayers::Limited(max_players) => { if new_team.users.len() >= max_players.get() as usize { - // return Json(json!({ - // "message": "The team you are trying to join already has the maximum number of players allowed by their division." - // })) - // .into_response(); - let html = state - .jinja - .get_template("join-error-max.html") - .unwrap() - .render(context! { - global => state.global_page_meta, - page, - title => format!("Team Join Error | {}", state.global_page_meta.title), - user, - team => new_team, - max_players, - }) - .unwrap(); + .jinja + .get_template("join-error-max.html") + .unwrap() + .render(context! { + global => state.global_page_meta, + page, + title => format!("Team Join Error | {}", state.global_page_meta.title), + user, + team => new_team, + max_players, + }) + .unwrap(); return Html(html).into_response(); } } } - let needs_divisions = team_divisions - .iter() - .filter(|division_id| !user_divisions.contains(division_id)) - .collect::>(); - - if !needs_divisions.is_empty() { - // return Json(json!({ - // "message": format!("To join this division you also need to join the following divisions: {}", needs_divisions.iter().map(|division_id| state.divisions.iter().find(|division| division.id == **division_id).unwrap().name.clone()).collect::>().join(", ")) - // })) - // .into_response(); - - let html = state - .jinja - .get_template("join-error-division.html") - .unwrap() - .render(context! { - global => state.global_page_meta, - page, - title => format!("Team Join Error | {}", state.global_page_meta.title), - user, - divisions => state.divisions, - user_divisions => user_divisions, - team_divisions => team_divisions, - team => new_team, - }) - .unwrap(); - return Html(html).into_response(); - } - state .db .add_user_to_team(user.id, team_meta.id, Some(old_team.id)) @@ -1067,7 +1021,7 @@ pub async fn route_signin_email_confirm_callback( async fn sign_in_cookie<'a>( state: &State, user_id: i64, - team_id: i64, + _team_id: i64, cookie_jar: &CookieJar, db: &Arc, ) -> Cookie<'static> { @@ -1076,17 +1030,6 @@ async fn sign_in_cookie<'a>( settings.jwt_secret.clone() }; - for division in state.divisions.iter() { - let eligible = division - .division_eligibility - .is_user_eligible(user_id) - .await; - - db.set_user_division(user_id, team_id, division.id, eligible.is_ok()) - .await - .unwrap(); - } - let now = chrono::Utc::now(); let iat = now.timestamp(); let exp = (now + chrono::Duration::try_hours(72).unwrap()).timestamp(); diff --git a/rhombus/src/internal/database/cache.rs b/rhombus/src/internal/database/cache.rs index 0645875..9ecd8af 100644 --- a/rhombus/src/internal/database/cache.rs +++ b/rhombus/src/internal/database/cache.rs @@ -10,9 +10,9 @@ use crate::{ internal::{ auth::User, database::provider::{ - Challenge, ChallengeData, Challenges, Connection, Database, Email, FirstBloods, - Leaderboard, Scoreboard, SetAccountNameError, SetTeamNameError, SiteStatistics, Team, - TeamMeta, TeamStandings, Ticket, Writeup, + Challenge, ChallengeData, Challenges, Connection, Database, Email, Leaderboard, + Scoreboard, SetAccountNameError, SetTeamNameError, SiteStatistics, Team, TeamInner, + TeamMeta, TeamStanding, Ticket, Writeup, }, division::Division, settings::Settings, @@ -267,15 +267,37 @@ impl Database for DbCache { &self, user_id: i64, team_id: i64, - challenge: &Challenge, - ) -> Result { + division_id: i64, + solved_challenge: &Challenge, + next_points: i64, + ) -> Result<()> { let result = self .inner - .solve_challenge(user_id, team_id, challenge) + .solve_challenge(user_id, team_id, division_id, solved_challenge, next_points) .await; if result.is_ok() { USER_CACHE.remove(&user_id); TEAM_CACHE.clear(); + SCOREBOARD_CACHE.clear(); + LEADERBOARD_CACHE.clear(); + TEAM_STANDINGS.clear(); + + if let Some(ref mut cached) = &mut *CHALLENGES_CACHE.write().await { + let mut challenges = cached.challenges.clone(); + if let Some(challenge) = challenges + .iter_mut() + .find(|challenge| challenge.id == solved_challenge.id) + { + *challenge.division_solves.get_mut(&division_id).unwrap() += 1; + challenge.points = next_points; + } + *cached = Arc::new(ChallengeData { + challenges, + authors: cached.authors.clone(), + categories: cached.categories.clone(), + divisions: cached.divisions.clone(), + }); + } } result } @@ -438,28 +460,57 @@ impl Database for DbCache { result } - async fn get_user_divisions(&self, user_id: i64) -> Result> { - get_user_divisions(&self.inner, user_id).await - } - - async fn set_user_division( + async fn set_team_division( &self, - user_id: i64, team_id: i64, - division_id: i64, - join: bool, + old_division_id: i64, + new_division_id: i64, + now: DateTime, ) -> Result<()> { let result = self .inner - .set_user_division(user_id, team_id, division_id, join) + .set_team_division(team_id, old_division_id, new_division_id, now) .await; if result.is_ok() { - USER_DIVISIONS.remove(&user_id); - TEAM_DIVISIONS.remove(&team_id); - // TEAM_STANDINGS.clear(); - // SCOREBOARD_CACHE.clear(); - // LEADERBOARD_CACHE.clear(); - // *CHALLENGES_CACHE.write().await = None; + TEAM_CACHE.alter(&team_id, |_, v| TimedCache { + value: Arc::new(TeamInner { + division_id: new_division_id, + last_division_change: Some(now), + id: v.value.id, + name: v.value.name.clone(), + invite_token: v.value.invite_token.clone(), + users: v.value.users.clone(), + solves: v.value.solves.clone(), + writeups: v.value.writeups.clone(), + owner_user_id: v.value.owner_user_id, + }), + insert_timestamp: v.insert_timestamp, + }); + TEAM_STANDINGS.clear(); + SCOREBOARD_CACHE.clear(); + LEADERBOARD_CACHE.clear(); + + if let Some(ref mut cached) = &mut *CHALLENGES_CACHE.write().await { + let mut challenges = cached.challenges.clone(); + + let team = self.get_team_from_id(team_id).await?; + for (challenge_id, _) in team.solves.iter() { + if let Some(challenge) = challenges + .iter_mut() + .find(|challenge| challenge.id == *challenge_id) + { + *challenge.division_solves.get_mut(&new_division_id).unwrap() += 1; + *challenge.division_solves.get_mut(&old_division_id).unwrap() -= 1; + } + } + + *cached = Arc::new(ChallengeData { + challenges, + authors: cached.authors.clone(), + categories: cached.categories.clone(), + divisions: cached.divisions.clone(), + }); + } } result } @@ -467,50 +518,17 @@ impl Database for DbCache { async fn insert_divisions(&self, divisions: &[Division]) -> Result<()> { let result = self.inner.insert_divisions(divisions).await; if result.is_ok() { - USER_DIVISIONS.clear(); - TEAM_DIVISIONS.clear(); // *CHALLENGES_CACHE.write().await = None; } result } - async fn get_team_divisions(&self, team_id: i64) -> Result> { - get_team_divisions(&self.inner, team_id).await - } - - async fn get_team_division_last_edit_time( + async fn get_team_standing( &self, team_id: i64, division_id: i64, - ) -> Result>> { - self.inner - .get_team_division_last_edit_time(team_id, division_id) - .await - } - - async fn set_team_division_last_edit_time(&self, team_id: i64, division_id: i64) -> Result<()> { - self.inner - .set_team_division_last_edit_time(team_id, division_id) - .await - } - - async fn set_team_division(&self, team_id: i64, division_id: i64, join: bool) -> Result<()> { - let result = self - .inner - .set_team_division(team_id, division_id, join) - .await; - if result.is_ok() { - TEAM_DIVISIONS.remove(&team_id); - // TEAM_STANDINGS.clear(); - // SCOREBOARD_CACHE.clear(); - // LEADERBOARD_CACHE.clear(); - // *CHALLENGES_CACHE.write().await = None; - } - result - } - - async fn get_team_standings(&self, team_id: i64) -> Result { - get_team_standing(&self.inner, team_id).await + ) -> Result> { + get_team_standing(&self.inner, team_id, division_id).await } async fn upload_file(&self, hash: &str, filename: &str, bytes: &[u8]) -> Result<()> { @@ -680,57 +698,25 @@ pub async fn get_emails_for_user_id(db: &Connection, user_id: i64) -> Result>> = DashMap::new(); + pub static ref TEAM_STANDINGS: DashMap>> = DashMap::new(); } -pub async fn get_user_divisions(db: &Connection, user_id: i64) -> Result> { - if let Some(divisions) = USER_DIVISIONS.get(&user_id) { - return Ok(divisions.value.clone()); - } - tracing::trace!(user_id, "cache miss: get_user_divisions"); - - let divisions = db.get_user_divisions(user_id).await; - - if let Ok(divisions) = &divisions { - USER_DIVISIONS.insert(user_id, TimedCache::new(divisions.clone())); - } - divisions -} - -lazy_static::lazy_static! { - pub static ref TEAM_DIVISIONS: DashMap>> = DashMap::new(); -} - -pub async fn get_team_divisions(db: &Connection, team_id: i64) -> Result> { - if let Some(divisions) = TEAM_DIVISIONS.get(&team_id) { - return Ok(divisions.value.clone()); - } - tracing::trace!(team_id, "cache miss: get_team_divisions"); - - let divisions = db.get_team_divisions(team_id).await; - - if let Ok(divisions) = &divisions { - TEAM_DIVISIONS.insert(team_id, TimedCache::new(divisions.clone())); - } - divisions -} - -lazy_static::lazy_static! { - pub static ref TEAM_STANDINGS: DashMap> = DashMap::new(); -} - -pub async fn get_team_standing(db: &Connection, team_id: i64) -> Result { - if let Some(standings) = TEAM_STANDINGS.get(&team_id) { - return Ok(standings.value.clone()); +pub async fn get_team_standing( + db: &Connection, + team_id: i64, + division_id: i64, +) -> Result> { + if let Some(standing) = TEAM_STANDINGS.get(&team_id) { + return Ok(standing.value.clone()); } - tracing::trace!(team_id, "cache miss: get_team_standing"); + tracing::trace!(team_id, division_id, "cache miss: get_team_standing"); - let standings = db.get_team_standings(team_id).await; + let standing = db.get_team_standing(team_id, division_id).await; - if let Ok(standings) = &standings { - TEAM_STANDINGS.insert(team_id, TimedCache::new(standings.clone())); + if let Ok(standing) = &standing { + TEAM_STANDINGS.insert(team_id, TimedCache::new(standing.clone())); } - standings + standing } pub fn database_cache_evictor(seconds: u64, db: Connection) { @@ -816,34 +802,6 @@ pub fn database_cache_evictor(seconds: u64, db: Connection) { tracing::trace!(count, "Evicted user emails cache"); } - // User divisions cache - let mut count: i64 = 0; - USER_DIVISIONS.retain(|_, v| { - if v.insert_timestamp > evict_threshold { - true - } else { - count += 1; - false - } - }); - if count > 0 { - tracing::trace!(count, "Evicted user divisions cache"); - } - - // Team divisions cache - let mut count: i64 = 0; - TEAM_DIVISIONS.retain(|_, v| { - if v.insert_timestamp > evict_threshold { - true - } else { - count += 1; - false - } - }); - if count > 0 { - tracing::trace!(count, "Evicted team divisions cache"); - } - { let mut challenges = CHALLENGES_CACHE.write().await; if challenges.is_some() { @@ -865,8 +823,6 @@ pub async fn clear_all_caches() { SCOREBOARD_CACHE.clear(); LEADERBOARD_CACHE.clear(); USER_EMAILS_CACHE.clear(); - USER_DIVISIONS.clear(); - TEAM_DIVISIONS.clear(); TEAM_STANDINGS.clear(); *CHALLENGES_CACHE.write().await = None; } diff --git a/rhombus/src/internal/database/libsql.rs b/rhombus/src/internal/database/libsql.rs index 2a19b37..9c3c088 100644 --- a/rhombus/src/internal/database/libsql.rs +++ b/rhombus/src/internal/database/libsql.rs @@ -27,11 +27,10 @@ use crate::{ cache::Writeups, provider::{ Author, Category, Challenge, ChallengeAttachment, ChallengeData, ChallengeDivision, - ChallengeDivisionPoints, ChallengeSolve, Challenges, Database, Email, FirstBloods, - Leaderboard, LeaderboardEntry, Scoreboard, ScoreboardSeriesPoint, ScoreboardTeam, - SetAccountNameError, SetTeamNameError, SiteStatistics, StatisticsCategory, Team, - TeamInner, TeamMeta, TeamMetaInner, TeamStandingEntry, TeamStandings, TeamUser, - Ticket, Writeup, + ChallengeSolve, Challenges, Database, Email, Leaderboard, LeaderboardEntry, + Scoreboard, ScoreboardSeriesPoint, ScoreboardTeam, SetAccountNameError, + SetTeamNameError, SiteStatistics, StatisticsCategory, Team, TeamInner, TeamMeta, + TeamMetaInner, TeamStanding, TeamUser, Ticket, Writeup, }, }, division::Division, @@ -87,6 +86,7 @@ pub struct InMemoryLibSQL { } impl InMemoryLibSQL { + #[allow(unused)] pub async fn new() -> Result { let conn = Builder::new_local(":memory:").build().await?.connect()?; @@ -602,36 +602,55 @@ impl Database for T { async fn get_challenges(&self) -> Result { let tx = self.transaction().await?; - let rhombus_challenge_division_points = tx + let mut division_rows = tx + .query("SELECT id, name FROM rhombus_division", ()) + .await?; + #[derive(Debug, Deserialize)] + struct DbDivision { + id: i64, + name: String, + } + let mut divisions: BTreeMap = Default::default(); + while let Some(row) = division_rows.next().await? { + let query_division = de::from_row::(&row).unwrap(); + divisions.insert( + query_division.id, + ChallengeDivision { + name: query_division.name, + }, + ); + } + + let challenge_division_solves_rows = tx .query( " SELECT * - FROM rhombus_challenge_division_points + FROM rhombus_challenge_division_solves ", (), ) .await? .into_stream() - .map(|row| de::from_row::(&row.unwrap()).unwrap()) + .map(|row| de::from_row::(&row.unwrap()).unwrap()) .collect::>() .await; #[derive(Debug, Deserialize)] - struct DbChallengeDivisionPoints { + struct DbChallengeDivisionSolves { challenge_id: i64, division_id: i64, - points: f64, - solves: f64, + solves: i64, } - let mut dbps = BTreeMap::new(); - for d in rhombus_challenge_division_points.into_iter() { - let elem = ChallengeDivisionPoints { - division_id: d.division_id, - points: d.points as u64, - solves: d.solves as u64, - }; - match dbps.get_mut(&d.challenge_id) { - None => _ = dbps.insert(d.challenge_id, vec![elem]), - Some(ps) => ps.push(elem), + let mut challenge_division_solves = BTreeMap::new(); + for row in challenge_division_solves_rows.into_iter() { + match challenge_division_solves.get_mut(&row.challenge_id) { + None => { + let mut map = BTreeMap::new(); + map.insert(row.division_id, row.solves as u64); + _ = challenge_division_solves.insert(row.challenge_id, map); + } + Some(division_solves) => { + _ = division_solves.insert(row.division_id, row.solves as u64) + } } } @@ -650,23 +669,26 @@ impl Database for T { name: String, url: String, } - let mut attachments = BTreeMap::new(); + let mut challenge_attachments = BTreeMap::new(); while let Some(row) = query_challenges.next().await? { let query_attachment = de::from_row::(&row).unwrap(); let attachment = ChallengeAttachment { name: query_attachment.name, url: query_attachment.url, }; - match attachments.get_mut(&query_attachment.challenge_id) { - None => _ = attachments.insert(query_attachment.challenge_id, vec![attachment]), - Some(ws) => ws.push(attachment), + match challenge_attachments.get_mut(&query_attachment.challenge_id) { + None => { + _ = challenge_attachments + .insert(query_attachment.challenge_id, vec![attachment]) + } + Some(attachments) => attachments.push(attachment), }; } let challenge_rows = tx .query( " - SELECT rhombus_challenge.*, COUNT(rhombus_solve.challenge_id) AS solves_count + SELECT rhombus_challenge.* FROM rhombus_challenge LEFT JOIN rhombus_solve ON rhombus_challenge.id = rhombus_solve.challenge_id GROUP BY rhombus_challenge.id @@ -679,14 +701,16 @@ impl Database for T { id: i64, name: String, description: String, + flag: String, category_id: i64, author_id: i64, - healthy: Option, + ticket_template: Option, healthscript: Option, + healthy: Option, last_healthcheck: Option, - flag: String, - score_type: i64, - ticket_template: Option, + metadata: String, + points: i64, + score_type: String, } let challenges = challenge_rows .into_stream() @@ -695,18 +719,34 @@ impl Database for T { id: challenge.id, name: challenge.name, description: challenge.description, + flag: challenge.flag, category_id: challenge.category_id, author_id: challenge.author_id, - healthy: challenge.healthy, + ticket_template: challenge.ticket_template, healthscript: challenge.healthscript, + healthy: challenge.healthy, last_healthcheck: challenge .last_healthcheck .map(|t| Utc.timestamp_opt(t, 0).unwrap()), - flag: challenge.flag, - scoring_type: challenge.score_type.into(), - division_points: dbps.get(&challenge.id).unwrap_or(&vec![]).to_vec(), - ticket_template: challenge.ticket_template, - attachments: attachments.get(&challenge.id).unwrap_or(&vec![]).to_vec(), + score_type: challenge.score_type, + metadata: serde_json::from_str(&challenge.metadata).unwrap(), + points: challenge.points, + attachments: challenge_attachments + .get(&challenge.id) + .unwrap_or(&vec![]) + .to_vec(), + division_solves: { + let mut division_solves = challenge_division_solves + .get(&challenge.id) + .unwrap_or(&BTreeMap::new()) + .clone(); + for (division_id, _) in divisions.iter() { + if !division_solves.contains_key(division_id) { + division_solves.insert(*division_id, 0); + } + } + division_solves + }, }) .collect::>() .await; @@ -752,23 +792,6 @@ impl Database for T { ); } - let mut division_rows = tx.query("SELECT * FROM rhombus_division", ()).await?; - #[derive(Debug, Deserialize)] - struct DbDivision { - id: i64, - name: String, - } - let mut divisions: BTreeMap = Default::default(); - while let Some(row) = division_rows.next().await? { - let query_division = de::from_row::(&row).unwrap(); - divisions.insert( - query_division.id, - ChallengeDivision { - name: query_division.name, - }, - ); - } - tx.commit().await?; Ok(Arc::new(ChallengeData { @@ -834,10 +857,12 @@ impl Database for T { struct QueryTeam { name: String, invite_token: String, + division_id: i64, + last_division_change: Option, } let query_team_row = tx .query( - "SELECT name, invite_token FROM rhombus_team WHERE id = ?1", + "SELECT name, invite_token, division_id, last_division_change FROM rhombus_team WHERE id = ?1", [team_id], ) .await? @@ -860,9 +885,13 @@ impl Database for T { [team_id], ) .await?; + let mut owner_user_id = 0; let mut users: BTreeMap = Default::default(); while let Some(row) = query_user_rows.next().await? { let query_user = de::from_row::(&row).unwrap(); + if query_user.owner_team_id == team_id { + owner_user_id = query_user.id; + } users.insert( query_user.id, TeamUser { @@ -879,11 +908,12 @@ impl Database for T { pub challenge_id: i64, pub user_id: i64, pub solved_at: i64, + pub points: Option, } let mut query_solves = tx .query( " - SELECT challenge_id, user_id, solved_at + SELECT challenge_id, user_id, solved_at, points FROM rhombus_solve WHERE team_id = ?1 ", @@ -896,6 +926,7 @@ impl Database for T { let solve = ChallengeSolve { user_id: query_solve.user_id, solved_at: DateTime::::from_timestamp(query_solve.solved_at, 0).unwrap(), + points: query_solve.points, }; // favor the earliest solve @@ -946,6 +977,11 @@ impl Database for T { id: team_id, name: query_team.name, invite_token: query_team.invite_token, + division_id: query_team.division_id, + last_division_change: query_team + .last_division_change + .map(|t| DateTime::::from_timestamp(t, 0).unwrap()), + owner_user_id, users, solves, writeups, @@ -1203,8 +1239,10 @@ impl Database for T { &self, user_id: i64, team_id: i64, + division_id: i64, challenge: &Challenge, - ) -> Result { + next_points: i64, + ) -> Result<()> { let tx = self.transaction().await?; let now = chrono::Utc::now().timestamp(); @@ -1217,42 +1255,32 @@ impl Database for T { tx.execute( " - INSERT INTO rhombus_points_snapshot - SELECT team_id, division_id, ?1, points - FROM rhombus_team_division_points - WHERE division_id IN ( - SELECT division_id - FROM rhombus_team_division - WHERE team_id = ?2 - ) - ", - [now, team_id], + UPDATE rhombus_challenge + SET points = ?2 + WHERE id = ?1 + ", + [challenge.id, next_points], ) .await?; - let first_blood_division_ids = tx - .query( - " - SELECT rhombus_team_division.division_id - FROM rhombus_challenge_division_points - JOIN rhombus_team_division ON - rhombus_team_division.division_id = rhombus_challenge_division_points.division_id AND - rhombus_team_division.team_id = ?2 - WHERE challenge_id = ?1 AND solves = 1 - ", - [challenge.id, team_id], - ) - .await? - .into_stream() - .map(|row| row.unwrap().get::(0).unwrap()) - .collect::>() - .await; + tx.execute( + " + INSERT INTO rhombus_points_snapshot + SELECT team_id, ?1, ?2, points + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team.id = rhombus_team_points.team_id AND + rhombus_team.division_id = ?1 + ORDER BY points DESC + LIMIT 20 + ", + [division_id, now], + ) + .await?; tx.commit().await?; - Ok(FirstBloods { - division_ids: first_blood_division_ids, - }) + Ok(()) } async fn add_writeup( @@ -1642,9 +1670,11 @@ impl Database for T { let top_team_ids = tx .query( " - SELECT team_id - FROM rhombus_team_division_points - WHERE division_id = ?1 + SELECT rhombus_team_points.team_id + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team_points.team_id = rhombus_team.id AND + rhombus_team.division_id = ?1 ORDER BY points DESC, last_solved_at ASC LIMIT 10 ", @@ -1746,10 +1776,12 @@ impl Database for T { let num_teams = tx .query( " - SELECT COUNT(*) - FROM rhombus_team_division_points - WHERE division_id = ?1 - ", + SELECT COUNT(*) + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team_points.team_id = rhombus_team.id AND + rhombus_team.division_id = ?1 + ", [division_id], ) .await? @@ -1770,13 +1802,14 @@ impl Database for T { let leaderboard_entries = tx .query( " - SELECT team_id, name, points - FROM rhombus_team_division_points - JOIN rhombus_team ON rhombus_team_division_points.team_id = rhombus_team.id - WHERE division_id = ?1 - ORDER BY points DESC, last_solved_at ASC - LIMIT ?3 OFFSET ?2 - ", + SELECT rhombus_team_points.team_id, name, points + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team_points.team_id = rhombus_team.id AND + rhombus_team.division_id = ?1 + ORDER BY points DESC, last_solved_at ASC + LIMIT ?3 OFFSET ?2 + ", params!(division_id, page * PAGE_SIZE, PAGE_SIZE), ) .await? @@ -1808,12 +1841,13 @@ impl Database for T { .await? .query( " - SELECT team_id, name, points - FROM rhombus_team_division_points - JOIN rhombus_team ON rhombus_team_division_points.team_id = rhombus_team.id - WHERE division_id = ?1 - ORDER BY points DESC - ", + SELECT rhombus_team_points.team_id, name, points + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team_points.team_id = rhombus_team.id AND + division_id = ?1 + ORDER BY points DESC + ", params!(division_id), ) .await? @@ -1993,76 +2027,20 @@ impl Database for T { Ok(()) } - async fn get_user_divisions(&self, user_id: i64) -> Result> { - let divisions = self - .connect() - .await? - .query( - "SELECT division_id FROM rhombus_user_division WHERE user_id = ?1", - [user_id], - ) - .await? - .into_stream() - .map(|row| row.unwrap().get::(0).unwrap()) - .collect::>() - .await; - - Ok(divisions) - } - - async fn set_user_division( + async fn set_team_division( &self, - user_id: i64, team_id: i64, - division_id: i64, - join: bool, + _old_division_id: i64, + new_division_id: i64, + now: DateTime, ) -> Result<()> { - let tx = self.transaction().await?; + let conn = self.connect().await?; - if join { - let num_users_in_team = tx - .query( - "SELECT COUNT(*) FROM rhombus_user WHERE team_id = ?1", - [team_id], - ) - .await? - .next() - .await? - .unwrap() - .get::(0) - .unwrap(); - - tx - .execute( - "INSERT OR IGNORE INTO rhombus_user_division (user_id, division_id) VALUES (?1, ?2)", - [user_id, division_id], - ) - .await?; - - if num_users_in_team == 1 { - tx - .execute( - "INSERT OR IGNORE INTO rhombus_team_division (team_id, division_id) VALUES (?1, ?2)", - [team_id, division_id], - ) - .await?; - } - } else { - _ = tx - .execute( - "DELETE FROM rhombus_user_division WHERE user_id = ?1 AND division_id = ?2", - [user_id, division_id], - ) - .await; - _ = tx - .execute( - "DELETE FROM rhombus_team_division WHERE team_id = ?1 AND division_id = ?2", - [team_id, division_id], - ) - .await; - } - - tx.commit().await?; + conn.execute( + "UPDATE rhombus_team SET division_id = ?1, last_division_change = ?2 WHERE id = ?3", + params!(new_division_id, now.timestamp(), team_id), + ) + .await?; Ok(()) } @@ -2088,8 +2066,8 @@ impl Database for T { for division in divisions { tx.execute( - "INSERT OR REPLACE INTO rhombus_division (id, name, description) VALUES (?1, ?2, ?3)", - params!(division.id, division.name.as_str(), division.description.as_str()), + "INSERT OR REPLACE INTO rhombus_division (id, name, description, is_default) VALUES (?1, ?2, ?3, ?4)", + params!(division.id, division.name.as_str(), division.description.as_str(), division.is_default), ) .await?; } @@ -2099,133 +2077,50 @@ impl Database for T { Ok(()) } - async fn get_team_divisions(&self, team_id: i64) -> Result> { - let divisions = self - .connect() - .await? - .query( - "SELECT division_id FROM rhombus_team_division WHERE team_id = ?1", - [team_id], - ) - .await? - .into_stream() - .map(|row| row.unwrap().get::(0).unwrap()) - .collect::>() - .await; - - Ok(divisions) - } - - async fn get_team_division_last_edit_time( + async fn get_team_standing( &self, team_id: i64, division_id: i64, - ) -> Result>> { - let last_edit_at_timestamp = self - .connect() - .await? - .query( - " - SELECT last_edit_at - FROM rhombus_team_division_last_edit - WHERE team_id = ?1 AND division_id = ?2 - ", - [team_id, division_id], - ) - .await? - .next() - .await? - .map(|row| row.get::(0).unwrap()); - - let last_edit_at = - last_edit_at_timestamp.and_then(|t| DateTime::::from_timestamp(t, 0)); - - Ok(last_edit_at) - } - - async fn set_team_division_last_edit_time(&self, team_id: i64, division_id: i64) -> Result<()> { - self.connect().await? - .execute( - " - INSERT OR REPLACE INTO rhombus_team_division_last_edit (team_id, division_id, last_edit_at) - VALUES (?1, ?2, ?3) - ", - [team_id, division_id, chrono::Utc::now().timestamp()], - ) - .await?; - - Ok(()) - } - - async fn set_team_division(&self, team_id: i64, division_id: i64, join: bool) -> Result<()> { - if join { - self.connect().await? - .execute( - "INSERT OR IGNORE INTO rhombus_team_division (team_id, division_id) VALUES (?1, ?2)", - [team_id, division_id], - ) - .await?; - } else { - _ = self - .connect() - .await? - .execute( - "DELETE FROM rhombus_team_division WHERE team_id = ?1 AND division_id = ?2", - [team_id, division_id], - ) - .await; - } - - Ok(()) - } - - async fn get_team_standings(&self, team_id: i64) -> Result { + ) -> Result> { #[derive(Debug, Deserialize)] - struct DbTeamDivisionPoints { - division_id: i64, + struct DbPointsRank { points: f64, rank: i64, } - let mut standings = BTreeMap::new(); - let mut standing_rows = self + let standing = self .connect() .await? .query( " WITH ranked_teams AS ( SELECT - team_id, - division_id, + rhombus_team_points.team_id, points, - RANK() OVER (PARTITION BY division_id ORDER BY points DESC) AS rank - FROM - rhombus_team_division_points + RANK() OVER (ORDER BY points DESC) AS rank + FROM rhombus_team_points + JOIN rhombus_team ON + rhombus_team_points.team_id = rhombus_team.id + AND rhombus_team.division_id = ?2 ) - SELECT - division_id, - points, - rank - FROM - ranked_teams - WHERE - team_id = ?1 + SELECT points, rank + FROM ranked_teams + WHERE team_id = ?1 ", - [team_id], + [team_id, division_id], ) - .await?; - while let Some(row) = standing_rows.next().await? { - let standing = de::from_row::(&row).unwrap(); - standings.insert( - standing.division_id, - TeamStandingEntry { - points: standing.points as u64, - rank: standing.rank as u64, - }, - ); - } + .await? + .next() + .await? + .map(|row| { + let points_rank = de::from_row::(&row).unwrap(); + TeamStanding { + points: points_rank.points as i64, + rank: points_rank.rank as u64, + } + }); - Ok(TeamStandings { standings }) + Ok(standing) } async fn upload_file(&self, hash: &str, filename: &str, bytes: &[u8]) -> Result<()> { @@ -2371,6 +2266,23 @@ impl Database for T { } pub async fn create_team(tx: &Transaction) -> Result { + let default_division_id = tx + .query( + " + SELECT id + FROM rhombus_division + WHERE is_default = TRUE + LIMIT 1 + ", + (), + ) + .await? + .next() + .await? + .unwrap() + .get::(0) + .unwrap(); + loop { let team_invite_token = create_team_invite_token(); @@ -2380,8 +2292,8 @@ pub async fn create_team(tx: &Transaction) -> Result { if let Ok(team_id) = tx .query( - "INSERT INTO rhombus_team (name, invite_token) VALUES (?1, ?2) RETURNING id", - [team_name, team_invite_token], + "INSERT INTO rhombus_team (name, invite_token, division_id) VALUES (?1, ?2, ?3) RETURNING id", + params!(team_name, team_invite_token, default_division_id), ) .await? .next() diff --git a/rhombus/src/internal/database/postgres.rs b/rhombus/src/internal/database/postgres.rs index eaef8e9..b31999f 100644 --- a/rhombus/src/internal/database/postgres.rs +++ b/rhombus/src/internal/database/postgres.rs @@ -11,9 +11,9 @@ use crate::{ database::{ cache::Writeups, provider::{ - Challenge, Challenges, Database, Email, FirstBloods, Leaderboard, Scoreboard, + Challenge, Challenges, Database, Email, Leaderboard, Scoreboard, SetAccountNameError, SetTeamNameError, SiteStatistics, Team, TeamMeta, - TeamStandings, Ticket, + TeamStanding, Ticket, }, }, division::Division, @@ -218,8 +218,10 @@ impl Database for Postgres { &self, _user_id: i64, _team_id: i64, + _division_id: i64, _challenge: &Challenge, - ) -> Result { + _next_points: i64, + ) -> Result<()> { todo!() } @@ -339,16 +341,12 @@ impl Database for Postgres { todo!() } - async fn get_user_divisions(&self, _user_id: i64) -> Result> { - todo!() - } - - async fn set_user_division( + async fn set_team_division( &self, - _user_id: i64, _team_id: i64, - _division_id: i64, - _join: bool, + _old_division_id: i64, + _new_division_id: i64, + _now: DateTime, ) -> Result<()> { todo!() } @@ -357,34 +355,14 @@ impl Database for Postgres { todo!() } - async fn get_team_divisions(&self, _team_id: i64) -> Result> { - todo!() - } - - async fn get_team_division_last_edit_time( - &self, - _team_id: i64, - _division_id: i64, - ) -> Result>> { - todo!() - } - - async fn set_team_division_last_edit_time( + async fn get_team_standing( &self, _team_id: i64, _division_id: i64, - ) -> Result<()> { + ) -> Result> { todo!() } - async fn set_team_division(&self, _team_id: i64, _division_id: i64, _join: bool) -> Result<()> { - todo!() - } - - async fn get_team_standings(&self, _team_id: i64) -> Result { - todo!(); - } - async fn upload_file(&self, _hash: &str, _filename: &str, _bytes: &[u8]) -> Result<()> { todo!() } diff --git a/rhombus/src/internal/database/provider.rs b/rhombus/src/internal/database/provider.rs index 3eb0903..95b39e8 100644 --- a/rhombus/src/internal/database/provider.rs +++ b/rhombus/src/internal/database/provider.rs @@ -8,6 +8,7 @@ use std::{ use async_trait::async_trait; use chrono::{DateTime, Utc}; use serde::Serialize; +use serde_json::Value; use tokio_util::bytes::Bytes; use crate::{ @@ -18,28 +19,6 @@ use crate::{ pub type Connection = Arc; pub type WeakConnection = Weak; -#[derive(Debug, Serialize, Clone)] -pub enum ScoringType { - Dynamic, - Static, -} - -impl From for ScoringType { - fn from(value: i64) -> Self { - match value { - 0 => ScoringType::Dynamic, - _ => ScoringType::Static, - } - } -} - -#[derive(Debug, Serialize, Clone)] -pub struct ChallengeDivisionPoints { - pub division_id: i64, - pub points: u64, - pub solves: u64, -} - #[derive(Debug, Serialize, Clone)] pub struct ChallengeAttachment { pub name: String, @@ -51,16 +30,18 @@ pub struct Challenge { pub id: i64, pub name: String, pub description: String, + pub flag: String, pub category_id: i64, pub author_id: i64, + pub ticket_template: Option, pub healthscript: Option, pub healthy: Option, pub last_healthcheck: Option>, - pub division_points: Vec, - pub scoring_type: ScoringType, - pub flag: String, - pub ticket_template: Option, + pub score_type: String, + pub metadata: Value, + pub points: i64, pub attachments: Vec, + pub division_solves: BTreeMap, } #[derive(Debug, Serialize, Clone)] @@ -96,6 +77,7 @@ pub type Challenges = Arc; pub struct ChallengeSolve { pub solved_at: DateTime, pub user_id: i64, + pub points: Option, } #[derive(Debug, Serialize, Clone)] @@ -120,6 +102,9 @@ pub struct TeamInner { pub users: BTreeMap, pub solves: BTreeMap, pub writeups: BTreeMap>, + pub owner_user_id: i64, + pub division_id: i64, + pub last_division_change: Option>, } pub type Team = Arc; @@ -132,11 +117,6 @@ pub struct TeamMetaInner { pub type TeamMeta = Arc; -#[derive(Debug, Serialize, Clone)] -pub struct FirstBloods { - pub division_ids: Vec, -} - #[derive(Debug, Serialize, Clone)] pub struct ScoreboardSeriesPoint { pub timestamp: i64, @@ -175,16 +155,11 @@ pub struct Email { } #[derive(Debug, Serialize, Clone)] -pub struct TeamStandingEntry { - pub points: u64, +pub struct TeamStanding { + pub points: i64, pub rank: u64, } -#[derive(Debug, Serialize, Clone)] -pub struct TeamStandings { - pub standings: BTreeMap, -} - #[derive(Debug, Serialize, Clone)] pub struct Ticket { pub ticket_number: u64, @@ -281,8 +256,10 @@ pub trait Database { &self, user_id: i64, team_id: i64, + division_id: i64, challenge: &Challenge, - ) -> Result; + next_points: i64, + ) -> Result<()>; async fn get_user_from_id(&self, user_id: i64) -> Result; async fn get_user_from_discord_id(&self, discord_id: NonZeroU64) -> Result; async fn kick_user(&self, user_id: i64, team_id: i64) -> Result<()>; @@ -347,24 +324,19 @@ pub trait Database { async fn verify_email_signin_callback_code(&self, code: &str) -> Result; async fn get_email_signin_by_callback_code(&self, code: &str) -> Result; async fn delete_email(&self, user_id: i64, email: &str) -> Result<()>; - async fn get_user_divisions(&self, user_id: i64) -> Result>; - async fn set_user_division( + async fn set_team_division( &self, - user_id: i64, team_id: i64, - division_id: i64, - join: bool, + old_division_id: i64, + new_division_id: i64, + now: DateTime, ) -> Result<()>; async fn insert_divisions(&self, divisions: &[Division]) -> Result<()>; - async fn get_team_divisions(&self, team_id: i64) -> Result>; - async fn get_team_division_last_edit_time( + async fn get_team_standing( &self, team_id: i64, division_id: i64, - ) -> Result>>; - async fn set_team_division_last_edit_time(&self, team_id: i64, division_id: i64) -> Result<()>; - async fn set_team_division(&self, team_id: i64, division_id: i64, join: bool) -> Result<()>; - async fn get_team_standings(&self, team_id: i64) -> Result; + ) -> Result>; async fn upload_file(&self, hash: &str, filename: &str, bytes: &[u8]) -> Result<()>; async fn download_file(&self, hash: &str) -> Result<(Bytes, String)>; async fn get_site_statistics(&self) -> Result; diff --git a/rhombus/src/internal/discord.rs b/rhombus/src/internal/discord.rs index 3d53a31..c3105a5 100644 --- a/rhombus/src/internal/discord.rs +++ b/rhombus/src/internal/discord.rs @@ -13,7 +13,7 @@ use serenity::{ all::{ ButtonStyle, ChannelId, ChannelType, CreateActionRow, CreateAttachment, CreateButton, CreateEmbed, CreateEmbedAuthor, CreateMessage, CreateThread, EditMessage, EditThread, - GatewayIntents, GetMessages, Http, UserId, + GatewayIntents, GetMessages, Http, MessageFlags, UserId, }, Client, }; @@ -24,7 +24,7 @@ use crate::{ internal::{ auth::User, database::provider::{ - Author, Category, Challenge, ChallengeDivision, Connection, FirstBloods, Team, Ticket, + Author, Category, Challenge, ChallengeDivision, Connection, Team, Ticket, }, email::outbound_mailer::OutboundMailer, settings::Settings, @@ -752,7 +752,9 @@ impl Bot { ":crossed_swords: Challenge", format!( "[{}]({}/challenges#{})", - challenge.name, location_url, challenge.name + challenge.name, + location_url, + urlencoding::encode(&challenge.name) ), true, ) @@ -796,19 +798,14 @@ impl Bot { challenge: &Challenge, divisions: &BTreeMap, categories: &[Category], - first_bloods: &FirstBloods, + division_id: i64, ) -> Result<()> { let category = categories .iter() .find(|category| category.id == challenge.category_id) .unwrap(); - let divisions = first_bloods - .division_ids - .iter() - .map(|division_id| divisions[division_id].name.as_str()) - .collect::>(); - let division_string = format_list_en(&divisions); + let division_name = divisions[&division_id].name.as_str(); let emoji = [ "🩸", @@ -861,22 +858,21 @@ impl Bot { channel_id.send_message( &self.http, - CreateMessage::new().content({ + CreateMessage::new().flags(MessageFlags::SUPPRESS_EMBEDS).content({ let user_link = match user.discord_id { Some(discord_id) => format!("<@{}>", discord_id), None => format!("**[{}]({}/user/{})**", escape_discord_link(&user.name), location_url, user.id), }; format!( - "Congrats to {} on team **[{}]({location_url}/team/{})** for first blood on **[{} / {}]({location_url}/challenges#{})** in {}! {}", + "Congrats to {} on team **[{}]({location_url}/team/{})** for first blood on **[{} / {}]({location_url}/challenges#{})** in **{}** division! {}", user_link, escape_discord_link(&team.name), team.id, category.name, challenge.name, urlencoding::encode(&challenge.name), - division_string, + division_name, emoji, - location_url = location_url, ) }), ) @@ -973,32 +969,6 @@ lazy_static::lazy_static! { }); } -fn format_list_en(items: &[&str]) -> String { - match items.len() { - 0 => String::new(), - 1 => format!("**{}** division", items[0]), - 2 => format!("**{}** and **{}** divisions", items[0], items[1]), - _ => { - let mut formatted = String::new(); - for (i, item) in items.iter().take(items.len() - 1).enumerate() { - formatted.push_str("**"); - formatted.push_str(item); - formatted.push_str("**"); - if i < items.len() - 2 { - formatted.push_str(", "); - } else { - formatted.push_str(", and "); - } - } - formatted.push_str("**"); - formatted.push_str(items[items.len() - 1]); - formatted.push_str("**"); - formatted.push_str(" divisions"); - formatted - } - } -} - fn escape_discord_link(input: &str) -> Cow { // Discord markdown parsing is frustration. let special_characters = &['[', ']', '@', '#', '\\', '*', '`', '_']; diff --git a/rhombus/src/internal/division.rs b/rhombus/src/internal/division.rs index baecdb4..5651a82 100644 --- a/rhombus/src/internal/division.rs +++ b/rhombus/src/internal/division.rs @@ -62,6 +62,7 @@ pub struct Division { pub name: String, pub description: String, pub max_players: MaxDivisionPlayers, + pub is_default: bool, #[serde(skip)] pub division_eligibility: DivisionEligibilityProvider, diff --git a/rhombus/src/internal/open_graph.rs b/rhombus/src/internal/open_graph.rs index 488a3f2..78f6b1c 100644 --- a/rhombus/src/internal/open_graph.rs +++ b/rhombus/src/internal/open_graph.rs @@ -270,10 +270,10 @@ pub async fn route_team_og_image( } let challenge_data = state.db.get_challenges(); - let standings = state.db.get_team_standings(team_id.0); - let (challenge_data, standings) = tokio::join!(challenge_data, standings); + let standing = state.db.get_team_standing(team_id.0, team.division_id); + let (challenge_data, standings) = tokio::join!(challenge_data, standing); let challenge_data = challenge_data.unwrap(); - let standings = standings.unwrap(); + let standing = standings.unwrap(); let site = { let settings = state.settings.read().await; @@ -355,7 +355,7 @@ pub async fn route_team_og_image( ctf_start_time, ctf_end_time, divisions => state.divisions, - standings => standings.standings, + standing, num_solves, num_users, categories, diff --git a/rhombus/src/internal/router.rs b/rhombus/src/internal/router.rs index 3115cbc..fe3555e 100644 --- a/rhombus/src/internal/router.rs +++ b/rhombus/src/internal/router.rs @@ -1,3 +1,11 @@ +use std::{ + collections::BTreeMap, + convert::Infallible, + future::Future, + pin::Pin, + sync::{atomic::AtomicPtr, Arc}, +}; + use axum::{ body::Body, extract::State, @@ -5,20 +13,22 @@ use axum::{ response::{IntoResponse, Response}, Extension, }; -use std::{ - convert::Infallible, - future::Future, - pin::Pin, - sync::{atomic::AtomicPtr, Arc}, -}; use tokio::sync::{Mutex, RwLock}; use tower::{make::Shared, Service, ServiceExt}; use crate::{ internal::{ - database::provider::Connection, discord::Bot, division::Division, - email::outbound_mailer::OutboundMailer, ip::IpExtractorFn, locales::Localizations, - routes::meta::GlobalPageMeta, settings::Settings, + database::provider::Connection, + discord::Bot, + division::Division, + email::outbound_mailer::OutboundMailer, + ip::IpExtractorFn, + locales::Localizations, + routes::{ + challenges::{ChallengeFlag, ChallengePoints}, + meta::GlobalPageMeta, + }, + settings::Settings, }, Plugin, UploadProvider, }; @@ -36,6 +46,8 @@ pub struct RouterStateInner { pub divisions: Arc>, pub router: Arc, pub global_page_meta: Arc, + pub score_type_map: Arc>>>, + pub flag_fn_map: Arc>>>, } pub struct Router { diff --git a/rhombus/src/internal/routes/account.rs b/rhombus/src/internal/routes/account.rs index 93830ed..c201432 100644 --- a/rhombus/src/internal/routes/account.rs +++ b/rhombus/src/internal/routes/account.rs @@ -17,7 +17,10 @@ use unicode_segmentation::UnicodeSegmentation; use crate::internal::{ auth::User, - database::{cache::TimedCache, provider::SetAccountNameError}, + database::{ + cache::TimedCache, + provider::{Email, SetAccountNameError}, + }, router::RouterState, routes::meta::PageMeta, }; @@ -56,15 +59,6 @@ async fn is_in_server( is_in } -#[derive(Serialize)] -pub struct UserDivision<'a> { - pub id: i64, - pub name: &'a str, - pub description: &'a str, - pub eligible: bool, - pub requirement: Option, -} - pub async fn route_account( state: State, Extension(user): Extension, @@ -110,41 +104,8 @@ pub async fn route_account( let challenge_data = state.db.get_challenges(); let team = state.db.get_team_from_id(user.team_id); let emails = state.db.get_emails_for_user_id(user.id); - let user_divisions = state.db.get_user_divisions(user.id); - let (challenge_data, team, emails, user_divisions) = - tokio::join!(challenge_data, team, emails, user_divisions); - let (challenge_data, team, emails, user_divisions) = ( - challenge_data.unwrap(), - team.unwrap(), - emails.unwrap(), - user_divisions.unwrap(), - ); - - let mut divisions = vec![]; - for division in state.divisions.iter() { - let eligible = division - .division_eligibility - .is_user_eligible(user.id) - .await; - - let joined = user_divisions.contains(&division.id); - - if eligible.is_ok() != joined { - state - .db - .set_user_division(user.id, team.id, division.id, eligible.is_ok()) - .await - .unwrap(); - } - - divisions.push(UserDivision { - id: division.id, - name: &division.name, - description: &division.description, - eligible: eligible.is_ok(), - requirement: eligible.err(), - }) - } + let (challenge_data, team, emails) = tokio::join!(challenge_data, team, emails); + let (challenge_data, team, emails) = (challenge_data.unwrap(), team.unwrap(), emails.unwrap()); let mut challenges = BTreeMap::new(); for challenge in &challenge_data.challenges { @@ -173,7 +134,6 @@ pub async fn route_account( challenges, categories, emails, - divisions, }) .unwrap(), ) @@ -193,26 +153,36 @@ pub async fn route_account_add_email( ) -> impl IntoResponse { if form.email.is_empty() || form.email.len() > 255 { return Response::builder() - .body(format!( - r#"
{}
"#, - state - .localizer - .localize(&page.lang, "account-error-email-length", None) - .unwrap(), - )) + .status(StatusCode::BAD_REQUEST) + .header( + "HX-Trigger", + format!( + r##"{{"toast":{{"kind":"error","message":"{}"}}}}"##, + state + .localizer + .localize(&page.lang, "account-error-email-length", None) + .unwrap(), + ), + ) + .body("".to_owned()) .unwrap(); } - let emails = state.db.get_emails_for_user_id(user.id).await.unwrap(); + let mut emails = state.db.get_emails_for_user_id(user.id).await.unwrap(); if emails.iter().any(|email| email.address == form.email) { return Response::builder() - .body(format!( - r#"
{}
"#, - state - .localizer - .localize(&page.lang, "account-error-email-already-added", None) - .unwrap(), - )) + .status(StatusCode::BAD_REQUEST) + .header( + "HX-Trigger", + format!( + r##"{{"toast":{{"kind":"error","message":"{}"}}}}"##, + state + .localizer + .localize(&page.lang, "account-error-email-already-added", None) + .unwrap(), + ), + ) + .body("".to_owned()) .unwrap(); } @@ -223,13 +193,18 @@ pub async fn route_account_add_email( .await else { return Response::builder() - .body(format!( - r#"
{}
"#, - state - .localizer - .localize(&page.lang, "account-error-verification-email", None) - .unwrap(), - )) + .status(StatusCode::BAD_REQUEST) + .header( + "HX-Trigger", + format!( + r##"{{"toast":{{"kind":"error","message":"{}"}}}}"##, + state + .localizer + .localize(&page.lang, "account-error-verification-email", None) + .unwrap(), + ), + ) + .body("".to_owned()) .unwrap(); }; @@ -246,13 +221,18 @@ pub async fn route_account_add_email( state.db.delete_email(user.id, &form.email).await.unwrap(); return Response::builder() - .body(format!( - r#"
{}
"#, - state - .localizer - .localize(&page.lang, "account-error-verification-email", None) - .unwrap(), - )) + .status(StatusCode::BAD_REQUEST) + .header( + "HX-Trigger", + format!( + r##"{{"toast":{{"kind":"error","message":"{}"}}}}"##, + state + .localizer + .localize(&page.lang, "account-error-verification-email", None) + .unwrap(), + ), + ) + .body("".to_owned()) .unwrap(); } @@ -263,14 +243,34 @@ pub async fn route_account_add_email( ); } + emails.push(Email { + address: form.email, + verified: false, + }); + Response::builder() - .body(format!( - r#"
{}
"#, + .header( + "HX-Trigger", + format!( + r##"{{"toast":{{"kind":"success","message":"{}"}}}}"##, + state + .localizer + .localize(&page.lang, "account-check-email", None) + .unwrap(), + ), + ) + .body( state - .localizer - .localize(&page.lang, "account-check-email", None) + .jinja + .get_template("account-emails.html") + .unwrap() + .render(context! { + page, + emails, + oob => true, + }) .unwrap(), - )) + ) .unwrap() } @@ -336,9 +336,10 @@ pub struct EmailRemove { pub async fn route_account_delete_email( state: State, Extension(user): Extension, + Extension(page): Extension, Query(query): Query, ) -> impl IntoResponse { - let emails = state.db.get_emails_for_user_id(user.id).await.unwrap(); + let mut emails = state.db.get_emails_for_user_id(user.id).await.unwrap(); if emails.len() == 1 { return Response::builder() @@ -349,9 +350,21 @@ pub async fn route_account_delete_email( state.db.delete_email(user.id, &query.email).await.unwrap(); + emails.retain(|email| email.address != query.email); + Response::builder() - .header("HX-Trigger", "pageRefresh") - .body("".to_owned()) + .body( + state + .jinja + .get_template("account-emails.html") + .unwrap() + .render(context! { + page, + emails, + oob => true, + }) + .unwrap(), + ) .unwrap() } diff --git a/rhombus/src/internal/routes/challenges.rs b/rhombus/src/internal/routes/challenges.rs index 3a2b3b7..fa04faf 100644 --- a/rhombus/src/internal/routes/challenges.rs +++ b/rhombus/src/internal/routes/challenges.rs @@ -10,9 +10,14 @@ use chrono::{DateTime, Utc}; use dashmap::DashMap; use minijinja::context; use serde::Deserialize; -use serde_json::json; +use serde_json::{json, Value}; -use crate::internal::{auth::User, router::RouterState, routes::meta::PageMeta}; +use crate::internal::{ + auth::User, + database::provider::{Challenge, Team}, + router::RouterState, + routes::meta::PageMeta, +}; pub async fn route_challenges( state: State, @@ -59,6 +64,7 @@ pub async fn route_challenges( }; let challenge_json = json!({ + "division_id": team.division_id, "ticket_enabled": ticket_enabled, "challenges": challenge_data.challenges.iter().map(|challenge| json!({ "id": challenge.id, @@ -72,12 +78,12 @@ pub async fn route_challenges( } else { None }, + "points": challenge.points, "category_id": challenge.category_id, "author_id": challenge.author_id, - "division_points": challenge.division_points.iter().map(|division_points| json!({ - "division_id": division_points.division_id, - "points": division_points.points, - "solves": division_points.solves, + "division_solves": challenge.division_solves.iter().map(|(division_id, solves)| json!({ + "division_id": division_id, + "solves": solves, })).collect::(), "attachments": challenge.attachments.iter().map(|attachment| json!({ "name": attachment.name, @@ -111,6 +117,7 @@ pub async fn route_challenges( (solve.0.to_string(), json!({ "solved_at": solve.1.solved_at, "user_id": solve.1.user_id, + "points": solve.1.points, })) ).collect::(), }) @@ -136,6 +143,88 @@ pub async fn route_challenges( Html(html).into_response() } +#[async_trait::async_trait] +pub trait ChallengeFlag { + async fn correct_flag( + &self, + challenge: &Challenge, + flag: &str, + ) -> std::result::Result; +} + +pub struct ExactFlag; + +#[async_trait::async_trait] +impl ChallengeFlag for ExactFlag { + async fn correct_flag( + &self, + challenge: &Challenge, + flag: &str, + ) -> std::result::Result { + Ok(challenge.flag.trim() == flag.trim()) + } +} + +#[async_trait::async_trait] +pub trait ChallengePoints { + async fn initial(&self, metadata: &Value) -> crate::Result; + async fn next(&self, user: &User, team: &Team, challenge: &Challenge) -> crate::Result; +} + +pub struct DynamicPoints; + +#[async_trait::async_trait] +impl ChallengePoints for DynamicPoints { + async fn initial(&self, metadata: &Value) -> crate::Result { + let initial = metadata["dynamic"]["initial"].as_i64().unwrap_or(500); + + Ok(initial) + } + + async fn next(&self, _user: &User, _team: &Team, challenge: &Challenge) -> crate::Result { + let initial = challenge.metadata["dynamic"]["initial"] + .as_f64() + .unwrap_or(500.); + let minimum = challenge.metadata["dynamic"]["minimum"] + .as_f64() + .unwrap_or(100.); + let decay = challenge.metadata["dynamic"]["decay"] + .as_f64() + .unwrap_or(100.); + + let total_solves = challenge.division_solves.values().sum::() as f64; + + let solves = total_solves + 1.; + let points = + (((minimum - initial) / (decay * decay) * (solves * solves)) + initial).ceil() as i64; + + Ok(points) + } +} + +pub struct StaticPoints; + +#[async_trait::async_trait] +impl ChallengePoints for StaticPoints { + async fn initial(&self, metadata: &Value) -> crate::Result { + let points = metadata["points"].as_i64().unwrap_or(100); + + Ok(points) + } + + async fn next(&self, _user: &User, _team: &Team, challenge: &Challenge) -> crate::Result { + let Some(points) = challenge.metadata["points"].as_i64() else { + tracing::error!( + challenge_id = challenge.id, + "Static scoring used but no points specified. Defaulting to 100 points", + ); + return Ok(100); + }; + + Ok(points) + } +} + pub async fn route_challenge_view( state: State, Extension(user): Extension, @@ -422,20 +511,44 @@ pub async fn route_challenge_submit( .find(|c| challenge_id.eq(&c.id)) .unwrap(); - if challenge.flag != form.flag { - let html = state - .jinja - .get_template("challenge-submit.html") - .unwrap() - .render(context! { - page, - error => state.localizer.localize(&page.lang, "challenges-error-incorrect-flag", None), - }) - .unwrap(); - return Response::builder() - .header("content-type", "text/html") - .body(html) - .unwrap(); + let correct_flag = if let Some(custom) = state.flag_fn_map.lock().await.get(&challenge_id) { + custom.correct_flag(challenge, &form.flag).await + } else { + ExactFlag.correct_flag(challenge, &form.flag).await + }; + + match correct_flag { + Ok(true) => (), + Ok(false) => { + let html = state + .jinja + .get_template("challenge-submit.html") + .unwrap() + .render(context! { + page, + error => state.localizer.localize(&page.lang, "challenges-error-incorrect-flag", None), + }) + .unwrap(); + return Response::builder() + .header("content-type", "text/html") + .body(html) + .unwrap(); + } + Err(error) => { + let html = state + .jinja + .get_template("challenge-submit.html") + .unwrap() + .render(context! { + page, + error, + }) + .unwrap(); + return Response::builder() + .header("content-type", "text/html") + .body(html) + .unwrap(); + } } if let Some(end_time) = state.settings.read().await.end_time { @@ -479,12 +592,40 @@ pub async fn route_challenge_submit( .unwrap(); } - let first_bloods = state - .db - .solve_challenge(user.id, user.team_id, challenge) - .await; + let team = state.db.get_team_from_id(user.team_id).await.unwrap(); - if let Err(error) = first_bloods { + let next_points = state + .score_type_map + .lock() + .await + .get(challenge.score_type.as_str()) + .unwrap() + .next(&user, &team, challenge) + .await + .unwrap_or_else(|error| { + let total_solves = challenge.division_solves.values().sum::(); + + tracing::error!( + challenge_id = challenge.id, + user_id = user.id, + team_id = user.team_id, + score_type = challenge.score_type, + division_solves = ?challenge.division_solves, + total_solves, + previous_points=challenge.points, + ?error, + "Failed to calculate points for challenge after solve. Defaulting to previous value" + ); + challenge.points + }); + + let first_blooded = challenge.division_solves[&team.division_id] == 0; + + if let Err(error) = state + .db + .solve_challenge(user.id, team.id, team.division_id, challenge, next_points) + .await + { tracing::error!("{:#?}", error); let html = state .jinja @@ -516,30 +657,32 @@ pub async fn route_challenge_submit( .is_some() }; - if first_blood_enabled { - let first_bloods = first_bloods.unwrap(); - - if !first_bloods.division_ids.is_empty() { - let team = state.db.get_team_from_id(user.team_id).await.unwrap(); - _ = bot - .send_first_blood( - &user, - &team, - challenge, - &challenge_data.divisions, - &challenge_data.categories, - &first_bloods, - ) - .await; + if first_blood_enabled && first_blooded { + if let Err(error) = bot + .send_first_blood( + &user, + &team, + challenge, + &challenge_data.divisions, + &challenge_data.categories, + team.division_id, + ) + .await + { + tracing::error!( + user_id = user.id, + team_id = user.team_id, + challenge_id = challenge.id, + division_id = team.division_id, + error = ?error, + "First blood failed to send", + ); + } else { tracing::info!( user_id = user.id, + team_id = user.team_id, challenge_id = challenge.id, - divisions = first_bloods - .division_ids - .iter() - .map(|n| n.to_string()) - .collect::>() - .join(","), + division_id = team.division_id, "First blooded" ); } diff --git a/rhombus/src/internal/routes/public.rs b/rhombus/src/internal/routes/public.rs index c5c354b..6ff49d6 100644 --- a/rhombus/src/internal/routes/public.rs +++ b/rhombus/src/internal/routes/public.rs @@ -75,10 +75,10 @@ pub async fn route_public_team( }; let challenge_data = state.db.get_challenges(); - let standings = state.db.get_team_standings(team_id.0); - let (challenge_data, standings) = tokio::join!(challenge_data, standings); + let standing = state.db.get_team_standing(team_id.0, team.division_id); + let (challenge_data, standing) = tokio::join!(challenge_data, standing); let challenge_data = challenge_data.unwrap(); - let standings = standings.unwrap(); + let standing = standing.unwrap(); let mut challenges = BTreeMap::new(); for challenge in &challenge_data.challenges { @@ -106,7 +106,7 @@ pub async fn route_public_team( challenges, categories, divisions => state.divisions, - standings => standings.standings, + standing, }) .unwrap(), ) diff --git a/rhombus/src/internal/routes/team.rs b/rhombus/src/internal/routes/team.rs index 0b7b6ee..8b9ecc7 100644 --- a/rhombus/src/internal/routes/team.rs +++ b/rhombus/src/internal/routes/team.rs @@ -29,7 +29,7 @@ pub struct TeamDivision<'a> { pub name: &'a str, pub description: &'a str, pub eligible: bool, - pub ineligible_user_ids: Vec, + pub requirement: Option, pub joined: bool, pub max_players: MaxDivisionPlayers, } @@ -41,14 +41,15 @@ pub async fn route_team( ) -> impl IntoResponse { let challenge_data = state.db.get_challenges(); let team = state.db.get_team_from_id(user.team_id); - let team_divisions = state.db.get_team_divisions(user.team_id); - let standings = state.db.get_team_standings(user.team_id); - let (challenge_data, team, team_divisions, standings) = - tokio::join!(challenge_data, team, team_divisions, standings); + let (challenge_data, team) = tokio::join!(challenge_data, team); let challenge_data = challenge_data.unwrap(); let team = team.unwrap(); - let team_divisions = team_divisions.unwrap(); - let standings = standings.unwrap(); + + let standing = state + .db + .get_team_standing(user.team_id, team.division_id) + .await + .unwrap(); let location_url = state.settings.read().await.location_url.clone(); @@ -66,14 +67,10 @@ pub async fn route_team( let mut divisions = vec![]; for division in state.divisions.iter() { - let mut ineligible_user_ids = vec![]; - for user_id in team.users.keys() { - let user_divisions = state.db.get_user_divisions(*user_id).await.unwrap(); - - if !user_divisions.contains(&division.id) { - ineligible_user_ids.push(*user_id); - } - } + let eligible = division + .division_eligibility + .is_user_eligible(team.owner_user_id) + .await; let oversized = match division.max_players { MaxDivisionPlayers::Unlimited => true, @@ -82,13 +79,15 @@ pub async fn route_team( } }; + let joined = team.division_id == division.id; + divisions.push(TeamDivision { id: division.id, name: &division.name, description: &division.description, - eligible: ineligible_user_ids.is_empty() && oversized, - ineligible_user_ids, - joined: team_divisions.contains(&division.id), + eligible: eligible.is_ok() && oversized, + requirement: eligible.err(), + joined, max_players: division.max_players.clone(), }) } @@ -104,7 +103,7 @@ pub async fn route_team( .map(MaxDivisionPlayers::Limited) .unwrap_or(MaxDivisionPlayers::Unlimited); - let num_joined_divisions = divisions.iter().filter(|d| d.joined).count(); + let now = chrono::Utc::now(); Html( state @@ -120,12 +119,13 @@ pub async fn route_team( team, team_invite_url, max_players, - now => chrono::Utc::now(), + now, + minutes_until_division_change => team.last_division_change.map(|t| ((t + chrono::Duration::minutes(60)) - now).num_minutes() + 1), challenges, categories, - num_joined_divisions, divisions, - standings => standings.standings, + standing, + division_id => team.division_id, }) .unwrap(), ) @@ -277,17 +277,11 @@ pub async fn route_user_kick( .unwrap() } -#[derive(Deserialize)] -pub struct DivisionSet { - join: Option, -} - pub async fn route_team_set_division( state: State, Extension(user): Extension, Extension(page): Extension, Path(division_id): Path, - Form(form): Form, ) -> impl IntoResponse { if !user.is_team_owner { return Response::builder() @@ -303,16 +297,14 @@ pub async fn route_team_set_division( .unwrap(); } - let team_division_last_edit_time = state - .db - .get_team_division_last_edit_time(user.team_id, division_id) - .await - .unwrap() - .unwrap_or_default(); + let team = state.db.get_team_from_id(user.team_id).await.unwrap(); - let next_allowed = team_division_last_edit_time + chrono::Duration::minutes(120); - if next_allowed > chrono::Utc::now() { - let resets_in = next_allowed - chrono::Utc::now(); + let next_allowed = + team.last_division_change.unwrap_or_default() + chrono::Duration::minutes(60); + + let now = chrono::Utc::now(); + if next_allowed > now { + let resets_in = next_allowed - now; return Response::builder() .header( @@ -327,92 +319,59 @@ pub async fn route_team_set_division( .unwrap(); } - state - .db - .set_team_division_last_edit_time(user.team_id, division_id) - .await - .unwrap(); - - let team = state.db.get_team_from_id(user.team_id).await.unwrap(); let division = state.divisions.iter().find(|d| d.id == division_id); - if let Some(division) = division { - match division.max_players { - MaxDivisionPlayers::Limited(max_players) => { - if team.users.len() > max_players.get() as usize { - return Response::builder() - .status(StatusCode::FORBIDDEN) - .body("".to_owned()) - .unwrap(); - } - } - MaxDivisionPlayers::Unlimited => {} - } - } else { + let Some(division) = division else { return Response::builder() .status(StatusCode::NOT_FOUND) .body("".to_owned()) .unwrap(); + }; + + match division.max_players { + MaxDivisionPlayers::Limited(max_players) => { + if team.users.len() > max_players.get() as usize { + return Response::builder() + .status(StatusCode::FORBIDDEN) + .body("".to_owned()) + .unwrap(); + } + } + MaxDivisionPlayers::Unlimited => {} } - let team_divisions = state.db.get_team_divisions(team.id).await.unwrap(); + let eligible = division + .division_eligibility + .is_user_eligible(user.id) + .await + .is_ok(); - if team_divisions.len() == 1 && team_divisions.contains(&division_id) { - tracing::info!("Cannot remove last division"); + if !eligible { return Response::builder() .status(StatusCode::FORBIDDEN) .body("".to_owned()) .unwrap(); } - let mut eligible = true; - for user_id in team.users.keys() { - let user_divisions = state.db.get_user_divisions(*user_id).await.unwrap(); - - if !user_divisions.contains(&division_id) { - eligible = false; - break; - } - } - state .db - .set_team_division(user.team_id, division_id, eligible && form.join.is_some()) + .set_team_division(team.id, team.division_id, division_id, now) .await .unwrap(); - let standings = state.db.get_team_standings(user.team_id).await.unwrap(); - - tracing::trace!( - user_id = user.id, - division_id, - joined = form.join.is_some(), - "Set division" - ); + tracing::trace!(team_id = team.id, division_id, "Set division"); - let team_divisions = state.db.get_team_divisions(team.id).await.unwrap(); - let max_players = state - .divisions - .iter() - .filter(|division| team_divisions.contains(&division.id)) - .filter_map(|division| match division.max_players { - MaxDivisionPlayers::Unlimited => None, - MaxDivisionPlayers::Limited(max) => Some(max), - }) - .min() - .map(MaxDivisionPlayers::Limited) - .unwrap_or(MaxDivisionPlayers::Unlimited); + let standing = state + .db + .get_team_standing(user.team_id, division_id) + .await + .unwrap(); - let team = state.db.get_team_from_id(user.team_id).await.unwrap(); let mut divisions = vec![]; for division in state.divisions.iter() { - let mut ineligible_user_ids = vec![]; - for user_id in team.users.keys() { - let user_divisions = state.db.get_user_divisions(*user_id).await.unwrap(); - - if !user_divisions.contains(&division.id) { - ineligible_user_ids.push(*user_id); - } - } + let eligible = division + .division_eligibility + .is_user_eligible(team.owner_user_id) + .await; let oversized = match division.max_players { MaxDivisionPlayers::Unlimited => true, @@ -421,18 +380,29 @@ pub async fn route_team_set_division( } }; + let joined = division_id == division.id; + divisions.push(TeamDivision { id: division.id, name: &division.name, description: &division.description, - eligible: ineligible_user_ids.is_empty() && oversized, - ineligible_user_ids, - joined: team_divisions.contains(&division.id), + eligible: eligible.is_ok() && oversized, + requirement: eligible.err(), + joined, max_players: division.max_players.clone(), }) } - let num_joined_divisions = divisions.iter().filter(|d| d.joined).count(); + let max_players = divisions + .iter() + .filter(|division| division.joined) + .filter_map(|division| match division.max_players { + MaxDivisionPlayers::Unlimited => None, + MaxDivisionPlayers::Limited(max) => Some(max), + }) + .min() + .map(MaxDivisionPlayers::Limited) + .unwrap_or(MaxDivisionPlayers::Unlimited); let html = state .jinja @@ -444,8 +414,9 @@ pub async fn route_team_set_division( max_players, user, divisions, - standings => standings.standings, - num_joined_divisions, + division_id, + standing, + minutes_until_division_change => Some(60), oob => true, }) .unwrap(); diff --git a/rhombus/src/plugin.rs b/rhombus/src/plugin.rs index 3d89902..248d30c 100644 --- a/rhombus/src/plugin.rs +++ b/rhombus/src/plugin.rs @@ -1,13 +1,18 @@ -use std::{any::Any, sync::Arc}; +use std::{any::Any, collections::BTreeMap, sync::Arc}; use axum::Router; -use tokio::sync::RwLock; +use tokio::sync::{Mutex, RwLock}; use crate::{ builder::RawDb, internal::{ - database::provider::Connection, division::Division, locales::Localizations, - router::RouterState, settings::Settings, templates::Templates, + database::provider::Connection, + division::Division, + locales::Localizations, + router::RouterState, + routes::challenges::{ChallengeFlag, ChallengePoints}, + settings::Settings, + templates::Templates, }, upload_provider::EitherUploadProvider, Result, UploadProvider, @@ -38,6 +43,10 @@ pub struct RunContext<'a, U: UploadProvider> { /// Divisions and their eligibility functions. pub divisions: &'a mut Vec, + + pub score_type_map: &'a Arc>>>, + + pub flag_fn_map: &'a Arc>>>, } pub struct UploadProviderContext<'a> { diff --git a/rhombus/static/app.js b/rhombus/static/app.js index da43ce4..201dea1 100644 --- a/rhombus/static/app.js +++ b/rhombus/static/app.js @@ -1,5 +1,5 @@ -var rhombus=(()=>{var Lo=Object.defineProperty;var Zs=Object.getOwnPropertyDescriptor;var Xs=Object.getOwnPropertyNames;var Ys=Object.prototype.hasOwnProperty;var Js=(e,t)=>{for(var n in t)Lo(e,n,{get:t[n],enumerable:!0})},Qs=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Xs(t))!Ys.call(e,a)&&a!==n&&Lo(e,a,{get:()=>t[a],enumerable:!(o=Zs(t,a))||o.enumerable});return e};var ec=e=>Qs(Lo({},"__esModule",{value:!0}),e);var Su={};Js(Su,{renderChallenges:()=>bu,toast:()=>Ce,translate:()=>ne});var H={context:void 0,registry:void 0};function Io(e){H.context=e}function tc(){return{...H.context,id:`${H.context.id}${H.context.count++}-`,count:0}}var nc=(e,t)=>e===t,fe=Symbol("solid-proxy"),Qt=Symbol("solid-track"),Nu=Symbol("solid-dev-component"),Tn={equals:nc},Aa=null,qa=za,Le=1,Xt=2,Va={owned:null,cleanups:null,context:null,owner:null},No={},E=null,S=null,xt=null,wt=null,K=null,ce=null,ye=null,On=0;function Fe(e,t){let n=K,o=E,a=e.length===0,r=t===void 0?o:t,i=a?Va:{owned:null,cleanups:null,context:r?r.context:null,owner:r},s=a?e:()=>e(()=>Q(()=>et(i)));E=i,K=null;try{return ve(s,!0)}finally{K=n,E=o}}function P(e,t){t=t?Object.assign({},Tn,t):Tn;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},o=a=>(typeof a=="function"&&(S&&S.running&&S.sources.has(n)?a=a(n.tValue):a=a(n.value)),Ha(n,a));return[Ea.bind(n),o]}function Po(e,t,n){let o=Bn(e,t,!0,Le);xt&&S&&S.running?ce.push(o):Ct(o)}function U(e,t,n){let o=Bn(e,t,!1,Le);xt&&S&&S.running?ce.push(o):Ct(o)}function I(e,t,n){qa=sc;let o=Bn(e,t,!1,Le),a=Yt&&ue(Yt);a&&(o.suspense=a),(!n||!n.render)&&(o.user=!0),ye?ye.push(o):Ct(o)}function O(e,t,n){n=n?Object.assign({},Tn,n):Tn;let o=Bn(e,t,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=n.equals||void 0,xt&&S&&S.running?(o.tState=Le,ce.push(o)):Ct(o),Ea.bind(o)}function oc(e){return e&&typeof e=="object"&&"then"in e}function To(e,t,n){let o,a,r;arguments.length===2&&typeof t=="object"||arguments.length===1?(o=!0,a=e,r=t||{}):(o=e,a=t,r=n||{});let i=null,s=No,c=null,l=!1,u=!1,d="initialValue"in r,h=typeof o=="function"&&O(o),y=new Set,[p,m]=(r.storage||P)(r.initialValue),[x,v]=P(void 0),[w,L]=P(void 0,{equals:!1}),[A,q]=P(d?"ready":"unresolved");if(H.context){c=`${H.context.id}${H.context.count++}`;let k;r.ssrLoadFrom==="initial"?s=r.initialValue:H.load&&(k=H.load(c))&&(s=k)}function R(k,g,M,N){return i===k&&(i=null,N!==void 0&&(d=!0),(k===s||g===s)&&r.onHydrated&&queueMicrotask(()=>r.onHydrated(N,{value:g})),s=No,S&&k&&l?(S.promises.delete(k),l=!1,ve(()=>{S.running=!0,j(g,M)},!1)):j(g,M)),g}function j(k,g){ve(()=>{g===void 0&&m(()=>k),q(g!==void 0?"errored":d?"ready":"unresolved"),v(g);for(let M of y.keys())M.decrement();y.clear()},!1)}function _(){let k=Yt&&ue(Yt),g=p(),M=x();if(M!==void 0&&!i)throw M;return K&&!K.user&&k&&Po(()=>{w(),i&&(k.resolved&&S&&l?S.promises.add(i):y.has(k)||(k.increment(),y.add(k)))}),g}function C(k=!0){if(k!==!1&&u)return;u=!1;let g=h?h():o;if(l=S&&S.running,g==null||g===!1){R(i,Q(p));return}S&&i&&S.promises.delete(i);let M=s!==No?s:Q(()=>a(g,{value:p(),refetching:k}));return oc(M)?(i=M,"value"in M?(M.status==="success"?R(i,M.value,void 0,g):R(i,void 0,void 0,g),M):(u=!0,queueMicrotask(()=>u=!1),ve(()=>{q(d?"refreshing":"pending"),L()},!1),M.then(N=>R(M,N,void 0,g),N=>R(M,void 0,_a(N),g)))):(R(i,M,void 0,g),M)}return Object.defineProperties(_,{state:{get:()=>A()},error:{get:()=>x()},loading:{get(){let k=A();return k==="pending"||k==="refreshing"}},latest:{get(){if(!d)return _();let k=x();if(k&&!i)throw k;return p()}}}),h?Po(()=>C(!1)):C(!1),[_,{refetch:C,mutate:m}]}function Fo(e){return ve(e,!1)}function Q(e){if(!wt&&K===null)return e();let t=K;K=null;try{return wt?wt.untrack(e):e()}finally{K=t}}function Oe(e,t,n){let o=Array.isArray(e),a,r=n&&n.defer;return i=>{let s;if(o){s=Array(e.length);for(let l=0;lt(s,a,i));return a=s,c}}function pe(e){I(()=>Q(e))}function T(e){return E===null||(E.cleanups===null?E.cleanups=[e]:E.cleanups.push(e)),e}function Rn(){return K}function qn(){return E}function Ba(e,t){let n=E,o=K;E=e,K=null;try{return ve(t,!0)}catch(a){En(a)}finally{E=n,K=o}}function ac(e){if(S&&S.running)return e(),S.done;let t=K,n=E;return Promise.resolve().then(()=>{K=t,E=n;let o;return(xt||Yt)&&(o=S||(S={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0}),o.done||(o.done=new Promise(a=>o.resolve=a)),o.running=!0),ve(e,!1),K=E=null,o?o.done:void 0})}var[$u,Ta]=P(!1);function F(e,t){let n=Symbol("context");return{id:n,Provider:cc(n),defaultValue:e}}function ue(e){return E&&E.context&&E.context[e.id]!==void 0?E.context[e.id]:e.defaultValue}function Vn(e){let t=O(e),n=O(()=>Do(t()));return n.toArray=()=>{let o=n();return Array.isArray(o)?o:o!=null?[o]:[]},n}var Yt;function Ea(){let e=S&&S.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===Le)Ct(this);else{let t=ce;ce=null,ve(()=>Fn(this),!1),ce=t}if(K){let t=this.observers?this.observers.length:0;K.sources?(K.sources.push(this),K.sourceSlots.push(t)):(K.sources=[this],K.sourceSlots=[t]),this.observers?(this.observers.push(K),this.observerSlots.push(K.sources.length-1)):(this.observers=[K],this.observerSlots=[K.sources.length-1])}return e&&S.sources.has(this)?this.tValue:this.value}function Ha(e,t,n){let o=S&&S.running&&S.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(o,t)){if(S){let a=S.running;(a||!n&&S.sources.has(e))&&(S.sources.add(e),e.tValue=t),a||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&ve(()=>{for(let a=0;a1e6)throw ce=[],new Error},!1)}return t}function Ct(e){if(!e.fn)return;et(e);let t=On;Fa(e,S&&S.running&&S.sources.has(e)?e.tValue:e.value,t),S&&!S.running&&S.sources.has(e)&&queueMicrotask(()=>{ve(()=>{S&&(S.running=!0),K=E=e,Fa(e,e.tValue,t),K=E=null},!1)})}function Fa(e,t,n){let o,a=E,r=K;K=E=e;try{o=e.fn(t)}catch(i){return e.pure&&(S&&S.running?(e.tState=Le,e.tOwned&&e.tOwned.forEach(et),e.tOwned=void 0):(e.state=Le,e.owned&&e.owned.forEach(et),e.owned=null)),e.updatedAt=n+1,En(i)}finally{K=r,E=a}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ha(e,o,!0):S&&S.running&&e.pure?(S.sources.add(e),e.tValue=o):e.value=o,e.updatedAt=n)}function Bn(e,t,n,o=Le,a){let r={fn:e,state:o,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:E,context:E?E.context:null,pure:n};if(S&&S.running&&(r.state=0,r.tState=o),E===null||E!==Va&&(S&&S.running&&E.pure?E.tOwned?E.tOwned.push(r):E.tOwned=[r]:E.owned?E.owned.push(r):E.owned=[r]),wt&&r.fn){let[i,s]=P(void 0,{equals:!1}),c=wt.factory(r.fn,s);T(()=>c.dispose());let l=()=>ac(s).then(()=>u.dispose()),u=wt.factory(r.fn,l);r.fn=d=>(i(),S&&S.running?u.track(d):c.track(d))}return r}function Jt(e){let t=S&&S.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Xt)return Fn(e);if(e.suspense&&Q(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;o--){if(e=n[o],t){let a=e,r=n[o+1];for(;(a=a.owner)&&a!==r;)if(S.disposed.has(a))return}if((t?e.tState:e.state)===Le)Ct(e);else if((t?e.tState:e.state)===Xt){let a=ce;ce=null,ve(()=>Fn(e,n[0]),!1),ce=a}}}function ve(e,t){if(ce)return e();let n=!1;t||(ce=[]),ye?n=!0:ye=[],On++;try{let o=e();return rc(n),o}catch(o){n||(ye=null),ce=null,En(o)}}function rc(e){if(ce&&(xt&&S&&S.running?ic(ce):za(ce),ce=null),e)return;let t;if(S){if(!S.promises.size&&!S.queue.size){let o=S.sources,a=S.disposed;ye.push.apply(ye,S.effects),t=S.resolve;for(let r of ye)"tState"in r&&(r.state=r.tState),delete r.tState;S=null,ve(()=>{for(let r of a)et(r);for(let r of o){if(r.value=r.tValue,r.owned)for(let i=0,s=r.owned.length;iqa(n),!1),t&&t()}function za(e){for(let t=0;t{o.delete(n),ve(()=>{S.running=!0,Jt(n)},!1),S&&(S.running=!1)}))}}function sc(e){let t,n=0;for(t=0;t=0;t--)et(e.tOwned[t]);delete e.tOwned}Ua(e,!0)}else if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}S&&S.running?e.tState=0:e.state=0}function Ua(e,t){if(t||(e.tState=0,S.disposed.add(e)),e.owned)for(let n=0;na=Q(()=>(E.context={...E.context,[e]:o.value},Vn(()=>o.children))),void 0),a}}var lc=Symbol("fallback");function Ra(e){for(let t=0;t1?[]:null;return T(()=>Ra(r)),()=>{let c=e()||[],l,u;return c[Qt],Q(()=>{let h=c.length,y,p,m,x,v,w,L,A,q;if(h===0)i!==0&&(Ra(r),r=[],o=[],a=[],i=0,s&&(s=[])),n.fallback&&(o=[lc],a[0]=Fe(R=>(r[0]=R,n.fallback())),i=1);else if(i===0){for(a=new Array(h),u=0;u=w&&A>=w&&o[L]===c[A];L--,A--)m[A]=a[L],x[A]=r[L],s&&(v[A]=s[L]);for(y=new Map,p=new Array(A+1),u=A;u>=w;u--)q=c[u],l=y.get(q),p[u]=l===void 0?-1:l,y.set(q,u);for(l=w;l<=L;l++)q=o[l],u=y.get(q),u!==void 0&&u!==-1?(m[u]=a[l],x[u]=r[l],s&&(v[u]=s[l]),u=p[u],y.set(q,u)):r[l]();for(u=w;ue(t||{}));return Io(n),o}return Q(()=>e(t||{}))}function An(){return!0}var Ao={get(e,t,n){return t===fe?n:e.get(t)},has(e,t){return t===fe?!0:e.has(t)},set:An,deleteProperty:An,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:An,deleteProperty:An}},ownKeys(e){return e.keys()}};function $o(e){return(e=typeof e=="function"?e():e)?e:{}}function hc(){for(let e=0,t=this.length;e=0;s--){let c=$o(e[s])[i];if(c!==void 0)return c}},has(i){for(let s=e.length-1;s>=0;s--)if(i in $o(e[s]))return!0;return!1},keys(){let i=[];for(let s=0;s=0;i--){let s=e[i];if(!s)continue;let c=Object.getOwnPropertyNames(s);for(let l=c.length-1;l>=0;l--){let u=c[l];if(u==="__proto__"||u==="constructor")continue;let d=Object.getOwnPropertyDescriptor(s,u);if(!o[u])o[u]=d.get?{enumerable:!0,configurable:!0,get:hc.bind(n[u]=[d.get.bind(s)])}:d.value!==void 0?d:void 0;else{let h=n[u];h&&(d.get?h.push(d.get.bind(s)):d.value!==void 0&&h.push(()=>d.value))}}}let a={},r=Object.keys(o);for(let i=r.length-1;i>=0;i--){let s=r[i],c=o[s];c&&c.get?Object.defineProperty(a,s,c):a[s]=c?c.value:void 0}return a}function B(e,...t){if(fe in e){let a=new Set(t.length>1?t.flat():t[0]),r=t.map(i=>new Proxy({get(s){return i.includes(s)?e[s]:void 0},has(s){return i.includes(s)&&s in e},keys(){return i.filter(s=>s in e)}},Ao));return r.push(new Proxy({get(i){return a.has(i)?void 0:e[i]},has(i){return a.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!a.has(i))}},Ao)),r}let n={},o=t.map(()=>({}));for(let a of Object.getOwnPropertyNames(e)){let r=Object.getOwnPropertyDescriptor(e,a),i=!r.get&&!r.set&&r.enumerable&&r.writable&&r.configurable,s=!1,c=0;for(let l of t)l.includes(a)&&(s=!0,i?o[c][a]=r.value:Object.defineProperty(o[c],a,r)),++c;s||(i?n[a]=r.value:Object.defineProperty(n,a,r))}return[...o,n]}var pc=0;function me(){let e=H.context;return e?`${e.id}${e.count++}`:`cl-${pc++}`}var Ka=e=>`Stale read from <${e}>.`;function Me(e){let t="fallback"in e&&{fallback:()=>e.fallback};return O(dc(()=>e.each,e.children,t||void 0))}function G(e){let t=e.keyed,n=O(()=>e.when,void 0,{equals:(o,a)=>t?o===a:!o==!a});return O(()=>{let o=n();if(o){let a=e.children;return typeof a=="function"&&a.length>0?Q(()=>a(t?o:()=>{if(!Q(n))throw Ka("Show");return e.when})):a}return e.fallback},void 0,void 0)}function Hn(e){let t=!1,n=(r,i)=>(t?r[1]===i[1]:!r[1]==!i[1])&&r[2]===i[2],o=Vn(()=>e.children),a=O(()=>{let r=o();Array.isArray(r)||(r=[r]);for(let i=0;i{let[r,i,s]=a();if(r<0)return e.fallback;let c=s.children;return typeof c=="function"&&c.length>0?Q(()=>c(t?i:()=>{if(Q(a)[0]!==r)throw Ka("Match");return s.when})):c},void 0,void 0)}function lt(e){return e}var Iu=F();var fc=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],kc=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...fc]),mc=new Set(["innerHTML","textContent","innerText","children"]),gc=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),vc=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Mc(e,t){let n=vc[e];return typeof n=="object"?n[t]?n.$:void 0:n}var wc=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),xc=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),Cc={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function bc(e,t,n){let o=n.length,a=t.length,r=o,i=0,s=0,c=t[a-1].nextSibling,l=null;for(;iu-s){let p=t[i];for(;s{a=r,t===document?e():D(t,e(),t.firstChild?null:void 0,n)},o.owner),()=>{a(),t.textContent=""}}function z(e,t,n){let o,a=()=>{let i=document.createElement("template");return i.innerHTML=e,n?i.content.firstChild.firstChild:i.content.firstChild},r=t?()=>Q(()=>document.importNode(o||(o=a()),!0)):()=>(o||(o=a())).cloneNode(!0);return r.cloneNode=r,r}function jn(e,t=window.document){let n=t[Ga]||(t[Ga]=new Set);for(let o=0,a=e.length;oa.call(e,n[1],r))}else e.addEventListener(t,n)}function Nc(e,t,n={}){let o=Object.keys(t||{}),a=Object.keys(n),r,i;for(r=0,i=a.length;ra.children=St(e,t.children,a.children)),U(()=>typeof t.ref=="function"?Ke(t.ref,e):t.ref=e),U(()=>$c(e,t,n,!0,a,!0)),a}function Ke(e,t,n){return Q(()=>e(t,n))}function D(e,t,n,o){if(n!==void 0&&!o&&(o=[]),typeof t!="function")return St(e,t,o,n);U(a=>St(e,t(),a,n),o)}function $c(e,t,n,o,a={},r=!1){t||(t={});for(let i in a)if(!(i in t)){if(i==="children")continue;a[i]=Za(e,i,null,a[i],n,r)}for(let i in t){if(i==="children"){o||St(e,t.children);continue}let s=t[i];a[i]=Za(e,i,s,a[i],n,r)}}function Ic(e){let t,n;return!H.context||!(t=H.registry.get(n=Ac()))?e():(H.completed&&H.completed.add(t),H.registry.delete(n),t)}function Pc(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Wa(e,t,n){let o=t.trim().split(/\s+/);for(let a=0,r=o.length;a-1&&Cc[t.split(":")[0]];d?Sc(e,d,t,n):ee(e,gc[t]||t,n)}return n}function Dc(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),H.registry&&!H.done&&(H.done=_$HY.done=!0);n;){let o=n[t];if(o&&!n.disabled){let a=n[`${t}Data`];if(a!==void 0?o.call(n,a,e):o.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function St(e,t,n,o,a){let r=!!H.context&&e.isConnected;if(r){!n&&(n=[...e.childNodes]);let c=[];for(let l=0;l{let c=t();for(;typeof c=="function";)c=c();n=St(e,c,n,o)}),()=>n;if(Array.isArray(t)){let c=[],l=n&&Array.isArray(n);if(Oo(c,t,n,a))return U(()=>n=St(e,c,n,o,!0)),()=>n;if(r){if(!c.length)return n;if(o===void 0)return[...e.childNodes];let u=c[0],d=[u];for(;(u=u.nextSibling)!==o;)d.push(u);return n=d}if(c.length===0){if(n=bt(e,n,o),s)return n}else l?n.length===0?Xa(e,c,o):bc(e,n,c):(n&&bt(e),Xa(e,c));n=c}else if(t.nodeType){if(r&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=bt(e,n,o,t);bt(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function Oo(e,t,n,o){let a=!1;for(let r=0,i=t.length;r=0;i--){let s=t[i];if(a!==s){let c=s.parentNode===e;!r&&!i?c?e.replaceChild(a,s):e.insertBefore(a,n):c&&s.remove()}else r=!0}}else e.insertBefore(a,n);return[a]}function Ac(){let e=H.context;return`${e.id}${e.count++}`}var Ru=Symbol();var X=!1;var Tc="http://www.w3.org/2000/svg";function Ya(e,t=!1){return t?document.createElementNS(Tc,e):document.createElement(e)}function Lt(e){let{useShadow:t}=e,n=document.createTextNode(""),o=()=>e.mount||document.body,a=qn(),r,i=!!H.context;return I(()=>{i&&(qn().user=i=!1),r||(r=Ba(a,()=>O(()=>e.children)));let s=o();if(s instanceof HTMLHeadElement){let[c,l]=P(!1),u=()=>l(!0);Fe(d=>D(s,()=>c()?d():r(),null)),T(u)}else{let c=Ya(e.isSVG?"g":"div",e.isSVG),l=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),D(l,r),s.appendChild(c),e.ref&&e.ref(c),T(()=>s.removeChild(c))}},void 0,{render:!i}),n}function tt(e){let[t,n]=B(e,["component"]),o=O(()=>t.component);return O(()=>{let a=o();switch(typeof a){case"function":return Q(()=>a(n));case"string":let r=xc.has(a),i=H.context?Ic():Ya(a,r);return ie(i,n,r),i}})}function Nt(e){return(...t)=>{for(let n of e)n&&n(...t)}}function Ro(e){return(...t)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];o&&o(...t)}}}var Z=e=>typeof e=="function"&&!e.length?e():e;function $t(e,...t){return typeof e=="function"?e(...t):e}function Un(){return!0}var Oc={get(e,t,n){return t===fe?n:e.get(t)},has(e,t){return e.has(t)},set:Un,deleteProperty:Un,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Un,deleteProperty:Un}},ownKeys(e){return e.keys()}};var Rc=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Ja(e){let t={},n;for(;n=Rc.exec(e);)t[n[1]]=n[2];return t}function qc(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Ja(e)}else typeof t=="string"&&(t=Ja(t));return{...e,...t}}var qo=(e,t,n)=>{let o;for(let a of e){let r=Z(a)[t];o?r&&(o=n(o,r)):o=r}return o};function Vo(...e){let t=Array.isArray(e[0]),n=t?e[0]:e;if(n.length===1)return n[0];let o=t&&e[1]?.reverseEventHandlers?Ro:Nt,a={};for(let i of n){let s=Z(i);for(let c in s)if(c[0]==="o"&&c[1]==="n"&&c[2]){let l=s[c],u=c.toLowerCase(),d=typeof l=="function"?l:Array.isArray(l)?l.length===1?l[0]:l[0].bind(void 0,l[1]):void 0;d?a[u]?a[u].push(d):a[u]=[d]:delete a[u]}}let r=$(...n);return new Proxy({get(i){if(typeof i!="string")return Reflect.get(r,i);if(i==="style")return qo(n,"style",qc);if(i==="ref"){let s=[];for(let c of n){let l=Z(c)[i];typeof l=="function"&&s.push(l)}return o(s)}if(i[0]==="o"&&i[1]==="n"&&i[2]){let s=a[i.toLowerCase()];return s?o(s):Reflect.get(r,i)}return i==="class"||i==="className"?qo(n,i,(s,c)=>`${s} ${c}`):i==="classList"?qo(n,i,(s,c)=>({...s,...c})):Reflect.get(r,i)},has(i){return Reflect.has(r,i)},keys(){return Object.keys(r)}},Oc)}function oe(...e){return Nt(e)}function It(e,t){let n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function nr(e){return Array.isArray(e)}function Kn(e){return Object.prototype.toString.call(e)==="[object String]"}function or(e){return typeof e=="function"}function Pt(e){return t=>`${e()}-${t}`}function J(e,t){return e?e===t||e.contains(t):!1}function Re(e,t=!1){let{activeElement:n}=ae(e);if(!n?.nodeName)return null;if(ar(n)&&n.contentDocument)return Re(n.contentDocument.body,t);if(t){let o=n.getAttribute("aria-activedescendant");if(o){let a=ae(n).getElementById(o);if(a)return a}}return n}function nn(e){return ae(e).defaultView||window}function ae(e){return e?e.ownerDocument||e:document}function ar(e){return e.tagName==="IFRAME"}var on=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(on||{});function Vc(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function rr(){return Vc(/^Mac/i)}function ke(e,t){return t&&(or(t)?t(e):t[0](t[1],e)),e?.defaultPrevented}function Dt(e){return t=>{for(let n of e)ke(t,n)}}function Gn(e){return rr()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function se(e){if(e)if(Bc())e.focus({preventScroll:!0});else{let t=Ec(e);e.focus(),Hc(t)}}var _n=null;function Bc(){if(_n==null){_n=!1;try{document.createElement("div").focus({get preventScroll(){return _n=!0,!0}})}catch{}}return _n}function Ec(e){let t=e.parentNode,n=[],o=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight{if(ar(a)&&a.contentDocument){let i=a.contentDocument.body,s=an(i,!1);o.splice(r,1,...s)}}),o}function Qa(e){return rn(e)&&!jc(e)}function rn(e){return e.matches(sr)&&cr(e)}function jc(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}function cr(e,t){return e.nodeName!=="#comment"&&Uc(e)&&_c(e,t)&&(!e.parentElement||cr(e.parentElement,e))}function Uc(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;let{display:t,visibility:n}=e.style,o=t!=="none"&&n!=="hidden"&&n!=="collapse";if(o){if(!e.ownerDocument.defaultView)return o;let{getComputedStyle:a}=e.ownerDocument.defaultView,{display:r,visibility:i}=a(e);o=r!=="none"&&i!=="hidden"&&i!=="collapse"}return o}function _c(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Wn(){}function Bo(e){return[e.clientX,e.clientY]}function Eo(e,t){let[n,o]=e,a=!1,r=t.length;for(let i=r,s=0,c=i-1;s=h&&o0&&(o===h?o>y&&(a=!a):a=!a)}}else if(uu&&o<=h){if(p===0)return!0;p<0&&(o===h?o=d&&n<=l||n>=l&&n<=d))return!0}return a}function re(e,t){return $(e,t)}var tn=new Map,er=new Set;function tr(){if(typeof window>"u")return;let e=n=>{if(!n.target)return;let o=tn.get(n.target);o||(o=new Set,tn.set(n.target,o),n.target.addEventListener("transitioncancel",t)),o.add(n.propertyName)},t=n=>{if(!n.target)return;let o=tn.get(n.target);if(o&&(o.delete(n.propertyName),o.size===0&&(n.target.removeEventListener("transitioncancel",t),tn.delete(n.target)),tn.size===0)){for(let a of er)a();er.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?tr():document.addEventListener("DOMContentLoaded",tr));var Zn={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};var Kc=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Gc=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Wc(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize().script??"";return Kc.has(n)}let t=e.split("-")[0];return Gc.has(t)}function Zc(e){return Wc(e)?"rtl":"ltr"}function dr(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:Zc(e)}}var Ho=dr(),sn=new Set;function lr(){Ho=dr();for(let e of sn)e(Ho)}function Xc(){let e={locale:"en-US",direction:"ltr"},[t,n]=P(Ho),o=O(()=>X?e:t());return pe(()=>{sn.size===0&&window.addEventListener("languagechange",lr),sn.add(n),T(()=>{sn.delete(n),sn.size===0&&window.removeEventListener("languagechange",lr)})}),{locale:()=>o().locale,direction:()=>o().direction}}var Yc=F();function ur(){let e=Xc();return ue(Yc)||e}function Ne(e){let[t,n]=B(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return f(tt,$({get component(){return t.as}},n))}var hr=["top","right","bottom","left"];var He=Math.min,ge=Math.max,ln=Math.round,dn=Math.floor,Ge=e=>({x:e,y:e}),Jc={left:"right",right:"left",bottom:"top",top:"bottom"},Qc={start:"end",end:"start"};function Yn(e,t,n){return ge(e,He(t,n))}function nt(e,t){return typeof e=="function"?e(t):e}function We(e){return e.split("-")[0]}function dt(e){return e.split("-")[1]}function zo(e){return e==="x"?"y":"x"}function Jn(e){return e==="y"?"height":"width"}function At(e){return["top","bottom"].includes(We(e))?"y":"x"}function Qn(e){return zo(At(e))}function pr(e,t,n){n===void 0&&(n=!1);let o=dt(e),a=Qn(e),r=Jn(a),i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=cn(i)),[i,cn(i)]}function yr(e){let t=cn(e);return[Xn(e),t,Xn(t)]}function Xn(e){return e.replace(/start|end/g,t=>Qc[t])}function e1(e,t,n){let o=["left","right"],a=["right","left"],r=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?a:o:t?o:a;case"left":case"right":return t?r:i;default:return[]}}function fr(e,t,n,o){let a=dt(e),r=e1(We(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Xn)))),r}function cn(e){return e.replace(/left|right|bottom|top/g,t=>Jc[t])}function t1(e){return{top:0,right:0,bottom:0,left:0,...e}}function jo(e){return typeof e!="number"?t1(e):{top:e,right:e,bottom:e,left:e}}function ut(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function kr(e,t,n){let{reference:o,floating:a}=e,r=At(t),i=Qn(t),s=Jn(i),c=We(t),l=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,h=o[s]/2-a[s]/2,y;switch(c){case"top":y={x:u,y:o.y-a.height};break;case"bottom":y={x:u,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:d};break;case"left":y={x:o.x-a.width,y:d};break;default:y={x:o.x,y:o.y}}switch(dt(t)){case"start":y[i]-=h*(n&&l?-1:1);break;case"end":y[i]+=h*(n&&l?-1:1);break}return y}var vr=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,s=r.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t)),l=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=kr(l,o,c),h=o,y={},p=0;for(let m=0;m({name:"arrow",options:e,async fn(t){let{x:n,y:o,placement:a,rects:r,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=nt(e,t)||{};if(l==null)return{};let d=jo(u),h={x:n,y:o},y=Qn(a),p=Jn(y),m=await i.getDimensions(l),x=y==="y",v=x?"top":"left",w=x?"bottom":"right",L=x?"clientHeight":"clientWidth",A=r.reference[p]+r.reference[y]-h[y]-r.floating[p],q=h[y]-r.reference[y],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l)),j=R?R[L]:0;(!j||!await(i.isElement==null?void 0:i.isElement(R)))&&(j=s.floating[L]||r.floating[p]);let _=A/2-q/2,C=j/2-m[p]/2-1,k=He(d[v],C),g=He(d[w],C),M=k,N=j-m[p]-g,b=j/2-m[p]/2+_,V=Yn(M,b,N),W=!c.arrow&&dt(a)!=null&&b!==V&&r.reference[p]/2-(bM<=0)){var C,k;let M=(((C=r.flip)==null?void 0:C.index)||0)+1,N=q[M];if(N)return{data:{index:M,overflows:_},reset:{placement:N}};let b=(k=_.filter(V=>V.overflows[0]<=0).sort((V,W)=>V.overflows[1]-W.overflows[1])[0])==null?void 0:k.placement;if(!b)switch(y){case"bestFit":{var g;let V=(g=_.map(W=>[W.placement,W.overflows.filter(de=>de>0).reduce((de,So)=>de+So,0)]).sort((W,de)=>W[1]-de[1])[0])==null?void 0:g[0];V&&(b=V);break}case"initialPlacement":b=s;break}if(a!==b)return{reset:{placement:b}}}return{}}}};function mr(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gr(e){return hr.some(t=>e[t]>=0)}var xr=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n}=t,{strategy:o="referenceHidden",...a}=nt(e,t);switch(o){case"referenceHidden":{let r=await Tt(t,{...a,elementContext:"reference"}),i=mr(r,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:gr(i)}}}case"escaped":{let r=await Tt(t,{...a,altBoundary:!0}),i=mr(r,n.floating);return{data:{escapedOffsets:i,escaped:gr(i)}}}default:return{}}}}};async function n1(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=We(n),s=dt(n),c=At(n)==="y",l=["left","top"].includes(i)?-1:1,u=r&&c?-1:1,d=nt(t,e),{mainAxis:h,crossAxis:y,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&typeof p=="number"&&(y=s==="end"?p*-1:p),c?{x:y*u,y:h*l}:{x:h*l,y:y*u}}var Cr=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:i,middlewareData:s}=t,c=await n1(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:a+c.x,y:r+c.y,data:{...c,placement:i}}}}},br=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a}=t,{mainAxis:r=!0,crossAxis:i=!1,limiter:s={fn:x=>{let{x:v,y:w}=x;return{x:v,y:w}}},...c}=nt(e,t),l={x:n,y:o},u=await Tt(t,c),d=At(We(a)),h=zo(d),y=l[h],p=l[d];if(r){let x=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=y+u[x],L=y-u[v];y=Yn(w,y,L)}if(i){let x=d==="y"?"top":"left",v=d==="y"?"bottom":"right",w=p+u[x],L=p-u[v];p=Yn(w,p,L)}let m=s.fn({...t,[h]:y,[d]:p});return{...m,data:{x:m.x-n,y:m.y-o}}}}};var Sr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:o,platform:a,elements:r}=t,{apply:i=()=>{},...s}=nt(e,t),c=await Tt(t,s),l=We(n),u=dt(n),d=At(n)==="y",{width:h,height:y}=o.floating,p,m;l==="top"||l==="bottom"?(p=l,m=u===(await(a.isRTL==null?void 0:a.isRTL(r.floating))?"start":"end")?"left":"right"):(m=l,p=u==="end"?"top":"bottom");let x=y-c[p],v=h-c[m],w=!t.middlewareData.shift,L=x,A=v;if(d){let R=h-c.left-c.right;A=u||w?He(v,R):R}else{let R=y-c.top-c.bottom;L=u||w?He(x,R):R}if(w&&!u){let R=ge(c.left,0),j=ge(c.right,0),_=ge(c.top,0),C=ge(c.bottom,0);d?A=h-2*(R!==0||j!==0?R+j:ge(c.left,c.right)):L=y-2*(_!==0||C!==0?_+C:ge(c.top,c.bottom))}await i({...t,availableWidth:A,availableHeight:L});let q=await a.getDimensions(r.floating);return h!==q.width||y!==q.height?{reset:{rects:!0}}:{}}}};function ht(e){return Nr(e)?(e.nodeName||"").toLowerCase():"#document"}function we(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ze(e){var t;return(t=(Nr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nr(e){return e instanceof Node||e instanceof we(e).Node}function qe(e){return e instanceof Element||e instanceof we(e).Element}function Ve(e){return e instanceof HTMLElement||e instanceof we(e).HTMLElement}function Lr(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof we(e).ShadowRoot}function Ot(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Pe(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!["inline","contents"].includes(a)}function $r(e){return["table","td","th"].includes(ht(e))}function eo(e){let t=to(),n=Pe(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function Ir(e){let t=Ze(e);for(;Ve(t)&&!pt(t);){if(eo(t))return t;t=Ze(t)}return null}function to(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function pt(e){return["html","body","#document"].includes(ht(e))}function Pe(e){return we(e).getComputedStyle(e)}function un(e){return qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ze(e){if(ht(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Lr(e)&&e.host||ze(e);return Lr(t)?t.host:t}function Pr(e){let t=Ze(e);return pt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ve(t)&&Ot(t)?t:Pr(t)}function Ft(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=Pr(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=we(a);return r?t.concat(i,i.visualViewport||[],Ot(a)?a:[],i.frameElement&&n?Ft(i.frameElement):[]):t.concat(a,Ft(a,[],n))}function Tr(e){let t=Pe(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=Ve(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,s=ln(n)!==r||ln(o)!==i;return s&&(n=r,o=i),{width:n,height:o,$:s}}function _o(e){return qe(e)?e:e.contextElement}function Rt(e){let t=_o(e);if(!Ve(t))return Ge(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=Tr(t),i=(r?ln(n.width):n.width)/o,s=(r?ln(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}var o1=Ge(0);function Fr(e){let t=we(e);return!to()||!t.visualViewport?o1:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function a1(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==we(e)?!1:t}function yt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=_o(e),i=Ge(1);t&&(o?qe(o)&&(i=Rt(o)):i=Rt(e));let s=a1(r,n,o)?Fr(r):Ge(0),c=(a.left+s.x)/i.x,l=(a.top+s.y)/i.y,u=a.width/i.x,d=a.height/i.y;if(r){let h=we(r),y=o&&qe(o)?we(o):o,p=h,m=p.frameElement;for(;m&&o&&y!==p;){let x=Rt(m),v=m.getBoundingClientRect(),w=Pe(m),L=v.left+(m.clientLeft+parseFloat(w.paddingLeft))*x.x,A=v.top+(m.clientTop+parseFloat(w.paddingTop))*x.y;c*=x.x,l*=x.y,u*=x.x,d*=x.y,c+=L,l+=A,p=we(m),m=p.frameElement}}return ut({width:u,height:d,x:c,y:l})}var r1=[":popover-open",":modal"];function Ko(e){return r1.some(t=>{try{return e.matches(t)}catch{return!1}})}function i1(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",i=ze(o),s=t?Ko(t.floating):!1;if(o===i||s&&r)return n;let c={scrollLeft:0,scrollTop:0},l=Ge(1),u=Ge(0),d=Ve(o);if((d||!d&&!r)&&((ht(o)!=="body"||Ot(i))&&(c=un(o)),Ve(o))){let h=yt(o);l=Rt(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x,y:n.y*l.y-c.scrollTop*l.y+u.y}}function s1(e){return Array.from(e.getClientRects())}function Or(e){return yt(ze(e)).left+un(e).scrollLeft}function c1(e){let t=ze(e),n=un(e),o=e.ownerDocument.body,a=ge(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=ge(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),i=-n.scrollLeft+Or(e),s=-n.scrollTop;return Pe(o).direction==="rtl"&&(i+=ge(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:s}}function l1(e,t){let n=we(e),o=ze(e),a=n.visualViewport,r=o.clientWidth,i=o.clientHeight,s=0,c=0;if(a){r=a.width,i=a.height;let l=to();(!l||l&&t==="fixed")&&(s=a.offsetLeft,c=a.offsetTop)}return{width:r,height:i,x:s,y:c}}function d1(e,t){let n=yt(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=Ve(e)?Rt(e):Ge(1),i=e.clientWidth*r.x,s=e.clientHeight*r.y,c=a*r.x,l=o*r.y;return{width:i,height:s,x:c,y:l}}function Dr(e,t,n){let o;if(t==="viewport")o=l1(e,n);else if(t==="document")o=c1(ze(e));else if(qe(t))o=d1(t,n);else{let a=Fr(e);o={...t,x:t.x-a.x,y:t.y-a.y}}return ut(o)}function Rr(e,t){let n=Ze(e);return n===t||!qe(n)||pt(n)?!1:Pe(n).position==="fixed"||Rr(n,t)}function u1(e,t){let n=t.get(e);if(n)return n;let o=Ft(e,[],!1).filter(s=>qe(s)&&ht(s)!=="body"),a=null,r=Pe(e).position==="fixed",i=r?Ze(e):e;for(;qe(i)&&!pt(i);){let s=Pe(i),c=eo(i);!c&&s.position==="fixed"&&(a=null),(r?!c&&!a:!c&&s.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Ot(i)&&!c&&Rr(e,i))?o=o.filter(u=>u!==i):a=s,i=Ze(i)}return t.set(e,o),o}function h1(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,i=[...n==="clippingAncestors"?Ko(t)?[]:u1(t,this._c):[].concat(n),o],s=i[0],c=i.reduce((l,u)=>{let d=Dr(t,u,a);return l.top=ge(d.top,l.top),l.right=He(d.right,l.right),l.bottom=He(d.bottom,l.bottom),l.left=ge(d.left,l.left),l},Dr(t,s,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function p1(e){let{width:t,height:n}=Tr(e);return{width:t,height:n}}function y1(e,t,n){let o=Ve(t),a=ze(t),r=n==="fixed",i=yt(e,!0,r,t),s={scrollLeft:0,scrollTop:0},c=Ge(0);if(o||!o&&!r)if((ht(t)!=="body"||Ot(a))&&(s=un(t)),o){let d=yt(t,!0,r,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else a&&(c.x=Or(a));let l=i.left+s.scrollLeft-c.x,u=i.top+s.scrollTop-c.y;return{x:l,y:u,width:i.width,height:i.height}}function Uo(e){return Pe(e).position==="static"}function Ar(e,t){return!Ve(e)||Pe(e).position==="fixed"?null:t?t(e):e.offsetParent}function qr(e,t){let n=we(e);if(Ko(e))return n;if(!Ve(e)){let a=Ze(e);for(;a&&!pt(a);){if(qe(a)&&!Uo(a))return a;a=Ze(a)}return n}let o=Ar(e,t);for(;o&&$r(o)&&Uo(o);)o=Ar(o,t);return o&&pt(o)&&Uo(o)&&!eo(o)?n:o||Ir(e)||n}var f1=async function(e){let t=this.getOffsetParent||qr,n=this.getDimensions,o=await n(e.floating);return{reference:y1(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function k1(e){return Pe(e).direction==="rtl"}var Go={convertOffsetParentRelativeRectToViewportRelativeRect:i1,getDocumentElement:ze,getClippingRect:h1,getOffsetParent:qr,getElementRects:f1,getClientRects:s1,getDimensions:p1,getScale:Rt,isElement:qe,isRTL:k1};function m1(e,t){let n=null,o,a=ze(e);function r(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),r();let{left:l,top:u,width:d,height:h}=e.getBoundingClientRect();if(s||t(),!d||!h)return;let y=dn(u),p=dn(a.clientWidth-(l+d)),m=dn(a.clientHeight-(u+h)),x=dn(l),w={rootMargin:-y+"px "+-p+"px "+-m+"px "+-x+"px",threshold:ge(0,He(1,c))||1},L=!0;function A(q){let R=q[0].intersectionRatio;if(R!==c){if(!L)return i();R?i(!1,R):o=setTimeout(()=>{i(!1,1e-7)},1e3)}L=!1}try{n=new IntersectionObserver(A,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(A,w)}n.observe(e)}return i(!0),r}function Vr(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=_o(e),u=a||r?[...l?Ft(l):[],...Ft(t)]:[];u.forEach(v=>{a&&v.addEventListener("scroll",n,{passive:!0}),r&&v.addEventListener("resize",n)});let d=l&&s?m1(l,n):null,h=-1,y=null;i&&(y=new ResizeObserver(v=>{let[w]=v;w&&w.target===l&&y&&(y.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var L;(L=y)==null||L.observe(t)})),n()}),l&&!c&&y.observe(l),y.observe(t));let p,m=c?yt(e):null;c&&x();function x(){let v=yt(e);m&&(v.x!==m.x||v.y!==m.y||v.width!==m.width||v.height!==m.height)&&n(),m=v,p=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(w=>{a&&w.removeEventListener("scroll",n),r&&w.removeEventListener("resize",n)}),d?.(),(v=y)==null||v.disconnect(),y=null,c&&cancelAnimationFrame(p)}}var Br=Cr;var Er=br,Hr=wr,zr=Sr,jr=xr,Ur=Mr;var _r=(e,t,n)=>{let o=new Map,a={platform:Go,...n},r={...a.platform,_c:o};return vr(e,t,{...a,platform:r})};var Zo=F();function Xo(){let e=ue(Zo);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var g1=z(''),Wo=30,Kr=Wo/2,v1={top:180,right:-90,bottom:0,left:90};function no(e){let t=Xo(),n=re({size:Wo},e),[o,a]=B(n,["ref","style","size"]),r=()=>t.currentPlacement().split("-")[0],i=M1(t.contentRef),s=()=>i()?.getPropertyValue("background-color")||"none",c=()=>i()?.getPropertyValue(`border-${r()}-color`)||"none",l=()=>i()?.getPropertyValue(`border-${r()}-width`)||"0px",u=()=>parseInt(l())*2*(Wo/o.size),d=()=>`rotate(${v1[r()]} ${Kr} ${Kr})`;return f(Ne,$({as:"div",ref(h){let y=oe(t.setArrowRef,o.ref);typeof y=="function"&&y(h)},"aria-hidden":"true",get style(){return{position:"absolute","font-size":`${o.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:s(),stroke:c(),"stroke-width":u(),...o.style}}},a,{get children(){let h=g1(),y=h.firstChild;return U(()=>ee(y,"transform",d())),h}}))}function M1(e){let[t,n]=P();return I(()=>{let o=e();o&&n(nn(o).getComputedStyle(o))}),t}function w1(e){let t=Xo(),[n,o]=B(e,["ref","style"]);return f(Ne,$({as:"div",ref(a){let r=oe(t.setPositionerRef,n.ref);typeof r=="function"&&r(a)},"data-popper-positioner":"",get style(){return{position:"absolute",top:0,left:0,"min-width":"max-content",...n.style}}},o))}function Gr(e){let{x:t=0,y:n=0,width:o=0,height:a=0}=e??{};if(typeof DOMRect=="function")return new DOMRect(t,n,o,a);let r={x:t,y:n,width:o,height:a,top:n,right:t+o,bottom:n+a,left:t};return{...r,toJSON:()=>r}}function x1(e,t){return{contextElement:e,getBoundingClientRect:()=>{let o=t(e);return o?Gr(o):e?e.getBoundingClientRect():Gr()}}}function C1(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var b1={top:"bottom",right:"left",bottom:"top",left:"right"};function S1(e,t){let[n,o]=e.split("-"),a=b1[n];return o?n==="left"||n==="right"?`${a} ${o==="start"?"top":"bottom"}`:o==="start"?`${a} ${t==="rtl"?"right":"left"}`:`${a} ${t==="rtl"?"left":"right"}`:`${a} center`}function L1(e){let t=re({getAnchorRect:h=>h?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,o]=P(),[a,r]=P(),[i,s]=P(t.placement),c=()=>x1(t.anchorRef?.(),t.getAnchorRect),{direction:l}=ur();async function u(){let h=c(),y=n(),p=a();if(!h||!y)return;let m=(p?.clientHeight||0)/2,x=typeof t.gutter=="number"?t.gutter+m:t.gutter??m;y.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),h.getBoundingClientRect();let v=[Br(({placement:R})=>{let j=!!R.split("-")[1];return{mainAxis:x,crossAxis:j?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){let R=typeof t.flip=="string"?t.flip.split(" "):void 0;if(R!==void 0&&!R.every(C1))throw new Error("`flip` expects a spaced-delimited list of placements");v.push(Hr({padding:t.overflowPadding,fallbackPlacements:R}))}(t.slide||t.overlap)&&v.push(Er({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),v.push(zr({padding:t.overflowPadding,apply({availableWidth:R,availableHeight:j,rects:_}){let C=Math.round(_.reference.width);R=Math.floor(R),j=Math.floor(j),y.style.setProperty("--kb-popper-anchor-width",`${C}px`),y.style.setProperty("--kb-popper-content-available-width",`${R}px`),y.style.setProperty("--kb-popper-content-available-height",`${j}px`),t.sameWidth&&(y.style.width=`${C}px`),t.fitViewport&&(y.style.maxWidth=`${R}px`,y.style.maxHeight=`${j}px`)}})),t.hideWhenDetached&&v.push(jr({padding:t.detachedPadding})),p&&v.push(Ur({element:p,padding:t.arrowPadding}));let w=await _r(h,y,{placement:t.placement,strategy:"absolute",middleware:v,platform:{...Go,isRTL:()=>l()==="rtl"}});if(s(w.placement),t.onCurrentPlacementChange?.(w.placement),!y)return;y.style.setProperty("--kb-popper-content-transform-origin",S1(w.placement,l()));let L=Math.round(w.x),A=Math.round(w.y),q;if(t.hideWhenDetached&&(q=w.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(y.style,{top:"0",left:"0",transform:`translate3d(${L}px, ${A}px, 0)`,visibility:q}),p&&w.middlewareData.arrow){let{x:R,y:j}=w.middlewareData.arrow,_=w.placement.split("-")[0];Object.assign(p.style,{left:R!=null?`${R}px`:"",top:j!=null?`${j}px`:"",[_]:"100%"})}}I(()=>{let h=c(),y=n();if(!h||!y)return;let p=Vr(h,y,u,{elementResize:typeof ResizeObserver=="function"});T(p)}),I(()=>{let h=n(),y=t.contentRef?.();!h||!y||queueMicrotask(()=>{h.style.zIndex=getComputedStyle(y).zIndex})});let d={currentPlacement:i,contentRef:()=>t.contentRef?.(),setPositionerRef:o,setArrowRef:r};return f(Zo.Provider,{value:d,get children(){return t.children}})}var Yo=Object.assign(L1,{Arrow:no,Context:Zo,usePopperContext:Xo,Positioner:w1});function Wr(e){let t=n=>{n.key===on.Escape&&e.onEscapeKeyDown?.(n)};I(()=>{if(X||Z(e.isDisabled))return;let n=e.ownerDocument?.()??ae();n.addEventListener("keydown",t),T(()=>{n.removeEventListener("keydown",t)})})}var ft="data-kb-top-layer",Zr,Jo=!1,Xe=[];function hn(e){return Xe.findIndex(t=>t.node===e)}function N1(e){return Xe[hn(e)]}function $1(e){return Xe[Xe.length-1].node===e}function Xr(){return Xe.filter(e=>e.isPointerBlocking)}function I1(){return[...Xr()].slice(-1)[0]}function Qo(){return Xr().length>0}function Yr(e){let t=hn(I1()?.node);return hn(e)ae(t()),r=d=>e.onPointerDownOutside?.(d),i=d=>e.onFocusOutside?.(d),s=d=>e.onInteractOutside?.(d),c=d=>{let h=d.target;return!(h instanceof HTMLElement)||h.closest(`[${ft}]`)||!J(a(),h)||J(t(),h)?!1:!e.shouldExcludeElement?.(h)},l=d=>{function h(){let y=t(),p=d.target;if(!y||!p||!c(d))return;let m=Dt([r,s]);p.addEventListener(Jr,m,{once:!0});let x=new CustomEvent(Jr,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:d.button===2||Gn(d)&&d.button===0}});p.dispatchEvent(x)}d.pointerType==="touch"?(a().removeEventListener("click",h),o=h,a().addEventListener("click",h,{once:!0})):h()},u=d=>{let h=t(),y=d.target;if(!h||!y||!c(d))return;let p=Dt([i,s]);y.addEventListener(Qr,p,{once:!0});let m=new CustomEvent(Qr,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:!1}});y.dispatchEvent(m)};I(()=>{X||Z(e.isDisabled)||(n=window.setTimeout(()=>{a().addEventListener("pointerdown",l,!0)},0),a().addEventListener("focusin",u,!0),T(()=>{window.clearTimeout(n),a().removeEventListener("click",o),a().removeEventListener("pointerdown",l,!0),a().removeEventListener("focusin",u,!0)}))})}var ti=F();function O1(){return ue(ti)}function oo(e){let t,n=O1(),[o,a]=B(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]),i=d=>{r.add(d);let h=n?.registerNestedLayer(d);return()=>{r.delete(d),h?.()}};ei({shouldExcludeElement:d=>t?o.excludedElements?.some(h=>J(h(),d))||[...r].some(h=>J(h,d)):!1,onPointerDownOutside:d=>{!t||xe.isBelowPointerBlockingLayer(t)||!o.bypassTopMostLayerCheck&&!xe.isTopMostLayer(t)||(o.onPointerDownOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.())},onFocusOutside:d=>{o.onFocusOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.()}},()=>t),Wr({ownerDocument:()=>ae(t),onEscapeKeyDown:d=>{!t||!xe.isTopMostLayer(t)||(o.onEscapeKeyDown?.(d),!d.defaultPrevented&&o.onDismiss&&(d.preventDefault(),o.onDismiss()))}}),pe(()=>{if(!t)return;xe.addLayer({node:t,isPointerBlocking:o.disableOutsidePointerEvents,dismiss:o.onDismiss});let d=n?.registerNestedLayer(t);xe.assignPointerEventToLayers(),xe.disableBodyPointerEvents(t),T(()=>{t&&(xe.removeLayer(t),d?.(),xe.assignPointerEventToLayers(),xe.restoreBodyPointerEvents(t))})}),I(Oe([()=>t,()=>o.disableOutsidePointerEvents],([d,h])=>{if(!d)return;let y=xe.find(d);y&&y.isPointerBlocking!==h&&(y.isPointerBlocking=h,xe.assignPointerEventToLayers()),h&&xe.disableBodyPointerEvents(d),T(()=>{xe.restoreBodyPointerEvents(d)})},{defer:!0}));let u={registerNestedLayer:i};return f(ti.Provider,{value:u,get children(){return f(Ne,$({as:"div",ref(d){let h=oe(y=>t=y,o.ref);typeof h=="function"&&h(d)}},a))}})}function R1(e){let[t,n]=P(e.defaultValue?.()),o=O(()=>e.value?.()!==void 0),a=O(()=>o()?e.value?.():t());return[a,i=>{Q(()=>{let s=$t(i,a());return Object.is(s,a())||(o()||n(s),e.onChange?.(s)),s})}]}function ni(e){let[t,n]=R1(e);return[()=>t()??!1,n]}function ao(e={}){let[t,n]=ni({value:()=>Z(e.open),defaultValue:()=>!!Z(e.defaultOpen),onChange:i=>e.onOpenChange?.(i)}),o=()=>{n(!0)},a=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:o,close:a,toggle:()=>{t()?a():o()}}}function qt(e){return t=>(e(t),()=>e(void 0))}function pn(e){let[t,n]=P(),o={},a=e(),r="none",[i,s]=q1(e()?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return I(Oe(i,c=>{let l=ro(o);r=c==="mounted"?l:"none"})),I(Oe(e,c=>{if(a===c)return;let l=ro(o);c?s("MOUNT"):o?.display==="none"?s("UNMOUNT"):s(a&&r!==l?"ANIMATION_OUT":"UNMOUNT"),a=c})),I(Oe(t,c=>{if(c){let l=d=>{let y=ro(o).includes(d.animationName);d.target===c&&y&&s("ANIMATION_END")},u=d=>{d.target===c&&(r=ro(o))};c.addEventListener("animationstart",u),c.addEventListener("animationcancel",l),c.addEventListener("animationend",l),T(()=>{c.removeEventListener("animationstart",u),c.removeEventListener("animationcancel",l),c.removeEventListener("animationend",l)})}else s("ANIMATION_END")})),{isPresent:()=>["mounted","unmountSuspended"].includes(i()),setRef:c=>{c&&(o=getComputedStyle(c)),n(c)}}}function ro(e){return e?.animationName||"none"}function q1(e,t){let n=(i,s)=>t[i][s]??i,[o,a]=P(e);return[o,i=>{a(s=>n(s,i))}]}var V1=Object.defineProperty,Vt=(e,t)=>{for(var n in t)V1(e,n,{get:t[n],enumerable:!0})};var B1={};Vt(B1,{Arrow:()=>no,Content:()=>ta,Portal:()=>na,Root:()=>oa,Tooltip:()=>Y,Trigger:()=>aa});var oi=F();function ea(){let e=ue(oi);if(e===void 0)throw new Error("[kobalte]: `useTooltipContext` must be used within a `Tooltip` component");return e}function ta(e){let t=ea(),n=re({id:t.generateId("content")},e),[o,a]=B(n,["ref","style"]);return I(()=>T(t.registerContentId(a.id))),f(G,{get when(){return t.contentPresence.isPresent()},get children(){return f(Yo.Positioner,{get children(){return f(oo,$({ref(r){let i=oe(s=>{t.setContentRef(s),t.contentPresence.setRef(s)},o.ref);typeof i=="function"&&i(r)},role:"tooltip",disableOutsidePointerEvents:!1,get style(){return{"--kb-tooltip-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative",...o.style}},onFocusOutside:r=>r.preventDefault(),onDismiss:()=>t.hideTooltip(!0)},()=>t.dataset(),a))}})}})}function na(e){let t=ea();return f(G,{get when(){return t.contentPresence.isPresent()},get children(){return f(Lt,e)}})}function E1(e,t,n){let o=e.split("-")[0],a=t.getBoundingClientRect(),r=n.getBoundingClientRect(),i=[],s=a.left+a.width/2,c=a.top+a.height/2;switch(o){case"top":i.push([a.left,c]),i.push([r.left,r.bottom]),i.push([r.left,r.top]),i.push([r.right,r.top]),i.push([r.right,r.bottom]),i.push([a.right,c]);break;case"right":i.push([s,a.top]),i.push([r.left,r.top]),i.push([r.right,r.top]),i.push([r.right,r.bottom]),i.push([r.left,r.bottom]),i.push([s,a.bottom]);break;case"bottom":i.push([a.left,c]),i.push([r.left,r.top]),i.push([r.left,r.bottom]),i.push([r.right,r.bottom]),i.push([r.right,r.top]),i.push([a.right,c]);break;case"left":i.push([s,a.top]),i.push([r.right,r.top]),i.push([r.left,r.top]),i.push([r.left,r.bottom]),i.push([r.right,r.bottom]),i.push([s,a.bottom]);break}return i}var kt={},H1=0,Bt=!1,Ye,yn;function oa(e){let t=`tooltip-${me()}`,n=`${++H1}`,o=re({id:t,openDelay:700,closeDelay:300},e),[a,r]=B(o,["id","open","defaultOpen","onOpenChange","disabled","triggerOnFocusOnly","openDelay","closeDelay","ignoreSafeArea","forceMount"]),i,[s,c]=P(),[l,u]=P(),[d,h]=P(),[y,p]=P(r.placement),m=ao({open:()=>a.open,defaultOpen:()=>a.defaultOpen,onOpenChange:b=>a.onOpenChange?.(b)}),x=pn(()=>a.forceMount||m.isOpen()),v=()=>{kt[n]=L},w=()=>{for(let b in kt)b!==n&&(kt[b](!0),delete kt[b])},L=(b=!1)=>{X||(b||a.closeDelay&&a.closeDelay<=0?(window.clearTimeout(i),i=void 0,m.close()):i||(i=window.setTimeout(()=>{i=void 0,m.close()},a.closeDelay)),window.clearTimeout(Ye),Ye=void 0,Bt&&(window.clearTimeout(yn),yn=window.setTimeout(()=>{delete kt[n],yn=void 0,Bt=!1},a.closeDelay)))},A=()=>{X||(clearTimeout(i),i=void 0,w(),v(),Bt=!0,m.open(),window.clearTimeout(Ye),Ye=void 0,window.clearTimeout(yn),yn=void 0)},q=()=>{X||(w(),v(),!m.isOpen()&&!Ye&&!Bt?Ye=window.setTimeout(()=>{Ye=void 0,Bt=!0,A()},a.openDelay):m.isOpen()||A())},R=(b=!1)=>{X||(!b&&a.openDelay&&a.openDelay>0&&!i?q():A())},j=()=>{X||(window.clearTimeout(Ye),Ye=void 0,Bt=!1)},_=()=>{X||(window.clearTimeout(i),i=void 0)},C=b=>J(l(),b)||J(d(),b),k=b=>{let V=l(),W=d();if(!(!V||!W))return E1(b,V,W)},g=b=>{let V=b.target;if(C(V)){_();return}if(!a.ignoreSafeArea){let W=k(y());if(W&&Eo(Bo(b),W)){_();return}}i||L()};I(()=>{if(X||!m.isOpen())return;let b=ae();b.addEventListener("pointermove",g,!0),T(()=>{b.removeEventListener("pointermove",g,!0)})}),I(()=>{let b=l();if(!b||!m.isOpen())return;let V=de=>{let So=de.target;J(So,b)&&L(!0)},W=nn();W.addEventListener("scroll",V,{capture:!0}),T(()=>{W.removeEventListener("scroll",V,{capture:!0})})}),T(()=>{clearTimeout(i),kt[n]&&delete kt[n]});let N={dataset:O(()=>({"data-expanded":m.isOpen()?"":void 0,"data-closed":m.isOpen()?void 0:""})),isOpen:m.isOpen,isDisabled:()=>a.disabled??!1,triggerOnFocusOnly:()=>a.triggerOnFocusOnly??!1,contentId:s,contentPresence:x,openTooltip:R,hideTooltip:L,cancelOpening:j,generateId:Pt(()=>o.id),registerContentId:qt(c),isTargetOnTooltip:C,setTriggerRef:u,setContentRef:h};return f(oi.Provider,{value:N,get children(){return f(Yo,$({anchorRef:l,contentRef:d,onCurrentPlacementChange:p},r))}})}function aa(e){let t,n=ea(),[o,a]=B(e,["ref","onPointerEnter","onPointerLeave","onPointerDown","onClick","onFocus","onBlur"]),r=!1,i=!1,s=!1,c=()=>{r=!1},l=()=>{!n.isOpen()&&(i||s)&&n.openTooltip(s)},u=v=>{n.isOpen()&&!i&&!s&&n.hideTooltip(v)},d=v=>{ke(v,o.onPointerEnter),!(v.pointerType==="touch"||n.triggerOnFocusOnly()||n.isDisabled()||v.defaultPrevented)&&(i=!0,l())},h=v=>{ke(v,o.onPointerLeave),v.pointerType!=="touch"&&(i=!1,s=!1,n.isOpen()?u():n.cancelOpening())},y=v=>{ke(v,o.onPointerDown),r=!0,ae(t).addEventListener("pointerup",c,{once:!0})},p=v=>{ke(v,o.onClick),i=!1,s=!1,u(!0)},m=v=>{ke(v,o.onFocus),!(n.isDisabled()||v.defaultPrevented||r)&&(s=!0,l())},x=v=>{ke(v,o.onBlur);let w=v.relatedTarget;n.isTargetOnTooltip(w)||(i=!1,s=!1,u(!0))};return T(()=>{X||ae(t).removeEventListener("pointerup",c)}),f(Ne,$({as:"button",ref(v){let w=oe(L=>{n.setTriggerRef(L),t=L},o.ref);typeof w=="function"&&w(v)},get"aria-describedby"(){return O(()=>!!n.isOpen())()?n.contentId():void 0},onPointerEnter:d,onPointerLeave:h,onPointerDown:y,onClick:p,onFocus:m,onBlur:x},()=>n.dataset(),a))}var Y=Object.assign(oa,{Arrow:no,Content:ta,Portal:na,Trigger:aa});function z1(e){return Object.keys(e).reduce((n,o)=>{let a=e[o];return n[o]=Object.assign({},a),ii(a.value)&&!G1(a.value)&&!Array.isArray(a.value)&&(n[o].value=Object.assign({},a.value)),Array.isArray(a.value)&&(n[o].value=a.value.slice(0)),n},{})}function j1(e){return e?Object.keys(e).reduce((n,o)=>{let a=e[o];return n[o]=ii(a)&&"value"in a?a:{value:a},n[o].attribute||(n[o].attribute=K1(o)),n[o].parse="parse"in n[o]?n[o].parse:typeof n[o].value!="string",n},{}):{}}function U1(e){return Object.keys(e).reduce((n,o)=>(n[o]=e[o].value,n),{})}function _1(e,t){let n=z1(t);return Object.keys(t).forEach(a=>{let r=n[a],i=e.getAttribute(r.attribute),s=e[a];i&&(r.value=r.parse?ri(i):i),s!=null&&(r.value=Array.isArray(s)?s.slice(0):s),r.reflect&&ai(e,r.attribute,r.value),Object.defineProperty(e,a,{get(){return r.value},set(c){let l=r.value;r.value=c,r.reflect&&ai(this,r.attribute,r.value);for(let u=0,d=this.__propertyChangedCallbacks.length;udelete e.__updating[t])}function K1(e){return e.replace(/\.?([A-Z]+)/g,(t,n)=>"-"+n.toLowerCase()).replace("_","-").replace(/^-/,"")}function ii(e){return e!=null&&(typeof e=="object"||typeof e=="function")}function G1(e){return Object.prototype.toString.call(e)==="[object Function]"}function W1(e){return typeof e=="function"&&e.toString().indexOf("class")===0}var ra;function Z1(e,t){let n=Object.keys(t);return class extends e{static get observedAttributes(){return n.map(a=>t[a].attribute)}constructor(){super(),this.__initialized=!1,this.__released=!1,this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props={}}connectedCallback(){if(this.__initialized)return;this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props=_1(this,t);let a=U1(this.props),r=this.Component,i=ra;try{ra=this,this.__initialized=!0,W1(r)?new r(a,{element:this}):r(a,{element:this})}finally{ra=i}}async disconnectedCallback(){if(await Promise.resolve(),this.isConnected)return;this.__propertyChangedCallbacks.length=0;let a=null;for(;a=this.__releaseCallbacks.pop();)a(this);delete this.__initialized,this.__released=!0}attributeChangedCallback(a,r,i){if(this.__initialized&&!this.__updating[a]&&(a=this.lookupProp(a),a in t)){if(i==null&&!this[a])return;this[a]=t[a].parse?ri(i):i}}lookupProp(a){if(t)return n.find(r=>a===r||a===t[r].attribute)}get renderRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}addReleaseCallback(a){this.__releaseCallbacks.push(a)}addPropertyChangedCallback(a){this.__propertyChangedCallbacks.push(a)}}}var z0=Symbol("element-context");function si(e,t={},n={}){let{BaseElement:o=HTMLElement,extension:a}=n;return r=>{if(!e)throw new Error("tag is required to register a Component");let i=customElements.get(e);return i?(i.prototype.Component=r,i):(i=Z1(o,j1(t)),i.prototype.Component=r,i.prototype.registeredTag=e,customElements.define(e,i,a),i)}}function X1(e){let t=Object.keys(e),n={};for(let o=0;oi)}})}return n}function Y1(e){if(e.assignedSlot&&e.assignedSlot._$owner)return e.assignedSlot._$owner;let t=e.parentNode;for(;t&&!t._$owner&&!(t.assignedSlot&&t.assignedSlot._$owner);)t=t.parentNode;return t&&t.assignedSlot?t.assignedSlot._$owner:e._$owner}function J1(e){return(t,n)=>{let{element:o}=n;return Fe(a=>{let r=X1(t);o.addPropertyChangedCallback((s,c)=>r[s]=c),o.addReleaseCallback(()=>{o.renderRoot.textContent="",a()});let i=e(r,n);return D(o.renderRoot,i)},Y1(o))}}function ci(e,t,n){return arguments.length===2&&(n=t,t={}),si(e,t)(J1(n))}var Q1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},Et=Q1,el=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),tl=(...e)=>e.filter((t,n,o)=>!!t&&o.indexOf(t)===n).join(" "),nl=z(""),ol=e=>{let[t,n]=B(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var o=nl();return ie(o,$(Et,{get width(){return t.size??Et.width},get height(){return t.size??Et.height},get stroke(){return t.color??Et.stroke},get"stroke-width"(){return O(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Et["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Et["stroke-width"])},get class(){return tl("lucide","lucide-icon",t.name!=null?`lucide-${el(t?.name)}`:void 0,t.class!=null?t.class:"")}},n),!0,!0),D(o,f(Me,{get each(){return t.iconNode},children:([a,r])=>f(tt,$({component:a},r))})),o})()},Be=ol;var al=[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]],rl=e=>f(Be,$(e,{name:"Home",iconNode:al})),li=rl;var il=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],sl=e=>f(Be,$(e,{name:"LogIn",iconNode:il})),ia=sl,cl=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],ll=e=>f(Be,$(e,{name:"LogOut",iconNode:cl})),di=ll;var dl=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],ul=e=>f(Be,$(e,{name:"Moon",iconNode:dl})),ui=ul;var hl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],pl=e=>f(Be,$(e,{name:"Search",iconNode:hl})),hi=pl;var yl=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fl=e=>f(Be,$(e,{name:"Sun",iconNode:yl})),pi=fl;var kl=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],ml=e=>f(Be,$(e,{name:"Swords",iconNode:kl})),sa=ml;var gl=[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]],vl=e=>f(Be,$(e,{name:"Trophy",iconNode:gl})),yi=vl;var Ml=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],wl=e=>f(Be,$(e,{name:"User",iconNode:Ml})),fi=wl;var xl=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Cl=e=>f(Be,$(e,{name:"Users",iconNode:xl})),ki=Cl;var bl=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Sl=e=>f(Be,$(e,{name:"X",iconNode:bl})),mi=Sl;var io=Symbol("store-raw"),Ht=Symbol("store-node"),Je=Symbol("store-has"),gi=Symbol("store-self");function vi(e){let t=e[fe];if(!t&&(Object.defineProperty(e,fe,{value:t=new Proxy(e,$l)}),!Array.isArray(e))){let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let a=0,r=n.length;ae[fe][t]),n}function Mi(e){Rn()&&kn(so(e,Ht),gi)()}function Nl(e){return Mi(e),Reflect.ownKeys(e)}var $l={get(e,t,n){if(t===io)return e;if(t===fe)return n;if(t===Qt)return Mi(e),n;let o=so(e,Ht),a=o[t],r=a?a():e[t];if(t===Ht||t===Je||t==="__proto__")return r;if(!a){let i=Object.getOwnPropertyDescriptor(e,t);Rn()&&(typeof r!="function"||e.hasOwnProperty(t))&&!(i&&i.get)&&(r=kn(o,t,r)())}return zt(r)?vi(r):r},has(e,t){return t===io||t===fe||t===Qt||t===Ht||t===Je||t==="__proto__"?!0:(Rn()&&kn(so(e,Je),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Nl,getOwnPropertyDescriptor:Ll};function Ut(e,t,n,o=!1){if(!o&&e[t]===n)return;let a=e[t],r=e.length;n===void 0?(delete e[t],e[Je]&&e[Je][t]&&a!==void 0&&e[Je][t].$()):(e[t]=n,e[Je]&&e[Je][t]&&a===void 0&&e[Je][t].$());let i=so(e,Ht),s;if((s=kn(i,t,a))&&s.$(()=>n),Array.isArray(e)&&e.length!==r){for(let c=e.length;c1){o=t.shift();let i=typeof o,s=Array.isArray(e);if(Array.isArray(o)){for(let c=0;c1){fn(e[o],t,[o].concat(n));return}a=e[o],n=[o].concat(n)}let r=t[0];typeof r=="function"&&(r=r(a,n),r===a)||o===void 0&&r==null||(r=jt(r),o===void 0||zt(a)&&zt(r)&&!Array.isArray(r)?wi(a,r):Ut(e,o,r))}function _t(...[e,t]){let n=jt(e||{}),o=Array.isArray(n),a=vi(n);function r(...i){Fo(()=>{o&&i.length===1?Il(n,i[0]):fn(n,i)})}return[a,r]}var J0=Symbol("store-root");var co=new WeakMap,xi={get(e,t){if(t===io)return e;let n=e[t],o;return zt(n)?co.get(n)||(co.set(n,o=new Proxy(n,xi)),o):n},set(e,t,n){return Ut(e,t,jt(n)),!0},deleteProperty(e,t){return Ut(e,t,void 0,!0),!0}};function mn(e){return t=>{if(zt(t)){let n;(n=co.get(t))||co.set(t,n=new Proxy(t,xi)),e(n)}return t}}var Pl=e=>typeof e=="function",po=(e,t)=>Pl(e)?e(t):e,le;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(le||(le={}));var[mt,ot]=_t({toasts:[],pausedAt:void 0}),Dl=()=>{let{pausedAt:e,toasts:t}=mt;if(e)return;let n=Date.now();return t.map(a=>{if(a.duration===1/0)return;let r=(a.duration||0)+a.pauseDuration-(n-a.createdAt);if(r<=0){a.visible&&Ee({type:le.DISMISS_TOAST,toastId:a.id});return}return setTimeout(()=>{Ee({type:le.DISMISS_TOAST,toastId:a.id})},r)})},gn=new Map,Ci=(e,t)=>{if(gn.has(e))return;let n=setTimeout(()=>{gn.delete(e),Ee({type:le.REMOVE_TOAST,toastId:e})},t);gn.set(e,n)},Al=e=>{let t=gn.get(e);gn.delete(e),t&&clearTimeout(t)},Ee=e=>{switch(e.type){case le.ADD_TOAST:ot("toasts",a=>{let r=a;return[e.toast,...r]});break;case le.DISMISS_TOAST:let{toastId:t}=e,n=mt.toasts;if(t){let a=n.find(r=>r.id===t);a&&Ci(t,a.unmountDelay),ot("toasts",r=>r.id===t,mn(r=>r.visible=!1))}else n.forEach(a=>{Ci(a.id,a.unmountDelay)}),ot("toasts",a=>a.id!==void 0,mn(a=>a.visible=!1));break;case le.REMOVE_TOAST:if(!e.toastId){ot("toasts",[]);break}ot("toasts",a=>a.filter(i=>i.id!==e.toastId));break;case le.UPDATE_TOAST:e.toast.id&&Al(e.toast.id),ot("toasts",a=>a.id===e.toast.id,a=>({...a,...e.toast}));break;case le.UPSERT_TOAST:mt.toasts.find(a=>a.id===e.toast.id)?Ee({type:le.UPDATE_TOAST,toast:e.toast}):Ee({type:le.ADD_TOAST,toast:e.toast});break;case le.START_PAUSE:ot(mn(a=>{a.pausedAt=Date.now(),a.toasts.forEach(r=>{r.paused=!0})}));break;case le.END_PAUSE:let o=e.time-(mt.pausedAt||0);ot(mn(a=>{a.pausedAt=void 0,a.toasts.forEach(r=>{r.pauseDuration+=o,r.paused=!1})}));break}},Tl={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Gt={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},bi={position:"top-right",toastOptions:Gt,gutter:8,containerStyle:{},containerClassName:""},lo="16px",Fl={position:"fixed","z-index":9999,top:lo,bottom:lo,left:lo,right:lo,"pointer-events":"none"},Ol=(()=>{let e=0;return()=>String(++e)})(),Rl=e=>{jl(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},ql=(e,t)=>{let o=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},a=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...o,...a}},Vl=(e,t)=>{let n=e.getBoundingClientRect();n.height!==t.height&&Ee({type:le.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},Bl=(e,t)=>{let{toasts:n}=mt,o=Kt().gutter||bi.gutter||8,a=n.filter(c=>(c.position||t)===t&&c.height),r=a.findIndex(c=>c.id===e.id),i=a.filter((c,l)=>lc+o+(l.height||0),0)},El=(e,t)=>(e.position||t).includes("top")?1:-1,Hl={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},zl={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},uo={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},yo=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Kt,jl]=P(bi),Ul=(e,t="blank",n)=>({...Gt,...Kt().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Ol(),paused:!1,style:{...Gt.style,...Kt().toastOptions?.style,...n.style},duration:n.duration||Kt().toastOptions?.duration||Tl[t],position:n.position||Kt().toastOptions?.position||Kt().position||Gt.position}),vn=e=>(t,n={})=>Fe(()=>{let o=mt.toasts.find(r=>r.id===n.id),a=Ul(t,e,{...o,duration:void 0,...n});return Ee({type:le.UPSERT_TOAST,toast:a}),a.id}),Ce=(e,t)=>vn("blank")(e,t);Q(()=>Ce);Ce.error=vn("error");Ce.success=vn("success");Ce.loading=vn("loading");Ce.custom=vn("custom");Ce.dismiss=e=>{Ee({type:le.DISMISS_TOAST,toastId:e})};Ce.promise=(e,t,n)=>{let o=Ce.loading(t.loading,{...n});return e.then(a=>(Ce.success(po(t.success,a),{id:o,...n}),a)).catch(a=>{Ce.error(po(t.error,a),{id:o,...n})}),e};Ce.remove=e=>{Ee({type:le.REMOVE_TOAST,toastId:e})};var _l=z("
",4),Si=e=>(I(()=>{Rl(e)}),I(()=>{let t=Dl();T(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{let t=_l.cloneNode(!0);return t.firstChild,D(t,f(Me,{get each(){return mt.toasts},children:n=>f(Zl,{toast:n})}),null),U(n=>{let o={...Fl,...e.containerStyle},a=e.containerClassName;return n._v$=he(t,o,n._v$),a!==n._v$2&&en(t,n._v$2=a),n},{_v$:void 0,_v$2:void 0}),t})()),ho=z("
",2),Kl=z("
",4),Gl=e=>{let t;return I(()=>{if(!t)return;let n=El(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{let n=Kl.cloneNode(!0),o=n.firstChild,a=t;return typeof a=="function"?a(n):t=n,D(n,f(Hn,{get children(){return[f(lt,{get when(){return e.toast.icon},get children(){let r=ho.cloneNode(!0);return D(r,()=>e.toast.icon),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="loading"},get children(){let r=ho.cloneNode(!0);return D(r,f(od,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="success"},get children(){let r=ho.cloneNode(!0);return D(r,f(Ql,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="error"},get children(){let r=ho.cloneNode(!0);return D(r,f(td,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}})]}}),o),ie(o,()=>e.toast.ariaProps,!1,!0),D(o,()=>po(e.toast.message,e.toast)),U(r=>{let i=e.toast.className,s={...Hl,...e.toast.style},c=zl;return i!==r._v$&&en(n,r._v$=i),r._v$2=he(n,s,r._v$2),r._v$3=he(o,c,r._v$3),r},{_v$:void 0,_v$2:void 0,_v$3:void 0}),n})()},Wl=z("
",2),Zl=e=>{let t=()=>{let a=e.toast.position||Gt.position,r=Bl(e.toast,a);return ql(a,r)},n=O(()=>t()),o;return pe(()=>{o&&Vl(o,e.toast)}),(()=>{let a=Wl.cloneNode(!0);a.addEventListener("mouseleave",()=>Ee({type:le.END_PAUSE,time:Date.now()})),a.addEventListener("mouseenter",()=>Ee({type:le.START_PAUSE,time:Date.now()}));let r=o;return typeof r=="function"?r(a):o=a,D(a,(()=>{let i=O(()=>e.toast.type==="custom",!0);return()=>i()?po(e.toast.message,e.toast):f(Gl,{get toast(){return e.toast},get position(){return e.toast.position||Gt.position}})})()),U(i=>{let s=n(),c=e.toast.visible?"sldt-active":"";return i._v$=he(a,s,i._v$),c!==i._v$2&&en(a,i._v$2=c),i},{_v$:void 0,_v$2:void 0}),a})()},Xl=z('',8,!0),Yl=z('',8,!0),Li=e=>{let t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{let n=Xl.cloneNode(!0),o=n.firstChild,a=o.nextSibling;return ie(o,t,!0,!1),ie(a,t,!0,!1),U(()=>ee(n,"fill",e.fill)),n})()},Ni=e=>{let t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...yo("0.0 0.0 0.2 1")};return(()=>{let n=Yl.cloneNode(!0),o=n.firstChild,a=o.nextSibling;return ie(o,t,!0,!1),ie(a,t,!0,!1),U(()=>ee(n,"fill",e.fill)),n})()},Jl=z('',6),Ql=e=>{let t=e.primary||"#34C759";return(()=>{let n=Jl.cloneNode(!0),o=n.firstChild,a=o.firstChild;return n.style.setProperty("overflow","visible"),D(n,f(Li,{fill:t}),o),D(n,f(Ni,{fill:t,begin:"350ms"}),o),ie(a,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),U(()=>ee(o,"stroke",e.secondary||"#FCFCFC")),n})()},ed=z('',10),td=e=>{let t=e.primary||"#FF3B30";return(()=>{let n=ed.cloneNode(!0),o=n.firstChild,a=o.firstChild,r=o.nextSibling,i=r.firstChild;return n.style.setProperty("overflow","visible"),D(n,f(Li,{fill:t}),o),D(n,f(Ni,{fill:t}),o),ie(a,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),ie(i,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),U(s=>{let c=e.secondary||"#FFFFFF",l=e.secondary||"#FFFFFF";return c!==s._v$&&ee(o,"stroke",s._v$=c),l!==s._v$2&&ee(r,"fill",s._v$2=l),s},{_v$:void 0,_v$2:void 0}),n})()},nd=z('',8),od=e=>(()=>{let t=nd.cloneNode(!0),n=t.firstChild,o=n.nextSibling;return t.style.setProperty("overflow","visible"),U(a=>{let r=e.primary||"#E5E7EB",i=e.secondary||"#4b5563";return r!==a._v$&&ee(n,"stroke",a._v$=r),i!==a._v$2&&ee(o,"stroke",a._v$2=i),a},{_v$:void 0,_v$2:void 0}),t})(),ca=Ce;var at=class{constructor(t){this.value=t}valueOf(){return this.value}},te=class extends at{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}},be=class extends at{constructor(t,n={}){super(t),this.opts=n}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(n){return t.reportError(n),this.value.toString(10)}}},je=class extends at{constructor(t,n={}){super(t),this.opts=n}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(n){return t.reportError(n),new Date(this.value).toISOString()}}};var $i=100,ad="\u2068",rd="\u2069";function id(e,t,n){if(n===t||n instanceof be&&t instanceof be&&n.value===t.value)return!0;if(t instanceof be&&typeof n=="string"){let o=e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value);if(n===o)return!0}return!1}function Ii(e,t,n){return t[n]?Wt(e,t[n].value):(e.reportError(new RangeError("No default")),new te)}function la(e,t){let n=[],o=Object.create(null);for(let a of t)a.type==="narg"?o[a.name]=Mn(e,a.value):n.push(Mn(e,a));return{positional:n,named:o}}function Mn(e,t){switch(t.type){case"str":return t.value;case"num":return new be(t.value,{minimumFractionDigits:t.precision});case"var":return sd(e,t);case"mesg":return cd(e,t);case"term":return ld(e,t);case"func":return dd(e,t);case"select":return ud(e,t);default:return new te}}function sd(e,{name:t}){let n;if(e.params)if(Object.prototype.hasOwnProperty.call(e.params,t))n=e.params[t];else return new te(`$${t}`);else if(e.args&&Object.prototype.hasOwnProperty.call(e.args,t))n=e.args[t];else return e.reportError(new ReferenceError(`Unknown variable: $${t}`)),new te(`$${t}`);if(n instanceof at)return n;switch(typeof n){case"string":return n;case"number":return new be(n);case"object":if(n instanceof Date)return new je(n.getTime());default:return e.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof n}`)),new te(`$${t}`)}}function cd(e,{name:t,attr:n}){let o=e.bundle._messages.get(t);if(!o)return e.reportError(new ReferenceError(`Unknown message: ${t}`)),new te(t);if(n){let a=o.attributes[n];return a?Wt(e,a):(e.reportError(new ReferenceError(`Unknown attribute: ${n}`)),new te(`${t}.${n}`))}return o.value?Wt(e,o.value):(e.reportError(new ReferenceError(`No value: ${t}`)),new te(t))}function ld(e,{name:t,attr:n,args:o}){let a=`-${t}`,r=e.bundle._terms.get(a);if(!r)return e.reportError(new ReferenceError(`Unknown term: ${a}`)),new te(a);if(n){let s=r.attributes[n];if(s){e.params=la(e,o).named;let c=Wt(e,s);return e.params=null,c}return e.reportError(new ReferenceError(`Unknown attribute: ${n}`)),new te(`${a}.${n}`)}e.params=la(e,o).named;let i=Wt(e,r.value);return e.params=null,i}function dd(e,{name:t,args:n}){let o=e.bundle._functions[t];if(!o)return e.reportError(new ReferenceError(`Unknown function: ${t}()`)),new te(`${t}()`);if(typeof o!="function")return e.reportError(new TypeError(`Function ${t}() is not callable`)),new te(`${t}()`);try{let a=la(e,n);return o(a.positional,a.named)}catch(a){return e.reportError(a),new te(`${t}()`)}}function ud(e,{selector:t,variants:n,star:o}){let a=Mn(e,t);if(a instanceof te)return Ii(e,n,o);for(let r of n){let i=Mn(e,r.key);if(id(e,a,i))return Wt(e,r.value)}return Ii(e,n,o)}function da(e,t){if(e.dirty.has(t))return e.reportError(new RangeError("Cyclic reference")),new te;e.dirty.add(t);let n=[],o=e.bundle._useIsolating&&t.length>1;for(let a of t){if(typeof a=="string"){n.push(e.bundle._transform(a));continue}if(e.placeables++,e.placeables>$i)throw e.dirty.delete(t),new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is ${$i}`);o&&n.push(ad),n.push(Mn(e,a).toString(e)),o&&n.push(rd)}return e.dirty.delete(t),n.join("")}function Wt(e,t){return typeof t=="string"?e.bundle._transform(t):da(e,t)}var fo=class{constructor(t,n,o){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=n,this.args=o}reportError(t){if(!this.errors||!(t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,n){let o=this.bundle._intls.get(t);o||(o={},this.bundle._intls.set(t,o));let a=JSON.stringify(n);return o[a]||(o[a]=new t(this.bundle.locales,n)),o[a]}};function ko(e,t){let n=Object.create(null);for(let[o,a]of Object.entries(e))t.includes(o)&&(n[o]=a.valueOf());return n}var Pi=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Ai(e,t){let n=e[0];if(n instanceof te)return new te(`NUMBER(${n.valueOf()})`);if(n instanceof be)return new be(n.valueOf(),{...n.opts,...ko(t,Pi)});if(n instanceof je)return new be(n.valueOf(),{...ko(t,Pi)});throw new TypeError("Invalid argument to NUMBER")}var Di=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ti(e,t){let n=e[0];if(n instanceof te)return new te(`DATETIME(${n.valueOf()})`);if(n instanceof je)return new je(n.valueOf(),{...n.opts,...ko(t,Di)});if(n instanceof be)return new je(n.valueOf(),{...ko(t,Di)});throw new TypeError("Invalid argument to DATETIME")}var Fi=new Map;function Oi(e){let t=Array.isArray(e)?e.join(" "):e,n=Fi.get(t);return n===void 0&&(n=new Map,Fi.set(t,n)),n}var wn=class{constructor(t,{functions:n,useIsolating:o=!0,transform:a=r=>r}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Ai,DATETIME:Ti,...n},this._useIsolating=o,this._transform=a,this._intls=Oi(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:n=!1}={}){let o=[];for(let a=0;a\s*/y,bd=/\s*:\s*/y,Sd=/\s*,?\s*/y,Ld=/\s+/y,xn=class{constructor(t){this.body=[],ua.lastIndex=0;let n=0;for(;;){let C=ua.exec(t);if(C===null)break;n=ua.lastIndex;try{this.body.push(c(C[1]))}catch(k){if(k instanceof SyntaxError)continue;throw k}}function o(C){return C.lastIndex=n,C.test(t)}function a(C,k){if(t[n]===C)return n++,!0;if(k)throw new k(`Expected ${C}`);return!1}function r(C,k){if(o(C))return n=C.lastIndex,!0;if(k)throw new k(`Expected ${C.toString()}`);return!1}function i(C){C.lastIndex=n;let k=C.exec(t);if(k===null)throw new SyntaxError(`Expected ${C.toString()}`);return n=C.lastIndex,k}function s(C){return i(C)[1]}function c(C){let k=u(),g=l();if(k===null&&Object.keys(g).length===0)throw new SyntaxError("Expected message value or attributes");return{id:C,value:k,attributes:g}}function l(){let C=Object.create(null);for(;o(Ri);){let k=s(Ri),g=u();if(g===null)throw new SyntaxError("Expected attribute value");C[k]=g}return C}function u(){let C;if(o(mo)&&(C=s(mo)),t[n]==="{"||t[n]==="}")return d(C?[C]:[],1/0);let k=R();return k?C?d([C,k],k.length):(k.value=j(k.value,kd),d([k],k.length)):C?j(C,Ei):null}function d(C=[],k){for(;;){if(o(mo)){C.push(s(mo));continue}if(t[n]==="{"){C.push(h());continue}if(t[n]==="}")throw new SyntaxError("Unbalanced closing brace");let b=R();if(b){C.push(b),k=Math.min(k,b.length);continue}break}let g=C.length-1,M=C[g];typeof M=="string"&&(C[g]=j(M,Ei));let N=[];for(let b of C)b instanceof go&&(b=b.value.slice(0,b.value.length-k)),b&&N.push(b);return N}function h(){r(vd,SyntaxError);let C=y();if(r(Hi))return C;if(r(Cd)){let k=x();return r(Hi,SyntaxError),{type:"select",selector:C,...k}}throw new SyntaxError("Unclosed placeable")}function y(){if(t[n]==="{")return h();if(o(qi)){let[,C,k,g=null]=i(qi);if(C==="$")return{type:"var",name:k};if(r(xd)){let M=p();if(C==="-")return{type:"term",name:k,attr:g,args:M};if(yd.test(k))return{type:"func",name:k,args:M};throw new SyntaxError("Function names must be all upper-case")}return C==="-"?{type:"term",name:k,attr:g,args:[]}:{type:"mesg",name:k,attr:g}}return w()}function p(){let C=[];for(;;){switch(t[n]){case")":return n++,C;case void 0:throw new SyntaxError("Unclosed argument list")}C.push(m()),r(Sd)}}function m(){let C=y();return C.type!=="mesg"?C:r(bd)?{type:"narg",name:C.name,value:w()}:C}function x(){let C=[],k=0,g;for(;o(hd);){a("*")&&(g=k);let M=v(),N=u();if(N===null)throw new SyntaxError("Expected variant value");C[k++]={key:M,value:N}}if(k===0)return null;if(g===void 0)throw new SyntaxError("Expected default variant");return{variants:C,star:g}}function v(){r(Md,SyntaxError);let C;return o(ha)?C=L():C={type:"str",value:s(pd)},r(wd,SyntaxError),C}function w(){if(o(ha))return L();if(t[n]==='"')return A();throw new SyntaxError("Invalid expression")}function L(){let[,C,k=""]=i(ha),g=k.length;return{type:"num",value:parseFloat(C),precision:g}}function A(){a('"',SyntaxError);let C="";for(;;){if(C+=s(fd),t[n]==="\\"){C+=q();continue}if(a('"'))return{type:"str",value:C};throw new SyntaxError("Unclosed string literal")}}function q(){if(o(Vi))return s(Vi);if(o(Bi)){let[,C,k]=i(Bi),g=parseInt(C||k,16);return g<=55295||57344<=g?String.fromCodePoint(g):"\uFFFD"}throw new SyntaxError("Unknown escape sequence")}function R(){let C=n;switch(r(Ld),t[n]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return _(t.slice(C,n))}return t[n-1]===" "?_(t.slice(C,n)):!1}function j(C,k){return C.replace(k,"")}function _(C){let k=C.replace(md,` -`),g=gd.exec(C)[1].length;return new go(k,g)}}},go=class{constructor(t,n){this.value=t,this.length=n}};var Nd="([a-z]{2,3}|\\*)",$d="(?:-([a-z]{4}|\\*))",Id="(?:-([a-z]{2}|\\*))",Pd="(?:-(([0-9][a-z0-9]{3}|[a-z0-9]{5,8})|\\*))",Dd=new RegExp(`^${Nd}${$d}?${Id}?${Pd}?$`,"i"),rt=class{constructor(t){let n=Dd.exec(t.replace(/_/g,"-"));if(!n){this.isWellFormed=!1;return}let[,o,a,r,i]=n;o&&(this.language=o.toLowerCase()),a&&(this.script=a[0].toUpperCase()+a.slice(1)),r&&(this.region=r.toUpperCase()),this.variant=i,this.isWellFormed=!0}isEqual(t){return this.language===t.language&&this.script===t.script&&this.region===t.region&&this.variant===t.variant}matches(t,n=!1,o=!1){return(this.language===t.language||n&&this.language===void 0||o&&t.language===void 0)&&(this.script===t.script||n&&this.script===void 0||o&&t.script===void 0)&&(this.region===t.region||n&&this.region===void 0||o&&t.region===void 0)&&(this.variant===t.variant||n&&this.variant===void 0||o&&t.variant===void 0)}toString(){return[this.language,this.script,this.region,this.variant].filter(t=>t!==void 0).join("-")}clearVariants(){this.variant=void 0}clearRegion(){this.region=void 0}addLikelySubtags(){let t=Td(this.toString().toLowerCase());return t?(this.language=t.language,this.script=t.script,this.region=t.region,this.variant=t.variant,!0):!1}},zi={ar:"ar-arab-eg","az-arab":"az-arab-ir","az-ir":"az-arab-ir",be:"be-cyrl-by",da:"da-latn-dk",el:"el-grek-gr",en:"en-latn-us",fa:"fa-arab-ir",ja:"ja-jpan-jp",ko:"ko-kore-kr",pt:"pt-latn-br",sr:"sr-cyrl-rs","sr-ru":"sr-latn-ru",sv:"sv-latn-se",ta:"ta-taml-in",uk:"uk-cyrl-ua",zh:"zh-hans-cn","zh-hant":"zh-hant-tw","zh-hk":"zh-hant-hk","zh-mo":"zh-hant-mo","zh-tw":"zh-hant-tw","zh-gb":"zh-hant-gb","zh-us":"zh-hant-us"},Ad=["az","bg","cs","de","es","fi","fr","hu","it","lt","lv","nl","pl","ro","ru"];function Td(e){if(Object.prototype.hasOwnProperty.call(zi,e))return new rt(zi[e]);let t=new rt(e);return t.language&&Ad.includes(t.language)?(t.region=t.language.toUpperCase(),t):null}function pa(e,t,n){let o=new Set,a=new Map;for(let r of t)new rt(r).isWellFormed&&a.set(r,new rt(r));e:for(let r of e){let i=r.toLowerCase(),s=new rt(i);if(s.language!==void 0){for(let c of a.keys())if(i===c.toLowerCase()){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}if(s.addLikelySubtags()){for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}s.clearVariants();for(let[c,l]of a.entries())if(l.matches(s,!0,!0)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}if(s.clearRegion(),s.addLikelySubtags()){for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}s.clearRegion();for(let[c,l]of a.entries())if(l.matches(s,!0,!0)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}}return Array.from(o)}function ya(e,t,{strategy:n="filtering",defaultLocale:o}={}){let a=pa(Array.from(e??[]).map(String),Array.from(t??[]).map(String),n);if(n==="lookup"){if(o===void 0)throw new Error("defaultLocale cannot be undefined for strategy `lookup`");a.length===0&&a.push(o)}else o&&!a.includes(o)&&a.push(o);return a}var ji=1,Fd=.9,Od=.8,Rd=.17,fa=.1,ka=.999,qd=.9999,Vd=.99,Bd=/[\\\/_+.#"@\[\(\{&]/,Ed=/[\\\/_+.#"@\[\(\{&]/g,Hd=/[\s-]/,_i=/[\s-]/g;function ma(e,t,n,o,a,r,i){if(r===t.length)return a===e.length?ji:Vd;var s=`${a},${r}`;if(i[s]!==void 0)return i[s];for(var c=o.charAt(r),l=n.indexOf(c,a),u=0,d,h,y,p;l>=0;)d=ma(e,t,n,o,l+1,r+1,i),d>u&&(l===a?d*=ji:Bd.test(e.charAt(l-1))?(d*=Od,y=e.slice(a,l-1).match(Ed),y&&a>0&&(d*=Math.pow(ka,y.length))):Hd.test(e.charAt(l-1))?(d*=Fd,p=e.slice(a,l-1).match(_i),p&&a>0&&(d*=Math.pow(ka,p.length))):(d*=Rd,a>0&&(d*=Math.pow(ka,l-a))),e.charAt(l)!==t.charAt(r)&&(d*=qd)),(dd&&(d=h*fa)),d>u&&(u=d),l=n.indexOf(c,l+1);return i[s]=u,u}function Ui(e){return e.toLowerCase().replace(_i," ")}function Ki(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ma(e,t,Ui(e),Ui(t),0,0,{})}var Se=e=>typeof e=="function"?e():e;var vo=new Map,zd=e=>{I(()=>{let t=Se(e.style)??{},n=Se(e.properties)??[],o={};for(let r in t)o[r]=e.element.style[r];let a=vo.get(e.key);a?a.activeCount++:vo.set(e.key,{activeCount:1,originalStyles:o,properties:n.map(r=>r.key)}),Object.assign(e.element.style,e.style);for(let r of n)e.element.style.setProperty(r.key,r.value);T(()=>{let r=vo.get(e.key);if(r){if(r.activeCount!==1){r.activeCount--;return}vo.delete(e.key);for(let[i,s]of Object.entries(r.originalStyles))e.element.style[i]=s;for(let i of r.properties)e.element.style.removeProperty(i);e.element.style.length===0&&e.element.removeAttribute("style"),e.cleanup?.()}})})},Mo=zd;var jd=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Ud=(e,t)=>{let n=getComputedStyle(e),o=t==="x"?n.overflowX:n.overflowY;return o==="auto"||o==="scroll"||e.tagName==="HTML"&&o==="visible"},Gi=(e,t,n)=>{let o=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1,a=e,r=0,i=0,s=!1;do{let[c,l,u]=jd(a,t),d=u-c-o*l;(l!==0||d!==0)&&Ud(a,t)&&(r+=d,i+=l),a===(n??document.documentElement)?s=!0:a=a._$host??a.parentElement}while(a&&!s);return[r,i]};var[Wi,Zi]=P([]),_d=e=>Wi().indexOf(e)===Wi().length-1,Kd=e=>{let t=$({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",allowPinchZoom:!1},e),n=me(),o=[0,0],a=null,r=null;I(()=>{Se(t.enabled)&&(Zi(l=>[...l,n]),T(()=>{Zi(l=>l.filter(u=>u!==n))}))}),I(()=>{if(!Se(t.enabled)||!Se(t.hideScrollbar))return;let{body:l}=document,u=window.innerWidth-l.offsetWidth;if(Mo({key:"prevent-scroll-overflow",element:l,style:{overflow:"hidden"}}),Se(t.preventScrollbarShift)){let d={},h=[];u>0&&(Se(t.preventScrollbarShiftMode)==="padding"?d.paddingRight=`calc(${window.getComputedStyle(l).paddingRight} + ${u}px)`:d.marginRight=`calc(${window.getComputedStyle(l).marginRight} + ${u}px)`,h.push({key:"--scrollbar-width",value:`${u}px`}));let y=window.scrollY,p=window.scrollX;Mo({key:"prevent-scroll-scrollbar",element:l,style:d,properties:h,cleanup:()=>{u>0&&window.scrollTo(p,y)}})}}),I(()=>{!_d(n)||!Se(t.enabled)||(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",i,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),T(()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",i),document.removeEventListener("touchmove",c)}))});let i=l=>{o=Xi(l),a=null,r=null},s=l=>{let u=l.target,d=Se(t.element),h=Gd(l),y=Math.abs(h[0])>Math.abs(h[1])?"x":"y",p=y==="x"?h[0]:h[1],m=Yi(u,y,p,d),x;d&&ga(d,u)?x=!m:x=!0,x&&l.cancelable&&l.preventDefault()},c=l=>{let u=Se(t.element),d=l.target,h;if(l.touches.length===2)h=!Se(t.allowPinchZoom);else{if(a==null||r===null){let y=Xi(l).map((m,x)=>o[x]-m),p=Math.abs(y[0])>Math.abs(y[1])?"x":"y";a=p,r=p==="x"?y[0]:y[1]}if(d.type==="range")h=!1;else{let y=Yi(d,a,r,u);u&&ga(u,d)?h=!y:h=!0}}h&&l.cancelable&&l.preventDefault()}},Gd=e=>[e.deltaX,e.deltaY],Xi=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Yi=(e,t,n,o)=>{let a=o!==null&&ga(o,e),[r,i]=Gi(e,t,a?o:void 0);return!(n>0&&Math.abs(r)<=1||n<0&&Math.abs(i)<1)},ga=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},Wd=Kd,wo=Wd;var gy=F();var ls="kb-color-mode";function Zd(e){return{ssr:!1,type:"localStorage",get:t=>{if(X)return t;let n;try{n=localStorage.getItem(e)}catch{}return n??t},set:t=>{try{localStorage.setItem(e,t)}catch{}}}}var vy=Zd(ls);function Ji(e,t){return e.match(new RegExp(`(^| )${t}=([^;]+)`))?.[2]}function Xd(e,t){return{ssr:!!t,type:"cookie",get:n=>t?Ji(t,e)??n:X?n:Ji(document.cookie,e)??n,set:n=>{document.cookie=`${e}=${n}; max-age=31536000; path=/`}}}var My=Xd(ls);function Yd(e){let[t,n]=P(e.defaultValue?.()),o=O(()=>e.value?.()!==void 0),a=O(()=>o()?e.value?.():t());return[a,i=>{Q(()=>{let s=$t(i,a());return Object.is(s,a())||(o()||n(s),e.onChange?.(s)),s})}]}function Jd(e){let[t,n]=Yd(e);return[()=>t()??!1,n]}function Qd(e={}){let[t,n]=Jd({value:()=>Z(e.open),defaultValue:()=>!!Z(e.defaultOpen),onChange:i=>e.onOpenChange?.(i)}),o=()=>{n(!0)},a=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:o,close:a,toggle:()=>{t()?a():o()}}}function e2(e){let t=n=>{n.key===on.Escape&&e.onEscapeKeyDown?.(n)};I(()=>{if(X||Z(e.isDisabled))return;let n=e.ownerDocument?.()??ae();n.addEventListener("keydown",t),T(()=>{n.removeEventListener("keydown",t)})})}var Co="data-kb-top-layer",ds,xa=!1,Qe=[];function bn(e){return Qe.findIndex(t=>t.node===e)}function t2(e){return Qe[bn(e)]}function n2(e){return Qe[Qe.length-1].node===e}function us(){return Qe.filter(e=>e.isPointerBlocking)}function o2(){return[...us()].slice(-1)[0]}function Ca(){return us().length>0}function hs(e){let t=bn(o2()?.node);return bn(e)e.onMountAutoFocus?.(p),s=p=>e.onUnmountAutoFocus?.(p),c=()=>ae(t()),l=()=>{let p=c().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,Zn),p},u=()=>{let p=t();return p?an(p,!0).filter(m=>!m.hasAttribute("data-focus-trap")):[]},d=()=>{let p=u();return p.length>0?p[0]:null},h=()=>{let p=u();return p.length>0?p[p.length-1]:null},y=()=>{let p=t();if(!p)return!1;let m=Re(p);return!m||J(p,m)?!1:rn(m)};I(()=>{if(X)return;let p=t();if(!p)return;es.add(a);let m=Re(p);if(!J(p,m)){let v=new CustomEvent(va,Qi);p.addEventListener(va,i),p.dispatchEvent(v),v.defaultPrevented||setTimeout(()=>{se(d()),Re(p)===m&&se(p)},0)}T(()=>{p.removeEventListener(va,i),setTimeout(()=>{let v=new CustomEvent(Ma,Qi);y()&&v.preventDefault(),p.addEventListener(Ma,s),p.dispatchEvent(v),v.defaultPrevented||se(m??c().body),p.removeEventListener(Ma,s),es.remove(a)},0)})}),I(()=>{if(X)return;let p=t();if(!p||!Z(e.trapFocus)||n())return;let m=v=>{let w=v.target;w?.closest(`[${Co}]`)||(J(p,w)?r=w:se(r))},x=v=>{let L=v.relatedTarget??Re(p);L?.closest(`[${Co}]`)||J(p,L)||se(r)};c().addEventListener("focusin",m),c().addEventListener("focusout",x),T(()=>{c().removeEventListener("focusin",m),c().removeEventListener("focusout",x)})}),I(()=>{if(X)return;let p=t();if(!p||!Z(e.trapFocus)||n())return;let m=l();p.insertAdjacentElement("afterbegin",m);let x=l();p.insertAdjacentElement("beforeend",x);function v(L){let A=d(),q=h();L.relatedTarget===A?se(q):se(A)}m.addEventListener("focusin",v),x.addEventListener("focusin",v);let w=new MutationObserver(L=>{for(let A of L)A.previousSibling===x&&(x.remove(),p.insertAdjacentElement("beforeend",x)),A.nextSibling===m&&(m.remove(),p.insertAdjacentElement("afterbegin",m))});w.observe(p,{childList:!0,subtree:!1}),T(()=>{m.removeEventListener("focusin",v),x.removeEventListener("focusin",v),m.remove(),x.remove(),w.disconnect()})})}var d2="data-live-announcer";function u2(e){I(()=>{Z(e.isDisabled)||T(h2(Z(e.targets),Z(e.root)))})}var Cn=new WeakMap,De=[];function h2(e,t=document.body){let n=new Set(e),o=new Set,a=c=>{for(let h of c.querySelectorAll(`[${d2}], [${Co}]`))n.add(h);let l=h=>{if(n.has(h)||h.parentElement&&o.has(h.parentElement)&&h.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(let y of n)if(h.contains(y))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},u=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:l}),d=l(c);if(d===NodeFilter.FILTER_ACCEPT&&r(c),d!==NodeFilter.FILTER_REJECT){let h=u.nextNode();for(;h!=null;)r(h),h=u.nextNode()}},r=c=>{let l=Cn.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),o.add(c),Cn.set(c,l+1))};De.length&&De[De.length-1].disconnect(),a(t);let i=new MutationObserver(c=>{for(let l of c)if(!(l.type!=="childList"||l.addedNodes.length===0)&&![...n,...o].some(u=>u.contains(l.target))){for(let u of l.removedNodes)u instanceof Element&&(n.delete(u),o.delete(u));for(let u of l.addedNodes)(u instanceof HTMLElement||u instanceof SVGElement)&&(u.dataset.liveAnnouncer==="true"||u.dataset.reactAriaTopLayer==="true")?n.add(u):u instanceof Element&&a(u)}});i.observe(t,{childList:!0,subtree:!0});let s={observe(){i.observe(t,{childList:!0,subtree:!0})},disconnect(){i.disconnect()}};return De.push(s),()=>{i.disconnect();for(let c of o){let l=Cn.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),Cn.delete(c)):Cn.set(c,l-1)}s===De[De.length-1]?(De.pop(),De.length&&De[De.length-1].observe()):De.splice(De.indexOf(s),1)}}var ts="interactOutside.pointerDownOutside",ns="interactOutside.focusOutside";function p2(e,t){let n,o=Wn,a=()=>ae(t()),r=d=>e.onPointerDownOutside?.(d),i=d=>e.onFocusOutside?.(d),s=d=>e.onInteractOutside?.(d),c=d=>{let h=d.target;return!(h instanceof HTMLElement)||h.closest(`[${Co}]`)||!J(a(),h)||J(t(),h)?!1:!e.shouldExcludeElement?.(h)},l=d=>{function h(){let y=t(),p=d.target;if(!y||!p||!c(d))return;let m=Dt([r,s]);p.addEventListener(ts,m,{once:!0});let x=new CustomEvent(ts,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:d.button===2||Gn(d)&&d.button===0}});p.dispatchEvent(x)}d.pointerType==="touch"?(a().removeEventListener("click",h),o=h,a().addEventListener("click",h,{once:!0})):h()},u=d=>{let h=t(),y=d.target;if(!h||!y||!c(d))return;let p=Dt([i,s]);y.addEventListener(ns,p,{once:!0});let m=new CustomEvent(ns,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:!1}});y.dispatchEvent(m)};I(()=>{X||Z(e.isDisabled)||(n=window.setTimeout(()=>{a().addEventListener("pointerdown",l,!0)},0),a().addEventListener("focusin",u,!0),T(()=>{window.clearTimeout(n),a().removeEventListener("click",o),a().removeEventListener("pointerdown",l,!0),a().removeEventListener("focusin",u,!0)}))})}function os(e){let[t,n]=P(),o={},a=e(),r="none",[i,s]=y2(e()?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return I(Oe(i,c=>{let l=xo(o);r=c==="mounted"?l:"none"})),I(Oe(e,c=>{if(a===c)return;let l=xo(o);c?s("MOUNT"):o?.display==="none"?s("UNMOUNT"):s(a&&r!==l?"ANIMATION_OUT":"UNMOUNT"),a=c})),I(Oe(t,c=>{if(c){let l=d=>{let y=xo(o).includes(d.animationName);d.target===c&&y&&s("ANIMATION_END")},u=d=>{d.target===c&&(r=xo(o))};c.addEventListener("animationstart",u),c.addEventListener("animationcancel",l),c.addEventListener("animationend",l),T(()=>{c.removeEventListener("animationstart",u),c.removeEventListener("animationcancel",l),c.removeEventListener("animationend",l)})}else s("ANIMATION_END")})),{isPresent:()=>["mounted","unmountSuspended"].includes(i()),setRef:c=>{c&&(o=getComputedStyle(c)),n(c)}}}function xo(e){return e?.animationName||"none"}function y2(e,t){let n=(i,s)=>t[i][s]??i,[o,a]=P(e);return[o,i=>{a(s=>n(s,i))}]}function wa(e){return t=>(e(t),()=>e(void 0))}function f2(e,t){let[n,o]=P(as(t?.()));return I(()=>{o(e()?.tagName.toLowerCase()||as(t?.()))}),n}function as(e){return Kn(e)?e:void 0}var wy=F();function Sn(e){let[t,n]=B(e,["asChild","as","children"]);if(!t.asChild)return f(tt,$({get component(){return t.as}},n,{get children(){return t.children}}));let o=Vn(()=>t.children);if(rs(o())){let a=is(n,o()?.props??{});return f(tt,a)}if(nr(o())){let a=o().find(rs);if(a){let r=()=>f(Me,{get each(){return o()},children:s=>f(G,{when:s===a,fallback:s,get children(){return a.props.children}})}),i=is(n,a?.props??{});return f(tt,$(i,{children:r}))}}throw new Error("[kobalte]: Component is expected to render `asChild` but no children `As` component was found.")}var k2=Symbol("$$KobalteAsComponent");function rs(e){return e?.[k2]===!0}function is(e,t){return Vo([e,t],{reverseEventHandlers:!0})}var m2=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),g2=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function v2(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize().script??"";return m2.has(n)}let t=e.split("-")[0];return g2.has(t)}function M2(e){return v2(e)?"rtl":"ltr"}function w2(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:M2(e)}}var xy=w2();var Cy=F();var[by,Sy]=_t({toasts:[]});var Ly=F();var x2=["button","color","file","image","reset","submit"];function C2(e){let t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?x2.indexOf(e.type)!==-1:!1}function ps(e){let t,n=re({type:"button"},e),[o,a]=B(n,["ref","type","disabled"]),r=f2(()=>t,()=>"button"),i=O(()=>{let l=r();return l==null?!1:C2({tagName:l,type:o.type})}),s=O(()=>r()==="input"),c=O(()=>r()==="a"&&t?.getAttribute("href")!=null);return f(Sn,$({as:"button",ref(l){let u=oe(d=>t=d,o.ref);typeof u=="function"&&u(l)},get type(){return i()||s()?o.type:void 0},get role(){return!i()&&!c()?"button":void 0},get tabIndex(){return!i()&&!c()&&!o.disabled?0:void 0},get disabled(){return i()||s()?o.disabled:void 0},get"aria-disabled"(){return!i()&&!s()&&o.disabled?!0:void 0},get"data-disabled"(){return o.disabled?"":void 0}},a))}var Ny=F();var $y=F();var Iy=F();var ys=F();function gt(){let e=ue(ys);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function b2(e){let t=gt(),[n,o]=B(e,["aria-label","onClick"]);return f(ps,$({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:r=>{ke(r,n.onClick),t.close()}},o))}var fs=F();function S2(){return ue(fs)}function L2(e){let t,n=S2(),[o,a]=B(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]),i=d=>{r.add(d);let h=n?.registerNestedLayer(d);return()=>{r.delete(d),h?.()}};p2({shouldExcludeElement:d=>t?o.excludedElements?.some(h=>J(h(),d))||[...r].some(h=>J(h,d)):!1,onPointerDownOutside:d=>{!t||$e.isBelowPointerBlockingLayer(t)||!o.bypassTopMostLayerCheck&&!$e.isTopMostLayer(t)||(o.onPointerDownOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.())},onFocusOutside:d=>{o.onFocusOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.()}},()=>t),e2({ownerDocument:()=>ae(t),onEscapeKeyDown:d=>{!t||!$e.isTopMostLayer(t)||(o.onEscapeKeyDown?.(d),!d.defaultPrevented&&o.onDismiss&&(d.preventDefault(),o.onDismiss()))}}),pe(()=>{if(!t)return;$e.addLayer({node:t,isPointerBlocking:o.disableOutsidePointerEvents,dismiss:o.onDismiss});let d=n?.registerNestedLayer(t);$e.assignPointerEventToLayers(),$e.disableBodyPointerEvents(t),T(()=>{t&&($e.removeLayer(t),d?.(),$e.assignPointerEventToLayers(),$e.restoreBodyPointerEvents(t))})}),I(Oe([()=>t,()=>o.disableOutsidePointerEvents],([d,h])=>{if(!d)return;let y=$e.find(d);y&&y.isPointerBlocking!==h&&(y.isPointerBlocking=h,$e.assignPointerEventToLayers()),h&&$e.disableBodyPointerEvents(d),T(()=>{$e.restoreBodyPointerEvents(d)})},{defer:!0}));let u={registerNestedLayer:i};return f(fs.Provider,{value:u,get children(){return f(Sn,$({as:"div",ref(d){let h=oe(y=>t=y,o.ref);typeof h=="function"&&h(d)}},a))}})}function N2(e){let t,n=gt(),o=re({id:n.generateId("content")},e),[a,r]=B(o,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]),i=!1,s=!1,c=h=>{a.onPointerDownOutside?.(h),n.modal()&&h.detail.isContextMenu&&h.preventDefault()},l=h=>{a.onFocusOutside?.(h),n.modal()&&h.preventDefault()},u=h=>{a.onInteractOutside?.(h),!n.modal()&&(h.defaultPrevented||(i=!0,h.detail.originalEvent.type==="pointerdown"&&(s=!0)),J(n.triggerRef(),h.target)&&h.preventDefault(),h.detail.originalEvent.type==="focusin"&&s&&h.preventDefault())},d=h=>{a.onCloseAutoFocus?.(h),n.modal()?(h.preventDefault(),se(n.triggerRef())):(h.defaultPrevented||(i||se(n.triggerRef()),h.preventDefault()),i=!1,s=!1)};return u2({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),wo({element:()=>t??null,enabled:()=>n.isOpen()&&n.preventScroll()}),l2({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:a.onOpenAutoFocus,onUnmountAutoFocus:d},()=>t),I(()=>T(n.registerContentId(r.id))),f(G,{get when(){return n.contentPresence.isPresent()},get children(){return f(L2,$({ref(h){let y=oe(p=>{n.contentPresence.setRef(p),t=p},a.ref);typeof y=="function"&&y(h)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return O(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,get onDismiss(){return n.close}},r))}})}function $2(e){let t=gt(),n=re({id:t.generateId("description")},e),[o,a]=B(n,["id"]);return I(()=>T(t.registerDescriptionId(o.id))),f(Sn,$({as:"p",get id(){return o.id}},a))}function I2(e){let t=gt(),[n,o]=B(e,["ref","style","onPointerDown"]),a=r=>{ke(r,n.onPointerDown),r.target===r.currentTarget&&r.preventDefault()};return f(G,{get when(){return t.overlayPresence.isPresent()},get children(){return f(Sn,$({as:"div",ref(r){let i=oe(t.overlayPresence.setRef,n.ref);typeof i=="function"&&i(r)},get style(){return{"pointer-events":"auto",...n.style}},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:a},o))}})}function P2(e){let t=gt();return f(G,{get when(){return t.contentPresence.isPresent()||t.overlayPresence.isPresent()},get children(){return f(Lt,e)}})}var ss={dismiss:"Dismiss"};function D2(e){let t=`dialog-${me()}`,n=re({id:t,modal:!0,translations:ss},e),[o,a]=P(),[r,i]=P(),[s,c]=P(),[l,u]=P(),d=Qd({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:x=>n.onOpenChange?.(x)}),h=()=>n.forceMount||d.isOpen(),y=os(h),p=os(h),m={translations:()=>n.translations??ss,isOpen:d.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??m.modal(),contentId:o,titleId:r,descriptionId:s,triggerRef:l,overlayPresence:y,contentPresence:p,close:d.close,toggle:d.toggle,setTriggerRef:u,generateId:Pt(()=>n.id),registerContentId:wa(a),registerTitleId:wa(i),registerDescriptionId:wa(c)};return f(ys.Provider,{value:m,get children(){return n.children}})}function A2(e){let t=gt(),n=re({id:t.generateId("title")},e),[o,a]=B(n,["id"]);return I(()=>T(t.registerTitleId(o.id))),f(Sn,$({as:"h2",get id(){return o.id}},a))}function T2(e){let t=gt(),[n,o]=B(e,["ref","onClick"]);return f(ps,$({ref(r){let i=oe(t.setTriggerRef,n.ref);typeof i=="function"&&i(r)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return O(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:r=>{ke(r,n.onClick),t.toggle()}},o))}var Ln=Object.freeze({__proto__:null,CloseButton:b2,Content:N2,Description:$2,Overlay:I2,Portal:P2,Root:D2,Title:A2,Trigger:T2});var Py=F();var Dy=F();var Ay=F();var Ty=F();var Fy=F();var Oy=F();var F2=30,Ry=F2/2;var qy=F();var Vy=F();var By=F();var Ey=F();var Hy=F();var zy=F();var jy=F();var Uy=F();var _y=F();var cs=["Enter"," "],Ky={ltr:[...cs,"ArrowRight"],rtl:[...cs,"ArrowLeft"]};var Gy=F();var Wy=F();var Zy=F();var Xy=F();var Yy=F();var Jy=F();var Qy=F();var ef=F();var tf=F();var nf=F();var of=F();var af=F();var rf=F();var sf=F();var cf=F();var lf=F();var df=F();var uf=F();var hf=F();jn(["focusin","focusout","pointermove"]);jn(["keydown","pointerdown","pointermove","pointerup"]);var pf=F();function ba(e){return ks(e,new Set),e}function ks(e,t){let n,o;if(e!=null&&typeof e=="object"&&!t.has(e)&&((n=Array.isArray(e))||e[fe]||!(o=Object.getPrototypeOf(e))||o===Object.prototype)){t.add(e);for(let a of n?e:Object.values(e))ks(a,t)}}var O2=z('
{ data().divisions[ - division_points.division_id + division_solves.division_id ].name } {translate("solves", { - solves: division_points.solves, - })} - - {translate("points", { - points: division_points.points, + solves: division_solves.solves, })}
"),fu=z('
'),Ws=z("
"),gu=z('
'),vu=z('
');function ct(e){htmx.ajax("GET",e,{select:"#screen",target:"#screen",swap:"outerHTML",history:"push",headers:{"HX-Boosted":!0}}),history.pushState({htmx:!0},"",e)}var Mu=()=>{let[e,t]=P(!1),[n]=To(async()=>await(await fetch("/command-palette")).json());return pe(()=>{let o=a=>{a.key==="k"&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),t(r=>!r))};window.openCommandPalette=()=>t(!0),document.addEventListener("keydown",o),T(()=>document.removeEventListener("keydown",o))}),f(Us,{get open(){return e()},onOpenChange:t,get children(){return[f(_s,{get placeholder(){return ne("type-to-search")}}),f(Ks,{get children(){return[f(Gs,{get children(){return ne("no-results")}}),f(Zt,{get heading(){return ne("pages")},get children(){return[f(Te,{onSelect:()=>{ct("/"),t(!1)},get children(){return[f(li,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("home")),o})()]}}),f(G,{get when(){return n().challenges},get children(){return[f(Te,{onSelect:()=>{ct("/challenges"),t(!1)},get children(){return[f(sa,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("challenges")),o})()]}}),f(Te,{onSelect:()=>{ct("/team"),t(!1)},get children(){return[f(ki,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("team")),o})()]}}),f(Te,{onSelect:()=>{ct("/account"),t(!1)},get children(){return[f(fi,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("account")),o})()]}})]}}),f(G,{get when(){return!n().challenges},get children(){return f(Te,{onSelect:()=>{ct("/signin"),t(!1)},get children(){return[f(ia,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("sign-in")),o})()]}})}})]}}),f(Dn,{}),f(G,{get when(){return n().challenges},get children(){return[f(Me,{get each(){return Object.entries(n().challenges)},children:o=>{let a=o[0],r=o[1];return f(Zt,{heading:a,get children(){return f(Me,{each:r,children:i=>f(Te,{onSelect:()=>{ct(`/challenges#${i}`),t(!1)},get children(){return[f(sa,{class:"mr-2 h-4 w-4"}),(()=>{var s=Ie();return D(s,i),s})()]}})})}})}}),f(Dn,{})]}}),f(G,{get when(){return n().divisions},get children(){return[f(Zt,{get heading(){return ne("scoreboard-title")},get children(){return f(Me,{get each(){return Object.entries(n().divisions)},children:o=>{let a=o[0],r=o[1];return f(Te,{onSelect:()=>{ct(`/scoreboard/${a}`),t(!1)},get children(){return[f(yi,{class:"mr-2 h-4 w-4"}),(()=>{var i=Ie();return D(i,()=>ne("scoreboard",{scoreboard:r})),i})()]}})}})}}),f(Dn,{})]}}),f(Zt,{get heading(){return ne("account")},get children(){return[f(G,{get when(){return!n().challenges},get children(){return f(Te,{onSelect:()=>{window.location="/signin/discord"},get children(){return[f(ia,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("sign-in-with-discord")),o})()]}})}}),f(G,{get when(){return n().challenges},get children(){return f(Te,{onSelect:()=>{ct("/signout"),t(!1)},get children(){return[f(di,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("sign-out")),o})()]}})}})]}}),f(Dn,{}),f(Zt,{get heading(){return ne("theme")},get children(){return[f(Te,{onSelect:()=>{setTheme(!1),t(!1)},get children(){return[f(pi,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("light-theme")),o})()]}}),f(Te,{onSelect:()=>{setTheme(!0),t(!1)},get children(){return[f(ui,{class:"mr-2 h-4 w-4"}),(()=>{var o=Ie();return D(o,()=>ne("dark-theme")),o})()]}})]}})]}})]}})},Da={en:` +var rhombus=(()=>{var Lo=Object.defineProperty;var Zs=Object.getOwnPropertyDescriptor;var Xs=Object.getOwnPropertyNames;var Ys=Object.prototype.hasOwnProperty;var Js=(e,t)=>{for(var n in t)Lo(e,n,{get:t[n],enumerable:!0})},Qs=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Xs(t))!Ys.call(e,a)&&a!==n&&Lo(e,a,{get:()=>t[a],enumerable:!(o=Zs(t,a))||o.enumerable});return e};var ec=e=>Qs(Lo({},"__esModule",{value:!0}),e);var Su={};Js(Su,{renderChallenges:()=>bu,toast:()=>Ce,translate:()=>ae});var H={context:void 0,registry:void 0};function Io(e){H.context=e}function tc(){return{...H.context,id:`${H.context.id}${H.context.count++}-`,count:0}}var nc=(e,t)=>e===t,fe=Symbol("solid-proxy"),Qt=Symbol("solid-track"),Nu=Symbol("solid-dev-component"),Tn={equals:nc},Aa=null,qa=za,Le=1,Xt=2,Va={owned:null,cleanups:null,context:null,owner:null},No={},E=null,S=null,xt=null,wt=null,K=null,ce=null,ye=null,On=0;function Fe(e,t){let n=K,o=E,a=e.length===0,r=t===void 0?o:t,i=a?Va:{owned:null,cleanups:null,context:r?r.context:null,owner:r},s=a?e:()=>e(()=>Q(()=>et(i)));E=i,K=null;try{return ve(s,!0)}finally{K=n,E=o}}function P(e,t){t=t?Object.assign({},Tn,t):Tn;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},o=a=>(typeof a=="function"&&(S&&S.running&&S.sources.has(n)?a=a(n.tValue):a=a(n.value)),Ha(n,a));return[Ea.bind(n),o]}function Po(e,t,n){let o=Bn(e,t,!0,Le);xt&&S&&S.running?ce.push(o):Ct(o)}function U(e,t,n){let o=Bn(e,t,!1,Le);xt&&S&&S.running?ce.push(o):Ct(o)}function I(e,t,n){qa=sc;let o=Bn(e,t,!1,Le),a=Yt&&ue(Yt);a&&(o.suspense=a),(!n||!n.render)&&(o.user=!0),ye?ye.push(o):Ct(o)}function O(e,t,n){n=n?Object.assign({},Tn,n):Tn;let o=Bn(e,t,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=n.equals||void 0,xt&&S&&S.running?(o.tState=Le,ce.push(o)):Ct(o),Ea.bind(o)}function oc(e){return e&&typeof e=="object"&&"then"in e}function To(e,t,n){let o,a,r;arguments.length===2&&typeof t=="object"||arguments.length===1?(o=!0,a=e,r=t||{}):(o=e,a=t,r=n||{});let i=null,s=No,c=null,l=!1,u=!1,d="initialValue"in r,h=typeof o=="function"&&O(o),y=new Set,[p,m]=(r.storage||P)(r.initialValue),[x,v]=P(void 0),[w,L]=P(void 0,{equals:!1}),[A,q]=P(d?"ready":"unresolved");if(H.context){c=`${H.context.id}${H.context.count++}`;let k;r.ssrLoadFrom==="initial"?s=r.initialValue:H.load&&(k=H.load(c))&&(s=k)}function R(k,g,M,N){return i===k&&(i=null,N!==void 0&&(d=!0),(k===s||g===s)&&r.onHydrated&&queueMicrotask(()=>r.onHydrated(N,{value:g})),s=No,S&&k&&l?(S.promises.delete(k),l=!1,ve(()=>{S.running=!0,j(g,M)},!1)):j(g,M)),g}function j(k,g){ve(()=>{g===void 0&&m(()=>k),q(g!==void 0?"errored":d?"ready":"unresolved"),v(g);for(let M of y.keys())M.decrement();y.clear()},!1)}function _(){let k=Yt&&ue(Yt),g=p(),M=x();if(M!==void 0&&!i)throw M;return K&&!K.user&&k&&Po(()=>{w(),i&&(k.resolved&&S&&l?S.promises.add(i):y.has(k)||(k.increment(),y.add(k)))}),g}function C(k=!0){if(k!==!1&&u)return;u=!1;let g=h?h():o;if(l=S&&S.running,g==null||g===!1){R(i,Q(p));return}S&&i&&S.promises.delete(i);let M=s!==No?s:Q(()=>a(g,{value:p(),refetching:k}));return oc(M)?(i=M,"value"in M?(M.status==="success"?R(i,M.value,void 0,g):R(i,void 0,void 0,g),M):(u=!0,queueMicrotask(()=>u=!1),ve(()=>{q(d?"refreshing":"pending"),L()},!1),M.then(N=>R(M,N,void 0,g),N=>R(M,void 0,_a(N),g)))):(R(i,M,void 0,g),M)}return Object.defineProperties(_,{state:{get:()=>A()},error:{get:()=>x()},loading:{get(){let k=A();return k==="pending"||k==="refreshing"}},latest:{get(){if(!d)return _();let k=x();if(k&&!i)throw k;return p()}}}),h?Po(()=>C(!1)):C(!1),[_,{refetch:C,mutate:m}]}function Fo(e){return ve(e,!1)}function Q(e){if(!wt&&K===null)return e();let t=K;K=null;try{return wt?wt.untrack(e):e()}finally{K=t}}function Oe(e,t,n){let o=Array.isArray(e),a,r=n&&n.defer;return i=>{let s;if(o){s=Array(e.length);for(let l=0;lt(s,a,i));return a=s,c}}function pe(e){I(()=>Q(e))}function T(e){return E===null||(E.cleanups===null?E.cleanups=[e]:E.cleanups.push(e)),e}function Rn(){return K}function qn(){return E}function Ba(e,t){let n=E,o=K;E=e,K=null;try{return ve(t,!0)}catch(a){En(a)}finally{E=n,K=o}}function ac(e){if(S&&S.running)return e(),S.done;let t=K,n=E;return Promise.resolve().then(()=>{K=t,E=n;let o;return(xt||Yt)&&(o=S||(S={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0}),o.done||(o.done=new Promise(a=>o.resolve=a)),o.running=!0),ve(e,!1),K=E=null,o?o.done:void 0})}var[$u,Ta]=P(!1);function F(e,t){let n=Symbol("context");return{id:n,Provider:cc(n),defaultValue:e}}function ue(e){return E&&E.context&&E.context[e.id]!==void 0?E.context[e.id]:e.defaultValue}function Vn(e){let t=O(e),n=O(()=>Do(t()));return n.toArray=()=>{let o=n();return Array.isArray(o)?o:o!=null?[o]:[]},n}var Yt;function Ea(){let e=S&&S.running;if(this.sources&&(e?this.tState:this.state))if((e?this.tState:this.state)===Le)Ct(this);else{let t=ce;ce=null,ve(()=>Fn(this),!1),ce=t}if(K){let t=this.observers?this.observers.length:0;K.sources?(K.sources.push(this),K.sourceSlots.push(t)):(K.sources=[this],K.sourceSlots=[t]),this.observers?(this.observers.push(K),this.observerSlots.push(K.sources.length-1)):(this.observers=[K],this.observerSlots=[K.sources.length-1])}return e&&S.sources.has(this)?this.tValue:this.value}function Ha(e,t,n){let o=S&&S.running&&S.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(o,t)){if(S){let a=S.running;(a||!n&&S.sources.has(e))&&(S.sources.add(e),e.tValue=t),a||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&ve(()=>{for(let a=0;a1e6)throw ce=[],new Error},!1)}return t}function Ct(e){if(!e.fn)return;et(e);let t=On;Fa(e,S&&S.running&&S.sources.has(e)?e.tValue:e.value,t),S&&!S.running&&S.sources.has(e)&&queueMicrotask(()=>{ve(()=>{S&&(S.running=!0),K=E=e,Fa(e,e.tValue,t),K=E=null},!1)})}function Fa(e,t,n){let o,a=E,r=K;K=E=e;try{o=e.fn(t)}catch(i){return e.pure&&(S&&S.running?(e.tState=Le,e.tOwned&&e.tOwned.forEach(et),e.tOwned=void 0):(e.state=Le,e.owned&&e.owned.forEach(et),e.owned=null)),e.updatedAt=n+1,En(i)}finally{K=r,E=a}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Ha(e,o,!0):S&&S.running&&e.pure?(S.sources.add(e),e.tValue=o):e.value=o,e.updatedAt=n)}function Bn(e,t,n,o=Le,a){let r={fn:e,state:o,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:E,context:E?E.context:null,pure:n};if(S&&S.running&&(r.state=0,r.tState=o),E===null||E!==Va&&(S&&S.running&&E.pure?E.tOwned?E.tOwned.push(r):E.tOwned=[r]:E.owned?E.owned.push(r):E.owned=[r]),wt&&r.fn){let[i,s]=P(void 0,{equals:!1}),c=wt.factory(r.fn,s);T(()=>c.dispose());let l=()=>ac(s).then(()=>u.dispose()),u=wt.factory(r.fn,l);r.fn=d=>(i(),S&&S.running?u.track(d):c.track(d))}return r}function Jt(e){let t=S&&S.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===Xt)return Fn(e);if(e.suspense&&Q(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;o--){if(e=n[o],t){let a=e,r=n[o+1];for(;(a=a.owner)&&a!==r;)if(S.disposed.has(a))return}if((t?e.tState:e.state)===Le)Ct(e);else if((t?e.tState:e.state)===Xt){let a=ce;ce=null,ve(()=>Fn(e,n[0]),!1),ce=a}}}function ve(e,t){if(ce)return e();let n=!1;t||(ce=[]),ye?n=!0:ye=[],On++;try{let o=e();return rc(n),o}catch(o){n||(ye=null),ce=null,En(o)}}function rc(e){if(ce&&(xt&&S&&S.running?ic(ce):za(ce),ce=null),e)return;let t;if(S){if(!S.promises.size&&!S.queue.size){let o=S.sources,a=S.disposed;ye.push.apply(ye,S.effects),t=S.resolve;for(let r of ye)"tState"in r&&(r.state=r.tState),delete r.tState;S=null,ve(()=>{for(let r of a)et(r);for(let r of o){if(r.value=r.tValue,r.owned)for(let i=0,s=r.owned.length;iqa(n),!1),t&&t()}function za(e){for(let t=0;t{o.delete(n),ve(()=>{S.running=!0,Jt(n)},!1),S&&(S.running=!1)}))}}function sc(e){let t,n=0;for(t=0;t=0;t--)et(e.tOwned[t]);delete e.tOwned}Ua(e,!0)}else if(e.owned){for(t=e.owned.length-1;t>=0;t--)et(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}S&&S.running?e.tState=0:e.state=0}function Ua(e,t){if(t||(e.tState=0,S.disposed.add(e)),e.owned)for(let n=0;na=Q(()=>(E.context={...E.context,[e]:o.value},Vn(()=>o.children))),void 0),a}}var lc=Symbol("fallback");function Ra(e){for(let t=0;t1?[]:null;return T(()=>Ra(r)),()=>{let c=e()||[],l,u;return c[Qt],Q(()=>{let h=c.length,y,p,m,x,v,w,L,A,q;if(h===0)i!==0&&(Ra(r),r=[],o=[],a=[],i=0,s&&(s=[])),n.fallback&&(o=[lc],a[0]=Fe(R=>(r[0]=R,n.fallback())),i=1);else if(i===0){for(a=new Array(h),u=0;u=w&&A>=w&&o[L]===c[A];L--,A--)m[A]=a[L],x[A]=r[L],s&&(v[A]=s[L]);for(y=new Map,p=new Array(A+1),u=A;u>=w;u--)q=c[u],l=y.get(q),p[u]=l===void 0?-1:l,y.set(q,u);for(l=w;l<=L;l++)q=o[l],u=y.get(q),u!==void 0&&u!==-1?(m[u]=a[l],x[u]=r[l],s&&(v[u]=s[l]),u=p[u],y.set(q,u)):r[l]();for(u=w;ue(t||{}));return Io(n),o}return Q(()=>e(t||{}))}function An(){return!0}var Ao={get(e,t,n){return t===fe?n:e.get(t)},has(e,t){return t===fe?!0:e.has(t)},set:An,deleteProperty:An,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:An,deleteProperty:An}},ownKeys(e){return e.keys()}};function $o(e){return(e=typeof e=="function"?e():e)?e:{}}function hc(){for(let e=0,t=this.length;e=0;s--){let c=$o(e[s])[i];if(c!==void 0)return c}},has(i){for(let s=e.length-1;s>=0;s--)if(i in $o(e[s]))return!0;return!1},keys(){let i=[];for(let s=0;s=0;i--){let s=e[i];if(!s)continue;let c=Object.getOwnPropertyNames(s);for(let l=c.length-1;l>=0;l--){let u=c[l];if(u==="__proto__"||u==="constructor")continue;let d=Object.getOwnPropertyDescriptor(s,u);if(!o[u])o[u]=d.get?{enumerable:!0,configurable:!0,get:hc.bind(n[u]=[d.get.bind(s)])}:d.value!==void 0?d:void 0;else{let h=n[u];h&&(d.get?h.push(d.get.bind(s)):d.value!==void 0&&h.push(()=>d.value))}}}let a={},r=Object.keys(o);for(let i=r.length-1;i>=0;i--){let s=r[i],c=o[s];c&&c.get?Object.defineProperty(a,s,c):a[s]=c?c.value:void 0}return a}function B(e,...t){if(fe in e){let a=new Set(t.length>1?t.flat():t[0]),r=t.map(i=>new Proxy({get(s){return i.includes(s)?e[s]:void 0},has(s){return i.includes(s)&&s in e},keys(){return i.filter(s=>s in e)}},Ao));return r.push(new Proxy({get(i){return a.has(i)?void 0:e[i]},has(i){return a.has(i)?!1:i in e},keys(){return Object.keys(e).filter(i=>!a.has(i))}},Ao)),r}let n={},o=t.map(()=>({}));for(let a of Object.getOwnPropertyNames(e)){let r=Object.getOwnPropertyDescriptor(e,a),i=!r.get&&!r.set&&r.enumerable&&r.writable&&r.configurable,s=!1,c=0;for(let l of t)l.includes(a)&&(s=!0,i?o[c][a]=r.value:Object.defineProperty(o[c],a,r)),++c;s||(i?n[a]=r.value:Object.defineProperty(n,a,r))}return[...o,n]}var pc=0;function me(){let e=H.context;return e?`${e.id}${e.count++}`:`cl-${pc++}`}var Ka=e=>`Stale read from <${e}>.`;function Me(e){let t="fallback"in e&&{fallback:()=>e.fallback};return O(dc(()=>e.each,e.children,t||void 0))}function G(e){let t=e.keyed,n=O(()=>e.when,void 0,{equals:(o,a)=>t?o===a:!o==!a});return O(()=>{let o=n();if(o){let a=e.children;return typeof a=="function"&&a.length>0?Q(()=>a(t?o:()=>{if(!Q(n))throw Ka("Show");return e.when})):a}return e.fallback},void 0,void 0)}function Hn(e){let t=!1,n=(r,i)=>(t?r[1]===i[1]:!r[1]==!i[1])&&r[2]===i[2],o=Vn(()=>e.children),a=O(()=>{let r=o();Array.isArray(r)||(r=[r]);for(let i=0;i{let[r,i,s]=a();if(r<0)return e.fallback;let c=s.children;return typeof c=="function"&&c.length>0?Q(()=>c(t?i:()=>{if(Q(a)[0]!==r)throw Ka("Match");return s.when})):c},void 0,void 0)}function lt(e){return e}var Iu=F();var fc=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected"],kc=new Set(["className","value","readOnly","formNoValidate","isMap","noModule","playsInline",...fc]),mc=new Set(["innerHTML","textContent","innerText","children"]),gc=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),vc=Object.assign(Object.create(null),{class:"className",formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1}});function Mc(e,t){let n=vc[e];return typeof n=="object"?n[t]?n.$:void 0:n}var wc=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),xc=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),Cc={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"};function bc(e,t,n){let o=n.length,a=t.length,r=o,i=0,s=0,c=t[a-1].nextSibling,l=null;for(;iu-s){let p=t[i];for(;s{a=r,t===document?e():D(t,e(),t.firstChild?null:void 0,n)},o.owner),()=>{a(),t.textContent=""}}function z(e,t,n){let o,a=()=>{let i=document.createElement("template");return i.innerHTML=e,n?i.content.firstChild.firstChild:i.content.firstChild},r=t?()=>Q(()=>document.importNode(o||(o=a()),!0)):()=>(o||(o=a())).cloneNode(!0);return r.cloneNode=r,r}function jn(e,t=window.document){let n=t[Ga]||(t[Ga]=new Set);for(let o=0,a=e.length;oa.call(e,n[1],r))}else e.addEventListener(t,n)}function Nc(e,t,n={}){let o=Object.keys(t||{}),a=Object.keys(n),r,i;for(r=0,i=a.length;ra.children=St(e,t.children,a.children)),U(()=>typeof t.ref=="function"?Ke(t.ref,e):t.ref=e),U(()=>$c(e,t,n,!0,a,!0)),a}function Ke(e,t,n){return Q(()=>e(t,n))}function D(e,t,n,o){if(n!==void 0&&!o&&(o=[]),typeof t!="function")return St(e,t,o,n);U(a=>St(e,t(),a,n),o)}function $c(e,t,n,o,a={},r=!1){t||(t={});for(let i in a)if(!(i in t)){if(i==="children")continue;a[i]=Za(e,i,null,a[i],n,r)}for(let i in t){if(i==="children"){o||St(e,t.children);continue}let s=t[i];a[i]=Za(e,i,s,a[i],n,r)}}function Ic(e){let t,n;return!H.context||!(t=H.registry.get(n=Ac()))?e():(H.completed&&H.completed.add(t),H.registry.delete(n),t)}function Pc(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Wa(e,t,n){let o=t.trim().split(/\s+/);for(let a=0,r=o.length;a-1&&Cc[t.split(":")[0]];d?Sc(e,d,t,n):ee(e,gc[t]||t,n)}return n}function Dc(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}}),H.registry&&!H.done&&(H.done=_$HY.done=!0);n;){let o=n[t];if(o&&!n.disabled){let a=n[`${t}Data`];if(a!==void 0?o.call(n,a,e):o.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function St(e,t,n,o,a){let r=!!H.context&&e.isConnected;if(r){!n&&(n=[...e.childNodes]);let c=[];for(let l=0;l{let c=t();for(;typeof c=="function";)c=c();n=St(e,c,n,o)}),()=>n;if(Array.isArray(t)){let c=[],l=n&&Array.isArray(n);if(Oo(c,t,n,a))return U(()=>n=St(e,c,n,o,!0)),()=>n;if(r){if(!c.length)return n;if(o===void 0)return[...e.childNodes];let u=c[0],d=[u];for(;(u=u.nextSibling)!==o;)d.push(u);return n=d}if(c.length===0){if(n=bt(e,n,o),s)return n}else l?n.length===0?Xa(e,c,o):bc(e,n,c):(n&&bt(e),Xa(e,c));n=c}else if(t.nodeType){if(r&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=bt(e,n,o,t);bt(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function Oo(e,t,n,o){let a=!1;for(let r=0,i=t.length;r=0;i--){let s=t[i];if(a!==s){let c=s.parentNode===e;!r&&!i?c?e.replaceChild(a,s):e.insertBefore(a,n):c&&s.remove()}else r=!0}}else e.insertBefore(a,n);return[a]}function Ac(){let e=H.context;return`${e.id}${e.count++}`}var Ru=Symbol();var X=!1;var Tc="http://www.w3.org/2000/svg";function Ya(e,t=!1){return t?document.createElementNS(Tc,e):document.createElement(e)}function Lt(e){let{useShadow:t}=e,n=document.createTextNode(""),o=()=>e.mount||document.body,a=qn(),r,i=!!H.context;return I(()=>{i&&(qn().user=i=!1),r||(r=Ba(a,()=>O(()=>e.children)));let s=o();if(s instanceof HTMLHeadElement){let[c,l]=P(!1),u=()=>l(!0);Fe(d=>D(s,()=>c()?d():r(),null)),T(u)}else{let c=Ya(e.isSVG?"g":"div",e.isSVG),l=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),D(l,r),s.appendChild(c),e.ref&&e.ref(c),T(()=>s.removeChild(c))}},void 0,{render:!i}),n}function tt(e){let[t,n]=B(e,["component"]),o=O(()=>t.component);return O(()=>{let a=o();switch(typeof a){case"function":return Q(()=>a(n));case"string":let r=xc.has(a),i=H.context?Ic():Ya(a,r);return ie(i,n,r),i}})}function Nt(e){return(...t)=>{for(let n of e)n&&n(...t)}}function Ro(e){return(...t)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];o&&o(...t)}}}var W=e=>typeof e=="function"&&!e.length?e():e;function $t(e,...t){return typeof e=="function"?e(...t):e}function Un(){return!0}var Oc={get(e,t,n){return t===fe?n:e.get(t)},has(e,t){return e.has(t)},set:Un,deleteProperty:Un,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:Un,deleteProperty:Un}},ownKeys(e){return e.keys()}};var Rc=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;function Ja(e){let t={},n;for(;n=Rc.exec(e);)t[n[1]]=n[2];return t}function qc(e,t){if(typeof e=="string"){if(typeof t=="string")return`${e};${t}`;e=Ja(e)}else typeof t=="string"&&(t=Ja(t));return{...e,...t}}var qo=(e,t,n)=>{let o;for(let a of e){let r=W(a)[t];o?r&&(o=n(o,r)):o=r}return o};function Vo(...e){let t=Array.isArray(e[0]),n=t?e[0]:e;if(n.length===1)return n[0];let o=t&&e[1]?.reverseEventHandlers?Ro:Nt,a={};for(let i of n){let s=W(i);for(let c in s)if(c[0]==="o"&&c[1]==="n"&&c[2]){let l=s[c],u=c.toLowerCase(),d=typeof l=="function"?l:Array.isArray(l)?l.length===1?l[0]:l[0].bind(void 0,l[1]):void 0;d?a[u]?a[u].push(d):a[u]=[d]:delete a[u]}}let r=$(...n);return new Proxy({get(i){if(typeof i!="string")return Reflect.get(r,i);if(i==="style")return qo(n,"style",qc);if(i==="ref"){let s=[];for(let c of n){let l=W(c)[i];typeof l=="function"&&s.push(l)}return o(s)}if(i[0]==="o"&&i[1]==="n"&&i[2]){let s=a[i.toLowerCase()];return s?o(s):Reflect.get(r,i)}return i==="class"||i==="className"?qo(n,i,(s,c)=>`${s} ${c}`):i==="classList"?qo(n,i,(s,c)=>({...s,...c})):Reflect.get(r,i)},has(i){return Reflect.has(r,i)},keys(){return Object.keys(r)}},Oc)}function ne(...e){return Nt(e)}function It(e,t){let n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function nr(e){return Array.isArray(e)}function Kn(e){return Object.prototype.toString.call(e)==="[object String]"}function or(e){return typeof e=="function"}function Pt(e){return t=>`${e()}-${t}`}function J(e,t){return e?e===t||e.contains(t):!1}function Re(e,t=!1){let{activeElement:n}=oe(e);if(!n?.nodeName)return null;if(ar(n)&&n.contentDocument)return Re(n.contentDocument.body,t);if(t){let o=n.getAttribute("aria-activedescendant");if(o){let a=oe(n).getElementById(o);if(a)return a}}return n}function nn(e){return oe(e).defaultView||window}function oe(e){return e?e.ownerDocument||e:document}function ar(e){return e.tagName==="IFRAME"}var on=(e=>(e.Escape="Escape",e.Enter="Enter",e.Tab="Tab",e.Space=" ",e.ArrowDown="ArrowDown",e.ArrowLeft="ArrowLeft",e.ArrowRight="ArrowRight",e.ArrowUp="ArrowUp",e.End="End",e.Home="Home",e.PageDown="PageDown",e.PageUp="PageUp",e))(on||{});function Vc(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.userAgentData?.platform||window.navigator.platform):!1}function rr(){return Vc(/^Mac/i)}function ke(e,t){return t&&(or(t)?t(e):t[0](t[1],e)),e?.defaultPrevented}function Dt(e){return t=>{for(let n of e)ke(t,n)}}function Gn(e){return rr()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function se(e){if(e)if(Bc())e.focus({preventScroll:!0});else{let t=Ec(e);e.focus(),Hc(t)}}var _n=null;function Bc(){if(_n==null){_n=!1;try{document.createElement("div").focus({get preventScroll(){return _n=!0,!0}})}catch{}}return _n}function Ec(e){let t=e.parentNode,n=[],o=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight{if(ar(a)&&a.contentDocument){let i=a.contentDocument.body,s=an(i,!1);o.splice(r,1,...s)}}),o}function Qa(e){return rn(e)&&!jc(e)}function rn(e){return e.matches(sr)&&cr(e)}function jc(e){return parseInt(e.getAttribute("tabindex")||"0",10)<0}function cr(e,t){return e.nodeName!=="#comment"&&Uc(e)&&_c(e,t)&&(!e.parentElement||cr(e.parentElement,e))}function Uc(e){if(!(e instanceof HTMLElement)&&!(e instanceof SVGElement))return!1;let{display:t,visibility:n}=e.style,o=t!=="none"&&n!=="hidden"&&n!=="collapse";if(o){if(!e.ownerDocument.defaultView)return o;let{getComputedStyle:a}=e.ownerDocument.defaultView,{display:r,visibility:i}=a(e);o=r!=="none"&&i!=="hidden"&&i!=="collapse"}return o}function _c(e,t){return!e.hasAttribute("hidden")&&(e.nodeName==="DETAILS"&&t&&t.nodeName!=="SUMMARY"?e.hasAttribute("open"):!0)}function Wn(){}function Bo(e){return[e.clientX,e.clientY]}function Eo(e,t){let[n,o]=e,a=!1,r=t.length;for(let i=r,s=0,c=i-1;s=h&&o0&&(o===h?o>y&&(a=!a):a=!a)}}else if(uu&&o<=h){if(p===0)return!0;p<0&&(o===h?o=d&&n<=l||n>=l&&n<=d))return!0}return a}function re(e,t){return $(e,t)}var tn=new Map,er=new Set;function tr(){if(typeof window>"u")return;let e=n=>{if(!n.target)return;let o=tn.get(n.target);o||(o=new Set,tn.set(n.target,o),n.target.addEventListener("transitioncancel",t)),o.add(n.propertyName)},t=n=>{if(!n.target)return;let o=tn.get(n.target);if(o&&(o.delete(n.propertyName),o.size===0&&(n.target.removeEventListener("transitioncancel",t),tn.delete(n.target)),tn.size===0)){for(let a of er)a();er.clear()}};document.body.addEventListener("transitionrun",e),document.body.addEventListener("transitionend",t)}typeof document<"u"&&(document.readyState!=="loading"?tr():document.addEventListener("DOMContentLoaded",tr));var Zn={border:"0",clip:"rect(0 0 0 0)","clip-path":"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:"0",position:"absolute",width:"1px","white-space":"nowrap"};var Kc=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Gc=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Wc(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize().script??"";return Kc.has(n)}let t=e.split("-")[0];return Gc.has(t)}function Zc(e){return Wc(e)?"rtl":"ltr"}function dr(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";return{locale:e,direction:Zc(e)}}var Ho=dr(),sn=new Set;function lr(){Ho=dr();for(let e of sn)e(Ho)}function Xc(){let e={locale:"en-US",direction:"ltr"},[t,n]=P(Ho),o=O(()=>X?e:t());return pe(()=>{sn.size===0&&window.addEventListener("languagechange",lr),sn.add(n),T(()=>{sn.delete(n),sn.size===0&&window.removeEventListener("languagechange",lr)})}),{locale:()=>o().locale,direction:()=>o().direction}}var Yc=F();function ur(){let e=Xc();return ue(Yc)||e}function Ne(e){let[t,n]=B(e,["as"]);if(!t.as)throw new Error("[kobalte]: Polymorphic is missing the required `as` prop.");return f(tt,$({get component(){return t.as}},n))}var hr=["top","right","bottom","left"];var He=Math.min,ge=Math.max,ln=Math.round,dn=Math.floor,Ge=e=>({x:e,y:e}),Jc={left:"right",right:"left",bottom:"top",top:"bottom"},Qc={start:"end",end:"start"};function Yn(e,t,n){return ge(e,He(t,n))}function nt(e,t){return typeof e=="function"?e(t):e}function We(e){return e.split("-")[0]}function dt(e){return e.split("-")[1]}function zo(e){return e==="x"?"y":"x"}function Jn(e){return e==="y"?"height":"width"}function At(e){return["top","bottom"].includes(We(e))?"y":"x"}function Qn(e){return zo(At(e))}function pr(e,t,n){n===void 0&&(n=!1);let o=dt(e),a=Qn(e),r=Jn(a),i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=cn(i)),[i,cn(i)]}function yr(e){let t=cn(e);return[Xn(e),t,Xn(t)]}function Xn(e){return e.replace(/start|end/g,t=>Qc[t])}function e1(e,t,n){let o=["left","right"],a=["right","left"],r=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?a:o:t?o:a;case"left":case"right":return t?r:i;default:return[]}}function fr(e,t,n,o){let a=dt(e),r=e1(We(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(Xn)))),r}function cn(e){return e.replace(/left|right|bottom|top/g,t=>Jc[t])}function t1(e){return{top:0,right:0,bottom:0,left:0,...e}}function jo(e){return typeof e!="number"?t1(e):{top:e,right:e,bottom:e,left:e}}function ut(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function kr(e,t,n){let{reference:o,floating:a}=e,r=At(t),i=Qn(t),s=Jn(i),c=We(t),l=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,h=o[s]/2-a[s]/2,y;switch(c){case"top":y={x:u,y:o.y-a.height};break;case"bottom":y={x:u,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:d};break;case"left":y={x:o.x-a.width,y:d};break;default:y={x:o.x,y:o.y}}switch(dt(t)){case"start":y[i]-=h*(n&&l?-1:1);break;case"end":y[i]+=h*(n&&l?-1:1);break}return y}var vr=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,s=r.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t)),l=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=kr(l,o,c),h=o,y={},p=0;for(let m=0;m({name:"arrow",options:e,async fn(t){let{x:n,y:o,placement:a,rects:r,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=nt(e,t)||{};if(l==null)return{};let d=jo(u),h={x:n,y:o},y=Qn(a),p=Jn(y),m=await i.getDimensions(l),x=y==="y",v=x?"top":"left",w=x?"bottom":"right",L=x?"clientHeight":"clientWidth",A=r.reference[p]+r.reference[y]-h[y]-r.floating[p],q=h[y]-r.reference[y],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l)),j=R?R[L]:0;(!j||!await(i.isElement==null?void 0:i.isElement(R)))&&(j=s.floating[L]||r.floating[p]);let _=A/2-q/2,C=j/2-m[p]/2-1,k=He(d[v],C),g=He(d[w],C),M=k,N=j-m[p]-g,b=j/2-m[p]/2+_,V=Yn(M,b,N),Z=!c.arrow&&dt(a)!=null&&b!==V&&r.reference[p]/2-(bM<=0)){var C,k;let M=(((C=r.flip)==null?void 0:C.index)||0)+1,N=q[M];if(N)return{data:{index:M,overflows:_},reset:{placement:N}};let b=(k=_.filter(V=>V.overflows[0]<=0).sort((V,Z)=>V.overflows[1]-Z.overflows[1])[0])==null?void 0:k.placement;if(!b)switch(y){case"bestFit":{var g;let V=(g=_.map(Z=>[Z.placement,Z.overflows.filter(de=>de>0).reduce((de,So)=>de+So,0)]).sort((Z,de)=>Z[1]-de[1])[0])==null?void 0:g[0];V&&(b=V);break}case"initialPlacement":b=s;break}if(a!==b)return{reset:{placement:b}}}return{}}}};function mr(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gr(e){return hr.some(t=>e[t]>=0)}var xr=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n}=t,{strategy:o="referenceHidden",...a}=nt(e,t);switch(o){case"referenceHidden":{let r=await Tt(t,{...a,elementContext:"reference"}),i=mr(r,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:gr(i)}}}case"escaped":{let r=await Tt(t,{...a,altBoundary:!0}),i=mr(r,n.floating);return{data:{escapedOffsets:i,escaped:gr(i)}}}default:return{}}}}};async function n1(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=We(n),s=dt(n),c=At(n)==="y",l=["left","top"].includes(i)?-1:1,u=r&&c?-1:1,d=nt(t,e),{mainAxis:h,crossAxis:y,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return s&&typeof p=="number"&&(y=s==="end"?p*-1:p),c?{x:y*u,y:h*l}:{x:h*l,y:y*u}}var Cr=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:i,middlewareData:s}=t,c=await n1(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:a+c.x,y:r+c.y,data:{...c,placement:i}}}}},br=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a}=t,{mainAxis:r=!0,crossAxis:i=!1,limiter:s={fn:x=>{let{x:v,y:w}=x;return{x:v,y:w}}},...c}=nt(e,t),l={x:n,y:o},u=await Tt(t,c),d=At(We(a)),h=zo(d),y=l[h],p=l[d];if(r){let x=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=y+u[x],L=y-u[v];y=Yn(w,y,L)}if(i){let x=d==="y"?"top":"left",v=d==="y"?"bottom":"right",w=p+u[x],L=p-u[v];p=Yn(w,p,L)}let m=s.fn({...t,[h]:y,[d]:p});return{...m,data:{x:m.x-n,y:m.y-o}}}}};var Sr=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:o,platform:a,elements:r}=t,{apply:i=()=>{},...s}=nt(e,t),c=await Tt(t,s),l=We(n),u=dt(n),d=At(n)==="y",{width:h,height:y}=o.floating,p,m;l==="top"||l==="bottom"?(p=l,m=u===(await(a.isRTL==null?void 0:a.isRTL(r.floating))?"start":"end")?"left":"right"):(m=l,p=u==="end"?"top":"bottom");let x=y-c[p],v=h-c[m],w=!t.middlewareData.shift,L=x,A=v;if(d){let R=h-c.left-c.right;A=u||w?He(v,R):R}else{let R=y-c.top-c.bottom;L=u||w?He(x,R):R}if(w&&!u){let R=ge(c.left,0),j=ge(c.right,0),_=ge(c.top,0),C=ge(c.bottom,0);d?A=h-2*(R!==0||j!==0?R+j:ge(c.left,c.right)):L=y-2*(_!==0||C!==0?_+C:ge(c.top,c.bottom))}await i({...t,availableWidth:A,availableHeight:L});let q=await a.getDimensions(r.floating);return h!==q.width||y!==q.height?{reset:{rects:!0}}:{}}}};function ht(e){return Nr(e)?(e.nodeName||"").toLowerCase():"#document"}function we(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ze(e){var t;return(t=(Nr(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nr(e){return e instanceof Node||e instanceof we(e).Node}function qe(e){return e instanceof Element||e instanceof we(e).Element}function Ve(e){return e instanceof HTMLElement||e instanceof we(e).HTMLElement}function Lr(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof we(e).ShadowRoot}function Ot(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Pe(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!["inline","contents"].includes(a)}function $r(e){return["table","td","th"].includes(ht(e))}function eo(e){let t=to(),n=Pe(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function Ir(e){let t=Ze(e);for(;Ve(t)&&!pt(t);){if(eo(t))return t;t=Ze(t)}return null}function to(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function pt(e){return["html","body","#document"].includes(ht(e))}function Pe(e){return we(e).getComputedStyle(e)}function un(e){return qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ze(e){if(ht(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Lr(e)&&e.host||ze(e);return Lr(t)?t.host:t}function Pr(e){let t=Ze(e);return pt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ve(t)&&Ot(t)?t:Pr(t)}function Ft(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=Pr(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=we(a);return r?t.concat(i,i.visualViewport||[],Ot(a)?a:[],i.frameElement&&n?Ft(i.frameElement):[]):t.concat(a,Ft(a,[],n))}function Tr(e){let t=Pe(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=Ve(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,s=ln(n)!==r||ln(o)!==i;return s&&(n=r,o=i),{width:n,height:o,$:s}}function _o(e){return qe(e)?e:e.contextElement}function Rt(e){let t=_o(e);if(!Ve(t))return Ge(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=Tr(t),i=(r?ln(n.width):n.width)/o,s=(r?ln(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}var o1=Ge(0);function Fr(e){let t=we(e);return!to()||!t.visualViewport?o1:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function a1(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==we(e)?!1:t}function yt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=_o(e),i=Ge(1);t&&(o?qe(o)&&(i=Rt(o)):i=Rt(e));let s=a1(r,n,o)?Fr(r):Ge(0),c=(a.left+s.x)/i.x,l=(a.top+s.y)/i.y,u=a.width/i.x,d=a.height/i.y;if(r){let h=we(r),y=o&&qe(o)?we(o):o,p=h,m=p.frameElement;for(;m&&o&&y!==p;){let x=Rt(m),v=m.getBoundingClientRect(),w=Pe(m),L=v.left+(m.clientLeft+parseFloat(w.paddingLeft))*x.x,A=v.top+(m.clientTop+parseFloat(w.paddingTop))*x.y;c*=x.x,l*=x.y,u*=x.x,d*=x.y,c+=L,l+=A,p=we(m),m=p.frameElement}}return ut({width:u,height:d,x:c,y:l})}var r1=[":popover-open",":modal"];function Ko(e){return r1.some(t=>{try{return e.matches(t)}catch{return!1}})}function i1(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",i=ze(o),s=t?Ko(t.floating):!1;if(o===i||s&&r)return n;let c={scrollLeft:0,scrollTop:0},l=Ge(1),u=Ge(0),d=Ve(o);if((d||!d&&!r)&&((ht(o)!=="body"||Ot(i))&&(c=un(o)),Ve(o))){let h=yt(o);l=Rt(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x,y:n.y*l.y-c.scrollTop*l.y+u.y}}function s1(e){return Array.from(e.getClientRects())}function Or(e){return yt(ze(e)).left+un(e).scrollLeft}function c1(e){let t=ze(e),n=un(e),o=e.ownerDocument.body,a=ge(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=ge(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),i=-n.scrollLeft+Or(e),s=-n.scrollTop;return Pe(o).direction==="rtl"&&(i+=ge(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:i,y:s}}function l1(e,t){let n=we(e),o=ze(e),a=n.visualViewport,r=o.clientWidth,i=o.clientHeight,s=0,c=0;if(a){r=a.width,i=a.height;let l=to();(!l||l&&t==="fixed")&&(s=a.offsetLeft,c=a.offsetTop)}return{width:r,height:i,x:s,y:c}}function d1(e,t){let n=yt(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=Ve(e)?Rt(e):Ge(1),i=e.clientWidth*r.x,s=e.clientHeight*r.y,c=a*r.x,l=o*r.y;return{width:i,height:s,x:c,y:l}}function Dr(e,t,n){let o;if(t==="viewport")o=l1(e,n);else if(t==="document")o=c1(ze(e));else if(qe(t))o=d1(t,n);else{let a=Fr(e);o={...t,x:t.x-a.x,y:t.y-a.y}}return ut(o)}function Rr(e,t){let n=Ze(e);return n===t||!qe(n)||pt(n)?!1:Pe(n).position==="fixed"||Rr(n,t)}function u1(e,t){let n=t.get(e);if(n)return n;let o=Ft(e,[],!1).filter(s=>qe(s)&&ht(s)!=="body"),a=null,r=Pe(e).position==="fixed",i=r?Ze(e):e;for(;qe(i)&&!pt(i);){let s=Pe(i),c=eo(i);!c&&s.position==="fixed"&&(a=null),(r?!c&&!a:!c&&s.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Ot(i)&&!c&&Rr(e,i))?o=o.filter(u=>u!==i):a=s,i=Ze(i)}return t.set(e,o),o}function h1(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,i=[...n==="clippingAncestors"?Ko(t)?[]:u1(t,this._c):[].concat(n),o],s=i[0],c=i.reduce((l,u)=>{let d=Dr(t,u,a);return l.top=ge(d.top,l.top),l.right=He(d.right,l.right),l.bottom=He(d.bottom,l.bottom),l.left=ge(d.left,l.left),l},Dr(t,s,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function p1(e){let{width:t,height:n}=Tr(e);return{width:t,height:n}}function y1(e,t,n){let o=Ve(t),a=ze(t),r=n==="fixed",i=yt(e,!0,r,t),s={scrollLeft:0,scrollTop:0},c=Ge(0);if(o||!o&&!r)if((ht(t)!=="body"||Ot(a))&&(s=un(t)),o){let d=yt(t,!0,r,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else a&&(c.x=Or(a));let l=i.left+s.scrollLeft-c.x,u=i.top+s.scrollTop-c.y;return{x:l,y:u,width:i.width,height:i.height}}function Uo(e){return Pe(e).position==="static"}function Ar(e,t){return!Ve(e)||Pe(e).position==="fixed"?null:t?t(e):e.offsetParent}function qr(e,t){let n=we(e);if(Ko(e))return n;if(!Ve(e)){let a=Ze(e);for(;a&&!pt(a);){if(qe(a)&&!Uo(a))return a;a=Ze(a)}return n}let o=Ar(e,t);for(;o&&$r(o)&&Uo(o);)o=Ar(o,t);return o&&pt(o)&&Uo(o)&&!eo(o)?n:o||Ir(e)||n}var f1=async function(e){let t=this.getOffsetParent||qr,n=this.getDimensions,o=await n(e.floating);return{reference:y1(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function k1(e){return Pe(e).direction==="rtl"}var Go={convertOffsetParentRelativeRectToViewportRelativeRect:i1,getDocumentElement:ze,getClippingRect:h1,getOffsetParent:qr,getElementRects:f1,getClientRects:s1,getDimensions:p1,getScale:Rt,isElement:qe,isRTL:k1};function m1(e,t){let n=null,o,a=ze(e);function r(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),r();let{left:l,top:u,width:d,height:h}=e.getBoundingClientRect();if(s||t(),!d||!h)return;let y=dn(u),p=dn(a.clientWidth-(l+d)),m=dn(a.clientHeight-(u+h)),x=dn(l),w={rootMargin:-y+"px "+-p+"px "+-m+"px "+-x+"px",threshold:ge(0,He(1,c))||1},L=!0;function A(q){let R=q[0].intersectionRatio;if(R!==c){if(!L)return i();R?i(!1,R):o=setTimeout(()=>{i(!1,1e-7)},1e3)}L=!1}try{n=new IntersectionObserver(A,{...w,root:a.ownerDocument})}catch{n=new IntersectionObserver(A,w)}n.observe(e)}return i(!0),r}function Vr(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=_o(e),u=a||r?[...l?Ft(l):[],...Ft(t)]:[];u.forEach(v=>{a&&v.addEventListener("scroll",n,{passive:!0}),r&&v.addEventListener("resize",n)});let d=l&&s?m1(l,n):null,h=-1,y=null;i&&(y=new ResizeObserver(v=>{let[w]=v;w&&w.target===l&&y&&(y.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var L;(L=y)==null||L.observe(t)})),n()}),l&&!c&&y.observe(l),y.observe(t));let p,m=c?yt(e):null;c&&x();function x(){let v=yt(e);m&&(v.x!==m.x||v.y!==m.y||v.width!==m.width||v.height!==m.height)&&n(),m=v,p=requestAnimationFrame(x)}return n(),()=>{var v;u.forEach(w=>{a&&w.removeEventListener("scroll",n),r&&w.removeEventListener("resize",n)}),d?.(),(v=y)==null||v.disconnect(),y=null,c&&cancelAnimationFrame(p)}}var Br=Cr;var Er=br,Hr=wr,zr=Sr,jr=xr,Ur=Mr;var _r=(e,t,n)=>{let o=new Map,a={platform:Go,...n},r={...a.platform,_c:o};return vr(e,t,{...a,platform:r})};var Zo=F();function Xo(){let e=ue(Zo);if(e===void 0)throw new Error("[kobalte]: `usePopperContext` must be used within a `Popper` component");return e}var g1=z(''),Wo=30,Kr=Wo/2,v1={top:180,right:-90,bottom:0,left:90};function no(e){let t=Xo(),n=re({size:Wo},e),[o,a]=B(n,["ref","style","size"]),r=()=>t.currentPlacement().split("-")[0],i=M1(t.contentRef),s=()=>i()?.getPropertyValue("background-color")||"none",c=()=>i()?.getPropertyValue(`border-${r()}-color`)||"none",l=()=>i()?.getPropertyValue(`border-${r()}-width`)||"0px",u=()=>parseInt(l())*2*(Wo/o.size),d=()=>`rotate(${v1[r()]} ${Kr} ${Kr})`;return f(Ne,$({as:"div",ref(h){let y=ne(t.setArrowRef,o.ref);typeof y=="function"&&y(h)},"aria-hidden":"true",get style(){return{position:"absolute","font-size":`${o.size}px`,width:"1em",height:"1em","pointer-events":"none",fill:s(),stroke:c(),"stroke-width":u(),...o.style}}},a,{get children(){let h=g1(),y=h.firstChild;return U(()=>ee(y,"transform",d())),h}}))}function M1(e){let[t,n]=P();return I(()=>{let o=e();o&&n(nn(o).getComputedStyle(o))}),t}function w1(e){let t=Xo(),[n,o]=B(e,["ref","style"]);return f(Ne,$({as:"div",ref(a){let r=ne(t.setPositionerRef,n.ref);typeof r=="function"&&r(a)},"data-popper-positioner":"",get style(){return{position:"absolute",top:0,left:0,"min-width":"max-content",...n.style}}},o))}function Gr(e){let{x:t=0,y:n=0,width:o=0,height:a=0}=e??{};if(typeof DOMRect=="function")return new DOMRect(t,n,o,a);let r={x:t,y:n,width:o,height:a,top:n,right:t+o,bottom:n+a,left:t};return{...r,toJSON:()=>r}}function x1(e,t){return{contextElement:e,getBoundingClientRect:()=>{let o=t(e);return o?Gr(o):e?e.getBoundingClientRect():Gr()}}}function C1(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}var b1={top:"bottom",right:"left",bottom:"top",left:"right"};function S1(e,t){let[n,o]=e.split("-"),a=b1[n];return o?n==="left"||n==="right"?`${a} ${o==="start"?"top":"bottom"}`:o==="start"?`${a} ${t==="rtl"?"right":"left"}`:`${a} ${t==="rtl"?"left":"right"}`:`${a} center`}function L1(e){let t=re({getAnchorRect:h=>h?.getBoundingClientRect(),placement:"bottom",gutter:0,shift:0,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,hideWhenDetached:!1,detachedPadding:0,arrowPadding:4,overflowPadding:8},e),[n,o]=P(),[a,r]=P(),[i,s]=P(t.placement),c=()=>x1(t.anchorRef?.(),t.getAnchorRect),{direction:l}=ur();async function u(){let h=c(),y=n(),p=a();if(!h||!y)return;let m=(p?.clientHeight||0)/2,x=typeof t.gutter=="number"?t.gutter+m:t.gutter??m;y.style.setProperty("--kb-popper-content-overflow-padding",`${t.overflowPadding}px`),h.getBoundingClientRect();let v=[Br(({placement:R})=>{let j=!!R.split("-")[1];return{mainAxis:x,crossAxis:j?void 0:t.shift,alignmentAxis:t.shift}})];if(t.flip!==!1){let R=typeof t.flip=="string"?t.flip.split(" "):void 0;if(R!==void 0&&!R.every(C1))throw new Error("`flip` expects a spaced-delimited list of placements");v.push(Hr({padding:t.overflowPadding,fallbackPlacements:R}))}(t.slide||t.overlap)&&v.push(Er({mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding})),v.push(zr({padding:t.overflowPadding,apply({availableWidth:R,availableHeight:j,rects:_}){let C=Math.round(_.reference.width);R=Math.floor(R),j=Math.floor(j),y.style.setProperty("--kb-popper-anchor-width",`${C}px`),y.style.setProperty("--kb-popper-content-available-width",`${R}px`),y.style.setProperty("--kb-popper-content-available-height",`${j}px`),t.sameWidth&&(y.style.width=`${C}px`),t.fitViewport&&(y.style.maxWidth=`${R}px`,y.style.maxHeight=`${j}px`)}})),t.hideWhenDetached&&v.push(jr({padding:t.detachedPadding})),p&&v.push(Ur({element:p,padding:t.arrowPadding}));let w=await _r(h,y,{placement:t.placement,strategy:"absolute",middleware:v,platform:{...Go,isRTL:()=>l()==="rtl"}});if(s(w.placement),t.onCurrentPlacementChange?.(w.placement),!y)return;y.style.setProperty("--kb-popper-content-transform-origin",S1(w.placement,l()));let L=Math.round(w.x),A=Math.round(w.y),q;if(t.hideWhenDetached&&(q=w.middlewareData.hide?.referenceHidden?"hidden":"visible"),Object.assign(y.style,{top:"0",left:"0",transform:`translate3d(${L}px, ${A}px, 0)`,visibility:q}),p&&w.middlewareData.arrow){let{x:R,y:j}=w.middlewareData.arrow,_=w.placement.split("-")[0];Object.assign(p.style,{left:R!=null?`${R}px`:"",top:j!=null?`${j}px`:"",[_]:"100%"})}}I(()=>{let h=c(),y=n();if(!h||!y)return;let p=Vr(h,y,u,{elementResize:typeof ResizeObserver=="function"});T(p)}),I(()=>{let h=n(),y=t.contentRef?.();!h||!y||queueMicrotask(()=>{h.style.zIndex=getComputedStyle(y).zIndex})});let d={currentPlacement:i,contentRef:()=>t.contentRef?.(),setPositionerRef:o,setArrowRef:r};return f(Zo.Provider,{value:d,get children(){return t.children}})}var Yo=Object.assign(L1,{Arrow:no,Context:Zo,usePopperContext:Xo,Positioner:w1});function Wr(e){let t=n=>{n.key===on.Escape&&e.onEscapeKeyDown?.(n)};I(()=>{if(X||W(e.isDisabled))return;let n=e.ownerDocument?.()??oe();n.addEventListener("keydown",t),T(()=>{n.removeEventListener("keydown",t)})})}var ft="data-kb-top-layer",Zr,Jo=!1,Xe=[];function hn(e){return Xe.findIndex(t=>t.node===e)}function N1(e){return Xe[hn(e)]}function $1(e){return Xe[Xe.length-1].node===e}function Xr(){return Xe.filter(e=>e.isPointerBlocking)}function I1(){return[...Xr()].slice(-1)[0]}function Qo(){return Xr().length>0}function Yr(e){let t=hn(I1()?.node);return hn(e)oe(t()),r=d=>e.onPointerDownOutside?.(d),i=d=>e.onFocusOutside?.(d),s=d=>e.onInteractOutside?.(d),c=d=>{let h=d.target;return!(h instanceof HTMLElement)||h.closest(`[${ft}]`)||!J(a(),h)||J(t(),h)?!1:!e.shouldExcludeElement?.(h)},l=d=>{function h(){let y=t(),p=d.target;if(!y||!p||!c(d))return;let m=Dt([r,s]);p.addEventListener(Jr,m,{once:!0});let x=new CustomEvent(Jr,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:d.button===2||Gn(d)&&d.button===0}});p.dispatchEvent(x)}d.pointerType==="touch"?(a().removeEventListener("click",h),o=h,a().addEventListener("click",h,{once:!0})):h()},u=d=>{let h=t(),y=d.target;if(!h||!y||!c(d))return;let p=Dt([i,s]);y.addEventListener(Qr,p,{once:!0});let m=new CustomEvent(Qr,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:!1}});y.dispatchEvent(m)};I(()=>{X||W(e.isDisabled)||(n=window.setTimeout(()=>{a().addEventListener("pointerdown",l,!0)},0),a().addEventListener("focusin",u,!0),T(()=>{window.clearTimeout(n),a().removeEventListener("click",o),a().removeEventListener("pointerdown",l,!0),a().removeEventListener("focusin",u,!0)}))})}var ti=F();function O1(){return ue(ti)}function oo(e){let t,n=O1(),[o,a]=B(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]),i=d=>{r.add(d);let h=n?.registerNestedLayer(d);return()=>{r.delete(d),h?.()}};ei({shouldExcludeElement:d=>t?o.excludedElements?.some(h=>J(h(),d))||[...r].some(h=>J(h,d)):!1,onPointerDownOutside:d=>{!t||xe.isBelowPointerBlockingLayer(t)||!o.bypassTopMostLayerCheck&&!xe.isTopMostLayer(t)||(o.onPointerDownOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.())},onFocusOutside:d=>{o.onFocusOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.()}},()=>t),Wr({ownerDocument:()=>oe(t),onEscapeKeyDown:d=>{!t||!xe.isTopMostLayer(t)||(o.onEscapeKeyDown?.(d),!d.defaultPrevented&&o.onDismiss&&(d.preventDefault(),o.onDismiss()))}}),pe(()=>{if(!t)return;xe.addLayer({node:t,isPointerBlocking:o.disableOutsidePointerEvents,dismiss:o.onDismiss});let d=n?.registerNestedLayer(t);xe.assignPointerEventToLayers(),xe.disableBodyPointerEvents(t),T(()=>{t&&(xe.removeLayer(t),d?.(),xe.assignPointerEventToLayers(),xe.restoreBodyPointerEvents(t))})}),I(Oe([()=>t,()=>o.disableOutsidePointerEvents],([d,h])=>{if(!d)return;let y=xe.find(d);y&&y.isPointerBlocking!==h&&(y.isPointerBlocking=h,xe.assignPointerEventToLayers()),h&&xe.disableBodyPointerEvents(d),T(()=>{xe.restoreBodyPointerEvents(d)})},{defer:!0}));let u={registerNestedLayer:i};return f(ti.Provider,{value:u,get children(){return f(Ne,$({as:"div",ref(d){let h=ne(y=>t=y,o.ref);typeof h=="function"&&h(d)}},a))}})}function R1(e){let[t,n]=P(e.defaultValue?.()),o=O(()=>e.value?.()!==void 0),a=O(()=>o()?e.value?.():t());return[a,i=>{Q(()=>{let s=$t(i,a());return Object.is(s,a())||(o()||n(s),e.onChange?.(s)),s})}]}function ni(e){let[t,n]=R1(e);return[()=>t()??!1,n]}function ao(e={}){let[t,n]=ni({value:()=>W(e.open),defaultValue:()=>!!W(e.defaultOpen),onChange:i=>e.onOpenChange?.(i)}),o=()=>{n(!0)},a=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:o,close:a,toggle:()=>{t()?a():o()}}}function qt(e){return t=>(e(t),()=>e(void 0))}function pn(e){let[t,n]=P(),o={},a=e(),r="none",[i,s]=q1(e()?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return I(Oe(i,c=>{let l=ro(o);r=c==="mounted"?l:"none"})),I(Oe(e,c=>{if(a===c)return;let l=ro(o);c?s("MOUNT"):o?.display==="none"?s("UNMOUNT"):s(a&&r!==l?"ANIMATION_OUT":"UNMOUNT"),a=c})),I(Oe(t,c=>{if(c){let l=d=>{let y=ro(o).includes(d.animationName);d.target===c&&y&&s("ANIMATION_END")},u=d=>{d.target===c&&(r=ro(o))};c.addEventListener("animationstart",u),c.addEventListener("animationcancel",l),c.addEventListener("animationend",l),T(()=>{c.removeEventListener("animationstart",u),c.removeEventListener("animationcancel",l),c.removeEventListener("animationend",l)})}else s("ANIMATION_END")})),{isPresent:()=>["mounted","unmountSuspended"].includes(i()),setRef:c=>{c&&(o=getComputedStyle(c)),n(c)}}}function ro(e){return e?.animationName||"none"}function q1(e,t){let n=(i,s)=>t[i][s]??i,[o,a]=P(e);return[o,i=>{a(s=>n(s,i))}]}var V1=Object.defineProperty,Vt=(e,t)=>{for(var n in t)V1(e,n,{get:t[n],enumerable:!0})};var B1={};Vt(B1,{Arrow:()=>no,Content:()=>ta,Portal:()=>na,Root:()=>oa,Tooltip:()=>Y,Trigger:()=>aa});var oi=F();function ea(){let e=ue(oi);if(e===void 0)throw new Error("[kobalte]: `useTooltipContext` must be used within a `Tooltip` component");return e}function ta(e){let t=ea(),n=re({id:t.generateId("content")},e),[o,a]=B(n,["ref","style"]);return I(()=>T(t.registerContentId(a.id))),f(G,{get when(){return t.contentPresence.isPresent()},get children(){return f(Yo.Positioner,{get children(){return f(oo,$({ref(r){let i=ne(s=>{t.setContentRef(s),t.contentPresence.setRef(s)},o.ref);typeof i=="function"&&i(r)},role:"tooltip",disableOutsidePointerEvents:!1,get style(){return{"--kb-tooltip-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative",...o.style}},onFocusOutside:r=>r.preventDefault(),onDismiss:()=>t.hideTooltip(!0)},()=>t.dataset(),a))}})}})}function na(e){let t=ea();return f(G,{get when(){return t.contentPresence.isPresent()},get children(){return f(Lt,e)}})}function E1(e,t,n){let o=e.split("-")[0],a=t.getBoundingClientRect(),r=n.getBoundingClientRect(),i=[],s=a.left+a.width/2,c=a.top+a.height/2;switch(o){case"top":i.push([a.left,c]),i.push([r.left,r.bottom]),i.push([r.left,r.top]),i.push([r.right,r.top]),i.push([r.right,r.bottom]),i.push([a.right,c]);break;case"right":i.push([s,a.top]),i.push([r.left,r.top]),i.push([r.right,r.top]),i.push([r.right,r.bottom]),i.push([r.left,r.bottom]),i.push([s,a.bottom]);break;case"bottom":i.push([a.left,c]),i.push([r.left,r.top]),i.push([r.left,r.bottom]),i.push([r.right,r.bottom]),i.push([r.right,r.top]),i.push([a.right,c]);break;case"left":i.push([s,a.top]),i.push([r.right,r.top]),i.push([r.left,r.top]),i.push([r.left,r.bottom]),i.push([r.right,r.bottom]),i.push([s,a.bottom]);break}return i}var kt={},H1=0,Bt=!1,Ye,yn;function oa(e){let t=`tooltip-${me()}`,n=`${++H1}`,o=re({id:t,openDelay:700,closeDelay:300},e),[a,r]=B(o,["id","open","defaultOpen","onOpenChange","disabled","triggerOnFocusOnly","openDelay","closeDelay","ignoreSafeArea","forceMount"]),i,[s,c]=P(),[l,u]=P(),[d,h]=P(),[y,p]=P(r.placement),m=ao({open:()=>a.open,defaultOpen:()=>a.defaultOpen,onOpenChange:b=>a.onOpenChange?.(b)}),x=pn(()=>a.forceMount||m.isOpen()),v=()=>{kt[n]=L},w=()=>{for(let b in kt)b!==n&&(kt[b](!0),delete kt[b])},L=(b=!1)=>{X||(b||a.closeDelay&&a.closeDelay<=0?(window.clearTimeout(i),i=void 0,m.close()):i||(i=window.setTimeout(()=>{i=void 0,m.close()},a.closeDelay)),window.clearTimeout(Ye),Ye=void 0,Bt&&(window.clearTimeout(yn),yn=window.setTimeout(()=>{delete kt[n],yn=void 0,Bt=!1},a.closeDelay)))},A=()=>{X||(clearTimeout(i),i=void 0,w(),v(),Bt=!0,m.open(),window.clearTimeout(Ye),Ye=void 0,window.clearTimeout(yn),yn=void 0)},q=()=>{X||(w(),v(),!m.isOpen()&&!Ye&&!Bt?Ye=window.setTimeout(()=>{Ye=void 0,Bt=!0,A()},a.openDelay):m.isOpen()||A())},R=(b=!1)=>{X||(!b&&a.openDelay&&a.openDelay>0&&!i?q():A())},j=()=>{X||(window.clearTimeout(Ye),Ye=void 0,Bt=!1)},_=()=>{X||(window.clearTimeout(i),i=void 0)},C=b=>J(l(),b)||J(d(),b),k=b=>{let V=l(),Z=d();if(!(!V||!Z))return E1(b,V,Z)},g=b=>{let V=b.target;if(C(V)){_();return}if(!a.ignoreSafeArea){let Z=k(y());if(Z&&Eo(Bo(b),Z)){_();return}}i||L()};I(()=>{if(X||!m.isOpen())return;let b=oe();b.addEventListener("pointermove",g,!0),T(()=>{b.removeEventListener("pointermove",g,!0)})}),I(()=>{let b=l();if(!b||!m.isOpen())return;let V=de=>{let So=de.target;J(So,b)&&L(!0)},Z=nn();Z.addEventListener("scroll",V,{capture:!0}),T(()=>{Z.removeEventListener("scroll",V,{capture:!0})})}),T(()=>{clearTimeout(i),kt[n]&&delete kt[n]});let N={dataset:O(()=>({"data-expanded":m.isOpen()?"":void 0,"data-closed":m.isOpen()?void 0:""})),isOpen:m.isOpen,isDisabled:()=>a.disabled??!1,triggerOnFocusOnly:()=>a.triggerOnFocusOnly??!1,contentId:s,contentPresence:x,openTooltip:R,hideTooltip:L,cancelOpening:j,generateId:Pt(()=>o.id),registerContentId:qt(c),isTargetOnTooltip:C,setTriggerRef:u,setContentRef:h};return f(oi.Provider,{value:N,get children(){return f(Yo,$({anchorRef:l,contentRef:d,onCurrentPlacementChange:p},r))}})}function aa(e){let t,n=ea(),[o,a]=B(e,["ref","onPointerEnter","onPointerLeave","onPointerDown","onClick","onFocus","onBlur"]),r=!1,i=!1,s=!1,c=()=>{r=!1},l=()=>{!n.isOpen()&&(i||s)&&n.openTooltip(s)},u=v=>{n.isOpen()&&!i&&!s&&n.hideTooltip(v)},d=v=>{ke(v,o.onPointerEnter),!(v.pointerType==="touch"||n.triggerOnFocusOnly()||n.isDisabled()||v.defaultPrevented)&&(i=!0,l())},h=v=>{ke(v,o.onPointerLeave),v.pointerType!=="touch"&&(i=!1,s=!1,n.isOpen()?u():n.cancelOpening())},y=v=>{ke(v,o.onPointerDown),r=!0,oe(t).addEventListener("pointerup",c,{once:!0})},p=v=>{ke(v,o.onClick),i=!1,s=!1,u(!0)},m=v=>{ke(v,o.onFocus),!(n.isDisabled()||v.defaultPrevented||r)&&(s=!0,l())},x=v=>{ke(v,o.onBlur);let w=v.relatedTarget;n.isTargetOnTooltip(w)||(i=!1,s=!1,u(!0))};return T(()=>{X||oe(t).removeEventListener("pointerup",c)}),f(Ne,$({as:"button",ref(v){let w=ne(L=>{n.setTriggerRef(L),t=L},o.ref);typeof w=="function"&&w(v)},get"aria-describedby"(){return O(()=>!!n.isOpen())()?n.contentId():void 0},onPointerEnter:d,onPointerLeave:h,onPointerDown:y,onClick:p,onFocus:m,onBlur:x},()=>n.dataset(),a))}var Y=Object.assign(oa,{Arrow:no,Content:ta,Portal:na,Trigger:aa});function z1(e){return Object.keys(e).reduce((n,o)=>{let a=e[o];return n[o]=Object.assign({},a),ii(a.value)&&!G1(a.value)&&!Array.isArray(a.value)&&(n[o].value=Object.assign({},a.value)),Array.isArray(a.value)&&(n[o].value=a.value.slice(0)),n},{})}function j1(e){return e?Object.keys(e).reduce((n,o)=>{let a=e[o];return n[o]=ii(a)&&"value"in a?a:{value:a},n[o].attribute||(n[o].attribute=K1(o)),n[o].parse="parse"in n[o]?n[o].parse:typeof n[o].value!="string",n},{}):{}}function U1(e){return Object.keys(e).reduce((n,o)=>(n[o]=e[o].value,n),{})}function _1(e,t){let n=z1(t);return Object.keys(t).forEach(a=>{let r=n[a],i=e.getAttribute(r.attribute),s=e[a];i&&(r.value=r.parse?ri(i):i),s!=null&&(r.value=Array.isArray(s)?s.slice(0):s),r.reflect&&ai(e,r.attribute,r.value),Object.defineProperty(e,a,{get(){return r.value},set(c){let l=r.value;r.value=c,r.reflect&&ai(this,r.attribute,r.value);for(let u=0,d=this.__propertyChangedCallbacks.length;udelete e.__updating[t])}function K1(e){return e.replace(/\.?([A-Z]+)/g,(t,n)=>"-"+n.toLowerCase()).replace("_","-").replace(/^-/,"")}function ii(e){return e!=null&&(typeof e=="object"||typeof e=="function")}function G1(e){return Object.prototype.toString.call(e)==="[object Function]"}function W1(e){return typeof e=="function"&&e.toString().indexOf("class")===0}var ra;function Z1(e,t){let n=Object.keys(t);return class extends e{static get observedAttributes(){return n.map(a=>t[a].attribute)}constructor(){super(),this.__initialized=!1,this.__released=!1,this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props={}}connectedCallback(){if(this.__initialized)return;this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props=_1(this,t);let a=U1(this.props),r=this.Component,i=ra;try{ra=this,this.__initialized=!0,W1(r)?new r(a,{element:this}):r(a,{element:this})}finally{ra=i}}async disconnectedCallback(){if(await Promise.resolve(),this.isConnected)return;this.__propertyChangedCallbacks.length=0;let a=null;for(;a=this.__releaseCallbacks.pop();)a(this);delete this.__initialized,this.__released=!0}attributeChangedCallback(a,r,i){if(this.__initialized&&!this.__updating[a]&&(a=this.lookupProp(a),a in t)){if(i==null&&!this[a])return;this[a]=t[a].parse?ri(i):i}}lookupProp(a){if(t)return n.find(r=>a===r||a===t[r].attribute)}get renderRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}addReleaseCallback(a){this.__releaseCallbacks.push(a)}addPropertyChangedCallback(a){this.__propertyChangedCallbacks.push(a)}}}var z0=Symbol("element-context");function si(e,t={},n={}){let{BaseElement:o=HTMLElement,extension:a}=n;return r=>{if(!e)throw new Error("tag is required to register a Component");let i=customElements.get(e);return i?(i.prototype.Component=r,i):(i=Z1(o,j1(t)),i.prototype.Component=r,i.prototype.registeredTag=e,customElements.define(e,i,a),i)}}function X1(e){let t=Object.keys(e),n={};for(let o=0;oi)}})}return n}function Y1(e){if(e.assignedSlot&&e.assignedSlot._$owner)return e.assignedSlot._$owner;let t=e.parentNode;for(;t&&!t._$owner&&!(t.assignedSlot&&t.assignedSlot._$owner);)t=t.parentNode;return t&&t.assignedSlot?t.assignedSlot._$owner:e._$owner}function J1(e){return(t,n)=>{let{element:o}=n;return Fe(a=>{let r=X1(t);o.addPropertyChangedCallback((s,c)=>r[s]=c),o.addReleaseCallback(()=>{o.renderRoot.textContent="",a()});let i=e(r,n);return D(o.renderRoot,i)},Y1(o))}}function ci(e,t,n){return arguments.length===2&&(n=t,t={}),si(e,t)(J1(n))}var Q1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},Et=Q1,el=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),tl=(...e)=>e.filter((t,n,o)=>!!t&&o.indexOf(t)===n).join(" "),nl=z(""),ol=e=>{let[t,n]=B(e,["color","size","strokeWidth","children","class","name","iconNode","absoluteStrokeWidth"]);return(()=>{var o=nl();return ie(o,$(Et,{get width(){return t.size??Et.width},get height(){return t.size??Et.height},get stroke(){return t.color??Et.stroke},get"stroke-width"(){return O(()=>!!t.absoluteStrokeWidth)()?Number(t.strokeWidth??Et["stroke-width"])*24/Number(t.size):Number(t.strokeWidth??Et["stroke-width"])},get class(){return tl("lucide","lucide-icon",t.name!=null?`lucide-${el(t?.name)}`:void 0,t.class!=null?t.class:"")}},n),!0,!0),D(o,f(Me,{get each(){return t.iconNode},children:([a,r])=>f(tt,$({component:a},r))})),o})()},Be=ol;var al=[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]],rl=e=>f(Be,$(e,{name:"Home",iconNode:al})),li=rl;var il=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],sl=e=>f(Be,$(e,{name:"LogIn",iconNode:il})),ia=sl,cl=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],ll=e=>f(Be,$(e,{name:"LogOut",iconNode:cl})),di=ll;var dl=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],ul=e=>f(Be,$(e,{name:"Moon",iconNode:dl})),ui=ul;var hl=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],pl=e=>f(Be,$(e,{name:"Search",iconNode:hl})),hi=pl;var yl=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fl=e=>f(Be,$(e,{name:"Sun",iconNode:yl})),pi=fl;var kl=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],ml=e=>f(Be,$(e,{name:"Swords",iconNode:kl})),sa=ml;var gl=[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]],vl=e=>f(Be,$(e,{name:"Trophy",iconNode:gl})),yi=vl;var Ml=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],wl=e=>f(Be,$(e,{name:"User",iconNode:Ml})),fi=wl;var xl=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Cl=e=>f(Be,$(e,{name:"Users",iconNode:xl})),ki=Cl;var bl=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Sl=e=>f(Be,$(e,{name:"X",iconNode:bl})),mi=Sl;var io=Symbol("store-raw"),Ht=Symbol("store-node"),Je=Symbol("store-has"),gi=Symbol("store-self");function vi(e){let t=e[fe];if(!t&&(Object.defineProperty(e,fe,{value:t=new Proxy(e,$l)}),!Array.isArray(e))){let n=Object.keys(e),o=Object.getOwnPropertyDescriptors(e);for(let a=0,r=n.length;ae[fe][t]),n}function Mi(e){Rn()&&kn(so(e,Ht),gi)()}function Nl(e){return Mi(e),Reflect.ownKeys(e)}var $l={get(e,t,n){if(t===io)return e;if(t===fe)return n;if(t===Qt)return Mi(e),n;let o=so(e,Ht),a=o[t],r=a?a():e[t];if(t===Ht||t===Je||t==="__proto__")return r;if(!a){let i=Object.getOwnPropertyDescriptor(e,t);Rn()&&(typeof r!="function"||e.hasOwnProperty(t))&&!(i&&i.get)&&(r=kn(o,t,r)())}return zt(r)?vi(r):r},has(e,t){return t===io||t===fe||t===Qt||t===Ht||t===Je||t==="__proto__"?!0:(Rn()&&kn(so(e,Je),t)(),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:Nl,getOwnPropertyDescriptor:Ll};function Ut(e,t,n,o=!1){if(!o&&e[t]===n)return;let a=e[t],r=e.length;n===void 0?(delete e[t],e[Je]&&e[Je][t]&&a!==void 0&&e[Je][t].$()):(e[t]=n,e[Je]&&e[Je][t]&&a===void 0&&e[Je][t].$());let i=so(e,Ht),s;if((s=kn(i,t,a))&&s.$(()=>n),Array.isArray(e)&&e.length!==r){for(let c=e.length;c1){o=t.shift();let i=typeof o,s=Array.isArray(e);if(Array.isArray(o)){for(let c=0;c1){fn(e[o],t,[o].concat(n));return}a=e[o],n=[o].concat(n)}let r=t[0];typeof r=="function"&&(r=r(a,n),r===a)||o===void 0&&r==null||(r=jt(r),o===void 0||zt(a)&&zt(r)&&!Array.isArray(r)?wi(a,r):Ut(e,o,r))}function _t(...[e,t]){let n=jt(e||{}),o=Array.isArray(n),a=vi(n);function r(...i){Fo(()=>{o&&i.length===1?Il(n,i[0]):fn(n,i)})}return[a,r]}var J0=Symbol("store-root");var co=new WeakMap,xi={get(e,t){if(t===io)return e;let n=e[t],o;return zt(n)?co.get(n)||(co.set(n,o=new Proxy(n,xi)),o):n},set(e,t,n){return Ut(e,t,jt(n)),!0},deleteProperty(e,t){return Ut(e,t,void 0,!0),!0}};function mn(e){return t=>{if(zt(t)){let n;(n=co.get(t))||co.set(t,n=new Proxy(t,xi)),e(n)}return t}}var Pl=e=>typeof e=="function",po=(e,t)=>Pl(e)?e(t):e,le;(function(e){e[e.ADD_TOAST=0]="ADD_TOAST",e[e.UPDATE_TOAST=1]="UPDATE_TOAST",e[e.UPSERT_TOAST=2]="UPSERT_TOAST",e[e.DISMISS_TOAST=3]="DISMISS_TOAST",e[e.REMOVE_TOAST=4]="REMOVE_TOAST",e[e.START_PAUSE=5]="START_PAUSE",e[e.END_PAUSE=6]="END_PAUSE"})(le||(le={}));var[mt,ot]=_t({toasts:[],pausedAt:void 0}),Dl=()=>{let{pausedAt:e,toasts:t}=mt;if(e)return;let n=Date.now();return t.map(a=>{if(a.duration===1/0)return;let r=(a.duration||0)+a.pauseDuration-(n-a.createdAt);if(r<=0){a.visible&&Ee({type:le.DISMISS_TOAST,toastId:a.id});return}return setTimeout(()=>{Ee({type:le.DISMISS_TOAST,toastId:a.id})},r)})},gn=new Map,Ci=(e,t)=>{if(gn.has(e))return;let n=setTimeout(()=>{gn.delete(e),Ee({type:le.REMOVE_TOAST,toastId:e})},t);gn.set(e,n)},Al=e=>{let t=gn.get(e);gn.delete(e),t&&clearTimeout(t)},Ee=e=>{switch(e.type){case le.ADD_TOAST:ot("toasts",a=>{let r=a;return[e.toast,...r]});break;case le.DISMISS_TOAST:let{toastId:t}=e,n=mt.toasts;if(t){let a=n.find(r=>r.id===t);a&&Ci(t,a.unmountDelay),ot("toasts",r=>r.id===t,mn(r=>r.visible=!1))}else n.forEach(a=>{Ci(a.id,a.unmountDelay)}),ot("toasts",a=>a.id!==void 0,mn(a=>a.visible=!1));break;case le.REMOVE_TOAST:if(!e.toastId){ot("toasts",[]);break}ot("toasts",a=>a.filter(i=>i.id!==e.toastId));break;case le.UPDATE_TOAST:e.toast.id&&Al(e.toast.id),ot("toasts",a=>a.id===e.toast.id,a=>({...a,...e.toast}));break;case le.UPSERT_TOAST:mt.toasts.find(a=>a.id===e.toast.id)?Ee({type:le.UPDATE_TOAST,toast:e.toast}):Ee({type:le.ADD_TOAST,toast:e.toast});break;case le.START_PAUSE:ot(mn(a=>{a.pausedAt=Date.now(),a.toasts.forEach(r=>{r.paused=!0})}));break;case le.END_PAUSE:let o=e.time-(mt.pausedAt||0);ot(mn(a=>{a.pausedAt=void 0,a.toasts.forEach(r=>{r.pauseDuration+=o,r.paused=!1})}));break}},Tl={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},Gt={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},bi={position:"top-right",toastOptions:Gt,gutter:8,containerStyle:{},containerClassName:""},lo="16px",Fl={position:"fixed","z-index":9999,top:lo,bottom:lo,left:lo,right:lo,"pointer-events":"none"},Ol=(()=>{let e=0;return()=>String(++e)})(),Rl=e=>{jl(t=>({containerClassName:e.containerClassName??t.containerClassName,containerStyle:e.containerStyle??t.containerStyle,gutter:e.gutter??t.gutter,position:e.position??t.position,toastOptions:{...e.toastOptions}}))},ql=(e,t)=>{let o=e.includes("top")?{top:0,"margin-top":`${t}px`}:{bottom:0,"margin-bottom":`${t}px`},a=e.includes("center")?{"justify-content":"center"}:e.includes("right")?{"justify-content":"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",...o,...a}},Vl=(e,t)=>{let n=e.getBoundingClientRect();n.height!==t.height&&Ee({type:le.UPDATE_TOAST,toast:{id:t.id,height:n.height}})},Bl=(e,t)=>{let{toasts:n}=mt,o=Kt().gutter||bi.gutter||8,a=n.filter(c=>(c.position||t)===t&&c.height),r=a.findIndex(c=>c.id===e.id),i=a.filter((c,l)=>lc+o+(l.height||0),0)},El=(e,t)=>(e.position||t).includes("top")?1:-1,Hl={display:"flex","align-items":"center",color:"#363636",background:"white","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},zl={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},uo={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},yo=e=>({calcMode:"spline",keyTimes:"0; 1",keySplines:e}),[Kt,jl]=P(bi),Ul=(e,t="blank",n)=>({...Gt,...Kt().toastOptions,...n,type:t,message:e,pauseDuration:0,createdAt:Date.now(),visible:!0,id:n.id||Ol(),paused:!1,style:{...Gt.style,...Kt().toastOptions?.style,...n.style},duration:n.duration||Kt().toastOptions?.duration||Tl[t],position:n.position||Kt().toastOptions?.position||Kt().position||Gt.position}),vn=e=>(t,n={})=>Fe(()=>{let o=mt.toasts.find(r=>r.id===n.id),a=Ul(t,e,{...o,duration:void 0,...n});return Ee({type:le.UPSERT_TOAST,toast:a}),a.id}),Ce=(e,t)=>vn("blank")(e,t);Q(()=>Ce);Ce.error=vn("error");Ce.success=vn("success");Ce.loading=vn("loading");Ce.custom=vn("custom");Ce.dismiss=e=>{Ee({type:le.DISMISS_TOAST,toastId:e})};Ce.promise=(e,t,n)=>{let o=Ce.loading(t.loading,{...n});return e.then(a=>(Ce.success(po(t.success,a),{id:o,...n}),a)).catch(a=>{Ce.error(po(t.error,a),{id:o,...n})}),e};Ce.remove=e=>{Ee({type:le.REMOVE_TOAST,toastId:e})};var _l=z("
",4),Si=e=>(I(()=>{Rl(e)}),I(()=>{let t=Dl();T(()=>{t&&t.forEach(n=>n&&clearTimeout(n))})}),(()=>{let t=_l.cloneNode(!0);return t.firstChild,D(t,f(Me,{get each(){return mt.toasts},children:n=>f(Zl,{toast:n})}),null),U(n=>{let o={...Fl,...e.containerStyle},a=e.containerClassName;return n._v$=he(t,o,n._v$),a!==n._v$2&&en(t,n._v$2=a),n},{_v$:void 0,_v$2:void 0}),t})()),ho=z("
",2),Kl=z("
",4),Gl=e=>{let t;return I(()=>{if(!t)return;let n=El(e.toast,e.position);e.toast.visible?t.animate([{transform:`translate3d(0,${n*-200}%,0) scale(.6)`,opacity:.5},{transform:"translate3d(0,0,0) scale(1)",opacity:1}],{duration:350,fill:"forwards",easing:"cubic-bezier(.21,1.02,.73,1)"}):t.animate([{transform:"translate3d(0,0,-1px) scale(1)",opacity:1},{transform:`translate3d(0,${n*-150}%,-1px) scale(.4)`,opacity:0}],{duration:400,fill:"forwards",easing:"cubic-bezier(.06,.71,.55,1)"})}),(()=>{let n=Kl.cloneNode(!0),o=n.firstChild,a=t;return typeof a=="function"?a(n):t=n,D(n,f(Hn,{get children(){return[f(lt,{get when(){return e.toast.icon},get children(){let r=ho.cloneNode(!0);return D(r,()=>e.toast.icon),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="loading"},get children(){let r=ho.cloneNode(!0);return D(r,f(od,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="success"},get children(){let r=ho.cloneNode(!0);return D(r,f(Ql,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}}),f(lt,{get when(){return e.toast.type==="error"},get children(){let r=ho.cloneNode(!0);return D(r,f(td,$(()=>e.toast.iconTheme))),U(i=>he(r,uo,i)),r}})]}}),o),ie(o,()=>e.toast.ariaProps,!1,!0),D(o,()=>po(e.toast.message,e.toast)),U(r=>{let i=e.toast.className,s={...Hl,...e.toast.style},c=zl;return i!==r._v$&&en(n,r._v$=i),r._v$2=he(n,s,r._v$2),r._v$3=he(o,c,r._v$3),r},{_v$:void 0,_v$2:void 0,_v$3:void 0}),n})()},Wl=z("
",2),Zl=e=>{let t=()=>{let a=e.toast.position||Gt.position,r=Bl(e.toast,a);return ql(a,r)},n=O(()=>t()),o;return pe(()=>{o&&Vl(o,e.toast)}),(()=>{let a=Wl.cloneNode(!0);a.addEventListener("mouseleave",()=>Ee({type:le.END_PAUSE,time:Date.now()})),a.addEventListener("mouseenter",()=>Ee({type:le.START_PAUSE,time:Date.now()}));let r=o;return typeof r=="function"?r(a):o=a,D(a,(()=>{let i=O(()=>e.toast.type==="custom",!0);return()=>i()?po(e.toast.message,e.toast):f(Gl,{get toast(){return e.toast},get position(){return e.toast.position||Gt.position}})})()),U(i=>{let s=n(),c=e.toast.visible?"sldt-active":"";return i._v$=he(a,s,i._v$),c!==i._v$2&&en(a,i._v$2=c),i},{_v$:void 0,_v$2:void 0}),a})()},Xl=z('',8,!0),Yl=z('',8,!0),Li=e=>{let t={dur:"0.35s",begin:"100ms",fill:"freeze",calcMode:"spline",keyTimes:"0; 0.6; 1",keySplines:"0.25 0.71 0.4 0.88; .59 .22 .87 .63"};return(()=>{let n=Xl.cloneNode(!0),o=n.firstChild,a=o.nextSibling;return ie(o,t,!0,!1),ie(a,t,!0,!1),U(()=>ee(n,"fill",e.fill)),n})()},Ni=e=>{let t={dur:"1s",begin:e.begin||"320ms",fill:"freeze",...yo("0.0 0.0 0.2 1")};return(()=>{let n=Yl.cloneNode(!0),o=n.firstChild,a=o.nextSibling;return ie(o,t,!0,!1),ie(a,t,!0,!1),U(()=>ee(n,"fill",e.fill)),n})()},Jl=z('',6),Ql=e=>{let t=e.primary||"#34C759";return(()=>{let n=Jl.cloneNode(!0),o=n.firstChild,a=o.firstChild;return n.style.setProperty("overflow","visible"),D(n,f(Li,{fill:t}),o),D(n,f(Ni,{fill:t,begin:"350ms"}),o),ie(a,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),U(()=>ee(o,"stroke",e.secondary||"#FCFCFC")),n})()},ed=z('',10),td=e=>{let t=e.primary||"#FF3B30";return(()=>{let n=ed.cloneNode(!0),o=n.firstChild,a=o.firstChild,r=o.nextSibling,i=r.firstChild;return n.style.setProperty("overflow","visible"),D(n,f(Li,{fill:t}),o),D(n,f(Ni,{fill:t}),o),ie(a,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),ie(i,()=>yo("0.0, 0.0, 0.58, 1.0"),!0,!1),U(s=>{let c=e.secondary||"#FFFFFF",l=e.secondary||"#FFFFFF";return c!==s._v$&&ee(o,"stroke",s._v$=c),l!==s._v$2&&ee(r,"fill",s._v$2=l),s},{_v$:void 0,_v$2:void 0}),n})()},nd=z('',8),od=e=>(()=>{let t=nd.cloneNode(!0),n=t.firstChild,o=n.nextSibling;return t.style.setProperty("overflow","visible"),U(a=>{let r=e.primary||"#E5E7EB",i=e.secondary||"#4b5563";return r!==a._v$&&ee(n,"stroke",a._v$=r),i!==a._v$2&&ee(o,"stroke",a._v$2=i),a},{_v$:void 0,_v$2:void 0}),t})(),ca=Ce;var at=class{constructor(t){this.value=t}valueOf(){return this.value}},te=class extends at{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}},be=class extends at{constructor(t,n={}){super(t),this.opts=n}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(n){return t.reportError(n),this.value.toString(10)}}},je=class extends at{constructor(t,n={}){super(t),this.opts=n}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(n){return t.reportError(n),new Date(this.value).toISOString()}}};var $i=100,ad="\u2068",rd="\u2069";function id(e,t,n){if(n===t||n instanceof be&&t instanceof be&&n.value===t.value)return!0;if(t instanceof be&&typeof n=="string"){let o=e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value);if(n===o)return!0}return!1}function Ii(e,t,n){return t[n]?Wt(e,t[n].value):(e.reportError(new RangeError("No default")),new te)}function la(e,t){let n=[],o=Object.create(null);for(let a of t)a.type==="narg"?o[a.name]=Mn(e,a.value):n.push(Mn(e,a));return{positional:n,named:o}}function Mn(e,t){switch(t.type){case"str":return t.value;case"num":return new be(t.value,{minimumFractionDigits:t.precision});case"var":return sd(e,t);case"mesg":return cd(e,t);case"term":return ld(e,t);case"func":return dd(e,t);case"select":return ud(e,t);default:return new te}}function sd(e,{name:t}){let n;if(e.params)if(Object.prototype.hasOwnProperty.call(e.params,t))n=e.params[t];else return new te(`$${t}`);else if(e.args&&Object.prototype.hasOwnProperty.call(e.args,t))n=e.args[t];else return e.reportError(new ReferenceError(`Unknown variable: $${t}`)),new te(`$${t}`);if(n instanceof at)return n;switch(typeof n){case"string":return n;case"number":return new be(n);case"object":if(n instanceof Date)return new je(n.getTime());default:return e.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof n}`)),new te(`$${t}`)}}function cd(e,{name:t,attr:n}){let o=e.bundle._messages.get(t);if(!o)return e.reportError(new ReferenceError(`Unknown message: ${t}`)),new te(t);if(n){let a=o.attributes[n];return a?Wt(e,a):(e.reportError(new ReferenceError(`Unknown attribute: ${n}`)),new te(`${t}.${n}`))}return o.value?Wt(e,o.value):(e.reportError(new ReferenceError(`No value: ${t}`)),new te(t))}function ld(e,{name:t,attr:n,args:o}){let a=`-${t}`,r=e.bundle._terms.get(a);if(!r)return e.reportError(new ReferenceError(`Unknown term: ${a}`)),new te(a);if(n){let s=r.attributes[n];if(s){e.params=la(e,o).named;let c=Wt(e,s);return e.params=null,c}return e.reportError(new ReferenceError(`Unknown attribute: ${n}`)),new te(`${a}.${n}`)}e.params=la(e,o).named;let i=Wt(e,r.value);return e.params=null,i}function dd(e,{name:t,args:n}){let o=e.bundle._functions[t];if(!o)return e.reportError(new ReferenceError(`Unknown function: ${t}()`)),new te(`${t}()`);if(typeof o!="function")return e.reportError(new TypeError(`Function ${t}() is not callable`)),new te(`${t}()`);try{let a=la(e,n);return o(a.positional,a.named)}catch(a){return e.reportError(a),new te(`${t}()`)}}function ud(e,{selector:t,variants:n,star:o}){let a=Mn(e,t);if(a instanceof te)return Ii(e,n,o);for(let r of n){let i=Mn(e,r.key);if(id(e,a,i))return Wt(e,r.value)}return Ii(e,n,o)}function da(e,t){if(e.dirty.has(t))return e.reportError(new RangeError("Cyclic reference")),new te;e.dirty.add(t);let n=[],o=e.bundle._useIsolating&&t.length>1;for(let a of t){if(typeof a=="string"){n.push(e.bundle._transform(a));continue}if(e.placeables++,e.placeables>$i)throw e.dirty.delete(t),new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is ${$i}`);o&&n.push(ad),n.push(Mn(e,a).toString(e)),o&&n.push(rd)}return e.dirty.delete(t),n.join("")}function Wt(e,t){return typeof t=="string"?e.bundle._transform(t):da(e,t)}var fo=class{constructor(t,n,o){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=n,this.args=o}reportError(t){if(!this.errors||!(t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,n){let o=this.bundle._intls.get(t);o||(o={},this.bundle._intls.set(t,o));let a=JSON.stringify(n);return o[a]||(o[a]=new t(this.bundle.locales,n)),o[a]}};function ko(e,t){let n=Object.create(null);for(let[o,a]of Object.entries(e))t.includes(o)&&(n[o]=a.valueOf());return n}var Pi=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Ai(e,t){let n=e[0];if(n instanceof te)return new te(`NUMBER(${n.valueOf()})`);if(n instanceof be)return new be(n.valueOf(),{...n.opts,...ko(t,Pi)});if(n instanceof je)return new be(n.valueOf(),{...ko(t,Pi)});throw new TypeError("Invalid argument to NUMBER")}var Di=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ti(e,t){let n=e[0];if(n instanceof te)return new te(`DATETIME(${n.valueOf()})`);if(n instanceof je)return new je(n.valueOf(),{...n.opts,...ko(t,Di)});if(n instanceof be)return new je(n.valueOf(),{...ko(t,Di)});throw new TypeError("Invalid argument to DATETIME")}var Fi=new Map;function Oi(e){let t=Array.isArray(e)?e.join(" "):e,n=Fi.get(t);return n===void 0&&(n=new Map,Fi.set(t,n)),n}var wn=class{constructor(t,{functions:n,useIsolating:o=!0,transform:a=r=>r}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Ai,DATETIME:Ti,...n},this._useIsolating=o,this._transform=a,this._intls=Oi(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:n=!1}={}){let o=[];for(let a=0;a\s*/y,bd=/\s*:\s*/y,Sd=/\s*,?\s*/y,Ld=/\s+/y,xn=class{constructor(t){this.body=[],ua.lastIndex=0;let n=0;for(;;){let C=ua.exec(t);if(C===null)break;n=ua.lastIndex;try{this.body.push(c(C[1]))}catch(k){if(k instanceof SyntaxError)continue;throw k}}function o(C){return C.lastIndex=n,C.test(t)}function a(C,k){if(t[n]===C)return n++,!0;if(k)throw new k(`Expected ${C}`);return!1}function r(C,k){if(o(C))return n=C.lastIndex,!0;if(k)throw new k(`Expected ${C.toString()}`);return!1}function i(C){C.lastIndex=n;let k=C.exec(t);if(k===null)throw new SyntaxError(`Expected ${C.toString()}`);return n=C.lastIndex,k}function s(C){return i(C)[1]}function c(C){let k=u(),g=l();if(k===null&&Object.keys(g).length===0)throw new SyntaxError("Expected message value or attributes");return{id:C,value:k,attributes:g}}function l(){let C=Object.create(null);for(;o(Ri);){let k=s(Ri),g=u();if(g===null)throw new SyntaxError("Expected attribute value");C[k]=g}return C}function u(){let C;if(o(mo)&&(C=s(mo)),t[n]==="{"||t[n]==="}")return d(C?[C]:[],1/0);let k=R();return k?C?d([C,k],k.length):(k.value=j(k.value,kd),d([k],k.length)):C?j(C,Ei):null}function d(C=[],k){for(;;){if(o(mo)){C.push(s(mo));continue}if(t[n]==="{"){C.push(h());continue}if(t[n]==="}")throw new SyntaxError("Unbalanced closing brace");let b=R();if(b){C.push(b),k=Math.min(k,b.length);continue}break}let g=C.length-1,M=C[g];typeof M=="string"&&(C[g]=j(M,Ei));let N=[];for(let b of C)b instanceof go&&(b=b.value.slice(0,b.value.length-k)),b&&N.push(b);return N}function h(){r(vd,SyntaxError);let C=y();if(r(Hi))return C;if(r(Cd)){let k=x();return r(Hi,SyntaxError),{type:"select",selector:C,...k}}throw new SyntaxError("Unclosed placeable")}function y(){if(t[n]==="{")return h();if(o(qi)){let[,C,k,g=null]=i(qi);if(C==="$")return{type:"var",name:k};if(r(xd)){let M=p();if(C==="-")return{type:"term",name:k,attr:g,args:M};if(yd.test(k))return{type:"func",name:k,args:M};throw new SyntaxError("Function names must be all upper-case")}return C==="-"?{type:"term",name:k,attr:g,args:[]}:{type:"mesg",name:k,attr:g}}return w()}function p(){let C=[];for(;;){switch(t[n]){case")":return n++,C;case void 0:throw new SyntaxError("Unclosed argument list")}C.push(m()),r(Sd)}}function m(){let C=y();return C.type!=="mesg"?C:r(bd)?{type:"narg",name:C.name,value:w()}:C}function x(){let C=[],k=0,g;for(;o(hd);){a("*")&&(g=k);let M=v(),N=u();if(N===null)throw new SyntaxError("Expected variant value");C[k++]={key:M,value:N}}if(k===0)return null;if(g===void 0)throw new SyntaxError("Expected default variant");return{variants:C,star:g}}function v(){r(Md,SyntaxError);let C;return o(ha)?C=L():C={type:"str",value:s(pd)},r(wd,SyntaxError),C}function w(){if(o(ha))return L();if(t[n]==='"')return A();throw new SyntaxError("Invalid expression")}function L(){let[,C,k=""]=i(ha),g=k.length;return{type:"num",value:parseFloat(C),precision:g}}function A(){a('"',SyntaxError);let C="";for(;;){if(C+=s(fd),t[n]==="\\"){C+=q();continue}if(a('"'))return{type:"str",value:C};throw new SyntaxError("Unclosed string literal")}}function q(){if(o(Vi))return s(Vi);if(o(Bi)){let[,C,k]=i(Bi),g=parseInt(C||k,16);return g<=55295||57344<=g?String.fromCodePoint(g):"\uFFFD"}throw new SyntaxError("Unknown escape sequence")}function R(){let C=n;switch(r(Ld),t[n]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return _(t.slice(C,n))}return t[n-1]===" "?_(t.slice(C,n)):!1}function j(C,k){return C.replace(k,"")}function _(C){let k=C.replace(md,` +`),g=gd.exec(C)[1].length;return new go(k,g)}}},go=class{constructor(t,n){this.value=t,this.length=n}};var Nd="([a-z]{2,3}|\\*)",$d="(?:-([a-z]{4}|\\*))",Id="(?:-([a-z]{2}|\\*))",Pd="(?:-(([0-9][a-z0-9]{3}|[a-z0-9]{5,8})|\\*))",Dd=new RegExp(`^${Nd}${$d}?${Id}?${Pd}?$`,"i"),rt=class{constructor(t){let n=Dd.exec(t.replace(/_/g,"-"));if(!n){this.isWellFormed=!1;return}let[,o,a,r,i]=n;o&&(this.language=o.toLowerCase()),a&&(this.script=a[0].toUpperCase()+a.slice(1)),r&&(this.region=r.toUpperCase()),this.variant=i,this.isWellFormed=!0}isEqual(t){return this.language===t.language&&this.script===t.script&&this.region===t.region&&this.variant===t.variant}matches(t,n=!1,o=!1){return(this.language===t.language||n&&this.language===void 0||o&&t.language===void 0)&&(this.script===t.script||n&&this.script===void 0||o&&t.script===void 0)&&(this.region===t.region||n&&this.region===void 0||o&&t.region===void 0)&&(this.variant===t.variant||n&&this.variant===void 0||o&&t.variant===void 0)}toString(){return[this.language,this.script,this.region,this.variant].filter(t=>t!==void 0).join("-")}clearVariants(){this.variant=void 0}clearRegion(){this.region=void 0}addLikelySubtags(){let t=Td(this.toString().toLowerCase());return t?(this.language=t.language,this.script=t.script,this.region=t.region,this.variant=t.variant,!0):!1}},zi={ar:"ar-arab-eg","az-arab":"az-arab-ir","az-ir":"az-arab-ir",be:"be-cyrl-by",da:"da-latn-dk",el:"el-grek-gr",en:"en-latn-us",fa:"fa-arab-ir",ja:"ja-jpan-jp",ko:"ko-kore-kr",pt:"pt-latn-br",sr:"sr-cyrl-rs","sr-ru":"sr-latn-ru",sv:"sv-latn-se",ta:"ta-taml-in",uk:"uk-cyrl-ua",zh:"zh-hans-cn","zh-hant":"zh-hant-tw","zh-hk":"zh-hant-hk","zh-mo":"zh-hant-mo","zh-tw":"zh-hant-tw","zh-gb":"zh-hant-gb","zh-us":"zh-hant-us"},Ad=["az","bg","cs","de","es","fi","fr","hu","it","lt","lv","nl","pl","ro","ru"];function Td(e){if(Object.prototype.hasOwnProperty.call(zi,e))return new rt(zi[e]);let t=new rt(e);return t.language&&Ad.includes(t.language)?(t.region=t.language.toUpperCase(),t):null}function pa(e,t,n){let o=new Set,a=new Map;for(let r of t)new rt(r).isWellFormed&&a.set(r,new rt(r));e:for(let r of e){let i=r.toLowerCase(),s=new rt(i);if(s.language!==void 0){for(let c of a.keys())if(i===c.toLowerCase()){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}if(s.addLikelySubtags()){for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}s.clearVariants();for(let[c,l]of a.entries())if(l.matches(s,!0,!0)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}if(s.clearRegion(),s.addLikelySubtags()){for(let[c,l]of a.entries())if(l.matches(s,!0,!1)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}s.clearRegion();for(let[c,l]of a.entries())if(l.matches(s,!0,!0)){if(o.add(c),a.delete(c),n==="lookup")return Array.from(o);if(n==="filtering")continue;continue e}}}return Array.from(o)}function ya(e,t,{strategy:n="filtering",defaultLocale:o}={}){let a=pa(Array.from(e??[]).map(String),Array.from(t??[]).map(String),n);if(n==="lookup"){if(o===void 0)throw new Error("defaultLocale cannot be undefined for strategy `lookup`");a.length===0&&a.push(o)}else o&&!a.includes(o)&&a.push(o);return a}var ji=1,Fd=.9,Od=.8,Rd=.17,fa=.1,ka=.999,qd=.9999,Vd=.99,Bd=/[\\\/_+.#"@\[\(\{&]/,Ed=/[\\\/_+.#"@\[\(\{&]/g,Hd=/[\s-]/,_i=/[\s-]/g;function ma(e,t,n,o,a,r,i){if(r===t.length)return a===e.length?ji:Vd;var s=`${a},${r}`;if(i[s]!==void 0)return i[s];for(var c=o.charAt(r),l=n.indexOf(c,a),u=0,d,h,y,p;l>=0;)d=ma(e,t,n,o,l+1,r+1,i),d>u&&(l===a?d*=ji:Bd.test(e.charAt(l-1))?(d*=Od,y=e.slice(a,l-1).match(Ed),y&&a>0&&(d*=Math.pow(ka,y.length))):Hd.test(e.charAt(l-1))?(d*=Fd,p=e.slice(a,l-1).match(_i),p&&a>0&&(d*=Math.pow(ka,p.length))):(d*=Rd,a>0&&(d*=Math.pow(ka,l-a))),e.charAt(l)!==t.charAt(r)&&(d*=qd)),(dd&&(d=h*fa)),d>u&&(u=d),l=n.indexOf(c,l+1);return i[s]=u,u}function Ui(e){return e.toLowerCase().replace(_i," ")}function Ki(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ma(e,t,Ui(e),Ui(t),0,0,{})}var Se=e=>typeof e=="function"?e():e;var vo=new Map,zd=e=>{I(()=>{let t=Se(e.style)??{},n=Se(e.properties)??[],o={};for(let r in t)o[r]=e.element.style[r];let a=vo.get(e.key);a?a.activeCount++:vo.set(e.key,{activeCount:1,originalStyles:o,properties:n.map(r=>r.key)}),Object.assign(e.element.style,e.style);for(let r of n)e.element.style.setProperty(r.key,r.value);T(()=>{let r=vo.get(e.key);if(r){if(r.activeCount!==1){r.activeCount--;return}vo.delete(e.key);for(let[i,s]of Object.entries(r.originalStyles))e.element.style[i]=s;for(let i of r.properties)e.element.style.removeProperty(i);e.element.style.length===0&&e.element.removeAttribute("style"),e.cleanup?.()}})})},Mo=zd;var jd=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Ud=(e,t)=>{let n=getComputedStyle(e),o=t==="x"?n.overflowX:n.overflowY;return o==="auto"||o==="scroll"||e.tagName==="HTML"&&o==="visible"},Gi=(e,t,n)=>{let o=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1,a=e,r=0,i=0,s=!1;do{let[c,l,u]=jd(a,t),d=u-c-o*l;(l!==0||d!==0)&&Ud(a,t)&&(r+=d,i+=l),a===(n??document.documentElement)?s=!0:a=a._$host??a.parentElement}while(a&&!s);return[r,i]};var[Wi,Zi]=P([]),_d=e=>Wi().indexOf(e)===Wi().length-1,Kd=e=>{let t=$({element:null,enabled:!0,hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",allowPinchZoom:!1},e),n=me(),o=[0,0],a=null,r=null;I(()=>{Se(t.enabled)&&(Zi(l=>[...l,n]),T(()=>{Zi(l=>l.filter(u=>u!==n))}))}),I(()=>{if(!Se(t.enabled)||!Se(t.hideScrollbar))return;let{body:l}=document,u=window.innerWidth-l.offsetWidth;if(Mo({key:"prevent-scroll-overflow",element:l,style:{overflow:"hidden"}}),Se(t.preventScrollbarShift)){let d={},h=[];u>0&&(Se(t.preventScrollbarShiftMode)==="padding"?d.paddingRight=`calc(${window.getComputedStyle(l).paddingRight} + ${u}px)`:d.marginRight=`calc(${window.getComputedStyle(l).marginRight} + ${u}px)`,h.push({key:"--scrollbar-width",value:`${u}px`}));let y=window.scrollY,p=window.scrollX;Mo({key:"prevent-scroll-scrollbar",element:l,style:d,properties:h,cleanup:()=>{u>0&&window.scrollTo(p,y)}})}}),I(()=>{!_d(n)||!Se(t.enabled)||(document.addEventListener("wheel",s,{passive:!1}),document.addEventListener("touchstart",i,{passive:!1}),document.addEventListener("touchmove",c,{passive:!1}),T(()=>{document.removeEventListener("wheel",s),document.removeEventListener("touchstart",i),document.removeEventListener("touchmove",c)}))});let i=l=>{o=Xi(l),a=null,r=null},s=l=>{let u=l.target,d=Se(t.element),h=Gd(l),y=Math.abs(h[0])>Math.abs(h[1])?"x":"y",p=y==="x"?h[0]:h[1],m=Yi(u,y,p,d),x;d&&ga(d,u)?x=!m:x=!0,x&&l.cancelable&&l.preventDefault()},c=l=>{let u=Se(t.element),d=l.target,h;if(l.touches.length===2)h=!Se(t.allowPinchZoom);else{if(a==null||r===null){let y=Xi(l).map((m,x)=>o[x]-m),p=Math.abs(y[0])>Math.abs(y[1])?"x":"y";a=p,r=p==="x"?y[0]:y[1]}if(d.type==="range")h=!1;else{let y=Yi(d,a,r,u);u&&ga(u,d)?h=!y:h=!0}}h&&l.cancelable&&l.preventDefault()}},Gd=e=>[e.deltaX,e.deltaY],Xi=e=>e.changedTouches[0]?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0],Yi=(e,t,n,o)=>{let a=o!==null&&ga(o,e),[r,i]=Gi(e,t,a?o:void 0);return!(n>0&&Math.abs(r)<=1||n<0&&Math.abs(i)<1)},ga=(e,t)=>{if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;n=n._$host??n.parentElement}return!1},Wd=Kd,wo=Wd;var gy=F();var ls="kb-color-mode";function Zd(e){return{ssr:!1,type:"localStorage",get:t=>{if(X)return t;let n;try{n=localStorage.getItem(e)}catch{}return n??t},set:t=>{try{localStorage.setItem(e,t)}catch{}}}}var vy=Zd(ls);function Ji(e,t){return e.match(new RegExp(`(^| )${t}=([^;]+)`))?.[2]}function Xd(e,t){return{ssr:!!t,type:"cookie",get:n=>t?Ji(t,e)??n:X?n:Ji(document.cookie,e)??n,set:n=>{document.cookie=`${e}=${n}; max-age=31536000; path=/`}}}var My=Xd(ls);function Yd(e){let[t,n]=P(e.defaultValue?.()),o=O(()=>e.value?.()!==void 0),a=O(()=>o()?e.value?.():t());return[a,i=>{Q(()=>{let s=$t(i,a());return Object.is(s,a())||(o()||n(s),e.onChange?.(s)),s})}]}function Jd(e){let[t,n]=Yd(e);return[()=>t()??!1,n]}function Qd(e={}){let[t,n]=Jd({value:()=>W(e.open),defaultValue:()=>!!W(e.defaultOpen),onChange:i=>e.onOpenChange?.(i)}),o=()=>{n(!0)},a=()=>{n(!1)};return{isOpen:t,setIsOpen:n,open:o,close:a,toggle:()=>{t()?a():o()}}}function e2(e){let t=n=>{n.key===on.Escape&&e.onEscapeKeyDown?.(n)};I(()=>{if(X||W(e.isDisabled))return;let n=e.ownerDocument?.()??oe();n.addEventListener("keydown",t),T(()=>{n.removeEventListener("keydown",t)})})}var Co="data-kb-top-layer",ds,xa=!1,Qe=[];function bn(e){return Qe.findIndex(t=>t.node===e)}function t2(e){return Qe[bn(e)]}function n2(e){return Qe[Qe.length-1].node===e}function us(){return Qe.filter(e=>e.isPointerBlocking)}function o2(){return[...us()].slice(-1)[0]}function Ca(){return us().length>0}function hs(e){let t=bn(o2()?.node);return bn(e)e.onMountAutoFocus?.(p),s=p=>e.onUnmountAutoFocus?.(p),c=()=>oe(t()),l=()=>{let p=c().createElement("span");return p.setAttribute("data-focus-trap",""),p.tabIndex=0,Object.assign(p.style,Zn),p},u=()=>{let p=t();return p?an(p,!0).filter(m=>!m.hasAttribute("data-focus-trap")):[]},d=()=>{let p=u();return p.length>0?p[0]:null},h=()=>{let p=u();return p.length>0?p[p.length-1]:null},y=()=>{let p=t();if(!p)return!1;let m=Re(p);return!m||J(p,m)?!1:rn(m)};I(()=>{if(X)return;let p=t();if(!p)return;es.add(a);let m=Re(p);if(!J(p,m)){let v=new CustomEvent(va,Qi);p.addEventListener(va,i),p.dispatchEvent(v),v.defaultPrevented||setTimeout(()=>{se(d()),Re(p)===m&&se(p)},0)}T(()=>{p.removeEventListener(va,i),setTimeout(()=>{let v=new CustomEvent(Ma,Qi);y()&&v.preventDefault(),p.addEventListener(Ma,s),p.dispatchEvent(v),v.defaultPrevented||se(m??c().body),p.removeEventListener(Ma,s),es.remove(a)},0)})}),I(()=>{if(X)return;let p=t();if(!p||!W(e.trapFocus)||n())return;let m=v=>{let w=v.target;w?.closest(`[${Co}]`)||(J(p,w)?r=w:se(r))},x=v=>{let L=v.relatedTarget??Re(p);L?.closest(`[${Co}]`)||J(p,L)||se(r)};c().addEventListener("focusin",m),c().addEventListener("focusout",x),T(()=>{c().removeEventListener("focusin",m),c().removeEventListener("focusout",x)})}),I(()=>{if(X)return;let p=t();if(!p||!W(e.trapFocus)||n())return;let m=l();p.insertAdjacentElement("afterbegin",m);let x=l();p.insertAdjacentElement("beforeend",x);function v(L){let A=d(),q=h();L.relatedTarget===A?se(q):se(A)}m.addEventListener("focusin",v),x.addEventListener("focusin",v);let w=new MutationObserver(L=>{for(let A of L)A.previousSibling===x&&(x.remove(),p.insertAdjacentElement("beforeend",x)),A.nextSibling===m&&(m.remove(),p.insertAdjacentElement("afterbegin",m))});w.observe(p,{childList:!0,subtree:!1}),T(()=>{m.removeEventListener("focusin",v),x.removeEventListener("focusin",v),m.remove(),x.remove(),w.disconnect()})})}var d2="data-live-announcer";function u2(e){I(()=>{W(e.isDisabled)||T(h2(W(e.targets),W(e.root)))})}var Cn=new WeakMap,De=[];function h2(e,t=document.body){let n=new Set(e),o=new Set,a=c=>{for(let h of c.querySelectorAll(`[${d2}], [${Co}]`))n.add(h);let l=h=>{if(n.has(h)||h.parentElement&&o.has(h.parentElement)&&h.parentElement.getAttribute("role")!=="row")return NodeFilter.FILTER_REJECT;for(let y of n)if(h.contains(y))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},u=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,{acceptNode:l}),d=l(c);if(d===NodeFilter.FILTER_ACCEPT&&r(c),d!==NodeFilter.FILTER_REJECT){let h=u.nextNode();for(;h!=null;)r(h),h=u.nextNode()}},r=c=>{let l=Cn.get(c)??0;c.getAttribute("aria-hidden")==="true"&&l===0||(l===0&&c.setAttribute("aria-hidden","true"),o.add(c),Cn.set(c,l+1))};De.length&&De[De.length-1].disconnect(),a(t);let i=new MutationObserver(c=>{for(let l of c)if(!(l.type!=="childList"||l.addedNodes.length===0)&&![...n,...o].some(u=>u.contains(l.target))){for(let u of l.removedNodes)u instanceof Element&&(n.delete(u),o.delete(u));for(let u of l.addedNodes)(u instanceof HTMLElement||u instanceof SVGElement)&&(u.dataset.liveAnnouncer==="true"||u.dataset.reactAriaTopLayer==="true")?n.add(u):u instanceof Element&&a(u)}});i.observe(t,{childList:!0,subtree:!0});let s={observe(){i.observe(t,{childList:!0,subtree:!0})},disconnect(){i.disconnect()}};return De.push(s),()=>{i.disconnect();for(let c of o){let l=Cn.get(c);if(l==null)return;l===1?(c.removeAttribute("aria-hidden"),Cn.delete(c)):Cn.set(c,l-1)}s===De[De.length-1]?(De.pop(),De.length&&De[De.length-1].observe()):De.splice(De.indexOf(s),1)}}var ts="interactOutside.pointerDownOutside",ns="interactOutside.focusOutside";function p2(e,t){let n,o=Wn,a=()=>oe(t()),r=d=>e.onPointerDownOutside?.(d),i=d=>e.onFocusOutside?.(d),s=d=>e.onInteractOutside?.(d),c=d=>{let h=d.target;return!(h instanceof HTMLElement)||h.closest(`[${Co}]`)||!J(a(),h)||J(t(),h)?!1:!e.shouldExcludeElement?.(h)},l=d=>{function h(){let y=t(),p=d.target;if(!y||!p||!c(d))return;let m=Dt([r,s]);p.addEventListener(ts,m,{once:!0});let x=new CustomEvent(ts,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:d.button===2||Gn(d)&&d.button===0}});p.dispatchEvent(x)}d.pointerType==="touch"?(a().removeEventListener("click",h),o=h,a().addEventListener("click",h,{once:!0})):h()},u=d=>{let h=t(),y=d.target;if(!h||!y||!c(d))return;let p=Dt([i,s]);y.addEventListener(ns,p,{once:!0});let m=new CustomEvent(ns,{bubbles:!1,cancelable:!0,detail:{originalEvent:d,isContextMenu:!1}});y.dispatchEvent(m)};I(()=>{X||W(e.isDisabled)||(n=window.setTimeout(()=>{a().addEventListener("pointerdown",l,!0)},0),a().addEventListener("focusin",u,!0),T(()=>{window.clearTimeout(n),a().removeEventListener("click",o),a().removeEventListener("pointerdown",l,!0),a().removeEventListener("focusin",u,!0)}))})}function os(e){let[t,n]=P(),o={},a=e(),r="none",[i,s]=y2(e()?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return I(Oe(i,c=>{let l=xo(o);r=c==="mounted"?l:"none"})),I(Oe(e,c=>{if(a===c)return;let l=xo(o);c?s("MOUNT"):o?.display==="none"?s("UNMOUNT"):s(a&&r!==l?"ANIMATION_OUT":"UNMOUNT"),a=c})),I(Oe(t,c=>{if(c){let l=d=>{let y=xo(o).includes(d.animationName);d.target===c&&y&&s("ANIMATION_END")},u=d=>{d.target===c&&(r=xo(o))};c.addEventListener("animationstart",u),c.addEventListener("animationcancel",l),c.addEventListener("animationend",l),T(()=>{c.removeEventListener("animationstart",u),c.removeEventListener("animationcancel",l),c.removeEventListener("animationend",l)})}else s("ANIMATION_END")})),{isPresent:()=>["mounted","unmountSuspended"].includes(i()),setRef:c=>{c&&(o=getComputedStyle(c)),n(c)}}}function xo(e){return e?.animationName||"none"}function y2(e,t){let n=(i,s)=>t[i][s]??i,[o,a]=P(e);return[o,i=>{a(s=>n(s,i))}]}function wa(e){return t=>(e(t),()=>e(void 0))}function f2(e,t){let[n,o]=P(as(t?.()));return I(()=>{o(e()?.tagName.toLowerCase()||as(t?.()))}),n}function as(e){return Kn(e)?e:void 0}var wy=F();function Sn(e){let[t,n]=B(e,["asChild","as","children"]);if(!t.asChild)return f(tt,$({get component(){return t.as}},n,{get children(){return t.children}}));let o=Vn(()=>t.children);if(rs(o())){let a=is(n,o()?.props??{});return f(tt,a)}if(nr(o())){let a=o().find(rs);if(a){let r=()=>f(Me,{get each(){return o()},children:s=>f(G,{when:s===a,fallback:s,get children(){return a.props.children}})}),i=is(n,a?.props??{});return f(tt,$(i,{children:r}))}}throw new Error("[kobalte]: Component is expected to render `asChild` but no children `As` component was found.")}var k2=Symbol("$$KobalteAsComponent");function rs(e){return e?.[k2]===!0}function is(e,t){return Vo([e,t],{reverseEventHandlers:!0})}var m2=new Set(["Avst","Arab","Armi","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),g2=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function v2(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize().script??"";return m2.has(n)}let t=e.split("-")[0];return g2.has(t)}function M2(e){return v2(e)?"rtl":"ltr"}function w2(){let e=typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:M2(e)}}var xy=w2();var Cy=F();var[by,Sy]=_t({toasts:[]});var Ly=F();var x2=["button","color","file","image","reset","submit"];function C2(e){let t=e.tagName.toLowerCase();return t==="button"?!0:t==="input"&&e.type?x2.indexOf(e.type)!==-1:!1}function ps(e){let t,n=re({type:"button"},e),[o,a]=B(n,["ref","type","disabled"]),r=f2(()=>t,()=>"button"),i=O(()=>{let l=r();return l==null?!1:C2({tagName:l,type:o.type})}),s=O(()=>r()==="input"),c=O(()=>r()==="a"&&t?.getAttribute("href")!=null);return f(Sn,$({as:"button",ref(l){let u=ne(d=>t=d,o.ref);typeof u=="function"&&u(l)},get type(){return i()||s()?o.type:void 0},get role(){return!i()&&!c()?"button":void 0},get tabIndex(){return!i()&&!c()&&!o.disabled?0:void 0},get disabled(){return i()||s()?o.disabled:void 0},get"aria-disabled"(){return!i()&&!s()&&o.disabled?!0:void 0},get"data-disabled"(){return o.disabled?"":void 0}},a))}var Ny=F();var $y=F();var Iy=F();var ys=F();function gt(){let e=ue(ys);if(e===void 0)throw new Error("[kobalte]: `useDialogContext` must be used within a `Dialog` component");return e}function b2(e){let t=gt(),[n,o]=B(e,["aria-label","onClick"]);return f(ps,$({get"aria-label"(){return n["aria-label"]||t.translations().dismiss},onClick:r=>{ke(r,n.onClick),t.close()}},o))}var fs=F();function S2(){return ue(fs)}function L2(e){let t,n=S2(),[o,a]=B(e,["ref","disableOutsidePointerEvents","excludedElements","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","bypassTopMostLayerCheck"]),r=new Set([]),i=d=>{r.add(d);let h=n?.registerNestedLayer(d);return()=>{r.delete(d),h?.()}};p2({shouldExcludeElement:d=>t?o.excludedElements?.some(h=>J(h(),d))||[...r].some(h=>J(h,d)):!1,onPointerDownOutside:d=>{!t||$e.isBelowPointerBlockingLayer(t)||!o.bypassTopMostLayerCheck&&!$e.isTopMostLayer(t)||(o.onPointerDownOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.())},onFocusOutside:d=>{o.onFocusOutside?.(d),o.onInteractOutside?.(d),d.defaultPrevented||o.onDismiss?.()}},()=>t),e2({ownerDocument:()=>oe(t),onEscapeKeyDown:d=>{!t||!$e.isTopMostLayer(t)||(o.onEscapeKeyDown?.(d),!d.defaultPrevented&&o.onDismiss&&(d.preventDefault(),o.onDismiss()))}}),pe(()=>{if(!t)return;$e.addLayer({node:t,isPointerBlocking:o.disableOutsidePointerEvents,dismiss:o.onDismiss});let d=n?.registerNestedLayer(t);$e.assignPointerEventToLayers(),$e.disableBodyPointerEvents(t),T(()=>{t&&($e.removeLayer(t),d?.(),$e.assignPointerEventToLayers(),$e.restoreBodyPointerEvents(t))})}),I(Oe([()=>t,()=>o.disableOutsidePointerEvents],([d,h])=>{if(!d)return;let y=$e.find(d);y&&y.isPointerBlocking!==h&&(y.isPointerBlocking=h,$e.assignPointerEventToLayers()),h&&$e.disableBodyPointerEvents(d),T(()=>{$e.restoreBodyPointerEvents(d)})},{defer:!0}));let u={registerNestedLayer:i};return f(fs.Provider,{value:u,get children(){return f(Sn,$({as:"div",ref(d){let h=ne(y=>t=y,o.ref);typeof h=="function"&&h(d)}},a))}})}function N2(e){let t,n=gt(),o=re({id:n.generateId("content")},e),[a,r]=B(o,["ref","onOpenAutoFocus","onCloseAutoFocus","onPointerDownOutside","onFocusOutside","onInteractOutside"]),i=!1,s=!1,c=h=>{a.onPointerDownOutside?.(h),n.modal()&&h.detail.isContextMenu&&h.preventDefault()},l=h=>{a.onFocusOutside?.(h),n.modal()&&h.preventDefault()},u=h=>{a.onInteractOutside?.(h),!n.modal()&&(h.defaultPrevented||(i=!0,h.detail.originalEvent.type==="pointerdown"&&(s=!0)),J(n.triggerRef(),h.target)&&h.preventDefault(),h.detail.originalEvent.type==="focusin"&&s&&h.preventDefault())},d=h=>{a.onCloseAutoFocus?.(h),n.modal()?(h.preventDefault(),se(n.triggerRef())):(h.defaultPrevented||(i||se(n.triggerRef()),h.preventDefault()),i=!1,s=!1)};return u2({isDisabled:()=>!(n.isOpen()&&n.modal()),targets:()=>t?[t]:[]}),wo({element:()=>t??null,enabled:()=>n.isOpen()&&n.preventScroll()}),l2({trapFocus:()=>n.isOpen()&&n.modal(),onMountAutoFocus:a.onOpenAutoFocus,onUnmountAutoFocus:d},()=>t),I(()=>T(n.registerContentId(r.id))),f(G,{get when(){return n.contentPresence.isPresent()},get children(){return f(L2,$({ref(h){let y=ne(p=>{n.contentPresence.setRef(p),t=p},a.ref);typeof y=="function"&&y(h)},role:"dialog",tabIndex:-1,get disableOutsidePointerEvents(){return O(()=>!!n.modal())()&&n.isOpen()},get excludedElements(){return[n.triggerRef]},get"aria-labelledby"(){return n.titleId()},get"aria-describedby"(){return n.descriptionId()},get"data-expanded"(){return n.isOpen()?"":void 0},get"data-closed"(){return n.isOpen()?void 0:""},onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,get onDismiss(){return n.close}},r))}})}function $2(e){let t=gt(),n=re({id:t.generateId("description")},e),[o,a]=B(n,["id"]);return I(()=>T(t.registerDescriptionId(o.id))),f(Sn,$({as:"p",get id(){return o.id}},a))}function I2(e){let t=gt(),[n,o]=B(e,["ref","style","onPointerDown"]),a=r=>{ke(r,n.onPointerDown),r.target===r.currentTarget&&r.preventDefault()};return f(G,{get when(){return t.overlayPresence.isPresent()},get children(){return f(Sn,$({as:"div",ref(r){let i=ne(t.overlayPresence.setRef,n.ref);typeof i=="function"&&i(r)},get style(){return{"pointer-events":"auto",...n.style}},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onPointerDown:a},o))}})}function P2(e){let t=gt();return f(G,{get when(){return t.contentPresence.isPresent()||t.overlayPresence.isPresent()},get children(){return f(Lt,e)}})}var ss={dismiss:"Dismiss"};function D2(e){let t=`dialog-${me()}`,n=re({id:t,modal:!0,translations:ss},e),[o,a]=P(),[r,i]=P(),[s,c]=P(),[l,u]=P(),d=Qd({open:()=>n.open,defaultOpen:()=>n.defaultOpen,onOpenChange:x=>n.onOpenChange?.(x)}),h=()=>n.forceMount||d.isOpen(),y=os(h),p=os(h),m={translations:()=>n.translations??ss,isOpen:d.isOpen,modal:()=>n.modal??!0,preventScroll:()=>n.preventScroll??m.modal(),contentId:o,titleId:r,descriptionId:s,triggerRef:l,overlayPresence:y,contentPresence:p,close:d.close,toggle:d.toggle,setTriggerRef:u,generateId:Pt(()=>n.id),registerContentId:wa(a),registerTitleId:wa(i),registerDescriptionId:wa(c)};return f(ys.Provider,{value:m,get children(){return n.children}})}function A2(e){let t=gt(),n=re({id:t.generateId("title")},e),[o,a]=B(n,["id"]);return I(()=>T(t.registerTitleId(o.id))),f(Sn,$({as:"h2",get id(){return o.id}},a))}function T2(e){let t=gt(),[n,o]=B(e,["ref","onClick"]);return f(ps,$({ref(r){let i=ne(t.setTriggerRef,n.ref);typeof i=="function"&&i(r)},"aria-haspopup":"dialog",get"aria-expanded"(){return t.isOpen()},get"aria-controls"(){return O(()=>!!t.isOpen())()?t.contentId():void 0},get"data-expanded"(){return t.isOpen()?"":void 0},get"data-closed"(){return t.isOpen()?void 0:""},onClick:r=>{ke(r,n.onClick),t.toggle()}},o))}var Ln=Object.freeze({__proto__:null,CloseButton:b2,Content:N2,Description:$2,Overlay:I2,Portal:P2,Root:D2,Title:A2,Trigger:T2});var Py=F();var Dy=F();var Ay=F();var Ty=F();var Fy=F();var Oy=F();var F2=30,Ry=F2/2;var qy=F();var Vy=F();var By=F();var Ey=F();var Hy=F();var zy=F();var jy=F();var Uy=F();var _y=F();var cs=["Enter"," "],Ky={ltr:[...cs,"ArrowRight"],rtl:[...cs,"ArrowLeft"]};var Gy=F();var Wy=F();var Zy=F();var Xy=F();var Yy=F();var Jy=F();var Qy=F();var ef=F();var tf=F();var nf=F();var of=F();var af=F();var rf=F();var sf=F();var cf=F();var lf=F();var df=F();var uf=F();var hf=F();jn(["focusin","focusout","pointermove"]);jn(["keydown","pointerdown","pointermove","pointerup"]);var pf=F();function ba(e){return ks(e,new Set),e}function ks(e,t){let n,o;if(e!=null&&typeof e=="object"&&!t.has(e)&&((n=Array.isArray(e))||e[fe]||!(o=Object.getPrototypeOf(e))||o===Object.prototype)){t.add(e);for(let a of n?e:Object.values(e))ks(a,t)}}var O2=z('