{escape(title)}
+{escape(body)}
+ +diff --git a/README.md b/README.md index 78cef14..20cdefe 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Toggle **This review** (impact subgraph) vs **Indexed architecture** (the repo m ### Pull requests -GitHub and Bitbucket via API tokens from Settings. Pick a PR and jump to a branch-range review. The screenshot uses a fixture PR so the tab is not empty. +GitHub and Bitbucket via **Sign in** (OAuth) or a token in Settings. After connecting, **My repos** lists every repository the account can access. Pick one and jump to a branch-range review. Review still runs against a **local clone** — if that clone is already a Loadpath workspace, selecting the remote repo fills the local path from `git remote`. The screenshot uses a fixture PR so the tab is not empty.  @@ -75,7 +75,11 @@ Browse the filesystem, pick a project root. Loadpath remembers recent workspaces ### Settings -Appearance (all 24 themes), GitHub / Bitbucket tokens, and AI providers (Anthropic, OpenAI, Grok/xAI, DeepSeek, Cursor-compatible, Ollama). Residual analysis only — Loadpath does not comment every hunk. +Appearance (all 24 themes), GitHub / Bitbucket **OAuth sign-in** (or a classic PAT / app password), and AI providers (Anthropic, OpenAI, Grok/xAI, DeepSeek, Cursor-compatible, Ollama). Residual analysis only — Loadpath does not comment every hunk. + +GitHub uses device flow (`repo read:user read:org`). Create an OAuth App, enable Device Flow, then set `LOADPATH_GITHUB_CLIENT_ID` or paste the client ID in Settings. + +Bitbucket uses authorization code. Create an OAuth consumer whose callback is `http://127.0.0.1:7345/api/oauth/bitbucket/callback`, then set `LOADPATH_BITBUCKET_CLIENT_ID` / `LOADPATH_BITBUCKET_CLIENT_SECRET` or paste the key and secret in Settings. Access tokens are refreshed automatically. SCM sign-in and repo listing are local-only (loopback) so a tunneled MCP server does not expose private repos.  @@ -221,7 +225,7 @@ MCP URL: `https://your-tunnel.example/mcp` (or `http://127.0.0.1:7345/mcp` on th **Cursor / Claude / ChatGPT / Gemini (HTTP + OAuth)** — add that MCP URL in the host’s connectors. The first connect opens a consent page on the Loadpath machine. -Tools: `list_workspaces`, `init_repo`, `index_repo`, `architecture`, `review`, `detect_repo`, `list_pull_requests`, `post_review_comment`. `review` returns the load-path brief (confidence, sinks, reviewers) — not hunk comments. +Tools: `list_workspaces`, `init_repo`, `index_repo`, `architecture`, `review`, `detect_repo`, `list_pull_requests`, `list_remote_repositories`, `post_review_comment`. `review` returns the load-path brief (confidence, sinks, reviewers) — not hunk comments. Put `loadpath.yml` at the repo root (see [`loadpath.yml.example`](loadpath.yml.example) and [`fixtures/demo_monorepo/loadpath.yml`](fixtures/demo_monorepo/loadpath.yml)). The tool is opinionated about *your* architecture, not a generic module graph. diff --git a/SECURITY.md b/SECURITY.md index 96ac4e2..7709706 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,4 +4,4 @@ Please report vulnerabilities privately to the repository owner (`Modsofthenatio Once this repository is public, enable [GitHub private vulnerability reporting](https://docs.github.com/code-security/security-advisories/working-with-repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository) so researchers can use Security Advisories. The `/security/advisories/new` form 404s until that setting is on. -Tokens and OAuth state live on the machine that runs Loadpath (`~/.loadpath/`); treat that host as trusted. +Tokens and OAuth state live on the machine that runs Loadpath (`~/.loadpath/`); treat that host as trusted. SCM sign-in, disconnect, and `/api/scm/repos` only accept the local Loadpath UI (loopback Origin/Host), so a tunneled MCP server does not list private repositories. diff --git a/desktop/urls.mjs b/desktop/urls.mjs index e39cf16..397733e 100644 --- a/desktop/urls.mjs +++ b/desktop/urls.mjs @@ -8,11 +8,13 @@ export function isAllowedExternalUrl(url) { if (parsed.protocol !== "https:") return false; if (parsed.username || parsed.password) return false; const host = parsed.hostname.toLowerCase(); - return ( + return ( host === "github.com" || host.endsWith(".github.com") || host === "bitbucket.org" || - host.endsWith(".bitbucket.org") + host.endsWith(".bitbucket.org") || + host === "id.atlassian.com" || + host.endsWith(".atlassian.com") ); } diff --git a/desktop/urls.test.mjs b/desktop/urls.test.mjs index 1a40470..cd1e871 100644 --- a/desktop/urls.test.mjs +++ b/desktop/urls.test.mjs @@ -7,6 +7,7 @@ describe("isAllowedExternalUrl", () => { it("allows GitHub and Bitbucket https PR links", () => { assert.equal(isAllowedExternalUrl("https://github.com/acme/demo/pull/12"), true); assert.equal(isAllowedExternalUrl("https://bitbucket.org/acme/demo/pull-requests/3"), true); + assert.equal(isAllowedExternalUrl("https://id.atlassian.com/login"), true); }); it("rejects credentials, other hosts, and non-https schemes", () => { diff --git a/src/loadpath/mcp/server.py b/src/loadpath/mcp/server.py index 6bf7591..abdd217 100644 --- a/src/loadpath/mcp/server.py +++ b/src/loadpath/mcp/server.py @@ -67,6 +67,10 @@ def _register_tools(mcp: MCPServer) -> None: name="list_pull_requests", description="List GitHub or Bitbucket pull requests using tokens stored in Loadpath settings.", )(tools.list_pull_requests) + mcp.tool( + name="list_remote_repositories", + description="List GitHub or Bitbucket repositories the signed-in account can access.", + )(tools.list_remote_repositories) mcp.tool( name="post_review_comment", description="Upsert the single Loadpath markdown brief on a pull request (updated in place).", diff --git a/src/loadpath/mcp/tools.py b/src/loadpath/mcp/tools.py index 45ef745..4357bca 100644 --- a/src/loadpath/mcp/tools.py +++ b/src/loadpath/mcp/tools.py @@ -1,18 +1,51 @@ from __future__ import annotations from pathlib import Path -from typing import Any +from typing import Any, Callable, TypeVar + +import httpx from loadpath.architecture.snapshot import architecture_report, summarize_index from loadpath.config import load_config from loadpath.detect import detect_layout, write_draft_config from loadpath.index import index_repo from loadpath.mcp.compact import compact_architecture, compact_review -from loadpath.providers.scm import provider_for +from loadpath.providers.scm import attach_local_paths, provider_for from loadpath.review.engine import run_review from loadpath.review.render import render_markdown from loadpath.settings import AppSettings, register_workspace +_T = TypeVar("_T") + + +def _with_scm(provider: str, fn: Callable[[Any], _T]) -> _T | dict[str, str]: + settings = AppSettings.load() + token = settings.github_token if provider == "github" else settings.bitbucket_token + username = settings.bitbucket_username + if not token: + return {"error": f"No {provider} token configured in Loadpath settings"} + try: + return fn(provider_for(provider, token, username=username)) + except httpx.HTTPStatusError as exc: + if ( + provider == "bitbucket" + and exc.response is not None + and exc.response.status_code == 401 + and settings.bitbucket_refresh_token + ): + from loadpath.providers.oauth import refresh_bitbucket_access_token + + try: + settings = refresh_bitbucket_access_token(settings) + except Exception as refresh_exc: # noqa: BLE001 + return {"error": str(refresh_exc)} + token = settings.bitbucket_token + username = settings.bitbucket_username + return fn(provider_for(provider, token, username=username)) + return {"error": str(exc)} + except Exception as exc: # noqa: BLE001 + return {"error": str(exc)} + def _repo(path: str) -> Path | dict[str, str]: root = Path(path).expanduser().resolve() @@ -124,17 +157,21 @@ def list_pull_requests( state: str = "open", ) -> dict[str, Any]: """List pull requests from GitHub or Bitbucket using tokens in ~/.loadpath/settings.json.""" + result = _with_scm(provider, lambda scm: scm.list_pull_requests(repo, state=state)) + if isinstance(result, dict) and result.get("error"): + return result + return {"pull_requests": [p.to_dict() for p in result]} + + +def list_remote_repositories(provider: str) -> dict[str, Any]: + """List GitHub or Bitbucket repositories the saved token can access.""" settings = AppSettings.load() - token = settings.github_token if provider == "github" else settings.bitbucket_token - username = settings.bitbucket_username - if not token: - return {"error": f"No {provider} token configured in Loadpath settings"} - try: - scm = provider_for(provider, token, username=username) - prs = scm.list_pull_requests(repo, state=state) - except Exception as exc: # noqa: BLE001 - return {"error": str(exc)} - return {"pull_requests": [p.to_dict() for p in prs]} + result = _with_scm(provider, lambda scm: (scm.list_repositories(), scm.current_user())) + if isinstance(result, dict) and result.get("error"): + return result + repos, profile = result + attach_local_paths(repos, [w.path for w in settings.workspaces]) + return {"provider": provider, "user": profile, "repos": [r.to_dict() for r in repos]} def post_review_comment( @@ -146,13 +183,8 @@ def post_review_comment( """Upsert the single Loadpath brief comment on a pull request.""" if not markdown.strip(): return {"error": "markdown is empty"} - settings = AppSettings.load() - token = settings.github_token if provider == "github" else settings.bitbucket_token - username = settings.bitbucket_username - if not token: - return {"error": f"No {provider} token configured in Loadpath settings"} - try: - scm = provider_for(provider, token, username=username) - return scm.upsert_pull_request_comment(repo, number, markdown) - except Exception as exc: # noqa: BLE001 - return {"error": str(exc)} + result = _with_scm( + provider, + lambda scm: scm.upsert_pull_request_comment(repo, number, markdown), + ) + return result diff --git a/src/loadpath/providers/__init__.py b/src/loadpath/providers/__init__.py index 9f62a5e..fbcb31e 100644 --- a/src/loadpath/providers/__init__.py +++ b/src/loadpath/providers/__init__.py @@ -1,3 +1,19 @@ -from loadpath.providers.scm import BitbucketProvider, GitHubProvider, PullRequest, provider_for +from loadpath.providers.scm import ( + BitbucketProvider, + GitHubProvider, + PullRequest, + RemoteRepo, + attach_local_paths, + parse_remote_url, + provider_for, +) -__all__ = ["BitbucketProvider", "GitHubProvider", "PullRequest", "provider_for"] +__all__ = [ + "BitbucketProvider", + "GitHubProvider", + "PullRequest", + "RemoteRepo", + "attach_local_paths", + "parse_remote_url", + "provider_for", +] diff --git a/src/loadpath/providers/oauth.py b/src/loadpath/providers/oauth.py new file mode 100644 index 0000000..9107a93 --- /dev/null +++ b/src/loadpath/providers/oauth.py @@ -0,0 +1,367 @@ +"""GitHub device flow and Bitbucket authorization-code login. Tokens stay on this machine.""" + +from __future__ import annotations + +import os +import secrets +import threading +import time +from html import escape +from typing import Any +from urllib.parse import urlencode, urlparse + +import httpx + +from loadpath.providers.scm import provider_for +from loadpath.settings import AppSettings + +GITHUB_DEVICE_CODE_URL = "https://github.com/login/device/code" +GITHUB_TOKEN_URL = "https://github.com/login/oauth/access_token" +GITHUB_SCOPES = "repo read:user read:org" +BITBUCKET_AUTHORIZE_URL = "https://bitbucket.org/site/oauth2/authorize" +BITBUCKET_TOKEN_URL = "https://bitbucket.org/site/oauth2/access_token" +BITBUCKET_SCOPES = "account repository pullrequest" +LOOPBACK_HOSTS = frozenset({"127.0.0.1", "localhost", "::1", "testserver", "testclient"}) +GITHUB_DEVICE_HOSTS = frozenset({"github.com", "www.github.com"}) +MAX_PENDING = 8 + +_lock = threading.RLock() +_pending: dict[str, dict[str, Any]] = {} + + +def _hostname(host_header: str) -> str: + raw = (host_header or "").strip() + if raw.startswith("["): + return raw[1:].split("]", 1)[0].lower() + return raw.split(":", 1)[0].lower() + + +def is_loopback_request(host_header: str, origin: str = "") -> bool: + """True for the local UI, TestClient, or curl on loopback. False for other websites.""" + if (origin or "").strip(): + host = (urlparse(origin).hostname or "").lower().strip("[]") + return host in LOOPBACK_HOSTS + return _hostname(host_header) in LOOPBACK_HOSTS + + +def _is_github_device_url(url: str) -> bool: + try: + parsed = urlparse(url) + except ValueError: + return False + if parsed.scheme != "https" or parsed.username or parsed.password: + return False + if (parsed.hostname or "").lower() not in GITHUB_DEVICE_HOSTS: + return False + return parsed.path.rstrip("/") == "/login/device" + + +def github_device_urls(data: dict[str, Any], user_code: str) -> tuple[str, str]: + verification = data.get("verification_uri") or "https://github.com/login/device" + if not _is_github_device_url(verification): + raise ValueError("GitHub returned an unexpected verification URL") + complete = data.get("verification_uri_complete") or "" + if not _is_github_device_url(complete): + complete = f"https://github.com/login/device?user_code={user_code}" + return verification, complete + + +def _remember_pending(flow_id: str, row: dict[str, Any]) -> None: + with _lock: + now = time.time() + for key, item in list(_pending.items()): + if float(item.get("expires_at") or 0) < now: + _pending.pop(key, None) + while len(_pending) >= MAX_PENDING: + oldest = min(_pending, key=lambda key: float(_pending[key].get("expires_at") or 0)) + _pending.pop(oldest, None) + _pending[flow_id] = row + + +def github_client_id(settings: AppSettings | None = None) -> str: + settings = settings or AppSettings.load() + return (os.environ.get("LOADPATH_GITHUB_CLIENT_ID") or settings.github_oauth_client_id or "").strip() + + +def bitbucket_oauth_client(settings: AppSettings | None = None) -> tuple[str, str]: + settings = settings or AppSettings.load() + client_id = (os.environ.get("LOADPATH_BITBUCKET_CLIENT_ID") or settings.bitbucket_oauth_client_id or "").strip() + secret = ( + os.environ.get("LOADPATH_BITBUCKET_CLIENT_SECRET") or settings.bitbucket_oauth_client_secret or "" + ).strip() + return client_id, secret + + +def oauth_status(settings: AppSettings | None = None) -> dict[str, Any]: + settings = settings or AppSettings.load() + bb_id, bb_secret = bitbucket_oauth_client(settings) + return { + "github": { + "connected": bool(settings.github_token), + "user": settings.github_user, + "token_set": bool(settings.github_token), + "oauth_ready": bool(github_client_id(settings)), + }, + "bitbucket": { + "connected": bool(settings.bitbucket_token), + "user": settings.bitbucket_user, + "token_set": bool(settings.bitbucket_token), + "oauth_ready": bool(bb_id and bb_secret), + }, + } + + +def _client(client: httpx.Client | None) -> httpx.Client: + return client or httpx.Client(timeout=30.0) + + +def start_github_device(client: httpx.Client | None = None) -> dict[str, Any]: + settings = AppSettings.load() + client_id = github_client_id(settings) + if not client_id: + raise ValueError( + "GitHub OAuth client ID is not configured. Set LOADPATH_GITHUB_CLIENT_ID " + "or paste a GitHub OAuth App client ID in Settings (enable Device Flow on the app)." + ) + http = _client(client) + response = http.post( + GITHUB_DEVICE_CODE_URL, + data={"client_id": client_id, "scope": GITHUB_SCOPES}, + headers={"Accept": "application/json"}, + ) + response.raise_for_status() + data = response.json() + device_code = data.get("device_code") or "" + user_code = data.get("user_code") or "" + if not device_code or not user_code: + raise ValueError("GitHub did not return a device code") + verification, complete = github_device_urls(data, user_code) + flow_id = secrets.token_urlsafe(16) + interval = int(data.get("interval") or 5) + expires_in = int(data.get("expires_in") or 900) + _remember_pending( + flow_id, + { + "provider": "github", + "device_code": device_code, + "client_id": client_id, + "interval": interval, + "expires_at": time.time() + expires_in, + }, + ) + return { + "flow_id": flow_id, + "user_code": user_code, + "verification_uri": verification, + "verification_uri_complete": complete, + "interval": interval, + "expires_in": expires_in, + } + + +def poll_github_device(flow_id: str, client: httpx.Client | None = None) -> dict[str, Any]: + with _lock: + pending = _pending.get(flow_id) + if not pending or pending.get("provider") != "github": + raise ValueError("Unknown or expired GitHub sign-in") + if pending["expires_at"] < time.time(): + with _lock: + _pending.pop(flow_id, None) + return {"status": "expired"} + http = _client(client) + response = http.post( + GITHUB_TOKEN_URL, + data={ + "client_id": pending["client_id"], + "device_code": pending["device_code"], + "grant_type": "urn:ietf:params:oauth:grant-type:device_code", + }, + headers={"Accept": "application/json"}, + ) + try: + data = response.json() + except ValueError: + response.raise_for_status() + data = {} + if not isinstance(data, dict): + response.raise_for_status() + data = {} + error = data.get("error") + if error == "authorization_pending": + return {"status": "pending", "interval": pending["interval"]} + if error == "slow_down": + return {"status": "slow_down", "interval": pending["interval"] + 5} + if error in {"expired_token", "access_denied"}: + with _lock: + _pending.pop(flow_id, None) + return {"status": "denied" if error == "access_denied" else "expired"} + if error: + raise ValueError(data.get("error_description") or error) + response.raise_for_status() + token = data.get("access_token") or "" + if not token: + raise ValueError("GitHub did not return an access token") + with _lock: + _pending.pop(flow_id, None) + settings = _store_login("github", token, client=http) + return {"status": "complete", **oauth_status(settings)["github"]} + + +def start_bitbucket_authorize(redirect_uri: str) -> dict[str, Any]: + settings = AppSettings.load() + client_id, secret = bitbucket_oauth_client(settings) + if not client_id or not secret: + raise ValueError( + "Bitbucket OAuth consumer is not configured. Set LOADPATH_BITBUCKET_CLIENT_ID and " + "LOADPATH_BITBUCKET_CLIENT_SECRET, or paste the consumer key and secret in Settings. " + f"Callback URL must be {redirect_uri}." + ) + flow_id = secrets.token_urlsafe(16) + _remember_pending( + flow_id, + { + "provider": "bitbucket", + "redirect_uri": redirect_uri, + "expires_at": time.time() + 600, + }, + ) + query = urlencode( + { + "client_id": client_id, + "response_type": "code", + "scope": BITBUCKET_SCOPES, + "state": flow_id, + "redirect_uri": redirect_uri, + } + ) + return {"flow_id": flow_id, "authorize_url": f"{BITBUCKET_AUTHORIZE_URL}?{query}"} + + +def finish_bitbucket_authorize( + code: str, + state: str, + client: httpx.Client | None = None, +) -> AppSettings: + with _lock: + pending = _pending.pop(state, None) + if not pending or pending.get("provider") != "bitbucket": + raise ValueError("Unknown or expired Bitbucket sign-in") + if pending["expires_at"] < time.time(): + raise ValueError("Bitbucket sign-in expired. Start again from Settings.") + settings = AppSettings.load() + client_id, secret = bitbucket_oauth_client(settings) + http = _client(client) + response = http.post( + BITBUCKET_TOKEN_URL, + data={ + "grant_type": "authorization_code", + "code": code, + "redirect_uri": pending["redirect_uri"], + }, + auth=(client_id, secret), + headers={"Accept": "application/json"}, + ) + response.raise_for_status() + data = response.json() + token = data.get("access_token") or "" + if not token: + raise ValueError(data.get("error_description") or "Bitbucket did not return an access token") + return _store_login( + "bitbucket", + token, + refresh_token=data.get("refresh_token") or "", + client=http, + ) + + +def refresh_bitbucket_access_token( + settings: AppSettings | None = None, + client: httpx.Client | None = None, +) -> AppSettings: + settings = settings or AppSettings.load() + client_id, secret = bitbucket_oauth_client(settings) + refresh = settings.bitbucket_refresh_token + if not (client_id and secret and refresh): + raise ValueError("Bitbucket refresh token is missing") + http = _client(client) + response = http.post( + BITBUCKET_TOKEN_URL, + data={"grant_type": "refresh_token", "refresh_token": refresh}, + auth=(client_id, secret), + headers={"Accept": "application/json"}, + ) + response.raise_for_status() + data = response.json() + token = data.get("access_token") or "" + if not token: + raise ValueError("Bitbucket refresh did not return an access token") + settings.bitbucket_token = token + if data.get("refresh_token"): + settings.bitbucket_refresh_token = data["refresh_token"] + settings.save() + return settings + + +def disconnect_scm(provider: str) -> AppSettings: + settings = AppSettings.load() + if provider == "github": + settings.github_token = "" + settings.github_user = "" + elif provider == "bitbucket": + settings.bitbucket_token = "" + settings.bitbucket_user = "" + settings.bitbucket_refresh_token = "" + else: + raise ValueError(f"Unknown SCM provider: {provider}") + settings.save() + return settings + + +def _store_login( + provider: str, + token: str, + *, + refresh_token: str = "", + client: httpx.Client | None = None, +) -> AppSettings: + settings = AppSettings.load() + username = "" + if provider == "github": + settings.github_token = token + else: + settings.bitbucket_token = token + settings.bitbucket_username = "" + if refresh_token: + settings.bitbucket_refresh_token = refresh_token + try: + scm = provider_for(provider, token, username=username, client=client) + profile = scm.current_user() + login = profile.get("login") or "" + if provider == "github": + settings.github_user = login + else: + settings.bitbucket_user = login + except httpx.HTTPError: + pass + settings.save() + return settings + + +def callback_html(*, ok: bool, title: str, body: str) -> str: + tone = "#8fd4a0" if ok else "#f88" + return f""" +
+ + +{escape(body)}
+ +>>1,T=A[P];if(0>>1;Pa(ue,F))ce a(de,ue)?(A[P]=de,A[ce]=F,P=ce):(A[P]=ue,A[re]=F,P=re);else if(ce a(de,F))A[P]=de,A[ce]=F,P=ce;else break e}}return z}function a(A,z){var F=A.sortIndex-z.sortIndex;return F!==0?F:A.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();t.unstable_now=function(){return d.now()-f}}var p=[],y=[],g=1,x=null,v=3,_=!1,S=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(A){for(var z=i(y);z!==null;){if(z.callback===null)l(y);else if(z.startTime<=A)l(y),z.sortIndex=z.expirationTime,r(p,z);else break;z=i(y)}}function j(A){if(C=!1,k(A),!S)if(i(p)!==null)S=!0,B(R);else{var z=i(y);z!==null&&U(j,z.startTime-A)}}function R(A,z){S=!1,C&&(C=!1,N(X),X=-1),_=!0;var F=v;try{for(k(z),x=i(p);x!==null&&(!(x.expirationTime>z)||A&&!Z());){var P=x.callback;if(typeof P=="function"){x.callback=null,v=x.priorityLevel;var T=P(x.expirationTime<=z);z=t.unstable_now(),typeof T=="function"?x.callback=T:x===i(p)&&l(p),k(z)}else l(p);x=i(p)}if(x!==null)var ne=!0;else{var re=i(y);re!==null&&U(j,re.startTime-z),ne=!1}return ne}finally{x=null,v=F,_=!1}}var D=!1,H=null,X=-1,V=5,ee=-1;function Z(){return!(t.unstable_now()-ee A||125P?(A.sortIndex=F,r(y,A),i(p)===null&&A===i(y)&&(C?(N(X),X=-1):C=!0,U(j,F-P))):(A.sortIndex=T,r(p,A),S||_||(S=!0,B(R))),A},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(A){var z=v;return function(){var F=v;v=z;try{return A.apply(this,arguments)}finally{v=F}}}})(Eu)),Eu}var Yf;function J0(){return Yf||(Yf=1,ku.exports=Z0()),ku.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Xf;function ey(){if(Xf)return kt;Xf=1;var t=Si(),r=J0();function i(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,o=1;o "u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},x={};function v(e){return p.call(x,e)?!0:p.call(g,e)?!1:y.test(e)?x[e]=!0:(g[e]=!0,!1)}function _(e,n,o,s){if(o!==null&&o.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return s?!1:o!==null?!o.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function S(e,n,o,s){if(n===null||typeof n>"u"||_(e,n,o,s))return!0;if(s)return!1;if(o!==null)switch(o.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function C(e,n,o,s,c,h,w){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=s,this.attributeNamespace=c,this.mustUseProperty=o,this.propertyName=e,this.type=n,this.sanitizeURL=h,this.removeEmptyString=w}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new C(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new C(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function b(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,b);E[n]=new C(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,b);E[n]=new C(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,b);E[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,o,s){var c=E.hasOwnProperty(n)?E[n]:null;(c!==null?c.type!==0:s||!(2 I||c[w]!==h[I]){var L=` -`+c[w].replace(" at new "," at ");return e.displayName&&L.includes(" ")&&(L=L.replace(" ",e.displayName)),L}while(1<=w&&0<=I);break}}}finally{ne=!1,Error.prepareStackTrace=o}return(e=e?e.displayName||e.name:"")?T(e):""}function ue(e){switch(e.tag){case 5:return T(e.type);case 16:return T("Lazy");case 13:return T("Suspense");case 19:return T("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function ce(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case D:return"Portal";case V:return"Profiler";case X:return"StrictMode";case J:return"Suspense";case M:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case ee:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:ce(e.type)||"Memo";case B:n=e._payload,e=e._init;try{return ce(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ce(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function fe(e){var n=se(e)?"checked":"value",o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),s=""+e[n];if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var c=o.get,h=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return c.call(this)},set:function(w){s=""+w,h.call(this,w)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(w){s=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function me(e){e._valueTracker||(e._valueTracker=fe(e))}function xe(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var o=n.getValue(),s="";return e&&(s=se(e)?e.checked?"true":"false":e.value),e=s,e!==o?(n.setValue(e),!0):!1}function pe(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ce(e,n){var o=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??e._wrapperState.initialChecked})}function je(e,n){var o=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;o=Q(n.value!=null?n.value:o),e._wrapperState={initialChecked:s,initialValue:o,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Me(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function Re(e,n){Me(e,n);var o=Q(n.value),s=n.type;if(o!=null)s==="number"?(o===0&&e.value===""||e.value!=o)&&(e.value=""+o):e.value!==""+o&&(e.value=""+o);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?rt(e,n.type,o):n.hasOwnProperty("defaultValue")&&rt(e,n.type,Q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Xe(e,n,o){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var s=n.type;if(!(s!=="submit"&&s!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,o||n===e.value||(e.value=n),e.defaultValue=n}o=e.name,o!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,o!==""&&(e.name=o)}function rt(e,n,o){(n!=="number"||pe(e.ownerDocument)!==e)&&(o==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+o&&(e.defaultValue=""+o))}var Ze=Array.isArray;function Je(e,n,o,s){if(e=e.options,n){n={};for(var c=0;c "+n.valueOf().toString()+"",n=pt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var o=e.firstChild;if(o&&o===e.lastChild&&o.nodeType===3){o.nodeValue=n;return}}e.textContent=n}var hn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ir=["Webkit","ms","Moz","O"];Object.keys(hn).forEach(function(e){Ir.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),hn[n]=hn[e]})});function er(e,n,o){return n==null||typeof n=="boolean"||n===""?"":o||typeof n!="number"||n===0||hn.hasOwnProperty(e)&&hn[e]?(""+n).trim():n+"px"}function tr(e,n){e=e.style;for(var o in n)if(n.hasOwnProperty(o)){var s=o.indexOf("--")===0,c=er(o,n[o],s);o==="float"&&(o="cssFloat"),s?e.setProperty(o,c):e[o]=c}}var br=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function jn(e,n){if(n){if(br[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(i(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(i(61))}if(n.style!=null&&typeof n.style!="object")throw Error(i(62))}}function Mn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Pn=null;function K(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ye=null,Le=null,Nt=null;function Ct(e){if(e=Vo(e)){if(typeof ye!="function")throw Error(i(280));var n=e.stateNode;n&&(n=os(n),ye(e.stateNode,e.type,n))}}function Pi(e){Le?Nt?Nt.push(e):Nt=[e]:Le=e}function Ii(){if(Le){var e=Le,n=Nt;if(Nt=Le=null,Ct(e),n)for(e=0;e >>=0,e===0?32:31-(Ol(e)/Fl|0)|0}var Ar=64,Dr=4194304;function ir(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function pn(e,n){var o=e.pendingLanes;if(o===0)return 0;var s=0,c=e.suspendedLanes,h=e.pingedLanes,w=o&268435455;if(w!==0){var I=w&~c;I!==0?s=ir(I):(h&=w,h!==0&&(s=ir(h)))}else w=o&~c,w!==0?s=ir(w):h!==0&&(s=ir(h));if(s===0)return 0;if(n!==0&&n!==s&&(n&c)===0&&(c=s&-s,h=n&-n,c>=h||c===16&&(h&4194240)!==0))return n;if((s&4)!==0&&(s|=o&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=s;0 o;o++)n.push(e);return n}function lr(e,n,o){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Mt(n),e[n]=o}function Vl(e,n){var o=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0 =Lo),Rc=" ",Lc=!1;function zc(e,n){switch(e){case"keyup":return Vg.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ac(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Hr=!1;function Wg(e,n){switch(e){case"compositionend":return Ac(n);case"keypress":return n.which!==32?null:(Lc=!0,Rc);case"textInput":return e=n.data,e===Rc&&Lc?null:e;default:return null}}function Yg(e,n){if(Hr)return e==="compositionend"||!ea&&zc(e,n)?(e=jc(),Xi=Gl=Ln=null,Hr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1 =n)return{node:o,offset:n-e};e=s}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Vc(o)}}function Wc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Wc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Yc(){for(var e=window,n=pe();n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=pe(e.document)}return n}function ra(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function t0(e){var n=Yc(),o=e.focusedElem,s=e.selectionRange;if(n!==o&&o&&o.ownerDocument&&Wc(o.ownerDocument.documentElement,o)){if(s!==null&&ra(o)){if(n=s.start,e=s.end,e===void 0&&(e=n),"selectionStart"in o)o.selectionStart=n,o.selectionEnd=Math.min(e,o.value.length);else if(e=(n=o.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var c=o.textContent.length,h=Math.min(s.start,c);s=s.end===void 0?h:Math.min(s.end,c),!e.extend&&h>s&&(c=s,s=h,h=c),c=Uc(o,h);var w=Uc(o,s);c&&w&&(e.rangeCount!==1||e.anchorNode!==c.node||e.anchorOffset!==c.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(n=n.createRange(),n.setStart(c.node,c.offset),e.removeAllRanges(),h>s?(e.addRange(n),e.extend(w.node,w.offset)):(n.setEnd(w.node,w.offset),e.addRange(n)))}}for(n=[],e=o;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o =document.documentMode,Br=null,oa=null,$o=null,ia=!1;function Xc(e,n,o){var s=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ia||Br==null||Br!==pe(s)||(s=Br,"selectionStart"in s&&ra(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),$o&&Do($o,s)||($o=s,s=ts(oa,"onSelect"),0 Xr||(e.current=ya[Xr],ya[Xr]=null,Xr--)}function Ae(e,n){Xr++,ya[Xr]=e.current,e.current=n}var $n={},at=Dn($n),vt=Dn(!1),ur=$n;function Gr(e,n){var o=e.type.contextTypes;if(!o)return $n;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===n)return s.__reactInternalMemoizedMaskedChildContext;var c={},h;for(h in o)c[h]=n[h];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=c),c}function xt(e){return e=e.childContextTypes,e!=null}function is(){$e(vt),$e(at)}function ad(e,n,o){if(at.current!==$n)throw Error(i(168));Ae(at,n),Ae(vt,o)}function ud(e,n,o){var s=e.stateNode;if(n=n.childContextTypes,typeof s.getChildContext!="function")return o;s=s.getChildContext();for(var c in s)if(!(c in n))throw Error(i(108,de(e)||"Unknown",c));return F({},o,s)}function ss(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$n,ur=at.current,Ae(at,e),Ae(vt,vt.current),!0}function cd(e,n,o){var s=e.stateNode;if(!s)throw Error(i(169));o?(e=ud(e,n,ur),s.__reactInternalMemoizedMergedChildContext=e,$e(vt),$e(at),Ae(at,e)):$e(vt),Ae(vt,o)}var gn=null,ls=!1,va=!1;function dd(e){gn===null?gn=[e]:gn.push(e)}function h0(e){ls=!0,dd(e)}function On(){if(!va&&gn!==null){va=!0;var e=0,n=ze;try{var o=gn;for(ze=1;e >=w,c-=w,yn=1<<32-Mt(n)+c|o< Ne?(nt=Ee,Ee=null):nt=Ee.sibling;var Te=oe(Y,Ee,G[Ne],ae);if(Te===null){Ee===null&&(Ee=nt);break}e&&Ee&&Te.alternate===null&&n(Y,Ee),$=h(Te,$,Ne),ke===null?_e=Te:ke.sibling=Te,ke=Te,Ee=nt}if(Ne===G.length)return o(Y,Ee),Fe&&dr(Y,Ne),_e;if(Ee===null){for(;Ne Ne?(nt=Ee,Ee=null):nt=Ee.sibling;var Gn=oe(Y,Ee,Te.value,ae);if(Gn===null){Ee===null&&(Ee=nt);break}e&&Ee&&Gn.alternate===null&&n(Y,Ee),$=h(Gn,$,Ne),ke===null?_e=Gn:ke.sibling=Gn,ke=Gn,Ee=nt}if(Te.done)return o(Y,Ee),Fe&&dr(Y,Ne),_e;if(Ee===null){for(;!Te.done;Ne++,Te=G.next())Te=le(Y,Te.value,ae),Te!==null&&($=h(Te,$,Ne),ke===null?_e=Te:ke.sibling=Te,ke=Te);return Fe&&dr(Y,Ne),_e}for(Ee=s(Y,Ee);!Te.done;Ne++,Te=G.next())Te=he(Ee,Y,Ne,Te.value,ae),Te!==null&&(e&&Te.alternate!==null&&Ee.delete(Te.key===null?Ne:Te.key),$=h(Te,$,Ne),ke===null?_e=Te:ke.sibling=Te,ke=Te);return e&&Ee.forEach(function(X0){return n(Y,X0)}),Fe&&dr(Y,Ne),_e}function Ye(Y,$,G,ae){if(typeof G=="object"&&G!==null&&G.type===H&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case R:e:{for(var _e=G.key,ke=$;ke!==null;){if(ke.key===_e){if(_e=G.type,_e===H){if(ke.tag===7){o(Y,ke.sibling),$=c(ke,G.props.children),$.return=Y,Y=$;break e}}else if(ke.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===B&&yd(_e)===ke.type){o(Y,ke.sibling),$=c(ke,G.props),$.ref=Uo(Y,ke,G),$.return=Y,Y=$;break e}o(Y,ke);break}else n(Y,ke);ke=ke.sibling}G.type===H?($=xr(G.props.children,Y.mode,ae,G.key),$.return=Y,Y=$):(ae=zs(G.type,G.key,G.props,null,Y.mode,ae),ae.ref=Uo(Y,$,G),ae.return=Y,Y=ae)}return w(Y);case D:e:{for(ke=G.key;$!==null;){if($.key===ke)if($.tag===4&&$.stateNode.containerInfo===G.containerInfo&&$.stateNode.implementation===G.implementation){o(Y,$.sibling),$=c($,G.children||[]),$.return=Y,Y=$;break e}else{o(Y,$);break}else n(Y,$);$=$.sibling}$=mu(G,Y.mode,ae),$.return=Y,Y=$}return w(Y);case B:return ke=G._init,Ye(Y,$,ke(G._payload),ae)}if(Ze(G))return ve(Y,$,G,ae);if(z(G))return we(Y,$,G,ae);ds(Y,G)}return typeof G=="string"&&G!==""||typeof G=="number"?(G=""+G,$!==null&&$.tag===6?(o(Y,$.sibling),$=c($,G),$.return=Y,Y=$):(o(Y,$),$=pu(G,Y.mode,ae),$.return=Y,Y=$),w(Y)):o(Y,$)}return Ye}var Zr=vd(!0),xd=vd(!1),fs=Dn(null),hs=null,Jr=null,Ea=null;function Na(){Ea=Jr=hs=null}function Ca(e){var n=fs.current;$e(fs),e._currentValue=n}function ja(e,n,o){for(;e!==null;){var s=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,s!==null&&(s.childLanes|=n)):s!==null&&(s.childLanes&n)!==n&&(s.childLanes|=n),e===o)break;e=e.return}}function eo(e,n){hs=e,Ea=Jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(wt=!0),e.firstContext=null)}function Ot(e){var n=e._currentValue;if(Ea!==e)if(e={context:e,memoizedValue:n,next:null},Jr===null){if(hs===null)throw Error(i(308));Jr=e,hs.dependencies={lanes:0,firstContext:e}}else Jr=Jr.next=e;return n}var fr=null;function Ma(e){fr===null?fr=[e]:fr.push(e)}function wd(e,n,o,s){var c=n.interleaved;return c===null?(o.next=o,Ma(n)):(o.next=c.next,c.next=o),n.interleaved=o,xn(e,s)}function xn(e,n){e.lanes|=n;var o=e.alternate;for(o!==null&&(o.lanes|=n),o=e,e=e.return;e!==null;)e.childLanes|=n,o=e.alternate,o!==null&&(o.childLanes|=n),o=e,e=e.return;return o.tag===3?o.stateNode:null}var Fn=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _d(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function wn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Hn(e,n,o){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Ie&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,xn(e,o)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,xn(e,o)}function ps(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194240)!==0)){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,$r(e,o)}}function Sd(e,n){var o=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,o===s)){var c=null,h=null;if(o=o.firstBaseUpdate,o!==null){do{var w={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};h===null?c=h=w:h=h.next=w,o=o.next}while(o!==null);h===null?c=h=n:h=h.next=n}else c=h=n;o={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:h,shared:s.shared,effects:s.effects},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}function ms(e,n,o,s){var c=e.updateQueue;Fn=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,I=c.shared.pending;if(I!==null){c.shared.pending=null;var L=I,q=L.next;L.next=null,w===null?h=q:w.next=q,w=L;var ie=e.alternate;ie!==null&&(ie=ie.updateQueue,I=ie.lastBaseUpdate,I!==w&&(I===null?ie.firstBaseUpdate=q:I.next=q,ie.lastBaseUpdate=L))}if(h!==null){var le=c.baseState;w=0,ie=q=L=null,I=h;do{var oe=I.lane,he=I.eventTime;if((s&oe)===oe){ie!==null&&(ie=ie.next={eventTime:he,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var ve=e,we=I;switch(oe=n,he=o,we.tag){case 1:if(ve=we.payload,typeof ve=="function"){le=ve.call(he,le,oe);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=we.payload,oe=typeof ve=="function"?ve.call(he,le,oe):ve,oe==null)break e;le=F({},le,oe);break e;case 2:Fn=!0}}I.callback!==null&&I.lane!==0&&(e.flags|=64,oe=c.effects,oe===null?c.effects=[I]:oe.push(I))}else he={eventTime:he,lane:oe,tag:I.tag,payload:I.payload,callback:I.callback,next:null},ie===null?(q=ie=he,L=le):ie=ie.next=he,w|=oe;if(I=I.next,I===null){if(I=c.shared.pending,I===null)break;oe=I,I=oe.next,oe.next=null,c.lastBaseUpdate=oe,c.shared.pending=null}}while(!0);if(ie===null&&(L=le),c.baseState=L,c.firstBaseUpdate=q,c.lastBaseUpdate=ie,n=c.shared.interleaved,n!==null){c=n;do w|=c.lane,c=c.next;while(c!==n)}else h===null&&(c.shared.lanes=0);mr|=w,e.lanes=w,e.memoizedState=le}}function kd(e,n,o){if(e=n.effects,n.effects=null,e!==null)for(n=0;n o?o:4,e(!0);var s=La.transition;La.transition={};try{e(!1),n()}finally{ze=o,La.transition=s}}function Bd(){return Ft().memoizedState}function y0(e,n,o){var s=Wn(e);if(o={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null},Vd(e))Ud(n,o);else if(o=wd(e,n,o,s),o!==null){var c=gt();Kt(o,e,s,c),Wd(o,n,s)}}function v0(e,n,o){var s=Wn(e),c={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null};if(Vd(e))Ud(n,c);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=n.lastRenderedReducer,h!==null))try{var w=n.lastRenderedState,I=h(w,o);if(c.hasEagerState=!0,c.eagerState=I,Wt(I,w)){var L=n.interleaved;L===null?(c.next=c,Ma(n)):(c.next=L.next,L.next=c),n.interleaved=c;return}}catch{}finally{}o=wd(e,n,c,s),o!==null&&(c=gt(),Kt(o,e,s,c),Wd(o,n,s))}}function Vd(e){var n=e.alternate;return e===Ve||n!==null&&n===Ve}function Ud(e,n){Go=vs=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function Wd(e,n,o){if((o&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,$r(e,o)}}var _s={readContext:Ot,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useInsertionEffect:ut,useLayoutEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useMutableSource:ut,useSyncExternalStore:ut,useId:ut,unstable_isNewReconciler:!1},x0={readContext:Ot,useCallback:function(e,n){return an().memoizedState=[e,n===void 0?null:n],e},useContext:Ot,useEffect:Ld,useImperativeHandle:function(e,n,o){return o=o!=null?o.concat([e]):null,xs(4194308,4,Dd.bind(null,n,e),o)},useLayoutEffect:function(e,n){return xs(4194308,4,e,n)},useInsertionEffect:function(e,n){return xs(4,2,e,n)},useMemo:function(e,n){var o=an();return n=n===void 0?null:n,e=e(),o.memoizedState=[e,n],e},useReducer:function(e,n,o){var s=an();return n=o!==void 0?o(n):n,s.memoizedState=s.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},s.queue=e,e=e.dispatch=y0.bind(null,Ve,e),[s.memoizedState,e]},useRef:function(e){var n=an();return e={current:e},n.memoizedState=e},useState:Td,useDebugValue:Ha,useDeferredValue:function(e){return an().memoizedState=e},useTransition:function(){var e=Td(!1),n=e[0];return e=g0.bind(null,e[1]),an().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,o){var s=Ve,c=an();if(Fe){if(o===void 0)throw Error(i(407));o=o()}else{if(o=n(),tt===null)throw Error(i(349));(pr&30)!==0||jd(s,n,o)}c.memoizedState=o;var h={value:o,getSnapshot:n};return c.queue=h,Ld(Pd.bind(null,s,h,e),[e]),s.flags|=2048,qo(9,Md.bind(null,s,h,o,n),void 0,null),o},useId:function(){var e=an(),n=tt.identifierPrefix;if(Fe){var o=vn,s=yn;o=(s&~(1<<32-Mt(s)-1)).toString(32)+o,n=":"+n+"R"+o,o=Qo++,0 <\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=w.createElement(o,{is:s.is}):(e=w.createElement(o),o==="select"&&(w=e,s.multiple?w.multiple=!0:s.size&&(w.size=s.size))):e=w.createElementNS(e,o),e[sn]=n,e[Bo]=s,ff(e,n,!1,!1),n.stateNode=e;e:{switch(w=Mn(o,s),o){case"dialog":De("cancel",e),De("close",e),c=s;break;case"iframe":case"object":case"embed":De("load",e),c=s;break;case"video":case"audio":for(c=0;c io&&(n.flags|=128,s=!0,Zo(h,!1),n.lanes=4194304)}else{if(!s)if(e=gs(w),e!==null){if(n.flags|=128,s=!0,o=e.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),Zo(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Fe)return ct(n),null}else 2*He()-h.renderingStartTime>io&&o!==1073741824&&(n.flags|=128,s=!0,Zo(h,!1),n.lanes=4194304);h.isBackwards?(w.sibling=n.child,n.child=w):(o=h.last,o!==null?o.sibling=w:n.child=w,h.last=w)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=He(),n.sibling=null,o=Be.current,Ae(Be,s?o&1|2:o&1),n):(ct(n),null);case 22:case 23:return du(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Tt&1073741824)!==0&&(ct(n),n.subtreeFlags&6&&(n.flags|=8192)):ct(n),null;case 24:return null;case 25:return null}throw Error(i(156,n.tag))}function j0(e,n){switch(wa(n),n.tag){case 1:return xt(n.type)&&is(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return to(),$e(vt),$e(at),Ra(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return ba(n),null;case 13:if($e(Be),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));qr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return $e(Be),null;case 4:return to(),null;case 10:return Ca(n.type._context),null;case 22:case 23:return du(),null;case 24:return null;default:return null}}var Ns=!1,dt=!1,M0=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ro(e,n){var o=e.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(s){We(e,n,s)}else o.current=null}function Ja(e,n,o){try{o()}catch(s){We(e,n,s)}}var mf=!1;function P0(e,n){if(da=Wi,e=Yc(),ra(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var s=o.getSelection&&o.getSelection();if(s&&s.rangeCount!==0){o=s.anchorNode;var c=s.anchorOffset,h=s.focusNode;s=s.focusOffset;try{o.nodeType,h.nodeType}catch{o=null;break e}var w=0,I=-1,L=-1,q=0,ie=0,le=e,oe=null;t:for(;;){for(var he;le!==o||c!==0&&le.nodeType!==3||(I=w+c),le!==h||s!==0&&le.nodeType!==3||(L=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)oe=le,le=he;for(;;){if(le===e)break t;if(oe===o&&++q===c&&(I=w),oe===h&&++ie===s&&(L=w),(he=le.nextSibling)!==null)break;le=oe,oe=le.parentNode}le=he}o=I===-1||L===-1?null:{start:I,end:L}}else o=null}o=o||{start:0,end:0}}else o=null;for(fa={focusedElem:e,selectionRange:o},Wi=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var we=ve.memoizedProps,Ye=ve.memoizedState,Y=n.stateNode,$=Y.getSnapshotBeforeUpdate(n.elementType===n.type?we:Xt(n.type,we),Ye);Y.__reactInternalSnapshotBeforeUpdate=$}break;case 3:var G=n.stateNode.containerInfo;G.nodeType===1?G.textContent="":G.nodeType===9&&G.documentElement&&G.removeChild(G.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(ae){We(n,n.return,ae)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=mf,mf=!1,ve}function Jo(e,n,o){var s=n.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var c=s=s.next;do{if((c.tag&e)===e){var h=c.destroy;c.destroy=void 0,h!==void 0&&Ja(n,o,h)}c=c.next}while(c!==s)}}function Cs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var o=n=n.next;do{if((o.tag&e)===e){var s=o.create;o.destroy=s()}o=o.next}while(o!==n)}}function eu(e){var n=e.ref;if(n!==null){var o=e.stateNode;switch(e.tag){case 5:e=o;break;default:e=o}typeof n=="function"?n(e):n.current=e}}function gf(e){var n=e.alternate;n!==null&&(e.alternate=null,gf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[sn],delete n[Bo],delete n[ga],delete n[d0],delete n[f0])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function yf(e){return e.tag===5||e.tag===3||e.tag===4}function vf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function tu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.nodeType===8?o.parentNode.insertBefore(e,n):o.insertBefore(e,n):(o.nodeType===8?(n=o.parentNode,n.insertBefore(e,o)):(n=o,n.appendChild(e)),o=o._reactRootContainer,o!=null||n.onclick!==null||(n.onclick=rs));else if(s!==4&&(e=e.child,e!==null))for(tu(e,n,o),e=e.sibling;e!==null;)tu(e,n,o),e=e.sibling}function nu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,o),e=e.sibling;e!==null;)nu(e,n,o),e=e.sibling}var it=null,Gt=!1;function Bn(e,n,o){for(o=o.child;o!==null;)xf(e,n,o),o=o.sibling}function xf(e,n,o){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(zr,o)}catch{}switch(o.tag){case 5:dt||ro(o,n);case 6:var s=it,c=Gt;it=null,Bn(e,n,o),it=s,Gt=c,it!==null&&(Gt?(e=it,o=o.stateNode,e.nodeType===8?e.parentNode.removeChild(o):e.removeChild(o)):it.removeChild(o.stateNode));break;case 18:it!==null&&(Gt?(e=it,o=o.stateNode,e.nodeType===8?ma(e.parentNode,o):e.nodeType===1&&ma(e,o),bo(e)):ma(it,o.stateNode));break;case 4:s=it,c=Gt,it=o.stateNode.containerInfo,Gt=!0,Bn(e,n,o),it=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!dt&&(s=o.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){c=s=s.next;do{var h=c,w=h.destroy;h=h.tag,w!==void 0&&((h&2)!==0||(h&4)!==0)&&Ja(o,n,w),c=c.next}while(c!==s)}Bn(e,n,o);break;case 1:if(!dt&&(ro(o,n),s=o.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=o.memoizedProps,s.state=o.memoizedState,s.componentWillUnmount()}catch(I){We(o,n,I)}Bn(e,n,o);break;case 21:Bn(e,n,o);break;case 22:o.mode&1?(dt=(s=dt)||o.memoizedState!==null,Bn(e,n,o),dt=s):Bn(e,n,o);break;default:Bn(e,n,o)}}function wf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var o=e.stateNode;o===null&&(o=e.stateNode=new M0),n.forEach(function(s){var c=$0.bind(null,e,s);o.has(s)||(o.add(s),s.then(c,c))})}}function Qt(e,n){var o=n.deletions;if(o!==null)for(var s=0;s c&&(c=w),s&=~h}if(s=c,s=He()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*b0(s/1960))-s,10 e?16:e,Un===null)var s=!1;else{if(e=Un,Un=null,bs=0,(Ie&6)!==0)throw Error(i(331));var c=Ie;for(Ie|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var I=h.deletions;if(I!==null){for(var L=0;LHe()-iu?yr(e,0):ou|=o),St(e,n)}function Rf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Dr,Dr<<=1,(Dr&130023424)===0&&(Dr=4194304)));var o=gt();e=xn(e,n),e!==null&&(lr(e,n,o),St(e,o))}function D0(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Rf(e,o)}function $0(e,n){var o=0;switch(e.tag){case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(o=c.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(i(314))}s!==null&&s.delete(n),Rf(e,o)}var Lf;Lf=function(e,n,o){if(e!==null)if(e.memoizedProps!==n.pendingProps||vt.current)wt=!0;else{if((e.lanes&o)===0&&(n.flags&128)===0)return wt=!1,N0(e,n,o);wt=(e.flags&131072)!==0}else wt=!1,Fe&&(n.flags&1048576)!==0&&fd(n,us,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Es(e,n),e=n.pendingProps;var c=Gr(n,at.current);eo(n,o),c=Aa(null,n,s,e,c,o);var h=Da();return n.flags|=1,typeof c=="object"&&c!==null&&typeof c.render=="function"&&c.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,xt(s)?(h=!0,ss(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=Ss,n.stateNode=c,c._reactInternals=n,Va(n,s,e,o),n=Xa(null,n,s,!0,h,o)):(n.tag=0,Fe&&h&&xa(n),mt(null,n,c,o),n=n.child),n;case 16:s=n.elementType;e:{switch(Es(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=F0(s),e=Xt(s,e),c){case 0:n=Ya(null,n,s,e,o);break e;case 1:n=sf(null,n,s,e,o);break e;case 11:n=ef(null,n,s,e,o);break e;case 14:n=tf(null,n,s,Xt(s.type,e),o);break e}throw Error(i(306,s,""))}return n;case 0:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ya(e,n,s,c,o);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),sf(e,n,s,c,o);case 3:e:{if(lf(n),e===null)throw Error(i(387));s=n.pendingProps,h=n.memoizedState,c=h.element,_d(e,n),ms(n,s,null,o);var w=n.memoizedState;if(s=w.element,h.isDehydrated)if(h={element:s,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},n.updateQueue.baseState=h,n.memoizedState=h,n.flags&256){c=no(Error(i(423)),n),n=af(e,n,s,o,c);break e}else if(s!==c){c=no(Error(i(424)),n),n=af(e,n,s,o,c);break e}else for(bt=An(n.stateNode.containerInfo.firstChild),It=n,Fe=!0,Yt=null,o=xd(n,null,s,o),n.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(qr(),s===c){n=_n(e,n,o);break e}mt(e,n,s,o)}n=n.child}return n;case 5:return Ed(n),e===null&&Sa(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,ha(s,c)?w=null:h!==null&&ha(s,h)&&(n.flags|=32),of(e,n),mt(e,n,w,o),n.child;case 6:return e===null&&Sa(n),null;case 13:return uf(e,n,o);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=Zr(n,null,s,o):mt(e,n,s,o),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),ef(e,n,s,c,o);case 7:return mt(e,n,n.pendingProps,o),n.child;case 8:return mt(e,n,n.pendingProps.children,o),n.child;case 12:return mt(e,n,n.pendingProps.children,o),n.child;case 10:e:{if(s=n.type._context,c=n.pendingProps,h=n.memoizedProps,w=c.value,Ae(fs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!vt.current){n=_n(e,n,o);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var I=h.dependencies;if(I!==null){w=h.child;for(var L=I.firstContext;L!==null;){if(L.context===s){if(h.tag===1){L=wn(-1,o&-o),L.tag=2;var q=h.updateQueue;if(q!==null){q=q.shared;var ie=q.pending;ie===null?L.next=L:(L.next=ie.next,ie.next=L),q.pending=L}}h.lanes|=o,L=h.alternate,L!==null&&(L.lanes|=o),ja(h.return,o,n),I.lanes|=o;break}L=L.next}}else if(h.tag===10)w=h.type===n.type?null:h.child;else if(h.tag===18){if(w=h.return,w===null)throw Error(i(341));w.lanes|=o,I=w.alternate,I!==null&&(I.lanes|=o),ja(w,o,n),w=h.sibling}else w=h.child;if(w!==null)w.return=h;else for(w=h;w!==null;){if(w===n){w=null;break}if(h=w.sibling,h!==null){h.return=w.return,w=h;break}w=w.return}h=w}mt(e,n,c.children,o),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,eo(n,o),c=Ot(c),s=s(c),n.flags|=1,mt(e,n,s,o),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),tf(e,n,s,c,o);case 15:return nf(e,n,n.type,n.pendingProps,o);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Es(e,n),n.tag=1,xt(s)?(e=!0,ss(n)):e=!1,eo(n,o),Xd(n,s,c),Va(n,s,c,o),Xa(null,n,s,!0,e,o);case 19:return df(e,n,o);case 22:return rf(e,n,o)}throw Error(i(156,n.tag))};function zf(e,n){return Ai(e,n)}function O0(e,n,o,s){this.tag=e,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bt(e,n,o,s){return new O0(e,n,o,s)}function hu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function F0(e){if(typeof e=="function")return hu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===W)return 14}return 2}function Xn(e,n){var o=e.alternate;return o===null?(o=Bt(e.tag,n,e.key,e.mode),o.elementType=e.elementType,o.type=e.type,o.stateNode=e.stateNode,o.alternate=e,e.alternate=o):(o.pendingProps=n,o.type=e.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=e.flags&14680064,o.childLanes=e.childLanes,o.lanes=e.lanes,o.child=e.child,o.memoizedProps=e.memoizedProps,o.memoizedState=e.memoizedState,o.updateQueue=e.updateQueue,n=e.dependencies,o.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},o.sibling=e.sibling,o.index=e.index,o.ref=e.ref,o}function zs(e,n,o,s,c,h){var w=2;if(s=e,typeof e=="function")hu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return xr(o.children,c,h,n);case X:w=8,c|=8;break;case V:return e=Bt(12,o,n,c|2),e.elementType=V,e.lanes=h,e;case J:return e=Bt(13,o,n,c),e.elementType=J,e.lanes=h,e;case M:return e=Bt(19,o,n,c),e.elementType=M,e.lanes=h,e;case U:return As(o,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ee:w=10;break e;case Z:w=9;break e;case te:w=11;break e;case W:w=14;break e;case B:w=16,s=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return n=Bt(w,o,n,c),n.elementType=e,n.type=s,n.lanes=h,n}function xr(e,n,o,s){return e=Bt(7,e,s,n),e.lanes=o,e}function As(e,n,o,s){return e=Bt(22,e,s,n),e.elementType=U,e.lanes=o,e.stateNode={isHidden:!1},e}function pu(e,n,o){return e=Bt(6,e,null,n),e.lanes=o,e}function mu(e,n,o){return n=Bt(4,e.children!==null?e.children:[],e.key,n),n.lanes=o,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function H0(e,n,o,s,c){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sr(0),this.expirationTimes=sr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function gu(e,n,o,s,c,h,w,I,L){return e=new H0(e,n,o,I,L),n===1?(n=1,h===!0&&(n|=8)):n=0,h=Bt(3,null,null,n),e.current=h,h.stateNode=e,h.memoizedState={element:s,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},Pa(h),e}function B0(e,n,o){var s=3 "u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Su.exports=ey(),Su.exports}var Qf;function ty(){if(Qf)return Vs;Qf=1;var t=xp();return Vs.createRoot=t.createRoot,Vs.hydrateRoot=t.hydrateRoot,Vs}var ny=ty();function ry(t,r="Request failed"){const i=(t||"").trim();if(!i)return r;try{const a=JSON.parse(i).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(d=>typeof d=="string"?d:d&&typeof d=="object"&&"msg"in d?String(d.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return i}async function yt(t,r){const i=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!i.ok){const l=await i.text();throw new Error(ry(l,i.statusText||"Request failed"))}return i.json()}const oy=["github_token","bitbucket_token","ai_api_key","ai_model","ai_base_url"],ft={health:()=>yt("/api/health"),settings:()=>yt("/api/settings"),saveSettings:t=>{const r={...t};for(const i of oy)r[i]===""&&delete r[i];return yt("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>yt("/api/repos"),browse:t=>yt(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>yt(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>yt("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>yt(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>yt(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,i,l=!0)=>yt("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:i||null,reindex:l,incremental:!0,three_dot:!0})}),init:(t,r=!1)=>yt("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,i,l)=>yt("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:i,markdown:l})}),graph:(t,r="full")=>yt(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,i="open")=>yt("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:i})}),residual:t=>yt("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function di(t){return t.replaceAll("_"," ")}function iy(t){return t.replaceAll("_"," ")}function gl(t){return t.split(".").pop()||t}function sy(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function ao(t){return t.replace(/([/\\._:@-])/g,"$1")}function Pr({className:t,children:r}){return m.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function ly({className:t}){return m.jsxs(Pr,{className:t,children:[m.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),m.jsx("path",{d:"M9.5 3.5V7H13"}),m.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function ay({className:t}){return m.jsxs(Pr,{className:t,children:[m.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),m.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),m.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),m.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function uy({className:t}){return m.jsxs(Pr,{className:t,children:[m.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),m.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),m.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),m.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function cy({className:t}){return m.jsxs(Pr,{className:t,children:[m.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),m.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),m.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),m.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function dy({className:t}){return m.jsxs(Pr,{className:t,children:[m.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),m.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function wp({className:t}){return m.jsx(Pr,{className:t,children:m.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function fy({className:t}){return m.jsx(Pr,{className:t,children:m.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const hy="modulepreload",py=function(t,r){return new URL(t,r).href},Kf={},my=function(r,i,l){let a=Promise.resolve();if(i&&i.length>0){let d=function(g){return Promise.all(g.map(x=>Promise.resolve(x).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=d(i.map(g=>{if(g=py(g,l),g in Kf)return;Kf[g]=!0;const x=g.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const E=f[C];if(E.href===g&&(!x||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${g}"]${v}`))return;const S=document.createElement("link");if(S.rel=x?"stylesheet":hy,x||(S.as="script"),S.crossOrigin="",S.href=g,y&&S.setAttribute("nonce",y),document.head.appendChild(S),x)return new Promise((C,E)=>{S.addEventListener("load",C),S.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${g}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return a.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return r().catch(u)})};function Qe(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let i=0,l;i {}};function yl(){for(var t=0,r=arguments.length,i={},l;t =0&&(l=i.slice(a+1),i=i.slice(0,a)),i&&!r.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:l}})}el.prototype=yl.prototype={constructor:el,on:function(t,r){var i=this._,l=yy(t+"",i),a,u=-1,d=l.length;if(arguments.length<2){for(;++u 0)for(var i=new Array(a),l=0,a,u;l=0&&(r=t.slice(0,i))!=="xmlns"&&(t=t.slice(i+1)),Zf.hasOwnProperty(r)?{space:Zf[r],local:t}:t}function xy(t){return function(){var r=this.ownerDocument,i=this.namespaceURI;return i===Ou&&r.documentElement.namespaceURI===Ou?r.createElement(t):r.createElementNS(i,t)}}function wy(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function _p(t){var r=vl(t);return(r.local?wy:xy)(r)}function _y(){}function Ju(t){return t==null?_y:function(){return this.querySelector(t)}}function Sy(t){typeof t!="function"&&(t=Ju(t));for(var r=this._groups,i=r.length,l=new Array(i),a=0;a=k&&(k=b+1);!(R=E[k])&&++k =0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function Xy(t){t||(t=Gy);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var i=this._groups,l=i.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function Qy(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Ky(){return Array.from(this)}function qy(){for(var t=this._groups,r=0,i=t.length;r1?this.each((r==null?av:typeof r=="function"?cv:uv)(t,r,i??"")):ho(this.node(),t)}function ho(t,r){return t.style.getPropertyValue(r)||Cp(t).getComputedStyle(t,null).getPropertyValue(r)}function fv(t){return function(){delete this[t]}}function hv(t,r){return function(){this[t]=r}}function pv(t,r){return function(){var i=r.apply(this,arguments);i==null?delete this[t]:this[t]=i}}function mv(t,r){return arguments.length>1?this.each((r==null?fv:typeof r=="function"?pv:hv)(t,r)):this.node()[t]}function jp(t){return t.trim().split(/^|\s+/)}function ec(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=jp(t.getAttribute("class")||"")}Mp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Pp(t,r){for(var i=ec(t),l=-1,a=r.length;++l=0&&(i=r.slice(l+1),r=r.slice(0,l)),{type:r,name:i}})}function Vv(t){return function(){var r=this.__on;if(r){for(var i=0,l=-1,a=r.length,u;i()=>t;function Fu(t,{sourceEvent:r,subject:i,target:l,identifier:a,active:u,x:d,y:f,dx:p,dy:y,dispatch:g}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:f,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:g}})}Fu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Jv(t){return!t.ctrlKey&&!t.button}function ex(){return this.parentNode}function tx(t,r){return r??{x:t.x,y:t.y}}function nx(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=Jv,r=ex,i=tx,l=nx,a={},u=yl("start","drag","end"),d=0,f,p,y,g,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",E).on("touchmove.drag",N,Zv).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(g||!t.call(this,j,R))){var D=k(this,r.call(this,j,R),j,R,"mouse");D&&(Rt(j.view).on("mousemove.drag",S,fi).on("mouseup.drag",C,fi),Rp(j.view),Nu(j),y=!1,f=j.clientX,p=j.clientY,D("start",j))}}function S(j){if(co(j),!y){var R=j.clientX-f,D=j.clientY-p;y=R*R+D*D>x}a.mouse("drag",j)}function C(j){Rt(j.view).on("mousemove.drag mouseup.drag",null),Lp(j.view,y),co(j),a.mouse("end",j)}function E(j,R){if(t.call(this,j,R)){var D=j.changedTouches,H=r.call(this,j,R),X=D.length,V,ee;for(V=0;V >8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):i===8?Ws(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):i===4?Ws(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=ox.exec(t))?new Et(r[1],r[2],r[3],1):(r=ix.exec(t))?new Et(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=sx.exec(t))?Ws(r[1],r[2],r[3],r[4]):(r=lx.exec(t))?Ws(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ax.exec(t))?ih(r[1],r[2]/100,r[3]/100,1):(r=ux.exec(t))?ih(r[1],r[2]/100,r[3]/100,r[4]):Jf.hasOwnProperty(t)?nh(Jf[t]):t==="transparent"?new Et(NaN,NaN,NaN,0):null}function nh(t){return new Et(t>>16&255,t>>8&255,t&255,1)}function Ws(t,r,i,l){return l<=0&&(t=r=i=NaN),new Et(t,r,i,l)}function fx(t){return t instanceof Ei||(t=Er(t)),t?(t=t.rgb(),new Et(t.r,t.g,t.b,t.opacity)):new Et}function Hu(t,r,i,l){return arguments.length===1?fx(t):new Et(t,r,i,l??1)}function Et(t,r,i,l){this.r=+t,this.g=+r,this.b=+i,this.opacity=+l}tc(Et,Hu,Ap(Ei,{brighter(t){return t=t==null?sl:Math.pow(sl,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?hi:Math.pow(hi,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Et(Sr(this.r),Sr(this.g),Sr(this.b),ll(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rh,formatHex:rh,formatHex8:hx,formatRgb:oh,toString:oh}));function rh(){return`#${_r(this.r)}${_r(this.g)}${_r(this.b)}`}function hx(){return`#${_r(this.r)}${_r(this.g)}${_r(this.b)}${_r((isNaN(this.opacity)?1:this.opacity)*255)}`}function oh(){const t=ll(this.opacity);return`${t===1?"rgb(":"rgba("}${Sr(this.r)}, ${Sr(this.g)}, ${Sr(this.b)}${t===1?")":`, ${t})`}`}function ll(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Sr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function _r(t){return t=Sr(t),(t<16?"0":"")+t.toString(16)}function ih(t,r,i,l){return l<=0?t=r=i=NaN:i<=0||i>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,i,l)}function Dp(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Ei||(t=Er(t)),!t)return new Zt;if(t instanceof Zt)return t;t=t.rgb();var r=t.r/255,i=t.g/255,l=t.b/255,a=Math.min(r,i,l),u=Math.max(r,i,l),d=NaN,f=u-a,p=(u+a)/2;return f?(r===u?d=(i-l)/f+(i 0&&p<1?0:d,new Zt(d,f,p,t.opacity)}function px(t,r,i,l){return arguments.length===1?Dp(t):new Zt(t,r,i,l??1)}function Zt(t,r,i,l){this.h=+t,this.s=+r,this.l=+i,this.opacity=+l}tc(Zt,px,Ap(Ei,{brighter(t){return t=t==null?sl:Math.pow(sl,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?hi:Math.pow(hi,t),new Zt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,i=this.l,l=i+(i<.5?i:1-i)*r,a=2*i-l;return new Et(Cu(t>=240?t-240:t+120,a,l),Cu(t,a,l),Cu(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(sh(this.h),Ys(this.s),Ys(this.l),ll(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ll(this.opacity);return`${t===1?"hsl(":"hsla("}${sh(this.h)}, ${Ys(this.s)*100}%, ${Ys(this.l)*100}%${t===1?")":`, ${t})`}`}}));function sh(t){return t=(t||0)%360,t<0?t+360:t}function Ys(t){return Math.max(0,Math.min(1,t||0))}function Cu(t,r,i){return(t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r)*255}const nc=t=>()=>t;function mx(t,r){return function(i){return t+i*r}}function gx(t,r,i){return t=Math.pow(t,i),r=Math.pow(r,i)-t,i=1/i,function(l){return Math.pow(t+l*r,i)}}function yx(t){return(t=+t)==1?$p:function(r,i){return i-r?gx(r,i,t):nc(isNaN(r)?i:r)}}function $p(t,r){var i=r-t;return i?mx(t,i):nc(isNaN(t)?r:t)}const al=(function t(r){var i=yx(r);function l(a,u){var d=i((a=Hu(a)).r,(u=Hu(u)).r),f=i(a.g,u.g),p=i(a.b,u.b),y=$p(a.opacity,u.opacity);return function(g){return a.r=d(g),a.g=f(g),a.b=p(g),a.opacity=y(g),a+""}}return l.gamma=t,l})(1);function vx(t,r){r||(r=[]);var i=t?Math.min(r.length,t.length):0,l=r.slice(),a;return function(u){for(a=0;ai&&(u=r.slice(i,u),f[d]?f[d]+=u:f[++d]=u),(l=l[0])===(a=a[0])?f[d]?f[d]+=a:f[++d]=a:(f[++d]=null,p.push({i:d,x:cn(l,a)})),i=ju.lastIndex;return i 180?g+=360:g-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:cn(y,g)})):g&&x.push(a(x)+"rotate("+g+l)}function f(y,g,x,v){y!==g?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:cn(y,g)}):g&&x.push(a(x)+"skewX("+g+l)}function p(y,g,x,v,_,S){if(y!==x||g!==v){var C=_.push(a(_)+"scale(",null,",",null,")");S.push({i:C-4,x:cn(y,x)},{i:C-2,x:cn(g,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,g){var x=[],v=[];return y=t(y),g=t(g),u(y.translateX,y.translateY,g.translateX,g.translateY,x,v),d(y.rotate,g.rotate,x,v),f(y.skewX,g.skewX,x,v),p(y.scaleX,y.scaleY,g.scaleX,g.scaleY,x,v),y=g=null,function(_){for(var S=-1,C=v.length,E;++S =0&&t._call.call(void 0,r),t=t._next;--po}function uh(){Nr=(cl=mi.now())+xl,po=li=0;try{Rx()}finally{po=0,zx(),Nr=0}}function Lx(){var t=mi.now(),r=t-cl;r>Bp&&(xl-=r,cl=t)}function zx(){for(var t,r=ul,i,l=1/0;r;)r._call?(l>r._time&&(l=r._time),t=r,r=r._next):(i=r._next,r._next=null,r=t?t._next=i:ul=i);ai=t,Uu(l)}function Uu(t){if(!po){li&&(li=clearTimeout(li));var r=t-Nr;r>24?(t<1/0&&(li=setTimeout(uh,t-mi.now()-xl)),ii&&(ii=clearInterval(ii))):(ii||(cl=mi.now(),ii=setInterval(Lx,Bp)),po=1,Vp(uh))}}function ch(t,r,i){var l=new dl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,i),l}var Ax=yl("start","end","cancel","interrupt"),Dx=[],Wp=0,dh=1,Wu=2,nl=3,fh=4,Yu=5,rl=6;function wl(t,r,i,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(i in d)return;$x(t,i,{name:r,index:l,group:a,on:Ax,tween:Dx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Wp})}function oc(t,r){var i=nn(t,r);if(i.state>Wp)throw new Error("too late; already scheduled");return i}function fn(t,r){var i=nn(t,r);if(i.state>nl)throw new Error("too late; already running");return i}function nn(t,r){var i=t.__transition;if(!i||!(i=i[r]))throw new Error("transition not found");return i}function $x(t,r,i){var l=t.__transition,a;l[r]=i,i.timer=Up(u,0,i.time);function u(y){i.state=dh,i.timer.restart(d,i.delay,i.time),i.delay<=y&&d(y-i.delay)}function d(y){var g,x,v,_;if(i.state!==dh)return p();for(g in l)if(_=l[g],_.name===i.name){if(_.state===nl)return ch(d);_.state===fh?(_.state=rl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[g]):+g Wu&&l.state =0&&(r=r.slice(0,i)),!r||r==="start"})}function pw(t,r,i){var l,a,u=hw(r)?oc:fn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,i),d.on=a}}function mw(t,r){var i=this._id;return arguments.length<2?nn(this.node(),i).on.on(t):this.each(pw(i,t,r))}function gw(t){return function(){var r=this.parentNode;for(var i in this.__transition)if(+i!==t)return;r&&r.removeChild(this)}}function yw(){return this.on("end.remove",gw(this._id))}function vw(t){var r=this._name,i=this._id;typeof t!="function"&&(t=Ju(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Vw(t,{sourceEvent:r,target:i,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function En(t,r,i){this.k=t,this.x=r,this.y=i}En.prototype={constructor:En,scale:function(t){return t===1?this:new En(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new En(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var _l=new En(1,0,0);Qp.prototype=En.prototype;function Qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return _l;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function si(t){t.preventDefault(),t.stopImmediatePropagation()}function Uw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Ww(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function hh(){return this.__zoom||_l}function Yw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Xw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gw(t,r,i){var l=t.invertX(r[0][0])-i[0][0],a=t.invertX(r[1][0])-i[1][0],u=t.invertY(r[0][1])-i[0][1],d=t.invertY(r[1][1])-i[1][1];return t.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),d>u?(u+d)/2:Math.min(0,u)||Math.max(0,d))}function Kp(){var t=Uw,r=Ww,i=Gw,l=Yw,a=Xw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,p=tl,y=yl("start","zoom","end"),g,x,v,_=500,S=150,C=0,E=10;function N(M){M.property("__zoom",hh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",ee).filter(a).on("touchstart.zoom",Z).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(M,W,B,U){var A=M.selection?M.selection():M;A.property("__zoom",hh),M!==A?R(M,W,B,U):A.interrupt().each(function(){D(this,arguments).event(U).start().zoom(null,typeof W=="function"?W.apply(this,arguments):W).end()})},N.scaleBy=function(M,W,B,U){N.scaleTo(M,function(){var A=this.__zoom.k,z=typeof W=="function"?W.apply(this,arguments):W;return A*z},B,U)},N.scaleTo=function(M,W,B,U){N.transform(M,function(){var A=r.apply(this,arguments),z=this.__zoom,F=B==null?j(A):typeof B=="function"?B.apply(this,arguments):B,P=z.invert(F),T=typeof W=="function"?W.apply(this,arguments):W;return i(k(b(z,T),F,P),A,d)},B,U)},N.translateBy=function(M,W,B,U){N.transform(M,function(){return i(this.__zoom.translate(typeof W=="function"?W.apply(this,arguments):W,typeof B=="function"?B.apply(this,arguments):B),r.apply(this,arguments),d)},null,U)},N.translateTo=function(M,W,B,U,A){N.transform(M,function(){var z=r.apply(this,arguments),F=this.__zoom,P=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return i(_l.translate(P[0],P[1]).scale(F.k).translate(typeof W=="function"?-W.apply(this,arguments):-W,typeof B=="function"?-B.apply(this,arguments):-B),z,d)},U,A)};function b(M,W){return W=Math.max(u[0],Math.min(u[1],W)),W===M.k?M:new En(W,M.x,M.y)}function k(M,W,B){var U=W[0]-B[0]*M.k,A=W[1]-B[1]*M.k;return U===M.x&&A===M.y?M:new En(M.k,U,A)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function R(M,W,B,U){M.on("start.zoom",function(){D(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(U).end()}).tween("zoom",function(){var A=this,z=arguments,F=D(A,z).event(U),P=r.apply(A,z),T=B==null?j(P):typeof B=="function"?B.apply(A,z):B,ne=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),re=A.__zoom,ue=typeof W=="function"?W.apply(A,z):W,ce=p(re.invert(T).concat(ne/re.k),ue.invert(T).concat(ne/ue.k));return function(de){if(de===1)de=ue;else{var Q=ce(de),se=ne/Q[2];de=new En(se,T[0]-Q[0]*se,T[1]-Q[1]*se)}F.zoom(null,de)}})}function D(M,W,B){return!B&&M.__zooming||new H(M,W)}function H(M,W){this.that=M,this.args=W,this.active=0,this.sourceEvent=null,this.extent=r.apply(M,W),this.taps=0}H.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,W){return this.mouse&&M!=="mouse"&&(this.mouse[1]=W.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=W.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=W.invert(this.touch1[0])),this.that.__zoom=W,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var W=Rt(this.that).datum();y.call(M,this.that,new Vw(M,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:y}),W)}};function X(M,...W){if(!t.apply(this,arguments))return;var B=D(this,W).event(M),U=this.__zoom,A=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=qt(M);if(B.wheel)(B.mouse[0][0]!==z[0]||B.mouse[0][1]!==z[1])&&(B.mouse[1]=U.invert(B.mouse[0]=z)),clearTimeout(B.wheel);else{if(U.k===A)return;B.mouse=[z,U.invert(z)],ol(this),B.start()}si(M),B.wheel=setTimeout(F,S),B.zoom("mouse",i(k(b(U,A),B.mouse[0],B.mouse[1]),B.extent,d));function F(){B.wheel=null,B.end()}}function V(M,...W){if(v||!t.apply(this,arguments))return;var B=M.currentTarget,U=D(this,W,!0).event(M),A=Rt(M.view).on("mousemove.zoom",T,!0).on("mouseup.zoom",ne,!0),z=qt(M,B),F=M.clientX,P=M.clientY;Rp(M.view),Mu(M),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function T(re){if(si(re),!U.moved){var ue=re.clientX-F,ce=re.clientY-P;U.moved=ue*ue+ce*ce>C}U.event(re).zoom("mouse",i(k(U.that.__zoom,U.mouse[0]=qt(re,B),U.mouse[1]),U.extent,d))}function ne(re){A.on("mousemove.zoom mouseup.zoom",null),Lp(re.view,U.moved),si(re),U.event(re).end()}}function ee(M,...W){if(t.apply(this,arguments)){var B=this.__zoom,U=qt(M.changedTouches?M.changedTouches[0]:M,this),A=B.invert(U),z=B.k*(M.shiftKey?.5:2),F=i(k(b(B,z),U,A),r.apply(this,W),d);si(M),f>0?Rt(this).transition().duration(f).call(R,F,U,M):Rt(this).call(N.transform,F,U,M)}}function Z(M,...W){if(t.apply(this,arguments)){var B=M.touches,U=B.length,A=D(this,W,M.changedTouches.length===U).event(M),z,F,P,T;for(Mu(M),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:i,targetHandle:l})=>`Couldn't create edge for ${t} handle id: "${t==="source"?i:l}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},gi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],qp=["Enter"," ","Escape"],Zp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y:i})=>`Moved selected node ${t}. New position, x: ${r}, y: ${i}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var mo;(function(t){t.Strict="strict",t.Loose="loose"})(mo||(mo={}));var kr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(kr||(kr={}));var yi;(function(t){t.Partial="partial",t.Full="full"})(yi||(yi={}));const Jp={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Zn;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Zn||(Zn={}));var vi;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(vi||(vi={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const ph={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function em(t){return t===null?null:t?"valid":"invalid"}const tm=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Qw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),sc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Ni=(t,r=[0,0])=>{const{width:i,height:l}=rn(t),a=t.origin??r,u=i*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Kw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let i=!1;const l=t.reduce((a,u)=>{const d=typeof u=="string";let f=!r.nodeLookup&&!d?u:void 0;return r.nodeLookup&&(f=d?r.nodeLookup.get(u):sc(u)?u:r.nodeLookup.get(u.id)),f?(i=!0,Sl(a,fl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return i?kl(l):{x:0,y:0,width:0,height:0}},Ci=(t,r={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(i=Sl(i,fl(a)),l=!0)}),l?kl(i):{x:0,y:0,width:0,height:0}},lc=(t,r,[i,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-i)/a,p=(r.y-l)/a,y=r.width/a,g=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:S=!0,hidden:C=!1}=v;if(d&&!S||C)continue;const E=_.width??v.width??v.initialWidth??0,N=_.height??v.height??v.initialHeight??0,{x:b,y:k}=v.internals.positionAbsolute,j=im(f,p,y,g,b,k,E,N),R=E*N,D=u&&j>0;(!v.internals.handleBounds||D||j>=R||v.dragging)&&x.push(v)}return x},qw=(t,r)=>{const i=new Set;return t.forEach(l=>{i.add(l.id)}),r.filter(l=>i.has(l.source)||i.has(l.target))};function Zw(t,r){const i=new Map,l=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:d,height:f}=rn(a);u=d>0&&f>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!l||l.has(a.id))&&i.set(a.id,a)}),i}async function Jw({nodes:t,width:r,height:i,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Zw(t,d),p=Ci(f),y=uc(p,r,i,(d==null?void 0:d.minZoom)??a,(d==null?void 0:d.maxZoom)??u,(d==null?void 0:d.padding)??.1);return await l.setViewport(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function nm({nodeId:t,nextPosition:r,nodeLookup:i,nodeOrigin:l=[0,0],nodeExtent:a,onError:u}){const d=i.get(t),f=d.parentId?i.get(d.parentId):void 0,{x:p,y}=f?f.internals.positionAbsolute:{x:0,y:0},g=d.origin??l;let x=d.extent||a;if(d.extent==="parent"&&!d.expandParent)if(!f)u==null||u("005",tn.error005());else{const{width:_,height:S}=rn(f);_&&S&&(x=[[p,y],[p+_,y+S]])}else f&&jr(d.extent)&&(x=[[d.extent[0][0]+p,d.extent[0][1]+y],[d.extent[1][0]+p,d.extent[1][1]+y]]);const v=jr(x)?Cr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-p+(d.measured.width??0)*g[0],y:v.y-y+(d.measured.height??0)*g[1]},positionAbsolute:v}}async function e1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:i,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of i){if(v.deletable===!1)continue;const _=u.has(v.id),S=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||S)&&d.push(v)}const f=new Set(r.map(v=>v.id)),p=l.filter(v=>v.deletable!==!1),g=qw(d,p);for(const v of p)f.has(v.id)&&!g.find(S=>S.id===v.id)&&g.push(v);if(!a)return{edges:g,nodes:d};const x=await a({nodes:d,edges:g});return typeof x=="boolean"?x?{edges:g,nodes:d}:{edges:[],nodes:[]}:x}const go=(t,r=0,i=1)=>Math.min(Math.max(t,r),i),Cr=(t={x:0,y:0},r,i)=>({x:go(t.x,r[0][0],r[1][0]-((i==null?void 0:i.width)??0)),y:go(t.y,r[0][1],r[1][1]-((i==null?void 0:i.height)??0))});function rm(t,r,i){const{width:l,height:a}=rn(i),{x:u,y:d}=i.internals.positionAbsolute;return Cr(t,[[u,d],[u+l,d+a]],r)}const mh=(t,r,i)=>t i?-go(Math.abs(t-i),1,r)/r:0,ac=(t,r,i=15,l=40)=>{const a=mh(t.x,l,r.width-l)*i,u=mh(t.y,l,r.height-l)*i;return[a,u]},Sl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),Xu=({x:t,y:r,width:i,height:l})=>({x:t,y:r,x2:t+i,y2:r+l}),kl=({x:t,y:r,x2:i,y2:l})=>({x:t,y:r,width:i-t,height:l-r}),xi=(t,r=[0,0])=>{var a,u;const{x:i,y:l}=sc(t)?t.internals.positionAbsolute:Ni(t,r);return{x:i,y:l,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},fl=(t,r=[0,0])=>{var a,u;const{x:i,y:l}=sc(t)?t.internals.positionAbsolute:Ni(t,r);return{x:i,y:l,x2:i+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:l+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},om=(t,r)=>kl(Sl(Xu(t),Xu(r))),im=(t,r,i,l,a,u,d,f)=>{const p=Math.max(0,Math.min(t+i,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(p*y)},hl=(t,r)=>im(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),gh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),sm=(t,r)=>(i,l)=>{},ji=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Mi=({x:t,y:r},[i,l,a],u=!1,d=[1,1])=>{const f={x:(t-i)/a,y:(r-l)/a};return u?ji(f,d):f},yo=({x:t,y:r},[i,l,a])=>({x:t*a+i,y:r*a+l});function lo(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(i)}if(typeof t=="string"&&t.endsWith("%")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(r*i*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function t1(t,r,i){if(typeof t=="string"||typeof t=="number"){const l=lo(t,i),a=lo(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=lo(t.top??t.y??0,i),a=lo(t.bottom??t.y??0,i),u=lo(t.left??t.x??0,r),d=lo(t.right??t.x??0,r);return{top:l,right:d,bottom:a,left:u,x:u+d,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function n1(t,r,i,l,a,u){const{x:d,y:f}=yo(t,[r,i,l]),{x:p,y}=yo({x:t.x+t.width,y:t.y+t.height},[r,i,l]),g=a-p,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(g),bottom:Math.floor(x)}}const uc=(t,r,i,l,a,u)=>{const d=t1(u,r,i),f=(r-d.x)/t.width,p=(i-d.y)/t.height,y=Math.min(f,p),g=go(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*g,S=i/2-v*g,C=n1(t,_,S,g,r,i),E={left:Math.min(C.left-d.left,0),top:Math.min(C.top-d.top,0),right:Math.min(C.right-d.right,0),bottom:Math.min(C.bottom-d.bottom,0)};return{x:_-E.left+E.right,y:S-E.top+E.bottom,zoom:g}},wi=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function jr(t){return t!=null&&t!=="parent"}function rn(t){var r,i;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0}}function lm(t){var r,i;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight)!==void 0}function am(t,r={width:0,height:0},i,l,a){const u={...t},d=l.get(i);if(d){const f=d.origin||a;u.x+=d.internals.positionAbsolute.x-(r.width??0)*f[0],u.y+=d.internals.positionAbsolute.y-(r.height??0)*f[1]}return u}function yh(t,r){if(t.size!==r.size)return!1;for(const i of t)if(!r.has(i))return!1;return!0}function r1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Zp,...t||{}}}function ci(t,{snapGrid:r=[0,0],snapToGrid:i=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Mi({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:p,y}=i?ji(f,r):f;return{xSnapped:p,ySnapped:y,...f}}const cc=t=>({width:t.offsetWidth,height:t.offsetHeight}),um=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},i1=["INPUT","SELECT","TEXTAREA"];function cm(t){var l,a;const r=((a=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:i1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const dm=t=>"clientX"in t,en=(t,r)=>{var u,d;const i=dm(t),l=i?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=i?t.clientY:(d=t.touches)==null?void 0:d[0].clientY;return{x:l-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},vh=(t,r,i,l,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(d=>{const f=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),type:t,nodeId:a,position:d.getAttribute("data-handlepos"),x:(f.left-i.left)/l,y:(f.top-i.top)/l,...cc(d)}})};function fm({sourceX:t,sourceY:r,targetX:i,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const p=t*.125+a*.375+d*.375+i*.125,y=r*.125+u*.375+f*.375+l*.125,g=Math.abs(p-t),x=Math.abs(y-r);return[p,y,g,x]}function Qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function xh({pos:t,x1:r,y1:i,x2:l,y2:a,c:u}){switch(t){case Se.Left:return[r-Qs(r-l,u),i];case Se.Right:return[r+Qs(l-r,u),i];case Se.Top:return[r,i-Qs(i-a,u)];case Se.Bottom:return[r,i+Qs(a-i,u)]}}function hm({sourceX:t,sourceY:r,sourcePosition:i=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,p]=xh({pos:i,x1:t,y1:r,x2:l,y2:a,c:d}),[y,g]=xh({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,S]=fm({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:p,targetControlX:y,targetControlY:g});return[`M${t},${r} C${f},${p} ${y},${g} ${l},${a}`,x,v,_,S]}function pm({sourceX:t,sourceY:r,targetX:i,targetY:l}){const a=Math.abs(i-t)/2,u=i 0}const a1=({source:t,sourceHandle:r,target:i,targetHandle:l})=>`xy-edge__${t}${r||""}-${i}${l||""}`,u1=(t,r)=>r.some(i=>i.source===t.source&&i.target===t.target&&(i.sourceHandle===t.sourceHandle||!i.sourceHandle&&!t.sourceHandle)&&(i.targetHandle===t.targetHandle||!i.targetHandle&&!t.targetHandle)),c1=(t,r,i={})=>{var u;if(!t.source||!t.target)return(u=i.onError)==null||u.call(i,"006",tn.error006()),r;const l=i.getEdgeId||a1;let a;return tm(t)?a={...t}:a={...t,id:l(t)},u1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mm({sourceX:t,sourceY:r,targetX:i,targetY:l}){const[a,u,d,f]=pm({sourceX:t,sourceY:r,targetX:i,targetY:l});return[`M ${t},${r}L ${i},${l}`,a,u,d,f]}const wh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},d1=({source:t,sourcePosition:r=Se.Bottom,target:i})=>r===Se.Left||r===Se.Right?t.x Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function f1({source:t,sourcePosition:r=Se.Bottom,target:i,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=wh[r],p=wh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},g={x:i.x+p.x*u,y:i.y+p.y*u},x=d1({source:y,sourcePosition:r,target:g}),v=x.x!==0?"x":"y",_=x[v];let S=[],C,E;const N={x:0,y:0},b={x:0,y:0},[,,k,j]=pm({sourceX:t.x,sourceY:t.y,targetX:i.x,targetY:i.y});if(f[v]*p[v]===-1){v==="x"?(C=a.x??y.x+(g.x-y.x)*d,E=a.y??(y.y+g.y)/2):(C=a.x??(y.x+g.x)/2,E=a.y??y.y+(g.y-y.y)*d);const X=[{x:C,y:y.y},{x:C,y:g.y}],V=[{x:y.x,y:E},{x:g.x,y:E}];f[v]===_?S=v==="x"?X:V:S=v==="x"?V:X}else{const X=[{x:y.x,y:g.y}],V=[{x:g.x,y:y.y}];if(v==="x"?S=f.x===_?V:X:S=f.y===_?X:V,r===l){const M=Math.abs(t[v]-i[v]);if(M<=u){const W=Math.min(u-1,u-M);f[v]===_?N[v]=(y[v]>t[v]?-1:1)*W:b[v]=(g[v]>i[v]?-1:1)*W}}if(r!==l){const M=v==="x"?"y":"x",W=f[v]===p[M],B=y[M]>g[M],U=y[M] =J?(C=(ee.x+Z.x)/2,E=S[0].y):(C=S[0].x,E=(ee.y+Z.y)/2)}const R={x:y.x+N.x,y:y.y+N.y},D={x:g.x+b.x,y:g.y+b.y};return[[t,...R.x!==S[0].x||R.y!==S[0].y?[R]:[],...S,...D.x!==S[S.length-1].x||D.y!==S[S.length-1].y?[D]:[],i],C,E,k,j]}function h1(t,r,i,l){const a=Math.min(_h(t,r)/2,_h(r,i)/2,l),{x:u,y:d}=r;if(t.x===u&&u===i.x||t.y===d&&d===i.y)return`L${u} ${d}`;if(t.y===d){const y=t.x i.id===r):t[0])||null}function Qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(t,{id:r,defaultColor:i,defaultMarkerStart:l,defaultMarkerEnd:a}){const u=new Set;return t.reduce((d,f)=>([f.markerStart||l,f.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=Qu(p,r);u.has(y)||(d.push({id:y,color:p.color||i,...p}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const gm=1e3,g1=10,dc={nodeOrigin:[0,0],nodeExtent:gi,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},y1={...dc,checkEquality:!0};function fc(t,r){const i={...t};for(const l in r)r[l]!==void 0&&(i[l]=r[l]);return i}function v1(t,r,i){const l=fc(dc,i);for(const a of t.values())if(a.parentId)pc(a,t,r,l);else{const u=Ni(a,l.nodeOrigin),d=jr(a.extent)?a.extent:l.nodeExtent,f=Cr(u,d,rn(a));a.internals.positionAbsolute=f}}function x1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const i=[],l=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?i.push(u):a.type==="target"&&l.push(u)}return{source:i,target:l}}function hc(t){return t==="manual"}function Ku(t,r,i,l={}){var g,x;const a=fc(y1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!hc(a.zIndexMode)?gm:0;let p=t.length>0,y=!1;r.clear(),i.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const S=Ni(v,a.nodeOrigin),C=jr(v.extent)?v.extent:a.nodeExtent,E=Cr(S,C,rn(v));_={...a.defaults,...v,measured:{width:(g=v.measured)==null?void 0:g.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:E,handleBounds:x1(v,_),z:ym(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),v.parentId&&pc(_,r,i,l,u),y||(y=v.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function w1(t,r){if(!t.parentId)return;const i=r.get(t.parentId);i?i.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function pc(t,r,i,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}=fc(dc,l),y=t.parentId,g=r.get(y);if(!g){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}w1(t,i),a&&!g.parentId&&g.internals.rootParentIndex===void 0&&p==="auto"&&(g.internals.rootParentIndex=++a.i,g.internals.z=g.internals.z+a.i*g1),a&&g.internals.rootParentIndex!==void 0&&(a.i=g.internals.rootParentIndex);const x=u&&!hc(p)?gm:0,{x:v,y:_,z:S}=_1(t,g,d,f,x,p),{positionAbsolute:C}=t.internals,E=v!==C.x||_!==C.y;(E||S!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:v,y:_}:C,z:S}})}function ym(t,r,i){const l=Jt(t.zIndex)?t.zIndex:0;return hc(i)?l:l+(t.selected?r:0)}function _1(t,r,i,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,p=rn(t),y=Ni(t,i),g=jr(t.extent)?Cr(y,t.extent,p):y;let x=Cr({x:d+g.x,y:f+g.y},l,p);t.extent==="parent"&&(x=rm(x,p,r));const v=ym(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function mc(t,r,i,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const p=r.get(f.parentId);if(!p)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??xi(p),g=om(y,f.rect);u.set(f.parentId,{expandedRect:g,parent:p})}return u.size>0&&u.forEach(({expandedRect:f,parent:p},y)=>{var k;const g=p.internals.positionAbsolute,x=rn(p),v=p.origin??l,_=f.x 0||S>0||N||b)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+N,y:p.position.y-S+b}}),(k=i.get(y))==null||k.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+S}})})),(x.width 0){const _=mc(v,r,i,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function k1({delta:t,panZoom:r,transform:i,translateExtent:l,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const d=await r.setViewportConstrained({x:i[0]+t.x,y:i[1]+t.y,zoom:i[2]},[[0,0],[a,u]],l);return!!d&&(d.x!==i[0]||d.y!==i[1]||d.k!==i[2])}function Nh(t,r,i,l,a,u){let d=a;const f=l.get(d)||new Map;l.set(d,f.set(i,r)),d=`${a}-${t}`;const p=l.get(d)||new Map;if(l.set(d,p.set(i,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(i,r))}}function vm(t,r,i){t.clear(),r.clear();for(const l of i){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,p={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,g=`${u}-${f}--${a}-${d}`;Nh("source",p,g,t,a,d),Nh("target",p,y,t,u,f),r.set(l.id,l)}}function xm(t,r){if(!t.parentId)return!1;const i=r.get(t.parentId);return i?i.selected?!0:xm(i,r):!1}function Ch(t,r,i){var a;let l=t;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,r))return!0;if(l===i)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function E1(t,r,i,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!xm(d,t))&&(d.draggable||r&&typeof d.draggable>"u")){const f=t.get(u);f&&a.set(u,{id:u,position:f.position||{x:0,y:0},distance:{x:i.x-f.internals.positionAbsolute.x,y:i.y-f.internals.positionAbsolute.y},extent:f.extent,parentId:f.parentId,origin:f.origin,expandParent:f.expandParent,internals:{positionAbsolute:f.internals.positionAbsolute||{x:0,y:0}},measured:{width:f.measured.width??0,height:f.measured.height??0}})}return a}function Pu({nodeId:t,dragItems:r,nodeLookup:i,dragging:l=!0}){var d,f,p;const a=[];for(const[y,g]of r){const x=(d=i.get(y))==null?void 0:d.internals.userNode;x&&a.push({...x,position:g.position,dragging:l})}if(!t)return[a[0],a];const u=(f=i.get(t))==null?void 0:f.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:l}:a[0],a]}function N1({dragItems:t,snapGrid:r,x:i,y:l}){const a=t.values().next().value;if(!a)return null;const u={x:i-a.distance.x,y:l-a.distance.y},d=ji(u,r);return{x:d.x-u.x,y:d.y-u.y}}function C1({onNodeMouseDown:t,getStoreItems:r,onDragStart:i,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,p=!1,y={x:0,y:0},g=null,x=!1,v=null,_=!1,S=!1,C=null;function E({noDragClassName:b,handleSelector:k,domNode:j,isSelectable:R,nodeId:D,nodeClickDistance:H=0}){v=Rt(j);function X({x:te,y:J}){const{nodeLookup:M,nodeExtent:W,snapGrid:B,snapToGrid:U,nodeOrigin:A,onNodeDrag:z,onSelectionDrag:F,onError:P,updateNodePositions:T}=r();u={x:te,y:J};let ne=!1;const re=f.size>1,ue=re&&W?Xu(Ci(f)):null,ce=re&&U?N1({dragItems:f,snapGrid:B,x:te,y:J}):null;for(const[de,Q]of f){if(!M.has(de))continue;let se={x:te-Q.distance.x,y:J-Q.distance.y};U&&(se=ce?{x:Math.round(se.x+ce.x),y:Math.round(se.y+ce.y)}:ji(se,B));let fe=null;if(re&&W&&!Q.extent&&ue){const{positionAbsolute:pe}=Q.internals,Ce=pe.x-ue.x+W[0][0],je=pe.x+Q.measured.width-ue.x2+W[1][0],Me=pe.y-ue.y+W[0][1],Re=pe.y+Q.measured.height-ue.y2+W[1][1];fe=[[Ce,Me],[je,Re]]}const{position:me,positionAbsolute:xe}=nm({nodeId:de,nextPosition:se,nodeLookup:M,nodeExtent:fe||W,nodeOrigin:A,onError:P});ne=ne||Q.position.x!==me.x||Q.position.y!==me.y,Q.position=me,Q.internals.positionAbsolute=xe}if(S=S||ne,!!ne&&(T(f,!0),C&&(l||z||!D&&F))){const[de,Q]=Pu({nodeId:D,dragItems:f,nodeLookup:M});l==null||l(C,f,de,Q),z==null||z(C,de,Q),D||F==null||F(C,Q)}}async function V(){if(!g)return;const{transform:te,panBy:J,autoPanSpeed:M,autoPanOnNodeDrag:W}=r();if(!W){p=!1,cancelAnimationFrame(d);return}const[B,U]=ac(y,g,M);(B!==0||U!==0)&&(u.x=(u.x??0)-B/te[2],u.y=(u.y??0)-U/te[2],await J({x:B,y:U})&&X(u)),d=requestAnimationFrame(V)}function ee(te){var re;const{nodeLookup:J,multiSelectionActive:M,nodesDraggable:W,transform:B,snapGrid:U,snapToGrid:A,selectNodesOnDrag:z,onNodeDragStart:F,onSelectionDragStart:P,unselectNodesAndEdges:T}=r();x=!0,(!z||!R)&&!M&&D&&((re=J.get(D))!=null&&re.selected||T()),R&&z&&D&&(t==null||t(D));const ne=ci(te.sourceEvent,{transform:B,snapGrid:U,snapToGrid:A,containerBounds:g});if(u=ne,f=E1(J,W,ne,D),f.size>0&&(i||F||!D&&P)){const[ue,ce]=Pu({nodeId:D,dragItems:f,nodeLookup:J});i==null||i(te.sourceEvent,f,ue,ce),F==null||F(te.sourceEvent,ue,ce),D||P==null||P(te.sourceEvent,ce)}}const Z=zp().clickDistance(H).on("start",te=>{const{domNode:J,nodeDragThreshold:M,transform:W,snapGrid:B,snapToGrid:U}=r();g=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,S=!1,C=te.sourceEvent,M===0&&ee(te),u=ci(te.sourceEvent,{transform:W,snapGrid:B,snapToGrid:U,containerBounds:g}),y=en(te.sourceEvent,g)}).on("drag",te=>{const{autoPanOnNodeDrag:J,transform:M,snapGrid:W,snapToGrid:B,nodeDragThreshold:U,nodeLookup:A}=r(),z=ci(te.sourceEvent,{transform:M,snapGrid:W,snapToGrid:B,containerBounds:g});if(C=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||D&&!A.has(D))&&(_=!0),!_){if(!p&&J&&x&&(p=!0,V()),!x){const F=en(te.sourceEvent,g),P=F.x-y.x,T=F.y-y.y;Math.sqrt(P*P+T*T)>U&&ee(te)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(y=en(te.sourceEvent,g),X(z))}}).on("end",te=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(p=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:M,onNodeDragStop:W,onSelectionDragStop:B}=r();if(S&&(M(f,!1),S=!1),a||W||!D&&B){const[U,A]=Pu({nodeId:D,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(te.sourceEvent,f,U,A),W==null||W(te.sourceEvent,U,A),D||B==null||B(te.sourceEvent,A)}}}).filter(te=>{const J=te.target;return!te.button&&(!b||!Ch(J,`.${b}`,j))&&(!k||Ch(J,k,j))});v.call(Z)}function N(){v==null||v.on(".drag",null)}return{update:E,destroy:N}}function j1(t,r,i){const l=[],a={x:t.x-i,y:t.y-i,width:i*2,height:i*2};for(const u of r.values())hl(a,xi(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,i,l){var f,p;let a=[],u=1/0;const d=j1(t,i,r+M1);for(const y of d){const g=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const x of g){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=Mr(y,x,x.position,!0),S=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));S>r||(S1){const y=l.type==="source"?"target":"source";return a.find(g=>g.type===y)??a[0]}return a[0]}function wm(t,r,i,l,a,u=!1){var y,g,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((g=d.internals.handleBounds)==null?void 0:g.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],p=(i?f==null?void 0:f.find(v=>v.id===i):f==null?void 0:f[0])??null;return p&&u?{...p,...Mr(d,p,p.position,!0)}:p}function _m(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let i=null;return r?i=!0:t&&!r&&(i=!1),i}const Sm=()=>!0;function b1(t,{connectionMode:r,connectionRadius:i,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:p,lib:y,autoPanOnConnect:g,flowId:x,panBy:v,cancelConnection:_,onConnectStart:S,onConnect:C,onConnectEnd:E,isValidConnection:N=Sm,onReconnectEnd:b,updateConnection:k,getTransform:j,getFromHandle:R,autoPanSpeed:D,dragThreshold:H=1,handleDomNode:X}){const V=um(t.target);let ee=0,Z;const{x:te,y:J}=en(t),M=_m(u,X),W=f==null?void 0:f.getBoundingClientRect();let B=!1;if(!W||!M)return;const U=wm(a,M,l,p,r);if(!U)return;let A=en(t,W),z=!1,F=null,P=!1,T=null;function ne(){if(!g||!W)return;const[me,xe]=ac(A,W,D);v({x:me,y:xe}),ee=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:M,position:U.position},ue=p.get(a);let de={inProgress:!0,isValid:null,from:Mr(ue,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ue,to:A,toHandle:null,toPosition:ph[re.position],toNode:null,pointer:A};function Q(){B=!0,k(de),S==null||S(t,{nodeId:a,handleId:l,handleType:M})}H===0&&Q();function se(me){if(!B){const{x:Re,y:Xe}=en(me),rt=Re-te,Ze=Xe-J;if(!(rt*rt+Ze*Ze>H*H))return;Q()}if(!R()||!re){fe(me);return}const xe=j();A=en(me,W),Z=P1(Mi(A,xe,!1,[1,1]),i,p,re),z||(ne(),z=!0);const pe=km(me,{handle:Z,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:N,doc:V,lib:y,flowId:x,nodeLookup:p});T=pe.handleDomNode,F=pe.connection,P=I1(!!Z,pe.isValid);const Ce=p.get(a),je=Ce?Mr(Ce,re,Se.Left,!0):de.from,Me={...de,from:je,isValid:P,to:pe.toHandle&&P?yo({x:pe.toHandle.x,y:pe.toHandle.y},xe):A,toHandle:pe.toHandle,toPosition:P&&pe.toHandle?pe.toHandle.position:ph[re.position],toNode:pe.toHandle?p.get(pe.toHandle.nodeId):null,pointer:A};k(Me),de=Me}function fe(me){if(!("touches"in me&&me.touches.length>0)){if(B){(Z||T)&&F&&P&&(C==null||C(F));const{inProgress:xe,...pe}=de,Ce={...pe,toPosition:de.toHandle?de.toPosition:null};E==null||E(me,Ce),u&&(b==null||b(me,Ce))}_(),cancelAnimationFrame(ee),z=!1,P=!1,F=null,T=null,V.removeEventListener("mousemove",se),V.removeEventListener("mouseup",fe),V.removeEventListener("touchmove",se),V.removeEventListener("touchend",fe)}}V.addEventListener("mousemove",se),V.addEventListener("mouseup",fe),V.addEventListener("touchmove",se),V.addEventListener("touchend",fe)}function km(t,{handle:r,connectionMode:i,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:p,isValidConnection:y=Sm,nodeLookup:g}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:S}=en(t),C=d.elementFromPoint(_,S),E=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const b=_m(void 0,E),k=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),R=E.classList.contains("connectable"),D=E.classList.contains("connectableend");if(!k||!b)return N;const H={source:x?k:l,sourceHandle:x?j:a,target:x?l:k,targetHandle:x?a:j};N.connection=H;const V=R&&D&&(i===mo.Strict?x&&b==="source"||!x&&b==="target":k!==l||j!==a);N.isValid=V&&y(H),N.toHandle=wm(k,b,j,g,i,!0)}return N}const qu={onPointerDown:b1,isValid:km};function T1({domNode:t,panZoom:r,getTransform:i,getViewScale:l}){const a=Rt(t);function u({translateExtent:f,width:p,height:y,zoomStep:g=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const S=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const j=i(),R=k.sourceEvent.ctrlKey&&wi()?10:1,D=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*g,H=j[2]*Math.pow(2,D*R);r.scaleTo(H)};let C=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(C=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},N=k=>{const j=i();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const R=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],D=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),X={x:j[0]-D[0]*H,y:j[1]-D[1]*H},V=[[0,0],[p,y]];r.setViewportConstrained({x:X.x,y:X.y,zoom:j[2]},V,f)},b=Kp().on("start",E).on("zoom",x?N:null).on("zoom.wheel",v?S:null);a.call(b,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:qt}}const El=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:i})=>_l.translate(t,r).scale(i),qn=(t,r)=>t.target.closest(`.${r}`),Em=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),R1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,bu=(t,r=0,i=R1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(i).on("end",l):t},Nm=t=>{const r=t.ctrlKey&&wi()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function L1({zoomPanValues:t,noWheelClassName:r,d3Selection:i,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:p,onPanZoomEnd:y}){return g=>{if(qn(g,r))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const x=i.property("__zoom").k||1;if(g.ctrlKey&&d){const E=qt(g),N=Nm(g),b=x*Math.pow(2,N);l.scaleTo(i,b,E,g);return}const v=g.deltaMode===1?20:1;let _=a===kr.Vertical?0:g.deltaX*v,S=a===kr.Horizontal?0:g.deltaY*v;!wi()&&g.shiftKey&&a!==kr.Vertical&&(_=g.deltaY*v,S=0),l.translateBy(i,-(_/x)*u,-(S/x)*u,{internal:!0});const C=El(i.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(g,C):(t.isPanScrolling=!0,f==null||f(g,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(g,C),t.isPanScrolling=!1},150)}}function z1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:i}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=qn(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),i.call(this,l,a)}}function A1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:i}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=El(l.transform);t.mouseButton=((d=l.sourceEvent)==null?void 0:d.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((f=l.sourceEvent)==null?void 0:f.type)==="mousedown"&&r(!0),i&&(i==null||i(l.sourceEvent,a))}}function D1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:i,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(i&&Em(r,t.mouseButton??0)),(d=u.sourceEvent)!=null&&d.sync||l([u.transform.x,u.transform.y,u.transform.k]),a&&!((f=u.sourceEvent)!=null&&f.internal)&&(a==null||a(u.sourceEvent,El(u.transform)))}}function $1({zoomPanValues:t,panOnDrag:r,panOnScroll:i,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:u}){return d=>{var f;if(!((f=d.sourceEvent)!=null&&f.internal)&&(t.isZoomingOrPanning=!1,u&&Em(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const p=El(d.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,p)},i?150:0)}}}function O1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:i,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:p,noPanClassName:y,lib:g,connectionInProgress:x}){return v=>{var N;const _=r||i,S=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(qn(v,`${g}-flow__node`)||qn(v,`${g}-flow__edge`)||qn(v,`${g}-flow__selection`)||qn(v,`${g}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||qn(v,p)&&C||qn(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((N=v.touches)==null?void 0:N.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!S&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&E}}function F1({domNode:t,minZoom:r,maxZoom:i,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=t.getBoundingClientRect();let x=[[0,0],[g.width,g.height]];const v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const M=J[0];M&&(x=[[0,0],[M.contentRect.width,M.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,i]).translateExtent(l),S=Rt(t).call(_);j({x:a.x,y:a.y,zoom:go(a.zoom,r,i)},[[0,0],[g.width,g.height]],l);const C=S.on("wheel.zoom"),E=S.on("dblclick.zoom");_.wheelDelta(Nm);async function N(J,M){return S?new Promise(W=>{_==null||_.interpolate((M==null?void 0:M.interpolate)==="linear"?ui:tl).transform(bu(S,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),J)}):!1}function b({noWheelClassName:J,noPanClassName:M,onPaneContextMenu:W,userSelectionActive:B,panOnScroll:U,panOnDrag:A,panOnScrollMode:z,panOnScrollSpeed:F,preventScrolling:P,zoomOnPinch:T,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ue=!1,zoomActivationKeyPressed:ce,lib:de,onTransformChange:Q,connectionInProgress:se,paneClickDistance:fe,selectionOnDrag:me}){B&&!y.isZoomingOrPanning&&k();const xe=U&&!ce&&!B;_.clickDistance(me?1/0:!Jt(fe)||fe<0?0:fe);const pe=xe?L1({zoomPanValues:y,noWheelClassName:J,d3Selection:S,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:F,zoomOnPinch:T,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):z1({noWheelClassName:J,preventScrolling:P,d3ZoomHandler:C});S.on("wheel.zoom",pe,{passive:!1});const Ce=A1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:d});_.on("start",Ce);const je=D1({zoomPanValues:y,panOnDrag:A,onPaneContextMenu:!!W,onPanZoom:u,onTransformChange:Q});_.on("zoom",je);const Me=$1({zoomPanValues:y,panOnDrag:A,panOnScroll:U,onPaneContextMenu:W,onPanZoomEnd:f,onDraggingChange:p});_.on("end",Me);const Re=O1({panActivationKeyPressed:ue,zoomActivationKeyPressed:ce,panOnDrag:A,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:T,userSelectionActive:B,noPanClassName:M,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Re),re?S.on("dblclick.zoom",E):S.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function j(J,M,W){const B=Iu(J),U=_==null?void 0:_.constrain()(B,M,W);return U&&await N(U),U}async function R(J,M){const W=Iu(J);return await N(W,M),W}function D(J){if(S){const M=Iu(J),W=S.property("__zoom");(W.k!==J.zoom||W.x!==J.x||W.y!==J.y)&&(_==null||_.transform(S,M,null,{sync:!0}))}}function H(){const J=S?Qp(S.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function X(J,M){return S?new Promise(W=>{_==null||_.interpolate((M==null?void 0:M.interpolate)==="linear"?ui:tl).scaleTo(bu(S,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),J)}):!1}async function V(J,M){return S?new Promise(W=>{_==null||_.interpolate((M==null?void 0:M.interpolate)==="linear"?ui:tl).scaleBy(bu(S,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),J)}):!1}function ee(J){_==null||_.scaleExtent(J)}function Z(J){_==null||_.translateExtent(J)}function te(J){const M=!Jt(J)||J<0?0:J;_==null||_.clickDistance(M)}return{update:b,destroy:k,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:X,scaleBy:V,setScaleExtent:ee,setTranslateExtent:Z,syncViewport:D,setClickDistance:te}}var vo;(function(t){t.Line="line",t.Handle="handle"})(vo||(vo={}));function H1({width:t,prevWidth:r,height:i,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=i-l,p=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(p[0]=p[0]*-1),f&&u&&(p[1]=p[1]*-1),p}function jh(t){const r=t.includes("right")||t.includes("left"),i=t.includes("bottom")||t.includes("top"),l=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:i,affectsX:l,affectsY:a}}function Qn(t,r){return Math.max(0,r-t)}function Kn(t,r){return Math.max(0,t-r)}function Ks(t,r,i){return Math.max(0,r-t,t-i)}function Mh(t,r){return t?!r:r}function B1(t,r,i,l,a,u,d,f){let{affectsX:p,affectsY:y}=r;const{isHorizontal:g,isVertical:x}=r,v=g&&x,{xSnapped:_,ySnapped:S}=i,{minWidth:C,maxWidth:E,minHeight:N,maxHeight:b}=l,{x:k,y:j,width:R,height:D,aspectRatio:H}=t;let X=Math.floor(g?_-t.pointerX:0),V=Math.floor(x?S-t.pointerY:0);const ee=R+(p?-X:X),Z=D+(y?-V:V),te=-u[0]*R,J=-u[1]*D;let M=Ks(ee,C,E),W=Ks(Z,N,b);if(d){let A=0,z=0;p&&X<0?A=Qn(k+X+te,d[0][0]):!p&&X>0&&(A=Kn(k+ee+te,d[1][0])),y&&V<0?z=Qn(j+V+J,d[0][1]):!y&&V>0&&(z=Kn(j+Z+J,d[1][1])),M=Math.max(M,A),W=Math.max(W,z)}if(f){let A=0,z=0;p&&X>0?A=Kn(k+X,f[0][0]):!p&&X<0&&(A=Qn(k+ee,f[1][0])),y&&V>0?z=Kn(j+V,f[0][1]):!y&&V<0&&(z=Qn(j+Z,f[1][1])),M=Math.max(M,A),W=Math.max(W,z)}if(a){if(g){const A=Ks(ee/H,N,b)*H;if(M=Math.max(M,A),d){let z=0;!p&&!y||p&&!y&&v?z=Kn(j+J+ee/H,d[1][1])*H:z=Qn(j+J+(p?X:-X)/H,d[0][1])*H,M=Math.max(M,z)}if(f){let z=0;!p&&!y||p&&!y&&v?z=Qn(j+ee/H,f[1][1])*H:z=Kn(j+(p?X:-X)/H,f[0][1])*H,M=Math.max(M,z)}}if(x){const A=Ks(Z*H,C,E)/H;if(W=Math.max(W,A),d){let z=0;!p&&!y||y&&!p&&v?z=Kn(k+Z*H+te,d[1][0])/H:z=Qn(k+(y?V:-V)*H+te,d[0][0])/H,W=Math.max(W,z)}if(f){let z=0;!p&&!y||y&&!p&&v?z=Qn(k+Z*H,f[1][0])/H:z=Kn(k+(y?V:-V)*H,f[0][0])/H,W=Math.max(W,z)}}}V=V+(V<0?W:-W),X=X+(X<0?M:-M),a&&(v?ee>Z*H?V=(Mh(p,y)?-X:X)/H:X=(Mh(p,y)?-V:V)*H:g?(V=X/H,y=p):(X=V*H,p=y));const B=p?k+X:k,U=y?j+V:j;return{width:R+(p?-X:X),height:D+(y?-V:V),x:u[0]*X*(p?-1:1)+B,y:u[1]*V*(y?-1:1)+U}}const Cm={width:0,height:0,x:0,y:0},V1={...Cm,pointerX:0,pointerY:0,aspectRatio:1};function U1(t,r,i){const l=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,d=t.measured.height??0,f=i[0]*u,p=i[1]*d;return[[l-f,a-p],[l+u-f,a+d-p]]}function W1({domNode:t,nodeId:r,getStoreItems:i,onChange:l,onEnd:a}){const u=Rt(t);let d={controlDirection:jh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:g,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:S,onResizeEnd:C,shouldResize:E}){let N={...Cm},b={...V1};d={boundaries:g,resizeDirection:v,keepAspectRatio:x,controlDirection:jh(y)};let k,j=null,R=[],D,H,X,V=!1;const ee=zp().on("start",Z=>{const{nodeLookup:te,transform:J,snapGrid:M,snapToGrid:W,nodeOrigin:B,paneDomNode:U}=i();if(k=te.get(r),!k)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:z}=ci(Z.sourceEvent,{transform:J,snapGrid:M,snapToGrid:W,containerBounds:j});N={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},b={...N,pointerX:A,pointerY:z,aspectRatio:N.width/N.height},D=void 0,H=jr(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(D=te.get(k.parentId)),D&&k.extent==="parent"&&(H=[[0,0],[D.measured.width,D.measured.height]]),R=[],X=void 0;for(const[F,P]of te)if(P.parentId===r&&(R.push({id:F,position:{...P.position},extent:P.extent}),P.extent==="parent"||P.expandParent)){const T=U1(P,k,P.origin??B);X?X=[[Math.min(T[0][0],X[0][0]),Math.min(T[0][1],X[0][1])],[Math.max(T[1][0],X[1][0]),Math.max(T[1][1],X[1][1])]]:X=T}_==null||_(Z,{...N})}).on("drag",Z=>{const{transform:te,snapGrid:J,snapToGrid:M,nodeOrigin:W}=i(),B=ci(Z.sourceEvent,{transform:te,snapGrid:J,snapToGrid:M,containerBounds:j}),U=[];if(!k)return;const{x:A,y:z,width:F,height:P}=N,T={},ne=k.origin??W,{width:re,height:ue,x:ce,y:de}=B1(b,d.controlDirection,B,d.boundaries,d.keepAspectRatio,ne,H,X),Q=re!==F,se=ue!==P,fe=ce!==A&&Q,me=de!==z&&se;if(!fe&&!me&&!Q&&!se)return;if((fe||me||ne[0]===1||ne[1]===1)&&(T.x=fe?ce:N.x,T.y=me?de:N.y,N.x=T.x,N.y=T.y,R.length>0)){const je=ce-A,Me=de-z;for(const Re of R)Re.position={x:Re.position.x-je+ne[0]*(re-F),y:Re.position.y-Me+ne[1]*(ue-P)},U.push(Re)}if((Q||se)&&(T.width=Q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:N.width,T.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ue:N.height,N.width=T.width,N.height=T.height),D&&k.expandParent){const je=ne[0]*(T.width??0);T.x&&T.x {V&&(C==null||C(Z,{...N}),a==null||a({...N}),V=!1)});u.call(ee)}function p(){u.on(".drag",null)}return{update:f,destroy:p}}var Tu={exports:{}},Ru={},Lu={exports:{}},zu={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ph;function Y1(){if(Ph)return zu;Ph=1;var t=Si();function r(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var i=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,v){var _=v(),S=l({inst:{value:_,getSnapshot:v}}),C=S[0].inst,E=S[1];return u(function(){C.value=_,C.getSnapshot=v,p(C)&&E({inst:C})},[x,_,v]),a(function(){return p(C)&&E({inst:C}),x(function(){p(C)&&E({inst:C})})},[x]),d(_),_}function p(x){var v=x.getSnapshot;x=x.value;try{var _=v();return!i(x,_)}catch{return!0}}function y(x,v){return v()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:f;return zu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:g,zu}var Ih;function X1(){return Ih||(Ih=1,Lu.exports=Y1()),Lu.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var bh;function G1(){if(bh)return Ru;bh=1;var t=Si(),r=X1();function i(y,g){return y===g&&(y!==0||1/y===1/g)||y!==y&&g!==g}var l=typeof Object.is=="function"?Object.is:i,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,p=t.useDebugValue;return Ru.useSyncExternalStoreWithSelector=function(y,g,x,v,_){var S=u(null);if(S.current===null){var C={hasValue:!1,value:null};S.current=C}else C=S.current;S=f(function(){function N(D){if(!b){if(b=!0,k=D,D=v(D),_!==void 0&&C.hasValue){var H=C.value;if(_(H,D))return j=H}return j=D}if(H=j,l(k,D))return H;var X=v(D);return _!==void 0&&_(H,X)?(k=D,H):(k=D,j=X)}var b=!1,k,j,R=x===void 0?null:x;return[function(){return N(g())},R===null?void 0:function(){return N(R())}]},[g,x,v,_]);var E=a(y,S[0],S[1]);return d(function(){C.hasValue=!0,C.value=E},[E]),p(E),E},Ru}var Th;function Q1(){return Th||(Th=1,Tu.exports=G1()),Tu.exports}var K1=Q1();const q1=vp(K1),Z1={},Rh=t=>{let r;const i=new Set,l=(g,x)=>{const v=typeof g=="function"?g(r):g;if(!Object.is(v,r)){const _=r;r=x??(typeof v!="object"||v===null)?v:Object.assign({},r,v),i.forEach(S=>S(r,_))}},a=()=>r,p={setState:l,getState:a,getInitialState:()=>y,subscribe:g=>(i.add(g),()=>i.delete(g)),destroy:()=>{(Z1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},y=r=t(l,a,p);return p},J1=t=>t?Rh(t):Rh,{useDebugValue:e_}=q0,{useSyncExternalStoreWithSelector:t_}=q1,n_=t=>t;function jm(t,r=n_,i){const l=t_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,i);return e_(l),l}const Lh=(t,r)=>{const i=J1(t),l=(a,u=r)=>jm(i,a,u);return Object.assign(l,i),l},r_=(t,r)=>t?Lh(t,r):Lh;function Ue(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[l,a]of t)if(!Object.is(a,r.get(l)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const l of t)if(!r.has(l))return!1;return!0}const i=Object.keys(t);if(i.length!==Object.keys(r).length)return!1;for(const l of i)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(t[l],r[l]))return!1;return!0}xp();const Nl=O.createContext(null),o_=Nl.Provider,Mm=tn.error001("react");function be(t,r){const i=O.useContext(Nl);if(i===null)throw new Error(Mm);return jm(i,t,r)}function Oe(){const t=O.useContext(Nl);if(t===null)throw new Error(Mm);return O.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const zh={display:"none"},i_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pm="react-flow__node-desc",Im="react-flow__edge-desc",s_="react-flow__aria-live",l_=t=>t.ariaLiveMessage,a_=t=>t.ariaLabelConfig;function u_({rfId:t}){const r=be(l_);return m.jsx("div",{id:`${s_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:i_,children:r})}function c_({rfId:t,disableKeyboardA11y:r}){const i=be(a_);return m.jsxs(m.Fragment,{children:[m.jsx("div",{id:`${Pm}-${t}`,style:zh,children:r?i["node.a11yDescription.default"]:i["node.a11yDescription.keyboardDisabled"]}),m.jsx("div",{id:`${Im}-${t}`,style:zh,children:i["edge.a11yDescription.default"]}),!r&&m.jsx(u_,{rfId:t})]})}const Cl=O.forwardRef(({position:t="top-left",children:r,className:i,style:l,...a},u)=>{const d=`${t}`.split("-");return m.jsx("div",{className:Qe(["react-flow__panel",i,...d]),style:l,ref:u,...a,children:r})});Cl.displayName="Panel";const Ah="https://reactflow.dev?utm_source=attribution";function d_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:m.jsx(Cl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ah}`,children:m.jsx("a",{href:Ah,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const f_=t=>{const r=[],i=[];for(const[,l]of t.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of t.edgeLookup)l.selected&&i.push(l);return{selectedNodes:r,selectedEdges:i}},qs=t=>t.id;function h_(t,r){return Ue(t.selectedNodes.map(qs),r.selectedNodes.map(qs))&&Ue(t.selectedEdges.map(qs),r.selectedEdges.map(qs))}function p_({onSelectionChange:t}){const r=Oe(),{selectedNodes:i,selectedEdges:l}=be(f_,h_);return O.useEffect(()=>{const a={nodes:i,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[i,l,t]),null}const m_=t=>!!t.onSelectionChangeHandlers;function g_({onSelectionChange:t}){const r=be(m_);return t||r?m.jsx(p_,{onSelectionChange:t}):null}const bm=[0,0],y_={x:0,y:0,zoom:1},v_=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Dh=[...v_,"rfId"],x_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),$h={translateExtent:gi,nodeOrigin:bm,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function w_(t){const{setNodes:r,setEdges:i,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:p}=be(x_,Ue),y=Oe();O.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{g.current=$h,f()}),[]);const g=O.useRef($h);return O.useEffect(()=>{for(const x of Dh){const v=t[x],_=g.current[x];v!==_&&(typeof t[x]>"u"||(x==="nodes"?r(v):x==="edges"?i(v):x==="minZoom"?l(v):x==="maxZoom"?a(v):x==="translateExtent"?u(v):x==="nodeExtent"?d(v):x==="ariaLabelConfig"?y.setState({ariaLabelConfig:o1(v)}):x==="fitView"?y.setState({fitViewQueued:v}):x==="fitViewOptions"?y.setState({fitViewOptions:v}):y.setState({[x]:v})))}g.current=t},Dh.map(x=>t[x])),null}function Oh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function __(t){var l;const[r,i]=O.useState(t==="system"?null:t);return O.useEffect(()=>{if(t!=="system"){i(t);return}const a=Oh(),u=()=>i(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(l=Oh())!=null&&l.matches?"dark":"light"}const Fh=typeof document<"u"?document:null;function _i(t=null,r={target:Fh,actInsideInputWithModifier:!0}){const[i,l]=O.useState(!1),a=O.useRef(!1),u=O.useRef(new Set([])),[d,f]=O.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),g=y.reduce((x,v)=>x.concat(...v),[]);return[y,g]}return[[],[]]},[t]);return O.useEffect(()=>{const p=(r==null?void 0:r.target)??Fh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const g=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&cm(_))return!1;const C=Bh(_.code,f);if(u.current.add(_[C]),Hh(d,u.current,!1)){const b=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,k=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),l(!0)}},x=_=>{const S=Bh(_.code,f);Hh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[S]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return p==null||p.addEventListener("keydown",g),p==null||p.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{p==null||p.removeEventListener("keydown",g),p==null||p.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),i}function Hh(t,r,i){return t.filter(l=>i||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Bh(t,r){return r.includes(t)?"code":"key"}const S_=()=>{const t=Oe();return O.useMemo(()=>({zoomIn:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1/1.2,r):!1},zoomTo:async(r,i)=>{const{panZoom:l}=t.getState();return l?l.scaleTo(r,i):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,i)=>{const{transform:[l,a,u],panZoom:d}=t.getState();return d?(await d.setViewport({x:r.x??l,y:r.y??a,zoom:r.zoom??u},i),!0):!1},getViewport:()=>{const[r,i,l]=t.getState().transform;return{x:r,y:i,zoom:l}},setCenter:async(r,i,l)=>t.getState().setCenter(r,i,l),fitBounds:async(r,i)=>{const{width:l,height:a,minZoom:u,maxZoom:d,panZoom:f}=t.getState(),p=uc(r,l,a,u,d,(i==null?void 0:i.padding)??.1);return f?(await f.setViewport(p,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0):!1},screenToFlowPosition:(r,i={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:p}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-p},g=i.snapGrid??a,x=i.snapToGrid??u;return Mi(y,l,x,g)},flowToScreenPosition:r=>{const{transform:i,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=yo(r,i);return{x:d.x+a,y:d.y+u}}}),[])};function Tm(t,r){const i=[],l=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")l.set(u.id,[u]);else{const d=l.get(u.id);d?d.push(u):l.set(u.id,[u])}for(const u of r){const d=l.get(u.id);if(!d){i.push(u);continue}if(d[0].type==="remove")continue;if(d[0].type==="replace"){i.push({...d[0].item});continue}const f={...u};for(const p of d)k_(p,f);i.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?i.splice(u.index,0,{...u.item}):i.push({...u.item})}),i}function k_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function E_(t,r){return Tm(t,r)}function N_(t,r){return Tm(t,r)}function wr(t,r){return{id:t,type:"select",selected:r}}function uo(t,r=new Set,i=!1){const l=[];for(const[a,u]of t){const d=r.has(a);!(u.selected===void 0&&!d)&&u.selected!==d&&(i&&(u.selected=d),l.push(wr(u.id,d)))}return l}function Vh({items:t=[],lookup:r}){var a;const i=[],l=new Map(t.map(u=>[u.id,u]));for(const[u,d]of t.entries()){const f=r.get(d.id),p=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;p!==void 0&&p!==d&&i.push({id:d.id,item:d,type:"replace"}),p===void 0&&i.push({item:d,type:"add",index:u})}for(const[u]of r)l.get(u)===void 0&&i.push({id:u,type:"remove"});return i}function Uh(t){return{id:t.id,type:"remove"}}const C_=sm();function j_(t,r,i={}){return c1(t,r,{...i,onError:i.onError??C_})}const Wh=t=>Qw(t),M_=t=>tm(t);function Rm(t){return O.forwardRef(t)}const Lm=typeof window<"u"?O.useLayoutEffect:O.useEffect;function Yh(t){const[r,i]=O.useState(BigInt(0)),[l]=O.useState(()=>P_(()=>i(a=>a+BigInt(1))));return Lm(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:i=>{r.push(i),t()}}}const zm=O.createContext(null);function I_({children:t}){const r=Oe(),i=O.useCallback(f=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:g,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:S}=r.getState();let C=p;for(const N of f)C=typeof N=="function"?N(C):N;let E=Vh({items:C,lookup:v});for(const N of S.values())E=N(E);g&&y(C),E.length>0?x==null||x(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:b,setNodes:k}=r.getState();N&&k(b)})},[]),l=Yh(i),a=O.useCallback(f=>{const{edges:p=[],setEdges:y,hasDefaultEdges:g,onEdgesChange:x,edgeLookup:v}=r.getState();let _=p;for(const S of f)_=typeof S=="function"?S(_):S;g?y(_):x&&x(Vh({items:_,lookup:v}))},[]),u=Yh(a),d=O.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return m.jsx(zm.Provider,{value:d,children:t})}function b_(){const t=O.useContext(zm);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const T_=t=>!!t.panZoom;function gc(){const t=S_(),r=Oe(),i=b_(),l=be(T_),a=O.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{i.nodeQueue.push(x)},f=x=>{i.edgeQueue.push(x)},p=x=>{var N,b;const{nodeLookup:v,nodeOrigin:_}=r.getState(),S=Wh(x)?x:v.get(x.id),C=S.parentId?am(S.position,S.measured,S.parentId,v,_):S.position,E={...S,position:C,width:((N=S.measured)==null?void 0:N.width)??S.width,height:((b=S.measured)==null?void 0:b.height)??S.height};return xi(E)},y=(x,v,_={replace:!1})=>{d(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&Wh(E)?E:{...C,...E}}return C}))},g=(x,v,_={replace:!1})=>{f(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&M_(E)?E:{...C,...E}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];i.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];i.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[S,C,E]=_;return{nodes:x.map(N=>({...N})),edges:v.map(N=>({...N})),viewport:{x:S,y:C,zoom:E}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:S,onNodesDelete:C,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:b,onDelete:k,onBeforeDelete:j}=r.getState(),{nodes:R,edges:D}=await e1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:S,onBeforeDelete:j}),H=D.length>0,X=R.length>0;if(H){const V=D.map(Uh);E==null||E(D),b(V)}if(X){const V=R.map(Uh);C==null||C(R),N(V)}return(X||H)&&(k==null||k({nodes:R,edges:D})),{deletedNodes:R,deletedEdges:D}},getIntersectingNodes:(x,v=!0,_)=>{const S=gh(x),C=S?x:p(x),E=_!==void 0;return C?(_||r.getState().nodes).filter(N=>{const b=r.getState().nodeLookup.get(N.id);if(b&&!S&&(N.id===x.id||!b.internals.positionAbsolute))return!1;const k=xi(E?N:b),j=hl(k,C);return v&&j>0||j>=k.width*k.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=gh(x)?x:p(x);if(!C)return!1;const E=hl(C,v);return _&&E>0||E>=v.width*v.height||E>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},updateEdge:g,updateEdgeData:(x,v,_={replace:!1})=>{g(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Kw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:S.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??r1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),i.nodeQueue.push(_=>[..._]),v.promise}}},[]);return O.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Xh=t=>t.selected,R_=typeof window<"u"?window:void 0;function L_({deleteKeyCode:t,multiSelectionKeyCode:r}){const i=Oe(),{deleteElements:l}=gc(),a=_i(t,{actInsideInputWithModifier:!1}),u=_i(r,{target:R_});O.useEffect(()=>{if(a){const{edges:d,nodes:f}=i.getState();l({nodes:f.filter(Xh),edges:d.filter(Xh)}),i.setState({nodesSelectionActive:!1})}},[a]),O.useEffect(()=>{i.setState({multiSelectionActive:u})},[u])}function z_(t){const r=Oe();O.useEffect(()=>{const i=()=>{var a,u,d,f;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const l=cc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.error004())),r.setState({width:l.width||500,height:l.height||500})};if(t.current){i(),window.addEventListener("resize",i);const l=new ResizeObserver(()=>i());return l.observe(t.current),()=>{window.removeEventListener("resize",i),l&&t.current&&l.unobserve(t.current)}}},[])}const jl={position:"absolute",width:"100%",height:"100%",top:0,left:0},A_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function D_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=kr.Free,zoomOnDoubleClick:f=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:g,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:S=!0,children:C,noWheelClassName:E,noPanClassName:N,onViewportChange:b,isControlledViewport:k,paneClickDistance:j,selectionOnDrag:R}){const D=Oe(),H=O.useRef(null),{userSelectionActive:X,lib:V,connectionInProgress:ee}=be(A_,Ue),Z=_i(_),te=O.useRef();z_(H);const J=O.useCallback(M=>{b==null||b({x:M[0],y:M[1],zoom:M[2]}),k||D.setState({transform:M})},[b,k]);return O.useEffect(()=>{if(H.current){te.current=F1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:g,viewport:y,onDraggingChange:U=>D.setState(A=>A.paneDragging===U?A:{paneDragging:U}),onPanZoomStart:(U,A)=>{const{onViewportChangeStart:z,onMoveStart:F}=D.getState();F==null||F(U,A),z==null||z(A)},onPanZoom:(U,A)=>{const{onViewportChange:z,onMove:F}=D.getState();F==null||F(U,A),z==null||z(A)},onPanZoomEnd:(U,A)=>{const{onViewportChangeEnd:z,onMoveEnd:F}=D.getState();F==null||F(U,A),z==null||z(A)}});const{x:M,y:W,zoom:B}=te.current.getViewport();return D.setState({panZoom:te.current,transform:[M,W,B],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),O.useEffect(()=>{var M;(M=te.current)==null||M.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:S,noPanClassName:N,userSelectionActive:X,noWheelClassName:E,lib:V,onTransformChange:J,connectionInProgress:ee,selectionOnDrag:R,paneClickDistance:j})},[t,r,i,l,a,u,d,f,p,Z,S,N,X,E,V,J,ee,R,j]),m.jsx("div",{className:"react-flow__renderer",ref:H,style:jl,children:C})}const $_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function O_(){const{userSelectionActive:t,userSelectionRect:r}=be($_,Ue);return t&&r?m.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Au=(t,r)=>i=>{i.target===r.current&&(t==null||t(i))},F_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function H_({isSelecting:t,selectionKeyPressed:r,selectionMode:i=yi.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:g,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:S,children:C}){const E=O.useRef(0),N=Oe(),{userSelectionActive:b,elementsSelectable:k,dragging:j,panBy:R,autoPanSpeed:D}=be(F_,Ue),H=k&&(t||b),X=O.useRef(null),V=O.useRef(),ee=O.useRef(new Set),Z=O.useRef(new Set),te=O.useRef(!1),J=O.useRef(!1),M=O.useRef({x:0,y:0}),W=O.useRef(!1),B=Q=>{if(J.current||te.current||N.getState().connection.inProgress){J.current=!1,te.current=!1;return}y==null||y(Q),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}g==null||g(Q)},A=x?Q=>x(Q):void 0,z=Q=>{J.current&&(Q.stopPropagation(),J.current=!1)},F=Q=>{var Re,Xe;if(Q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:fe}=N.getState();if(V.current=se==null?void 0:se.getBoundingClientRect(),!V.current)return;const me=Q.target===X.current;if(!me&&!!Q.target.closest(".nokey")||!t||!(d&&me||r)||Q.button!==0||!Q.isPrimary)return;(Xe=(Re=Q.target)==null?void 0:Re.setPointerCapture)==null||Xe.call(Re,Q.pointerId),J.current=!1;const{x:Ce,y:je}=en(Q.nativeEvent,V.current),Me=Mi({x:Ce,y:je},fe);N.setState({userSelectionRect:{width:0,height:0,startX:Me.x,startY:Me.y,x:Ce,y:je}}),me||(Q.stopPropagation(),Q.preventDefault())};function P(Q,se){const{userSelectionRect:fe}=N.getState();if(!fe)return;const{transform:me,nodeLookup:xe,edgeLookup:pe,connectionLookup:Ce,triggerNodeChanges:je,triggerEdgeChanges:Me,defaultEdgeOptions:Re}=N.getState(),Xe={x:fe.startX,y:fe.startY},{x:rt,y:Ze}=yo(Xe,me),Je={startX:Xe.x,startY:Xe.y,x:Q